From: Toni Wilen Date: Fri, 10 Feb 2023 19:29:00 +0000 (+0200) Subject: NMI inputevent was unreliable X-Git-Tag: 5.0.0~155 X-Git-Url: https://git.unchartedbackwaters.co.uk/w/?a=commitdiff_plain;h=61746c02dca7d9eef9d0190f9793cd1b7a3079e3;p=francis%2Fwinuae.git NMI inputevent was unreliable --- diff --git a/custom.cpp b/custom.cpp index 2e93ba1a..e78efa24 100644 --- a/custom.cpp +++ b/custom.cpp @@ -7770,25 +7770,40 @@ static void DMACON(int hpos, uae_u16 v) } static int irq_forced; -static evt_t irq_delay; +static evt_t irq_forced_delay; void IRQ_forced(int lvl, int delay) { irq_forced = lvl; - irq_delay = 0; + irq_forced_delay = 0; if (delay > 0 && currprefs.cpu_compatible) { - irq_delay = get_cycles() + delay * CYCLE_UNIT; + irq_forced_delay = get_cycles() + delay * CYCLE_UNIT; + } else if (delay < 0) { + irq_forced_delay = -1; } doint(); } +void intlev_ack(int lvl) +{ + if (!irq_forced) { + return; + } + if (lvl >= irq_forced && irq_forced_delay < 0) { + irq_forced_delay = 0; + irq_forced = 0; + } +} + int intlev(void) { if (irq_forced) { int lvl = irq_forced; - if (irq_delay == -1 || get_cycles() > irq_delay) { + if (irq_forced_delay == 0) { irq_forced = 0; - irq_delay = -1; + } else if (irq_forced_delay > 0 && get_cycles() > irq_forced_delay) { + irq_forced = 0; + irq_forced_delay = 0; } return lvl; } @@ -13381,6 +13396,9 @@ void custom_reset(bool hardreset, bool keyboardreset) sprite_dma_change_cycle_on = -1; custom_color_write_cycle = -1; + irq_forced_delay = 0; + irq_forced = 0; + if (hardreset || savestate_state) { maxhpos = ntsc ? MAXHPOS_NTSC : MAXHPOS_PAL; maxhpos_short = ntsc ? MAXHPOS_NTSC : MAXHPOS_PAL; diff --git a/include/custom.h b/include/custom.h index 84b0e647..eec7b140 100644 --- a/include/custom.h +++ b/include/custom.h @@ -52,6 +52,7 @@ extern int custom_init(void); extern void custom_prepare(void); extern void custom_reset(bool hardreset, bool keyboardreset); extern int intlev(void); +extern void intlev_ack(int); extern void dumpcustom(void); extern void do_copper(void); diff --git a/newcpu.cpp b/newcpu.cpp index 6cf99ae5..02bbadf5 100644 --- a/newcpu.cpp +++ b/newcpu.cpp @@ -3459,6 +3459,8 @@ static void do_interrupt (int nr) assert (nr < 8 && nr >= 0); + intlev_ack(nr); + for (;;) { Exception (nr + 24); if (!currprefs.cpu_compatible || currprefs.cpu_model == 68060)