aboutsummaryrefslogtreecommitdiff
path: root/src/arch/portable.h
diff options
context:
space:
mode:
authorSebastiano Tronto <sebastiano@tronto.net>2024-10-04 12:01:41 +0200
committerSebastiano Tronto <sebastiano@tronto.net>2024-10-04 12:01:41 +0200
commit80b065f757240af7920862b3e09f32a6dc06d392 (patch)
treec0223ba1f0a3254305f59637b3fb25bd58698cf8 /src/arch/portable.h
parentfd111a1a51b8293f79db6284331af50824df92b9 (diff)
downloadnissy-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 'src/arch/portable.h')
-rw-r--r--src/arch/portable.h49
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
12STATIC void 1STATIC void
13pieces(cube_t *cube, uint8_t c[static 8], uint8_t e[static 12]) 2pieces(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
8STATIC_INLINE cube_t
9cubefrompieces(
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
19STATIC_INLINE bool 46STATIC_INLINE bool
20equal(cube_t c1, cube_t c2) 47equal(cube_t c1, cube_t c2)
21{ 48{

Generated with cgit - Back to sebastiano.tronto.net