libsnescore: make deterministic mode savestates all the same size (previously, frame 0 savestates were slightly smaller)

rewind: throw a slightly more intelligible exception message when savestates differ in size
This commit is contained in:
goyuken 2012-10-08 18:18:43 +00:00
parent 039987cbd3
commit c24abbcbad
2 changed files with 10 additions and 0 deletions

View File

@ -447,6 +447,8 @@ namespace BizHawk.Emulation.Consoles.Nintendo.SNES
BinaryWriter bw = new BinaryWriter(ms);
bw.Write(CoreSaveState());
bw.Write(true); // framezero, so no controller follows and don't frameadvance on load
// hack: write fake dummy controller info
bw.Write(new byte[536]);
bw.Close();
savestatebuff = ms.ToArray();
}
@ -868,6 +870,10 @@ namespace BizHawk.Emulation.Consoles.Nintendo.SNES
this.Controller = tmp;
ssc.Serialize(bw);
}
else // hack: dummy controller info
{
bw.Write(reader.ReadBytes(536));
}
bw.Close();
savestatebuff = ms.ToArray();
}

View File

@ -39,6 +39,8 @@ namespace BizHawk.MultiClient
void CaptureRewindState64K()
{
byte[] CurrentState = Global.Emulator.SaveStateBinary();
if (CurrentState.Length != LastState.Length)
throw new System.Exception(string.Format("Rewind error: Savestate size mismatch:{0} old {1} new", LastState.Length, CurrentState.Length));
int beginChangeSequence = -1;
bool inChangeSequence = false;
var ms = new MemoryStream();
@ -83,6 +85,8 @@ namespace BizHawk.MultiClient
void CaptureRewindStateLarge()
{
byte[] CurrentState = Global.Emulator.SaveStateBinary();
if (CurrentState.Length != LastState.Length)
throw new System.Exception(string.Format("Rewind error: Savestate size mismatch:{0} old {1} new", LastState.Length, CurrentState.Length));
int beginChangeSequence = -1;
bool inChangeSequence = false;
var ms = new MemoryStream();