C64 - refactor CassettePort and subclasses to not use SyncObject

This commit is contained in:
adelikat 2017-05-13 10:20:44 -05:00
parent 4ffcc9654a
commit 4d99f9fd95
5 changed files with 16 additions and 8 deletions

View File

@ -319,7 +319,9 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64
ser.EndSection(); ser.EndSection();
} }
ser.BeginSection("Cassette"); SaveState.SyncObject(ser, Cassette); ser.EndSection(); ser.BeginSection("Cassette");
Cassette.SyncState(ser);
ser.EndSection();
ser.BeginSection("Serial"); SaveState.SyncObject(ser, Serial); ser.EndSection(); ser.BeginSection("Serial"); SaveState.SyncObject(ser, Serial); ser.EndSection();
ser.BeginSection("TapeDrive"); SaveState.SyncObject(ser, TapeDrive); ser.EndSection(); // TODO: only if tape ser.BeginSection("TapeDrive"); SaveState.SyncObject(ser, TapeDrive); ser.EndSection(); // TODO: only if tape

View File

@ -12,6 +12,7 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.Cassette
[SaveState.SaveWithName("Device")] [SaveState.SaveWithName("Device")]
private CassettePortDevice _device; private CassettePortDevice _device;
[SaveState.SaveWithName("Connected")] [SaveState.SaveWithName("Connected")]
private bool _connected; private bool _connected;
@ -43,7 +44,11 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.Cassette
public void SyncState(Serializer ser) public void SyncState(Serializer ser)
{ {
SaveState.SyncObject(ser, this); ser.Sync("Connected", ref _connected);
if (_device != null)
{
_device.SyncState(ser);
}
} }
public void Connect(CassettePortDevice device) public void Connect(CassettePortDevice device)

View File

@ -28,9 +28,6 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.Cassette
return true; return true;
} }
public virtual void SyncState(Serializer ser) public abstract void SyncState(Serializer ser);
{
SaveState.SyncObject(ser, this);
}
} }
} }

View File

@ -30,7 +30,7 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.Cassette
public override void SyncState(Serializer ser) public override void SyncState(Serializer ser)
{ {
SaveState.SyncObject(ser, this); _tape.SyncState(ser);
} }
public void Insert(Tape tape) public void Insert(Tape tape)

View File

@ -13,8 +13,10 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.Media
[SaveState.SaveWithName("Position")] [SaveState.SaveWithName("Position")]
private int _pos; private int _pos;
[SaveState.SaveWithName("Cycle")] [SaveState.SaveWithName("Cycle")]
private int _cycle; private int _cycle;
[SaveState.SaveWithName("Data")] [SaveState.SaveWithName("Data")]
private bool _data; private bool _data;
@ -97,7 +99,9 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.Media
public void SyncState(Serializer ser) public void SyncState(Serializer ser)
{ {
SaveState.SyncObject(ser, this); ser.Sync("Position", ref _pos);
ser.Sync("Cycle", ref _cycle);
ser.Sync("Data", ref _data);
} }
} }
} }