From 1c8cc06a021a43c051bad0d95505d774417abfda Mon Sep 17 00:00:00 2001 From: adelikat Date: Sat, 13 May 2017 07:55:46 -0500 Subject: [PATCH] C64 - Refactor Cia.Port to be a base interface instead of abstract class, and remove SyncState since none of the current implementations have any state to sync. --- .../Computers/Commodore64/MOS/Cia.Port.cs | 34 ++++++++----------- .../Computers/Commodore64/MOS/Cia.cs | 7 +--- 2 files changed, 15 insertions(+), 26 deletions(-) diff --git a/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/Cia.Port.cs b/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/Cia.Port.cs index dce8b4f0a3..5d511d732a 100644 --- a/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/Cia.Port.cs +++ b/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/Cia.Port.cs @@ -1,38 +1,32 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using BizHawk.Common; namespace BizHawk.Emulation.Cores.Computers.Commodore64.MOS { public sealed partial class Cia { - private abstract class Port + private interface IPort { - public abstract int ReadPra(int pra, int ddra, int prb, int ddrb); - public abstract int ReadPrb(int pra, int ddra, int prb, int ddrb); + int ReadPra(int pra, int ddra, int prb, int ddrb); + int ReadPrb(int pra, int ddra, int prb, int ddrb); - public void SyncState(Serializer ser) - { - SaveState.SyncObject(ser, this); - } + // If an IPort needs to save state we can do it with something like this: + // void SyncState(Serializer ser); } - private sealed class DisconnectedPort : Port + private sealed class DisconnectedPort : IPort { - public override int ReadPra(int pra, int ddra, int prb, int ddrb) + public int ReadPra(int pra, int ddra, int prb, int ddrb) { return (pra | ~ddra) & 0xFF; } - public override int ReadPrb(int pra, int ddra, int prb, int ddrb) + public int ReadPrb(int pra, int ddra, int prb, int ddrb) { return (prb | ~ddrb) & 0xFF; } } - private sealed class JoystickKeyboardPort : Port + private sealed class JoystickKeyboardPort : IPort { [SaveState.DoNotSave] private int _ret; [SaveState.DoNotSave] private int _tst; @@ -112,7 +106,7 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.MOS return result; } - public override int ReadPra(int pra, int ddra, int prb, int ddrb) + public int ReadPra(int pra, int ddra, int prb, int ddrb) { _ret = (pra | ~ddra) & 0xFF; _tst = (prb | ~ddrb) & GetJoystick1(); @@ -120,7 +114,7 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.MOS return _ret & GetJoystick2(); } - public override int ReadPrb(int pra, int ddra, int prb, int ddrb) + public int ReadPrb(int pra, int ddra, int prb, int ddrb) { _ret = ~ddrb & 0xFF; _tst = (pra | ~ddra) & GetJoystick2(); @@ -129,7 +123,7 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.MOS } } - private sealed class IecPort : Port + private sealed class IecPort : IPort { private readonly Func _readIec; @@ -138,12 +132,12 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.MOS _readIec = readIec; } - public override int ReadPra(int pra, int ddra, int prb, int ddrb) + public int ReadPra(int pra, int ddra, int prb, int ddrb) { return (pra & ddra) | (~ddra & _readIec()); } - public override int ReadPrb(int pra, int ddra, int prb, int ddrb) + public int ReadPrb(int pra, int ddra, int prb, int ddrb) { return (prb | ~ddrb) & 0xFF; } diff --git a/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/Cia.cs b/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/Cia.cs index b443de15ba..dfdce572af 100644 --- a/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/Cia.cs +++ b/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/Cia.cs @@ -74,7 +74,7 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.MOS [SaveState.DoNotSave] private bool _flagInput; [SaveState.DoNotSave] private bool _taUnderflow; - private readonly Port _port; + private readonly IPort _port; [SaveState.DoNotSave] private int _todlo; [SaveState.DoNotSave] private int _todhi; [SaveState.DoNotSave] private readonly int _todNum; @@ -546,12 +546,7 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.MOS ser.Sync("_newCrb", ref _newCrb); ser.Sync("_flagLatch", ref _flagLatch); - ser.BeginSection("Port"); - _port.SyncState(ser); - ser.EndSection(); - ser.Sync("_todCounter", ref _todCounter); - //SaveState.SyncObject(ser, this); } } }