diff options
| author | Sebastiano Tronto <sebastiano@tronto.net> | 2024-08-18 14:26:45 +0200 |
|---|---|---|
| committer | Sebastiano Tronto <sebastiano@tronto.net> | 2024-08-18 14:26:45 +0200 |
| commit | 18c9a8b8905304cf5f8fc15825769046a3144866 (patch) | |
| tree | a7807bb32b0a5d9ded7d3cedccc598f64a9b00fe /src/io_move_trans.h | |
| parent | f25a10e19eca294c4e6a99e4f80ce5cfd11a0e5f (diff) | |
| download | nissy-core-18c9a8b8905304cf5f8fc15825769046a3144866.tar.gz nissy-core-18c9a8b8905304cf5f8fc15825769046a3144866.zip | |
Reorganized folder structure
Diffstat (limited to 'src/io_move_trans.h')
| -rw-r--r-- | src/io_move_trans.h | 87 |
1 files changed, 0 insertions, 87 deletions
diff --git a/src/io_move_trans.h b/src/io_move_trans.h deleted file mode 100644 index cfeb93c..0000000 --- a/src/io_move_trans.h +++ /dev/null | |||
| @@ -1,87 +0,0 @@ | |||
| 1 | _static uint8_t readmove(char); | ||
| 2 | _static uint8_t readmodifier(char); | ||
| 3 | _static uint8_t readtrans(const char *); | ||
| 4 | _static int writemoves(uint8_t *, int, char *); | ||
| 5 | _static void writetrans(uint8_t, char *); | ||
| 6 | |||
| 7 | _static uint8_t | ||
| 8 | readmove(char c) | ||
| 9 | { | ||
| 10 | switch (c) { | ||
| 11 | case 'U': | ||
| 12 | return _move_U; | ||
| 13 | case 'D': | ||
| 14 | return _move_D; | ||
| 15 | case 'R': | ||
| 16 | return _move_R; | ||
| 17 | case 'L': | ||
| 18 | return _move_L; | ||
| 19 | case 'F': | ||
| 20 | return _move_F; | ||
| 21 | case 'B': | ||
| 22 | return _move_B; | ||
| 23 | default: | ||
| 24 | return _error; | ||
| 25 | } | ||
| 26 | } | ||
| 27 | |||
| 28 | _static uint8_t | ||
| 29 | readmodifier(char c) | ||
| 30 | { | ||
| 31 | switch (c) { | ||
| 32 | case '1': /* Fallthrough */ | ||
| 33 | case '2': /* Fallthrough */ | ||
| 34 | case '3': | ||
| 35 | return c - '0' - 1; | ||
| 36 | case '\'': | ||
| 37 | return 2; | ||
| 38 | default: | ||
| 39 | return 0; | ||
| 40 | } | ||
| 41 | } | ||
| 42 | |||
| 43 | _static uint8_t | ||
| 44 | readtrans(const char *buf) | ||
| 45 | { | ||
| 46 | uint8_t t; | ||
| 47 | |||
| 48 | for (t = 0; t < 48; t++) | ||
| 49 | if (!strncmp(buf, transstr[t], 11)) | ||
| 50 | return t; | ||
| 51 | |||
| 52 | LOG("readtrans error\n"); | ||
| 53 | return _error; | ||
| 54 | } | ||
| 55 | |||
| 56 | _static int | ||
| 57 | writemoves(uint8_t *m, int n, char *buf) | ||
| 58 | { | ||
| 59 | int i; | ||
| 60 | size_t len; | ||
| 61 | const char *s; | ||
| 62 | char *b; | ||
| 63 | |||
| 64 | for (i = 0, b = buf; i < n; i++, b++) { | ||
| 65 | s = movestr[m[i]]; | ||
| 66 | len = strlen(s); | ||
| 67 | memcpy(b, s, len); | ||
| 68 | b += len; | ||
| 69 | *b = ' '; | ||
| 70 | } | ||
| 71 | |||
| 72 | if (b != buf) | ||
| 73 | b--; /* Remove last space */ | ||
| 74 | *b = '\0'; | ||
| 75 | |||
| 76 | return b - buf; | ||
| 77 | } | ||
| 78 | |||
| 79 | _static void | ||
| 80 | writetrans(uint8_t t, char *buf) | ||
| 81 | { | ||
| 82 | if (t >= 48) | ||
| 83 | memcpy(buf, "error trans", 11); | ||
| 84 | else | ||
| 85 | memcpy(buf, transstr[t], 11); | ||
| 86 | buf[11] = '\0'; | ||
| 87 | } | ||
