From: Alex Kompel Date: Thu, 11 Jun 2015 02:18:56 +0000 (-0700) Subject: win32_gui: flicker mitigation X-Git-Tag: NetHack-3.6.0_RC01~278 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ad654cdc614e01e32ae11b42c58155020f63a785;p=nethack win32_gui: flicker mitigation - do not invalidate window area if tile has not actually changed - do not erase backround when invalidating the tile - use NO_GLYPH for uninitialized map areas (as opposed to -1) --- diff --git a/win/win32/mhmap.c b/win/win32/mhmap.c index ec5f5c5f7..1b491f00c 100644 --- a/win/win32/mhmap.c +++ b/win/win32/mhmap.c @@ -452,12 +452,15 @@ onMSNHCommand(HWND hWnd, WPARAM wParam, LPARAM lParam) switch (wParam) { case MSNH_MSG_PRINT_GLYPH: { PMSNHMsgPrintGlyph msg_data = (PMSNHMsgPrintGlyph) lParam; - data->map[msg_data->x][msg_data->y] = msg_data->glyph; - data->bkmap[msg_data->x][msg_data->y] = msg_data->bkglyph; - - /* invalidate the update area */ - nhcoord2display(data, msg_data->x, msg_data->y, &rt); - InvalidateRect(hWnd, &rt, TRUE); + if((data->map[msg_data->x][msg_data->y] != msg_data->glyph) + || (data->bkmap[msg_data->x][msg_data->y] != msg_data->bkglyph)) { + data->map[msg_data->x][msg_data->y] = msg_data->glyph; + data->bkmap[msg_data->x][msg_data->y] = msg_data->bkglyph; + + /* invalidate the update area */ + nhcoord2display(data, msg_data->x, msg_data->y, &rt); + InvalidateRect(hWnd, &rt, FALSE); + } } break; case MSNH_MSG_CLIPAROUND: { @@ -508,7 +511,8 @@ onMSNHCommand(HWND hWnd, WPARAM wParam, LPARAM lParam) int i, j; for (i = 0; i < COLNO; i++) for (j = 0; j < ROWNO; j++) { - data->map[i][j] = -1; + data->map[i][j] = NO_GLYPH; + data->bkmap[i][j] = NO_GLYPH; } InvalidateRect(hWnd, NULL, TRUE); } break; @@ -556,7 +560,7 @@ onMSNHCommand(HWND hWnd, WPARAM wParam, LPARAM lParam) for (col = 0; col < COLNO; col++) { if (index >= msg_data->max_size) break; - if (data->map[col][row] == -1) { + if (data->map[col][row] == NO_GLYPH) { mgch = ' '; } else { (void) mapglyph(data->map[col][row], &mgch, &color, @@ -593,8 +597,8 @@ onCreate(HWND hWnd, WPARAM wParam, LPARAM lParam) ZeroMemory(data, sizeof(NHMapWindow)); for (i = 0; i < COLNO; i++) for (j = 0; j < ROWNO; j++) { - data->map[i][j] = -1; - data->bkmap[i][j] = -1; + data->map[i][j] = NO_GLYPH; + data->bkmap[i][j] = NO_GLYPH; } data->bAsciiMode = FALSE; @@ -712,13 +716,13 @@ onPaint(HWND hWnd) for (i = paint_rt.left; i < paint_rt.right; i++) for (j = paint_rt.top; j < paint_rt.bottom; j++) { glyph = data->map[i][j]; - bkglyph = (glyph >= 0)? data->bkmap[i][j] : -1; + bkglyph = (glyph != NO_GLYPH)? data->bkmap[i][j] : NO_GLYPH; if (glyph == bkglyph) { - glyph = -1; + glyph = NO_GLYPH; } - if (bkglyph >= 0) { + if (bkglyph != NO_GLYPH) { ntile = glyph2tile[bkglyph]; t_x = TILEBMP_X(ntile); t_y = TILEBMP_Y(ntile); @@ -730,7 +734,7 @@ onPaint(HWND hWnd) GetNHApp()->mapTile_Y, SRCCOPY); } - if (glyph >= 0) { + if (glyph != NO_GLYPH) { ntile = glyph2tile[glyph]; t_x = TILEBMP_X(ntile); t_y = TILEBMP_Y(ntile);