2016-08-09 17:03:23 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.IO;
|
|
|
|
|
|
|
|
|
|
using BizHawk.Common.BufferExtensions;
|
|
|
|
|
using BizHawk.Emulation.Common;
|
|
|
|
|
|
2016-08-10 19:27:46 +00:00
|
|
|
|
namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx64
|
2016-08-09 17:03:23 +00:00
|
|
|
|
{
|
|
|
|
|
public partial class GPGX : IStatable
|
|
|
|
|
{
|
|
|
|
|
public bool BinarySaveStatesPreferred
|
|
|
|
|
{
|
|
|
|
|
get { return true; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void SaveStateText(TextWriter writer)
|
|
|
|
|
{
|
|
|
|
|
var temp = SaveStateBinary();
|
|
|
|
|
temp.SaveAsHexFast(writer);
|
|
|
|
|
// write extra copy of stuff we don't use
|
|
|
|
|
writer.WriteLine("Frame {0}", Frame);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void LoadStateText(TextReader reader)
|
|
|
|
|
{
|
|
|
|
|
string hex = reader.ReadLine();
|
|
|
|
|
byte[] state = new byte[hex.Length / 2];
|
|
|
|
|
state.ReadFromHexFast(hex);
|
|
|
|
|
LoadStateBinary(new BinaryReader(new MemoryStream(state)));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void LoadStateBinary(BinaryReader reader)
|
|
|
|
|
{
|
2016-08-10 19:27:46 +00:00
|
|
|
|
Elf.LoadStateBinary(reader);
|
2016-08-09 17:03:23 +00:00
|
|
|
|
// other variables
|
|
|
|
|
Frame = reader.ReadInt32();
|
|
|
|
|
LagCount = reader.ReadInt32();
|
|
|
|
|
IsLagFrame = reader.ReadBoolean();
|
2016-08-10 19:27:46 +00:00
|
|
|
|
// any managed pointers that we sent to the core need to be resent now!
|
|
|
|
|
Core.gpgx_set_input_callback(InputCallback);
|
|
|
|
|
RefreshMemCallbacks();
|
|
|
|
|
Core.gpgx_set_cdd_callback(cd_callback_handle);
|
|
|
|
|
Core.gpgx_invalidate_pattern_cache();
|
2016-08-09 17:03:23 +00:00
|
|
|
|
UpdateVideo();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void SaveStateBinary(BinaryWriter writer)
|
|
|
|
|
{
|
2016-08-10 19:27:46 +00:00
|
|
|
|
Elf.SaveStateBinary(writer);
|
2016-08-09 17:03:23 +00:00
|
|
|
|
// other variables
|
|
|
|
|
writer.Write(Frame);
|
|
|
|
|
writer.Write(LagCount);
|
|
|
|
|
writer.Write(IsLagFrame);
|
|
|
|
|
}
|
|
|
|
|
|
2016-08-10 19:27:46 +00:00
|
|
|
|
public byte[] SaveStateBinary()
|
|
|
|
|
{
|
|
|
|
|
var ms = new MemoryStream();
|
|
|
|
|
var bw = new BinaryWriter(ms);
|
|
|
|
|
SaveStateBinary(bw);
|
|
|
|
|
bw.Flush();
|
|
|
|
|
ms.Close();
|
|
|
|
|
return ms.ToArray();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void InitStateBuffers()
|
|
|
|
|
{
|
|
|
|
|
}
|
2016-08-09 17:03:23 +00:00
|
|
|
|
}
|
|
|
|
|
}
|