platform sdl, fix minor bug in window size handling
authorkub <derkub@gmail.com>
Sun, 12 Feb 2023 22:51:44 +0000 (22:51 +0000)
committerkub <derkub@gmail.com>
Sun, 12 Feb 2023 22:51:44 +0000 (22:51 +0000)
platform/common/plat_sdl.c
platform/linux/emu.c

index 24224ce..de4b054 100644 (file)
@@ -161,6 +161,14 @@ void plat_video_set_size(int w, int h)
        }
 }
 
+void plat_video_set_shadow(int w, int h)
+{
+       g_screen_width = w;
+       g_screen_height = h;
+       g_screen_ppitch = w;
+       g_screen_ptr = shadow_fb;
+}
+
 void plat_video_flip(void)
 {
        resize_buffers();
@@ -292,8 +300,13 @@ void plat_video_loop_prepare(void)
 
        // switch over to scaled output if available, but keep the aspect ratio
        if (plat_sdl_overlay || plat_sdl_gl_active) {
-               g_screen_width = (240 * g_menuscreen_w / g_menuscreen_h) & ~1;
-               g_screen_height = 240;
+               if (g_menuscreen_w * 240 >= g_menuscreen_h * 320) {
+                       g_screen_width = (240 * g_menuscreen_w/g_menuscreen_h) & ~1;
+                       g_screen_height= 240;
+               } else {
+                       g_screen_width = 320;
+                       g_screen_height= (320 * g_menuscreen_h/g_menuscreen_w) & ~1;
+               }
                g_screen_ppitch = g_screen_width;
                g_screen_ptr = shadow_fb;
        }
@@ -317,10 +330,12 @@ void plat_early_init(void)
 static void plat_sdl_resize(int w, int h)
 {
        // take over new settings
-       g_menuscreen_h = plat_sdl_screen->h;
-       g_menuscreen_w = plat_sdl_screen->w;
-       resize_buffers();
-       rendstatus_old = -1;
+       if (plat_sdl_screen->w != area.w || plat_sdl_screen->h != area.h) {
+               g_menuscreen_h = plat_sdl_screen->h;
+               g_menuscreen_w = plat_sdl_screen->w;
+               resize_buffers();
+               rendstatus_old = -1;
+       }
 }
 
 static void plat_sdl_quit(void)
index 746109b..f4a1c51 100644 (file)
@@ -442,7 +442,7 @@ void pemu_loop_prep(void)
 void pemu_loop_end(void)\r
 {\r
        /* do one more frame for menu bg */\r
-       plat_video_set_size(320, 240);\r
+       plat_video_set_shadow(320, 240);\r
        pemu_forced_frame(0, 1);\r
        g_menubg_src_w = g_screen_width;\r
        g_menubg_src_h = g_screen_height;\r