From c1afbc0597849ffc65e3d525c820d9b9383cb26c Mon Sep 17 00:00:00 2001 From: Toni Wilen Date: Sat, 21 Jan 2023 12:48:42 +0200 Subject: [PATCH] Fix cycle-accurate CIA emulation mode HI timer load. --- cia.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/cia.cpp b/cia.cpp index 89d4df8b..b4bddb68 100644 --- 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; } } } -- 2.47.3