From f65526dab1ecffa34036c78620ca94e2480aaf58 Mon Sep 17 00:00:00 2001 From: Toni Wilen Date: Wed, 20 Jul 2022 20:58:54 +0300 Subject: [PATCH] STOP timing fix. --- gencpu.cpp | 11 +++++++++-- include/newcpu.h | 2 ++ newcpu.cpp | 13 ++++++++++--- 3 files changed, 21 insertions(+), 5 deletions(-) diff --git a/gencpu.cpp b/gencpu.cpp index 6e5fef58..cf9056c2 100644 --- a/gencpu.cpp +++ b/gencpu.cpp @@ -6679,9 +6679,16 @@ static void gen_opcode (unsigned int opcode) write_return_cycles(0); out("}\n"); } - out("regs.sr = sr;\n"); check_ipl_always(); - out("MakeFromSR();\n"); + if (cpu_level <= 1) { + out("checkint();\n"); + out("regs.sr = sr;\n"); + out("MakeFromSR_STOP();\n"); + } else { + out("regs.sr = sr;\n"); + out("checkint();\n"); + out("MakeFromSR_STOP();\n"); + } out("do_cycles_stop(4);\n"); out("m68k_setstopped();\n"); // STOP does not prefetch anything diff --git a/include/newcpu.h b/include/newcpu.h index 82621185..afa0d5cf 100644 --- a/include/newcpu.h +++ b/include/newcpu.h @@ -682,6 +682,7 @@ extern void flush_cpu_caches_040(uae_u16 opcode); extern void REGPARAM3 MakeSR (void) REGPARAM; extern void REGPARAM3 MakeFromSR(void) REGPARAM; extern void REGPARAM3 MakeFromSR_T0(void) REGPARAM; +extern void REGPARAM3 MakeFromSR_STOP(void) REGPARAM; extern void REGPARAM3 MakeFromSR_intmask(uae_u16 oldsr, uae_u16 newsr) REGPARAM; extern void REGPARAM3 Exception (int) REGPARAM; extern void REGPARAM3 Exception_cpu(int) REGPARAM; @@ -691,6 +692,7 @@ extern void NMI (void); extern void IRQ_forced(int, int); extern void prepare_interrupt (uae_u32); extern void doint(void); +extern void checkint(void); extern void intlev_load(void); extern void dump_counts (void); extern int m68k_move2c (int, uae_u32 *); diff --git a/newcpu.cpp b/newcpu.cpp index 8b842876..913b9f54 100644 --- a/newcpu.cpp +++ b/newcpu.cpp @@ -2318,7 +2318,7 @@ static void activate_trace(void) } // make sure interrupt is checked immediately after current instruction -static void doint_imm(void) +void checkint(void) { doint(); if (!currprefs.cachesize && !(regs.spcflags & SPCFLAG_INT) && (regs.spcflags & SPCFLAG_DOINT)) @@ -2368,7 +2368,7 @@ static void MakeFromSR_x(int t0trace) regs.t1 = (regs.sr >> 15) & 1; regs.t0 = (regs.sr >> 14) & 1; regs.s = (regs.sr >> 13) & 1; - regs.m = (regs.sr >> 12) & 1; + regs.m = (regs.sr >> 12) & 1; regs.intmask = (regs.sr >> 8) & 7; if (currprefs.cpu_model >= 68020) { @@ -2419,7 +2419,10 @@ static void MakeFromSR_x(int t0trace) } #endif - doint_imm(); + if (t0trace >= 0) { + checkint(); + } + if (regs.t1 || regs.t0) { set_special (SPCFLAG_TRACE); } else { @@ -2443,6 +2446,10 @@ void REGPARAM2 MakeFromSR(void) { MakeFromSR_x(0); } +void REGPARAM2 MakeFromSR_STOP(void) +{ + MakeFromSR_x(-1); +} void REGPARAM2 MakeFromSR_intmask(uae_u16 oldsr, uae_u16 newsr) { -- 2.47.3