]> git.unchartedbackwaters.co.uk Git - francis/winuae.git/commitdiff
Reimplement resolution autoswitch.
authorToni Wilen <twilen@winuae.net>
Sun, 4 May 2025 10:14:44 +0000 (13:14 +0300)
committerToni Wilen <twilen@winuae.net>
Sun, 4 May 2025 10:14:44 +0000 (13:14 +0300)
custom.cpp
drawing.cpp
include/drawing.h

index 3217b9071ea8ac84966cb595050cdaf5ec8be90f..c51461abf02a1f5e54e480ee2dcd864ab716e72a 100644 (file)
@@ -4594,8 +4594,8 @@ static void maybe_process_pull_audio(void)
 static bool crender_screen(int monid, int mode, bool immediate)
 {
        if (currprefs.gfx_vresolution && interlace_seen > 0 && currprefs.gfx_iscanlines == 0) {
-               // if non-fields interlace mode: render only every other frame
-               if (vsync_counter & 1) {
+               // if non-fields interlace mode: render only complete frames
+               if (!lof_display) {
                        return true;
                }
        }
@@ -5524,6 +5524,9 @@ static void hsync_handler_pre(bool onvsync)
                        }
                }
 
+               if (GET_PLANES(bplcon0)) {
+                       notice_resolution_seen(GET_RES_AGNUS(bplcon0), interlace_seen != 0);
+               }
        }
 
        devices_hsync();
index d57acd72f9c53409d5d8659a7136cc556cefc437..eeb847cbad0d89b0c00877e781dfe2a816177d5b 100644 (file)
@@ -851,6 +851,8 @@ void store_custom_limits(int w, int h, int x, int y)
 
 int get_custom_limits(int *pw, int *ph, int *pdx, int *pdy, int *prealh, int *hres, int *vres)
 {
+       static int interlace_count;
+       static int interlace_lof[2];
        struct vidbuf_description *vidinfo = &adisplays[0].gfxvidinfo;
        int w, h, dx, dy, y1, y2, dbl1, dbl2;
        int ret = 0;
@@ -882,17 +884,27 @@ int get_custom_limits(int *pw, int *ph, int *pdx, int *pdy, int *prealh, int *hr
                ret = -1;
 
        if (interlace_seen) {
-               static int interlace_count;
-               // interlace = only use long frames
-               if (lof_display && (interlace_count & 1) == 0)
-                       interlace_count++;
-               if (!lof_display && (interlace_count & 1) != 0)
+               for (;;) {
+                       // if more than 1 long or short frames only: accept it, we may have double (non field) mode.
+                       if (interlace_lof[0] >= 2 || interlace_lof[1] >= 2) {
+                               break;
+                       }
+                       // wait for long frame
+                       if (interlace_lof[0] && interlace_lof[1]) {
+                               if (!lof_display) {
+                                       return ret;
+                               }
+                       }
                        interlace_count++;
-               if (interlace_count < 3)
-                       return ret;
-               if (!lof_display)
-                       return ret;
+                       interlace_lof[lof_display]++;
+                       if (interlace_count < 3) {
+                               return ret;
+                       }
+               }
+       } else {
                interlace_count = 0;
+               interlace_lof[0] = 0;
+               interlace_lof[1] = 0;
        }
 
        int skip = denise_hdelay << (RES_MAX + 1);
@@ -1460,6 +1472,20 @@ static void center_image (void)
 
 static int frame_res_cnt;
 static int autoswitch_old_resolution;
+
+void notice_resolution_seen(int res, bool lace)
+{
+       if (res > frame_res) {
+               frame_res = res;
+       }
+       if (res > 0) {
+               can_use_lores = 0;
+       }
+       if (!frame_res_lace && lace) {
+               frame_res_lace = lace;
+       }
+}
+
 static void init_drawing_frame(void)
 {
        struct amigadisplay *ad = &adisplays[0];
@@ -1470,8 +1496,9 @@ static void init_drawing_frame(void)
        int largest_count = 0;
        int largest_count_res = 0;
        for (int i = 0; i <= RES_MAX; i++) {
-               if (resolution_count[i])
+               if (resolution_count[i]) {
                        largest_res = i;
+               }
                if (resolution_count[i] >= largest_count) {
                        largest_count = resolution_count[i];
                        largest_count_res = i;
@@ -5703,7 +5730,9 @@ static void draw_denise_line(int gfx_ypos, enum nln_how how, uae_u32 linecnt, in
                ls->lol = lol;
        }
 
-       resolution_count[denise_res]++;
+       if (!line_is_blanked && denise_planes > 0) {
+               resolution_count[denise_res]++;
+       }
        lines_count++;
 }
 
@@ -6557,6 +6586,11 @@ void draw_denise_border_line_fast(int gfx_ypos, enum nln_how how, struct linesta
 
        get_line(gfx_ypos, how);
 
+       if (!buf1 && !ls->blankedline && denise_planes > 0) {
+               resolution_count[denise_res]++;
+       }
+       lines_count++;
+
        if (!buf1) {
                return;
        }
@@ -6631,6 +6665,12 @@ void draw_denise_bitplane_line_fast(int gfx_ypos, enum nln_how how, struct lines
 
        get_line(gfx_ypos, how);
 
+       if (!buf1 && !ls->blankedline && denise_planes > 0) {
+               resolution_count[denise_res]++;
+       }
+       lines_count++;
+
+
        if (!buf1) {
                return;
        }
index b550c3db307af10eb7ea4717c2c2c0f22bbd1de8..fd8849129bd97b8bd2927f527025d44827e29d29 100644 (file)
@@ -124,13 +124,14 @@ extern void set_custom_limits(int w, int h, int dx, int dy, bool blank);
 extern void check_custom_limits(void);
 extern void get_custom_topedge(int *x, int *y, bool max);
 extern void get_custom_raw_limits(int *pw, int *ph, int *pdx, int *pdy);
-void get_custom_mouse_limits(int *pw, int *ph, int *pdx, int *pdy, int dbl);
+extern void get_custom_mouse_limits(int *pw, int *ph, int *pdx, int *pdy, int dbl);
 extern void putpixel(uae_u8 *buf, uae_u8 *genlockbuf, int x, xcolnr c8);
 extern void allocvidbuffer(int monid, struct vidbuffer *buf, int width, int height, int depth);
 extern void freevidbuffer(int monid, struct vidbuffer *buf);
 extern void check_prefs_picasso(void);
 extern int get_vertical_visible_height(bool);
 extern void get_mode_blanking_limits(int *phbstop, int *phbstrt, int *pvbstop, int *pvbstrt);
+extern void notice_resolution_seen(int res, bool lace);
 
 /* Finally, stuff that shouldn't really be shared.  */