h48

A prototype for an optimal Rubik's cube solver, work in progress.
git clone https://git.tronto.net/h48
Download | Log | Files | Refs | README | LICENSE

commit 0de1530f4cea21f2bc0a0e0f1cbf9da016c7bda5
parent 80b065f757240af7920862b3e09f32a6dc06d392
Author: Sebastiano Tronto <sebastiano@tronto.net>
Date:   Fri,  4 Oct 2024 12:15:37 +0200

Revert table-based transformations

Long live the giant switch!

Diffstat:
Msrc/arch/avx2.h | 42++++++++++--------------------------------
Msrc/arch/common.h | 7-------
Msrc/arch/neon.h | 57+++++++++++++++++++--------------------------------------
Msrc/arch/portable.h | 49+++++++++++--------------------------------------
Msrc/core/constant_cubes.h | 456++++++++++++++++++++++++++++++++++++++++----------------------------------------
Msrc/core/core.h | 6------
Msrc/core/cube.h | 19+++++--------------
Msrc/core/io_cube.h | 6+++---
Msrc/core/moves.h | 4++--
Msrc/core/transform.h | 463+++++++++++++++++++++++++++++++++++++++++++++++++++++++------------------------
Dsrc/core/transform_with_switch.h | 354-------------------------------------------------------------------------------
11 files changed, 600 insertions(+), 863 deletions(-)

diff --git a/src/arch/avx2.h b/src/arch/avx2.h @@ -6,6 +6,16 @@ #define EO_AVX2 \ _mm256_set_epi64x(INT64_C(0x10101010), INT64_C(0x1010101010101010), 0, 0) +#define STATIC_CUBE(c_ufr, c_ubl, c_dfl, c_dbr, c_ufl, c_ubr, c_dfr, c_dbl, \ + e_uf, e_ub, e_db, e_df, e_ur, e_ul, e_dl, e_dr, e_fr, e_fl, e_bl, e_br) \ + _mm256_set_epi8(0, 0, 0, 0, e_br, e_bl, e_fl, e_fr, \ + e_dr, e_dl, e_ul, e_ur, e_df, e_db, e_ub, e_uf, \ + 0, 0, 0, 0, 0, 0, 0, 0, \ + c_dbl, c_dfr, c_ubr, c_ufl, c_dbr, c_dfl, c_ubl, c_ufr) +#define ZERO_CUBE _mm256_set_epi64x(0, 0, 0, 0) +#define SOLVED_CUBE STATIC_CUBE( \ + 0, 1, 2, 3, 4, 5, 6, 7, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11) + STATIC void pieces(cube_t *cube, uint8_t c[static 8], uint8_t e[static 12]) { @@ -16,38 +26,6 @@ pieces(cube_t *cube, uint8_t c[static 8], uint8_t e[static 12]) memcpy(e, aux+16, 12); } -STATIC_INLINE cube_t -cubefrompieces( - uint8_t c_ufr, - uint8_t c_ubl, - uint8_t c_dfl, - uint8_t c_dbr, - uint8_t c_ufl, - uint8_t c_ubr, - uint8_t c_dfr, - uint8_t c_dbl, - - uint8_t e_uf, - uint8_t e_ub, - uint8_t e_db, - uint8_t e_df, - uint8_t e_ur, - uint8_t e_ul, - uint8_t e_dl, - uint8_t e_dr, - uint8_t e_fr, - uint8_t e_fl, - uint8_t e_bl, - uint8_t e_br -) { - return _mm256_set_epi8( - 0, 0, 0, 0, e_br, e_bl, e_fl, e_fr, - e_dr, e_dl, e_ul, e_ur, e_df, e_db, e_ub, e_uf, - 0, 0, 0, 0, 0, 0, 0, 0, - c_dbl, c_dfr, c_ubr, c_ufl, c_dbr, c_dfl, c_ubl, c_ufr - ); -} - STATIC_INLINE bool equal(cube_t c1, cube_t c2) { diff --git a/src/arch/common.h b/src/arch/common.h @@ -1,11 +1,4 @@ -#define ZERO_CUBE cubefrompieces( \ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) -#define SOLVED_CUBE cubefrompieces( \ - 0, 1, 2, 3, 4, 5, 6, 7, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11) STATIC void pieces(cube_t *, uint8_t [static 8], uint8_t [static 12]); -STATIC_INLINE cube_t cubefrompieces(uint8_t, uint8_t, uint8_t, uint8_t, - uint8_t, uint8_t, uint8_t, uint8_t, uint8_t, uint8_t, uint8_t, uint8_t, - uint8_t, uint8_t, uint8_t, uint8_t, uint8_t, uint8_t, uint8_t, uint8_t); STATIC_INLINE bool equal(cube_t, cube_t); STATIC_INLINE cube_t invertco(cube_t); STATIC_INLINE cube_t compose_epcpeo(cube_t, cube_t); diff --git a/src/arch/neon.h b/src/arch/neon.h @@ -7,6 +7,25 @@ STATIC_INLINE uint8x16_t compose_edges_slim(uint8x16_t, uint8x16_t); STATIC_INLINE uint8x16_t compose_corners_slim(uint8x16_t, uint8x16_t); +// static cube +#define STATIC_CUBE(c_ufr, c_ubl, c_dfl, c_dbr, c_ufl, c_ubr, c_dfr, c_dbl, \ + e_uf, e_ub, e_db, e_df, e_ur, e_ul, e_dl, e_dr, e_fr, e_fl, e_bl, e_br) \ + ((cube_t){ \ + .corner = {c_ufr, c_ubl, c_dfl, c_dbr, c_ufl, c_ubr, c_dfr, c_dbl, 0, 0, 0, 0, 0, 0, 0, 0}, \ + .edge = {e_uf, e_ub, e_db, e_df, e_ur, e_ul, e_dl, e_dr, e_fr, e_fl, e_bl, e_br, 0, 0, 0, 0}}) + +// zero cube +#define ZERO_CUBE \ + (cube_t) \ + { \ + .corner = vdupq_n_u8(0), \ + .edge = vdupq_n_u8(0) \ + } + +// solved cube +#define SOLVED_CUBE STATIC_CUBE( \ + 0, 1, 2, 3, 4, 5, 6, 7, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11) + STATIC void pieces(cube_t *cube, uint8_t c[static 8], uint8_t e[static 12]) { @@ -20,44 +39,6 @@ pieces(cube_t *cube, uint8_t c[static 8], uint8_t e[static 12]) vst1_lane_u32((uint32_t *)(e + 8), vreinterpret_u32_u8(vget_high_u8(cube->edge)), 0); } -STATIC_INLINE cube_t -cubefrompieces( - uint8_t c_ufr, - uint8_t c_ubl, - uint8_t c_dfl, - uint8_t c_dbr, - uint8_t c_ufl, - uint8_t c_ubr, - uint8_t c_dfr, - uint8_t c_dbl, - - uint8_t e_uf, - uint8_t e_ub, - uint8_t e_db, - uint8_t e_df, - uint8_t e_ur, - uint8_t e_ul, - uint8_t e_dl, - uint8_t e_dr, - uint8_t e_fr, - uint8_t e_fl, - uint8_t e_bl, - uint8_t e_br -) { - cube_t ret = { - .corner = { - c_ufr, c_ubl, c_dfl, c_dbr, c_ufl, c_ubr, c_dfr, c_dbl, - 0, 0, 0, 0, 0, 0, 0, 0 - }, - .edge = { - e_uf, e_ub, e_db, e_df, e_ur, e_ul, e_dl, e_dr, e_fr, - e_fl, e_bl, e_br, 0, 0, 0, 0 - } - }; - - return ret; -} - STATIC_INLINE bool equal(cube_t c1, cube_t c2) { diff --git a/src/arch/portable.h b/src/arch/portable.h @@ -1,3 +1,14 @@ +#define STATIC_CUBE(c_ufr, c_ubl, c_dfl, c_dbr, c_ufl, c_ubr, c_dfr, c_dbl, \ + e_uf, e_ub, e_db, e_df, e_ur, e_ul, e_dl, e_dr, e_fr, e_fl, e_bl, e_br) \ + ((cube_t) { \ + .corner = { c_ufr, c_ubl, c_dfl, c_dbr, c_ufl, c_ubr, c_dfr, c_dbl }, \ + .edge = { e_uf, e_ub, e_db, e_df, e_ur, e_ul, \ + e_dl, e_dr, e_fr, e_fl, e_bl, e_br } }) +#define ZERO_CUBE STATIC_CUBE( \ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) +#define SOLVED_CUBE STATIC_CUBE( \ + 0, 1, 2, 3, 4, 5, 6, 7, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11) + STATIC void pieces(cube_t *cube, uint8_t c[static 8], uint8_t e[static 12]) { @@ -5,44 +16,6 @@ pieces(cube_t *cube, uint8_t c[static 8], uint8_t e[static 12]) memcpy(e, cube->edge, 12); } -STATIC_INLINE cube_t -cubefrompieces( - uint8_t c_ufr, - uint8_t c_ubl, - uint8_t c_dfl, - uint8_t c_dbr, - uint8_t c_ufl, - uint8_t c_ubr, - uint8_t c_dfr, - uint8_t c_dbl, - - uint8_t e_uf, - uint8_t e_ub, - uint8_t e_db, - uint8_t e_df, - uint8_t e_ur, - uint8_t e_ul, - uint8_t e_dl, - uint8_t e_dr, - uint8_t e_fr, - uint8_t e_fl, - uint8_t e_bl, - uint8_t e_br -) { - cube_t ret = { - .corner = { - 0, 0, 0, 0, 0, 0, 0, 0, - c_dbl, c_dfr, c_ubr, c_ufl, c_dbr, c_dfl, c_ubl, c_ufr - }, - .edge = { - 0, 0, 0, 0, e_br, e_bl, e_fl, e_fr, - e_dr, e_dl, e_ul, e_ur, e_df, e_db, e_ub, e_uf - } - }; - - return ret; -} - STATIC_INLINE bool equal(cube_t c1, cube_t c2) { diff --git a/src/core/constant_cubes.h b/src/core/constant_cubes.h @@ -1,229 +1,229 @@ -#define MOVE_CUBE_U \ - 5, 4, 2, 3, 0, 1, 6, 7, 4, 5, 2, 3, 1, 0, 6, 7, 8, 9, 10, 11 -#define MOVE_CUBE_U2 \ - 1, 0, 2, 3, 5, 4, 6, 7, 1, 0, 2, 3, 5, 4, 6, 7, 8, 9, 10, 11 -#define MOVE_CUBE_U3 \ - 4, 5, 2, 3, 1, 0, 6, 7, 5, 4, 2, 3, 0, 1, 6, 7, 8, 9, 10, 11 -#define MOVE_CUBE_D \ - 0, 1, 7, 6, 4, 5, 2, 3, 0, 1, 7, 6, 4, 5, 2, 3, 8, 9, 10, 11 -#define MOVE_CUBE_D2 \ - 0, 1, 3, 2, 4, 5, 7, 6, 0, 1, 3, 2, 4, 5, 7, 6, 8, 9, 10, 11 -#define MOVE_CUBE_D3 \ - 0, 1, 6, 7, 4, 5, 3, 2, 0, 1, 6, 7, 4, 5, 3, 2, 8, 9, 10, 11 -#define MOVE_CUBE_R \ - 70, 1, 2, 69, 4, 32, 35, 7, 0, 1, 2, 3, 8, 5, 6, 11, 7, 9, 10, 4 -#define MOVE_CUBE_R2 \ - 3, 1, 2, 0, 4, 6, 5, 7, 0, 1, 2, 3, 7, 5, 6, 4, 11, 9, 10, 8 -#define MOVE_CUBE_R3 \ - 69, 1, 2, 70, 4, 35, 32, 7, 0, 1, 2, 3, 11, 5, 6, 8, 4, 9, 10, 7 -#define MOVE_CUBE_L \ - 0, 71, 68, 3, 33, 5, 6, 34, 0, 1, 2, 3, 4, 10, 9, 7, 8, 5, 6, 11 -#define MOVE_CUBE_L2 \ - 0, 2, 1, 3, 7, 5, 6, 4, 0, 1, 2, 3, 4, 6, 5, 7, 8, 10, 9, 11 -#define MOVE_CUBE_L3 \ - 0, 68, 71, 3, 34, 5, 6, 33, 0, 1, 2, 3, 4, 9, 10, 7, 8, 6, 5, 11 -#define MOVE_CUBE_F \ - 36, 1, 38, 3, 66, 5, 64, 7, 25, 1, 2, 24, 4, 5, 6, 7, 16, 19, 10, 11 -#define MOVE_CUBE_F2 \ - 2, 1, 0, 3, 6, 5, 4, 7, 3, 1, 2, 0, 4, 5, 6, 7, 9, 8, 10, 11 -#define MOVE_CUBE_F3 \ - 38, 1, 36, 3, 64, 5, 66, 7, 24, 1, 2, 25, 4, 5, 6, 7, 19, 16, 10, 11 -#define MOVE_CUBE_B \ - 0, 37, 2, 39, 4, 67, 6, 65, 0, 27, 26, 3, 4, 5, 6, 7, 8, 9, 17, 18 -#define MOVE_CUBE_B2 \ - 0, 3, 2, 1, 4, 7, 6, 5, 0, 2, 1, 3, 4, 5, 6, 7, 8, 9, 11, 10 -#define MOVE_CUBE_B3 \ - 0, 39, 2, 37, 4, 65, 6, 67, 0, 26, 27, 3, 4, 5, 6, 7, 8, 9, 18, 17 +#define MOVE_CUBE_U STATIC_CUBE( \ + 5, 4, 2, 3, 0, 1, 6, 7, 4, 5, 2, 3, 1, 0, 6, 7, 8, 9, 10, 11) +#define MOVE_CUBE_U2 STATIC_CUBE( \ + 1, 0, 2, 3, 5, 4, 6, 7, 1, 0, 2, 3, 5, 4, 6, 7, 8, 9, 10, 11) +#define MOVE_CUBE_U3 STATIC_CUBE( \ + 4, 5, 2, 3, 1, 0, 6, 7, 5, 4, 2, 3, 0, 1, 6, 7, 8, 9, 10, 11) +#define MOVE_CUBE_D STATIC_CUBE( \ + 0, 1, 7, 6, 4, 5, 2, 3, 0, 1, 7, 6, 4, 5, 2, 3, 8, 9, 10, 11) +#define MOVE_CUBE_D2 STATIC_CUBE( \ + 0, 1, 3, 2, 4, 5, 7, 6, 0, 1, 3, 2, 4, 5, 7, 6, 8, 9, 10, 11) +#define MOVE_CUBE_D3 STATIC_CUBE( \ + 0, 1, 6, 7, 4, 5, 3, 2, 0, 1, 6, 7, 4, 5, 3, 2, 8, 9, 10, 11) +#define MOVE_CUBE_R STATIC_CUBE( \ + 70, 1, 2, 69, 4, 32, 35, 7, 0, 1, 2, 3, 8, 5, 6, 11, 7, 9, 10, 4) +#define MOVE_CUBE_R2 STATIC_CUBE( \ + 3, 1, 2, 0, 4, 6, 5, 7, 0, 1, 2, 3, 7, 5, 6, 4, 11, 9, 10, 8) +#define MOVE_CUBE_R3 STATIC_CUBE( \ + 69, 1, 2, 70, 4, 35, 32, 7, 0, 1, 2, 3, 11, 5, 6, 8, 4, 9, 10, 7) +#define MOVE_CUBE_L STATIC_CUBE( \ + 0, 71, 68, 3, 33, 5, 6, 34, 0, 1, 2, 3, 4, 10, 9, 7, 8, 5, 6, 11) +#define MOVE_CUBE_L2 STATIC_CUBE( \ + 0, 2, 1, 3, 7, 5, 6, 4, 0, 1, 2, 3, 4, 6, 5, 7, 8, 10, 9, 11) +#define MOVE_CUBE_L3 STATIC_CUBE( \ + 0, 68, 71, 3, 34, 5, 6, 33, 0, 1, 2, 3, 4, 9, 10, 7, 8, 6, 5, 11) +#define MOVE_CUBE_F STATIC_CUBE( \ + 36, 1, 38, 3, 66, 5, 64, 7, 25, 1, 2, 24, 4, 5, 6, 7, 16, 19, 10, 11) +#define MOVE_CUBE_F2 STATIC_CUBE( \ + 2, 1, 0, 3, 6, 5, 4, 7, 3, 1, 2, 0, 4, 5, 6, 7, 9, 8, 10, 11) +#define MOVE_CUBE_F3 STATIC_CUBE( \ + 38, 1, 36, 3, 64, 5, 66, 7, 24, 1, 2, 25, 4, 5, 6, 7, 19, 16, 10, 11) +#define MOVE_CUBE_B STATIC_CUBE( \ + 0, 37, 2, 39, 4, 67, 6, 65, 0, 27, 26, 3, 4, 5, 6, 7, 8, 9, 17, 18) +#define MOVE_CUBE_B2 STATIC_CUBE( \ + 0, 3, 2, 1, 4, 7, 6, 5, 0, 2, 1, 3, 4, 5, 6, 7, 8, 9, 11, 10) +#define MOVE_CUBE_B3 STATIC_CUBE( \ + 0, 39, 2, 37, 4, 65, 6, 67, 0, 26, 27, 3, 4, 5, 6, 7, 8, 9, 18, 17) -#define TRANS_CUBE_UFr \ - 0, 1, 2, 3, 4, 5, 6, 7, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 -#define TRANS_CUBE_UFr_INVERSE \ - 0, 1, 2, 3, 4, 5, 6, 7, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 -#define TRANS_CUBE_ULr \ - 4, 5, 7, 6, 1, 0, 2, 3, 5, 4, 7, 6, 0, 1, 2, 3, 25, 26, 27, 24 -#define TRANS_CUBE_ULr_INVERSE \ - 5, 4, 6, 7, 0, 1, 3, 2, 4, 5, 6, 7, 1, 0, 3, 2, 27, 24, 25, 26 -#define TRANS_CUBE_UBr \ - 1, 0, 3, 2, 5, 4, 7, 6, 1, 0, 3, 2, 5, 4, 7, 6, 10, 11, 8, 9 -#define TRANS_CUBE_UBr_INVERSE \ - 1, 0, 3, 2, 5, 4, 7, 6, 1, 0, 3, 2, 5, 4, 7, 6, 10, 11, 8, 9 -#define TRANS_CUBE_URr \ - 5, 4, 6, 7, 0, 1, 3, 2, 4, 5, 6, 7, 1, 0, 3, 2, 27, 24, 25, 26 -#define TRANS_CUBE_URr_INVERSE \ - 4, 5, 7, 6, 1, 0, 2, 3, 5, 4, 7, 6, 0, 1, 2, 3, 25, 26, 27, 24 -#define TRANS_CUBE_DFr \ - 2, 3, 0, 1, 6, 7, 4, 5, 3, 2, 1, 0, 6, 7, 4, 5, 9, 8, 11, 10 -#define TRANS_CUBE_DFr_INVERSE \ - 2, 3, 0, 1, 6, 7, 4, 5, 3, 2, 1, 0, 6, 7, 4, 5, 9, 8, 11, 10 -#define TRANS_CUBE_DLr \ - 7, 6, 4, 5, 2, 3, 1, 0, 6, 7, 4, 5, 2, 3, 0, 1, 26, 25, 24, 27 -#define TRANS_CUBE_DLr_INVERSE \ - 7, 6, 4, 5, 2, 3, 1, 0, 6, 7, 4, 5, 2, 3, 0, 1, 26, 25, 24, 27 -#define TRANS_CUBE_DBr \ - 3, 2, 1, 0, 7, 6, 5, 4, 2, 3, 0, 1, 7, 6, 5, 4, 11, 10, 9, 8 -#define TRANS_CUBE_DBr_INVERSE \ - 3, 2, 1, 0, 7, 6, 5, 4, 2, 3, 0, 1, 7, 6, 5, 4, 11, 10, 9, 8 -#define TRANS_CUBE_DRr \ - 6, 7, 5, 4, 3, 2, 0, 1, 7, 6, 5, 4, 3, 2, 1, 0, 24, 27, 26, 25 -#define TRANS_CUBE_DRr_INVERSE \ - 6, 7, 5, 4, 3, 2, 0, 1, 7, 6, 5, 4, 3, 2, 1, 0, 24, 27, 26, 25 -#define TRANS_CUBE_RUr \ - 64, 67, 65, 66, 37, 38, 36, 39, 20, 23, 22, 21, 24, 27, 26, 25, 0, 1, 2, 3 -#define TRANS_CUBE_RUr_INVERSE \ - 32, 34, 35, 33, 70, 68, 69, 71, 8, 9, 10, 11, 16, 19, 18, 17, 20, 23, 22, 21 -#define TRANS_CUBE_RFr \ - 38, 37, 36, 39, 64, 67, 66, 65, 24, 27, 26, 25, 23, 20, 21, 22, 19, 16, 17, 18 -#define TRANS_CUBE_RFr_INVERSE \ - 36, 39, 38, 37, 66, 65, 64, 67, 25, 26, 27, 24, 21, 22, 23, 20, 16, 19, 18, 17 -#define TRANS_CUBE_RDr \ - 67, 64, 66, 65, 38, 37, 39, 36, 23, 20, 21, 22, 27, 24, 25, 26, 2, 3, 0, 1 -#define TRANS_CUBE_RDr_INVERSE \ - 33, 35, 34, 32, 71, 69, 68, 70, 10, 11, 8, 9, 17, 18, 19, 16, 21, 22, 23, 20 -#define TRANS_CUBE_RBr \ - 37, 38, 39, 36, 67, 64, 65, 66, 27, 24, 25, 26, 20, 23, 22, 21, 17, 18, 19, 16 -#define TRANS_CUBE_RBr_INVERSE \ - 37, 38, 39, 36, 67, 64, 65, 66, 27, 24, 25, 26, 20, 23, 22, 21, 17, 18, 19, 16 -#define TRANS_CUBE_LUr \ - 65, 66, 64, 67, 36, 39, 37, 38, 21, 22, 23, 20, 26, 25, 24, 27, 1, 0, 3, 2 -#define TRANS_CUBE_LUr_INVERSE \ - 34, 32, 33, 35, 68, 70, 71, 69, 9, 8, 11, 10, 19, 16, 17, 18, 22, 21, 20, 23 -#define TRANS_CUBE_LFr \ - 36, 39, 38, 37, 66, 65, 64, 67, 25, 26, 27, 24, 21, 22, 23, 20, 16, 19, 18, 17 -#define TRANS_CUBE_LFr_INVERSE \ - 38, 37, 36, 39, 64, 67, 66, 65, 24, 27, 26, 25, 23, 20, 21, 22, 19, 16, 17, 18 -#define TRANS_CUBE_LDr \ - 66, 65, 67, 64, 39, 36, 38, 37, 22, 21, 20, 23, 25, 26, 27, 24, 3, 2, 1, 0 -#define TRANS_CUBE_LDr_INVERSE \ - 35, 33, 32, 34, 69, 71, 70, 68, 11, 10, 9, 8, 18, 17, 16, 19, 23, 20, 21, 22 -#define TRANS_CUBE_LBr \ - 39, 36, 37, 38, 65, 66, 67, 64, 26, 25, 24, 27, 22, 21, 20, 23, 18, 17, 16, 19 -#define TRANS_CUBE_LBr_INVERSE \ - 39, 36, 37, 38, 65, 66, 67, 64, 26, 25, 24, 27, 22, 21, 20, 23, 18, 17, 16, 19 -#define TRANS_CUBE_FUr \ - 68, 70, 69, 71, 32, 34, 33, 35, 16, 19, 18, 17, 9, 8, 11, 10, 5, 4, 7, 6 -#define TRANS_CUBE_FUr_INVERSE \ - 68, 70, 69, 71, 32, 34, 33, 35, 16, 19, 18, 17, 9, 8, 11, 10, 5, 4, 7, 6 -#define TRANS_CUBE_FRr \ - 32, 34, 35, 33, 70, 68, 69, 71, 8, 9, 10, 11, 16, 19, 18, 17, 20, 23, 22, 21 -#define TRANS_CUBE_FRr_INVERSE \ - 64, 67, 65, 66, 37, 38, 36, 39, 20, 23, 22, 21, 24, 27, 26, 25, 0, 1, 2, 3 -#define TRANS_CUBE_FDr \ - 70, 68, 71, 69, 34, 32, 35, 33, 19, 16, 17, 18, 8, 9, 10, 11, 7, 6, 5, 4 -#define TRANS_CUBE_FDr_INVERSE \ - 69, 71, 68, 70, 33, 35, 32, 34, 17, 18, 19, 16, 11, 10, 9, 8, 4, 5, 6, 7 -#define TRANS_CUBE_FLr \ - 34, 32, 33, 35, 68, 70, 71, 69, 9, 8, 11, 10, 19, 16, 17, 18, 22, 21, 20, 23 -#define TRANS_CUBE_FLr_INVERSE \ - 65, 66, 64, 67, 36, 39, 37, 38, 21, 22, 23, 20, 26, 25, 24, 27, 1, 0, 3, 2 -#define TRANS_CUBE_BUr \ - 69, 71, 68, 70, 33, 35, 32, 34, 17, 18, 19, 16, 11, 10, 9, 8, 4, 5, 6, 7 -#define TRANS_CUBE_BUr_INVERSE \ - 70, 68, 71, 69, 34, 32, 35, 33, 19, 16, 17, 18, 8, 9, 10, 11, 7, 6, 5, 4 -#define TRANS_CUBE_BRr \ - 35, 33, 32, 34, 69, 71, 70, 68, 11, 10, 9, 8, 18, 17, 16, 19, 23, 20, 21, 22 -#define TRANS_CUBE_BRr_INVERSE \ - 66, 65, 67, 64, 39, 36, 38, 37, 22, 21, 20, 23, 25, 26, 27, 24, 3, 2, 1, 0 -#define TRANS_CUBE_BDr \ - 71, 69, 70, 68, 35, 33, 34, 32, 18, 17, 16, 19, 10, 11, 8, 9, 6, 7, 4, 5 -#define TRANS_CUBE_BDr_INVERSE \ - 71, 69, 70, 68, 35, 33, 34, 32, 18, 17, 16, 19, 10, 11, 8, 9, 6, 7, 4, 5 -#define TRANS_CUBE_BLr \ - 33, 35, 34, 32, 71, 69, 68, 70, 10, 11, 8, 9, 17, 18, 19, 16, 21, 22, 23, 20 -#define TRANS_CUBE_BLr_INVERSE \ - 67, 64, 66, 65, 38, 37, 39, 36, 23, 20, 21, 22, 27, 24, 25, 26, 2, 3, 0, 1 -#define TRANS_CUBE_UFm \ - 4, 5, 6, 7, 0, 1, 2, 3, 0, 1, 2, 3, 5, 4, 7, 6, 9, 8, 11, 10 -#define TRANS_CUBE_UFm_INVERSE \ - 4, 5, 6, 7, 0, 1, 2, 3, 0, 1, 2, 3, 5, 4, 7, 6, 9, 8, 11, 10 -#define TRANS_CUBE_ULm \ - 0, 1, 3, 2, 5, 4, 6, 7, 4, 5, 6, 7, 0, 1, 2, 3, 24, 27, 26, 25 -#define TRANS_CUBE_ULm_INVERSE \ - 0, 1, 3, 2, 5, 4, 6, 7, 4, 5, 6, 7, 0, 1, 2, 3, 24, 27, 26, 25 -#define TRANS_CUBE_UBm \ - 5, 4, 7, 6, 1, 0, 3, 2, 1, 0, 3, 2, 4, 5, 6, 7, 11, 10, 9, 8 -#define TRANS_CUBE_UBm_INVERSE \ - 5, 4, 7, 6, 1, 0, 3, 2, 1, 0, 3, 2, 4, 5, 6, 7, 11, 10, 9, 8 -#define TRANS_CUBE_URm \ - 1, 0, 2, 3, 4, 5, 7, 6, 5, 4, 7, 6, 1, 0, 3, 2, 26, 25, 24, 27 -#define TRANS_CUBE_URm_INVERSE \ - 1, 0, 2, 3, 4, 5, 7, 6, 5, 4, 7, 6, 1, 0, 3, 2, 26, 25, 24, 27 -#define TRANS_CUBE_DFm \ - 6, 7, 4, 5, 2, 3, 0, 1, 3, 2, 1, 0, 7, 6, 5, 4, 8, 9, 10, 11 -#define TRANS_CUBE_DFm_INVERSE \ - 6, 7, 4, 5, 2, 3, 0, 1, 3, 2, 1, 0, 7, 6, 5, 4, 8, 9, 10, 11 -#define TRANS_CUBE_DLm \ - 3, 2, 0, 1, 6, 7, 5, 4, 7, 6, 5, 4, 2, 3, 0, 1, 27, 24, 25, 26 -#define TRANS_CUBE_DLm_INVERSE \ - 2, 3, 1, 0, 7, 6, 4, 5, 6, 7, 4, 5, 3, 2, 1, 0, 25, 26, 27, 24 -#define TRANS_CUBE_DBm \ - 7, 6, 5, 4, 3, 2, 1, 0, 2, 3, 0, 1, 6, 7, 4, 5, 10, 11, 8, 9 -#define TRANS_CUBE_DBm_INVERSE \ - 7, 6, 5, 4, 3, 2, 1, 0, 2, 3, 0, 1, 6, 7, 4, 5, 10, 11, 8, 9 -#define TRANS_CUBE_DRm \ - 2, 3, 1, 0, 7, 6, 4, 5, 6, 7, 4, 5, 3, 2, 1, 0, 25, 26, 27, 24 -#define TRANS_CUBE_DRm_INVERSE \ - 3, 2, 0, 1, 6, 7, 5, 4, 7, 6, 5, 4, 2, 3, 0, 1, 27, 24, 25, 26 -#define TRANS_CUBE_RUm \ - 68, 71, 69, 70, 33, 34, 32, 35, 21, 22, 23, 20, 25, 26, 27, 24, 0, 1, 2, 3 -#define TRANS_CUBE_RUm_INVERSE \ - 70, 68, 69, 71, 32, 34, 35, 33, 8, 9, 10, 11, 19, 16, 17, 18, 23, 20, 21, 22 -#define TRANS_CUBE_RFm \ - 34, 33, 32, 35, 68, 71, 70, 69, 25, 26, 27, 24, 22, 21, 20, 23, 19, 16, 17, 18 -#define TRANS_CUBE_RFm_INVERSE \ - 66, 65, 64, 67, 36, 39, 38, 37, 25, 26, 27, 24, 22, 21, 20, 23, 19, 16, 17, 18 -#define TRANS_CUBE_RDm \ - 71, 68, 70, 69, 34, 33, 35, 32, 22, 21, 20, 23, 26, 25, 24, 27, 2, 3, 0, 1 -#define TRANS_CUBE_RDm_INVERSE \ - 71, 69, 68, 70, 33, 35, 34, 32, 10, 11, 8, 9, 18, 17, 16, 19, 22, 21, 20, 23 -#define TRANS_CUBE_RBm \ - 33, 34, 35, 32, 71, 68, 69, 70, 26, 25, 24, 27, 21, 22, 23, 20, 17, 18, 19, 16 -#define TRANS_CUBE_RBm_INVERSE \ - 67, 64, 65, 66, 37, 38, 39, 36, 27, 24, 25, 26, 23, 20, 21, 22, 18, 17, 16, 19 -#define TRANS_CUBE_LUm \ - 69, 70, 68, 71, 32, 35, 33, 34, 20, 23, 22, 21, 27, 24, 25, 26, 1, 0, 3, 2 -#define TRANS_CUBE_LUm_INVERSE \ - 68, 70, 71, 69, 34, 32, 33, 35, 9, 8, 11, 10, 16, 19, 18, 17, 21, 22, 23, 20 -#define TRANS_CUBE_LFm \ - 32, 35, 34, 33, 70, 69, 68, 71, 24, 27, 26, 25, 20, 23, 22, 21, 16, 19, 18, 17 -#define TRANS_CUBE_LFm_INVERSE \ - 64, 67, 66, 65, 38, 37, 36, 39, 24, 27, 26, 25, 20, 23, 22, 21, 16, 19, 18, 17 -#define TRANS_CUBE_LDm \ - 70, 69, 71, 68, 35, 32, 34, 33, 23, 20, 21, 22, 24, 27, 26, 25, 3, 2, 1, 0 -#define TRANS_CUBE_LDm_INVERSE \ - 69, 71, 70, 68, 35, 33, 32, 34, 11, 10, 9, 8, 17, 18, 19, 16, 20, 23, 22, 21 -#define TRANS_CUBE_LBm \ - 35, 32, 33, 34, 69, 70, 71, 68, 27, 24, 25, 26, 23, 20, 21, 22, 18, 17, 16, 19 -#define TRANS_CUBE_LBm_INVERSE \ - 65, 66, 67, 64, 39, 36, 37, 38, 26, 25, 24, 27, 21, 22, 23, 20, 17, 18, 19, 16 -#define TRANS_CUBE_FUm \ - 64, 66, 65, 67, 36, 38, 37, 39, 16, 19, 18, 17, 8, 9, 10, 11, 4, 5, 6, 7 -#define TRANS_CUBE_FUm_INVERSE \ - 32, 34, 33, 35, 68, 70, 69, 71, 16, 19, 18, 17, 8, 9, 10, 11, 4, 5, 6, 7 -#define TRANS_CUBE_FRm \ - 36, 38, 39, 37, 66, 64, 65, 67, 9, 8, 11, 10, 16, 19, 18, 17, 21, 22, 23, 20 -#define TRANS_CUBE_FRm_INVERSE \ - 37, 38, 36, 39, 64, 67, 65, 66, 20, 23, 22, 21, 27, 24, 25, 26, 1, 0, 3, 2 -#define TRANS_CUBE_FDm \ - 66, 64, 67, 65, 38, 36, 39, 37, 19, 16, 17, 18, 9, 8, 11, 10, 6, 7, 4, 5 -#define TRANS_CUBE_FDm_INVERSE \ - 33, 35, 32, 34, 69, 71, 68, 70, 17, 18, 19, 16, 10, 11, 8, 9, 5, 4, 7, 6 -#define TRANS_CUBE_FLm \ - 38, 36, 37, 39, 64, 66, 67, 65, 8, 9, 10, 11, 19, 16, 17, 18, 23, 20, 21, 22 -#define TRANS_CUBE_FLm_INVERSE \ - 36, 39, 37, 38, 65, 66, 64, 67, 21, 22, 23, 20, 25, 26, 27, 24, 0, 1, 2, 3 -#define TRANS_CUBE_BUm \ - 65, 67, 64, 66, 37, 39, 36, 38, 17, 18, 19, 16, 10, 11, 8, 9, 5, 4, 7, 6 -#define TRANS_CUBE_BUm_INVERSE \ - 34, 32, 35, 33, 70, 68, 71, 69, 19, 16, 17, 18, 9, 8, 11, 10, 6, 7, 4, 5 -#define TRANS_CUBE_BRm \ - 39, 37, 36, 38, 65, 67, 66, 64, 10, 11, 8, 9, 18, 17, 16, 19, 22, 21, 20, 23 -#define TRANS_CUBE_BRm_INVERSE \ - 39, 36, 38, 37, 66, 65, 67, 64, 22, 21, 20, 23, 26, 25, 24, 27, 2, 3, 0, 1 -#define TRANS_CUBE_BDm \ - 67, 65, 66, 64, 39, 37, 38, 36, 18, 17, 16, 19, 11, 10, 9, 8, 7, 6, 5, 4 -#define TRANS_CUBE_BDm_INVERSE \ - 35, 33, 34, 32, 71, 69, 70, 68, 18, 17, 16, 19, 11, 10, 9, 8, 7, 6, 5, 4 -#define TRANS_CUBE_BLm \ - 37, 39, 38, 36, 67, 65, 64, 66, 11, 10, 9, 8, 17, 18, 19, 16, 20, 23, 22, 21 -#define TRANS_CUBE_BLm_INVERSE \ - 38, 37, 39, 36, 67, 64, 66, 65, 23, 20, 21, 22, 24, 27, 26, 25, 3, 2, 1, 0 +#define TRANS_CUBE_UFr STATIC_CUBE( \ + 0, 1, 2, 3, 4, 5, 6, 7, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11) +#define TRANS_CUBE_UFr_INVERSE STATIC_CUBE( \ + 0, 1, 2, 3, 4, 5, 6, 7, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11) +#define TRANS_CUBE_ULr STATIC_CUBE( \ + 4, 5, 7, 6, 1, 0, 2, 3, 5, 4, 7, 6, 0, 1, 2, 3, 25, 26, 27, 24) +#define TRANS_CUBE_ULr_INVERSE STATIC_CUBE( \ + 5, 4, 6, 7, 0, 1, 3, 2, 4, 5, 6, 7, 1, 0, 3, 2, 27, 24, 25, 26) +#define TRANS_CUBE_UBr STATIC_CUBE( \ + 1, 0, 3, 2, 5, 4, 7, 6, 1, 0, 3, 2, 5, 4, 7, 6, 10, 11, 8, 9) +#define TRANS_CUBE_UBr_INVERSE STATIC_CUBE( \ + 1, 0, 3, 2, 5, 4, 7, 6, 1, 0, 3, 2, 5, 4, 7, 6, 10, 11, 8, 9) +#define TRANS_CUBE_URr STATIC_CUBE( \ + 5, 4, 6, 7, 0, 1, 3, 2, 4, 5, 6, 7, 1, 0, 3, 2, 27, 24, 25, 26) +#define TRANS_CUBE_URr_INVERSE STATIC_CUBE( \ + 4, 5, 7, 6, 1, 0, 2, 3, 5, 4, 7, 6, 0, 1, 2, 3, 25, 26, 27, 24) +#define TRANS_CUBE_DFr STATIC_CUBE( \ + 2, 3, 0, 1, 6, 7, 4, 5, 3, 2, 1, 0, 6, 7, 4, 5, 9, 8, 11, 10) +#define TRANS_CUBE_DFr_INVERSE STATIC_CUBE( \ + 2, 3, 0, 1, 6, 7, 4, 5, 3, 2, 1, 0, 6, 7, 4, 5, 9, 8, 11, 10) +#define TRANS_CUBE_DLr STATIC_CUBE( \ + 7, 6, 4, 5, 2, 3, 1, 0, 6, 7, 4, 5, 2, 3, 0, 1, 26, 25, 24, 27) +#define TRANS_CUBE_DLr_INVERSE STATIC_CUBE( \ + 7, 6, 4, 5, 2, 3, 1, 0, 6, 7, 4, 5, 2, 3, 0, 1, 26, 25, 24, 27) +#define TRANS_CUBE_DBr STATIC_CUBE( \ + 3, 2, 1, 0, 7, 6, 5, 4, 2, 3, 0, 1, 7, 6, 5, 4, 11, 10, 9, 8) +#define TRANS_CUBE_DBr_INVERSE STATIC_CUBE( \ + 3, 2, 1, 0, 7, 6, 5, 4, 2, 3, 0, 1, 7, 6, 5, 4, 11, 10, 9, 8) +#define TRANS_CUBE_DRr STATIC_CUBE( \ + 6, 7, 5, 4, 3, 2, 0, 1, 7, 6, 5, 4, 3, 2, 1, 0, 24, 27, 26, 25) +#define TRANS_CUBE_DRr_INVERSE STATIC_CUBE( \ + 6, 7, 5, 4, 3, 2, 0, 1, 7, 6, 5, 4, 3, 2, 1, 0, 24, 27, 26, 25) +#define TRANS_CUBE_RUr STATIC_CUBE( \ + 64, 67, 65, 66, 37, 38, 36, 39, 20, 23, 22, 21, 24, 27, 26, 25, 0, 1, 2, 3) +#define TRANS_CUBE_RUr_INVERSE STATIC_CUBE( \ + 32, 34, 35, 33, 70, 68, 69, 71, 8, 9, 10, 11, 16, 19, 18, 17, 20, 23, 22, 21) +#define TRANS_CUBE_RFr STATIC_CUBE( \ + 38, 37, 36, 39, 64, 67, 66, 65, 24, 27, 26, 25, 23, 20, 21, 22, 19, 16, 17, 18) +#define TRANS_CUBE_RFr_INVERSE STATIC_CUBE( \ + 36, 39, 38, 37, 66, 65, 64, 67, 25, 26, 27, 24, 21, 22, 23, 20, 16, 19, 18, 17) +#define TRANS_CUBE_RDr STATIC_CUBE( \ + 67, 64, 66, 65, 38, 37, 39, 36, 23, 20, 21, 22, 27, 24, 25, 26, 2, 3, 0, 1) +#define TRANS_CUBE_RDr_INVERSE STATIC_CUBE( \ + 33, 35, 34, 32, 71, 69, 68, 70, 10, 11, 8, 9, 17, 18, 19, 16, 21, 22, 23, 20) +#define TRANS_CUBE_RBr STATIC_CUBE( \ + 37, 38, 39, 36, 67, 64, 65, 66, 27, 24, 25, 26, 20, 23, 22, 21, 17, 18, 19, 16) +#define TRANS_CUBE_RBr_INVERSE STATIC_CUBE( \ + 37, 38, 39, 36, 67, 64, 65, 66, 27, 24, 25, 26, 20, 23, 22, 21, 17, 18, 19, 16) +#define TRANS_CUBE_LUr STATIC_CUBE( \ + 65, 66, 64, 67, 36, 39, 37, 38, 21, 22, 23, 20, 26, 25, 24, 27, 1, 0, 3, 2) +#define TRANS_CUBE_LUr_INVERSE STATIC_CUBE( \ + 34, 32, 33, 35, 68, 70, 71, 69, 9, 8, 11, 10, 19, 16, 17, 18, 22, 21, 20, 23) +#define TRANS_CUBE_LFr STATIC_CUBE( \ + 36, 39, 38, 37, 66, 65, 64, 67, 25, 26, 27, 24, 21, 22, 23, 20, 16, 19, 18, 17) +#define TRANS_CUBE_LFr_INVERSE STATIC_CUBE( \ + 38, 37, 36, 39, 64, 67, 66, 65, 24, 27, 26, 25, 23, 20, 21, 22, 19, 16, 17, 18) +#define TRANS_CUBE_LDr STATIC_CUBE( \ + 66, 65, 67, 64, 39, 36, 38, 37, 22, 21, 20, 23, 25, 26, 27, 24, 3, 2, 1, 0) +#define TRANS_CUBE_LDr_INVERSE STATIC_CUBE( \ + 35, 33, 32, 34, 69, 71, 70, 68, 11, 10, 9, 8, 18, 17, 16, 19, 23, 20, 21, 22) +#define TRANS_CUBE_LBr STATIC_CUBE( \ + 39, 36, 37, 38, 65, 66, 67, 64, 26, 25, 24, 27, 22, 21, 20, 23, 18, 17, 16, 19) +#define TRANS_CUBE_LBr_INVERSE STATIC_CUBE( \ + 39, 36, 37, 38, 65, 66, 67, 64, 26, 25, 24, 27, 22, 21, 20, 23, 18, 17, 16, 19) +#define TRANS_CUBE_FUr STATIC_CUBE( \ + 68, 70, 69, 71, 32, 34, 33, 35, 16, 19, 18, 17, 9, 8, 11, 10, 5, 4, 7, 6) +#define TRANS_CUBE_FUr_INVERSE STATIC_CUBE( \ + 68, 70, 69, 71, 32, 34, 33, 35, 16, 19, 18, 17, 9, 8, 11, 10, 5, 4, 7, 6) +#define TRANS_CUBE_FRr STATIC_CUBE( \ + 32, 34, 35, 33, 70, 68, 69, 71, 8, 9, 10, 11, 16, 19, 18, 17, 20, 23, 22, 21) +#define TRANS_CUBE_FRr_INVERSE STATIC_CUBE( \ + 64, 67, 65, 66, 37, 38, 36, 39, 20, 23, 22, 21, 24, 27, 26, 25, 0, 1, 2, 3) +#define TRANS_CUBE_FDr STATIC_CUBE( \ + 70, 68, 71, 69, 34, 32, 35, 33, 19, 16, 17, 18, 8, 9, 10, 11, 7, 6, 5, 4) +#define TRANS_CUBE_FDr_INVERSE STATIC_CUBE( \ + 69, 71, 68, 70, 33, 35, 32, 34, 17, 18, 19, 16, 11, 10, 9, 8, 4, 5, 6, 7) +#define TRANS_CUBE_FLr STATIC_CUBE( \ + 34, 32, 33, 35, 68, 70, 71, 69, 9, 8, 11, 10, 19, 16, 17, 18, 22, 21, 20, 23) +#define TRANS_CUBE_FLr_INVERSE STATIC_CUBE( \ + 65, 66, 64, 67, 36, 39, 37, 38, 21, 22, 23, 20, 26, 25, 24, 27, 1, 0, 3, 2) +#define TRANS_CUBE_BUr STATIC_CUBE( \ + 69, 71, 68, 70, 33, 35, 32, 34, 17, 18, 19, 16, 11, 10, 9, 8, 4, 5, 6, 7) +#define TRANS_CUBE_BUr_INVERSE STATIC_CUBE( \ + 70, 68, 71, 69, 34, 32, 35, 33, 19, 16, 17, 18, 8, 9, 10, 11, 7, 6, 5, 4) +#define TRANS_CUBE_BRr STATIC_CUBE( \ + 35, 33, 32, 34, 69, 71, 70, 68, 11, 10, 9, 8, 18, 17, 16, 19, 23, 20, 21, 22) +#define TRANS_CUBE_BRr_INVERSE STATIC_CUBE( \ + 66, 65, 67, 64, 39, 36, 38, 37, 22, 21, 20, 23, 25, 26, 27, 24, 3, 2, 1, 0) +#define TRANS_CUBE_BDr STATIC_CUBE( \ + 71, 69, 70, 68, 35, 33, 34, 32, 18, 17, 16, 19, 10, 11, 8, 9, 6, 7, 4, 5) +#define TRANS_CUBE_BDr_INVERSE STATIC_CUBE( \ + 71, 69, 70, 68, 35, 33, 34, 32, 18, 17, 16, 19, 10, 11, 8, 9, 6, 7, 4, 5) +#define TRANS_CUBE_BLr STATIC_CUBE( \ + 33, 35, 34, 32, 71, 69, 68, 70, 10, 11, 8, 9, 17, 18, 19, 16, 21, 22, 23, 20) +#define TRANS_CUBE_BLr_INVERSE STATIC_CUBE( \ + 67, 64, 66, 65, 38, 37, 39, 36, 23, 20, 21, 22, 27, 24, 25, 26, 2, 3, 0, 1) +#define TRANS_CUBE_UFm STATIC_CUBE( \ + 4, 5, 6, 7, 0, 1, 2, 3, 0, 1, 2, 3, 5, 4, 7, 6, 9, 8, 11, 10) +#define TRANS_CUBE_UFm_INVERSE STATIC_CUBE( \ + 4, 5, 6, 7, 0, 1, 2, 3, 0, 1, 2, 3, 5, 4, 7, 6, 9, 8, 11, 10) +#define TRANS_CUBE_ULm STATIC_CUBE( \ + 0, 1, 3, 2, 5, 4, 6, 7, 4, 5, 6, 7, 0, 1, 2, 3, 24, 27, 26, 25) +#define TRANS_CUBE_ULm_INVERSE STATIC_CUBE( \ + 0, 1, 3, 2, 5, 4, 6, 7, 4, 5, 6, 7, 0, 1, 2, 3, 24, 27, 26, 25) +#define TRANS_CUBE_UBm STATIC_CUBE( \ + 5, 4, 7, 6, 1, 0, 3, 2, 1, 0, 3, 2, 4, 5, 6, 7, 11, 10, 9, 8) +#define TRANS_CUBE_UBm_INVERSE STATIC_CUBE( \ + 5, 4, 7, 6, 1, 0, 3, 2, 1, 0, 3, 2, 4, 5, 6, 7, 11, 10, 9, 8) +#define TRANS_CUBE_URm STATIC_CUBE( \ + 1, 0, 2, 3, 4, 5, 7, 6, 5, 4, 7, 6, 1, 0, 3, 2, 26, 25, 24, 27) +#define TRANS_CUBE_URm_INVERSE STATIC_CUBE( \ + 1, 0, 2, 3, 4, 5, 7, 6, 5, 4, 7, 6, 1, 0, 3, 2, 26, 25, 24, 27) +#define TRANS_CUBE_DFm STATIC_CUBE( \ + 6, 7, 4, 5, 2, 3, 0, 1, 3, 2, 1, 0, 7, 6, 5, 4, 8, 9, 10, 11) +#define TRANS_CUBE_DFm_INVERSE STATIC_CUBE( \ + 6, 7, 4, 5, 2, 3, 0, 1, 3, 2, 1, 0, 7, 6, 5, 4, 8, 9, 10, 11) +#define TRANS_CUBE_DLm STATIC_CUBE( \ + 3, 2, 0, 1, 6, 7, 5, 4, 7, 6, 5, 4, 2, 3, 0, 1, 27, 24, 25, 26) +#define TRANS_CUBE_DLm_INVERSE STATIC_CUBE( \ + 2, 3, 1, 0, 7, 6, 4, 5, 6, 7, 4, 5, 3, 2, 1, 0, 25, 26, 27, 24) +#define TRANS_CUBE_DBm STATIC_CUBE( \ + 7, 6, 5, 4, 3, 2, 1, 0, 2, 3, 0, 1, 6, 7, 4, 5, 10, 11, 8, 9) +#define TRANS_CUBE_DBm_INVERSE STATIC_CUBE( \ + 7, 6, 5, 4, 3, 2, 1, 0, 2, 3, 0, 1, 6, 7, 4, 5, 10, 11, 8, 9) +#define TRANS_CUBE_DRm STATIC_CUBE( \ + 2, 3, 1, 0, 7, 6, 4, 5, 6, 7, 4, 5, 3, 2, 1, 0, 25, 26, 27, 24) +#define TRANS_CUBE_DRm_INVERSE STATIC_CUBE( \ + 3, 2, 0, 1, 6, 7, 5, 4, 7, 6, 5, 4, 2, 3, 0, 1, 27, 24, 25, 26) +#define TRANS_CUBE_RUm STATIC_CUBE( \ + 68, 71, 69, 70, 33, 34, 32, 35, 21, 22, 23, 20, 25, 26, 27, 24, 0, 1, 2, 3) +#define TRANS_CUBE_RUm_INVERSE STATIC_CUBE( \ + 70, 68, 69, 71, 32, 34, 35, 33, 8, 9, 10, 11, 19, 16, 17, 18, 23, 20, 21, 22) +#define TRANS_CUBE_RFm STATIC_CUBE( \ + 34, 33, 32, 35, 68, 71, 70, 69, 25, 26, 27, 24, 22, 21, 20, 23, 19, 16, 17, 18) +#define TRANS_CUBE_RFm_INVERSE STATIC_CUBE( \ + 66, 65, 64, 67, 36, 39, 38, 37, 25, 26, 27, 24, 22, 21, 20, 23, 19, 16, 17, 18) +#define TRANS_CUBE_RDm STATIC_CUBE( \ + 71, 68, 70, 69, 34, 33, 35, 32, 22, 21, 20, 23, 26, 25, 24, 27, 2, 3, 0, 1) +#define TRANS_CUBE_RDm_INVERSE STATIC_CUBE( \ + 71, 69, 68, 70, 33, 35, 34, 32, 10, 11, 8, 9, 18, 17, 16, 19, 22, 21, 20, 23) +#define TRANS_CUBE_RBm STATIC_CUBE( \ + 33, 34, 35, 32, 71, 68, 69, 70, 26, 25, 24, 27, 21, 22, 23, 20, 17, 18, 19, 16) +#define TRANS_CUBE_RBm_INVERSE STATIC_CUBE( \ + 67, 64, 65, 66, 37, 38, 39, 36, 27, 24, 25, 26, 23, 20, 21, 22, 18, 17, 16, 19) +#define TRANS_CUBE_LUm STATIC_CUBE( \ + 69, 70, 68, 71, 32, 35, 33, 34, 20, 23, 22, 21, 27, 24, 25, 26, 1, 0, 3, 2) +#define TRANS_CUBE_LUm_INVERSE STATIC_CUBE( \ + 68, 70, 71, 69, 34, 32, 33, 35, 9, 8, 11, 10, 16, 19, 18, 17, 21, 22, 23, 20) +#define TRANS_CUBE_LFm STATIC_CUBE( \ + 32, 35, 34, 33, 70, 69, 68, 71, 24, 27, 26, 25, 20, 23, 22, 21, 16, 19, 18, 17) +#define TRANS_CUBE_LFm_INVERSE STATIC_CUBE( \ + 64, 67, 66, 65, 38, 37, 36, 39, 24, 27, 26, 25, 20, 23, 22, 21, 16, 19, 18, 17) +#define TRANS_CUBE_LDm STATIC_CUBE( \ + 70, 69, 71, 68, 35, 32, 34, 33, 23, 20, 21, 22, 24, 27, 26, 25, 3, 2, 1, 0) +#define TRANS_CUBE_LDm_INVERSE STATIC_CUBE( \ + 69, 71, 70, 68, 35, 33, 32, 34, 11, 10, 9, 8, 17, 18, 19, 16, 20, 23, 22, 21) +#define TRANS_CUBE_LBm STATIC_CUBE( \ + 35, 32, 33, 34, 69, 70, 71, 68, 27, 24, 25, 26, 23, 20, 21, 22, 18, 17, 16, 19) +#define TRANS_CUBE_LBm_INVERSE STATIC_CUBE( \ + 65, 66, 67, 64, 39, 36, 37, 38, 26, 25, 24, 27, 21, 22, 23, 20, 17, 18, 19, 16) +#define TRANS_CUBE_FUm STATIC_CUBE( \ + 64, 66, 65, 67, 36, 38, 37, 39, 16, 19, 18, 17, 8, 9, 10, 11, 4, 5, 6, 7) +#define TRANS_CUBE_FUm_INVERSE STATIC_CUBE( \ + 32, 34, 33, 35, 68, 70, 69, 71, 16, 19, 18, 17, 8, 9, 10, 11, 4, 5, 6, 7) +#define TRANS_CUBE_FRm STATIC_CUBE( \ + 36, 38, 39, 37, 66, 64, 65, 67, 9, 8, 11, 10, 16, 19, 18, 17, 21, 22, 23, 20) +#define TRANS_CUBE_FRm_INVERSE STATIC_CUBE( \ + 37, 38, 36, 39, 64, 67, 65, 66, 20, 23, 22, 21, 27, 24, 25, 26, 1, 0, 3, 2) +#define TRANS_CUBE_FDm STATIC_CUBE( \ + 66, 64, 67, 65, 38, 36, 39, 37, 19, 16, 17, 18, 9, 8, 11, 10, 6, 7, 4, 5) +#define TRANS_CUBE_FDm_INVERSE STATIC_CUBE( \ + 33, 35, 32, 34, 69, 71, 68, 70, 17, 18, 19, 16, 10, 11, 8, 9, 5, 4, 7, 6) +#define TRANS_CUBE_FLm STATIC_CUBE( \ + 38, 36, 37, 39, 64, 66, 67, 65, 8, 9, 10, 11, 19, 16, 17, 18, 23, 20, 21, 22) +#define TRANS_CUBE_FLm_INVERSE STATIC_CUBE( \ + 36, 39, 37, 38, 65, 66, 64, 67, 21, 22, 23, 20, 25, 26, 27, 24, 0, 1, 2, 3) +#define TRANS_CUBE_BUm STATIC_CUBE( \ + 65, 67, 64, 66, 37, 39, 36, 38, 17, 18, 19, 16, 10, 11, 8, 9, 5, 4, 7, 6) +#define TRANS_CUBE_BUm_INVERSE STATIC_CUBE( \ + 34, 32, 35, 33, 70, 68, 71, 69, 19, 16, 17, 18, 9, 8, 11, 10, 6, 7, 4, 5) +#define TRANS_CUBE_BRm STATIC_CUBE( \ + 39, 37, 36, 38, 65, 67, 66, 64, 10, 11, 8, 9, 18, 17, 16, 19, 22, 21, 20, 23) +#define TRANS_CUBE_BRm_INVERSE STATIC_CUBE( \ + 39, 36, 38, 37, 66, 65, 67, 64, 22, 21, 20, 23, 26, 25, 24, 27, 2, 3, 0, 1) +#define TRANS_CUBE_BDm STATIC_CUBE( \ + 67, 65, 66, 64, 39, 37, 38, 36, 18, 17, 16, 19, 11, 10, 9, 8, 7, 6, 5, 4) +#define TRANS_CUBE_BDm_INVERSE STATIC_CUBE( \ + 35, 33, 34, 32, 71, 69, 70, 68, 18, 17, 16, 19, 11, 10, 9, 8, 7, 6, 5, 4) +#define TRANS_CUBE_BLm STATIC_CUBE( \ + 37, 39, 38, 36, 67, 65, 64, 66, 11, 10, 9, 8, 17, 18, 19, 16, 20, 23, 22, 21) +#define TRANS_CUBE_BLm_INVERSE STATIC_CUBE( \ + 38, 37, 39, 36, 67, 64, 66, 65, 23, 20, 21, 22, 24, 27, 26, 25, 3, 2, 1, 0) diff --git a/src/core/core.h b/src/core/core.h @@ -4,10 +4,4 @@ #include "cube.h" #include "io_cube.h" #include "moves.h" - -/* TODO: work in progress */ -#if 1 #include "transform.h" -#else -#include "transform_with_switch.h" -#endif diff --git a/src/core/cube.h b/src/core/cube.h @@ -1,6 +1,5 @@ STATIC cube_t solvecube(void); -STATIC_INLINE cube_t cubefromarray_ce(uint8_t [static 8], uint8_t [static 12]); -STATIC_INLINE cube_t cubefromarray_single(uint8_t [static 20]); +STATIC cube_t cubefromarray(uint8_t [static 8], uint8_t [static 12]); STATIC bool isconsistent(cube_t); STATIC bool issolvable(cube_t); STATIC bool issolved(cube_t); @@ -15,23 +14,15 @@ solvedcube(void) return SOLVED_CUBE; } -STATIC_INLINE cube_t -cubefromarray_ce(uint8_t c[static 8], uint8_t e[static 12]) +STATIC cube_t +cubefromarray(uint8_t c[static 8], uint8_t e[static 12]) { - return cubefrompieces( + return STATIC_CUBE( c[0], c[1], c[2], c[3], c[4], c[5], c[6], c[7], e[0], e[1], e[2], e[3], e[4], e[5], e[6], e[7], e[8], e[9], e[10], e[11]); } -STATIC_INLINE cube_t -cubefromarray_single(uint8_t p[static 20]) -{ - return cubefrompieces( - p[0], p[1], p[2], p[3], p[4], p[5], p[6], p[7], p[8], p[9], p[10], - p[11], p[12], p[13], p[14], p[15], p[16], p[17], p[18], p[19]); -} - STATIC bool isconsistent(cube_t cube) { @@ -187,5 +178,5 @@ getcube(int64_t ep, int64_t eo, int64_t cp, int64_t co) for (i = 0; i < 8; i++) carr[i] |= coarr[i] << COSHIFT; - return cubefromarray_ce(carr, earr); + return cubefromarray(carr, earr); } diff --git a/src/core/io_cube.h b/src/core/io_cube.h @@ -143,7 +143,7 @@ readcube_B32(const char *buf) "Error reading B32 edge %d (char %d)\n", i, i+9); } - return cubefromarray_ce(c, e); + return cubefromarray(c, e); } STATIC cube_t @@ -178,7 +178,7 @@ readcube_H48(const char *buf) c[i] = piece | orient; } - return cubefromarray_ce(c, e); + return cubefromarray(c, e); } STATIC uint8_t @@ -210,7 +210,7 @@ readcube_LST(const char *buf) for (i = 0; i < 12; i++) e[i] = readpiece_LST(&buf); - return cubefromarray_ce(c, e); + return cubefromarray(c, e); } STATIC int diff --git a/src/core/moves.h b/src/core/moves.h @@ -1,5 +1,5 @@ -#define MOVE(M, c) compose(c, cubefrompieces(MOVE_CUBE_ ## M)) -#define PREMOVE(M, c) compose(cubefrompieces(MOVE_CUBE_ ## M), c) +#define MOVE(M, c) compose(c, MOVE_CUBE_ ## M) +#define PREMOVE(M, c) compose(MOVE_CUBE_ ## M, c) STATIC_INLINE bool allowednextmove(uint8_t *, uint8_t); diff --git a/src/core/transform.h b/src/core/transform.h @@ -1,162 +1,343 @@ +#define TRANS_EDGES_ROTATION(T, c) \ + compose_edges(compose_edges(TRANS_CUBE_ ## T, c), \ + TRANS_CUBE_ ## T ## _INVERSE) +#define TRANS_EDGES_MIRRORED(T, c) TRANS_EDGES_ROTATION(T, c) + +#define TRANS_CORNERS_ROTATION(T, c) \ + compose_corners(compose_corners(TRANS_CUBE_ ## T, c), \ + TRANS_CUBE_ ## T ## _INVERSE) +#define TRANS_CORNERS_MIRRORED(T, c) \ + invertco(compose_corners( \ + compose_corners(TRANS_CUBE_ ## T, c), TRANS_CUBE_ ## T ## _INVERSE)) + +#define TRANS_ROTATION(T, c) \ + compose(compose(TRANS_CUBE_ ## T, c), \ + TRANS_CUBE_ ## T ## _INVERSE) +#define TRANS_MIRRORED(T, c) \ + invertco(compose(compose(TRANS_CUBE_ ## T, c), \ + TRANS_CUBE_ ## T ## _INVERSE)) + STATIC cube_t transform_edges(cube_t, uint8_t); STATIC cube_t transform_corners(cube_t, uint8_t); STATIC cube_t transform(cube_t, uint8_t); STATIC cube_t applytrans(cube_t, const char *); -static uint8_t cube_trans_table[48][20] = { - [TRANS_UFr] = { TRANS_CUBE_UFr }, - [TRANS_UFm] = { TRANS_CUBE_UFm }, - [TRANS_ULr] = { TRANS_CUBE_ULr }, - [TRANS_ULm] = { TRANS_CUBE_ULm }, - [TRANS_UBr] = { TRANS_CUBE_UBr }, - [TRANS_UBm] = { TRANS_CUBE_UBm }, - [TRANS_URr] = { TRANS_CUBE_URr }, - [TRANS_URm] = { TRANS_CUBE_URm }, - [TRANS_DFr] = { TRANS_CUBE_DFr }, - [TRANS_DFm] = { TRANS_CUBE_DFm }, - [TRANS_DLr] = { TRANS_CUBE_DLr }, - [TRANS_DLm] = { TRANS_CUBE_DLm }, - [TRANS_DBr] = { TRANS_CUBE_DBr }, - [TRANS_DBm] = { TRANS_CUBE_DBm }, - [TRANS_DRr] = { TRANS_CUBE_DRr }, - [TRANS_DRm] = { TRANS_CUBE_DRm }, - [TRANS_RUr] = { TRANS_CUBE_RUr }, - [TRANS_RUm] = { TRANS_CUBE_RUm }, - [TRANS_RFr] = { TRANS_CUBE_RFr }, - [TRANS_RFm] = { TRANS_CUBE_RFm }, - [TRANS_RDr] = { TRANS_CUBE_RDr }, - [TRANS_RDm] = { TRANS_CUBE_RDm }, - [TRANS_RBr] = { TRANS_CUBE_RBr }, - [TRANS_RBm] = { TRANS_CUBE_RBm }, - [TRANS_LUr] = { TRANS_CUBE_LUr }, - [TRANS_LUm] = { TRANS_CUBE_LUm }, - [TRANS_LFr] = { TRANS_CUBE_LFr }, - [TRANS_LFm] = { TRANS_CUBE_LFm }, - [TRANS_LDr] = { TRANS_CUBE_LDr }, - [TRANS_LDm] = { TRANS_CUBE_LDm }, - [TRANS_LBr] = { TRANS_CUBE_LBr }, - [TRANS_LBm] = { TRANS_CUBE_LBm }, - [TRANS_FUr] = { TRANS_CUBE_FUr }, - [TRANS_FUm] = { TRANS_CUBE_FUm }, - [TRANS_FRr] = { TRANS_CUBE_FRr }, - [TRANS_FRm] = { TRANS_CUBE_FRm }, - [TRANS_FDr] = { TRANS_CUBE_FDr }, - [TRANS_FDm] = { TRANS_CUBE_FDm }, - [TRANS_FLr] = { TRANS_CUBE_FLr }, - [TRANS_FLm] = { TRANS_CUBE_FLm }, - [TRANS_BUr] = { TRANS_CUBE_BUr }, - [TRANS_BUm] = { TRANS_CUBE_BUm }, - [TRANS_BRr] = { TRANS_CUBE_BRr }, - [TRANS_BRm] = { TRANS_CUBE_BRm }, - [TRANS_BDr] = { TRANS_CUBE_BDr }, - [TRANS_BDm] = { TRANS_CUBE_BDm }, - [TRANS_BLr] = { TRANS_CUBE_BLr }, - [TRANS_BLm] = { TRANS_CUBE_BLm }, -}; - -static uint8_t cube_trans_table_inverse[48][20] = { - [TRANS_UFr] = { TRANS_CUBE_UFr_INVERSE }, - [TRANS_UFm] = { TRANS_CUBE_UFm_INVERSE }, - [TRANS_ULr] = { TRANS_CUBE_ULr_INVERSE }, - [TRANS_ULm] = { TRANS_CUBE_ULm_INVERSE }, - [TRANS_UBr] = { TRANS_CUBE_UBr_INVERSE }, - [TRANS_UBm] = { TRANS_CUBE_UBm_INVERSE }, - [TRANS_URr] = { TRANS_CUBE_URr_INVERSE }, - [TRANS_URm] = { TRANS_CUBE_URm_INVERSE }, - [TRANS_DFr] = { TRANS_CUBE_DFr_INVERSE }, - [TRANS_DFm] = { TRANS_CUBE_DFm_INVERSE }, - [TRANS_DLr] = { TRANS_CUBE_DLr_INVERSE }, - [TRANS_DLm] = { TRANS_CUBE_DLm_INVERSE }, - [TRANS_DBr] = { TRANS_CUBE_DBr_INVERSE }, - [TRANS_DBm] = { TRANS_CUBE_DBm_INVERSE }, - [TRANS_DRr] = { TRANS_CUBE_DRr_INVERSE }, - [TRANS_DRm] = { TRANS_CUBE_DRm_INVERSE }, - [TRANS_RUr] = { TRANS_CUBE_RUr_INVERSE }, - [TRANS_RUm] = { TRANS_CUBE_RUm_INVERSE }, - [TRANS_RFr] = { TRANS_CUBE_RFr_INVERSE }, - [TRANS_RFm] = { TRANS_CUBE_RFm_INVERSE }, - [TRANS_RDr] = { TRANS_CUBE_RDr_INVERSE }, - [TRANS_RDm] = { TRANS_CUBE_RDm_INVERSE }, - [TRANS_RBr] = { TRANS_CUBE_RBr_INVERSE }, - [TRANS_RBm] = { TRANS_CUBE_RBm_INVERSE }, - [TRANS_LUr] = { TRANS_CUBE_LUr_INVERSE }, - [TRANS_LUm] = { TRANS_CUBE_LUm_INVERSE }, - [TRANS_LFr] = { TRANS_CUBE_LFr_INVERSE }, - [TRANS_LFm] = { TRANS_CUBE_LFm_INVERSE }, - [TRANS_LDr] = { TRANS_CUBE_LDr_INVERSE }, - [TRANS_LDm] = { TRANS_CUBE_LDm_INVERSE }, - [TRANS_LBr] = { TRANS_CUBE_LBr_INVERSE }, - [TRANS_LBm] = { TRANS_CUBE_LBm_INVERSE }, - [TRANS_FUr] = { TRANS_CUBE_FUr_INVERSE }, - [TRANS_FUm] = { TRANS_CUBE_FUm_INVERSE }, - [TRANS_FRr] = { TRANS_CUBE_FRr_INVERSE }, - [TRANS_FRm] = { TRANS_CUBE_FRm_INVERSE }, - [TRANS_FDr] = { TRANS_CUBE_FDr_INVERSE }, - [TRANS_FDm] = { TRANS_CUBE_FDm_INVERSE }, - [TRANS_FLr] = { TRANS_CUBE_FLr_INVERSE }, - [TRANS_FLm] = { TRANS_CUBE_FLm_INVERSE }, - [TRANS_BUr] = { TRANS_CUBE_BUr_INVERSE }, - [TRANS_BUm] = { TRANS_CUBE_BUm_INVERSE }, - [TRANS_BRr] = { TRANS_CUBE_BRr_INVERSE }, - [TRANS_BRm] = { TRANS_CUBE_BRm_INVERSE }, - [TRANS_BDr] = { TRANS_CUBE_BDr_INVERSE }, - [TRANS_BDm] = { TRANS_CUBE_BDm_INVERSE }, - [TRANS_BLr] = { TRANS_CUBE_BLr_INVERSE }, - [TRANS_BLm] = { TRANS_CUBE_BLm_INVERSE }, -}; - STATIC cube_t transform_edges(cube_t c, uint8_t t) { - cube_t ret, trans_cube, trans_inv; - - DBG_ASSERT(t < 48, ZERO_CUBE, - "transform: invalid transformation %" PRIu8 - ", must be between 0 and 47\n", t); - - trans_cube = cubefromarray_single(cube_trans_table[t]); - trans_inv = cubefromarray_single(cube_trans_table_inverse[t]); - - ret = compose_edges(trans_cube, c); - ret = compose_edges(ret, trans_inv); - - return ret; + switch (t) { + case TRANS_UFr: + return c; + case TRANS_ULr: + return TRANS_EDGES_ROTATION(ULr, c); + case TRANS_UBr: + return TRANS_EDGES_ROTATION(UBr, c); + case TRANS_URr: + return TRANS_EDGES_ROTATION(URr, c); + case TRANS_DFr: + return TRANS_EDGES_ROTATION(DFr, c); + case TRANS_DLr: + return TRANS_EDGES_ROTATION(DLr, c); + case TRANS_DBr: + return TRANS_EDGES_ROTATION(DBr, c); + case TRANS_DRr: + return TRANS_EDGES_ROTATION(DRr, c); + case TRANS_RUr: + return TRANS_EDGES_ROTATION(RUr, c); + case TRANS_RFr: + return TRANS_EDGES_ROTATION(RFr, c); + case TRANS_RDr: + return TRANS_EDGES_ROTATION(RDr, c); + case TRANS_RBr: + return TRANS_EDGES_ROTATION(RBr, c); + case TRANS_LUr: + return TRANS_EDGES_ROTATION(LUr, c); + case TRANS_LFr: + return TRANS_EDGES_ROTATION(LFr, c); + case TRANS_LDr: + return TRANS_EDGES_ROTATION(LDr, c); + case TRANS_LBr: + return TRANS_EDGES_ROTATION(LBr, c); + case TRANS_FUr: + return TRANS_EDGES_ROTATION(FUr, c); + case TRANS_FRr: + return TRANS_EDGES_ROTATION(FRr, c); + case TRANS_FDr: + return TRANS_EDGES_ROTATION(FDr, c); + case TRANS_FLr: + return TRANS_EDGES_ROTATION(FLr, c); + case TRANS_BUr: + return TRANS_EDGES_ROTATION(BUr, c); + case TRANS_BRr: + return TRANS_EDGES_ROTATION(BRr, c); + case TRANS_BDr: + return TRANS_EDGES_ROTATION(BDr, c); + case TRANS_BLr: + return TRANS_EDGES_ROTATION(BLr, c); + case TRANS_UFm: + return TRANS_EDGES_MIRRORED(UFm, c); + case TRANS_ULm: + return TRANS_EDGES_MIRRORED(ULm, c); + case TRANS_UBm: + return TRANS_EDGES_MIRRORED(UBm, c); + case TRANS_URm: + return TRANS_EDGES_MIRRORED(URm, c); + case TRANS_DFm: + return TRANS_EDGES_MIRRORED(DFm, c); + case TRANS_DLm: + return TRANS_EDGES_MIRRORED(DLm, c); + case TRANS_DBm: + return TRANS_EDGES_MIRRORED(DBm, c); + case TRANS_DRm: + return TRANS_EDGES_MIRRORED(DRm, c); + case TRANS_RUm: + return TRANS_EDGES_MIRRORED(RUm, c); + case TRANS_RFm: + return TRANS_EDGES_MIRRORED(RFm, c); + case TRANS_RDm: + return TRANS_EDGES_MIRRORED(RDm, c); + case TRANS_RBm: + return TRANS_EDGES_MIRRORED(RBm, c); + case TRANS_LUm: + return TRANS_EDGES_MIRRORED(LUm, c); + case TRANS_LFm: + return TRANS_EDGES_MIRRORED(LFm, c); + case TRANS_LDm: + return TRANS_EDGES_MIRRORED(LDm, c); + case TRANS_LBm: + return TRANS_EDGES_MIRRORED(LBm, c); + case TRANS_FUm: + return TRANS_EDGES_MIRRORED(FUm, c); + case TRANS_FRm: + return TRANS_EDGES_MIRRORED(FRm, c); + case TRANS_FDm: + return TRANS_EDGES_MIRRORED(FDm, c); + case TRANS_FLm: + return TRANS_EDGES_MIRRORED(FLm, c); + case TRANS_BUm: + return TRANS_EDGES_MIRRORED(BUm, c); + case TRANS_BRm: + return TRANS_EDGES_MIRRORED(BRm, c); + case TRANS_BDm: + return TRANS_EDGES_MIRRORED(BDm, c); + case TRANS_BLm: + return TRANS_EDGES_MIRRORED(BLm, c); + default: + LOG("transform error, unknown transformation %" PRIu8 "\n", t); + return ZERO_CUBE; + } } STATIC cube_t transform_corners(cube_t c, uint8_t t) { - cube_t ret, trans_cube, trans_inv; - - DBG_ASSERT(t < 48, ZERO_CUBE, - "transform: invalid transformation %" PRIu8 - ", must be between 0 and 47\n", t); - - trans_cube = cubefromarray_single(cube_trans_table[t]); - trans_inv = cubefromarray_single(cube_trans_table_inverse[t]); - - ret = compose_corners(trans_cube, c); - ret = compose_corners(ret, trans_inv); - - return t < 24 ? ret : invertco(ret); + switch (t) { + case TRANS_UFr: + return c; + case TRANS_ULr: + return TRANS_CORNERS_ROTATION(ULr, c); + case TRANS_UBr: + return TRANS_CORNERS_ROTATION(UBr, c); + case TRANS_URr: + return TRANS_CORNERS_ROTATION(URr, c); + case TRANS_DFr: + return TRANS_CORNERS_ROTATION(DFr, c); + case TRANS_DLr: + return TRANS_CORNERS_ROTATION(DLr, c); + case TRANS_DBr: + return TRANS_CORNERS_ROTATION(DBr, c); + case TRANS_DRr: + return TRANS_CORNERS_ROTATION(DRr, c); + case TRANS_RUr: + return TRANS_CORNERS_ROTATION(RUr, c); + case TRANS_RFr: + return TRANS_CORNERS_ROTATION(RFr, c); + case TRANS_RDr: + return TRANS_CORNERS_ROTATION(RDr, c); + case TRANS_RBr: + return TRANS_CORNERS_ROTATION(RBr, c); + case TRANS_LUr: + return TRANS_CORNERS_ROTATION(LUr, c); + case TRANS_LFr: + return TRANS_CORNERS_ROTATION(LFr, c); + case TRANS_LDr: + return TRANS_CORNERS_ROTATION(LDr, c); + case TRANS_LBr: + return TRANS_CORNERS_ROTATION(LBr, c); + case TRANS_FUr: + return TRANS_CORNERS_ROTATION(FUr, c); + case TRANS_FRr: + return TRANS_CORNERS_ROTATION(FRr, c); + case TRANS_FDr: + return TRANS_CORNERS_ROTATION(FDr, c); + case TRANS_FLr: + return TRANS_CORNERS_ROTATION(FLr, c); + case TRANS_BUr: + return TRANS_CORNERS_ROTATION(BUr, c); + case TRANS_BRr: + return TRANS_CORNERS_ROTATION(BRr, c); + case TRANS_BDr: + return TRANS_CORNERS_ROTATION(BDr, c); + case TRANS_BLr: + return TRANS_CORNERS_ROTATION(BLr, c); + case TRANS_UFm: + return TRANS_CORNERS_MIRRORED(UFm, c); + case TRANS_ULm: + return TRANS_CORNERS_MIRRORED(ULm, c); + case TRANS_UBm: + return TRANS_CORNERS_MIRRORED(UBm, c); + case TRANS_URm: + return TRANS_CORNERS_MIRRORED(URm, c); + case TRANS_DFm: + return TRANS_CORNERS_MIRRORED(DFm, c); + case TRANS_DLm: + return TRANS_CORNERS_MIRRORED(DLm, c); + case TRANS_DBm: + return TRANS_CORNERS_MIRRORED(DBm, c); + case TRANS_DRm: + return TRANS_CORNERS_MIRRORED(DRm, c); + case TRANS_RUm: + return TRANS_CORNERS_MIRRORED(RUm, c); + case TRANS_RFm: + return TRANS_CORNERS_MIRRORED(RFm, c); + case TRANS_RDm: + return TRANS_CORNERS_MIRRORED(RDm, c); + case TRANS_RBm: + return TRANS_CORNERS_MIRRORED(RBm, c); + case TRANS_LUm: + return TRANS_CORNERS_MIRRORED(LUm, c); + case TRANS_LFm: + return TRANS_CORNERS_MIRRORED(LFm, c); + case TRANS_LDm: + return TRANS_CORNERS_MIRRORED(LDm, c); + case TRANS_LBm: + return TRANS_CORNERS_MIRRORED(LBm, c); + case TRANS_FUm: + return TRANS_CORNERS_MIRRORED(FUm, c); + case TRANS_FRm: + return TRANS_CORNERS_MIRRORED(FRm, c); + case TRANS_FDm: + return TRANS_CORNERS_MIRRORED(FDm, c); + case TRANS_FLm: + return TRANS_CORNERS_MIRRORED(FLm, c); + case TRANS_BUm: + return TRANS_CORNERS_MIRRORED(BUm, c); + case TRANS_BRm: + return TRANS_CORNERS_MIRRORED(BRm, c); + case TRANS_BDm: + return TRANS_CORNERS_MIRRORED(BDm, c); + case TRANS_BLm: + return TRANS_CORNERS_MIRRORED(BLm, c); + default: + LOG("transform error, unknown transformation %" PRIu8 "\n", t); + return ZERO_CUBE; + } } STATIC cube_t transform(cube_t c, uint8_t t) { - cube_t ret, trans_cube, trans_inv; - - DBG_ASSERT(t < 48, ZERO_CUBE, - "transform: invalid transformation %" PRIu8 - ", must be between 0 and 47\n", t); - - trans_cube = cubefromarray_single(cube_trans_table[t]); - trans_inv = cubefromarray_single(cube_trans_table_inverse[t]); - - ret = compose(trans_cube, c); - ret = compose(ret, trans_inv); - - return t < 24 ? ret : invertco(ret); + switch (t) { + case TRANS_UFr: + return c; + case TRANS_ULr: + return TRANS_ROTATION(ULr, c); + case TRANS_UBr: + return TRANS_ROTATION(UBr, c); + case TRANS_URr: + return TRANS_ROTATION(URr, c); + case TRANS_DFr: + return TRANS_ROTATION(DFr, c); + case TRANS_DLr: + return TRANS_ROTATION(DLr, c); + case TRANS_DBr: + return TRANS_ROTATION(DBr, c); + case TRANS_DRr: + return TRANS_ROTATION(DRr, c); + case TRANS_RUr: + return TRANS_ROTATION(RUr, c); + case TRANS_RFr: + return TRANS_ROTATION(RFr, c); + case TRANS_RDr: + return TRANS_ROTATION(RDr, c); + case TRANS_RBr: + return TRANS_ROTATION(RBr, c); + case TRANS_LUr: + return TRANS_ROTATION(LUr, c); + case TRANS_LFr: + return TRANS_ROTATION(LFr, c); + case TRANS_LDr: + return TRANS_ROTATION(LDr, c); + case TRANS_LBr: + return TRANS_ROTATION(LBr, c); + case TRANS_FUr: + return TRANS_ROTATION(FUr, c); + case TRANS_FRr: + return TRANS_ROTATION(FRr, c); + case TRANS_FDr: + return TRANS_ROTATION(FDr, c); + case TRANS_FLr: + return TRANS_ROTATION(FLr, c); + case TRANS_BUr: + return TRANS_ROTATION(BUr, c); + case TRANS_BRr: + return TRANS_ROTATION(BRr, c); + case TRANS_BDr: + return TRANS_ROTATION(BDr, c); + case TRANS_BLr: + return TRANS_ROTATION(BLr, c); + case TRANS_UFm: + return TRANS_MIRRORED(UFm, c); + case TRANS_ULm: + return TRANS_MIRRORED(ULm, c); + case TRANS_UBm: + return TRANS_MIRRORED(UBm, c); + case TRANS_URm: + return TRANS_MIRRORED(URm, c); + case TRANS_DFm: + return TRANS_MIRRORED(DFm, c); + case TRANS_DLm: + return TRANS_MIRRORED(DLm, c); + case TRANS_DBm: + return TRANS_MIRRORED(DBm, c); + case TRANS_DRm: + return TRANS_MIRRORED(DRm, c); + case TRANS_RUm: + return TRANS_MIRRORED(RUm, c); + case TRANS_RFm: + return TRANS_MIRRORED(RFm, c); + case TRANS_RDm: + return TRANS_MIRRORED(RDm, c); + case TRANS_RBm: + return TRANS_MIRRORED(RBm, c); + case TRANS_LUm: + return TRANS_MIRRORED(LUm, c); + case TRANS_LFm: + return TRANS_MIRRORED(LFm, c); + case TRANS_LDm: + return TRANS_MIRRORED(LDm, c); + case TRANS_LBm: + return TRANS_MIRRORED(LBm, c); + case TRANS_FUm: + return TRANS_MIRRORED(FUm, c); + case TRANS_FRm: + return TRANS_MIRRORED(FRm, c); + case TRANS_FDm: + return TRANS_MIRRORED(FDm, c); + case TRANS_FLm: + return TRANS_MIRRORED(FLm, c); + case TRANS_BUm: + return TRANS_MIRRORED(BUm, c); + case TRANS_BRm: + return TRANS_MIRRORED(BRm, c); + case TRANS_BDm: + return TRANS_MIRRORED(BDm, c); + case TRANS_BLm: + return TRANS_MIRRORED(BLm, c); + default: + LOG("transform error, unknown transformation %" PRIu8 "\n", t); + return ZERO_CUBE; + } } STATIC cube_t diff --git a/src/core/transform_with_switch.h b/src/core/transform_with_switch.h @@ -1,354 +0,0 @@ -#define TRANS_EDGES_ROTATION(T, c) \ - compose_edges(compose_edges(TRANS_CUBE_ ## T, c), \ - TRANS_CUBE_ ## T ## _INVERSE) -#define TRANS_EDGES_MIRRORED(T, c) TRANS_EDGES_ROTATION(T, c) - -#define TRANS_CORNERS_ROTATION(T, c) \ - compose_corners(compose_corners(TRANS_CUBE_ ## T, c), \ - TRANS_CUBE_ ## T ## _INVERSE) -#define TRANS_CORNERS_MIRRORED(T, c) \ - invertco(compose_corners( \ - compose_corners(TRANS_CUBE_ ## T, c), TRANS_CUBE_ ## T ## _INVERSE)) - -#define TRANS_ROTATION(T, c) \ - compose(compose(TRANS_CUBE_ ## T, c), \ - TRANS_CUBE_ ## T ## _INVERSE) -#define TRANS_MIRRORED(T, c) \ - invertco(compose(compose(TRANS_CUBE_ ## T, c), \ - TRANS_CUBE_ ## T ## _INVERSE)) - -STATIC cube_t transform_edges(cube_t, uint8_t); -STATIC cube_t transform_corners(cube_t, uint8_t); -STATIC cube_t transform(cube_t, uint8_t); -STATIC cube_t applytrans(cube_t, const char *); - -STATIC cube_t -transform_edges(cube_t c, uint8_t t) -{ - switch (t) { - case TRANS_UFr: - return c; - case TRANS_ULr: - return TRANS_EDGES_ROTATION(ULr, c); - case TRANS_UBr: - return TRANS_EDGES_ROTATION(UBr, c); - case TRANS_URr: - return TRANS_EDGES_ROTATION(URr, c); - case TRANS_DFr: - return TRANS_EDGES_ROTATION(DFr, c); - case TRANS_DLr: - return TRANS_EDGES_ROTATION(DLr, c); - case TRANS_DBr: - return TRANS_EDGES_ROTATION(DBr, c); - case TRANS_DRr: - return TRANS_EDGES_ROTATION(DRr, c); - case TRANS_RUr: - return TRANS_EDGES_ROTATION(RUr, c); - case TRANS_RFr: - return TRANS_EDGES_ROTATION(RFr, c); - case TRANS_RDr: - return TRANS_EDGES_ROTATION(RDr, c); - case TRANS_RBr: - return TRANS_EDGES_ROTATION(RBr, c); - case TRANS_LUr: - return TRANS_EDGES_ROTATION(LUr, c); - case TRANS_LFr: - return TRANS_EDGES_ROTATION(LFr, c); - case TRANS_LDr: - return TRANS_EDGES_ROTATION(LDr, c); - case TRANS_LBr: - return TRANS_EDGES_ROTATION(LBr, c); - case TRANS_FUr: - return TRANS_EDGES_ROTATION(FUr, c); - case TRANS_FRr: - return TRANS_EDGES_ROTATION(FRr, c); - case TRANS_FDr: - return TRANS_EDGES_ROTATION(FDr, c); - case TRANS_FLr: - return TRANS_EDGES_ROTATION(FLr, c); - case TRANS_BUr: - return TRANS_EDGES_ROTATION(BUr, c); - case TRANS_BRr: - return TRANS_EDGES_ROTATION(BRr, c); - case TRANS_BDr: - return TRANS_EDGES_ROTATION(BDr, c); - case TRANS_BLr: - return TRANS_EDGES_ROTATION(BLr, c); - case TRANS_UFm: - return TRANS_EDGES_MIRRORED(UFm, c); - case TRANS_ULm: - return TRANS_EDGES_MIRRORED(ULm, c); - case TRANS_UBm: - return TRANS_EDGES_MIRRORED(UBm, c); - case TRANS_URm: - return TRANS_EDGES_MIRRORED(URm, c); - case TRANS_DFm: - return TRANS_EDGES_MIRRORED(DFm, c); - case TRANS_DLm: - return TRANS_EDGES_MIRRORED(DLm, c); - case TRANS_DBm: - return TRANS_EDGES_MIRRORED(DBm, c); - case TRANS_DRm: - return TRANS_EDGES_MIRRORED(DRm, c); - case TRANS_RUm: - return TRANS_EDGES_MIRRORED(RUm, c); - case TRANS_RFm: - return TRANS_EDGES_MIRRORED(RFm, c); - case TRANS_RDm: - return TRANS_EDGES_MIRRORED(RDm, c); - case TRANS_RBm: - return TRANS_EDGES_MIRRORED(RBm, c); - case TRANS_LUm: - return TRANS_EDGES_MIRRORED(LUm, c); - case TRANS_LFm: - return TRANS_EDGES_MIRRORED(LFm, c); - case TRANS_LDm: - return TRANS_EDGES_MIRRORED(LDm, c); - case TRANS_LBm: - return TRANS_EDGES_MIRRORED(LBm, c); - case TRANS_FUm: - return TRANS_EDGES_MIRRORED(FUm, c); - case TRANS_FRm: - return TRANS_EDGES_MIRRORED(FRm, c); - case TRANS_FDm: - return TRANS_EDGES_MIRRORED(FDm, c); - case TRANS_FLm: - return TRANS_EDGES_MIRRORED(FLm, c); - case TRANS_BUm: - return TRANS_EDGES_MIRRORED(BUm, c); - case TRANS_BRm: - return TRANS_EDGES_MIRRORED(BRm, c); - case TRANS_BDm: - return TRANS_EDGES_MIRRORED(BDm, c); - case TRANS_BLm: - return TRANS_EDGES_MIRRORED(BLm, c); - default: - LOG("transform error, unknown transformation %" PRIu8 "\n", t); - return ZERO_CUBE; - } -} - -STATIC cube_t -transform_corners(cube_t c, uint8_t t) -{ - switch (t) { - case TRANS_UFr: - return c; - case TRANS_ULr: - return TRANS_CORNERS_ROTATION(ULr, c); - case TRANS_UBr: - return TRANS_CORNERS_ROTATION(UBr, c); - case TRANS_URr: - return TRANS_CORNERS_ROTATION(URr, c); - case TRANS_DFr: - return TRANS_CORNERS_ROTATION(DFr, c); - case TRANS_DLr: - return TRANS_CORNERS_ROTATION(DLr, c); - case TRANS_DBr: - return TRANS_CORNERS_ROTATION(DBr, c); - case TRANS_DRr: - return TRANS_CORNERS_ROTATION(DRr, c); - case TRANS_RUr: - return TRANS_CORNERS_ROTATION(RUr, c); - case TRANS_RFr: - return TRANS_CORNERS_ROTATION(RFr, c); - case TRANS_RDr: - return TRANS_CORNERS_ROTATION(RDr, c); - case TRANS_RBr: - return TRANS_CORNERS_ROTATION(RBr, c); - case TRANS_LUr: - return TRANS_CORNERS_ROTATION(LUr, c); - case TRANS_LFr: - return TRANS_CORNERS_ROTATION(LFr, c); - case TRANS_LDr: - return TRANS_CORNERS_ROTATION(LDr, c); - case TRANS_LBr: - return TRANS_CORNERS_ROTATION(LBr, c); - case TRANS_FUr: - return TRANS_CORNERS_ROTATION(FUr, c); - case TRANS_FRr: - return TRANS_CORNERS_ROTATION(FRr, c); - case TRANS_FDr: - return TRANS_CORNERS_ROTATION(FDr, c); - case TRANS_FLr: - return TRANS_CORNERS_ROTATION(FLr, c); - case TRANS_BUr: - return TRANS_CORNERS_ROTATION(BUr, c); - case TRANS_BRr: - return TRANS_CORNERS_ROTATION(BRr, c); - case TRANS_BDr: - return TRANS_CORNERS_ROTATION(BDr, c); - case TRANS_BLr: - return TRANS_CORNERS_ROTATION(BLr, c); - case TRANS_UFm: - return TRANS_CORNERS_MIRRORED(UFm, c); - case TRANS_ULm: - return TRANS_CORNERS_MIRRORED(ULm, c); - case TRANS_UBm: - return TRANS_CORNERS_MIRRORED(UBm, c); - case TRANS_URm: - return TRANS_CORNERS_MIRRORED(URm, c); - case TRANS_DFm: - return TRANS_CORNERS_MIRRORED(DFm, c); - case TRANS_DLm: - return TRANS_CORNERS_MIRRORED(DLm, c); - case TRANS_DBm: - return TRANS_CORNERS_MIRRORED(DBm, c); - case TRANS_DRm: - return TRANS_CORNERS_MIRRORED(DRm, c); - case TRANS_RUm: - return TRANS_CORNERS_MIRRORED(RUm, c); - case TRANS_RFm: - return TRANS_CORNERS_MIRRORED(RFm, c); - case TRANS_RDm: - return TRANS_CORNERS_MIRRORED(RDm, c); - case TRANS_RBm: - return TRANS_CORNERS_MIRRORED(RBm, c); - case TRANS_LUm: - return TRANS_CORNERS_MIRRORED(LUm, c); - case TRANS_LFm: - return TRANS_CORNERS_MIRRORED(LFm, c); - case TRANS_LDm: - return TRANS_CORNERS_MIRRORED(LDm, c); - case TRANS_LBm: - return TRANS_CORNERS_MIRRORED(LBm, c); - case TRANS_FUm: - return TRANS_CORNERS_MIRRORED(FUm, c); - case TRANS_FRm: - return TRANS_CORNERS_MIRRORED(FRm, c); - case TRANS_FDm: - return TRANS_CORNERS_MIRRORED(FDm, c); - case TRANS_FLm: - return TRANS_CORNERS_MIRRORED(FLm, c); - case TRANS_BUm: - return TRANS_CORNERS_MIRRORED(BUm, c); - case TRANS_BRm: - return TRANS_CORNERS_MIRRORED(BRm, c); - case TRANS_BDm: - return TRANS_CORNERS_MIRRORED(BDm, c); - case TRANS_BLm: - return TRANS_CORNERS_MIRRORED(BLm, c); - default: - LOG("transform error, unknown transformation %" PRIu8 "\n", t); - return ZERO_CUBE; - } -} - -STATIC cube_t -transform(cube_t c, uint8_t t) -{ - switch (t) { - case TRANS_UFr: - return c; - case TRANS_ULr: - return TRANS_ROTATION(ULr, c); - case TRANS_UBr: - return TRANS_ROTATION(UBr, c); - case TRANS_URr: - return TRANS_ROTATION(URr, c); - case TRANS_DFr: - return TRANS_ROTATION(DFr, c); - case TRANS_DLr: - return TRANS_ROTATION(DLr, c); - case TRANS_DBr: - return TRANS_ROTATION(DBr, c); - case TRANS_DRr: - return TRANS_ROTATION(DRr, c); - case TRANS_RUr: - return TRANS_ROTATION(RUr, c); - case TRANS_RFr: - return TRANS_ROTATION(RFr, c); - case TRANS_RDr: - return TRANS_ROTATION(RDr, c); - case TRANS_RBr: - return TRANS_ROTATION(RBr, c); - case TRANS_LUr: - return TRANS_ROTATION(LUr, c); - case TRANS_LFr: - return TRANS_ROTATION(LFr, c); - case TRANS_LDr: - return TRANS_ROTATION(LDr, c); - case TRANS_LBr: - return TRANS_ROTATION(LBr, c); - case TRANS_FUr: - return TRANS_ROTATION(FUr, c); - case TRANS_FRr: - return TRANS_ROTATION(FRr, c); - case TRANS_FDr: - return TRANS_ROTATION(FDr, c); - case TRANS_FLr: - return TRANS_ROTATION(FLr, c); - case TRANS_BUr: - return TRANS_ROTATION(BUr, c); - case TRANS_BRr: - return TRANS_ROTATION(BRr, c); - case TRANS_BDr: - return TRANS_ROTATION(BDr, c); - case TRANS_BLr: - return TRANS_ROTATION(BLr, c); - case TRANS_UFm: - return TRANS_MIRRORED(UFm, c); - case TRANS_ULm: - return TRANS_MIRRORED(ULm, c); - case TRANS_UBm: - return TRANS_MIRRORED(UBm, c); - case TRANS_URm: - return TRANS_MIRRORED(URm, c); - case TRANS_DFm: - return TRANS_MIRRORED(DFm, c); - case TRANS_DLm: - return TRANS_MIRRORED(DLm, c); - case TRANS_DBm: - return TRANS_MIRRORED(DBm, c); - case TRANS_DRm: - return TRANS_MIRRORED(DRm, c); - case TRANS_RUm: - return TRANS_MIRRORED(RUm, c); - case TRANS_RFm: - return TRANS_MIRRORED(RFm, c); - case TRANS_RDm: - return TRANS_MIRRORED(RDm, c); - case TRANS_RBm: - return TRANS_MIRRORED(RBm, c); - case TRANS_LUm: - return TRANS_MIRRORED(LUm, c); - case TRANS_LFm: - return TRANS_MIRRORED(LFm, c); - case TRANS_LDm: - return TRANS_MIRRORED(LDm, c); - case TRANS_LBm: - return TRANS_MIRRORED(LBm, c); - case TRANS_FUm: - return TRANS_MIRRORED(FUm, c); - case TRANS_FRm: - return TRANS_MIRRORED(FRm, c); - case TRANS_FDm: - return TRANS_MIRRORED(FDm, c); - case TRANS_FLm: - return TRANS_MIRRORED(FLm, c); - case TRANS_BUm: - return TRANS_MIRRORED(BUm, c); - case TRANS_BRm: - return TRANS_MIRRORED(BRm, c); - case TRANS_BDm: - return TRANS_MIRRORED(BDm, c); - case TRANS_BLm: - return TRANS_MIRRORED(BLm, c); - default: - LOG("transform error, unknown transformation %" PRIu8 "\n", t); - return ZERO_CUBE; - } -} - -STATIC cube_t -applytrans(cube_t cube, const char *buf) -{ - uint8_t t; - - DBG_ASSERT(isconsistent(cube), ZERO_CUBE, - "transformation error: inconsistent cube\n"); - - t = readtrans(buf); - - return transform(cube, t); -}