From a2f8f23152301a3d346ffa1df8e685b970396bbb Mon Sep 17 00:00:00 2001 From: Nick Briggs Date: Mon, 8 Nov 2021 18:16:14 -0800 Subject: [PATCH] Keep damage notification boundaries within the current screen On startup, bitblt calls may be made for the original screen size and if the new screen size is smaller than that, we must ensure that damage notifications are contained within the new screen. Move definition of min() so we can use it in sdl_notify_damage() --- src/sdl.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/sdl.c b/src/sdl.c index 2d9ff06..5e5fe16 100644 --- a/src/sdl.c +++ b/src/sdl.c @@ -199,6 +199,12 @@ void DoRing() { if (*KEYBUFFERING68k == NIL) *KEYBUFFERING68k = ATOM_T; } +static int min(int a, int b) { + if(a < b) + return a; + return b; +} + static int should_update_texture = 0; static int min_x = 0; @@ -211,9 +217,9 @@ void sdl_notify_damage(int x, int y, int w, int h) { if(y < min_y) min_y = y; if(x + w > max_x) - max_x = x + w; + max_x = min(x + w, sdl_displaywidth - 1); if(y + h > max_y) - max_y = y + h; + max_y = min(y + h, sdl_displayheight - 1); should_update_texture = 1; } @@ -388,11 +394,6 @@ static void sdl_update_viewport(int width, int height) { SDL_RenderSetViewport(sdl_renderer, &r); printf("new viewport: %d / %d\n", w, h); } -static int min(int a, int b) { - if(a < b) - return a; - return b; -} static int last_draw = 0; static int last_keystate[512] = { 0 }; /* void handle_keyboard() { */