]> git.unchartedbackwaters.co.uk Git - francis/winuae.git/commitdiff
Automatic scale/blanking detection updates
authorToni Wilen <twilen@winuae.net>
Sun, 15 Mar 2026 18:33:06 +0000 (20:33 +0200)
committerToni Wilen <twilen@winuae.net>
Sun, 15 Mar 2026 18:33:06 +0000 (20:33 +0200)
drawing.cpp

index 4cdab093057925fdf8be7b372d593836b6fa6b9c..27a565b5ea718d77278822f01f4fcd090389c333 100644 (file)
@@ -50,8 +50,9 @@ extern int multithread_enabled;
 #define BLANK_COLOR_EDGE 0x000000
 
 #if 0
-#define DEBUG_TVOVERSCAN_H_GRAYSCALE 0x22
-#define DEBUG_TVOVERSCAN_V_GRAYSCALE 0x44
+#define DEBUG_TVOVERSCAN_H_GRAYSCALE_LEFT 0x22
+#define DEBUG_TVOVERSCAN_H_GRAYSCALE_RIGHT 0x44
+#define DEBUG_TVOVERSCAN_V_GRAYSCALE 0x88
 #define DEBUG_LOL_COLOR 0x006600
 #else
 #define DEBUG_TVOVERSCAN_H_GRAYSCALE_LEFT 0x0
@@ -441,7 +442,6 @@ static int denise_strlong_lores, denise_strlong_hd;
 static bool denise_strlong_unalign, strlong_emulation;
 static int denise_phbstrt, denise_phbstop, denise_phbstrt_lores, denise_phbstop_lores;
 static int linear_denise_vbstrt, linear_denise_vbstop;
-static int linear_denise_hbstrt, linear_denise_hbstop;
 static int linear_denise_frame_hbstrt, linear_denise_frame_hbstop;
 static int linear_denise_frame_hbstrt_tmp, linear_denise_frame_hbstop_tmp;
 static int linear_denise_frame_hbstrt_sel, linear_denise_frame_hbstop_sel;
@@ -1051,7 +1051,7 @@ int get_custom_limits(int *pw, int *ph, int *pdx, int *pdy, int *prealh, int *hr
        if (w == 0 || h == 0)
                return 0;
 
-#if 1
+#if 0
        if (doublescan <= 0 && programmedmode != 1) {
                if ((w >> currprefs.gfx_resolution) < MIN_DISPLAY_W) {
                        dx += (w - (MIN_DISPLAY_W << currprefs.gfx_resolution)) / 2;
@@ -4773,7 +4773,6 @@ static void do_hbstrt(int cnt)
                }
                do_hb();
                hstart_new();
-               linear_denise_hbstrt = internal_pixel_cnt;
                // hstop was not matched?
                if (!diwlastword_total && bpl1dat_trigger_offset >= 0) {
                        diwlastword_total = internal_pixel_cnt;
@@ -4800,7 +4799,6 @@ static void do_hbstop(int cnt)
                        delayed_vblank_ecs = 0;
                }
                do_hb();
-               linear_denise_hbstop = internal_pixel_cnt;
        }
 #ifdef DEBUGGER
        if (debug_dma) {
@@ -4822,7 +4820,6 @@ static void do_phbstrt_aga(int cnt)
                        denise_blank_active = denise_blank_enabled ? denise_blank_active2 : false;
                }
                hstart_new();
-               linear_denise_hbstrt = internal_pixel_cnt;
                do_exthblankon_aga();
                copy_strlong();
                denise_sprite_blank_active = denise_blank_active;
@@ -4842,7 +4839,6 @@ static void do_phbstop_aga(int cnt)
                }
                do_exthblankon_aga();
                denise_sprite_blank_active = denise_blank_active;
-               linear_denise_hbstop = internal_pixel_cnt;
        }
 }
 
@@ -4861,7 +4857,6 @@ static void do_phbstrt_ecs(int cnt)
                }
                hstart_new();
                do_exthblankon_ecs();
-               linear_denise_hbstrt = internal_pixel_cnt;
        }
 }
 static void do_phbstop_ecs(int cnt)
@@ -4878,7 +4873,6 @@ static void do_phbstop_ecs(int cnt)
                        denise_sprite_blank_active = denise_blank_active;
                }
                do_exthblankon_ecs();
-               linear_denise_hbstop = internal_pixel_cnt;
        }
 }
 
@@ -5882,9 +5876,9 @@ static void edgeblanking(int hbstrt_offset, int hbstop_offset, int internal_pixe
        int hbstrt_offset2 = (hbstrt_offset - internal_pixel_start_cnt) >> rshift;
        int hbstop_offset2 = (hbstop_offset - internal_pixel_start_cnt) >> rshift;
        uae_u32 *hbstrt_ptr1 = buf1t && hbstrt_offset2 >= 0 ? buf1t + hbstrt_offset2 : NULL;
-       uae_u32 *hbstop_ptr1 = buf1t && hbstop_offset2 >= 0 ? buf1t + hbstop_offset2 : NULL;
+       uae_u32 *hbstop_ptr1 = buf1t && hbstop_offset2 >= 0 ? buf1t - hbstop_offset2 : NULL;
        uae_u32 *hbstrt_ptr2 = buf2t && hbstrt_offset2 >= 0 ? buf2t + hbstrt_offset2 : NULL;
-       uae_u32 *hbstop_ptr2 = buf2t && hbstop_offset2 >= 0 ? buf2t + hbstop_offset2 : NULL;
+       uae_u32 *hbstop_ptr2 = buf2t && hbstop_offset2 >= 0 ? buf2t - hbstop_offset2 : NULL;
        // blank last pixel row if normal overscan mode, it might have NTSC artifacts
        if (strlong_seen && hbstrt_ptr1) {
                int add = 1 << hresolution;
@@ -6050,8 +6044,6 @@ static void draw_denise_line(int gfx_ypos, enum nln_how how, uae_u32 linecnt, in
                bpl1dat_trigger_offset = -1;
                internal_pixel_cnt = 0;
                internal_pixel_start_cnt = 0;
-               linear_denise_hbstrt = -1;
-               linear_denise_hbstop = -1;
 
                buf1t = buf1;
                buf2t = buf2;
@@ -6213,8 +6205,8 @@ static void draw_denise_line(int gfx_ypos, enum nln_how how, uae_u32 linecnt, in
 
        // detect horizontal blanking
        if (!denise_vblank_active) {
-               linear_denise_frame_hbstrt = linear_denise_hbstrt;
-               linear_denise_frame_hbstop = linear_denise_hbstop;
+               linear_denise_frame_hbstrt = hbstrt_offset;
+               linear_denise_frame_hbstop = hbstop_offset;
                //write_log("%d %d\n", linear_denise_frame_hbstrt, linear_denise_frame_hbstop);
 
                if (linear_denise_frame_hbstrt == linear_denise_frame_hbstrt_tmp && linear_denise_frame_hbstop == linear_denise_frame_hbstop_tmp) {
@@ -7161,6 +7153,10 @@ static void tvadjust(int *hbstrt_offset, int *hbstop_offset, struct linestate *l
                if (hbstrt_offset && ww2 > 0) {
                        *hbstrt_offset -= ww2;
                }
+               int hbstop_left = *hbstop_offset - ls->internal_pixel_start_cnt;
+               if (hbstop_left > 0) {
+                       ww1 -= hbstop_left;
+               }
                if (hbstop_offset && ww1 > 0) {
                        *hbstop_offset += ww1;
                }