2014-12-05 03:16:08 +00:00
|
|
|
|
using System.IO;
|
|
|
|
|
|
|
|
|
|
using BizHawk.Common;
|
|
|
|
|
using BizHawk.Emulation.Common;
|
|
|
|
|
|
|
|
|
|
namespace BizHawk.Emulation.Cores.ColecoVision
|
|
|
|
|
{
|
|
|
|
|
public partial class ColecoVision : IStatable
|
|
|
|
|
{
|
2017-10-13 21:50:54 +00:00
|
|
|
|
public bool BinarySaveStatesPreferred
|
|
|
|
|
{
|
|
|
|
|
get { return true; }
|
|
|
|
|
}
|
2014-12-05 03:16:08 +00:00
|
|
|
|
|
2017-10-13 21:50:54 +00:00
|
|
|
|
public void SaveStateText(TextWriter writer)
|
2014-12-05 03:16:08 +00:00
|
|
|
|
{
|
2017-10-13 21:50:54 +00:00
|
|
|
|
SyncState(new Serializer(writer));
|
2014-12-05 03:16:08 +00:00
|
|
|
|
}
|
|
|
|
|
|
2017-10-13 21:50:54 +00:00
|
|
|
|
public void LoadStateText(TextReader reader)
|
2014-12-05 03:16:08 +00:00
|
|
|
|
{
|
2017-10-13 21:50:54 +00:00
|
|
|
|
SyncState(new Serializer(reader));
|
2014-12-05 03:16:08 +00:00
|
|
|
|
}
|
|
|
|
|
|
2017-10-13 21:50:54 +00:00
|
|
|
|
public void SaveStateBinary(BinaryWriter bw)
|
2014-12-05 03:16:08 +00:00
|
|
|
|
{
|
2017-10-13 21:50:54 +00:00
|
|
|
|
SyncState(new Serializer(bw));
|
2014-12-05 03:16:08 +00:00
|
|
|
|
}
|
|
|
|
|
|
2017-10-13 21:50:54 +00:00
|
|
|
|
public void LoadStateBinary(BinaryReader br)
|
2014-12-05 03:16:08 +00:00
|
|
|
|
{
|
2017-10-13 21:50:54 +00:00
|
|
|
|
SyncState(new Serializer(br));
|
2014-12-05 03:16:08 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public byte[] SaveStateBinary()
|
|
|
|
|
{
|
2017-10-13 21:50:54 +00:00
|
|
|
|
MemoryStream ms = new MemoryStream();
|
|
|
|
|
BinaryWriter bw = new BinaryWriter(ms);
|
|
|
|
|
SaveStateBinary(bw);
|
|
|
|
|
bw.Flush();
|
|
|
|
|
return ms.ToArray();
|
2014-12-05 03:16:08 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void SyncState(Serializer ser)
|
|
|
|
|
{
|
2017-10-13 21:50:54 +00:00
|
|
|
|
byte[] core = null;
|
|
|
|
|
if (ser.IsWriter)
|
|
|
|
|
{
|
|
|
|
|
var ms = new MemoryStream();
|
|
|
|
|
ms.Close();
|
|
|
|
|
core = ms.ToArray();
|
|
|
|
|
}
|
2017-05-08 16:37:16 +00:00
|
|
|
|
_cpu.SyncState(ser);
|
2017-10-13 21:50:54 +00:00
|
|
|
|
|
|
|
|
|
ser.BeginSection("Coleco");
|
2017-05-08 16:37:16 +00:00
|
|
|
|
_vdp.SyncState(ser);
|
2018-03-09 00:58:38 +00:00
|
|
|
|
ControllerDeck.SyncState(ser);
|
2014-12-05 03:16:08 +00:00
|
|
|
|
PSG.SyncState(ser);
|
2018-03-03 15:55:15 +00:00
|
|
|
|
SGM_sound.SyncState(ser);
|
|
|
|
|
ser.Sync("UseSGM", ref use_SGM);
|
2019-03-28 03:18:58 +00:00
|
|
|
|
ser.Sync(nameof(is_MC), ref is_MC);
|
|
|
|
|
ser.Sync(nameof(MC_bank), ref MC_bank);
|
2018-03-03 15:55:15 +00:00
|
|
|
|
ser.Sync("EnableSGMhigh", ref enable_SGM_high);
|
|
|
|
|
ser.Sync("EnableSGMlow", ref enable_SGM_low);
|
|
|
|
|
ser.Sync("Port_0x53", ref port_0x53);
|
|
|
|
|
ser.Sync("Port_0x7F", ref port_0x7F);
|
2017-05-08 16:37:16 +00:00
|
|
|
|
ser.Sync("RAM", ref _ram, false);
|
2019-03-28 03:18:58 +00:00
|
|
|
|
ser.Sync(nameof(SGM_high_RAM), ref SGM_high_RAM, false);
|
|
|
|
|
ser.Sync(nameof(SGM_low_RAM), ref SGM_low_RAM, false);
|
2017-05-08 16:37:16 +00:00
|
|
|
|
ser.Sync("Frame", ref _frame);
|
2014-12-05 03:16:08 +00:00
|
|
|
|
ser.Sync("LagCount", ref _lagCount);
|
|
|
|
|
ser.Sync("IsLag", ref _isLag);
|
2018-03-09 00:58:38 +00:00
|
|
|
|
|
2014-12-05 03:16:08 +00:00
|
|
|
|
ser.EndSection();
|
2016-08-22 17:14:47 +00:00
|
|
|
|
|
|
|
|
|
if (ser.IsReader)
|
|
|
|
|
{
|
|
|
|
|
SyncAllByteArrayDomains();
|
|
|
|
|
}
|
2014-12-05 03:16:08 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|