fix some savestate issues
authornotaz <notasas@gmail.com>
Sun, 15 Mar 2026 22:53:08 +0000 (00:53 +0200)
committernotaz <notasas@gmail.com>
Sun, 15 Mar 2026 22:53:08 +0000 (00:53 +0200)
libpcsxcore/misc.c
libpcsxcore/new_dynarec/emu_if.c
libpcsxcore/new_dynarec/new_dynarec.c
libpcsxcore/psxbios.c
libpcsxcore/psxbios.h

index 3bb4a5c..25eb1d6 100644 (file)
@@ -859,6 +859,8 @@ int LoadState(const char *file) {
 
        if (Config.HLE)
                psxBiosInit();
+       else if (oldhle)
+               psxBiosResetTables();
 
        // ex-ScreenPic space
        SaveFuncs.seek(f, EX_SCREENPIC_SIZE, SEEK_CUR);
index d9f834d..3260ba5 100644 (file)
@@ -293,9 +293,12 @@ static void ari64_notify(enum R3000Anote note, void *data) {
                break;
        case R3000ACPU_NOTIFY_AFTER_LOAD:
                ari64_on_ext_change(data == NULL, 0);
-               // fallthrough
-       // for state load, we take no action to not duplicate ndrc_freeze() work
+               psxInt.Notify(note, data);
+               break;
        case R3000ACPU_NOTIFY_AFTER_LOAD_STATE:
+               // no invalidate since ndrc_freeze() already did it
+               new_dyna_pcsx_mem_reset();
+               new_dyna_pcsx_mem_load_state();
                psxInt.Notify(note, data);
                break;
        }
index db18d7f..6a08079 100644 (file)
@@ -1519,17 +1519,17 @@ static void *check_addr(u_int vaddr)
 // asumes blocks are to be destroyed separately
 static void blocks_clear(struct block_info **head)
 {
-  struct block_info *cur, *next;
+  struct block_info *cur;
 
   if ((cur = *head)) {
     *head = NULL;
-    while (cur) {
-      next = cur->next_by_vaddr;
 #if !BLOCK_INFO_IN_TC
+    while (cur) {
+      struct block_info *next = cur->next_by_vaddr;
       free(cur);
-#endif
       cur = next;
     }
+#endif
   }
 }
 
index ee358a7..7a74fb5 100644 (file)
@@ -3648,6 +3648,18 @@ static void hleExc0_1_2();
 
 #include "sjisfont.h"
 
+void psxBiosResetTables() {
+       memset(biosA0, 0, sizeof(biosA0));
+       // biosB0 is just a ptr to C0
+       memset(biosC0, 0, sizeof(biosC0));
+
+       biosA0[0x03] = biosB0[0x35] = psxBios_write_psxout;
+       biosA0[0x3c] = biosB0[0x3d] = psxBios_putchar_psxout;
+       biosA0[0x3e] = biosB0[0x3f] = psxBios_puts_psxout;
+       // calls putchar() internally so no need to override
+       //biosA0[0x3f] = psxBios_printf_psxout;
+}
+
 void psxBiosInit() {
        u32 *ptr, *ram32, *rom32;
        char *romc;
@@ -3656,17 +3668,8 @@ void psxBiosInit() {
 
        psxRegs.biosBranchCheck = ~0;
 
+       psxBiosResetTables();
        memset(psxRegs.ptrs.psxM, 0, 0x10000);
-       for(i = 0; i < 256; i++) {
-               biosA0[i] = NULL;
-               biosB0[i] = NULL;
-               biosC0[i] = NULL;
-       }
-       biosA0[0x03] = biosB0[0x35] = psxBios_write_psxout;
-       biosA0[0x3c] = biosB0[0x3d] = psxBios_putchar_psxout;
-       biosA0[0x3e] = biosB0[0x3f] = psxBios_puts_psxout;
-       // calls putchar() internally so no need to override
-       //biosA0[0x3f] = psxBios_printf_psxout;
 
        if (!Config.HLE) {
                char verstr[0x24+1];
index 1f26693..772767b 100644 (file)
@@ -43,6 +43,7 @@ void psxBiosSetupBootState(void);
 void psxBiosCheckExe(u32 t_addr, u32 t_size, int loading_state);
 void psxBiosCheckBranch(void);
 int  psxBiosSoftcallEnded(void);
+void psxBiosResetTables();
 
 extern void (*biosA0[256])();
 extern void (**biosB0)();