From db2b6d996608f7323b04dcf425bee2796a36dbbe Mon Sep 17 00:00:00 2001 From: kub Date: Fri, 12 Apr 2024 20:29:50 +0200 Subject: [PATCH] core z80, fix cycle counting in reset state --- pico/debug.c | 2 +- pico/pico.c | 3 +-- pico/pico_cmn.c | 2 +- pico/pico_int.h | 4 ++-- pico/sms.c | 2 +- 5 files changed, 6 insertions(+), 7 deletions(-) diff --git a/pico/debug.c b/pico/debug.c index e928d73b..5a85a30a 100644 --- a/pico/debug.c +++ b/pico/debug.c @@ -389,7 +389,7 @@ void PDebugZ80Frame(void) else lines = 262; - z80_resetCycles(); + z80_resetCycles(Pico.t.z80c_aim); PsndStartFrame(); if (/*Pico.m.z80Run &&*/ !Pico.m.z80_reset && (PicoIn.opt&POPT_EN_Z80)) { diff --git a/pico/pico.c b/pico/pico.c index 34026577..d913e082 100644 --- a/pico/pico.c +++ b/pico/pico.c @@ -72,8 +72,6 @@ void PicoPower(void) memset(&Pico.m,0,sizeof(Pico.m)); memset(&Pico.t,0,sizeof(Pico.t)); - z80_reset(); - // my MD1 VA6 console has this in IO PicoMem.ioports[1] = PicoMem.ioports[2] = PicoMem.ioports[3] = 0xff; @@ -169,6 +167,7 @@ int PicoReset(void) memset(&PicoIn.padInt, 0, sizeof(PicoIn.padInt)); + z80_reset(); if (PicoIn.AHW & PAHW_SMS) { PicoResetMS(); return 0; diff --git a/pico/pico_cmn.c b/pico/pico_cmn.c index c3b14caa..519aba35 100644 --- a/pico/pico_cmn.c +++ b/pico/pico_cmn.c @@ -141,8 +141,8 @@ static int PicoFrameHints(void) skip = PicoIn.skipFrame; + z80_resetCycles(cycles_68k_to_z80(Pico.t.m68c_aim - Pico.t.m68c_frame_start)); Pico.t.m68c_frame_start = Pico.t.m68c_aim; - z80_resetCycles(); PsndStartFrame(); hint = pv->hint_cnt; diff --git a/pico/pico_int.h b/pico/pico_int.h index d39e9809..c576ecbf 100644 --- a/pico/pico_int.h +++ b/pico/pico_int.h @@ -201,8 +201,8 @@ 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(aim) \ + Pico.t.z80c_cnt -= (aim < Pico.t.z80c_cnt ? aim : Pico.t.z80c_cnt), Pico.t.z80c_aim = Pico.t.z80_scanline = 0 #define z80_cyclesDone() \ (Pico.t.z80c_aim - z80_cyclesLeft) diff --git a/pico/sms.c b/pico/sms.c index 6b1425b2..e954bc8b 100644 --- a/pico/sms.c +++ b/pico/sms.c @@ -846,7 +846,7 @@ void PicoFrameMS(void) int nmi; int y; - z80_resetCycles(); + z80_resetCycles(Pico.t.z80c_aim); PsndStartFrame(); // for SMS the pause button generates an NMI, for GG ths is not the case -- 2.39.5