From: Toni Wilen Date: Sat, 4 May 2024 16:53:42 +0000 (+0300) Subject: Fix incomplete NTSC fix. X-Git-Tag: 5300~16 X-Git-Url: https://git.unchartedbackwaters.co.uk/w/?a=commitdiff_plain;h=dbfb0c8cea6d44b5d0d8f342c1c2158b801ce1f1;p=francis%2Fwinuae.git Fix incomplete NTSC fix. --- diff --git a/custom.cpp b/custom.cpp index fe426b2b..c2ec739b 100644 --- a/custom.cpp +++ b/custom.cpp @@ -136,6 +136,7 @@ int lof_display; // what display device thinks int scandoubled_line; static bool lof_lastline, lof_prev_lastline; static int lol, lol_prev; +static bool linetoggle; static int next_lineno; static int linear_vpos; static enum nln_how nextline_how; @@ -1931,6 +1932,7 @@ static uae_s8 estimated_cycles_empty[MAX_CHIPSETSLOTS + MAX_CHIPSETSLOTS_EXTRA]; static int estimate_cycles_empty_index = -1; static uae_u16 estimated_bplcon0, estimated_fm, estimated_plfstrt, estimated_plfstop; static uae_s8 *estimated_cycles = estimated_cycles_empty; +static uae_s8 *estimated_cycles_next = estimated_cycles_empty; static bool estimated_empty; static int estimated_maxhpos[2]; @@ -1948,16 +1950,41 @@ static void end_estimate_last_fetch_cycle(int hpos) } if (estimated_cycles_empty != estimated_cycles) { estimated_cycles = estimated_cycles_empty; + estimated_cycles_next = estimated_cycles_empty; estimate_cycles_empty_index = hpos; - uae_s8 *est = maxhposeven ? estimated_cycles_buf1 : estimated_cycles_buf0; - if (maxhpos == estimated_maxhpos[0]) { - est = estimated_cycles_buf0; - } else if (maxhpos == estimated_maxhpos[1]) { - est = estimated_cycles_buf1; - } - for (int i = 0; i < RGA_PIPELINE_ADJUST; i++) { - int pos = (hpos + i) % maxhpos; - estimated_cycles_empty[pos] = est[pos]; + if (linetoggle) { + uae_s8 *est = maxhposeven ? estimated_cycles_buf1 : estimated_cycles_buf0; + uae_s8 *est_n = maxhposeven ? estimated_cycles_buf0 : estimated_cycles_buf1; + if (maxhpos == estimated_maxhpos[0]) { + est = estimated_cycles_buf0; + est_n = estimated_cycles_buf1; + } else if (maxhpos == estimated_maxhpos[1]) { + est = estimated_cycles_buf1; + est_n = estimated_cycles_buf0; + } + for (int i = 0; i < RGA_PIPELINE_ADJUST; i++) { + int pos = hpos + i; + if (pos >= maxhpos) { + pos -= maxhpos; + estimated_cycles_empty[pos] = est_n[pos]; + } else { + estimated_cycles_empty[pos] = est[pos]; + } + } + } else { + uae_s8 *est = maxhposeven ? estimated_cycles_buf1 : estimated_cycles_buf0; + if (maxhpos == estimated_maxhpos[0]) { + est = estimated_cycles_buf0; + } else if (maxhpos == estimated_maxhpos[1]) { + est = estimated_cycles_buf1; + } + for (int i = 0; i < RGA_PIPELINE_ADJUST; i++) { + int pos = hpos + i; + if (pos >= maxhpos) { + pos -= maxhpos; + } + estimated_cycles_empty[pos] = est[pos]; + } } } #else @@ -1983,13 +2010,28 @@ static void estimate_last_fetch_cycle(int hpos) #if OPTIMIZED_ESTIMATE if (estimated_bplcon0 == bplcon0 && bpl_hstart == hpos && estimated_plfstrt == bpl_hstart && estimated_plfstop == plfstop && estimated_fm == fetchmode) { - if (maxhpos == estimated_maxhpos[0]) { - estimated_cycles = estimated_cycles_buf0; - return; - } - if (maxhpos == estimated_maxhpos[1]) { - estimated_cycles = estimated_cycles_buf1; - return; + if (linetoggle) { + if (maxhpos == estimated_maxhpos[0]) { + estimated_cycles = estimated_cycles_buf0; + estimated_cycles_next = estimated_cycles_buf1; + return; + } + if (maxhpos == estimated_maxhpos[1]) { + estimated_cycles = estimated_cycles_buf1; + estimated_cycles_next = estimated_cycles_buf0; + return; + } + } else { + if (maxhpos == estimated_maxhpos[0]) { + estimated_cycles = estimated_cycles_buf0; + estimated_cycles_next = estimated_cycles; + return; + } + if (maxhpos == estimated_maxhpos[1]) { + estimated_cycles = estimated_cycles_buf1; + estimated_cycles_next = estimated_cycles; + return; + } } } else { estimated_maxhpos[0] = estimated_maxhpos[1] = -1; @@ -2055,8 +2097,14 @@ static void estimate_last_fetch_cycle(int hpos) #if OPTIMIZED_ESTIMATE estimated_cycles = maxhposeven ? estimated_cycles_buf1 : estimated_cycles_buf0; + if (linetoggle) { + estimated_cycles_next = maxhposeven ? estimated_cycles_buf0 : estimated_cycles_buf1; + } else { + estimated_cycles_next = estimated_cycles; + } #else estimated_cycles = estimated_cycles_buf0; + estimated_cycles_next = estimated_cycles; #endif uae_s8 *ecycs = estimated_cycles; // bitplane DMA end can wrap around, even in non-overrun cases @@ -2083,8 +2131,8 @@ static void estimate_last_fetch_cycle(int hpos) start_pos++; if (start_pos >= maxhpos) { start_pos = 0; - if (islinetoggle()) { - ecycs = maxhposeven ? estimated_cycles_buf0 : estimated_cycles_buf1; + if (linetoggle) { + ecycs = estimated_cycles_next; } } if (start_pos == REFRESH_FIRST_HPOS) { @@ -2397,7 +2445,7 @@ static void set_delay_lastcycle(void) { delay_lastcycle[0] = (((maxhpos + 0) * 2) + 2) << LORES_TO_SHRES_SHIFT; delay_lastcycle[1] = delay_lastcycle[0]; - if (islinetoggle()) { + if (linetoggle) { delay_lastcycle[1] += 1 << LORES_TO_SHRES_SHIFT; } delay_hsynccycle = (((maxhpos + hsyncstartpos_start_cycles) * 2) - DDF_OFFSET) << LORES_TO_SHRES_SHIFT; @@ -6592,7 +6640,7 @@ void compute_vsynctime(void) } vsynctimebase_orig = vsynctimebase; - if (islinetoggle()) { + if (linetoggle) { shpos += 0.5f; } if (interlace_seen) { @@ -7114,7 +7162,7 @@ void compute_framesync(void) compute_vsynctime(); - hblank_hz = (currprefs.ntscmode ? CHIPSET_CLOCK_NTSC : CHIPSET_CLOCK_PAL) / (maxhpos + (islinetoggle() ? 0.5f : 0.0f)); + hblank_hz = (currprefs.ntscmode ? CHIPSET_CLOCK_NTSC : CHIPSET_CLOCK_PAL) / (maxhpos + (linetoggle ? 0.5f : 0.0f)); write_log(_T("%s mode%s%s V=%.4fHz H=%0.4fHz (%dx%d+%d) IDX=%d (%s) D=%d RTG=%d/%d\n"), isntsc ? _T("NTSC") : _T("PAL"), @@ -7957,7 +8005,7 @@ static uae_u16 VPOSR(void) lofr = lofr ? 0 : 1; } } - if (islinetoggle()) { + if (linetoggle) { lolr = lolr ? 0 : 1; } } @@ -10332,9 +10380,13 @@ bool bitplane_dma_access(int hpos, int coffset) hpos += coffset; if (hpos >= maxhpos) { hpos -= maxhpos; - } - if (estimated_cycles[hpos] > 0) { - return true; + if (estimated_cycles_next[hpos] > 0) { + return true; + } + } else { + if (estimated_cycles[hpos] > 0) { + return true; + } } } return false; @@ -13240,8 +13292,18 @@ static void hsync_handler_pre(bool onvsync) lol_prev = lol; if (islinetoggle()) { lol = lol ? 0 : 1; + estimated_cycles_next = estimated_cycles; + if (maxhpos == estimated_maxhpos[0]) { + estimated_cycles = estimated_cycles_buf0; + estimated_cycles_next = estimated_cycles_buf1; + } else if (maxhpos == estimated_maxhpos[1]) { + estimated_cycles = estimated_cycles_buf1; + estimated_cycles_next = estimated_cycles_buf0; + } + linetoggle = true; } else { lol = 0; + linetoggle = false; } memset(cycle_line_slot, 0, maxhposm1 + 1); @@ -14016,7 +14078,7 @@ static void hsync_handler_post(bool onvsync) if (cia_hsync < maxhpos) { int newcount; CIAA_tod_handler(cia_hsync); - newcount = (int)((vblank_hz * (2 * maxvpos + (interlace_seen ? 1 : 0)) * (2 * maxhpos + (islinetoggle () ? 1 : 0))) / ((currprefs.cs_ciaatod == 2 ? 60 : 50) * 4)); + newcount = (int)((vblank_hz * (2 * maxvpos + (interlace_seen ? 1 : 0)) * (2 * maxhpos + (linetoggle ? 1 : 0))) / ((currprefs.cs_ciaatod == 2 ? 60 : 50) * 4)); cia_hsync += newcount; } else { cia_hsync -= maxhpos;