fixed jaws version
[xboard.git] / winboard / jaws.c
index 95f70d2..99f41b1 100644 (file)
 \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
@@ -239,7 +229,6 @@ AdaptMenu()
 \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
@@ -919,13 +908,14 @@ SayWhosTurn()
        }\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
@@ -981,6 +971,7 @@ SayMachineMove(int evenIfDuplicate)
                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
@@ -1037,11 +1028,11 @@ SayMachineMove(int evenIfDuplicate)
                                        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
@@ -1062,6 +1053,8 @@ SayMachineMove(int evenIfDuplicate)
                    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
@@ -1129,9 +1122,10 @@ KeyboardMove(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
                                (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
@@ -1142,7 +1136,7 @@ KeyboardMove(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
                                }       \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