fix n64 savestates

This commit is contained in:
zeromus 2013-11-22 19:34:24 +00:00
parent 4c247672fe
commit 5651181d39
2 changed files with 7 additions and 3 deletions

View File

@ -252,6 +252,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.N64
byte[] saveram = api.SaveSaveram();
writer.Write(saveram);
if (saveram.Length != mupen64plusApi.kSaveramSize)
throw new InvalidOperationException("Unexpected N64 SaveRam size");
// other variables
writer.Write(IsLagFrame);
@ -267,7 +269,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.N64
api.LoadState(data);
reader.Read(SaveStatePrivateBuff,0,0x800 + 0x8000 * 4);
reader.Read(SaveStatePrivateBuff, 0, mupen64plusApi.kSaveramSize);
api.LoadSaveram(SaveStatePrivateBuff);
// other variables

View File

@ -792,6 +792,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.N64
m64pinit_saveram();
}
public const int kSaveramSize = 0x800 + 4 * 0x8000 + 0x20000 + 0x8000;
public byte[] SaveSaveram()
{
if (disposed)
@ -803,12 +805,12 @@ namespace BizHawk.Emulation.Cores.Nintendo.N64
else
{
// This shouldn't happen!!
return new byte[0x800 + 4 * 0x8000 + 0x20000 + 0x8000];
return new byte[kSaveramSize];
}
}
else
{
byte[] dest = new byte[0x800 + 4 * 0x8000 + 0x20000 + 0x8000];
byte[] dest = new byte[kSaveramSize];
m64psave_saveram(dest);
return dest;
}