diff options
| author | Sebastiano Tronto <sebastiano@tronto.net> | 2024-10-04 12:01:41 +0200 |
|---|---|---|
| committer | Sebastiano Tronto <sebastiano@tronto.net> | 2024-10-04 12:01:41 +0200 |
| commit | 80b065f757240af7920862b3e09f32a6dc06d392 (patch) | |
| tree | c0223ba1f0a3254305f59637b3fb25bd58698cf8 /src/arch/portable.h | |
| parent | fd111a1a51b8293f79db6284331af50824df92b9 (diff) | |
| download | nissy-core-80b065f757240af7920862b3e09f32a6dc06d392.tar.gz nissy-core-80b065f757240af7920862b3e09f32a6dc06d392.zip | |
Table-based transformations (will revert immediately)
This commit changes transformations to being based on a lookup
table intead of a big switch. This is something I had planned for a long
time and the code is nicer with this change. But unfortunately the performance
is noticeably worse, so I'll revert all these changes in the next commit.
I wanted to push this anyway so we can keep track of this.
Diffstat (limited to '')
| -rw-r--r-- | src/arch/portable.h | 49 |
1 files changed, 38 insertions, 11 deletions
diff --git a/src/arch/portable.h b/src/arch/portable.h index e9a8dd0..3776c90 100644 --- a/src/arch/portable.h +++ b/src/arch/portable.h | |||
| @@ -1,14 +1,3 @@ | |||
| 1 | #define STATIC_CUBE(c_ufr, c_ubl, c_dfl, c_dbr, c_ufl, c_ubr, c_dfr, c_dbl, \ | ||
| 2 | e_uf, e_ub, e_db, e_df, e_ur, e_ul, e_dl, e_dr, e_fr, e_fl, e_bl, e_br) \ | ||
| 3 | ((cube_t) { \ | ||
| 4 | .corner = { c_ufr, c_ubl, c_dfl, c_dbr, c_ufl, c_ubr, c_dfr, c_dbl }, \ | ||
| 5 | .edge = { e_uf, e_ub, e_db, e_df, e_ur, e_ul, \ | ||
| 6 | e_dl, e_dr, e_fr, e_fl, e_bl, e_br } }) | ||
| 7 | #define ZERO_CUBE STATIC_CUBE( \ | ||
| 8 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) | ||
| 9 | #define SOLVED_CUBE STATIC_CUBE( \ | ||
| 10 | 0, 1, 2, 3, 4, 5, 6, 7, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11) | ||
| 11 | |||
| 12 | STATIC void | 1 | STATIC void |
| 13 | pieces(cube_t *cube, uint8_t c[static 8], uint8_t e[static 12]) | 2 | pieces(cube_t *cube, uint8_t c[static 8], uint8_t e[static 12]) |
| 14 | { | 3 | { |
| @@ -16,6 +5,44 @@ pieces(cube_t *cube, uint8_t c[static 8], uint8_t e[static 12]) | |||
| 16 | memcpy(e, cube->edge, 12); | 5 | memcpy(e, cube->edge, 12); |
| 17 | } | 6 | } |
| 18 | 7 | ||
| 8 | STATIC_INLINE cube_t | ||
| 9 | cubefrompieces( | ||
| 10 | uint8_t c_ufr, | ||
| 11 | uint8_t c_ubl, | ||
| 12 | uint8_t c_dfl, | ||
| 13 | uint8_t c_dbr, | ||
| 14 | uint8_t c_ufl, | ||
| 15 | uint8_t c_ubr, | ||
| 16 | uint8_t c_dfr, | ||
| 17 | uint8_t c_dbl, | ||
| 18 | |||
| 19 | uint8_t e_uf, | ||
| 20 | uint8_t e_ub, | ||
| 21 | uint8_t e_db, | ||
| 22 | uint8_t e_df, | ||
| 23 | uint8_t e_ur, | ||
| 24 | uint8_t e_ul, | ||
| 25 | uint8_t e_dl, | ||
| 26 | uint8_t e_dr, | ||
| 27 | uint8_t e_fr, | ||
| 28 | uint8_t e_fl, | ||
| 29 | uint8_t e_bl, | ||
| 30 | uint8_t e_br | ||
| 31 | ) { | ||
| 32 | cube_t ret = { | ||
| 33 | .corner = { | ||
| 34 | 0, 0, 0, 0, 0, 0, 0, 0, | ||
| 35 | c_dbl, c_dfr, c_ubr, c_ufl, c_dbr, c_dfl, c_ubl, c_ufr | ||
| 36 | }, | ||
| 37 | .edge = { | ||
| 38 | 0, 0, 0, 0, e_br, e_bl, e_fl, e_fr, | ||
| 39 | e_dr, e_dl, e_ul, e_ur, e_df, e_db, e_ub, e_uf | ||
| 40 | } | ||
| 41 | }; | ||
| 42 | |||
| 43 | return ret; | ||
| 44 | } | ||
| 45 | |||
| 19 | STATIC_INLINE bool | 46 | STATIC_INLINE bool |
| 20 | equal(cube_t c1, cube_t c2) | 47 | equal(cube_t c1, cube_t c2) |
| 21 | { | 48 | { |
