X-Git-Url: http://winboard.nl/cgi-bin?a=blobdiff_plain;f=winboard%2Fjaws.c;h=99f41b120c19509586cc7b6e51e98b3bed301e72;hb=ebcbd4b12741dd5598bee06d531fa3d75e4bba93;hp=1891f070555721e2db26a4647e4677967d4663e8;hpb=b580902926ac214d50d6fb21e45402b42421949c;p=xboard.git diff --git a/winboard/jaws.c b/winboard/jaws.c index 1891f07..99f41b1 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) @@ -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 @@ -814,7 +825,7 @@ SayAllBoard() { int Xpos, Ypos; ChessSquare currentpiece; - char *piece, *xchar, *ynum ; + char *piece, *ynum ; if(gameInfo.holdingsWidth) { int first = 0; @@ -848,7 +859,7 @@ SayAllBoard() for(Xpos=BOARD_LEFT; Xpos