/* * ECE476Lab6ChessCode.h /* Data Structure: Tiles are represented by bytes. The low bit indicates pressence or absence of a piece, one represents presences of a piece. The second to low bit indicates color (0 for black). The top six bits represent the piece in question. It is easiest to represent the pieces 'one hot': Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0 HasPiece | IsWhite | IsPawn | IsKnight | IsBishop | IsRook | IsQueen | IsKing */ #define HASPIECE(x) ((x & 0x80) == 0x80) #define IsWhite(x) ((x & 0x40) == 0x40) #define IsBlack(x) ((x & 0xC0) == 0x80) #define IsPawn(x) ((x & 0x20) == 0x20) #define IsKnight(x) ((x & 0x10) == 0x10) #define IsBishop(x) ((x & 0x08) == 0x08) #define IsRook(x) ((x & 0x04) == 0x04) #define IsQueen(x) ((x & 0x02) == 0x02) #define IsKing(x) ((x & 0x01) == 00x01) #define IsNotPawn(x) ((x & 0x20) != 0x20) #define IsNotKnight(x) ((x & 0x10) != 0x10) #define IsNotBishop(x) ((x & 0x08) != 0x08) #define IsNotRook(x) ((x & 0x04) != 0x04) #define IsNotQueen(x) ((x & 0x02) != 0x02) #define IsNotKing(x) ((x & 0x01) != 0x01) #define BlackPawn 0b10100000 #define WhitePawn 0b11100000 #define BlackKnight 0b10010000 #define WhiteKnight 0b11010000 #define BlackBishop 0b10001000 #define WhiteBishop 0b11001000 #define BlackRook 0b10000100 #define WhiteRook 0b11000100 #define BlackQueen 0b10000010 #define WhiteQueen 0b11000010 #define BlackKing 0b10000001 #define WhiteKing 0b11000001 #define EmptyTile 0b00000000 unsigned char INDEXtoPIECES[] = { BlackPawn, BlackPawn, WhitePawn, WhitePawn, BlackKnight, BlackKnight, WhiteKnight, WhiteKnight, BlackBishop, BlackBishop, WhiteBishop, WhiteBishop, BlackRook, BlackRook, WhiteRook, WhiteRook, BlackQueen, BlackQueen, WhiteQueen, WhiteQueen, BlackKing, BlackKing, WhiteKing, WhiteKing, EmptyTile, EmptyTile}; unsigned char board[8][8]; unsigned char OldBoard[8][8]; unsigned char ScanBoard[8][8]; #define A1 board[0,0]; #define A2 board[0,1]; #define A3 board[0,2]; #define A4 board[0,3]; #define A5 board[0,4]; #define A6 board[0,5]; #define A7 board[0,6]; #define A8 board[0,7]; #define B1 board[1,0]; #define B2 board[1,1]; #define B3 board[1,2]; #define B4 board[1,3]; #define B5 board[1,4]; #define B6 board[1,5]; #define B7 board[1,6]; #define B8 board[1,7]; #define C1 board[2,0]; #define C2 board[2,1]; #define C3 board[2,2]; #define C4 board[2,3]; #define C5 board[2,4]; #define C6 board[2,5]; #define C7 board[2,6]; #define C8 board[2,7]; #define D1 board[3,0]; #define D2 board[3,1]; #define D3 board[3,2]; #define D4 board[3,3]; #define D5 board[3,4]; #define D6 board[3,5]; #define D7 board[3,6]; #define D8 board[3,7]; #define E1 board[4,0]; #define E2 board[4,1]; #define E3 board[4,2]; #define E4 board[4,3]; #define E5 board[4,4]; #define E6 board[4,5]; #define E7 board[4,6]; #define E8 board[4,7]; #define F1 board[5,0]; #define F2 board[5,1]; #define F3 board[5,2]; #define F4 board[5,3]; #define F5 board[5,4]; #define F6 board[5,5]; #define F7 board[5,6]; #define F8 board[5,7]; #define G1 board[6,0]; #define G2 board[6,1]; #define G3 board[6,2]; #define G4 board[6,3]; #define G5 board[6,4]; #define G6 board[6,5]; #define G7 board[6,6]; #define G8 board[6,7]; #define H1 board[7,0]; #define H2 board[7,1]; #define H3 board[7,2]; #define H4 board[7,3]; #define H5 board[7,4]; #define H6 board[7,5]; #define H7 board[7,6]; #define H8 board[7,7]; #define PAWN 0 #define KNIGHT 4 #define BISHOP 8 #define ROOK 12 #define QUEEN 16 #define KING 20 #define TILE 24 flash char PIECES[26][7]={ //0 Black Pawn, Black Tile 0b00000000, 0b00000000, 0b00011000, 0b00100100, 0b00011000, 0b00100100, 0b01000010, //1 Black Pawn, White Tile 0b11111111, 0b11111111, 0b11100111, 0b11000011, 0b11100111, 0b11000011, 0b10000001, //2 White Pawn, Black Tile 0b00000000, 0b00000000, 0b00011000, 0b00111100, 0b00011000, 0b00111100, 0b01111110, //3 White Pawn, White Tile 0b11111111, 0b11111111, 0b11100111, 0b11011011, 0b11100111, 0b11011011, 0b10111101, //4 Black Knight, Black Tile 0b00101000, 0b00111100, 0b01000100, 0b10010010, 0b01100010, 0b00010001, 0b00111111, //5 Black Knight, White Tile 0b11010111, 0b11000011, 0b10000011, 0b00010001, 0b10110001, 0b11100000, 0b11000000, //6 White Knight, Black Tile 0b00101000, 0b00111100, 0b01111100, 0b11101110, 0b01001110, 0b00011111, 0b00111111, //7 White Knight, White Tile 0b11010111, 0b11000011, 0b10111011, 0b01101101, 0b10011101, 0b11101110, 0b11000000, //8 Black Bishop, Black Tile 0b00100100, 0b01000010, 0b01011010, 0b01000010, 0b00100100, 0b01000010, 0b11111111, //9 Black Bishop, White Tile 0b11100111, 0b11000011, 0b11011011, 0b11000011, 0b11100111, 0b10000001, 0b00000000, //10 White Bishop, Black Tile 0b00011000, 0b00111100, 0b00100100, 0b00111100, 0b00011000, 0b01111110, 0b11111111, //11 White Bishop, White Tile 0b11011011, 0b10111101, 0b10100101, 0b10111101, 0b11011011, 0b10111101, 0b00000000, //12 Black Rook, Black Tile 0b10011001, 0b10011001, 0b11100111, 0b00100100, 0b00100100, 0b00100100, 0b11000011, //13 Black Rook, White Tile 0b01100110, 0b01100110, 0b00000000, 0b00000000, 0b11000011, 0b11000011, 0b00000000, //22 White Rook, Black Tile 0b10011001, 0b10011001, 0b11111111, 0b11111111, 0b00111100, 0b00111100, 0b11111111, //15 White Rook, White Tile 0b01100110, 0b01100110, 0b00011000, 0b11011011, 0b11011011, 0b11011011, 0b00111100, //16 Black Queen, Black Tile 0b10100101, 0b10100101, 0b10100101, 0b01011010, 0b01000010, 0b00100100, 0b11000011, //17 Black Queen, White Tile 0b01011010, 0b01011010, 0b01011010, 0b10000001, 0b10000001, 0b11000011, 0b00000000, //18 White Queen, Black Tile 0b10100101, 0b10100101, 0b10100101, 0b01111110, 0b01111110, 0b00111100, 0b11111111, //19 White Queen, White Tile 0b01011010, 0b01011010, 0b01011010, 0b10100101, 0b10111101, 0b11011011, 0b00111100, //20 Black King, Black Tile 0b00011000, 0b01011010, 0b10100101, 0b01000010, 0b00100100, 0b00011000, 0b01100110, //21 Black King, White Tile 0b11100111, 0b10100101, 0b00000000, 0b10000001, 0b11000011, 0b11100111, 0b10000001, //22 White King, Black Tile 0b00011000, 0b01011010, 0b11111111, 0b01111110, 0b00111100, 0b00011000, 0b01111110, //23 White King, White Tile 0b11100111, 0b10100101, 0b01011010, 0b10111101, 0b11011011, 0b11100111, 0b10011001, //24 Black Tile 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, //25 White Tile 0b11111111, 0b11111111, 0b11111111, 0b11111111, 0b11111111, 0b11111111, 0b11111111}; flash char bitmap[26][7]={ //0 bishop_bb 0b00100100, 0b01000010, 0b01011010, 0b01000010, 0b00100100, 0b01000010, 0b11111111, //1 bishop_wb 0b11100111, 0b11000011, 0b11011011, 0b11000011, 0b11100111, 0b10000001, 0b00000000, //2 bishop_bw 0b00011000, 0b00111100, 0b00100100, 0b00111100, 0b00011000, 0b01111110, 0b11111111, //3 bishop_ww 0b11011011, 0b10111101, 0b10100101, 0b10111101, 0b11011011, 0b10111101, 0b00000000, //4 king_bb 0b00011000, 0b01011010, 0b10100101, 0b01000010, 0b00100100, 0b00011000, 0b01100110, //5 king_wb 0b11100111, 0b10100101, 0b00000000, 0b10000001, 0b11000011, 0b11100111, 0b10000001, //6 king_bw 0b00011000, 0b01011010, 0b11111111, 0b01111110, 0b00111100, 0b00011000, 0b01111110, //7 king_ww 0b11100111, 0b10100101, 0b01011010, 0b10111101, 0b11011011, 0b11100111, 0b10011001, //8 knight_bb 0b00101000, 0b00111100, 0b01000100, 0b10010010, 0b01100010, 0b00010001, 0b00111111, //9 knight_wb 0b11010111, 0b11000011, 0b10000011, 0b00010001, 0b10110001, 0b11100000, 0b11000000, //10 knight_bw 0b00101000, 0b00111100, 0b01111100, 0b11101110, 0b01001110, 0b00011111, 0b00111111, //11 knight_ww 0b11010111, 0b11000011, 0b10111011, 0b01101101, 0b10011101, 0b11101110, 0b11000000, //12 pawn_bb 0b00000000, 0b00000000, 0b00011000, 0b00100100, 0b00011000, 0b00100100, 0b01000010, //13 pawn_wb 0b11111111, 0b11111111, 0b11100111, 0b11000011, 0b11100111, 0b11000011, 0b10000001, //14 pawn_bw 0b00000000, 0b00000000, 0b00011000, 0b00111100, 0b00011000, 0b00111100, 0b01111110, //15 pawn_ww 0b11111111, 0b11111111, 0b11100111, 0b11011011, 0b11100111, 0b11011011, 0b10111101, //16 queen_bb 0b10100101, 0b10100101, 0b10100101, 0b01011010, 0b01000010, 0b00100100, 0b11000011, //17 queen_wb 0b01011010, 0b01011010, 0b01011010, 0b10000001, 0b10000001, 0b11000011, 0b00000000, //18 queen_bw 0b10100101, 0b10100101, 0b10100101, 0b01111110, 0b01111110, 0b00111100, 0b11111111, //19 queen_ww 0b01011010, 0b01011010, 0b01011010, 0b10100101, 0b10111101, 0b11011011, 0b00111100, //20 rook_bb 0b10011001, 0b10011001, 0b11100111, 0b00100100, 0b00100100, 0b00100100, 0b11000011, //21 rook_wb 0b01100110, 0b01100110, 0b00000000, 0b00000000, 0b11000011, 0b11000011, 0b00000000, //22 rook_bw 0b10011001, 0b10011001, 0b11111111, 0b11111111, 0b00111100, 0b00111100, 0b11111111, //23 rook_ww 0b01100110, 0b01100110, 0b00011000, 0b11011011, 0b11011011, 0b11011011, 0b00111100, //24 black 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, //25 white 0b11111111, 0b11111111, 0b11111111, 0b11111111, 0b11111111, 0b11111111, 0b11111111};