/*ACKNOWLEDGEMENTS: We consulted and used parts of the graphics and chess functionality software of the following ECE 4760 (formerly ECE 476) final project groups: "Remote Chess" Spring, 2008 Erik Jarva eaj24@cornell.edu William Baughman wpb3@cornell.edu In addition, we received help and advice from the Spring, 2012 TAs and from Professor Bruce Land. We used the graphics functionality that can be found on the ECE 4760 course website: http://people.ece.cornell.edu/land/courses/ece4760/video/videoGCC/UARTvideo/video_192x150_20MHz_uart_GCC644.c */ ////////////////////////////////////////////////////////////////////////////// #include #include #include #include #include #include #include #include #include /////////////////////////////////////// // C0 C1 C2 C3 C4 C5 C6 C7 //A0 //A1 //A2 //A3 //A4 //A5 //A6 //A7 /////////////////////////////////////// #define loc_deb_lim 10 volatile unsigned char location_piece=250; volatile unsigned char loc_deb=-1; volatile unsigned char loc_deb_count=0; unsigned char old_location_piece=251; unsigned char possible=0; unsigned char start_move_x=240; unsigned char start_move_y=241; unsigned char stop_move_x=242; unsigned char stop_move_y=243; volatile unsigned char turn=0; char SolidKingHasMoved = 0; char HollowKingHasMoved = 0; char SolidKingSideRookHasMoved = 0; char SolidQueenSideRookHasMoved = 0; char HollowKingSideRookHasMoved = 0; char HollowQueenSideRookHasMoved = 0; char SolidCastleKingSide = 0; char SolidCastleQueenSide = 0; char HollowCastleKingSide = 0; char HollowCastleQueenSide = 0; unsigned char choosePiece=0; //piece chosen unsigned char moveToDestination=1; //moving to destination //the task subroutine void task1(void); void initializeLocation(void); void initialize(void); int getTileColor(unsigned char); //cycles = 63.625 * 16 Note NTSC is 63.55 //but this line duration makes each frame exactly 1/60 sec //which is nice for keeping a realtime clock #define lineTime 1018 #define sleepTime 1038 //around 20 more than lineTime #NEW TIMER CODE #define ScreenTop 30 #define ScreenBot 200 #define mapHollowPawnBlackTile 0 #define mapSolidPawnWhiteTile 1 #define mapSolidPawnBlackTile 2 #define mapHollowPawnWhiteTile 3 #define mapHollowKnightBlackTile 4 #define mapSolidKnightWhiteTile 5 #define mapSolidKnightBlackTile 6 #define mapHollowKnightWhiteTile 7 #define mapHollowBishopBlackTile 8 #define mapSolidBishopWhiteTile 9 #define mapSolidBishopBlackTile 10 #define mapHollowBishopWhiteTile 11 #define mapHollowRookBlackTile 12 #define mapSolidRookWhiteTile 13 #define mapSolidRookBlackTile 14 #define mapHollowRookWhiteTile 15 #define mapHollowQueenBlackTile 16 #define mapSolidQueenWhiteTile 17 #define mapSolidQueenBlackTile 18 #define mapHollowQueenWhiteTile 19 #define mapHollowKingBlackTile 20 #define mapSolidKingWhiteTile 21 #define mapSolidKingBlackTile 22 #define mapHollowKingWhiteTile 23 #define mapBlackTile 24 #define mapWhiteTile 25 #define begin { #define end } //sync char syncON, syncOFF; //current line number in the current frame volatile int LineCount; volatile unsigned int a=0; volatile unsigned int t; //200 x 144 - screen buffer and pointer char screen[3060]; int* screenindex; //One bit masks char pos[8] = {0x80,0x40,0x20,0x10,0x08,0x04,0x02,0x01}; //initialize board containing 0 for unoccupied cells and 1 for occupied cells char tileboard[8][8]={ 1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1, 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, 2,2,2,2,2,2,2,2, 2,2,2,2,2,2,2,2 }; //increment x-coordinate by 17 instead of 15 char boardloc[64][2]={ 9,//10+15*0, 15,//15+20*0, 24,//10+15*1, 15,//15+20*0, 41,//10+15*2, 15,//15+20*0, 58,//10+15*3, 15,//15+20*0, 75,//10+15*4, 15,//15+20*0, 92,//10+15*5, 15,//15+20*0, 109,//10+15*6, 15,//15+20*0, 126,//10+15*7, 15,//15+20*0, 9,//10+15*0, 35,//15+20*1, 24,//10+15*1, 35,//15+20*1, 41,//10+15*2, 35,//15+20*1, 58,//10+15*3, 35,//15+20*1, 75,//10+15*4, 35,//15+20*1, 92,//10+15*5, 35,//15+20*1, 109,//10+15*6, 35,//15+20*1, 126,//10+15*7, 55,//15+20*1, 9,//10+15*0, 55,//15+20*2, 24,//10+15*1, 55,//15+20*2, 41,//10+15*2, 55,//15+20*2, 58,//10+15*3, 55,//15+20*2, 75,//10+15*4, 55,//15+20*2, 92,//10+15*5, 55,//15+20*2, 109,//10+15*6, 55,//15+20*2, 126,//10+15*7, 55,//15+20*2, 9,//10+15*0, 75,//15+20*3, 24,//10+15*1, 75,//15+20*3, 41,//10+15*2, 75,//15+20*3, 58,//10+15*3, 75,//15+20*3, 75,//10+15*4, 75,//15+20*3, 92,//10+15*5, 75,//15+20*3, 109,//10+15*6, 75,//15+20*3, 126,//10+15*7, 75,//15+20*3, 9,//10+15*0, 95,//15+20*4, 24,//10+15*1, 95,//15+20*4, 41,//10+15*2, 95,//15+20*4, 58,//10+15*3, 95,//15+20*4, 75,//10+15*4, 95,//15+20*4, 92,//10+15*5, 95,//15+20*4, 109,//10+15*6, 95,//15+20*4, 126,//10+15*7, 95,//15+20*4, 9,//10+15*0, 115,//15+20*5, 24,//10+15*1, 115,//15+20*5, 41,//10+15*2, 115,//15+20*5, 58,//10+15*3, 115,//15+20*5, 75,//10+15*4, 115,//15+20*5, 92,//10+15*5, 115,//15+20*5, 109,//10+15*6, 115,//15+20*5, 126,//10+15*7, 115,//15+20*5, 9,//10+15*0, 135,//15+20*6, 24,//10+15*1, 135,//15+20*6, 41,//10+15*2, 135,//15+20*6, 58,//10+15*3, 135,//15+20*6, 75,//10+15*4, 135,//15+20*6, 92,//10+15*5, 135,//15+20*6, 109,//10+15*6, 135,//15+20*6, 126,//10+15*7, 135,//15+20*6, 9,//10+15*0, 155,//15+20*7, 24,//10+15*1, 155,//15+20*7, 41,//10+15*2, 155,//15+20*7, 58,//10+15*3, 155,//15+20*7, 75,//10+15*4, 155,//15+20*7, 92,//10+15*5, 155,//15+20*7, 109,//10+15*6, 155,//15+20*7, 126,//10+15*7, 155//15+20*7 }; //================================ //3x5 font numbers, then letters //packed two per definition for fast //copy to the screen at x-position divisible by 4 prog_char smallbitmap[39][5] = { //0 0b11101110, 0b10101010, 0b10101010, 0b10101010, 0b11101110, //1 0b01000100, 0b11001100, 0b01000100, 0b01000100, 0b11101110, //2 0b11101110, 0b00100010, 0b11101110, 0b10001000, 0b11101110, //3 0b11101110, 0b00100010, 0b11101110, 0b00100010, 0b11101110, //4 0b10101010, 0b10101010, 0b11101110, 0b00100010, 0b00100010, //5 0b11101110, 0b10001000, 0b11101110, 0b00100010, 0b11101110, //6 0b11001100, 0b10001000, 0b11101110, 0b10101010, 0b11101110, //7 0b11101110, 0b00100010, 0b01000100, 0b10001000, 0b10001000, //8 0b11101110, 0b10101010, 0b11101110, 0b10101010, 0b11101110, //9 0b11101110, 0b10101010, 0b11101110, 0b00100010, 0b01100110, //: 0b00000000, 0b01000100, 0b00000000, 0b01000100, 0b00000000, //= 0b00000000, 0b11101110, 0b00000000, 0b11101110, 0b00000000, //blank 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, //A 0b11101110, 0b10101010, 0b11101110, 0b10101010, 0b10101010, //B 0b11001100, 0b10101010, 0b11101110, 0b10101010, 0b11001100, //C 0b11101110, 0b10001000, 0b10001000, 0b10001000, 0b11101110, //D 0b11001100, 0b10101010, 0b10101010, 0b10101010, 0b11001100, //E 0b11101110, 0b10001000, 0b11101110, 0b10001000, 0b11101110, //F 0b11101110, 0b10001000, 0b11101110, 0b10001000, 0b10001000, //G 0b11101110, 0b10001000, 0b10001000, 0b10101010, 0b11101110, //H 0b10101010, 0b10101010, 0b11101110, 0b10101010, 0b10101010, //I 0b11101110, 0b01000100, 0b01000100, 0b01000100, 0b11101110, //J 0b00100010, 0b00100010, 0b00100010, 0b10101010, 0b11101110, //K 0b10001000, 0b10101010, 0b11001100, 0b11001100, 0b10101010, //L 0b10001000, 0b10001000, 0b10001000, 0b10001000, 0b11101110, //M 0b10101010, 0b11101110, 0b11101110, 0b10101010, 0b10101010, //N 0b00000000, 0b11001100, 0b10101010, 0b10101010, 0b10101010, //O 0b01000100, 0b10101010, 0b10101010, 0b10101010, 0b01000100, //P 0b11101110, 0b10101010, 0b11101110, 0b10001000, 0b10001000, //Q 0b01000100, 0b10101010, 0b10101010, 0b11101110, 0b01100110, //R 0b11101110, 0b10101010, 0b11001100, 0b11101110, 0b10101010, //S 0b11101110, 0b10001000, 0b11101110, 0b00100010, 0b11101110, //T 0b11101110, 0b01000100, 0b01000100, 0b01000100, 0b01000100, //U 0b10101010, 0b10101010, 0b10101010, 0b10101010, 0b11101110, //V 0b10101010, 0b10101010, 0b10101010, 0b10101010, 0b01000100, //W 0b10101010, 0b10101010, 0b11101110, 0b11101110, 0b10101010, //X 0b00000000, 0b10101010, 0b01000100, 0b01000100, 0b10101010, //Y 0b10101010, 0b10101010, 0b01000100, 0b01000100, 0b01000100, //Z 0b11101110, 0b00100010, 0b01000100, 0b10001000, 0b11101110 }; //=============================================== // Full 5x7 char set // Designed by: David Perez de la Cruz,and Ed Lau // see: http://instruct1.cit.cornell.edu/courses/ee476/FinalProjects/s2005/dp93/index.html prog_char ascii[128][7] = { /* //0 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, //1 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, //2 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, //3 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, //4 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, //5 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, //6 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, //7 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, //8 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, //9 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, //10 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, //11 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, //12 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, //13 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, //14 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, //15 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, //16 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, //17 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, //18 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, //19 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, //20 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, //21 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, //22 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, //23 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000,*/ //0 Hollow Pawn, Black Tile 0b00000000, 0b00000000, 0b00011000, 0b00100100, 0b00011000, 0b00100100, 0b01000010, //1 Solid Pawn, White Tile 0b11111111, 0b11111111, 0b11100111, 0b11000011, 0b11100111, 0b11000011, 0b10000001, //2 Solid Pawn, Black Tile 0b00000000, 0b00000000, 0b00011000, 0b00111100, 0b00011000, 0b00111100, 0b01111110, //3 Hollow Pawn, White Tile 0b11111111, 0b11111111, 0b11100111, 0b11011011, 0b11100111, 0b11011011, 0b10111101, //4 Hollow Knight, Black Tile 0b00101000, 0b00111100, 0b01000100, 0b10010010, 0b01100010, 0b00010001, 0b00111111, //5 Solid Knight, White Tile 0b11010111, 0b11000011, 0b10000011, 0b00010001, 0b10110001, 0b11100000, 0b11000000, //6 Solid Knight, Black Tile 0b00101000, 0b00111100, 0b01111100, 0b11101110, 0b01001110, 0b00011111, 0b00111111, //7 Hollow Knight, White Tile 0b11010111, 0b11000011, 0b10111011, 0b01101101, 0b10011101, 0b11101110, 0b11000000, //8 Hollow Bishop, Black Tile 0b00100100, 0b01000010, 0b01011010, 0b01000010, 0b00100100, 0b01000010, 0b11111111, //9 Solid Bishop, White Tile 0b11100111, 0b11000011, 0b11011011, 0b11000011, 0b11100111, 0b10000001, 0b00000000, //10 Solid Bishop, Black Tile 0b00011000, 0b00111100, 0b00100100, 0b00111100, 0b00011000, 0b01111110, 0b11111111, //11 Hollow Bishop, White Tile 0b11011011, 0b10111101, 0b10100101, 0b10111101, 0b11011011, 0b10111101, 0b00000000, //12 Hollow Rook, Black Tile 0b10011001, 0b10011001, 0b11100111, 0b00100100, 0b00100100, 0b00100100, 0b11000011, //13 Solid Rook, White Tile 0b01100110, 0b01100110, 0b00000000, 0b00000000, 0b11000011, 0b11000011, 0b00000000, //14 Solid Rook, Black Tile 0b10011001, 0b10011001, 0b11111111, 0b11111111, 0b00111100, 0b00111100, 0b11111111, //15 Hollow Rook, White Tile 0b01100110, 0b01100110, 0b00011000, 0b11011011, 0b11011011, 0b11011011, 0b00111100, //16 Black Queen, Black Tile 0b10100101, 0b10100101, 0b10100101, 0b01011010, 0b01000010, 0b00100100, 0b11000011, //17 Solid Queen, White Tile 0b01011010, 0b01011010, 0b01011010, 0b10000001, 0b10000001, 0b11000011, 0b00000000, //18 Solid Queen, Black Tile 0b10100101, 0b10100101, 0b10100101, 0b01111110, 0b01111110, 0b00111100, 0b11111111, //19 Hollow Queen, White Tile 0b01011010, 0b01011010, 0b01011010, 0b10100101, 0b10111101, 0b11011011, 0b00111100, //20 Hollow King, Black Tile 0b00011000, 0b01011010, 0b10100101, 0b01000010, 0b00100100, 0b00011000, 0b01100110, //21 Solid King, White Tile 0b11100111, 0b10100101, 0b00000000, 0b10000001, 0b11000011, 0b11100111, 0b10000001, //22 Solid King, Black Tile 0b00011000, 0b01011010, 0b11111111, 0b01111110, 0b00111100, 0b00011000, 0b01111110, //23 Hollow King, White Tile 0b11100111, 0b10100101, 0b01011010, 0b10111101, 0b11011011, 0b11100111, 0b10011001, /////////////////////////////////////////////////////////////////////////////////////// //24 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, //25 0b11111111, 0b11111111, 0b11111111, 0b11111111, 0b11111111, 0b11111111, 0b11111111, //26 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, //27 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, //28 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, //29 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, //30 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, //31 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, //32 Space 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, //33 Exclamation ! 0b01100000, 0b01100000, 0b01100000, 0b01100000, 0b00000000, 0b00000000, 0b01100000, //34 Quotes " 0b01010000, 0b01010000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, //35 Number # 0b00000000, 0b01010000, 0b11111000, 0b01010000, 0b11111000, 0b01010000, 0b00000000, //36 Dollars $ 0b01110000, 0b10100000, 0b10100000, 0b01110000, 0b00101000, 0b00101000, 0b01110000, //37 Percent % 0b01000000, 0b10101000, 0b01010000, 0b00100000, 0b01010000, 0b10101000, 0b00010000, //38 Ampersand & 0b00100000, 0b01010000, 0b10100000, 0b01000000, 0b10101000, 0b10010000, 0b01101000, //39 Single Quote ' 0b01000000, 0b01000000, 0b01000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, //40 Left Parenthesis ( 0b00010000, 0b00100000, 0b01000000, 0b01000000, 0b01000000, 0b00100000, 0b00010000, //41 Right Parenthesis ) 0b01000000, 0b00100000, 0b00010000, 0b00010000, 0b00010000, 0b00100000, 0b01000000, //42 Star * 0b00010000, 0b00111000, 0b00010000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, //43 Plus + 0b00000000, 0b00100000, 0b00100000, 0b11111000, 0b00100000, 0b00100000, 0b00000000, //44 Comma , 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00010000, 0b00010000, //45 Minus - 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b11111000, 0b00000000, 0b00000000, //46 Period . 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00010000, // 47 Backslash / 0b00000000, 0b00001000, 0b00010000, 0b00100000, 0b01000000, 0b10000000, 0b00000000, // 48 Zero 0b01110000, 0b10001000, 0b10011000, 0b10101000, 0b11001000, 0b10001000, 0b01110000, //49 One 0b00100000, 0b01100000, 0b00100000, 0b00100000, 0b00100000, 0b00100000, 0b01110000, //50 two 0b01110000, 0b10001000, 0b00001000, 0b00010000, 0b00100000, 0b01000000, 0b11111000, //51 Three 0b11111000, 0b00010000, 0b00100000, 0b00010000, 0b00001000, 0b10001000, 0b01110000, //52 Four 0b00010000, 0b00110000, 0b01010000, 0b10010000, 0b11111000, 0b00010000, 0b00010000, //53 Five 0b11111000, 0b10000000, 0b11110000, 0b00001000, 0b00001000, 0b10001000, 0b01110000, //54 Six 0b01000000, 0b10000000, 0b10000000, 0b11110000, 0b10001000, 0b10001000, 0b01110000, //55 Seven 0b11111000, 0b00001000, 0b00010000, 0b00100000, 0b01000000, 0b10000000, 0b10000000, //56 Eight 0b01110000, 0b10001000, 0b10001000, 0b01110000, 0b10001000, 0b10001000, 0b01110000, //57 Nine 0b01110000, 0b10001000, 0b10001000, 0b01111000, 0b00001000, 0b00001000, 0b00010000, //58 : 0b00000000, 0b00000000, 0b00100000, 0b00000000, 0b00000000, 0b00000000, 0b00100000, //59 ; 0b00000000, 0b00000000, 0b00100000, 0b00000000, 0b00000000, 0b00100000, 0b00100000, //60 < 0b00000000, 0b00011000, 0b01100000, 0b10000000, 0b01100000, 0b00011000, 0b00000000, //61 = 0b00000000, 0b00000000, 0b01111000, 0b00000000, 0b01111000, 0b00000000, 0b00000000, //62 > 0b00000000, 0b11000000, 0b00110000, 0b00001000, 0b00110000, 0b11000000, 0b00000000, //63 ? 0b00110000, 0b01001000, 0b00010000, 0b00100000, 0b00100000, 0b00000000, 0b00100000, //64 @ 0b01110000, 0b10001000, 0b10111000, 0b10101000, 0b10010000, 0b10001000, 0b01110000, //65 A 0b01110000, 0b10001000, 0b10001000, 0b10001000, 0b11111000, 0b10001000, 0b10001000, //B 0b11110000, 0b10001000, 0b10001000, 0b11110000, 0b10001000, 0b10001000, 0b11110000, //C 0b01110000, 0b10001000, 0b10000000, 0b10000000, 0b10000000, 0b10001000, 0b01110000, //D 0b11110000, 0b10001000, 0b10001000, 0b10001000, 0b10001000, 0b10001000, 0b11110000, //E 0b11111000, 0b10000000, 0b10000000, 0b11111000, 0b10000000, 0b10000000, 0b11111000, //F 0b11111000, 0b10000000, 0b10000000, 0b11111000, 0b10000000, 0b10000000, 0b10000000, //G 0b01110000, 0b10001000, 0b10000000, 0b10011000, 0b10001000, 0b10001000, 0b01110000, //H 0b10001000, 0b10001000, 0b10001000, 0b11111000, 0b10001000, 0b10001000, 0b10001000, //I 0b01110000, 0b00100000, 0b00100000, 0b00100000, 0b00100000, 0b00100000, 0b01110000, //J 0b00111000, 0b00010000, 0b00010000, 0b00010000, 0b00010000, 0b10010000, 0b01100000, //K 0b10001000, 0b10010000, 0b10100000, 0b11000000, 0b10100000, 0b10010000, 0b10001000, //L 0b10000000, 0b10000000, 0b10000000, 0b10000000, 0b10000000, 0b10000000, 0b11111000, //M 0b10001000, 0b11011000, 0b10101000, 0b10101000, 0b10001000, 0b10001000, 0b10001000, //N 0b10001000, 0b10001000, 0b11001000, 0b10101000, 0b10011000, 0b10001000, 0b10001000, //O 0b01110000, 0b10001000, 0b10001000, 0b10001000, 0b10001000, 0b10001000, 0b01110000, //P 0b11110000, 0b10001000, 0b10001000, 0b11110000, 0b10000000, 0b10000000, 0b10000000, //Q 0b01110000, 0b10001000, 0b10001000, 0b10001000, 0b10101000, 0b10010000, 0b01101000, //R 0b11110000, 0b10001000, 0b10001000, 0b11110000, 0b10100000, 0b10010000, 0b10001000, //S 0b01111000, 0b10000000, 0b10000000, 0b01110000, 0b00001000, 0b00001000, 0b11110000, //T 0b11111000, 0b00100000, 0b00100000, 0b00100000, 0b00100000, 0b00100000, 0b00100000, //U 0b10001000, 0b10001000, 0b10001000, 0b10001000, 0b10001000, 0b10001000, 0b01110000, //V 0b10001000, 0b10001000, 0b10001000, 0b10001000, 0b10001000, 0b01010000, 0b00100000, //W 0b10001000, 0b10001000, 0b10001000, 0b10101000, 0b10101000, 0b10101000, 0b01010000, //X 0b10001000, 0b10001000, 0b01010000, 0b00100000, 0b01010000, 0b10001000, 0b10001000, //Y 0b10001000, 0b10001000, 0b10001000, 0b01010000, 0b00100000, 0b00100000, 0b00100000, //Z 0b11111000, 0b00001000, 0b00010000, 0b00100000, 0b01000000, 0b10000000, 0b11111000, //91 [ 0b11100000, 0b10000000, 0b10000000, 0b10000000, 0b10000000, 0b10000000, 0b11100000, //92 (backslash) 0b00000000, 0b10000000, 0b01000000, 0b00100000, 0b00010000, 0b00001000, 0b00000000, //93 ] 0b00111000, 0b00001000, 0b00001000, 0b00001000, 0b00001000, 0b00001000, 0b00111000, //94 ^ 0b00100000, 0b01010000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, //95 _ 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b11111000, //96 ` 0b10000000, 0b01000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, //97 a 0b00000000, 0b01100000, 0b00010000, 0b01110000, 0b10010000, 0b01100000, 0b00000000, //98 b 0b10000000, 0b10000000, 0b11100000, 0b10010000, 0b10010000, 0b11100000, 0b00000000, //99 c 0b00000000, 0b00000000, 0b01110000, 0b10000000, 0b10000000, 0b01110000, 0b00000000, // 100 d 0b00010000, 0b00010000, 0b01110000, 0b10010000, 0b10010000, 0b01110000, 0b00000000, //101 e 0b00000000, 0b01100000, 0b10010000, 0b11110000, 0b10000000, 0b01110000, 0b00000000, //102 f 0b00110000, 0b01000000, 0b11100000, 0b01000000, 0b01000000, 0b01000000, 0b00000000, //103 g 0b00000000, 0b01100000, 0b10010000, 0b01110000, 0b00010000, 0b00010000, 0b01100000, //104 h 0b10000000, 0b10000000, 0b11100000, 0b10010000, 0b10010000, 0b10010000, 0b00000000, //105 i 0b00000000, 0b00100000, 0b00000000, 0b00100000, 0b00100000, 0b00100000, 0b00000000, //106 j 0b00000000, 0b00010000, 0b00000000, 0b00010000, 0b00010000, 0b00010000, 0b01100000, //107 k 0b10000000, 0b10010000, 0b10100000, 0b11000000, 0b10100000, 0b10010000, 0b00000000, //108 l 0b00100000, 0b00100000, 0b00100000, 0b00100000, 0b00100000, 0b00100000, 0b00000000, //109 m 0b00000000, 0b00000000, 0b01010000, 0b10101000, 0b10101000, 0b10101000, 0b00000000, //110 n 0b00000000, 0b00000000, 0b01100000, 0b10010000, 0b10010000, 0b10010000, 0b00000000, //111 o 0b00000000, 0b00000000, 0b01100000, 0b10010000, 0b10010000, 0b01100000, 0b00000000, //112 p 0b00000000, 0b00000000, 0b01100000, 0b10010000, 0b11110000, 0b10000000, 0b10000000, //113 q 0b00000000, 0b00000000, 0b01100000, 0b10010000, 0b11110000, 0b00010000, 0b00010000, //114 r 0b00000000, 0b00000000, 0b10111000, 0b01000000, 0b01000000, 0b01000000, 0b00000000, //115 s 0b00000000, 0b00000000, 0b01110000, 0b01000000, 0b00010000, 0b01110000, 0b00000000, //116 t 0b01000000, 0b01000000, 0b11100000, 0b01000000, 0b01000000, 0b01000000, 0b00000000, // 117u 0b00000000, 0b00000000, 0b10010000, 0b10010000, 0b10010000, 0b01100000, 0b00000000, //118 v 0b00000000, 0b00000000, 0b10001000, 0b10001000, 0b01010000, 0b00100000, 0b00000000, //119 w 0b00000000, 0b00000000, 0b10101000, 0b10101000, 0b01010000, 0b01010000, 0b00000000, //120 x 0b00000000, 0b00000000, 0b10010000, 0b01100000, 0b01100000, 0b10010000, 0b00000000, //121 y 0b00000000, 0b00000000, 0b10010000, 0b10010000, 0b01100000, 0b01000000, 0b10000000, //122 z 0b00000000, 0b00000000, 0b11110000, 0b00100000, 0b01000000, 0b11110000, 0b00000000, //123 { 0b00100000, 0b01000000, 0b01000000, 0b10000000, 0b01000000, 0b01000000, 0b00100000, //124 | 0b00100000, 0b00100000, 0b00100000, 0b00100000, 0b00100000, 0b00100000, 0b00100000, //125 } 0b00100000, 0b00010000, 0b00010000, 0b00001000, 0b00010000, 0b00010000, 0b00100000, //126 ~ 0b00000000, 0b00000000, 0b01000000, 0b10101000, 0b00010000, 0b00000000, 0b00000000, //127 DEL 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000 }; prog_char ascii2[128][7] = { //0 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, //1 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, //2 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, //3 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, //4 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, //5 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, //6 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, //7 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, //8 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, //9 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, //10 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, //11 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, //12 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, //13 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, //14 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, //15 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, //16 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, //17 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, //18 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, //19 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, //20 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, //21 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, //22 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, //23 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, //24 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, //25 0b11111111, 0b11111111, 0b11111111, 0b11111111, 0b11111111, 0b11111111, 0b11111111, //26 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, //27 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, //28 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, //29 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, //30 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, //31 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, //32 Space 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, //33 Exclamation ! 0b01100000, 0b01100000, 0b01100000, 0b01100000, 0b00000000, 0b00000000, 0b01100000, //34 Quotes " 0b01010000, 0b01010000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, //35 Number # 0b00000000, 0b01010000, 0b11111000, 0b01010000, 0b11111000, 0b01010000, 0b00000000, //36 Dollars $ 0b01110000, 0b10100000, 0b10100000, 0b01110000, 0b00101000, 0b00101000, 0b01110000, //37 Percent % 0b01000000, 0b10101000, 0b01010000, 0b00100000, 0b01010000, 0b10101000, 0b00010000, //38 Ampersand & 0b00100000, 0b01010000, 0b10100000, 0b01000000, 0b10101000, 0b10010000, 0b01101000, //39 Single Quote ' 0b01000000, 0b01000000, 0b01000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, //40 Left Parenthesis ( 0b00010000, 0b00100000, 0b01000000, 0b01000000, 0b01000000, 0b00100000, 0b00010000, //41 Right Parenthesis ) 0b01000000, 0b00100000, 0b00010000, 0b00010000, 0b00010000, 0b00100000, 0b01000000, //42 Star * 0b00010000, 0b00111000, 0b00010000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, //43 Plus + 0b00000000, 0b00100000, 0b00100000, 0b11111000, 0b00100000, 0b00100000, 0b00000000, //44 Comma , 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00010000, 0b00010000, //45 Minus - 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b11111000, 0b00000000, 0b00000000, //46 Period . 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00010000, // 47 Backslash / 0b00000000, 0b00001000, 0b00010000, 0b00100000, 0b01000000, 0b10000000, 0b00000000, // 48 Zero 0b01110000, 0b10001000, 0b10011000, 0b10101000, 0b11001000, 0b10001000, 0b01110000, //49 One 0b00100000, 0b01100000, 0b00100000, 0b00100000, 0b00100000, 0b00100000, 0b01110000, //50 two 0b01110000, 0b10001000, 0b00001000, 0b00010000, 0b00100000, 0b01000000, 0b11111000, //51 Three 0b11111000, 0b00010000, 0b00100000, 0b00010000, 0b00001000, 0b10001000, 0b01110000, //52 Four 0b00010000, 0b00110000, 0b01010000, 0b10010000, 0b11111000, 0b00010000, 0b00010000, //53 Five 0b11111000, 0b10000000, 0b11110000, 0b00001000, 0b00001000, 0b10001000, 0b01110000, //54 Six 0b01000000, 0b10000000, 0b10000000, 0b11110000, 0b10001000, 0b10001000, 0b01110000, //55 Seven 0b11111000, 0b00001000, 0b00010000, 0b00100000, 0b01000000, 0b10000000, 0b10000000, //56 Eight 0b01110000, 0b10001000, 0b10001000, 0b01110000, 0b10001000, 0b10001000, 0b01110000, //57 Nine 0b01110000, 0b10001000, 0b10001000, 0b01111000, 0b00001000, 0b00001000, 0b00010000, //58 : 0b00000000, 0b00000000, 0b00100000, 0b00000000, 0b00000000, 0b00000000, 0b00100000, //59 ; 0b00000000, 0b00000000, 0b00100000, 0b00000000, 0b00000000, 0b00100000, 0b00100000, //60 < 0b00000000, 0b00011000, 0b01100000, 0b10000000, 0b01100000, 0b00011000, 0b00000000, //61 = 0b00000000, 0b00000000, 0b01111000, 0b00000000, 0b01111000, 0b00000000, 0b00000000, //62 > 0b00000000, 0b11000000, 0b00110000, 0b00001000, 0b00110000, 0b11000000, 0b00000000, //63 ? 0b00110000, 0b01001000, 0b00010000, 0b00100000, 0b00100000, 0b00000000, 0b00100000, //64 @ 0b01110000, 0b10001000, 0b10111000, 0b10101000, 0b10010000, 0b10001000, 0b01110000, //65 A 0b01110000, 0b10001000, 0b10001000, 0b10001000, 0b11111000, 0b10001000, 0b10001000, //B 0b11110000, 0b10001000, 0b10001000, 0b11110000, 0b10001000, 0b10001000, 0b11110000, //C 0b01110000, 0b10001000, 0b10000000, 0b10000000, 0b10000000, 0b10001000, 0b01110000, //D 0b11110000, 0b10001000, 0b10001000, 0b10001000, 0b10001000, 0b10001000, 0b11110000, //E 0b11111000, 0b10000000, 0b10000000, 0b11111000, 0b10000000, 0b10000000, 0b11111000, //F 0b11111000, 0b10000000, 0b10000000, 0b11111000, 0b10000000, 0b10000000, 0b10000000, //G 0b01110000, 0b10001000, 0b10000000, 0b10011000, 0b10001000, 0b10001000, 0b01110000, //H 0b10001000, 0b10001000, 0b10001000, 0b11111000, 0b10001000, 0b10001000, 0b10001000, //I 0b01110000, 0b00100000, 0b00100000, 0b00100000, 0b00100000, 0b00100000, 0b01110000, //J 0b00111000, 0b00010000, 0b00010000, 0b00010000, 0b00010000, 0b10010000, 0b01100000, //K 0b10001000, 0b10010000, 0b10100000, 0b11000000, 0b10100000, 0b10010000, 0b10001000, //L 0b10000000, 0b10000000, 0b10000000, 0b10000000, 0b10000000, 0b10000000, 0b11111000, //M 0b10001000, 0b11011000, 0b10101000, 0b10101000, 0b10001000, 0b10001000, 0b10001000, //N 0b10001000, 0b10001000, 0b11001000, 0b10101000, 0b10011000, 0b10001000, 0b10001000, //O 0b01110000, 0b10001000, 0b10001000, 0b10001000, 0b10001000, 0b10001000, 0b01110000, //P 0b11110000, 0b10001000, 0b10001000, 0b11110000, 0b10000000, 0b10000000, 0b10000000, //Q 0b01110000, 0b10001000, 0b10001000, 0b10001000, 0b10101000, 0b10010000, 0b01101000, //R 0b11110000, 0b10001000, 0b10001000, 0b11110000, 0b10100000, 0b10010000, 0b10001000, //S 0b01111000, 0b10000000, 0b10000000, 0b01110000, 0b00001000, 0b00001000, 0b11110000, //T 0b11111000, 0b00100000, 0b00100000, 0b00100000, 0b00100000, 0b00100000, 0b00100000, //U 0b10001000, 0b10001000, 0b10001000, 0b10001000, 0b10001000, 0b10001000, 0b01110000, //V 0b10001000, 0b10001000, 0b10001000, 0b10001000, 0b10001000, 0b01010000, 0b00100000, //W 0b10001000, 0b10001000, 0b10001000, 0b10101000, 0b10101000, 0b10101000, 0b01010000, //X 0b10001000, 0b10001000, 0b01010000, 0b00100000, 0b01010000, 0b10001000, 0b10001000, //Y 0b10001000, 0b10001000, 0b10001000, 0b01010000, 0b00100000, 0b00100000, 0b00100000, //Z 0b11111000, 0b00001000, 0b00010000, 0b00100000, 0b01000000, 0b10000000, 0b11111000, //91 [ 0b11100000, 0b10000000, 0b10000000, 0b10000000, 0b10000000, 0b10000000, 0b11100000, //92 (backslash) 0b00000000, 0b10000000, 0b01000000, 0b00100000, 0b00010000, 0b00001000, 0b00000000, //93 ] 0b00111000, 0b00001000, 0b00001000, 0b00001000, 0b00001000, 0b00001000, 0b00111000, //94 ^ 0b00100000, 0b01010000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, //95 _ 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b11111000, //96 ` 0b10000000, 0b01000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, //97 a 0b00000000, 0b01100000, 0b00010000, 0b01110000, 0b10010000, 0b01100000, 0b00000000, //98 b 0b10000000, 0b10000000, 0b11100000, 0b10010000, 0b10010000, 0b11100000, 0b00000000, //99 c 0b00000000, 0b00000000, 0b01110000, 0b10000000, 0b10000000, 0b01110000, 0b00000000, // 100 d 0b00010000, 0b00010000, 0b01110000, 0b10010000, 0b10010000, 0b01110000, 0b00000000, //101 e 0b00000000, 0b01100000, 0b10010000, 0b11110000, 0b10000000, 0b01110000, 0b00000000, //102 f 0b00110000, 0b01000000, 0b11100000, 0b01000000, 0b01000000, 0b01000000, 0b00000000, //103 g 0b00000000, 0b01100000, 0b10010000, 0b01110000, 0b00010000, 0b00010000, 0b01100000, //104 h 0b10000000, 0b10000000, 0b11100000, 0b10010000, 0b10010000, 0b10010000, 0b00000000, //105 i 0b00000000, 0b00100000, 0b00000000, 0b00100000, 0b00100000, 0b00100000, 0b00000000, //106 j 0b00000000, 0b00010000, 0b00000000, 0b00010000, 0b00010000, 0b00010000, 0b01100000, //107 k 0b10000000, 0b10010000, 0b10100000, 0b11000000, 0b10100000, 0b10010000, 0b00000000, //108 l 0b00100000, 0b00100000, 0b00100000, 0b00100000, 0b00100000, 0b00100000, 0b00000000, //109 m 0b00000000, 0b00000000, 0b01010000, 0b10101000, 0b10101000, 0b10101000, 0b00000000, //110 n 0b00000000, 0b00000000, 0b01100000, 0b10010000, 0b10010000, 0b10010000, 0b00000000, //111 o 0b00000000, 0b00000000, 0b01100000, 0b10010000, 0b10010000, 0b01100000, 0b00000000, //112 p 0b00000000, 0b00000000, 0b01100000, 0b10010000, 0b11110000, 0b10000000, 0b10000000, //113 q 0b00000000, 0b00000000, 0b01100000, 0b10010000, 0b11110000, 0b00010000, 0b00010000, //114 r 0b00000000, 0b00000000, 0b10111000, 0b01000000, 0b01000000, 0b01000000, 0b00000000, //115 s 0b00000000, 0b00000000, 0b01110000, 0b01000000, 0b00010000, 0b01110000, 0b00000000, //116 t 0b01000000, 0b01000000, 0b11100000, 0b01000000, 0b01000000, 0b01000000, 0b00000000, // 117u 0b00000000, 0b00000000, 0b10010000, 0b10010000, 0b10010000, 0b01100000, 0b00000000, //118 v 0b00000000, 0b00000000, 0b10001000, 0b10001000, 0b01010000, 0b00100000, 0b00000000, //119 w 0b00000000, 0b00000000, 0b10101000, 0b10101000, 0b01010000, 0b01010000, 0b00000000, //120 x 0b00000000, 0b00000000, 0b10010000, 0b01100000, 0b01100000, 0b10010000, 0b00000000, //121 y 0b00000000, 0b00000000, 0b10010000, 0b10010000, 0b01100000, 0b01000000, 0b10000000, //122 z 0b00000000, 0b00000000, 0b11110000, 0b00100000, 0b01000000, 0b11110000, 0b00000000, //123 { 0b00100000, 0b01000000, 0b01000000, 0b10000000, 0b01000000, 0b01000000, 0b00100000, //124 | 0b00100000, 0b00100000, 0b00100000, 0b00100000, 0b00100000, 0b00100000, 0b00100000, //125 } 0b00100000, 0b00010000, 0b00010000, 0b00001000, 0b00010000, 0b00010000, 0b00100000, //126 ~ 0b00000000, 0b00000000, 0b01000000, 0b10101000, 0b00010000, 0b00000000, 0b00000000, //127 DEL 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000 }; 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}; 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}; //macro to put a byte to the screen asm(".MACRO videobits\n\t" "BST R4,7\n\t" "BLD R30,5\n\t" "OUT 0x0b,R30\n\t" //"NOP \n\t" "NOP \n\t" "BST R4,6\n\t" "BLD R30,5\n\t" "OUT 0x0b,R30\n\t" //"NOP \n\t" "NOP \n\t" "BST R4,5\n\t" "BLD R30,5\n\t" "OUT 0x0b,R30\n\t" //"NOP \n\t" "NOP \n\t" "BST R4,4\n\t" "BLD R30,5\n\t" "OUT 0x0b,R30\n\t" //"NOP \n\t" "NOP \n\t" "BST R4,3\n\t" "BLD R30,5\n\t" "OUT 0x0b,R30\n\t" //"NOP \n\t" "NOP \n\t" "BST R4,2\n\t" "BLD R30,5\n\t" "OUT 0x0b,R30\n\t" //"NOP \n\t" "NOP \n\t" "BST R4,1\n\t" "BLD R30,5\n\t" "OUT 0x0b,R30\n\t" //"NOP \n\t" "NOP \n\t" "BST R4,0\n\t" "BLD R30,5\n\t" "OUT 0x0b,R30\n\t" ".ENDM\n\t" ); // puts 18 bytes (1 line) to the screen void byteblast() { asm("LDS R26,screenindex\n\t" "LDS R27,screenindex+1\n\t" "LDI R30, 0x40\n\t" "LD R4,X+\n\t" "videobits\n\t" "LD R4,X+\n\t" "videobits\n\t" "LD R4,X+\n\t" "videobits\n\t" "LD R4,X+\n\t" "videobits\n\t" "LD R4,X+\n\t" "videobits\n\t" "LD R4,X+\n\t" "videobits\n\t" "LD R4,X+\n\t" "videobits\n\t" "LD R4,X+\n\t" "videobits\n\t" "LD R4,X+\n\t" "videobits\n\t" "LD R4,X+\n\t" "videobits\n\t" "LD R4,X+\n\t" "videobits\n\t" "LD R4,X+\n\t" "videobits\n\t" "LD R4,X+\n\t" "videobits\n\t" "LD R4,X+\n\t" "videobits\n\t" "LD R4,X+\n\t" "videobits\n\t" "LD R4,X+\n\t" "videobits\n\t" "LD R4,X+\n\t" "videobits\n\t" "LD R4,X\n\t" "videobits\n\t" "CLT\n\t" "LDI R30, 0x40\n\t" "BLD R30,5\n\t" "OUT 0x0b,R30\n\t" ); } // put the MCU to sleep JUST before the CompA ISR goes off #NEW TIMER CODE ISR(TIMER1_COMPB_vect, ISR_NAKED) { sei(); sleep_cpu(); reti(); } //================================== //This is the sync generator and raster generator. It MUST be entered from //sleep mode to get accurate timing of the sync pulses ISR (TIMER1_COMPA_vect) { //start the Horizontal sync pulse PORTD = syncON; //update the current scanline number LineCount++; //begin inverted (Vertical) synch after line 247 if (LineCount==248) { syncON = 0b01000000; syncOFF = 0; } //back to regular sync after line 250 if (LineCount==251) { syncON = 0; syncOFF = 0b01000000; } //start new frame after line 262 if (LineCount==263) LineCount = 1; //adjust to make 5 us pulses _delay_us(2); //end sync pulse PORTD = syncOFF; if (LineCount < ScreenBot && LineCount >= ScreenTop) { //compute offset into screen array screenindex = screen + ((LineCount - ScreenTop) << 4) + ((LineCount - ScreenTop) << 1); //center image on screen _delay_us(8); //12 //blast the data to the screen byteblast(); } } //================================== //plot one point //at x,y with color 1=white 0=black 2=invert void video_pt(char x, char y, char c) { //each line has 18 bytes //calculate i based upon this and x,y // the byte with the pixel in it int i = (x >> 3) + ((int)y<<4) + ((int)y<<1); if (c==1) screen[i] = screen[i] | pos[x & 7]; else if (c==0) screen[i] = screen[i] & ~pos[x & 7]; else screen[i] = screen[i] ^ pos[x & 7]; } //================================== //plot a line //at x1,y1 to x2,y2 with color 1=white 0=black 2=invert //NOTE: this function requires signed chars //Code is from David Rodgers, //"Procedural Elements of Computer Graphics",1985 void video_line(char x1, char y1, char x2, char y2, char c) { int e; signed int dx,dy,j, temp; signed char s1,s2, xchange; signed int x,y; x = x1; y = y1; //take absolute value if (x2 < x1) { dx = x1 - x2; s1 = -1; } else if (x2 == x1) { dx = 0; s1 = 0; } else { dx = x2 - x1; s1 = 1; } if (y2 < y1) { dy = y1 - y2; s2 = -1; } else if (y2 == y1) { dy = 0; s2 = 0; } else { dy = y2 - y1; s2 = 1; } xchange = 0; if (dy>dx) { temp = dx; dx = dy; dy = temp; xchange = 1; } e = ((int)dy<<1) - dx; for (j=0; j<=dx; j++) { video_pt(x,y,c); if (e>=0) { if (xchange==1) x = x + s1; else y = y + s2; e = e - ((int)dx<<1); } if (xchange==1) y = y + s2; else x = x + s1; e = e + ((int)dy<<1); } } //================================== // put a big character on the screen // c is index into bitmap void video_putchar(char x, char y, char c) { char i; char y_pos; uint8_t j; for (i=0;i<7;i++) { y_pos = y + i; j = pgm_read_byte(((uint32_t)(ascii)) + c*7 + i); video_pt(x, y_pos, (j & 0x80)==0x80); video_pt(x+1, y_pos, (j & 0x40)==0x40); video_pt(x+2, y_pos, (j & 0x20)==0x20); video_pt(x+3, y_pos, (j & 0x10)==0x10); video_pt(x+4, y_pos, (j & 0x08)==0x08); video_pt(x+5, y_pos, (j & 0x04)==0x04); video_pt(x+6, y_pos, (j & 0x02)==0x02); video_pt(x+7, y_pos, (j & 0x01)==0x01); } } //================================== // put a big character on the screen // c is index into bitmap void video_putchess(char x, char y, char c) { char i; char y_pos; uint8_t j; for (i=0;i<7;i++) { y_pos = y + i; j = pgm_read_byte(((uint32_t)(ascii2)) + c*7 + i); video_pt(x, y_pos, (j & 0x80)==0x80); video_pt(x+1, y_pos, (j & 0x40)==0x40); video_pt(x+2, y_pos, (j & 0x20)==0x20); video_pt(x+3, y_pos, (j & 0x10)==0x10); video_pt(x+4, y_pos, (j & 0x08)==0x08); video_pt(x+5, y_pos, (j & 0x04)==0x04); video_pt(x+6, y_pos, (j & 0x02)==0x02); video_pt(x+7, y_pos, (j & 0x01)==0x01); } } //================================== // put a string of big characters on the screen void video_puts(char x, char y, char *str) { char i; for (i=0; str[i]!=0; i++) { video_putchess(x,y,str[i]); // putchar x = x+10; } } //================================== // put a small character on the screen // x-coord must be on divisible by 4 // c is index into bitmap void video_smallchar(char x, char y, char c) { char mask; int i=((int)x>>3) + ((int)y<<4) + (((int)y)<<1); if (x == (x & 0xf8)) mask = 0x0f; //f8 else mask = 0xf0; uint8_t j = pgm_read_byte(((uint32_t)(smallbitmap)) + c*5); screen[i] = (screen[i] & mask) | (j & ~mask); j = pgm_read_byte(((uint32_t)(smallbitmap)) + c*5 + 1); screen[i+18] = (screen[i+18] & mask) | (j & ~mask); j = pgm_read_byte(((uint32_t)(smallbitmap)) + c*5 + 2); screen[i+36] = (screen[i+36] & mask) | (j & ~mask); j = pgm_read_byte(((uint32_t)(smallbitmap)) + c*5 + 3); screen[i+54] = (screen[i+54] & mask) | (j & ~mask); j = pgm_read_byte(((uint32_t)(smallbitmap)) + c*5 + 4); screen[i+72] = (screen[i+72] & mask) | (j & ~mask); } //================================== // put a string of small characters on the screen // x-cood must be on divisible by 4 void video_putsmalls(char x, char y, char *str) { char i; x = x & 0b1111100; //make it divisible by 4 for (i = 0; str[i] != 0; i++) { if (str[i] >= 0x30 && str[i] <= 0x3a) video_smallchar(x, y, str[i] - 0x30); else video_smallchar(x, y, str[i]-0x40+12); x += 4; } } //================================== //return the value of one point //at x,y with color 1=white 0=black 2=invert char video_set(char x, char y) { //The following construction //detects exactly one bit at the x,y location int i = (x>>3) + ((int)y<<4) + ((int)y<<1); return (screen[i] & 1<<(7-(x & 0x7))); } //=== fixed conversion macros ========================================= #define int2fix(a) (((int)(a))<<8) //Convert char to fix. a is a char #define fix2int(a) ((signed char)((a)>>8)) //Convert fix to int. a is an int #define float2fix(a) ((int)((a)*256.0)) //Convert float to fix. a is a float #define fix2float(a) (((float)(a))/256.0) //Convert fix to float. a is an int //=== animation stuff ================================================== unsigned int x, y; int vx, vy, g, drag; char sel[]="SEL"; char solidwin[]="SOLID WINS!"; char hollowwin[]="HOLLOW WINS!"; typedef struct SolidRook_t { unsigned char location; } ; struct SolidRook_t SR1; struct SolidRook_t SR2; typedef struct HollowRook_t begin unsigned char location; //bitmaps end ; struct HollowRook_t HR1; struct HollowRook_t HR2; typedef struct SolidKnight_t begin unsigned char location; end; struct SolidKnight_t SKN1; struct SolidKnight_t SKN2; typedef struct HollowKnight_t begin unsigned char location; end; struct HollowKnight_t HKN1; struct HollowKnight_t HKN2; typedef struct SolidBishop_t begin unsigned char location; end ; struct SolidBishop_t SB1; struct SolidBishop_t SB2; typedef struct HollowBishop_t begin unsigned char location; end ; struct HollowBishop_t HB1; struct HollowBishop_t HB2; typedef struct SolidQueen_t begin unsigned char location; end ; struct SolidQueen_t SQ1; typedef struct HollowQueen_t begin unsigned char location; end; struct HollowQueen_t HQ1; typedef struct SolidKing_t begin unsigned char location; end ; struct SolidKing_t SK1; typedef struct HollowKing_t begin unsigned char location; end; struct HollowKing_t HK1; typedef struct SolidPawn_t begin unsigned char location; end; struct SolidPawn_t SP1; struct SolidPawn_t SP2; struct SolidPawn_t SP3; struct SolidPawn_t SP4; struct SolidPawn_t SP5; struct SolidPawn_t SP6; struct SolidPawn_t SP7; struct SolidPawn_t SP8; typedef struct HollowPawn_t begin unsigned char location; end ; struct HollowPawn_t HP1; struct HollowPawn_t HP2; struct HollowPawn_t HP3; struct HollowPawn_t HP4; struct HollowPawn_t HP5; struct HollowPawn_t HP6; struct HollowPawn_t HP7; struct HollowPawn_t HP8; void initializeLocation(void) begin SR1.location=0; SR2.location=7; HR1.location=56; HR2.location=63; SKN1.location=1; SKN2.location=6; HKN1.location=57; HKN2.location=62; SB1.location=2; SB2.location=5; HB1.location=58; HB2.location=61; SK1.location=3; HK1.location=59; SQ1.location=4; HQ1.location=60; SP1.location=8; SP2.location=9; SP3.location=10; SP4.location=11; SP5.location=12; SP6.location=13; SP7.location=14; SP8.location=15; HP1.location=48; HP2.location=49; HP3.location=50; HP4.location=51; HP5.location=52; HP6.location=53; HP7.location=54; HP8.location=55; end /**********************************************************/ signed char IsMovePossible(unsigned char old_location_piece, unsigned char location_piece)//(signed char x1, signed char y1, signed char x2, signed char y2) begin char x1=old_location_piece%8; char y1=old_location_piece/8; char x2=location_piece%8; char y2=location_piece/8; if ((old_location_piece==location_piece)||(old_location_piece==250)||(location_piece==250)||((turn==0)&&(tileboard[y2][x2]==1))||((turn==1)&&(tileboard[y2][x2]==2))) begin return 0; end int j; int k; //Check if move is possible //moving a solid if (!turn) begin if ((SP1.location==old_location_piece) || (SP2.location==old_location_piece) || (SP3.location==old_location_piece) || (SP4.location==old_location_piece) || (SP5.location==old_location_piece) || (SP6.location==old_location_piece) || (SP7.location==old_location_piece) || (SP8.location==old_location_piece)) begin if((x1==x2)&&(((y2-1)==y1))&&(tileboard[y2][x2]==0))//Move ahead one begin return 1; end else if((x1==x2)&&((y2-2)==y1)&&(tileboard[y2][x2]==0)&&(tileboard[(y2-1)][x2]==0)&&(y1==1))//Move ahead two solid begin return 1; end else if(((x1-1) == x2)&&((y1+1) == y2) && (tileboard[y2][x2]==2))//solid pawn takes hollow piece begin return 1; end else if(((x1+1) == x2)&&((y1+1) == y2)&&(tileboard[y2][x2]==2))//Take Piece White begin return 1; end end //end solid pawn else if (((SKN1.location==old_location_piece) || (SKN2.location==old_location_piece)) && (tileboard[y2][x2]!=1)) begin//NOTE: We aren't worried about moving off the board if(((x1-2)==x2)&&((y1-1)==y2)) return 1; else if(((x1-2)==x2)&&((y1+1)==y2)) return 1; else if(((x1-2)==x2)&&((y1+1)==y2)) return 1; else if(((x1-1)==x2)&&((y1-2)==y2)) return 1; else if(((x1-1)==x2)&&((y1+2)==y2)) return 1; else if(((x1+1)==x2)&&((y1-2)==y2)) return 1; else if(((x1+1)==x2)&&((y1+2)==y2)) return 1; else if(((x1+2)==x2)&&((y1-1)==y2)) return 1; else if(((x1+2)==x2)&&((y1+1)==y2)) return 1; else begin return 0; end end //end solid knight else if(SK1.location==old_location_piece) begin if((-1 <= (x1-x2)) && (1 >= (x1-x2)) && (-1 <= (y1-y2)) && (1 >= (y1-y2))) begin SolidKingHasMoved=1; return 1; end else if(!SolidKingHasMoved) begin if((x2 == 1)&&(y2 == 0)&&(tileboard[0][1] == 0)&&(tileboard[0][2] == 0)&&(SR1.location==0)&&(!SolidKingSideRookHasMoved)) begin SolidKingHasMoved = 1; SR1.location=2; return 1; end else if((x2 == 5)&&(y2 = 0)&&(tileboard[0][4] == 0)&&(tileboard[0][5] == 0)&&(tileboard[0][6] == 0)&&(SR2.location==7)&&(!SolidQueenSideRookHasMoved)) begin SolidKingHasMoved = 1; SR2.location=4; return 1; end else begin return 0; end end end //end solid king else //all other pieces begin if((SQ1.location==old_location_piece)||(SB1.location==old_location_piece)||(SB2.location==old_location_piece)) begin if((x2-x1)==(y2-y1))//A1 to H8 begin if(x2>x1)//right and down begin j = x1+1; k = y1+1; while((jx2)&&(k>y2)&&(tileboard[k][j] == 0)) begin j--; k--; end if((j == x2) && (k == y2)) begin return 1; end else begin return 0; end end //end up and left end//A1 to H8 else if((x2-x1)==(y1-y2)) begin//A8 to H1 if(x2>x1)//right and up begin j = x1+1; k = y1-1; while((jy2)&&(tileboard[k][j] == 0)) begin j++; k--; end if((j == x2) && (k == y2)) begin return 1; end else begin return 0; end end//end right and up else begin//down and left j = x1-1; k = y1+1; while((j>x2)&&(ky1)) begin//down j = y1+1; while((jy2)) begin//up j = y1-1; while((j>y2)&&(tileboard[j][x1] == 0)) begin j--; end if(j==y2) return 1; else begin return 0; end end//end up else if ((y1 == y2)&&(x1 > x2)) begin//Left j = x1-1; while((j>x2)&&(tileboard[y1][j] == 0)) begin j--; end if(j==x2) return 1; else begin return 0; end end//end Left else begin return 0; end end//Rook or Queen end//Everyone Else end//!turn else begin // moving a hollow if ((HP1.location==old_location_piece) || (HP2.location==old_location_piece) || (HP3.location==old_location_piece) || (HP4.location==old_location_piece) || (HP5.location==old_location_piece) || (HP6.location==old_location_piece) || (HP7.location==old_location_piece) || (HP8.location==old_location_piece)) begin if((x1==x2)&&(((y2+1)==y1))&&(tileboard[y2][x2]==0))//Move ahead one begin return 1; end else if((x1==x2)&&((y2+2)==y1)&&(tileboard[y2][x2]==0)&&(tileboard[(y2+1)][x2]==0)&&(y1==6))//Move ahead two solid begin return 1; end else if(((x1-1) == x2)&&((y1-1) == y2) && (tileboard[y2][x2]==1))//hollow pawn takes solid piece begin return 1; end else if(((x1+1) == x2)&&((y1-1) == y2) && (tileboard[y2][x2]==1))//hollow pawn takes solid begin return 1; end end //end hollow pawn else if (((HKN1.location==old_location_piece) || (HKN2.location==old_location_piece)) && (tileboard[y2][x2]!=2)) begin//NOTE: We aren't worried about moving off the board if(((x1-2)==x2)&&((y1-1)==y2)) return 1; else if(((x1-2)==x2)&&((y1+1)==y2)) return 1; else if(((x1-2)==x2)&&((y1+1)==y2)) return 1; else if(((x1-1)==x2)&&((y1-2)==y2)) return 1; else if(((x1-1)==x2)&&((y1+2)==y2)) return 1; else if(((x1+1)==x2)&&((y1-2)==y2)) return 1; else if(((x1+1)==x2)&&((y1+2)==y2)) return 1; else if(((x1+2)==x2)&&((y1-1)==y2)) return 1; else if(((x1+2)==x2)&&((y1+1)==y2)) return 1; else begin return 0; end end //end hollow knight else if(HK1.location==old_location_piece) begin if((-1 <= (x1-x2)) && (1 >= (x1-x2)) && (-1 <= (y1-y2)) && (1 >= (y1-y2))) begin HollowKingHasMoved=1; return 1; end else if(!HollowKingHasMoved) begin if((x2 == 1)&&(y2 == 7)&&(tileboard[7][1] == 0)&&(tileboard[7][2] == 0)&&(HR1.location==0)&&(!HollowKingSideRookHasMoved)) begin HollowKingHasMoved = 1; HR1.location=58; return 1; end else if((x2 == 5)&&(y2 = 7)&&(tileboard[7][4] == 0)&&(tileboard[7][5] == 0)&&(tileboard[7][6] == 0)&&(HR2.location==7)&&(!HollowQueenSideRookHasMoved)) begin HollowKingHasMoved = 1; HR2.location=60; return 1; end else begin return 0; end end end //end solid king else //all other pieces begin if((HQ1.location==old_location_piece)||(HB1.location==old_location_piece)||(HB2.location==old_location_piece)) begin if((x2-x1)==(y2-y1))//A1 to H8 begin if(x2>x1)//right and down begin j = x1+1; k = y1+1; while((jx2)&&(k>y2)&&(tileboard[k][j] == 0)) begin j--; k--; end if((j == x2) && (k == y2)) begin return 1; end else begin return 0; end end //end up and left end//A1 to H8 else if((x2-x1)==(y1-y2)) begin//A8 to H1 if(x2>x1)//right and up begin j = x1+1; k = y1-1; while((jy2)&&(tileboard[k][j] == 0)) begin j++; k--; end if((j == x2) && (k == y2)) begin return 1; end else begin return 0; end end//end right and up else begin//down and left j = x1-1; k = y1+1; while((j>x2)&&(ky1)) begin//down j = y1+1; while((jy2)) begin//up j = y1-1; while((j>y2)&&(tileboard[j][x1] == 0)) begin j--; end if(j==y2) return 1; else begin return 0; end end//end up else if ((y1 == y2)&&(x1 > x2)) begin//Left j = x1-1; while((j>x2)&&(tileboard[y1][j] == 0)) begin j--; end if(j==x2) return 1; else begin return 0; end end//end Left else begin return 0; end end//Rook or Queen end//Everyone Else end//turn return 0; end//IsMovePossible /**********************************************************/ void initialize(void) begin //init timer 1 to generate sync OCR1A = lineTime; //One NTSC line OCR1B = sleepTime; //time to go to sleep #NEW TIMER CODE TCCR1B = 0x09; //full speed; clear-on-match; WGM12 AND CS10 TCCR1A = 0x00; //turn off pwm and oc lines TIMSK1 = 0x06; //enable interrupt T1 cmp A (OCIE1A) //enable interrupt T1 cmp B (OCIE1B) #NEW TIMER CODE //init ports DDRA=0; //side phototransistors in DDRC=0; //top phototransistors in DDRD=0xf0; //video out DDRB = 0x00; //switches //initialize synch constants LineCount = 1; syncON = 0b00000000; syncOFF = 0b01000000; //side lines (edited by Caspar apr 28, 2012) //side lines 1 #define width 142 #define height 199 int i=-15; int fini=i+17; int j; while (i<119) begin if (i==fini) begin i=fini+17; fini=fini+2*17; end else begin i++; end j=-15; while(j<170-25) begin video_line(i+17,j+20,i+17 ,j+20+20,1); j=j+2*20; end end //side lines 2 int ii=2; int finii=ii+17; int jj; while (ii<119) begin if (ii==finii) begin ii=finii+17; finii=finii+2*17; end else begin ii++; end jj=5; while(jj<170-25) begin video_line(ii+17,jj+20,ii+17 ,jj+20+20,1); jj=jj+2*20; end end char c0=0;//PAWN BB char c1=1;//BW char c2=2;//WB char c3=3;//WW char c4=4;//KNIGHT char c5=5; char c6=6; char c7=7; char c8=8;//BISHOP char c9=9; char c10=10; char c11=11; char c12=12;//ROOK char c13=13; char c14=14; char c15=15; char c16=16;//QUEEN char c17=17; char c18=18; char c19=19; char c20=20;//KING char c21=21; char c22=22; char c23=23; ////////////HOLLOW TEAM (nominally black)///////////////////// video_putchar(9,155,c12); video_putchar(24,155, c7); video_putchar(41,155, c8); video_putchar(58,155, c23); video_putchar(75,155, c16); video_putchar(92,155, c11); video_putchar(109,155, c4); video_putchar(126,155, c15); video_putchar(9,135,c3); video_putchar(24,135,c0); video_putchar(41,135,c3); video_putchar(58,135,c0); video_putchar(75,135,c3); video_putchar(92,135,c0); video_putchar(109,135,c3); video_putchar(126,135,c0); /////////////SOLID TEAM (nominally white)////////////////////// video_putchar(9,15,c13); video_putchar(24,15,c6); video_putchar(41,15,c9); video_putchar(58,15,c22); video_putchar(75,15,c16); video_putchar(92,15,c10); video_putchar(109,15,c5); video_putchar(126,15,c14); video_putchar(9,35,c2); video_putchar(24,35,c1); video_putchar(41,35,c2); video_putchar(58,35,c1); video_putchar(75,35,c2); video_putchar(92,35,c1); video_putchar(109,35,c2); video_putchar(126,35,c1); // Set up single video line timing sei(); set_sleep_mode(SLEEP_MODE_IDLE); sleep_enable(); end /**********************************************************/ int main(void) begin initialize(); initializeLocation(); //The following loop executes once/video line during lines //1-230, then does all of the frame-end processing while ((SK1.location!=-5)&&(HK1.location!=-5)) {// for(;;) { //stall here until next line starts //use sleep to make entry into sync ISR uniform time //sleep_cpu(); //SLEEP CPU IN SEPARATE INTERRUPT //The following code executes during the vertical blanking //Code here can be as long as //a total of 60 lines x 63.5 uSec/line x 8 cycles/uSec if (LineCount == ScreenBot+1) { task1(); } } //while if (SK1.location==-5) video_putsmalls(50,50,hollowwin); else video_putsmalls(50,50,solidwin); end void task1(void) begin if ((old_location_piece!=251)&&(old_location_piece!=250)) video_putsmalls(boardloc[old_location_piece][0],boardloc[old_location_piece][1]+2,sel); if (PINA) begin if (loc_deb_count==loc_deb_lim) begin if ((PINA & 0x01) && (PINC & 0x01) && (loc_deb==0)) begin if (location_piece!=0) begin old_location_piece=location_piece; choosePiece=choosePiece^1; moveToDestination=moveToDestination^1; end location_piece=0; loc_deb_count=0; end if ((PINA & 0x01) && (!PINC) && (loc_deb==1)) begin if (location_piece!=1) begin old_location_piece=location_piece; choosePiece=choosePiece^1; moveToDestination=moveToDestination^1; end location_piece=1; loc_deb_count=0; end if ((PINA & 0x01) && (PINC & 0x04) && (loc_deb==2)) begin if (location_piece!=2) begin old_location_piece=location_piece; choosePiece=choosePiece^1; moveToDestination=moveToDestination^1; end location_piece=2; loc_deb_count=0; end if ((PINA & 0x01) && (PINC & 0x08) && (loc_deb==3)) begin if (location_piece!=3) begin old_location_piece=location_piece; choosePiece=choosePiece^1; moveToDestination=moveToDestination^1; end location_piece=3; loc_deb_count=0; end if ((PINA & 0x01) && (PINC & 0x10) && (loc_deb==4)) begin if (location_piece!=4) begin old_location_piece=location_piece; choosePiece=choosePiece^1; moveToDestination=moveToDestination^1; end location_piece=4; loc_deb_count=0; end if ((PINA & 0x01) && (PINC & 0x20) && (loc_deb==5)) begin if (location_piece!=5) begin old_location_piece=location_piece; choosePiece=choosePiece^1; moveToDestination=moveToDestination^1; end location_piece=5; loc_deb_count=0; end if ((PINA & 0x01) && (PINC & 0x40) && (loc_deb==6)) begin if (location_piece!=6) begin old_location_piece=location_piece; choosePiece=choosePiece^1; moveToDestination=moveToDestination^1; end location_piece=6; loc_deb_count=0; end if ((PINA & 0x01) && (PINC & 0x80) && (loc_deb==7)) begin if (location_piece!=7) begin old_location_piece=location_piece; choosePiece=choosePiece^1; moveToDestination=moveToDestination^1; end location_piece=7; loc_deb_count=0; end //////////////////////////////////////////////////////////////////// if ((PINA & 0x02) && (PINC & 0x01) && (loc_deb==8)) begin if (location_piece!=8) begin old_location_piece=location_piece; choosePiece=choosePiece^1; moveToDestination=moveToDestination^1; end location_piece=8; loc_deb_count=0; end if ((PINA & 0x02) && (!PINC) && (loc_deb==9)) begin if (location_piece!=9) begin old_location_piece=location_piece; choosePiece=choosePiece^1; moveToDestination=moveToDestination^1; end location_piece=9; loc_deb_count=0; end if ((PINA & 0x02) && (PINC & 0x04) && (loc_deb==10)) begin if (location_piece!=10) begin old_location_piece=location_piece; choosePiece=choosePiece^1; moveToDestination=moveToDestination^1; end location_piece=10; loc_deb_count=0; end if ((PINA & 0x02) && (PINC & 0x08) && (loc_deb==11)) begin if (location_piece!=11) begin old_location_piece=location_piece; choosePiece=choosePiece^1; moveToDestination=moveToDestination^1; end location_piece=11; loc_deb_count=0; end if ((PINA & 0x02) && (PINC & 0x10) && (loc_deb==12)) begin if (location_piece!=12) begin old_location_piece=location_piece; choosePiece=choosePiece^1; moveToDestination=moveToDestination^1; end location_piece=12; loc_deb_count=0; end if ((PINA & 0x02) && (PINC & 0x20) && (loc_deb==13)) begin if (location_piece!=13) begin old_location_piece=location_piece; choosePiece=choosePiece^1; moveToDestination=moveToDestination^1; end location_piece=13; loc_deb_count=0; end if ((PINA & 0x02) && (PINC & 0x40) && (loc_deb==14)) begin if (location_piece!=14) begin old_location_piece=location_piece; choosePiece=choosePiece^1; moveToDestination=moveToDestination^1; end location_piece=14; loc_deb_count=0; end if ((PINA & 0x02) && (PINC & 0x80) && (loc_deb==15)) begin if (location_piece!=15) begin old_location_piece=location_piece; choosePiece=choosePiece^1; moveToDestination=moveToDestination^1; end location_piece=15; loc_deb_count=0; end ///////////////////////////////////////////////////////////////////// if ((PINA & 0x04) && (PINC & 0x01) && (loc_deb==16)) begin if (location_piece!=16) begin old_location_piece=location_piece; choosePiece=choosePiece^1; moveToDestination=moveToDestination^1; end location_piece=16; loc_deb_count=0; end if ((PINA & 0x04) && (!PINC) && (loc_deb==17)) begin if (location_piece!=17) begin old_location_piece=location_piece; choosePiece=choosePiece^1; moveToDestination=moveToDestination^1; end location_piece=17; loc_deb_count=0; end if ((PINA & 0x04) && (PINC & 0x04) && (loc_deb==18)) begin if (location_piece!=18) begin old_location_piece=location_piece; choosePiece=choosePiece^1; moveToDestination=moveToDestination^1; end location_piece=18; loc_deb_count=0; end if ((PINA & 0x04) && (PINC & 0x08) && (loc_deb==19)) begin if (location_piece!=19) begin old_location_piece=location_piece; choosePiece=choosePiece^1; moveToDestination=moveToDestination^1; end location_piece=19; loc_deb_count=0; end if ((PINA & 0x04) && (PINC & 0x10) && (loc_deb==20)) begin if (location_piece!=20) begin old_location_piece=location_piece; choosePiece=choosePiece^1; moveToDestination=moveToDestination^1; end location_piece=20; loc_deb_count=0; end if ((PINA & 0x04) && (PINC & 0x20) && (loc_deb==21)) begin if (location_piece!=21) begin old_location_piece=location_piece; choosePiece=choosePiece^1; moveToDestination=moveToDestination^1; end location_piece=21; loc_deb_count=0; end if ((PINA & 0x04) && (PINC & 0x40) && (loc_deb==22)) begin if (location_piece!=22) begin old_location_piece=location_piece; choosePiece=choosePiece^1; moveToDestination=moveToDestination^1; end location_piece=22; loc_deb_count=0; end if ((PINA & 0x04) && (PINC & 0x80) && (loc_deb==23)) begin if (location_piece!=23) begin old_location_piece=location_piece; choosePiece=choosePiece^1; moveToDestination=moveToDestination^1; end location_piece=23; loc_deb_count=0; end ///////////////////////////////////////////////////////////////////// if ((PINA & 0x08) && (PINC & 0x01) && (loc_deb==24)) begin if (location_piece!=24) begin old_location_piece=location_piece; choosePiece=choosePiece^1; moveToDestination=moveToDestination^1; end location_piece=24; loc_deb_count=0; end if ((PINA & 0x08) && (!PINC) && (loc_deb==25)) begin if (location_piece!=25) begin old_location_piece=location_piece; choosePiece=choosePiece^1; moveToDestination=moveToDestination^1; end location_piece=25; loc_deb_count=0; end if ((PINA & 0x08) && (PINC & 0x04) && (loc_deb==26)) begin if (location_piece!=26) begin old_location_piece=location_piece; choosePiece=choosePiece^1; moveToDestination=moveToDestination^1; end location_piece=26; loc_deb_count=0; end if ((PINA & 0x08) && (PINC & 0x08) && (loc_deb==27)) begin if (location_piece!=27) begin old_location_piece=location_piece; choosePiece=choosePiece^1; moveToDestination=moveToDestination^1; end location_piece=27; loc_deb_count=0; end if ((PINA & 0x08) && (PINC & 0x10) && (loc_deb==28)) begin if (location_piece!=28) begin old_location_piece=location_piece; choosePiece=choosePiece^1; moveToDestination=moveToDestination^1; end location_piece=28; loc_deb_count=0; end if ((PINA & 0x08) && (PINC & 0x20) && (loc_deb==29)) begin if (location_piece!=29) begin old_location_piece=location_piece; choosePiece=choosePiece^1; moveToDestination=moveToDestination^1; end location_piece=29; loc_deb_count=0; end if ((PINA & 0x08) && (PINC & 0x40) && (loc_deb==30)) begin if (location_piece!=30) begin old_location_piece=location_piece; choosePiece=choosePiece^1; moveToDestination=moveToDestination^1; end location_piece=30; loc_deb_count=0; end if ((PINA & 0x08) && (PINC & 0x80) && (loc_deb==31)) begin if (location_piece!=31) begin old_location_piece=location_piece; choosePiece=choosePiece^1; moveToDestination=moveToDestination^1; end location_piece=31; loc_deb_count=0; end ////////////////////////////////////////////////////////////////////// if ((PINA & 0x10) && (PINC & 0x01) && (loc_deb==32)) begin if (location_piece!=32) begin old_location_piece=location_piece; choosePiece=choosePiece^1; moveToDestination=moveToDestination^1; end location_piece=32; loc_deb_count=0; end if ((PINA & 0x10) && (!PINC) && (loc_deb==33)) begin if (location_piece!=33) begin old_location_piece=location_piece; choosePiece=choosePiece^1; moveToDestination=moveToDestination^1; end location_piece=33; loc_deb_count=0; end if ((PINA & 0x10) && (PINC & 0x04) && (loc_deb==34)) begin if (location_piece!=34) begin old_location_piece=location_piece; choosePiece=choosePiece^1; moveToDestination=moveToDestination^1; end location_piece=34; loc_deb_count=0; end if ((PINA & 0x10) && (PINC & 0x08) && (loc_deb==35)) begin if (location_piece!=35) begin old_location_piece=location_piece; choosePiece=choosePiece^1; moveToDestination=moveToDestination^1; end location_piece=35; loc_deb_count=0; end if ((PINA & 0x10) && (PINC & 0x10) && (loc_deb==36)) begin if (location_piece!=36) begin old_location_piece=location_piece; choosePiece=choosePiece^1; moveToDestination=moveToDestination^1; end location_piece=36; loc_deb_count=0; end if ((PINA & 0x10) && (PINC & 0x20) && (loc_deb==37)) begin if (location_piece!=37) begin old_location_piece=location_piece; choosePiece=choosePiece^1; moveToDestination=moveToDestination^1; end location_piece=37; loc_deb_count=0; end if ((PINA & 0x10) && (PINC & 0x40) && (loc_deb==38)) begin if (location_piece!=38) begin old_location_piece=location_piece; choosePiece=choosePiece^1; moveToDestination=moveToDestination^1; end location_piece=38; loc_deb_count=0; end if ((PINA & 0x10) && (PINC & 0x80) && (loc_deb==39)) begin if (location_piece!=39) begin old_location_piece=location_piece; choosePiece=choosePiece^1; moveToDestination=moveToDestination^1; end location_piece=39; loc_deb_count=0; end /////////////////////////////////////////////////////////////////////////// if ((PINA & 0x20) && (PINC & 0x01) && (loc_deb==40)) begin if (location_piece!=40) begin old_location_piece=location_piece; choosePiece=choosePiece^1; moveToDestination=moveToDestination^1; end location_piece=40; loc_deb_count=0; end if ((PINA & 0x20) && (!PINC) && (loc_deb==41)) begin if (location_piece!=41) begin old_location_piece=location_piece; choosePiece=choosePiece^1; moveToDestination=moveToDestination^1; end location_piece=41; loc_deb_count=0; end if ((PINA & 0x20) && (PINC & 0x04) && (loc_deb==42)) begin if (location_piece!=42) begin old_location_piece=location_piece; choosePiece=choosePiece^1; moveToDestination=moveToDestination^1; end location_piece=42; loc_deb_count=0; end if ((PINA & 0x20) && (PINC & 0x08) && (loc_deb==43)) begin if (location_piece!=43) begin old_location_piece=location_piece; choosePiece=choosePiece^1; moveToDestination=moveToDestination^1; end location_piece=43; loc_deb_count=0; end if ((PINA & 0x20) && (PINC & 0x10) && (loc_deb==44)) begin if (location_piece!=44) begin old_location_piece=location_piece; choosePiece=choosePiece^1; moveToDestination=moveToDestination^1; end location_piece=44; loc_deb_count=0; end if ((PINA & 0x20) && (PINC & 0x20) && (loc_deb==45)) begin if (location_piece!=45) begin old_location_piece=location_piece; choosePiece=choosePiece^1; moveToDestination=moveToDestination^1; end location_piece=45; loc_deb_count=0; end if ((PINA & 0x20) && (PINC & 0x40) && (loc_deb==46)) begin if (location_piece!=46) begin old_location_piece=location_piece; choosePiece=choosePiece^1; moveToDestination=moveToDestination^1; end location_piece=46; loc_deb_count=0; end if ((PINA & 0x20) && (PINC & 0x80) && (loc_deb==47)) begin if (location_piece!=47) begin old_location_piece=location_piece; choosePiece=choosePiece^1; moveToDestination=moveToDestination^1; end location_piece=47; loc_deb_count=0; end //////////////////////////////////////////////////////////////////////////// if ((PINA & 0x40) && (PINC & 0x01) && (loc_deb==48)) begin if (location_piece!=48) begin old_location_piece=location_piece; choosePiece=choosePiece^1; moveToDestination=moveToDestination^1; end location_piece=48; loc_deb_count=0; end if ((PINA & 0x40) && (!PINC) && (loc_deb==49)) begin if (location_piece!=49) begin old_location_piece=location_piece; choosePiece=choosePiece^1; moveToDestination=moveToDestination^1; end location_piece=49; loc_deb_count=0; end if ((PINA & 0x40) && (PINC & 0x04) && (loc_deb==50)) begin if (location_piece!=50) begin old_location_piece=location_piece; choosePiece=choosePiece^1; moveToDestination=moveToDestination^1; end location_piece=50; loc_deb_count=0; end if ((PINA & 0x40) && (PINC & 0x08) && (loc_deb==51)) begin if (location_piece!=51) begin old_location_piece=location_piece; choosePiece=choosePiece^1; moveToDestination=moveToDestination^1; end location_piece=51; loc_deb_count=0; end if ((PINA & 0x40) && (PINC & 0x10) && (loc_deb==52)) begin if (location_piece!=52) begin old_location_piece=location_piece; choosePiece=choosePiece^1; moveToDestination=moveToDestination^1; end location_piece=52; loc_deb_count=0; end if ((PINA & 0x40) && (PINC & 0x20) && (loc_deb==53)) begin if (location_piece!=53) begin old_location_piece=location_piece; choosePiece=choosePiece^1; moveToDestination=moveToDestination^1; end location_piece=53; loc_deb_count=0; end if ((PINA & 0x40) && (PINC & 0x40) && (loc_deb==54)) begin if (location_piece!=54) begin old_location_piece=location_piece; choosePiece=choosePiece^1; moveToDestination=moveToDestination^1; end location_piece=54; loc_deb_count=0; end if ((PINA & 0x40) && (PINC & 0x80) && (loc_deb==55)) begin if (location_piece!=55) begin old_location_piece=location_piece; choosePiece=choosePiece^1; moveToDestination=moveToDestination^1; end location_piece=55; loc_deb_count=0; end ////////////////////////////////////////////////////////////////////////////// if ((PINA & 0x80) && (PINC & 0x01) && (loc_deb==56)) begin if (location_piece!=56) begin old_location_piece=location_piece; choosePiece=choosePiece^1; moveToDestination=moveToDestination^1; end location_piece=56; loc_deb_count=0; end if ((PINA & 0x80) && (!PINC) && (loc_deb==57)) begin if (location_piece!=57) begin old_location_piece=location_piece; choosePiece=choosePiece^1; moveToDestination=moveToDestination^1; end location_piece=57; loc_deb_count=0; end if ((PINA & 0x80) && (PINC & 0x04) && (loc_deb==58)) begin if (location_piece!=58) begin old_location_piece=location_piece; choosePiece=choosePiece^1; moveToDestination=moveToDestination^1; end location_piece=58; loc_deb_count=0; end if ((PINA & 0x80) && (PINC & 0x08) && (loc_deb==59)) begin if (location_piece!=59) begin old_location_piece=location_piece; choosePiece=choosePiece^1; moveToDestination=moveToDestination^1; end location_piece=59; loc_deb_count=0; end if ((PINA & 0x80) && (PINC & 0x10) && (loc_deb==60)) begin if (location_piece!=60) begin old_location_piece=location_piece; choosePiece=choosePiece^1; moveToDestination=moveToDestination^1; end location_piece=60; loc_deb_count=0; end if ((PINA & 0x80) && (PINC & 0x20) && (loc_deb==61)) begin if (location_piece!=61) begin old_location_piece=location_piece; choosePiece=choosePiece^1; moveToDestination=moveToDestination^1; end location_piece=61; loc_deb_count=0; end if ((PINA & 0x80) && (PINC & 0x40) && (loc_deb==62)) begin if (location_piece!=62) begin old_location_piece=location_piece; choosePiece=choosePiece^1; moveToDestination=moveToDestination^1; end location_piece=62; loc_deb_count=0; end if ((PINA & 0x80) && (PINC & 0x80) && (loc_deb==63)) begin if (location_piece!=63) begin old_location_piece=location_piece; choosePiece=choosePiece^1; moveToDestination=moveToDestination^1; end location_piece=63; loc_deb_count=0; end end else begin if ((PINA & 0x01) && (PINC & 0x01) && (loc_deb==0)) begin loc_deb_count++; end else if ((PINA & 0x01) && (PINC & 0x01)) begin loc_deb=0; loc_deb_count=0; end if ((PINA & 0x01) && (!PINC) && (loc_deb==1)) begin loc_deb_count++; end else if ((PINA & 0x01) && (!PINC)) begin loc_deb=1; loc_deb_count=0; end if ((PINA & 0x01) && (PINC & 0x04) && (loc_deb==2)) begin loc_deb_count++; end else if ((PINA & 0x01) && (PINC & 0x04)) begin loc_deb=2; loc_deb_count=0; end if ((PINA & 0x01) && (PINC & 0x08) && (loc_deb==3)) begin loc_deb_count++; end else if ((PINA & 0x01) && (PINC & 0x08)) begin loc_deb=3; loc_deb_count=0; end if ((PINA & 0x01) && (PINC & 0x10) && (loc_deb==4)) begin loc_deb_count++; end else if ((PINA & 0x01) && (PINC & 0x10)) begin loc_deb=4; loc_deb_count=0; end if ((PINA & 0x01) && (PINC & 0x20) && (loc_deb==5)) begin loc_deb_count++; end else if ((PINA & 0x01) && (PINC & 0x20)) begin loc_deb=5; loc_deb_count=0; end if ((PINA & 0x01) && (PINC & 0x40) && (loc_deb==6)) begin loc_deb_count++; end else if ((PINA & 0x01) && (PINC & 0x40)) begin loc_deb=6; loc_deb_count=0; end if ((PINA & 0x01) && (PINC & 0x80) && (loc_deb==7)) begin loc_deb_count++; end else if ((PINA & 0x01) && (PINC & 0x80)) begin loc_deb=7; loc_deb_count=0; end //////////////////////////////////////////////////////////////////// if ((PINA & 0x02) && (PINC & 0x01) && (loc_deb==8)) begin loc_deb_count++; end else if ((PINA & 0x02) && (PINC & 0x01)) begin loc_deb=8; loc_deb_count=0; end if ((PINA & 0x02) && (!PINC) && (loc_deb==9)) begin loc_deb_count++; end else if ((PINA & 0x02) && (!PINC)) begin loc_deb=9; loc_deb_count=0; end if ((PINA & 0x02) && (PINC & 0x04) && (loc_deb==10)) begin loc_deb_count++; end else if ((PINA & 0x02) && (PINC & 0x04)) begin loc_deb=10; loc_deb_count=0; end if ((PINA & 0x02) && (PINC & 0x08) && (loc_deb==11)) begin loc_deb_count++; end else if ((PINA & 0x02) && (PINC & 0x08)) begin loc_deb=11; loc_deb_count=0; end if ((PINA & 0x02) && (PINC & 0x10) && (loc_deb==12)) begin loc_deb_count++; end else if ((PINA & 0x02) && (PINC & 0x10)) begin loc_deb=12; loc_deb_count=0; end if ((PINA & 0x02) && (PINC & 0x20) && (loc_deb==13)) begin loc_deb_count++; end else if ((PINA & 0x02) && (PINC & 0x20)) begin loc_deb=13; loc_deb_count=0; end if ((PINA & 0x02) && (PINC & 0x40) && (loc_deb==14)) begin loc_deb_count++; end else if ((PINA & 0x02) && (PINC & 0x40)) begin loc_deb=14; loc_deb_count=0; end if ((PINA & 0x02) && (PINC & 0x80) && (loc_deb==15)) begin loc_deb_count++; end else if ((PINA & 0x02) && (PINC & 0x80)) begin loc_deb=15; loc_deb_count=0; end ///////////////////////////////////////////////////////////////////// if ((PINA & 0x04) && (PINC & 0x01) && (loc_deb==16)) begin loc_deb_count++; end else if ((PINA & 0x04) && (PINC & 0x01)) begin loc_deb=16; loc_deb_count=0; end if ((PINA & 0x04) && (!PINC) && (loc_deb==17)) begin loc_deb_count++; end else if ((PINA & 0x04) && (!PINC)) begin loc_deb=17; loc_deb_count=0; end if ((PINA & 0x04) && (PINC & 0x04) && (loc_deb==18)) begin loc_deb_count++; end else if ((PINA & 0x04) && (PINC & 0x04)) begin loc_deb=18; loc_deb_count=0; end if ((PINA & 0x04) && (PINC & 0x08) && (loc_deb==19)) begin loc_deb_count++; end else if ((PINA & 0x04) && (PINC & 0x08)) begin loc_deb=19; loc_deb_count=0; end if ((PINA & 0x04) && (PINC & 0x10) && (loc_deb==20)) begin loc_deb_count++; end else if ((PINA & 0x04) && (PINC & 0x10)) begin loc_deb=20; loc_deb_count=0; end if ((PINA & 0x04) && (PINC & 0x20) && (loc_deb==21)) begin loc_deb_count++; end else if ((PINA & 0x04) && (PINC & 0x20)) begin loc_deb=21; loc_deb_count=0; end if ((PINA & 0x04) && (PINC & 0x40) && (loc_deb==22)) begin loc_deb_count++; end else if ((PINA & 0x04) && (PINC & 0x40)) begin loc_deb=22; loc_deb_count=0; end if ((PINA & 0x04) && (PINC & 0x80) && (loc_deb==23)) begin loc_deb_count++; end else if ((PINA & 0x04) && (PINC & 0x80)) begin loc_deb=23; loc_deb_count=0; end ///////////////////////////////////////////////////////////////////// if ((PINA & 0x08) && (PINC & 0x01) && (loc_deb==24)) begin loc_deb_count++; end else if ((PINA & 0x08) && (PINC & 0x01)) begin loc_deb=24; loc_deb_count=0; end if ((PINA & 0x08) && (!PINC) && (loc_deb==25)) begin loc_deb_count++; end else if ((PINA & 0x08) && (!PINC)) begin loc_deb=25; loc_deb_count=0; end if ((PINA & 0x08) && (PINC & 0x04) && (loc_deb==26)) begin loc_deb_count++; end else if ((PINA & 0x08) && (PINC & 0x04)) begin loc_deb=26; loc_deb_count=0; end if ((PINA & 0x08) && (PINC & 0x08) && (loc_deb==27)) begin loc_deb_count++; end else if ((PINA & 0x08) && (PINC & 0x08)) begin loc_deb=27; loc_deb_count=0; end if ((PINA & 0x08) && (PINC & 0x10) && (loc_deb==28)) begin loc_deb_count++; end else if ((PINA & 0x08) && (PINC & 0x10)) begin loc_deb=28; loc_deb_count=0; end if ((PINA & 0x08) && (PINC & 0x20) && (loc_deb==29)) begin loc_deb_count++; end else if ((PINA & 0x08) && (PINC & 0x20)) begin loc_deb=29; loc_deb_count=0; end if ((PINA & 0x08) && (PINC & 0x40) && (loc_deb==30)) begin loc_deb_count++; end else if ((PINA & 0x08) && (PINC & 0x40)) begin loc_deb=30; loc_deb_count=0; end if ((PINA & 0x08) && (PINC & 0x80) && (loc_deb==31)) begin loc_deb_count++; end else if ((PINA & 0x08) && (PINC & 0x80)) begin loc_deb=31; loc_deb_count=0; end ////////////////////////////////////////////////////////////////////// if ((PINA & 0x10) && (PINC & 0x01) && (loc_deb==32)) begin loc_deb_count++; end else if ((PINA & 0x10) && (PINC & 0x01)) begin loc_deb=32; loc_deb_count=0; end if ((PINA & 0x10) && (!PINC) && (loc_deb==33)) begin loc_deb_count++; end else if ((PINA & 0x10) && (!PINC)) begin loc_deb=33; loc_deb_count=0; end if ((PINA & 0x10) && (PINC & 0x04) && (loc_deb==34)) begin loc_deb_count++; end else if ((PINA & 0x10) && (PINC & 0x04)) begin loc_deb=34; loc_deb_count=0; end if ((PINA & 0x10) && (PINC & 0x08) && (loc_deb==35)) begin loc_deb_count++; end else if ((PINA & 0x10) && (PINC & 0x08)) begin loc_deb=35; loc_deb_count=0; end if ((PINA & 0x10) && (PINC & 0x10) && (loc_deb==36)) begin loc_deb_count++; end else if ((PINA & 0x10) && (PINC & 0x10)) begin loc_deb=36; loc_deb_count=0; end if ((PINA & 0x10) && (PINC & 0x20) && (loc_deb==37)) begin loc_deb_count++; end else if ((PINA & 0x10) && (PINC & 0x20)) begin loc_deb=37; loc_deb_count=0; end if ((PINA & 0x10) && (PINC & 0x40) && (loc_deb==38)) begin loc_deb_count++; end else if ((PINA & 0x10) && (PINC & 0x40)) begin loc_deb=38; loc_deb_count=0; end if ((PINA & 0x10) && (PINC & 0x80) && (loc_deb==39)) begin loc_deb_count++; end else if ((PINA & 0x10) && (PINC & 0x80)) begin loc_deb=39; loc_deb_count=0; end /////////////////////////////////////////////////////////////////////////// if ((PINA & 0x20) && (PINC & 0x01) && (loc_deb==40)) begin loc_deb_count++; end else if ((PINA & 0x20) && (PINC & 0x01)) begin loc_deb=40; loc_deb_count=0; end if ((PINA & 0x20) && (!PINC) && (loc_deb==41)) begin loc_deb_count++; end else if ((PINA & 0x20) && (!PINC)) begin loc_deb=41; loc_deb_count=0; end if ((PINA & 0x20) && (PINC & 0x04) && (loc_deb==42)) begin loc_deb_count++; end else if ((PINA & 0x20) && (PINC & 0x04)) begin loc_deb=42; loc_deb_count=0; end if ((PINA & 0x20) && (PINC & 0x08) && (loc_deb==43)) begin loc_deb_count++; end else if ((PINA & 0x20) && (PINC & 0x08)) begin loc_deb=43; loc_deb_count=0; end if ((PINA & 0x20) && (PINC & 0x10) && (loc_deb==44)) begin loc_deb_count++; end else if ((PINA & 0x20) && (PINC & 0x10)) begin loc_deb=44; loc_deb_count=0; end if ((PINA & 0x20) && (PINC & 0x20) && (loc_deb==45)) begin loc_deb_count++; end else if ((PINA & 0x20) && (PINC & 0x20)) begin loc_deb=45; loc_deb_count=0; end if ((PINA & 0x20) && (PINC & 0x40) && (loc_deb==46)) begin loc_deb_count++; end else if ((PINA & 0x20) && (PINC & 0x40)) begin loc_deb=46; loc_deb_count=0; end if ((PINA & 0x20) && (PINC & 0x80) && (loc_deb==47)) begin loc_deb_count++; end else if ((PINA & 0x20) && (PINC & 0x80)) begin loc_deb=47; loc_deb_count=0; end //////////////////////////////////////////////////////////////////////////// if ((PINA & 0x40) && (PINC & 0x01) && (loc_deb==48)) begin loc_deb_count++; end else if ((PINA & 0x40) && (PINC & 0x01)) begin loc_deb=48; loc_deb_count=0; end if ((PINA & 0x40) && (!PINC) && (loc_deb==49)) begin loc_deb_count++; end else if ((PINA & 0x40) && (!PINC)) begin loc_deb=49; loc_deb_count=0; end if ((PINA & 0x40) && (PINC & 0x04) && (loc_deb==50)) begin loc_deb_count++; end else if ((PINA & 0x40) && (PINC & 0x04)) begin loc_deb=50; loc_deb_count=0; end if ((PINA & 0x40) && (PINC & 0x08) && (loc_deb==51)) begin loc_deb_count++; end else if ((PINA & 0x40) && (PINC & 0x08)) begin loc_deb=51; loc_deb_count=0; end if ((PINA & 0x40) && (PINC & 0x10) && (loc_deb==52)) begin loc_deb_count++; end else if ((PINA & 0x40) && (PINC & 0x10)) begin loc_deb=52; loc_deb_count=0; end if ((PINA & 0x40) && (PINC & 0x20) && (loc_deb==53)) begin loc_deb_count++; end else if ((PINA & 0x40) && (PINC & 0x20)) begin loc_deb=53; loc_deb_count=0; end if ((PINA & 0x40) && (PINC & 0x40) && (loc_deb==54)) begin loc_deb_count++; end else if ((PINA & 0x40) && (PINC & 0x40)) begin loc_deb=54; loc_deb_count=0; end if ((PINA & 0x40) && (PINC & 0x80) && (loc_deb==55)) begin loc_deb_count++; end else if ((PINA & 0x40) && (PINC & 0x80)) begin loc_deb=55; loc_deb_count=0; end ////////////////////////////////////////////////////////////////////////////// if ((PINA & 0x80) && (PINC & 0x01) && (loc_deb==56)) begin loc_deb_count++; end else if ((PINA & 0x80) && (PINC & 0x01)) begin loc_deb=56; loc_deb_count=0; end if ((PINA & 0x80) && (!PINC) && (loc_deb==57)) begin loc_deb_count++; end else if ((PINA & 0x80) && (!PINC)) begin loc_deb=57; loc_deb_count=0; end if ((PINA & 0x80) && (PINC & 0x04) && (loc_deb==58)) begin loc_deb_count++; end else if ((PINA & 0x80) && (PINC & 0x04)) begin loc_deb=58; loc_deb_count=0; end if ((PINA & 0x80) && (PINC & 0x08) && (loc_deb==59)) begin loc_deb_count++; end else if ((PINA & 0x80) && (PINC & 0x08)) begin loc_deb=59; loc_deb_count=0; end if ((PINA & 0x80) && (PINC & 0x10) && (loc_deb==60)) begin loc_deb_count++; end else if ((PINA & 0x80) && (PINC & 0x10)) begin loc_deb=60; loc_deb_count=0; end if ((PINA & 0x80) && (PINC & 0x20) && (loc_deb==61)) begin loc_deb_count++; end else if ((PINA & 0x80) && (PINC & 0x20)) begin loc_deb=61; loc_deb_count=0; end if ((PINA & 0x80) && (PINC & 0x40) && (loc_deb==62)) begin loc_deb_count++; end else if ((PINA & 0x80) && (PINC & 0x40)) begin loc_deb=62; loc_deb_count=0; end if ((PINA & 0x80) && (PINC & 0x80) && (loc_deb==63)) begin loc_deb_count++; end else if ((PINA & 0x80) && (PINC & 0x80)) begin loc_deb=63; loc_deb_count=0; end end end //if(PINA) if (choosePiece) begin start_move_x=location_piece%8; start_move_y=location_piece/8; end if(moveToDestination) begin stop_move_x=location_piece%8; stop_move_y=location_piece/8; end if (start_move_x!=240 && start_move_y!=241 && stop_move_x!=242 && stop_move_y!=243) begin possible= IsMovePossible(old_location_piece, location_piece); // && turn; change turns end if (possible) begin char x1=old_location_piece%8; char y1=old_location_piece/8; char x2=location_piece%8; char y2=location_piece/8; if (turn==0) //solid begin tileboard[y1][x1] = 0; tileboard[y2][x2] = 1; if (location_piece== HR1.location) begin HR1.location=-5; end if (location_piece== HR2.location) begin HR2.location=-5; end if (location_piece== HKN1.location) begin HKN1.location=-5; end if (location_piece== HKN2.location) begin HKN2.location=-5; end if (location_piece== HB1.location) begin HB1.location=-5; end if (location_piece== HB2.location) begin HB2.location=-5; end if (location_piece== HQ1.location) begin HQ1.location=-5; end if (location_piece== HP1.location) begin HP1.location=-5; end if (location_piece== HP2.location) begin HP2.location=-5; end if (location_piece== HP3.location) begin HP3.location=-5; end if (location_piece== HP4.location) begin HP4.location=-5; end if (location_piece== HP5.location) begin HP5.location=-5; end if (location_piece== HP6.location) begin HP6.location=-5; end if (location_piece== HP7.location) begin HP7.location=-5; end if (location_piece== HP8.location) begin HP8.location=-5; end if (location_piece== HK1.location) begin HK1.location=-5; end end if (turn==1) //hollow begin tileboard[y1][x1] = 0; tileboard[y2][x2] = 2; if (location_piece== SR1.location) begin SR1.location=-5; end if (location_piece== SR2.location) begin SR2.location=-5; end if (location_piece== SKN1.location) begin SKN1.location=-5; end if (location_piece== SKN2.location) begin SKN2.location=-5; end if (location_piece== SB1.location) begin SB1.location=-5; end if (location_piece== SB2.location) begin SB2.location=-5; end if (location_piece== SQ1.location) begin SQ1.location=-5; end if (location_piece== SP1.location) begin SP1.location=-5; end if (location_piece== SP2.location) begin SP2.location=-5; end if (location_piece== SP3.location) begin SP3.location=-5; end if (location_piece== SP4.location) begin SP4.location=-5; end if (location_piece== SP5.location) begin SP5.location=-5; end if (location_piece== SP6.location) begin SP6.location=-5; end if (location_piece== SP7.location) begin SP7.location=-5; end if (location_piece== SP8.location) begin SP8.location=-5; end if (location_piece== SK1.location) begin SK1.location=-5; end end if (old_location_piece==SR1.location) begin SR1.location=location_piece; if (getTileColor(location_piece)==1) begin //white tile video_putchar(boardloc[location_piece][0],boardloc[location_piece][1],mapSolidRookWhiteTile); if(getTileColor(old_location_piece)==1) begin //old location was white video_putchar(boardloc[old_location_piece][0],boardloc[old_location_piece][1],mapWhiteTile); end else begin //black video_putchar(boardloc[old_location_piece][0],boardloc[old_location_piece][1],mapBlackTile); end end else begin //black tile video_putchar(boardloc[location_piece][0],boardloc[location_piece][1],mapSolidRookBlackTile); if(getTileColor(old_location_piece)==1) begin //old location was white video_putchar(boardloc[old_location_piece][0],boardloc[old_location_piece][1],mapWhiteTile); end else begin //black video_putchar(boardloc[old_location_piece][0],boardloc[old_location_piece][1],mapBlackTile); end end end /////////////////////////////////////////////////////////////////////////////// if (old_location_piece==SR2.location) begin SR2.location=location_piece; if (getTileColor(location_piece)==1) begin //white tile video_putchar(boardloc[location_piece][0],boardloc[location_piece][1],mapSolidRookWhiteTile); if(getTileColor(old_location_piece)==1) begin //old location was white video_putchar(boardloc[old_location_piece][0],boardloc[old_location_piece][1],mapWhiteTile); end else begin //black video_putchar(boardloc[old_location_piece][0],boardloc[old_location_piece][1],mapBlackTile); end end else begin //black tile video_putchar(boardloc[location_piece][0],boardloc[location_piece][1],mapSolidRookBlackTile); if(getTileColor(old_location_piece)==1) begin //old location was white video_putchar(boardloc[old_location_piece][0],boardloc[old_location_piece][1],mapWhiteTile); end else begin //black video_putchar(boardloc[old_location_piece][0],boardloc[old_location_piece][1],mapBlackTile); end end end if (old_location_piece==HR1.location) begin HR1.location=location_piece; if (getTileColor(location_piece)==1) begin //white tile video_putchar(boardloc[location_piece][0],boardloc[location_piece][1],mapHollowRookWhiteTile); if(getTileColor(old_location_piece)==1) begin //old location was white video_putchar(boardloc[old_location_piece][0],boardloc[old_location_piece][1],mapWhiteTile); end else begin //black video_putchar(boardloc[old_location_piece][0],boardloc[old_location_piece][1],mapBlackTile); end end else begin //black tile video_putchar(boardloc[location_piece][0],boardloc[location_piece][1],mapHollowRookBlackTile); if(getTileColor(old_location_piece)==1) begin //old location was white video_putchar(boardloc[old_location_piece][0],boardloc[old_location_piece][1],mapWhiteTile); end else begin //black video_putchar(boardloc[old_location_piece][0],boardloc[old_location_piece][1],mapBlackTile); end end end if (old_location_piece==HR2.location) begin HR2.location=location_piece; if (getTileColor(location_piece)==1) begin //white tile video_putchar(boardloc[location_piece][0],boardloc[location_piece][1],mapHollowRookWhiteTile); if(getTileColor(old_location_piece)==1) begin //old location was white video_putchar(boardloc[old_location_piece][0],boardloc[old_location_piece][1],mapWhiteTile); end else begin //black video_putchar(boardloc[old_location_piece][0],boardloc[old_location_piece][1],mapBlackTile); end end else begin //black tile video_putchar(boardloc[location_piece][0],boardloc[location_piece][1],mapHollowRookBlackTile); if(getTileColor(old_location_piece)==1) begin //old location was white video_putchar(boardloc[old_location_piece][0],boardloc[old_location_piece][1],mapWhiteTile); end else begin //black video_putchar(boardloc[old_location_piece][0],boardloc[old_location_piece][1],mapBlackTile); end end end if(old_location_piece==SKN1.location) begin SKN1.location=location_piece; if (getTileColor(location_piece)==1) begin //white tile video_putchar(boardloc[location_piece][0],boardloc[location_piece][1],mapSolidKnightWhiteTile); if(getTileColor(old_location_piece)==1) begin //old location was white video_putchar(boardloc[old_location_piece][0],boardloc[old_location_piece][1],mapWhiteTile); end else begin //black video_putchar(boardloc[old_location_piece][0],boardloc[old_location_piece][1],mapBlackTile); end end else begin //black tile video_putchar(boardloc[location_piece][0],boardloc[location_piece][1],mapSolidKnightBlackTile); if(getTileColor(old_location_piece)==1) begin //old location was white video_putchar(boardloc[old_location_piece][0],boardloc[old_location_piece][1],mapWhiteTile); end else begin //black video_putchar(boardloc[old_location_piece][0],boardloc[old_location_piece][1],mapBlackTile); end end end if (old_location_piece==SKN2.location) begin SKN2.location=location_piece; if (getTileColor(location_piece)==1) begin //white tile video_putchar(boardloc[location_piece][0],boardloc[location_piece][1],mapSolidKnightWhiteTile); if(getTileColor(old_location_piece)==1) begin //old location was white video_putchar(boardloc[old_location_piece][0],boardloc[old_location_piece][1],mapWhiteTile); end else begin //black video_putchar(boardloc[old_location_piece][0],boardloc[old_location_piece][1],mapBlackTile); end end else begin //black tile video_putchar(boardloc[location_piece][0],boardloc[location_piece][1],mapSolidKnightBlackTile); if(getTileColor(old_location_piece)==1) begin //old location was white video_putchar(boardloc[old_location_piece][0],boardloc[old_location_piece][1],mapWhiteTile); end else begin //black video_putchar(boardloc[old_location_piece][0],boardloc[old_location_piece][1],mapBlackTile); end end end if (old_location_piece==HKN1.location) begin HKN1.location=location_piece; if (getTileColor(location_piece)==1) begin //white tile video_putchar(boardloc[location_piece][0],boardloc[location_piece][1],mapHollowKnightWhiteTile); if(getTileColor(old_location_piece)==1) begin //old location was white video_putchar(boardloc[old_location_piece][0],boardloc[old_location_piece][1],mapWhiteTile); end else begin //black video_putchar(boardloc[old_location_piece][0],boardloc[old_location_piece][1],mapBlackTile); end end else begin //black tile video_putchar(boardloc[location_piece][0],boardloc[location_piece][1],mapHollowKnightBlackTile); if(getTileColor(old_location_piece)==1) begin //old location was white video_putchar(boardloc[old_location_piece][0],boardloc[old_location_piece][1],mapWhiteTile); end else begin //black video_putchar(boardloc[old_location_piece][0],boardloc[old_location_piece][1],mapBlackTile); end end end if (old_location_piece==HKN2.location) begin HKN2.location=location_piece; if (getTileColor(location_piece)==1) begin //white tile video_putchar(boardloc[location_piece][0],boardloc[location_piece][1],mapHollowKnightWhiteTile); if(getTileColor(old_location_piece)==1) begin //old location was white video_putchar(boardloc[old_location_piece][0],boardloc[old_location_piece][1],mapWhiteTile); end else begin //black video_putchar(boardloc[old_location_piece][0],boardloc[old_location_piece][1],mapBlackTile); end end else begin //black tile video_putchar(boardloc[location_piece][0],boardloc[location_piece][1],mapHollowKnightBlackTile); if(getTileColor(old_location_piece)==1) begin //old location was white video_putchar(boardloc[old_location_piece][0],boardloc[old_location_piece][1],mapWhiteTile); end else begin //black video_putchar(boardloc[old_location_piece][0],boardloc[old_location_piece][1],mapBlackTile); end end end if (old_location_piece==SB1.location) begin SB1.location=location_piece; if (getTileColor(location_piece)==1) begin //white tile video_putchar(boardloc[location_piece][0],boardloc[location_piece][1],mapSolidBishopWhiteTile); if(getTileColor(old_location_piece)==1) begin //old location was white video_putchar(boardloc[old_location_piece][0],boardloc[old_location_piece][1],mapWhiteTile); end else begin //black video_putchar(boardloc[old_location_piece][0],boardloc[old_location_piece][1],mapBlackTile); end end else begin //black tile video_putchar(boardloc[location_piece][0],boardloc[location_piece][1],mapSolidBishopBlackTile); if(getTileColor(old_location_piece)==1) begin //old location was white video_putchar(boardloc[old_location_piece][0],boardloc[old_location_piece][1],mapWhiteTile); end else begin //black video_putchar(boardloc[old_location_piece][0],boardloc[old_location_piece][1],mapBlackTile); end end end if (old_location_piece==SB2.location) begin SB2.location=location_piece; if (getTileColor(location_piece)==1) begin //white tile video_putchar(boardloc[location_piece][0],boardloc[location_piece][1],mapSolidBishopWhiteTile); if(getTileColor(old_location_piece)==1) begin //old location was white video_putchar(boardloc[old_location_piece][0],boardloc[old_location_piece][1],mapWhiteTile); end else begin //black video_putchar(boardloc[old_location_piece][0],boardloc[old_location_piece][1],mapBlackTile); end end else begin //black tile video_putchar(boardloc[location_piece][0],boardloc[location_piece][1],mapSolidBishopBlackTile); if(getTileColor(old_location_piece)==1) begin //old location was white video_putchar(boardloc[old_location_piece][0],boardloc[old_location_piece][1],mapWhiteTile); end else begin //black video_putchar(boardloc[old_location_piece][0],boardloc[old_location_piece][1],mapBlackTile); end end end if (old_location_piece==HB1.location) begin HB1.location=location_piece; if (getTileColor(location_piece)==1) begin //white tile video_putchar(boardloc[location_piece][0],boardloc[location_piece][1],mapHollowBishopWhiteTile); if(getTileColor(old_location_piece)==1) begin //old location was white video_putchar(boardloc[old_location_piece][0],boardloc[old_location_piece][1],mapWhiteTile); end else begin //black video_putchar(boardloc[old_location_piece][0],boardloc[old_location_piece][1],mapBlackTile); end end else begin //black tile video_putchar(boardloc[location_piece][0],boardloc[location_piece][1],mapHollowBishopBlackTile); if(getTileColor(old_location_piece)==1) begin //old location was white video_putchar(boardloc[old_location_piece][0],boardloc[old_location_piece][1],mapWhiteTile); end else begin //black video_putchar(boardloc[old_location_piece][0],boardloc[old_location_piece][1],mapBlackTile); end end end if (old_location_piece==HB2.location) begin HB2.location=location_piece; if (getTileColor(location_piece)==1) begin //white tile video_putchar(boardloc[location_piece][0],boardloc[location_piece][1],mapHollowBishopWhiteTile); if(getTileColor(old_location_piece)==1) begin //old location was white video_putchar(boardloc[old_location_piece][0],boardloc[old_location_piece][1],mapWhiteTile); end else begin //black video_putchar(boardloc[old_location_piece][0],boardloc[old_location_piece][1],mapBlackTile); end end else begin //black tile video_putchar(boardloc[location_piece][0],boardloc[location_piece][1],mapHollowBishopBlackTile); if(getTileColor(old_location_piece)==1) begin //old location was white video_putchar(boardloc[old_location_piece][0],boardloc[old_location_piece][1],mapWhiteTile); end else begin //black video_putchar(boardloc[old_location_piece][0],boardloc[old_location_piece][1],mapBlackTile); end end end if (old_location_piece==SK1.location) begin SK1.location=location_piece; if (getTileColor(location_piece)==1) begin //white tile video_putchar(boardloc[location_piece][0],boardloc[location_piece][1],mapSolidKingWhiteTile); if(getTileColor(old_location_piece)==1) begin //old location was white video_putchar(boardloc[old_location_piece][0],boardloc[old_location_piece][1],mapWhiteTile); end else begin //black video_putchar(boardloc[old_location_piece][0],boardloc[old_location_piece][1],mapBlackTile); end end else begin //black tile video_putchar(boardloc[location_piece][0],boardloc[location_piece][1],mapSolidKingBlackTile); if(getTileColor(old_location_piece)==1) begin //old location was white video_putchar(boardloc[old_location_piece][0],boardloc[old_location_piece][1],mapWhiteTile); end else begin //black video_putchar(boardloc[old_location_piece][0],boardloc[old_location_piece][1],mapBlackTile); end end end if (old_location_piece==HK1.location) begin HK1.location=location_piece; if (getTileColor(location_piece)==1) begin //white tile video_putchar(boardloc[location_piece][0],boardloc[location_piece][1],mapHollowKingWhiteTile); if(getTileColor(old_location_piece)==1) begin //old location was white video_putchar(boardloc[old_location_piece][0],boardloc[old_location_piece][1],mapWhiteTile); end else begin //black video_putchar(boardloc[old_location_piece][0],boardloc[old_location_piece][1],mapBlackTile); end end else begin //black tile video_putchar(boardloc[location_piece][0],boardloc[location_piece][1],mapHollowKingBlackTile); if(getTileColor(old_location_piece)==1) begin //old location was white video_putchar(boardloc[old_location_piece][0],boardloc[old_location_piece][1],mapWhiteTile); end else begin //black video_putchar(boardloc[old_location_piece][0],boardloc[old_location_piece][1],mapBlackTile); end end end if (old_location_piece==SQ1.location) begin SQ1.location=location_piece; if (getTileColor(location_piece)==1) begin //white tile video_putchar(boardloc[location_piece][0],boardloc[location_piece][1],mapSolidQueenWhiteTile); if(getTileColor(old_location_piece)==1) begin //old location was white video_putchar(boardloc[old_location_piece][0],boardloc[old_location_piece][1],mapWhiteTile); end else begin //black video_putchar(boardloc[old_location_piece][0],boardloc[old_location_piece][1],mapBlackTile); end end else begin //black tile video_putchar(boardloc[location_piece][0],boardloc[location_piece][1],mapSolidQueenBlackTile); if(getTileColor(old_location_piece)==1) begin //old location was white video_putchar(boardloc[old_location_piece][0],boardloc[old_location_piece][1],mapWhiteTile); end else begin //black video_putchar(boardloc[old_location_piece][0],boardloc[old_location_piece][1],mapBlackTile); end end end if (old_location_piece==HQ1.location) begin HQ1.location=location_piece; if (getTileColor(location_piece)==1) begin //white tile video_putchar(boardloc[location_piece][0],boardloc[location_piece][1],mapHollowQueenWhiteTile); if(getTileColor(old_location_piece)==1) begin //old location was white video_putchar(boardloc[old_location_piece][0],boardloc[old_location_piece][1],mapWhiteTile); end else begin //black video_putchar(boardloc[old_location_piece][0],boardloc[old_location_piece][1],mapBlackTile); end end else begin //black tile video_putchar(boardloc[location_piece][0],boardloc[location_piece][1],mapHollowQueenBlackTile); if(getTileColor(old_location_piece)==1) begin //old location was white video_putchar(boardloc[old_location_piece][0],boardloc[old_location_piece][1],mapWhiteTile); end else begin //black video_putchar(boardloc[old_location_piece][0],boardloc[old_location_piece][1],mapBlackTile); end end end if (old_location_piece==SP1.location) begin SP1.location=location_piece; if (getTileColor(location_piece)==1) begin //white tile video_putchar(boardloc[location_piece][0],boardloc[location_piece][1],mapSolidPawnWhiteTile); if(getTileColor(old_location_piece)==1) begin //old location was white video_putchar(boardloc[old_location_piece][0],boardloc[old_location_piece][1],mapWhiteTile); end else begin //black video_putchar(boardloc[old_location_piece][0],boardloc[old_location_piece][1],mapBlackTile); end end else begin //black tile video_putchar(boardloc[location_piece][0],boardloc[location_piece][1],mapSolidPawnBlackTile); if(getTileColor(old_location_piece)==1) begin //old location was white video_putchar(boardloc[old_location_piece][0],boardloc[old_location_piece][1],mapWhiteTile); end else begin //black video_putchar(boardloc[old_location_piece][0],boardloc[old_location_piece][1],mapBlackTile); end end end if (old_location_piece==SP2.location) begin SP2.location=location_piece; if (getTileColor(location_piece)==1) begin //white tile video_putchar(boardloc[location_piece][0],boardloc[location_piece][1],mapSolidPawnWhiteTile); if(getTileColor(old_location_piece)==1) begin //old location was white video_putchar(boardloc[old_location_piece][0],boardloc[old_location_piece][1],mapWhiteTile); end else begin //black video_putchar(boardloc[old_location_piece][0],boardloc[old_location_piece][1],mapBlackTile); end end else begin //black tile video_putchar(boardloc[location_piece][0],boardloc[location_piece][1],mapSolidPawnBlackTile); if(getTileColor(old_location_piece)==1) begin //old location was white video_putchar(boardloc[old_location_piece][0],boardloc[old_location_piece][1],mapWhiteTile); end else begin //black video_putchar(boardloc[old_location_piece][0],boardloc[old_location_piece][1],mapBlackTile); end end end if (old_location_piece==SP3.location) begin SP3.location=location_piece; if (getTileColor(location_piece)==1) begin //white tile video_putchar(boardloc[location_piece][0],boardloc[location_piece][1],mapSolidPawnWhiteTile); if(getTileColor(old_location_piece)==1) begin //old location was white video_putchar(boardloc[old_location_piece][0],boardloc[old_location_piece][1],mapWhiteTile); end else begin //black video_putchar(boardloc[old_location_piece][0],boardloc[old_location_piece][1],mapBlackTile); end end else begin //black tile video_putchar(boardloc[location_piece][0],boardloc[location_piece][1],mapSolidPawnBlackTile); if(getTileColor(old_location_piece)==1) begin //old location was white video_putchar(boardloc[old_location_piece][0],boardloc[old_location_piece][1],mapWhiteTile); end else begin //black video_putchar(boardloc[old_location_piece][0],boardloc[old_location_piece][1],mapBlackTile); end end end if (old_location_piece==SP4.location) begin SP4.location=location_piece; if (getTileColor(location_piece)==1) begin //white tile video_putchar(boardloc[location_piece][0],boardloc[location_piece][1],mapSolidPawnWhiteTile); if(getTileColor(old_location_piece)==1) begin //old location was white video_putchar(boardloc[old_location_piece][0],boardloc[old_location_piece][1],mapWhiteTile); end else begin //black video_putchar(boardloc[old_location_piece][0],boardloc[old_location_piece][1],mapBlackTile); end end else begin //black tile video_putchar(boardloc[location_piece][0],boardloc[location_piece][1],mapSolidPawnBlackTile); if(getTileColor(old_location_piece)==1) begin //old location was white video_putchar(boardloc[old_location_piece][0],boardloc[old_location_piece][1],mapWhiteTile); end else begin //black video_putchar(boardloc[old_location_piece][0],boardloc[old_location_piece][1],mapBlackTile); end end end if (old_location_piece==SP5.location) begin SP5.location=location_piece; if (getTileColor(location_piece)==1) begin //white tile video_putchar(boardloc[location_piece][0],boardloc[location_piece][1],mapSolidPawnWhiteTile); if(getTileColor(old_location_piece)==1) begin //old location was white video_putchar(boardloc[old_location_piece][0],boardloc[old_location_piece][1],mapWhiteTile); end else begin //black video_putchar(boardloc[old_location_piece][0],boardloc[old_location_piece][1],mapBlackTile); end end else begin //black tile video_putchar(boardloc[location_piece][0],boardloc[location_piece][1],mapSolidPawnBlackTile); if(getTileColor(old_location_piece)==1) begin //old location was white video_putchar(boardloc[old_location_piece][0],boardloc[old_location_piece][1],mapWhiteTile); end else begin //black video_putchar(boardloc[old_location_piece][0],boardloc[old_location_piece][1],mapBlackTile); end end end if (old_location_piece==SP6.location) begin SP6.location=location_piece; if (getTileColor(location_piece)==1) begin //white tile video_putchar(boardloc[location_piece][0],boardloc[location_piece][1],mapSolidPawnWhiteTile); if(getTileColor(old_location_piece)==1) begin //old location was white video_putchar(boardloc[old_location_piece][0],boardloc[old_location_piece][1],mapWhiteTile); end else begin //black video_putchar(boardloc[old_location_piece][0],boardloc[old_location_piece][1],mapBlackTile); end end else begin //black tile video_putchar(boardloc[location_piece][0],boardloc[location_piece][1],mapSolidPawnBlackTile); if(getTileColor(old_location_piece)==1) begin //old location was white video_putchar(boardloc[old_location_piece][0],boardloc[old_location_piece][1],mapWhiteTile); end else begin //black video_putchar(boardloc[old_location_piece][0],boardloc[old_location_piece][1],mapBlackTile); end end end if (old_location_piece==SP7.location) begin SP7.location=location_piece; if (getTileColor(location_piece)==1) begin //white tile video_putchar(boardloc[location_piece][0],boardloc[location_piece][1],mapSolidPawnWhiteTile); if(getTileColor(old_location_piece)==1) begin //old location was white video_putchar(boardloc[old_location_piece][0],boardloc[old_location_piece][1],mapWhiteTile); end else begin //black video_putchar(boardloc[old_location_piece][0],boardloc[old_location_piece][1],mapBlackTile); end end else begin //black tile video_putchar(boardloc[location_piece][0],boardloc[location_piece][1],mapSolidPawnBlackTile); if(getTileColor(old_location_piece)==1) begin //old location was white video_putchar(boardloc[old_location_piece][0],boardloc[old_location_piece][1],mapWhiteTile); end else begin //black video_putchar(boardloc[old_location_piece][0],boardloc[old_location_piece][1],mapBlackTile); end end end if (old_location_piece==SP8.location) begin SP8.location=location_piece; if (getTileColor(location_piece)==1) begin //white tile video_putchar(boardloc[location_piece][0],boardloc[location_piece][1],mapSolidPawnWhiteTile); if(getTileColor(old_location_piece)==1) begin //old location was white video_putchar(boardloc[old_location_piece][0],boardloc[old_location_piece][1],mapWhiteTile); end else begin //black video_putchar(boardloc[old_location_piece][0],boardloc[old_location_piece][1],mapBlackTile); end end else begin //black tile video_putchar(boardloc[location_piece][0],boardloc[location_piece][1],mapSolidPawnBlackTile); if(getTileColor(old_location_piece)==1) begin //old location was white video_putchar(boardloc[old_location_piece][0],boardloc[old_location_piece][1],mapWhiteTile); end else begin //black video_putchar(boardloc[old_location_piece][0],boardloc[old_location_piece][1],mapBlackTile); end end end if (old_location_piece==HP1.location) begin HP1.location=location_piece; if (getTileColor(location_piece)==1) begin //white tile video_putchar(boardloc[location_piece][0],boardloc[location_piece][1],mapHollowPawnWhiteTile); if(getTileColor(old_location_piece)==1) begin //old location was white video_putchar(boardloc[old_location_piece][0],boardloc[old_location_piece][1],mapWhiteTile); end else begin //black video_putchar(boardloc[old_location_piece][0],boardloc[old_location_piece][1],mapBlackTile); end end else begin //black tile video_putchar(boardloc[location_piece][0],boardloc[location_piece][1],mapHollowPawnBlackTile); if(getTileColor(old_location_piece)==1) begin //old location was white video_putchar(boardloc[old_location_piece][0],boardloc[old_location_piece][1],mapWhiteTile); end else begin //black video_putchar(boardloc[old_location_piece][0],boardloc[old_location_piece][1],mapBlackTile); end end end if(old_location_piece==HP2.location) begin HP2.location=location_piece; if (getTileColor(location_piece)==1) begin //white tile video_putchar(boardloc[location_piece][0],boardloc[location_piece][1],mapHollowPawnWhiteTile); if(getTileColor(old_location_piece)==1) begin //old location was white video_putchar(boardloc[old_location_piece][0],boardloc[old_location_piece][1],mapWhiteTile); end else begin //black video_putchar(boardloc[old_location_piece][0],boardloc[old_location_piece][1],mapBlackTile); end end else begin //black tile video_putchar(boardloc[location_piece][0],boardloc[location_piece][1],mapHollowPawnBlackTile); if(getTileColor(old_location_piece)==1) begin //old location was white video_putchar(boardloc[old_location_piece][0],boardloc[old_location_piece][1],mapWhiteTile); end else begin //black video_putchar(boardloc[old_location_piece][0],boardloc[old_location_piece][1],mapBlackTile); end end end if (old_location_piece==HP3.location) begin HP3.location=location_piece; if (getTileColor(location_piece)==1) begin //white tile video_putchar(boardloc[location_piece][0],boardloc[location_piece][1],mapHollowPawnWhiteTile); if(getTileColor(old_location_piece)==1) begin //old location was white video_putchar(boardloc[old_location_piece][0],boardloc[old_location_piece][1],mapWhiteTile); end else begin //black video_putchar(boardloc[old_location_piece][0],boardloc[old_location_piece][1],mapBlackTile); end end else begin //black tile video_putchar(boardloc[location_piece][0],boardloc[location_piece][1],mapHollowPawnBlackTile); if(getTileColor(old_location_piece)==1) begin //old location was white video_putchar(boardloc[old_location_piece][0],boardloc[old_location_piece][1],mapWhiteTile); end else begin //black video_putchar(boardloc[old_location_piece][0],boardloc[old_location_piece][1],mapBlackTile); end end end if (old_location_piece==HP4.location) begin HP4.location=location_piece; if (getTileColor(location_piece)==1) begin //white tile video_putchar(boardloc[location_piece][0],boardloc[location_piece][1],mapHollowPawnWhiteTile); if(getTileColor(old_location_piece)==1) begin //old location was white video_putchar(boardloc[old_location_piece][0],boardloc[old_location_piece][1],mapWhiteTile); end else begin //black video_putchar(boardloc[old_location_piece][0],boardloc[old_location_piece][1],mapBlackTile); end end else begin //black tile video_putchar(boardloc[location_piece][0],boardloc[location_piece][1],mapHollowPawnBlackTile); if(getTileColor(old_location_piece)==1) begin //old location was white video_putchar(boardloc[old_location_piece][0],boardloc[old_location_piece][1],mapWhiteTile); end else begin //black video_putchar(boardloc[old_location_piece][0],boardloc[old_location_piece][1],mapBlackTile); end end end if (old_location_piece==HP5.location) begin HP5.location=location_piece; if (getTileColor(location_piece)==1) begin //white tile video_putchar(boardloc[location_piece][0],boardloc[location_piece][1],mapHollowPawnWhiteTile); if(getTileColor(old_location_piece)==1) begin //old location was white video_putchar(boardloc[old_location_piece][0],boardloc[old_location_piece][1],mapWhiteTile); end else begin //black video_putchar(boardloc[old_location_piece][0],boardloc[old_location_piece][1],mapBlackTile); end end else begin //black tile video_putchar(boardloc[location_piece][0],boardloc[location_piece][1],mapHollowPawnBlackTile); if(getTileColor(old_location_piece)==1) begin //old location was white video_putchar(boardloc[old_location_piece][0],boardloc[old_location_piece][1],mapWhiteTile); end else begin //black video_putchar(boardloc[old_location_piece][0],boardloc[old_location_piece][1],mapBlackTile); end end end if (old_location_piece==HP6.location) begin HP6.location=location_piece; if (getTileColor(location_piece)==1) begin //white tile video_putchar(boardloc[location_piece][0],boardloc[location_piece][1],mapHollowPawnWhiteTile); if(getTileColor(old_location_piece)==1) begin //old location was white video_putchar(boardloc[old_location_piece][0],boardloc[old_location_piece][1],mapWhiteTile); end else begin //black video_putchar(boardloc[old_location_piece][0],boardloc[old_location_piece][1],mapBlackTile); end end else begin //black tile video_putchar(boardloc[location_piece][0],boardloc[location_piece][1],mapHollowPawnBlackTile); if(getTileColor(old_location_piece)==1) begin //old location was white video_putchar(boardloc[old_location_piece][0],boardloc[old_location_piece][1],mapWhiteTile); end else begin //black video_putchar(boardloc[old_location_piece][0],boardloc[old_location_piece][1],mapBlackTile); end end end if (old_location_piece==HP7.location) begin HP7.location=location_piece; if (getTileColor(location_piece)==1) begin //white tile video_putchar(boardloc[location_piece][0],boardloc[location_piece][1],mapHollowPawnWhiteTile); if(getTileColor(old_location_piece)==1) begin //old location was white video_putchar(boardloc[old_location_piece][0],boardloc[old_location_piece][1],mapWhiteTile); end else begin //black video_putchar(boardloc[old_location_piece][0],boardloc[old_location_piece][1],mapBlackTile); end end else begin //black tile video_putchar(boardloc[location_piece][0],boardloc[location_piece][1],mapHollowPawnBlackTile); if(getTileColor(old_location_piece)==1) begin //old location was white video_putchar(boardloc[old_location_piece][0],boardloc[old_location_piece][1],mapWhiteTile); end else begin //black video_putchar(boardloc[old_location_piece][0],boardloc[old_location_piece][1],mapBlackTile); end end end if (old_location_piece==HP8.location) begin HP8.location=location_piece; if (getTileColor(location_piece)==1) begin //white tile video_putchar(boardloc[location_piece][0],boardloc[location_piece][1],mapHollowPawnWhiteTile); if(getTileColor(old_location_piece)==1) begin //old location was white video_putchar(boardloc[old_location_piece][0],boardloc[old_location_piece][1],mapWhiteTile); end else begin //black video_putchar(boardloc[old_location_piece][0],boardloc[old_location_piece][1],mapBlackTile); end end else begin //black tile video_putchar(boardloc[location_piece][0],boardloc[location_piece][1],mapHollowPawnBlackTile); if(getTileColor(old_location_piece)==1) begin //old location was white video_putchar(boardloc[old_location_piece][0],boardloc[old_location_piece][1],mapWhiteTile); end else begin //black video_putchar(boardloc[old_location_piece][0],boardloc[old_location_piece][1],mapBlackTile); end end end old_location_piece=251; location_piece=250; turn=turn^1; end//possible else if ((old_location_piece!=250)&&(location_piece!=250)) begin location_piece=250;//old_location_piece; old_location_piece=251; loc_deb=-1; loc_deb_count=0; end end//task1 int getTileColor(unsigned char location_piece) begin if (((location_piece/8) %2 ==0) && ((location_piece%8)%2 ==0)) return 1; //white if (((location_piece/8) %2 ==1) && ((location_piece%8)%2 ==1)) return 1; //white if (((location_piece/8) %2 ==0) && ((location_piece%8)%2 ==1)) return 0; //black if (((location_piece/8) %2 ==1) && ((location_piece%8)%2 ==0)) return 0; //black end