diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/_constants.c | 72 | ||||
| -rw-r--r-- | src/cube.h | 90 |
2 files changed, 74 insertions, 88 deletions
diff --git a/src/_constants.c b/src/_constants.c index 0070990..a6b19fe 100644 --- a/src/_constants.c +++ b/src/_constants.c | |||
| @@ -1,3 +1,75 @@ | |||
| 1 | #define U 0U | ||
| 2 | #define U2 1U | ||
| 3 | #define U3 2U | ||
| 4 | #define D 3U | ||
| 5 | #define D2 4U | ||
| 6 | #define D3 5U | ||
| 7 | #define R 6U | ||
| 8 | #define R2 7U | ||
| 9 | #define R3 8U | ||
| 10 | #define L 9U | ||
| 11 | #define L2 10U | ||
| 12 | #define L3 11U | ||
| 13 | #define F 12U | ||
| 14 | #define F2 13U | ||
| 15 | #define F3 14U | ||
| 16 | #define B 15U | ||
| 17 | #define B2 16U | ||
| 18 | #define B3 17U | ||
| 19 | |||
| 20 | #define UFr 0 | ||
| 21 | #define ULr 1 | ||
| 22 | #define UBr 2 | ||
| 23 | #define URr 3 | ||
| 24 | #define DFr 4 | ||
| 25 | #define DLr 5 | ||
| 26 | #define DBr 6 | ||
| 27 | #define DRr 7 | ||
| 28 | #define RUr 8 | ||
| 29 | #define RFr 9 | ||
| 30 | #define RDr 10 | ||
| 31 | #define RBr 11 | ||
| 32 | #define LUr 12 | ||
| 33 | #define LFr 13 | ||
| 34 | #define LDr 14 | ||
| 35 | #define LBr 15 | ||
| 36 | #define FUr 16 | ||
| 37 | #define FRr 17 | ||
| 38 | #define FDr 18 | ||
| 39 | #define FLr 19 | ||
| 40 | #define BUr 20 | ||
| 41 | #define BRr 21 | ||
| 42 | #define BDr 22 | ||
| 43 | #define BLr 23 | ||
| 44 | |||
| 45 | #define UFm 24 | ||
| 46 | #define ULm 25 | ||
| 47 | #define UBm 26 | ||
| 48 | #define URm 27 | ||
| 49 | #define DFm 28 | ||
| 50 | #define DLm 29 | ||
| 51 | #define DBm 30 | ||
| 52 | #define DRm 31 | ||
| 53 | #define RUm 32 | ||
| 54 | #define RFm 33 | ||
| 55 | #define RDm 34 | ||
| 56 | #define RBm 35 | ||
| 57 | #define LUm 36 | ||
| 58 | #define LFm 37 | ||
| 59 | #define LDm 38 | ||
| 60 | #define LBm 39 | ||
| 61 | #define FUm 40 | ||
| 62 | #define FRm 41 | ||
| 63 | #define FDm 42 | ||
| 64 | #define FLm 43 | ||
| 65 | #define BUm 44 | ||
| 66 | #define BRm 45 | ||
| 67 | #define BDm 46 | ||
| 68 | #define BLm 47 | ||
| 69 | |||
| 70 | #define errormove 99U | ||
| 71 | #define errortrans 99U | ||
| 72 | |||
| 1 | #define _c_ufr 0U | 73 | #define _c_ufr 0U |
| 2 | #define _c_ubl 1U | 74 | #define _c_ubl 1U |
| 3 | #define _c_dfl 2U | 75 | #define _c_dfl 2U |
| @@ -1,6 +1,3 @@ | |||
| 1 | /* Types *********************************************************************/ | ||
| 2 | |||
| 3 | /* See doc/CUBE_INTERNAL.md for a description of the cube format */ | ||
| 4 | typedef struct { | 1 | typedef struct { |
| 5 | uint8_t c[16]; | 2 | uint8_t c[16]; |
| 6 | uint8_t e[16]; | 3 | uint8_t e[16]; |
| @@ -14,8 +11,6 @@ typedef cube_arr_t cube_t; | |||
| 14 | typedef uint8_t move_t; | 11 | typedef uint8_t move_t; |
| 15 | typedef uint8_t trans_t; | 12 | typedef uint8_t trans_t; |
| 16 | 13 | ||
| 17 | /* Functions *****************************************************************/ | ||
| 18 | |||
| 19 | int readmoves(char *, move_t *); | 14 | int readmoves(char *, move_t *); |
| 20 | void writemoves(move_t *, int, char *); | 15 | void writemoves(move_t *, int, char *); |
| 21 | trans_t readtrans(char *); | 16 | trans_t readtrans(char *); |
| @@ -24,11 +19,9 @@ void writetrans(trans_t, char *); | |||
| 24 | move_t inverse_move(move_t); | 19 | move_t inverse_move(move_t); |
| 25 | trans_t inverse_trans(trans_t); | 20 | trans_t inverse_trans(trans_t); |
| 26 | 21 | ||
| 27 | /* Not all formats are supported for both read and write. */ | ||
| 28 | /* See doc/CUBE_TEXT.md for details. */ | ||
| 29 | typedef enum {H48, SRC} format_t; | 22 | typedef enum {H48, SRC} format_t; |
| 30 | cube_t readcube(format_t, char *); | 23 | cube_t readcube(format_t, char *); /* Supports: H48 */ |
| 31 | void writecube(format_t, cube_t, char *); | 24 | void writecube(format_t, cube_t, char *); /* Supports: H48, SRC */ |
| 32 | 25 | ||
| 33 | cube_t solvedcube(void); | 26 | cube_t solvedcube(void); |
| 34 | cube_t zerocube(void); | 27 | cube_t zerocube(void); |
| @@ -41,82 +34,3 @@ cube_t move(cube_t, move_t); | |||
| 41 | cube_t inverse(cube_t); | 34 | cube_t inverse(cube_t); |
| 42 | cube_t compose(cube_t, cube_t); | 35 | cube_t compose(cube_t, cube_t); |
| 43 | cube_t transform(cube_t, trans_t); | 36 | cube_t transform(cube_t, trans_t); |
| 44 | |||
| 45 | /* Constants for moves and transformations ***********************************/ | ||
| 46 | |||
| 47 | /* Standard moves */ | ||
| 48 | #define U 0U | ||
| 49 | #define U2 1U | ||
| 50 | #define U3 2U | ||
| 51 | #define D 3U | ||
| 52 | #define D2 4U | ||
| 53 | #define D3 5U | ||
| 54 | #define R 6U | ||
| 55 | #define R2 7U | ||
| 56 | #define R3 8U | ||
| 57 | #define L 9U | ||
| 58 | #define L2 10U | ||
| 59 | #define L3 11U | ||
| 60 | #define F 12U | ||
| 61 | #define F2 13U | ||
| 62 | #define F3 14U | ||
| 63 | #define B 15U | ||
| 64 | #define B2 16U | ||
| 65 | #define B3 17U | ||
| 66 | |||
| 67 | /* Regular transformations (rotations) */ | ||
| 68 | #define UFr 0 | ||
| 69 | #define ULr 1 | ||
| 70 | #define UBr 2 | ||
| 71 | #define URr 3 | ||
| 72 | #define DFr 4 | ||
| 73 | #define DLr 5 | ||
| 74 | #define DBr 6 | ||
| 75 | #define DRr 7 | ||
| 76 | #define RUr 8 | ||
| 77 | #define RFr 9 | ||
| 78 | #define RDr 10 | ||
| 79 | #define RBr 11 | ||
| 80 | #define LUr 12 | ||
| 81 | #define LFr 13 | ||
| 82 | #define LDr 14 | ||
| 83 | #define LBr 15 | ||
| 84 | #define FUr 16 | ||
| 85 | #define FRr 17 | ||
| 86 | #define FDr 18 | ||
| 87 | #define FLr 19 | ||
| 88 | #define BUr 20 | ||
| 89 | #define BRr 21 | ||
| 90 | #define BDr 22 | ||
| 91 | #define BLr 23 | ||
| 92 | |||
| 93 | /* Mirrored transformations */ | ||
| 94 | #define UFm 24 | ||
| 95 | #define ULm 25 | ||
| 96 | #define UBm 26 | ||
| 97 | #define URm 27 | ||
| 98 | #define DFm 28 | ||
| 99 | #define DLm 29 | ||
| 100 | #define DBm 30 | ||
| 101 | #define DRm 31 | ||
| 102 | #define RUm 32 | ||
| 103 | #define RFm 33 | ||
| 104 | #define RDm 34 | ||
| 105 | #define RBm 35 | ||
| 106 | #define LUm 36 | ||
| 107 | #define LFm 37 | ||
| 108 | #define LDm 38 | ||
| 109 | #define LBm 39 | ||
| 110 | #define FUm 40 | ||
| 111 | #define FRm 41 | ||
| 112 | #define FDm 42 | ||
| 113 | #define FLm 43 | ||
| 114 | #define BUm 44 | ||
| 115 | #define BRm 45 | ||
| 116 | #define BDm 46 | ||
| 117 | #define BLm 47 | ||
| 118 | |||
| 119 | /* Errors */ | ||
| 120 | #define errormove 99U | ||
| 121 | #define errortrans 99U | ||
| 122 | |||
