From b1a6586688ec846988a45773c924db6fc4e05821 Mon Sep 17 00:00:00 2001 From: kub Date: Thu, 6 Jan 2022 21:35:49 +0100 Subject: [PATCH] 32x, improve loading save state (memory leak, 68k hang) --- pico/32x/32x.c | 1 + pico/32x/memory.c | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/pico/32x/32x.c b/pico/32x/32x.c index b041507d..d1e08aa1 100644 --- a/pico/32x/32x.c +++ b/pico/32x/32x.c @@ -618,6 +618,7 @@ void Pico32xStateLoaded(int is_early) sh2s[0].m68krcycles_done = sh2s[1].m68krcycles_done = SekCyclesDone(); p32x_update_irls(NULL, SekCyclesDone()); + p32x_timers_recalc(); p32x_pwm_state_loaded(); p32x_run_events(SekCyclesDone()); } diff --git a/pico/32x/memory.c b/pico/32x/memory.c index 324d9e50..18a2f724 100644 --- a/pico/32x/memory.c +++ b/pico/32x/memory.c @@ -2296,11 +2296,13 @@ void PicoMemSetup32x(void) unsigned int rs; int i; - Pico32xMem = plat_mmap(0x06000000, sizeof(*Pico32xMem), 0, 0); + if (Pico32xMem == NULL) + Pico32xMem = plat_mmap(0x06000000, sizeof(*Pico32xMem), 0, 0); if (Pico32xMem == NULL) { elprintf(EL_STATUS, "OOM"); return; } + memset(Pico32xMem, 0, sizeof(struct Pico32xMem)); get_bios(); @@ -2481,12 +2483,12 @@ void Pico32xMemStateLoaded(void) memset(Pico32xMem->pwm, 0, sizeof(Pico32xMem->pwm)); Pico32x.dirty_pal = 1; - Pico32x.emu_flags &= ~(P32XF_68KCPOLL | P32XF_68KVPOLL); memset(&m68k_poll, 0, sizeof(m68k_poll)); msh2.state = 0; msh2.poll_addr = msh2.poll_cycles = msh2.poll_cnt = 0; ssh2.state = 0; ssh2.poll_addr = ssh2.poll_cycles = ssh2.poll_cnt = 0; + memset(sh2_poll_fifo, 0, sizeof(sh2_poll_fifo)); sh2_drc_flush_all(); } -- 2.39.5