diff options
| author | Sebastiano Tronto <sebastiano@tronto.net> | 2024-09-05 08:53:38 +0200 |
|---|---|---|
| committer | Sebastiano Tronto <sebastiano@tronto.net> | 2024-09-05 08:55:25 +0200 |
| commit | fd5ddb3db9f50411ca579d84f225f265ca35b56a (patch) | |
| tree | b659112cc0e2abd6c7edb08b0938c0d2de4ca066 /src/core/io_cube.h | |
| parent | c9e2d6466e42d6b779ac9ffa7c5ee9a9c7558df8 (diff) | |
| download | nissy-core-fd5ddb3db9f50411ca579d84f225f265ca35b56a.tar.gz nissy-core-fd5ddb3db9f50411ca579d84f225f265ca35b56a.zip | |
Rename constants from _underscore to CAPS
Diffstat (limited to 'src/core/io_cube.h')
| -rw-r--r-- | src/core/io_cube.h | 98 |
1 files changed, 49 insertions, 49 deletions
diff --git a/src/core/io_cube.h b/src/core/io_cube.h index 956494d..cb0e4c7 100644 --- a/src/core/io_cube.h +++ b/src/core/io_cube.h | |||
| @@ -1,23 +1,23 @@ | |||
| 1 | _static uint8_t readco(const char *); | 1 | STATIC uint8_t readco(const char *); |
| 2 | _static uint8_t readcp(const char *); | 2 | STATIC uint8_t readcp(const char *); |
| 3 | _static uint8_t readeo(const char *); | 3 | STATIC uint8_t readeo(const char *); |
| 4 | _static uint8_t readep(const char *); | 4 | STATIC uint8_t readep(const char *); |
| 5 | _static cube_t readcube_B32(const char *); | 5 | STATIC cube_t readcube_B32(const char *); |
| 6 | _static cube_t readcube_H48(const char *); | 6 | STATIC cube_t readcube_H48(const char *); |
| 7 | _static uint8_t readpiece_LST(const char **); | 7 | STATIC uint8_t readpiece_LST(const char **); |
| 8 | _static cube_t readcube_LST(const char *); | 8 | STATIC cube_t readcube_LST(const char *); |
| 9 | 9 | ||
| 10 | _static int writepiece_LST(uint8_t, char *); | 10 | STATIC int writepiece_LST(uint8_t, char *); |
| 11 | _static void writecube_B32(cube_t, char *); | 11 | STATIC void writecube_B32(cube_t, char *); |
| 12 | _static void writecube_H48(cube_t, char *); | 12 | STATIC void writecube_H48(cube_t, char *); |
| 13 | _static void writecube_LST(cube_t, char *); | 13 | STATIC void writecube_LST(cube_t, char *); |
| 14 | 14 | ||
| 15 | _static uint8_t b32toedge(char); | 15 | STATIC uint8_t b32toedge(char); |
| 16 | _static uint8_t b32tocorner(char); | 16 | STATIC uint8_t b32tocorner(char); |
| 17 | _static char edgetob32(uint8_t); | 17 | STATIC char edgetob32(uint8_t); |
| 18 | _static char cornertob32(uint8_t); | 18 | STATIC char cornertob32(uint8_t); |
| 19 | 19 | ||
| 20 | _static struct { | 20 | STATIC struct { |
| 21 | const char *name; | 21 | const char *name; |
| 22 | cube_t (*read)(const char *); | 22 | cube_t (*read)(const char *); |
| 23 | void (*write)(cube_t, char *); | 23 | void (*write)(cube_t, char *); |
| @@ -72,21 +72,21 @@ writecube_error: | |||
| 72 | buf[len+1] = '\0'; | 72 | buf[len+1] = '\0'; |
| 73 | } | 73 | } |
| 74 | 74 | ||
| 75 | _static uint8_t | 75 | STATIC uint8_t |
| 76 | readco(const char *str) | 76 | readco(const char *str) |
| 77 | { | 77 | { |
| 78 | if (*str == '0') | 78 | if (*str == '0') |
| 79 | return 0; | 79 | return 0; |
| 80 | if (*str == '1') | 80 | if (*str == '1') |
| 81 | return _ctwist_cw; | 81 | return CTWIST_CW; |
| 82 | if (*str == '2') | 82 | if (*str == '2') |
| 83 | return _ctwist_ccw; | 83 | return CTWIST_CCW; |
| 84 | 84 | ||
| 85 | LOG("Error reading CO\n"); | 85 | LOG("Error reading CO\n"); |
| 86 | return _error; | 86 | return UINT8_ERROR; |
| 87 | } | 87 | } |
| 88 | 88 | ||
| 89 | _static uint8_t | 89 | STATIC uint8_t |
| 90 | readcp(const char *str) | 90 | readcp(const char *str) |
| 91 | { | 91 | { |
| 92 | uint8_t c; | 92 | uint8_t c; |
| @@ -97,22 +97,22 @@ readcp(const char *str) | |||
| 97 | return c; | 97 | return c; |
| 98 | 98 | ||
| 99 | LOG("Error reading CP\n"); | 99 | LOG("Error reading CP\n"); |
| 100 | return _error; | 100 | return UINT8_ERROR; |
| 101 | } | 101 | } |
| 102 | 102 | ||
| 103 | _static uint8_t | 103 | STATIC uint8_t |
| 104 | readeo(const char *str) | 104 | readeo(const char *str) |
| 105 | { | 105 | { |
| 106 | if (*str == '0') | 106 | if (*str == '0') |
| 107 | return 0; | 107 | return 0; |
| 108 | if (*str == '1') | 108 | if (*str == '1') |
| 109 | return _eflip; | 109 | return EFLIP; |
| 110 | 110 | ||
| 111 | LOG("Error reading EO\n"); | 111 | LOG("Error reading EO\n"); |
| 112 | return _error; | 112 | return UINT8_ERROR; |
| 113 | } | 113 | } |
| 114 | 114 | ||
| 115 | _static uint8_t | 115 | STATIC uint8_t |
| 116 | readep(const char *str) | 116 | readep(const char *str) |
| 117 | { | 117 | { |
| 118 | uint8_t e; | 118 | uint8_t e; |
| @@ -122,10 +122,10 @@ readep(const char *str) | |||
| 122 | return e; | 122 | return e; |
| 123 | 123 | ||
| 124 | LOG("Error reading EP\n"); | 124 | LOG("Error reading EP\n"); |
| 125 | return _error; | 125 | return UINT8_ERROR; |
| 126 | } | 126 | } |
| 127 | 127 | ||
| 128 | _static cube_t | 128 | STATIC cube_t |
| 129 | readcube_B32(const char *buf) | 129 | readcube_B32(const char *buf) |
| 130 | { | 130 | { |
| 131 | int i; | 131 | int i; |
| @@ -146,7 +146,7 @@ readcube_B32(const char *buf) | |||
| 146 | return cubefromarray(c, e); | 146 | return cubefromarray(c, e); |
| 147 | } | 147 | } |
| 148 | 148 | ||
| 149 | _static cube_t | 149 | STATIC cube_t |
| 150 | readcube_H48(const char *buf) | 150 | readcube_H48(const char *buf) |
| 151 | { | 151 | { |
| 152 | int i; | 152 | int i; |
| @@ -158,10 +158,10 @@ readcube_H48(const char *buf) | |||
| 158 | for (i = 0; i < 12; i++) { | 158 | for (i = 0; i < 12; i++) { |
| 159 | while (*b == ' ' || *b == '\t' || *b == '\n') | 159 | while (*b == ' ' || *b == '\t' || *b == '\n') |
| 160 | b++; | 160 | b++; |
| 161 | if ((piece = readep(b)) == _error) | 161 | if ((piece = readep(b)) == UINT8_ERROR) |
| 162 | return zero; | 162 | return zero; |
| 163 | b += 2; | 163 | b += 2; |
| 164 | if ((orient = readeo(b)) == _error) | 164 | if ((orient = readeo(b)) == UINT8_ERROR) |
| 165 | return zero; | 165 | return zero; |
| 166 | b++; | 166 | b++; |
| 167 | e[i] = piece | orient; | 167 | e[i] = piece | orient; |
| @@ -169,10 +169,10 @@ readcube_H48(const char *buf) | |||
| 169 | for (i = 0; i < 8; i++) { | 169 | for (i = 0; i < 8; i++) { |
| 170 | while (*b == ' ' || *b == '\t' || *b == '\n') | 170 | while (*b == ' ' || *b == '\t' || *b == '\n') |
| 171 | b++; | 171 | b++; |
| 172 | if ((piece = readcp(b)) == _error) | 172 | if ((piece = readcp(b)) == UINT8_ERROR) |
| 173 | return zero; | 173 | return zero; |
| 174 | b += 3; | 174 | b += 3; |
| 175 | if ((orient = readco(b)) == _error) | 175 | if ((orient = readco(b)) == UINT8_ERROR) |
| 176 | return zero; | 176 | return zero; |
| 177 | b++; | 177 | b++; |
| 178 | c[i] = piece | orient; | 178 | c[i] = piece | orient; |
| @@ -181,7 +181,7 @@ readcube_H48(const char *buf) | |||
| 181 | return cubefromarray(c, e); | 181 | return cubefromarray(c, e); |
| 182 | } | 182 | } |
| 183 | 183 | ||
| 184 | _static uint8_t | 184 | STATIC uint8_t |
| 185 | readpiece_LST(const char **b) | 185 | readpiece_LST(const char **b) |
| 186 | { | 186 | { |
| 187 | uint8_t ret; | 187 | uint8_t ret; |
| @@ -195,10 +195,10 @@ readpiece_LST(const char **b) | |||
| 195 | ret = ret * 10 + (**b) - '0'; | 195 | ret = ret * 10 + (**b) - '0'; |
| 196 | } | 196 | } |
| 197 | 197 | ||
| 198 | return read ? ret : _error; | 198 | return read ? ret : UINT8_ERROR; |
| 199 | } | 199 | } |
| 200 | 200 | ||
| 201 | _static cube_t | 201 | STATIC cube_t |
| 202 | readcube_LST(const char *buf) | 202 | readcube_LST(const char *buf) |
| 203 | { | 203 | { |
| 204 | int i; | 204 | int i; |
| @@ -213,7 +213,7 @@ readcube_LST(const char *buf) | |||
| 213 | return cubefromarray(c, e); | 213 | return cubefromarray(c, e); |
| 214 | } | 214 | } |
| 215 | 215 | ||
| 216 | _static int | 216 | STATIC int |
| 217 | writepiece_LST(uint8_t piece, char *buf) | 217 | writepiece_LST(uint8_t piece, char *buf) |
| 218 | { | 218 | { |
| 219 | char digits[3]; | 219 | char digits[3]; |
| @@ -237,7 +237,7 @@ writepiece_LST(uint8_t piece, char *buf) | |||
| 237 | return len+2; | 237 | return len+2; |
| 238 | } | 238 | } |
| 239 | 239 | ||
| 240 | _static void | 240 | STATIC void |
| 241 | writecube_B32(cube_t cube, char *buf) | 241 | writecube_B32(cube_t cube, char *buf) |
| 242 | { | 242 | { |
| 243 | int i; | 243 | int i; |
| @@ -256,7 +256,7 @@ writecube_B32(cube_t cube, char *buf) | |||
| 256 | buf[21] = '\0'; | 256 | buf[21] = '\0'; |
| 257 | } | 257 | } |
| 258 | 258 | ||
| 259 | _static void | 259 | STATIC void |
| 260 | writecube_H48(cube_t cube, char *buf) | 260 | writecube_H48(cube_t cube, char *buf) |
| 261 | { | 261 | { |
| 262 | uint8_t piece, perm, orient, corner[8], edge[12]; | 262 | uint8_t piece, perm, orient, corner[8], edge[12]; |
| @@ -266,8 +266,8 @@ writecube_H48(cube_t cube, char *buf) | |||
| 266 | 266 | ||
| 267 | for (i = 0; i < 12; i++) { | 267 | for (i = 0; i < 12; i++) { |
| 268 | piece = edge[i]; | 268 | piece = edge[i]; |
| 269 | perm = piece & _pbits; | 269 | perm = piece & PBITS; |
| 270 | orient = (piece & _eobit) >> _eoshift; | 270 | orient = (piece & EOBIT) >> EOSHIFT; |
| 271 | buf[4*i ] = edgestr[perm][0]; | 271 | buf[4*i ] = edgestr[perm][0]; |
| 272 | buf[4*i + 1] = edgestr[perm][1]; | 272 | buf[4*i + 1] = edgestr[perm][1]; |
| 273 | buf[4*i + 2] = orient + '0'; | 273 | buf[4*i + 2] = orient + '0'; |
| @@ -275,8 +275,8 @@ writecube_H48(cube_t cube, char *buf) | |||
| 275 | } | 275 | } |
| 276 | for (i = 0; i < 8; i++) { | 276 | for (i = 0; i < 8; i++) { |
| 277 | piece = corner[i]; | 277 | piece = corner[i]; |
| 278 | perm = piece & _pbits; | 278 | perm = piece & PBITS; |
| 279 | orient = (piece & _cobits) >> _coshift; | 279 | orient = (piece & COBITS) >> COSHIFT; |
| 280 | buf[48 + 5*i ] = cornerstr[perm][0]; | 280 | buf[48 + 5*i ] = cornerstr[perm][0]; |
| 281 | buf[48 + 5*i + 1] = cornerstr[perm][1]; | 281 | buf[48 + 5*i + 1] = cornerstr[perm][1]; |
| 282 | buf[48 + 5*i + 2] = cornerstr[perm][2]; | 282 | buf[48 + 5*i + 2] = cornerstr[perm][2]; |
| @@ -287,7 +287,7 @@ writecube_H48(cube_t cube, char *buf) | |||
| 287 | buf[48+39] = '\0'; | 287 | buf[48+39] = '\0'; |
| 288 | } | 288 | } |
| 289 | 289 | ||
| 290 | _static void | 290 | STATIC void |
| 291 | writecube_LST(cube_t cube, char *buf) | 291 | writecube_LST(cube_t cube, char *buf) |
| 292 | { | 292 | { |
| 293 | int i; | 293 | int i; |
| @@ -310,7 +310,7 @@ writecube_LST(cube_t cube, char *buf) | |||
| 310 | *(buf+ptr-2) = 0; | 310 | *(buf+ptr-2) = 0; |
| 311 | } | 311 | } |
| 312 | 312 | ||
| 313 | _static uint8_t | 313 | STATIC uint8_t |
| 314 | b32toedge(char c) | 314 | b32toedge(char c) |
| 315 | { | 315 | { |
| 316 | if (!((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'f'))) | 316 | if (!((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'f'))) |
| @@ -319,7 +319,7 @@ b32toedge(char c) | |||
| 319 | return c <= 'Z' ? (uint8_t)(c - 'A') : (uint8_t)(c - 'a') + 26; | 319 | return c <= 'Z' ? (uint8_t)(c - 'A') : (uint8_t)(c - 'a') + 26; |
| 320 | } | 320 | } |
| 321 | 321 | ||
| 322 | _static uint8_t | 322 | STATIC uint8_t |
| 323 | b32tocorner(char c) { | 323 | b32tocorner(char c) { |
| 324 | uint8_t val; | 324 | uint8_t val; |
| 325 | 325 | ||
| @@ -331,13 +331,13 @@ b32tocorner(char c) { | |||
| 331 | return (val & 7) | ((val & 24) << 2); | 331 | return (val & 7) | ((val & 24) << 2); |
| 332 | } | 332 | } |
| 333 | 333 | ||
| 334 | _static char | 334 | STATIC char |
| 335 | edgetob32(uint8_t edge) | 335 | edgetob32(uint8_t edge) |
| 336 | { | 336 | { |
| 337 | return edge < 26 ? 'A' + (char)edge : 'a' + (char)(edge - 26); | 337 | return edge < 26 ? 'A' + (char)edge : 'a' + (char)(edge - 26); |
| 338 | } | 338 | } |
| 339 | 339 | ||
| 340 | _static char | 340 | STATIC char |
| 341 | cornertob32(uint8_t corner) | 341 | cornertob32(uint8_t corner) |
| 342 | { | 342 | { |
| 343 | uint8_t val; | 343 | uint8_t val; |
