diff options
Diffstat (limited to 'src/cube_portable.h')
| -rw-r--r-- | src/cube_portable.h | 52 |
1 files changed, 44 insertions, 8 deletions
diff --git a/src/cube_portable.h b/src/cube_portable.h index e72c169..d62661a 100644 --- a/src/cube_portable.h +++ b/src/cube_portable.h | |||
| @@ -11,6 +11,10 @@ _static cube_t fasttocube(cube_fast_t); | |||
| 11 | _static_inline bool equal_fast(cube_fast_t, cube_fast_t); | 11 | _static_inline bool equal_fast(cube_fast_t, cube_fast_t); |
| 12 | _static_inline bool issolved_fast(cube_fast_t); | 12 | _static_inline bool issolved_fast(cube_fast_t); |
| 13 | _static_inline cube_fast_t invertco_fast(cube_fast_t); | 13 | _static_inline cube_fast_t invertco_fast(cube_fast_t); |
| 14 | _static_inline void compose_edges_inplace(cube_fast_t, cube_fast_t, cube_fast_t *); | ||
| 15 | _static_inline void compose_corners_inplace(cube_fast_t, cube_fast_t, cube_fast_t *); | ||
| 16 | _static_inline cube_fast_t compose_fast_edges(cube_fast_t, cube_fast_t); | ||
| 17 | _static_inline cube_fast_t compose_fast_corners(cube_fast_t, cube_fast_t); | ||
| 14 | _static_inline cube_fast_t compose_fast(cube_fast_t, cube_fast_t); | 18 | _static_inline cube_fast_t compose_fast(cube_fast_t, cube_fast_t); |
| 15 | 19 | ||
| 16 | _static_inline int64_t coord_fast_co(cube_fast_t); | 20 | _static_inline int64_t coord_fast_co(cube_fast_t); |
| @@ -115,21 +119,24 @@ invertco_fast(cube_fast_t c) | |||
| 115 | return ret; | 119 | return ret; |
| 116 | } | 120 | } |
| 117 | 121 | ||
| 118 | _static_inline cube_fast_t | 122 | _static_inline void |
| 119 | compose_fast(cube_fast_t c1, cube_fast_t c2) | 123 | compose_edges_inplace(cube_fast_t c1, cube_fast_t c2, cube_fast_t *ret) |
| 120 | { | 124 | { |
| 121 | cube_fast_t ret; | 125 | uint8_t i, piece1, piece2, p, orien; |
| 122 | uint8_t i, piece1, piece2, p, orien, aux, auy; | ||
| 123 | |||
| 124 | ret = zero_fast; | ||
| 125 | 126 | ||
| 126 | for (i = 0; i < 12; i++) { | 127 | for (i = 0; i < 12; i++) { |
| 127 | piece2 = c2.edge[i]; | 128 | piece2 = c2.edge[i]; |
| 128 | p = piece2 & _pbits; | 129 | p = piece2 & _pbits; |
| 129 | piece1 = c1.edge[p]; | 130 | piece1 = c1.edge[p]; |
| 130 | orien = (piece2 ^ piece1) & _eobit; | 131 | orien = (piece2 ^ piece1) & _eobit; |
| 131 | ret.edge[i] = (piece1 & _pbits) | orien; | 132 | ret->edge[i] = (piece1 & _pbits) | orien; |
| 132 | } | 133 | } |
| 134 | } | ||
| 135 | |||
| 136 | _static_inline void | ||
| 137 | compose_corners_inplace(cube_fast_t c1, cube_fast_t c2, cube_fast_t *ret) | ||
| 138 | { | ||
| 139 | uint8_t i, piece1, piece2, p, orien, aux, auy; | ||
| 133 | 140 | ||
| 134 | for (i = 0; i < 8; i++) { | 141 | for (i = 0; i < 8; i++) { |
| 135 | piece2 = c2.corner[i]; | 142 | piece2 = c2.corner[i]; |
| @@ -138,8 +145,37 @@ compose_fast(cube_fast_t c1, cube_fast_t c2) | |||
| 138 | aux = (piece2 & _cobits) + (piece1 & _cobits); | 145 | aux = (piece2 & _cobits) + (piece1 & _cobits); |
| 139 | auy = (aux + _ctwist_cw) >> 2U; | 146 | auy = (aux + _ctwist_cw) >> 2U; |
| 140 | orien = (aux + auy) & _cobits2; | 147 | orien = (aux + auy) & _cobits2; |
| 141 | ret.corner[i] = (piece1 & _pbits) | orien; | 148 | ret->corner[i] = (piece1 & _pbits) | orien; |
| 142 | } | 149 | } |
| 150 | } | ||
| 151 | |||
| 152 | _static_inline cube_fast_t | ||
| 153 | compose_fast_edges(cube_fast_t c1, cube_fast_t c2) | ||
| 154 | { | ||
| 155 | cube_fast_t ret = zero_fast; | ||
| 156 | |||
| 157 | compose_edges_inplace(c1, c2, &ret); | ||
| 158 | |||
| 159 | return ret; | ||
| 160 | } | ||
| 161 | |||
| 162 | _static_inline cube_fast_t | ||
| 163 | compose_fast_corners(cube_fast_t c1, cube_fast_t c2) | ||
| 164 | { | ||
| 165 | cube_fast_t ret = zero_fast; | ||
| 166 | |||
| 167 | compose_corners_inplace(c1, c2, &ret); | ||
| 168 | |||
| 169 | return ret; | ||
| 170 | } | ||
| 171 | |||
| 172 | _static_inline cube_fast_t | ||
| 173 | compose_fast(cube_fast_t c1, cube_fast_t c2) | ||
| 174 | { | ||
| 175 | cube_fast_t ret = zero_fast; | ||
| 176 | |||
| 177 | compose_edges_inplace(c1, c2, &ret); | ||
| 178 | compose_corners_inplace(c1, c2, &ret); | ||
| 143 | 179 | ||
| 144 | return ret; | 180 | return ret; |
| 145 | } | 181 | } |
