diff --git a/BizHawk.Client.Common/movie/Movie.cs b/BizHawk.Client.Common/movie/Movie.cs index 8a623b1055..4aa615ed61 100644 --- a/BizHawk.Client.Common/movie/Movie.cs +++ b/BizHawk.Client.Common/movie/Movie.cs @@ -108,7 +108,7 @@ namespace BizHawk.Client.Common // If Starting a new recording requires clearing sram it shoudl be done at a higher layer and not rely on all IMovies doing this // Haven't removed it yet because I coudln't guarantee that power-on movies coudl live without it // And the immediate fire is that Savestate movies are breaking - if (!Header.StartsFromSavestate && Global.Emulator.SystemId != "WSWAN") + if (!Header.StartsFromSavestate) // && Global.Emulator.SystemId != "WSWAN") { Global.Emulator.ClearSaveRam(); } @@ -126,7 +126,7 @@ namespace BizHawk.Client.Common public void StartNewPlayback() { // See StartNewRecording for details as to why this savestate check is here - if (!Header.StartsFromSavestate && Global.Emulator.SystemId != "WSWAN") + if (!Header.StartsFromSavestate) // && Global.Emulator.SystemId != "WSWAN") { Global.Emulator.ClearSaveRam(); } diff --git a/BizHawk.Client.Common/movie/TasMovie.cs b/BizHawk.Client.Common/movie/TasMovie.cs index 4af915c268..25ea42c9c4 100644 --- a/BizHawk.Client.Common/movie/TasMovie.cs +++ b/BizHawk.Client.Common/movie/TasMovie.cs @@ -191,7 +191,7 @@ namespace BizHawk.Client.Common public void StartNewPlayback() { _mode = Moviemode.Play; - Global.Emulator.ClearSaveRam(); + Global.Emulator.ClearSaveRam(); // should this exist?? } public void Stop(bool saveChanges = true) diff --git a/BizHawk.Emulation.Cores/Consoles/WonderSwan/BizSwan.cs b/BizHawk.Emulation.Cores/Consoles/WonderSwan/BizSwan.cs index e1c30b106b..c20643ac99 100644 --- a/BizHawk.Emulation.Cores/Consoles/WonderSwan/BizSwan.cs +++ b/BizHawk.Emulation.Cores/Consoles/WonderSwan/BizSwan.cs @@ -86,6 +86,14 @@ namespace BizHawk.Emulation.Cores.WonderSwan [DllImport(dd, CallingConvention = cc)] public static extern bool bizswan_saveramsave(IntPtr core, byte[] data, int maxsize); + /// + /// bad function + /// + /// + /// pass EXACTLY the same syncsettings you originally passed on core load, else DRAGONS + [DllImport(dd, CallingConvention = cc)] + public static extern void bizswan_saveramclearhacky(IntPtr core, [In] ref SyncSettings settings); + /// /// put non-sync settings, can be done at any time /// diff --git a/BizHawk.Emulation.Cores/Consoles/WonderSwan/WonderSwan.cs b/BizHawk.Emulation.Cores/Consoles/WonderSwan/WonderSwan.cs index 75c3ad4741..bee8490f59 100644 --- a/BizHawk.Emulation.Cores/Consoles/WonderSwan/WonderSwan.cs +++ b/BizHawk.Emulation.Cores/Consoles/WonderSwan/WonderSwan.cs @@ -64,6 +64,9 @@ namespace BizHawk.Emulation.Cores.WonderSwan if (!BizSwan.bizswan_load(Core, rom, rom.Length, ref ss, ref rotate)) throw new InvalidOperationException("bizswan_load() returned FALSE!"); + // for future uses of ClearSaveRam(), it's important that we save this + _DONTTOUCHME = ss; + CoreComm.VsyncNum = 3072000; // master CPU clock, also pixel clock CoreComm.VsyncDen = (144 + 15) * (224 + 32); // 144 vislines, 15 vblank lines; 224 vispixels, 32 hblank pixels @@ -149,7 +152,8 @@ namespace BizHawk.Emulation.Cores.WonderSwan public void ClearSaveRam() { - throw new InvalidOperationException("A new core starts with a clear saveram. Instantiate a new core if you want this."); + BizSwan.bizswan_saveramclearhacky(Core, ref _DONTTOUCHME); + //throw new InvalidOperationException("A new core starts with a clear saveram. Instantiate a new core if you want this."); } public bool SaveRamModified @@ -307,6 +311,7 @@ namespace BizHawk.Emulation.Cores.WonderSwan Settings _Settings; SyncSettings _SyncSettings; + BizSwan.SyncSettings _DONTTOUCHME; public class Settings { diff --git a/output/dll/bizswan.dll b/output/dll/bizswan.dll index 9ad84e4e81..a45545bccc 100644 Binary files a/output/dll/bizswan.dll and b/output/dll/bizswan.dll differ diff --git a/wonderswan/system.cpp b/wonderswan/system.cpp index 0d56e3406a..e87d24b854 100644 --- a/wonderswan/system.cpp +++ b/wonderswan/system.cpp @@ -308,6 +308,13 @@ namespace MDFN_IEN_WSWAN NSS(rotate); } + void System::SaveRamClearHacky(const SyncSettings &s) + { + // this really shouldn't be done + // be sure to pass the same SyncSettings that the core was originally initialized with! + memory.Init(s); + } + EXPORT System *bizswan_new() { return new System(); @@ -397,4 +404,9 @@ namespace MDFN_IEN_WSWAN NewStateExternalFunctions loader(ff); s->SyncState(&loader); } + + EXPORT void bizswan_saveramclearhacky(System *s, const SyncSettings *settings) + { + s->SaveRamClearHacky(*settings); + } } diff --git a/wonderswan/system.h b/wonderswan/system.h index 1893a20239..875d926f53 100644 --- a/wonderswan/system.h +++ b/wonderswan/system.h @@ -45,6 +45,8 @@ public: bool GetMemoryArea(int index, const char *&name, int &size, uint8 *&data); + void SaveRamClearHacky(const SyncSettings &s); + public: GFX gfx; Memory memory;