prevent Windows back_buffer_flip() early on

This commit is contained in:
nhmall
2022-02-06 10:47:41 -05:00
parent 88e447475e
commit 19ff846645
+9
View File
@@ -180,6 +180,7 @@ static COLORREF DefaultColors[CLR_MAX] = {
}; };
#endif #endif
struct console_t { struct console_t {
boolean is_ready;
WORD background; WORD background;
WORD foreground; WORD foreground;
WORD attr; WORD attr;
@@ -217,6 +218,7 @@ struct console_t {
DWORD out_cmode; DWORD out_cmode;
long color24; long color24;
} console = { } console = {
FALSE,
(FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_RED), /* background */ (FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_RED), /* background */
(FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_RED), /* foreground */ (FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_RED), /* foreground */
0, /* attr */ 0, /* attr */
@@ -718,6 +720,9 @@ back_buffer_flip(void)
DWORD reserved; DWORD reserved;
unsigned do_anything, did_anything; unsigned do_anything, did_anything;
if (!console.is_ready)
return;
emit_hide_cursor(); emit_hide_cursor();
for (pos.Y = 0; pos.Y < console.height; pos.Y++) { for (pos.Y = 0; pos.Y < console.height; pos.Y++) {
for (pos.X = 0; pos.X < console.width; pos.X++) { for (pos.X = 0; pos.X < console.width; pos.X++) {
@@ -797,6 +802,9 @@ back_buffer_flip(void)
COORD pos; COORD pos;
DWORD unused; DWORD unused;
if (!console.is_ready)
return;
for (pos.Y = 0; pos.Y < console.height; pos.Y++) { for (pos.Y = 0; pos.Y < console.height; pos.Y++) {
for (pos.X = 0; pos.X < console.width; pos.X++) { for (pos.X = 0; pos.X < console.width; pos.X++) {
if (back->attribute != front->attribute) { if (back->attribute != front->attribute) {
@@ -2729,6 +2737,7 @@ void nethack_enter_consoletty(void)
init_custom_colors(); init_custom_colors();
#endif /* VIRTUAL_TERMINAL_SEQUENCES */ #endif /* VIRTUAL_TERMINAL_SEQUENCES */
console.current_nhcolor = NO_COLOR; console.current_nhcolor = NO_COLOR;
console.is_ready = TRUE;
} }
#endif /* TTY_GRAPHICS */ #endif /* TTY_GRAPHICS */