aboutsummaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
Diffstat (limited to 'src/core')
-rw-r--r--src/core/cube.h8
-rw-r--r--src/core/moves.h30
-rw-r--r--src/core/transform.h17
3 files changed, 28 insertions, 27 deletions
diff --git a/src/core/cube.h b/src/core/cube.h
index 9e79dda..1c21ce1 100644
--- a/src/core/cube.h
+++ b/src/core/cube.h
@@ -1,6 +1,6 @@
1STATIC bool cube_true(cube_t); 1STATIC bool cube_true(cube_t);
2 2
3STATIC cube_t cubefromarray(uint8_t [static 8], uint8_t [static 12]); 3STATIC cube_t cubefromarray(uint8_t [SIZE(8)], uint8_t [SIZE(12)]);
4STATIC bool isconsistent(oriented_cube_t); 4STATIC bool isconsistent(oriented_cube_t);
5STATIC bool issolvable(oriented_cube_t); 5STATIC bool issolvable(oriented_cube_t);
6STATIC bool issolved(oriented_cube_t); 6STATIC bool issolved(oriented_cube_t);
@@ -10,7 +10,7 @@ STATIC void getcube_fix(long long *, long long *,
10STATIC cube_t getcube(uint64_t, uint64_t, uint64_t, uint64_t); 10STATIC cube_t getcube(uint64_t, uint64_t, uint64_t, uint64_t);
11 11
12STATIC oriented_cube_t readcube(const char *); 12STATIC oriented_cube_t readcube(const char *);
13STATIC int64_t writecube(oriented_cube_t, size_t n, char [n]); 13STATIC int64_t writecube(oriented_cube_t, size_t n, char *);
14STATIC uint8_t readco(const char *); 14STATIC uint8_t readco(const char *);
15STATIC uint8_t readcp(const char *); 15STATIC uint8_t readcp(const char *);
16STATIC uint8_t readeo(const char *); 16STATIC uint8_t readeo(const char *);
@@ -29,7 +29,7 @@ cube_true(cube_t cube)
29} 29}
30 30
31STATIC cube_t 31STATIC cube_t
32cubefromarray(uint8_t c[static 8], uint8_t e[static 12]) 32cubefromarray(uint8_t c[SIZE(8)], uint8_t e[SIZE(12)])
33{ 33{
34 return STATIC_CUBE( 34 return STATIC_CUBE(
35 c[0], c[1], c[2], c[3], c[4], c[5], c[6], c[7], 35 c[0], c[1], c[2], c[3], c[4], c[5], c[6], c[7],
@@ -304,7 +304,7 @@ readcube(const char *buf)
304} 304}
305 305
306STATIC int64_t 306STATIC int64_t
307writecube(oriented_cube_t cube, size_t buf_size, char buf[buf_size]) 307writecube(oriented_cube_t cube, size_t buf_size, char *buf)
308{ 308{
309 int i; 309 int i;
310 uint8_t corner[8], edge[12]; 310 uint8_t corner[8], edge[12];
diff --git a/src/core/moves.h b/src/core/moves.h
index 6169c6e..9f1f7cc 100644
--- a/src/core/moves.h
+++ b/src/core/moves.h
@@ -4,15 +4,15 @@
4STATIC uint8_t readmove(char); 4STATIC uint8_t readmove(char);
5STATIC int64_t readmoves(const char *, 5STATIC int64_t readmoves(const char *,
6 size_t, size_t, size_t *, size_t *, uint8_t *, uint8_t *); 6 size_t, size_t, size_t *, size_t *, uint8_t *, uint8_t *);
7STATIC int64_t readmoves_struct(const char *, moves_struct_t [static 1]); 7STATIC int64_t readmoves_struct(const char *, moves_struct_t [NON_NULL]);
8STATIC int64_t countmoves(const char *); 8STATIC int64_t countmoves(const char *);
9STATIC bool moves_struct_equal( 9STATIC bool moves_struct_equal(
10 const moves_struct_t [static 1], const moves_struct_t [static 1]); 10 const moves_struct_t [NON_NULL], const moves_struct_t [NON_NULL]);
11STATIC long long comparemoves(const char *, const char *); 11STATIC long long comparemoves(const char *, const char *);
12STATIC uint8_t readmodifier(char); 12STATIC uint8_t readmodifier(char);
13STATIC int64_t writemoves(size_t, const uint8_t *, size_t, char *); 13STATIC int64_t writemoves(size_t, const uint8_t *, size_t, char *);
14STATIC int64_t writemoves_struct( 14STATIC int64_t writemoves_struct(
15 const moves_struct_t [static 1], size_t, char *); 15 const moves_struct_t [NON_NULL], size_t, char *);
16 16
17STATIC_INLINE bool allowednextmove(uint8_t, uint8_t); 17STATIC_INLINE bool allowednextmove(uint8_t, uint8_t);
18STATIC bool allowedmoves(size_t, const uint8_t *); 18STATIC bool allowedmoves(size_t, const uint8_t *);
@@ -36,9 +36,9 @@ STATIC bool are_lastmoves_singlecw(size_t, const uint8_t*);
36 36
37STATIC int64_t move_variations(const char *, const char *, size_t, char *); 37STATIC int64_t move_variations(const char *, const char *, size_t, char *);
38STATIC int64_t move_variations_lastqt( 38STATIC int64_t move_variations_lastqt(
39 const moves_struct_t [static 1], size_t, char *); 39 const moves_struct_t [NON_NULL], size_t, char *);
40STATIC int64_t move_variations_unniss( 40STATIC int64_t move_variations_unniss(
41 const moves_struct_t [static 1], size_t, char *); 41 const moves_struct_t [NON_NULL], size_t, char *);
42 42
43#define FOREACH_READMOVE(ARG_BUF, ARG_MOVE, ARG_C, ARG_MAX, \ 43#define FOREACH_READMOVE(ARG_BUF, ARG_MOVE, ARG_C, ARG_MAX, \
44 RET_ERROR, ARG_ACTION) \ 44 RET_ERROR, ARG_ACTION) \
@@ -167,7 +167,7 @@ readmoves(
167} 167}
168 168
169STATIC int64_t 169STATIC int64_t
170readmoves_struct(const char *moves, moves_struct_t ret[static 1]) 170readmoves_struct(const char *moves, moves_struct_t ret[NON_NULL])
171{ 171{
172 return readmoves(moves, NISSY_SIZE_MOVES, NISSY_SIZE_MOVES, 172 return readmoves(moves, NISSY_SIZE_MOVES, NISSY_SIZE_MOVES,
173 &ret->nnormal, &ret->ninverse, ret->normal, ret->inverse); 173 &ret->nnormal, &ret->ninverse, ret->normal, ret->inverse);
@@ -190,8 +190,8 @@ countmoves(const char *buf)
190 190
191STATIC bool 191STATIC bool
192moves_struct_equal( 192moves_struct_equal(
193 const moves_struct_t ms1[static 1], 193 const moves_struct_t ms1[NON_NULL],
194 const moves_struct_t ms2[static 1] 194 const moves_struct_t ms2[NON_NULL]
195) 195)
196{ 196{
197 size_t i; 197 size_t i;
@@ -281,7 +281,7 @@ writemoves_error:
281 281
282STATIC int64_t 282STATIC int64_t
283writemoves_struct( 283writemoves_struct(
284 const moves_struct_t moves[static 1], 284 const moves_struct_t moves[NON_NULL],
285 size_t buf_size, 285 size_t buf_size,
286 char *buf 286 char *buf
287) 287)
@@ -612,7 +612,7 @@ move_variations(
612 612
613STATIC int64_t 613STATIC int64_t
614move_variations_lastqt( 614move_variations_lastqt(
615 const moves_struct_t s[static 1], 615 const moves_struct_t s[NON_NULL],
616 size_t result_size, 616 size_t result_size,
617 char *result 617 char *result
618) 618)
@@ -623,10 +623,10 @@ move_variations_lastqt(
623 size_t u; 623 size_t u;
624 moves_struct_t ss; 624 moves_struct_t ss;
625 625
626 in1 = s->nnormal-1; 626 in1 = (uint8_t)(s->nnormal-1);
627 in2 = s->nnormal-2; 627 in2 = (uint8_t)(s->nnormal-2);
628 ii1 = s->ninverse-1; 628 ii1 = (uint8_t)(s->ninverse-1);
629 ii2 = s->ninverse-2; 629 ii2 = (uint8_t)(s->ninverse-2);
630 630
631 n1 = in1 >= 0 ? s->normal[in1] : UINT8_ERROR; 631 n1 = in1 >= 0 ? s->normal[in1] : UINT8_ERROR;
632 n2 = in2 >= 0 ? s->normal[in2] : UINT8_ERROR; 632 n2 = in2 >= 0 ? s->normal[in2] : UINT8_ERROR;
@@ -686,7 +686,7 @@ lastqt_error:
686 686
687STATIC int64_t 687STATIC int64_t
688move_variations_unniss( 688move_variations_unniss(
689 const moves_struct_t s[static 1], 689 const moves_struct_t s[NON_NULL],
690 size_t result_size, 690 size_t result_size,
691 char *result 691 char *result
692) 692)
diff --git a/src/core/transform.h b/src/core/transform.h
index f19c44f..af4634e 100644
--- a/src/core/transform.h
+++ b/src/core/transform.h
@@ -17,9 +17,9 @@
17 invertco(compose(compose(TRANS_CUBE_ ## T, c), \ 17 invertco(compose(compose(TRANS_CUBE_ ## T, c), \
18 TRANS_CUBE_ ## T ## _INVERSE)) 18 TRANS_CUBE_ ## T ## _INVERSE))
19 19
20STATIC uint8_t readtrans(const char [static NISSY_SIZE_TRANSFORMATION]); 20STATIC uint8_t readtrans(const char [SIZE(NISSY_SIZE_TRANSFORMATION)]);
21STATIC uint8_t readrotation(const char [static 2]); 21STATIC uint8_t readrotation(const char [SIZE(2)]);
22STATIC void writetrans(uint8_t, char [static NISSY_SIZE_TRANSFORMATION]); 22STATIC void writetrans(uint8_t, char [SIZE(NISSY_SIZE_TRANSFORMATION)]);
23 23
24STATIC cube_t transform_edges(cube_t, uint8_t); 24STATIC cube_t transform_edges(cube_t, uint8_t);
25STATIC cube_t transform_corners(cube_t, uint8_t); 25STATIC cube_t transform_corners(cube_t, uint8_t);
@@ -29,7 +29,7 @@ STATIC_INLINE uint8_t inverse_trans(uint8_t);
29STATIC uint64_t symmetry_mask(cube_t); 29STATIC uint64_t symmetry_mask(cube_t);
30 30
31STATIC uint8_t 31STATIC uint8_t
32readtrans(const char buf[static NISSY_SIZE_TRANSFORMATION]) 32readtrans(const char buf[SIZE(NISSY_SIZE_TRANSFORMATION)])
33{ 33{
34 uint8_t t; 34 uint8_t t;
35 35
@@ -41,7 +41,7 @@ readtrans(const char buf[static NISSY_SIZE_TRANSFORMATION])
41} 41}
42 42
43STATIC uint8_t 43STATIC uint8_t
44readrotation(const char buf[static 2]) 44readrotation(const char buf[SIZE(2)])
45{ 45{
46 char trans_str[NISSY_SIZE_TRANSFORMATION]; 46 char trans_str[NISSY_SIZE_TRANSFORMATION];
47 47
@@ -53,7 +53,7 @@ readrotation(const char buf[static 2])
53} 53}
54 54
55STATIC void 55STATIC void
56writetrans(uint8_t t, char buf[static NISSY_SIZE_TRANSFORMATION]) 56writetrans(uint8_t t, char buf[SIZE(NISSY_SIZE_TRANSFORMATION)])
57{ 57{
58 if (t >= 48) 58 if (t >= 48)
59 memcpy(buf, "error trans", 11); 59 memcpy(buf, "error trans", 11);
@@ -407,12 +407,13 @@ inverse_trans(uint8_t t)
407STATIC uint64_t 407STATIC uint64_t
408symmetry_mask(cube_t cube) 408symmetry_mask(cube_t cube)
409{ 409{
410 uint64_t t, ret; 410 uint64_t ret;
411 uint8_t t;
411 cube_t transformed; 412 cube_t transformed;
412 413
413 for (t = 0, ret = 0; t < NTRANS; t++) { 414 for (t = 0, ret = 0; t < NTRANS; t++) {
414 transformed = transform(cube, t); 415 transformed = transform(cube, t);
415 ret |= ((uint64_t)equal(cube, transformed)) << t; 416 ret |= ((uint64_t)equal(cube, transformed)) << (uint64_t)t;
416 } 417 }
417 418
418 return ret; 419 return ret;

Generated with cgit - Back to sebastiano.tronto.net