X-Git-Url: http://git.draconx.ca/gitweb/rrace.git/blobdiff_plain/a13b072946d80c2da325e90cb73d96a25485a80a..8e6b9fd79ca87c131d33d74d40f68df9696c7f5c:/src/game.h diff --git a/src/game.h b/src/game.h index fb2fe97..6a02a42 100644 --- a/src/game.h +++ b/src/game.h @@ -32,7 +32,9 @@ enum { TILE_MAX }; -enum { GOAL_SHIFT = 6 }; +#define GOAL_SHIFT 6 +#define GOAL_MASK 0x739c0ul + struct board { /* * Bit planes representing the current game area. @@ -111,6 +113,46 @@ static inline uint_fast32_t board_mask_v(int x, int y0, int y1) return (col << 5*y1) & (col >> 5*(4-y0)); } +/* + * Return the board bitmap setting locations on or above row y. + */ +static inline uint_fast32_t board_above(int y) +{ + uint_fast32_t val = board_row(y); + + return val | (val-1); +} + +/* + * Return the board bitmap setting locations on or below row y. + */ +static inline uint_fast32_t board_below(int y) +{ + uint_fast32_t val = board_row(y); + + return val | (~val + 1); +} + +/* + * Return the board bitmap setting locations on or left of column x. + */ +static inline uint_fast32_t board_left(int x) +{ + uint_fast32_t val = board_column(x); + + return val | (val - 0x108421); +} + +/* + * Return the board bitmap setting locations on or right of column x. + */ +static inline uint_fast32_t board_right(int x) +{ + uint_fast32_t val = board_column(x); + + return ~val + 0x108421; +} + /* * Move the bits in the game bitmaps according to a move at position (x, y), * and update the location of the empty position which, if the move was valid