From 9961d9fdb8d810b3d88f9c1b913165cd876cec60 Mon Sep 17 00:00:00 2001 From: kub Date: Mon, 3 Jul 2023 23:29:51 +0200 Subject: [PATCH] 32x, fix disabling via ADEN (memory leak, mcd) --- pico/32x/32x.c | 13 +++++++++---- pico/cart.c | 3 +-- pico/pico_int.h | 1 + 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/pico/32x/32x.c b/pico/32x/32x.c index 67ad5a3a..61da4816 100644 --- a/pico/32x/32x.c +++ b/pico/32x/32x.c @@ -129,12 +129,16 @@ void Pico32xShutdown(void) sh2_finish(&msh2); sh2_finish(&ssh2); - Pico32x.vdp_regs[6] = P32XS_RV; + Pico32x.vdp_regs[0] |= P32XS_nRES; + Pico32x.vdp_regs[6] |= P32XS_RV; rendstatus_old = -1; PicoIn.AHW &= ~PAHW_32X; - PicoMemSetup(); + if (PicoIn.AHW & PAHW_MCD) + PicoMemSetupCD(); + else + PicoMemSetup(); emu_32x_startup(); } @@ -209,7 +213,8 @@ void PicoPower32x(void) void PicoUnload32x(void) { - Pico32xShutdown(); + if (PicoIn.AHW & PAHW_32X) + Pico32xShutdown(); if (Pico32xMem != NULL) plat_munmap(Pico32xMem, sizeof(*Pico32xMem)); @@ -464,7 +469,7 @@ void sync_sh2s_normal(unsigned int m68k_target) elprintf(EL_32X, "sh2 sync to %u", m68k_target); - if (!(Pico32x.regs[0] & P32XS_nRES) || !(Pico32x.regs[0] & P32XS_ADEN)) { + if ((Pico32x.regs[0] & (P32XS_nRES|P32XS_ADEN)) != (P32XS_nRES|P32XS_ADEN)) { msh2.m68krcycles_done = ssh2.m68krcycles_done = m68k_target; return; // rare } diff --git a/pico/cart.c b/pico/cart.c index bcdf5529..e8293abc 100644 --- a/pico/cart.c +++ b/pico/cart.c @@ -908,8 +908,7 @@ void PicoCartUnload(void) PicoCartUnloadHook = NULL; } - if (PicoIn.AHW & PAHW_32X) - PicoUnload32x(); + PicoUnload32x(); if (Pico.rom != NULL) { SekFinishIdleDet(); diff --git a/pico/pico_int.h b/pico/pico_int.h index 4944bb7d..c04a5ccf 100644 --- a/pico/pico_int.h +++ b/pico/pico_int.h @@ -995,6 +995,7 @@ void Pico32xInit(void); void PicoPower32x(void); void PicoReset32x(void); void Pico32xStartup(void); +void Pico32xShutdown(void); void PicoUnload32x(void); void PicoFrame32x(void); void Pico32xStateLoaded(int is_early); -- 2.39.2