From 2fb95adb1abce6b0b6cc52d58f284b9f2188b600 Mon Sep 17 00:00:00 2001 From: saxxonpike Date: Fri, 3 Oct 2014 21:04:37 +0000 Subject: [PATCH] Commodore 64: Remove useless 'experimental' folder, make namespaces match folders --- .../BizHawk.Emulation.Cores.csproj | 50 +- .../Computers/Commodore64/C64.Core.cs | 1 + .../Computers/Commodore64/C64.Motherboard.cs | 15 +- .../Computers/Commodore64/C64.cs | 1 + .../Commodore64/Cartridge/Mapper0000.cs | 2 +- .../Commodore64/Cartridge/Mapper0005.cs | 2 +- .../Commodore64/Cartridge/Mapper000B.cs | 2 +- .../Commodore64/Cartridge/Mapper0012.cs | 2 +- .../Commodore64/Cartridge/Mapper0013.cs | 2 +- .../Commodore64/Cartridge/Mapper0020.cs | 148 ++++-- .../CassettePort/CassettePortDevice.cs | 34 ++ .../Computers/Commodore64/Disk/VIC1541.PLA.cs | 72 --- .../Computers/Commodore64/Disk/VIC1541.cs | 266 ----------- .../Commodore64/Experimental/C64.Glue.cs | 161 ------- .../Computers/Commodore64/Experimental/C64.cs | 131 ------ .../Experimental/C64Presets.NTSC.cs | 40 -- .../Experimental/C64Presets.PAL.cs | 40 -- .../Experimental/Chips/Internals/Cassette.cs | 21 - .../Chips/Internals/Cia.Interface.cs | 35 -- .../Chips/Internals/Cia.Internal.cs | 19 - .../Chips/Internals/Cia.Registers.cs | 29 -- .../Chips/Internals/Cia.Settings.cs | 11 - .../Chips/Internals/Cpu.Interface.cs | 40 -- .../Chips/Internals/Cpu.Internal.cs | 91 ---- .../Experimental/Chips/Internals/Cpu.State.cs | 11 - .../Experimental/Chips/Internals/Expansion.cs | 22 - .../Experimental/Chips/Internals/Joystick.cs | 18 - .../Experimental/Chips/Internals/Keyboard.cs | 20 - .../Experimental/Chips/Internals/Pla.cs | 324 ------------- .../Experimental/Chips/Internals/Ram.cs | 45 -- .../Experimental/Chips/Internals/Rom.cs | 35 -- .../Experimental/Chips/Internals/Serial.cs | 25 - .../Chips/Internals/Sid.Interface.cs | 14 - .../Chips/Internals/Sid.Internal.cs | 25 - .../Chips/Internals/Sid.Registers.cs | 29 -- .../Chips/Internals/Sid.Settings.cs | 11 - .../Chips/Internals/Sid.SoundProvider.cs | 17 - .../Experimental/Chips/Internals/Userport.cs | 38 -- .../Chips/Internals/Vic.Graphics.cs | 155 ------ .../Chips/Internals/Vic.Interface.cs | 30 -- .../Chips/Internals/Vic.Internal.cs | 33 -- .../Chips/Internals/Vic.Registers.cs | 428 ----------------- .../Chips/Internals/Vic.Settings.cs | 11 - .../Chips/Internals/Vic.Sprite.cs | 127 ----- .../Experimental/Chips/Internals/Vic.State.cs | 16 - .../Experimental/Chips/Internals/Vic.Synth.cs | 30 -- .../Chips/Internals/Vic.Timing.cs | 86 ---- .../Chips/Internals/Vic.VideoProvider.cs | 70 --- .../Commodore64/Experimental/Chips/Presets.cs | 58 --- .../Commodore64/Experimental/IMotherboard.cs | 32 -- .../Commodore64/MOS/CartridgePort.cs | 3 +- .../Computers/Commodore64/MOS/CassettePort.cs | 2 +- .../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/MOS6522.cs | 2 +- .../Computers/Commodore64/MOS/MOS6526.cs | 2 +- .../Computers/Commodore64/MOS/MOS6567.cs | 2 +- .../Computers/Commodore64/MOS/MOS6569.cs | 2 +- .../Computers/Commodore64/MOS/MOS6581.cs | 2 +- .../Computers/Commodore64/MOS/MOSPLA.cs | 2 +- .../Computers/Commodore64/MOS/Port.cs | 2 +- .../Computers/Commodore64/MOS/SerialPort.cs | 2 +- .../Computers/Commodore64/MOS/Sid.Envelope.cs | 2 +- .../Commodore64/MOS/Sid.Registers.cs | 216 +++++++++ .../Computers/Commodore64/MOS/Sid.Voice.cs | 5 +- .../Computers/Commodore64/MOS/Sid.cs | 212 +-------- .../Computers/Commodore64/MOS/UserPort.cs | 2 +- .../Commodore64/MOS/Vic.GraphicsGenerator.cs | 11 - .../Computers/Commodore64/MOS/Vic.Parse.cs | 444 +++++++++--------- .../Commodore64/MOS/Vic.Registers.cs | 2 +- .../Computers/Commodore64/MOS/Vic.Render.cs | 145 +++--- .../{Vic.SpriteGenerator.cs => Vic.Sprite.cs} | 8 +- .../Computers/Commodore64/MOS/Vic.State.cs | 164 +++---- .../Commodore64/MOS/Vic.TimingBuilder.cs | 8 +- .../Commodore64/MOS/Vic.VideoProvider.cs | 20 +- .../Computers/Commodore64/MOS/Vic.cs | 28 +- .../Computers/Commodore64/Media/PRG.cs | 4 +- .../Computers/Commodore64/Tape/VIC1530.cs | 8 - .../Commodore64/UserPort/UserPortDevice.cs | 77 +++ 81 files changed, 898 insertions(+), 3412 deletions(-) create mode 100644 BizHawk.Emulation.Cores/Computers/Commodore64/CassettePort/CassettePortDevice.cs delete mode 100644 BizHawk.Emulation.Cores/Computers/Commodore64/Disk/VIC1541.PLA.cs delete mode 100644 BizHawk.Emulation.Cores/Computers/Commodore64/Disk/VIC1541.cs delete mode 100644 BizHawk.Emulation.Cores/Computers/Commodore64/Experimental/C64.Glue.cs delete mode 100644 BizHawk.Emulation.Cores/Computers/Commodore64/Experimental/C64.cs delete mode 100644 BizHawk.Emulation.Cores/Computers/Commodore64/Experimental/C64Presets.NTSC.cs delete mode 100644 BizHawk.Emulation.Cores/Computers/Commodore64/Experimental/C64Presets.PAL.cs delete mode 100644 BizHawk.Emulation.Cores/Computers/Commodore64/Experimental/Chips/Internals/Cassette.cs delete mode 100644 BizHawk.Emulation.Cores/Computers/Commodore64/Experimental/Chips/Internals/Cia.Interface.cs delete mode 100644 BizHawk.Emulation.Cores/Computers/Commodore64/Experimental/Chips/Internals/Cia.Internal.cs delete mode 100644 BizHawk.Emulation.Cores/Computers/Commodore64/Experimental/Chips/Internals/Cia.Registers.cs delete mode 100644 BizHawk.Emulation.Cores/Computers/Commodore64/Experimental/Chips/Internals/Cia.Settings.cs delete mode 100644 BizHawk.Emulation.Cores/Computers/Commodore64/Experimental/Chips/Internals/Cpu.Interface.cs delete mode 100644 BizHawk.Emulation.Cores/Computers/Commodore64/Experimental/Chips/Internals/Cpu.Internal.cs delete mode 100644 BizHawk.Emulation.Cores/Computers/Commodore64/Experimental/Chips/Internals/Cpu.State.cs delete mode 100644 BizHawk.Emulation.Cores/Computers/Commodore64/Experimental/Chips/Internals/Expansion.cs delete mode 100644 BizHawk.Emulation.Cores/Computers/Commodore64/Experimental/Chips/Internals/Joystick.cs delete mode 100644 BizHawk.Emulation.Cores/Computers/Commodore64/Experimental/Chips/Internals/Keyboard.cs delete mode 100644 BizHawk.Emulation.Cores/Computers/Commodore64/Experimental/Chips/Internals/Pla.cs delete mode 100644 BizHawk.Emulation.Cores/Computers/Commodore64/Experimental/Chips/Internals/Ram.cs delete mode 100644 BizHawk.Emulation.Cores/Computers/Commodore64/Experimental/Chips/Internals/Rom.cs delete mode 100644 BizHawk.Emulation.Cores/Computers/Commodore64/Experimental/Chips/Internals/Serial.cs delete mode 100644 BizHawk.Emulation.Cores/Computers/Commodore64/Experimental/Chips/Internals/Sid.Interface.cs delete mode 100644 BizHawk.Emulation.Cores/Computers/Commodore64/Experimental/Chips/Internals/Sid.Internal.cs delete mode 100644 BizHawk.Emulation.Cores/Computers/Commodore64/Experimental/Chips/Internals/Sid.Registers.cs delete mode 100644 BizHawk.Emulation.Cores/Computers/Commodore64/Experimental/Chips/Internals/Sid.Settings.cs delete mode 100644 BizHawk.Emulation.Cores/Computers/Commodore64/Experimental/Chips/Internals/Sid.SoundProvider.cs delete mode 100644 BizHawk.Emulation.Cores/Computers/Commodore64/Experimental/Chips/Internals/Userport.cs delete mode 100644 BizHawk.Emulation.Cores/Computers/Commodore64/Experimental/Chips/Internals/Vic.Graphics.cs delete mode 100644 BizHawk.Emulation.Cores/Computers/Commodore64/Experimental/Chips/Internals/Vic.Interface.cs delete mode 100644 BizHawk.Emulation.Cores/Computers/Commodore64/Experimental/Chips/Internals/Vic.Internal.cs delete mode 100644 BizHawk.Emulation.Cores/Computers/Commodore64/Experimental/Chips/Internals/Vic.Registers.cs delete mode 100644 BizHawk.Emulation.Cores/Computers/Commodore64/Experimental/Chips/Internals/Vic.Settings.cs delete mode 100644 BizHawk.Emulation.Cores/Computers/Commodore64/Experimental/Chips/Internals/Vic.Sprite.cs delete mode 100644 BizHawk.Emulation.Cores/Computers/Commodore64/Experimental/Chips/Internals/Vic.State.cs delete mode 100644 BizHawk.Emulation.Cores/Computers/Commodore64/Experimental/Chips/Internals/Vic.Synth.cs delete mode 100644 BizHawk.Emulation.Cores/Computers/Commodore64/Experimental/Chips/Internals/Vic.Timing.cs delete mode 100644 BizHawk.Emulation.Cores/Computers/Commodore64/Experimental/Chips/Internals/Vic.VideoProvider.cs delete mode 100644 BizHawk.Emulation.Cores/Computers/Commodore64/Experimental/Chips/Presets.cs delete mode 100644 BizHawk.Emulation.Cores/Computers/Commodore64/Experimental/IMotherboard.cs create mode 100644 BizHawk.Emulation.Cores/Computers/Commodore64/MOS/Sid.Registers.cs delete mode 100644 BizHawk.Emulation.Cores/Computers/Commodore64/MOS/Vic.GraphicsGenerator.cs rename BizHawk.Emulation.Cores/Computers/Commodore64/MOS/{Vic.SpriteGenerator.cs => Vic.Sprite.cs} (82%) delete mode 100644 BizHawk.Emulation.Cores/Computers/Commodore64/Tape/VIC1530.cs create mode 100644 BizHawk.Emulation.Cores/Computers/Commodore64/UserPort/UserPortDevice.cs diff --git a/BizHawk.Emulation.Cores/BizHawk.Emulation.Cores.csproj b/BizHawk.Emulation.Cores/BizHawk.Emulation.Cores.csproj index 0ebc656f82..4303a26fb0 100644 --- a/BizHawk.Emulation.Cores/BizHawk.Emulation.Cores.csproj +++ b/BizHawk.Emulation.Cores/BizHawk.Emulation.Cores.csproj @@ -99,45 +99,7 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + @@ -161,19 +123,19 @@ + - - + - + @@ -577,9 +539,7 @@ true - - - + {866F8D13-0678-4FF9-80A4-A3993FD4D8A3} diff --git a/BizHawk.Emulation.Cores/Computers/Commodore64/C64.Core.cs b/BizHawk.Emulation.Cores/Computers/Commodore64/C64.Core.cs index 36300282aa..f36de5e7ce 100644 --- a/BizHawk.Emulation.Cores/Computers/Commodore64/C64.Core.cs +++ b/BizHawk.Emulation.Cores/Computers/Commodore64/C64.Core.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.IO; using BizHawk.Emulation.Common; +using BizHawk.Emulation.Cores.Computers.Commodore64.MOS; namespace BizHawk.Emulation.Cores.Computers.Commodore64 { diff --git a/BizHawk.Emulation.Cores/Computers/Commodore64/C64.Motherboard.cs b/BizHawk.Emulation.Cores/Computers/Commodore64/C64.Motherboard.cs index 95aecd4b6f..5f2fc26d6a 100644 --- a/BizHawk.Emulation.Cores/Computers/Commodore64/C64.Motherboard.cs +++ b/BizHawk.Emulation.Cores/Computers/Commodore64/C64.Motherboard.cs @@ -2,6 +2,9 @@ using BizHawk.Common; using BizHawk.Emulation.Common; +using BizHawk.Emulation.Cores.Computers.Commodore64.MOS; +using BizHawk.Emulation.Cores.Computers.Commodore64.CassettePort; +using BizHawk.Emulation.Cores.Computers.Commodore64.UserPort; namespace BizHawk.Emulation.Cores.Computers.Commodore64 { @@ -25,10 +28,10 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64 // ports public CartridgePort cartPort; - public CassettePort cassPort; + public CassettePortDevice cassPort; public IController controller; public SerialPort serPort; - public UserPort userPort; + public UserPortDevice userPort; // state //public int address; @@ -45,7 +48,7 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64 _c64 = c64; cartPort = new CartridgePort(); - cassPort = new CassettePort(); + cassPort = new CassettePortDevice(); cia0 = new MOS6526(initRegion); cia1 = new MOS6526(initRegion); colorRam = new Chip2114(); @@ -59,7 +62,7 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64 case Region.NTSC: vic = MOS6567.Create(); break; case Region.PAL: vic = MOS6569.Create(); break; } - userPort = new UserPort(); + userPort = new UserPortDevice(); } // ----------------------------------------- @@ -241,6 +244,10 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64 sid.SyncState(ser); ser.EndSection(); + ser.BeginSection("user"); + userPort.SyncState(ser); + ser.EndSection(); + ser.BeginSection("vic"); vic.SyncState(ser); ser.EndSection(); diff --git a/BizHawk.Emulation.Cores/Computers/Commodore64/C64.cs b/BizHawk.Emulation.Cores/Computers/Commodore64/C64.cs index 8febd93cad..951bda2bf3 100644 --- a/BizHawk.Emulation.Cores/Computers/Commodore64/C64.cs +++ b/BizHawk.Emulation.Cores/Computers/Commodore64/C64.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.IO; using BizHawk.Emulation.Common; +using BizHawk.Emulation.Cores.Computers.Commodore64.MOS; namespace BizHawk.Emulation.Cores.Computers.Commodore64 { diff --git a/BizHawk.Emulation.Cores/Computers/Commodore64/Cartridge/Mapper0000.cs b/BizHawk.Emulation.Cores/Computers/Commodore64/Cartridge/Mapper0000.cs index 4aa855fe65..39dd6730cb 100644 --- a/BizHawk.Emulation.Cores/Computers/Commodore64/Cartridge/Mapper0000.cs +++ b/BizHawk.Emulation.Cores/Computers/Commodore64/Cartridge/Mapper0000.cs @@ -3,7 +3,7 @@ using System.Collections.Generic; namespace BizHawk.Emulation.Cores.Computers.Commodore64 { - public class Mapper0000 : Cart + sealed public class Mapper0000 : Cart { private byte[] romA; private int romAMask; diff --git a/BizHawk.Emulation.Cores/Computers/Commodore64/Cartridge/Mapper0005.cs b/BizHawk.Emulation.Cores/Computers/Commodore64/Cartridge/Mapper0005.cs index 565da3b740..b480c23edb 100644 --- a/BizHawk.Emulation.Cores/Computers/Commodore64/Cartridge/Mapper0005.cs +++ b/BizHawk.Emulation.Cores/Computers/Commodore64/Cartridge/Mapper0005.cs @@ -5,7 +5,7 @@ using BizHawk.Common; namespace BizHawk.Emulation.Cores.Computers.Commodore64 { - public class Mapper0005 : Cart + sealed public class Mapper0005 : Cart { private byte[][] banksA = new byte[0][]; //8000 private byte[][] banksB = new byte[0][]; //A000 diff --git a/BizHawk.Emulation.Cores/Computers/Commodore64/Cartridge/Mapper000B.cs b/BizHawk.Emulation.Cores/Computers/Commodore64/Cartridge/Mapper000B.cs index 19d140faad..222c490207 100644 --- a/BizHawk.Emulation.Cores/Computers/Commodore64/Cartridge/Mapper000B.cs +++ b/BizHawk.Emulation.Cores/Computers/Commodore64/Cartridge/Mapper000B.cs @@ -10,7 +10,7 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64 // the RAM underneath (BASIC variable values probably) // and then disables once loaded. - public class Mapper000B : Cart + sealed public class Mapper000B : Cart { private byte[] rom = new byte[0x4000]; diff --git a/BizHawk.Emulation.Cores/Computers/Commodore64/Cartridge/Mapper0012.cs b/BizHawk.Emulation.Cores/Computers/Commodore64/Cartridge/Mapper0012.cs index 1b4ff9fb1f..8d7e182007 100644 --- a/BizHawk.Emulation.Cores/Computers/Commodore64/Cartridge/Mapper0012.cs +++ b/BizHawk.Emulation.Cores/Computers/Commodore64/Cartridge/Mapper0012.cs @@ -5,7 +5,7 @@ using BizHawk.Common; namespace BizHawk.Emulation.Cores.Computers.Commodore64 { - public class Mapper0012 : Cart + sealed public class Mapper0012 : Cart { private byte[] bankMain; private byte[][] bankHigh; diff --git a/BizHawk.Emulation.Cores/Computers/Commodore64/Cartridge/Mapper0013.cs b/BizHawk.Emulation.Cores/Computers/Commodore64/Cartridge/Mapper0013.cs index b7fbe1f3f5..e5872b2e27 100644 --- a/BizHawk.Emulation.Cores/Computers/Commodore64/Cartridge/Mapper0013.cs +++ b/BizHawk.Emulation.Cores/Computers/Commodore64/Cartridge/Mapper0013.cs @@ -12,7 +12,7 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64 // Bank select is DE00, bit 7 enabled means to disable // ROM in 8000-9FFF. - public class Mapper0013 : Cart + sealed public class Mapper0013 : Cart { private byte[][] banks = new byte[0][]; //8000 private int bankMask; diff --git a/BizHawk.Emulation.Cores/Computers/Commodore64/Cartridge/Mapper0020.cs b/BizHawk.Emulation.Cores/Computers/Commodore64/Cartridge/Mapper0020.cs index bf60f270bd..66dcb69217 100644 --- a/BizHawk.Emulation.Cores/Computers/Commodore64/Cartridge/Mapper0020.cs +++ b/BizHawk.Emulation.Cores/Computers/Commodore64/Cartridge/Mapper0020.cs @@ -18,7 +18,9 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64 // There is also 256 bytes RAM at DF00-DFFF. - public class Mapper0020 : Cart + // We emulate having the AM29F040 chip. + + sealed public class Mapper0020 : Cart { private byte[][] banksA = new byte[64][]; //8000 private byte[][] banksB = new byte[64][]; //A000 @@ -30,6 +32,9 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64 private bool jumper = false; private int stateBits; private byte[] ram = new byte[256]; + private bool commandLatch55; + private bool commandLatchAA; + private int internalRomState; public Mapper0020(List newAddresses, List newBanks, List newData) { @@ -66,6 +71,11 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64 // default to bank 0 BankSet(0); + + // internal operation settings + commandLatch55 = false; + commandLatchAA = false; + internalRomState = 0; } private void BankSet(int index) @@ -117,12 +127,12 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64 public override byte Read8000(int addr) { - return currentBankA[addr]; + return ReadInternal(addr); } public override byte ReadA000(int addr) { - return currentBankB[addr]; + return ReadInternal(addr | 0x2000); } public override byte ReadDF00(int addr) @@ -130,6 +140,38 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64 return ram[addr]; } + private byte ReadInternal(int addr) + { + switch (internalRomState) + { + case 0x80: + break; + case 0x90: + switch (addr & 0x1FFF) + { + case 0x0000: + return 0x01; + case 0x0001: + return 0xA4; + case 0x0002: + return 0x00; + } + break; + case 0xA0: + break; + case 0xF0: + break; + } + if ((addr & 0x3FFF) < 0x2000) + { + return currentBankA[addr & 0x1FFF]; + } + else + { + return currentBankB[addr & 0x1FFF]; + } + } + private void StateSet(byte val) { stateBits = val &= 0x87; @@ -139,6 +181,7 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64 pinGame = jumper; pinExRom = ((val & 0x02) == 0); boardLed = ((val & 0x80) != 0); + internalRomState = 0; UpdateState(); } @@ -150,33 +193,79 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64 public override void Write8000(int addr, byte val) { - if (!pinGame && pinExRom) - { - System.Diagnostics.Debug.WriteLine("EasyFlash Write: $" + C64Util.ToHex(addr | 0x8000, 4) + " = " + C64Util.ToHex(val, 2)); - if (addr == 0x0555) - { - } - else if (addr == 0x02AA) // $82AA - { - } - else if (addr == 0x07FF) // $87FF - { - } - else if (addr == 0x0007) // $8007 - { - } - else if (addr == 0x1000) // $9000 - { - } - else if (addr == 0x0000) // $8000 - { - } - else - { - } - } + WriteInternal(addr, val); } + public override void WriteA000(int addr, byte val) + { + WriteInternal(addr | 0x2000, val); + } + + private void WriteInternal(int addr, byte val) + { + if (!pinGame && pinExRom) + { + System.Diagnostics.Debug.WriteLine("EasyFlash Write: $" + C64Util.ToHex(addr | 0x8000, 4) + " = " + C64Util.ToHex(val, 2)); + if (val == 0xF0) // any address, resets flash + { + internalRomState = 0; + commandLatch55 = false; + commandLatchAA = false; + } + else if (internalRomState != 0x00 && internalRomState != 0xF0) + { + switch (internalRomState) + { + case 0xA0: + if ((addr & 0x2000) == 0) + { + addr &= 0x1FFF; + banksA[bankNumber][addr] = val; + currentBankA[addr] = val; + } + else + { + addr &= 0x1FFF; + banksB[bankNumber][addr] = val; + currentBankB[addr] = val; + } + break; + } + } + else if (addr == 0x0555) // $8555 + { + if (!commandLatchAA) + { + if (val == 0xAA) + { + commandLatch55 = true; + } + } + else + { + // process EZF command + internalRomState = val; + } + } + else if (addr == 0x02AA) // $82AA + { + if (commandLatch55 && val == 0x55) + { + commandLatchAA = true; + } + else + { + commandLatch55 = false; + } + } + else + { + commandLatch55 = false; + commandLatchAA = false; + } + } + } + public override void WriteDE00(int addr, byte val) { addr &= 0x02; @@ -194,9 +283,6 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64 public override void SyncState(Serializer ser) { base.SyncState(ser); - ser.Sync("bankNumber", ref bankNumber); - ser.Sync("boardLed", ref boardLed); - ser.Sync("ram", ref ram, false); if (ser.IsReader) UpdateState(); } diff --git a/BizHawk.Emulation.Cores/Computers/Commodore64/CassettePort/CassettePortDevice.cs b/BizHawk.Emulation.Cores/Computers/Commodore64/CassettePort/CassettePortDevice.cs new file mode 100644 index 0000000000..d8f567713c --- /dev/null +++ b/BizHawk.Emulation.Cores/Computers/Commodore64/CassettePort/CassettePortDevice.cs @@ -0,0 +1,34 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using BizHawk.Common; +using BizHawk.Emulation.Common; + +namespace BizHawk.Emulation.Cores.Computers.Commodore64.CassettePort +{ + public class CassettePortDevice + { + public Func ReadDataOutput; + public Func ReadMotor; + + public void HardReset() + { + } + + virtual public bool ReadDataInputBuffer() + { + return true; + } + + virtual public bool ReadSenseBuffer() + { + return true; + } + + public void SyncState(Serializer ser) + { + SaveState.SyncObject(ser, this); + } + } +} diff --git a/BizHawk.Emulation.Cores/Computers/Commodore64/Disk/VIC1541.PLA.cs b/BizHawk.Emulation.Cores/Computers/Commodore64/Disk/VIC1541.PLA.cs deleted file mode 100644 index 9a588caeac..0000000000 --- a/BizHawk.Emulation.Cores/Computers/Commodore64/Disk/VIC1541.PLA.cs +++ /dev/null @@ -1,72 +0,0 @@ -using System; - -namespace BizHawk.Emulation.Cores.Computers.Commodore64 -{ - public class VIC1541PLA - { - public Func PeekRam; - public Func PeekRom; - public Func PeekVia0; - public Func PeekVia1; - public Action PokeRam; - public Action PokeRom; - public Action PokeVia0; - public Action PokeVia1; - public Func ReadRam; - public Func ReadRom; - public Func ReadVia0; - public Func ReadVia1; - public Action WriteRam; - public Action WriteRom; - public Action WriteVia0; - public Action WriteVia1; - - public byte Peek(int addr) - { - if (addr >= 0x1800 && addr < 0x1C00) - return PeekVia0(addr); - else if (addr >= 0x1C00 && addr < 0x2000) - return PeekVia1(addr); - else if (addr >= 0xC000) - return PeekRom(addr); - else - return PeekRam(addr); - } - - public void Poke(int addr, byte val) - { - if (addr >= 0x1800 && addr < 0x1C00) - PokeVia0(addr, val); - else if (addr >= 0x1C00 && addr < 0x2000) - PokeVia1(addr, val); - else if (addr >= 0xC000) - PokeRom(addr, val); - else - PokeRam(addr, val); - } - - public byte Read(ushort addr) - { - if (addr >= 0x1800 && addr < 0x1C00) - return ReadVia0(addr); - else if (addr >= 0x1C00 && addr < 0x2000) - return ReadVia1(addr); - else if (addr >= 0xC000) - return ReadRom(addr); - else - return ReadRam(addr); - } - - public void Write(ushort addr, byte val) - { - if (addr >= 0x1800 && addr < 0x1C00) - WriteVia0(addr, val); - else if (addr >= 0x1C00 && addr < 0x2000) - WriteVia1(addr, val); - else if (addr >= 0xC000) - WriteRom(addr, val); - else - WriteRam(addr, val); - } - } -} diff --git a/BizHawk.Emulation.Cores/Computers/Commodore64/Disk/VIC1541.cs b/BizHawk.Emulation.Cores/Computers/Commodore64/Disk/VIC1541.cs deleted file mode 100644 index 2634933696..0000000000 --- a/BizHawk.Emulation.Cores/Computers/Commodore64/Disk/VIC1541.cs +++ /dev/null @@ -1,266 +0,0 @@ -using System; -using BizHawk.Emulation.Cores.Components.M6502; - -#if false - -namespace BizHawk.Emulation.Cores.Computers.Commodore64 -{ - public class VIC1541 - { - public Action Connect; - public Action Execute; - public Action HardReset; - - public Func Peek; - public Func PeekRom; - public Func PeekRam; - public Func PeekVia0; - public Func PeekVia1; - public Action Poke; - public Action PokeRam; - public Action PokeRom; - public Action PokeVia0; - public Action PokeVia1; - public Func Read; - public Func ReadRam; - public Func ReadRom; - public Func ReadVia0; - public Func ReadVia1; - public Action Write; - public Action WriteRam; - public Action WriteRom; - public Action WriteVia0; - public Action WriteVia1; - - public VIC1541Motherboard board; - - public VIC1541(Region initRegion, byte[] rom) - { - board = new VIC1541Motherboard(initRegion, rom); - Connect = board.Connect; - Execute = board.Execute; - HardReset = board.HardReset; - - Peek = board.pla.Peek; - PeekRam = board.pla.PeekRam; - PeekRom = board.pla.PeekRom; - PeekVia0 = board.pla.PeekVia0; - PeekVia1 = board.pla.PeekVia1; - Poke = board.pla.Poke; - PokeRam = board.pla.PokeRam; - PokeRom = board.pla.PokeRom; - PokeVia0 = board.pla.PokeVia0; - PokeVia1 = board.pla.PokeVia1; - Read = board.pla.Read; - ReadRam = board.pla.ReadRam; - ReadRom = board.pla.ReadRom; - ReadVia0 = board.pla.ReadVia0; - ReadVia1 = board.pla.ReadVia1; - Write = board.pla.Write; - WriteRam = board.pla.WriteRam; - WriteRom = board.pla.WriteRom; - WriteVia0 = board.pla.WriteVia0; - WriteVia1 = board.pla.WriteVia1; - } - - public ushort PC - { - get - { - return board.cpu.PC; - } - } - } - - // because the VIC1541 doesn't have bank switching like the system does, - // we simplify things by processing the rom bytes directly. - - // note: when a byte is read, the drive mechanics will cause - // the V flag on the 6502 to be enabled - - // note: 6502 IRQ is wired to both VIA0 and VIA1. the NMI - // pin is not connected to any other source and is always - // held low. - - // note: there is a GATE ARRAY that directs the signal - // between different parts of the board. it is not emulated - // directly, we are actually performing all its functions - // within the motherboard class itself. - - public class VIC1541Motherboard - { - public MOS6502X cpu; - public VIC1541PLA pla; - public byte[] ram; - public byte[] rom; - public SerialPort serPort; - public MOS6522 via0; - public MOS6522 via1; - - public bool via0CA0; - public bool via0CA1; - public bool via0CB0; - public bool via0CB1; - public byte via0DataA; - public byte via0DataB; - public byte via0DirA; - public byte via0DirB; - public bool via1CA0; - public bool via1CA1; - public bool via1CB0; - public bool via1CB1; - public byte via1DataA; - public byte via1DataB; - public byte via1DirA; - public byte via1DirB; - - public VIC1541Motherboard(Region initRegion, byte[] initRom) - { - cpu = new MOS6502X(); - pla = new VIC1541PLA(); - ram = new byte[0x800]; - rom = initRom; - serPort = new SerialPort(); - via0 = new MOS6522(); - via1 = new MOS6522(); - - cpu.DummyReadMemory = pla.Read; - cpu.ReadMemory = pla.Read; - cpu.WriteMemory = pla.Write; - - pla.PeekRam = ((int addr) => { return ram[addr & 0x07FF]; }); - pla.PeekRom = ((int addr) => { return rom[addr & 0x3FFF]; }); - pla.PeekVia0 = via0.Peek; - pla.PeekVia1 = via1.Peek; - pla.PokeRam = ((int addr, byte val) => { ram[addr & 0x07FF] = val; }); - pla.PokeRom = ((int addr, byte val) => { }); - pla.PokeVia0 = via0.Poke; - pla.PokeVia1 = via1.Poke; - pla.ReadRam = ((ushort addr) => { return ram[addr & 0x07FF]; }); - pla.ReadRom = ((ushort addr) => { return rom[addr & 0x3FFF]; }); - pla.ReadVia0 = via0.Read; - pla.ReadVia1 = via1.Read; - pla.WriteRam = ((ushort addr, byte val) => { ram[addr & 0x07FF] = val; }); - pla.WriteRom = ((ushort addr, byte val) => { }); - pla.WriteVia0 = via0.Write; - pla.WriteVia1 = via1.Write; - - via0CA0 = false; - via0CA1 = false; - via0CB0 = false; - via0CB1 = false; - via0DirA = 0x00; - via0DirB = 0x00; - via0DataA = 0xFF; - via0DataB = 0xFF; - via1CA0 = false; - via1CA1 = false; - via1CB0 = false; - via1CB1 = false; - via1DirA = 0x00; - via1DirB = 0x00; - via1DataA = 0xFF; - via1DataB = 0xFF; - - via0.ReadCA0 = (() => { return via0CA0; }); - via0.ReadCA1 = (() => { return via0CA1; }); - via0.ReadCB0 = (() => { return via0CB0; }); - via0.ReadCB1 = (() => { return via0CB1; }); - via0.ReadDirA = (() => { return via0DirA; }); - via0.ReadDirB = (() => { return via0DirB; }); - via0.ReadPortA = (() => { return via0DataA; }); - via0.ReadPortB = (() => { return via0DataB; }); - via0.WriteCA0 = ((bool val) => { via0CA0 = val; }); - via0.WriteCA1 = ((bool val) => { via0CA1 = val; }); - via0.WriteCB0 = ((bool val) => { via0CB0 = val; }); - via0.WriteCB1 = ((bool val) => { via0CB1 = val; }); - via0.WriteDirA = ((byte val) => { via0DirA = val; }); - via0.WriteDirB = ((byte val) => { via0DirB = val; }); - via0.WritePortA = ((byte val) => { - via0DataA = Port.CPUWrite(via0DataA, val, via0DirA); - }); - via0.WritePortB = ((byte val) => { - via0DataB = Port.CPUWrite(via0DataB, val, via0DirB); - serPort.DeviceWriteAtn((via0DataB & 0x80) != 0); - serPort.DeviceWriteClock((via0DataB & 0x08) != 0); - serPort.DeviceWriteData((via0DataB & 0x02) != 0); - }); - - via1.ReadCA0 = (() => { return via1CA0; }); - via1.ReadCA1 = (() => { return via1CA1; }); - via1.ReadCB0 = (() => { return via1CB0; }); - via1.ReadCB1 = (() => { return via1CB1; }); - via1.ReadDirA = (() => { return via1DirA; }); - via1.ReadDirB = (() => { return via1DirB; }); - via1.ReadPortA = (() => { return via1DataA; }); - via1.ReadPortB = (() => { return via1DataB; }); - via1.WriteCA0 = ((bool val) => { via1CA0 = val; }); - via1.WriteCA1 = ((bool val) => { via1CA1 = val; }); - via1.WriteCB0 = ((bool val) => { via1CB0 = val; }); - via1.WriteCB1 = ((bool val) => { via1CB1 = val; }); - via1.WriteDirA = ((byte val) => { via1DirA = val; }); - via1.WriteDirB = ((byte val) => { via1DirB = val; }); - via1.WritePortA = ((byte val) => { - via1DataA = Port.CPUWrite(via1DataA, val, via1DirA); - }); - via1.WritePortB = ((byte val) => { - via1DataB = Port.CPUWrite(via1DataB, val, via1DirB); - }); - } - - public void Connect(SerialPort newSerPort) - { - // TODO: verify polarity - serPort = newSerPort; - serPort.SystemReadAtn = (() => { - return true; - }); - serPort.SystemReadClock = (() => { - return ((via0DataB & 0x08) != 0); - }); // bit 3 - serPort.SystemReadData = (() => { - return ((via0DataB & 0x02) != 0); - }); // bit 1 - serPort.SystemReadSrq = (() => { - return false; - }); // device sensing - serPort.SystemWriteAtn = ((bool val) => { - via0DataB = Port.ExternalWrite(via0DataB, (byte)((via0DataB & 0x7F) | (val ? 0x80 : 0x00)), via0DataB); - via0CA0 = val; - // repeat to DATA OUT if bit 4 enabled on port B - if ((via0DataB & 0x10) != 0) - serPort.DeviceWriteData(val); - }); - serPort.SystemWriteClock = ((bool val) => { - via0DataB = Port.ExternalWrite(via0DataB, (byte)((via0DataB & 0xFB) | (val ? 0x04 : 0x00)), via0DataB); - }); - serPort.SystemWriteData = ((bool val) => { - via0DataB = Port.ExternalWrite(via0DataB, (byte)((via0DataB & 0xFE) | (val ? 0x01 : 0x00)), via0DataB); - }); - serPort.SystemWriteReset = ((bool val) => { }); - - serPort.DeviceWriteSrq(false); - } - - public void Execute() - { - via0.ExecutePhase1(); - via1.ExecutePhase1(); - - cpu.IRQ = !(via0.IRQ && via1.IRQ); - cpu.ExecuteOne(); - via0.ExecutePhase2(); - via1.ExecutePhase2(); - } - - public void HardReset() - { - for (uint i = 0; i < 0x7FF; i++) - ram[i] = 0x00; - cpu.PC = (ushort)(cpu.ReadMemory(0xFFFC) | ((ushort)cpu.ReadMemory(0xFFFD) << 8)); - via0.HardReset(); - via1.HardReset(); - } - } -} -#endif \ No newline at end of file diff --git a/BizHawk.Emulation.Cores/Computers/Commodore64/Experimental/C64.Glue.cs b/BizHawk.Emulation.Cores/Computers/Commodore64/Experimental/C64.Glue.cs deleted file mode 100644 index 9a0a73cc5d..0000000000 --- a/BizHawk.Emulation.Cores/Computers/Commodore64/Experimental/C64.Glue.cs +++ /dev/null @@ -1,161 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace BizHawk.Emulation.Cores.Computers.Commodore64.Experimental -{ - public sealed partial class C64 - { - public void InitializeConnections() - { - cia1.InputCNT = user.OutputCNT1; - cia1.InputFlag = ReadCia1Flag; - cia1.InputPortA = ReadCia1PortA; - cia1.InputPortB = ReadCia1PortB; - cia1.InputSP = user.OutputSP1; - - cia2.InputCNT = user.OutputCNT2; - cia2.InputFlag = user.OutputFLAG2; - cia2.InputPortA = ReadCia2PortA; - cia2.InputPortB = user.OutputData; - cia2.InputSP = user.OutputSP2; - - cpu.InputAEC = vic.OutputAEC; - cpu.InputIRQ = ReadIRQ; - cpu.InputNMI = ReadNMI; - cpu.InputPort = ReadCPUPort; - cpu.InputRDY = vic.OutputBA; - cpu.ReadMemory = pla.ReadMemory; - cpu.WriteMemory = pla.WriteMemory; - - //expansion.InputBA = vic.OutputBA; - //expansion.InputData = ReadData; - //expansion.InputHiExpansion = ReadHiExpansion; - //expansion.InputHiRom = pla.OutputRomHi; - //expansion.InputIRQ = ReadIRQ; - //expansion.InputLoExpansion = ReadLoExpansion; - //expansion.InputLoRom = pla.OutputRomLo; - //expansion.InputNMI = ReadNMI; - - //pla.InputAEC = vic.OutputAEC; - //pla.InputBA = vic.OutputBA; - //pla.InputCharen = ReadCharen; - //pla.InputExRom = expansion.OutputExRom; - //pla.InputGame = expansion.OutputGame; - //pla.InputHiRam = ReadHiRam; - //pla.InputLoRam = ReadLoRam; - //pla.InputVA = ReadVicAddress; - - //serial.InputATN = ReadSerialATN; - //serial.InputClock = ReadSerialCLK; - //serial.InputData = ReadSerialDTA; - - //user.InputCNT1 = cia1.OutputCNT; - //user.InputCNT2 = cia2.OutputCNT; - //user.InputData = cia2.OutputPortB; - //user.InputPA2 = ReadUserPA2; - //user.InputPC2 = cia2.OutputPC; - //user.InputSP1 = cia1.OutputSP; - //user.InputSP2 = cia2.OutputSP; - } - - bool ReadCia1Cnt() - { - // this pin is not connected - return true; - } - - bool ReadCia1Flag() - { - return serial.SRQ && cassette.Data; - } - - int ReadCia1PortA() - { - return joystickB.Data & keyboard.Column; - } - - int ReadCia1PortB() - { - return joystickA.Data & keyboard.Row; - } - - int ReadCia2PortA() - { - int result = 0xFF; - if (!user.PA2) - result &= 0xFB; - if (!serial.Clock) - result &= 0xBF; - if (!serial.Data) - result &= 0x7F; - return result; - } - - int ReadCPUPort() - { - return 0xFF; - } - - bool ReadHiExpansion() - { - int addr = 0xFFFF; - return (addr >= 0xDF00 && addr < 0xE000); - } - - bool ReadIRQ() - { - return ( - cia1.IRQ && - vic.IRQ && - expansion.IRQ - ); - } - - bool ReadLoExpansion() - { - int addr = 0xFFFF; - return (addr >= 0xDE00 && addr < 0xDF00); - } - - bool ReadLoRam() - { - return (cpu.Port & 0x1) != 0; - } - - bool ReadNMI() - { - return ( - cia2.IRQ && - expansion.NMI - ); - } - - bool ReadSerialATN() - { - return (cia2.PortA & 0x08) != 0; - } - - bool ReadSerialCLK() - { - return (cia2.PortA & 0x10) != 0; - } - - bool ReadSerialDTA() - { - return (cia2.PortA & 0x20) != 0; - } - - bool ReadUserPA2() - { - return (cia2.PortA & 0x04) != 0; - } - - int ReadVicAddress() - { - //return (vic.Address | ((cia2.PortA & 0x3) << 14)); - return 0xFFFF; - } - } -} diff --git a/BizHawk.Emulation.Cores/Computers/Commodore64/Experimental/C64.cs b/BizHawk.Emulation.Cores/Computers/Commodore64/Experimental/C64.cs deleted file mode 100644 index 27e8a8dba2..0000000000 --- a/BizHawk.Emulation.Cores/Computers/Commodore64/Experimental/C64.cs +++ /dev/null @@ -1,131 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace BizHawk.Emulation.Cores.Computers.Commodore64.Experimental -{ - public sealed partial class C64 : IMotherboard - { - public Rom basicRom; - public Cassette cassette; - public Rom characterRom; - public Cia cia1; - public Cia cia2; - public Ram colorRam; - public Cpu cpu; - public Expansion expansion; - public Joystick joystickA; - public Joystick joystickB; - public Rom kernalRom; - public Keyboard keyboard; - public Ram memory; - public Pla pla; - public Serial serial; - public Sid sid; - public Userport user; - public Vic vic; - - public C64(C64Timing timing) - { - } - - public void ExecuteFrame() - { - } - - public byte PeekBasicRom(int addr) - { - throw new NotImplementedException(); - } - - public byte PeekCartridge(int addr) - { - throw new NotImplementedException(); - } - - public byte PeekCharRom(int addr) - { - throw new NotImplementedException(); - } - - public byte PeekCpu(int addr) - { - throw new NotImplementedException(); - } - - public byte PeekKernalRom(int addr) - { - throw new NotImplementedException(); - } - - public byte PeekRam(int addr) - { - throw new NotImplementedException(); - } - - public byte PeekSerial(int addr) - { - throw new NotImplementedException(); - } - - public byte PeekSid(int addr) - { - throw new NotImplementedException(); - } - - public byte PeekVic(int addr) - { - throw new NotImplementedException(); - } - - public void PokeBasicRom(int addr, byte val) - { - throw new NotImplementedException(); - } - - public void PokeCartridge(int addr, byte val) - { - throw new NotImplementedException(); - } - - public void PokeCharRom(int addr, byte val) - { - throw new NotImplementedException(); - } - - public void PokeCpu(int addr, byte val) - { - throw new NotImplementedException(); - } - - public void PokeKernalRom(int addr, byte val) - { - throw new NotImplementedException(); - } - - public void PokeRam(int addr, byte val) - { - throw new NotImplementedException(); - } - - public void PokeSerial(int addr, byte val) - { - throw new NotImplementedException(); - } - - public void PokeSid(int addr, byte val) - { - throw new NotImplementedException(); - } - - public void PokeVic(int addr, byte val) - { - throw new NotImplementedException(); - } - } - - public class C64Timing - { - } -} diff --git a/BizHawk.Emulation.Cores/Computers/Commodore64/Experimental/C64Presets.NTSC.cs b/BizHawk.Emulation.Cores/Computers/Commodore64/Experimental/C64Presets.NTSC.cs deleted file mode 100644 index 83d60dace4..0000000000 --- a/BizHawk.Emulation.Cores/Computers/Commodore64/Experimental/C64Presets.NTSC.cs +++ /dev/null @@ -1,40 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace BizHawk.Emulation.Cores.Computers.Commodore64.Experimental -{ - static public partial class C64ChipPresets - { - static public C64 NTSC(byte[] basic, byte[] kernal, byte[] character) - { - C64 result = new C64(NTSCTiming()); - result.basicRom = ChipPresets.Rom2364(basic); - result.cassette = new Cassette(); - result.characterRom = ChipPresets.Rom2332(character); - result.cia1 = ChipPresets.Cia6526(true); - result.cia2 = ChipPresets.Cia6526(true); - result.colorRam = ChipPresets.Ram2114(); - result.cpu = new Cpu(); - result.expansion = new Expansion(); - result.joystickA = new Joystick(); - result.joystickB = new Joystick(); - result.kernalRom = ChipPresets.Rom2364(kernal); - result.keyboard = new Keyboard(); - result.memory = ChipPresets.Ram4864(); - result.pla = new Pla(); - result.serial = new Serial(); - result.sid = ChipPresets.Sid6581(); - result.user = new Userport(); - result.vic = ChipPresets.Vic6567(); - result.InitializeConnections(); - return result; - } - - static public C64Timing NTSCTiming() - { - return new C64Timing(); - } - } -} diff --git a/BizHawk.Emulation.Cores/Computers/Commodore64/Experimental/C64Presets.PAL.cs b/BizHawk.Emulation.Cores/Computers/Commodore64/Experimental/C64Presets.PAL.cs deleted file mode 100644 index 0d4c0df451..0000000000 --- a/BizHawk.Emulation.Cores/Computers/Commodore64/Experimental/C64Presets.PAL.cs +++ /dev/null @@ -1,40 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace BizHawk.Emulation.Cores.Computers.Commodore64.Experimental -{ - static public partial class C64ChipPresets - { - static public C64 PAL(byte[] basic, byte[] kernal, byte[] character) - { - C64 result = new C64(PALTiming()); - result.basicRom = ChipPresets.Rom2364(basic); - result.cassette = new Cassette(); - result.characterRom = ChipPresets.Rom2332(character); - result.cia1 = ChipPresets.Cia6526(true); - result.cia2 = ChipPresets.Cia6526(true); - result.colorRam = ChipPresets.Ram2114(); - result.cpu = new Cpu(); - result.expansion = new Expansion(); - result.joystickA = new Joystick(); - result.joystickB = new Joystick(); - result.kernalRom = ChipPresets.Rom2364(kernal); - result.keyboard = new Keyboard(); - result.memory = ChipPresets.Ram4864(); - result.pla = new Pla(); - result.serial = new Serial(); - result.sid = ChipPresets.Sid6581(); - result.user = new Userport(); - result.vic = ChipPresets.Vic6569(); - result.InitializeConnections(); - return result; - } - - static public C64Timing PALTiming() - { - return new C64Timing(); - } - } -} diff --git a/BizHawk.Emulation.Cores/Computers/Commodore64/Experimental/Chips/Internals/Cassette.cs b/BizHawk.Emulation.Cores/Computers/Commodore64/Experimental/Chips/Internals/Cassette.cs deleted file mode 100644 index e020b0c920..0000000000 --- a/BizHawk.Emulation.Cores/Computers/Commodore64/Experimental/Chips/Internals/Cassette.cs +++ /dev/null @@ -1,21 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -using BizHawk.Common; - -namespace BizHawk.Emulation.Cores.Computers.Commodore64.Experimental -{ - public class Cassette - { - public Func InputData; - public Func InputMotor; - - virtual public bool Data { get { return true; } } - public bool OutputData() { return Data; } - public bool OutputSense() { return Sense; } - virtual public bool Sense { get { return true; } } - virtual public void SyncState(Serializer ser) { SaveState.SyncObject(ser, this); } - } -} diff --git a/BizHawk.Emulation.Cores/Computers/Commodore64/Experimental/Chips/Internals/Cia.Interface.cs b/BizHawk.Emulation.Cores/Computers/Commodore64/Experimental/Chips/Internals/Cia.Interface.cs deleted file mode 100644 index a6c9f8617b..0000000000 --- a/BizHawk.Emulation.Cores/Computers/Commodore64/Experimental/Chips/Internals/Cia.Interface.cs +++ /dev/null @@ -1,35 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -using BizHawk.Common; - -namespace BizHawk.Emulation.Cores.Computers.Commodore64.Experimental -{ - sealed public partial class Cia - { - public Func InputCNT; - public Func InputFlag; - public Func InputPortA; - public Func InputPortB; - public Func InputSP; - - public bool CNT { get { return true; } } - public bool IRQ { get { return true; } } - public bool OutputCNT() { return CNT; } - public bool OutputIRQ() { return IRQ; } - public bool OutputPC() { return PC; } - public int OutputPortA() { return PortA; } - public int OutputPortB() { return PortB; } - public bool OutputSP() { return SP; } - public bool PC { get { return true; } } - public int PortA { get { return 0xFF; } } - public int PortB { get { return 0xFF; } } - public bool PortA0 { get { return true; } } - public bool SP { get { return true; } } - - public void Clock() { } - public void SyncState(Serializer ser) { SaveState.SyncObject(ser, this); } - } -} diff --git a/BizHawk.Emulation.Cores/Computers/Commodore64/Experimental/Chips/Internals/Cia.Internal.cs b/BizHawk.Emulation.Cores/Computers/Commodore64/Experimental/Chips/Internals/Cia.Internal.cs deleted file mode 100644 index 5570f9c8d7..0000000000 --- a/BizHawk.Emulation.Cores/Computers/Commodore64/Experimental/Chips/Internals/Cia.Internal.cs +++ /dev/null @@ -1,19 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace BizHawk.Emulation.Cores.Computers.Commodore64.Experimental -{ - sealed public partial class Cia - { - public Cia(CiaSettings settings) - { - Reset(); - } - - public void Reset() - { - } - } -} diff --git a/BizHawk.Emulation.Cores/Computers/Commodore64/Experimental/Chips/Internals/Cia.Registers.cs b/BizHawk.Emulation.Cores/Computers/Commodore64/Experimental/Chips/Internals/Cia.Registers.cs deleted file mode 100644 index 3721518bbf..0000000000 --- a/BizHawk.Emulation.Cores/Computers/Commodore64/Experimental/Chips/Internals/Cia.Registers.cs +++ /dev/null @@ -1,29 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace BizHawk.Emulation.Cores.Computers.Commodore64.Experimental -{ - sealed public partial class Cia - { - public int Peek(int addr) - { - return 0xFF; - } - - public void Poke(int addr, int val) - { - } - - public int Read(int addr) - { - return Peek(addr); - } - - public void Write(int addr, int val) - { - Poke(addr, val); - } - } -} diff --git a/BizHawk.Emulation.Cores/Computers/Commodore64/Experimental/Chips/Internals/Cia.Settings.cs b/BizHawk.Emulation.Cores/Computers/Commodore64/Experimental/Chips/Internals/Cia.Settings.cs deleted file mode 100644 index 3f0ac62073..0000000000 --- a/BizHawk.Emulation.Cores/Computers/Commodore64/Experimental/Chips/Internals/Cia.Settings.cs +++ /dev/null @@ -1,11 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace BizHawk.Emulation.Cores.Computers.Commodore64.Experimental -{ - public class CiaSettings - { - } -} diff --git a/BizHawk.Emulation.Cores/Computers/Commodore64/Experimental/Chips/Internals/Cpu.Interface.cs b/BizHawk.Emulation.Cores/Computers/Commodore64/Experimental/Chips/Internals/Cpu.Interface.cs deleted file mode 100644 index 78de172e45..0000000000 --- a/BizHawk.Emulation.Cores/Computers/Commodore64/Experimental/Chips/Internals/Cpu.Interface.cs +++ /dev/null @@ -1,40 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -using BizHawk.Common; - -namespace BizHawk.Emulation.Cores.Computers.Commodore64.Experimental -{ - sealed public partial class Cpu - { - public Func InputAEC; - public Func InputIRQ; - public Func InputNMI; - public Func InputPort; - public Func InputRDY; - public Func ReadMemory; - public Action WriteMemory; - - public int OutputPort() { return Port; } - public bool OutputPort0() { return Port0; } - public bool OutputPort1() { return Port1; } - public bool OutputPort2() { return Port2; } - public bool OutputPort3() { return Port3; } - public bool OutputPort4() { return Port4; } - public bool OutputPort5() { return Port5; } - public bool OutputPort6() { return Port6; } - public bool OutputPort7() { return Port7; } - public int Port { get { return (portLatch | (~portDirection)) & 0xFF; } } - public bool Port0 { get { return (Port & 0x01) != 0; } } - public bool Port1 { get { return (Port & 0x02) != 0; } } - public bool Port2 { get { return (Port & 0x04) != 0; } } - public bool Port3 { get { return (Port & 0x08) != 0; } } - public bool Port4 { get { return (Port & 0x10) != 0; } } - 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) { SaveState.SyncObject(ser, this); } - } -} diff --git a/BizHawk.Emulation.Cores/Computers/Commodore64/Experimental/Chips/Internals/Cpu.Internal.cs b/BizHawk.Emulation.Cores/Computers/Commodore64/Experimental/Chips/Internals/Cpu.Internal.cs deleted file mode 100644 index 0afad89dcf..0000000000 --- a/BizHawk.Emulation.Cores/Computers/Commodore64/Experimental/Chips/Internals/Cpu.Internal.cs +++ /dev/null @@ -1,91 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -using BizHawk.Emulation.Cores.Components.M6502; - -namespace BizHawk.Emulation.Cores.Computers.Commodore64.Experimental -{ - sealed public partial class Cpu - { - int cachedAddress; - int cachedData; - bool cachedNMI; - int delayCycles; - bool nmiBuffer; - int portDirection; - int portLatch; - MOS6502X processor; - int resetPC; - - public Cpu() - { - processor = new MOS6502X(); - processor.DummyReadMemory = CoreReadMemory; - processor.ReadMemory = CoreReadMemory; - processor.WriteMemory = CoreWriteMemory; - Reset(); - } - - public void Clock() - { - if (delayCycles > 0) - { - delayCycles--; - if (delayCycles == 1) - { - resetPC = ReadMemory(0xFFFC); - } - else if (delayCycles == 0) - { - resetPC |= ReadMemory(0xFFFD) << 8; - processor.PC = (ushort)resetPC; - } - } - else - { - if (InputAEC()) - { - processor.IRQ = !InputIRQ(); //6502 core expects inverted input - nmiBuffer = InputNMI(); - if (!nmiBuffer && cachedNMI) - processor.NMI = true; //6502 core expects inverted input - cachedNMI = nmiBuffer; - processor.RDY = InputRDY(); - processor.ExecuteOne(); - } - } - } - - byte CoreReadMemory(ushort addr) - { - if (addr == 0x0000) - return (byte)(portDirection & 0xFF); - else if (addr == 0x0001) - return (byte)((InputPort() | (portDirection ^ 0xFF)) & 0xFF); - else - return (byte)(ReadMemory(addr) & 0xFF); - } - - void CoreWriteMemory(ushort addr, byte val) - { - cachedAddress = addr; - cachedData = val; - if (addr == 0x0000) - portDirection = val; - else if (addr == 0x0001) - portLatch = val; - else - WriteMemory(addr, val); - } - - public void Reset() - { - delayCycles = 6; - processor.Reset(); - processor.BCD_Enabled = true; - processor.PC = (ushort)((CoreReadMemory(0xFFFD) << 8) | CoreReadMemory(0xFFFC)); - } - } -} diff --git a/BizHawk.Emulation.Cores/Computers/Commodore64/Experimental/Chips/Internals/Cpu.State.cs b/BizHawk.Emulation.Cores/Computers/Commodore64/Experimental/Chips/Internals/Cpu.State.cs deleted file mode 100644 index 22d923a7f2..0000000000 --- a/BizHawk.Emulation.Cores/Computers/Commodore64/Experimental/Chips/Internals/Cpu.State.cs +++ /dev/null @@ -1,11 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace BizHawk.Emulation.Cores.Computers.Commodore64.Experimental -{ - sealed public partial class Cpu - { - } -} diff --git a/BizHawk.Emulation.Cores/Computers/Commodore64/Experimental/Chips/Internals/Expansion.cs b/BizHawk.Emulation.Cores/Computers/Commodore64/Experimental/Chips/Internals/Expansion.cs deleted file mode 100644 index 43fb3b44f5..0000000000 --- a/BizHawk.Emulation.Cores/Computers/Commodore64/Experimental/Chips/Internals/Expansion.cs +++ /dev/null @@ -1,22 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -using BizHawk.Common; - -namespace BizHawk.Emulation.Cores.Computers.Commodore64.Experimental -{ - public class Expansion - { - virtual public bool ExRom { get { return true; } } - virtual public bool Game { get { return true; } } - virtual public bool IRQ { get { return true; } } - virtual public bool NMI { get { return true; } } - public bool OutputExRom() { return ExRom; } - public bool OutputGame() { return Game; } - public bool OutputIRQ() { return IRQ; } - public bool OutputNMI() { return NMI; } - virtual public void SyncState(Serializer ser) { SaveState.SyncObject(ser, this); } - } -} diff --git a/BizHawk.Emulation.Cores/Computers/Commodore64/Experimental/Chips/Internals/Joystick.cs b/BizHawk.Emulation.Cores/Computers/Commodore64/Experimental/Chips/Internals/Joystick.cs deleted file mode 100644 index 824e9ebf73..0000000000 --- a/BizHawk.Emulation.Cores/Computers/Commodore64/Experimental/Chips/Internals/Joystick.cs +++ /dev/null @@ -1,18 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -using BizHawk.Common; - -namespace BizHawk.Emulation.Cores.Computers.Commodore64.Experimental -{ - public class Joystick - { - virtual public int Data { get { return 0xFF; } } - public int OutputData() { return Data; } - public int OutputPot() { return Pot; } - virtual public int Pot { get { return 0xFF; } } - virtual public void SyncState(Serializer ser) { SaveState.SyncObject(ser, this); } - } -} diff --git a/BizHawk.Emulation.Cores/Computers/Commodore64/Experimental/Chips/Internals/Keyboard.cs b/BizHawk.Emulation.Cores/Computers/Commodore64/Experimental/Chips/Internals/Keyboard.cs deleted file mode 100644 index d267ebd9c9..0000000000 --- a/BizHawk.Emulation.Cores/Computers/Commodore64/Experimental/Chips/Internals/Keyboard.cs +++ /dev/null @@ -1,20 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -using BizHawk.Common; - -namespace BizHawk.Emulation.Cores.Computers.Commodore64.Experimental -{ - public class Keyboard - { - virtual public int Column { get { return 0xFF; } } - public int OutputColumn() { return Column; } - public bool OutputRestore() { return Restore; } - 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) { SaveState.SyncObject(ser, this); } - } -} diff --git a/BizHawk.Emulation.Cores/Computers/Commodore64/Experimental/Chips/Internals/Pla.cs b/BizHawk.Emulation.Cores/Computers/Commodore64/Experimental/Chips/Internals/Pla.cs deleted file mode 100644 index c181eb7f0c..0000000000 --- a/BizHawk.Emulation.Cores/Computers/Commodore64/Experimental/Chips/Internals/Pla.cs +++ /dev/null @@ -1,324 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace BizHawk.Emulation.Cores.Computers.Commodore64.Experimental -{ - sealed public class Pla - { - public Func InputCharen; - public Func InputExRom; - public Func InputGame; - public Func InputHiRam; - public Func InputLoRam; - - public Func PeekBasicRom; - public Func PeekCartridgeLo; - public Func PeekCartridgeHi; - public Func PeekCharRom; - public Func PeekCia1; - public Func PeekCia2; - public Func PeekColorRam; - public Func PeekExpansionLo; - public Func PeekExpansionHi; - public Func PeekKernalRom; - public Func PeekMemory; - public Func PeekSid; - public Func PeekVic; - public Action PokeCartridgeLo; - public Action PokeCartridgeHi; - public Action PokeCia1; - public Action PokeCia2; - public Action PokeColorRam; - public Action PokeExpansionLo; - public Action PokeExpansionHi; - public Action PokeMemory; - public Action PokeSid; - public Action PokeVic; - public Func ReadBasicRom; - public Func ReadCartridgeLo; - public Func ReadCartridgeHi; - public Func ReadCharRom; - public Func ReadCia1; - public Func ReadCia2; - public Func ReadColorRam; - public Func ReadExpansionLo; - public Func ReadExpansionHi; - public Func ReadKernalRom; - public Func ReadMemory; - public Func ReadSid; - public Func ReadVic; - public Action WriteCartridgeLo; - public Action WriteCartridgeHi; - public Action WriteCia1; - public Action WriteCia2; - public Action WriteColorRam; - public Action WriteExpansionLo; - public Action WriteExpansionHi; - public Action WriteMemory; - public Action WriteSid; - public Action WriteVic; - - enum PLABank - { - None, - RAM, - BasicROM, - KernalROM, - CharROM, - IO, - CartridgeLo, - CartridgeHi, - Vic, - Sid, - ColorRam, - Cia1, - Cia2, - ExpansionLo, - ExpansionHi - } - - bool loram; - bool hiram; - bool game; - bool exrom; - bool charen; - bool a15; - bool a14; - bool a13; - bool a12; - - public int Peek(int addr) - { - switch (Resolve(addr, true)) - { - case PLABank.BasicROM: - return PeekBasicRom(addr); - case PLABank.CartridgeHi: - return PeekCartridgeHi(addr); - case PLABank.CartridgeLo: - return PeekCartridgeLo(addr); - case PLABank.CharROM: - return PeekCharRom(addr); - case PLABank.Cia1: - return PeekCia1(addr); - case PLABank.Cia2: - return PeekCia2(addr); - case PLABank.ColorRam: - return PeekColorRam(addr); - case PLABank.ExpansionLo: - return PeekExpansionLo(addr); - case PLABank.ExpansionHi: - return PeekExpansionHi(addr); - case PLABank.KernalROM: - return PeekKernalRom(addr); - case PLABank.RAM: - return PeekMemory(addr); - case PLABank.Sid: - return PeekSid(addr); - case PLABank.Vic: - return PeekVic(addr); - } - return 0xFF; - } - - public void Poke(int addr, int val) - { - switch (Resolve(addr, false)) - { - case PLABank.CartridgeHi: - PokeCartridgeHi(addr, val); - break; - case PLABank.CartridgeLo: - PokeCartridgeLo(addr, val); - break; - case PLABank.Cia1: - PokeCia1(addr, val); - break; - case PLABank.Cia2: - PokeCia2(addr, val); - break; - case PLABank.ColorRam: - PokeColorRam(addr, val); - break; - case PLABank.ExpansionLo: - PokeExpansionLo(addr, val); - break; - case PLABank.ExpansionHi: - PokeExpansionHi(addr, val); - break; - case PLABank.RAM: - PokeMemory(addr, val); - break; - case PLABank.Sid: - PokeSid(addr, val); - break; - case PLABank.Vic: - PokeVic(addr, val); - break; - } - } - - public int Read(int addr) - { - switch (Resolve(addr, true)) - { - case PLABank.BasicROM: - return ReadBasicRom(addr); - case PLABank.CartridgeHi: - return ReadCartridgeHi(addr); - case PLABank.CartridgeLo: - return ReadCartridgeLo(addr); - case PLABank.CharROM: - return ReadCharRom(addr); - case PLABank.Cia1: - return ReadCia1(addr); - case PLABank.Cia2: - return ReadCia2(addr); - case PLABank.ColorRam: - return ReadColorRam(addr); - case PLABank.ExpansionLo: - return ReadExpansionLo(addr); - case PLABank.ExpansionHi: - return ReadExpansionHi(addr); - case PLABank.KernalROM: - return ReadKernalRom(addr); - case PLABank.RAM: - return ReadMemory(addr); - case PLABank.Sid: - return ReadSid(addr); - case PLABank.Vic: - return ReadVic(addr); - } - return 0xFF; - } - - PLABank Resolve(int addr, bool read) - { - loram = InputLoRam(); - hiram = InputHiRam(); - game = InputGame(); - exrom = InputExRom(); - - a15 = (addr & 0x08000) != 0; - a14 = (addr & 0x04000) != 0; - a13 = (addr & 0x02000) != 0; - a12 = (addr & 0x01000) != 0; - - // upper memory regions 8000-FFFF - if (a15) - { - // io/character access - if (a14 && !a13 && a12) - { - // character rom, banked in at D000-DFFF - charen = InputCharen(); - if (read && !charen && (((hiram || loram) && game) || (hiram && !exrom && !game))) - return PLABank.CharROM; - - // io block, banked in at D000-DFFF - if ((charen && (hiram || loram)) || (exrom && !game)) - { - if (addr < 0xD400) - return PLABank.Vic; - if (addr < 0xD800) - return PLABank.Sid; - if (addr < 0xDC00) - return PLABank.ColorRam; - if (addr < 0xDD00) - return PLABank.Cia1; - if (addr < 0xDE00) - return PLABank.Cia2; - if (addr < 0xDF00) - return PLABank.ExpansionLo; - return PLABank.ExpansionHi; - } - } - - if (read) - { - // cartridge high, banked either at A000-BFFF or E000-FFFF depending - if (a13 && !game && ((hiram && !a14 && !exrom) || (a14 && exrom))) - return PLABank.CartridgeHi; - - // cartridge low, banked at 8000-9FFF - if (!a14 && !a13 && ((loram && hiram && !exrom) || (exrom && !game))) - return PLABank.CartridgeLo; - - // kernal rom, banked at E000-FFFF - if (hiram && a14 && a13 && (game || (!exrom && !game))) - return PLABank.KernalROM; - - // basic rom, banked at A000-BFFF - if (loram && hiram && !a14 && a13 && game) - return PLABank.BasicROM; - } - } - - // ultimax mode ram exclusion - if (exrom && !game && ((a15 && ((!a14 && a13) || (a14 && !a13 && !a12))) || (!a15 && (a14 || (!a14 && (a12 || a13)))))) - return PLABank.None; - - return PLABank.RAM; - } - - public int VicRead(int addr) - { - game = InputGame(); - exrom = InputExRom(); - a14 = (addr & 0x04000) == 0; - a13 = (addr & 0x02000) != 0; - a12 = (addr & 0x01000) != 0; - - // read char rom at 1000-1FFF and 9000-9FFF - if (a14 && !a13 && a12 && (game || !exrom)) - return ReadCharRom(addr); - - // read cartridge rom in ultimax mode - if (a13 && a12 && exrom && !game) - return ReadCartridgeHi(addr); - - return ReadMemory(addr); - } - - public void Write(int addr, int val) - { - switch (Resolve(addr, false)) - { - case PLABank.CartridgeHi: - WriteCartridgeHi(addr, val); - WriteMemory(addr, val); - break; - case PLABank.CartridgeLo: - WriteCartridgeLo(addr, val); - WriteMemory(addr, val); - break; - case PLABank.Cia1: - WriteCia1(addr, val); - break; - case PLABank.Cia2: - WriteCia2(addr, val); - break; - case PLABank.ColorRam: - WriteColorRam(addr, val); - break; - case PLABank.ExpansionLo: - WriteExpansionLo(addr, val); - return; - case PLABank.ExpansionHi: - WriteExpansionHi(addr, val); - return; - case PLABank.RAM: - WriteMemory(addr, val); - break; - case PLABank.Sid: - WriteSid(addr, val); - break; - case PLABank.Vic: - WriteVic(addr, val); - break; - } - } - } -} diff --git a/BizHawk.Emulation.Cores/Computers/Commodore64/Experimental/Chips/Internals/Ram.cs b/BizHawk.Emulation.Cores/Computers/Commodore64/Experimental/Chips/Internals/Ram.cs deleted file mode 100644 index 520ffa530d..0000000000 --- a/BizHawk.Emulation.Cores/Computers/Commodore64/Experimental/Chips/Internals/Ram.cs +++ /dev/null @@ -1,45 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -using BizHawk.Common; - -namespace BizHawk.Emulation.Cores.Computers.Commodore64.Experimental -{ - sealed public class Ram - { - int addressMask; - int dataMask; - int[] memory; - - public Ram(int size, int addressMask, int dataMask) - { - this.addressMask = addressMask; - this.dataMask = dataMask; - this.memory = new int[size]; - } - - public int Peek(int addr) - { - return memory[addr & addressMask]; - } - - public void Poke(int addr, int val) - { - memory[addr & addressMask] = val; - } - - public int Read(int addr) - { - return memory[addr & addressMask]; - } - - public void Write(int addr, int val) - { - memory[addr & addressMask] = val & dataMask; - } - - public void SyncState(Serializer ser) { SaveState.SyncObject(ser, this); } - } -} diff --git a/BizHawk.Emulation.Cores/Computers/Commodore64/Experimental/Chips/Internals/Rom.cs b/BizHawk.Emulation.Cores/Computers/Commodore64/Experimental/Chips/Internals/Rom.cs deleted file mode 100644 index 0e82dcfb2e..0000000000 --- a/BizHawk.Emulation.Cores/Computers/Commodore64/Experimental/Chips/Internals/Rom.cs +++ /dev/null @@ -1,35 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -using BizHawk.Common; - -namespace BizHawk.Emulation.Cores.Computers.Commodore64.Experimental -{ - public class Rom - { - int addressMask; - int[] memory; - - public Rom(int size, int addressMask, byte[] data) - { - this.addressMask = addressMask; - this.memory = new int[size]; - for (int i = 0; i < size; i++) - memory[i] = data[i]; - } - - public int Peek(int addr) - { - return memory[addr & addressMask]; - } - - public int Read(int addr) - { - return memory[addr & addressMask]; - } - - public void SyncState(Serializer ser) { SaveState.SyncObject(ser, this); } - } -} diff --git a/BizHawk.Emulation.Cores/Computers/Commodore64/Experimental/Chips/Internals/Serial.cs b/BizHawk.Emulation.Cores/Computers/Commodore64/Experimental/Chips/Internals/Serial.cs deleted file mode 100644 index 2a5294d082..0000000000 --- a/BizHawk.Emulation.Cores/Computers/Commodore64/Experimental/Chips/Internals/Serial.cs +++ /dev/null @@ -1,25 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -using BizHawk.Common; - -namespace BizHawk.Emulation.Cores.Computers.Commodore64.Experimental -{ - public class Serial - { - public Func InputATN; - public Func InputClock; - public Func InputData; - public Func InputReset; - - virtual public bool Clock { get { return true; } } - virtual public bool Data { get { return true; } } - public bool OutputClock() { return Clock; } - public bool OutputData() { return Data; } - public bool OutputSRQ() { return SRQ; } - virtual public bool SRQ { get { return true; } } - virtual public void SyncState(Serializer ser) { SaveState.SyncObject(ser, this); } - } -} diff --git a/BizHawk.Emulation.Cores/Computers/Commodore64/Experimental/Chips/Internals/Sid.Interface.cs b/BizHawk.Emulation.Cores/Computers/Commodore64/Experimental/Chips/Internals/Sid.Interface.cs deleted file mode 100644 index dfcdec712b..0000000000 --- a/BizHawk.Emulation.Cores/Computers/Commodore64/Experimental/Chips/Internals/Sid.Interface.cs +++ /dev/null @@ -1,14 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -using BizHawk.Common; - -namespace BizHawk.Emulation.Cores.Computers.Commodore64.Experimental -{ - sealed public partial class Sid - { - public void SyncState(Serializer ser) { } - } -} diff --git a/BizHawk.Emulation.Cores/Computers/Commodore64/Experimental/Chips/Internals/Sid.Internal.cs b/BizHawk.Emulation.Cores/Computers/Commodore64/Experimental/Chips/Internals/Sid.Internal.cs deleted file mode 100644 index 19a79db941..0000000000 --- a/BizHawk.Emulation.Cores/Computers/Commodore64/Experimental/Chips/Internals/Sid.Internal.cs +++ /dev/null @@ -1,25 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace BizHawk.Emulation.Cores.Computers.Commodore64.Experimental -{ - sealed public partial class Sid - { - public Sid(SidSettings settings) - { - Reset(); - } - - public void Clock() - { - } - - public void Reset() - { - for (int i = 0; i < 0x20; i++) - Poke(i, 0); - } - } -} diff --git a/BizHawk.Emulation.Cores/Computers/Commodore64/Experimental/Chips/Internals/Sid.Registers.cs b/BizHawk.Emulation.Cores/Computers/Commodore64/Experimental/Chips/Internals/Sid.Registers.cs deleted file mode 100644 index 09f5156ad0..0000000000 --- a/BizHawk.Emulation.Cores/Computers/Commodore64/Experimental/Chips/Internals/Sid.Registers.cs +++ /dev/null @@ -1,29 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace BizHawk.Emulation.Cores.Computers.Commodore64.Experimental -{ - sealed public partial class Sid - { - public int Peek(int addr) - { - return 0xFF; - } - - public void Poke(int addr, int val) - { - } - - public int Read(int addr) - { - return Peek(addr); - } - - public void Write(int addr, int val) - { - Poke(addr, val); - } - } -} diff --git a/BizHawk.Emulation.Cores/Computers/Commodore64/Experimental/Chips/Internals/Sid.Settings.cs b/BizHawk.Emulation.Cores/Computers/Commodore64/Experimental/Chips/Internals/Sid.Settings.cs deleted file mode 100644 index 258bbd9a5a..0000000000 --- a/BizHawk.Emulation.Cores/Computers/Commodore64/Experimental/Chips/Internals/Sid.Settings.cs +++ /dev/null @@ -1,11 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace BizHawk.Emulation.Cores.Computers.Commodore64.Experimental -{ - public class SidSettings - { - } -} diff --git a/BizHawk.Emulation.Cores/Computers/Commodore64/Experimental/Chips/Internals/Sid.SoundProvider.cs b/BizHawk.Emulation.Cores/Computers/Commodore64/Experimental/Chips/Internals/Sid.SoundProvider.cs deleted file mode 100644 index f4b048dbdf..0000000000 --- a/BizHawk.Emulation.Cores/Computers/Commodore64/Experimental/Chips/Internals/Sid.SoundProvider.cs +++ /dev/null @@ -1,17 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -using BizHawk.Emulation.Common; - -namespace BizHawk.Emulation.Cores.Computers.Commodore64.Experimental -{ - sealed public partial class Sid - { - public ISoundProvider GetSoundProvider() - { - return new NullSound(); - } - } -} diff --git a/BizHawk.Emulation.Cores/Computers/Commodore64/Experimental/Chips/Internals/Userport.cs b/BizHawk.Emulation.Cores/Computers/Commodore64/Experimental/Chips/Internals/Userport.cs deleted file mode 100644 index 3989f79b5e..0000000000 --- a/BizHawk.Emulation.Cores/Computers/Commodore64/Experimental/Chips/Internals/Userport.cs +++ /dev/null @@ -1,38 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace BizHawk.Emulation.Cores.Computers.Commodore64.Experimental -{ - public class Userport - { - public Func InputCNT1; - public Func InputCNT2; - public Func InputData; - public Func InputPA2; - public Func InputPC2; - public Func InputReset; - public Func InputSP1; - public Func InputSP2; - - virtual public bool ATN { get { return true; } } - virtual public bool CNT1 { get { return true; } } - virtual public bool CNT2 { get { return true; } } - virtual public int Data { get { return 0xFF; } } - virtual public bool FLAG2 { get { return true; } } - public bool OutputATN() { return ATN; } - public bool OutputCNT1() { return CNT1; } - public bool OutputCNT2() { return CNT2; } - public int OutputData() { return Data; } - public bool OutputFLAG2() { return FLAG2; } - public bool OutputPA2() { return PA2; } - public bool OutputReset() { return Reset; } - public bool OutputSP1() { return SP1; } - public bool OutputSP2() { return SP2; } - virtual public bool PA2 { get { return true; } } - virtual public bool Reset { get { return true; } } - virtual public bool SP1 { get { return true; } } - virtual public bool SP2 { get { return true; } } - } -} diff --git a/BizHawk.Emulation.Cores/Computers/Commodore64/Experimental/Chips/Internals/Vic.Graphics.cs b/BizHawk.Emulation.Cores/Computers/Commodore64/Experimental/Chips/Internals/Vic.Graphics.cs deleted file mode 100644 index ab07ee145b..0000000000 --- a/BizHawk.Emulation.Cores/Computers/Commodore64/Experimental/Chips/Internals/Vic.Graphics.cs +++ /dev/null @@ -1,155 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -#pragma warning disable 649 //adelikat: Disable dumb warnings until this file is complete -#pragma warning disable 169 //adelikat: Disable dumb warnings until this file is complete - -namespace BizHawk.Emulation.Cores.Computers.Commodore64.Experimental -{ - sealed public partial class Vic - { - const int GRAPHICS_DATA_00 = 0; - const int GRAPHICS_DATA_01 = 0x4000; - const int GRAPHICS_DATA_10 = GRAPHICS_DATA_01 << 1; - const int GRAPHICS_DATA_11 = GRAPHICS_DATA_01 | GRAPHICS_DATA_10; - const int GRAPHICS_DATA_OUTPUT_MASK = GRAPHICS_DATA_11; - - enum GraphicsMode - { - Mode000, - Mode001, - Mode010, - Mode011, - Mode100, - Mode101, - Mode110, - Mode111 - } - - int g_BufferC; - int g_BufferG; - int g_DataC; - int g_DataG; - bool g_Idle; - int g_FillRasterX; - GraphicsMode g_Mode; - int g_OutData; - int g_OutPixel; - int g_ShiftRegister; - - void RenderGraphics() - { - if ((rasterX & 0x7) == g_FillRasterX) - { - if (g_Idle) - g_DataC = 0; - else - g_DataC = g_BufferC; - - if (multiColorMode && (bitmapMode || (g_DataC & 0x8) != 0)) - { - // load multicolor bits - // xx00xx11xx22xx33 - g_ShiftRegister = - ((g_DataG & 0x03) << 0) | - ((g_DataG & 0x0C) << 2) | - ((g_DataG & 0x30) << 4) | - ((g_DataG & 0xC0) << 6) - ; - - // duplicate bits - // 0000111122223333 - g_ShiftRegister |= g_ShiftRegister << 2; - } - else - { - // load single color bits - // 0x1x2x3x4x5x6x7x - g_ShiftRegister = - ((g_DataG & 0x01) << 1) | - ((g_DataG & 0x02) << 2) | - ((g_DataG & 0x04) << 3) | - ((g_DataG & 0x08) << 4) | - ((g_DataG & 0x10) << 5) | - ((g_DataG & 0x20) << 6) | - ((g_DataG & 0x40) << 7) | - ((g_DataG & 0x80) << 8) - ; - - if (!bitmapMode) - { - // duplicate bits - // 0011223344556677 - g_ShiftRegister |= g_ShiftRegister << 1; - } - else - { - // convert to bitmap format - g_ShiftRegister = (g_ShiftRegister | 0x5555) ^ (g_ShiftRegister >> 1); - } - } - } - - g_OutData = g_ShiftRegister & GRAPHICS_DATA_OUTPUT_MASK; - - switch (g_Mode) - { - case GraphicsMode.Mode000: - case GraphicsMode.Mode001: - if (g_OutData == GRAPHICS_DATA_00) - g_OutPixel = backgroundColor[0]; - else if (g_OutData == GRAPHICS_DATA_11) - g_OutPixel = ((g_DataC >> 8) & 0x7); - else if (g_OutData == GRAPHICS_DATA_01) - g_OutPixel = backgroundColor[1]; - else - g_OutPixel = backgroundColor[2]; - break; - case GraphicsMode.Mode010: - case GraphicsMode.Mode011: - if (g_OutData == GRAPHICS_DATA_00) - g_OutPixel = backgroundColor[0]; - else if (g_OutData == GRAPHICS_DATA_01) - g_OutPixel = ((g_DataC >> 4) & 0xF); - else if (g_OutData == GRAPHICS_DATA_10) - g_OutPixel = (g_DataC & 0xF); - else - g_OutPixel = (g_DataC >> 8); - break; - case GraphicsMode.Mode100: - if (g_OutData == GRAPHICS_DATA_00) - g_OutPixel = backgroundColor[(g_DataC >> 6) & 0x3]; - else - g_OutPixel = (g_DataC >> 8); - break; - default: - g_OutPixel = 0; - break; - } - - g_ShiftRegister <<= 2; - } - - void UpdateGraphicsMode() - { - if (!extraColorMode && !bitmapMode && !multiColorMode) - g_Mode = GraphicsMode.Mode000; - else if (!extraColorMode && !bitmapMode && multiColorMode) - g_Mode = GraphicsMode.Mode001; - else if (!extraColorMode && bitmapMode && !multiColorMode) - g_Mode = GraphicsMode.Mode010; - else if (!extraColorMode && bitmapMode && multiColorMode) - g_Mode = GraphicsMode.Mode011; - else if (extraColorMode && !bitmapMode && !multiColorMode) - g_Mode = GraphicsMode.Mode100; - else if (extraColorMode && !bitmapMode && multiColorMode) - g_Mode = GraphicsMode.Mode101; - else if (extraColorMode && bitmapMode && !multiColorMode) - g_Mode = GraphicsMode.Mode110; - else if (extraColorMode && bitmapMode && multiColorMode) - g_Mode = GraphicsMode.Mode111; - } - } -} diff --git a/BizHawk.Emulation.Cores/Computers/Commodore64/Experimental/Chips/Internals/Vic.Interface.cs b/BizHawk.Emulation.Cores/Computers/Commodore64/Experimental/Chips/Internals/Vic.Interface.cs deleted file mode 100644 index 41d47faad8..0000000000 --- a/BizHawk.Emulation.Cores/Computers/Commodore64/Experimental/Chips/Internals/Vic.Interface.cs +++ /dev/null @@ -1,30 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace BizHawk.Emulation.Cores.Computers.Commodore64.Experimental -{ - sealed public partial class Vic - { - // inputs - public Action ClockPhi0; - public Func ReadColorRam; - public Func ReadRam; - - // outputs - public bool AEC { get { return true; } } - public bool BA { get { return true; } } - public bool IRQ { get { return true; } } - public bool OutputAEC() { return true; } - public bool OutputBA() { return true; } - public bool OutputIRQ() { return true; } - - // exposed internal data - public int Address { get { return address; } } - public int CyclesPerFrame { get { return rasterCount * rasterWidth / 8; } } - public int CyclesPerSecond { get { return frequency; } } - public int Data { get { return data; } } - public int DataPhi1 { get { return phi1Data; } } - } -} diff --git a/BizHawk.Emulation.Cores/Computers/Commodore64/Experimental/Chips/Internals/Vic.Internal.cs b/BizHawk.Emulation.Cores/Computers/Commodore64/Experimental/Chips/Internals/Vic.Internal.cs deleted file mode 100644 index b6ab166fe0..0000000000 --- a/BizHawk.Emulation.Cores/Computers/Commodore64/Experimental/Chips/Internals/Vic.Internal.cs +++ /dev/null @@ -1,33 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -#pragma warning disable 649 //adelikat: Disable dumb warnings until this file is complete -#pragma warning disable 169 //adelikat: Disable dumb warnings until this file is complete - -namespace BizHawk.Emulation.Cores.Computers.Commodore64.Experimental -{ - sealed public partial class Vic - { - int address; - bool aec; - bool ba; - int data; - int phi1Data; - int rasterX; - - public Vic(VicSettings settings) - { - } - - public void Clock() - { - Render(); - } - - public void Reset() - { - } - } -} diff --git a/BizHawk.Emulation.Cores/Computers/Commodore64/Experimental/Chips/Internals/Vic.Registers.cs b/BizHawk.Emulation.Cores/Computers/Commodore64/Experimental/Chips/Internals/Vic.Registers.cs deleted file mode 100644 index 4a1ab55dde..0000000000 --- a/BizHawk.Emulation.Cores/Computers/Commodore64/Experimental/Chips/Internals/Vic.Registers.cs +++ /dev/null @@ -1,428 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -#pragma warning disable 649 //adelikat: Disable dumb warnings until this file is complete - -namespace BizHawk.Emulation.Cores.Computers.Commodore64.Experimental -{ - sealed public partial class Vic - { - int[] backgroundColor; - bool bitmapMode; - int borderColor; - int characterBitmap; - bool columnSelect; - bool dataCollisionInterrupt; - bool dataCollisionInterruptEnable; - bool displayEnable; - bool extraColorMode; - bool irq; - bool lightPenInterrupt; - bool lightPenInterruptEnable; - int lightPenX; - int lightPenY; - bool multiColorMode; - bool rasterInterrupt; - bool rasterInterruptEnable; - int rasterY; - int rasterYCompare; - bool reset; - bool rowSelect; - bool spriteCollisionInterrupt; - bool spriteCollisionInterruptEnable; - int[] spriteMultiColor; - int videoMemory; - int xScroll; - int yScroll; - - public int Peek(int addr) - { - switch (addr) - { - case 0x00: return sprites[0].X & 0xFF; - case 0x01: return sprites[1].X & 0xFF; - case 0x02: return sprites[2].X & 0xFF; - case 0x03: return sprites[3].X & 0xFF; - case 0x04: return sprites[4].X & 0xFF; - case 0x05: return sprites[5].X & 0xFF; - case 0x06: return sprites[6].X & 0xFF; - case 0x07: return sprites[7].X & 0xFF; - case 0x08: return sprites[0].Y; - case 0x09: return sprites[1].Y; - case 0x0A: return sprites[2].Y; - case 0x0B: return sprites[3].Y; - case 0x0C: return sprites[4].Y; - case 0x0D: return sprites[5].Y; - case 0x0E: return sprites[6].Y; - case 0x0F: return sprites[7].Y; - case 0x10: return ( - ((sprites[0].X & 0x80) >> 7) | - ((sprites[1].X & 0x80) >> 6) | - ((sprites[2].X & 0x80) >> 5) | - ((sprites[3].X & 0x80) >> 4) | - ((sprites[4].X & 0x80) >> 3) | - ((sprites[5].X & 0x80) >> 2) | - ((sprites[6].X & 0x80) >> 1) | - (sprites[7].X & 0x80) - ); - case 0x11: return ( - yScroll | - (rowSelect ? 0x08 : 0x00) | - (displayEnable ? 0x10 : 0x00) | - (bitmapMode ? 0x20 : 0x00) | - (extraColorMode ? 0x40 : 0x00) | - ((rasterY & 0x100) >> 1) - ); - case 0x12: return (rasterY & 0xFF); - case 0x13: return lightPenX; - case 0x14: return lightPenY; - case 0x15: return ( - (sprites[0].Enabled ? 0x01 : 0x00) | - (sprites[1].Enabled ? 0x02 : 0x00) | - (sprites[2].Enabled ? 0x04 : 0x00) | - (sprites[3].Enabled ? 0x08 : 0x00) | - (sprites[4].Enabled ? 0x10 : 0x00) | - (sprites[5].Enabled ? 0x20 : 0x00) | - (sprites[6].Enabled ? 0x40 : 0x00) | - (sprites[7].Enabled ? 0x80 : 0x00) - ); - case 0x16: return ( - xScroll | - (columnSelect ? 0x08 : 0x00) | - (multiColorMode ? 0x10 : 0x00) | - (reset ? 0x20 : 0x00) | - 0xC0 - ); - case 0x17: return ( - (sprites[0].ExpandY ? 0x01 : 0x00) | - (sprites[1].ExpandY ? 0x02 : 0x00) | - (sprites[2].ExpandY ? 0x04 : 0x00) | - (sprites[3].ExpandY ? 0x08 : 0x00) | - (sprites[4].ExpandY ? 0x10 : 0x00) | - (sprites[5].ExpandY ? 0x20 : 0x00) | - (sprites[6].ExpandY ? 0x40 : 0x00) | - (sprites[7].ExpandY ? 0x80 : 0x00) - ); - case 0x18: return ( - (videoMemory >> 6) | - (characterBitmap >> 10) - ); - case 0x19: return ( - (rasterInterrupt ? 0x01 : 0x00) | - (dataCollisionInterrupt ? 0x02 : 0x00) | - (spriteCollisionInterrupt ? 0x04 : 0x00) | - (lightPenInterrupt ? 0x08 : 0x00) | - 0x70 | - (irq ? 0x80 : 0x00) - ); - case 0x1A: return ( - (rasterInterruptEnable ? 0x01 : 0x00) | - (dataCollisionInterruptEnable ? 0x02 : 0x00) | - (spriteCollisionInterruptEnable ? 0x04 : 0x00) | - (lightPenInterruptEnable ? 0x08 : 0x00) | - 0xF0 - ); - case 0x1B: return ( - (sprites[0].Priority ? 0x01 : 0x00) | - (sprites[1].Priority ? 0x02 : 0x00) | - (sprites[2].Priority ? 0x04 : 0x00) | - (sprites[3].Priority ? 0x08 : 0x00) | - (sprites[4].Priority ? 0x10 : 0x00) | - (sprites[5].Priority ? 0x20 : 0x00) | - (sprites[6].Priority ? 0x40 : 0x00) | - (sprites[7].Priority ? 0x80 : 0x00) - ); - case 0x1C: return ( - (sprites[0].Multicolor ? 0x01 : 0x00) | - (sprites[1].Multicolor ? 0x02 : 0x00) | - (sprites[2].Multicolor ? 0x04 : 0x00) | - (sprites[3].Multicolor ? 0x08 : 0x00) | - (sprites[4].Multicolor ? 0x10 : 0x00) | - (sprites[5].Multicolor ? 0x20 : 0x00) | - (sprites[6].Multicolor ? 0x40 : 0x00) | - (sprites[7].Multicolor ? 0x80 : 0x00) - ); - case 0x1D: return ( - (sprites[0].ExpandX ? 0x01 : 0x00) | - (sprites[1].ExpandX ? 0x02 : 0x00) | - (sprites[2].ExpandX ? 0x04 : 0x00) | - (sprites[3].ExpandX ? 0x08 : 0x00) | - (sprites[4].ExpandX ? 0x10 : 0x00) | - (sprites[5].ExpandX ? 0x20 : 0x00) | - (sprites[6].ExpandX ? 0x40 : 0x00) | - (sprites[7].ExpandX ? 0x80 : 0x00) - ); - case 0x1E: return ( - (sprites[0].SpriteCollision ? 0x01 : 0x00) | - (sprites[1].SpriteCollision ? 0x02 : 0x00) | - (sprites[2].SpriteCollision ? 0x04 : 0x00) | - (sprites[3].SpriteCollision ? 0x08 : 0x00) | - (sprites[4].SpriteCollision ? 0x10 : 0x00) | - (sprites[5].SpriteCollision ? 0x20 : 0x00) | - (sprites[6].SpriteCollision ? 0x40 : 0x00) | - (sprites[7].SpriteCollision ? 0x80 : 0x00) - ); - case 0x1F: return ( - (sprites[0].DataCollision ? 0x01 : 0x00) | - (sprites[1].DataCollision ? 0x02 : 0x00) | - (sprites[2].DataCollision ? 0x04 : 0x00) | - (sprites[3].DataCollision ? 0x08 : 0x00) | - (sprites[4].DataCollision ? 0x10 : 0x00) | - (sprites[5].DataCollision ? 0x20 : 0x00) | - (sprites[6].DataCollision ? 0x40 : 0x00) | - (sprites[7].DataCollision ? 0x80 : 0x00) - ); - case 0x20: return borderColor | 0xF0; - case 0x21: return backgroundColor[0] | 0xF0; - case 0x22: return backgroundColor[1] | 0xF0; - case 0x23: return backgroundColor[2] | 0xF0; - case 0x24: return backgroundColor[3] | 0xF0; - case 0x25: return spriteMultiColor[0] | 0xF0; - case 0x26: return spriteMultiColor[1] | 0xF0; - case 0x27: return sprites[0].Color | 0xF0; - case 0x28: return sprites[1].Color | 0xF0; - case 0x29: return sprites[2].Color | 0xF0; - case 0x2A: return sprites[3].Color | 0xF0; - case 0x2B: return sprites[4].Color | 0xF0; - case 0x2C: return sprites[5].Color | 0xF0; - case 0x2D: return sprites[6].Color | 0xF0; - case 0x2E: return sprites[7].Color | 0xF0; - default: return 0xFF; - } - } - - public byte PeekByte(int addr) - { - return (byte)(Peek(addr) & 0xFF); - } - - public void Poke(int addr, int val) - { - switch (addr) - { - case 0x00: sprites[0].X = (sprites[0].X & 0x100 | val); return; - case 0x01: sprites[1].X = (sprites[1].X & 0x100 | val); return; - case 0x02: sprites[2].X = (sprites[2].X & 0x100 | val); return; - case 0x03: sprites[3].X = (sprites[3].X & 0x100 | val); return; - case 0x04: sprites[4].X = (sprites[4].X & 0x100 | val); return; - case 0x05: sprites[5].X = (sprites[5].X & 0x100 | val); return; - case 0x06: sprites[6].X = (sprites[6].X & 0x100 | val); return; - case 0x07: sprites[7].X = (sprites[7].X & 0x100 | val); return; - case 0x08: sprites[0].Y = val; return; - case 0x09: sprites[1].Y = val; return; - case 0x0A: sprites[2].Y = val; return; - case 0x0B: sprites[3].Y = val; return; - case 0x0C: sprites[4].Y = val; return; - case 0x0D: sprites[5].Y = val; return; - case 0x0E: sprites[6].Y = val; return; - case 0x0F: sprites[7].Y = val; return; - case 0x10: - sprites[0].X = (sprites[0].X & 0xFF) | ((val & 0x01) << 8); - sprites[1].X = (sprites[1].X & 0xFF) | ((val & 0x02) << 7); - sprites[2].X = (sprites[2].X & 0xFF) | ((val & 0x04) << 6); - sprites[3].X = (sprites[3].X & 0xFF) | ((val & 0x08) << 5); - sprites[4].X = (sprites[4].X & 0xFF) | ((val & 0x10) << 4); - sprites[5].X = (sprites[5].X & 0xFF) | ((val & 0x20) << 3); - sprites[6].X = (sprites[6].X & 0xFF) | ((val & 0x40) << 2); - sprites[7].X = (sprites[7].X & 0xFF) | ((val & 0x80) << 1); - return; - case 0x11: - yScroll = (val & 0x07); - rowSelect = ((val & 0x08) != 0); - displayEnable = ((val & 0x10) != 0); - bitmapMode = ((val & 0x20) != 0); - extraColorMode = ((val & 0x40) != 0); - rasterYCompare = (rasterYCompare & 0xFF) | ((val & 0x80) << 1); - return; - case 0x12: rasterYCompare = (rasterYCompare & 0x100) | val; return; - case 0x13: lightPenX = val; return; - case 0x14: lightPenY = val; return; - case 0x15: - sprites[0].Enabled = ((val & 0x01) != 0); - sprites[1].Enabled = ((val & 0x02) != 0); - sprites[2].Enabled = ((val & 0x04) != 0); - sprites[3].Enabled = ((val & 0x08) != 0); - sprites[4].Enabled = ((val & 0x10) != 0); - sprites[5].Enabled = ((val & 0x20) != 0); - sprites[6].Enabled = ((val & 0x40) != 0); - sprites[7].Enabled = ((val & 0x80) != 0); - return; - case 0x16: - xScroll = (val & 0x07); - columnSelect = ((val & 0x08) != 0); - multiColorMode = ((val & 0x10) != 0); - reset = ((val & 0x20) != 0); - return; - case 0x17: - sprites[0].ExpandY = ((val & 0x01) != 0); - sprites[1].ExpandY = ((val & 0x02) != 0); - sprites[2].ExpandY = ((val & 0x04) != 0); - sprites[3].ExpandY = ((val & 0x08) != 0); - sprites[4].ExpandY = ((val & 0x10) != 0); - sprites[5].ExpandY = ((val & 0x20) != 0); - sprites[6].ExpandY = ((val & 0x40) != 0); - sprites[7].ExpandY = ((val & 0x80) != 0); - return; - case 0x18: - videoMemory = (val & 0xF0) << 6; - characterBitmap = (val & 0x0E) << 10; - return; - case 0x19: - rasterInterrupt = ((val & 0x01) != 0); - dataCollisionInterrupt = ((val & 0x02) != 0); - spriteCollisionInterrupt = ((val & 0x04) != 0); - lightPenInterrupt = ((val & 0x08) != 0); - irq = ((val & 0x80) != 0); - return; - case 0x1A: - rasterInterruptEnable = ((val & 0x01) != 0); - dataCollisionInterruptEnable = ((val & 0x02) != 0); - spriteCollisionInterruptEnable = ((val & 0x04) != 0); - lightPenInterruptEnable = ((val & 0x08) != 0); - return; - case 0x1B: - sprites[0].Priority = ((val & 0x01) != 0); - sprites[1].Priority = ((val & 0x02) != 0); - sprites[2].Priority = ((val & 0x04) != 0); - sprites[3].Priority = ((val & 0x08) != 0); - sprites[4].Priority = ((val & 0x10) != 0); - sprites[5].Priority = ((val & 0x20) != 0); - sprites[6].Priority = ((val & 0x40) != 0); - sprites[7].Priority = ((val & 0x80) != 0); - return; - case 0x1C: - sprites[0].Multicolor = ((val & 0x01) != 0); - sprites[1].Multicolor = ((val & 0x02) != 0); - sprites[2].Multicolor = ((val & 0x04) != 0); - sprites[3].Multicolor = ((val & 0x08) != 0); - sprites[4].Multicolor = ((val & 0x10) != 0); - sprites[5].Multicolor = ((val & 0x20) != 0); - sprites[6].Multicolor = ((val & 0x40) != 0); - sprites[7].Multicolor = ((val & 0x80) != 0); - return; - case 0x1D: - sprites[0].ExpandX = ((val & 0x01) != 0); - sprites[1].ExpandX = ((val & 0x02) != 0); - sprites[2].ExpandX = ((val & 0x04) != 0); - sprites[3].ExpandX = ((val & 0x08) != 0); - sprites[4].ExpandX = ((val & 0x10) != 0); - sprites[5].ExpandX = ((val & 0x20) != 0); - sprites[6].ExpandX = ((val & 0x40) != 0); - sprites[7].ExpandX = ((val & 0x80) != 0); - return; - case 0x1E: - sprites[0].SpriteCollision = ((val & 0x01) != 0); - sprites[1].SpriteCollision = ((val & 0x02) != 0); - sprites[2].SpriteCollision = ((val & 0x04) != 0); - sprites[3].SpriteCollision = ((val & 0x08) != 0); - sprites[4].SpriteCollision = ((val & 0x10) != 0); - sprites[5].SpriteCollision = ((val & 0x20) != 0); - sprites[6].SpriteCollision = ((val & 0x40) != 0); - sprites[7].SpriteCollision = ((val & 0x80) != 0); - return; - case 0x1F: - sprites[0].DataCollision = ((val & 0x01) != 0); - sprites[1].DataCollision = ((val & 0x02) != 0); - sprites[2].DataCollision = ((val & 0x04) != 0); - sprites[3].DataCollision = ((val & 0x08) != 0); - sprites[4].DataCollision = ((val & 0x10) != 0); - sprites[5].DataCollision = ((val & 0x20) != 0); - sprites[6].DataCollision = ((val & 0x40) != 0); - sprites[7].DataCollision = ((val & 0x80) != 0); - return; - case 0x20: borderColor = val & 0x0F; return; - case 0x21: backgroundColor[0] = val & 0x0F; return; - case 0x22: backgroundColor[1] = val & 0x0F; return; - case 0x23: backgroundColor[2] = val & 0x0F; return; - case 0x24: backgroundColor[3] = val & 0x0F; return; - case 0x25: spriteMultiColor[0] = val & 0x0F; return; - case 0x26: spriteMultiColor[1] = val & 0x0F; return; - case 0x27: sprites[0].Color = val & 0x0F; return; - case 0x28: sprites[1].Color = val & 0x0F; return; - case 0x29: sprites[2].Color = val & 0x0F; return; - case 0x2A: sprites[3].Color = val & 0x0F; return; - case 0x2B: sprites[4].Color = val & 0x0F; return; - case 0x2C: sprites[5].Color = val & 0x0F; return; - case 0x2D: sprites[6].Color = val & 0x0F; return; - case 0x2E: sprites[7].Color = val & 0x0F; return; - default: return; - } - } - - public void PokeByte(int addr, byte val) - { - Poke(addr, val); - } - - public int Read(int addr) - { - int result; - addr &= 0x3F; - - switch (addr) - { - case 0x1E: - case 0x1F: - result = Peek(addr); - Poke(addr, 0); - return result; - default: - return Peek(addr & 0x3F); - } - } - - public byte ReadByte(int addr) - { - return (byte)(Read(addr) & 0xFF); - } - - public void Write(int addr, int val) - { - addr &= 0x3F; - val &= 0xFF; - switch (addr) - { - case 0x19: - if ((val & 0x01) != 0) - rasterInterrupt = false; - if ((val & 0x02) != 0) - dataCollisionInterrupt = false; - if ((val & 0x04) != 0) - spriteCollisionInterrupt = false; - if ((val & 0x08) != 0) - lightPenInterrupt = false; - return; - case 0x1E: - case 0x1F: - case 0x2F: - case 0x30: - case 0x31: - case 0x32: - case 0x33: - case 0x34: - case 0x35: - case 0x36: - case 0x37: - case 0x38: - case 0x39: - case 0x3A: - case 0x3B: - case 0x3C: - case 0x3D: - case 0x3E: - case 0x3F: - return; - default: - Poke(addr, val); - return; - } - } - - public void WriteByte(int addr, byte val) - { - Write(addr, val); - } - } -} diff --git a/BizHawk.Emulation.Cores/Computers/Commodore64/Experimental/Chips/Internals/Vic.Settings.cs b/BizHawk.Emulation.Cores/Computers/Commodore64/Experimental/Chips/Internals/Vic.Settings.cs deleted file mode 100644 index 960cc2646c..0000000000 --- a/BizHawk.Emulation.Cores/Computers/Commodore64/Experimental/Chips/Internals/Vic.Settings.cs +++ /dev/null @@ -1,11 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace BizHawk.Emulation.Cores.Computers.Commodore64.Experimental -{ - sealed public class VicSettings - { - } -} diff --git a/BizHawk.Emulation.Cores/Computers/Commodore64/Experimental/Chips/Internals/Vic.Sprite.cs b/BizHawk.Emulation.Cores/Computers/Commodore64/Experimental/Chips/Internals/Vic.Sprite.cs deleted file mode 100644 index 7ecaaa8d15..0000000000 --- a/BizHawk.Emulation.Cores/Computers/Commodore64/Experimental/Chips/Internals/Vic.Sprite.cs +++ /dev/null @@ -1,127 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -#pragma warning disable 649 //adelikat: Disable dumb warnings until this file is complete - -namespace BizHawk.Emulation.Cores.Computers.Commodore64.Experimental -{ - sealed public partial class Vic - { - const int SPRITE_DATA_00 = 0; - const int SPRITE_DATA_01 = 0x400000; - const int SPRITE_DATA_10 = SPRITE_DATA_01 << 1; - const int SPRITE_DATA_11 = SPRITE_DATA_01 | SPRITE_DATA_10; - const int SPRITE_DATA_OUTPUT_MASK = SPRITE_DATA_11; - - sealed class Sprite - { - public bool CrunchMC; - public bool CrunchX; - public bool CrunchY; - public bool Display; - public int ShiftRegister; - public bool ShiftRegisterEnable; - - public int Color; - public bool DataCollision; - public bool Enabled; - public bool ExpandX; - public bool ExpandY; - public bool Multicolor; - public bool Priority; - public bool SpriteCollision; - public int X; - public int Y; - - public Sprite() - { - } - - public void Clock() - { - } - - public void LoadP(int value) - { - } - - public void LoadS(int value) - { - } - } - - Sprite s_CollideSprite; - int s_Data; - bool s_OutData; - int s_OutPixel; - bool s_Priority; - Sprite[] sprites; - - void RenderSprites() - { - s_OutData = false; - s_CollideSprite = null; - - foreach (Sprite sprite in sprites) - { - if (sprite.Display && rasterX == sprite.X) - sprite.ShiftRegisterEnable = true; - - if (sprite.ShiftRegisterEnable) - { - if (sprite.ShiftRegister == 0) - { - sprite.ShiftRegisterEnable = false; - sprite.CrunchMC = true; - sprite.CrunchX = true; - } - else - { - sprite.CrunchX = !sprite.CrunchX || !sprite.ExpandX; - if (sprite.CrunchX) - sprite.CrunchMC = !sprite.CrunchMC || !sprite.Multicolor; - - if (sprite.Multicolor) - s_Data = sprite.ShiftRegister & SPRITE_DATA_11; - else - s_Data = (sprite.ShiftRegister << 1) & SPRITE_DATA_10; - - if (s_CollideSprite == null) - { - if (s_Data == SPRITE_DATA_10) - s_OutPixel = sprite.Color; - else if (s_Data == SPRITE_DATA_01) - s_OutPixel = spriteMultiColor[0]; - else if (s_Data == SPRITE_DATA_11) - s_OutPixel = spriteMultiColor[1]; - - if (s_Data != SPRITE_DATA_00) - { - s_CollideSprite = sprite; - s_OutData = true; - s_Priority = sprite.Priority; - } - } - else if (s_Data != SPRITE_DATA_00) - { - s_CollideSprite.SpriteCollision = true; - sprite.SpriteCollision = true; - spriteCollisionInterrupt = true; - } - - if (s_Data != SPRITE_DATA_00 && g_OutData >= GRAPHICS_DATA_10) - { - sprite.DataCollision = true; - dataCollisionInterrupt = true; - } - - if (sprite.CrunchMC && sprite.CrunchX) - sprite.ShiftRegister <<= sprite.Multicolor ? 2 : 1; - } - } - } - } - } -} diff --git a/BizHawk.Emulation.Cores/Computers/Commodore64/Experimental/Chips/Internals/Vic.State.cs b/BizHawk.Emulation.Cores/Computers/Commodore64/Experimental/Chips/Internals/Vic.State.cs deleted file mode 100644 index c9d8c3faa5..0000000000 --- a/BizHawk.Emulation.Cores/Computers/Commodore64/Experimental/Chips/Internals/Vic.State.cs +++ /dev/null @@ -1,16 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -using BizHawk.Common; - -namespace BizHawk.Emulation.Cores.Computers.Commodore64.Experimental -{ - sealed public partial class Vic - { - public void SyncState(Serializer ser) - { - } - } -} diff --git a/BizHawk.Emulation.Cores/Computers/Commodore64/Experimental/Chips/Internals/Vic.Synth.cs b/BizHawk.Emulation.Cores/Computers/Commodore64/Experimental/Chips/Internals/Vic.Synth.cs deleted file mode 100644 index cde4252d53..0000000000 --- a/BizHawk.Emulation.Cores/Computers/Commodore64/Experimental/Chips/Internals/Vic.Synth.cs +++ /dev/null @@ -1,30 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace BizHawk.Emulation.Cores.Computers.Commodore64.Experimental -{ - sealed public partial class Vic - { - int v_Pixel; - - public void Render() - { - RenderGraphics(); - RenderSprites(); - - if (s_OutData && (!s_Priority || g_OutData < GRAPHICS_DATA_10)) - { - if (s_Priority && g_OutData < GRAPHICS_DATA_10) - v_Pixel = s_OutPixel; - else - v_Pixel = g_OutPixel; - } - else - { - v_Pixel = g_OutPixel; - } - } - } -} diff --git a/BizHawk.Emulation.Cores/Computers/Commodore64/Experimental/Chips/Internals/Vic.Timing.cs b/BizHawk.Emulation.Cores/Computers/Commodore64/Experimental/Chips/Internals/Vic.Timing.cs deleted file mode 100644 index 267a51e5f9..0000000000 --- a/BizHawk.Emulation.Cores/Computers/Commodore64/Experimental/Chips/Internals/Vic.Timing.cs +++ /dev/null @@ -1,86 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -#pragma warning disable 649 //adelikat: Disable dumb warnings until this file is complete -#pragma warning disable 169 //adelikat: Disable dumb warnings until this file is complete - -namespace BizHawk.Emulation.Cores.Computers.Commodore64.Experimental -{ - sealed public class VicColumnState - { - public VicBAType BA; - public VicFetchType Fetch; - public bool HBlank; - public int RasterX; - } - - public enum VicActType - { - None, - SpriteDMA, - SpriteExpandY, - RCAdvance, - RasterAdvance, - RasterAdvanceBottom, - VCReset, - } - - public enum VicBAType - { - None, - Badline, - Sprite0, - Sprite01, - Sprite012, - Sprite12, - Sprite123, - Sprite23, - Sprite234, - Sprite34, - Sprite345, - Sprite45, - Sprite456, - Sprite56, - Sprite567, - Sprite67, - Sprite7 - } - - public enum VicFetchType - { - None, - Graphics, - Color, - Idle, - Refresh, - Sprite, - Pointer - } - - public enum VicRowType - { - None, - ScreenVisible, - ScreenBlank, - ResetVCBase - } - - sealed public class VicTiming - { - public int ColumnCount; - public int DelayColumn; - public int RasterAdvanceColumn; - public int RasterCount; - public int RasterWidth; - } - sealed public partial class Vic - { - int frequency; - VicColumnState[] pipelineColumns; - VicRowType[] pipelineRows; - int rasterCount; - int rasterWidth; - } -} diff --git a/BizHawk.Emulation.Cores/Computers/Commodore64/Experimental/Chips/Internals/Vic.VideoProvider.cs b/BizHawk.Emulation.Cores/Computers/Commodore64/Experimental/Chips/Internals/Vic.VideoProvider.cs deleted file mode 100644 index 9d5a239bf3..0000000000 --- a/BizHawk.Emulation.Cores/Computers/Commodore64/Experimental/Chips/Internals/Vic.VideoProvider.cs +++ /dev/null @@ -1,70 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -using BizHawk.Common; -using BizHawk.Emulation.Common; - -#pragma warning disable 649 //adelikat: Disable dumb warnings until this file is complete - -namespace BizHawk.Emulation.Cores.Computers.Commodore64.Experimental -{ - sealed public partial class Vic : IVideoProvider - { - int screenHeight; - int screenWidth; - int[] videoBuffer; - - // palette - static private int[] palette = - { - Colors.ARGB(0x00, 0x00, 0x00), - Colors.ARGB(0xFF, 0xFF, 0xFF), - Colors.ARGB(0x68, 0x37, 0x2B), - Colors.ARGB(0x70, 0xA4, 0xB2), - Colors.ARGB(0x6F, 0x3D, 0x86), - Colors.ARGB(0x58, 0x8D, 0x43), - Colors.ARGB(0x35, 0x28, 0x79), - Colors.ARGB(0xB8, 0xC7, 0x6F), - Colors.ARGB(0x6F, 0x4F, 0x25), - Colors.ARGB(0x43, 0x39, 0x00), - Colors.ARGB(0x9A, 0x67, 0x59), - Colors.ARGB(0x44, 0x44, 0x44), - Colors.ARGB(0x6C, 0x6C, 0x6C), - Colors.ARGB(0x9A, 0xD2, 0x84), - Colors.ARGB(0x6C, 0x5E, 0xB5), - Colors.ARGB(0x95, 0x95, 0x95) - }; - - public int[] GetVideoBuffer() - { - return videoBuffer; - } - - public int VirtualWidth - { - get { return screenWidth; } - } - - public int VirtualHeight - { - get { return screenHeight; } - } - - public int BufferWidth - { - get { return screenWidth; } - } - - public int BufferHeight - { - get { return screenHeight; } - } - - public int BackgroundColor - { - get { return palette[0]; } - } - } -} diff --git a/BizHawk.Emulation.Cores/Computers/Commodore64/Experimental/Chips/Presets.cs b/BizHawk.Emulation.Cores/Computers/Commodore64/Experimental/Chips/Presets.cs deleted file mode 100644 index aca7e84ba9..0000000000 --- a/BizHawk.Emulation.Cores/Computers/Commodore64/Experimental/Chips/Presets.cs +++ /dev/null @@ -1,58 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace BizHawk.Emulation.Cores.Computers.Commodore64.Experimental -{ - static public class ChipPresets - { - static public Cia Cia6526(bool todJumper) { return new Cia(Settings6526(todJumper)); } - static public Cia Cia6526A(bool todJumper) { return new Cia(Settings6526A(todJumper)); } - static public Cpu Cpu6510() { return new Cpu(); } - static public Ram Ram2114() { return new Ram(0x1000, 0x0FFF, 0x0F); } - static public Ram Ram4864() { return new Ram(0x10000, 0xFFFF, 0xFF); } - static public Rom Rom2332(byte[] data) { return new Rom(0x1000, 0xFFF, data); } - static public Rom Rom2364(byte[] data) { return new Rom(0x2000, 0x1FFF, data); } - static public Sid Sid6581() { return new Sid(Settings6581()); } - static public Sid Sid8580() { return new Sid(Settings8580()); } - static public Vic Vic6567() { return new Vic(Settings6567()); } - static public Vic Vic6569() { return new Vic(Settings6569()); } - - static private CiaSettings Settings6526(bool todJumper) - { - CiaSettings result = new CiaSettings(); - return result; - } - - static private CiaSettings Settings6526A(bool todJumper) - { - CiaSettings result = new CiaSettings(); - return result; - } - - static private VicSettings Settings6567() - { - VicSettings result = new VicSettings(); - return result; - } - - static private VicSettings Settings6569() - { - VicSettings result = new VicSettings(); - return result; - } - - static private SidSettings Settings6581() - { - SidSettings result = new SidSettings(); - return result; - } - - static private SidSettings Settings8580() - { - SidSettings result = new SidSettings(); - return result; - } - } -} diff --git a/BizHawk.Emulation.Cores/Computers/Commodore64/Experimental/IMotherboard.cs b/BizHawk.Emulation.Cores/Computers/Commodore64/Experimental/IMotherboard.cs deleted file mode 100644 index 25dea88804..0000000000 --- a/BizHawk.Emulation.Cores/Computers/Commodore64/Experimental/IMotherboard.cs +++ /dev/null @@ -1,32 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace BizHawk.Emulation.Cores.Computers.Commodore64.Experimental -{ - public interface IMotherboard - { - void ExecuteFrame(); - - byte PeekBasicRom(int addr); - byte PeekCartridge(int addr); - byte PeekCharRom(int addr); - byte PeekCpu(int addr); - byte PeekKernalRom(int addr); - byte PeekRam(int addr); - byte PeekSerial(int addr); - byte PeekSid(int addr); - byte PeekVic(int addr); - - void PokeBasicRom(int addr, byte val); - void PokeCartridge(int addr, byte val); - void PokeCharRom(int addr, byte val); - void PokeCpu(int addr, byte val); - void PokeKernalRom(int addr, byte val); - void PokeRam(int addr, byte val); - void PokeSerial(int addr, byte val); - void PokeSid(int addr, byte val); - void PokeVic(int addr, byte val); - } -} diff --git a/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/CartridgePort.cs b/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/CartridgePort.cs index 462605b6ee..d3925f641e 100644 --- a/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/CartridgePort.cs +++ b/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/CartridgePort.cs @@ -1,7 +1,7 @@ using System; using BizHawk.Common; -namespace BizHawk.Emulation.Cores.Computers.Commodore64 +namespace BizHawk.Emulation.Cores.Computers.Commodore64.MOS { sealed public class CartridgePort { @@ -81,6 +81,7 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64 public void SyncState(Serializer ser) { SaveState.SyncObject(ser, this); + cart.SyncState(ser); } } } diff --git a/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/CassettePort.cs b/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/CassettePort.cs index 79132d4c3b..26ddeb1b49 100644 --- a/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/CassettePort.cs +++ b/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/CassettePort.cs @@ -1,7 +1,7 @@ using System; using BizHawk.Common; -namespace BizHawk.Emulation.Cores.Computers.Commodore64 +namespace BizHawk.Emulation.Cores.Computers.Commodore64.MOS { public class CassettePort { diff --git a/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/Chip2114.cs b/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/Chip2114.cs index 05756e31ce..436010cf4b 100644 --- a/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/Chip2114.cs +++ b/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/Chip2114.cs @@ -1,6 +1,6 @@ using BizHawk.Common; -namespace BizHawk.Emulation.Cores.Computers.Commodore64 +namespace BizHawk.Emulation.Cores.Computers.Commodore64.MOS { // used as Color RAM in C64 diff --git a/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/Chip23XX.cs b/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/Chip23XX.cs index 3575da635d..053ecebc55 100644 --- a/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/Chip23XX.cs +++ b/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/Chip23XX.cs @@ -1,7 +1,7 @@ using System; using BizHawk.Common; -namespace BizHawk.Emulation.Cores.Computers.Commodore64 +namespace BizHawk.Emulation.Cores.Computers.Commodore64.MOS { // ROM chips // 2332: 32 kbit (4kbyte) diff --git a/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/Chip4864.cs b/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/Chip4864.cs index 536e509f12..4cf6478ae7 100644 --- a/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/Chip4864.cs +++ b/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/Chip4864.cs @@ -1,6 +1,6 @@ using BizHawk.Common; -namespace BizHawk.Emulation.Cores.Computers.Commodore64 +namespace BizHawk.Emulation.Cores.Computers.Commodore64.MOS { // DRAM for the c64 // 4164 = 64 kbit diff --git a/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/MOS6510.cs b/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/MOS6510.cs index 2307893061..5a42230f05 100644 --- a/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/MOS6510.cs +++ b/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/MOS6510.cs @@ -5,7 +5,7 @@ using System.Runtime.InteropServices; using BizHawk.Common; using BizHawk.Emulation.Cores.Components.M6502; -namespace BizHawk.Emulation.Cores.Computers.Commodore64 +namespace BizHawk.Emulation.Cores.Computers.Commodore64.MOS { // an extension of the 6502 processor diff --git a/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/MOS6522.cs b/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/MOS6522.cs index 070a294016..455c33416d 100644 --- a/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/MOS6522.cs +++ b/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/MOS6522.cs @@ -1,7 +1,7 @@ using System; #if false -namespace BizHawk.Emulation.Cores.Computers.Commodore64 +namespace BizHawk.Emulation.Cores.Computers.Commodore64.MOS { // via public class MOS6522 : Timer diff --git a/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/MOS6526.cs b/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/MOS6526.cs index 969b9c2597..5e0adb52c2 100644 --- a/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/MOS6526.cs +++ b/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/MOS6526.cs @@ -1,7 +1,7 @@ using System; using BizHawk.Common; -namespace BizHawk.Emulation.Cores.Computers.Commodore64 +namespace BizHawk.Emulation.Cores.Computers.Commodore64.MOS { // MOS technology 6526 "CIA" // diff --git a/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/MOS6567.cs b/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/MOS6567.cs index 7a346f446b..939e8211f8 100644 --- a/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/MOS6567.cs +++ b/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/MOS6567.cs @@ -1,6 +1,6 @@ using System.Drawing; -namespace BizHawk.Emulation.Cores.Computers.Commodore64 +namespace BizHawk.Emulation.Cores.Computers.Commodore64.MOS { // vic ntsc static public class MOS6567 diff --git a/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/MOS6569.cs b/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/MOS6569.cs index 6491e75a03..0c00115a95 100644 --- a/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/MOS6569.cs +++ b/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/MOS6569.cs @@ -1,6 +1,6 @@ using System.Drawing; -namespace BizHawk.Emulation.Cores.Computers.Commodore64 +namespace BizHawk.Emulation.Cores.Computers.Commodore64.MOS { // vic pal static public class MOS6569 diff --git a/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/MOS6581.cs b/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/MOS6581.cs index 5c88e5a2f1..9485937697 100644 --- a/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/MOS6581.cs +++ b/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/MOS6581.cs @@ -1,4 +1,4 @@ -namespace BizHawk.Emulation.Cores.Computers.Commodore64 +namespace BizHawk.Emulation.Cores.Computers.Commodore64.MOS { // sid static public class MOS6581 diff --git a/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/MOSPLA.cs b/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/MOSPLA.cs index 463d02dbc1..185fac7a66 100644 --- a/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/MOSPLA.cs +++ b/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/MOSPLA.cs @@ -1,7 +1,7 @@ using System; using BizHawk.Common; -namespace BizHawk.Emulation.Cores.Computers.Commodore64 +namespace BizHawk.Emulation.Cores.Computers.Commodore64.MOS { // emulates the PLA // which handles all bank switching diff --git a/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/Port.cs b/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/Port.cs index df00275241..ba947b5a5f 100644 --- a/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/Port.cs +++ b/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/Port.cs @@ -1,7 +1,7 @@ using System; using BizHawk.Common; -namespace BizHawk.Emulation.Cores.Computers.Commodore64 +namespace BizHawk.Emulation.Cores.Computers.Commodore64.MOS { sealed public class LatchedPort { diff --git a/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/SerialPort.cs b/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/SerialPort.cs index 0a5f6e510f..004e78b09b 100644 --- a/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/SerialPort.cs +++ b/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/SerialPort.cs @@ -1,7 +1,7 @@ using System; using BizHawk.Common; -namespace BizHawk.Emulation.Cores.Computers.Commodore64 +namespace BizHawk.Emulation.Cores.Computers.Commodore64.MOS { // the functions on this port are at the point of // view of an external device. diff --git a/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/Sid.Envelope.cs b/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/Sid.Envelope.cs index a1cb38dd90..0dcdcdd553 100644 --- a/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/Sid.Envelope.cs +++ b/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/Sid.Envelope.cs @@ -5,7 +5,7 @@ using System.Text; using BizHawk.Common; -namespace BizHawk.Emulation.Cores.Computers.Commodore64 +namespace BizHawk.Emulation.Cores.Computers.Commodore64.MOS { sealed public partial class Sid { diff --git a/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/Sid.Registers.cs b/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/Sid.Registers.cs new file mode 100644 index 0000000000..26e2f8b75d --- /dev/null +++ b/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/Sid.Registers.cs @@ -0,0 +1,216 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace BizHawk.Emulation.Cores.Computers.Commodore64.MOS +{ + sealed public partial class Sid + { + public byte Peek(int addr) + { + return ReadRegister((addr & 0x1F)); + } + + public void Poke(int addr, byte val) + { + WriteRegister((addr & 0x1F), val); + } + + public byte Read(int addr) + { + addr &= 0x1F; + byte result = 0x00; + switch (addr) + { + case 0x19: + case 0x1A: + case 0x1B: + case 0x1C: + Flush(); + result = ReadRegister(addr); + break; + } + return result; + } + + private byte ReadRegister(int addr) + { + byte result = 0x00; + + switch (addr) + { + case 0x00: result = (byte)voices[0].FrequencyLo; break; + case 0x01: result = (byte)voices[0].FrequencyHi; break; + case 0x02: result = (byte)voices[0].PulseWidthLo; break; + case 0x03: result = (byte)voices[0].PulseWidthHi; break; + case 0x04: + result = (byte)( + (envelopes[0].Gate ? 0x01 : 0x00) | + (voices[0].Sync ? 0x02 : 0x00) | + (voices[0].RingMod ? 0x04 : 0x00) | + (voices[0].Test ? 0x08 : 0x00) | + (byte)(voices[0].Waveform << 4) + ); + break; + case 0x05: + result = (byte)( + (envelopes[0].Attack << 4) | + (envelopes[0].Decay) + ); + break; + case 0x06: + result = (byte)( + (envelopes[0].Sustain << 4) | + (envelopes[0].Release) + ); + break; + case 0x07: result = (byte)voices[1].FrequencyLo; break; + case 0x08: result = (byte)voices[1].FrequencyHi; break; + case 0x09: result = (byte)voices[1].PulseWidthLo; break; + case 0x0A: result = (byte)voices[1].PulseWidthHi; break; + case 0x0B: + result = (byte)( + (envelopes[1].Gate ? 0x01 : 0x00) | + (voices[1].Sync ? 0x02 : 0x00) | + (voices[1].RingMod ? 0x04 : 0x00) | + (voices[1].Test ? 0x08 : 0x00) | + (byte)(voices[1].Waveform << 4) + ); + break; + case 0x0C: + result = (byte)( + (envelopes[1].Attack << 4) | + (envelopes[1].Decay) + ); + break; + case 0x0D: + result = (byte)( + (envelopes[1].Sustain << 4) | + (envelopes[1].Release) + ); + break; + case 0x0E: result = (byte)voices[2].FrequencyLo; break; + case 0x0F: result = (byte)voices[2].FrequencyHi; break; + case 0x10: result = (byte)voices[2].PulseWidthLo; break; + case 0x11: result = (byte)voices[2].PulseWidthHi; break; + case 0x12: + result = (byte)( + (envelopes[2].Gate ? 0x01 : 0x00) | + (voices[2].Sync ? 0x02 : 0x00) | + (voices[2].RingMod ? 0x04 : 0x00) | + (voices[2].Test ? 0x08 : 0x00) | + (byte)(voices[2].Waveform << 4) + ); + break; + case 0x13: + result = (byte)( + (envelopes[2].Attack << 4) | + (envelopes[2].Decay) + ); + break; + case 0x14: + result = (byte)( + (envelopes[2].Sustain << 4) | + (envelopes[2].Release) + ); + break; + case 0x15: result = (byte)(filterFrequency & 0x7); break; + case 0x16: result = (byte)((filterFrequency >> 3) & 0xFF); break; + case 0x17: + result = (byte)( + (filterEnable[0] ? 0x01 : 0x00) | + (filterEnable[1] ? 0x02 : 0x00) | + (filterEnable[2] ? 0x04 : 0x00) | + (byte)(filterResonance << 4) + ); + break; + case 0x18: + result = (byte)( + (byte)volume | + (filterSelectLoPass ? 0x10 : 0x00) | + (filterSelectBandPass ? 0x20 : 0x00) | + (filterSelectHiPass ? 0x40 : 0x00) | + (disableVoice3 ? 0x80 : 0x00) + ); + break; + case 0x19: result = (byte)potX; break; + case 0x1A: result = (byte)potY; break; + case 0x1B: result = (byte)(voiceOutput[2] >> 4); break; + case 0x1C: result = (byte)(envelopeOutput[2]); break; + } + + return result; + } + + public void Write(int addr, byte val) + { + addr &= 0x1F; + switch (addr) + { + case 0x19: + case 0x1A: + case 0x1B: + case 0x1C: + case 0x1D: + case 0x1E: + case 0x1F: + // can't write to these + break; + default: + Flush(); + WriteRegister(addr, val); + break; + } + } + + private void WriteRegister(int addr, byte val) + { + switch (addr) + { + case 0x00: voices[0].FrequencyLo = val; break; + case 0x01: voices[0].FrequencyHi = val; break; + case 0x02: voices[0].PulseWidthLo = val; break; + case 0x03: voices[0].PulseWidthHi = val; break; + case 0x04: voices[0].Control = val; envelopes[0].Gate = ((val & 0x01) != 0); break; + case 0x05: envelopes[0].Attack = (val >> 4); envelopes[0].Decay = (val & 0xF); break; + case 0x06: envelopes[0].Sustain = (val >> 4); envelopes[0].Release = (val & 0xF); break; + case 0x07: voices[1].FrequencyLo = val; break; + case 0x08: voices[1].FrequencyHi = val; break; + case 0x09: voices[1].PulseWidthLo = val; break; + case 0x0A: voices[1].PulseWidthHi = val; break; + case 0x0B: voices[1].Control = val; envelopes[1].Gate = ((val & 0x01) != 0); break; + case 0x0C: envelopes[1].Attack = (val >> 4); envelopes[1].Decay = (val & 0xF); break; + case 0x0D: envelopes[1].Sustain = (val >> 4); envelopes[1].Release = (val & 0xF); break; + case 0x0E: voices[2].FrequencyLo = val; break; + case 0x0F: voices[2].FrequencyHi = val; break; + case 0x10: voices[2].PulseWidthLo = val; break; + case 0x11: voices[2].PulseWidthHi = val; break; + case 0x12: voices[2].Control = val; envelopes[2].Gate = ((val & 0x01) != 0); break; + case 0x13: envelopes[2].Attack = (val >> 4); envelopes[2].Decay = (val & 0xF); break; + case 0x14: envelopes[2].Sustain = (val >> 4); envelopes[2].Release = (val & 0xF); break; + case 0x15: filterFrequency &= 0x3FF; filterFrequency |= (val & 0x7); break; + case 0x16: filterFrequency &= 0x7; filterFrequency |= val << 3; break; + case 0x17: + filterEnable[0] = ((val & 0x1) != 0); + filterEnable[1] = ((val & 0x2) != 0); + filterEnable[2] = ((val & 0x4) != 0); + filterResonance = val >> 4; + break; + case 0x18: + volume = (val & 0xF); + filterSelectLoPass = ((val & 0x10) != 0); + filterSelectBandPass = ((val & 0x20) != 0); + filterSelectHiPass = ((val & 0x40) != 0); + disableVoice3 = ((val & 0x40) != 0); + break; + case 0x19: + potX = val; + break; + case 0x1A: + potY = val; + break; + } + } + } +} diff --git a/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/Sid.Voice.cs b/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/Sid.Voice.cs index ad1b74af44..f72f07f430 100644 --- a/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/Sid.Voice.cs +++ b/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/Sid.Voice.cs @@ -5,7 +5,7 @@ using System.Text; using BizHawk.Common; -namespace BizHawk.Emulation.Cores.Computers.Commodore64 +namespace BizHawk.Emulation.Cores.Computers.Commodore64.MOS { sealed public partial class Sid { @@ -336,9 +336,6 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64 public void SyncState(Serializer ser) { SaveState.SyncObject(ser, this); - - if (ser.IsReader) - wave = waveTable[waveform]; } } diff --git a/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/Sid.cs b/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/Sid.cs index 9a520f1d09..d74e8fc828 100644 --- a/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/Sid.cs +++ b/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/Sid.cs @@ -7,12 +7,10 @@ using BizHawk.Emulation.Common; #pragma warning disable 169 //adelikat: Disable dumb warnings until this file is complete #pragma warning disable 219 //adelikat: Disable dumb warnings until this file is complete -namespace BizHawk.Emulation.Cores.Computers.Commodore64 +namespace BizHawk.Emulation.Cores.Computers.Commodore64.MOS { sealed public partial class Sid { - // ------------------------------------ - // ------------------------------------ @@ -152,214 +150,6 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64 } } - // ------------------------------------ - - public byte Peek(int addr) - { - return ReadRegister((addr & 0x1F)); - } - - public void Poke(int addr, byte val) - { - WriteRegister((addr & 0x1F), val); - } - - public byte Read(int addr) - { - addr &= 0x1F; - byte result = 0x00; - switch (addr) - { - case 0x19: - case 0x1A: - case 0x1B: - case 0x1C: - Flush(); - result = ReadRegister(addr); - break; - } - return result; - } - - private byte ReadRegister(int addr) - { - byte result = 0x00; - - switch (addr) - { - case 0x00: result = (byte)voices[0].FrequencyLo; break; - case 0x01: result = (byte)voices[0].FrequencyHi; break; - case 0x02: result = (byte)voices[0].PulseWidthLo; break; - case 0x03: result = (byte)voices[0].PulseWidthHi; break; - case 0x04: - result = (byte)( - (envelopes[0].Gate ? 0x01 : 0x00) | - (voices[0].Sync ? 0x02 : 0x00) | - (voices[0].RingMod ? 0x04 : 0x00) | - (voices[0].Test ? 0x08 : 0x00) | - (byte)(voices[0].Waveform << 4) - ); - break; - case 0x05: - result = (byte)( - (envelopes[0].Attack << 4) | - (envelopes[0].Decay) - ); - break; - case 0x06: - result = (byte)( - (envelopes[0].Sustain << 4) | - (envelopes[0].Release) - ); - break; - case 0x07: result = (byte)voices[1].FrequencyLo; break; - case 0x08: result = (byte)voices[1].FrequencyHi; break; - case 0x09: result = (byte)voices[1].PulseWidthLo; break; - case 0x0A: result = (byte)voices[1].PulseWidthHi; break; - case 0x0B: - result = (byte)( - (envelopes[1].Gate ? 0x01 : 0x00) | - (voices[1].Sync ? 0x02 : 0x00) | - (voices[1].RingMod ? 0x04 : 0x00) | - (voices[1].Test ? 0x08 : 0x00) | - (byte)(voices[1].Waveform << 4) - ); - break; - case 0x0C: - result = (byte)( - (envelopes[1].Attack << 4) | - (envelopes[1].Decay) - ); - break; - case 0x0D: - result = (byte)( - (envelopes[1].Sustain << 4) | - (envelopes[1].Release) - ); - break; - case 0x0E: result = (byte)voices[2].FrequencyLo; break; - case 0x0F: result = (byte)voices[2].FrequencyHi; break; - case 0x10: result = (byte)voices[2].PulseWidthLo; break; - case 0x11: result = (byte)voices[2].PulseWidthHi; break; - case 0x12: - result = (byte)( - (envelopes[2].Gate ? 0x01 : 0x00) | - (voices[2].Sync ? 0x02 : 0x00) | - (voices[2].RingMod ? 0x04 : 0x00) | - (voices[2].Test ? 0x08 : 0x00) | - (byte)(voices[2].Waveform << 4) - ); - break; - case 0x13: - result = (byte)( - (envelopes[2].Attack << 4) | - (envelopes[2].Decay) - ); - break; - case 0x14: - result = (byte)( - (envelopes[2].Sustain << 4) | - (envelopes[2].Release) - ); - break; - case 0x15: result = (byte)(filterFrequency & 0x7); break; - case 0x16: result = (byte)((filterFrequency >> 3) & 0xFF); break; - case 0x17: - result = (byte)( - (filterEnable[0] ? 0x01 : 0x00) | - (filterEnable[1] ? 0x02 : 0x00) | - (filterEnable[2] ? 0x04 : 0x00) | - (byte)(filterResonance << 4) - ); - break; - case 0x18: - result = (byte)( - (byte)volume | - (filterSelectLoPass ? 0x10 : 0x00) | - (filterSelectBandPass ? 0x20 : 0x00) | - (filterSelectHiPass ? 0x40 : 0x00) | - (disableVoice3 ? 0x80 : 0x00) - ); - break; - case 0x19: result = (byte)potX; break; - case 0x1A: result = (byte)potY; break; - case 0x1B: result = (byte)(voiceOutput[2] >> 4); break; - case 0x1C: result = (byte)(envelopeOutput[2]); break; - } - - return result; - } - - public void Write(int addr, byte val) - { - addr &= 0x1F; - switch (addr) - { - case 0x19: - case 0x1A: - case 0x1B: - case 0x1C: - case 0x1D: - case 0x1E: - case 0x1F: - // can't write to these - break; - default: - Flush(); - WriteRegister(addr, val); - break; - } - } - - private void WriteRegister(int addr, byte val) - { - switch (addr) - { - case 0x00: voices[0].FrequencyLo = val; break; - case 0x01: voices[0].FrequencyHi = val; break; - case 0x02: voices[0].PulseWidthLo = val; break; - case 0x03: voices[0].PulseWidthHi = val; break; - case 0x04: voices[0].Control = val; envelopes[0].Gate = ((val & 0x01) != 0); break; - case 0x05: envelopes[0].Attack = (val >> 4); envelopes[0].Decay = (val & 0xF); break; - case 0x06: envelopes[0].Sustain = (val >> 4); envelopes[0].Release = (val & 0xF); break; - case 0x07: voices[1].FrequencyLo = val; break; - case 0x08: voices[1].FrequencyHi = val; break; - case 0x09: voices[1].PulseWidthLo = val; break; - case 0x0A: voices[1].PulseWidthHi = val; break; - case 0x0B: voices[1].Control = val; envelopes[1].Gate = ((val & 0x01) != 0); break; - case 0x0C: envelopes[1].Attack = (val >> 4); envelopes[1].Decay = (val & 0xF); break; - case 0x0D: envelopes[1].Sustain = (val >> 4); envelopes[1].Release = (val & 0xF); break; - case 0x0E: voices[2].FrequencyLo = val; break; - case 0x0F: voices[2].FrequencyHi = val; break; - case 0x10: voices[2].PulseWidthLo = val; break; - case 0x11: voices[2].PulseWidthHi = val; break; - case 0x12: voices[2].Control = val; envelopes[2].Gate = ((val & 0x01) != 0); break; - case 0x13: envelopes[2].Attack = (val >> 4); envelopes[2].Decay = (val & 0xF); break; - case 0x14: envelopes[2].Sustain = (val >> 4); envelopes[2].Release = (val & 0xF); break; - case 0x15: filterFrequency &= 0x3FF; filterFrequency |= (val & 0x7); break; - case 0x16: filterFrequency &= 0x7; filterFrequency |= val << 3; break; - case 0x17: - filterEnable[0] = ((val & 0x1) != 0); - filterEnable[1] = ((val & 0x2) != 0); - filterEnable[2] = ((val & 0x4) != 0); - filterResonance = val >> 4; - break; - case 0x18: - volume = (val & 0xF); - filterSelectLoPass = ((val & 0x10) != 0); - filterSelectBandPass = ((val & 0x20) != 0); - filterSelectHiPass = ((val & 0x40) != 0); - disableVoice3 = ((val & 0x40) != 0); - break; - case 0x19: - potX = val; - break; - case 0x1A: - potY = val; - break; - } - } - // ---------------------------------- public void SyncState(Serializer ser) diff --git a/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/UserPort.cs b/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/UserPort.cs index f8a0fc8c81..88effc10b6 100644 --- a/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/UserPort.cs +++ b/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/UserPort.cs @@ -1,7 +1,7 @@ using System; using BizHawk.Common; -namespace BizHawk.Emulation.Cores.Computers.Commodore64 +namespace BizHawk.Emulation.Cores.Computers.Commodore64.MOS { public class UserPort { diff --git a/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/Vic.GraphicsGenerator.cs b/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/Vic.GraphicsGenerator.cs deleted file mode 100644 index c8e1efbe8c..0000000000 --- a/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/Vic.GraphicsGenerator.cs +++ /dev/null @@ -1,11 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace BizHawk.Emulation.Cores.Computers.Commodore64 -{ - sealed public partial class Vic - { - } -} diff --git a/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/Vic.Parse.cs b/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/Vic.Parse.cs index 1de2c4fd33..f510f09159 100644 --- a/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/Vic.Parse.cs +++ b/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/Vic.Parse.cs @@ -3,7 +3,7 @@ using System.Collections.Generic; using System.Linq; using System.Text; -namespace BizHawk.Emulation.Cores.Computers.Commodore64 +namespace BizHawk.Emulation.Cores.Computers.Commodore64.MOS { sealed public partial class Vic { @@ -25,251 +25,235 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64 const int rasterIrqLine0Cycle = 1; const int rasterIrqLineXCycle = 0; - int parseaddr; - int parsecycleBAsprite0; - int parsecycleBAsprite1; - int parsecycleBAsprite2; - int parsecycleFetchSpriteIndex; - int parsefetch; - int parsefetchType; - int parseba; - int parseact; + private int parseaddr; + private int parsecycleBAsprite0; + private int parsecycleBAsprite1; + private int parsecycleBAsprite2; + private int parsecycleFetchSpriteIndex; + private int parsefetch; + private int parsefetchType; + private int parseba; + private int parseact; private void ParseCycle() { + parseaddr = 0x3FFF; + parsefetch = pipeline[1][cycleIndex]; + parseba = pipeline[2][cycleIndex]; + parseact = pipeline[3][cycleIndex]; + + // apply X location + rasterX = pipeline[0][cycleIndex]; + rasterXHold = ((parseact & pipelineHoldX) != 0); + + // perform fetch + parsefetchType = parsefetch & 0xFF00; + if (parsefetchType == 0x100) { - parseaddr = 0x3FFF; - parsefetch = pipeline[1][cycleIndex]; - parseba = pipeline[2][cycleIndex]; - parseact = pipeline[3][cycleIndex]; - - // apply X location - rasterX = pipeline[0][cycleIndex]; - rasterXHold = ((parseact & pipelineHoldX) != 0); - - // perform fetch - parsefetchType = parsefetch & 0xFF00; - if (parsefetchType == 0x100) + // fetch R + refreshCounter = (refreshCounter - 1) & 0xFF; + parseaddr = (0x3F00 | refreshCounter); + ReadMemory(parseaddr); + } + else if (parsefetchType == 0x200) + { + delayC = xScroll; + if (!idle) { - // fetch R - refreshCounter = (refreshCounter - 1) & 0xFF; - parseaddr = (0x3F00 | refreshCounter); - ReadMemory(parseaddr); - } - else if (parsefetchType == 0x200) - { - delayC = xScroll; - if (!idle) + if (badline) { - if (badline) - { - parseaddr = (pointerVM | vc); - dataC = ReadMemory(parseaddr); - dataC |= ((int)ReadColorRam(parseaddr) & 0xF) << 8; - bufferC[vmli] = dataC; - } - else - { - dataC = bufferC[vmli]; - } - } - else - { - dataC = 0; + parseaddr = (pointerVM | vc); + dataC = ReadMemory(parseaddr); + dataC |= ((int)ReadColorRam(parseaddr) & 0xF) << 8; bufferC[vmli] = dataC; } - srC <<= 12; - srC |= dataC; - } - else if (parsefetchType == 0x300) - { - // fetch G - if (idle) - parseaddr = 0x3FFF; else { - if (bitmapMode) - parseaddr = (rc | (vc << 3) | ((pointerCB & 0x4) << 11)); - else - parseaddr = (rc | ((dataC & 0xFF) << 3) | (pointerCB << 11)); + dataC = bufferC[vmli]; } - if (extraColorMode) - parseaddr &= 0x39FF; - dataG = ReadMemory(parseaddr); - sr |= dataG << (7 - xScroll); - srSync |= 0xAA << (7 - xScroll); - if (!idle) - { - bufferG[vmli] = dataG; - vmli = (vmli + 1) & 0x3F; - vc = (vc + 1) & 0x3FF; - } - } - else if (parsefetchType == 0x400) - { - // fetch I - parseaddr = (extraColorMode ? 0x39FF : 0x3FFF); - dataG = ReadMemory(parseaddr); - } - else if (parsefetchType == 0x500) - { - // fetch none } else { - parsecycleFetchSpriteIndex = (parsefetch & 0x7); - if ((parsefetch & 0xF0) == 0) // sprite rule 5 - { - // fetch P - parseaddr = (0x3F8 | pointerVM | parsecycleFetchSpriteIndex); - sprites[parsecycleFetchSpriteIndex].pointer = ReadMemory(parseaddr); - sprites[parsecycleFetchSpriteIndex].shiftEnable = false; - } - else - { - // fetch S - SpriteGenerator spr = sprites[parsecycleFetchSpriteIndex]; - if (spr.dma && spr.mcbase < 63) - { - parseaddr = (spr.mc | (spr.pointer << 6)); - spr.sr <<= 8; - spr.sr |= ReadMemory(parseaddr); - spr.srMask <<= 8; - spr.srMask |= 0xFF; - spr.mc++; - spr.dmaCount++; - } - else - { - spr.dma = false; - //spr.mc = 0; - } - } + dataC = 0; + bufferC[vmli] = dataC; } - - // perform BA flag manipulation - if (parseba == 0x0000) - { - pinBA = true; - } - else if (parseba == 0x1000) - { - pinBA = !badline; - } - else - { - parsecycleBAsprite0 = (parseba & 0x000F); - parsecycleBAsprite1 = (parseba & 0x00F0) >> 4; - parsecycleBAsprite2 = (parseba & 0x0F00) >> 8; - if ((parsecycleBAsprite0 < 8 && sprites[parsecycleBAsprite0].dma) || - (parsecycleBAsprite1 < 8 && sprites[parsecycleBAsprite1].dma) || - (parsecycleBAsprite2 < 8 && sprites[parsecycleBAsprite2].dma)) - pinBA = false; - else - pinBA = true; - } - - // perform actions - borderCheckLEnable = ((parseact & (pipelineChkBrdL0 | pipelineChkBrdL1)) != 0); - borderCheckREnable = ((parseact & (pipelineChkBrdR0 | pipelineChkBrdR1)) != 0); - hblankCheckEnableL = ((parseact & pipelineHBlankL) != 0); - hblankCheckEnableR = ((parseact & pipelineHBlankR) != 0); - - if (parseact != 0) - { - if ((parseact & pipelineChkSprCrunch) != 0) // sprite rule 7 - { - foreach (SpriteGenerator spr in sprites) - { - spr.yCrunch |= !spr.yExpand; // sprite rule 1 - spr.shiftEnable = false; - spr.xCrunch = !spr.xExpand; - spr.multicolorCrunch = !spr.multicolor; - } - } - - else if ((parseact & pipelineChkSprDisp) != 0) // sprite rule 4 - { - foreach (SpriteGenerator spr in sprites) - { - spr.yCrunch |= !spr.yExpand; // sprite rule 1 - spr.mc = spr.mcbase; - if (spr.dma && spr.y == (rasterLine & 0xFF)) - { - spr.display = true; - } - } - } - - else if ((parseact & pipelineChkSprDma) != 0) // sprite rule 3 - { - foreach (SpriteGenerator spr in sprites) - { - spr.yCrunch |= !spr.yExpand; // sprite rule 1 - if (spr.enable && spr.y == (rasterLine & 0xFF) && !spr.dma) - { - spr.dma = true; - spr.mcbase = 0; - spr.yCrunch = !spr.yExpand; - spr.mc = 0; - spr.dmaCount = 0; - } - } - } - - else if ((parseact & pipelineChkSprExp) != 0) // sprite rule 2 - { - foreach (SpriteGenerator spr in sprites) - { - spr.yCrunch |= !spr.yExpand; // sprite rule 1 - if (spr.yExpand) - spr.yCrunch ^= true; - if (spr.yCrunch) - { - spr.mcbase = spr.mc; - } - } - } - - else if ((parseact & pipelineUpdateMcBase) != 0) // sprite rule 8 - { - foreach (SpriteGenerator spr in sprites) - { - if (spr.yCrunch && spr.display) - { - //spr.mcbase = spr.mc; - if (spr.mcbase == 63 && spr.dma) - { - //spr.display = false; - //spr.dma = false; - } - } - spr.yCrunch |= !spr.yExpand; // sprite rule 1 - } - } - - else if ((parseact & pipelineUpdateRc) != 0) // VC/RC rule 5 - { - if (rc == 7) - { - idle = true; - vcbase = vc; - } - if (!idle) - rc = (rc + 1) & 0x7; - } - - else if ((parseact & pipelineUpdateVc) != 0) // VC/RC rule 2 - { - vc = vcbase; - vmli = 0; - if (badline) - rc = 0; - } - } - - cycleIndex++; + srC <<= 12; + srC |= dataC; } + else if (parsefetchType == 0x300) + { + // fetch G + if (idle) + parseaddr = 0x3FFF; + else + { + if (bitmapMode) + parseaddr = (rc | (vc << 3) | ((pointerCB & 0x4) << 11)); + else + parseaddr = (rc | ((dataC & 0xFF) << 3) | (pointerCB << 11)); + } + if (extraColorMode) + parseaddr &= 0x39FF; + dataG = ReadMemory(parseaddr); + sr |= dataG << (7 - xScroll); + srSync |= 0xAA << (7 - xScroll); + if (!idle) + { + bufferG[vmli] = dataG; + vmli = (vmli + 1) & 0x3F; + vc = (vc + 1) & 0x3FF; + } + } + else if (parsefetchType == 0x400) + { + // fetch I + parseaddr = (extraColorMode ? 0x39FF : 0x3FFF); + dataG = ReadMemory(parseaddr); + } + else if (parsefetchType == 0x500) + { + // fetch none + } + else + { + parsecycleFetchSpriteIndex = (parsefetch & 0x7); + if ((parsefetch & 0xF0) == 0) // sprite rule 5 + { + // fetch P + parseaddr = (0x3F8 | pointerVM | parsecycleFetchSpriteIndex); + sprites[parsecycleFetchSpriteIndex].pointer = ReadMemory(parseaddr); + sprites[parsecycleFetchSpriteIndex].shiftEnable = false; + } + else + { + // fetch S + var spr = sprites[parsecycleFetchSpriteIndex]; + if (spr.dma) + { + parseaddr = (spr.mc | (spr.pointer << 6)); + spr.sr |= (int)(ReadMemory(parseaddr)) << ((0x30 - (parsefetch & 0x30)) >> 1); + spr.mc++; + spr.loaded |= 0x800000; + } + } + } + + // perform BA flag manipulation + if (parseba == 0x0000) + { + pinBA = true; + } + else if (parseba == 0x1000) + { + pinBA = !badline; + } + else + { + parsecycleBAsprite0 = (parseba & 0x000F); + parsecycleBAsprite1 = (parseba & 0x00F0) >> 4; + parsecycleBAsprite2 = (parseba & 0x0F00) >> 8; + if ((parsecycleBAsprite0 < 8 && sprites[parsecycleBAsprite0].dma) || + (parsecycleBAsprite1 < 8 && sprites[parsecycleBAsprite1].dma) || + (parsecycleBAsprite2 < 8 && sprites[parsecycleBAsprite2].dma)) + pinBA = false; + else + pinBA = true; + } + + // perform actions + borderCheckLEnable = ((parseact & (pipelineChkBrdL0 | pipelineChkBrdL1)) != 0); + borderCheckREnable = ((parseact & (pipelineChkBrdR0 | pipelineChkBrdR1)) != 0); + hblankCheckEnableL = ((parseact & pipelineHBlankL) != 0); + hblankCheckEnableR = ((parseact & pipelineHBlankR) != 0); + + foreach (var spr in sprites) + { + if (!spr.yExpand) + spr.yCrunch = true; + } + + if ((parseact & pipelineChkSprExp) != 0) + { + foreach (var spr in sprites) + { + if (spr.yExpand) + spr.yCrunch ^= true; + } + } + + if ((parseact & pipelineChkSprDma) != 0) + { + foreach (var spr in sprites) + { + if (spr.enable && spr.y == (rasterLine & 0xFF) && !spr.dma) + { + spr.dma = true; + spr.mcbase = 0; + spr.yCrunch = !spr.yExpand; + } + } + } + + if ((parseact & pipelineChkSprDisp) != 0) + { + foreach (var spr in sprites) + { + spr.mc = spr.mcbase; + if (spr.dma && spr.y == (rasterLine & 0xFF)) + { + spr.display = true; + } + else if (!spr.dma) + { + spr.display = false; + } + } + } + + if ((parseact & pipelineChkSprCrunch) != 0) + { + // not sure if anything has to go here, + // some sources say yes, some say no... + } + + if ((parseact & pipelineUpdateMcBase) != 0) + { + foreach (var spr in sprites) + { + if (spr.yCrunch) + { + spr.mcbase = spr.mc; + if (spr.mcbase == 63) + { + if (!spr.yCrunch) + { + } + spr.dma = false; + } + } + } + } + + if ((parseact & pipelineUpdateRc) != 0) // VC/RC rule 5 + { + if (rc == 7) + { + idle = true; + vcbase = vc; + } + if (!idle) + rc = (rc + 1) & 0x7; + } + + if ((parseact & pipelineUpdateVc) != 0) // VC/RC rule 2 + { + vc = vcbase; + vmli = 0; + if (badline) + rc = 0; + } + + cycleIndex++; } } } diff --git a/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/Vic.Registers.cs b/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/Vic.Registers.cs index 04c014839e..3c51a8c843 100644 --- a/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/Vic.Registers.cs +++ b/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/Vic.Registers.cs @@ -3,7 +3,7 @@ using System.Collections.Generic; using System.Linq; using System.Text; -namespace BizHawk.Emulation.Cores.Computers.Commodore64 +namespace BizHawk.Emulation.Cores.Computers.Commodore64.MOS { sealed public partial class Vic { diff --git a/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/Vic.Render.cs b/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/Vic.Render.cs index cedad91361..d8093aa33e 100644 --- a/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/Vic.Render.cs +++ b/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/Vic.Render.cs @@ -3,30 +3,22 @@ using System.Collections.Generic; using System.Linq; using System.Text; -namespace BizHawk.Emulation.Cores.Computers.Commodore64 +namespace BizHawk.Emulation.Cores.Computers.Commodore64.MOS { sealed public partial class Vic { - int delayC; - int ecmPixel; - int pixel; - int pixelData; - SpriteGenerator pixelOwner; - int sprData; - int sprPixel; - int srC = 0; - int srSync = 0; - VicVideoMode videoMode; - - enum VicVideoMode : int - { - Mode000, - Mode001, - Mode010, - Mode011, - Mode100, - ModeBad - } + private int delayC; + private int ecmPixel; + private int pixel; + private int pixelCounter; + private int pixelData; + private int pixelOwner; + private int sprData; + private int sprIndex; + private int sprPixel; + private int srC = 0; + private int srSync = 0; + private int videoMode; private void Render() { @@ -42,7 +34,8 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64 } renderEnabled = (!hblank && !vblank); - for (int i = 0; i < 4; i++) + pixelCounter = -1; + while (pixelCounter++ < 3) { if (delayC > 0) @@ -51,6 +44,7 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64 displayC = (srC >> 12) & 0xFFF; + #region PRE-RENDER BORDER if (borderCheckLEnable && (rasterX == borderL)) { if (rasterLine == borderB) @@ -60,14 +54,16 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64 if (!borderOnVertical) borderOnMain = false; } + #endregion + #region CHARACTER GRAPHICS switch (videoMode) { - case VicVideoMode.Mode000: + case 0: pixelData = sr & srMask2; pixel = (pixelData != 0) ? (displayC >> 8) : backgroundColor0; break; - case VicVideoMode.Mode001: + case 1: if ((displayC & 0x800) != 0) { // multicolor 001 @@ -90,11 +86,11 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64 pixel = (pixelData != 0) ? (displayC >> 8) : backgroundColor0; } break; - case VicVideoMode.Mode010: + case 2: pixelData = sr & srMask2; pixel = (pixelData != 0) ? (displayC >> 4) : (displayC); break; - case VicVideoMode.Mode011: + case 3: if ((srSync & srMask2) != 0) pixelData = sr & srMask3; @@ -107,7 +103,7 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64 else pixel = (displayC >> 8); break; - case VicVideoMode.Mode100: + case 4: pixelData = sr & srMask2; if (pixelData != 0) { @@ -134,60 +130,78 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64 pixel &= 0xF; sr <<= 1; srSync <<= 1; +#endregion - // render sprite - pixelOwner = null; - foreach (SpriteGenerator spr in sprites) + #region SPRITES + // render sprites + pixelOwner = -1; + sprIndex = 0; + foreach (var spr in sprites) { sprData = 0; sprPixel = pixel; - spr.srMask &= 0xFFFFFF; if (spr.x == rasterX) - spr.shiftEnable = spr.display && spr.srMask != 0; + { + spr.shiftEnable = spr.display; + spr.xCrunch = !spr.xExpand; + spr.multicolorCrunch = false; + } + else + { + spr.xCrunch |= !spr.xExpand; + } if (spr.shiftEnable) // sprite rule 6 { if (spr.multicolor) { sprData = (spr.sr & srSpriteMaskMC); - if (spr.multicolorCrunch && spr.xCrunch && !rasterXHold) - { - spr.sr <<= 2; - spr.srMask <<= 2; - } + if (spr.multicolorCrunch && spr.xCrunch && !rasterXHold) + { + if (spr.loaded == 0) + { + spr.shiftEnable = false; + } + spr.sr <<= 2; + spr.loaded >>= 2; + } spr.multicolorCrunch ^= spr.xCrunch; } else { sprData = (spr.sr & srSpriteMask); - if (spr.xCrunch && !rasterXHold) - { - spr.sr <<= 1; - spr.srMask <<= 1; - } + if (spr.xCrunch && !rasterXHold) + { + if (spr.loaded == 0) + { + spr.shiftEnable = false; + } + spr.sr <<= 1; + spr.loaded >>= 1; + } } spr.xCrunch ^= spr.xExpand; if (sprData != 0) { // sprite-sprite collision - if (pixelOwner == null) + if (pixelOwner < 0) { - if (sprData == srSpriteMask1) - sprPixel = spriteMulticolor0; - else if (sprData == srSpriteMask2) - sprPixel = spr.color; - else if (sprData == srSpriteMask3) - sprPixel = spriteMulticolor1; - pixelOwner = spr; + if (sprData == srSpriteMask1) + sprPixel = spriteMulticolor0; + else if (sprData == srSpriteMask2) + sprPixel = spr.color; + else if (sprData == srSpriteMask3) + sprPixel = spriteMulticolor1; + pixelOwner = sprIndex; } else { if (!borderOnVertical) { spr.collideSprite = true; - pixelOwner.collideSprite = true; + sprites[pixelOwner].collideSprite = true; } } @@ -197,28 +211,31 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64 spr.collideData = true; } - // sprite priority logic - if (spr.priority) - { - pixel = (pixelData >= srMask2) ? pixel : sprPixel; - } - else - { - pixel = sprPixel; - } - } - if (spr.srMask == 0) - spr.shiftEnable = false; - //pixel = (spr.mcbase / 3) & 0xF; + // sprite priority logic + if (spr.priority) + { + pixel = (pixelData >= srMask2) ? pixel : sprPixel; + } + else + { + pixel = sprPixel; + } + } } + + sprIndex++; } +#endregion + + #region POST-RENDER BORDER if (borderCheckREnable && (rasterX == borderR)) borderOnMain = true; // border doesn't work with the background buffer if (borderOnMain || borderOnVertical) pixel = borderColor; + #endregion // plot pixel if within viewing area if (renderEnabled) diff --git a/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/Vic.SpriteGenerator.cs b/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/Vic.Sprite.cs similarity index 82% rename from BizHawk.Emulation.Cores/Computers/Commodore64/MOS/Vic.SpriteGenerator.cs rename to BizHawk.Emulation.Cores/Computers/Commodore64/MOS/Vic.Sprite.cs index b8b8e2591e..be30e83193 100644 --- a/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/Vic.SpriteGenerator.cs +++ b/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/Vic.Sprite.cs @@ -5,19 +5,19 @@ using System.Text; using BizHawk.Common; -namespace BizHawk.Emulation.Cores.Computers.Commodore64 +namespace BizHawk.Emulation.Cores.Computers.Commodore64.MOS { sealed public partial class Vic { - sealed class SpriteGenerator + sealed class Sprite { public bool collideData; public bool collideSprite; public int color; public bool display; public bool dma; - public int dmaCount; public bool enable; + public int loaded; public int mc; public int mcbase; public bool multicolor; @@ -26,7 +26,6 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64 public bool priority; public bool shiftEnable; public int sr; - public int srMask; public int x; public bool xCrunch; public bool xExpand; @@ -41,7 +40,6 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64 color = 0; display = false; dma = false; - dmaCount = 0; enable = false; mc = 0; mcbase = 0; diff --git a/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/Vic.State.cs b/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/Vic.State.cs index 9d8f6fdc78..e013f51d6f 100644 --- a/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/Vic.State.cs +++ b/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/Vic.State.cs @@ -6,91 +6,91 @@ using System.Text; using BizHawk.Common; -namespace BizHawk.Emulation.Cores.Computers.Commodore64 +namespace BizHawk.Emulation.Cores.Computers.Commodore64.MOS { sealed public partial class Vic { - int backgroundColor0; - int backgroundColor1; - int backgroundColor2; - int backgroundColor3; - int baCount; - bool badline; - bool badlineEnable; - int bitmapColumn; - bool bitmapMode; - int borderB; - bool borderCheckLEnable; - bool borderCheckREnable; - int borderColor; - int borderL; - bool borderOnMain; - bool borderOnVertical; - int borderR; - int borderT; - int[] bufferC; - int[] bufferG; - int cycle; - int cycleIndex; - bool columnSelect; - int dataC; - int dataG; - bool displayEnable; - int displayC; - bool enableIntLightPen; - bool enableIntRaster; - bool enableIntSpriteCollision; - bool enableIntSpriteDataCollision; - bool extraColorMode; - bool hblank; - bool idle; - bool intLightPen; - bool intRaster; - bool intSpriteCollision; - bool intSpriteDataCollision; - int hblankEnd; - int hblankStart; - bool hblankCheckEnableL; - bool hblankCheckEnableR; - int lastRasterLine; - int lightPenX; - int lightPenY; - bool multicolorMode; - bool pinAEC = true; - bool pinBA = true; - bool pinIRQ = true; - int pointerCB; - int pointerVM; - int rasterInterruptLine; - int rasterLine; - int rasterX; - bool rasterXHold; - int rc; - int refreshCounter; - bool renderEnabled; - bool rowSelect; - int spriteMulticolor0; - int spriteMulticolor1; - SpriteGenerator[] sprites; - int sr; - int srMask; - int srMask1; - int srMask2; - int srMask3; - int srMaskMC; - int srSpriteMask; - int srSpriteMask1; - int srSpriteMask2; - int srSpriteMask3; - int srSpriteMaskMC; - bool vblank; - int vblankEnd; - int vblankStart; - int vc; - int vcbase; - int vmli; - int xScroll; - int yScroll; + private int backgroundColor0; + private int backgroundColor1; + private int backgroundColor2; + private int backgroundColor3; + private int baCount; + private bool badline; + private bool badlineEnable; + private int bitmapColumn; + private bool bitmapMode; + private int borderB; + private bool borderCheckLEnable; + private bool borderCheckREnable; + private int borderColor; + private int borderL; + private bool borderOnMain; + private bool borderOnVertical; + private int borderR; + private int borderT; + private int[] bufferC; + private int[] bufferG; + private int cycle; + private int cycleIndex; + private bool columnSelect; + private int dataC; + private int dataG; + private bool displayEnable; + private int displayC; + private bool enableIntLightPen; + private bool enableIntRaster; + private bool enableIntSpriteCollision; + private bool enableIntSpriteDataCollision; + private bool extraColorMode; + private bool hblank; + private bool idle; + private bool intLightPen; + private bool intRaster; + private bool intSpriteCollision; + private bool intSpriteDataCollision; + private int hblankEnd; + private int hblankStart; + private bool hblankCheckEnableL; + private bool hblankCheckEnableR; + private int lastRasterLine; + private int lightPenX; + private int lightPenY; + private bool multicolorMode; + private bool pinAEC = true; + private bool pinBA = true; + private bool pinIRQ = true; + private int pointerCB; + private int pointerVM; + private int rasterInterruptLine; + private int rasterLine; + private int rasterX; + private bool rasterXHold; + private int rc; + private int refreshCounter; + private bool renderEnabled; + private bool rowSelect; + private int spriteMulticolor0; + private int spriteMulticolor1; + private Sprite[] sprites; + private int sr; + private int srMask; + private int srMask1; + private int srMask2; + private int srMask3; + private int srMaskMC; + private int srSpriteMask; + private int srSpriteMask1; + private int srSpriteMask2; + private int srSpriteMask3; + private int srSpriteMaskMC; + private bool vblank; + private int vblankEnd; + private int vblankStart; + private int vc; + private int vcbase; + private int vmli; + private int xScroll; + private int yScroll; public void HardReset() { diff --git a/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/Vic.TimingBuilder.cs b/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/Vic.TimingBuilder.cs index ebe9e21e93..a8988ea487 100644 --- a/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/Vic.TimingBuilder.cs +++ b/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/Vic.TimingBuilder.cs @@ -3,7 +3,7 @@ using System.Collections.Generic; using System.Linq; using System.Text; -namespace BizHawk.Emulation.Cores.Computers.Commodore64 +namespace BizHawk.Emulation.Cores.Computers.Commodore64.MOS { sealed public partial class Vic { @@ -13,16 +13,16 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64 const int BORDER_RIGHT_40 = 0x158; // The special actions taken by the Vic are in the same order and interval on all chips, just different offsets. - static int[] TimingBuilder_Cycle14Act = new int[] + static private int[] TimingBuilder_Cycle14Act = new int[] { pipelineUpdateVc, 0, pipelineChkSprCrunch, 0, pipelineUpdateMcBase, 0, }; - static int[] TimingBuilder_Cycle55Act = new int[] + static private int[] TimingBuilder_Cycle55Act = new int[] { pipelineChkSprDma, 0, - pipelineChkSprDma, pipelineChkSprExp, + pipelineChkSprDma | pipelineChkSprExp, 0, 0, 0, pipelineChkSprDisp, pipelineUpdateRc }; diff --git a/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/Vic.VideoProvider.cs b/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/Vic.VideoProvider.cs index dfdac33915..e543bcfdf1 100644 --- a/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/Vic.VideoProvider.cs +++ b/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/Vic.VideoProvider.cs @@ -3,21 +3,21 @@ using BizHawk.Common; using BizHawk.Emulation.Common; -namespace BizHawk.Emulation.Cores.Computers.Commodore64 +namespace BizHawk.Emulation.Cores.Computers.Commodore64.MOS { sealed public partial class Vic : IVideoProvider { - int[] buf; - int bufHeight; - int bufLength; - int bufOffset; - int bufWidth; - int pixBufferSize = 12; - int[] pixBuffer; - int pixBufferIndex; + private int[] buf; + private int bufHeight; + private int bufLength; + private int bufOffset; + private int bufWidth; + private int pixBufferSize = 12; + private int[] pixBuffer; + private int pixBufferIndex; // palette - int[] palette = + private int[] palette = { Colors.ARGB(0x00, 0x00, 0x00), Colors.ARGB(0xFF, 0xFF, 0xFF), diff --git a/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/Vic.cs b/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/Vic.cs index 109cced622..ba587c6360 100644 --- a/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/Vic.cs +++ b/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/Vic.cs @@ -1,7 +1,7 @@ using System; using System.Drawing; -namespace BizHawk.Emulation.Cores.Computers.Commodore64 +namespace BizHawk.Emulation.Cores.Computers.Commodore64.MOS { sealed public partial class Vic { @@ -12,11 +12,11 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64 public bool ReadBABuffer() { return pinBA; } public bool ReadIRQBuffer() { return pinIRQ; } - int cyclesPerSec; - int irqShift; - int[][] pipeline; - int totalCycles; - int totalLines; + private int cyclesPerSec; + private int irqShift; + private int[][] pipeline; + private int totalCycles; + private int totalLines; public Vic(int newCycles, int newLines, int[][] newPipeline, int newCyclesPerSec, int hblankStart, int hblankEnd, int vblankStart, int vblankEnd) { @@ -37,9 +37,9 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64 buf = new int[bufWidth * bufHeight]; bufLength = buf.Length; - sprites = new SpriteGenerator[8]; + sprites = new Sprite[8]; for (int i = 0; i < 8; i++) - sprites[i] = new SpriteGenerator(); + sprites[i] = new Sprite(); bufferC = new int[40]; bufferG = new int[40]; @@ -180,30 +180,30 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64 { if (!extraColorMode && !bitmapMode && !multicolorMode) { - videoMode = VicVideoMode.Mode000; + videoMode = 0; return; } else if (!extraColorMode && !bitmapMode && multicolorMode) { - videoMode = VicVideoMode.Mode001; + videoMode = 1; return; } else if (!extraColorMode && bitmapMode && !multicolorMode) { - videoMode = VicVideoMode.Mode010; + videoMode = 2; return; } else if (!extraColorMode && bitmapMode && multicolorMode) { - videoMode = VicVideoMode.Mode011; + videoMode = 3; return; } else if (extraColorMode && !bitmapMode && !multicolorMode) { - videoMode = VicVideoMode.Mode100; + videoMode = 4; return; } - videoMode = VicVideoMode.ModeBad; + videoMode = -1; } } } diff --git a/BizHawk.Emulation.Cores/Computers/Commodore64/Media/PRG.cs b/BizHawk.Emulation.Cores/Computers/Commodore64/Media/PRG.cs index 264eb21a3b..37b552acac 100644 --- a/BizHawk.Emulation.Cores/Computers/Commodore64/Media/PRG.cs +++ b/BizHawk.Emulation.Cores/Computers/Commodore64/Media/PRG.cs @@ -1,4 +1,6 @@ -namespace BizHawk.Emulation.Cores.Computers.Commodore64 +using BizHawk.Emulation.Cores.Computers.Commodore64.MOS; + +namespace BizHawk.Emulation.Cores.Computers.Commodore64 { public static class PRG { diff --git a/BizHawk.Emulation.Cores/Computers/Commodore64/Tape/VIC1530.cs b/BizHawk.Emulation.Cores/Computers/Commodore64/Tape/VIC1530.cs deleted file mode 100644 index 095cf467bb..0000000000 --- a/BizHawk.Emulation.Cores/Computers/Commodore64/Tape/VIC1530.cs +++ /dev/null @@ -1,8 +0,0 @@ -namespace BizHawk.Emulation.Cores.Computers.Commodore64 -{ - // common tape drive that works with the C64. - - public class VIC1530 - { - } -} diff --git a/BizHawk.Emulation.Cores/Computers/Commodore64/UserPort/UserPortDevice.cs b/BizHawk.Emulation.Cores/Computers/Commodore64/UserPort/UserPortDevice.cs new file mode 100644 index 0000000000..eedf9a1872 --- /dev/null +++ b/BizHawk.Emulation.Cores/Computers/Commodore64/UserPort/UserPortDevice.cs @@ -0,0 +1,77 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using BizHawk.Common; +using BizHawk.Emulation.Common; + +namespace BizHawk.Emulation.Cores.Computers.Commodore64.UserPort +{ + public class UserPortDevice + { + public Func ReadCounter1; + public Func ReadCounter2; + public Func ReadHandshake; + public Func ReadSerial1; + public Func ReadSerial2; + + public UserPortDevice() + { + } + + virtual public void HardReset() + { + // note: this will not disconnect any attached media + } + + virtual public bool ReadAtn() + { + return true; + } + + virtual public bool ReadCounter1Buffer() + { + return true; + } + + virtual public bool ReadCounter2Buffer() + { + return true; + } + + virtual public byte ReadData() + { + return 0xFF; + } + + virtual public bool ReadFlag2() + { + return true; + } + + virtual public bool ReadPA2() + { + return true; + } + + virtual public bool ReadReset() + { + return true; + } + + virtual public bool ReadSerial1Buffer() + { + return true; + } + + virtual public bool ReadSerial2Buffer() + { + return true; + } + + public void SyncState(Serializer ser) + { + SaveState.SyncObject(ser, this); + } + } +}