]> git.unchartedbackwaters.co.uk Git - francis/winuae.git/commitdiff
Fixed 6.0.x statefile bug and added partial workaround
authorToni Wilen <twilen@winuae.net>
Sat, 4 Apr 2026 09:34:20 +0000 (12:34 +0300)
committerToni Wilen <twilen@winuae.net>
Sat, 4 Apr 2026 09:34:20 +0000 (12:34 +0300)
custom.cpp
include/savestate.h
newcpu.cpp
savestate.cpp

index d620cea98ce5956942083c10cf35d9776e243529..1f04f2279558f4254e98c75e23fd832b17d5fadc 100644 (file)
@@ -12436,7 +12436,7 @@ uae_u32 wait_cpu_cycle_read(uaecptr addr, int mode)
        }
 #endif
 
-       x_do_cycles_post(CYCLE_UNIT, 0);
+       x_do_cycles_post(CYCLE_UNIT, v);
 
        regs.chipset_latch_rw = regs.chipset_latch_read = v;
 
index c750a8e38f6013ef6f645e4cd2fdca823d1ac772..74fbfb9675c4aa8cba05e727b387b8374d88a420 100644 (file)
@@ -265,6 +265,7 @@ extern bool savestate_restore_finish(void);
 extern void savestate_restore_final(void);
 extern void savestate_memorysave(void);
 extern bool is_savestate_incompatible(void);
+extern uae_u32 get_statefile_version(void);
 
 extern void custom_prepare_savestate(void);
 
index a7e3997b3bc07be386ae16ead1cd41487a81beb3..2501a57159e3147fbe6cb368b01131b8dabac5bb 100644 (file)
@@ -482,6 +482,15 @@ static bool get_trace(uaecptr addr, int accessmode, int size, uae_u32 *data)
                                }
                        }
                        check_trace();
+
+                       // Partially fix 6.0.x statefiles where 68000 word read value was stored as a zero.
+                       // This can be only fixed when it was 68000 instruction prefetch.
+                       if ((get_statefile_version() & 0xffffff00) == 0x00060000) {
+                               if (!ctm->data && accessmode == 2 && currprefs.cpu_model <= 68010 && currprefs.cpu_cycle_exact && addr > regs.pc && addr < regs.pc + 20) {
+                                       return true;
+                               }
+                       }
+
                        *data = ctm->data;
                        return false;
                }
index ea9886cb0ba8fdd12b2b1c17ad2b76e44ebe6efa..538de5b944d7d0e11ff9b33f8cc0e9c505231a70 100644 (file)
@@ -82,6 +82,7 @@ struct zfile *savestate_file;
 #define SAVESTATE_ALWAYSUSEPATH 16
 #define SAVESTATE_SPECIALDUMP (SAVESTATE_SPECIALDUMP1 | SAVESTATE_SPECIALDUMP2)
 static int savestate_flags;
+static uae_u32 statefile_version;
 
 TCHAR savestate_fname[MAX_DPATH];
 TCHAR path_statefile[MAX_DPATH];
@@ -577,6 +578,11 @@ static uae_u8 *restore_log (uae_u8 *src)
        return src;
 }
 
+uae_u32 get_statefile_version(void)
+{
+       return statefile_version;
+}
+
 static void restore_header (uae_u8 *src)
 {
        TCHAR *emuname, *emuversion, *description;
@@ -587,6 +593,21 @@ static void restore_header (uae_u8 *src)
        description = restore_string ();
        write_log (_T("Saved with: '%s %s', description: '%s'\n"),
                emuname, emuversion, description);
+
+       statefile_version = 0;
+       TCHAR *tmpp = _tcschr(emuversion, '.');
+       if (tmpp) {
+               *tmpp++ = 0;
+               TCHAR *tmpp2 = tmpp;
+               statefile_version = _tstol(emuversion) << 16;
+               tmpp = _tcschr(tmpp, '.');
+               if (tmpp) {
+                       *tmpp++ = 0;
+                       statefile_version |= _tstol(tmpp2) << 8;
+                       statefile_version |= _tstol(tmpp);
+               }
+       }
+
        xfree (description);
        xfree (emuversion);
        xfree (emuname);