]> git.unchartedbackwaters.co.uk Git - francis/winuae.git/commitdiff
NMI inputevent was unreliable
authorToni Wilen <twilen@winuae.net>
Fri, 10 Feb 2023 19:29:00 +0000 (21:29 +0200)
committerToni Wilen <twilen@winuae.net>
Fri, 10 Feb 2023 19:29:00 +0000 (21:29 +0200)
custom.cpp
include/custom.h
newcpu.cpp

index 2e93ba1ac2458725b6a140517496b917fea16210..e78efa2416c45e8fb893c318f5ea8ad5ed53332e 100644 (file)
@@ -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;
index 84b0e647107b65a4a0789590f37d4b750fe54db2..eec7b1406e5d4f32240cd3b93d6f818badff3d96 100644 (file)
@@ -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);
index 6cf99ae57b7c4ef0c4110ef054086e3b2142c31b..02bbadf590510378a661d715b041a82ab2b32913 100644 (file)
@@ -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)