aboutsummaryrefslogtreecommitdiff
path: root/include/actions.c
diff options
context:
space:
mode:
Diffstat (limited to 'include/actions.c')
-rw-r--r--include/actions.c43
1 files changed, 20 insertions, 23 deletions
diff --git a/include/actions.c b/include/actions.c
index 96264d0..5085330 100644
--- a/include/actions.c
+++ b/include/actions.c
@@ -187,10 +187,10 @@ action_list_t *action_list_generate(void) {
}
void action_take(const action_t action) {
- const int8_t loc = GET_LOC(action);
- if (GET_TYPE(action) == A_PLACE) {
+ const int8_t loc = A_GET_LOC(action);
+ if (A_GET_TYPE(action) == A_PLACE) {
const uint8_t black = (current_colour == C_BLACK);
- switch (GET_DATA0(action)) {
+ switch (A_GET_DATA0(action)) {
case STONE_FLAT: {
if (black) black_count--;
else white_count--;
@@ -217,9 +217,9 @@ void action_take(const action_t action) {
// not interested in whether we crushed, it will work out by
// anyway because we overwrite the top stone type. See (*) later
// for when we do need to know.
- const uint8_t gaps = GET_DATA0(action) & 0x7F,
- num = GET_DATA1(action) & 0x0F, // unpack
- dir = GET_DATA1(action) >> 4;
+ const uint8_t gaps = A_GET_DATA0(action) & 0x7F,
+ num = A_GET_DATA1(action) & 0x0F, // unpack
+ dir = A_GET_DATA1(action) >> 4;
int8_t delta = move_deltas[dir];
// Use the Kernighan method to count the set bits
@@ -266,11 +266,11 @@ void action_undo(const action_t action) {
// Previous ply
inline_prev_ply();
- const int8_t loc = GET_LOC(action);
- if (GET_TYPE(action) == A_PLACE) {
+ const int8_t loc = A_GET_LOC(action);
+ if (A_GET_TYPE(action) == A_PLACE) {
const uint8_t black = (current_colour == C_BLACK);
celldat[loc] = 0;
- if (GET_DATA0(action) == STONE_CAPSTONE) {
+ if (A_GET_DATA0(action) == STONE_CAPSTONE) {
if (black) black_count |= 0x80;
else white_count |= 0x80;
} else {
@@ -280,10 +280,10 @@ void action_undo(const action_t action) {
} else {
// See action_take for comments, this is the time reversal, but
// there is one caveat -- undoing a crush! (*)
- const uint8_t gaps = GET_DATA0(action) & 0x7F,
- crush = GET_DATA0(action) & 0x80,
- num = GET_DATA1(action) & 0x0F,
- dir = GET_DATA1(action) >> 4;
+ const uint8_t gaps = A_GET_DATA0(action) & 0x7F,
+ crush = A_GET_DATA0(action) & 0x80,
+ num = A_GET_DATA1(action) & 0x0F,
+ dir = A_GET_DATA1(action) >> 4;
const int8_t delta = move_deltas[dir];
int8_t steps = 1;
@@ -317,13 +317,13 @@ void action_undo(const action_t action) {
}
void action_to_ptn(const action_t action, char* out_ptn) {
- const int8_t loc = GET_LOC(action);
- if (GET_TYPE(action) == A_PLACE) {
- generate_place(loc, GET_DATA0(action), out_ptn);
+ const int8_t loc = A_GET_LOC(action);
+ if (A_GET_TYPE(action) == A_PLACE) {
+ generate_place(loc, A_GET_DATA0(action), out_ptn);
} else {
- const uint8_t gaps = GET_DATA0(action) & 0x7F,
- num = GET_DATA1(action) & 0x0F, // unpack
- dir = GET_DATA1(action) >> 4;
+ const uint8_t gaps = A_GET_DATA0(action) & 0x7F,
+ num = A_GET_DATA1(action) & 0x0F, // unpack
+ dir = A_GET_DATA1(action) >> 4;
uint8_t drops[board_size]; // we only ever need board_size-1 in
// drops actually, the last spot is to
@@ -356,10 +356,7 @@ list_append(action_list_t *list, const enum A_TYPE type,
// TODO: trap errno
new->next = NULL;
- new->action = (type << TYPE_SHIFT)
- | (loc << LOC_SHIFT)
- | (data0 << DATA0_SHIFT)
- | data1;
+ new->action = A_BUILD(type, loc, data0, data1);
if (list->length) {
list->tail->next = new;