aboutsummaryrefslogtreecommitdiff
path: root/src/arch/portable.h
diff options
context:
space:
mode:
authorSebastiano Tronto <sebastiano@tronto.net>2025-07-29 10:00:56 +0200
committerSebastiano Tronto <sebastiano@tronto.net>2025-07-29 10:00:56 +0200
commit38014615238a51f1c0c1f2f96d37cbfbf765520a (patch)
tree24fff81dd4692ba91b96dd0ab099e043b7108824 /src/arch/portable.h
parent1d93860c6f6d3fdbdddabdcd870ef0f8b6e47c81 (diff)
downloadnissy-core-38014615238a51f1c0c1f2f96d37cbfbf765520a.tar.gz
nissy-core-38014615238a51f1c0c1f2f96d37cbfbf765520a.zip
Optimized some coordinates
Diffstat (limited to 'src/arch/portable.h')
-rw-r--r--src/arch/portable.h44
1 files changed, 44 insertions, 0 deletions
diff --git a/src/arch/portable.h b/src/arch/portable.h
index bd67c18..ec992a8 100644
--- a/src/arch/portable.h
+++ b/src/arch/portable.h
@@ -290,3 +290,47 @@ set_eo(cube_t cube[static 1], int64_t eo)
290 } 290 }
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
294STATIC_INLINE int64_t
295coord_cp(cube_t cube)
296{
297 int i;
298
299 for (i = 0; i < 8; i++)
300 cube.corner[i] &= PBITS;
301
302 return permtoindex(8, cube.corner);
303}
304
305STATIC_INLINE cube_t
306invcoord_cp(int64_t i)
307{
308 uint8_t c[8];
309
310 indextoperm(i, 8, c);
311
312 return STATIC_CUBE(c[0], c[1], c[2], c[3], c[4], c[5], c[6], c[7],
313 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11);
314}
315
316STATIC_INLINE int64_t
317coord_epud(cube_t cube)
318{
319 int i;
320
321 for (i = 0; i < 8; i++)
322 cube.edge[i] &= PBITS;
323
324 return permtoindex(8, cube.edge);
325}
326
327STATIC_INLINE cube_t
328invcoord_epud(int64_t i)
329{
330 uint8_t e[8];
331
332 indextoperm(i, 8, e);
333
334 return STATIC_CUBE(0, 1, 2, 3, 4, 5, 6, 7,
335 e[0], e[1], e[2], e[3], e[4], e[5], e[6], e[7], 8, 9, 10, 11);
336}

Generated with cgit - Back to sebastiano.tronto.net