From c3be2879bc0265073092484010736894d092a075 Mon Sep 17 00:00:00 2001 From: nattthebear Date: Tue, 25 Oct 2016 18:14:20 -0400 Subject: [PATCH] Save state stuff mgba blah I'm bad --- .../Consoles/Nintendo/GBA/MGBAHawk.cs | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBA/MGBAHawk.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBA/MGBAHawk.cs index c1dbd4cec8..0899eb8922 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBA/MGBAHawk.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBA/MGBAHawk.cs @@ -386,7 +386,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBA LoadStateBinary(new BinaryReader(new MemoryStream(state))); } - public void SaveStateBinary(BinaryWriter writer) + private void StartSaveStateBinaryInternal() { IntPtr p = IntPtr.Zero; int size = 0; @@ -398,6 +398,10 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBA _savebuff2 = new byte[size + 13]; } LibmGBA.BizFinishGetState(p, _savebuff, size); + } + + private void FinishSaveStateBinaryInternal(BinaryWriter writer) + { writer.Write(_savebuff.Length); writer.Write(_savebuff, 0, _savebuff.Length); @@ -407,6 +411,12 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBA writer.Write(Frame); } + public void SaveStateBinary(BinaryWriter writer) + { + StartSaveStateBinaryInternal(); + FinishSaveStateBinaryInternal(writer); + } + public void LoadStateBinary(BinaryReader reader) { int length = reader.ReadInt32(); @@ -427,9 +437,10 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBA public byte[] SaveStateBinary() { + StartSaveStateBinaryInternal(); var ms = new MemoryStream(_savebuff2, true); var bw = new BinaryWriter(ms); - SaveStateBinary(bw); + FinishSaveStateBinaryInternal(bw); bw.Flush(); ms.Close(); return _savebuff2;