diff options
| author | Sebastiano Tronto <sebastiano@tronto.net> | 2024-05-28 15:42:26 +0200 |
|---|---|---|
| committer | Sebastiano Tronto <sebastiano@tronto.net> | 2024-05-28 15:42:26 +0200 |
| commit | 28ad019d62583b7e89b4e76922aa73857d5876eb (patch) | |
| tree | 1a103ea701eb013785f1d0fa45f450d6a16b6d78 /src/cube_routines.h | |
| parent | 49b9c4a516f72e03d53277075f4580e2df8f0e63 (diff) | |
| download | nissy-core-28ad019d62583b7e89b4e76922aa73857d5876eb.tar.gz nissy-core-28ad019d62583b7e89b4e76922aa73857d5876eb.zip | |
Added roadmap for refactor and some simple routines
Diffstat (limited to 'src/cube_routines.h')
| -rw-r--r-- | src/cube_routines.h | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/src/cube_routines.h b/src/cube_routines.h index fb19355..3730e90 100644 --- a/src/cube_routines.h +++ b/src/cube_routines.h | |||
| @@ -12,6 +12,10 @@ _static cube_t readcube_LST(const char *); | |||
| 12 | _static int writepiece_LST(uint8_t, char *); | 12 | _static int writepiece_LST(uint8_t, char *); |
| 13 | _static void writecube_H48(cube_t, char *); | 13 | _static void writecube_H48(cube_t, char *); |
| 14 | _static void writecube_LST(cube_t, char *); | 14 | _static void writecube_LST(cube_t, char *); |
| 15 | _static uint8_t b32toedge(char); | ||
| 16 | _static uint8_t b32tocorner(char); | ||
| 17 | _static char edgetob32(uint8_t); | ||
| 18 | _static char cornertob32(uint8_t); | ||
| 15 | _static uint8_t readmove(char); | 19 | _static uint8_t readmove(char); |
| 16 | _static uint8_t readmodifier(char); | 20 | _static uint8_t readmodifier(char); |
| 17 | _static uint8_t readtrans(const char *); | 21 | _static uint8_t readtrans(const char *); |
| @@ -494,6 +498,43 @@ writecube_LST(cube_t cube, char *buf) | |||
| 494 | } | 498 | } |
| 495 | 499 | ||
| 496 | _static uint8_t | 500 | _static uint8_t |
| 501 | b32toedge(char c) | ||
| 502 | { | ||
| 503 | DBG_ASSERT((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'g'), 255, | ||
| 504 | "Error reading base32 piece"); | ||
| 505 | |||
| 506 | return c <= 'Z' ? (uint8_t)(c - 'A') : (uint8_t)(c - 'a'); | ||
| 507 | } | ||
| 508 | |||
| 509 | _static uint8_t | ||
| 510 | b32tocorner(char c) { | ||
| 511 | uint8_t val; | ||
| 512 | |||
| 513 | DBG_ASSERT((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'g'), 255, | ||
| 514 | "Error reading base32 piece"); | ||
| 515 | |||
| 516 | val = c <= 'Z' ? (uint8_t)(c - 'A') : (uint8_t)(c - 'a') + 26; | ||
| 517 | |||
| 518 | return (val & 7) | ((val & 24) << 2); | ||
| 519 | } | ||
| 520 | |||
| 521 | _static char | ||
| 522 | edgetob32(uint8_t edge) | ||
| 523 | { | ||
| 524 | return edge <= 26 ? 'A' + (char)edge : 'a' + (char)(edge - 26); | ||
| 525 | } | ||
| 526 | |||
| 527 | _static char | ||
| 528 | cornertob32(uint8_t corner) | ||
| 529 | { | ||
| 530 | uint8_t val; | ||
| 531 | |||
| 532 | val = (corner & 7) | ((corner & 96) >> 2); | ||
| 533 | |||
| 534 | return val <= 26 ? 'A' + (char)val : 'a' + (char)(val - 26); | ||
| 535 | } | ||
| 536 | |||
| 537 | _static uint8_t | ||
| 497 | readmove(char c) | 538 | readmove(char c) |
| 498 | { | 539 | { |
| 499 | switch (c) { | 540 | switch (c) { |
