aboutsummaryrefslogtreecommitdiff
path: root/src/cube_array.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/cube_array.c')
-rw-r--r--src/cube_array.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/cube_array.c b/src/cube_array.c
index a051610..b0b5e1e 100644
--- a/src/cube_array.c
+++ b/src/cube_array.c
@@ -25,6 +25,7 @@ The third bit is needed because x+y+1 can exceed 4.
25#include <stdio.h> 25#include <stdio.h>
26#endif 26#endif
27 27
28#include "constants.h"
28#include "cube.h" 29#include "cube.h"
29 30
30#define _c_ufr 0U 31#define _c_ufr 0U
@@ -713,6 +714,32 @@ inverse_inconsistent:
713cube_t 714cube_t
714compose(cube_t c1, cube_t c2) 715compose(cube_t c1, cube_t c2)
715{ 716{
717 uint8_t i, piece, orien, aux, auy;
718 cube_t ret = {0};
719
720#ifdef DEBUG
721 if (!isconsistent(c1) || !isconsistent(c2))
722 goto compose_inconsistent;
723#endif
724
725 for (i = 0; i < 12; i++) {
726 piece = c2.e[i] & _pbits;
727 orien = (c2.e[i] ^ c1.e[piece]) & _eobit;
728 ret.e[i] = (c1.e[piece] & _pbits) | orien;
729 }
730
731 for (i = 0; i < 8; i++) {
732 piece = c2.c[i] & _pbits;
733 aux = (c2.c[i] & _cobits) + (c1.c[piece] & _cobits);
734 auy = (aux + _ctwist_cw) >> 2U;
735 orien = (aux + auy) & _cobits2;
736 ret.c[i] = (c1.c[piece] & _pbits) | orien;
737 }
738
739 return ret;
740
741compose_inconsistent:
742 fprintf(stderr, "compose error, inconsistent cube\n");
716 return errorcube; 743 return errorcube;
717} 744}
718 745

Generated with cgit - Back to sebastiano.tronto.net