70 uint8_t piece; |
70 uint8_t piece; |
71 uint8_t fromfile; |
71 uint8_t fromfile; |
72 uint8_t fromrow; |
72 uint8_t fromrow; |
73 uint8_t tofile; |
73 uint8_t tofile; |
74 uint8_t torow; |
74 uint8_t torow; |
|
75 uint8_t promotion; |
75 _Bool check; |
76 _Bool check; |
76 _Bool checkmate; |
77 _Bool checkmate; |
77 _Bool capture; |
78 _Bool capture; |
78 } Move; |
79 } Move; |
|
80 |
|
81 typedef struct MoveList MoveList; |
|
82 typedef struct MoveListRoot MoveListRoot; |
|
83 |
|
84 struct MoveListRoot { |
|
85 MoveList* first; |
|
86 MoveList* last; |
|
87 }; |
|
88 |
|
89 struct MoveList { |
|
90 Move move; |
|
91 MoveList* next; |
|
92 }; |
79 |
93 |
80 #define POS_UNSPECIFIED UINT8_MAX |
94 #define POS_UNSPECIFIED UINT8_MAX |
81 #define mdst(b,m) b[(m)->torow][(m)->tofile] |
95 #define mdst(b,m) b[(m)->torow][(m)->tofile] |
82 #define msrc(b,m) b[(m)->fromrow][(m)->fromfile] |
96 #define msrc(b,m) b[(m)->fromrow][(m)->fromfile] |
83 |
97 |
87 #define isrow(row) (row >= '1' && row <= '8') |
101 #define isrow(row) (row >= '1' && row <= '8') |
88 |
102 |
89 #define rowidx(row) (row-'1') |
103 #define rowidx(row) (row-'1') |
90 #define fileidx(file) (file-'a') |
104 #define fileidx(file) (file-'a') |
91 |
105 |
|
106 #define rowchr(row) (row+'1') |
|
107 #define filechr(file) (file+'a') |
|
108 |
92 #define chkidx(move) (isidx((move)->fromfile) && isidx((move)->fromrow) && \ |
109 #define chkidx(move) (isidx((move)->fromfile) && isidx((move)->fromrow) && \ |
93 isidx((move)->tofile) && isidx((move)->torow)) |
110 isidx((move)->tofile) && isidx((move)->torow)) |
94 |
111 |
95 /* secure versions - use, if index is not checked with isidx() */ |
112 /* secure versions - use, if index is not checked with isidx() */ |
96 #define fileidx_s(c) (isfile(c)?fileidx(c):POS_UNSPECIFIED) |
113 #define fileidx_s(c) (isfile(c)?fileidx(c):POS_UNSPECIFIED) |
97 #define rowidx_s(c) (isrow(c)?rowidx(c):POS_UNSPECIFIED) |
114 #define rowidx_s(c) (isrow(c)?rowidx(c):POS_UNSPECIFIED) |
98 |
115 |
99 void game_start(Settings *settings, int opponent); |
116 void game_start(Settings *settings, int opponent); |
100 |
117 |
|
118 void freemovelist(MoveListRoot* list); |
|
119 void addmove(MoveListRoot *movelist, Move *move); |
|
120 |
101 #ifdef __cplusplus |
121 #ifdef __cplusplus |
102 } |
122 } |
103 #endif |
123 #endif |
104 |
124 |
105 #endif /* GAME_H */ |
125 #endif /* GAME_H */ |