aboutsummaryrefslogtreecommitdiff
path: root/src/cube_routines.h
diff options
context:
space:
mode:
authorSebastiano Tronto <sebastiano@tronto.net>2024-05-28 15:42:26 +0200
committerSebastiano Tronto <sebastiano@tronto.net>2024-05-28 15:42:26 +0200
commit28ad019d62583b7e89b4e76922aa73857d5876eb (patch)
tree1a103ea701eb013785f1d0fa45f450d6a16b6d78 /src/cube_routines.h
parent49b9c4a516f72e03d53277075f4580e2df8f0e63 (diff)
downloadnissy-core-28ad019d62583b7e89b4e76922aa73857d5876eb.tar.gz
nissy-core-28ad019d62583b7e89b4e76922aa73857d5876eb.zip
Added roadmap for refactor and some simple routines
Diffstat (limited to '')
-rw-r--r--src/cube_routines.h41
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
501b32toedge(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
510b32tocorner(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
522edgetob32(uint8_t edge)
523{
524 return edge <= 26 ? 'A' + (char)edge : 'a' + (char)(edge - 26);
525}
526
527_static char
528cornertob32(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
497readmove(char c) 538readmove(char c)
498{ 539{
499 switch (c) { 540 switch (c) {

Generated with cgit - Back to sebastiano.tronto.net