]> git.unchartedbackwaters.co.uk Git - francis/winuae.git/commitdiff
Calculate number of visible lines for filter use, recalculate hblank centering if...
authorToni Wilen <twilen@winuae.net>
Sun, 27 Jul 2025 16:34:32 +0000 (19:34 +0300)
committerToni Wilen <twilen@winuae.net>
Sun, 27 Jul 2025 16:34:32 +0000 (19:34 +0300)
custom.cpp
drawing.cpp
include/drawing.h

index fa81f95c3565b642404aca3eea75ce8f5fa552e7..e557951276eeec0df4d18e37273c0c5d8fe3f260 100644 (file)
@@ -395,6 +395,7 @@ static int linear_vpos_vsync;
 static int linear_display_vpos;
 int current_linear_vpos, current_linear_hpos;
 int current_linear_vpos_nom, current_linear_hpos_short;
+static int linear_vpos_visible, current_linear_vpos_visible;
 static int current_linear_vpos_temp, current_linear_hpos_temp;
 static int current_linear_temp_change;
 static bool display_redraw;
@@ -419,6 +420,7 @@ int display_reset;
 static bool initial_frame;
 static int custom_fastmode_exit;
 static evt_t last_vsync_evt, last_hsync_evt;
+static bool aexthblanken;
 #if 0
 static int custom_fastmode_bplextendmask;
 #endif
@@ -610,6 +612,7 @@ static uae_u16 ddfstrt_saved, ddfstop_saved, diwhigh_saved;
 static uae_u32 saved_color_regs_aga[32];
 static struct color_entry agnus_colors;
 static int varsync_changed, varsync_maybe_changed[2];
+static int lines_after_beamcon_change;
 static bool programmed_register_accessed_v, programmed_register_accessed_h;
 static bool need_vdiw_check;
 static int varhblank_lines, varhblank_val[2];
@@ -1735,6 +1738,7 @@ static void init_beamcon0(void)
 
        doublescan = 0;
        programmedmode = 0;
+       lines_after_beamcon_change = 5;
 
        isntsc = (beamcon0 & BEAMCON0_PAL) ? 0 : 1;
        islace = (interlace_seen) ? 1 : 0;
@@ -1787,7 +1791,7 @@ static void init_beamcon0(void)
                if (currprefs.gfx_overscanmode >= OVERSCANMODE_ULTRA) {
                        display_hstart_cyclewait_end = 0;
                } else {
-                       if (exthblanken && !(beamcon0 & BEAMCON0_VARBEAMEN)) {
+                       if (aexthblanken && !(beamcon0 & BEAMCON0_VARBEAMEN)) {
                                int hp2 = maxhpos * 2;
                                int hbstrtx, hbstopx;
                                int hb = 1;
@@ -1884,7 +1888,8 @@ static void init_beamcon0(void)
                } else {
                        int hp2 = maxhpos * 2;
                        int hbstrtx, hbstopx;
-                       if (exthblanken) {
+
+                       if (aexthblanken) {
 
                                hb = 1;
                                hbstrtx = (hbstrt & 0xff) * 2;
@@ -2165,6 +2170,7 @@ static void init_hz_reset(void)
        current_linear_hpos_temp = current_linear_hpos;
        current_linear_vpos_temp = current_linear_vpos;
        current_linear_temp_change = 0;
+       current_linear_vpos_visible = 0;
        init_hz();
 }
 
@@ -3497,10 +3503,22 @@ static void update_agnus_vb(void)
                agnus_vb_active = agnus_pvb;
                agnus_vb_active_end_line = agnus_pvb_end_line;
                agnus_vb_active_start_line = agnus_pvb_start_line;
+               if (agnus_pvb_start_line) {
+                       current_linear_vpos_visible = linear_vpos_visible;
+               }
+               if (agnus_pvb_end_line) {
+                       linear_vpos_visible = 1;
+               }
        } else {
                agnus_vb_active = agnus_vb == 1;
                agnus_vb_active_end_line = agnus_vb_end_line;
                agnus_vb_active_start_line = agnus_vb_start_line;
+               if (agnus_vb_start_line) {
+                       current_linear_vpos_visible = linear_vpos_visible;
+               }
+               if (agnus_vb_end_line) {
+                       linear_vpos_visible = 1;
+               }
        }
 }
 
@@ -3529,7 +3547,13 @@ static void BEAMCON0(uae_u16 v)
 
 static void check_exthblank(void)
 {
+       aexthblanken = (bplcon0 & 1) && (bplcon3 & 1) && ecs_denise;
        resetfulllinestate();
+       // Recalculate beamcon0 settings if exthblank was set after BEAMCON0 modification (hblank is used for programmed mode centering)
+       if (lines_after_beamcon_change > 0) {
+               init_beamcon0();
+               lines_after_beamcon_change = 0;
+       }
 }
 
 static void varsync(int reg, bool resync, int oldval)
@@ -5058,7 +5082,6 @@ static void vsync_display_render(void)
                vsyncmintimepre = read_processor_time();
 
                if (!custom_disabled) {
-                       start_draw_denise();
                        draw_denise_vsync_queue(display_redraw);
                        display_redraw = false;
                }
@@ -6513,6 +6536,9 @@ static void vsync_start_check(void)
                }
                displayreset_delayed >>= 1;
        }
+       if (lines_after_beamcon_change > 0) {
+               lines_after_beamcon_change--;
+       }
 }
 
 static bool uae_quit_check(void)
@@ -6696,6 +6722,7 @@ void custom_reset(bool hardreset, bool keyboardreset)
        maxvpos_display_vsync_next = false;
        programmed_register_accessed_h = false;
        programmed_register_accessed_v = false;
+       aexthblanken = false;
        denise_reset(false);
 
        agnus_hpos_next = -1;
@@ -11260,6 +11287,7 @@ static void custom_trigger_start_nosync(void)
 {
        linear_display_vpos = linear_vpos;
        linear_vpos++;
+       linear_vpos_visible++;
        if (linear_vpos >= maxvpos + lof_store) {
                vsync_nosync();
        }
@@ -11279,6 +11307,7 @@ static void custom_trigger_start(void)
        }
        linear_display_vpos = linear_vpos;
        linear_vpos++;
+       linear_vpos_visible++;
        draw_line_next_line = 0;
 
        linear_vpos_vsync++;
@@ -12735,7 +12764,7 @@ bool isvga(void)
 bool ispal(int *lines)
 {
        if (lines) {
-               *lines = current_linear_vpos_nom;
+               *lines = current_linear_vpos_visible;
        }
        if (programmedmode == 1) {
                return currprefs.ntscmode == 0;
index 0c0168367dbf52df0c1f20e954f5957a7fed5ebc..97b259ba84292ed172c891a8dbae0b00f072cd01 100644 (file)
@@ -353,7 +353,7 @@ int visible_left_border, visible_right_border;
 /* Pixels outside of visible_start and visible_stop are always black */
 static int visible_left_start, visible_right_stop;
 static int visible_top_start, visible_bottom_stop;
-bool exthblanken;
+static bool exthblanken;
 static int exthblank;
 static bool syncdebug;
 
@@ -5146,14 +5146,16 @@ void end_draw_denise(void)
        struct vidbuf_description *vidinfo = &adisplays[0].gfxvidinfo;
        struct vidbuffer *vb = &vidinfo->drawbuffer;
 
-       draw_denise_line_queue_flush();
+       if (thread_debug_lock) {
+               draw_denise_line_queue_flush();
 
-       thread_debug_lock = false;
+               thread_debug_lock = false;
 
-       unlockscr(vb, denise_y_start, denise_y_end);
+               unlockscr(vb, denise_y_start, denise_y_end);
 
-       if (vidinfo->outbuffer != vidinfo->inbuffer) {
-               vidinfo->inbuffer->locked = vidinfo->outbuffer->locked;
+               if (vidinfo->outbuffer != vidinfo->inbuffer) {
+                       vidinfo->inbuffer->locked = vidinfo->outbuffer->locked;
+               }
        }
 }
 
@@ -5346,6 +5348,7 @@ static void get_line(int gfx_ypos, enum nln_how how)
        struct vidbuffer *vb = vidinfo->inbuffer;
        int eraselines = 0;
        int yadjust = currprefs.gfx_overscanmode < OVERSCANMODE_ULTRA ? minfirstline_linear << currprefs.gfx_vresolution : 0;
+       uae_u8 *xstart, *xend;
        int xshift = 0;
 
        xlinebuffer = NULL;
@@ -7396,7 +7399,7 @@ void draw_denise_vsync_queue(int erase)
 {
        if (MULTITHREADED_DENISE) {
 
-               if (!waitqueue()) {
+               if (!waitqueue_nolock()) {
                        return;
                }
                struct denise_rga_queue *q = &rga_queue[rga_queue_write & DENISE_RGA_SLOT_CHUNKS_MASK];
index 0b67eb7f4d822ca798e34ed5f0d611257dfa7538..c13825169c27b255f4b0d4e5aadac478e3c91f33 100644 (file)
@@ -24,7 +24,6 @@ extern int visible_left_border, visible_right_border;
 extern int detected_screen_resolution;
 extern int hsync_end_left_border, hdisplay_left_border, denisehtotal;
 extern int vsync_startline;
-extern bool exthblanken;
 
 #define AMIGA_WIDTH_MAX (754 / 2)
 #define AMIGA_HEIGHT_MAX_PAL (576 / 2)