src/game.h

changeset 19
6a26114297a1
parent 18
6008840b859e
child 23
824c9522ce66
     1.1 --- a/src/game.h	Sat Mar 29 16:53:58 2014 +0100
     1.2 +++ b/src/game.h	Mon Mar 31 11:16:32 2014 +0200
     1.3 @@ -30,54 +30,13 @@
     1.4  #ifndef GAME_H
     1.5  #define	GAME_H
     1.6  
     1.7 +#include "chess/chess.h"
     1.8  #include "terminal-chess.h"
     1.9 -#include <stdint.h>
    1.10  
    1.11  #ifdef	__cplusplus
    1.12  extern "C" {
    1.13  #endif
    1.14  
    1.15 -#define PIECE_MASK       0x0F
    1.16 -#define COLOR_MASK       0x30
    1.17 -#define ENPASSANT_THREAT 0x40
    1.18 -
    1.19 -#define WHITE 0x10
    1.20 -#define BLACK 0x20
    1.21 -
    1.22 -#define PAWN   0x01
    1.23 -#define ROOK   0x02
    1.24 -#define KNIGHT 0x03
    1.25 -#define BISHOP 0x04
    1.26 -#define QUEEN  0x05
    1.27 -#define KING   0x06
    1.28 -
    1.29 -#define WPAWN   (WHITE|PAWN)
    1.30 -#define WROOK   (WHITE|ROOK)
    1.31 -#define WKNIGHT (WHITE|KNIGHT)
    1.32 -#define WBISHOP (WHITE|BISHOP)
    1.33 -#define WQUEEN  (WHITE|QUEEN)
    1.34 -#define WKING   (WHITE|KING)
    1.35 -#define BPAWN   (BLACK|PAWN)
    1.36 -#define BROOK   (BLACK|ROOK)
    1.37 -#define BKNIGHT (BLACK|KNIGHT)
    1.38 -#define BBISHOP (BLACK|BISHOP)
    1.39 -#define BQUEEN  (BLACK|QUEEN)
    1.40 -#define BKING   (BLACK|KING)
    1.41 -
    1.42 -typedef uint8_t Board[8][8];
    1.43 -
    1.44 -typedef struct {
    1.45 -    uint8_t piece;
    1.46 -    uint8_t fromfile;
    1.47 -    uint8_t fromrow;
    1.48 -    uint8_t tofile;
    1.49 -    uint8_t torow;
    1.50 -    uint8_t promotion;
    1.51 -    _Bool check;
    1.52 -    _Bool checkmate;
    1.53 -    _Bool capture;
    1.54 -} Move;
    1.55 -
    1.56  typedef struct MoveList MoveList;
    1.57  typedef struct MoveListRoot MoveListRoot;
    1.58  
    1.59 @@ -91,27 +50,6 @@
    1.60      MoveList* next;
    1.61  };
    1.62  
    1.63 -#define POS_UNSPECIFIED UINT8_MAX
    1.64 -#define mdst(b,m) b[(m)->torow][(m)->tofile]
    1.65 -#define msrc(b,m) b[(m)->fromrow][(m)->fromfile]
    1.66 -
    1.67 -#define isidx(idx) ((uint8_t)idx < 8)
    1.68 -
    1.69 -#define isfile(file) (file >= 'a' && file <= 'h')
    1.70 -#define isrow(row) (row >= '1' && row <= '8')
    1.71 -
    1.72 -#define rowidx(row) (row-'1')
    1.73 -#define fileidx(file) (file-'a')
    1.74 -
    1.75 -#define rowchr(row) (row+'1')
    1.76 -#define filechr(file) (file+'a')
    1.77 -
    1.78 -#define chkidx(move) (isidx((move)->fromfile) && isidx((move)->fromrow) && \
    1.79 -        isidx((move)->tofile) && isidx((move)->torow))
    1.80 -
    1.81 -/* secure versions - use, if index is not checked with isidx() */
    1.82 -#define fileidx_s(c) (isfile(c)?fileidx(c):POS_UNSPECIFIED)
    1.83 -#define rowidx_s(c) (isrow(c)?rowidx(c):POS_UNSPECIFIED)
    1.84  
    1.85  void game_start(Settings *settings, int opponent);
    1.86  

mercurial