implement ClearSaveRam in gambatte core, and fix a bug with using memory domains before any frames have been run
This commit is contained in:
parent
17567b4952
commit
4101efb92d
|
@ -161,6 +161,22 @@ namespace BizHawk.Emulation.Consoles.GB
|
|||
LibGambatte.gambatte_loadsavedata(GambatteState, data);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// reset cart save ram, if any, to initial state
|
||||
/// </summary>
|
||||
public void ClearSaveRam()
|
||||
{
|
||||
int length = LibGambatte.gambatte_savesavedatalength(GambatteState);
|
||||
if (length == 0)
|
||||
return;
|
||||
|
||||
byte[] clear = new byte[length];
|
||||
for (int i = 0; i < clear.Length; i++)
|
||||
clear[i] = 0xff; // this exactly matches what gambatte core does
|
||||
|
||||
StoreSaveRam(clear);
|
||||
}
|
||||
|
||||
|
||||
public bool SaveRamModified
|
||||
{
|
||||
|
@ -278,9 +294,10 @@ namespace BizHawk.Emulation.Consoles.GB
|
|||
CachedMemory = new byte[length];
|
||||
|
||||
writeneeded = false;
|
||||
readneeded = false;
|
||||
// needs to be true in case a read is attempted before the first frame advance
|
||||
readneeded = true;
|
||||
}
|
||||
|
||||
|
||||
bool readneeded;
|
||||
bool writeneeded;
|
||||
|
||||
|
|
|
@ -3436,8 +3436,7 @@ namespace BizHawk.MultiClient
|
|||
if (Global.Emulator is LibsnesCore)
|
||||
((LibsnesCore)Global.Emulator).StoreSaveRam(sram);
|
||||
else if (Global.Emulator is Gameboy)
|
||||
// todo: i don't like this at all. there's no guarantee that a 0-filled sram is even an accurate clear?
|
||||
throw new Exception("Please fix me!");
|
||||
((Gameboy)Global.Emulator).ClearSaveRam();
|
||||
else
|
||||
Array.Copy(sram, Global.Emulator.ReadSaveRam, Global.Emulator.ReadSaveRam.Length);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue