]> git.unchartedbackwaters.co.uk Git - francis/winuae.git/commitdiff
Allow backwards VPOSW writes if old position was out of range.
authorToni Wilen <twilen@winuae.net>
Tue, 23 May 2023 16:57:23 +0000 (19:57 +0300)
committerToni Wilen <twilen@winuae.net>
Tue, 23 May 2023 16:57:23 +0000 (19:57 +0300)
custom.cpp

index 50d32e8746352214a0d3e1b4b16428499a64b73e..687ddb6f4c3016a50867eeb5b24ebd494bfa79ed 100644 (file)
@@ -7753,6 +7753,7 @@ static uae_u16 VPOSR(void)
 static void VPOSW(uae_u16 v)
 {
        int oldvpos = vpos;
+       int newvpos = vpos;
 
 #if 0
        if (M68K_GETPC < 0xf00000 || 1)
@@ -7769,19 +7770,22 @@ static void VPOSW(uae_u16 v)
        if (lof_changing) {
                return;
        }
-       vpos &= 0x00ff;
+       newvpos &= 0x00ff;
        v &= 7;
        if (!ecs_agnus) {
                v &= 1;
        }
-       vpos |= v << 8;
-       if (vpos != oldvpos) {
-               cia_adjust_eclock_phase((vpos - oldvpos) * maxhpos);
+       newvpos |= v << 8;
+       if (newvpos != oldvpos) {
+               cia_adjust_eclock_phase((newvpos - oldvpos) * maxhpos);
                vposw_change++;
        }
-       if (vpos < oldvpos) {
-               vpos = oldvpos;
+
+       if (newvpos < oldvpos && oldvpos <= maxvpos) {
+               newvpos = oldvpos;
        }
+       vpos = newvpos;
+
        vb_check();
 }