TI83 - break off code into TI83.IStatable.cs
This commit is contained in:
parent
76148ae111
commit
093180f652
|
@ -95,6 +95,9 @@
|
|||
<Compile Include="Calculator\TI83.IDebuggable.cs">
|
||||
<DependentUpon>TI83.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Calculator\TI83.IStatable.cs">
|
||||
<DependentUpon>TI83.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Calculator\TI83LinkPort.cs" />
|
||||
<Compile Include="Computers\Commodore64\C64.Core.cs" />
|
||||
<Compile Include="Computers\Commodore64\C64.cs" />
|
||||
|
@ -208,14 +211,14 @@
|
|||
<Compile Include="Consoles\Atari\2600\Tia\Tia.PlayfieldData.cs" />
|
||||
<Compile Include="Consoles\Atari\7800\Atari7800.cs" />
|
||||
<Compile Include="Consoles\Atari\7800\Atari7800.IDebuggable.cs">
|
||||
<DependentUpon>Atari7800.cs</DependentUpon>
|
||||
<DependentUpon>Atari7800.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Consoles\Atari\7800\Atari7800.IMemoryDomains.cs">
|
||||
<DependentUpon>Atari7800.cs</DependentUpon>
|
||||
<DependentUpon>Atari7800.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Consoles\Atari\7800\Atari7800Control.cs" />
|
||||
<Compile Include="Consoles\Atari\7800\Atari7800.ISaveRam.cs">
|
||||
<DependentUpon>Atari7800.cs</DependentUpon>
|
||||
<DependentUpon>Atari7800.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Consoles\Atari\lynx\LibLynx.cs" />
|
||||
<Compile Include="Consoles\Atari\lynx\Lynx.cs" />
|
||||
|
|
|
@ -0,0 +1,81 @@
|
|||
using System.IO;
|
||||
|
||||
using BizHawk.Common;
|
||||
using BizHawk.Emulation.Common;
|
||||
|
||||
namespace BizHawk.Emulation.Cores.Calculators
|
||||
{
|
||||
public partial class TI83 : IStatable
|
||||
{
|
||||
private byte[] _stateBuffer;
|
||||
|
||||
public bool BinarySaveStatesPreferred
|
||||
{
|
||||
get { return false; }
|
||||
}
|
||||
|
||||
public void SaveStateBinary(BinaryWriter bw)
|
||||
{
|
||||
SyncState(Serializer.CreateBinaryWriter(bw));
|
||||
}
|
||||
|
||||
public void LoadStateBinary(BinaryReader br)
|
||||
{
|
||||
SyncState(Serializer.CreateBinaryReader(br));
|
||||
}
|
||||
|
||||
public void SaveStateText(TextWriter tw)
|
||||
{
|
||||
SyncState(Serializer.CreateTextWriter(tw));
|
||||
}
|
||||
|
||||
public void LoadStateText(TextReader tr)
|
||||
{
|
||||
SyncState(Serializer.CreateTextReader(tr));
|
||||
}
|
||||
|
||||
public byte[] SaveStateBinary()
|
||||
{
|
||||
if (_stateBuffer == null)
|
||||
{
|
||||
var stream = new MemoryStream();
|
||||
var writer = new BinaryWriter(stream);
|
||||
SaveStateBinary(writer);
|
||||
_stateBuffer = stream.ToArray();
|
||||
writer.Close();
|
||||
return _stateBuffer;
|
||||
}
|
||||
else
|
||||
{
|
||||
var stream = new MemoryStream(_stateBuffer);
|
||||
var writer = new BinaryWriter(stream);
|
||||
SaveStateBinary(writer);
|
||||
writer.Close();
|
||||
return _stateBuffer;
|
||||
}
|
||||
}
|
||||
|
||||
private void SyncState(Serializer ser)
|
||||
{
|
||||
ser.BeginSection("TI83");
|
||||
cpu.SyncState(ser);
|
||||
ser.Sync("RAM", ref ram, false);
|
||||
ser.Sync("romPageLow3Bits", ref romPageLow3Bits);
|
||||
ser.Sync("romPageHighBit", ref romPageHighBit);
|
||||
ser.Sync("disp_mode", ref disp_mode);
|
||||
ser.Sync("disp_move", ref disp_move);
|
||||
ser.Sync("disp_x", ref disp_x);
|
||||
ser.Sync("disp_y", ref disp_y);
|
||||
ser.Sync("m_CursorMoved", ref m_CursorMoved);
|
||||
ser.Sync("maskOn", ref maskOn);
|
||||
ser.Sync("onPressed", ref onPressed);
|
||||
ser.Sync("keyboardMask", ref keyboardMask);
|
||||
ser.Sync("m_LinkOutput", ref m_LinkOutput);
|
||||
ser.Sync("VRAM", ref vram, false);
|
||||
ser.Sync("Frame", ref frame);
|
||||
ser.Sync("LagCount", ref lagCount);
|
||||
ser.Sync("IsLag", ref isLag);
|
||||
ser.EndSection();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -524,57 +524,6 @@ namespace BizHawk.Emulation.Cores.Calculators
|
|||
|
||||
public bool DeterministicEmulation { get { return true; } }
|
||||
|
||||
public bool BinarySaveStatesPreferred { get { return false; } }
|
||||
public void SaveStateBinary(BinaryWriter bw) { SyncState(Serializer.CreateBinaryWriter(bw)); }
|
||||
public void LoadStateBinary(BinaryReader br) { SyncState(Serializer.CreateBinaryReader(br)); }
|
||||
public void SaveStateText(TextWriter tw) { SyncState(Serializer.CreateTextWriter(tw)); }
|
||||
public void LoadStateText(TextReader tr) { SyncState(Serializer.CreateTextReader(tr)); }
|
||||
|
||||
private void SyncState(Serializer ser)
|
||||
{
|
||||
ser.BeginSection("TI83");
|
||||
cpu.SyncState(ser);
|
||||
ser.Sync("RAM", ref ram, false);
|
||||
ser.Sync("romPageLow3Bits", ref romPageLow3Bits);
|
||||
ser.Sync("romPageHighBit", ref romPageHighBit);
|
||||
ser.Sync("disp_mode", ref disp_mode);
|
||||
ser.Sync("disp_move", ref disp_move);
|
||||
ser.Sync("disp_x", ref disp_x);
|
||||
ser.Sync("disp_y", ref disp_y);
|
||||
ser.Sync("m_CursorMoved", ref m_CursorMoved);
|
||||
ser.Sync("maskOn", ref maskOn);
|
||||
ser.Sync("onPressed", ref onPressed);
|
||||
ser.Sync("keyboardMask", ref keyboardMask);
|
||||
ser.Sync("m_LinkOutput", ref m_LinkOutput);
|
||||
ser.Sync("VRAM", ref vram, false);
|
||||
ser.Sync("Frame", ref frame);
|
||||
ser.Sync("LagCount", ref lagCount);
|
||||
ser.Sync("IsLag", ref isLag);
|
||||
ser.EndSection();
|
||||
}
|
||||
|
||||
private byte[] stateBuffer;
|
||||
public byte[] SaveStateBinary()
|
||||
{
|
||||
if (stateBuffer == null)
|
||||
{
|
||||
var stream = new MemoryStream();
|
||||
var writer = new BinaryWriter(stream);
|
||||
SaveStateBinary(writer);
|
||||
stateBuffer = stream.ToArray();
|
||||
writer.Close();
|
||||
return stateBuffer;
|
||||
}
|
||||
else
|
||||
{
|
||||
var stream = new MemoryStream(stateBuffer);
|
||||
var writer = new BinaryWriter(stream);
|
||||
SaveStateBinary(writer);
|
||||
writer.Close();
|
||||
return stateBuffer;
|
||||
}
|
||||
}
|
||||
|
||||
public string SystemId { get { return "TI83"; } }
|
||||
public string BoardName { get { return null; } }
|
||||
|
||||
|
|
Loading…
Reference in New Issue