aboutsummaryrefslogtreecommitdiff
path: root/old/moves_trans
diff options
context:
space:
mode:
authorSebastiano Tronto <sebastiano@tronto.net>2023-11-17 19:14:26 +0100
committerSebastiano Tronto <sebastiano@tronto.net>2023-11-17 19:14:26 +0100
commitd6fdf14d5c320bdca455f910d58d652c5a7827da (patch)
tree15642a013e719e81526cf02b6656ce22adb8a3cf /old/moves_trans
parenta26ae103faf8fa53b65f7757fb8b4255a37fcd22 (diff)
downloadnissy-core-d6fdf14d5c320bdca455f910d58d652c5a7827da.tar.gz
nissy-core-d6fdf14d5c320bdca455f910d58d652c5a7827da.zip
Simplified move and transform code
Diffstat (limited to 'old/moves_trans')
-rwxr-xr-xold/moves_trans/genmovecode.sh19
-rwxr-xr-xold/moves_trans/gentranscode.sh42
-rw-r--r--old/moves_trans/moves_src.c264
3 files changed, 325 insertions, 0 deletions
diff --git a/old/moves_trans/genmovecode.sh b/old/moves_trans/genmovecode.sh
new file mode 100755
index 0000000..0857f31
--- /dev/null
+++ b/old/moves_trans/genmovecode.sh
@@ -0,0 +1,19 @@
1#!/bin/sh
2
3type="${1:-src}"
4
5gcc -DDEBUG h48_to_"$type".c ../cube.c -o h48_to_"$type"
6
7genfuncs() {
8 for f in move_??_*.txt; do
9 move="$(echo $f | sed 's/.*_// ; s/\.txt//')"
10 printf 'static inline cube_fast_t\n_move_%s' "$move"
11 printf '(cube_fast_t c)\n{\n'
12 printf '\tcube_fast_t m = '
13 ./h48_to_"$type" <"$f" | sed '2,4s/^/\t/'
14 printf ';\n\n\treturn compose_fast(c, m);\n}\n\n'
15 done
16}
17
18genfuncs
19rm -f h48_to_"$type" invert
diff --git a/old/moves_trans/gentranscode.sh b/old/moves_trans/gentranscode.sh
new file mode 100755
index 0000000..198ac93
--- /dev/null
+++ b/old/moves_trans/gentranscode.sh
@@ -0,0 +1,42 @@
1#!/bin/sh
2
3type="${1:-src}"
4
5gcc -DDEBUG h48_to_"$type".c ../cube.c -o h48_to_"$type"
6gcc -DDEBUG invert.c ../cube.c -o invert
7
8# Old version
9genarray() {
10 for f in transform_??_???.txt; do
11 trans="$(echo $f | sed 's/.*_// ; s/\.txt//')"
12 printf '[%s] = ' "$trans"
13 if [ "$1" = "-i" ]; then
14 ./invert <"$f" | ./h48_to_"$type"
15 else
16 ./h48_to_"$type" <"$f"
17 fi
18 printf ',\n'
19 done
20}
21
22genfuncs() {
23 for f in transform_??_???.txt; do
24 trans="$(echo $f | sed 's/.*_// ; s/\.txt//')"
25 printf 'static inline cube_fast_t\n_trans_%s' "$trans"
26 printf '(cube_fast_t c)\n{\n'
27 printf '\tcube_fast_t ret;\n\n'
28 printf '\tcube_fast_t tn = '
29 ./h48_to_"$type" <"$f" | sed '2,4s/^/\t/'
30 printf ';\n\tcube_fast_t ti = '
31 ./invert <"$f" | ./h48_to_"$type" | sed '2,4 s/^/\t/'
32 printf ';\n\n\tret = compose_fast(tn, c);\n'
33 printf '\tret = compose_fast(ret, ti);\n'
34 if [ -n "$(echo "$trans" | grep "m")" ]; then
35 printf '\tret = invertco_fast(ret);\n'
36 fi
37 printf '\n\treturn ret;\n}\n\n'
38 done
39}
40
41genfuncs
42rm -f h48_to_"$type" invert
diff --git a/old/moves_trans/moves_src.c b/old/moves_trans/moves_src.c
new file mode 100644
index 0000000..faf4729
--- /dev/null
+++ b/old/moves_trans/moves_src.c
@@ -0,0 +1,264 @@
1#define PERM4(r, i, j, k, l) \
2 aux = r[i]; \
3 r[i] = r[l]; \
4 r[l] = r[k]; \
5 r[k] = r[j]; \
6 r[j] = aux;
7#define PERM22(r, i, j, k, l) \
8 aux = r[i]; \
9 r[i] = r[j]; \
10 r[j] = aux; \
11 aux = r[k]; \
12 r[k] = r[l]; \
13 r[l] = aux;
14#define CO(a, b) \
15 aux = (a & _cobits) + (b & _cobits); \
16 auy = (aux + _ctwist_cw) >> 2U; \
17 auz = (aux + auy) & _cobits2; \
18 a = (a & _pbits) | auz;
19#define CO4(r, i, j, k, l) \
20 CO(r[i], _ctwist_cw) \
21 CO(r[j], _ctwist_cw) \
22 CO(r[k], _ctwist_ccw) \
23 CO(r[l], _ctwist_ccw)
24#define EO4(r, i, j, k, l) \
25 r[i] ^= _eobit; \
26 r[j] ^= _eobit; \
27 r[k] ^= _eobit; \
28 r[l] ^= _eobit;
29
30_static_inline cube_fast_t
31_move_U(cube_fast_t c)
32{
33 uint8_t aux;
34 cube_fast_t ret = c;
35
36 PERM4(ret.edge, _e_uf, _e_ul, _e_ub, _e_ur)
37 PERM4(ret.corner, _c_ufr, _c_ufl, _c_ubl, _c_ubr)
38
39 return ret;
40}
41
42_static_inline cube_fast_t
43_move_U2(cube_fast_t c)
44{
45 uint8_t aux;
46 cube_fast_t ret = c;
47
48 PERM22(ret.edge, _e_uf, _e_ub, _e_ul, _e_ur)
49 PERM22(ret.corner, _c_ufr, _c_ubl, _c_ufl, _c_ubr)
50
51 return ret;
52}
53
54_static_inline cube_fast_t
55_move_U3(cube_fast_t c)
56{
57 uint8_t aux;
58 cube_fast_t ret = c;
59
60 PERM4(ret.edge, _e_uf, _e_ur, _e_ub, _e_ul)
61 PERM4(ret.corner, _c_ufr, _c_ubr, _c_ubl, _c_ufl)
62
63 return ret;
64}
65
66_static_inline cube_fast_t
67_move_D(cube_fast_t c)
68{
69 uint8_t aux;
70 cube_fast_t ret = c;
71
72 PERM4(ret.edge, _e_df, _e_dr, _e_db, _e_dl)
73 PERM4(ret.corner, _c_dfr, _c_dbr, _c_dbl, _c_dfl)
74
75 return ret;
76}
77
78_static_inline cube_fast_t
79_move_D2(cube_fast_t c)
80{
81 uint8_t aux;
82 cube_fast_t ret = c;
83
84 PERM22(ret.edge, _e_df, _e_db, _e_dr, _e_dl)
85 PERM22(ret.corner, _c_dfr, _c_dbl, _c_dbr, _c_dfl)
86
87 return ret;
88}
89
90_static_inline cube_fast_t
91_move_D3(cube_fast_t c)
92{
93 uint8_t aux;
94 cube_fast_t ret = c;
95
96 PERM4(ret.edge, _e_df, _e_dl, _e_db, _e_dr)
97 PERM4(ret.corner, _c_dfr, _c_dfl, _c_dbl, _c_dbr)
98
99 return ret;
100}
101
102_static_inline cube_fast_t
103_move_R(cube_fast_t c)
104{
105 uint8_t aux, auy, auz;
106 cube_fast_t ret = c;
107
108 PERM4(ret.edge, _e_ur, _e_br, _e_dr, _e_fr)
109 PERM4(ret.corner, _c_ufr, _c_ubr, _c_dbr, _c_dfr)
110
111 CO4(ret.corner, _c_ubr, _c_dfr, _c_ufr, _c_dbr)
112
113 return ret;
114}
115
116_static_inline cube_fast_t
117_move_R2(cube_fast_t c)
118{
119 uint8_t aux;
120 cube_fast_t ret = c;
121
122 PERM22(ret.edge, _e_ur, _e_dr, _e_fr, _e_br)
123 PERM22(ret.corner, _c_ufr, _c_dbr, _c_ubr, _c_dfr)
124
125 return ret;
126}
127
128_static_inline cube_fast_t
129_move_R3(cube_fast_t c)
130{
131 uint8_t aux, auy, auz;
132 cube_fast_t ret = c;
133
134 PERM4(ret.edge, _e_ur, _e_fr, _e_dr, _e_br)
135 PERM4(ret.corner, _c_ufr, _c_dfr, _c_dbr, _c_ubr)
136
137 CO4(ret.corner, _c_ubr, _c_dfr, _c_ufr, _c_dbr)
138
139 return ret;
140}
141
142_static_inline cube_fast_t
143_move_L(cube_fast_t c)
144{
145 uint8_t aux, auy, auz;
146 cube_fast_t ret = c;
147
148 PERM4(ret.edge, _e_ul, _e_fl, _e_dl, _e_bl)
149 PERM4(ret.corner, _c_ufl, _c_dfl, _c_dbl, _c_ubl)
150
151 CO4(ret.corner, _c_ufl, _c_dbl, _c_dfl, _c_ubl)
152
153 return ret;
154}
155
156_static_inline cube_fast_t
157_move_L2(cube_fast_t c)
158{
159 uint8_t aux;
160 cube_fast_t ret = c;
161
162 PERM22(ret.edge, _e_ul, _e_dl, _e_fl, _e_bl)
163 PERM22(ret.corner, _c_ufl, _c_dbl, _c_ubl, _c_dfl)
164
165 return ret;
166}
167
168_static_inline cube_fast_t
169_move_L3(cube_fast_t c)
170{
171 uint8_t aux, auy, auz;
172 cube_fast_t ret = c;
173
174 PERM4(ret.edge, _e_ul, _e_bl, _e_dl, _e_fl)
175 PERM4(ret.corner, _c_ufl, _c_ubl, _c_dbl, _c_dfl)
176
177 CO4(ret.corner, _c_ufl, _c_dbl, _c_dfl, _c_ubl)
178
179 return ret;
180}
181
182_static_inline cube_fast_t
183_move_F(cube_fast_t c)
184{
185 uint8_t aux, auy, auz;
186 cube_fast_t ret = c;
187
188 PERM4(ret.edge, _e_uf, _e_fr, _e_df, _e_fl)
189 PERM4(ret.corner, _c_ufr, _c_dfr, _c_dfl, _c_ufl)
190
191 EO4(ret.edge, _e_uf, _e_fr, _e_df, _e_fl)
192 CO4(ret.corner, _c_ufr, _c_dfl, _c_dfr, _c_ufl)
193
194 return ret;
195}
196
197_static_inline cube_fast_t
198_move_F2(cube_fast_t c)
199{
200 uint8_t aux;
201 cube_fast_t ret = c;
202
203 PERM22(ret.edge, _e_uf, _e_df, _e_fr, _e_fl)
204 PERM22(ret.corner, _c_ufr, _c_dfl, _c_ufl, _c_dfr)
205
206 return ret;
207}
208
209_static_inline cube_fast_t
210_move_F3(cube_fast_t c)
211{
212 uint8_t aux, auy, auz;
213 cube_fast_t ret = c;
214
215 PERM4(ret.edge, _e_uf, _e_fl, _e_df, _e_fr)
216 PERM4(ret.corner, _c_ufr, _c_ufl, _c_dfl, _c_dfr)
217
218 EO4(ret.edge, _e_uf, _e_fr, _e_df, _e_fl)
219 CO4(ret.corner, _c_ufr, _c_dfl, _c_dfr, _c_ufl)
220
221 return ret;
222}
223
224_static_inline cube_fast_t
225_move_B(cube_fast_t c)
226{
227 uint8_t aux, auy, auz;
228 cube_fast_t ret = c;
229
230 PERM4(ret.edge, _e_ub, _e_bl, _e_db, _e_br)
231 PERM4(ret.corner, _c_ubr, _c_ubl, _c_dbl, _c_dbr)
232
233 EO4(ret.edge, _e_ub, _e_br, _e_db, _e_bl)
234 CO4(ret.corner, _c_ubl, _c_dbr, _c_dbl, _c_ubr)
235
236 return ret;
237}
238
239_static_inline cube_fast_t
240_move_B2(cube_fast_t c)
241{
242 uint8_t aux;
243 cube_fast_t ret = c;
244
245 PERM22(ret.edge, _e_ub, _e_db, _e_br, _e_bl)
246 PERM22(ret.corner, _c_ubr, _c_dbl, _c_ubl, _c_dbr)
247
248 return ret;
249}
250
251_static_inline cube_fast_t
252_move_B3(cube_fast_t c)
253{
254 uint8_t aux, auy, auz;
255 cube_fast_t ret = c;
256
257 PERM4(ret.edge, _e_ub, _e_br, _e_db, _e_bl)
258 PERM4(ret.corner, _c_ubr, _c_dbr, _c_dbl, _c_ubl)
259
260 EO4(ret.edge, _e_ub, _e_br, _e_db, _e_bl)
261 CO4(ret.corner, _c_ubl, _c_dbr, _c_dbl, _c_ubr)
262
263 return ret;
264}

Generated with cgit - Back to sebastiano.tronto.net