From 37c4aa74c9fe77c0cd9a52eda00713940b478834 Mon Sep 17 00:00:00 2001 From: Toni Wilen Date: Thu, 16 Jan 2025 20:57:56 +0200 Subject: [PATCH] Reimplement interlace scandoubler --- custom.cpp | 14 ++++++++------ drawing.cpp | 8 ++++++-- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/custom.cpp b/custom.cpp index 8b99e24a..88dba25d 100644 --- a/custom.cpp +++ b/custom.cpp @@ -119,8 +119,8 @@ static uae_u32 custom_state_flags; static int not_safe_mode; static bool dmal_next; -#define MAX_SCANDOUBLED_LINES 1000 -static uae_u32 scandoubled_bpl_ptr[MAX_SCANDOUBLED_LINES][8][2]; +#define MAX_SCANDOUBLED_LINES 1200 +static uae_u32 scandoubled_bpl_ptr[MAX_SCANDOUBLED_LINES][2][MAX_PLANES]; static evt_t blitter_dma_change_cycle, copper_dma_change_cycle, sprite_dma_change_cycle_on, sprite_dma_change_cycle_off; @@ -9637,7 +9637,7 @@ static void decide_bpl(int hpos) ddf_enable_on = 1; if (currprefs.gfx_scandoubler && vpos < MAX_SCANDOUBLED_LINES) { for (int i = 0; i < MAX_PLANES; i++) { - scandoubled_bpl_ptr[vpos][i][lof_store] = bplpt[i]; + scandoubled_bpl_ptr[vpos][lof_store][i] = bplpt[i]; } } } @@ -9795,7 +9795,7 @@ static void decide_bpl(int hpos) ddfstrt_match = true; if (currprefs.gfx_scandoubler && vpos < MAX_SCANDOUBLED_LINES) { for (int i = 0; i < MAX_PLANES; i++) { - scandoubled_bpl_ptr[vpos][i][lof_store] = bplpt[i]; + scandoubled_bpl_ptr[vpos][lof_store][i] = bplpt[i]; } } } else { @@ -10237,8 +10237,8 @@ static void do_scandouble(void) if (rd->rga >= 0x110 && rd->rga < 0x120) { int plane = (rd->rga - 0x110) / 2; if (vp < MAX_SCANDOUBLED_LINES) { - uaecptr l1 = scandoubled_bpl_ptr[vp][plane][l]; - uaecptr l2 = scandoubled_bpl_ptr[vp][plane][l ^ 1]; + uaecptr l1 = scandoubled_bpl_ptr[vp][l][plane]; + uaecptr l2 = scandoubled_bpl_ptr[vp][l ^ 1][plane]; rga.pv = rd->pt - l1 + l2; if (fetchmode_fmode_bpl == 3) { rd->v64 = fetch64(&rga); @@ -10485,7 +10485,9 @@ static void decide_hsync(void) do_scandouble(); denise_restore_registers(); lof_display ^= 1; + scandoubled_line = 1; draw_line(linear_hpos); + scandoubled_line = 0; lof_display ^= 1; } else { draw_line(linear_hpos); diff --git a/drawing.cpp b/drawing.cpp index 6c0fc6ce..1d530009 100644 --- a/drawing.cpp +++ b/drawing.cpp @@ -42,6 +42,8 @@ #define AUTOSCALE_SPRITES 1 #define LOL_SHIFT_COLORS 0 +int scandoubled_line; + struct amigadisplay adisplays[MAX_AMIGADISPLAYS]; typedef enum @@ -4579,8 +4581,10 @@ static void matchsprites_aga(int cnt) } static uae_u16 s_bplcon0, s_bplcon1, s_bplcon2, s_bplcon3, s_bplcon4, s_fmode; +static int denise_hcounter_s; void denise_store_registers(void) { + denise_hcounter_s = denise_hcounter; s_bplcon0 = bplcon0_denise; s_bplcon1 = bplcon1_denise; s_bplcon2 = bplcon2_denise; @@ -4590,6 +4594,7 @@ void denise_store_registers(void) } void denise_restore_registers(void) { + denise_hcounter = denise_hcounter_s; expand_bplcon0(s_bplcon0); expand_bplcon1(s_bplcon1); expand_bplcon2(s_bplcon2); @@ -4798,7 +4803,7 @@ static void get_line(int gfx_ypos, enum nln_how how) } // clear lines if mode height is now smaller than previously - if (gfx_ypos >= 0 && gfx_ypos < prevline) { + if (gfx_ypos >= 0 && gfx_ypos < prevline && !scandoubled_line) { struct vidbuf_description *vidinfo = &adisplays[0].gfxvidinfo; struct vidbuffer *vb = &vidinfo->drawbuffer; if (prevline > vb->inheight) { @@ -4927,7 +4932,6 @@ void draw_denise_line(int gfx_ypos, enum nln_how how, uae_u32 linecnt, int start get_line(gfx_ypos, how); hbstrt_ptr1 = NULL; - if (denise_pixtotal_max == -0x7fffffff || ((linear_vpos >= denise_vblank_extra_vbstop || linear_vpos < denise_vblank_extra_vbstrt) && currprefs.gfx_overscanmode < OVERSCANMODE_ULTRA)) { // don't draw vertical blanking if not ultra extreme overscan -- 2.47.3