From c6809aec4a68d45e31ef4bc8b6bcb8e0ec160684 Mon Sep 17 00:00:00 2001 From: notaz Date: Tue, 21 Jan 2025 22:51:15 +0200 Subject: [PATCH] cpu: make sure config is applied when core is changed --- frontend/libretro.c | 1 - frontend/menu.c | 1 - libpcsxcore/lightrec/plugin.c | 5 +++-- libpcsxcore/misc.c | 11 ++++++----- libpcsxcore/new_dynarec/emu_if.c | 3 +++ libpcsxcore/psxinterpreter.c | 1 + libpcsxcore/psxinterpreter.h | 1 + 7 files changed, 14 insertions(+), 9 deletions(-) diff --git a/frontend/libretro.c b/frontend/libretro.c index 86c33673..14ba8fc3 100644 --- a/frontend/libretro.c +++ b/frontend/libretro.c @@ -2311,7 +2311,6 @@ static void update_variables(bool in_flight) prev_cpu->Notify(R3000ACPU_NOTIFY_BEFORE_SAVE, NULL); prev_cpu->Shutdown(); psxCpu->Init(); - psxCpu->Reset(); psxCpu->Notify(R3000ACPU_NOTIFY_AFTER_LOAD, NULL); } } diff --git a/frontend/menu.c b/frontend/menu.c index 462d78c5..ec803abe 100644 --- a/frontend/menu.c +++ b/frontend/menu.c @@ -2739,7 +2739,6 @@ void menu_prepare_emu(void) prev_cpu->Notify(R3000ACPU_NOTIFY_BEFORE_SAVE, NULL); prev_cpu->Shutdown(); psxCpu->Init(); - psxCpu->Reset(); psxCpu->Notify(R3000ACPU_NOTIFY_AFTER_LOAD, NULL); } diff --git a/libpcsxcore/lightrec/plugin.c b/libpcsxcore/lightrec/plugin.c index 0ca44e44..a04d42d9 100644 --- a/libpcsxcore/lightrec/plugin.c +++ b/libpcsxcore/lightrec/plugin.c @@ -78,6 +78,7 @@ static u32 lightrec_begin_cycles; extern u32 lightrec_hacks; +static void lightrec_plugin_apply_config(); extern void lightrec_code_inv(void *ptr, uint32_t len); enum my_cp2_opcodes { @@ -493,6 +494,7 @@ static int lightrec_plugin_init(void) #ifndef _WIN32 signal(SIGPIPE, exit); #endif + lightrec_plugin_apply_config(); return 0; } @@ -726,6 +728,7 @@ static void lightrec_plugin_apply_config() cycles_per_op_old = cycles_per_op; lightrec_set_cycles_per_opcode(lightrec_state, cycles_per_op); + lightrec_set_unsafe_opt_flags(lightrec_state, lightrec_hacks); intApplyConfig(); } @@ -756,8 +759,6 @@ static void lightrec_plugin_reset(void) regs->cp0[12] = 0x10900000; // COP0 enabled | BEV = 1 | TS = 1 regs->cp0[15] = 0x00000002; // PRevID = Revision ID, same as R3000A - - lightrec_set_unsafe_opt_flags(lightrec_state, lightrec_hacks); } static void lightrec_plugin_sync_regs_from_pcsx(bool need_cp2) diff --git a/libpcsxcore/misc.c b/libpcsxcore/misc.c index 34745add..357a20a0 100644 --- a/libpcsxcore/misc.c +++ b/libpcsxcore/misc.c @@ -820,6 +820,12 @@ int LoadState(const char *file) { psxHwFreeze(f, 0); psxRcntFreeze(f, 0); mdecFreeze(f, 0); + + if (Config.HLE != oldhle) { + // at least ari64 drc compiles differently so hard reset + psxCpu->Shutdown(); + psxCpu->Init(); + } ndrc_freeze(f, 0); padFreeze(f, 0); @@ -827,11 +833,6 @@ int LoadState(const char *file) { if (Config.HLE) psxBiosCheckExe(biosBranchCheckOld, 0x60, 1); - if (Config.HLE != oldhle) { - // at least ari64 drc compiles differently so hard reset - psxCpu->Shutdown(); - psxCpu->Init(); - } psxCpu->Notify(R3000ACPU_NOTIFY_AFTER_LOAD, NULL); result = 0; diff --git a/libpcsxcore/new_dynarec/emu_if.c b/libpcsxcore/new_dynarec/emu_if.c index 4c21b002..618cafd8 100644 --- a/libpcsxcore/new_dynarec/emu_if.c +++ b/libpcsxcore/new_dynarec/emu_if.c @@ -570,6 +570,9 @@ static int ari64_init() zeromem_ptr = zero_mem; scratch_buf_ptr = scratch_buf; // for gte_neon.S + ndrc_g.cycle_multiplier_old = Config.cycle_multiplier; + ndrc_g.hacks_old = ndrc_g.hacks | ndrc_g.hacks_pergame; + ari64_apply_config(); ari64_thread_init(); return 0; diff --git a/libpcsxcore/psxinterpreter.c b/libpcsxcore/psxinterpreter.c index 7e732558..e0edecd6 100644 --- a/libpcsxcore/psxinterpreter.c +++ b/libpcsxcore/psxinterpreter.c @@ -1166,6 +1166,7 @@ void (*psxCP2[64])(struct psxCP2Regs *regs) = { /////////////////////////////////////////// static int intInit() { + intApplyConfig(); return 0; } diff --git a/libpcsxcore/psxinterpreter.h b/libpcsxcore/psxinterpreter.h index bc219a49..e4949898 100644 --- a/libpcsxcore/psxinterpreter.h +++ b/libpcsxcore/psxinterpreter.h @@ -2,6 +2,7 @@ #define __PSXINTERPRETER_H__ struct psxRegisters; +struct psxCP2Regs; // get an opcode without triggering exceptions or affecting cache u32 intFakeFetch(u32 pc); -- 2.39.5