X-Git-Url: http://winboard.nl/cgi-bin?a=blobdiff_plain;f=winboard%2Fjaws.c;h=27612fb43c6a11f089f965d6091f61847f2c023e;hb=f1fbc14f88e6dfef22020dc193f3b4805952778c;hp=c62f247640694333ce9661723e94a78765185146;hpb=2e85821da14eed8befd74e9aeb7ccf49c94a38a9;p=xboard.git diff --git a/winboard/jaws.c b/winboard/jaws.c index c62f247..27612fb 100644 --- a/winboard/jaws.c +++ b/winboard/jaws.c @@ -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" }; @@ -117,6 +107,22 @@ char *pieceToName[] = { "Empty" }; +char *pieceTypeName[] = { + "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", + "Guard", "Elephant", "Arch Bishop", "Chancellor", + "General", "Man", "Cannon", "Night Rider", + "Crowned Bishop", "Crowned Rook", "Grass Hopper", "Veteran", + "Falcon", "Amazon", "Snake", "Unicorn", + "King", + "Empty" + }; + int CoordToNum(c) char c; { @@ -130,7 +136,7 @@ char* PieceToName(p, i) int i; { if(i) return pieceToName[(int) p]; - return pieceToName[(int) p]+6; + return pieceTypeName[(int) p]; } char* SquareToChar(x) @@ -147,8 +153,8 @@ char* SquareToNum(y) // from winboard.c: all new routines - -#include "jfwapi.h" +#define JFWAPI __declspec(dllimport) +JFWAPI BOOL WINAPI JFWSayString (LPCTSTR lpszStrinToSpeak, BOOL bInterrupt); typedef JFWAPI BOOL (WINAPI *PSAYSTRING)(LPCTSTR lpszStrinToSpeak, BOOL bInterrupt); @@ -156,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:")) { @@ -188,8 +194,8 @@ MenuItemDesc menuItemJAWS[] = { {"Say Board &Rank\tAlt+R", IDM_ReadRow }, {"Say Board &File\tAlt+F", IDM_ReadColumn }, {"-", 0 }, -{"Say &Upper Diagnols\tAlt+U", IDM_SayUpperDiagnols }, -{"Say &Lower Diagnols\tAlt+L", IDM_SayLowerDiagnols }, +{"Say &Upper Diagonals\tAlt+U", IDM_SayUpperDiagnols }, +{"Say &Lower Diagonals\tAlt+L", IDM_SayLowerDiagnols }, {"Say K&night Moves\tAlt+N", IDM_SayKnightMoves }, {"Say Current &Square\tAlt+S", IDM_SayCurrentPos }, {"Say &Attacks\tAlt+A", IDM_PossibleAttackMove }, @@ -219,11 +225,10 @@ AdaptMenu() { HMENU menuMain, menuJAWS; MENUBARINFO helpMenuInfo; - int e, i; + int i; 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++) { @@ -275,12 +280,15 @@ InitJAWS() return TRUE; } +int beeps[] = { 1, 0, 0, 0, 0 }; +int beepCodes[] = { 0, MB_OK, MB_ICONERROR, MB_ICONQUESTION, MB_ICONEXCLAMATION, MB_ICONASTERISK }; + VOID KeyboardEvent(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { ChessSquare currentPiece; char *piece, *xchar, *ynum ; - int n; + int n, beepType = 1; // empty beep if(fromX == -1 || fromY == -1) { fromX = BOARD_LEFT; fromY = 0; @@ -288,34 +296,37 @@ KeyboardEvent(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) switch(wParam) { case VK_LEFT: if(fromX == BOARD_RGHT+1) fromX -= 2; else - if(fromX == BOARD_LEFT) { if(fromY >= BOARD_HEIGHT - gameInfo.holdingsSize) fromX -= 2; } else - if(fromX > BOARD_LEFT) fromX--; + if(fromX == BOARD_LEFT) { if(fromY >= BOARD_HEIGHT - gameInfo.holdingsSize) fromX -= 2; else beepType = 0; } else + if(fromX > BOARD_LEFT) fromX--; else beepType = 0; // off-board beep break; case VK_RIGHT: if(fromX == BOARD_LEFT-2) fromX += 2; else - if(fromX == BOARD_RGHT-1) { if(fromY < gameInfo.holdingsSize) fromX += 2; } else - if(fromX < BOARD_RGHT-1) fromX++; + if(fromX == BOARD_RGHT-1) { if(fromY < gameInfo.holdingsSize) fromX += 2; else beepType = 0; } else + if(fromX < BOARD_RGHT-1) fromX++; else beepType = 0; break; case VK_UP: - if(fromX == BOARD_RGHT+1) { if(fromY < gameInfo.holdingsSize - 1) fromY++; } else - if(fromY < BOARD_HEIGHT-1) fromY++; + if(fromX == BOARD_RGHT+1) { if(fromY < gameInfo.holdingsSize - 1) fromY++; else beepType = 0; } else + if(fromY < BOARD_HEIGHT-1) fromY++; else beepType = 0; break; case VK_DOWN: - if(fromX == BOARD_LEFT-2) { if(fromY > BOARD_HEIGHT - gameInfo.holdingsSize) fromY--; } else - if(fromY > 0) fromY--; + if(fromX == BOARD_LEFT-2) { if(fromY > BOARD_HEIGHT - gameInfo.holdingsSize) fromY--; else beepType = 0; } else + if(fromY > 0) fromY--; else beepType = 0; break; } SetHighlights(fromX, fromY, -1, -1); DrawPosition(FALSE, NULL); currentPiece = boards[currentMove][fromY][fromX]; piece = PieceToName(currentPiece,1); - if(currentPiece != EmptySquare) MessageBeep(currentPiece < (int)BlackPawn ? MB_OK : MB_ICONEXCLAMATION); + if(beepType == 1 && currentPiece != EmptySquare) beepType = currentPiece < (int) BlackPawn ? 2 : 3; // white or black beep + if(beeps[beepType] == beeps[1] && (fromX == BOARD_RGHT+1 || fromX == BOARD_LEFT-2)) beepType = 4; // holdings beep + beepType = beeps[beepType]%6; + if(beepType) MessageBeep(beepCodes[beepType]); if(fromX == BOARD_LEFT - 2) { SayString("black holdings", FALSE); if(currentPiece != EmptySquare) { char buf[MSG_SIZ]; n = boards[currentMove][fromY][1]; - sprintf(buf, "%d %s%s", n, piece+6, n == 1 ? "" : "s"); + sprintf(buf, "%d %s%s", n, PieceToName(currentPiece,0), n == 1 ? "" : "s"); SayString(buf, TRUE); } } else @@ -324,7 +335,7 @@ KeyboardEvent(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) if(currentPiece != EmptySquare) { char buf[MSG_SIZ]; n = boards[currentMove][fromY][BOARD_WIDTH-2]; - sprintf(buf, "%d %s%s", n, piece+6, n == 1 ? "" : "s"); + sprintf(buf, "%d %s%s", n, PieceToName(currentPiece,0), n == 1 ? "" : "s"); SayString(buf, TRUE); } } else @@ -341,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 { @@ -420,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 @@ -448,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 @@ -814,7 +821,7 @@ SayAllBoard() { int Xpos, Ypos; ChessSquare currentpiece; - char *piece, *xchar, *ynum ; + char *piece, *ynum ; if(gameInfo.holdingsWidth) { int first = 0; @@ -848,7 +855,7 @@ SayAllBoard() for(Xpos=BOARD_LEFT; Xpos