diff --git a/BizHawk.Emulation/Consoles/Sega/Saturn/LibYabause.cs b/BizHawk.Emulation/Consoles/Sega/Saturn/LibYabause.cs index 518510d7c4..05e98c4cc2 100644 --- a/BizHawk.Emulation/Consoles/Sega/Saturn/LibYabause.cs +++ b/BizHawk.Emulation/Consoles/Sega/Saturn/LibYabause.cs @@ -101,6 +101,13 @@ namespace BizHawk.Emulation.Consoles.Sega.Saturn [DllImport("libyabause.dll", CallingConvention = CallingConvention.Cdecl)] public static extern void libyabause_deinit(); + [DllImport("libyabause.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern bool libyabause_savesaveram(string fn); + [DllImport("libyabause.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern bool libyabause_loadsaveram(string fn); + [DllImport("libyabause.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern void libyabause_clearsaveram(); + /// /// /// diff --git a/BizHawk.Emulation/Consoles/Sega/Saturn/Yabause.cs b/BizHawk.Emulation/Consoles/Sega/Saturn/Yabause.cs index cfd7062399..b85cbe79a5 100644 --- a/BizHawk.Emulation/Consoles/Sega/Saturn/Yabause.cs +++ b/BizHawk.Emulation/Consoles/Sega/Saturn/Yabause.cs @@ -154,9 +154,7 @@ namespace BizHawk.Emulation.Consoles.Sega.Saturn if (Controller["Reset"]) LibYabause.libyabause_softreset(); if (Controller["Power"]) - { - // TODO - } + LibYabause.libyabause_hardreset(); LibYabause.libyabause_setpads(p11, p12, p21, p22); @@ -177,25 +175,49 @@ namespace BizHawk.Emulation.Consoles.Sega.Saturn public string SystemId { get { return "SAT"; } } public bool DeterministicEmulation { get { return true; } } + #region saveram + public byte[] ReadSaveRam() { - return new byte[0]; + var ms = new MemoryStream(); + var fp = new FilePiping(); + fp.Get(ms); + bool success = LibYabause.libyabause_savesaveram(fp.GetPipeNameNative()); + var e = fp.GetResults(); + if (e != null) + throw e; + if (!success) + throw new Exception("libyabause_savesaveram() failed!"); + var ret = ms.ToArray(); + ms.Dispose(); + return ret; } public void StoreSaveRam(byte[] data) { + var fp = new FilePiping(); + fp.Offer(data); + bool success = LibYabause.libyabause_loadsaveram(fp.GetPipeNameNative()); + var e = fp.GetResults(); + if (e != null) + throw e; + if (!success) + throw new Exception("libyabause_loadsaveram() failed!"); } public void ClearSaveRam() { + LibYabause.libyabause_clearsaveram(); } public bool SaveRamModified { - get; - set; + get { return true; } + set { if (!value) throw new InvalidOperationException(); } } + #endregion + public void ResetFrameCounter() { Frame = 0; @@ -295,7 +317,7 @@ namespace BizHawk.Emulation.Consoles.Sega.Saturn return ms.ToArray(); } -#endregion + #endregion public CoreComm CoreComm { get; private set; } @@ -345,29 +367,11 @@ namespace BizHawk.Emulation.Consoles.Sega.Saturn samples = SoundBuffer; } - public void DiscardSamples() - { - } - - public ISoundProvider SoundProvider - { - get { return null; } - } - - public ISyncSoundProvider SyncSoundProvider - { - get { return this; } - } - - public bool StartAsyncSound() - { - return false; - } - - public void EndAsyncSound() - { - - } + public void DiscardSamples() { } + public ISoundProvider SoundProvider { get { return null; } } + public ISyncSoundProvider SyncSoundProvider { get { return this; } } + public bool StartAsyncSound() { return false; } + public void EndAsyncSound() { } #endregion diff --git a/BizHawk.MultiClient/output/dll/libyabause.dll b/BizHawk.MultiClient/output/dll/libyabause.dll index 1e27372ff7..909a2d4957 100644 Binary files a/BizHawk.MultiClient/output/dll/libyabause.dll and b/BizHawk.MultiClient/output/dll/libyabause.dll differ diff --git a/yabause/src/libyabause/yui.cpp b/yabause/src/libyabause/yui.cpp index 38e3472de1..2796e59819 100644 --- a/yabause/src/libyabause/yui.cpp +++ b/yabause/src/libyabause/yui.cpp @@ -192,6 +192,21 @@ extern "C" __declspec(dllexport) int libyabause_savestate(const char *fn) return !YabSaveState(fn); } +extern "C" __declspec(dllexport) int libyabause_savesaveram(const char *fn) +{ + return !T123Save(BupRam, 0x10000, 1, fn); +} + +extern "C" __declspec(dllexport) int libyabause_loadsaveram(const char *fn) +{ + return !T123Load(BupRam, 0x10000, 1, fn); +} + +extern "C" __declspec(dllexport) void libyabause_clearsaveram() +{ + FormatBackupRam(BupRam, 0x10000); +} + extern "C" __declspec(dllexport) int libyabause_frameadvance(int *w, int *h, int *nsamp) { LagFrameFlag = 1;