Atari 2600/7800 - break off IStatable stuff
This commit is contained in:
parent
6a3955bde0
commit
ce3f7ae3ac
|
@ -165,6 +165,9 @@
|
||||||
<Compile Include="Consoles\Atari\2600\Atari2600.ISettable.cs">
|
<Compile Include="Consoles\Atari\2600\Atari2600.ISettable.cs">
|
||||||
<DependentUpon>Atari2600.cs</DependentUpon>
|
<DependentUpon>Atari2600.cs</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
<Compile Include="Consoles\Atari\2600\Atari2600.IStatable.cs">
|
||||||
|
<DependentUpon>Atari2600.cs</DependentUpon>
|
||||||
|
</Compile>
|
||||||
<Compile Include="Consoles\Atari\2600\Atari2600.RomHeuristics.cs">
|
<Compile Include="Consoles\Atari\2600\Atari2600.RomHeuristics.cs">
|
||||||
<DependentUpon>Atari2600.cs</DependentUpon>
|
<DependentUpon>Atari2600.cs</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
@ -216,6 +219,9 @@
|
||||||
<Compile Include="Consoles\Atari\7800\Atari7800.IMemoryDomains.cs">
|
<Compile Include="Consoles\Atari\7800\Atari7800.IMemoryDomains.cs">
|
||||||
<DependentUpon>Atari7800.cs</DependentUpon>
|
<DependentUpon>Atari7800.cs</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
<Compile Include="Consoles\Atari\7800\Atari7800.IStatable.cs">
|
||||||
|
<DependentUpon>Atari7800.cs</DependentUpon>
|
||||||
|
</Compile>
|
||||||
<Compile Include="Consoles\Atari\7800\Atari7800Control.cs" />
|
<Compile Include="Consoles\Atari\7800\Atari7800Control.cs" />
|
||||||
<Compile Include="Consoles\Atari\7800\Atari7800.ISaveRam.cs">
|
<Compile Include="Consoles\Atari\7800\Atari7800.ISaveRam.cs">
|
||||||
<DependentUpon>Atari7800.cs</DependentUpon>
|
<DependentUpon>Atari7800.cs</DependentUpon>
|
||||||
|
|
|
@ -0,0 +1,61 @@
|
||||||
|
using System.IO;
|
||||||
|
|
||||||
|
using BizHawk.Common;
|
||||||
|
using BizHawk.Emulation.Common;
|
||||||
|
|
||||||
|
namespace BizHawk.Emulation.Cores.Atari.Atari2600
|
||||||
|
{
|
||||||
|
public partial class Atari2600 : IStatable
|
||||||
|
{
|
||||||
|
public bool BinarySaveStatesPreferred
|
||||||
|
{
|
||||||
|
get { return false; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SaveStateText(TextWriter writer)
|
||||||
|
{
|
||||||
|
SyncState(Serializer.CreateTextWriter(writer));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void LoadStateText(TextReader reader)
|
||||||
|
{
|
||||||
|
SyncState(Serializer.CreateTextReader(reader));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SaveStateBinary(BinaryWriter bw)
|
||||||
|
{
|
||||||
|
SyncState(Serializer.CreateBinaryWriter(bw));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void LoadStateBinary(BinaryReader br)
|
||||||
|
{
|
||||||
|
SyncState(Serializer.CreateBinaryReader(br));
|
||||||
|
}
|
||||||
|
|
||||||
|
public byte[] SaveStateBinary()
|
||||||
|
{
|
||||||
|
var ms = new MemoryStream();
|
||||||
|
var bw = new BinaryWriter(ms);
|
||||||
|
SaveStateBinary(bw);
|
||||||
|
bw.Flush();
|
||||||
|
return ms.ToArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SyncState(Serializer ser)
|
||||||
|
{
|
||||||
|
ser.BeginSection("A2600");
|
||||||
|
Cpu.SyncState(ser);
|
||||||
|
ser.Sync("ram", ref this.Ram, false);
|
||||||
|
ser.Sync("Lag", ref _lagcount);
|
||||||
|
ser.Sync("Frame", ref _frame);
|
||||||
|
ser.Sync("IsLag", ref _islag);
|
||||||
|
ser.Sync("frameStartPending", ref _frameStartPending);
|
||||||
|
_tia.SyncState(ser);
|
||||||
|
M6532.SyncState(ser);
|
||||||
|
ser.BeginSection("Mapper");
|
||||||
|
_mapper.SyncState(ser);
|
||||||
|
ser.EndSection();
|
||||||
|
ser.EndSection();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -75,8 +75,6 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
|
||||||
|
|
||||||
public bool DeterministicEmulation { get; set; }
|
public bool DeterministicEmulation { get; set; }
|
||||||
|
|
||||||
public bool BinarySaveStatesPreferred { get { return false; } }
|
|
||||||
|
|
||||||
public A2600Settings Settings { get; private set; }
|
public A2600Settings Settings { get; private set; }
|
||||||
|
|
||||||
public A2600SyncSettings SyncSettings { get; private set; }
|
public A2600SyncSettings SyncSettings { get; private set; }
|
||||||
|
@ -120,8 +118,6 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public bool StartAsyncSound() { return true; }
|
public bool StartAsyncSound() { return true; }
|
||||||
|
|
||||||
public void EndAsyncSound() { }
|
public void EndAsyncSound() { }
|
||||||
|
@ -133,52 +129,6 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
|
||||||
_islag = false;
|
_islag = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SyncState(Serializer ser)
|
|
||||||
{
|
|
||||||
ser.BeginSection("A2600");
|
|
||||||
Cpu.SyncState(ser);
|
|
||||||
ser.Sync("ram", ref this.Ram, false);
|
|
||||||
ser.Sync("Lag", ref _lagcount);
|
|
||||||
ser.Sync("Frame", ref _frame);
|
|
||||||
ser.Sync("IsLag", ref _islag);
|
|
||||||
ser.Sync("frameStartPending", ref _frameStartPending);
|
|
||||||
_tia.SyncState(ser);
|
|
||||||
M6532.SyncState(ser);
|
|
||||||
ser.BeginSection("Mapper");
|
|
||||||
_mapper.SyncState(ser);
|
|
||||||
ser.EndSection();
|
|
||||||
ser.EndSection();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void SaveStateText(TextWriter writer)
|
|
||||||
{
|
|
||||||
SyncState(Serializer.CreateTextWriter(writer));
|
|
||||||
}
|
|
||||||
|
|
||||||
public void LoadStateText(TextReader reader)
|
|
||||||
{
|
|
||||||
SyncState(Serializer.CreateTextReader(reader));
|
|
||||||
}
|
|
||||||
|
|
||||||
public void SaveStateBinary(BinaryWriter bw)
|
|
||||||
{
|
|
||||||
SyncState(Serializer.CreateBinaryWriter(bw));
|
|
||||||
}
|
|
||||||
|
|
||||||
public void LoadStateBinary(BinaryReader br)
|
|
||||||
{
|
|
||||||
SyncState(Serializer.CreateBinaryReader(br));
|
|
||||||
}
|
|
||||||
|
|
||||||
public byte[] SaveStateBinary()
|
|
||||||
{
|
|
||||||
var ms = new MemoryStream();
|
|
||||||
var bw = new BinaryWriter(ms);
|
|
||||||
SaveStateBinary(bw);
|
|
||||||
bw.Flush();
|
|
||||||
return ms.ToArray();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Dispose() { }
|
public void Dispose() { }
|
||||||
|
|
||||||
private static bool DetectPal(GameInfo game, byte[] rom)
|
private static bool DetectPal(GameInfo game, byte[] rom)
|
||||||
|
|
|
@ -0,0 +1,66 @@
|
||||||
|
using System.IO;
|
||||||
|
|
||||||
|
using BizHawk.Common;
|
||||||
|
using BizHawk.Emulation.Common;
|
||||||
|
using EMU7800.Core;
|
||||||
|
|
||||||
|
namespace BizHawk.Emulation.Cores.Atari.Atari7800
|
||||||
|
{
|
||||||
|
public partial class Atari7800 : IStatable
|
||||||
|
{
|
||||||
|
public bool BinarySaveStatesPreferred { get { return true; } }
|
||||||
|
|
||||||
|
public void SaveStateText(TextWriter writer)
|
||||||
|
{
|
||||||
|
SyncState(new Serializer(writer));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void LoadStateText(TextReader reader)
|
||||||
|
{
|
||||||
|
SyncState(new Serializer(reader));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SaveStateBinary(BinaryWriter bw)
|
||||||
|
{
|
||||||
|
SyncState(new Serializer(bw));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void LoadStateBinary(BinaryReader br)
|
||||||
|
{
|
||||||
|
SyncState(new Serializer(br));
|
||||||
|
}
|
||||||
|
|
||||||
|
public byte[] SaveStateBinary()
|
||||||
|
{
|
||||||
|
MemoryStream ms = new MemoryStream();
|
||||||
|
BinaryWriter bw = new BinaryWriter(ms);
|
||||||
|
SaveStateBinary(bw);
|
||||||
|
bw.Flush();
|
||||||
|
return ms.ToArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SyncState(Serializer ser)
|
||||||
|
{
|
||||||
|
byte[] core = null;
|
||||||
|
if (ser.IsWriter)
|
||||||
|
{
|
||||||
|
var ms = new MemoryStream();
|
||||||
|
theMachine.Serialize(new BinaryWriter(ms));
|
||||||
|
ms.Close();
|
||||||
|
core = ms.ToArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
ser.BeginSection("Atari7800");
|
||||||
|
ser.Sync("core", ref core, false);
|
||||||
|
ser.Sync("Lag", ref _lagcount);
|
||||||
|
ser.Sync("Frame", ref _frame);
|
||||||
|
ser.Sync("IsLag", ref _islag);
|
||||||
|
ser.EndSection();
|
||||||
|
if (ser.IsReader)
|
||||||
|
{
|
||||||
|
theMachine = MachineBase.Deserialize(new BinaryReader(new MemoryStream(core, false)));
|
||||||
|
avProvider.ConnectToMachine(theMachine, GameInfo);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -87,7 +87,6 @@ namespace BizHawk.Emulation.Cores.Atari.Atari7800
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void ResetCounters()
|
public void ResetCounters()
|
||||||
{
|
{
|
||||||
_frame = 0;
|
_frame = 0;
|
||||||
|
@ -95,46 +94,6 @@ namespace BizHawk.Emulation.Cores.Atari.Atari7800
|
||||||
_islag = false;
|
_islag = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
#region savestates
|
|
||||||
public void SaveStateText(TextWriter writer) { SyncState(new Serializer(writer)); }
|
|
||||||
public void LoadStateText(TextReader reader) { SyncState(new Serializer(reader)); }
|
|
||||||
public void SaveStateBinary(BinaryWriter bw) { SyncState(new Serializer(bw)); }
|
|
||||||
public void LoadStateBinary(BinaryReader br) { SyncState(new Serializer(br)); }
|
|
||||||
public byte[] SaveStateBinary()
|
|
||||||
{
|
|
||||||
MemoryStream ms = new MemoryStream();
|
|
||||||
BinaryWriter bw = new BinaryWriter(ms);
|
|
||||||
SaveStateBinary(bw);
|
|
||||||
bw.Flush();
|
|
||||||
return ms.ToArray();
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool BinarySaveStatesPreferred { get { return true; } }
|
|
||||||
|
|
||||||
void SyncState(Serializer ser)
|
|
||||||
{
|
|
||||||
byte[] core = null;
|
|
||||||
if (ser.IsWriter)
|
|
||||||
{
|
|
||||||
var ms = new MemoryStream();
|
|
||||||
theMachine.Serialize(new BinaryWriter(ms));
|
|
||||||
ms.Close();
|
|
||||||
core = ms.ToArray();
|
|
||||||
}
|
|
||||||
ser.BeginSection("Atari7800");
|
|
||||||
ser.Sync("core", ref core, false);
|
|
||||||
ser.Sync("Lag", ref _lagcount);
|
|
||||||
ser.Sync("Frame", ref _frame);
|
|
||||||
ser.Sync("IsLag", ref _islag);
|
|
||||||
ser.EndSection();
|
|
||||||
if (ser.IsReader)
|
|
||||||
{
|
|
||||||
theMachine = MachineBase.Deserialize(new BinaryReader(new MemoryStream(core, false)));
|
|
||||||
avProvider.ConnectToMachine(theMachine, GameInfo);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
public Atari7800Control ControlAdapter;
|
public Atari7800Control ControlAdapter;
|
||||||
|
|
||||||
public ControllerDefinition ControllerDefinition { get; private set; }
|
public ControllerDefinition ControllerDefinition { get; private set; }
|
||||||
|
|
Loading…
Reference in New Issue