BizHawk/BizHawk.Emulation.Cores/Computers/Commodore64/C64.IStatable.cs

51 lines
1.0 KiB
C#
Raw Normal View History

using System.IO;
using BizHawk.Common;
using BizHawk.Emulation.Common;
2013-11-12 19:22:09 +00:00
namespace BizHawk.Emulation.Cores.Computers.Commodore64
{
2016-02-22 23:50:11 +00:00
public sealed partial class C64 : IStatable
{
2014-12-18 18:39:55 +00:00
public bool BinarySaveStatesPreferred { get { return false; } }
public void LoadStateBinary(BinaryReader br)
{
SyncState(new Serializer(br));
}
public void LoadStateText(TextReader reader)
{
SyncState(new Serializer(reader));
}
public void SaveStateBinary(BinaryWriter bw)
{
SyncState(new Serializer(bw));
}
public void SaveStateText(TextWriter writer)
{
SyncState(new Serializer(writer));
}
2014-12-18 18:39:55 +00:00
public byte[] SaveStateBinary()
{
2016-02-22 23:50:11 +00:00
using (var ms = new MemoryStream())
{
var bw = new BinaryWriter(ms);
SaveStateBinary(bw);
bw.Flush();
return ms.ToArray();
}
}
2014-12-18 18:39:55 +00:00
private void SyncState(Serializer ser)
{
ser.BeginSection("core");
2016-02-22 23:50:11 +00:00
SaveState.SyncObject(ser, this);
ser.EndSection();
}
}
}