C64 - refactor cartridge classes to not use SyncObject
This commit is contained in:
parent
762a35773c
commit
4ffcc9654a
|
@ -312,7 +312,13 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64
|
|||
Vic.SyncState(ser);
|
||||
ser.EndSection();
|
||||
|
||||
ser.BeginSection("CartPort"); SaveState.SyncObject(ser, CartPort); ser.EndSection(); // TODO: only if cart
|
||||
if (CartPort.IsConnected)
|
||||
{
|
||||
ser.BeginSection("CartPort");
|
||||
CartPort.SyncState(ser);
|
||||
ser.EndSection();
|
||||
}
|
||||
|
||||
ser.BeginSection("Cassette"); SaveState.SyncObject(ser, Cassette); ser.EndSection();
|
||||
|
||||
ser.BeginSection("Serial"); SaveState.SyncObject(ser, Serial); ser.EndSection();
|
||||
|
|
|
@ -130,14 +130,19 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.Cartridge
|
|||
|
||||
[SaveState.SaveWithName("ExRom")]
|
||||
protected bool pinExRom;
|
||||
|
||||
[SaveState.SaveWithName("Game")]
|
||||
protected bool pinGame;
|
||||
|
||||
[SaveState.SaveWithName("IRQ")]
|
||||
protected bool pinIRQ;
|
||||
|
||||
[SaveState.SaveWithName("NMI")]
|
||||
protected bool pinNMI;
|
||||
|
||||
[SaveState.SaveWithName("Reset")]
|
||||
protected bool pinReset;
|
||||
|
||||
[SaveState.DoNotSave]
|
||||
protected bool validCartridge;
|
||||
|
||||
|
@ -253,9 +258,18 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.Cartridge
|
|||
}
|
||||
}
|
||||
|
||||
protected abstract void SyncStateInternal(Serializer ser);
|
||||
|
||||
public virtual void SyncState(Serializer ser)
|
||||
{
|
||||
SaveState.SyncObject(ser, this);
|
||||
ser.Sync("pinExRom", ref pinExRom);
|
||||
ser.Sync("pinGame", ref pinGame);
|
||||
ser.Sync("pinIRQ", ref pinIRQ);
|
||||
ser.Sync("pinNMI", ref pinNMI);
|
||||
ser.Sync("pinReset", ref pinReset);
|
||||
|
||||
ser.Sync("_driveLightEnabled", ref _driveLightEnabled);
|
||||
ser.Sync("_driveLightOn", ref _driveLightOn);
|
||||
}
|
||||
|
||||
[SaveState.DoNotSave]
|
||||
|
@ -283,7 +297,19 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.Cartridge
|
|||
{
|
||||
}
|
||||
|
||||
public bool DriveLightEnabled { get; protected set; }
|
||||
public bool DriveLightOn { get; protected set; }
|
||||
private bool _driveLightEnabled;
|
||||
private bool _driveLightOn;
|
||||
|
||||
public bool DriveLightEnabled
|
||||
{
|
||||
get { return _driveLightEnabled; }
|
||||
protected set { _driveLightEnabled = value; }
|
||||
}
|
||||
|
||||
public bool DriveLightOn
|
||||
{
|
||||
get { return _driveLightOn; }
|
||||
protected set { _driveLightOn = value; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -132,7 +132,11 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.Cartridge
|
|||
|
||||
public void SyncState(Serializer ser)
|
||||
{
|
||||
SaveState.SyncObject(ser, this);
|
||||
ser.Sync("_connected", ref _connected);
|
||||
|
||||
ser.BeginSection("CartridgeDevice");
|
||||
_cartridgeDevice.SyncState(ser);
|
||||
ser.EndSection();
|
||||
}
|
||||
|
||||
public bool DriveLightEnabled { get { return _connected && _cartridgeDevice.DriveLightEnabled; } }
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using BizHawk.Common;
|
||||
|
||||
namespace BizHawk.Emulation.Cores.Computers.Commodore64.Cartridge
|
||||
{
|
||||
|
@ -7,12 +8,15 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.Cartridge
|
|||
{
|
||||
[SaveState.DoNotSave]
|
||||
private readonly int[] _romA;
|
||||
|
||||
[SaveState.SaveWithName("RomMaskA")]
|
||||
private readonly int _romAMask;
|
||||
private int _romAMask;
|
||||
|
||||
[SaveState.DoNotSave]
|
||||
private readonly int[] _romB;
|
||||
|
||||
[SaveState.SaveWithName("RomMaskB")]
|
||||
private readonly int _romBMask;
|
||||
private int _romBMask;
|
||||
|
||||
// standard cartridge mapper (Commodore)
|
||||
// note that this format also covers Ultimax carts
|
||||
|
@ -77,6 +81,12 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.Cartridge
|
|||
}
|
||||
}
|
||||
|
||||
protected override void SyncStateInternal(Serializer ser)
|
||||
{
|
||||
ser.Sync("RomMaskA", ref _romAMask);
|
||||
ser.Sync("RomMaskB", ref _romBMask);
|
||||
}
|
||||
|
||||
public override int Peek8000(int addr)
|
||||
{
|
||||
return _romA[addr & _romAMask];
|
||||
|
|
|
@ -1,11 +1,13 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
using BizHawk.Common;
|
||||
|
||||
namespace BizHawk.Emulation.Cores.Computers.Commodore64.Cartridge
|
||||
{
|
||||
internal sealed class Mapper0001 : CartridgeDevice
|
||||
{
|
||||
[SaveState.SaveWithName("RAM")] private readonly int[] _ram = new int[0x2000];
|
||||
[SaveState.SaveWithName("RAM")] private int[] _ram = new int[0x2000];
|
||||
[SaveState.SaveWithName("RAMEnabled")] private bool _ramEnabled;
|
||||
[SaveState.DoNotSave] private readonly int[] _rom = new int[0x8000];
|
||||
[SaveState.SaveWithName("ROMOffset")] private int _romOffset;
|
||||
|
@ -24,6 +26,14 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.Cartridge
|
|||
_cartEnabled = true;
|
||||
}
|
||||
|
||||
protected override void SyncStateInternal(Serializer ser)
|
||||
{
|
||||
ser.Sync("RAM", ref _ram, useNull: false);
|
||||
ser.Sync("RAMEnabled", ref _ramEnabled);
|
||||
ser.Sync("ROMOffset", ref _romOffset);
|
||||
ser.Sync("CartEnabled", ref _cartEnabled);
|
||||
}
|
||||
|
||||
public override void HardReset()
|
||||
{
|
||||
base.HardReset();
|
||||
|
|
|
@ -8,17 +8,23 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.Cartridge
|
|||
internal sealed class Mapper0005 : CartridgeDevice
|
||||
{
|
||||
[SaveState.DoNotSave]
|
||||
private readonly int[][] _banksA; //8000
|
||||
private readonly int[][] _banksA; // 8000
|
||||
|
||||
[SaveState.DoNotSave]
|
||||
private readonly int[][] _banksB = new int[0][]; //A000
|
||||
private readonly int[][] _banksB = new int[0][]; // A000
|
||||
|
||||
[SaveState.SaveWithName("BankMask")]
|
||||
private readonly int _bankMask;
|
||||
private int _bankMask;
|
||||
|
||||
[SaveState.SaveWithName("BankNumber")]
|
||||
private int _bankNumber;
|
||||
|
||||
[SaveState.DoNotSave]
|
||||
private int[] _currentBankA;
|
||||
|
||||
[SaveState.DoNotSave]
|
||||
private int[] _currentBankB;
|
||||
|
||||
[SaveState.DoNotSave]
|
||||
private readonly int[] _dummyBank;
|
||||
|
||||
|
@ -105,6 +111,12 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.Cartridge
|
|||
BankSet(0);
|
||||
}
|
||||
|
||||
protected override void SyncStateInternal(Serializer ser)
|
||||
{
|
||||
ser.Sync("BankMask", ref _bankMask);
|
||||
ser.Sync("BankNumber", ref _bankNumber);
|
||||
}
|
||||
|
||||
private void BankSet(int index)
|
||||
{
|
||||
_bankNumber = index & _bankMask;
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
using BizHawk.Common;
|
||||
|
||||
namespace BizHawk.Emulation.Cores.Computers.Commodore64.Cartridge
|
||||
{
|
||||
// Epyx Fastload. Uppermost page is always visible at DFxx.
|
||||
|
@ -17,6 +19,7 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.Cartridge
|
|||
|
||||
[SaveState.SaveWithName("CapacitorCycles")]
|
||||
private int _capacitorCycles;
|
||||
|
||||
[SaveState.DoNotSave]
|
||||
private readonly int[] _rom;
|
||||
|
||||
|
@ -27,6 +30,11 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.Cartridge
|
|||
pinGame = true;
|
||||
}
|
||||
|
||||
protected override void SyncStateInternal(Serializer ser)
|
||||
{
|
||||
ser.Sync("CapacitorCycles", ref _capacitorCycles);
|
||||
}
|
||||
|
||||
public override void ExecutePhase()
|
||||
{
|
||||
pinExRom = !(_capacitorCycles > 0);
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
using BizHawk.Common;
|
||||
|
||||
namespace BizHawk.Emulation.Cores.Computers.Commodore64.Cartridge
|
||||
{
|
||||
// Westermann Learning mapper.
|
||||
|
@ -30,6 +32,11 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.Cartridge
|
|||
validCartridge = true;
|
||||
}
|
||||
|
||||
protected override void SyncStateInternal(Serializer ser)
|
||||
{
|
||||
// Nothing to save
|
||||
}
|
||||
|
||||
public override int Peek8000(int addr)
|
||||
{
|
||||
return _rom[addr];
|
||||
|
|
|
@ -15,10 +15,13 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.Cartridge
|
|||
{
|
||||
[SaveState.DoNotSave]
|
||||
private readonly int[][] _banks; // 8000
|
||||
|
||||
[SaveState.SaveWithName("BankMask")]
|
||||
private readonly int _bankMask;
|
||||
private int _bankMask;
|
||||
|
||||
[SaveState.SaveWithName("BankNumber")]
|
||||
private int _bankNumber;
|
||||
|
||||
[SaveState.SaveWithName("CurrentBank")]
|
||||
private int[] _currentBank;
|
||||
|
||||
|
@ -84,6 +87,13 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.Cartridge
|
|||
BankSet(0);
|
||||
}
|
||||
|
||||
protected override void SyncStateInternal(Serializer ser)
|
||||
{
|
||||
ser.Sync("BankMask", ref _bankMask);
|
||||
ser.Sync("BankNumber", ref _bankNumber);
|
||||
ser.Sync("CurrentBank", ref _currentBank, useNull: false);
|
||||
}
|
||||
|
||||
protected void BankSet(int index)
|
||||
{
|
||||
_bankNumber = index & _bankMask;
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using System.Collections.Generic;
|
||||
using BizHawk.Common;
|
||||
|
||||
namespace BizHawk.Emulation.Cores.Computers.Commodore64.Cartridge
|
||||
{
|
||||
|
@ -14,6 +15,11 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.Cartridge
|
|||
// required to pass information to base class
|
||||
}
|
||||
|
||||
protected override void SyncStateInternal(Serializer ser)
|
||||
{
|
||||
// Nothing to save
|
||||
}
|
||||
|
||||
public override void PokeDE00(int addr, int val)
|
||||
{
|
||||
// do nothing
|
||||
|
|
|
@ -9,10 +9,13 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.Cartridge
|
|||
{
|
||||
[SaveState.DoNotSave]
|
||||
private readonly int[] _bankMain;
|
||||
|
||||
[SaveState.DoNotSave]
|
||||
private readonly int[][] _bankHigh;
|
||||
|
||||
[SaveState.SaveWithName("BankHighSelected")]
|
||||
private int[] _bankHighSelected;
|
||||
|
||||
[SaveState.SaveWithName("BankIndex")]
|
||||
private int _bankIndex;
|
||||
|
||||
|
@ -51,6 +54,12 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.Cartridge
|
|||
|
||||
}
|
||||
|
||||
protected override void SyncStateInternal(Serializer ser)
|
||||
{
|
||||
ser.Sync("BankHighSelected", ref _bankHighSelected, useNull: false);
|
||||
ser.Sync("BankIndex", ref _bankIndex);
|
||||
}
|
||||
|
||||
public override int Peek8000(int addr)
|
||||
{
|
||||
return _bankMain[addr];
|
||||
|
|
|
@ -16,12 +16,16 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.Cartridge
|
|||
{
|
||||
[SaveState.DoNotSave]
|
||||
private readonly int[][] _banks; // 8000
|
||||
|
||||
[SaveState.SaveWithName("BankMask")]
|
||||
private readonly int _bankMask;
|
||||
private int _bankMask;
|
||||
|
||||
[SaveState.SaveWithName("BankNumber")]
|
||||
private int _bankNumber;
|
||||
|
||||
[SaveState.DoNotSave]
|
||||
private int[] _currentBank;
|
||||
|
||||
[SaveState.SaveWithName("ROMEnable")]
|
||||
private bool _romEnable;
|
||||
|
||||
|
@ -72,6 +76,13 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.Cartridge
|
|||
BankSet(0);
|
||||
}
|
||||
|
||||
protected override void SyncStateInternal(Serializer ser)
|
||||
{
|
||||
ser.Sync("BankMask", ref _bankMask);
|
||||
ser.Sync("BankNumber", ref _bankNumber);
|
||||
ser.Sync("ROMEnable", ref _romEnable);
|
||||
}
|
||||
|
||||
private void BankSet(int index)
|
||||
{
|
||||
_bankNumber = index & _bankMask;
|
||||
|
|
|
@ -26,26 +26,37 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.Cartridge
|
|||
{
|
||||
[SaveState.SaveWithName("BankOffset")]
|
||||
private int _bankOffset = 63 << 13;
|
||||
|
||||
[SaveState.DoNotSave]
|
||||
private int[] _banksA = new int[64 << 13]; // 8000
|
||||
|
||||
[SaveState.DoNotSave]
|
||||
private int[] _banksB = new int[64 << 13]; // A000
|
||||
|
||||
[SaveState.DoNotSave]
|
||||
private readonly int[] _originalMediaA; // 8000
|
||||
|
||||
[SaveState.DoNotSave]
|
||||
private readonly int[] _originalMediaB; // A000
|
||||
|
||||
[SaveState.SaveWithName("BoardLed")]
|
||||
private bool _boardLed;
|
||||
|
||||
[SaveState.SaveWithName("Jumper")]
|
||||
private bool _jumper = false;
|
||||
|
||||
[SaveState.SaveWithName("StateBits")]
|
||||
private int _stateBits;
|
||||
|
||||
[SaveState.SaveWithName("RAM")]
|
||||
private readonly int[] _ram = new int[256];
|
||||
private int[] _ram = new int[256];
|
||||
|
||||
[SaveState.SaveWithName("CommandLatch55")]
|
||||
private bool _commandLatch55;
|
||||
|
||||
[SaveState.SaveWithName("CommandLatchAA")]
|
||||
private bool _commandLatchAa;
|
||||
|
||||
[SaveState.SaveWithName("InternalROMState")]
|
||||
private int _internalRomState;
|
||||
|
||||
|
@ -94,6 +105,18 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.Cartridge
|
|||
_originalMediaB = _banksB.Select(d => d).ToArray();
|
||||
}
|
||||
|
||||
protected override void SyncStateInternal(Serializer ser)
|
||||
{
|
||||
ser.Sync("BankOffset", ref _bankOffset);
|
||||
ser.Sync("BoardLed", ref _boardLed);
|
||||
ser.Sync("Jumper", ref _jumper);
|
||||
ser.Sync("StateBits", ref _stateBits);
|
||||
ser.Sync("RAM", ref _ram, useNull: false);
|
||||
ser.Sync("CommandLatch55", ref _commandLatchAa);
|
||||
ser.Sync("CommandLatchAA", ref _commandLatchAa);
|
||||
ser.Sync("InternalROMState", ref _internalRomState);
|
||||
}
|
||||
|
||||
private void BankSet(int index)
|
||||
{
|
||||
_bankOffset = (index & 0x3F) << 13;
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
using BizHawk.Common;
|
||||
|
||||
namespace BizHawk.Emulation.Cores.Computers.Commodore64.Cartridge
|
||||
{
|
||||
// Prophet 64 cartridge. Because we can.
|
||||
|
@ -12,8 +14,10 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.Cartridge
|
|||
{
|
||||
[SaveState.DoNotSave]
|
||||
private readonly int[] _rom;
|
||||
|
||||
[SaveState.SaveWithName("RomOffset")]
|
||||
private int _romOffset;
|
||||
|
||||
[SaveState.SaveWithName("RomEnabled")]
|
||||
private bool _romEnabled;
|
||||
|
||||
|
@ -33,6 +37,12 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.Cartridge
|
|||
}
|
||||
}
|
||||
|
||||
protected override void SyncStateInternal(Serializer ser)
|
||||
{
|
||||
ser.Sync("RomOffset", ref _romOffset);
|
||||
ser.Sync("RomEnabled", ref _romEnabled);
|
||||
}
|
||||
|
||||
public override void HardReset()
|
||||
{
|
||||
_romEnabled = true;
|
||||
|
|
Loading…
Reference in New Issue