From 702e5cd5b0bae1f406f6350c398e8cd3d39c2cdd Mon Sep 17 00:00:00 2001 From: Toni Wilen Date: Tue, 23 May 2023 19:57:23 +0300 Subject: [PATCH] Allow backwards VPOSW writes if old position was out of range. --- custom.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/custom.cpp b/custom.cpp index 50d32e87..687ddb6f 100644 --- a/custom.cpp +++ b/custom.cpp @@ -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(); } -- 2.47.3