From: Toni Wilen Date: Fri, 10 Mar 2023 18:20:11 +0000 (+0200) Subject: VPOSW mid screen change updates X-Git-Tag: 5.0.0~122 X-Git-Url: https://git.unchartedbackwaters.co.uk/w/?a=commitdiff_plain;h=841cf7ec5647776f3ce11ab5cfcb7e37a0896ae7;p=francis%2Fwinuae.git VPOSW mid screen change updates --- diff --git a/custom.cpp b/custom.cpp index 42fd3e9f..553c47d4 100644 --- a/custom.cpp +++ b/custom.cpp @@ -7470,7 +7470,6 @@ static void VPOSW(uae_u16 v) lol = 0; } if (lof_changing) { - bool newlof = (v & 0x8000) != 0; return; } vpos &= 0x00ff; @@ -7492,6 +7491,7 @@ static void VPOSW(uae_u16 v) static void VHPOSW(uae_u16 v) { int oldvpos = vpos; + int newvpos = vpos; #if 0 if (M68K_GETPC < 0xf00000 || 1) write_log (_T("VHPOSW %04X PC=%08x\n"), v, M68K_GETPC); @@ -7512,22 +7512,32 @@ static void VHPOSW(uae_u16 v) int hnew = v & 0xff; int hdiff = hnew - hpos; if (copper_access && (hdiff & 1)) { - write_log("VHPOSW write with odd horizontal change. Possible copper confusion possible.\n"); + write_log("VHPOSW write %04X. New horizontal value is odd. Copper confusion possible.\n", v); } modify_eventcounter(-(hdiff - 2)); v >>= 8; - vpos &= 0xff00; - vpos |= v; - if (vpos != oldvpos) { - cia_adjust_eclock_phase((vpos - oldvpos) * maxhpos); + newvpos &= 0xff00; + newvpos |= v; + if (newvpos != oldvpos) { + cia_adjust_eclock_phase((newvpos - oldvpos) * maxhpos); vposw_change++; +#ifdef DEBUGGER + record_dma_hsync(hpos + 2); + if (debug_dma) { + int vp = vpos; + vpos = newvpos; + record_dma_hsync(maxhpos); + vpos = vp; + } +#endif } - if (vpos < oldvpos) { - vpos = oldvpos; - } else if (vpos < minfirstline && oldvpos < minfirstline) { - vpos = oldvpos; + if (newvpos < oldvpos) { + newvpos = oldvpos; + } else if (newvpos < minfirstline && oldvpos < minfirstline) { + newvpos = oldvpos; } + vpos = newvpos; vb_check(); #if 0 if (vpos < oldvpos) diff --git a/events.cpp b/events.cpp index c5184993..3f1f1d21 100644 --- a/events.cpp +++ b/events.cpp @@ -467,14 +467,18 @@ int current_hpos(void) // emulate VPOSHW writes changing cycle counter void modify_eventcounter(int diff) { + if (diff == 0) { + return; + } int hpos = current_hpos(); - if (hpos + diff < 0) { - return; - } + // fake >HTOTAL change delays if (hpos + diff >= maxhpos) { - return; + int dd = maxhpos - (hpos + diff); + diff += dd; + } else if (hpos + diff < 0) { + diff = (maxhpos - (0x100 - hpos + diff)); } int cdiff = diff * CYCLE_UNIT; @@ -489,8 +493,6 @@ void modify_eventcounter(int diff) currcycle += cdiff; } - int hp1 = current_hpos(); - cia_adjust_eclock_phase(diff); // adjust all existing timers @@ -505,8 +507,6 @@ void modify_eventcounter(int diff) eventtab2[i].evtime += cdiff; } - int hp2 = current_hpos(); - events_schedule(); }