saturn: fix saveram problem

This commit is contained in:
goyuken 2013-05-09 00:47:16 +00:00
parent 7becee2284
commit aa73071870
1 changed files with 53 additions and 22 deletions

View File

@ -26,6 +26,7 @@ namespace BizHawk.Emulation.Consoles.Sega.Saturn
GCHandle SoundHandle;
bool Disposed = false;
byte[] DisposedSaveRam;
LibYabause.CDInterface.Init InitH;
LibYabause.CDInterface.DeInit DeInitH;
@ -182,6 +183,12 @@ namespace BizHawk.Emulation.Consoles.Sega.Saturn
#region saveram
public byte[] ReadSaveRam()
{
if (Disposed)
{
return DisposedSaveRam ?? new byte[0];
}
else
{
var ms = new MemoryStream();
var fp = new FilePiping();
@ -197,7 +204,15 @@ namespace BizHawk.Emulation.Consoles.Sega.Saturn
return ret;
}
}
public void StoreSaveRam(byte[] data)
{
if (Disposed)
{
throw new Exception("It's a bit late for that");
}
else
{
var fp = new FilePiping();
fp.Offer(data);
@ -208,15 +223,29 @@ namespace BizHawk.Emulation.Consoles.Sega.Saturn
if (!success)
throw new Exception("libyabause_loadsaveram() failed!");
}
}
public void ClearSaveRam()
{
if (Disposed)
{
throw new Exception("It's a bit late for that");
}
else
{
LibYabause.libyabause_clearsaveram();
}
}
public bool SaveRamModified
{
get { return LibYabause.libyabause_saveramodified(); }
get
{
if (Disposed)
return DisposedSaveRam != null;
else
return LibYabause.libyabause_saveramodified();
}
set { throw new InvalidOperationException("No you may not!"); }
}
@ -407,6 +436,8 @@ namespace BizHawk.Emulation.Consoles.Sega.Saturn
{
if (!Disposed)
{
if (SaveRamModified)
DisposedSaveRam = ReadSaveRam();
LibYabause.libyabause_setvidbuff(IntPtr.Zero);
LibYabause.libyabause_setsndbuff(IntPtr.Zero);
LibYabause.libyabause_deinit();