From 2f0c5639c13693092e36a00df5857b5b44302cef Mon Sep 17 00:00:00 2001 From: kub Date: Tue, 2 Jul 2024 22:43:26 +0200 Subject: [PATCH] core z80, fix cycle counting if z80 in hold on frame change --- pico/memory.c | 3 ++- pico/pico_int.h | 6 ++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/pico/memory.c b/pico/memory.c index 34d0cf7b..69ca8aa3 100644 --- a/pico/memory.c +++ b/pico/memory.c @@ -530,7 +530,8 @@ void NOINLINE ctl_write_z80busreq(u32 d) { if (d) { - Pico.t.z80c_aim = Pico.t.z80c_cnt = z80_cycles_from_68k() + (Pico.t.z80_busdelay >> 8) + 2; + Pico.t.z80c_aim = Pico.t.z80c_cnt = z80_cycles_from_68k() + 2; + Pico.t.z80c_cnt += Pico.t.z80_busdelay >> 8; Pico.t.z80_busdelay &= 0xff; } else diff --git a/pico/pico_int.h b/pico/pico_int.h index c57c5f6a..3d495739 100644 --- a/pico/pico_int.h +++ b/pico/pico_int.h @@ -201,8 +201,10 @@ extern struct DrZ80 drZ80; #define Z80_STATE_SIZE 0x60 -#define z80_resetCycles() \ - Pico.t.z80c_cnt -= Pico.t.z80c_aim, Pico.t.z80c_aim = Pico.t.z80_scanline = 0 +#define z80_resetCycles() { \ + Pico.t.z80c_cnt -= Pico.t.z80c_aim, Pico.t.z80c_aim = Pico.t.z80_scanline = 0; \ + if (!Pico.m.z80Run | Pico.m.z80_reset) Pico.t.z80c_cnt = 0; \ +} #define z80_cyclesDone() \ (Pico.t.z80c_aim - z80_cyclesLeft) -- 2.39.5