X-Git-Url: http://winboard.nl/cgi-bin?a=blobdiff_plain;f=winboard%2Fjaws.c;h=aa843ad083148bab9714ed688276a4a4d972fd7b;hb=HEAD;hp=540bf7b90a6bb01225bbd903bc2202978018469d;hpb=c612331f05b9a1ddddb6f25c598b4258f9e094b1;p=xboard.git diff --git a/winboard/jaws.c b/winboard/jaws.c index 540bf7b..aa843ad 100644 --- a/winboard/jaws.c +++ b/winboard/jaws.c @@ -5,7 +5,8 @@ * Massachusetts. * * Enhancements Copyright 1992-2001, 2002, 2003, 2004, 2005, 2006, - * 2007, 2008, 2009, 2010 Free Software Foundation, Inc. + * 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016 Free + * Software Foundation, Inc. * * XBoard borrows its colors and the bitmaps.xchess bitmap set from XChess, * which was written and is copyrighted by Wayne Christopher. @@ -92,7 +93,7 @@ char *squareToNum[] = {"naught", "1", "2", "3", "4", "5", "6", "7", "8", "9" }; char *ordinals[] = {"zeroth", "first", "second", "third", "fourth", "fifth", "sixth", "seventh", "eighth", "nineth"}; char *pieceToName[] = { - "White Pawn", "White Knight", "White Bishop", "White Rook", "White Queen", + "White Pawn", "White Knight", "White Bishop", "White Rook", "White Queen", "White Guard", "White Elephant", "White Arch Bishop", "White Chancellor", "White General", "White Man", "White Cannon", "White Night Rider", "White Crowned Bishop", "White Crowned Rook", "White Grass Hopper", "White Veteran", @@ -108,13 +109,13 @@ char *pieceToName[] = { }; char *pieceTypeName[] = { - "Pawn", "Knight", "Bishop", "Rook", "Queen", + "Pawn", "Knight", "Bishop", "Rook", "Queen", "Guard", "Elephant", "Arch Bishop", "Chancellor", "General", "Man", "Cannon", "Night Rider", "Crowned Bishop", "Crowned Rook", "Grass Hopper", "Veteran", "Falcon", "Amazon", "Snake", "Unicorn", "King", - "Pawn", "Knight", "Bishop", "Rook", "Queen", + "Pawn", "Knight", "Bishop", "Rook", "Queen", "Guard", "Elephant", "Arch Bishop", "Chancellor", "General", "Man", "Cannon", "Night Rider", "Crowned Bishop", "Crowned Rook", "Grass Hopper", "Veteran", @@ -162,15 +163,20 @@ PSAYSTRING RealSayString; VOID SayString(char *mess, BOOL flag) { // for debug file - char buf[8000], *p; + static char buf[8000], *p; + int l = strlen(buf); if(appData.debugMode) fprintf(debugFP, "SAY '%s'\n", mess); - strcpy(buf, mess); + if(l) buf[l++] = ' '; // separate by space from previous + safeStrCpy(buf+l, _(mess), 8000-1-l); // buffer + if(!flag) return; // wait for flush if(p = StrCaseStr(buf, "Xboard adjudication:")) { int i; for(i=19; i>1; i--) p[i] = p[i-1]; p[1] = ' '; } - RealSayString(buf, flag); + RealSayString(buf, !strcmp(mess, " ")); // kludge to indicate flushing of interruptable speach + if(appData.debugMode) fprintf(debugFP, "SPEAK '%s'\n", buf); + buf[0] = NULLCHAR; } //static int fromX = 0, fromY = 0; @@ -230,16 +236,16 @@ AdaptMenu() helpMenuInfo.cbSize = sizeof(helpMenuInfo); menuMain = GetMenu(hwndMain); menuJAWS = CreatePopupMenu(); - + for(i=0; menuItemJAWS[i].name; i++) { - if(menuItemJAWS[i].name[0] == '-') + if(menuItemJAWS[i].name[0] == '-') AppendMenu(menuJAWS, MF_SEPARATOR, (UINT_PTR) 0, NULL); - else AppendMenu(menuJAWS, MF_ENABLED|MF_STRING, - (UINT_PTR) menuItemJAWS[i].code, (LPCTSTR) menuItemJAWS[i].name); + else AppendMenu(menuJAWS, MF_ENABLED|MF_STRING, + (UINT_PTR) menuItemJAWS[i].code, (LPCTSTR) _(menuItemJAWS[i].name)); } - InsertMenu(menuMain, 5, MF_BYPOSITION|MF_POPUP|MF_ENABLED|MF_STRING, + InsertMenu(menuMain, 7, MF_BYPOSITION|MF_POPUP|MF_ENABLED|MF_STRING, (UINT_PTR) menuJAWS, "&JAWS"); - oldMenuItemState[6] = oldMenuItemState[5]; + oldMenuItemState[8] = oldMenuItemState[7]; DrawMenuBar(hwndMain); } @@ -248,7 +254,7 @@ InitJAWS() { // to be called at beginning of WinMain, after InitApplication and InitInstance HINSTANCE hApi = LoadLibrary("jfwapi32.dll"); if(!hApi) { - DisplayInformation("Missing jfwapi32.dll"); + DisplayInformation("Missing jfwapi32.dll"); return (FALSE); } @@ -264,8 +270,8 @@ InitJAWS() int i; AdaptMenu(); - menuBarText[0][5] = "&JAWS"; - for(i=0; i<7; i++) menuBarText[1][i] = menuBarText[0][i]; + menuBarText[0][8] = menuBarText[0][7]; menuBarText[0][7] = "&JAWS"; + for(i=0; i<9; i++) menuBarText[2][i] = menuBarText[1][i] = menuBarText[0][i]; } hAccelJAWS = CreateAcceleratorTable(acceleratorsJAWS, 14); @@ -282,6 +288,7 @@ InitJAWS() int beeps[] = { 1, 0, 0, 0, 0 }; int beepCodes[] = { 0, MB_OK, MB_ICONERROR, MB_ICONQUESTION, MB_ICONEXCLAMATION, MB_ICONASTERISK }; +static int dropX = -1, dropY = -1; VOID KeyboardEvent(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) @@ -290,6 +297,10 @@ KeyboardEvent(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) char *piece, *xchar, *ynum ; int n, beepType = 1; // empty beep + if(fromX == -1 || fromY == -1) { // if we just dropped piece, stay at that square + fromX = dropX; fromY = dropY; + dropX = dropY = -1; // but only once + } if(fromX == -1 || fromY == -1) { fromX = BOARD_LEFT; fromY = 0; } @@ -326,28 +337,30 @@ KeyboardEvent(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) if(currentPiece != EmptySquare) { char buf[MSG_SIZ]; n = boards[currentMove][fromY][1]; - sprintf(buf, "%d %s%s", n, PieceToName(currentPiece,0), n == 1 ? "" : "s"); - SayString(buf, TRUE); + snprintf(buf, MSG_SIZ, "%d %s%s", n, PieceToName(currentPiece,0), n == 1 ? "" : "s"); + SayString(buf, FALSE); } + SayString(" ", TRUE); } else if(fromX == BOARD_RGHT + 1) { SayString("white holdings", FALSE); if(currentPiece != EmptySquare) { char buf[MSG_SIZ]; n = boards[currentMove][fromY][BOARD_WIDTH-2]; - sprintf(buf, "%d %s%s", n, PieceToName(currentPiece,0), n == 1 ? "" : "s"); - SayString(buf, TRUE); + snprintf(buf, MSG_SIZ,"%d %s%s", n, PieceToName(currentPiece,0), n == 1 ? "" : "s"); + SayString(buf, FALSE); } + SayString(" ", TRUE); } else if(fromX >= BOARD_LEFT && fromX < BOARD_RGHT) { char buf[MSG_SIZ]; xchar = SquareToChar(fromX); ynum = SquareToNum(fromY); if(currentPiece != EmptySquare) { -// SayString(piece[0] == 'W' ? "white" : "black", TRUE); - sprintf(buf, "%s %s %s", piece, xchar, ynum); - } else sprintf(buf, "%s %s", xchar, ynum); - SayString(buf, TRUE); + snprintf(buf, MSG_SIZ, "%s %s %s", xchar, ynum, piece); + } else snprintf(buf, MSG_SIZ, "%s %s", xchar, ynum); + SayString(buf, FALSE); + SayString(" ", TRUE); } return; } @@ -409,7 +422,7 @@ PossibleAttackMove() //if(appData.debugMode) fprintf(debugFP, "PossibleAttackMove %d %d %d %d\n", fromX, fromY, oldFromX, oldFromY); if(fromY < 0 || fromY >= BOARD_HEIGHT) return; - if(fromX < BOARD_LEFT || fromX >= BOARD_RGHT) { SayString("holdings",FALSE); return; } + if(fromX < BOARD_LEFT || fromX >= BOARD_RGHT) { SayString("holdings",TRUE); return; } piece = boards[currentMove][fromY][fromX]; if(piece == EmptySquare) { // if square is empty, try to substitute selected piece @@ -420,7 +433,7 @@ PossibleAttackMove() SayString("Your", FALSE); SayString(PieceToName(piece, 0), FALSE); SayString("would have", FALSE); - } else { SayString("You must select a piece first", FALSE); return; } + } else { SayString("You must select a piece first", TRUE); return; } } victim = boards[currentMove][fromY][fromX]; @@ -432,6 +445,7 @@ PossibleAttackMove() cl.count = 0; cl.rf = fromY; cl.ff = fromX; cl.rt = cl.ft = -1; GenLegal(boards[currentMove], PosFlags(currentMove + swapColor), ReadCallback, (VOIDSTAR) &cl); if(cl.count == 0) SayString("None", FALSE); + SayString("", TRUE); // flush boards[currentMove][fromY][fromX] = victim; // repair if( removedSelectedPiece ) boards[currentMove][oldFromY][oldFromX] = piece; @@ -445,7 +459,7 @@ PossibleAttacked() ChessSquare piece = EmptySquare, victim; if(fromY < 0 || fromY >= BOARD_HEIGHT) return; - if(fromX < BOARD_LEFT || fromX >= BOARD_RGHT) { SayString("holdings",FALSE); return; } + if(fromX < BOARD_LEFT || fromX >= BOARD_RGHT) { SayString("holdings",TRUE); return; } if(oldFromX >= 0 && oldFromY >= 0) { // if piece is selected, remove it piece = boards[currentMove][oldFromY][oldFromX]; @@ -466,6 +480,7 @@ PossibleAttacked() cl.count = 0; cl.rt = fromY; cl.ft = fromX; cl.rf = cl.ff = -1; GenLegal(boards[currentMove], PosFlags(currentMove), ReadCallback, (VOIDSTAR) &cl); if(cl.count == 0) SayString("None", FALSE); + SayString("", TRUE); // flush boards[currentMove][fromY][fromX] = victim; // put back original occupant if(oldFromX >= 0 && oldFromY >= 0) { // put back possibl selected piece @@ -476,15 +491,15 @@ PossibleAttacked() VOID ReadRow() { - ChessSquare currentpiece; + ChessSquare currentpiece; char *piece, *xchar, *ynum ; int xPos, count=0; ynum = SquareToNum(fromY); - + if(fromY < 0) return; for (xPos=BOARD_LEFT; xPos=BOARD_LEFT) { - currentpiece = boards[currentMove][yPos][xPos]; + currentpiece = boards[currentMove][yPos][xPos]; piece = PieceToName(currentpiece,1); xchar = SquareToChar(xPos); ynum = SquareToNum(yPos); @@ -572,15 +589,16 @@ SayUpperDiagnols() } } else SayString("There is no squares to your upper left", FALSE); + SayString("", TRUE); // flush } VOID SayLowerDiagnols() { - ChessSquare currentpiece; + ChessSquare currentpiece; char *piece, *xchar, *ynum ; int yPos, xPos; - + if(fromX < 0 || fromY < 0) return; if(fromX < BOARD_RGHT-1 && fromY > 0) { @@ -588,7 +606,7 @@ SayLowerDiagnols() yPos = fromY-1; xPos = fromX+1; while(yPos>=0 && xPos=0 && xPos>=BOARD_LEFT) { - currentpiece = boards[currentMove][yPos][xPos]; + currentpiece = boards[currentMove][yPos][xPos]; piece = PieceToName(currentpiece,1); xchar = SquareToChar(xPos); ynum = SquareToNum(yPos); @@ -618,16 +636,17 @@ SayLowerDiagnols() } } else SayString("There is no squares to your lower left", FALSE); + SayString("", TRUE); // flush } VOID SayKnightMoves() { - ChessSquare currentpiece, oldpiece; + ChessSquare currentpiece, oldpiece; char *piece, *xchar, *ynum ; oldpiece = boards[currentMove][fromY][fromX]; - if(oldpiece == WhiteKnight || oldpiece == BlackKnight) + if(oldpiece == WhiteKnight || oldpiece == BlackKnight) SayString("The possible squares a Knight could move to are", FALSE); else SayString("The squares a Knight could possibly attack from are", FALSE); @@ -661,7 +680,7 @@ SayKnightMoves() SayString(piece, FALSE); } } - + if (fromY+1 < BOARD_HEIGHT && fromX+2 < BOARD_RGHT) { currentpiece = boards[currentMove][fromY+1][fromX+2]; if(((oldpiece == WhiteKnight) && (currentpiece > WhiteKing)) @@ -676,7 +695,7 @@ SayKnightMoves() SayString(piece, FALSE); } } - + if (fromY-1 >= 0 && fromX+2 < BOARD_RGHT) { currentpiece = boards[currentMove][fromY-1][fromX+2]; if(((oldpiece == WhiteKnight) && (currentpiece > WhiteKing)) @@ -691,7 +710,7 @@ SayKnightMoves() SayString(piece, FALSE); } } - + if (fromY-2 >= 0 && fromX+1 < BOARD_RGHT) { currentpiece = boards[currentMove][fromY-2][fromX+1]; if(((oldpiece == WhiteKnight) && (currentpiece > WhiteKing)) @@ -706,7 +725,7 @@ SayKnightMoves() SayString(piece, FALSE); } } - + if (fromY-2 >= 0 && fromX-1 >= BOARD_LEFT) { currentpiece = boards[currentMove][fromY-2][fromX-1]; if(((oldpiece == WhiteKnight) && (currentpiece > WhiteKing)) @@ -721,7 +740,7 @@ SayKnightMoves() SayString(piece, FALSE); } } - + if (fromY-1 >= 0 && fromX-2 >= BOARD_LEFT) { currentpiece = boards[currentMove][fromY-1][fromX-2]; if(((oldpiece == WhiteKnight) && (currentpiece > WhiteKing)) @@ -736,7 +755,7 @@ SayKnightMoves() SayString(piece, FALSE); } } - + if (fromY+1 < BOARD_HEIGHT && fromX-2 >= BOARD_LEFT) { currentpiece = boards[currentMove][fromY+1][fromX-2]; if(((oldpiece == WhiteKnight) && (currentpiece > WhiteKing)) @@ -751,12 +770,13 @@ SayKnightMoves() SayString(piece, FALSE); } } + SayString("", TRUE); // flush } VOID SayPieces(ChessSquare p) { - ChessSquare currentpiece; + ChessSquare currentpiece; char *piece, *xchar, *ynum ; int yPos, xPos, count = 0; char buf[50]; @@ -764,13 +784,13 @@ SayPieces(ChessSquare p) if(p == WhitePlay) SayString("White pieces", FALSE); else if(p == BlackPlay) SayString("Black pieces", FALSE); else if(p == EmptySquare) SayString("Pieces", FALSE); else { - sprintf(buf, "%ss", PieceToName(p,1)); + snprintf(buf, sizeof(buf)/sizeof(buf[0]),"%ss", PieceToName(p,1)); SayString(buf, FALSE); } SayString("are located", FALSE); for(yPos=0; yPos= BlackPawn && currentpiece <= BlackKing || p == WhitePlay && currentpiece >= WhitePawn && currentpiece <= WhiteKing ) piece = PieceToName(currentpiece,0); @@ -779,7 +799,7 @@ SayPieces(ChessSquare p) else if(p == currentpiece) piece = NULL; else continue; - + if(count == 0) SayString("at", FALSE); xchar = SquareToChar(xPos); ynum = SquareToNum(yPos); @@ -790,6 +810,7 @@ SayPieces(ChessSquare p) } } if(count == 0) SayString("nowhere", FALSE); + SayString("", TRUE); // flush } VOID @@ -799,7 +820,7 @@ SayCurrentPos() char *piece, *xchar, *ynum ; if(fromX < BOARD_LEFT) { SayString("You strayed into the white holdings", FALSE); return; } if(fromX >= BOARD_RGHT) { SayString("You strayed into the black holdings", FALSE); return; } - currentpiece = boards[currentMove][fromY][fromX]; + currentpiece = boards[currentMove][fromY][fromX]; piece = PieceToName(currentpiece,1); ynum = SquareToNum(fromY); xchar = SquareToChar(fromX); @@ -809,11 +830,11 @@ SayCurrentPos() SayString(piece, FALSE); if(((fromX-BOARD_LEFT) ^ fromY)&1) SayString("on a light square",FALSE); - else + else SayString("on a dark square",FALSE); PossibleAttacked(); - return; + SayString("", TRUE); // flush } VOID @@ -822,28 +843,32 @@ SayAllBoard() int Xpos, Ypos; ChessSquare currentpiece; char *piece, *ynum ; - + if(gameInfo.holdingsWidth) { int first = 0; for(Ypos=0; Ypos=BOARD_HEIGHT - gameInfo.holdingsSize; Ypos--) { int n = boards[currentMove][Ypos][1]; - if(n) { char buf[MSG_SIZ]; - if(!first++) SayString("black holds", FALSE); - currentpiece = boards[currentMove][Ypos][0]; - piece = PieceToName(currentpiece,0); - sprintf(buf, "%d %s%s", n, piece, (n==1 ? "" : "s") ); - SayString(buf, FALSE); + if(n) { + char buf[MSG_SIZ]; + if(!first++) + SayString("black holds", FALSE); + currentpiece = boards[currentMove][Ypos][0]; + piece = PieceToName(currentpiece,0); + snprintf(buf, MSG_SIZ, "%d %s%s", n, piece, (n==1 ? "" : "s") ); + SayString(buf, FALSE); } } } @@ -853,16 +878,17 @@ SayAllBoard() SayString(ynum, FALSE); SayString("rank", FALSE); for(Xpos=BOARD_LEFT; Xpos 1) { - sprintf(buf, "%d %ss", count, piece); - } else sprintf(buf, "%s", piece); + if(count > 1) + snprintf(buf, sizeof(buf)/sizeof(buf[0]), "%d %ss", count, piece); + else + snprintf(buf, sizeof(buf)/sizeof(buf[0]), "%s", piece); Xpos--; SayString(buf, FALSE); } else { @@ -872,9 +898,9 @@ SayAllBoard() if(Xpos == BOARD_RGHT && oldX == BOARD_LEFT) SayString("all", FALSE); else{ - if(count > 1) { + if(count > 1) { char buf[10]; - sprintf(buf, "%d", count); + snprintf(buf, sizeof(buf)/sizeof(buf[0]),"%d", count); SayString(buf, FALSE); } Xpos--; @@ -883,27 +909,28 @@ SayAllBoard() } } } - + SayString("", TRUE); // flush } VOID SayWhosTurn() { - if(gameMode == MachinePlaysBlack || gameMode == IcsPlayingBlack) { + if(gameMode == MachinePlaysBlack || gameMode == IcsPlayingWhite) { if(WhiteOnMove(currentMove)) SayString("It is your turn", FALSE); else SayString("It is your opponents turn", FALSE); - } else if(gameMode == MachinePlaysWhite || gameMode == IcsPlayingWhite) { + } else if(gameMode == MachinePlaysWhite || gameMode == IcsPlayingBlack) { if(WhiteOnMove(currentMove)) SayString("It is your opponents turn", FALSE); else SayString("It is your turn", FALSE); } else { - if(WhiteOnMove(currentMove)) + if(WhiteOnMove(currentMove)) SayString("White is on move here", FALSE); else SayString("Black is on move here", FALSE); } + SayString("", TRUE); // flush } - + extern char *commentList[]; VOID @@ -942,7 +969,7 @@ SayMachineMove(int evenIfDuplicate) c = 'W'; break; case IcsPlayingBlack: case MachinePlaysBlack: - c = 'B'; + c = 'B'; default: break; } @@ -950,7 +977,7 @@ SayMachineMove(int evenIfDuplicate) if(c != lastMover && !evenIfDuplicate) return; // line is thinking output of future move, ignore. if(2*moveNr - (dotCount < 2) == previousMove) return; // do not repeat same move; likely ponder output - sprintf(buf, "score %s %d at %d ply", + snprintf(buf, MSG_SIZ, "score %s %d at %d ply", score > 0 ? "plus" : score < 0 ? "minus" : "", (int) (fabs(score)*100+0.5), depth ); @@ -976,16 +1003,16 @@ SayMachineMove(int evenIfDuplicate) n = 2*moveNr - (dotCount < 2); - if(previousMove != 2*moveNr + (dotCount > 1) || evenIfDuplicate) { + if(previousMove != 2*moveNr + (dotCount > 1) || evenIfDuplicate) { char number[20]; previousMove = 2*moveNr + (dotCount > 1); // remember move nr of move last spoken - sprintf(number, "%d", moveNr); + snprintf(number, sizeof(number)/sizeof(number[0]),"%d", moveNr); yPos = CoordToNum(messageText[len-1]); /* turn char coords to ints */ xPos = CoordToNum(messageText[len-2]); if(xPos < 0 || xPos > 11) return; // prevent crashes if no coord string available to speak if(yPos < 0 || yPos > 9) return; - currentpiece = boards[n][yPos][xPos]; + currentpiece = boards[n][yPos][xPos]; piece = PieceToName(currentpiece,0); ynum = SquareToNum(yPos); xchar = SquareToChar(xPos); @@ -1039,8 +1066,8 @@ SayMachineMove(int evenIfDuplicate) if(StrStr(messageText, " 1/2-1/2")) p = "game ends in a draw"; if(comment[0]) { if(p) { - if(!StrCaseStr(comment, "draw") && - !StrCaseStr(comment, "white") && + if(!StrCaseStr(comment, "draw") && + !StrCaseStr(comment, "white") && !StrCaseStr(comment, "black") ) { SayString(p, FALSE); SayString("due to", FALSE); @@ -1057,6 +1084,7 @@ SayMachineMove(int evenIfDuplicate) SayString(messageText, FALSE); } + SayString("", TRUE); // flush } VOID @@ -1069,16 +1097,17 @@ SayClockTime() suppressClocks = 1; // if user is using alt+T command, no reason to display them if(abs(lastWhiteTime - whiteTimeRemaining) < 1000 && abs(lastBlackTime - blackTimeRemaining) < 1000) suppressClocks = 0; // back on after two requests in rapid succession - sprintf(buf1, "%s", TimeString(whiteTimeRemaining)); + snprintf(buf1, sizeof(buf1)/sizeof(buf1[0]),"%s", TimeString(whiteTimeRemaining)); str1 = buf1; - SayString("White's remaining time is", FALSE); + SayString("White clock", FALSE); SayString(str1, FALSE); - sprintf(buf2, "%s", TimeString(blackTimeRemaining)); + snprintf(buf2, sizeof(buf2)/sizeof(buf2[0]), "%s", TimeString(blackTimeRemaining)); str2 = buf2; - SayString("Black's remaining time is", FALSE); + SayString("Black clock", FALSE); SayString(str2, FALSE); lastWhiteTime = whiteTimeRemaining; lastBlackTime = blackTimeRemaining; + SayString("", TRUE); // flush } VOID @@ -1088,6 +1117,7 @@ Toggle(Boolean *b, char *mess) SayString(mess, FALSE); SayString("is now", FALSE); SayString(*b ? "on" : "off", FALSE); + SayString("", TRUE); // flush } /* handles keyboard moves in a click-click fashion */ @@ -1096,7 +1126,7 @@ KeyboardMove(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { ChessSquare currentpiece; char *piece; - + static BOOLEAN sameAgain = FALSE; switch (message) { case WM_KEYDOWN: @@ -1107,20 +1137,20 @@ KeyboardMove(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) break; } else if(oldFromX != -1) { - + ChessSquare pdown, pup; pdown = boards[currentMove][oldFromY][oldFromX]; pup = boards[currentMove][fromY][fromX]; - + if (gameMode == EditPosition || !((WhitePawn <= pdown && pdown <= WhiteKing && WhitePawn <= pup && pup <= WhiteKing) || (BlackPawn <= pdown && pdown <= BlackKing && BlackPawn <= pup && pup <= BlackKing))) { /* EditPosition, empty square, or different color piece; - click-click move is possible */ + click-click move is possible */ char promoChoice = NULLCHAR; - + if (HasPromotionChoice(oldFromX, oldFromY, fromX, fromY, &promoChoice)) { if (appData.alwaysPromoteToQueen) { UserMoveEvent(oldFromX, oldFromY, fromX, fromY, 'q'); @@ -1129,7 +1159,7 @@ KeyboardMove(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) toX = fromX; toY = fromY; fromX = oldFromX; fromY = oldFromY; PromotionPopup(hwnd); fromX = toX; fromY = toY; - } + } } else { UserMoveEvent(oldFromX, oldFromY, fromX, fromY, promoChoice); @@ -1137,16 +1167,16 @@ KeyboardMove(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) oldFromX = oldFromY = -1; break; } - + } /* First downclick, or restart on a square with same color piece */ if (OKToStartUserMove(fromX, fromY)) { oldFromX = fromX; oldFromY = fromY; - currentpiece = boards[currentMove][fromY][fromX]; + currentpiece = boards[currentMove][fromY][fromX]; piece = PieceToName(currentpiece,1); SayString(piece, FALSE); - SayString("selected", FALSE); + SayString("selected", TRUE); } else { oldFromX = oldFromY = -1; @@ -1159,10 +1189,10 @@ KeyboardMove(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) if (sameAgain) { /* Clicked same square twice: abort click-click move */ oldFromX = oldFromY = -1; - currentpiece = boards[currentMove][fromY][fromX]; + currentpiece = boards[currentMove][fromY][fromX]; piece = PieceToName(currentpiece,0); SayString(piece, FALSE); - SayString("unselected", FALSE); + SayString("unselected", TRUE); } } } @@ -1194,6 +1224,7 @@ NiceTime(int x) if ((char)wParam == 022 && gameMode == EditPosition) { /* . Pop up piece menu */\ POINT pt; int x, y;\ SquareToPos(fromY, fromX, &x, &y);\ + dropX = fromX; dropY = fromY;\ pt.x = x; pt.y = y;\ if(gameInfo.variant != VariantShogi)\ MenuPopup(hwnd, pt, LoadMenu(hInst, "PieceMenu"), -1);\ @@ -1206,13 +1237,12 @@ NiceTime(int x) case '\020': /* ctrl P */\ { char buf[MSG_SIZ];\ if(GetWindowText(hwnd, buf, MSG_SIZ-1))\ - SayString(buf, FALSE);\ + SayString(buf, TRUE);\ }\ return 0;\ -#define JAWS_KB_NAVIGATION \ +#define JAWS_KBDOWN_NAVIGATION \ \ - case WM_KEYDOWN:\ \ if(GetKeyState(VK_MENU) < 0 && GetKeyState(VK_CONTROL) < 0) {\ /* Control + Alt + letter used for speaking piece positions */\ @@ -1245,17 +1275,17 @@ NiceTime(int x) KeyboardEvent(hwnd, message, wParam, lParam);\ break;\ case VK_SPACE:\ + shiftKey = GetKeyState(VK_SHIFT) < 0;\ KeyboardMove(hwnd, message, wParam, lParam);\ break;\ }\ - break;\ - case WM_KEYUP:\ + +#define JAWS_KBUP_NAVIGATION \ switch (wParam) {\ case VK_SPACE:\ KeyboardMove(hwnd, message, wParam, lParam);\ break;\ }\ - break;\ #define JAWS_MENU_ITEMS \ case IDM_PossibleAttackMove: /*What can I possible attack from here */\ @@ -1362,7 +1392,7 @@ NiceTime(int x) #define JAWS_COPYRIGHT \ SetDlgItemText(hDlg, OPT_MESS, "Auditory/Keyboard Enhancements By: Ed Rodriguez (sort of)"); -#define SAY(S) SayString((S), FALSE) +#define SAY(S) SayString((S), TRUE) #define SAYMACHINEMOVE() SayMachineMove(0)