Allow starting a variation from keyboard entry in WB-JAWS
[xboard.git] / winboard / jaws.c
index 56c7411..bf7dab2 100644 (file)
@@ -92,7 +92,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"};\r
 \r
 char *pieceToName[] = {\r
 char *ordinals[] = {"zeroth", "first", "second", "third", "fourth", "fifth", "sixth", "seventh", "eighth", "nineth"};\r
 \r
 char *pieceToName[] = {\r
-               "White Pawn", "White Knight", "White Bishop", "White Rook", "White Queen", \r
+               "White Pawn", "White Knight", "White Bishop", "White Rook", "White Queen",\r
                "White Guard", "White Elephant", "White Arch Bishop", "White Chancellor",\r
                "White General", "White Man", "White Cannon", "White Night Rider",\r
                "White Crowned Bishop", "White Crowned Rook", "White Grass Hopper", "White Veteran",\r
                "White Guard", "White Elephant", "White Arch Bishop", "White Chancellor",\r
                "White General", "White Man", "White Cannon", "White Night Rider",\r
                "White Crowned Bishop", "White Crowned Rook", "White Grass Hopper", "White Veteran",\r
@@ -108,13 +108,13 @@ char *pieceToName[] = {
        };\r
 \r
 char *pieceTypeName[] = {\r
        };\r
 \r
 char *pieceTypeName[] = {\r
-               "Pawn", "Knight", "Bishop", "Rook", "Queen", \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
                "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
+               "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
                "Guard", "Elephant", "Arch Bishop", "Chancellor",\r
                "General", "Man", "Cannon", "Night Rider",\r
                "Crowned Bishop", "Crowned Rook", "Grass Hopper", "Veteran",\r
@@ -162,15 +162,20 @@ PSAYSTRING RealSayString;
 \r
 VOID SayString(char *mess, BOOL flag)\r
 { // for debug file\r
 \r
 VOID SayString(char *mess, BOOL flag)\r
 { // for debug file\r
-       char buf[8000], *p;\r
+       static char buf[8000], *p;\r
+        int l = strlen(buf);\r
        if(appData.debugMode) fprintf(debugFP, "SAY '%s'\n", mess);\r
        if(appData.debugMode) fprintf(debugFP, "SAY '%s'\n", mess);\r
-       strcpy(buf, mess);\r
+        if(l) buf[l++] = ' '; // separate by space from previous\r
+       safeStrCpy(buf+l, _(mess), 8000-1-l); // buffer\r
+        if(!flag) return; // wait for flush\r
        if(p = StrCaseStr(buf, "Xboard adjudication:")) {\r
                int i;\r
                for(i=19; i>1; i--) p[i] = p[i-1];\r
                p[1] = ' ';\r
        }\r
        if(p = StrCaseStr(buf, "Xboard adjudication:")) {\r
                int i;\r
                for(i=19; i>1; i--) p[i] = p[i-1];\r
                p[1] = ' ';\r
        }\r
-       RealSayString(buf, flag);\r
+       RealSayString(buf, !strcmp(mess, " ")); // kludge to indicate flushing of interruptable speach\r
+       if(appData.debugMode) fprintf(debugFP, "SPEAK '%s'\n", buf);\r
+       buf[0] = NULLCHAR;\r
 }\r
 \r
 //static int fromX = 0, fromY = 0;\r
 }\r
 \r
 //static int fromX = 0, fromY = 0;\r
@@ -230,16 +235,16 @@ AdaptMenu()
        helpMenuInfo.cbSize = sizeof(helpMenuInfo);\r
        menuMain = GetMenu(hwndMain);\r
        menuJAWS = CreatePopupMenu();\r
        helpMenuInfo.cbSize = sizeof(helpMenuInfo);\r
        menuMain = GetMenu(hwndMain);\r
        menuJAWS = CreatePopupMenu();\r
-       \r
+\r
        for(i=0; menuItemJAWS[i].name; i++) {\r
        for(i=0; menuItemJAWS[i].name; i++) {\r
-           if(menuItemJAWS[i].name[0] == '-') \r
+           if(menuItemJAWS[i].name[0] == '-')\r
                 AppendMenu(menuJAWS, MF_SEPARATOR, (UINT_PTR) 0, NULL);\r
                 AppendMenu(menuJAWS, MF_SEPARATOR, (UINT_PTR) 0, NULL);\r
-           else AppendMenu(menuJAWS, MF_ENABLED|MF_STRING, \r
-                       (UINT_PTR) menuItemJAWS[i].code, (LPCTSTR) menuItemJAWS[i].name);\r
+           else AppendMenu(menuJAWS, MF_ENABLED|MF_STRING,\r
+                       (UINT_PTR) menuItemJAWS[i].code, (LPCTSTR) _(menuItemJAWS[i].name));\r
        }\r
        }\r
-       InsertMenu(menuMain, 5, MF_BYPOSITION|MF_POPUP|MF_ENABLED|MF_STRING, \r
+       InsertMenu(menuMain, 7, MF_BYPOSITION|MF_POPUP|MF_ENABLED|MF_STRING,\r
                (UINT_PTR) menuJAWS, "&JAWS");\r
                (UINT_PTR) menuJAWS, "&JAWS");\r
-       oldMenuItemState[6] = oldMenuItemState[5];\r
+       oldMenuItemState[8] = oldMenuItemState[7];\r
        DrawMenuBar(hwndMain);\r
 }\r
 \r
        DrawMenuBar(hwndMain);\r
 }\r
 \r
@@ -248,7 +253,7 @@ InitJAWS()
 {      // to be called at beginning of WinMain, after InitApplication and InitInstance\r
        HINSTANCE hApi = LoadLibrary("jfwapi32.dll");\r
        if(!hApi) {\r
 {      // to be called at beginning of WinMain, after InitApplication and InitInstance\r
        HINSTANCE hApi = LoadLibrary("jfwapi32.dll");\r
        if(!hApi) {\r
-               DisplayInformation("Missing jfwapi32.dll");        \r
+               DisplayInformation("Missing jfwapi32.dll");\r
                return (FALSE);\r
        }\r
 \r
                return (FALSE);\r
        }\r
 \r
@@ -264,8 +269,8 @@ InitJAWS()
                int i;\r
 \r
                AdaptMenu();\r
                int i;\r
 \r
                AdaptMenu();\r
-               menuBarText[0][5] = "&JAWS";\r
-               for(i=0; i<7; i++) menuBarText[1][i] = menuBarText[0][i];\r
+               menuBarText[0][8] = menuBarText[0][7]; menuBarText[0][7] = "&JAWS";\r
+               for(i=0; i<9; i++) menuBarText[1][i] = menuBarText[0][i];\r
        }\r
 \r
        hAccelJAWS = CreateAcceleratorTable(acceleratorsJAWS, 14);\r
        }\r
 \r
        hAccelJAWS = CreateAcceleratorTable(acceleratorsJAWS, 14);\r
@@ -331,28 +336,30 @@ KeyboardEvent(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
                if(currentPiece != EmptySquare) {\r
                        char buf[MSG_SIZ];\r
                        n = boards[currentMove][fromY][1];\r
                if(currentPiece != EmptySquare) {\r
                        char buf[MSG_SIZ];\r
                        n = boards[currentMove][fromY][1];\r
-                       sprintf(buf, "%d %s%s", n, PieceToName(currentPiece,0), n == 1 ? "" : "s");\r
-                       SayString(buf, TRUE);\r
+                       snprintf(buf, MSG_SIZ, "%d %s%s", n, PieceToName(currentPiece,0), n == 1 ? "" : "s");\r
+                       SayString(buf, FALSE);\r
                }\r
                }\r
+               SayString(" ", TRUE);\r
        } else\r
        if(fromX == BOARD_RGHT + 1) {\r
                SayString("white holdings", FALSE);\r
                if(currentPiece != EmptySquare) {\r
                        char buf[MSG_SIZ];\r
                        n = boards[currentMove][fromY][BOARD_WIDTH-2];\r
        } else\r
        if(fromX == BOARD_RGHT + 1) {\r
                SayString("white holdings", FALSE);\r
                if(currentPiece != EmptySquare) {\r
                        char buf[MSG_SIZ];\r
                        n = boards[currentMove][fromY][BOARD_WIDTH-2];\r
-                       sprintf(buf, "%d %s%s", n, PieceToName(currentPiece,0), n == 1 ? "" : "s");\r
-                       SayString(buf, TRUE);\r
+                       snprintf(buf, MSG_SIZ,"%d %s%s", n, PieceToName(currentPiece,0), n == 1 ? "" : "s");\r
+                       SayString(buf, FALSE);\r
                }\r
                }\r
+               SayString(" ", TRUE);\r
        } else\r
        if(fromX >= BOARD_LEFT && fromX < BOARD_RGHT) {\r
                char buf[MSG_SIZ];\r
                xchar = SquareToChar(fromX);\r
                ynum = SquareToNum(fromY);\r
                if(currentPiece != EmptySquare) {\r
        } else\r
        if(fromX >= BOARD_LEFT && fromX < BOARD_RGHT) {\r
                char buf[MSG_SIZ];\r
                xchar = SquareToChar(fromX);\r
                ynum = SquareToNum(fromY);\r
                if(currentPiece != EmptySquare) {\r
-//                     SayString(piece[0] == 'W' ? "white" : "black", TRUE);\r
-                       sprintf(buf, "%s %s %s", xchar, ynum, piece);\r
-               } else sprintf(buf, "%s %s", xchar, ynum);\r
-               SayString(buf, TRUE);\r
+                 snprintf(buf, MSG_SIZ, "%s %s %s", xchar, ynum, piece);\r
+               } else snprintf(buf, MSG_SIZ, "%s %s", xchar, ynum);\r
+               SayString(buf, FALSE);\r
+               SayString(" ", TRUE);\r
        }\r
        return;\r
 }\r
        }\r
        return;\r
 }\r
@@ -414,7 +421,7 @@ PossibleAttackMove()
 \r
 //if(appData.debugMode) fprintf(debugFP, "PossibleAttackMove %d %d %d %d\n", fromX, fromY, oldFromX, oldFromY);\r
        if(fromY < 0 || fromY >= BOARD_HEIGHT) return;\r
 \r
 //if(appData.debugMode) fprintf(debugFP, "PossibleAttackMove %d %d %d %d\n", fromX, fromY, oldFromX, oldFromY);\r
        if(fromY < 0 || fromY >= BOARD_HEIGHT) return;\r
-       if(fromX < BOARD_LEFT || fromX >= BOARD_RGHT) { SayString("holdings",FALSE); return; }\r
+       if(fromX < BOARD_LEFT || fromX >= BOARD_RGHT) { SayString("holdings",TRUE); return; }\r
 \r
        piece = boards[currentMove][fromY][fromX];\r
        if(piece == EmptySquare) { // if square is empty, try to substitute selected piece\r
 \r
        piece = boards[currentMove][fromY][fromX];\r
        if(piece == EmptySquare) { // if square is empty, try to substitute selected piece\r
@@ -425,7 +432,7 @@ PossibleAttackMove()
                SayString("Your", FALSE);\r
                SayString(PieceToName(piece, 0), FALSE);\r
                SayString("would have", FALSE);\r
                SayString("Your", FALSE);\r
                SayString(PieceToName(piece, 0), FALSE);\r
                SayString("would have", FALSE);\r
-           } else { SayString("You must select a piece first", FALSE); return; }\r
+           } else { SayString("You must select a piece first", TRUE); return; }\r
        }\r
 \r
        victim = boards[currentMove][fromY][fromX];\r
        }\r
 \r
        victim = boards[currentMove][fromY][fromX];\r
@@ -437,6 +444,7 @@ PossibleAttackMove()
        cl.count = 0; cl.rf = fromY; cl.ff = fromX; cl.rt = cl.ft = -1;\r
        GenLegal(boards[currentMove], PosFlags(currentMove + swapColor), ReadCallback, (VOIDSTAR) &cl);\r
        if(cl.count == 0) SayString("None", FALSE);\r
        cl.count = 0; cl.rf = fromY; cl.ff = fromX; cl.rt = cl.ft = -1;\r
        GenLegal(boards[currentMove], PosFlags(currentMove + swapColor), ReadCallback, (VOIDSTAR) &cl);\r
        if(cl.count == 0) SayString("None", FALSE);\r
+       SayString("", TRUE); // flush\r
        boards[currentMove][fromY][fromX] = victim; // repair\r
 \r
        if( removedSelectedPiece ) boards[currentMove][oldFromY][oldFromX] = piece;\r
        boards[currentMove][fromY][fromX] = victim; // repair\r
 \r
        if( removedSelectedPiece ) boards[currentMove][oldFromY][oldFromX] = piece;\r
@@ -450,7 +458,7 @@ PossibleAttacked()
        ChessSquare piece = EmptySquare, victim;\r
 \r
        if(fromY < 0 || fromY >= BOARD_HEIGHT) return;\r
        ChessSquare piece = EmptySquare, victim;\r
 \r
        if(fromY < 0 || fromY >= BOARD_HEIGHT) return;\r
-       if(fromX < BOARD_LEFT || fromX >= BOARD_RGHT) { SayString("holdings",FALSE); return; }\r
+       if(fromX < BOARD_LEFT || fromX >= BOARD_RGHT) { SayString("holdings",TRUE); return; }\r
 \r
        if(oldFromX >= 0 && oldFromY >= 0) { // if piece is selected, remove it\r
                piece = boards[currentMove][oldFromY][oldFromX];\r
 \r
        if(oldFromX >= 0 && oldFromY >= 0) { // if piece is selected, remove it\r
                piece = boards[currentMove][oldFromY][oldFromX];\r
@@ -471,6 +479,7 @@ PossibleAttacked()
        cl.count = 0; cl.rt = fromY; cl.ft = fromX; cl.rf = cl.ff = -1;\r
        GenLegal(boards[currentMove], PosFlags(currentMove), ReadCallback, (VOIDSTAR) &cl);\r
        if(cl.count == 0) SayString("None", FALSE);\r
        cl.count = 0; cl.rt = fromY; cl.ft = fromX; cl.rf = cl.ff = -1;\r
        GenLegal(boards[currentMove], PosFlags(currentMove), ReadCallback, (VOIDSTAR) &cl);\r
        if(cl.count == 0) SayString("None", FALSE);\r
+       SayString("", TRUE); // flush\r
        boards[currentMove][fromY][fromX] = victim; // put back original occupant\r
 \r
        if(oldFromX >= 0 && oldFromY >= 0) { // put back possibl selected piece\r
        boards[currentMove][fromY][fromX] = victim; // put back original occupant\r
 \r
        if(oldFromX >= 0 && oldFromY >= 0) { // put back possibl selected piece\r
@@ -481,15 +490,15 @@ PossibleAttacked()
 VOID\r
 ReadRow()\r
 {\r
 VOID\r
 ReadRow()\r
 {\r
-       ChessSquare currentpiece; \r
+       ChessSquare currentpiece;\r
        char *piece, *xchar, *ynum ;\r
        int xPos, count=0;\r
        ynum = SquareToNum(fromY);\r
        char *piece, *xchar, *ynum ;\r
        int xPos, count=0;\r
        ynum = SquareToNum(fromY);\r
-       \r
+\r
        if(fromY < 0) return;\r
 \r
        for (xPos=BOARD_LEFT; xPos<BOARD_RGHT; xPos++) {\r
        if(fromY < 0) return;\r
 \r
        for (xPos=BOARD_LEFT; xPos<BOARD_RGHT; xPos++) {\r
-               currentpiece = boards[currentMove][fromY][xPos];        \r
+               currentpiece = boards[currentMove][fromY][xPos];\r
                if(currentpiece != EmptySquare) {\r
                        piece = PieceToName(currentpiece,1);\r
                        xchar = SquareToChar(xPos);\r
                if(currentpiece != EmptySquare) {\r
                        piece = PieceToName(currentpiece,1);\r
                        xchar = SquareToChar(xPos);\r
@@ -504,20 +513,21 @@ ReadRow()
                SayString(ynum, FALSE);\r
                SayString("empty", FALSE);\r
        }\r
                SayString(ynum, FALSE);\r
                SayString("empty", FALSE);\r
        }\r
+       SayString("", TRUE); // flush\r
 }\r
 \r
 VOID\r
 ReadColumn()\r
 {\r
 }\r
 \r
 VOID\r
 ReadColumn()\r
 {\r
-       ChessSquare currentpiece; \r
+       ChessSquare currentpiece;\r
        char *piece, *xchar, *ynum ;\r
        int yPos, count=0;\r
        xchar = SquareToChar(fromX);\r
        char *piece, *xchar, *ynum ;\r
        int yPos, count=0;\r
        xchar = SquareToChar(fromX);\r
-       \r
+\r
        if(fromX < 0) return;\r
 \r
        for (yPos=0; yPos<BOARD_HEIGHT; yPos++) {\r
        if(fromX < 0) return;\r
 \r
        for (yPos=0; yPos<BOARD_HEIGHT; yPos++) {\r
-               currentpiece = boards[currentMove][yPos][fromX];        \r
+               currentpiece = boards[currentMove][yPos][fromX];\r
                if(currentpiece != EmptySquare) {\r
                        piece = PieceToName(currentpiece,1);\r
                        ynum = SquareToNum(yPos);\r
                if(currentpiece != EmptySquare) {\r
                        piece = PieceToName(currentpiece,1);\r
                        ynum = SquareToNum(yPos);\r
@@ -531,15 +541,16 @@ ReadColumn()
                SayString(xchar, FALSE);\r
                SayString("file empty", FALSE);\r
        }\r
                SayString(xchar, FALSE);\r
                SayString("file empty", FALSE);\r
        }\r
+       SayString("", TRUE); // flush\r
 }\r
 \r
 VOID\r
 SayUpperDiagnols()\r
 {\r
 }\r
 \r
 VOID\r
 SayUpperDiagnols()\r
 {\r
-       ChessSquare currentpiece; \r
+       ChessSquare currentpiece;\r
        char *piece, *xchar, *ynum ;\r
        int yPos, xPos;\r
        char *piece, *xchar, *ynum ;\r
        int yPos, xPos;\r
-       \r
+\r
        if(fromX < 0 || fromY < 0) return;\r
 \r
        if(fromX < BOARD_RGHT-1 && fromY < BOARD_HEIGHT-1) {\r
        if(fromX < 0 || fromY < 0) return;\r
 \r
        if(fromX < BOARD_RGHT-1 && fromY < BOARD_HEIGHT-1) {\r
@@ -547,7 +558,7 @@ SayUpperDiagnols()
                yPos = fromY+1;\r
                xPos = fromX+1;\r
                while(yPos<BOARD_HEIGHT && xPos<BOARD_RGHT) {\r
                yPos = fromY+1;\r
                xPos = fromX+1;\r
                while(yPos<BOARD_HEIGHT && xPos<BOARD_RGHT) {\r
-                       currentpiece = boards[currentMove][yPos][xPos]; \r
+                       currentpiece = boards[currentMove][yPos][xPos];\r
                        piece = PieceToName(currentpiece,1);\r
                        xchar = SquareToChar(xPos);\r
                        ynum = SquareToNum(yPos);\r
                        piece = PieceToName(currentpiece,1);\r
                        xchar = SquareToChar(xPos);\r
                        ynum = SquareToNum(yPos);\r
@@ -565,7 +576,7 @@ SayUpperDiagnols()
                yPos = fromY+1;\r
                xPos = fromX-1;\r
                while(yPos<BOARD_HEIGHT && xPos>=BOARD_LEFT) {\r
                yPos = fromY+1;\r
                xPos = fromX-1;\r
                while(yPos<BOARD_HEIGHT && xPos>=BOARD_LEFT) {\r
-                       currentpiece = boards[currentMove][yPos][xPos]; \r
+                       currentpiece = boards[currentMove][yPos][xPos];\r
                        piece = PieceToName(currentpiece,1);\r
                        xchar = SquareToChar(xPos);\r
                        ynum = SquareToNum(yPos);\r
                        piece = PieceToName(currentpiece,1);\r
                        xchar = SquareToChar(xPos);\r
                        ynum = SquareToNum(yPos);\r
@@ -577,15 +588,16 @@ SayUpperDiagnols()
                }\r
        }\r
        else SayString("There is no squares to your upper left", FALSE);\r
                }\r
        }\r
        else SayString("There is no squares to your upper left", FALSE);\r
+       SayString("", TRUE); // flush\r
 }\r
 \r
 VOID\r
 SayLowerDiagnols()\r
 {\r
 }\r
 \r
 VOID\r
 SayLowerDiagnols()\r
 {\r
-       ChessSquare currentpiece; \r
+       ChessSquare currentpiece;\r
        char *piece, *xchar, *ynum ;\r
        int yPos, xPos;\r
        char *piece, *xchar, *ynum ;\r
        int yPos, xPos;\r
-       \r
+\r
        if(fromX < 0 || fromY < 0) return;\r
 \r
        if(fromX < BOARD_RGHT-1 && fromY > 0) {\r
        if(fromX < 0 || fromY < 0) return;\r
 \r
        if(fromX < BOARD_RGHT-1 && fromY > 0) {\r
@@ -593,7 +605,7 @@ SayLowerDiagnols()
                yPos = fromY-1;\r
                xPos = fromX+1;\r
                while(yPos>=0 && xPos<BOARD_RGHT) {\r
                yPos = fromY-1;\r
                xPos = fromX+1;\r
                while(yPos>=0 && xPos<BOARD_RGHT) {\r
-                       currentpiece = boards[currentMove][yPos][xPos]; \r
+                       currentpiece = boards[currentMove][yPos][xPos];\r
                        piece = PieceToName(currentpiece,1);\r
                        xchar = SquareToChar(xPos);\r
                        ynum = SquareToNum(yPos);\r
                        piece = PieceToName(currentpiece,1);\r
                        xchar = SquareToChar(xPos);\r
                        ynum = SquareToNum(yPos);\r
@@ -611,7 +623,7 @@ SayLowerDiagnols()
                yPos = fromY-1;\r
                xPos = fromX-1;\r
                while(yPos>=0 && xPos>=BOARD_LEFT) {\r
                yPos = fromY-1;\r
                xPos = fromX-1;\r
                while(yPos>=0 && xPos>=BOARD_LEFT) {\r
-                       currentpiece = boards[currentMove][yPos][xPos]; \r
+                       currentpiece = boards[currentMove][yPos][xPos];\r
                        piece = PieceToName(currentpiece,1);\r
                        xchar = SquareToChar(xPos);\r
                        ynum = SquareToNum(yPos);\r
                        piece = PieceToName(currentpiece,1);\r
                        xchar = SquareToChar(xPos);\r
                        ynum = SquareToNum(yPos);\r
@@ -623,16 +635,17 @@ SayLowerDiagnols()
                }\r
        }\r
        else SayString("There is no squares to your lower left", FALSE);\r
                }\r
        }\r
        else SayString("There is no squares to your lower left", FALSE);\r
+       SayString("", TRUE); // flush\r
 }\r
 \r
 VOID\r
 SayKnightMoves()\r
 {\r
 }\r
 \r
 VOID\r
 SayKnightMoves()\r
 {\r
-       ChessSquare currentpiece, oldpiece; \r
+       ChessSquare currentpiece, oldpiece;\r
        char *piece, *xchar, *ynum ;\r
 \r
        oldpiece = boards[currentMove][fromY][fromX];\r
        char *piece, *xchar, *ynum ;\r
 \r
        oldpiece = boards[currentMove][fromY][fromX];\r
-       if(oldpiece == WhiteKnight || oldpiece == BlackKnight) \r
+       if(oldpiece == WhiteKnight || oldpiece == BlackKnight)\r
                SayString("The possible squares a Knight could move to are", FALSE);\r
        else\r
                SayString("The squares a Knight could possibly attack from are", FALSE);\r
                SayString("The possible squares a Knight could move to are", FALSE);\r
        else\r
                SayString("The squares a Knight could possibly attack from are", FALSE);\r
@@ -666,7 +679,7 @@ SayKnightMoves()
                        SayString(piece, FALSE);\r
                }\r
        }\r
                        SayString(piece, FALSE);\r
                }\r
        }\r
-       \r
+\r
        if (fromY+1 < BOARD_HEIGHT && fromX+2 < BOARD_RGHT) {\r
                currentpiece = boards[currentMove][fromY+1][fromX+2];\r
                if(((oldpiece == WhiteKnight) && (currentpiece > WhiteKing))\r
        if (fromY+1 < BOARD_HEIGHT && fromX+2 < BOARD_RGHT) {\r
                currentpiece = boards[currentMove][fromY+1][fromX+2];\r
                if(((oldpiece == WhiteKnight) && (currentpiece > WhiteKing))\r
@@ -681,7 +694,7 @@ SayKnightMoves()
                        SayString(piece, FALSE);\r
                }\r
        }\r
                        SayString(piece, FALSE);\r
                }\r
        }\r
-       \r
+\r
        if (fromY-1 >= 0 && fromX+2 < BOARD_RGHT) {\r
                currentpiece = boards[currentMove][fromY-1][fromX+2];\r
                if(((oldpiece == WhiteKnight) && (currentpiece > WhiteKing))\r
        if (fromY-1 >= 0 && fromX+2 < BOARD_RGHT) {\r
                currentpiece = boards[currentMove][fromY-1][fromX+2];\r
                if(((oldpiece == WhiteKnight) && (currentpiece > WhiteKing))\r
@@ -696,7 +709,7 @@ SayKnightMoves()
                        SayString(piece, FALSE);\r
                }\r
        }\r
                        SayString(piece, FALSE);\r
                }\r
        }\r
-       \r
+\r
        if (fromY-2 >= 0 && fromX+1 < BOARD_RGHT) {\r
                currentpiece = boards[currentMove][fromY-2][fromX+1];\r
                if(((oldpiece == WhiteKnight) && (currentpiece > WhiteKing))\r
        if (fromY-2 >= 0 && fromX+1 < BOARD_RGHT) {\r
                currentpiece = boards[currentMove][fromY-2][fromX+1];\r
                if(((oldpiece == WhiteKnight) && (currentpiece > WhiteKing))\r
@@ -711,7 +724,7 @@ SayKnightMoves()
                        SayString(piece, FALSE);\r
                }\r
        }\r
                        SayString(piece, FALSE);\r
                }\r
        }\r
-       \r
+\r
        if (fromY-2 >= 0 && fromX-1 >= BOARD_LEFT) {\r
                currentpiece = boards[currentMove][fromY-2][fromX-1];\r
                if(((oldpiece == WhiteKnight) && (currentpiece > WhiteKing))\r
        if (fromY-2 >= 0 && fromX-1 >= BOARD_LEFT) {\r
                currentpiece = boards[currentMove][fromY-2][fromX-1];\r
                if(((oldpiece == WhiteKnight) && (currentpiece > WhiteKing))\r
@@ -726,7 +739,7 @@ SayKnightMoves()
                        SayString(piece, FALSE);\r
                }\r
        }\r
                        SayString(piece, FALSE);\r
                }\r
        }\r
-       \r
+\r
        if (fromY-1 >= 0 && fromX-2 >= BOARD_LEFT) {\r
                currentpiece = boards[currentMove][fromY-1][fromX-2];\r
                if(((oldpiece == WhiteKnight) && (currentpiece > WhiteKing))\r
        if (fromY-1 >= 0 && fromX-2 >= BOARD_LEFT) {\r
                currentpiece = boards[currentMove][fromY-1][fromX-2];\r
                if(((oldpiece == WhiteKnight) && (currentpiece > WhiteKing))\r
@@ -741,7 +754,7 @@ SayKnightMoves()
                        SayString(piece, FALSE);\r
                }\r
        }\r
                        SayString(piece, FALSE);\r
                }\r
        }\r
-       \r
+\r
        if (fromY+1 < BOARD_HEIGHT && fromX-2 >= BOARD_LEFT) {\r
                currentpiece = boards[currentMove][fromY+1][fromX-2];\r
                if(((oldpiece == WhiteKnight) && (currentpiece > WhiteKing))\r
        if (fromY+1 < BOARD_HEIGHT && fromX-2 >= BOARD_LEFT) {\r
                currentpiece = boards[currentMove][fromY+1][fromX-2];\r
                if(((oldpiece == WhiteKnight) && (currentpiece > WhiteKing))\r
@@ -756,12 +769,13 @@ SayKnightMoves()
                        SayString(piece, FALSE);\r
                }\r
        }\r
                        SayString(piece, FALSE);\r
                }\r
        }\r
+       SayString("", TRUE); // flush\r
 }\r
 \r
 VOID\r
 SayPieces(ChessSquare p)\r
 {\r
 }\r
 \r
 VOID\r
 SayPieces(ChessSquare p)\r
 {\r
-       ChessSquare currentpiece;  \r
+       ChessSquare currentpiece;\r
        char *piece, *xchar, *ynum ;\r
        int yPos, xPos, count = 0;\r
        char buf[50];\r
        char *piece, *xchar, *ynum ;\r
        int yPos, xPos, count = 0;\r
        char buf[50];\r
@@ -769,13 +783,13 @@ SayPieces(ChessSquare p)
        if(p == WhitePlay)   SayString("White pieces", FALSE); else\r
        if(p == BlackPlay)   SayString("Black pieces", FALSE); else\r
        if(p == EmptySquare) SayString("Pieces", FALSE); else {\r
        if(p == WhitePlay)   SayString("White pieces", FALSE); else\r
        if(p == BlackPlay)   SayString("Black pieces", FALSE); else\r
        if(p == EmptySquare) SayString("Pieces", FALSE); else {\r
-               sprintf(buf, "%ss", PieceToName(p,1));\r
+         snprintf(buf, sizeof(buf)/sizeof(buf[0]),"%ss", PieceToName(p,1));\r
                SayString(buf, FALSE);\r
        }\r
        SayString("are located", FALSE);\r
        for(yPos=0; yPos<BOARD_HEIGHT; yPos++) {\r
                for(xPos=BOARD_LEFT; xPos<BOARD_RGHT; xPos++) {\r
                SayString(buf, FALSE);\r
        }\r
        SayString("are located", FALSE);\r
        for(yPos=0; yPos<BOARD_HEIGHT; yPos++) {\r
                for(xPos=BOARD_LEFT; xPos<BOARD_RGHT; xPos++) {\r
-                       currentpiece = boards[currentMove][yPos][xPos]; \r
+                       currentpiece = boards[currentMove][yPos][xPos];\r
                        if(p == BlackPlay && currentpiece >= BlackPawn && currentpiece <= BlackKing ||\r
                           p == WhitePlay && currentpiece >= WhitePawn && currentpiece <= WhiteKing   )\r
                                piece = PieceToName(currentpiece,0);\r
                        if(p == BlackPlay && currentpiece >= BlackPawn && currentpiece <= BlackKing ||\r
                           p == WhitePlay && currentpiece >= WhitePawn && currentpiece <= WhiteKing   )\r
                                piece = PieceToName(currentpiece,0);\r
@@ -784,7 +798,7 @@ SayPieces(ChessSquare p)
                        else if(p == currentpiece)\r
                                piece = NULL;\r
                        else continue;\r
                        else if(p == currentpiece)\r
                                piece = NULL;\r
                        else continue;\r
-                               \r
+\r
                                if(count == 0) SayString("at", FALSE);\r
                                xchar = SquareToChar(xPos);\r
                                ynum = SquareToNum(yPos);\r
                                if(count == 0) SayString("at", FALSE);\r
                                xchar = SquareToChar(xPos);\r
                                ynum = SquareToNum(yPos);\r
@@ -795,6 +809,7 @@ SayPieces(ChessSquare p)
                }\r
        }\r
        if(count == 0) SayString("nowhere", FALSE);\r
                }\r
        }\r
        if(count == 0) SayString("nowhere", FALSE);\r
+       SayString("", TRUE); // flush\r
 }\r
 \r
 VOID\r
 }\r
 \r
 VOID\r
@@ -804,7 +819,7 @@ SayCurrentPos()
        char *piece, *xchar, *ynum ;\r
        if(fromX <  BOARD_LEFT) { SayString("You strayed into the white holdings", FALSE); return; }\r
        if(fromX >= BOARD_RGHT) { SayString("You strayed into the black holdings", FALSE); return; }\r
        char *piece, *xchar, *ynum ;\r
        if(fromX <  BOARD_LEFT) { SayString("You strayed into the white holdings", FALSE); return; }\r
        if(fromX >= BOARD_RGHT) { SayString("You strayed into the black holdings", FALSE); return; }\r
-       currentpiece = boards[currentMove][fromY][fromX];       \r
+       currentpiece = boards[currentMove][fromY][fromX];\r
        piece = PieceToName(currentpiece,1);\r
        ynum = SquareToNum(fromY);\r
        xchar = SquareToChar(fromX);\r
        piece = PieceToName(currentpiece,1);\r
        ynum = SquareToNum(fromY);\r
        xchar = SquareToChar(fromX);\r
@@ -814,11 +829,11 @@ SayCurrentPos()
        SayString(piece, FALSE);\r
        if(((fromX-BOARD_LEFT) ^ fromY)&1)\r
                SayString("on a light square",FALSE);\r
        SayString(piece, FALSE);\r
        if(((fromX-BOARD_LEFT) ^ fromY)&1)\r
                SayString("on a light square",FALSE);\r
-       else \r
+       else\r
                SayString("on a dark square",FALSE);\r
 \r
        PossibleAttacked();\r
                SayString("on a dark square",FALSE);\r
 \r
        PossibleAttacked();\r
-       return;\r
+       SayString("", TRUE); // flush\r
 }\r
 \r
 VOID\r
 }\r
 \r
 VOID\r
@@ -827,28 +842,32 @@ SayAllBoard()
        int Xpos, Ypos;\r
        ChessSquare currentpiece;\r
        char *piece, *ynum ;\r
        int Xpos, Ypos;\r
        ChessSquare currentpiece;\r
        char *piece, *ynum ;\r
-       \r
+\r
        if(gameInfo.holdingsWidth) {\r
                int first = 0;\r
                for(Ypos=0; Ypos<gameInfo.holdingsSize; Ypos++) {\r
                        int n = boards[currentMove][Ypos][BOARD_WIDTH-2];\r
        if(gameInfo.holdingsWidth) {\r
                int first = 0;\r
                for(Ypos=0; Ypos<gameInfo.holdingsSize; Ypos++) {\r
                        int n = boards[currentMove][Ypos][BOARD_WIDTH-2];\r
-                       if(n) {  char buf[MSG_SIZ];\r
-                               if(!first++) SayString("white holds", FALSE);\r
-                               currentpiece = boards[currentMove][Ypos][BOARD_WIDTH-1];        \r
-                               piece = PieceToName(currentpiece,0);\r
-                               sprintf(buf, "%d %s%s", n, piece, (n==1 ? "" : "s") );\r
-                               SayString(buf, FALSE);\r
+                       if(n) {\r
+                         char buf[MSG_SIZ];\r
+                         if(!first++)\r
+                           SayString("white holds", FALSE);\r
+                         currentpiece = boards[currentMove][Ypos][BOARD_WIDTH-1];\r
+                         piece = PieceToName(currentpiece,0);\r
+                         snprintf(buf, MSG_SIZ,"%d %s%s", n, piece, (n==1 ? "" : "s") );\r
+                         SayString(buf, FALSE);\r
                        }\r
                }\r
                first = 0;\r
                for(Ypos=BOARD_HEIGHT-1; Ypos>=BOARD_HEIGHT - gameInfo.holdingsSize; Ypos--) {\r
                        int n = boards[currentMove][Ypos][1];\r
                        }\r
                }\r
                first = 0;\r
                for(Ypos=BOARD_HEIGHT-1; Ypos>=BOARD_HEIGHT - gameInfo.holdingsSize; Ypos--) {\r
                        int n = boards[currentMove][Ypos][1];\r
-                       if(n) {  char buf[MSG_SIZ];\r
-                               if(!first++) SayString("black holds", FALSE);\r
-                               currentpiece = boards[currentMove][Ypos][0];    \r
-                               piece = PieceToName(currentpiece,0);\r
-                               sprintf(buf, "%d %s%s", n, piece, (n==1 ? "" : "s") );\r
-                               SayString(buf, FALSE);\r
+                       if(n) {\r
+                         char buf[MSG_SIZ];\r
+                         if(!first++)\r
+                           SayString("black holds", FALSE);\r
+                         currentpiece = boards[currentMove][Ypos][0];\r
+                         piece = PieceToName(currentpiece,0);\r
+                         snprintf(buf, MSG_SIZ, "%d %s%s", n, piece, (n==1 ? "" : "s") );\r
+                         SayString(buf, FALSE);\r
                        }\r
                }\r
        }\r
                        }\r
                }\r
        }\r
@@ -858,16 +877,17 @@ SayAllBoard()
                SayString(ynum, FALSE);\r
                SayString("rank", FALSE);\r
                for(Xpos=BOARD_LEFT; Xpos<BOARD_RGHT; Xpos++) {\r
                SayString(ynum, FALSE);\r
                SayString("rank", FALSE);\r
                for(Xpos=BOARD_LEFT; Xpos<BOARD_RGHT; Xpos++) {\r
-                       currentpiece = boards[currentMove][Ypos][Xpos]; \r
+                       currentpiece = boards[currentMove][Ypos][Xpos];\r
                        if(currentpiece != EmptySquare) {\r
                                int count = 0;\r
                                char buf[50];\r
                                piece = PieceToName(currentpiece,1);\r
                                while(Xpos < BOARD_RGHT && boards[currentMove][Ypos][Xpos] == currentpiece)\r
                                        Xpos++, count++;\r
                        if(currentpiece != EmptySquare) {\r
                                int count = 0;\r
                                char buf[50];\r
                                piece = PieceToName(currentpiece,1);\r
                                while(Xpos < BOARD_RGHT && boards[currentMove][Ypos][Xpos] == currentpiece)\r
                                        Xpos++, count++;\r
-                               if(count > 1) { \r
-                                       sprintf(buf, "%d %ss", count, piece);\r
-                               } else  sprintf(buf, "%s", piece);\r
+                               if(count > 1)\r
+                                 snprintf(buf, sizeof(buf)/sizeof(buf[0]), "%d %ss", count, piece);\r
+                               else\r
+                                 snprintf(buf, sizeof(buf)/sizeof(buf[0]), "%s", piece);\r
                                Xpos--;\r
                                SayString(buf, FALSE);\r
                        } else {\r
                                Xpos--;\r
                                SayString(buf, FALSE);\r
                        } else {\r
@@ -877,9 +897,9 @@ SayAllBoard()
                                if(Xpos == BOARD_RGHT && oldX == BOARD_LEFT)\r
                                        SayString("all", FALSE);\r
                                else{\r
                                if(Xpos == BOARD_RGHT && oldX == BOARD_LEFT)\r
                                        SayString("all", FALSE);\r
                                else{\r
-                                   if(count > 1) { \r
+                                   if(count > 1) {\r
                                        char buf[10];\r
                                        char buf[10];\r
-                                       sprintf(buf, "%d", count);\r
+                                       snprintf(buf, sizeof(buf)/sizeof(buf[0]),"%d", count);\r
                                        SayString(buf, FALSE);\r
                                    }\r
                                    Xpos--;\r
                                        SayString(buf, FALSE);\r
                                    }\r
                                    Xpos--;\r
@@ -888,27 +908,28 @@ SayAllBoard()
                        }\r
                }\r
        }\r
                        }\r
                }\r
        }\r
-       \r
+       SayString("", TRUE); // flush\r
 }\r
 \r
 VOID\r
 SayWhosTurn()\r
 {\r
 }\r
 \r
 VOID\r
 SayWhosTurn()\r
 {\r
-       if(gameMode == MachinePlaysBlack || gameMode == IcsPlayingBlack) {\r
+       if(gameMode == MachinePlaysBlack || gameMode == IcsPlayingWhite) {\r
                if(WhiteOnMove(currentMove))\r
                        SayString("It is your turn", FALSE);\r
                else    SayString("It is your opponents turn", FALSE);\r
                if(WhiteOnMove(currentMove))\r
                        SayString("It is your turn", FALSE);\r
                else    SayString("It is your opponents turn", FALSE);\r
-       } else if(gameMode == MachinePlaysWhite || gameMode == IcsPlayingWhite) {\r
+       } else if(gameMode == MachinePlaysWhite || gameMode == IcsPlayingBlack) {\r
                if(WhiteOnMove(currentMove))\r
                        SayString("It is your opponents turn", FALSE);\r
                else    SayString("It is your turn", FALSE);\r
        } else {\r
                if(WhiteOnMove(currentMove))\r
                        SayString("It is your opponents turn", FALSE);\r
                else    SayString("It is your turn", FALSE);\r
        } else {\r
-               if(WhiteOnMove(currentMove)) \r
+               if(WhiteOnMove(currentMove))\r
                        SayString("White is on move here", FALSE);\r
                else    SayString("Black is on move here", FALSE);\r
        }\r
                        SayString("White is on move here", FALSE);\r
                else    SayString("Black is on move here", FALSE);\r
        }\r
+       SayString("", TRUE); // flush\r
 }\r
 }\r
-       \r
+\r
 extern char *commentList[];\r
 \r
 VOID\r
 extern char *commentList[];\r
 \r
 VOID\r
@@ -947,7 +968,7 @@ SayMachineMove(int evenIfDuplicate)
                                    c = 'W'; break;\r
                                  case IcsPlayingBlack:\r
                                  case MachinePlaysBlack:\r
                                    c = 'W'; break;\r
                                  case IcsPlayingBlack:\r
                                  case MachinePlaysBlack:\r
-                                   c = 'B'; \r
+                                   c = 'B';\r
                                  default:\r
                                    break;\r
                                }\r
                                  default:\r
                                    break;\r
                                }\r
@@ -955,7 +976,7 @@ SayMachineMove(int evenIfDuplicate)
                            if(c != lastMover && !evenIfDuplicate) return; // line is thinking output of future move, ignore.\r
                            if(2*moveNr - (dotCount < 2) == previousMove)\r
                                return; // do not repeat same move; likely ponder output\r
                            if(c != lastMover && !evenIfDuplicate) return; // line is thinking output of future move, ignore.\r
                            if(2*moveNr - (dotCount < 2) == previousMove)\r
                                return; // do not repeat same move; likely ponder output\r
-                           sprintf(buf, "score %s %d at %d ply", \r
+                           snprintf(buf, MSG_SIZ, "score %s %d at %d ply",\r
                                        score > 0 ? "plus" : score < 0 ? "minus" : "",\r
                                        (int) (fabs(score)*100+0.5),\r
                                        depth );\r
                                        score > 0 ? "plus" : score < 0 ? "minus" : "",\r
                                        (int) (fabs(score)*100+0.5),\r
                                        depth );\r
@@ -981,16 +1002,16 @@ SayMachineMove(int evenIfDuplicate)
 \r
                n = 2*moveNr - (dotCount < 2);\r
 \r
 \r
                n = 2*moveNr - (dotCount < 2);\r
 \r
-               if(previousMove != 2*moveNr + (dotCount > 1) || evenIfDuplicate) { \r
+               if(previousMove != 2*moveNr + (dotCount > 1) || evenIfDuplicate) {\r
                    char number[20];\r
                    previousMove = 2*moveNr + (dotCount > 1); // remember move nr of move last spoken\r
                    char number[20];\r
                    previousMove = 2*moveNr + (dotCount > 1); // remember move nr of move last spoken\r
-                   sprintf(number, "%d", moveNr);\r
+                   snprintf(number, sizeof(number)/sizeof(number[0]),"%d", moveNr);\r
 \r
                    yPos = CoordToNum(messageText[len-1]);  /* turn char coords to ints */\r
                    xPos = CoordToNum(messageText[len-2]);\r
                    if(xPos < 0 || xPos > 11) return; // prevent crashes if no coord string available to speak\r
                    if(yPos < 0 || yPos > 9)  return;\r
 \r
                    yPos = CoordToNum(messageText[len-1]);  /* turn char coords to ints */\r
                    xPos = CoordToNum(messageText[len-2]);\r
                    if(xPos < 0 || xPos > 11) return; // prevent crashes if no coord string available to speak\r
                    if(yPos < 0 || yPos > 9)  return;\r
-                   currentpiece = boards[n][yPos][xPos];       \r
+                   currentpiece = boards[n][yPos][xPos];\r
                    piece = PieceToName(currentpiece,0);\r
                    ynum = SquareToNum(yPos);\r
                    xchar = SquareToChar(xPos);\r
                    piece = PieceToName(currentpiece,0);\r
                    ynum = SquareToNum(yPos);\r
                    xchar = SquareToChar(xPos);\r
@@ -1044,8 +1065,8 @@ SayMachineMove(int evenIfDuplicate)
                if(StrStr(messageText, " 1/2-1/2")) p = "game ends in a draw";\r
                if(comment[0]) {\r
                    if(p) {\r
                if(StrStr(messageText, " 1/2-1/2")) p = "game ends in a draw";\r
                if(comment[0]) {\r
                    if(p) {\r
-                       if(!StrCaseStr(comment, "draw") && \r
-                          !StrCaseStr(comment, "white") && \r
+                       if(!StrCaseStr(comment, "draw") &&\r
+                          !StrCaseStr(comment, "white") &&\r
                           !StrCaseStr(comment, "black") ) {\r
                                SayString(p, FALSE);\r
                                SayString("due to", FALSE);\r
                           !StrCaseStr(comment, "black") ) {\r
                                SayString(p, FALSE);\r
                                SayString("due to", FALSE);\r
@@ -1062,6 +1083,7 @@ SayMachineMove(int evenIfDuplicate)
                SayString(messageText, FALSE);\r
            }\r
 \r
                SayString(messageText, FALSE);\r
            }\r
 \r
+       SayString("", TRUE); // flush\r
 }\r
 \r
 VOID\r
 }\r
 \r
 VOID\r
@@ -1074,16 +1096,17 @@ SayClockTime()
        suppressClocks = 1; // if user is using alt+T command, no reason to display them\r
        if(abs(lastWhiteTime - whiteTimeRemaining) < 1000 && abs(lastBlackTime - blackTimeRemaining) < 1000)\r
                suppressClocks = 0; // back on after two requests in rapid succession\r
        suppressClocks = 1; // if user is using alt+T command, no reason to display them\r
        if(abs(lastWhiteTime - whiteTimeRemaining) < 1000 && abs(lastBlackTime - blackTimeRemaining) < 1000)\r
                suppressClocks = 0; // back on after two requests in rapid succession\r
-       sprintf(buf1, "%s", TimeString(whiteTimeRemaining));\r
+       snprintf(buf1, sizeof(buf1)/sizeof(buf1[0]),"%s", TimeString(whiteTimeRemaining));\r
        str1 = buf1;\r
        SayString("White clock", FALSE);\r
        SayString(str1, FALSE);\r
        str1 = buf1;\r
        SayString("White clock", FALSE);\r
        SayString(str1, FALSE);\r
-       sprintf(buf2, "%s", TimeString(blackTimeRemaining));\r
+       snprintf(buf2, sizeof(buf2)/sizeof(buf2[0]), "%s", TimeString(blackTimeRemaining));\r
        str2 = buf2;\r
        SayString("Black clock", FALSE);\r
        SayString(str2, FALSE);\r
        lastWhiteTime = whiteTimeRemaining;\r
        lastBlackTime = blackTimeRemaining;\r
        str2 = buf2;\r
        SayString("Black clock", FALSE);\r
        SayString(str2, FALSE);\r
        lastWhiteTime = whiteTimeRemaining;\r
        lastBlackTime = blackTimeRemaining;\r
+       SayString("", TRUE); // flush\r
 }\r
 \r
 VOID\r
 }\r
 \r
 VOID\r
@@ -1093,6 +1116,7 @@ Toggle(Boolean *b, char *mess)
        SayString(mess, FALSE);\r
        SayString("is now", FALSE);\r
        SayString(*b ? "on" : "off", FALSE);\r
        SayString(mess, FALSE);\r
        SayString("is now", FALSE);\r
        SayString(*b ? "on" : "off", FALSE);\r
+       SayString("", TRUE); // flush\r
 }\r
 \r
 /* handles keyboard moves in a click-click fashion */\r
 }\r
 \r
 /* handles keyboard moves in a click-click fashion */\r
@@ -1101,7 +1125,7 @@ KeyboardMove(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
 {\r
        ChessSquare currentpiece;\r
        char *piece;\r
 {\r
        ChessSquare currentpiece;\r
        char *piece;\r
-       \r
+\r
        static BOOLEAN sameAgain = FALSE;\r
        switch (message) {\r
        case WM_KEYDOWN:\r
        static BOOLEAN sameAgain = FALSE;\r
        switch (message) {\r
        case WM_KEYDOWN:\r
@@ -1112,20 +1136,20 @@ KeyboardMove(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
                        break;\r
                }\r
                else if(oldFromX != -1) {\r
                        break;\r
                }\r
                else if(oldFromX != -1) {\r
-                       \r
+\r
                        ChessSquare pdown, pup;\r
       pdown = boards[currentMove][oldFromY][oldFromX];\r
       pup = boards[currentMove][fromY][fromX];\r
                        ChessSquare pdown, pup;\r
       pdown = boards[currentMove][oldFromY][oldFromX];\r
       pup = boards[currentMove][fromY][fromX];\r
-               \r
+\r
                if (gameMode == EditPosition ||\r
                        !((WhitePawn <= pdown && pdown <= WhiteKing &&\r
                                 WhitePawn <= pup && pup <= WhiteKing) ||\r
                                (BlackPawn <= pdown && pdown <= BlackKing &&\r
                                 BlackPawn <= pup && pup <= BlackKing))) {\r
                        /* EditPosition, empty square, or different color piece;\r
                if (gameMode == EditPosition ||\r
                        !((WhitePawn <= pdown && pdown <= WhiteKing &&\r
                                 WhitePawn <= pup && pup <= WhiteKing) ||\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
                        char promoChoice = NULLCHAR;\r
-               \r
+\r
                        if (HasPromotionChoice(oldFromX, oldFromY, fromX, fromY, &promoChoice)) {\r
                                if (appData.alwaysPromoteToQueen) {\r
                                        UserMoveEvent(oldFromX, oldFromY, fromX, fromY, 'q');\r
                        if (HasPromotionChoice(oldFromX, oldFromY, fromX, fromY, &promoChoice)) {\r
                                if (appData.alwaysPromoteToQueen) {\r
                                        UserMoveEvent(oldFromX, oldFromY, fromX, fromY, 'q');\r
@@ -1134,7 +1158,7 @@ KeyboardMove(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
                                        toX = fromX; toY = fromY; fromX = oldFromX; fromY = oldFromY;\r
                                        PromotionPopup(hwnd);\r
                                        fromX = toX; fromY = toY;\r
                                        toX = fromX; toY = fromY; fromX = oldFromX; fromY = oldFromY;\r
                                        PromotionPopup(hwnd);\r
                                        fromX = toX; fromY = toY;\r
-                               }       \r
+                               }\r
                        }\r
                        else {\r
                                UserMoveEvent(oldFromX, oldFromY, fromX, fromY, promoChoice);\r
                        }\r
                        else {\r
                                UserMoveEvent(oldFromX, oldFromY, fromX, fromY, promoChoice);\r
@@ -1142,16 +1166,16 @@ KeyboardMove(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
                oldFromX = oldFromY = -1;\r
                break;\r
                }\r
                oldFromX = oldFromY = -1;\r
                break;\r
                }\r
-               \r
+\r
                }\r
                /* First downclick, or restart on a square with same color piece */\r
                if (OKToStartUserMove(fromX, fromY)) {\r
                oldFromX = fromX;\r
                oldFromY = fromY;\r
                }\r
                /* First downclick, or restart on a square with same color piece */\r
                if (OKToStartUserMove(fromX, fromY)) {\r
                oldFromX = fromX;\r
                oldFromY = fromY;\r
-               currentpiece = boards[currentMove][fromY][fromX];       \r
+               currentpiece = boards[currentMove][fromY][fromX];\r
                piece = PieceToName(currentpiece,1);\r
                SayString(piece, FALSE);\r
                piece = PieceToName(currentpiece,1);\r
                SayString(piece, FALSE);\r
-               SayString("selected", FALSE);\r
+               SayString("selected", TRUE);\r
                }\r
                else {\r
                oldFromX = oldFromY = -1;\r
                }\r
                else {\r
                oldFromX = oldFromY = -1;\r
@@ -1164,10 +1188,10 @@ KeyboardMove(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
       if (sameAgain) {\r
        /* Clicked same square twice: abort click-click move */\r
                        oldFromX = oldFromY = -1;\r
       if (sameAgain) {\r
        /* Clicked same square twice: abort click-click move */\r
                        oldFromX = oldFromY = -1;\r
-                       currentpiece = boards[currentMove][fromY][fromX];       \r
+                       currentpiece = boards[currentMove][fromY][fromX];\r
                        piece = PieceToName(currentpiece,0);\r
                        SayString(piece, FALSE);\r
                        piece = PieceToName(currentpiece,0);\r
                        SayString(piece, FALSE);\r
-                       SayString("unselected", FALSE);\r
+                       SayString("unselected", TRUE);\r
                        }\r
                }\r
        }\r
                        }\r
                }\r
        }\r
@@ -1212,7 +1236,7 @@ NiceTime(int x)
     case '\020': /* ctrl P */\\r
       { char buf[MSG_SIZ];\\r
        if(GetWindowText(hwnd, buf, MSG_SIZ-1))\\r
     case '\020': /* ctrl P */\\r
       { char buf[MSG_SIZ];\\r
        if(GetWindowText(hwnd, buf, MSG_SIZ-1))\\r
-               SayString(buf, FALSE);\\r
+               SayString(buf, TRUE);\\r
       }\\r
       return 0;\\r
 \r
       }\\r
       return 0;\\r
 \r
@@ -1251,6 +1275,7 @@ NiceTime(int x)
                        KeyboardEvent(hwnd, message, wParam, lParam);\\r
                        break;\\r
                case VK_SPACE:\\r
                        KeyboardEvent(hwnd, message, wParam, lParam);\\r
                        break;\\r
                case VK_SPACE:\\r
+                        shiftKey = GetKeyState(VK_SHIFT) < 0;\\r
                        KeyboardMove(hwnd, message, wParam, lParam);\\r
                        break;\\r
                }\\r
                        KeyboardMove(hwnd, message, wParam, lParam);\\r
                        break;\\r
                }\\r
@@ -1368,7 +1393,7 @@ NiceTime(int x)
 #define JAWS_COPYRIGHT \\r
        SetDlgItemText(hDlg, OPT_MESS, "Auditory/Keyboard Enhancements  By:  Ed Rodriguez (sort of)");\r
 \r
 #define JAWS_COPYRIGHT \\r
        SetDlgItemText(hDlg, OPT_MESS, "Auditory/Keyboard Enhancements  By:  Ed Rodriguez (sort of)");\r
 \r
-#define SAY(S) SayString((S), FALSE)\r
+#define SAY(S) SayString((S), TRUE)\r
 \r
 #define SAYMACHINEMOVE() SayMachineMove(0)\r
 \r
 \r
 #define SAYMACHINEMOVE() SayMachineMove(0)\r
 \r