From: DeaDDooMER Date: Thu, 2 Apr 2020 06:14:10 +0000 (+0400) Subject: software: fix crashes on buffer resize X-Git-Url: http://deadsoftware.ru/gitweb?a=commitdiff_plain;h=ce966b1616662fdba1adac371205cd93ee741588;p=flatwaifu.git software: fix crashes on buffer resize --- diff --git a/src/soft/render.c b/src/soft/render.c index 74a3c0f..bda8727 100644 --- a/src/soft/render.c +++ b/src/soft/render.c @@ -1361,7 +1361,7 @@ void R_set_videomode (int w, int h, int fullscreen) { } } else { Y_get_videomode(&SCRW, &SCRH); - Y_get_buffer(&buffer, &buf_w, &buf_h, &pitch); + V_update_buffer(); R_setgamma(gammaa); } } @@ -1370,7 +1370,7 @@ void R_toggle_fullscreen (void) { Y_set_fullscreen(!Y_get_fullscreen()); fullscreen = Y_get_fullscreen(); Y_get_videomode(&SCRW, &SCRH); - Y_get_buffer(&buffer, &buf_w, &buf_h, &pitch); + V_update_buffer(); R_setgamma(gammaa); } diff --git a/src/soft/vga.c b/src/soft/vga.c index ce83101..a747a31 100644 --- a/src/soft/vga.c +++ b/src/soft/vga.c @@ -64,6 +64,11 @@ vgaimg *V_loadvgaimg (char *name) { return V_getvgaimg(F_getresid(name)); } +void V_update_buffer (void) { + Y_get_buffer(&buffer, &buf_w, &buf_h, &pitch); + V_setrect(0, 0, buf_w, buf_h); +} + static void draw_rect (int x, int y, int w, int h, int c) { int i; int x0 = max(x, cx1); @@ -77,6 +82,8 @@ static void draw_rect (int x, int y, int w, int h, int c) { } void V_setrect (short x, short w, short y, short h) { + assert(w >= 0); + assert(h >= 0); cx1 = max(x, 0); cx2 = min(x + w - 1, buf_w - 1); cy1 = max(y, 0); diff --git a/src/soft/vga.h b/src/soft/vga.h index dc91d2b..eb07702 100644 --- a/src/soft/vga.h +++ b/src/soft/vga.h @@ -103,6 +103,7 @@ void V_remap (vgaimg *i, colormap m); void V_remap_rect (int x, int y, int w, int h, byte *cmap); +void V_update_buffer (void); void V_rotspr (int x, int y, vgaimg* i, int d); void V_center (int f); void V_offset (int ox, int oy);