if(fromX == -1 || fromY == -1) {\r
fromX = BOARD_LEFT; fromY = 0;\r
}\r
+ if(flipView) switch(wParam) {\r
+ case VK_LEFT: wParam = VK_RIGHT; break;\r
+ case VK_RIGHT: wParam = VK_LEFT; break;\r
+ case VK_UP: wParam = VK_DOWN; break;\r
+ case VK_DOWN: wParam = VK_UP; break;\r
+ }\r
switch(wParam) {\r
case VK_LEFT:\r
if(fromX == BOARD_RGHT+1) fromX -= 2; else\r
SayString("", TRUE); // flush\r
}\r
\r
+int\r
+OnBoard(int x, int y)\r
+{\r
+ return x >= BOARD_LEFT && x < BOARD_RGHT && y >= 0 && y < BOARD_HEIGHT;\r
+}\r
+\r
VOID\r
SayUpperDiagnols()\r
{\r
ChessSquare currentpiece;\r
char *piece, *xchar, *ynum ;\r
- int yPos, xPos;\r
+ int yPos, xPos, dir = (flipView ? -1 : 1);\r
\r
if(fromX < 0 || fromY < 0) return;\r
\r
- if(fromX < BOARD_RGHT-1 && fromY < BOARD_HEIGHT-1) {\r
+ if(OnBoard(fromX+dir, fromY+dir)) {\r
SayString("The diagnol squares to your upper right contain", FALSE);\r
- yPos = fromY+1;\r
- xPos = fromX+1;\r
- while(yPos<BOARD_HEIGHT && xPos<BOARD_RGHT) {\r
+ yPos = fromY+dir;\r
+ xPos = fromX+dir;\r
+ while(OnBoard(xPos, yPos)) {\r
currentpiece = boards[currentMove][yPos][xPos];\r
piece = PieceToName(currentpiece,1);\r
xchar = SquareToChar(xPos);\r
SayString(xchar , FALSE);\r
SayString(ynum, FALSE);\r
SayString(piece, FALSE);\r
- yPos++;\r
- xPos++;\r
+ yPos+=dir;\r
+ xPos+=dir;\r
}\r
}\r
else SayString("There is no squares to your upper right", FALSE);\r
\r
- if(fromX > BOARD_LEFT && fromY < BOARD_HEIGHT-1) {\r
+ if(OnBoard(fromX-dir, fromY+dir)) {\r
SayString("The diagnol squares to your upper left contain", FALSE);\r
- yPos = fromY+1;\r
- xPos = fromX-1;\r
- while(yPos<BOARD_HEIGHT && xPos>=BOARD_LEFT) {\r
+ yPos = fromY+dir;\r
+ xPos = fromX-dir;\r
+ while(OnBoard(xPos, yPos)) {\r
currentpiece = boards[currentMove][yPos][xPos];\r
piece = PieceToName(currentpiece,1);\r
xchar = SquareToChar(xPos);\r
SayString(xchar , FALSE);\r
SayString(ynum, FALSE);\r
SayString(piece, FALSE);\r
- yPos++;\r
- xPos--;\r
+ yPos+=dir;\r
+ xPos-=dir;\r
}\r
}\r
else SayString("There is no squares to your upper left", FALSE);\r
{\r
ChessSquare currentpiece;\r
char *piece, *xchar, *ynum ;\r
- int yPos, xPos;\r
+ int yPos, xPos, dir = (flipView ? -1 : 1);\r
\r
if(fromX < 0 || fromY < 0) return;\r
\r
- if(fromX < BOARD_RGHT-1 && fromY > 0) {\r
+ if(OnBoard(fromX+dir, fromY-dir)) {\r
SayString("The diagnol squares to your lower right contain", FALSE);\r
- yPos = fromY-1;\r
- xPos = fromX+1;\r
- while(yPos>=0 && xPos<BOARD_RGHT) {\r
+ yPos = fromY-dir;\r
+ xPos = fromX+dir;\r
+ while(OnBoard(xPos, yPos)) {\r
currentpiece = boards[currentMove][yPos][xPos];\r
piece = PieceToName(currentpiece,1);\r
xchar = SquareToChar(xPos);\r
SayString(xchar , FALSE);\r
SayString(ynum, FALSE);\r
SayString(piece, FALSE);\r
- yPos--;\r
- xPos++;\r
+ yPos-=dir;\r
+ xPos+=dir;\r
}\r
}\r
else SayString("There is no squares to your lower right", FALSE);\r
\r
- if(fromX > BOARD_LEFT && fromY > 0) {\r
+ if(OnBoard(fromX-dir, fromY-dir)) {\r
SayString("The diagnol squares to your lower left contain", FALSE);\r
- yPos = fromY-1;\r
- xPos = fromX-1;\r
- while(yPos>=0 && xPos>=BOARD_LEFT) {\r
+ yPos = fromY-dir;\r
+ xPos = fromX-dir;\r
+ while(OnBoard(xPos, yPos)) {\r
currentpiece = boards[currentMove][yPos][xPos];\r
piece = PieceToName(currentpiece,1);\r
xchar = SquareToChar(xPos);\r
SayString(xchar , FALSE);\r
SayString(ynum, FALSE);\r
SayString(piece, FALSE);\r
- yPos--;\r
- xPos--;\r
+ yPos-=dir;\r
+ xPos-=dir;\r
}\r
}\r
else SayString("There is no squares to your lower left", FALSE);\r