X-Git-Url: http://winboard.nl/cgi-bin?a=blobdiff_plain;f=board.c;h=b8be924af6f315fd5e4edb0cbe0418f558dd493c;hb=67b3a0d7c465522feb67841c7374bf863df19357;hp=0bc81f88c74cd20257a780ff43c45f806c277903;hpb=fbcf1f3b86b144dd4940b326c32d4b105c0f74b3;p=xboard.git diff --git a/board.c b/board.c index 0bc81f8..b8be924 100644 --- a/board.c +++ b/board.c @@ -98,6 +98,7 @@ extern char *getenv(); #include "backend.h" #include "moves.h" #include "board.h" +#include "draw.h" #ifdef __EMX__ @@ -148,7 +149,7 @@ int pm1X = -1, pm1Y = -1, pm2X = -1, pm2Y = -1; void SetHighlights (int fromX, int fromY, int toX, int toY) { - int arrow = hi2X > 0 && IsDrawArrowEnabled(); + int arrow = hi2X >= 0 && hi1Y >= 0 && IsDrawArrowEnabled(); if (hi1X != fromX || hi1Y != fromY) { if (hi1X >= 0 && hi1Y >= 0) { @@ -181,7 +182,7 @@ SetHighlights (int fromX, int fromY, int toX, int toY) hi2X = toX; hi2Y = toY; - if(arrow || toX < 0 && IsDrawArrowEnabled()) + if(arrow || toX >= 0 && fromY >= 0 && IsDrawArrowEnabled()) DrawPosition(FALSE, NULL); // repair any arrow damage, or draw a new one } @@ -812,8 +813,10 @@ DrawSquare (int row, int column, ChessSquare piece, int do_flash) if (do_flash && piece != EmptySquare && appData.flashCount > 0) { for (i=0; i 0) @@ -959,6 +964,8 @@ DrawPosition (int repaint, Board board) DrawSquare(i, j, board[i][j], 0); damage[nr][i][j] = False; } + + exposeAll = True; } CopyBoard(lastBoard[nr], board); @@ -972,15 +979,19 @@ DrawPosition (int repaint, Board board) /* Draw highlights */ if (pm1X >= 0 && pm1Y >= 0) { drawHighlight(pm1X, pm1Y, 2); + damage[nr][pm1Y][pm1X] = False; } if (pm2X >= 0 && pm2Y >= 0) { drawHighlight(pm2X, pm2Y, 2); + damage[nr][pm2Y][pm2X] = False; } if (hi1X >= 0 && hi1Y >= 0) { drawHighlight(hi1X, hi1Y, 1); + damage[nr][hi1Y][hi1X] = False; } if (hi2X >= 0 && hi2Y >= 0) { drawHighlight(hi2X, hi2Y, 1); + damage[nr][hi2Y][hi2X] = False; } DrawArrowHighlight(hi1X, hi1Y, hi2X, hi2Y); } @@ -989,6 +1000,30 @@ DrawPosition (int repaint, Board board) /* If piece being dragged around board, must redraw that too */ DrawDragPiece(); + if(exposeAll) + GraphExpose(currBoard, 0, 0, BOARD_WIDTH*(squareSize + lineGap) + lineGap, BOARD_HEIGHT*(squareSize + lineGap) + lineGap); + else { + for (i = 0; i < BOARD_HEIGHT; i++) + for (j = 0; j < BOARD_WIDTH; j++) + if(damage[nr][i][j]) { + int x, y; + if (flipView) { + x = lineGap + ((BOARD_WIDTH-1)-j) * + (squareSize + lineGap); + y = lineGap + i * (squareSize + lineGap); + } else { + x = lineGap + j * (squareSize + lineGap); + y = lineGap + ((BOARD_HEIGHT-1)-i) * + (squareSize + lineGap); + } + if(damage[nr][i][j] & 2) // damage by old or new arrow + GraphExpose(currBoard, x - lineGap, y - lineGap, squareSize + 2*lineGap, squareSize + 2*lineGap); + else + GraphExpose(currBoard, x, y, squareSize, squareSize); + damage[nr][i][j] &= ~2; // remember damage by newly drawn error in '2' bit, to schedule it for erasure next draw + } + } + FlashDelay(0); // this flushes drawing queue; if(nr) SwitchWindow(); } @@ -1134,10 +1169,10 @@ ArrowDamage (int s_col, int s_row, int d_col, int d_row) int hor, vert, i, n = partnerUp * twoBoards; hor = 64*s_col + 32; vert = 64*s_row + 32; for(i=0; i<= 64; i++) { - damage[n][vert+6>>6][hor+6>>6] = True; - damage[n][vert-6>>6][hor+6>>6] = True; - damage[n][vert+6>>6][hor-6>>6] = True; - damage[n][vert-6>>6][hor-6>>6] = True; + damage[n][vert+6>>6][hor+6>>6] |= 2; + damage[n][vert-6>>6][hor+6>>6] |= 2; + damage[n][vert+6>>6][hor-6>>6] |= 2; + damage[n][vert-6>>6][hor-6>>6] |= 2; hor += d_col - s_col; vert += d_row - s_row; } }