piece_t change, pack piece_details, conversion piece: mask<=>number
This commit is contained in:
@@ -20,23 +20,37 @@
|
||||
*/
|
||||
typedef u8 piece_t;
|
||||
|
||||
#define EMPTY 0
|
||||
enum {
|
||||
E_EMPTY = 0,
|
||||
E_PAWN,
|
||||
E_KNIGHT,
|
||||
E_BISHOP,
|
||||
E_ROOK,
|
||||
E_QUEEN,
|
||||
E_KING,
|
||||
E_COLOR = 8
|
||||
};
|
||||
|
||||
enum {
|
||||
EMPTY = 0,
|
||||
PAWN = 1 << (E_PAWN - 1), /* 0x01 00000001 */
|
||||
KNIGHT = 1 << (E_KNIGHT - 1), /* 0x02 00000010 */
|
||||
BISHOP = 1 << (E_BISHOP - 1), /* 0x04 00000100 */
|
||||
ROOK = 1 << (E_ROOK - 1), /* 0x08 00001000 */
|
||||
QUEEN = 1 << (E_QUEEN - 1), /* 0x10 00010000 */
|
||||
KING = 1 << (E_KING - 1), /* 0x20 00100000 */
|
||||
};
|
||||
|
||||
#define WHITE 0 /* 0x00 00000000 */
|
||||
#define BLACK 1 /* 0x01 00000001 */
|
||||
|
||||
#define PAWN (1 << 1) /* 0x02 00000010 */
|
||||
#define KNIGHT (1 << 2) /* 0x04 00000100 */
|
||||
#define BISHOP (1 << 3) /* 0x08 00001000 */
|
||||
#define ROOK (1 << 4) /* 0x10 00010000 */
|
||||
#define QUEEN (1 << 5) /* 0x20 00100000 */
|
||||
#define KING (1 << 6) /* 0x40 01000000 */
|
||||
#define MASK_PIECE 0x3F /* 00111111 */
|
||||
#define MASK_COLOR 0x80 /* 10000000 */
|
||||
|
||||
#define MASK_COLOR 0x01 /* 00000001 */
|
||||
#define MASK_PIECE 0x7E /* 01111110 */
|
||||
|
||||
#define COLOR(p) ((p) & MASK_COLOR)
|
||||
#define COLOR(p) ((p) & MASK_COLOR) /* bitmask */
|
||||
#define VCOLOR(p) (!!COLOR(p)) /* WHITE/BLACK */
|
||||
#define PIECE(p) ((p) & MASK_PIECE)
|
||||
#define E_PIECE(p) (ffs64(PIECE(p))) /* convert mask to E_XX */
|
||||
|
||||
#define IS_WHITE(p) (!COLOR(p))
|
||||
#define IS_BLACK(p) (COLOR(p))
|
||||
|
Reference in New Issue
Block a user