From 6fdc7284bd1bcfdeb941e9ef7606b10324895d1c Mon Sep 17 00:00:00 2001 From: saxxonpike Date: Mon, 26 Aug 2013 19:22:04 +0000 Subject: [PATCH] Commodore64: Split Sid classes into three files, up from one. Fixed border timing in TimingBuilder. Renamed Sync class to SaveState. --- BizHawk.Emulation/BizHawk.Emulation.csproj | 5 +- .../Computers/Commodore64/C64.Motherboard.cs | 2 +- .../Computers/Commodore64/Cartridge/Cart.cs | 2 +- .../Experimental/Chips/Internals/Cassette.cs | 2 +- .../Chips/Internals/Cia.Interface.cs | 2 +- .../Chips/Internals/Cpu.Interface.cs | 2 +- .../Experimental/Chips/Internals/Expansion.cs | 2 +- .../Experimental/Chips/Internals/Joystick.cs | 2 +- .../Experimental/Chips/Internals/Keyboard.cs | 2 +- .../Experimental/Chips/Internals/Ram.cs | 2 +- .../Experimental/Chips/Internals/Rom.cs | 2 +- .../Experimental/Chips/Internals/Serial.cs | 2 +- .../Commodore64/MOS/CartridgePort.cs | 4 +- .../Computers/Commodore64/MOS/CassettePort.cs | 6 +- .../Computers/Commodore64/MOS/Chip2114.cs | 2 +- .../Computers/Commodore64/MOS/Chip23XX.cs | 2 +- .../Computers/Commodore64/MOS/Chip4864.cs | 2 +- .../Computers/Commodore64/MOS/MOS6510.cs | 2 +- .../Computers/Commodore64/MOS/MOS6526.cs | 2 +- .../Computers/Commodore64/MOS/MOSPLA.cs | 2 +- .../Computers/Commodore64/MOS/Port.cs | 4 +- .../Computers/Commodore64/MOS/SerialPort.cs | 4 +- .../Computers/Commodore64/MOS/Sid.Envelope.cs | 251 ++++++++ .../Computers/Commodore64/MOS/Sid.Voice.cs | 344 +++++++++++ .../Computers/Commodore64/MOS/Sid.cs | 575 +----------------- .../Computers/Commodore64/MOS/Timer.cs | 5 - .../Computers/Commodore64/MOS/UserPort.cs | 22 +- .../Computers/Commodore64/MOS/Vic.Sprite.cs | 2 +- .../Computers/Commodore64/MOS/Vic.State.cs | 4 +- .../Commodore64/MOS/Vic.TimingBuilder.cs | 17 +- .../Computers/Commodore64/MOS/Vic.cs | 15 +- .../Commodore64/{Sync.cs => SaveState.cs} | 2 +- 32 files changed, 657 insertions(+), 637 deletions(-) create mode 100644 BizHawk.Emulation/Computers/Commodore64/MOS/Sid.Envelope.cs create mode 100644 BizHawk.Emulation/Computers/Commodore64/MOS/Sid.Voice.cs delete mode 100644 BizHawk.Emulation/Computers/Commodore64/MOS/Timer.cs rename BizHawk.Emulation/Computers/Commodore64/{Sync.cs => SaveState.cs} (97%) diff --git a/BizHawk.Emulation/BizHawk.Emulation.csproj b/BizHawk.Emulation/BizHawk.Emulation.csproj index b55814f577..123d45d138 100644 --- a/BizHawk.Emulation/BizHawk.Emulation.csproj +++ b/BizHawk.Emulation/BizHawk.Emulation.csproj @@ -155,7 +155,8 @@ - + + @@ -165,7 +166,7 @@ - + diff --git a/BizHawk.Emulation/Computers/Commodore64/C64.Motherboard.cs b/BizHawk.Emulation/Computers/Commodore64/C64.Motherboard.cs index eaaf3c5c01..17273a72e9 100644 --- a/BizHawk.Emulation/Computers/Commodore64/C64.Motherboard.cs +++ b/BizHawk.Emulation/Computers/Commodore64/C64.Motherboard.cs @@ -197,7 +197,7 @@ namespace BizHawk.Emulation.Computers.Commodore64 public void SyncState(Serializer ser) { ser.BeginSection("motherboard"); - Sync.SyncObject(ser, this); + SaveState.SyncObject(ser, this); ser.EndSection(); ser.BeginSection("cartridge"); diff --git a/BizHawk.Emulation/Computers/Commodore64/Cartridge/Cart.cs b/BizHawk.Emulation/Computers/Commodore64/Cartridge/Cart.cs index 28ae54bdc9..e8f949b463 100644 --- a/BizHawk.Emulation/Computers/Commodore64/Cartridge/Cart.cs +++ b/BizHawk.Emulation/Computers/Commodore64/Cartridge/Cart.cs @@ -236,7 +236,7 @@ namespace BizHawk.Emulation.Computers.Commodore64.Cartridge public virtual void SyncState(Serializer ser) { - Sync.SyncObject(ser, this); + SaveState.SyncObject(ser, this); } public bool Valid diff --git a/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Cassette.cs b/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Cassette.cs index 169f2ac1eb..60c3ee25fb 100644 --- a/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Cassette.cs +++ b/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Cassette.cs @@ -14,6 +14,6 @@ namespace BizHawk.Emulation.Computers.Commodore64.Experimental.Chips.Internals public bool OutputData() { return Data; } public bool OutputSense() { return Sense; } virtual public bool Sense { get { return true; } } - virtual public void SyncState(Serializer ser) { Sync.SyncObject(ser, this); } + virtual public void SyncState(Serializer ser) { SaveState.SyncObject(ser, this); } } } diff --git a/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Cia.Interface.cs b/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Cia.Interface.cs index 0c32a7edb4..66e65fbbef 100644 --- a/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Cia.Interface.cs +++ b/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Cia.Interface.cs @@ -28,6 +28,6 @@ namespace BizHawk.Emulation.Computers.Commodore64.Experimental.Chips.Internals public bool SP { get { return true; } } public void Clock() { } - public void SyncState(Serializer ser) { Sync.SyncObject(ser, this); } + public void SyncState(Serializer ser) { SaveState.SyncObject(ser, this); } } } diff --git a/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Cpu.Interface.cs b/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Cpu.Interface.cs index 7531cf0e12..2a54f4f528 100644 --- a/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Cpu.Interface.cs +++ b/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Cpu.Interface.cs @@ -33,6 +33,6 @@ namespace BizHawk.Emulation.Computers.Commodore64.Experimental.Chips.Internals public bool Port5 { get { return (Port & 0x20) != 0; } } public bool Port6 { get { return (Port & 0x40) != 0; } } public bool Port7 { get { return (Port & 0x80) != 0; } } - public void SyncState(Serializer ser) { Sync.SyncObject(ser, this); } + public void SyncState(Serializer ser) { SaveState.SyncObject(ser, this); } } } diff --git a/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Expansion.cs b/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Expansion.cs index 5c03af9182..8dfbf1cde7 100644 --- a/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Expansion.cs +++ b/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Expansion.cs @@ -15,6 +15,6 @@ namespace BizHawk.Emulation.Computers.Commodore64.Experimental.Chips.Internals public bool OutputGame() { return Game; } public bool OutputIRQ() { return IRQ; } public bool OutputNMI() { return NMI; } - virtual public void SyncState(Serializer ser) { Sync.SyncObject(ser, this); } + virtual public void SyncState(Serializer ser) { SaveState.SyncObject(ser, this); } } } diff --git a/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Joystick.cs b/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Joystick.cs index cae7c1b705..6e060cd8ab 100644 --- a/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Joystick.cs +++ b/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Joystick.cs @@ -11,6 +11,6 @@ namespace BizHawk.Emulation.Computers.Commodore64.Experimental.Chips.Internals public int OutputData() { return Data; } public int OutputPot() { return Pot; } virtual public int Pot { get { return 0xFF; } } - virtual public void SyncState(Serializer ser) { Sync.SyncObject(ser, this); } + virtual public void SyncState(Serializer ser) { SaveState.SyncObject(ser, this); } } } diff --git a/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Keyboard.cs b/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Keyboard.cs index 3c04846d54..64a2218ee4 100644 --- a/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Keyboard.cs +++ b/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Keyboard.cs @@ -13,6 +13,6 @@ namespace BizHawk.Emulation.Computers.Commodore64.Experimental.Chips.Internals public int OutputRow() { return Row; } virtual public bool Restore { get { return true; } } virtual public int Row { get { return 0xFF; } } - virtual public void SyncState(Serializer ser) { Sync.SyncObject(ser, this); } + virtual public void SyncState(Serializer ser) { SaveState.SyncObject(ser, this); } } } diff --git a/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Ram.cs b/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Ram.cs index 0fb33ae8ff..7858a9ba3b 100644 --- a/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Ram.cs +++ b/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Ram.cs @@ -38,6 +38,6 @@ namespace BizHawk.Emulation.Computers.Commodore64.Experimental.Chips.Internals memory[addr & addressMask] = val & dataMask; } - public void SyncState(Serializer ser) { Sync.SyncObject(ser, this); } + public void SyncState(Serializer ser) { SaveState.SyncObject(ser, this); } } } diff --git a/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Rom.cs b/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Rom.cs index ca225624d2..5e5a541f11 100644 --- a/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Rom.cs +++ b/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Rom.cs @@ -28,6 +28,6 @@ namespace BizHawk.Emulation.Computers.Commodore64.Experimental.Chips.Internals return memory[addr & addressMask]; } - public void SyncState(Serializer ser) { Sync.SyncObject(ser, this); } + public void SyncState(Serializer ser) { SaveState.SyncObject(ser, this); } } } diff --git a/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Serial.cs b/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Serial.cs index 50f929d75a..87fffa2426 100644 --- a/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Serial.cs +++ b/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Serial.cs @@ -18,6 +18,6 @@ namespace BizHawk.Emulation.Computers.Commodore64.Experimental.Chips.Internals public bool OutputData() { return Data; } public bool OutputSRQ() { return SRQ; } virtual public bool SRQ { get { return true; } } - virtual public void SyncState(Serializer ser) { Sync.SyncObject(ser, this); } + virtual public void SyncState(Serializer ser) { SaveState.SyncObject(ser, this); } } } diff --git a/BizHawk.Emulation/Computers/Commodore64/MOS/CartridgePort.cs b/BizHawk.Emulation/Computers/Commodore64/MOS/CartridgePort.cs index fabece8363..e30f8baf00 100644 --- a/BizHawk.Emulation/Computers/Commodore64/MOS/CartridgePort.cs +++ b/BizHawk.Emulation/Computers/Commodore64/MOS/CartridgePort.cs @@ -3,7 +3,7 @@ using BizHawk.Emulation.Computers.Commodore64.Cartridge; namespace BizHawk.Emulation.Computers.Commodore64.MOS { - public class CartridgePort + sealed public class CartridgePort { public Func ReadIRQ; public Func ReadNMI; @@ -80,7 +80,7 @@ namespace BizHawk.Emulation.Computers.Commodore64.MOS public void SyncState(Serializer ser) { - Sync.SyncObject(ser, this); + SaveState.SyncObject(ser, this); } } } diff --git a/BizHawk.Emulation/Computers/Commodore64/MOS/CassettePort.cs b/BizHawk.Emulation/Computers/Commodore64/MOS/CassettePort.cs index 9342b9f374..6da8aa8a15 100644 --- a/BizHawk.Emulation/Computers/Commodore64/MOS/CassettePort.cs +++ b/BizHawk.Emulation/Computers/Commodore64/MOS/CassettePort.cs @@ -11,19 +11,19 @@ namespace BizHawk.Emulation.Computers.Commodore64.MOS { } - public bool ReadDataInputBuffer() + virtual public bool ReadDataInputBuffer() { return true; } - public bool ReadSenseBuffer() + virtual public bool ReadSenseBuffer() { return true; } public void SyncState(Serializer ser) { - Sync.SyncObject(ser, this); + SaveState.SyncObject(ser, this); } } } diff --git a/BizHawk.Emulation/Computers/Commodore64/MOS/Chip2114.cs b/BizHawk.Emulation/Computers/Commodore64/MOS/Chip2114.cs index fad1334163..8a693848a2 100644 --- a/BizHawk.Emulation/Computers/Commodore64/MOS/Chip2114.cs +++ b/BizHawk.Emulation/Computers/Commodore64/MOS/Chip2114.cs @@ -38,7 +38,7 @@ public void SyncState(Serializer ser) { - Sync.SyncObject(ser, this); + SaveState.SyncObject(ser, this); } public void Write(int addr, byte val) diff --git a/BizHawk.Emulation/Computers/Commodore64/MOS/Chip23XX.cs b/BizHawk.Emulation/Computers/Commodore64/MOS/Chip23XX.cs index adafb82c5e..69c04922a7 100644 --- a/BizHawk.Emulation/Computers/Commodore64/MOS/Chip23XX.cs +++ b/BizHawk.Emulation/Computers/Commodore64/MOS/Chip23XX.cs @@ -53,7 +53,7 @@ namespace BizHawk.Emulation.Computers.Commodore64.MOS public void SyncState(Serializer ser) { - Sync.SyncObject(ser, this); + SaveState.SyncObject(ser, this); } } } diff --git a/BizHawk.Emulation/Computers/Commodore64/MOS/Chip4864.cs b/BizHawk.Emulation/Computers/Commodore64/MOS/Chip4864.cs index 037882ca2e..51bdd70e90 100644 --- a/BizHawk.Emulation/Computers/Commodore64/MOS/Chip4864.cs +++ b/BizHawk.Emulation/Computers/Commodore64/MOS/Chip4864.cs @@ -45,7 +45,7 @@ public void SyncState(Serializer ser) { - Sync.SyncObject(ser, this); + SaveState.SyncObject(ser, this); } public void Write(int addr, byte val) diff --git a/BizHawk.Emulation/Computers/Commodore64/MOS/MOS6510.cs b/BizHawk.Emulation/Computers/Commodore64/MOS/MOS6510.cs index 3ab5f00e39..a7fb20ebd0 100644 --- a/BizHawk.Emulation/Computers/Commodore64/MOS/MOS6510.cs +++ b/BizHawk.Emulation/Computers/Commodore64/MOS/MOS6510.cs @@ -142,7 +142,7 @@ namespace BizHawk.Emulation.Computers.Commodore64.MOS public void SyncState(Serializer ser) { cpu.SyncState(ser); - Sync.SyncObject(ser, this); + SaveState.SyncObject(ser, this); } public void Write(ushort addr, byte val) diff --git a/BizHawk.Emulation/Computers/Commodore64/MOS/MOS6526.cs b/BizHawk.Emulation/Computers/Commodore64/MOS/MOS6526.cs index d403ca56e2..75594b8a2c 100644 --- a/BizHawk.Emulation/Computers/Commodore64/MOS/MOS6526.cs +++ b/BizHawk.Emulation/Computers/Commodore64/MOS/MOS6526.cs @@ -546,7 +546,7 @@ namespace BizHawk.Emulation.Computers.Commodore64.MOS public void SyncState(Serializer ser) { - Sync.SyncObject(ser, this); + SaveState.SyncObject(ser, this); } public void Write(int addr, byte val) diff --git a/BizHawk.Emulation/Computers/Commodore64/MOS/MOSPLA.cs b/BizHawk.Emulation/Computers/Commodore64/MOS/MOSPLA.cs index 16f6c3ed52..2c950f0d44 100644 --- a/BizHawk.Emulation/Computers/Commodore64/MOS/MOSPLA.cs +++ b/BizHawk.Emulation/Computers/Commodore64/MOS/MOSPLA.cs @@ -282,7 +282,7 @@ namespace BizHawk.Emulation.Computers.Commodore64.MOS public void SyncState(Serializer ser) { - Sync.SyncObject(ser, this); + SaveState.SyncObject(ser, this); } public byte VicRead(int addr) diff --git a/BizHawk.Emulation/Computers/Commodore64/MOS/Port.cs b/BizHawk.Emulation/Computers/Commodore64/MOS/Port.cs index c494f8c3f4..fa02d8efa3 100644 --- a/BizHawk.Emulation/Computers/Commodore64/MOS/Port.cs +++ b/BizHawk.Emulation/Computers/Commodore64/MOS/Port.cs @@ -38,7 +38,7 @@ namespace BizHawk.Emulation.Computers.Commodore64.MOS public void SyncState(Serializer ser) { - Sync.SyncObject(ser, this); + SaveState.SyncObject(ser, this); } } @@ -78,7 +78,7 @@ namespace BizHawk.Emulation.Computers.Commodore64.MOS public void SyncState(Serializer ser) { - Sync.SyncObject(ser, this); + SaveState.SyncObject(ser, this); } } } diff --git a/BizHawk.Emulation/Computers/Commodore64/MOS/SerialPort.cs b/BizHawk.Emulation/Computers/Commodore64/MOS/SerialPort.cs index b410b7a2ab..4550650092 100644 --- a/BizHawk.Emulation/Computers/Commodore64/MOS/SerialPort.cs +++ b/BizHawk.Emulation/Computers/Commodore64/MOS/SerialPort.cs @@ -5,7 +5,7 @@ namespace BizHawk.Emulation.Computers.Commodore64.MOS // the functions on this port are at the point of // view of an external device. - public class SerialPort + sealed public class SerialPort { public Func ReadAtnOut; public Func ReadClockOut; @@ -21,7 +21,7 @@ namespace BizHawk.Emulation.Computers.Commodore64.MOS public void SyncState(Serializer ser) { - Sync.SyncObject(ser, this); + SaveState.SyncObject(ser, this); } public bool WriteClockIn() diff --git a/BizHawk.Emulation/Computers/Commodore64/MOS/Sid.Envelope.cs b/BizHawk.Emulation/Computers/Commodore64/MOS/Sid.Envelope.cs new file mode 100644 index 0000000000..4836c1cc47 --- /dev/null +++ b/BizHawk.Emulation/Computers/Commodore64/MOS/Sid.Envelope.cs @@ -0,0 +1,251 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace BizHawk.Emulation.Computers.Commodore64.MOS +{ + sealed public partial class Sid + { + sealed class Envelope + { + const int stateAttack = 0; + const int stateDecay = 1; + const int stateRelease = 2; + + int attack; + int decay; + bool delay; + int envCounter; + int expCounter; + int expPeriod; + bool freeze; + int lfsr; + bool gate; + int rate; + int release; + int state; + int sustain; + + static int[] adsrTable = new int[] + { + 0x7F00, 0x0006, 0x003C, 0x0330, + 0x20C0, 0x6755, 0x3800, 0x500E, + 0x1212, 0x0222, 0x1848, 0x59B8, + 0x3840, 0x77E2, 0x7625, 0x0A93 + }; + + static int[] expCounterTable = new int[] + { + 0xFF, 0x5D, 0x36, 0x1A, 0x0E, 0x06, 0x00 + }; + + static int[] expPeriodTable = new int[] + { + 0x01, 0x02, 0x04, 0x08, 0x10, 0x1E, 0x01 + }; + + static int[] sustainTable = new int[] + { + 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, + 0x88, 0x99, 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF + }; + + public Envelope() + { + HardReset(); + } + + public void ExecutePhase2() + { + + { + if (!delay) + { + envCounter--; + delay = true; + UpdateExpCounter(); + } + + if (lfsr != rate) + { + int feedback = ((lfsr >> 14) ^ (lfsr >> 13)) & 0x1; + lfsr = ((lfsr << 1) & 0x7FFF) | feedback; + return; + } + lfsr = 0x7FFF; + + if (state == stateAttack || ++expCounter == expPeriod) + { + expCounter = 0; + if (freeze) + return; + + switch (state) + { + case stateAttack: + envCounter++; + if (envCounter == 0xFF) + { + state = stateDecay; + rate = adsrTable[decay]; + } + break; + case stateDecay: + if (envCounter == sustainTable[sustain]) + { + return; + } + if (expPeriod != 1) + { + delay = false; + return; + } + envCounter--; + break; + case stateRelease: + if (expPeriod != 1) + { + delay = false; + return; + } + envCounter--; + break; + } + envCounter &= 0xFF; + UpdateExpCounter(); + } + } + } + + public void HardReset() + { + attack = 0; + decay = 0; + delay = true; + envCounter = 0; + expCounter = 0; + expPeriod = expPeriodTable[0]; + freeze = false; + gate = false; + lfsr = 0x7FFF; + rate = adsrTable[release]; + release = 0; + state = stateRelease; + sustain = 0; + } + + private void UpdateExpCounter() + { + + { + for (int i = 0; i < 7; i++) + { + if (envCounter == expCounterTable[i]) + expPeriod = expPeriodTable[i]; + } + if (envCounter == 0) + freeze = true; + } + } + + // ------------------------------------ + + public int Attack + { + get + { + return attack; + } + set + { + attack = (value & 0xF); + if (state == stateAttack) + rate = adsrTable[attack]; + } + } + + public int Decay + { + get + { + return decay; + } + set + { + decay = (value & 0xF); + if (state == stateDecay) + rate = adsrTable[decay]; + } + } + + public bool Gate + { + get + { + return gate; + } + set + { + bool nextGate = value; + if (nextGate && !gate) + { + state = stateAttack; + rate = adsrTable[attack]; + delay = true; + freeze = false; + } + else if (!nextGate && gate) + { + state = stateRelease; + rate = adsrTable[release]; + } + gate = nextGate; + } + } + + public int Level + { + get + { + return envCounter; + } + } + + public int Release + { + get + { + return release; + } + set + { + release = (value & 0xF); + if (state == stateRelease) + rate = adsrTable[release]; + } + } + + public int Sustain + { + get + { + return sustain; + } + set + { + sustain = (value & 0xF); + } + } + + // ------------------------------------ + + public void SyncState(Serializer ser) + { + SaveState.SyncObject(ser, this); + } + + // ------------------------------------ + } + } +} diff --git a/BizHawk.Emulation/Computers/Commodore64/MOS/Sid.Voice.cs b/BizHawk.Emulation/Computers/Commodore64/MOS/Sid.Voice.cs new file mode 100644 index 0000000000..6e87c95ecf --- /dev/null +++ b/BizHawk.Emulation/Computers/Commodore64/MOS/Sid.Voice.cs @@ -0,0 +1,344 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace BizHawk.Emulation.Computers.Commodore64.MOS +{ + sealed public partial class Sid + { + sealed class Voice + { + int accBits; + int accNext; + int accumulator; + bool controlTestPrev; + int controlWavePrev; + int delay; + int floatOutputTTL; + int frequency; + bool msbRising; + int noise; + int noNoise; + int noNoiseOrNoise; + int noPulse; + int output; + int pulse; + int pulseWidth; + bool ringMod; + int ringMsbMask; + int shiftRegister; + int shiftRegisterReset; + bool sync; + bool test; + int[] wave; + int waveform; + int waveformIndex; + int[][] waveTable; + + public Voice(int[][] newWaveTable) + { + waveTable = newWaveTable; + HardReset(); + } + + public void HardReset() + { + accumulator = 0; + delay = 0; + floatOutputTTL = 0; + frequency = 0; + msbRising = false; + noNoise = 0xFFF; + noPulse = 0xFFF; + output = 0x000; + pulse = 0xFFF; + pulseWidth = 0; + ringMsbMask = 0; + sync = false; + test = false; + wave = waveTable[0]; + waveform = 0; + + ResetShiftReg(); + } + + public void ExecutePhase2() + { + + { + if (test) + { + if (shiftRegisterReset != 0 && --shiftRegisterReset == 0) + { + ResetShiftReg(); + } + pulse = 0xFFF; + } + else + { + accNext = (accumulator + frequency) & 0xFFFFFF; + accBits = ~accumulator & accNext; + accumulator = accNext; + msbRising = ((accBits & 0x800000) != 0); + + if ((accBits & 0x080000) != 0) + delay = 2; + else if (delay != 0 && --delay == 0) + ClockShiftReg(); + } + } + } + + // ------------------------------------ + + private void ClockShiftReg() + { + + { + shiftRegister = ((shiftRegister << 1) | + (((shiftRegister >> 22) ^ (shiftRegister >> 17)) & 0x1) + ) & 0x7FFFFF; + SetNoise(); + } + } + + private void ResetShiftReg() + { + + { + shiftRegister = 0x7FFFFF; + shiftRegisterReset = 0; + SetNoise(); + } + } + + private void SetNoise() + { + + { + noise = + ((shiftRegister & 0x100000) >> 9) | + ((shiftRegister & 0x040000) >> 8) | + ((shiftRegister & 0x004000) >> 5) | + ((shiftRegister & 0x000800) >> 3) | + ((shiftRegister & 0x000200) >> 2) | + ((shiftRegister & 0x000020) << 1) | + ((shiftRegister & 0x000004) << 3) | + ((shiftRegister & 0x000001) << 4); + noNoiseOrNoise = noNoise | noise; + } + } + + private void WriteShiftReg() + { + + { + output &= + 0xBB5DA | + ((output & 0x800) << 9) | + ((output & 0x400) << 8) | + ((output & 0x200) << 5) | + ((output & 0x100) << 3) | + ((output & 0x040) >> 1) | + ((output & 0x020) >> 3) | + ((output & 0x010) >> 4); + noise &= output; + noNoiseOrNoise = noNoise | noise; + } + } + + // ------------------------------------ + + public int Control + { + set + { + controlWavePrev = waveform; + controlTestPrev = test; + + sync = ((value & 0x02) != 0); + ringMod = ((value & 0x04) != 0); + test = ((value & 0x08) != 0); + waveform = (value >> 4) & 0x0F; + wave = waveTable[waveform & 0x07]; + ringMsbMask = ((~value >> 5) & (value >> 2) & 0x1) << 23; + noNoise = ((waveform & 0x8) != 0) ? 0x000 : 0xFFF; + noNoiseOrNoise = noNoise | noise; + noPulse = ((waveform & 0x4) != 0) ? 0x000 : 0xFFF; + + if (!controlTestPrev && test) + { + accumulator = 0; + delay = 0; + shiftRegisterReset = 0x8000; + } + else if (controlTestPrev && !test) + { + shiftRegister = ((shiftRegister << 1) | + ((~shiftRegister >> 17) & 0x1) + ) & 0x7FFFFF; + SetNoise(); + } + + if (waveform == 0 && controlWavePrev != 0) + floatOutputTTL = 0x28000; + } + } + + public int Frequency + { + get + { + return frequency; + } + set + { + frequency = value; + } + } + + public int FrequencyLo + { + get + { + return (frequency & 0xFF); + } + set + { + frequency &= 0xFF00; + frequency |= value & 0x00FF; + } + } + + public int FrequencyHi + { + get + { + return (frequency >> 8); + } + set + { + frequency &= 0x00FF; + frequency |= (value & 0x00FF) << 8; + } + } + + public int Oscillator + { + get + { + return output; + } + } + + public int Output(Voice ringModSource) + { + + { + if (waveform != 0) + { + waveformIndex = (accumulator ^ (ringModSource.accumulator & ringMsbMask)) >> 12; + output = wave[waveformIndex] & (noPulse | pulse) & noNoiseOrNoise; + if (waveform > 8) + WriteShiftReg(); + } + else + { + if (floatOutputTTL != 0 && --floatOutputTTL == 0) + output = 0x000; + } + pulse = ((accumulator >> 12) >= pulseWidth) ? 0xFFF : 0x000; + return output; + } + } + + public int PulseWidth + { + get + { + return pulseWidth; + } + set + { + pulseWidth = value; + } + } + + public int PulseWidthLo + { + get + { + return (pulseWidth & 0xFF); + } + set + { + pulseWidth &= 0x0F00; + pulseWidth |= value & 0x00FF; + } + } + + public int PulseWidthHi + { + get + { + return (pulseWidth >> 8); + } + set + { + pulseWidth &= 0x00FF; + pulseWidth |= (value & 0x000F) << 8; + } + } + + public bool RingMod + { + get + { + return ringMod; + } + } + + public bool Sync + { + get + { + return sync; + } + } + + public void Synchronize(Voice target, Voice source) + { + if (msbRising && target.sync && !(sync && source.msbRising)) + target.accumulator = 0; + } + + public bool Test + { + get + { + return test; + } + } + + public int Waveform + { + get + { + return waveform; + } + } + + // ------------------------------------ + + public void SyncState(Serializer ser) + { + SaveState.SyncObject(ser, this); + + if (ser.IsReader) + wave = waveTable[waveform]; + } + } + + } +} diff --git a/BizHawk.Emulation/Computers/Commodore64/MOS/Sid.cs b/BizHawk.Emulation/Computers/Commodore64/MOS/Sid.cs index 88dda110bf..51032e556e 100644 --- a/BizHawk.Emulation/Computers/Commodore64/MOS/Sid.cs +++ b/BizHawk.Emulation/Computers/Commodore64/MOS/Sid.cs @@ -6,579 +6,6 @@ namespace BizHawk.Emulation.Computers.Commodore64.MOS { // ------------------------------------ - sealed class Envelope - { - const int stateAttack = 0; - const int stateDecay = 1; - const int stateRelease = 2; - - int attack; - int decay; - bool delay; - int envCounter; - int expCounter; - int expPeriod; - bool freeze; - int lfsr; - bool gate; - int rate; - int release; - int state; - int sustain; - - static int[] adsrTable = new int[] - { - 0x7F00, 0x0006, 0x003C, 0x0330, - 0x20C0, 0x6755, 0x3800, 0x500E, - 0x1212, 0x0222, 0x1848, 0x59B8, - 0x3840, 0x77E2, 0x7625, 0x0A93 - }; - - static int[] expCounterTable = new int[] - { - 0xFF, 0x5D, 0x36, 0x1A, 0x0E, 0x06, 0x00 - }; - - static int[] expPeriodTable = new int[] - { - 0x01, 0x02, 0x04, 0x08, 0x10, 0x1E, 0x01 - }; - - static int[] sustainTable = new int[] - { - 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, - 0x88, 0x99, 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF - }; - - public Envelope() - { - HardReset(); - } - - public void ExecutePhase2() - { - - { - if (!delay) - { - envCounter--; - delay = true; - UpdateExpCounter(); - } - - if (lfsr != rate) - { - int feedback = ((lfsr >> 14) ^ (lfsr >> 13)) & 0x1; - lfsr = ((lfsr << 1) & 0x7FFF) | feedback; - return; - } - lfsr = 0x7FFF; - - if (state == stateAttack || ++expCounter == expPeriod) - { - expCounter = 0; - if (freeze) - return; - - switch (state) - { - case stateAttack: - envCounter++; - if (envCounter == 0xFF) - { - state = stateDecay; - rate = adsrTable[decay]; - } - break; - case stateDecay: - if (envCounter == sustainTable[sustain]) - { - return; - } - if (expPeriod != 1) - { - delay = false; - return; - } - envCounter--; - break; - case stateRelease: - if (expPeriod != 1) - { - delay = false; - return; - } - envCounter--; - break; - } - envCounter &= 0xFF; - UpdateExpCounter(); - } - } - } - - public void HardReset() - { - attack = 0; - decay = 0; - delay = true; - envCounter = 0; - expCounter = 0; - expPeriod = expPeriodTable[0]; - freeze = false; - gate = false; - lfsr = 0x7FFF; - rate = adsrTable[release]; - release = 0; - state = stateRelease; - sustain = 0; - } - - private void UpdateExpCounter() - { - - { - for (int i = 0; i < 7; i++) - { - if (envCounter == expCounterTable[i]) - expPeriod = expPeriodTable[i]; - } - if (envCounter == 0) - freeze = true; - } - } - - // ------------------------------------ - - public int Attack - { - get - { - return attack; - } - set - { - attack = (value & 0xF); - if (state == stateAttack) - rate = adsrTable[attack]; - } - } - - public int Decay - { - get - { - return decay; - } - set - { - decay = (value & 0xF); - if (state == stateDecay) - rate = adsrTable[decay]; - } - } - - public bool Gate - { - get - { - return gate; - } - set - { - bool nextGate = value; - if (nextGate && !gate) - { - state = stateAttack; - rate = adsrTable[attack]; - delay = true; - freeze = false; - } - else if (!nextGate && gate) - { - state = stateRelease; - rate = adsrTable[release]; - } - gate = nextGate; - } - } - - public int Level - { - get - { - return envCounter; - } - } - - public int Release - { - get - { - return release; - } - set - { - release = (value & 0xF); - if (state == stateRelease) - rate = adsrTable[release]; - } - } - - public int Sustain - { - get - { - return sustain; - } - set - { - sustain = (value & 0xF); - } - } - - // ------------------------------------ - - public void SyncState(Serializer ser) - { - Sync.SyncObject(ser, this); - } - - // ------------------------------------ - } - - sealed class Voice - { - int accBits; - int accNext; - int accumulator; - bool controlTestPrev; - int controlWavePrev; - int delay; - int floatOutputTTL; - int frequency; - bool msbRising; - int noise; - int noNoise; - int noNoiseOrNoise; - int noPulse; - int output; - int pulse; - int pulseWidth; - bool ringMod; - int ringMsbMask; - int shiftRegister; - int shiftRegisterReset; - bool sync; - bool test; - int[] wave; - int waveform; - int waveformIndex; - int[][] waveTable; - - public Voice(int[][] newWaveTable) - { - waveTable = newWaveTable; - HardReset(); - } - - public void HardReset() - { - accumulator = 0; - delay = 0; - floatOutputTTL = 0; - frequency = 0; - msbRising = false; - noNoise = 0xFFF; - noPulse = 0xFFF; - output = 0x000; - pulse = 0xFFF; - pulseWidth = 0; - ringMsbMask = 0; - sync = false; - test = false; - wave = waveTable[0]; - waveform = 0; - - ResetShiftReg(); - } - - public void ExecutePhase2() - { - - { - if (test) - { - if (shiftRegisterReset != 0 && --shiftRegisterReset == 0) - { - ResetShiftReg(); - } - pulse = 0xFFF; - } - else - { - accNext = (accumulator + frequency) & 0xFFFFFF; - accBits = ~accumulator & accNext; - accumulator = accNext; - msbRising = ((accBits & 0x800000) != 0); - - if ((accBits & 0x080000) != 0) - delay = 2; - else if (delay != 0 && --delay == 0) - ClockShiftReg(); - } - } - } - - // ------------------------------------ - - private void ClockShiftReg() - { - - { - shiftRegister = ((shiftRegister << 1) | - (((shiftRegister >> 22) ^ (shiftRegister >> 17)) & 0x1) - ) & 0x7FFFFF; - SetNoise(); - } - } - - private void ResetShiftReg() - { - - { - shiftRegister = 0x7FFFFF; - shiftRegisterReset = 0; - SetNoise(); - } - } - - private void SetNoise() - { - - { - noise = - ((shiftRegister & 0x100000) >> 9) | - ((shiftRegister & 0x040000) >> 8) | - ((shiftRegister & 0x004000) >> 5) | - ((shiftRegister & 0x000800) >> 3) | - ((shiftRegister & 0x000200) >> 2) | - ((shiftRegister & 0x000020) << 1) | - ((shiftRegister & 0x000004) << 3) | - ((shiftRegister & 0x000001) << 4); - noNoiseOrNoise = noNoise | noise; - } - } - - private void WriteShiftReg() - { - - { - output &= - 0xBB5DA | - ((output & 0x800) << 9) | - ((output & 0x400) << 8) | - ((output & 0x200) << 5) | - ((output & 0x100) << 3) | - ((output & 0x040) >> 1) | - ((output & 0x020) >> 3) | - ((output & 0x010) >> 4); - noise &= output; - noNoiseOrNoise = noNoise | noise; - } - } - - // ------------------------------------ - - public int Control - { - set - { - controlWavePrev = waveform; - controlTestPrev = test; - - sync = ((value & 0x02) != 0); - ringMod = ((value & 0x04) != 0); - test = ((value & 0x08) != 0); - waveform = (value >> 4) & 0x0F; - wave = waveTable[waveform & 0x07]; - ringMsbMask = ((~value >> 5) & (value >> 2) & 0x1) << 23; - noNoise = ((waveform & 0x8) != 0) ? 0x000 : 0xFFF; - noNoiseOrNoise = noNoise | noise; - noPulse = ((waveform & 0x4) != 0) ? 0x000 : 0xFFF; - - if (!controlTestPrev && test) - { - accumulator = 0; - delay = 0; - shiftRegisterReset = 0x8000; - } - else if (controlTestPrev && !test) - { - shiftRegister = ((shiftRegister << 1) | - ((~shiftRegister >> 17) & 0x1) - ) & 0x7FFFFF; - SetNoise(); - } - - if (waveform == 0 && controlWavePrev != 0) - floatOutputTTL = 0x28000; - } - } - - public int Frequency - { - get - { - return frequency; - } - set - { - frequency = value; - } - } - - public int FrequencyLo - { - get - { - return (frequency & 0xFF); - } - set - { - frequency &= 0xFF00; - frequency |= value & 0x00FF; - } - } - - public int FrequencyHi - { - get - { - return (frequency >> 8); - } - set - { - frequency &= 0x00FF; - frequency |= (value & 0x00FF) << 8; - } - } - - public int Oscillator - { - get - { - return output; - } - } - - public int Output(Voice ringModSource) - { - - { - if (waveform != 0) - { - waveformIndex = (accumulator ^ (ringModSource.accumulator & ringMsbMask)) >> 12; - output = wave[waveformIndex] & (noPulse | pulse) & noNoiseOrNoise; - if (waveform > 8) - WriteShiftReg(); - } - else - { - if (floatOutputTTL != 0 && --floatOutputTTL == 0) - output = 0x000; - } - pulse = ((accumulator >> 12) >= pulseWidth) ? 0xFFF : 0x000; - return output; - } - } - - public int PulseWidth - { - get - { - return pulseWidth; - } - set - { - pulseWidth = value; - } - } - - public int PulseWidthLo - { - get - { - return (pulseWidth & 0xFF); - } - set - { - pulseWidth &= 0x0F00; - pulseWidth |= value & 0x00FF; - } - } - - public int PulseWidthHi - { - get - { - return (pulseWidth >> 8); - } - set - { - pulseWidth &= 0x00FF; - pulseWidth |= (value & 0x000F) << 8; - } - } - - public bool RingMod - { - get - { - return ringMod; - } - } - - public bool Sync - { - get - { - return sync; - } - } - - public void Synchronize(Voice target, Voice source) - { - if (msbRising && target.sync && !(sync && source.msbRising)) - target.accumulator = 0; - } - - public bool Test - { - get - { - return test; - } - } - - public int Waveform - { - get - { - return waveform; - } - } - - // ------------------------------------ - - public void SyncState(Serializer ser) - { - BizHawk.Emulation.Computers.Commodore64.Sync.SyncObject(ser, this); - - if (ser.IsReader) - wave = waveTable[waveform]; - } - } // ------------------------------------ @@ -930,7 +357,7 @@ namespace BizHawk.Emulation.Computers.Commodore64.MOS public void SyncState(Serializer ser) { - Sync.SyncObject(ser, this); + SaveState.SyncObject(ser, this); ser.BeginSection("env0"); envelopes[0].SyncState(ser); ser.EndSection(); diff --git a/BizHawk.Emulation/Computers/Commodore64/MOS/Timer.cs b/BizHawk.Emulation/Computers/Commodore64/MOS/Timer.cs deleted file mode 100644 index 363f41ea25..0000000000 --- a/BizHawk.Emulation/Computers/Commodore64/MOS/Timer.cs +++ /dev/null @@ -1,5 +0,0 @@ -using System; - -namespace BizHawk.Emulation.Computers.Commodore64.MOS -{ -} diff --git a/BizHawk.Emulation/Computers/Commodore64/MOS/UserPort.cs b/BizHawk.Emulation/Computers/Commodore64/MOS/UserPort.cs index 4cc2439f9d..bb9c204be4 100644 --- a/BizHawk.Emulation/Computers/Commodore64/MOS/UserPort.cs +++ b/BizHawk.Emulation/Computers/Commodore64/MOS/UserPort.cs @@ -14,59 +14,59 @@ namespace BizHawk.Emulation.Computers.Commodore64.MOS { } - public void HardReset() + virtual public void HardReset() { // note: this will not disconnect any attached media } - public bool ReadAtn() + virtual public bool ReadAtn() { return true; } - public bool ReadCounter1Buffer() + virtual public bool ReadCounter1Buffer() { return true; } - public bool ReadCounter2Buffer() + virtual public bool ReadCounter2Buffer() { return true; } - public byte ReadData() + virtual public byte ReadData() { return 0xFF; } - public bool ReadFlag2() + virtual public bool ReadFlag2() { return true; } - public bool ReadPA2() + virtual public bool ReadPA2() { return true; } - public bool ReadReset() + virtual public bool ReadReset() { return true; } - public bool ReadSerial1Buffer() + virtual public bool ReadSerial1Buffer() { return true; } - public bool ReadSerial2Buffer() + virtual public bool ReadSerial2Buffer() { return true; } public void SyncState(Serializer ser) { - Sync.SyncObject(ser, this); + SaveState.SyncObject(ser, this); } } } diff --git a/BizHawk.Emulation/Computers/Commodore64/MOS/Vic.Sprite.cs b/BizHawk.Emulation/Computers/Commodore64/MOS/Vic.Sprite.cs index 38efe7e12e..19c7e64834 100644 --- a/BizHawk.Emulation/Computers/Commodore64/MOS/Vic.Sprite.cs +++ b/BizHawk.Emulation/Computers/Commodore64/MOS/Vic.Sprite.cs @@ -7,7 +7,7 @@ namespace BizHawk.Emulation.Computers.Commodore64.MOS { sealed public partial class Vic { - class Sprite + sealed class Sprite { public bool collideData; public bool collideSprite; diff --git a/BizHawk.Emulation/Computers/Commodore64/MOS/Vic.State.cs b/BizHawk.Emulation/Computers/Commodore64/MOS/Vic.State.cs index 7f4c09ffb9..7cbb959810 100644 --- a/BizHawk.Emulation/Computers/Commodore64/MOS/Vic.State.cs +++ b/BizHawk.Emulation/Computers/Commodore64/MOS/Vic.State.cs @@ -196,11 +196,11 @@ namespace BizHawk.Emulation.Computers.Commodore64.MOS public void SyncState(Serializer ser) { - Sync.SyncObject(ser, this); + SaveState.SyncObject(ser, this); for (int i = 0; i < 8; i++) { ser.BeginSection("sprite" + i.ToString()); - Sync.SyncObject(ser, sprites[i]); + SaveState.SyncObject(ser, sprites[i]); ser.EndSection(); } } diff --git a/BizHawk.Emulation/Computers/Commodore64/MOS/Vic.TimingBuilder.cs b/BizHawk.Emulation/Computers/Commodore64/MOS/Vic.TimingBuilder.cs index aafc10553f..7600c72fa7 100644 --- a/BizHawk.Emulation/Computers/Commodore64/MOS/Vic.TimingBuilder.cs +++ b/BizHawk.Emulation/Computers/Commodore64/MOS/Vic.TimingBuilder.cs @@ -7,6 +7,11 @@ namespace BizHawk.Emulation.Computers.Commodore64.MOS { sealed public partial class Vic { + const int BORDER_LEFT_38 = 0x01F; + const int BORDER_LEFT_40 = 0x018; + const int BORDER_RIGHT_38 = 0x14F; + const int BORDER_RIGHT_40 = 0x158; + static int[] TimingBuilder_Cycle14Act = new int[] { pipelineUpdateVc, 0, @@ -45,17 +50,17 @@ namespace BizHawk.Emulation.Computers.Commodore64.MOS result[i] |= pipelineHoldX; // pipeline border checks - if (timing[i] == 0x018) + if (timing[i] == (BORDER_LEFT_40 & 0xFFC)) result[i] |= pipelineChkBrdL1; - if (timing[i] == 0x01C) + if (timing[i] == (BORDER_LEFT_38 & 0xFFC)) result[i] |= pipelineChkBrdL0; - if (timing[i] == 0x14C) + if (timing[i] == (BORDER_RIGHT_38 & 0xFFC)) result[i] |= pipelineChkBrdR0; - if (timing[i] == 0x158) + if (timing[i] == (BORDER_RIGHT_40 & 0xFFC)) result[i] |= pipelineChkBrdR1; - if (timing[i] == (hblankStart & 0xFFD)) + if (timing[i] == (hblankStart & 0xFFC)) result[i] |= pipelineHBlankR; - if (timing[i] == (hblankEnd & 0xFFD)) + if (timing[i] == (hblankEnd & 0xFFC)) result[i] |= pipelineHBlankL; } diff --git a/BizHawk.Emulation/Computers/Commodore64/MOS/Vic.cs b/BizHawk.Emulation/Computers/Commodore64/MOS/Vic.cs index 271e2fa15c..66e9dc2133 100644 --- a/BizHawk.Emulation/Computers/Commodore64/MOS/Vic.cs +++ b/BizHawk.Emulation/Computers/Commodore64/MOS/Vic.cs @@ -174,15 +174,12 @@ namespace BizHawk.Emulation.Computers.Commodore64.MOS private void UpdateBorder() { - - { - borderL = columnSelect ? 0x018 : 0x01F; - borderR = columnSelect ? 0x158 : 0x14F; - //borderL = columnSelect ? 28 : 35; - //borderR = columnSelect ? 348 : 339; - borderT = rowSelect ? 0x033 : 0x037; - borderB = rowSelect ? 0x0FB : 0x0F7; - } + borderL = columnSelect ? 0x018 : 0x01F; + borderR = columnSelect ? 0x158 : 0x14F; + //borderL = columnSelect ? 28 : 35; + //borderR = columnSelect ? 348 : 339; + borderT = rowSelect ? 0x033 : 0x037; + borderB = rowSelect ? 0x0FB : 0x0F7; } private void UpdatePins() diff --git a/BizHawk.Emulation/Computers/Commodore64/Sync.cs b/BizHawk.Emulation/Computers/Commodore64/SaveState.cs similarity index 97% rename from BizHawk.Emulation/Computers/Commodore64/Sync.cs rename to BizHawk.Emulation/Computers/Commodore64/SaveState.cs index 3b80a38de8..90f999a820 100644 --- a/BizHawk.Emulation/Computers/Commodore64/Sync.cs +++ b/BizHawk.Emulation/Computers/Commodore64/SaveState.cs @@ -8,7 +8,7 @@ using System.Text; namespace BizHawk.Emulation.Computers.Commodore64 { - static class Sync + static class SaveState { static public void SyncObject(Serializer ser, object obj) {