]> git.unchartedbackwaters.co.uk Git - francis/winuae.git/commitdiff
VPOSW mid screen change updates
authorToni Wilen <twilen@winuae.net>
Fri, 10 Mar 2023 18:20:11 +0000 (20:20 +0200)
committerToni Wilen <twilen@winuae.net>
Fri, 10 Mar 2023 18:20:11 +0000 (20:20 +0200)
custom.cpp
events.cpp

index 42fd3e9f7038cbf4dc3761ff9635d29ee051cea2..553c47d4b5813005665847a17df7522b32220985 100644 (file)
@@ -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)
index c518499362858480082554a108c5e6b2d503b5c8..3f1f1d2179602577558f0558963838d9e8d0ecfe 100644 (file)
@@ -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();
 }