\r
extern long whiteTimeRemaining, blackTimeRemaining, timeControl, timeIncrement;\r
\r
-#if 0\r
-// from moves.h, but no longer needed, as the new routines are all moved to winboard.c\r
-\r
-extern char* PieceToName P((ChessSquare p, int i));\r
-extern char* SquareToChar P((int Xpos)); \r
-extern char* SquareToNum P((int Ypos));\r
-extern int CoordToNum P((char c));\r
-\r
-#endif\r
-\r
// from moves.c, added WinBoard_F piece types and ranks / files\r
\r
char *squareToChar[] = { "ay", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l" };\r
"Empty"\r
};\r
\r
+char *pieceTypeName[] = {\r
+ "Pawn", "Knight", "Bishop", "Rook", "Queen", \r
+ "Guard", "Elephant", "Arch Bishop", "Chancellor",\r
+ "General", "Man", "Cannon", "Night Rider",\r
+ "Crowned Bishop", "Crowned Rook", "Grass Hopper", "Veteran",\r
+ "Falcon", "Amazon", "Snake", "Unicorn",\r
+ "King",\r
+ "Pawn", "Knight", "Bishop", "Rook", "Queen", \r
+ "Guard", "Elephant", "Arch Bishop", "Chancellor",\r
+ "General", "Man", "Cannon", "Night Rider",\r
+ "Crowned Bishop", "Crowned Rook", "Grass Hopper", "Veteran",\r
+ "Falcon", "Amazon", "Snake", "Unicorn",\r
+ "King",\r
+ "Empty"\r
+ };\r
+\r
int CoordToNum(c)\r
char c;\r
{\r
int i;\r
{\r
if(i) return pieceToName[(int) p];\r
- return pieceToName[(int) p]+6;\r
+ return pieceTypeName[(int) p];\r
}\r
\r
char* SquareToChar(x)\r
\r
VOID SayString(char *mess, BOOL flag)\r
{ // for debug file\r
- char buf[MSG_SIZ], *p;\r
+ char buf[8000], *p;\r
if(appData.debugMode) fprintf(debugFP, "SAY '%s'\n", mess);\r
strcpy(buf, mess);\r
if(p = StrCaseStr(buf, "Xboard adjudication:")) {\r
{"Say Board &Rank\tAlt+R", IDM_ReadRow },\r
{"Say Board &File\tAlt+F", IDM_ReadColumn },\r
{"-", 0 },\r
-{"Say &Upper Diagnols\tAlt+U", IDM_SayUpperDiagnols },\r
-{"Say &Lower Diagnols\tAlt+L", IDM_SayLowerDiagnols },\r
+{"Say &Upper Diagonals\tAlt+U", IDM_SayUpperDiagnols },\r
+{"Say &Lower Diagonals\tAlt+L", IDM_SayLowerDiagnols },\r
{"Say K&night Moves\tAlt+N", IDM_SayKnightMoves },\r
{"Say Current &Square\tAlt+S", IDM_SayCurrentPos },\r
{"Say &Attacks\tAlt+A", IDM_PossibleAttackMove },\r
{\r
HMENU menuMain, menuJAWS;\r
MENUBARINFO helpMenuInfo;\r
- int e, i;\r
+ int i;\r
\r
helpMenuInfo.cbSize = sizeof(helpMenuInfo);\r
menuMain = GetMenu(hwndMain);\r
- if(appData.debugMode) fprintf(debugFP, "hwndMain: %8x %8x\n", hwndMain, menuMain);\r
menuJAWS = CreatePopupMenu();\r
\r
for(i=0; menuItemJAWS[i].name; i++) {\r
return TRUE;\r
}\r
\r
+int beeps[] = { 1, 0, 0, 0, 0 };\r
+int beepCodes[] = { 0, MB_OK, MB_ICONERROR, MB_ICONQUESTION, MB_ICONEXCLAMATION, MB_ICONASTERISK };\r
+\r
VOID\r
KeyboardEvent(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)\r
{\r
ChessSquare currentPiece;\r
char *piece, *xchar, *ynum ;\r
- int n;\r
+ int n, beepType = 1; // empty beep\r
\r
if(fromX == -1 || fromY == -1) {\r
fromX = BOARD_LEFT; fromY = 0;\r
switch(wParam) {\r
case VK_LEFT:\r
if(fromX == BOARD_RGHT+1) fromX -= 2; else\r
- if(fromX == BOARD_LEFT) { if(fromY >= BOARD_HEIGHT - gameInfo.holdingsSize) fromX -= 2; } else\r
- if(fromX > BOARD_LEFT) fromX--;\r
+ if(fromX == BOARD_LEFT) { if(fromY >= BOARD_HEIGHT - gameInfo.holdingsSize) fromX -= 2; else beepType = 0; } else\r
+ if(fromX > BOARD_LEFT) fromX--; else beepType = 0; // off-board beep\r
break;\r
case VK_RIGHT:\r
if(fromX == BOARD_LEFT-2) fromX += 2; else\r
- if(fromX == BOARD_RGHT-1) { if(fromY < gameInfo.holdingsSize) fromX += 2; } else\r
- if(fromX < BOARD_RGHT-1) fromX++;\r
+ if(fromX == BOARD_RGHT-1) { if(fromY < gameInfo.holdingsSize) fromX += 2; else beepType = 0; } else\r
+ if(fromX < BOARD_RGHT-1) fromX++; else beepType = 0;\r
break;\r
case VK_UP:\r
- if(fromX == BOARD_RGHT+1) { if(fromY < gameInfo.holdingsSize - 1) fromY++; } else\r
- if(fromY < BOARD_HEIGHT-1) fromY++;\r
+ if(fromX == BOARD_RGHT+1) { if(fromY < gameInfo.holdingsSize - 1) fromY++; else beepType = 0; } else\r
+ if(fromY < BOARD_HEIGHT-1) fromY++; else beepType = 0;\r
break;\r
case VK_DOWN:\r
- if(fromX == BOARD_LEFT-2) { if(fromY > BOARD_HEIGHT - gameInfo.holdingsSize) fromY--; } else\r
- if(fromY > 0) fromY--;\r
+ if(fromX == BOARD_LEFT-2) { if(fromY > BOARD_HEIGHT - gameInfo.holdingsSize) fromY--; else beepType = 0; } else\r
+ if(fromY > 0) fromY--; else beepType = 0;\r
break;\r
}\r
SetHighlights(fromX, fromY, -1, -1);\r
DrawPosition(FALSE, NULL);\r
currentPiece = boards[currentMove][fromY][fromX];\r
piece = PieceToName(currentPiece,1);\r
- if(currentPiece != EmptySquare) MessageBeep(currentPiece < (int)BlackPawn ? MB_OK : MB_ICONEXCLAMATION);\r
+ if(beepType == 1 && currentPiece != EmptySquare) beepType = currentPiece < (int) BlackPawn ? 2 : 3; // white or black beep\r
+ if(beeps[beepType] == beeps[1] && (fromX == BOARD_RGHT+1 || fromX == BOARD_LEFT-2)) beepType = 4; // holdings beep\r
+ beepType = beeps[beepType]%6;\r
+ if(beepType) MessageBeep(beepCodes[beepType]);\r
if(fromX == BOARD_LEFT - 2) {\r
SayString("black holdings", FALSE);\r
if(currentPiece != EmptySquare) {\r
char buf[MSG_SIZ];\r
n = boards[currentMove][fromY][1];\r
- sprintf(buf, "%d %s%s", n, piece+6, n == 1 ? "" : "s");\r
+ sprintf(buf, "%d %s%s", n, PieceToName(currentPiece,0), n == 1 ? "" : "s");\r
SayString(buf, TRUE);\r
}\r
} else\r
if(currentPiece != EmptySquare) {\r
char buf[MSG_SIZ];\r
n = boards[currentMove][fromY][BOARD_WIDTH-2];\r
- sprintf(buf, "%d %s%s", n, piece+6, n == 1 ? "" : "s");\r
+ sprintf(buf, "%d %s%s", n, PieceToName(currentPiece,0), n == 1 ? "" : "s");\r
SayString(buf, TRUE);\r
}\r
} else\r
return;\r
}\r
\r
-extern char castlingRights[MAX_MOVES][BOARD_SIZE];\r
int PosFlags(int nr);\r
\r
typedef struct {\r
swapColor = piece < (int)BlackPawn && !WhiteOnMove(currentMove) ||\r
piece >= (int)BlackPawn && WhiteOnMove(currentMove);\r
cl.count = 0; cl.rf = fromY; cl.ff = fromX; cl.rt = cl.ft = -1;\r
- GenLegal(boards[currentMove], PosFlags(currentMove + swapColor), EP_NONE, \r
- castlingRights[currentMove], ReadCallback, (VOIDSTAR) &cl);\r
+ GenLegal(boards[currentMove], PosFlags(currentMove + swapColor), ReadCallback, (VOIDSTAR) &cl);\r
if(cl.count == 0) SayString("None", FALSE);\r
boards[currentMove][fromY][fromX] = victim; // repair\r
\r
victim = boards[currentMove][fromY][fromX]; // put dummy piece on target square, to activate Pawn captures\r
boards[currentMove][fromY][fromX] = WhiteOnMove(currentMove) ? WhiteQueen : BlackQueen;\r
cl.count = 0; cl.rt = fromY; cl.ft = fromX; cl.rf = cl.ff = -1;\r
- GenLegal(boards[currentMove], PosFlags(currentMove+1), EP_NONE, \r
- castlingRights[currentMove], ReadCallback, (VOIDSTAR) &cl);\r
+ GenLegal(boards[currentMove], PosFlags(currentMove+1), ReadCallback, (VOIDSTAR) &cl);\r
if(cl.count == 0) SayString("None", FALSE);\r
\r
SayString("You are defended by", FALSE);\r
\r
boards[currentMove][fromY][fromX] = WhiteOnMove(currentMove) ? BlackQueen : WhiteQueen;\r
cl.count = 0; cl.rt = fromY; cl.ft = fromX; cl.rf = cl.ff = -1;\r
- GenLegal(boards[currentMove], PosFlags(currentMove), EP_NONE, \r
- castlingRights[currentMove], ReadCallback, (VOIDSTAR) &cl);\r
+ GenLegal(boards[currentMove], PosFlags(currentMove), ReadCallback, (VOIDSTAR) &cl);\r
if(cl.count == 0) SayString("None", FALSE);\r
boards[currentMove][fromY][fromX] = victim; // put back original occupant\r
\r
{\r
int Xpos, Ypos;\r
ChessSquare currentpiece;\r
- char *piece, *xchar, *ynum ;\r
+ char *piece, *ynum ;\r
\r
if(gameInfo.holdingsWidth) {\r
int first = 0;\r
for(Xpos=BOARD_LEFT; Xpos<BOARD_RGHT; Xpos++) {\r
currentpiece = boards[currentMove][Ypos][Xpos]; \r
if(currentpiece != EmptySquare) {\r
- int count = 0, oldX = Xpos;\r
+ int count = 0;\r
char buf[50];\r
piece = PieceToName(currentpiece,1);\r
while(Xpos < BOARD_RGHT && boards[currentMove][Ypos][Xpos] == currentpiece)\r
}\r
}\r
\r
+extern char *commentList[];\r
\r
VOID\r
SayMachineMove(int evenIfDuplicate)\r
{\r
int len, xPos, yPos, moveNr, secondSpace = 0, castle = 0, n;\r
ChessSquare currentpiece;\r
- char *piece, *xchar, *ynum, *p;\r
+ char *piece, *xchar, *ynum, *p, checkMark = 0;\r
char c, buf[MSG_SIZ], comment[MSG_SIZ];\r
static char disambiguation[2];\r
static int previousMove = 0;\r
if(secondSpace) len = secondSpace; // position behind move\r
if(messageText[len-1] == '+' || messageText[len-1] == '#') { /* you are in checkmate */\r
len--; // strip off check or mate indicator\r
+ checkMark = messageText[len]; // make sure still seen after we stip off promo piece\r
}\r
if(messageText[len-2] == '=') { /* promotion */\r
len-=2; // strip off promotion piece\r
SayString(piece, FALSE);\r
} else SayString("Capturing onn passann",FALSE);\r
}\r
- if(messageText[len] == '+') SayString("check", FALSE); else\r
- if(messageText[len] == '#') {\r
+ }\r
+ if(checkMark == '+') SayString("check", FALSE); else\r
+ if(checkMark == '#') {\r
SayString("finishing off", FALSE);\r
SayString(WhiteOnMove(n) ? "White" : "Black", FALSE);\r
- }\r
}\r
}\r
\r
SayString(comment, FALSE); // alphabetic comment (usually game end)\r
} else if(p) SayString(p, FALSE);\r
\r
+ if(commentDialog && commentList[currentMove]) SetFocus(commentDialog);\r
+\r
} else {\r
/* starts not with digit */\r
if(StrCaseStr(messageText, "illegal")) PlayIcsUnfinishedSound();\r
(BlackPawn <= pdown && pdown <= BlackKing &&\r
BlackPawn <= pup && pup <= BlackKing))) {\r
/* EditPosition, empty square, or different color piece;\r
- click-click move is possible */\r
+ click-click move is possible */ \r
+ char promoChoice = NULLCHAR;\r
\r
- if (IsPromotion(oldFromX, oldFromY, fromX, fromY)) {\r
+ if (HasPromotionChoice(oldFromX, oldFromY, fromX, fromY, &promoChoice)) {\r
if (appData.alwaysPromoteToQueen) {\r
UserMoveEvent(oldFromX, oldFromY, fromX, fromY, 'q');\r
}\r
} \r
}\r
else {\r
- UserMoveEvent(oldFromX, oldFromY, fromX, fromY, NULLCHAR);\r
+ UserMoveEvent(oldFromX, oldFromY, fromX, fromY, promoChoice);\r
}\r
oldFromX = oldFromY = -1;\r
break;\r
return (x%3000 == 0);\r
}\r
\r
-#if 0\r
- if(isalpha((char)wParam)) {\r
- /* capitals of any ind are intercepted and distinguished by left and right shift */\r
- int mine = GetKeyState(VK_RSHIFT) < 0;\r
- if(mine || GetKeyState(VK_LSHIFT) < 0) {\r
-#endif\r
+#define JAWS_ARGS \\r
+ { "beepOffBoard", ArgInt, (LPVOID) beeps, TRUE, (ArgIniType) 1 },\\r
+ { "beepEmpty", ArgInt, (LPVOID) (beeps+1), TRUE, (ArgIniType) 0 },\\r
+ { "beepWhite", ArgInt, (LPVOID) (beeps+2), TRUE, (ArgIniType) 0 },\\r
+ { "beepBlack", ArgInt, (LPVOID) (beeps+3), TRUE, (ArgIniType) 0 },\\r
+ { "beepHoldings", ArgInt, (LPVOID) (beeps+4), TRUE, (ArgIniType) 0 },\\r
\r
#define JAWS_ALT_INTERCEPT \\r
if(suppressOneKey) {\\r