X-Git-Url: http://winboard.nl/cgi-bin?a=blobdiff_plain;f=winboard%2Fjaws.c;h=19ee0659de58f6fab86cdd988007741fb2ee45f9;hb=de0ee08250c127975c1769b1e2f6bd078e39632a;hp=95f70d244e646ae66338897184d15a537f2e361c;hpb=399cc00c90b392f98ab83aa08d77077ada6043b5;p=xboard.git diff --git a/winboard/jaws.c b/winboard/jaws.c index 95f70d2..19ee065 100644 --- a/winboard/jaws.c +++ b/winboard/jaws.c @@ -5,7 +5,7 @@ * Massachusetts. * * Enhancements Copyright 1992-2001, 2002, 2003, 2004, 2005, 2006, - * 2007, 2008, 2009 Free Software Foundation, Inc. + * 2007, 2008, 2009, 2010 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. @@ -83,16 +83,6 @@ extern long whiteTimeRemaining, blackTimeRemaining, timeControl, timeIncrement; -#if 0 -// from moves.h, but no longer needed, as the new routines are all moved to winboard.c - -extern char* PieceToName P((ChessSquare p, int i)); -extern char* SquareToChar P((int Xpos)); -extern char* SquareToNum P((int Ypos)); -extern int CoordToNum P((char c)); - -#endif - // from moves.c, added WinBoard_F piece types and ranks / files char *squareToChar[] = { "ay", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l" }; @@ -172,7 +162,7 @@ PSAYSTRING RealSayString; VOID SayString(char *mess, BOOL flag) { // for debug file - char buf[MSG_SIZ], *p; + char buf[8000], *p; if(appData.debugMode) fprintf(debugFP, "SAY '%s'\n", mess); strcpy(buf, mess); if(p = StrCaseStr(buf, "Xboard adjudication:")) { @@ -239,7 +229,6 @@ AdaptMenu() helpMenuInfo.cbSize = sizeof(helpMenuInfo); menuMain = GetMenu(hwndMain); - if(appData.debugMode) fprintf(debugFP, "hwndMain: %8x %8x\n", hwndMain, menuMain); menuJAWS = CreatePopupMenu(); for(i=0; menuItemJAWS[i].name; i++) { @@ -363,7 +352,6 @@ KeyboardEvent(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) return; } -extern char castlingRights[MAX_MOVES][BOARD_SIZE]; int PosFlags(int nr); typedef struct { @@ -442,8 +430,7 @@ PossibleAttackMove() swapColor = piece < (int)BlackPawn && !WhiteOnMove(currentMove) || piece >= (int)BlackPawn && WhiteOnMove(currentMove); cl.count = 0; cl.rf = fromY; cl.ff = fromX; cl.rt = cl.ft = -1; - GenLegal(boards[currentMove], PosFlags(currentMove + swapColor), EP_NONE, - castlingRights[currentMove], ReadCallback, (VOIDSTAR) &cl); + GenLegal(boards[currentMove], PosFlags(currentMove + swapColor), ReadCallback, (VOIDSTAR) &cl); if(cl.count == 0) SayString("None", FALSE); boards[currentMove][fromY][fromX] = victim; // repair @@ -470,16 +457,14 @@ PossibleAttacked() victim = boards[currentMove][fromY][fromX]; // put dummy piece on target square, to activate Pawn captures boards[currentMove][fromY][fromX] = WhiteOnMove(currentMove) ? WhiteQueen : BlackQueen; cl.count = 0; cl.rt = fromY; cl.ft = fromX; cl.rf = cl.ff = -1; - GenLegal(boards[currentMove], PosFlags(currentMove+1), EP_NONE, - castlingRights[currentMove], ReadCallback, (VOIDSTAR) &cl); + GenLegal(boards[currentMove], PosFlags(currentMove+1), ReadCallback, (VOIDSTAR) &cl); if(cl.count == 0) SayString("None", FALSE); SayString("You are defended by", FALSE); boards[currentMove][fromY][fromX] = WhiteOnMove(currentMove) ? BlackQueen : WhiteQueen; cl.count = 0; cl.rt = fromY; cl.ft = fromX; cl.rf = cl.ff = -1; - GenLegal(boards[currentMove], PosFlags(currentMove), EP_NONE, - castlingRights[currentMove], ReadCallback, (VOIDSTAR) &cl); + GenLegal(boards[currentMove], PosFlags(currentMove), ReadCallback, (VOIDSTAR) &cl); if(cl.count == 0) SayString("None", FALSE); boards[currentMove][fromY][fromX] = victim; // put back original occupant @@ -919,13 +904,14 @@ SayWhosTurn() } } +extern char *commentList[]; VOID SayMachineMove(int evenIfDuplicate) { int len, xPos, yPos, moveNr, secondSpace = 0, castle = 0, n; ChessSquare currentpiece; - char *piece, *xchar, *ynum, *p; + char *piece, *xchar, *ynum, *p, checkMark = 0; char c, buf[MSG_SIZ], comment[MSG_SIZ]; static char disambiguation[2]; static int previousMove = 0; @@ -981,6 +967,7 @@ SayMachineMove(int evenIfDuplicate) if(secondSpace) len = secondSpace; // position behind move if(messageText[len-1] == '+' || messageText[len-1] == '#') { /* you are in checkmate */ len--; // strip off check or mate indicator + checkMark = messageText[len]; // make sure still seen after we stip off promo piece } if(messageText[len-2] == '=') { /* promotion */ len-=2; // strip off promotion piece @@ -1037,11 +1024,11 @@ SayMachineMove(int evenIfDuplicate) SayString(piece, FALSE); } else SayString("Capturing onn passann",FALSE); } - if(messageText[len] == '+') SayString("check", FALSE); else - if(messageText[len] == '#') { + } + if(checkMark == '+') SayString("check", FALSE); else + if(checkMark == '#') { SayString("finishing off", FALSE); SayString(WhiteOnMove(n) ? "White" : "Black", FALSE); - } } } @@ -1062,6 +1049,8 @@ SayMachineMove(int evenIfDuplicate) SayString(comment, FALSE); // alphabetic comment (usually game end) } else if(p) SayString(p, FALSE); + if(commentDialog && commentList[currentMove]) SetFocus(commentDialog); + } else { /* starts not with digit */ if(StrCaseStr(messageText, "illegal")) PlayIcsUnfinishedSound(); @@ -1129,9 +1118,10 @@ KeyboardMove(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) (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 (IsPromotion(oldFromX, oldFromY, fromX, fromY)) { + if (HasPromotionChoice(oldFromX, oldFromY, fromX, fromY, &promoChoice)) { if (appData.alwaysPromoteToQueen) { UserMoveEvent(oldFromX, oldFromY, fromX, fromY, 'q'); } @@ -1142,7 +1132,7 @@ KeyboardMove(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) } } else { - UserMoveEvent(oldFromX, oldFromY, fromX, fromY, NULLCHAR); + UserMoveEvent(oldFromX, oldFromY, fromX, fromY, promoChoice); } oldFromX = oldFromY = -1; break; @@ -1190,11 +1180,11 @@ NiceTime(int x) } #define JAWS_ARGS \ - { "beepOffBoard", ArgInt, (LPVOID) beeps, TRUE },\ - { "beepEmpty", ArgInt, (LPVOID) (beeps+1), TRUE },\ - { "beepWhite", ArgInt, (LPVOID) (beeps+2), TRUE },\ - { "beepBlack", ArgInt, (LPVOID) (beeps+3), TRUE },\ - { "beepHoldings", ArgInt, (LPVOID) (beeps+4), TRUE },\ + { "beepOffBoard", ArgInt, (LPVOID) beeps, TRUE, (ArgIniType) 1 },\ + { "beepEmpty", ArgInt, (LPVOID) (beeps+1), TRUE, (ArgIniType) 0 },\ + { "beepWhite", ArgInt, (LPVOID) (beeps+2), TRUE, (ArgIniType) 0 },\ + { "beepBlack", ArgInt, (LPVOID) (beeps+3), TRUE, (ArgIniType) 0 },\ + { "beepHoldings", ArgInt, (LPVOID) (beeps+4), TRUE, (ArgIniType) 0 },\ #define JAWS_ALT_INTERCEPT \ if(suppressOneKey) {\