X-Git-Url: http://winboard.nl/cgi-bin?a=blobdiff_plain;f=winboard%2Fjaws.c;h=15be5ee528713fff1d7ff22364598f3cca486d3a;hb=93c28220b231b606325e8353b7c5eaba5ac78eef;hp=9d8ec9c9269541312662bacb0f314f6f315e23b1;hpb=08b791a1526fb669916eec752752f1cbb0582de1;p=xboard.git diff --git a/winboard/jaws.c b/winboard/jaws.c index 9d8ec9c..15be5ee 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++) { @@ -293,6 +282,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) @@ -301,6 +291,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; } @@ -356,14 +350,13 @@ KeyboardEvent(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) ynum = SquareToNum(fromY); if(currentPiece != EmptySquare) { // SayString(piece[0] == 'W' ? "white" : "black", TRUE); - sprintf(buf, "%s %s %s", piece, xchar, ynum); + sprintf(buf, "%s %s %s", xchar, ynum, piece); } else sprintf(buf, "%s %s", xchar, ynum); SayString(buf, TRUE); } return; } -extern char castlingRights[MAX_MOVES][BOARD_SIZE]; int PosFlags(int nr); typedef struct { @@ -442,8 +435,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 +462,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 @@ -904,11 +894,11 @@ SayAllBoard() 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); @@ -962,7 +952,7 @@ SayMachineMove(int evenIfDuplicate) break; } } - if(c != lastMover) return; // line is thinking output of future move, ignore. + 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", @@ -1086,11 +1076,11 @@ SayClockTime() suppressClocks = 0; // back on after two requests in rapid succession sprintf(buf1, "%s", TimeString(whiteTimeRemaining)); str1 = buf1; - SayString("White's remaining time is", FALSE); + SayString("White clock", FALSE); SayString(str1, FALSE); sprintf(buf2, "%s", TimeString(blackTimeRemaining)); str2 = buf2; - SayString("Black's remaining time is", FALSE); + SayString("Black clock", FALSE); SayString(str2, FALSE); lastWhiteTime = whiteTimeRemaining; lastBlackTime = blackTimeRemaining; @@ -1133,9 +1123,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'); } @@ -1146,7 +1137,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; @@ -1194,11 +1185,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) {\ @@ -1208,6 +1199,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);\