From: Toni Wilen Date: Sat, 19 Nov 2022 17:46:37 +0000 (+0200) Subject: Keep CPU stopped when keyboard reset is active. X-Git-Tag: 41000~65 X-Git-Url: https://git.unchartedbackwaters.co.uk/w/?a=commitdiff_plain;h=cd4cf259f1d4c25938080cfdbff87b543014320d;p=francis%2Fwinuae.git Keep CPU stopped when keyboard reset is active. --- diff --git a/include/custom.h b/include/custom.h index 9a7c9b63..031901f8 100644 --- a/include/custom.h +++ b/include/custom.h @@ -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 diff --git a/include/newcpu.h b/include/newcpu.h index e29f0277..524d1cd7 100644 --- a/include/newcpu.h +++ b/include/newcpu.h @@ -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); diff --git a/inputdevice.cpp b/inputdevice.cpp index c7703792..e4cdb4d2 100644 --- a/inputdevice.cpp +++ b/inputdevice.cpp @@ -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 diff --git a/newcpu.cpp b/newcpu.cpp index 3e67df6e..0cf9341d 100644 --- a/newcpu.cpp +++ b/newcpu.cpp @@ -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);