Apply savestate changes to disk subsystem.

This commit is contained in:
Anthony Konzel 2016-03-01 14:01:56 -06:00
parent 70e1a2ca29
commit 43ac625a95
5 changed files with 96 additions and 51 deletions

View File

@ -8,18 +8,29 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.Serial
{
public sealed partial class Drive1541
{
[SaveState.DoNotSave]
private const long LEHMER_RNG_PRIME = 48271;
[SaveState.SaveWithName("DiskDensityCounter")]
private int _diskDensityCounter; // density .. 16
[SaveState.SaveWithName("DiskSupplementaryCounter")]
private int _diskSupplementaryCounter; // 0 .. 16
[SaveState.SaveWithName("DiskFluxReversalDetected")]
private bool _diskFluxReversalDetected;
[SaveState.SaveWithName("DiskBitsRemainingInDataEntry")]
private int _diskBitsLeft;
[SaveState.SaveWithName("DiskDataEntryIndex")]
private int _diskByteOffset;
[SaveState.SaveWithName("DiskDataEntry")]
private int _diskBits;
[SaveState.SaveWithName("DiskCurrentCycle")]
private int _diskCycle;
[SaveState.SaveWithName("DiskDensityConfig")]
private int _diskDensity;
[SaveState.SaveWithName("PreviousCA1")]
private bool _previousCa1;
[SaveState.SaveWithName("CountsBeforeRandomTransition")]
private int _countsBeforeRandomTransition;
[SaveState.SaveWithName("CurrentRNG")]
private int _rngCurrent;
// Lehmer RNG

View File

@ -8,11 +8,13 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.Serial
{
public sealed partial class Drive1541 : IDisassemblable
{
[SaveState.DoNotSave]
IEnumerable<string> IDisassemblable.AvailableCpus
{
get { yield return "Disk Drive 6502"; }
}
[SaveState.DoNotSave]
string IDisassemblable.Cpu
{
get { return "Disk Drive 6502"; }
@ -21,6 +23,7 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.Serial
}
}
[SaveState.DoNotSave]
string IDisassemblable.PCRegisterName
{
get { return "PC"; }

View File

@ -13,28 +13,49 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.Serial
{
public sealed partial class Drive1541 : SerialPortDevice
{
[SaveState.SaveWithName("Disk")]
private Disk _disk;
[SaveState.SaveWithName("BitHistory")]
private int _bitHistory;
[SaveState.SaveWithName("BitsRemainingInLatchedByte")]
private int _bitsRemainingInLatchedByte;
[SaveState.SaveWithName("Sync")]
private bool _sync;
[SaveState.SaveWithName("ByteReady")]
private bool _byteReady;
[SaveState.DoNotSave] private readonly int _driveCpuClockNum;
[SaveState.SaveWithName("DriveCpuClockNumerator")]
private readonly int _driveCpuClockNum;
[SaveState.SaveWithName("TrackNumber")]
private int _trackNumber;
[SaveState.SaveWithName("MotorEnabled")]
private bool _motorEnabled;
[SaveState.SaveWithName("LedEnabled")]
private bool _ledEnabled;
[SaveState.SaveWithName("MotorStep")]
private int _motorStep;
[SaveState.DoNotSave]
private int _via0PortBtemp;
[SaveState.SaveWithName("CPU")]
private readonly MOS6502X _cpu;
[SaveState.SaveWithName("RAM")]
private readonly int[] _ram;
[SaveState.SaveWithName("VIA0")]
public readonly Via Via0;
[SaveState.SaveWithName("VIA1")]
public readonly Via Via1;
[SaveState.SaveWithName("SystemCpuClockNumerator")]
private readonly int _cpuClockNum;
[SaveState.SaveWithName("SystemDriveCpuRatioDifference")]
private int _ratioDifference;
[SaveState.SaveWithName("DriveLightOffTime")]
private int _driveLightOffTime;
[SaveState.DoNotSave] private int[] _trackImageData = new int[1];
[SaveState.DoNotSave]
private int[] _trackImageData = new int[1];
[SaveState.DoNotSave]
public Func<int> ReadIec = () => 0xFF;
[SaveState.DoNotSave]
public Action DebuggerStep;
[SaveState.DoNotSave]
public readonly Chip23128 DriveRom;
public Drive1541(int clockNum, int clockDen)

View File

@ -10,11 +10,16 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.Serial
{
public sealed class SerialPort : IDriveLight
{
[SaveState.DoNotSave]
public Func<bool> ReadMasterAtn = () => true;
[SaveState.DoNotSave]
public Func<bool> ReadMasterClk = () => true;
[SaveState.DoNotSave]
public Func<bool> ReadMasterData = () => true;
[SaveState.SaveWithName("Device")]
private SerialPortDevice _device;
[SaveState.SaveWithName("Connected")]
private bool _connected;
public void HardReset()
@ -75,7 +80,9 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.Serial
_device.ReadMasterData = () => ReadMasterData();
}
[SaveState.DoNotSave]
public bool DriveLightEnabled { get { return true; } }
[SaveState.DoNotSave]
public bool DriveLightOn { get { return ReadDeviceLight(); } }
}
}

View File

@ -1,47 +1,50 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using BizHawk.Common;
namespace BizHawk.Emulation.Cores.Computers.Commodore64.Serial
{
public abstract class SerialPortDevice
{
public Func<bool> ReadMasterAtn;
public Func<bool> ReadMasterClk;
public Func<bool> ReadMasterData;
public virtual void ExecutePhase()
{
}
public virtual void ExecuteDeferred(int cycles)
{
}
public virtual void HardReset()
{
}
public virtual bool ReadDeviceClk()
{
return true;
}
public virtual bool ReadDeviceData()
{
return true;
}
public virtual bool ReadDeviceLight()
{
return false;
}
public virtual void SyncState(Serializer ser)
{
SaveState.SyncObject(ser, this);
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using BizHawk.Common;
namespace BizHawk.Emulation.Cores.Computers.Commodore64.Serial
{
public abstract class SerialPortDevice
{
[SaveState.DoNotSave]
public Func<bool> ReadMasterAtn;
[SaveState.DoNotSave]
public Func<bool> ReadMasterClk;
[SaveState.DoNotSave]
public Func<bool> ReadMasterData;
public virtual void ExecutePhase()
{
}
public virtual void ExecuteDeferred(int cycles)
{
}
public virtual void HardReset()
{
}
public virtual bool ReadDeviceClk()
{
return true;
}
public virtual bool ReadDeviceData()
{
return true;
}
public virtual bool ReadDeviceLight()
{
return false;
}
public virtual void SyncState(Serializer ser)
{
SaveState.SyncObject(ser, this);
}
}
}