aboutsummaryrefslogtreecommitdiff
path: root/include/actions.c
diff options
context:
space:
mode:
Diffstat (limited to 'include/actions.c')
-rw-r--r--include/actions.c25
1 files changed, 8 insertions, 17 deletions
diff --git a/include/actions.c b/include/actions.c
index 9b3534b..96264d0 100644
--- a/include/actions.c
+++ b/include/actions.c
@@ -8,15 +8,6 @@
#define CLR_STONE NUM_MASK
-#define TYPE_SHIFT 24
-#define LOC_SHIFT 16
-#define DATA0_SHIFT 8
-
-#define GET_TYPE(a) (enum A_TYPE)((a)>>TYPE_SHIFT)
-#define GET_LOC(a) (int8_t)(((a)>>LOC_SHIFT) & 0xFF)
-#define GET_DATA0(a) (uint8_t)(((a)>>DATA0_SHIFT) & 0xFF)
-#define GET_DATA1(a) (uint8_t)((a) & 0xFF)
-
static inline void
list_append(action_list_t *list, const enum A_TYPE type,
const int8_t loc, const uint8_t data0,
@@ -65,13 +56,13 @@ void action_list_free(action_list_t *list) {
}
// Keep track of move offsets
-static int8_t deltas[4];
+int8_t move_deltas[4];
void action_list_init(void) {
- deltas[0] = +board_size;
- deltas[1] = -board_size;
- deltas[2] = -1;
- deltas[3] = +1;
+ move_deltas[0] = +board_size;
+ move_deltas[1] = -board_size;
+ move_deltas[2] = -1;
+ move_deltas[3] = +1;
}
action_list_t *action_list_generate(void) {
@@ -117,7 +108,7 @@ action_list_t *action_list_generate(void) {
// Now we check for caps and walls
const uint8_t cap_top = STONE_AT(loc) == STONE_CAPSTONE;
for (int d = 0; d < 4; d++){
- const int delta = deltas[d];
+ const int delta = move_deltas[d];
const int stop = end_stops[d];
end_stops[d] = 0;
for (int k = 1; k <= stop; k++) {
@@ -229,7 +220,7 @@ void action_take(const action_t action) {
const uint8_t gaps = GET_DATA0(action) & 0x7F,
num = GET_DATA1(action) & 0x0F, // unpack
dir = GET_DATA1(action) >> 4;
- int8_t delta = deltas[dir];
+ int8_t delta = move_deltas[dir];
// Use the Kernighan method to count the set bits
int8_t steps = 1;
@@ -293,7 +284,7 @@ void action_undo(const action_t action) {
crush = GET_DATA0(action) & 0x80,
num = GET_DATA1(action) & 0x0F,
dir = GET_DATA1(action) >> 4;
- const int8_t delta = deltas[dir];
+ const int8_t delta = move_deltas[dir];
int8_t steps = 1;
uint8_t gap_bit = 1, total = 1;