c64 - savestate refactor round 1 - do explicit savestating for the root C64 object

This commit is contained in:
adelikat 2017-05-12 16:26:04 -05:00
parent 1222b4d5b5
commit 383baa6d1e
4 changed files with 39 additions and 17 deletions

View File

@ -32,8 +32,8 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64
public void ResetCounters()
{
_frame = 0;
LagCount = 0;
IsLagFrame = false;
_lagCount = 0;
_isLagFrame = false;
_frameCycles = 0;
}

View File

@ -2,12 +2,24 @@
namespace BizHawk.Emulation.Cores.Computers.Commodore64
{
public partial class C64 : IInputPollable
public partial class C64// : IInputPollable
{
public bool IsLagFrame { get; set; }
public int LagCount { get; set; }
public bool IsLagFrame
{
get { return _isLagFrame; }
set { _isLagFrame = value; }
}
public int LagCount
{
get { return _lagCount; }
set { _lagCount = value; }
}
[SaveState.DoNotSave]
public IInputCallbackSystem InputCallbacks { get; private set; }
private bool _isLagFrame;
private int _lagCount;
}
}

View File

@ -31,19 +31,25 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64
public byte[] SaveStateBinary()
{
using (var ms = new MemoryStream())
{
var bw = new BinaryWriter(ms);
SaveStateBinary(bw);
bw.Flush();
return ms.ToArray();
}
}
using (var ms = new MemoryStream())
{
var bw = new BinaryWriter(ms);
SaveStateBinary(bw);
bw.Flush();
return ms.ToArray();
}
}
private void SyncState(Serializer ser)
{
ser.BeginSection("core");
SaveState.SyncObject(ser, this);
ser.Sync("_frameCycles", ref _frameCycles);
ser.Sync("Frame", ref _frame);
ser.Sync("IsLagFrame", ref _isLagFrame);
ser.Sync("LagCount", ref _lagCount);
ser.BeginSection("Board");
SaveState.SyncObject(ser, _board);
ser.EndSection();
ser.EndSection();
}
}

View File

@ -60,6 +60,7 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64
{
get
{
return SaveState.InspectProperties(this);
if (_board.CartPort.IsConnected)
{
return _board.CartPort.CartridgeType;
@ -135,10 +136,13 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64
}
_board.Flush();
IsLagFrame = !_board.InputRead;
_isLagFrame = !_board.InputRead;
if (_isLagFrame)
{
_lagCount++;
}
if (IsLagFrame)
LagCount++;
_frameCycles -= _cyclesPerFrame;
_frame++;
}