diff -r 6008840b859e -r 6a26114297a1 src/game.h --- a/src/game.h Sat Mar 29 16:53:58 2014 +0100 +++ b/src/game.h Mon Mar 31 11:16:32 2014 +0200 @@ -30,54 +30,13 @@ #ifndef GAME_H #define GAME_H +#include "chess/chess.h" #include "terminal-chess.h" -#include #ifdef __cplusplus extern "C" { #endif -#define PIECE_MASK 0x0F -#define COLOR_MASK 0x30 -#define ENPASSANT_THREAT 0x40 - -#define WHITE 0x10 -#define BLACK 0x20 - -#define PAWN 0x01 -#define ROOK 0x02 -#define KNIGHT 0x03 -#define BISHOP 0x04 -#define QUEEN 0x05 -#define KING 0x06 - -#define WPAWN (WHITE|PAWN) -#define WROOK (WHITE|ROOK) -#define WKNIGHT (WHITE|KNIGHT) -#define WBISHOP (WHITE|BISHOP) -#define WQUEEN (WHITE|QUEEN) -#define WKING (WHITE|KING) -#define BPAWN (BLACK|PAWN) -#define BROOK (BLACK|ROOK) -#define BKNIGHT (BLACK|KNIGHT) -#define BBISHOP (BLACK|BISHOP) -#define BQUEEN (BLACK|QUEEN) -#define BKING (BLACK|KING) - -typedef uint8_t Board[8][8]; - -typedef struct { - uint8_t piece; - uint8_t fromfile; - uint8_t fromrow; - uint8_t tofile; - uint8_t torow; - uint8_t promotion; - _Bool check; - _Bool checkmate; - _Bool capture; -} Move; - typedef struct MoveList MoveList; typedef struct MoveListRoot MoveListRoot; @@ -91,27 +50,6 @@ MoveList* next; }; -#define POS_UNSPECIFIED UINT8_MAX -#define mdst(b,m) b[(m)->torow][(m)->tofile] -#define msrc(b,m) b[(m)->fromrow][(m)->fromfile] - -#define isidx(idx) ((uint8_t)idx < 8) - -#define isfile(file) (file >= 'a' && file <= 'h') -#define isrow(row) (row >= '1' && row <= '8') - -#define rowidx(row) (row-'1') -#define fileidx(file) (file-'a') - -#define rowchr(row) (row+'1') -#define filechr(file) (file+'a') - -#define chkidx(move) (isidx((move)->fromfile) && isidx((move)->fromrow) && \ - isidx((move)->tofile) && isidx((move)->torow)) - -/* secure versions - use, if index is not checked with isidx() */ -#define fileidx_s(c) (isfile(c)?fileidx(c):POS_UNSPECIFIED) -#define rowidx_s(c) (isrow(c)?rowidx(c):POS_UNSPECIFIED) void game_start(Settings *settings, int opponent);