diff options
| author | Sebastiano Tronto <sebastiano@tronto.net> | 2025-07-29 12:12:43 +0200 |
|---|---|---|
| committer | Sebastiano Tronto <sebastiano@tronto.net> | 2025-07-29 12:12:43 +0200 |
| commit | ea0387796a349c91032fbcb10f50c6ad8607b0f6 (patch) | |
| tree | aed484690d24c0c28c7695d4b5389f2e3c341b96 /src/arch/portable.h | |
| parent | 52c21640508c3fc668107778ae027ff4428ebd89 (diff) | |
| download | nissy-core-ea0387796a349c91032fbcb10f50c6ad8607b0f6.tar.gz nissy-core-ea0387796a349c91032fbcb10f50c6ad8607b0f6.zip | |
All coordinates unsigned
Diffstat (limited to 'src/arch/portable.h')
| -rw-r--r-- | src/arch/portable.h | 32 |
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 | ||
| 157 | STATIC_INLINE int64_t | 157 | STATIC_INLINE uint64_t |
| 158 | coord_co(cube_t c) | 158 | coord_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 | ||
| 168 | STATIC_INLINE cube_t | 168 | STATIC_INLINE cube_t |
| 169 | invcoord_co(int64_t coord) | 169 | invcoord_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 | |||
| 189 | possible. Encoding this as a number from 0 to C(8,4) would save about 40% | 189 | possible. Encoding this as a number from 0 to C(8,4) would save about 40% |
| 190 | of space, but we are not going to use this coordinate in large tables. | 190 | of space, but we are not going to use this coordinate in large tables. |
| 191 | */ | 191 | */ |
| 192 | STATIC_INLINE int64_t | 192 | STATIC_INLINE uint64_t |
| 193 | coord_csep(cube_t c) | 193 | coord_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 | ||
| 204 | STATIC_INLINE int64_t | 204 | STATIC_INLINE uint64_t |
| 205 | coord_cocsep(cube_t c) | 205 | coord_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 | ||
| 210 | STATIC_INLINE int64_t | 210 | STATIC_INLINE uint64_t |
| 211 | coord_eo(cube_t c) | 211 | coord_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) | |||
| 223 | We encode the edge separation as a number from 0 to C(12,4)*C(8,4). | 223 | We encode the edge separation as a number from 0 to C(12,4)*C(8,4). |
| 224 | It can be seen as the composition of two "subset index" coordinates. | 224 | It can be seen as the composition of two "subset index" coordinates. |
| 225 | */ | 225 | */ |
| 226 | STATIC_INLINE int64_t | 226 | STATIC_INLINE uint64_t |
| 227 | coord_esep(cube_t c) | 227 | coord_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 | ||
| 258 | STATIC_INLINE cube_t | 258 | STATIC_INLINE cube_t |
| 259 | invcoord_esep(int64_t esep) | 259 | invcoord_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 | ||
| 281 | STATIC_INLINE void | 281 | STATIC_INLINE void |
| 282 | set_eo(cube_t cube[static 1], int64_t eo) | 282 | set_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 | ||
| 294 | STATIC_INLINE int64_t | 294 | STATIC_INLINE uint64_t |
| 295 | coord_cp(cube_t cube) | 295 | coord_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 | ||
| 305 | STATIC_INLINE cube_t | 305 | STATIC_INLINE cube_t |
| 306 | invcoord_cp(int64_t i) | 306 | invcoord_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 | ||
| 316 | STATIC_INLINE int64_t | 316 | STATIC_INLINE uint64_t |
| 317 | coord_epud(cube_t cube) | 317 | coord_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 | ||
| 327 | STATIC_INLINE cube_t | 327 | STATIC_INLINE cube_t |
| 328 | invcoord_epud(int64_t i) | 328 | invcoord_epud(uint64_t i) |
| 329 | { | 329 | { |
| 330 | uint8_t e[8]; | 330 | uint8_t e[8]; |
| 331 | 331 | ||
