aboutsummaryrefslogtreecommitdiff
path: root/src/arch/portable.h
diff options
context:
space:
mode:
authorSebastiano Tronto <sebastiano@tronto.net>2025-07-29 12:12:43 +0200
committerSebastiano Tronto <sebastiano@tronto.net>2025-07-29 12:12:43 +0200
commitea0387796a349c91032fbcb10f50c6ad8607b0f6 (patch)
treeaed484690d24c0c28c7695d4b5389f2e3c341b96 /src/arch/portable.h
parent52c21640508c3fc668107778ae027ff4428ebd89 (diff)
downloadnissy-core-ea0387796a349c91032fbcb10f50c6ad8607b0f6.tar.gz
nissy-core-ea0387796a349c91032fbcb10f50c6ad8607b0f6.zip
All coordinates unsigned
Diffstat (limited to '')
-rw-r--r--src/arch/portable.h32
1 files changed, 16 insertions, 16 deletions
diff --git a/src/arch/portable.h b/src/arch/portable.h
index ec992a8..5acccf2 100644
--- a/src/arch/portable.h
+++ b/src/arch/portable.h
@@ -154,7 +154,7 @@ inverse(cube_t cube)
154 return ret; 154 return ret;
155} 155}
156 156
157STATIC_INLINE int64_t 157STATIC_INLINE uint64_t
158coord_co(cube_t c) 158coord_co(cube_t c)
159{ 159{
160 int i, p, ret; 160 int i, p, ret;
@@ -166,9 +166,9 @@ coord_co(cube_t c)
166} 166}
167 167
168STATIC_INLINE cube_t 168STATIC_INLINE cube_t
169invcoord_co(int64_t coord) 169invcoord_co(uint64_t coord)
170{ 170{
171 int64_t i, c, p; 171 uint64_t i, c, p;
172 cube_t cube; 172 cube_t cube;
173 173
174 cube = SOLVED_CUBE; 174 cube = SOLVED_CUBE;
@@ -189,11 +189,11 @@ Ignoring the last bit, we have a value up to 2^7, but not all values are
189possible. Encoding this as a number from 0 to C(8,4) would save about 40% 189possible. Encoding this as a number from 0 to C(8,4) would save about 40%
190of space, but we are not going to use this coordinate in large tables. 190of space, but we are not going to use this coordinate in large tables.
191*/ 191*/
192STATIC_INLINE int64_t 192STATIC_INLINE uint64_t
193coord_csep(cube_t c) 193coord_csep(cube_t c)
194{ 194{
195 int i, p; 195 int i, p;
196 int64_t ret; 196 uint64_t ret;
197 197
198 for (ret = 0, i = 0, p = 1; i < 7; i++, p *= 2) 198 for (ret = 0, i = 0, p = 1; i < 7; i++, p *= 2)
199 ret += p * ((c.corner[i] & CSEPBIT) >> 2); 199 ret += p * ((c.corner[i] & CSEPBIT) >> 2);
@@ -201,17 +201,17 @@ coord_csep(cube_t c)
201 return ret; 201 return ret;
202} 202}
203 203
204STATIC_INLINE int64_t 204STATIC_INLINE uint64_t
205coord_cocsep(cube_t c) 205coord_cocsep(cube_t c)
206{ 206{
207 return (coord_co(c) << 7) + coord_csep(c); 207 return (coord_co(c) << 7) + coord_csep(c);
208} 208}
209 209
210STATIC_INLINE int64_t 210STATIC_INLINE uint64_t
211coord_eo(cube_t c) 211coord_eo(cube_t c)
212{ 212{
213 int i, p; 213 int i, p;
214 int64_t ret; 214 uint64_t ret;
215 215
216 for (ret = 0, i = 1, p = 1; i < 12; i++, p *= 2) 216 for (ret = 0, i = 1, p = 1; i < 12; i++, p *= 2)
217 ret += p * (c.edge[i] >> EOSHIFT); 217 ret += p * (c.edge[i] >> EOSHIFT);
@@ -223,10 +223,10 @@ coord_eo(cube_t c)
223We encode the edge separation as a number from 0 to C(12,4)*C(8,4). 223We encode the edge separation as a number from 0 to C(12,4)*C(8,4).
224It can be seen as the composition of two "subset index" coordinates. 224It can be seen as the composition of two "subset index" coordinates.
225*/ 225*/
226STATIC_INLINE int64_t 226STATIC_INLINE uint64_t
227coord_esep(cube_t c) 227coord_esep(cube_t c)
228{ 228{
229 int64_t i, j, jj, k, l, ret1, ret2, bit1, bit2, is1; 229 uint64_t i, j, jj, k, l, ret1, ret2, bit1, bit2, is1;
230 230
231 for (i = 0, j = 0, k = 4, l = 4, ret1 = 0, ret2 = 0; i < 12; i++) { 231 for (i = 0, j = 0, k = 4, l = 4, ret1 = 0, ret2 = 0; i < 12; i++) {
232 /* Simple version: 232 /* Simple version:
@@ -256,7 +256,7 @@ coord_esep(cube_t c)
256} 256}
257 257
258STATIC_INLINE cube_t 258STATIC_INLINE cube_t
259invcoord_esep(int64_t esep) 259invcoord_esep(uint64_t esep)
260{ 260{
261 cube_t ret; 261 cube_t ret;
262 262
@@ -279,7 +279,7 @@ copy_edges(cube_t dest[static 1], cube_t src)
279} 279}
280 280
281STATIC_INLINE void 281STATIC_INLINE void
282set_eo(cube_t cube[static 1], int64_t eo) 282set_eo(cube_t cube[static 1], uint64_t eo)
283{ 283{
284 uint8_t i, sum, flip; 284 uint8_t i, sum, flip;
285 285
@@ -291,7 +291,7 @@ set_eo(cube_t cube[static 1], int64_t eo)
291 cube->edge[0] = (cube->edge[0] & ~EOBIT) | (EOBIT * (sum % 2)); 291 cube->edge[0] = (cube->edge[0] & ~EOBIT) | (EOBIT * (sum % 2));
292} 292}
293 293
294STATIC_INLINE int64_t 294STATIC_INLINE uint64_t
295coord_cp(cube_t cube) 295coord_cp(cube_t cube)
296{ 296{
297 int i; 297 int i;
@@ -303,7 +303,7 @@ coord_cp(cube_t cube)
303} 303}
304 304
305STATIC_INLINE cube_t 305STATIC_INLINE cube_t
306invcoord_cp(int64_t i) 306invcoord_cp(uint64_t i)
307{ 307{
308 uint8_t c[8]; 308 uint8_t c[8];
309 309
@@ -313,7 +313,7 @@ invcoord_cp(int64_t i)
313 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11); 313 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11);
314} 314}
315 315
316STATIC_INLINE int64_t 316STATIC_INLINE uint64_t
317coord_epud(cube_t cube) 317coord_epud(cube_t cube)
318{ 318{
319 int i; 319 int i;
@@ -325,7 +325,7 @@ coord_epud(cube_t cube)
325} 325}
326 326
327STATIC_INLINE cube_t 327STATIC_INLINE cube_t
328invcoord_epud(int64_t i) 328invcoord_epud(uint64_t i)
329{ 329{
330 uint8_t e[8]; 330 uint8_t e[8];
331 331

Generated with cgit - Back to sebastiano.tronto.net