diff options
Diffstat (limited to 'include/tak.h')
| -rw-r--r-- | include/tak.h | 101 |
1 files changed, 52 insertions, 49 deletions
diff --git a/include/tak.h b/include/tak.h index 8a1d8be..26f4ae6 100644 --- a/include/tak.h +++ b/include/tak.h @@ -1,18 +1,18 @@ /* - This file is part of ct. + This file is part of ct. - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. - You should have received a copy of the GNU General Public License - along with ct. If not, see <https://www.gnu.org/licenses/>. + You should have received a copy of the GNU General Public License + along with ct. If not, see <https://www.gnu.org/licenses/>. */ #ifndef TAK_H @@ -24,28 +24,38 @@ // Types // =================================================================== -enum ACT_RESULT { ACT_OK, ACT_ILLEGAL, ACT_OVERFLOW, ACT_INVALID_PTN, GAME_END }; +enum ACT_RESULT { + ACT_OK, + ACT_ILLEGAL, + ACT_OVERFLOW, + ACT_INVALID_PTN, + GAME_END +}; enum PTN_RESULT { PTN_OK, PTN_INVALID }; enum TPS_RESULT { TPS_OK, TPS_INVALID }; -enum COLOUR { C_WHITE, C_BLACK }; -enum STONE_VARIANT { STONE_FLAT, STONE_STANDING, STONE_CAPSTONE }; +enum COLOUR { C_WHITE, C_BLACK }; +enum STONE_VARIANT { STONE_FLAT, STONE_STANDING, STONE_CAPSTONE }; enum MOVE_DIRECTION { M_UP, M_DOWN, M_LEFT, M_RIGHT }; -enum WIN_TYPE { WIN_DRAW, - WIN_FLAT_WHITE, WIN_FLAT_BLACK, - WIN_ROAD_WHITE, WIN_ROAD_BLACK }; +enum WIN_TYPE { + WIN_DRAW, + WIN_FLAT_WHITE, + WIN_FLAT_BLACK, + WIN_ROAD_WHITE, + WIN_ROAD_BLACK +}; typedef uint8_t data_t; typedef uint16_t colour_stack_t; -#define NUM_SHIFT 4 -#define NUM_MASK (0xF<<NUM_SHIFT) // 0b11110000 -#define NUM_INC (0x1<<NUM_SHIFT) // 0b00010000 -#define STONE_MASK 3 // 0b00000011 -#define STONE_AT(l) (celldat[(l)] & STONE_MASK) -#define COUNT_AT(l) (celldat[(l)] >> NUM_SHIFT) -#define THE_COORDS(col,row) ((col)+(row)*board_size) +#define NUM_SHIFT 4 +#define NUM_MASK (0xF << NUM_SHIFT) // 0b11110000 +#define NUM_INC (0x1 << NUM_SHIFT) // 0b00010000 +#define STONE_MASK 3 // 0b00000011 +#define STONE_AT(l) (celldat[(l)] & STONE_MASK) +#define COUNT_AT(l) (celldat[(l)] >> NUM_SHIFT) +#define THE_COORDS(col, row) ((col) + (row)*board_size) // =================================================================== // Variables @@ -70,42 +80,35 @@ extern uint8_t white_count, black_count, ply; void reset_state(const uint8_t new_board_size); void next_ply(void); -enum ACT_RESULT -try_place(const int8_t location, const enum COLOUR colour, - const enum STONE_VARIANT stone); +enum ACT_RESULT try_place(const int8_t location, const enum COLOUR colour, + const enum STONE_VARIANT stone); -enum ACT_RESULT -try_move(const int8_t location, const enum MOVE_DIRECTION direction, - const uint8_t steps, const uint8_t drops[5]); +enum ACT_RESULT try_move(const int8_t location, + const enum MOVE_DIRECTION direction, + const uint8_t steps, const uint8_t drops[5]); -enum WIN_TYPE -check_win(void); +enum WIN_TYPE check_win(void); // ------------------------------------------------------------------- // PTN related -enum PTN_RESULT -parse_place(char *in_ptn, uint8_t *out_location, - enum STONE_VARIANT *out_stone); +enum PTN_RESULT parse_place(char *in_ptn, uint8_t *out_location, + enum STONE_VARIANT *out_stone); -enum PTN_RESULT -parse_move(char *in_ptn, uint8_t *out_location, - enum MOVE_DIRECTION *out_direction, - uint8_t *out_steps, uint8_t out_drops[5]); +enum PTN_RESULT parse_move(char *in_ptn, uint8_t *out_location, + enum MOVE_DIRECTION *out_direction, + uint8_t *out_steps, uint8_t out_drops[5]); -void -generate_place(const uint8_t in_location, - const enum STONE_VARIANT in_stone, char out_ptn[4]); +void generate_place(const uint8_t in_location, + const enum STONE_VARIANT in_stone, char out_ptn[4]); -void -generate_move(const uint8_t in_location, - const enum MOVE_DIRECTION in_direction, - const uint8_t in_steps, const uint8_t in_drops[5], - char out_ptn[10]); +void generate_move(const uint8_t in_location, + const enum MOVE_DIRECTION in_direction, + const uint8_t in_steps, const uint8_t in_drops[5], + char out_ptn[10]); // ------------------------------------------------------------------- // Game driver -enum ACT_RESULT -do_ptn(char *ptn); +enum ACT_RESULT do_ptn(char *ptn); #endif |
