diff options
| author | Sebastiano Tronto <sebastiano@tronto.net> | 2025-03-26 19:22:50 +0100 |
|---|---|---|
| committer | Sebastiano Tronto <sebastiano@tronto.net> | 2025-03-26 19:22:50 +0100 |
| commit | 83338a2f753ebbb7ba7b154cc60b2f427b6121b0 (patch) | |
| tree | 149efb6a0b835fd6b3d89f7fd7808f8eed8e0288 /src/arch/portable.h | |
| parent | 56048d13b73ec6e6a9c59d62e82f41e69a3994bd (diff) | |
| download | nissy-core-83338a2f753ebbb7ba7b154cc60b2f427b6121b0.tar.gz nissy-core-83338a2f753ebbb7ba7b154cc60b2f427b6121b0.zip | |
Added inverse coordinate for CO
this is necessary for DR coordinate
Diffstat (limited to '')
| -rw-r--r-- | src/arch/portable.h | 42 |
1 files changed, 29 insertions, 13 deletions
diff --git a/src/arch/portable.h b/src/arch/portable.h index 4ac5fe7..56d3074 100644 --- a/src/arch/portable.h +++ b/src/arch/portable.h | |||
| @@ -144,8 +144,7 @@ inverse(cube_t cube) | |||
| 144 | STATIC_INLINE int64_t | 144 | STATIC_INLINE int64_t |
| 145 | coord_co(cube_t c) | 145 | coord_co(cube_t c) |
| 146 | { | 146 | { |
| 147 | int i, p; | 147 | int i, p, ret; |
| 148 | int64_t ret; | ||
| 149 | 148 | ||
| 150 | for (ret = 0, i = 0, p = 1; i < 7; i++, p *= 3) | 149 | for (ret = 0, i = 0, p = 1; i < 7; i++, p *= 3) |
| 151 | ret += p * (c.corner[i] >> COSHIFT); | 150 | ret += p * (c.corner[i] >> COSHIFT); |
| @@ -153,6 +152,23 @@ coord_co(cube_t c) | |||
| 153 | return ret; | 152 | return ret; |
| 154 | } | 153 | } |
| 155 | 154 | ||
| 155 | STATIC_INLINE cube_t | ||
| 156 | invcoord_co(int64_t coord) | ||
| 157 | { | ||
| 158 | int64_t i, c, p; | ||
| 159 | cube_t cube; | ||
| 160 | |||
| 161 | cube = SOLVED_CUBE; | ||
| 162 | for (i = 0, p = 0, c = coord; i < 7; i++, c /= 3) { | ||
| 163 | p += c % 3; | ||
| 164 | cube.corner[i] |= (c % 3) << COSHIFT; | ||
| 165 | } | ||
| 166 | |||
| 167 | cube.corner[7] |= ((3 - (p % 3)) % 3) << COSHIFT; | ||
| 168 | |||
| 169 | return cube; | ||
| 170 | } | ||
| 171 | |||
| 156 | /* | 172 | /* |
| 157 | For corner separation, we consider the axis (a.k.a. tetrad) each | 173 | For corner separation, we consider the axis (a.k.a. tetrad) each |
| 158 | corner belongs to as 0 or 1 and we translate this sequence into binary. | 174 | corner belongs to as 0 or 1 and we translate this sequence into binary. |
| @@ -226,6 +242,17 @@ coord_esep(cube_t c) | |||
| 226 | return ret1 * 70 + ret2; | 242 | return ret1 * 70 + ret2; |
| 227 | } | 243 | } |
| 228 | 244 | ||
| 245 | STATIC_INLINE cube_t | ||
| 246 | invcoord_esep(int64_t esep) | ||
| 247 | { | ||
| 248 | cube_t ret; | ||
| 249 | |||
| 250 | ret = SOLVED_CUBE; | ||
| 251 | invcoord_esep_array(esep % 70, esep / 70, ret.edge); | ||
| 252 | |||
| 253 | return ret; | ||
| 254 | } | ||
| 255 | |||
| 229 | STATIC_INLINE void | 256 | STATIC_INLINE void |
| 230 | copy_corners(cube_t dest[static 1], cube_t src) | 257 | copy_corners(cube_t dest[static 1], cube_t src) |
| 231 | { | 258 | { |
| @@ -250,14 +277,3 @@ set_eo(cube_t cube[static 1], int64_t eo) | |||
| 250 | } | 277 | } |
| 251 | cube->edge[0] = (cube->edge[0] & ~EOBIT) | (EOBIT * (sum % 2)); | 278 | cube->edge[0] = (cube->edge[0] & ~EOBIT) | (EOBIT * (sum % 2)); |
| 252 | } | 279 | } |
| 253 | |||
| 254 | STATIC_INLINE cube_t | ||
| 255 | invcoord_esep(int64_t esep) | ||
| 256 | { | ||
| 257 | cube_t ret; | ||
| 258 | |||
| 259 | ret = SOLVED_CUBE; | ||
| 260 | invcoord_esep_array(esep % 70, esep / 70, ret.edge); | ||
| 261 | |||
| 262 | return ret; | ||
| 263 | } | ||
