cpu: make sure config is applied when core is changed
authornotaz <notasas@gmail.com>
Tue, 21 Jan 2025 20:51:15 +0000 (22:51 +0200)
committernotaz <notasas@gmail.com>
Wed, 22 Jan 2025 02:36:09 +0000 (04:36 +0200)
frontend/libretro.c
frontend/menu.c
libpcsxcore/lightrec/plugin.c
libpcsxcore/misc.c
libpcsxcore/new_dynarec/emu_if.c
libpcsxcore/psxinterpreter.c
libpcsxcore/psxinterpreter.h

index 86c3367..14ba8fc 100644 (file)
@@ -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);
       }
    }
index 462d78c..ec803ab 100644 (file)
@@ -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);
        }
 
index 0ca44e4..a04d42d 100644 (file)
@@ -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)
index 34745ad..357a20a 100644 (file)
@@ -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;
index 4c21b00..618cafd 100644 (file)
@@ -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;
index 7e73255..e0edecd 100644 (file)
@@ -1166,6 +1166,7 @@ void (*psxCP2[64])(struct psxCP2Regs *regs) = {
 ///////////////////////////////////////////
 
 static int intInit() {
+       intApplyConfig();
        return 0;
 }
 
index bc219a4..e494989 100644 (file)
@@ -2,6 +2,7 @@
 #define __PSXINTERPRETER_H__
 
 struct psxRegisters;
+struct psxCP2Regs;
 
 // get an opcode without triggering exceptions or affecting cache
 u32 intFakeFetch(u32 pc);