From 6f6ca248006d17316f0c2f9c0dbe9be660f74783 Mon Sep 17 00:00:00 2001 From: Toni Wilen Date: Sat, 6 Jan 2024 10:39:56 +0200 Subject: [PATCH] NMI handling fix --- custom.cpp | 4 ++-- include/newcpu.h | 1 + newcpu.cpp | 5 ++++- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/custom.cpp b/custom.cpp index cd1b401a..f5a60b7c 100644 --- a/custom.cpp +++ b/custom.cpp @@ -8690,7 +8690,7 @@ int intlev(void) } uae_u16 imask = intreq2 & intena2; if (!(imask && (intena2 & 0x4000))) - return -1; + return 0; if (imask & (0x4000 | 0x2000)) // 13 14 return 6; if (imask & (0x1000 | 0x0800)) // 11 12 @@ -8703,7 +8703,7 @@ int intlev(void) return 2; if (imask & (0x0001 | 0x0002 | 0x0004)) // 0 1 2 return 1; - return -1; + return 0; } void rethink_uae_int(void) diff --git a/include/newcpu.h b/include/newcpu.h index 6eac8ff1..6f9793f1 100644 --- a/include/newcpu.h +++ b/include/newcpu.h @@ -207,6 +207,7 @@ struct regstruct int exception; int intmask; int ipl[2], ipl_pin, ipl_pin_p; + int lastipl; evt_t ipl_pin_change_evt, ipl_pin_change_evt_p; evt_t ipl_evt, ipl_evt_pre; int ipl_evt_pre_mode; diff --git a/newcpu.cpp b/newcpu.cpp index dde2bbfa..31e88ee9 100644 --- a/newcpu.cpp +++ b/newcpu.cpp @@ -3607,6 +3607,7 @@ static void m68k_reset2(bool hardreset) SET_VFLG(0); SET_NFLG(0); regs.intmask = 7; + regs.lastipl = 0; regs.vbr = regs.sfc = regs.dfc = 0; regs.irc = 0xffff; #ifdef FPUEMU @@ -4767,8 +4768,10 @@ static int do_specialties (int cycles) if (spcflags & SPCFLAG_INT) { int intr = intlev(); unset_special (SPCFLAG_INT | SPCFLAG_DOINT); - if (intr > regs.intmask || intr == 7) + if (intr > regs.intmask || (intr == 7 && intr > regs.lastipl)) { do_interrupt(intr); + } + regs.lastipl = intr; } } -- 2.47.3