]> git.unchartedbackwaters.co.uk Git - francis/winuae.git/commitdiff
Fix cycle-accurate CIA emulation mode HI timer load.
authorToni Wilen <twilen@winuae.net>
Sat, 21 Jan 2023 10:48:42 +0000 (12:48 +0200)
committerToni Wilen <twilen@winuae.net>
Sat, 21 Jan 2023 10:48:42 +0000 (12:48 +0200)
cia.cpp

diff --git a/cia.cpp b/cia.cpp
index 89d4df8bbd86f0650339ad1f8329c7b382571dc9..b4bddb68354f9beae5d5eaab695fa30748bd216c 100644 (file)
--- a/cia.cpp
+++ b/cia.cpp
@@ -1477,6 +1477,9 @@ static void CIA_thi_write(int num, int tnum, uae_u8 val)
 
        t->latch = (t->latch & 0xff) | (val << 8);
 
+       // If ONESHOT: Load and start timer.
+       // If CONTINUOUS: Load timer if not running.
+
        if (!acc_mode()) {
                // if inaccurate mode: do everything immediately
 
@@ -1498,15 +1501,15 @@ static void CIA_thi_write(int num, int tnum, uae_u8 val)
        } else {
                // if accurate mode: handle delays cycle-accurately
 
-               t->loaddelay |= 1 << 2;
-
                if (!(t->cr & CR_START)) {
                        t->loaddelay |= 1 << 1;
+                       t->loaddelay |= 1 << 2;
                }
 
                if (t->cr & CR_RUNMODE) {
                        t->cr |= CR_START;
                        t->loaddelay |= 0x01000000 << 1;
+                       t->loaddelay |= 1 << 2;
                }
        }
 }