]> git.unchartedbackwaters.co.uk Git - francis/winuae.git/commitdiff
Keep CPU stopped when keyboard reset is active.
authorToni Wilen <twilen@winuae.net>
Sat, 19 Nov 2022 17:46:37 +0000 (19:46 +0200)
committerToni Wilen <twilen@winuae.net>
Sat, 19 Nov 2022 17:46:37 +0000 (19:46 +0200)
include/custom.h
include/newcpu.h
inputdevice.cpp
newcpu.cpp

index 9a7c9b63520d0dbdcb2f185a221c86a4f4c6e7ab..031901f8418b713e5112a5ec006645d7cdb48302 100644 (file)
@@ -81,6 +81,7 @@ STATIC_INLINE int dmaen(unsigned int dmamask)
        return (dmamask & dmacon) && (dmacon & 0x200);
 }
 
+#define SPCFLAG_CPUINRESET 2
 #define SPCFLAG_COPPER 4
 #define SPCFLAG_INT 8
 #define SPCFLAG_BRK 16
index e29f027764ac5871a7f316a7a51e860859ebf817..524d1cd78668ccff89b08b37ddf8375b5e44a1bd 100644 (file)
@@ -776,14 +776,15 @@ extern void exception2_read(uae_u32 opcode, uaecptr addr, int size, int fc);
 extern void exception2_write(uae_u32 opcode, uaecptr addr, int size, uae_u32 val, int fc);
 extern void exception2_fetch_opcode(uae_u32 opcode, int offset, int pcoffset);
 extern void exception2_fetch(uae_u32 opcode, int offset, int pcoffset);
-extern void m68k_reset (void);
-extern bool cpureset (void);
-extern void cpu_halt (int id);
+extern void m68k_reset(void);
+extern bool cpureset(void);
+extern void cpu_halt(int id);
+extern void cpu_inreset(void);
 extern int cpu_sleep_millis(int ms);
 extern void cpu_change(int newmodel);
 extern void cpu_fallback(int mode);
 
-extern void fill_prefetch (void);
+extern void fill_prefetch(void);
 extern void fill_prefetch_020_ntx(void);
 extern void fill_prefetch_030_ntx(void);
 extern void fill_prefetch_030_ntx_continue(void);
index c7703792ae377ad9949df30c6159652667e826ec..e4cdb4d2d15ff1f4153aab777ec76faca058dc50 100644 (file)
@@ -4129,15 +4129,15 @@ void inputdevice_add_inputcode (int code, int state, const TCHAR *s)
        }
 }
 
-void inputdevice_do_keyboard (int code, int state)
+void inputdevice_do_keyboard(int code, int state)
 {
 #ifdef CDTV
        if (code >= 0x72 && code <= 0x77) { // CDTV keys
-               if (cdtv_front_panel (-1)) {
+               if (cdtv_front_panel(-1)) {
                        // front panel active
                        if (!state)
                                return;
-                       cdtv_front_panel (code - 0x72);
+                       cdtv_front_panel(code - 0x72);
                        return;
                }
        }
@@ -4150,10 +4150,12 @@ void inputdevice_do_keyboard (int code, int state)
                                memset(keybuf, 0, sizeof(keybuf));
                                send_internalevent(INTERNALEVENT_KBRESET);
                                if (keyboard_reset_seq >= 5 * 50) {
+                                       custom_reset(true, true);
                                        uae_reset(1, 1);
                                } else {
                                        if (currprefs.cs_resetwarning && resetwarning_do(0))
                                                return;
+                                       custom_reset(false, true);
                                        uae_reset(0, 1);
                                }
                                keyboard_reset_seq = 0;
@@ -4161,7 +4163,7 @@ void inputdevice_do_keyboard (int code, int state)
                }
 
                if (key == AK_RESETWARNING) {
-                       resetwarning_do (0);
+                       resetwarning_do(0);
                        return;
                } else if ((keybuf[AK_CTRL] || keybuf[AK_RCTRL]) && keybuf[AK_LAMI] && keybuf[AK_RAMI]) {
                        int r = keybuf[AK_LALT] | keybuf[AK_RALT];
@@ -4173,16 +4175,17 @@ void inputdevice_do_keyboard (int code, int state)
                                keyboard_reset_seq = 1;
                                if (!currprefs.cs_resetwarning || !resetwarning_do(0)) {
                                        custom_reset(false, true);
+                                       cpu_inreset();
                                }
                        }
                }
-               if (record_key ((uae_u8)((key << 1) | (key >> 7)))) {
+               if (record_key((uae_u8)((key << 1) | (key >> 7)))) {
                        if (inputdevice_logging & 1)
-                               write_log (_T("Amiga key %02X %d\n"), key & 0x7f, key >> 7);
+                               write_log(_T("Amiga key %02X %d\n"), key & 0x7f, key >> 7);
                }
                return;
        }
-       inputdevice_add_inputcode (code, state, NULL);
+       inputdevice_add_inputcode(code, state, NULL);
 }
 
 // these need cpu trace data
index 3e67df6e976094629207b205ff28012f03f3e53a..0cf9341d4a8bff75fe7b1cfc92b922ea69e4e073 100644 (file)
@@ -4635,6 +4635,16 @@ static int do_specialties (int cycles)
        }
 #endif
 
+       while ((regs.spcflags & SPCFLAG_CPUINRESET)) {
+               x_do_cycles(4 * CYCLE_UNIT);
+               if (regs.spcflags & SPCFLAG_COPPER) {
+                       do_copper();
+               }
+               if (!(regs.spcflags & SPCFLAG_CPUINRESET) || (regs.spcflags & SPCFLAG_BRK) || (regs.spcflags & SPCFLAG_MODE_CHANGE)) {
+                       break;
+               }
+       }
+
        while ((regs.spcflags & SPCFLAG_BLTNASTY) && dmaen (DMA_BLITTER) && cycles > 0 && ((currprefs.waiting_blits && currprefs.cpu_model >= 68020) || !currprefs.blitter_cycle_exact)) {
                int c = blitnasty();
                if (c < 0) {
@@ -5551,7 +5561,15 @@ static void check_halt(void)
                do_specialties (0);
 }
 
-void cpu_halt (int id)
+void cpu_inreset(void)
+{
+       set_special(SPCFLAG_CPUINRESET);
+       regs.s = 1;
+       regs.intmask = 7;
+       MakeSR();
+}
+
+void cpu_halt(int id)
 {
        // id < 0: m68k halted, PPC active.
        // id > 0: emulation halted.
@@ -7691,6 +7709,7 @@ bool cpureset (void)
        maybe_disable_fpu();
        m68k_reset_delay = currprefs.reset_delay;
        set_special(SPCFLAG_CHECK);
+       unset_special(SPCFLAG_CPUINRESET);
        send_internalevent(INTERNALEVENT_CPURESET);
        if (cpuboard_forced_hardreset()) {
                custom_reset_cpu(false, false);