diff --git a/BizHawk.Client.EmuHawk/MainForm.cs b/BizHawk.Client.EmuHawk/MainForm.cs index cb4104ea0a..cf39958b92 100644 --- a/BizHawk.Client.EmuHawk/MainForm.cs +++ b/BizHawk.Client.EmuHawk/MainForm.cs @@ -12,7 +12,7 @@ using BizHawk.Common; using BizHawk.Client.Common; using BizHawk.Emulation; using BizHawk.Emulation.Common; -using BizHawk.Emulation.Computers.Commodore64; +using BizHawk.Emulation.Cores.Computers.Commodore64; using BizHawk.Emulation.Cores.Calculator; using BizHawk.Emulation.Consoles.Coleco; using BizHawk.Emulation.Consoles.GB; diff --git a/BizHawk.Emulation/Computers/Commodore64/C64.Core.cs b/BizHawk.Emulation/Computers/Commodore64/C64.Core.cs index b352073b90..7cb5ac2d8b 100644 --- a/BizHawk.Emulation/Computers/Commodore64/C64.Core.cs +++ b/BizHawk.Emulation/Computers/Commodore64/C64.Core.cs @@ -2,12 +2,8 @@ using System.Collections.Generic; using System.IO; using BizHawk.Emulation.Common; -using BizHawk.Emulation.Computers.Commodore64.Cartridge; -using BizHawk.Emulation.Computers.Commodore64.Disk; -using BizHawk.Emulation.Computers.Commodore64.MOS; - -namespace BizHawk.Emulation.Computers.Commodore64 +namespace BizHawk.Emulation.Cores.Computers.Commodore64 { public enum Region { diff --git a/BizHawk.Emulation/Computers/Commodore64/C64.Input.cs b/BizHawk.Emulation/Computers/Commodore64/C64.Input.cs index 5c2c5ec555..13ca9292c4 100644 --- a/BizHawk.Emulation/Computers/Commodore64/C64.Input.cs +++ b/BizHawk.Emulation/Computers/Commodore64/C64.Input.cs @@ -1,6 +1,4 @@ -using BizHawk.Emulation.Computers.Commodore64.MOS; - -namespace BizHawk.Emulation.Computers.Commodore64 +namespace BizHawk.Emulation.Cores.Computers.Commodore64 { sealed public partial class Motherboard { @@ -28,48 +26,48 @@ namespace BizHawk.Emulation.Computers.Commodore64 static private byte[] inputBitMask = new byte[] { 0xFE, 0xFD, 0xFB, 0xF7, 0xEF, 0xDF, 0xBF, 0x7F }; static private byte[] inputBitSelect = new byte[] { 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80 }; - byte cia0InputLatchA; - byte cia0InputLatchB; - int pollIndex; + byte cia0InputLatchA; + byte cia0InputLatchB; + int pollIndex; public void PollInput() { // scan joysticks - pollIndex = 0; - for (int j = 0; j < 5; j++) + pollIndex = 0; + for (int j = 0; j < 5; j++) { - for (int i = 0; i < 2; i++) - { - joystickPressed[pollIndex++] = controller[joystickMatrix[i, j]] ? -1 : 0; + for (int i = 0; i < 2; i++) + { + joystickPressed[pollIndex++] = controller[joystickMatrix[i, j]] ? -1 : 0; } } // scan keyboard - pollIndex = 0; - for (int i = 0; i < 8; i++) + pollIndex = 0; + for (int i = 0; i < 8; i++) { - for (int j = 0; j < 8; j++) + for (int j = 0; j < 8; j++) { - keyboardPressed[pollIndex++] = controller[keyboardMatrix[i, j]] ? -1 : 0; + keyboardPressed[pollIndex++] = controller[keyboardMatrix[i, j]] ? -1 : 0; } } } private void WriteInputPort() { - byte portA = cia0.PortAData; - byte portB = cia0.PortBData; + byte portA = cia0.PortAData; + byte portB = cia0.PortBData; byte resultA = 0xFF; byte resultB = 0xFF; byte joyA = 0xFF; byte joyB = 0xFF; - pollIndex = 0; + pollIndex = 0; for (int i = 0; i < 8; i++) { for (int j = 0; j < 8; j++) { - if (keyboardPressed[pollIndex++] != 0) + if (keyboardPressed[pollIndex++] != 0) { if (((portA & inputBitSelect[i]) == 0) || ((portB & inputBitSelect[j]) == 0)) { @@ -80,23 +78,23 @@ namespace BizHawk.Emulation.Computers.Commodore64 } } - pollIndex = 0; + pollIndex = 0; for (int i = 0; i < 5; i++) { - if (joystickPressed[pollIndex++] != 0) - joyB &= inputBitMask[i]; - if (joystickPressed[pollIndex++] != 0) + if (joystickPressed[pollIndex++] != 0) + joyB &= inputBitMask[i]; + if (joystickPressed[pollIndex++] != 0) joyA &= inputBitMask[i]; } resultA &= joyA; resultB &= joyB; - cia0InputLatchA = resultA; + cia0InputLatchA = resultA; cia0InputLatchB = resultB; - // this joystick has special rules. - cia0.PortAMask = joyA; + // this joystick has special rules. + cia0.PortAMask = joyA; } } } diff --git a/BizHawk.Emulation/Computers/Commodore64/C64.Motherboard.cs b/BizHawk.Emulation/Computers/Commodore64/C64.Motherboard.cs index fbe8b6a83f..0eea68e498 100644 --- a/BizHawk.Emulation/Computers/Commodore64/C64.Motherboard.cs +++ b/BizHawk.Emulation/Computers/Commodore64/C64.Motherboard.cs @@ -1,10 +1,9 @@ -using BizHawk.Emulation.Computers.Commodore64.MOS; -using System.Reflection; +using System.Reflection; using BizHawk.Common; using BizHawk.Emulation.Common; -namespace BizHawk.Emulation.Computers.Commodore64 +namespace BizHawk.Emulation.Cores.Computers.Commodore64 { /// /// Contains the onboard chipset and glue. diff --git a/BizHawk.Emulation/Computers/Commodore64/C64.MotherboardInterface.cs b/BizHawk.Emulation/Computers/Commodore64/C64.MotherboardInterface.cs index f8650b0fdc..b114a6c25c 100644 --- a/BizHawk.Emulation/Computers/Commodore64/C64.MotherboardInterface.cs +++ b/BizHawk.Emulation/Computers/Commodore64/C64.MotherboardInterface.cs @@ -1,141 +1,139 @@ -using BizHawk.Emulation.Computers.Commodore64.MOS; - -using System; +using System; using System.Collections.Generic; using System.Linq; using System.Text; -namespace BizHawk.Emulation.Computers.Commodore64 +namespace BizHawk.Emulation.Cores.Computers.Commodore64 { - sealed public partial class Motherboard - { - bool CassPort_ReadDataOutput() - { - return (cpu.PortData & 0x08) != 0; - } + sealed public partial class Motherboard + { + bool CassPort_ReadDataOutput() + { + return (cpu.PortData & 0x08) != 0; + } - bool CassPort_ReadMotor() - { - return (cpu.PortData & 0x20) != 0; - } + bool CassPort_ReadMotor() + { + return (cpu.PortData & 0x20) != 0; + } - bool Cia0_ReadCnt() - { - return (userPort.ReadCounter1Buffer() && cia0.ReadCNTBuffer()); - } + bool Cia0_ReadCnt() + { + return (userPort.ReadCounter1Buffer() && cia0.ReadCNTBuffer()); + } - byte Cia0_ReadPortA() - { - return cia0InputLatchA; - } + byte Cia0_ReadPortA() + { + return cia0InputLatchA; + } - byte Cia0_ReadPortB() - { - return cia0InputLatchB; - } + byte Cia0_ReadPortB() + { + return cia0InputLatchB; + } - bool Cia0_ReadSP() - { - return (userPort.ReadSerial1Buffer() && cia0.ReadSPBuffer()); - } + bool Cia0_ReadSP() + { + return (userPort.ReadSerial1Buffer() && cia0.ReadSPBuffer()); + } - bool Cia1_ReadCnt() - { - return (userPort.ReadCounter2Buffer() && cia1.ReadCNTBuffer()); - } + bool Cia1_ReadCnt() + { + return (userPort.ReadCounter2Buffer() && cia1.ReadCNTBuffer()); + } - byte Cia1_ReadPortA() - { - // the low bits are actually the VIC memory address. - byte result = 0xFF; - if (serPort.WriteDataIn()) - result &= 0x7F; - if (serPort.WriteClockIn()) - result &= 0xBF; - return result; - } + byte Cia1_ReadPortA() + { + // the low bits are actually the VIC memory address. + byte result = 0xFF; + if (serPort.WriteDataIn()) + result &= 0x7F; + if (serPort.WriteClockIn()) + result &= 0xBF; + return result; + } - bool Cia1_ReadSP() - { - return (userPort.ReadSerial2Buffer() && cia1.ReadSPBuffer()); - } + bool Cia1_ReadSP() + { + return (userPort.ReadSerial2Buffer() && cia1.ReadSPBuffer()); + } - byte Cpu_ReadPort() - { - byte data = 0x1F; - if (!cassPort.ReadSenseBuffer()) - data &= 0xEF; - return data; - } + byte Cpu_ReadPort() + { + byte data = 0x1F; + if (!cassPort.ReadSenseBuffer()) + data &= 0xEF; + return data; + } - bool Glue_ReadIRQ() - { - return cia0.ReadIRQBuffer() & vic.ReadIRQBuffer() & cartPort.ReadIRQBuffer(); - } + bool Glue_ReadIRQ() + { + return cia0.ReadIRQBuffer() & vic.ReadIRQBuffer() & cartPort.ReadIRQBuffer(); + } - bool Pla_ReadCharen() - { - return (cpu.PortData & 0x04) != 0; - } + bool Pla_ReadCharen() + { + return (cpu.PortData & 0x04) != 0; + } - byte Pla_ReadCia0(int addr) - { - if (addr == 0xDC00 || addr == 0xDC01) - { - WriteInputPort(); - inputRead = true; - } - return cia0.Read(addr); - } + byte Pla_ReadCia0(int addr) + { + if (addr == 0xDC00 || addr == 0xDC01) + { + WriteInputPort(); + inputRead = true; + } + return cia0.Read(addr); + } - byte Pla_ReadColorRam(int addr) - { - byte result = bus; - result &= 0xF0; - result |= colorRam.Read(addr); - return result; - } + byte Pla_ReadColorRam(int addr) + { + byte result = bus; + result &= 0xF0; + result |= colorRam.Read(addr); + return result; + } - bool Pla_ReadHiRam() - { - return (cpu.PortData & 0x02) != 0; - } + bool Pla_ReadHiRam() + { + return (cpu.PortData & 0x02) != 0; + } - bool Pla_ReadLoRam() - { - return (cpu.PortData & 0x01) != 0; - } + bool Pla_ReadLoRam() + { + return (cpu.PortData & 0x01) != 0; + } - bool SerPort_ReadAtnOut() - { - return (cia1.PortBData & 0x08) == 0; - } + bool SerPort_ReadAtnOut() + { + return (cia1.PortBData & 0x08) == 0; + } - bool SerPort_ReadClockOut() - { - return (cia1.PortAData & 0x10) == 0; - } + bool SerPort_ReadClockOut() + { + return (cia1.PortAData & 0x10) == 0; + } - bool SerPort_ReadDataOut() - { - return (cia1.PortAData & 0x20) == 0; - } + bool SerPort_ReadDataOut() + { + return (cia1.PortAData & 0x20) == 0; + } - byte Sid_ReadPotX() - { - return 0; - } + byte Sid_ReadPotX() + { + return 0; + } - byte Sid_ReadPotY() - { - return 0; - } + byte Sid_ReadPotY() + { + return 0; + } - byte Vic_ReadMemory(int addr) - { - // the system sees (cia1.PortAData & 0x3) but we use a shortcut - addr |= (0x3 - (((cia1.PortALatch & cia1.PortADirection) | (~cia1.PortADirection)) & 0x3)) << 14; - return pla.VicRead(addr); - } - } + byte Vic_ReadMemory(int addr) + { + // the system sees (cia1.PortAData & 0x3) but we use a shortcut + addr |= (0x3 - (((cia1.PortALatch & cia1.PortADirection) | (~cia1.PortADirection)) & 0x3)) << 14; + return pla.VicRead(addr); + } + } } diff --git a/BizHawk.Emulation/Computers/Commodore64/C64.Savestate.cs b/BizHawk.Emulation/Computers/Commodore64/C64.Savestate.cs index 49e43c1491..23ca60d9ce 100644 --- a/BizHawk.Emulation/Computers/Commodore64/C64.Savestate.cs +++ b/BizHawk.Emulation/Computers/Commodore64/C64.Savestate.cs @@ -3,7 +3,7 @@ using BizHawk.Common; using BizHawk.Emulation.Common; -namespace BizHawk.Emulation.Computers.Commodore64 +namespace BizHawk.Emulation.Cores.Computers.Commodore64 { sealed public partial class C64 : IEmulator { diff --git a/BizHawk.Emulation/Computers/Commodore64/C64.cs b/BizHawk.Emulation/Computers/Commodore64/C64.cs index dd98ba15b6..ff41dcfc64 100644 --- a/BizHawk.Emulation/Computers/Commodore64/C64.cs +++ b/BizHawk.Emulation/Computers/Commodore64/C64.cs @@ -4,7 +4,7 @@ using System.IO; using BizHawk.Emulation.Common; -namespace BizHawk.Emulation.Computers.Commodore64 +namespace BizHawk.Emulation.Cores.Computers.Commodore64 { sealed public partial class C64 : IEmulator { @@ -118,7 +118,7 @@ namespace BizHawk.Emulation.Computers.Commodore64 // board.ram.Poke(0x0039, inputFileInfo.Data[4]); // board.ram.Poke(0x003A, inputFileInfo.Data[5]); //} - Media.PRG.Load(board.pla, inputFileInfo.Data); + PRG.Load(board.pla, inputFileInfo.Data); loadPrg = false; } } diff --git a/BizHawk.Emulation/Computers/Commodore64/Cartridge/Cart.cs b/BizHawk.Emulation/Computers/Commodore64/Cartridge/Cart.cs index b87de86028..db3a548db1 100644 --- a/BizHawk.Emulation/Computers/Commodore64/Cartridge/Cart.cs +++ b/BizHawk.Emulation/Computers/Commodore64/Cartridge/Cart.cs @@ -4,7 +4,7 @@ using System.IO; using BizHawk.Common; -namespace BizHawk.Emulation.Computers.Commodore64.Cartridge +namespace BizHawk.Emulation.Cores.Computers.Commodore64 { // this is the base cartridge class diff --git a/BizHawk.Emulation/Computers/Commodore64/Cartridge/Mapper0000.cs b/BizHawk.Emulation/Computers/Commodore64/Cartridge/Mapper0000.cs index 821233ad2b..4aa855fe65 100644 --- a/BizHawk.Emulation/Computers/Commodore64/Cartridge/Mapper0000.cs +++ b/BizHawk.Emulation/Computers/Commodore64/Cartridge/Mapper0000.cs @@ -1,7 +1,7 @@ using System; using System.Collections.Generic; -namespace BizHawk.Emulation.Computers.Commodore64.Cartridge +namespace BizHawk.Emulation.Cores.Computers.Commodore64 { public class Mapper0000 : Cart { diff --git a/BizHawk.Emulation/Computers/Commodore64/Cartridge/Mapper0005.cs b/BizHawk.Emulation/Computers/Commodore64/Cartridge/Mapper0005.cs index c2be6f2980..565da3b740 100644 --- a/BizHawk.Emulation/Computers/Commodore64/Cartridge/Mapper0005.cs +++ b/BizHawk.Emulation/Computers/Commodore64/Cartridge/Mapper0005.cs @@ -3,7 +3,7 @@ using System.Collections.Generic; using BizHawk.Common; -namespace BizHawk.Emulation.Computers.Commodore64.Cartridge +namespace BizHawk.Emulation.Cores.Computers.Commodore64 { public class Mapper0005 : Cart { diff --git a/BizHawk.Emulation/Computers/Commodore64/Cartridge/Mapper000B.cs b/BizHawk.Emulation/Computers/Commodore64/Cartridge/Mapper000B.cs index c5602e0f6a..19d140faad 100644 --- a/BizHawk.Emulation/Computers/Commodore64/Cartridge/Mapper000B.cs +++ b/BizHawk.Emulation/Computers/Commodore64/Cartridge/Mapper000B.cs @@ -1,7 +1,7 @@ using System; using System.Collections.Generic; -namespace BizHawk.Emulation.Computers.Commodore64.Cartridge +namespace BizHawk.Emulation.Cores.Computers.Commodore64 { // Westermann Learning mapper. // Starts up with both banks enabled, any read to DFxx diff --git a/BizHawk.Emulation/Computers/Commodore64/Cartridge/Mapper000F.cs b/BizHawk.Emulation/Computers/Commodore64/Cartridge/Mapper000F.cs index a33686205e..b9fe5bd3f5 100644 --- a/BizHawk.Emulation/Computers/Commodore64/Cartridge/Mapper000F.cs +++ b/BizHawk.Emulation/Computers/Commodore64/Cartridge/Mapper000F.cs @@ -3,7 +3,7 @@ using System.Collections.Generic; using BizHawk.Common; -namespace BizHawk.Emulation.Computers.Commodore64.Cartridge +namespace BizHawk.Emulation.Cores.Computers.Commodore64 { // This is a mapper used commonly by System 3. It is // also utilized by the short-lived C64 Game System. diff --git a/BizHawk.Emulation/Computers/Commodore64/Cartridge/Mapper0011.cs b/BizHawk.Emulation/Computers/Commodore64/Cartridge/Mapper0011.cs index 9958de8183..1fdc16a413 100644 --- a/BizHawk.Emulation/Computers/Commodore64/Cartridge/Mapper0011.cs +++ b/BizHawk.Emulation/Computers/Commodore64/Cartridge/Mapper0011.cs @@ -1,6 +1,6 @@ using System.Collections.Generic; -namespace BizHawk.Emulation.Computers.Commodore64.Cartridge +namespace BizHawk.Emulation.Cores.Computers.Commodore64 { // This mapper comes from Dinamic. It is in fact identical // to the System 3 mapper (000F) except that bank switching is diff --git a/BizHawk.Emulation/Computers/Commodore64/Cartridge/Mapper0012.cs b/BizHawk.Emulation/Computers/Commodore64/Cartridge/Mapper0012.cs index 40b4c0f561..1b4ff9fb1f 100644 --- a/BizHawk.Emulation/Computers/Commodore64/Cartridge/Mapper0012.cs +++ b/BizHawk.Emulation/Computers/Commodore64/Cartridge/Mapper0012.cs @@ -3,7 +3,7 @@ using System.Collections.Generic; using BizHawk.Common; -namespace BizHawk.Emulation.Computers.Commodore64.Cartridge +namespace BizHawk.Emulation.Cores.Computers.Commodore64 { public class Mapper0012 : Cart { diff --git a/BizHawk.Emulation/Computers/Commodore64/Cartridge/Mapper0013.cs b/BizHawk.Emulation/Computers/Commodore64/Cartridge/Mapper0013.cs index eafa460753..b7fbe1f3f5 100644 --- a/BizHawk.Emulation/Computers/Commodore64/Cartridge/Mapper0013.cs +++ b/BizHawk.Emulation/Computers/Commodore64/Cartridge/Mapper0013.cs @@ -2,7 +2,7 @@ using System.Collections.Generic; using BizHawk.Common; -namespace BizHawk.Emulation.Computers.Commodore64.Cartridge +namespace BizHawk.Emulation.Cores.Computers.Commodore64 { // Mapper for a few Domark and HES Australia games. // It seems a lot of people dumping these have remapped diff --git a/BizHawk.Emulation/Computers/Commodore64/Cartridge/Mapper0020.cs b/BizHawk.Emulation/Computers/Commodore64/Cartridge/Mapper0020.cs index eddb69b50f..576a29e268 100644 --- a/BizHawk.Emulation/Computers/Commodore64/Cartridge/Mapper0020.cs +++ b/BizHawk.Emulation/Computers/Commodore64/Cartridge/Mapper0020.cs @@ -1,7 +1,7 @@ using System.Collections.Generic; using BizHawk.Common; -namespace BizHawk.Emulation.Computers.Commodore64.Cartridge +namespace BizHawk.Emulation.Cores.Computers.Commodore64 { // EasyFlash cartridge // No official games came on one of these but there diff --git a/BizHawk.Emulation/Computers/Commodore64/Disk/VIC1541.PLA.cs b/BizHawk.Emulation/Computers/Commodore64/Disk/VIC1541.PLA.cs index 7d1a3f8b4f..9a588caeac 100644 --- a/BizHawk.Emulation/Computers/Commodore64/Disk/VIC1541.PLA.cs +++ b/BizHawk.Emulation/Computers/Commodore64/Disk/VIC1541.PLA.cs @@ -1,6 +1,6 @@ using System; -namespace BizHawk.Emulation.Computers.Commodore64.Disk +namespace BizHawk.Emulation.Cores.Computers.Commodore64 { public class VIC1541PLA { diff --git a/BizHawk.Emulation/Computers/Commodore64/Disk/VIC1541.cs b/BizHawk.Emulation/Computers/Commodore64/Disk/VIC1541.cs index 8d7c54420f..132bb78410 100644 --- a/BizHawk.Emulation/Computers/Commodore64/Disk/VIC1541.cs +++ b/BizHawk.Emulation/Computers/Commodore64/Disk/VIC1541.cs @@ -1,10 +1,9 @@ -using BizHawk.Emulation.CPUs.M6502; -using BizHawk.Emulation.Computers.Commodore64.MOS; -using System; +using System; +using BizHawk.Emulation.CPUs.M6502; #if false -namespace BizHawk.Emulation.Computers.Commodore64.Disk +namespace BizHawk.Emulation.Cores.Computers.Commodore64 { public class VIC1541 { diff --git a/BizHawk.Emulation/Computers/Commodore64/Experimental/C64.Glue.cs b/BizHawk.Emulation/Computers/Commodore64/Experimental/C64.Glue.cs index 84cb6681af..9a0a73cc5d 100644 --- a/BizHawk.Emulation/Computers/Commodore64/Experimental/C64.Glue.cs +++ b/BizHawk.Emulation/Computers/Commodore64/Experimental/C64.Glue.cs @@ -3,159 +3,159 @@ using System.Collections.Generic; using System.Linq; using System.Text; -namespace BizHawk.Emulation.Computers.Commodore64.Experimental +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; + 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; + 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; + 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; + //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; + //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; + //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; - } + //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 ReadCia1Cnt() + { + // this pin is not connected + return true; + } - bool ReadCia1Flag() - { - return serial.SRQ && cassette.Data; - } + bool ReadCia1Flag() + { + return serial.SRQ && cassette.Data; + } - int ReadCia1PortA() - { - return joystickB.Data & keyboard.Column; - } + int ReadCia1PortA() + { + return joystickB.Data & keyboard.Column; + } - int ReadCia1PortB() - { - return joystickA.Data & keyboard.Row; - } + 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 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; - } + int ReadCPUPort() + { + return 0xFF; + } - bool ReadHiExpansion() - { - int addr = 0xFFFF; - return (addr >= 0xDF00 && addr < 0xE000); - } + bool ReadHiExpansion() + { + int addr = 0xFFFF; + return (addr >= 0xDF00 && addr < 0xE000); + } - bool ReadIRQ() - { - return ( - cia1.IRQ && - vic.IRQ && - expansion.IRQ - ); - } + bool ReadIRQ() + { + return ( + cia1.IRQ && + vic.IRQ && + expansion.IRQ + ); + } - bool ReadLoExpansion() - { - int addr = 0xFFFF; - return (addr >= 0xDE00 && addr < 0xDF00); - } + bool ReadLoExpansion() + { + int addr = 0xFFFF; + return (addr >= 0xDE00 && addr < 0xDF00); + } - bool ReadLoRam() - { - return (cpu.Port & 0x1) != 0; - } + bool ReadLoRam() + { + return (cpu.Port & 0x1) != 0; + } - bool ReadNMI() - { - return ( - cia2.IRQ && - expansion.NMI - ); - } + bool ReadNMI() + { + return ( + cia2.IRQ && + expansion.NMI + ); + } - bool ReadSerialATN() - { - return (cia2.PortA & 0x08) != 0; - } + bool ReadSerialATN() + { + return (cia2.PortA & 0x08) != 0; + } - bool ReadSerialCLK() - { - return (cia2.PortA & 0x10) != 0; - } + bool ReadSerialCLK() + { + return (cia2.PortA & 0x10) != 0; + } - bool ReadSerialDTA() - { - return (cia2.PortA & 0x20) != 0; - } + bool ReadSerialDTA() + { + return (cia2.PortA & 0x20) != 0; + } - bool ReadUserPA2() - { - return (cia2.PortA & 0x04) != 0; - } + bool ReadUserPA2() + { + return (cia2.PortA & 0x04) != 0; + } - int ReadVicAddress() - { - //return (vic.Address | ((cia2.PortA & 0x3) << 14)); - return 0xFFFF; - } - } + int ReadVicAddress() + { + //return (vic.Address | ((cia2.PortA & 0x3) << 14)); + return 0xFFFF; + } + } } diff --git a/BizHawk.Emulation/Computers/Commodore64/Experimental/C64.cs b/BizHawk.Emulation/Computers/Commodore64/Experimental/C64.cs index cd297cd942..27e8a8dba2 100644 --- a/BizHawk.Emulation/Computers/Commodore64/Experimental/C64.cs +++ b/BizHawk.Emulation/Computers/Commodore64/Experimental/C64.cs @@ -1,132 +1,131 @@ -using BizHawk.Emulation.Computers.Commodore64.Experimental.Chips.Internals; -using System; +using System; using System.Collections.Generic; using System.Linq; using System.Text; -namespace BizHawk.Emulation.Computers.Commodore64.Experimental +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 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 C64(C64Timing timing) + { + } - public void ExecuteFrame() - { - } + public void ExecuteFrame() + { + } - public byte PeekBasicRom(int addr) - { - throw new NotImplementedException(); - } + public byte PeekBasicRom(int addr) + { + throw new NotImplementedException(); + } - public byte PeekCartridge(int addr) - { - throw new NotImplementedException(); - } + public byte PeekCartridge(int addr) + { + throw new NotImplementedException(); + } - public byte PeekCharRom(int addr) - { - throw new NotImplementedException(); - } + public byte PeekCharRom(int addr) + { + throw new NotImplementedException(); + } - public byte PeekCpu(int addr) - { - throw new NotImplementedException(); - } + public byte PeekCpu(int addr) + { + throw new NotImplementedException(); + } - public byte PeekKernalRom(int addr) - { - throw new NotImplementedException(); - } + public byte PeekKernalRom(int addr) + { + throw new NotImplementedException(); + } - public byte PeekRam(int addr) - { - throw new NotImplementedException(); - } + public byte PeekRam(int addr) + { + throw new NotImplementedException(); + } - public byte PeekSerial(int addr) - { - throw new NotImplementedException(); - } + public byte PeekSerial(int addr) + { + throw new NotImplementedException(); + } - public byte PeekSid(int addr) - { - throw new NotImplementedException(); - } + public byte PeekSid(int addr) + { + throw new NotImplementedException(); + } - public byte PeekVic(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 PokeBasicRom(int addr, byte val) + { + throw new NotImplementedException(); + } - public void PokeCartridge(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 PokeCharRom(int addr, byte val) + { + throw new NotImplementedException(); + } - public void PokeCpu(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 PokeKernalRom(int addr, byte val) + { + throw new NotImplementedException(); + } - public void PokeRam(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 PokeSerial(int addr, byte val) + { + throw new NotImplementedException(); + } - public void PokeSid(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 void PokeVic(int addr, byte val) + { + throw new NotImplementedException(); + } + } - public class C64Timing - { - } + public class C64Timing + { + } } diff --git a/BizHawk.Emulation/Computers/Commodore64/Experimental/C64Presets.NTSC.cs b/BizHawk.Emulation/Computers/Commodore64/Experimental/C64Presets.NTSC.cs index f5562b7fac..83d60dace4 100644 --- a/BizHawk.Emulation/Computers/Commodore64/Experimental/C64Presets.NTSC.cs +++ b/BizHawk.Emulation/Computers/Commodore64/Experimental/C64Presets.NTSC.cs @@ -1,42 +1,40 @@ -using BizHawk.Emulation.Computers.Commodore64.Experimental.Chips; -using BizHawk.Emulation.Computers.Commodore64.Experimental.Chips.Internals; -using System; +using System; using System.Collections.Generic; using System.Linq; using System.Text; -namespace BizHawk.Emulation.Computers.Commodore64.Experimental +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 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(); - } - } + static public C64Timing NTSCTiming() + { + return new C64Timing(); + } + } } diff --git a/BizHawk.Emulation/Computers/Commodore64/Experimental/C64Presets.PAL.cs b/BizHawk.Emulation/Computers/Commodore64/Experimental/C64Presets.PAL.cs index a033e1d7d0..0d4c0df451 100644 --- a/BizHawk.Emulation/Computers/Commodore64/Experimental/C64Presets.PAL.cs +++ b/BizHawk.Emulation/Computers/Commodore64/Experimental/C64Presets.PAL.cs @@ -1,42 +1,40 @@ -using BizHawk.Emulation.Computers.Commodore64.Experimental.Chips; -using BizHawk.Emulation.Computers.Commodore64.Experimental.Chips.Internals; -using System; +using System; using System.Collections.Generic; using System.Linq; using System.Text; -namespace BizHawk.Emulation.Computers.Commodore64.Experimental +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 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(); - } - } + static public C64Timing PALTiming() + { + return new C64Timing(); + } + } } diff --git a/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Cassette.cs b/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Cassette.cs index 90eca4a3ae..e020b0c920 100644 --- a/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Cassette.cs +++ b/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Cassette.cs @@ -5,7 +5,7 @@ using System.Text; using BizHawk.Common; -namespace BizHawk.Emulation.Computers.Commodore64.Experimental.Chips.Internals +namespace BizHawk.Emulation.Cores.Computers.Commodore64.Experimental { public class Cassette { diff --git a/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Cia.Interface.cs b/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Cia.Interface.cs index 525d813307..a6c9f8617b 100644 --- a/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Cia.Interface.cs +++ b/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Cia.Interface.cs @@ -5,7 +5,7 @@ using System.Text; using BizHawk.Common; -namespace BizHawk.Emulation.Computers.Commodore64.Experimental.Chips.Internals +namespace BizHawk.Emulation.Cores.Computers.Commodore64.Experimental { sealed public partial class Cia { diff --git a/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Cia.Internal.cs b/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Cia.Internal.cs index 7de0583667..5570f9c8d7 100644 --- a/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Cia.Internal.cs +++ b/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Cia.Internal.cs @@ -3,17 +3,17 @@ using System.Collections.Generic; using System.Linq; using System.Text; -namespace BizHawk.Emulation.Computers.Commodore64.Experimental.Chips.Internals +namespace BizHawk.Emulation.Cores.Computers.Commodore64.Experimental { - sealed public partial class Cia - { - public Cia(CiaSettings settings) - { - Reset(); - } + sealed public partial class Cia + { + public Cia(CiaSettings settings) + { + Reset(); + } - public void Reset() - { - } - } + public void Reset() + { + } + } } diff --git a/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Cia.Registers.cs b/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Cia.Registers.cs index 42b831199c..3721518bbf 100644 --- a/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Cia.Registers.cs +++ b/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Cia.Registers.cs @@ -3,27 +3,27 @@ using System.Collections.Generic; using System.Linq; using System.Text; -namespace BizHawk.Emulation.Computers.Commodore64.Experimental.Chips.Internals +namespace BizHawk.Emulation.Cores.Computers.Commodore64.Experimental { - sealed public partial class Cia - { - public int Peek(int addr) - { - return 0xFF; - } + sealed public partial class Cia + { + public int Peek(int addr) + { + return 0xFF; + } - public void Poke(int addr, int val) - { - } + public void Poke(int addr, int val) + { + } - public int Read(int addr) - { - return Peek(addr); - } + public int Read(int addr) + { + return Peek(addr); + } - public void Write(int addr, int val) - { - Poke(addr, val); - } - } + public void Write(int addr, int val) + { + Poke(addr, val); + } + } } diff --git a/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Cia.Settings.cs b/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Cia.Settings.cs index a8f2b16629..3f0ac62073 100644 --- a/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Cia.Settings.cs +++ b/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Cia.Settings.cs @@ -3,9 +3,9 @@ using System.Collections.Generic; using System.Linq; using System.Text; -namespace BizHawk.Emulation.Computers.Commodore64.Experimental.Chips.Internals +namespace BizHawk.Emulation.Cores.Computers.Commodore64.Experimental { - public class CiaSettings - { - } + public class CiaSettings + { + } } diff --git a/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Cpu.Interface.cs b/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Cpu.Interface.cs index d38cf735ca..78de172e45 100644 --- a/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Cpu.Interface.cs +++ b/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Cpu.Interface.cs @@ -5,7 +5,7 @@ using System.Text; using BizHawk.Common; -namespace BizHawk.Emulation.Computers.Commodore64.Experimental.Chips.Internals +namespace BizHawk.Emulation.Cores.Computers.Commodore64.Experimental { sealed public partial class Cpu { diff --git a/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Cpu.Internal.cs b/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Cpu.Internal.cs index 9e887631ea..4e768fb95b 100644 --- a/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Cpu.Internal.cs +++ b/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Cpu.Internal.cs @@ -4,87 +4,87 @@ using System.Collections.Generic; using System.Linq; using System.Text; -namespace BizHawk.Emulation.Computers.Commodore64.Experimental.Chips.Internals +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; + 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 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(); - } - } - } + 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); - } + 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); - } + 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)); - } - } + public void Reset() + { + delayCycles = 6; + processor.Reset(); + processor.BCD_Enabled = true; + processor.PC = (ushort)((CoreReadMemory(0xFFFD) << 8) | CoreReadMemory(0xFFFC)); + } + } } diff --git a/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Cpu.State.cs b/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Cpu.State.cs index d327f9aabc..22d923a7f2 100644 --- a/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Cpu.State.cs +++ b/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Cpu.State.cs @@ -3,7 +3,7 @@ using System.Collections.Generic; using System.Linq; using System.Text; -namespace BizHawk.Emulation.Computers.Commodore64.Experimental.Chips.Internals +namespace BizHawk.Emulation.Cores.Computers.Commodore64.Experimental { sealed public partial class Cpu { diff --git a/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Expansion.cs b/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Expansion.cs index 4124ecc69d..43fb3b44f5 100644 --- a/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Expansion.cs +++ b/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Expansion.cs @@ -5,7 +5,7 @@ using System.Text; using BizHawk.Common; -namespace BizHawk.Emulation.Computers.Commodore64.Experimental.Chips.Internals +namespace BizHawk.Emulation.Cores.Computers.Commodore64.Experimental { public class Expansion { diff --git a/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Joystick.cs b/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Joystick.cs index 8144204dc5..824e9ebf73 100644 --- a/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Joystick.cs +++ b/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Joystick.cs @@ -5,7 +5,7 @@ using System.Text; using BizHawk.Common; -namespace BizHawk.Emulation.Computers.Commodore64.Experimental.Chips.Internals +namespace BizHawk.Emulation.Cores.Computers.Commodore64.Experimental { public class Joystick { diff --git a/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Keyboard.cs b/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Keyboard.cs index 2ad3978377..d267ebd9c9 100644 --- a/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Keyboard.cs +++ b/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Keyboard.cs @@ -5,7 +5,7 @@ using System.Text; using BizHawk.Common; -namespace BizHawk.Emulation.Computers.Commodore64.Experimental.Chips.Internals +namespace BizHawk.Emulation.Cores.Computers.Commodore64.Experimental { public class Keyboard { diff --git a/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Pla.cs b/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Pla.cs index 3ad999bb9d..c181eb7f0c 100644 --- a/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Pla.cs +++ b/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Pla.cs @@ -3,322 +3,322 @@ using System.Collections.Generic; using System.Linq; using System.Text; -namespace BizHawk.Emulation.Computers.Commodore64.Experimental.Chips.Internals +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; + 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; + 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 - } + 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; + 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 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 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; - } + 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(); + 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; + 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; + // 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; - } - } + // 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; + 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; + // 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; + // 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; - } - } + // 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; + // ultimax mode ram exclusion + if (exrom && !game && ((a15 && ((!a14 && a13) || (a14 && !a13 && !a12))) || (!a15 && (a14 || (!a14 && (a12 || a13)))))) + return PLABank.None; - return PLABank.RAM; - } + return PLABank.RAM; + } - public int VicRead(int addr) - { - game = InputGame(); - exrom = InputExRom(); - a14 = (addr & 0x04000) == 0; - a13 = (addr & 0x02000) != 0; - a12 = (addr & 0x01000) != 0; + 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 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); + // read cartridge rom in ultimax mode + if (a13 && a12 && exrom && !game) + return ReadCartridgeHi(addr); - return ReadMemory(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; - } - } - } + 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/Computers/Commodore64/Experimental/Chips/Internals/Ram.cs b/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Ram.cs index b1333f06ac..520ffa530d 100644 --- a/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Ram.cs +++ b/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Ram.cs @@ -5,7 +5,7 @@ using System.Text; using BizHawk.Common; -namespace BizHawk.Emulation.Computers.Commodore64.Experimental.Chips.Internals +namespace BizHawk.Emulation.Cores.Computers.Commodore64.Experimental { sealed public class Ram { diff --git a/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Rom.cs b/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Rom.cs index c341e60a2a..0e82dcfb2e 100644 --- a/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Rom.cs +++ b/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Rom.cs @@ -5,7 +5,7 @@ using System.Text; using BizHawk.Common; -namespace BizHawk.Emulation.Computers.Commodore64.Experimental.Chips.Internals +namespace BizHawk.Emulation.Cores.Computers.Commodore64.Experimental { public class Rom { diff --git a/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Serial.cs b/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Serial.cs index 5273e5defd..2a5294d082 100644 --- a/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Serial.cs +++ b/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Serial.cs @@ -5,7 +5,7 @@ using System.Text; using BizHawk.Common; -namespace BizHawk.Emulation.Computers.Commodore64.Experimental.Chips.Internals +namespace BizHawk.Emulation.Cores.Computers.Commodore64.Experimental { public class Serial { diff --git a/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Sid.Interface.cs b/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Sid.Interface.cs index 3e62973037..dfcdec712b 100644 --- a/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Sid.Interface.cs +++ b/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Sid.Interface.cs @@ -5,7 +5,7 @@ using System.Text; using BizHawk.Common; -namespace BizHawk.Emulation.Computers.Commodore64.Experimental.Chips.Internals +namespace BizHawk.Emulation.Cores.Computers.Commodore64.Experimental { sealed public partial class Sid { diff --git a/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Sid.Internal.cs b/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Sid.Internal.cs index 86f789495f..19a79db941 100644 --- a/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Sid.Internal.cs +++ b/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Sid.Internal.cs @@ -3,23 +3,23 @@ using System.Collections.Generic; using System.Linq; using System.Text; -namespace BizHawk.Emulation.Computers.Commodore64.Experimental.Chips.Internals +namespace BizHawk.Emulation.Cores.Computers.Commodore64.Experimental { - sealed public partial class Sid - { - public Sid(SidSettings settings) - { - Reset(); - } + sealed public partial class Sid + { + public Sid(SidSettings settings) + { + Reset(); + } - public void Clock() - { - } + public void Clock() + { + } - public void Reset() - { - for (int i = 0; i < 0x20; i++) - Poke(i, 0); - } - } + public void Reset() + { + for (int i = 0; i < 0x20; i++) + Poke(i, 0); + } + } } diff --git a/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Sid.Registers.cs b/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Sid.Registers.cs index b041d2e401..09f5156ad0 100644 --- a/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Sid.Registers.cs +++ b/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Sid.Registers.cs @@ -3,27 +3,27 @@ using System.Collections.Generic; using System.Linq; using System.Text; -namespace BizHawk.Emulation.Computers.Commodore64.Experimental.Chips.Internals +namespace BizHawk.Emulation.Cores.Computers.Commodore64.Experimental { - sealed public partial class Sid - { - public int Peek(int addr) - { - return 0xFF; - } + sealed public partial class Sid + { + public int Peek(int addr) + { + return 0xFF; + } - public void Poke(int addr, int val) - { - } + public void Poke(int addr, int val) + { + } - public int Read(int addr) - { - return Peek(addr); - } + public int Read(int addr) + { + return Peek(addr); + } - public void Write(int addr, int val) - { - Poke(addr, val); - } - } + public void Write(int addr, int val) + { + Poke(addr, val); + } + } } diff --git a/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Sid.Settings.cs b/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Sid.Settings.cs index 270f79df4f..258bbd9a5a 100644 --- a/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Sid.Settings.cs +++ b/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Sid.Settings.cs @@ -3,9 +3,9 @@ using System.Collections.Generic; using System.Linq; using System.Text; -namespace BizHawk.Emulation.Computers.Commodore64.Experimental.Chips.Internals +namespace BizHawk.Emulation.Cores.Computers.Commodore64.Experimental { - public class SidSettings - { - } + public class SidSettings + { + } } diff --git a/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Sid.SoundProvider.cs b/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Sid.SoundProvider.cs index 33d9290b0b..f4b048dbdf 100644 --- a/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Sid.SoundProvider.cs +++ b/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Sid.SoundProvider.cs @@ -5,7 +5,7 @@ using System.Text; using BizHawk.Emulation.Common; -namespace BizHawk.Emulation.Computers.Commodore64.Experimental.Chips.Internals +namespace BizHawk.Emulation.Cores.Computers.Commodore64.Experimental { sealed public partial class Sid { diff --git a/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Userport.cs b/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Userport.cs index e13b9f079c..3989f79b5e 100644 --- a/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Userport.cs +++ b/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Userport.cs @@ -3,36 +3,36 @@ using System.Collections.Generic; using System.Linq; using System.Text; -namespace BizHawk.Emulation.Computers.Commodore64.Experimental.Chips.Internals +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; + 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; } } - } + 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/Computers/Commodore64/Experimental/Chips/Internals/Vic.Graphics.cs b/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Vic.Graphics.cs index 8ce8b6ed03..ab07ee145b 100644 --- a/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Vic.Graphics.cs +++ b/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Vic.Graphics.cs @@ -6,150 +6,150 @@ 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.Computers.Commodore64.Experimental.Chips.Internals +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; + 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 - } + 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; + 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; + 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) - ; + 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) - ; + // 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); - } - } - } + 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; + 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; - } + 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; - } + 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; - } - } + 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/Computers/Commodore64/Experimental/Chips/Internals/Vic.Interface.cs b/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Vic.Interface.cs index 1be2fbbf1b..41d47faad8 100644 --- a/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Vic.Interface.cs +++ b/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Vic.Interface.cs @@ -3,28 +3,28 @@ using System.Collections.Generic; using System.Linq; using System.Text; -namespace BizHawk.Emulation.Computers.Commodore64.Experimental.Chips.Internals +namespace BizHawk.Emulation.Cores.Computers.Commodore64.Experimental { - sealed public partial class Vic - { - // inputs - public Action ClockPhi0; - public Func ReadColorRam; - public Func ReadRam; + 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; } + // 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; } } - } + // 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/Computers/Commodore64/Experimental/Chips/Internals/Vic.Internal.cs b/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Vic.Internal.cs index b2f52f7b6b..b6ab166fe0 100644 --- a/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Vic.Internal.cs +++ b/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Vic.Internal.cs @@ -6,28 +6,28 @@ 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.Computers.Commodore64.Experimental.Chips.Internals +namespace BizHawk.Emulation.Cores.Computers.Commodore64.Experimental { - sealed public partial class Vic - { - int address; - bool aec; - bool ba; - int data; - int phi1Data; - int rasterX; + sealed public partial class Vic + { + int address; + bool aec; + bool ba; + int data; + int phi1Data; + int rasterX; - public Vic(VicSettings settings) - { - } + public Vic(VicSettings settings) + { + } - public void Clock() - { - Render(); - } + public void Clock() + { + Render(); + } - public void Reset() - { - } - } + public void Reset() + { + } + } } diff --git a/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Vic.Registers.cs b/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Vic.Registers.cs index 28d8e4d4df..4a1ab55dde 100644 --- a/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Vic.Registers.cs +++ b/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Vic.Registers.cs @@ -5,424 +5,424 @@ using System.Text; #pragma warning disable 649 //adelikat: Disable dumb warnings until this file is complete -namespace BizHawk.Emulation.Computers.Commodore64.Experimental.Chips.Internals +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; + 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 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 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 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 void PokeByte(int addr, byte val) + { + Poke(addr, val); + } - public int Read(int addr) - { - int result; - addr &= 0x3F; + 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); - } - } + 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 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 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); - } - } + public void WriteByte(int addr, byte val) + { + Write(addr, val); + } + } } diff --git a/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Vic.Settings.cs b/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Vic.Settings.cs index e222828152..960cc2646c 100644 --- a/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Vic.Settings.cs +++ b/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Vic.Settings.cs @@ -3,9 +3,9 @@ using System.Collections.Generic; using System.Linq; using System.Text; -namespace BizHawk.Emulation.Computers.Commodore64.Experimental.Chips.Internals +namespace BizHawk.Emulation.Cores.Computers.Commodore64.Experimental { - sealed public class VicSettings - { - } + sealed public class VicSettings + { + } } diff --git a/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Vic.Sprite.cs b/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Vic.Sprite.cs index 3cd96b6b08..7ecaaa8d15 100644 --- a/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Vic.Sprite.cs +++ b/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Vic.Sprite.cs @@ -5,123 +5,123 @@ using System.Text; #pragma warning disable 649 //adelikat: Disable dumb warnings until this file is complete -namespace BizHawk.Emulation.Computers.Commodore64.Experimental.Chips.Internals +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; + 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; - 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; + sealed class Sprite + { + public bool CrunchMC; + public bool CrunchX; + public bool CrunchY; + public bool Display; + public int ShiftRegister; + public bool ShiftRegisterEnable; - public Sprite() - { - } + 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 void Clock() - { - } + public Sprite() + { + } - public void LoadP(int value) - { - } + public void Clock() + { + } - public void LoadS(int value) - { - } - } + public void LoadP(int value) + { + } - Sprite s_CollideSprite; - int s_Data; - bool s_OutData; - int s_OutPixel; - bool s_Priority; - Sprite[] sprites; + public void LoadS(int value) + { + } + } - void RenderSprites() - { - s_OutData = false; - s_CollideSprite = null; + Sprite s_CollideSprite; + int s_Data; + bool s_OutData; + int s_OutPixel; + bool s_Priority; + Sprite[] sprites; - foreach (Sprite sprite in sprites) - { - if (sprite.Display && rasterX == sprite.X) - sprite.ShiftRegisterEnable = true; + void RenderSprites() + { + s_OutData = false; + s_CollideSprite = null; - 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; + foreach (Sprite sprite in sprites) + { + if (sprite.Display && rasterX == sprite.X) + sprite.ShiftRegisterEnable = true; - if (sprite.Multicolor) - s_Data = sprite.ShiftRegister & SPRITE_DATA_11; - else - s_Data = (sprite.ShiftRegister << 1) & SPRITE_DATA_10; + 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 (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 (sprite.Multicolor) + s_Data = sprite.ShiftRegister & SPRITE_DATA_11; + else + s_Data = (sprite.ShiftRegister << 1) & SPRITE_DATA_10; - 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_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 && g_OutData >= GRAPHICS_DATA_10) - { - sprite.DataCollision = true; - dataCollisionInterrupt = true; - } + 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 (sprite.CrunchMC && sprite.CrunchX) - sprite.ShiftRegister <<= sprite.Multicolor ? 2 : 1; - } - } - } - } - } + 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/Computers/Commodore64/Experimental/Chips/Internals/Vic.State.cs b/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Vic.State.cs index fb9c94d1a7..c9d8c3faa5 100644 --- a/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Vic.State.cs +++ b/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Vic.State.cs @@ -5,7 +5,7 @@ using System.Text; using BizHawk.Common; -namespace BizHawk.Emulation.Computers.Commodore64.Experimental.Chips.Internals +namespace BizHawk.Emulation.Cores.Computers.Commodore64.Experimental { sealed public partial class Vic { diff --git a/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Vic.Synth.cs b/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Vic.Synth.cs index 162d344177..cde4252d53 100644 --- a/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Vic.Synth.cs +++ b/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Vic.Synth.cs @@ -3,28 +3,28 @@ using System.Collections.Generic; using System.Linq; using System.Text; -namespace BizHawk.Emulation.Computers.Commodore64.Experimental.Chips.Internals +namespace BizHawk.Emulation.Cores.Computers.Commodore64.Experimental { - sealed public partial class Vic - { - int v_Pixel; + sealed public partial class Vic + { + int v_Pixel; - public void Render() - { - RenderGraphics(); - RenderSprites(); + 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; - } - } - } + 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/Computers/Commodore64/Experimental/Chips/Internals/Vic.Timing.cs b/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Vic.Timing.cs index 34ecf16865..267a51e5f9 100644 --- a/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Vic.Timing.cs +++ b/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Vic.Timing.cs @@ -6,81 +6,81 @@ 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.Computers.Commodore64.Experimental.Chips.Internals +namespace BizHawk.Emulation.Cores.Computers.Commodore64.Experimental { - sealed public class VicColumnState - { - public VicBAType BA; - public VicFetchType Fetch; - public bool HBlank; - public int RasterX; - } + 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 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 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 VicFetchType + { + None, + Graphics, + Color, + Idle, + Refresh, + Sprite, + Pointer + } - public enum VicRowType - { - None, - ScreenVisible, - ScreenBlank, - ResetVCBase - } + 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; - } + 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/Computers/Commodore64/Experimental/Chips/Internals/Vic.VideoProvider.cs b/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Vic.VideoProvider.cs index 650bf5c9c9..8b269d8c29 100644 --- a/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Vic.VideoProvider.cs +++ b/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Vic.VideoProvider.cs @@ -8,7 +8,7 @@ using BizHawk.Emulation.Common; #pragma warning disable 649 //adelikat: Disable dumb warnings until this file is complete -namespace BizHawk.Emulation.Computers.Commodore64.Experimental.Chips.Internals +namespace BizHawk.Emulation.Cores.Computers.Commodore64.Experimental { sealed public partial class Vic : IVideoProvider { diff --git a/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Presets.cs b/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Presets.cs index 26534f2b1a..aca7e84ba9 100644 --- a/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Presets.cs +++ b/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Presets.cs @@ -1,59 +1,58 @@ -using BizHawk.Emulation.Computers.Commodore64.Experimental.Chips.Internals; -using System; +using System; using System.Collections.Generic; using System.Linq; using System.Text; -namespace BizHawk.Emulation.Computers.Commodore64.Experimental.Chips +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 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 Settings6526(bool todJumper) + { + CiaSettings result = new CiaSettings(); + return result; + } - static private CiaSettings Settings6526A(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 Settings6567() + { + VicSettings result = new VicSettings(); + return result; + } - static private VicSettings Settings6569() - { - 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 Settings6581() + { + SidSettings result = new SidSettings(); + return result; + } - static private SidSettings Settings8580() - { - SidSettings result = new SidSettings(); - return result; - } - } + static private SidSettings Settings8580() + { + SidSettings result = new SidSettings(); + return result; + } + } } diff --git a/BizHawk.Emulation/Computers/Commodore64/Experimental/IMotherboard.cs b/BizHawk.Emulation/Computers/Commodore64/Experimental/IMotherboard.cs index 032d0b6aa3..25dea88804 100644 --- a/BizHawk.Emulation/Computers/Commodore64/Experimental/IMotherboard.cs +++ b/BizHawk.Emulation/Computers/Commodore64/Experimental/IMotherboard.cs @@ -3,30 +3,30 @@ using System.Collections.Generic; using System.Linq; using System.Text; -namespace BizHawk.Emulation.Computers.Commodore64.Experimental +namespace BizHawk.Emulation.Cores.Computers.Commodore64.Experimental { - public interface IMotherboard - { - void ExecuteFrame(); + 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); + 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); - } + 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/Computers/Commodore64/InputFileInfo.cs b/BizHawk.Emulation/Computers/Commodore64/InputFileInfo.cs index f8686553b9..ecbea24aa3 100644 --- a/BizHawk.Emulation/Computers/Commodore64/InputFileInfo.cs +++ b/BizHawk.Emulation/Computers/Commodore64/InputFileInfo.cs @@ -3,11 +3,11 @@ using System.Collections.Generic; using System.Linq; using System.Text; -namespace BizHawk.Emulation.Computers.Commodore64 +namespace BizHawk.Emulation.Cores.Computers.Commodore64 { - public struct InputFileInfo - { - public byte[] Data; - public string Extension; - } + public struct InputFileInfo + { + public byte[] Data; + public string Extension; + } } diff --git a/BizHawk.Emulation/Computers/Commodore64/MOS/CartridgePort.cs b/BizHawk.Emulation/Computers/Commodore64/MOS/CartridgePort.cs index 70a8898647..462605b6ee 100644 --- a/BizHawk.Emulation/Computers/Commodore64/MOS/CartridgePort.cs +++ b/BizHawk.Emulation/Computers/Commodore64/MOS/CartridgePort.cs @@ -1,9 +1,7 @@ using System; - using BizHawk.Common; -using BizHawk.Emulation.Computers.Commodore64.Cartridge; -namespace BizHawk.Emulation.Computers.Commodore64.MOS +namespace BizHawk.Emulation.Cores.Computers.Commodore64 { sealed public class CartridgePort { diff --git a/BizHawk.Emulation/Computers/Commodore64/MOS/CassettePort.cs b/BizHawk.Emulation/Computers/Commodore64/MOS/CassettePort.cs index 069db6bea5..79132d4c3b 100644 --- a/BizHawk.Emulation/Computers/Commodore64/MOS/CassettePort.cs +++ b/BizHawk.Emulation/Computers/Commodore64/MOS/CassettePort.cs @@ -1,7 +1,7 @@ using System; using BizHawk.Common; -namespace BizHawk.Emulation.Computers.Commodore64.MOS +namespace BizHawk.Emulation.Cores.Computers.Commodore64 { public class CassettePort { diff --git a/BizHawk.Emulation/Computers/Commodore64/MOS/Chip2114.cs b/BizHawk.Emulation/Computers/Commodore64/MOS/Chip2114.cs index 0f47ce0c88..05756e31ce 100644 --- a/BizHawk.Emulation/Computers/Commodore64/MOS/Chip2114.cs +++ b/BizHawk.Emulation/Computers/Commodore64/MOS/Chip2114.cs @@ -1,6 +1,6 @@ using BizHawk.Common; -namespace BizHawk.Emulation.Computers.Commodore64.MOS +namespace BizHawk.Emulation.Cores.Computers.Commodore64 { // used as Color RAM in C64 diff --git a/BizHawk.Emulation/Computers/Commodore64/MOS/Chip23XX.cs b/BizHawk.Emulation/Computers/Commodore64/MOS/Chip23XX.cs index e1cdb39842..3575da635d 100644 --- a/BizHawk.Emulation/Computers/Commodore64/MOS/Chip23XX.cs +++ b/BizHawk.Emulation/Computers/Commodore64/MOS/Chip23XX.cs @@ -1,24 +1,24 @@ using System; using BizHawk.Common; -namespace BizHawk.Emulation.Computers.Commodore64.MOS +namespace BizHawk.Emulation.Cores.Computers.Commodore64 { // ROM chips // 2332: 32 kbit (4kbyte) // 2364: 64 kbit (8kbyte) // 23128: 128 kbit (16kbyte) - public enum Chip23XXmodel + public enum Chip23XXmodel { Chip2332, Chip2364, Chip23128 } - sealed public class Chip23XX + sealed public class Chip23XX { - int addrMask; - byte[] rom; + int addrMask; + byte[] rom; public Chip23XX(Chip23XXmodel model, byte[] data) { @@ -55,6 +55,6 @@ namespace BizHawk.Emulation.Computers.Commodore64.MOS public void SyncState(Serializer ser) { SaveState.SyncObject(ser, this); - } + } } } diff --git a/BizHawk.Emulation/Computers/Commodore64/MOS/Chip4864.cs b/BizHawk.Emulation/Computers/Commodore64/MOS/Chip4864.cs index 83afb637ae..536e509f12 100644 --- a/BizHawk.Emulation/Computers/Commodore64/MOS/Chip4864.cs +++ b/BizHawk.Emulation/Computers/Commodore64/MOS/Chip4864.cs @@ -1,6 +1,6 @@ using BizHawk.Common; -namespace BizHawk.Emulation.Computers.Commodore64.MOS +namespace BizHawk.Emulation.Cores.Computers.Commodore64 { // DRAM for the c64 // 4164 = 64 kbit diff --git a/BizHawk.Emulation/Computers/Commodore64/MOS/MOS6510.cs b/BizHawk.Emulation/Computers/Commodore64/MOS/MOS6510.cs index 67b65b274c..7942d98f12 100644 --- a/BizHawk.Emulation/Computers/Commodore64/MOS/MOS6510.cs +++ b/BizHawk.Emulation/Computers/Commodore64/MOS/MOS6510.cs @@ -5,7 +5,7 @@ using System.Runtime.InteropServices; using BizHawk.Common; -namespace BizHawk.Emulation.Computers.Commodore64.MOS +namespace BizHawk.Emulation.Cores.Computers.Commodore64 { // an extension of the 6502 processor diff --git a/BizHawk.Emulation/Computers/Commodore64/MOS/MOS6522.cs b/BizHawk.Emulation/Computers/Commodore64/MOS/MOS6522.cs index 7d3c0ce0ff..070a294016 100644 --- a/BizHawk.Emulation/Computers/Commodore64/MOS/MOS6522.cs +++ b/BizHawk.Emulation/Computers/Commodore64/MOS/MOS6522.cs @@ -1,7 +1,7 @@ using System; #if false -namespace BizHawk.Emulation.Computers.Commodore64.MOS +namespace BizHawk.Emulation.Cores.Computers.Commodore64 { // via public class MOS6522 : Timer diff --git a/BizHawk.Emulation/Computers/Commodore64/MOS/MOS6526.cs b/BizHawk.Emulation/Computers/Commodore64/MOS/MOS6526.cs index 5a61e239b4..969b9c2597 100644 --- a/BizHawk.Emulation/Computers/Commodore64/MOS/MOS6526.cs +++ b/BizHawk.Emulation/Computers/Commodore64/MOS/MOS6526.cs @@ -1,7 +1,7 @@ using System; using BizHawk.Common; -namespace BizHawk.Emulation.Computers.Commodore64.MOS +namespace BizHawk.Emulation.Cores.Computers.Commodore64 { // MOS technology 6526 "CIA" // @@ -9,11 +9,11 @@ namespace BizHawk.Emulation.Computers.Commodore64.MOS // * CS, R/W and RS# pins are not emulated. (not needed) // * A low RES pin is emulated via HardReset(). - sealed public class MOS6526 + sealed public class MOS6526 { // ------------------------------------ - enum InMode + enum InMode { Phase2, CNT, @@ -21,36 +21,36 @@ namespace BizHawk.Emulation.Computers.Commodore64.MOS TimerAUnderflowCNT } - enum OutMode + enum OutMode { Pulse, Toggle } - enum RunMode + enum RunMode { Continuous, Oneshot } - enum SPMode + enum SPMode { Input, Output } - static byte[] PBOnBit = new byte[] { 0x40, 0x80 }; - static byte[] PBOnMask = new byte[] { 0xBF, 0x7F }; + static byte[] PBOnBit = new byte[] { 0x40, 0x80 }; + static byte[] PBOnMask = new byte[] { 0xBF, 0x7F }; // ------------------------------------ - public Func ReadCNT; - public Func ReadFlag; - public Func ReadSP; + public Func ReadCNT; + public Func ReadFlag; + public Func ReadSP; - // ------------------------------------ + // ------------------------------------ - bool alarmSelect; + bool alarmSelect; Region chipRegion; bool cntPos; bool enableIntAlarm; @@ -62,9 +62,9 @@ namespace BizHawk.Emulation.Computers.Commodore64.MOS bool intSP; bool[] intTimer; bool pinCnt; - bool pinCntLast; - bool pinPC; - bool pinSP; + bool pinCntLast; + bool pinPC; + bool pinSP; byte sr; int[] timerDelay; InMode[] timerInMode; @@ -98,47 +98,47 @@ namespace BizHawk.Emulation.Computers.Commodore64.MOS todAlarm = new byte[4]; SetTodIn(chipRegion); - portA = new LatchedPort(); - portB = new LatchedPort(); - timer = new int[2]; - timerLatch = new int[2]; - timerOn = new bool[2]; - underflow = new bool[2]; + portA = new LatchedPort(); + portB = new LatchedPort(); + timer = new int[2]; + timerLatch = new int[2]; + timerOn = new bool[2]; + underflow = new bool[2]; - pinSP = true; - } + pinSP = true; + } // ------------------------------------ public void ExecutePhase1() { // unsure if the timer actually operates in ph1 - pinIRQ = !( - (intTimer[0] && enableIntTimer[0]) || - (intTimer[1] && enableIntTimer[1]) || - (intAlarm && enableIntAlarm) || - (intSP && enableIntSP) || - (intFlag && enableIntFlag) - ); - } + pinIRQ = !( + (intTimer[0] && enableIntTimer[0]) || + (intTimer[1] && enableIntTimer[1]) || + (intAlarm && enableIntAlarm) || + (intSP && enableIntSP) || + (intFlag && enableIntFlag) + ); + } public void ExecutePhase2() { { - bool sumCnt = ReadCNT(); - cntPos |= (!pinCntLast && sumCnt); - pinCntLast = sumCnt; + bool sumCnt = ReadCNT(); + cntPos |= (!pinCntLast && sumCnt); + pinCntLast = sumCnt; - pinPC = true; - TODRun(); + pinPC = true; + TODRun(); if (timerPulse[0]) { - portA.Latch &= PBOnMask[0]; + portA.Latch &= PBOnMask[0]; } if (timerPulse[1]) { - portB.Latch &= PBOnMask[1]; + portB.Latch &= PBOnMask[1]; } if (timerDelay[0] == 0) @@ -209,7 +209,7 @@ namespace BizHawk.Emulation.Computers.Commodore64.MOS pinCnt = false; pinPC = true; - } + } private void SetTodIn(Region region) { @@ -230,7 +230,7 @@ namespace BizHawk.Emulation.Computers.Commodore64.MOS private byte BCDAdd(byte i, byte j, out bool overflow) { - + { int lo; int hi; @@ -255,13 +255,13 @@ namespace BizHawk.Emulation.Computers.Commodore64.MOS private void TimerRun(int index) { - + { if (timerOn[index]) { int t = timer[index]; bool u = false; - + { switch (timerInMode[index]) { @@ -270,8 +270,8 @@ namespace BizHawk.Emulation.Computers.Commodore64.MOS if (cntPos) { t--; - u = (t == 0); - intTimer[index] |= (t == 0); + u = (t == 0); + intTimer[index] |= (t == 0); } break; case InMode.Phase2: @@ -285,8 +285,8 @@ namespace BizHawk.Emulation.Computers.Commodore64.MOS if (underflow[0]) { t--; - u = (t == 0); - intTimer[index] |= (t == 0); + u = (t == 0); + intTimer[index] |= (t == 0); } break; case InMode.TimerAUnderflowCNT: @@ -294,8 +294,8 @@ namespace BizHawk.Emulation.Computers.Commodore64.MOS if (underflow[0] && pinCnt) { t--; - u = (t == 0); - intTimer[index] |= (t == 0); + u = (t == 0); + intTimer[index] |= (t == 0); } break; } @@ -303,23 +303,23 @@ namespace BizHawk.Emulation.Computers.Commodore64.MOS // underflow? if (u) { - timerDelay[index] = 1; - t = timerLatch[index]; + timerDelay[index] = 1; + t = timerLatch[index]; if (timerRunMode[index] == RunMode.Oneshot) timerOn[index] = false; if (timerPortEnable[index]) { // force port B bit to output - portB.Direction |= PBOnBit[index]; + portB.Direction |= PBOnBit[index]; switch (timerOutMode[index]) { case OutMode.Pulse: timerPulse[index] = true; - portB.Latch |= PBOnBit[index]; + portB.Latch |= PBOnBit[index]; break; case OutMode.Toggle: - portB.Latch ^= PBOnBit[index]; + portB.Latch ^= PBOnBit[index]; break; } } @@ -334,7 +334,7 @@ namespace BizHawk.Emulation.Computers.Commodore64.MOS private void TODRun() { - + { bool todV; @@ -416,15 +416,15 @@ namespace BizHawk.Emulation.Computers.Commodore64.MOS return val; } - public bool ReadCNTBuffer() - { - return pinCnt; - } + public bool ReadCNTBuffer() + { + return pinCnt; + } - public bool ReadPCBuffer() - { - return pinPC; - } + public bool ReadPCBuffer() + { + return pinPC; + } private byte ReadRegister(int addr) { @@ -440,10 +440,10 @@ namespace BizHawk.Emulation.Computers.Commodore64.MOS val = (byte)(portB.ReadInput(ReadPortB()) & PortBMask); break; case 0x2: - val = portA.Direction; + val = portA.Direction; break; case 0x3: - val = portB.Direction; + val = portB.Direction; break; case 0x4: timerVal = ReadTimerValue(0); @@ -527,10 +527,10 @@ namespace BizHawk.Emulation.Computers.Commodore64.MOS return val; } - public bool ReadSPBuffer() - { - return pinSP; - } + public bool ReadSPBuffer() + { + return pinSP; + } private int ReadTimerValue(int index) { @@ -549,7 +549,7 @@ namespace BizHawk.Emulation.Computers.Commodore64.MOS public void SyncState(Serializer ser) { - SaveState.SyncObject(ser, this); + SaveState.SyncObject(ser, this); } public void Write(int addr, byte val) @@ -602,16 +602,16 @@ namespace BizHawk.Emulation.Computers.Commodore64.MOS switch (addr) { case 0x0: - portA.Latch = val; + portA.Latch = val; break; case 0x1: - portB.Latch = val; + portB.Latch = val; break; case 0x2: - portA.Direction = val; + portA.Direction = val; break; case 0x3: - portB.Direction = val; + portB.Direction = val; break; case 0x4: timerLatch[0] &= 0xFF00; @@ -707,13 +707,13 @@ namespace BizHawk.Emulation.Computers.Commodore64.MOS // ------------------------------------ - public byte PortAMask = 0xFF; - public byte PortBMask = 0xFF; + public byte PortAMask = 0xFF; + public byte PortBMask = 0xFF; bool pinIRQ; - LatchedPort portA; - LatchedPort portB; - int[] timer; + LatchedPort portA; + LatchedPort portB; + int[] timer; int[] timerLatch; bool[] timerOn; bool[] underflow; @@ -730,54 +730,54 @@ namespace BizHawk.Emulation.Computers.Commodore64.MOS pinIRQ = true; } - public byte PortAData - { - get - { - return portA.ReadOutput(); - } - } + public byte PortAData + { + get + { + return portA.ReadOutput(); + } + } - public byte PortADirection - { - get - { - return portA.Direction; - } - } + public byte PortADirection + { + get + { + return portA.Direction; + } + } - public byte PortALatch - { - get - { - return portA.Latch; - } - } + public byte PortALatch + { + get + { + return portA.Latch; + } + } - public byte PortBData - { - get - { - return portB.ReadOutput(); - } - } + public byte PortBData + { + get + { + return portB.ReadOutput(); + } + } - public byte PortBDirection - { - get - { - return portB.Direction; - } - } + public byte PortBDirection + { + get + { + return portB.Direction; + } + } - public byte PortBLatch - { - get - { - return portB.Latch; - } - } + public byte PortBLatch + { + get + { + return portB.Latch; + } + } - public bool ReadIRQBuffer() { return pinIRQ; } - } + public bool ReadIRQBuffer() { return pinIRQ; } + } } diff --git a/BizHawk.Emulation/Computers/Commodore64/MOS/MOS6567.cs b/BizHawk.Emulation/Computers/Commodore64/MOS/MOS6567.cs index fdbb852026..7a346f446b 100644 --- a/BizHawk.Emulation/Computers/Commodore64/MOS/MOS6567.cs +++ b/BizHawk.Emulation/Computers/Commodore64/MOS/MOS6567.cs @@ -1,25 +1,25 @@ using System.Drawing; -namespace BizHawk.Emulation.Computers.Commodore64.MOS +namespace BizHawk.Emulation.Cores.Computers.Commodore64 { // vic ntsc static public class MOS6567 { - static int cycles = 65; - static int scanwidth = cycles * 8; - static int lines = 263; - static int vblankstart = 0x00D % lines; - static int vblankend = 0x018 % lines; - static int hblankoffset = 20; - static int hblankstart = (0x18C + hblankoffset) % scanwidth; - static int hblankend = (0x1F0 + hblankoffset) % scanwidth; + static int cycles = 65; + static int scanwidth = cycles * 8; + static int lines = 263; + static int vblankstart = 0x00D % lines; + static int vblankend = 0x018 % lines; + static int hblankoffset = 20; + static int hblankstart = (0x18C + hblankoffset) % scanwidth; + static int hblankend = (0x1F0 + hblankoffset) % scanwidth; - static int[] timing = Vic.TimingBuilder_XRaster(0x19C, 0x200, scanwidth, 0x18C, 8); - static int[] fetch = Vic.TimingBuilder_Fetch(timing, 0x174); - static int[] ba = Vic.TimingBuilder_BA(fetch); - static int[] act = Vic.TimingBuilder_Act(timing, 0x004, 0x14C, hblankstart, hblankend); + static int[] timing = Vic.TimingBuilder_XRaster(0x19C, 0x200, scanwidth, 0x18C, 8); + static int[] fetch = Vic.TimingBuilder_Fetch(timing, 0x174); + static int[] ba = Vic.TimingBuilder_BA(fetch); + static int[] act = Vic.TimingBuilder_Act(timing, 0x004, 0x14C, hblankstart, hblankend); - static int[][] pipeline = new int[][] + static int[][] pipeline = new int[][] { timing, fetch, @@ -27,15 +27,15 @@ namespace BizHawk.Emulation.Computers.Commodore64.MOS act }; - static public Vic Create() - { - return new Vic( - cycles, lines, - pipeline, - 14318181 / 14, - hblankstart, hblankend, - vblankstart, vblankend - ); - } + static public Vic Create() + { + return new Vic( + cycles, lines, + pipeline, + 14318181 / 14, + hblankstart, hblankend, + vblankstart, vblankend + ); + } } } diff --git a/BizHawk.Emulation/Computers/Commodore64/MOS/MOS6569.cs b/BizHawk.Emulation/Computers/Commodore64/MOS/MOS6569.cs index 80e2d10c19..6491e75a03 100644 --- a/BizHawk.Emulation/Computers/Commodore64/MOS/MOS6569.cs +++ b/BizHawk.Emulation/Computers/Commodore64/MOS/MOS6569.cs @@ -1,41 +1,41 @@ using System.Drawing; -namespace BizHawk.Emulation.Computers.Commodore64.MOS +namespace BizHawk.Emulation.Cores.Computers.Commodore64 { // vic pal static public class MOS6569 { - static int cycles = 63; - static int scanwidth = cycles * 8; - static int lines = 312; - static int vblankstart = 0x12C % lines; - static int vblankend = 0x00F % lines; - static int hblankoffset = 20; - static int hblankstart = (0x17C + hblankoffset) % scanwidth; - static int hblankend = (0x1E0 + hblankoffset) % scanwidth; + static int cycles = 63; + static int scanwidth = cycles * 8; + static int lines = 312; + static int vblankstart = 0x12C % lines; + static int vblankend = 0x00F % lines; + static int hblankoffset = 20; + static int hblankstart = (0x17C + hblankoffset) % scanwidth; + static int hblankend = (0x1E0 + hblankoffset) % scanwidth; - static int[] timing = Vic.TimingBuilder_XRaster(0x194, 0x1F8, scanwidth, -1, -1); - static int[] fetch = Vic.TimingBuilder_Fetch(timing, 0x164); - static int[] ba = Vic.TimingBuilder_BA(fetch); - static int[] act = Vic.TimingBuilder_Act(timing, 0x004, 0x14C, hblankstart, hblankend); + static int[] timing = Vic.TimingBuilder_XRaster(0x194, 0x1F8, scanwidth, -1, -1); + static int[] fetch = Vic.TimingBuilder_Fetch(timing, 0x164); + static int[] ba = Vic.TimingBuilder_BA(fetch); + static int[] act = Vic.TimingBuilder_Act(timing, 0x004, 0x14C, hblankstart, hblankend); - static int[][] pipeline = new int[][] + static int[][] pipeline = new int[][] { timing, fetch, ba, - act + act }; - static public Vic Create() - { - return new Vic( - cycles, lines, - pipeline, - 17734472 / 18, - hblankstart, hblankend, - vblankstart, vblankend - ); - } + static public Vic Create() + { + return new Vic( + cycles, lines, + pipeline, + 17734472 / 18, + hblankstart, hblankend, + vblankstart, vblankend + ); + } } } diff --git a/BizHawk.Emulation/Computers/Commodore64/MOS/MOS6581.cs b/BizHawk.Emulation/Computers/Commodore64/MOS/MOS6581.cs index 2b41cfa23c..5c88e5a2f1 100644 --- a/BizHawk.Emulation/Computers/Commodore64/MOS/MOS6581.cs +++ b/BizHawk.Emulation/Computers/Commodore64/MOS/MOS6581.cs @@ -1,9 +1,9 @@ -namespace BizHawk.Emulation.Computers.Commodore64.MOS +namespace BizHawk.Emulation.Cores.Computers.Commodore64 { // sid static public class MOS6581 { - static int[][] waveTable = new int[][] + static int[][] waveTable = new int[][] { new int[] { 0xFFF, 0xFFF, 0xFFF, 0xFFF, 0xFFF, 0xFFF, 0xFFF, 0xFFF, diff --git a/BizHawk.Emulation/Computers/Commodore64/MOS/MOSPLA.cs b/BizHawk.Emulation/Computers/Commodore64/MOS/MOSPLA.cs index 91029579e9..ef95c9e125 100644 --- a/BizHawk.Emulation/Computers/Commodore64/MOS/MOSPLA.cs +++ b/BizHawk.Emulation/Computers/Commodore64/MOS/MOSPLA.cs @@ -1,7 +1,7 @@ using System; using BizHawk.Common; -namespace BizHawk.Emulation.Computers.Commodore64.MOS +namespace BizHawk.Emulation.Cores.Computers.Commodore64 { // emulates the PLA // which handles all bank switching diff --git a/BizHawk.Emulation/Computers/Commodore64/MOS/Port.cs b/BizHawk.Emulation/Computers/Commodore64/MOS/Port.cs index eef6ed3ea0..df00275241 100644 --- a/BizHawk.Emulation/Computers/Commodore64/MOS/Port.cs +++ b/BizHawk.Emulation/Computers/Commodore64/MOS/Port.cs @@ -1,7 +1,7 @@ using System; using BizHawk.Common; -namespace BizHawk.Emulation.Computers.Commodore64.MOS +namespace BizHawk.Emulation.Cores.Computers.Commodore64 { sealed public class LatchedPort { diff --git a/BizHawk.Emulation/Computers/Commodore64/MOS/SerialPort.cs b/BizHawk.Emulation/Computers/Commodore64/MOS/SerialPort.cs index 3e8a5af14a..0a5f6e510f 100644 --- a/BizHawk.Emulation/Computers/Commodore64/MOS/SerialPort.cs +++ b/BizHawk.Emulation/Computers/Commodore64/MOS/SerialPort.cs @@ -1,7 +1,7 @@ using System; using BizHawk.Common; -namespace BizHawk.Emulation.Computers.Commodore64.MOS +namespace BizHawk.Emulation.Cores.Computers.Commodore64 { // the functions on this port are at the point of // view of an external device. diff --git a/BizHawk.Emulation/Computers/Commodore64/MOS/Sid.Envelope.cs b/BizHawk.Emulation/Computers/Commodore64/MOS/Sid.Envelope.cs index 711c2b58ed..a1cb38dd90 100644 --- a/BizHawk.Emulation/Computers/Commodore64/MOS/Sid.Envelope.cs +++ b/BizHawk.Emulation/Computers/Commodore64/MOS/Sid.Envelope.cs @@ -5,7 +5,7 @@ using System.Text; using BizHawk.Common; -namespace BizHawk.Emulation.Computers.Commodore64.MOS +namespace BizHawk.Emulation.Cores.Computers.Commodore64 { sealed public partial class Sid { diff --git a/BizHawk.Emulation/Computers/Commodore64/MOS/Sid.Voice.cs b/BizHawk.Emulation/Computers/Commodore64/MOS/Sid.Voice.cs index 8436b1ae3f..ad1b74af44 100644 --- a/BizHawk.Emulation/Computers/Commodore64/MOS/Sid.Voice.cs +++ b/BizHawk.Emulation/Computers/Commodore64/MOS/Sid.Voice.cs @@ -5,7 +5,7 @@ using System.Text; using BizHawk.Common; -namespace BizHawk.Emulation.Computers.Commodore64.MOS +namespace BizHawk.Emulation.Cores.Computers.Commodore64 { sealed public partial class Sid { diff --git a/BizHawk.Emulation/Computers/Commodore64/MOS/Sid.cs b/BizHawk.Emulation/Computers/Commodore64/MOS/Sid.cs index f184498155..bad7dee90a 100644 --- a/BizHawk.Emulation/Computers/Commodore64/MOS/Sid.cs +++ b/BizHawk.Emulation/Computers/Commodore64/MOS/Sid.cs @@ -5,7 +5,7 @@ using BizHawk.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.Computers.Commodore64.MOS +namespace BizHawk.Emulation.Cores.Computers.Commodore64 { sealed public partial class Sid { diff --git a/BizHawk.Emulation/Computers/Commodore64/MOS/UserPort.cs b/BizHawk.Emulation/Computers/Commodore64/MOS/UserPort.cs index 7039b28269..f8a0fc8c81 100644 --- a/BizHawk.Emulation/Computers/Commodore64/MOS/UserPort.cs +++ b/BizHawk.Emulation/Computers/Commodore64/MOS/UserPort.cs @@ -1,7 +1,7 @@ using System; using BizHawk.Common; -namespace BizHawk.Emulation.Computers.Commodore64.MOS +namespace BizHawk.Emulation.Cores.Computers.Commodore64 { public class UserPort { diff --git a/BizHawk.Emulation/Computers/Commodore64/MOS/Vic.GraphicsGenerator.cs b/BizHawk.Emulation/Computers/Commodore64/MOS/Vic.GraphicsGenerator.cs index fa096918f5..c8e1efbe8c 100644 --- a/BizHawk.Emulation/Computers/Commodore64/MOS/Vic.GraphicsGenerator.cs +++ b/BizHawk.Emulation/Computers/Commodore64/MOS/Vic.GraphicsGenerator.cs @@ -3,9 +3,9 @@ using System.Collections.Generic; using System.Linq; using System.Text; -namespace BizHawk.Emulation.Computers.Commodore64.MOS +namespace BizHawk.Emulation.Cores.Computers.Commodore64 { - sealed public partial class Vic - { - } + sealed public partial class Vic + { + } } diff --git a/BizHawk.Emulation/Computers/Commodore64/MOS/Vic.Parse.cs b/BizHawk.Emulation/Computers/Commodore64/MOS/Vic.Parse.cs index 6ec767b4c2..e0c60d51f6 100644 --- a/BizHawk.Emulation/Computers/Commodore64/MOS/Vic.Parse.cs +++ b/BizHawk.Emulation/Computers/Commodore64/MOS/Vic.Parse.cs @@ -3,256 +3,256 @@ using System.Collections.Generic; using System.Linq; using System.Text; -namespace BizHawk.Emulation.Computers.Commodore64.MOS +namespace BizHawk.Emulation.Cores.Computers.Commodore64 { - sealed public partial class Vic - { - const int baResetCounter = 7; - const int pipelineUpdateVc = 1; - const int pipelineChkSprChunch = 2; - const int pipelineUpdateMcBase = 4; - const int pipelineChkBrdL1 = 8; - const int pipelineChkBrdL0 = 16; - const int pipelineChkSprDma = 32; - const int pipelineChkBrdR0 = 64; - const int pipelineChkSprExp = 128; - const int pipelineChkBrdR1 = 256; - const int pipelineChkSprDisp = 512; - const int pipelineUpdateRc = 1024; - const int pipelineHBlankL = 0x10000000; - const int pipelineHBlankR = 0x20000000; - const int pipelineHoldX = 0x40000000; - const int rasterIrqLine0Cycle = 1; - const int rasterIrqLineXCycle = 0; + sealed public partial class Vic + { + const int baResetCounter = 7; + const int pipelineUpdateVc = 1; + const int pipelineChkSprChunch = 2; + const int pipelineUpdateMcBase = 4; + const int pipelineChkBrdL1 = 8; + const int pipelineChkBrdL0 = 16; + const int pipelineChkSprDma = 32; + const int pipelineChkBrdR0 = 64; + const int pipelineChkSprExp = 128; + const int pipelineChkBrdR1 = 256; + const int pipelineChkSprDisp = 512; + const int pipelineUpdateRc = 1024; + const int pipelineHBlankL = 0x10000000; + const int pipelineHBlankR = 0x20000000; + const int pipelineHoldX = 0x40000000; + 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; + int parseaddr; + int parsecycleBAsprite0; + int parsecycleBAsprite1; + int parsecycleBAsprite2; + int parsecycleFetchSpriteIndex; + int parsefetch; + int parsefetchType; + int parseba; + int parseact; - private void ParseCycle() - { - { - parseaddr = 0x3FFF; - parsefetch = pipeline[1][cycleIndex]; - parseba = pipeline[2][cycleIndex]; - parseact = pipeline[3][cycleIndex]; + 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); + // 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) - { - if (badline) - { - parseaddr = (pointerVM | vc); - dataC = ReadMemory(parseaddr); - dataC |= ((int)ReadColorRam(parseaddr) & 0xF) << 8; - bufferC[vmli] = dataC; - } - else - { - dataC = bufferC[vmli]; - } - } - else - { - dataC = 0; - 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)); - } - 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) - { - // fetch P - parseaddr = (0x3F8 | pointerVM | parsecycleFetchSpriteIndex); - sprites[parsecycleFetchSpriteIndex].pointer = ReadMemory(parseaddr); - sprites[parsecycleFetchSpriteIndex].shiftEnable = false; - } - else - { - // fetch S - if (sprites[parsecycleFetchSpriteIndex].dma) - { - SpriteGenerator spr = sprites[parsecycleFetchSpriteIndex]; - parseaddr = (spr.mc | (spr.pointer << 6)); - spr.sr <<= 8; - spr.sr |= ReadMemory(parseaddr); - spr.mc++; - } - } - } + // 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) + { + if (badline) + { + parseaddr = (pointerVM | vc); + dataC = ReadMemory(parseaddr); + dataC |= ((int)ReadColorRam(parseaddr) & 0xF) << 8; + bufferC[vmli] = dataC; + } + else + { + dataC = bufferC[vmli]; + } + } + else + { + dataC = 0; + 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)); + } + 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) + { + // fetch P + parseaddr = (0x3F8 | pointerVM | parsecycleFetchSpriteIndex); + sprites[parsecycleFetchSpriteIndex].pointer = ReadMemory(parseaddr); + sprites[parsecycleFetchSpriteIndex].shiftEnable = false; + } + else + { + // fetch S + if (sprites[parsecycleFetchSpriteIndex].dma) + { + SpriteGenerator spr = sprites[parsecycleFetchSpriteIndex]; + parseaddr = (spr.mc | (spr.pointer << 6)); + spr.sr <<= 8; + spr.sr |= ReadMemory(parseaddr); + spr.mc++; + } + } + } - // 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 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); + // 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 & pipelineChkSprChunch) != 0) - { - foreach (SpriteGenerator spr in sprites) - { - if (spr.yCrunch) - spr.mcbase += 2; - spr.shiftEnable = false; - spr.xCrunch = !spr.xExpand; - spr.multicolorCrunch = !spr.multicolor; - } - } + if (parseact != 0) + { + if ((parseact & pipelineChkSprChunch) != 0) + { + foreach (SpriteGenerator spr in sprites) + { + if (spr.yCrunch) + spr.mcbase += 2; + spr.shiftEnable = false; + spr.xCrunch = !spr.xExpand; + spr.multicolorCrunch = !spr.multicolor; + } + } - else if ((parseact & pipelineChkSprDisp) != 0) - { - foreach (SpriteGenerator spr in sprites) - { - spr.mc = spr.mcbase; - if (spr.dma && spr.y == (rasterLine & 0xFF)) - { - spr.display = true; - } - } - } + else if ((parseact & pipelineChkSprDisp) != 0) + { + foreach (SpriteGenerator spr in sprites) + { + spr.mc = spr.mcbase; + if (spr.dma && spr.y == (rasterLine & 0xFF)) + { + spr.display = true; + } + } + } - else if ((parseact & pipelineChkSprDma) != 0) - { - foreach (SpriteGenerator spr in sprites) - { - if (spr.enable && spr.y == (rasterLine & 0xFF) && !spr.dma) - { - spr.dma = true; - spr.mcbase = 0; - spr.yCrunch = !spr.yExpand; - } - } - } + else if ((parseact & pipelineChkSprDma) != 0) + { + foreach (SpriteGenerator spr in sprites) + { + if (spr.enable && spr.y == (rasterLine & 0xFF) && !spr.dma) + { + spr.dma = true; + spr.mcbase = 0; + spr.yCrunch = !spr.yExpand; + } + } + } - else if ((parseact & pipelineChkSprExp) != 0) - { - foreach (SpriteGenerator spr in sprites) - { - if (spr.yExpand) - spr.yCrunch ^= true; - } - } + else if ((parseact & pipelineChkSprExp) != 0) + { + foreach (SpriteGenerator spr in sprites) + { + if (spr.yExpand) + spr.yCrunch ^= true; + } + } - else if ((parseact & pipelineUpdateMcBase) != 0) - { - foreach (SpriteGenerator spr in sprites) - { - if (spr.yCrunch) - { - spr.mcbase++; - if (spr.mcbase == 63) - { - spr.dma = false; - spr.display = false; - } - } - } - } + else if ((parseact & pipelineUpdateMcBase) != 0) + { + foreach (SpriteGenerator spr in sprites) + { + if (spr.yCrunch) + { + spr.mcbase++; + if (spr.mcbase == 63) + { + spr.dma = false; + spr.display = false; + } + } + } + } - else if ((parseact & pipelineUpdateRc) != 0) - { - if (rc == 7) - { - idle = true; - vcbase = vc; - } - if (!idle) - rc = (rc + 1) & 0x7; - } + else if ((parseact & pipelineUpdateRc) != 0) + { + if (rc == 7) + { + idle = true; + vcbase = vc; + } + if (!idle) + rc = (rc + 1) & 0x7; + } - else if ((parseact & pipelineUpdateVc) != 0) - { - vc = vcbase; - vmli = 0; - if (badline) - rc = 0; - } - } + else if ((parseact & pipelineUpdateVc) != 0) + { + vc = vcbase; + vmli = 0; + if (badline) + rc = 0; + } + } - cycleIndex++; - } - } - } + cycleIndex++; + } + } + } } diff --git a/BizHawk.Emulation/Computers/Commodore64/MOS/Vic.Registers.cs b/BizHawk.Emulation/Computers/Commodore64/MOS/Vic.Registers.cs index b412eb7057..04c014839e 100644 --- a/BizHawk.Emulation/Computers/Commodore64/MOS/Vic.Registers.cs +++ b/BizHawk.Emulation/Computers/Commodore64/MOS/Vic.Registers.cs @@ -3,496 +3,496 @@ using System.Collections.Generic; using System.Linq; using System.Text; -namespace BizHawk.Emulation.Computers.Commodore64.MOS +namespace BizHawk.Emulation.Cores.Computers.Commodore64 { - sealed public partial class Vic - { - public byte Peek(int addr) - { - return ReadRegister((addr & 0x3F)); - } + sealed public partial class Vic + { + public byte Peek(int addr) + { + return ReadRegister((addr & 0x3F)); + } - public void Poke(int addr, byte val) - { - WriteRegister((addr & 0x3F), val); - } + public void Poke(int addr, byte val) + { + WriteRegister((addr & 0x3F), val); + } - public byte Read(int addr) - { - byte result; - addr &= 0x3F; + public byte Read(int addr) + { + byte result; + addr &= 0x3F; - switch (addr) - { - case 0x1E: - case 0x1F: - // reading clears these - result = ReadRegister(addr); - WriteRegister(addr, 0); - break; - default: - result = ReadRegister((addr & 0x3F)); - break; - } - return result; - } + switch (addr) + { + case 0x1E: + case 0x1F: + // reading clears these + result = ReadRegister(addr); + WriteRegister(addr, 0); + break; + default: + result = ReadRegister((addr & 0x3F)); + break; + } + return result; + } - private byte ReadRegister(int addr) - { - byte result = 0xFF; //unused bit value + private byte ReadRegister(int addr) + { + byte result = 0xFF; //unused bit value - switch (addr) - { - case 0x00: - case 0x02: - case 0x04: - case 0x06: - case 0x08: - case 0x0A: - case 0x0C: - case 0x0E: - result = (byte)(sprites[addr >> 1].x & 0xFF); - break; - case 0x01: - case 0x03: - case 0x05: - case 0x07: - case 0x09: - case 0x0B: - case 0x0D: - case 0x0F: - result = (byte)(sprites[addr >> 1].y & 0xFF); - break; - case 0x10: - result = (byte)( - ((sprites[0].x >> 8) & 0x01) | - ((sprites[1].x >> 7) & 0x02) | - ((sprites[2].x >> 6) & 0x04) | - ((sprites[3].x >> 5) & 0x08) | - ((sprites[4].x >> 4) & 0x10) | - ((sprites[5].x >> 3) & 0x20) | - ((sprites[6].x >> 2) & 0x40) | - ((sprites[7].x >> 1) & 0x80) - ); - break; - case 0x11: - result = (byte)( - (yScroll & 0x7) | - (rowSelect ? 0x08 : 0x00) | - (displayEnable ? 0x10 : 0x00) | - (bitmapMode ? 0x20 : 0x00) | - (extraColorMode ? 0x40 : 0x00) | - ((rasterLine & 0x100) >> 1) - ); - break; - case 0x12: - result = (byte)(rasterLine & 0xFF); - break; - case 0x13: - result = (byte)(lightPenX & 0xFF); - break; - case 0x14: - result = (byte)(lightPenY & 0xFF); - break; - case 0x15: - result = (byte)( - (sprites[0].enable ? 0x01 : 0x00) | - (sprites[1].enable ? 0x02 : 0x00) | - (sprites[2].enable ? 0x04 : 0x00) | - (sprites[3].enable ? 0x08 : 0x00) | - (sprites[4].enable ? 0x10 : 0x00) | - (sprites[5].enable ? 0x20 : 0x00) | - (sprites[6].enable ? 0x40 : 0x00) | - (sprites[7].enable ? 0x80 : 0x00) - ); - break; - case 0x16: - result &= 0xC0; - result |= (byte)( - (xScroll & 0x7) | - (columnSelect ? 0x08 : 0x00) | - (multicolorMode ? 0x10 : 0x00) - ); - break; - case 0x17: - result = (byte)( - (sprites[0].yExpand ? 0x01 : 0x00) | - (sprites[1].yExpand ? 0x02 : 0x00) | - (sprites[2].yExpand ? 0x04 : 0x00) | - (sprites[3].yExpand ? 0x08 : 0x00) | - (sprites[4].yExpand ? 0x10 : 0x00) | - (sprites[5].yExpand ? 0x20 : 0x00) | - (sprites[6].yExpand ? 0x40 : 0x00) | - (sprites[7].yExpand ? 0x80 : 0x00) - ); - break; - case 0x18: - result &= 0x01; - result |= (byte)( - ((pointerVM & 0x3C00) >> 6) | - ((pointerCB & 0x7) << 1) - ); - break; - case 0x19: - result &= 0x70; - result |= (byte)( - (intRaster ? 0x01 : 0x00) | - (intSpriteDataCollision ? 0x02 : 0x00) | - (intSpriteCollision ? 0x04 : 0x00) | - (intLightPen ? 0x08 : 0x00) | - (pinIRQ ? 0x00 : 0x80) - ); - break; - case 0x1A: - result &= 0xF0; - result |= (byte)( - (enableIntRaster ? 0x01 : 0x00) | - (enableIntSpriteDataCollision ? 0x02 : 0x00) | - (enableIntSpriteCollision ? 0x04 : 0x00) | - (enableIntLightPen ? 0x08 : 0x00) - ); - break; - case 0x1B: - result = (byte)( - (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) - ); - break; - case 0x1C: - result = (byte)( - (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) - ); - break; - case 0x1D: - result = (byte)( - (sprites[0].xExpand ? 0x01 : 0x00) | - (sprites[1].xExpand ? 0x02 : 0x00) | - (sprites[2].xExpand ? 0x04 : 0x00) | - (sprites[3].xExpand ? 0x08 : 0x00) | - (sprites[4].xExpand ? 0x10 : 0x00) | - (sprites[5].xExpand ? 0x20 : 0x00) | - (sprites[6].xExpand ? 0x40 : 0x00) | - (sprites[7].xExpand ? 0x80 : 0x00) - ); - break; - case 0x1E: - result = (byte)( - (sprites[0].collideSprite ? 0x01 : 0x00) | - (sprites[1].collideSprite ? 0x02 : 0x00) | - (sprites[2].collideSprite ? 0x04 : 0x00) | - (sprites[3].collideSprite ? 0x08 : 0x00) | - (sprites[4].collideSprite ? 0x10 : 0x00) | - (sprites[5].collideSprite ? 0x20 : 0x00) | - (sprites[6].collideSprite ? 0x40 : 0x00) | - (sprites[7].collideSprite ? 0x80 : 0x00) - ); - break; - case 0x1F: - result = (byte)( - (sprites[0].collideData ? 0x01 : 0x00) | - (sprites[1].collideData ? 0x02 : 0x00) | - (sprites[2].collideData ? 0x04 : 0x00) | - (sprites[3].collideData ? 0x08 : 0x00) | - (sprites[4].collideData ? 0x10 : 0x00) | - (sprites[5].collideData ? 0x20 : 0x00) | - (sprites[6].collideData ? 0x40 : 0x00) | - (sprites[7].collideData ? 0x80 : 0x00) - ); - break; - case 0x20: - result &= 0xF0; - result |= (byte)(borderColor & 0x0F); - break; - case 0x21: - result &= 0xF0; - result |= (byte)(backgroundColor0 & 0x0F); - break; - case 0x22: - result &= 0xF0; - result |= (byte)(backgroundColor1 & 0x0F); - break; - case 0x23: - result &= 0xF0; - result |= (byte)(backgroundColor2 & 0x0F); - break; - case 0x24: - result &= 0xF0; - result |= (byte)(backgroundColor3 & 0x0F); - break; - case 0x25: - result &= 0xF0; - result |= (byte)(spriteMulticolor0 & 0x0F); - break; - case 0x26: - result &= 0xF0; - result |= (byte)(spriteMulticolor1 & 0x0F); - break; - case 0x27: - case 0x28: - case 0x29: - case 0x2A: - case 0x2B: - case 0x2C: - case 0x2D: - case 0x2E: - result &= 0xF0; - result |= (byte)(sprites[addr - 0x27].color & 0xF); - break; - default: - // not connected - break; - } + switch (addr) + { + case 0x00: + case 0x02: + case 0x04: + case 0x06: + case 0x08: + case 0x0A: + case 0x0C: + case 0x0E: + result = (byte)(sprites[addr >> 1].x & 0xFF); + break; + case 0x01: + case 0x03: + case 0x05: + case 0x07: + case 0x09: + case 0x0B: + case 0x0D: + case 0x0F: + result = (byte)(sprites[addr >> 1].y & 0xFF); + break; + case 0x10: + result = (byte)( + ((sprites[0].x >> 8) & 0x01) | + ((sprites[1].x >> 7) & 0x02) | + ((sprites[2].x >> 6) & 0x04) | + ((sprites[3].x >> 5) & 0x08) | + ((sprites[4].x >> 4) & 0x10) | + ((sprites[5].x >> 3) & 0x20) | + ((sprites[6].x >> 2) & 0x40) | + ((sprites[7].x >> 1) & 0x80) + ); + break; + case 0x11: + result = (byte)( + (yScroll & 0x7) | + (rowSelect ? 0x08 : 0x00) | + (displayEnable ? 0x10 : 0x00) | + (bitmapMode ? 0x20 : 0x00) | + (extraColorMode ? 0x40 : 0x00) | + ((rasterLine & 0x100) >> 1) + ); + break; + case 0x12: + result = (byte)(rasterLine & 0xFF); + break; + case 0x13: + result = (byte)(lightPenX & 0xFF); + break; + case 0x14: + result = (byte)(lightPenY & 0xFF); + break; + case 0x15: + result = (byte)( + (sprites[0].enable ? 0x01 : 0x00) | + (sprites[1].enable ? 0x02 : 0x00) | + (sprites[2].enable ? 0x04 : 0x00) | + (sprites[3].enable ? 0x08 : 0x00) | + (sprites[4].enable ? 0x10 : 0x00) | + (sprites[5].enable ? 0x20 : 0x00) | + (sprites[6].enable ? 0x40 : 0x00) | + (sprites[7].enable ? 0x80 : 0x00) + ); + break; + case 0x16: + result &= 0xC0; + result |= (byte)( + (xScroll & 0x7) | + (columnSelect ? 0x08 : 0x00) | + (multicolorMode ? 0x10 : 0x00) + ); + break; + case 0x17: + result = (byte)( + (sprites[0].yExpand ? 0x01 : 0x00) | + (sprites[1].yExpand ? 0x02 : 0x00) | + (sprites[2].yExpand ? 0x04 : 0x00) | + (sprites[3].yExpand ? 0x08 : 0x00) | + (sprites[4].yExpand ? 0x10 : 0x00) | + (sprites[5].yExpand ? 0x20 : 0x00) | + (sprites[6].yExpand ? 0x40 : 0x00) | + (sprites[7].yExpand ? 0x80 : 0x00) + ); + break; + case 0x18: + result &= 0x01; + result |= (byte)( + ((pointerVM & 0x3C00) >> 6) | + ((pointerCB & 0x7) << 1) + ); + break; + case 0x19: + result &= 0x70; + result |= (byte)( + (intRaster ? 0x01 : 0x00) | + (intSpriteDataCollision ? 0x02 : 0x00) | + (intSpriteCollision ? 0x04 : 0x00) | + (intLightPen ? 0x08 : 0x00) | + (pinIRQ ? 0x00 : 0x80) + ); + break; + case 0x1A: + result &= 0xF0; + result |= (byte)( + (enableIntRaster ? 0x01 : 0x00) | + (enableIntSpriteDataCollision ? 0x02 : 0x00) | + (enableIntSpriteCollision ? 0x04 : 0x00) | + (enableIntLightPen ? 0x08 : 0x00) + ); + break; + case 0x1B: + result = (byte)( + (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) + ); + break; + case 0x1C: + result = (byte)( + (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) + ); + break; + case 0x1D: + result = (byte)( + (sprites[0].xExpand ? 0x01 : 0x00) | + (sprites[1].xExpand ? 0x02 : 0x00) | + (sprites[2].xExpand ? 0x04 : 0x00) | + (sprites[3].xExpand ? 0x08 : 0x00) | + (sprites[4].xExpand ? 0x10 : 0x00) | + (sprites[5].xExpand ? 0x20 : 0x00) | + (sprites[6].xExpand ? 0x40 : 0x00) | + (sprites[7].xExpand ? 0x80 : 0x00) + ); + break; + case 0x1E: + result = (byte)( + (sprites[0].collideSprite ? 0x01 : 0x00) | + (sprites[1].collideSprite ? 0x02 : 0x00) | + (sprites[2].collideSprite ? 0x04 : 0x00) | + (sprites[3].collideSprite ? 0x08 : 0x00) | + (sprites[4].collideSprite ? 0x10 : 0x00) | + (sprites[5].collideSprite ? 0x20 : 0x00) | + (sprites[6].collideSprite ? 0x40 : 0x00) | + (sprites[7].collideSprite ? 0x80 : 0x00) + ); + break; + case 0x1F: + result = (byte)( + (sprites[0].collideData ? 0x01 : 0x00) | + (sprites[1].collideData ? 0x02 : 0x00) | + (sprites[2].collideData ? 0x04 : 0x00) | + (sprites[3].collideData ? 0x08 : 0x00) | + (sprites[4].collideData ? 0x10 : 0x00) | + (sprites[5].collideData ? 0x20 : 0x00) | + (sprites[6].collideData ? 0x40 : 0x00) | + (sprites[7].collideData ? 0x80 : 0x00) + ); + break; + case 0x20: + result &= 0xF0; + result |= (byte)(borderColor & 0x0F); + break; + case 0x21: + result &= 0xF0; + result |= (byte)(backgroundColor0 & 0x0F); + break; + case 0x22: + result &= 0xF0; + result |= (byte)(backgroundColor1 & 0x0F); + break; + case 0x23: + result &= 0xF0; + result |= (byte)(backgroundColor2 & 0x0F); + break; + case 0x24: + result &= 0xF0; + result |= (byte)(backgroundColor3 & 0x0F); + break; + case 0x25: + result &= 0xF0; + result |= (byte)(spriteMulticolor0 & 0x0F); + break; + case 0x26: + result &= 0xF0; + result |= (byte)(spriteMulticolor1 & 0x0F); + break; + case 0x27: + case 0x28: + case 0x29: + case 0x2A: + case 0x2B: + case 0x2C: + case 0x2D: + case 0x2E: + result &= 0xF0; + result |= (byte)(sprites[addr - 0x27].color & 0xF); + break; + default: + // not connected + break; + } - return result; - } + return result; + } - public void Write(int addr, byte val) - { - addr &= 0x3F; - switch (addr) - { - case 0x19: - // interrupts are cleared by writing a 1 - if ((val & 0x01) != 0) - intRaster = false; - if ((val & 0x02) != 0) - intSpriteDataCollision = false; - if ((val & 0x04) != 0) - intSpriteCollision = false; - if ((val & 0x08) != 0) - intLightPen = false; - UpdatePins(); - break; - case 0x1A: - WriteRegister(addr, val); - break; - case 0x1E: - case 0x1F: - // can't write to these - break; - 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: - // not connected - break; - default: - WriteRegister(addr, val); - break; - } - } + public void Write(int addr, byte val) + { + addr &= 0x3F; + switch (addr) + { + case 0x19: + // interrupts are cleared by writing a 1 + if ((val & 0x01) != 0) + intRaster = false; + if ((val & 0x02) != 0) + intSpriteDataCollision = false; + if ((val & 0x04) != 0) + intSpriteCollision = false; + if ((val & 0x08) != 0) + intLightPen = false; + UpdatePins(); + break; + case 0x1A: + WriteRegister(addr, val); + break; + case 0x1E: + case 0x1F: + // can't write to these + break; + 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: + // not connected + break; + default: + WriteRegister(addr, val); + break; + } + } - private void WriteRegister(int addr, byte val) - { - switch (addr) - { - case 0x00: - case 0x02: - case 0x04: - case 0x06: - case 0x08: - case 0x0A: - case 0x0C: - case 0x0E: - sprites[addr >> 1].x &= 0x100; - sprites[addr >> 1].x |= val; - break; - case 0x01: - case 0x03: - case 0x05: - case 0x07: - case 0x09: - case 0x0B: - case 0x0D: - case 0x0F: - sprites[addr >> 1].y = val; - break; - 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); - break; - case 0x11: - yScroll = (val & 0x07); - rowSelect = ((val & 0x08) != 0); - displayEnable = ((val & 0x10) != 0); - bitmapMode = ((val & 0x20) != 0); - extraColorMode = ((val & 0x40) != 0); - rasterInterruptLine &= 0xFF; - rasterInterruptLine |= (val & 0x80) << 1; - UpdateBorder(); - UpdateVideoMode(); - break; - case 0x12: - rasterInterruptLine &= 0x100; - rasterInterruptLine |= val; - break; - case 0x13: - lightPenX = val; - break; - case 0x14: - lightPenY = val; - break; - case 0x15: - sprites[0].enable = ((val & 0x01) != 0); - sprites[1].enable = ((val & 0x02) != 0); - sprites[2].enable = ((val & 0x04) != 0); - sprites[3].enable = ((val & 0x08) != 0); - sprites[4].enable = ((val & 0x10) != 0); - sprites[5].enable = ((val & 0x20) != 0); - sprites[6].enable = ((val & 0x40) != 0); - sprites[7].enable = ((val & 0x80) != 0); - break; - case 0x16: - xScroll = (val & 0x07); - columnSelect = ((val & 0x08) != 0); - multicolorMode = ((val & 0x10) != 0); - UpdateBorder(); - UpdateVideoMode(); - break; - case 0x17: - sprites[0].yExpand = ((val & 0x01) != 0); - sprites[1].yExpand = ((val & 0x02) != 0); - sprites[2].yExpand = ((val & 0x04) != 0); - sprites[3].yExpand = ((val & 0x08) != 0); - sprites[4].yExpand = ((val & 0x10) != 0); - sprites[5].yExpand = ((val & 0x20) != 0); - sprites[6].yExpand = ((val & 0x40) != 0); - sprites[7].yExpand = ((val & 0x80) != 0); - break; - case 0x18: - pointerVM = ((val << 6) & 0x3C00); - pointerCB = ((val >> 1) & 0x7); - break; - case 0x19: - intRaster = ((val & 0x01) != 0); - intSpriteDataCollision = ((val & 0x02) != 0); - intSpriteCollision = ((val & 0x04) != 0); - intLightPen = ((val & 0x08) != 0); - UpdatePins(); - break; - case 0x1A: - enableIntRaster = ((val & 0x01) != 0); - enableIntSpriteDataCollision = ((val & 0x02) != 0); - enableIntSpriteCollision = ((val & 0x04) != 0); - enableIntLightPen = ((val & 0x08) != 0); - UpdatePins(); - break; - 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); - break; - 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); - break; - case 0x1D: - sprites[0].xExpand = ((val & 0x01) != 0); - sprites[1].xExpand = ((val & 0x02) != 0); - sprites[2].xExpand = ((val & 0x04) != 0); - sprites[3].xExpand = ((val & 0x08) != 0); - sprites[4].xExpand = ((val & 0x10) != 0); - sprites[5].xExpand = ((val & 0x20) != 0); - sprites[6].xExpand = ((val & 0x40) != 0); - sprites[7].xExpand = ((val & 0x80) != 0); - break; - case 0x1E: - sprites[0].collideSprite = ((val & 0x01) != 0); - sprites[1].collideSprite = ((val & 0x02) != 0); - sprites[2].collideSprite = ((val & 0x04) != 0); - sprites[3].collideSprite = ((val & 0x08) != 0); - sprites[4].collideSprite = ((val & 0x10) != 0); - sprites[5].collideSprite = ((val & 0x20) != 0); - sprites[6].collideSprite = ((val & 0x40) != 0); - sprites[7].collideSprite = ((val & 0x80) != 0); - break; - case 0x1F: - sprites[0].collideData = ((val & 0x01) != 0); - sprites[1].collideData = ((val & 0x02) != 0); - sprites[2].collideData = ((val & 0x04) != 0); - sprites[3].collideData = ((val & 0x08) != 0); - sprites[4].collideData = ((val & 0x10) != 0); - sprites[5].collideData = ((val & 0x20) != 0); - sprites[6].collideData = ((val & 0x40) != 0); - sprites[7].collideData = ((val & 0x80) != 0); - break; - case 0x20: - borderColor = (val & 0xF); - break; - case 0x21: - backgroundColor0 = (val & 0xF); - break; - case 0x22: - backgroundColor1 = (val & 0xF); - break; - case 0x23: - backgroundColor2 = (val & 0xF); - break; - case 0x24: - backgroundColor3 = (val & 0xF); - break; - case 0x25: - spriteMulticolor0 = (val & 0xF); - break; - case 0x26: - spriteMulticolor1 = (val & 0xF); - break; - case 0x27: - case 0x28: - case 0x29: - case 0x2A: - case 0x2B: - case 0x2C: - case 0x2D: - case 0x2E: - sprites[addr - 0x27].color = (val & 0xF); - break; - default: - break; - } - } - } + private void WriteRegister(int addr, byte val) + { + switch (addr) + { + case 0x00: + case 0x02: + case 0x04: + case 0x06: + case 0x08: + case 0x0A: + case 0x0C: + case 0x0E: + sprites[addr >> 1].x &= 0x100; + sprites[addr >> 1].x |= val; + break; + case 0x01: + case 0x03: + case 0x05: + case 0x07: + case 0x09: + case 0x0B: + case 0x0D: + case 0x0F: + sprites[addr >> 1].y = val; + break; + 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); + break; + case 0x11: + yScroll = (val & 0x07); + rowSelect = ((val & 0x08) != 0); + displayEnable = ((val & 0x10) != 0); + bitmapMode = ((val & 0x20) != 0); + extraColorMode = ((val & 0x40) != 0); + rasterInterruptLine &= 0xFF; + rasterInterruptLine |= (val & 0x80) << 1; + UpdateBorder(); + UpdateVideoMode(); + break; + case 0x12: + rasterInterruptLine &= 0x100; + rasterInterruptLine |= val; + break; + case 0x13: + lightPenX = val; + break; + case 0x14: + lightPenY = val; + break; + case 0x15: + sprites[0].enable = ((val & 0x01) != 0); + sprites[1].enable = ((val & 0x02) != 0); + sprites[2].enable = ((val & 0x04) != 0); + sprites[3].enable = ((val & 0x08) != 0); + sprites[4].enable = ((val & 0x10) != 0); + sprites[5].enable = ((val & 0x20) != 0); + sprites[6].enable = ((val & 0x40) != 0); + sprites[7].enable = ((val & 0x80) != 0); + break; + case 0x16: + xScroll = (val & 0x07); + columnSelect = ((val & 0x08) != 0); + multicolorMode = ((val & 0x10) != 0); + UpdateBorder(); + UpdateVideoMode(); + break; + case 0x17: + sprites[0].yExpand = ((val & 0x01) != 0); + sprites[1].yExpand = ((val & 0x02) != 0); + sprites[2].yExpand = ((val & 0x04) != 0); + sprites[3].yExpand = ((val & 0x08) != 0); + sprites[4].yExpand = ((val & 0x10) != 0); + sprites[5].yExpand = ((val & 0x20) != 0); + sprites[6].yExpand = ((val & 0x40) != 0); + sprites[7].yExpand = ((val & 0x80) != 0); + break; + case 0x18: + pointerVM = ((val << 6) & 0x3C00); + pointerCB = ((val >> 1) & 0x7); + break; + case 0x19: + intRaster = ((val & 0x01) != 0); + intSpriteDataCollision = ((val & 0x02) != 0); + intSpriteCollision = ((val & 0x04) != 0); + intLightPen = ((val & 0x08) != 0); + UpdatePins(); + break; + case 0x1A: + enableIntRaster = ((val & 0x01) != 0); + enableIntSpriteDataCollision = ((val & 0x02) != 0); + enableIntSpriteCollision = ((val & 0x04) != 0); + enableIntLightPen = ((val & 0x08) != 0); + UpdatePins(); + break; + 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); + break; + 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); + break; + case 0x1D: + sprites[0].xExpand = ((val & 0x01) != 0); + sprites[1].xExpand = ((val & 0x02) != 0); + sprites[2].xExpand = ((val & 0x04) != 0); + sprites[3].xExpand = ((val & 0x08) != 0); + sprites[4].xExpand = ((val & 0x10) != 0); + sprites[5].xExpand = ((val & 0x20) != 0); + sprites[6].xExpand = ((val & 0x40) != 0); + sprites[7].xExpand = ((val & 0x80) != 0); + break; + case 0x1E: + sprites[0].collideSprite = ((val & 0x01) != 0); + sprites[1].collideSprite = ((val & 0x02) != 0); + sprites[2].collideSprite = ((val & 0x04) != 0); + sprites[3].collideSprite = ((val & 0x08) != 0); + sprites[4].collideSprite = ((val & 0x10) != 0); + sprites[5].collideSprite = ((val & 0x20) != 0); + sprites[6].collideSprite = ((val & 0x40) != 0); + sprites[7].collideSprite = ((val & 0x80) != 0); + break; + case 0x1F: + sprites[0].collideData = ((val & 0x01) != 0); + sprites[1].collideData = ((val & 0x02) != 0); + sprites[2].collideData = ((val & 0x04) != 0); + sprites[3].collideData = ((val & 0x08) != 0); + sprites[4].collideData = ((val & 0x10) != 0); + sprites[5].collideData = ((val & 0x20) != 0); + sprites[6].collideData = ((val & 0x40) != 0); + sprites[7].collideData = ((val & 0x80) != 0); + break; + case 0x20: + borderColor = (val & 0xF); + break; + case 0x21: + backgroundColor0 = (val & 0xF); + break; + case 0x22: + backgroundColor1 = (val & 0xF); + break; + case 0x23: + backgroundColor2 = (val & 0xF); + break; + case 0x24: + backgroundColor3 = (val & 0xF); + break; + case 0x25: + spriteMulticolor0 = (val & 0xF); + break; + case 0x26: + spriteMulticolor1 = (val & 0xF); + break; + case 0x27: + case 0x28: + case 0x29: + case 0x2A: + case 0x2B: + case 0x2C: + case 0x2D: + case 0x2E: + sprites[addr - 0x27].color = (val & 0xF); + break; + default: + break; + } + } + } } diff --git a/BizHawk.Emulation/Computers/Commodore64/MOS/Vic.Render.cs b/BizHawk.Emulation/Computers/Commodore64/MOS/Vic.Render.cs index d2677a781e..b0b96e0d8c 100644 --- a/BizHawk.Emulation/Computers/Commodore64/MOS/Vic.Render.cs +++ b/BizHawk.Emulation/Computers/Commodore64/MOS/Vic.Render.cs @@ -3,226 +3,226 @@ using System.Collections.Generic; using System.Linq; using System.Text; -namespace BizHawk.Emulation.Computers.Commodore64.MOS +namespace BizHawk.Emulation.Cores.Computers.Commodore64 { - 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; + 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 - } + enum VicVideoMode : int + { + Mode000, + Mode001, + Mode010, + Mode011, + Mode100, + ModeBad + } - private void Render() - { - if (hblankCheckEnableL) - { - if (rasterX == hblankEnd) - hblank = false; - } - else if (hblankCheckEnableR) - { - if (rasterX == hblankStart) - hblank = true; - } + private void Render() + { + if (hblankCheckEnableL) + { + if (rasterX == hblankEnd) + hblank = false; + } + else if (hblankCheckEnableR) + { + if (rasterX == hblankStart) + hblank = true; + } - renderEnabled = (!hblank && !vblank); - for (int i = 0; i < 4; i++) - { + renderEnabled = (!hblank && !vblank); + for (int i = 0; i < 4; i++) + { - if (delayC > 0) - delayC--; - else - displayC = (srC >> 12) & 0xFFF; + if (delayC > 0) + delayC--; + else + displayC = (srC >> 12) & 0xFFF; - if (borderCheckLEnable && (rasterX == borderL)) - { - if (rasterLine == borderB) - borderOnVertical = true; - if (rasterLine == borderT && displayEnable) - borderOnVertical = false; - if (!borderOnVertical) - borderOnMain = false; - } + if (borderCheckLEnable && (rasterX == borderL)) + { + if (rasterLine == borderB) + borderOnVertical = true; + if (rasterLine == borderT && displayEnable) + borderOnVertical = false; + if (!borderOnVertical) + borderOnMain = false; + } - switch (videoMode) - { - case VicVideoMode.Mode000: - pixelData = sr & srMask2; - pixel = (pixelData != 0) ? (displayC >> 8) : backgroundColor0; - break; - case VicVideoMode.Mode001: - if ((displayC & 0x800) != 0) - { - // multicolor 001 - if ((srSync & srMask2) != 0) - pixelData = sr & srMask3; + switch (videoMode) + { + case VicVideoMode.Mode000: + pixelData = sr & srMask2; + pixel = (pixelData != 0) ? (displayC >> 8) : backgroundColor0; + break; + case VicVideoMode.Mode001: + if ((displayC & 0x800) != 0) + { + // multicolor 001 + if ((srSync & srMask2) != 0) + pixelData = sr & srMask3; - if (pixelData == 0) - pixel = backgroundColor0; - else if (pixelData == srMask1) - pixel = backgroundColor1; - else if (pixelData == srMask2) - pixel = backgroundColor2; - else - pixel = (displayC & 0x700) >> 8; - } - else - { - // standard 001 - pixelData = sr & srMask2; - pixel = (pixelData != 0) ? (displayC >> 8) : backgroundColor0; - } - break; - case VicVideoMode.Mode010: - pixelData = sr & srMask2; - pixel = (pixelData != 0) ? (displayC >> 4) : (displayC); - break; - case VicVideoMode.Mode011: - if ((srSync & srMask2) != 0) - pixelData = sr & srMask3; + if (pixelData == 0) + pixel = backgroundColor0; + else if (pixelData == srMask1) + pixel = backgroundColor1; + else if (pixelData == srMask2) + pixel = backgroundColor2; + else + pixel = (displayC & 0x700) >> 8; + } + else + { + // standard 001 + pixelData = sr & srMask2; + pixel = (pixelData != 0) ? (displayC >> 8) : backgroundColor0; + } + break; + case VicVideoMode.Mode010: + pixelData = sr & srMask2; + pixel = (pixelData != 0) ? (displayC >> 4) : (displayC); + break; + case VicVideoMode.Mode011: + if ((srSync & srMask2) != 0) + pixelData = sr & srMask3; - if (pixelData == 0) - pixel = backgroundColor0; - else if (pixelData == srMask1) - pixel = (displayC >> 4); - else if (pixelData == srMask2) - pixel = displayC; - else - pixel = (displayC >> 8); - break; - case VicVideoMode.Mode100: - pixelData = sr & srMask2; - if (pixelData != 0) - { - pixel = displayC >> 8; - } - else - { - ecmPixel = (displayC) & 0xC0; - if (ecmPixel == 0x00) - pixel = backgroundColor0; - else if (ecmPixel == 0x40) - pixel = backgroundColor1; - else if (ecmPixel == 0x80) - pixel = backgroundColor2; - else - pixel = backgroundColor3; - } - break; - default: - pixelData = 0; - pixel = 0; - break; - } - pixel &= 0xF; - sr <<= 1; - srSync <<= 1; - - // render sprite - pixelOwner = null; - foreach (SpriteGenerator spr in sprites) - { - sprData = 0; - sprPixel = pixel; + if (pixelData == 0) + pixel = backgroundColor0; + else if (pixelData == srMask1) + pixel = (displayC >> 4); + else if (pixelData == srMask2) + pixel = displayC; + else + pixel = (displayC >> 8); + break; + case VicVideoMode.Mode100: + pixelData = sr & srMask2; + if (pixelData != 0) + { + pixel = displayC >> 8; + } + else + { + ecmPixel = (displayC) & 0xC0; + if (ecmPixel == 0x00) + pixel = backgroundColor0; + else if (ecmPixel == 0x40) + pixel = backgroundColor1; + else if (ecmPixel == 0x80) + pixel = backgroundColor2; + else + pixel = backgroundColor3; + } + break; + default: + pixelData = 0; + pixel = 0; + break; + } + pixel &= 0xF; + sr <<= 1; + srSync <<= 1; - if (spr.x == rasterX) - spr.shiftEnable = true; + // render sprite + pixelOwner = null; + foreach (SpriteGenerator spr in sprites) + { + sprData = 0; + sprPixel = pixel; - if (spr.shiftEnable) - { - if (spr.multicolor) - { - sprData = (spr.sr & srSpriteMaskMC); - if (spr.multicolorCrunch && spr.xCrunch && !rasterXHold) - spr.sr <<= 2; - spr.multicolorCrunch ^= spr.xCrunch; - } - else - { - sprData = (spr.sr & srSpriteMask); - if (spr.xCrunch && !rasterXHold) - spr.sr <<= 1; - } - spr.xCrunch ^= spr.xExpand; + if (spr.x == rasterX) + spr.shiftEnable = true; - if (sprData != 0) - { - // sprite-sprite collision - if (pixelOwner == null) - { - if (!spr.priority || (pixelData == 0)) - { - if (sprData == srSpriteMask1) - pixel = spriteMulticolor0; - else if (sprData == srSpriteMask2) - pixel = spr.color; - else if (sprData == srSpriteMask3) - pixel = spriteMulticolor1; - } - pixelOwner = spr; - } - else - { - if (!borderOnVertical) - { - spr.collideSprite = true; - pixelOwner.collideSprite = true; - } - } + if (spr.shiftEnable) + { + if (spr.multicolor) + { + sprData = (spr.sr & srSpriteMaskMC); + if (spr.multicolorCrunch && spr.xCrunch && !rasterXHold) + spr.sr <<= 2; + spr.multicolorCrunch ^= spr.xCrunch; + } + else + { + sprData = (spr.sr & srSpriteMask); + if (spr.xCrunch && !rasterXHold) + spr.sr <<= 1; + } + spr.xCrunch ^= spr.xExpand; - // sprite-data collision - if (!borderOnVertical && (pixelData < srMask2)) - { - spr.collideData = true; - } - } - if (spr.sr == 0) - spr.shiftEnable = false; //optimization - } - } + if (sprData != 0) + { + // sprite-sprite collision + if (pixelOwner == null) + { + if (!spr.priority || (pixelData == 0)) + { + if (sprData == srSpriteMask1) + pixel = spriteMulticolor0; + else if (sprData == srSpriteMask2) + pixel = spr.color; + else if (sprData == srSpriteMask3) + pixel = spriteMulticolor1; + } + pixelOwner = spr; + } + else + { + if (!borderOnVertical) + { + spr.collideSprite = true; + pixelOwner.collideSprite = true; + } + } - if (borderCheckREnable && (rasterX == borderR)) - borderOnMain = true; + // sprite-data collision + if (!borderOnVertical && (pixelData < srMask2)) + { + spr.collideData = true; + } + } + if (spr.sr == 0) + spr.shiftEnable = false; //optimization + } + } - // border doesn't work with the background buffer - if (borderOnMain || borderOnVertical) - pixel = borderColor; + if (borderCheckREnable && (rasterX == borderR)) + borderOnMain = true; - // plot pixel if within viewing area - if (renderEnabled) - { - buf[bufOffset] = palette[pixBuffer[pixBufferIndex]]; - bufOffset++; - if (bufOffset == bufLength) - bufOffset = 0; - } - pixBuffer[pixBufferIndex] = pixel; - pixBufferIndex++; + // border doesn't work with the background buffer + if (borderOnMain || borderOnVertical) + pixel = borderColor; - if (!rasterXHold) - rasterX++; - bitmapColumn++; - } + // plot pixel if within viewing area + if (renderEnabled) + { + buf[bufOffset] = palette[pixBuffer[pixBufferIndex]]; + bufOffset++; + if (bufOffset == bufLength) + bufOffset = 0; + } + pixBuffer[pixBufferIndex] = pixel; + pixBufferIndex++; - if (pixBufferIndex >= pixBufferSize) - pixBufferIndex = 0; - } - } + if (!rasterXHold) + rasterX++; + bitmapColumn++; + } + + if (pixBufferIndex >= pixBufferSize) + pixBufferIndex = 0; + } + } } diff --git a/BizHawk.Emulation/Computers/Commodore64/MOS/Vic.SpriteGenerator.cs b/BizHawk.Emulation/Computers/Commodore64/MOS/Vic.SpriteGenerator.cs index f0f69348fb..e6212195f0 100644 --- a/BizHawk.Emulation/Computers/Commodore64/MOS/Vic.SpriteGenerator.cs +++ b/BizHawk.Emulation/Computers/Commodore64/MOS/Vic.SpriteGenerator.cs @@ -5,7 +5,7 @@ using System.Text; using BizHawk.Common; -namespace BizHawk.Emulation.Computers.Commodore64.MOS +namespace BizHawk.Emulation.Cores.Computers.Commodore64 { sealed public partial class Vic { diff --git a/BizHawk.Emulation/Computers/Commodore64/MOS/Vic.State.cs b/BizHawk.Emulation/Computers/Commodore64/MOS/Vic.State.cs index 06ec716cab..9d8f6fdc78 100644 --- a/BizHawk.Emulation/Computers/Commodore64/MOS/Vic.State.cs +++ b/BizHawk.Emulation/Computers/Commodore64/MOS/Vic.State.cs @@ -6,7 +6,7 @@ using System.Text; using BizHawk.Common; -namespace BizHawk.Emulation.Computers.Commodore64.MOS +namespace BizHawk.Emulation.Cores.Computers.Commodore64 { sealed public partial class Vic { diff --git a/BizHawk.Emulation/Computers/Commodore64/MOS/Vic.TimingBuilder.cs b/BizHawk.Emulation/Computers/Commodore64/MOS/Vic.TimingBuilder.cs index d7ba1138b7..91c5aae3d3 100644 --- a/BizHawk.Emulation/Computers/Commodore64/MOS/Vic.TimingBuilder.cs +++ b/BizHawk.Emulation/Computers/Commodore64/MOS/Vic.TimingBuilder.cs @@ -3,23 +3,23 @@ using System.Collections.Generic; using System.Linq; using System.Text; -namespace BizHawk.Emulation.Computers.Commodore64.MOS +namespace BizHawk.Emulation.Cores.Computers.Commodore64 { - sealed public partial class Vic - { - const int BORDER_LEFT_38 = 0x01F; - const int BORDER_LEFT_40 = 0x018; - const int BORDER_RIGHT_38 = 0x14F; - const int BORDER_RIGHT_40 = 0x158; + sealed public partial class Vic + { + const int BORDER_LEFT_38 = 0x01F; + const int BORDER_LEFT_40 = 0x018; + const int BORDER_RIGHT_38 = 0x14F; + const int BORDER_RIGHT_40 = 0x158; - // 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[] + // 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[] { pipelineUpdateVc, 0, pipelineChkSprChunch, 0, pipelineUpdateMcBase, 0, }; - static int[] TimingBuilder_Cycle55Act = new int[] + static int[] TimingBuilder_Cycle55Act = new int[] { pipelineChkSprDma, 0, pipelineChkSprDma, pipelineChkSprExp, @@ -27,251 +27,251 @@ namespace BizHawk.Emulation.Computers.Commodore64.MOS pipelineChkSprDisp, pipelineUpdateRc }; - // This builds a table of special actions to take on each half-cycle. Cycle14 is the X-raster position where - // pre-display operations happen, and Cycle55 is the X-raster position where post-display operations happen. - static public int[] TimingBuilder_Act(int[] timing, int cycle14, int cycle55, int hblankStart, int hblankEnd) - { - List result = new List(); + // This builds a table of special actions to take on each half-cycle. Cycle14 is the X-raster position where + // pre-display operations happen, and Cycle55 is the X-raster position where post-display operations happen. + static public int[] TimingBuilder_Act(int[] timing, int cycle14, int cycle55, int hblankStart, int hblankEnd) + { + List result = new List(); - int length = timing.Length; - for (int i = 0; i < length; i++) - { - while (i < result.Count) - i++; - if (timing[i] == cycle14) - result.AddRange(TimingBuilder_Cycle14Act); - else if (timing[i] == cycle55) - result.AddRange(TimingBuilder_Cycle55Act); - else - result.Add(0); - } - for (int i = 0; i < length; i++) - { - // pipeline raster X delay - if (timing[(i + 1) % length] == timing[i]) - result[i] |= pipelineHoldX; + int length = timing.Length; + for (int i = 0; i < length; i++) + { + while (i < result.Count) + i++; + if (timing[i] == cycle14) + result.AddRange(TimingBuilder_Cycle14Act); + else if (timing[i] == cycle55) + result.AddRange(TimingBuilder_Cycle55Act); + else + result.Add(0); + } + for (int i = 0; i < length; i++) + { + // pipeline raster X delay + if (timing[(i + 1) % length] == timing[i]) + result[i] |= pipelineHoldX; - // pipeline border checks - if (timing[i] == (BORDER_LEFT_40 & 0xFFC)) - result[i] |= pipelineChkBrdL1; - if (timing[i] == (BORDER_LEFT_38 & 0xFFC)) - result[i] |= pipelineChkBrdL0; - if (timing[i] == (BORDER_RIGHT_38 & 0xFFC)) - result[i] |= pipelineChkBrdR0; - if (timing[i] == (BORDER_RIGHT_40 & 0xFFC)) - result[i] |= pipelineChkBrdR1; - if (timing[i] == (hblankStart & 0xFFC)) - result[i] |= pipelineHBlankR; - if (timing[i] == (hblankEnd & 0xFFC)) - result[i] |= pipelineHBlankL; - } + // pipeline border checks + if (timing[i] == (BORDER_LEFT_40 & 0xFFC)) + result[i] |= pipelineChkBrdL1; + if (timing[i] == (BORDER_LEFT_38 & 0xFFC)) + result[i] |= pipelineChkBrdL0; + if (timing[i] == (BORDER_RIGHT_38 & 0xFFC)) + result[i] |= pipelineChkBrdR0; + if (timing[i] == (BORDER_RIGHT_40 & 0xFFC)) + result[i] |= pipelineChkBrdR1; + if (timing[i] == (hblankStart & 0xFFC)) + result[i] |= pipelineHBlankR; + if (timing[i] == (hblankEnd & 0xFFC)) + result[i] |= pipelineHBlankL; + } - return result.ToArray(); - } + return result.ToArray(); + } - // This builds a table of how the BA pin is supposed to act on each half-cycle. - static public int[] TimingBuilder_BA(int[] fetch) - { - int baRestart = 7; - int start = 0; - int length = fetch.Length; - int[] result = new int[length]; - int[] spriteBA = new int[8]; - int charBA = 0; + // This builds a table of how the BA pin is supposed to act on each half-cycle. + static public int[] TimingBuilder_BA(int[] fetch) + { + int baRestart = 7; + int start = 0; + int length = fetch.Length; + int[] result = new int[length]; + int[] spriteBA = new int[8]; + int charBA = 0; - while (true) - { - if (fetch[start] == 0) - break; - start++; - } + while (true) + { + if (fetch[start] == 0) + break; + start++; + } - while (true) - { - if (fetch[start] == 0x200) - break; - start--; - } + while (true) + { + if (fetch[start] == 0x200) + break; + start--; + } - if (start < 0) - start += length; - int offset = start; + if (start < 0) + start += length; + int offset = start; - while (true) - { - int ba = 0x0888; + while (true) + { + int ba = 0x0888; - if (fetch[offset] == 0x200) - charBA = baRestart; - else if ((fetch[offset] & 0xFF00) == 0x0000) - spriteBA[fetch[offset] & 0x007] = baRestart; + if (fetch[offset] == 0x200) + charBA = baRestart; + else if ((fetch[offset] & 0xFF00) == 0x0000) + spriteBA[fetch[offset] & 0x007] = baRestart; - for (int i = 0; i < 8; i++) - { - if (spriteBA[i] > 0) - { - ba <<= 4; - ba |= i; - spriteBA[i]--; - } - } - ba &= 0x0FFF; + for (int i = 0; i < 8; i++) + { + if (spriteBA[i] > 0) + { + ba <<= 4; + ba |= i; + spriteBA[i]--; + } + } + ba &= 0x0FFF; - if (charBA > 0) - { - ba = 0x1000; - charBA--; - } + if (charBA > 0) + { + ba = 0x1000; + charBA--; + } - result[offset] = ba; + result[offset] = ba; - offset--; - if (offset < 0) - offset += length; + offset--; + if (offset < 0) + offset += length; - if (offset == start) - break; - } + if (offset == start) + break; + } - for (int i = 0; i < length; i += 2) - { - result[i] = result[i + 1]; - } + for (int i = 0; i < length; i += 2) + { + result[i] = result[i + 1]; + } - return result; - } + return result; + } - // This builds a table of the fetch operations to take on each half-cycle. - static public int[] TimingBuilder_Fetch(int[] timing, int sprite) - { - int length = timing.Length; - int[] result = new int[length]; - int offset; - int index = -1; - int refreshCounter = 0; - bool spriteActive = false; - int spriteIndex = 0; - int spritePhase = 0; - int charCounter = 0; + // This builds a table of the fetch operations to take on each half-cycle. + static public int[] TimingBuilder_Fetch(int[] timing, int sprite) + { + int length = timing.Length; + int[] result = new int[length]; + int offset; + int index = -1; + int refreshCounter = 0; + bool spriteActive = false; + int spriteIndex = 0; + int spritePhase = 0; + int charCounter = 0; - for (int i = 0; i < length; i++) - { - result[i++] = 0x500; - result[i] = 0x100; - } + for (int i = 0; i < length; i++) + { + result[i++] = 0x500; + result[i] = 0x100; + } - while (true) - { - index++; - if (index >= length) - index -= length; - offset = timing[index]; + while (true) + { + index++; + if (index >= length) + index -= length; + offset = timing[index]; - if (charCounter > 0) - { - result[index] = (charCounter & 1) == 0 ? 0x200 : 0x300; - charCounter--; - if (charCounter == 0) - break; - } + if (charCounter > 0) + { + result[index] = (charCounter & 1) == 0 ? 0x200 : 0x300; + charCounter--; + if (charCounter == 0) + break; + } - if (refreshCounter > 0) - { - result[index] = (refreshCounter & 1) == 0 ? 0x500 : 0x100; - refreshCounter--; - if (refreshCounter == 0) - charCounter = 80; - } + if (refreshCounter > 0) + { + result[index] = (refreshCounter & 1) == 0 ? 0x500 : 0x100; + refreshCounter--; + if (refreshCounter == 0) + charCounter = 80; + } - if (offset == sprite) - { - spriteActive = true; - } + if (offset == sprite) + { + spriteActive = true; + } - if (spriteActive) - { - result[index] = (spriteIndex | (spritePhase << 4)); - spritePhase++; - if (spritePhase == 4) - { - spritePhase = 0; - spriteIndex++; - if (spriteIndex == 8) - { - spriteActive = false; - refreshCounter = 9; - } - } - } - } + if (spriteActive) + { + result[index] = (spriteIndex | (spritePhase << 4)); + spritePhase++; + if (spritePhase == 4) + { + spritePhase = 0; + spriteIndex++; + if (spriteIndex == 8) + { + spriteActive = false; + refreshCounter = 9; + } + } + } + } - return result.ToArray(); - } + return result.ToArray(); + } - // This uses the vBlank values to determine the height of the visible screen. - static public int TimingBuilder_ScreenHeight(int vblankStart, int vblankEnd, int lines) - { - int offset = vblankEnd; - int result = 0; - while (true) - { - if (offset >= lines) - offset -= lines; - if (offset == vblankStart) - return result; - offset++; - result++; - } - } + // This uses the vBlank values to determine the height of the visible screen. + static public int TimingBuilder_ScreenHeight(int vblankStart, int vblankEnd, int lines) + { + int offset = vblankEnd; + int result = 0; + while (true) + { + if (offset >= lines) + offset -= lines; + if (offset == vblankStart) + return result; + offset++; + result++; + } + } - // This uses the hBlank values to determine the width of the visible screen. - static public int TimingBuilder_ScreenWidth(int[] timing, int hblankStart, int hblankEnd) - { - int length = timing.Length; - int result = 0; - int offset = 0; + // This uses the hBlank values to determine the width of the visible screen. + static public int TimingBuilder_ScreenWidth(int[] timing, int hblankStart, int hblankEnd) + { + int length = timing.Length; + int result = 0; + int offset = 0; - while (timing[offset] != hblankEnd) { offset = (offset + 1) % length; } - while (timing[offset] != hblankStart) { offset = (offset + 1) % length; result++; } + while (timing[offset] != hblankEnd) { offset = (offset + 1) % length; } + while (timing[offset] != hblankStart) { offset = (offset + 1) % length; result++; } - return (result * 4); - } + return (result * 4); + } - // This builds the table of X-raster positions. Start marks the position where the - // Y-raster is incremented. Width is the position where the X-raster is reset to zero. Count - // is the width of a rasterline in pixels. DelayOffset is the X-raster position where lag begins - // (specifically on an NTSC 6567R8) and DelayAmount is the number of positions to lag. - static public int[] TimingBuilder_XRaster(int start, int width, int count, int delayOffset, int delayAmount) - { - List result = new List(); - int rasterX = start; - bool delayed = false; - count >>= 2; - delayAmount >>= 2; + // This builds the table of X-raster positions. Start marks the position where the + // Y-raster is incremented. Width is the position where the X-raster is reset to zero. Count + // is the width of a rasterline in pixels. DelayOffset is the X-raster position where lag begins + // (specifically on an NTSC 6567R8) and DelayAmount is the number of positions to lag. + static public int[] TimingBuilder_XRaster(int start, int width, int count, int delayOffset, int delayAmount) + { + List result = new List(); + int rasterX = start; + bool delayed = false; + count >>= 2; + delayAmount >>= 2; - for (int i = 0; i < count; i++) - { - result.Add(rasterX); + for (int i = 0; i < count; i++) + { + result.Add(rasterX); - if (!delayed) - { - rasterX += 4; - if (rasterX >= width) - rasterX -= width; - } - else - { - delayAmount--; - if (delayAmount <= 0) - delayed = false; - continue; - } + if (!delayed) + { + rasterX += 4; + if (rasterX >= width) + rasterX -= width; + } + else + { + delayAmount--; + if (delayAmount <= 0) + delayed = false; + continue; + } - if (rasterX == delayOffset && delayAmount > 0) - delayed = true; - } + if (rasterX == delayOffset && delayAmount > 0) + delayed = true; + } - return result.ToArray(); - } - } + return result.ToArray(); + } + } } diff --git a/BizHawk.Emulation/Computers/Commodore64/MOS/Vic.VideoProvider.cs b/BizHawk.Emulation/Computers/Commodore64/MOS/Vic.VideoProvider.cs index 09301f34fa..81428d69de 100644 --- a/BizHawk.Emulation/Computers/Commodore64/MOS/Vic.VideoProvider.cs +++ b/BizHawk.Emulation/Computers/Commodore64/MOS/Vic.VideoProvider.cs @@ -3,7 +3,7 @@ using BizHawk.Common; using BizHawk.Emulation.Common; -namespace BizHawk.Emulation.Computers.Commodore64.MOS +namespace BizHawk.Emulation.Cores.Computers.Commodore64 { sealed public partial class Vic : IVideoProvider { @@ -18,24 +18,24 @@ namespace BizHawk.Emulation.Computers.Commodore64.MOS // palette 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) - }; + { + 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 BackgroundColor { diff --git a/BizHawk.Emulation/Computers/Commodore64/MOS/Vic.cs b/BizHawk.Emulation/Computers/Commodore64/MOS/Vic.cs index 3ae5c55336..b46c4e2d19 100644 --- a/BizHawk.Emulation/Computers/Commodore64/MOS/Vic.cs +++ b/BizHawk.Emulation/Computers/Commodore64/MOS/Vic.cs @@ -1,157 +1,157 @@ using System; using System.Drawing; -namespace BizHawk.Emulation.Computers.Commodore64.MOS +namespace BizHawk.Emulation.Cores.Computers.Commodore64 { sealed public partial class Vic { - public Func ReadColorRam; - public Func ReadMemory; + public Func ReadColorRam; + public Func ReadMemory; - public bool ReadAECBuffer() { return pinAEC; } - public bool ReadBABuffer() { return pinBA; } - public bool ReadIRQBuffer() { return pinIRQ; } + public bool ReadAECBuffer() { return pinAEC; } + public bool ReadBABuffer() { return pinBA; } + public bool ReadIRQBuffer() { return pinIRQ; } - int cyclesPerSec; - int irqShift; + int cyclesPerSec; + int irqShift; int[][] pipeline; int totalCycles; int totalLines; public Vic(int newCycles, int newLines, int[][] newPipeline, int newCyclesPerSec, int hblankStart, int hblankEnd, int vblankStart, int vblankEnd) { - { - this.hblankStart = hblankStart; - this.hblankEnd = hblankEnd; - this.vblankStart = vblankStart; - this.vblankEnd = vblankEnd; + { + this.hblankStart = hblankStart; + this.hblankEnd = hblankEnd; + this.vblankStart = vblankStart; + this.vblankEnd = vblankEnd; - totalCycles = newCycles; + totalCycles = newCycles; totalLines = newLines; pipeline = newPipeline; cyclesPerSec = newCyclesPerSec; - bufWidth = TimingBuilder_ScreenWidth(pipeline[0], hblankStart, hblankEnd); - bufHeight = TimingBuilder_ScreenHeight(vblankStart, vblankEnd, newLines); + bufWidth = TimingBuilder_ScreenWidth(pipeline[0], hblankStart, hblankEnd); + bufHeight = TimingBuilder_ScreenHeight(vblankStart, vblankEnd, newLines); - buf = new int[bufWidth * bufHeight]; + buf = new int[bufWidth * bufHeight]; bufLength = buf.Length; - sprites = new SpriteGenerator[8]; + sprites = new SpriteGenerator[8]; for (int i = 0; i < 8; i++) - sprites[i] = new SpriteGenerator(); + sprites[i] = new SpriteGenerator(); bufferC = new int[40]; bufferG = new int[40]; } } - public int CyclesPerFrame - { - get - { - return (totalCycles * totalLines); - } - } + public int CyclesPerFrame + { + get + { + return (totalCycles * totalLines); + } + } - public int CyclesPerSecond - { - get - { - return cyclesPerSec; - } - } + public int CyclesPerSecond + { + get + { + return cyclesPerSec; + } + } - public void ExecutePhase1() - { - //xScroll = 1; - { - // raster IRQ compare - if ((cycle == rasterIrqLineXCycle && rasterLine > 0) || (cycle == rasterIrqLine0Cycle && rasterLine == 0)) - { - if (rasterLine != lastRasterLine) - if (rasterLine == rasterInterruptLine) - intRaster = true; - lastRasterLine = rasterLine; - } + public void ExecutePhase1() + { + //xScroll = 1; + { + // raster IRQ compare + if ((cycle == rasterIrqLineXCycle && rasterLine > 0) || (cycle == rasterIrqLine0Cycle && rasterLine == 0)) + { + if (rasterLine != lastRasterLine) + if (rasterLine == rasterInterruptLine) + intRaster = true; + lastRasterLine = rasterLine; + } - // display enable compare - if (rasterLine == 0x030) - badlineEnable |= displayEnable; + // display enable compare + if (rasterLine == 0x030) + badlineEnable |= displayEnable; - // badline compare - if (badlineEnable && rasterLine >= 0x030 && rasterLine < 0x0F7 && ((rasterLine & 0x7) == yScroll)) - { - badline = true; - } - else - { - badline = false; - } + // badline compare + if (badlineEnable && rasterLine >= 0x030 && rasterLine < 0x0F7 && ((rasterLine & 0x7) == yScroll)) + { + badline = true; + } + else + { + badline = false; + } - // go into display state on a badline - if (badline) - idle = false; + // go into display state on a badline + if (badline) + idle = false; - // process some sprite crunch vars - foreach (SpriteGenerator spr in sprites) - if (!spr.yExpand) spr.yCrunch = true; + // process some sprite crunch vars + foreach (SpriteGenerator spr in sprites) + if (!spr.yExpand) spr.yCrunch = true; - ParseCycle(); + ParseCycle(); - //xOffset = 0; - Render(); + //xOffset = 0; + Render(); - // if the BA counter is nonzero, allow CPU bus access - UpdateBA(); - pinAEC = false; + // if the BA counter is nonzero, allow CPU bus access + UpdateBA(); + pinAEC = false; - // must always come last - //UpdatePins(); - } - } + // must always come last + //UpdatePins(); + } + } - public void ExecutePhase2() - { + public void ExecutePhase2() + { - { - ParseCycle(); + { + ParseCycle(); - // advance cycle and optionally raster line - cycle++; - if (cycle == totalCycles) - { - if (rasterLine == borderB) - borderOnVertical = true; - if (rasterLine == borderT && displayEnable) - borderOnVertical = false; + // advance cycle and optionally raster line + cycle++; + if (cycle == totalCycles) + { + if (rasterLine == borderB) + borderOnVertical = true; + if (rasterLine == borderT && displayEnable) + borderOnVertical = false; - if (rasterLine == vblankStart) - vblank = true; - if (rasterLine == vblankEnd) - vblank = false; + if (rasterLine == vblankStart) + vblank = true; + if (rasterLine == vblankEnd) + vblank = false; - cycleIndex = 0; - cycle = 0; - rasterLine++; - if (rasterLine == totalLines) - { - rasterLine = 0; - vcbase = 0; - vc = 0; - } - } + cycleIndex = 0; + cycle = 0; + rasterLine++; + if (rasterLine == totalLines) + { + rasterLine = 0; + vcbase = 0; + vc = 0; + } + } - Render(); - UpdateBA(); - pinAEC = (baCount > 0); + Render(); + UpdateBA(); + pinAEC = (baCount > 0); - // must always come last - UpdatePins(); - } - } + // must always come last + UpdatePins(); + } + } - private void UpdateBA() + private void UpdateBA() { if (pinBA) baCount = baResetCounter; @@ -163,8 +163,8 @@ namespace BizHawk.Emulation.Computers.Commodore64.MOS { borderL = columnSelect ? 0x018 : 0x01F; borderR = columnSelect ? 0x158 : 0x14F; - //borderL = columnSelect ? 28 : 35; - //borderR = columnSelect ? 348 : 339; + //borderL = columnSelect ? 28 : 35; + //borderR = columnSelect ? 348 : 339; borderT = rowSelect ? 0x033 : 0x037; borderB = rowSelect ? 0x0FB : 0x0F7; } @@ -177,39 +177,39 @@ namespace BizHawk.Emulation.Computers.Commodore64.MOS (enableIntSpriteCollision & intSpriteCollision) | (enableIntLightPen & intLightPen)); - irqShift <<= 1; - irqShift |= (irqTemp ? 0x1 : 0x0); - pinIRQ = (irqShift & 0x1) != 0; + irqShift <<= 1; + irqShift |= (irqTemp ? 0x1 : 0x0); + pinIRQ = (irqShift & 0x1) != 0; } - private void UpdateVideoMode() - { - if (!extraColorMode && !bitmapMode && !multicolorMode) - { - videoMode = VicVideoMode.Mode000; - return; - } - else if (!extraColorMode && !bitmapMode && multicolorMode) - { - videoMode = VicVideoMode.Mode001; - return; - } - else if (!extraColorMode && bitmapMode && !multicolorMode) - { - videoMode = VicVideoMode.Mode010; - return; - } - else if (!extraColorMode && bitmapMode && multicolorMode) - { - videoMode = VicVideoMode.Mode011; - return; - } - else if (extraColorMode && !bitmapMode && !multicolorMode) - { - videoMode = VicVideoMode.Mode100; - return; - } - videoMode = VicVideoMode.ModeBad; - } + private void UpdateVideoMode() + { + if (!extraColorMode && !bitmapMode && !multicolorMode) + { + videoMode = VicVideoMode.Mode000; + return; + } + else if (!extraColorMode && !bitmapMode && multicolorMode) + { + videoMode = VicVideoMode.Mode001; + return; + } + else if (!extraColorMode && bitmapMode && !multicolorMode) + { + videoMode = VicVideoMode.Mode010; + return; + } + else if (!extraColorMode && bitmapMode && multicolorMode) + { + videoMode = VicVideoMode.Mode011; + return; + } + else if (extraColorMode && !bitmapMode && !multicolorMode) + { + videoMode = VicVideoMode.Mode100; + return; + } + videoMode = VicVideoMode.ModeBad; + } } } diff --git a/BizHawk.Emulation/Computers/Commodore64/Media/D64.cs b/BizHawk.Emulation/Computers/Commodore64/Media/D64.cs index 63e91a4c12..26868b2276 100644 --- a/BizHawk.Emulation/Computers/Commodore64/Media/D64.cs +++ b/BizHawk.Emulation/Computers/Commodore64/Media/D64.cs @@ -1,7 +1,7 @@ using System; using System.IO; -namespace BizHawk.Emulation.Computers.Commodore64.Media +namespace BizHawk.Emulation.Cores.Computers.Commodore64 { public static class D64 { diff --git a/BizHawk.Emulation/Computers/Commodore64/Media/Disk.cs b/BizHawk.Emulation/Computers/Commodore64/Media/Disk.cs index bc46eb30f1..013018df01 100644 --- a/BizHawk.Emulation/Computers/Commodore64/Media/Disk.cs +++ b/BizHawk.Emulation/Computers/Commodore64/Media/Disk.cs @@ -1,6 +1,6 @@ using System.Collections.Generic; -namespace BizHawk.Emulation.Computers.Commodore64.Media +namespace BizHawk.Emulation.Cores.Computers.Commodore64 { public class Track { diff --git a/BizHawk.Emulation/Computers/Commodore64/Media/G64.cs b/BizHawk.Emulation/Computers/Commodore64/Media/G64.cs index 12412403c6..451e2c2258 100644 --- a/BizHawk.Emulation/Computers/Commodore64/Media/G64.cs +++ b/BizHawk.Emulation/Computers/Commodore64/Media/G64.cs @@ -1,6 +1,6 @@ using System.IO; -namespace BizHawk.Emulation.Computers.Commodore64.Media +namespace BizHawk.Emulation.Cores.Computers.Commodore64 { public static class G64 { diff --git a/BizHawk.Emulation/Computers/Commodore64/Media/PRG.cs b/BizHawk.Emulation/Computers/Commodore64/Media/PRG.cs index c90cb8e991..264eb21a3b 100644 --- a/BizHawk.Emulation/Computers/Commodore64/Media/PRG.cs +++ b/BizHawk.Emulation/Computers/Commodore64/Media/PRG.cs @@ -1,6 +1,4 @@ -using BizHawk.Emulation.Computers.Commodore64.MOS; - -namespace BizHawk.Emulation.Computers.Commodore64.Media +namespace BizHawk.Emulation.Cores.Computers.Commodore64 { public static class PRG { diff --git a/BizHawk.Emulation/Computers/Commodore64/SaveState.cs b/BizHawk.Emulation/Computers/Commodore64/SaveState.cs index 413a059e21..65db8bc4d0 100644 --- a/BizHawk.Emulation/Computers/Commodore64/SaveState.cs +++ b/BizHawk.Emulation/Computers/Commodore64/SaveState.cs @@ -8,158 +8,158 @@ using System.Text; using BizHawk.Common; -namespace BizHawk.Emulation.Computers.Commodore64 +namespace BizHawk.Emulation.Cores.Computers.Commodore64 { - static class SaveState - { - static public void SyncObject(Serializer ser, object obj) - { - BindingFlags defaultFlags = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.FlattenHierarchy; - MemberInfo[] members = obj.GetType().GetMembers(defaultFlags); + static class SaveState + { + static public void SyncObject(Serializer ser, object obj) + { + BindingFlags defaultFlags = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.FlattenHierarchy; + MemberInfo[] members = obj.GetType().GetMembers(defaultFlags); - Bit refBit; - Boolean refBool; - Byte refByte; - ByteBuffer refByteBuffer; - Int16 refInt16; - Int32 refInt32; - IntBuffer refIntBuffer; - Int32 refPointX; - Int32 refPointY; - SByte refSByte; - UInt16 refUInt16; - UInt32 refUInt32; - Int32 refRectHeight; - Int32 refRectWidth; + Bit refBit; + Boolean refBool; + Byte refByte; + ByteBuffer refByteBuffer; + Int16 refInt16; + Int32 refInt32; + IntBuffer refIntBuffer; + Int32 refPointX; + Int32 refPointY; + SByte refSByte; + UInt16 refUInt16; + UInt32 refUInt32; + Int32 refRectHeight; + Int32 refRectWidth; - foreach (MemberInfo member in members) - { - object currentValue = null; - bool fail = false; - FieldInfo fieldInfo = null; - PropertyInfo propInfo = null; - Type valueType = null; + foreach (MemberInfo member in members) + { + object currentValue = null; + bool fail = false; + FieldInfo fieldInfo = null; + PropertyInfo propInfo = null; + Type valueType = null; - if (member.MemberType == MemberTypes.Field) - { - fieldInfo = member.ReflectedType.GetField(member.Name, defaultFlags); - valueType = fieldInfo.FieldType; - currentValue = fieldInfo.GetValue(obj); - } - else - { - fail = true; - } + if (member.MemberType == MemberTypes.Field) + { + fieldInfo = member.ReflectedType.GetField(member.Name, defaultFlags); + valueType = fieldInfo.FieldType; + currentValue = fieldInfo.GetValue(obj); + } + else + { + fail = true; + } - if (!fail) - { - if (valueType.IsArray) - { - } + if (!fail) + { + if (valueType.IsArray) + { + } - if (currentValue != null) - { - switch (valueType.Name) - { - case "Bit": - refBit = (Bit)currentValue; - ser.Sync(member.Name, ref refBit); - currentValue = refBit; - break; - case "Boolean": - refBool = (Boolean)currentValue; - ser.Sync(member.Name, ref refBool); - currentValue = refBool; - break; - case "Byte": - refByte = (Byte)currentValue; - ser.Sync(member.Name, ref refByte); - currentValue = refByte; - break; - case "Byte[]": - refByteBuffer = new ByteBuffer((byte[])currentValue); - ser.Sync(member.Name, ref refByteBuffer); - currentValue = refByteBuffer.arr; - break; - case "ByteBuffer": - refByteBuffer = (ByteBuffer)currentValue; - ser.Sync(member.Name, ref refByteBuffer); - currentValue = refByteBuffer; - break; - case "Int16": - refInt16 = (Int16)currentValue; - ser.Sync(member.Name, ref refInt16); - currentValue = refInt16; - break; - case "Int32": - refInt32 = (Int32)currentValue; - ser.Sync(member.Name, ref refInt32); - currentValue = refInt32; - break; - case "Int32[]": - refIntBuffer = new IntBuffer((int[])currentValue); - ser.Sync(member.Name, ref refIntBuffer); - currentValue = refIntBuffer.arr; - break; - case "IntBuffer": - refIntBuffer = (IntBuffer)currentValue; - ser.Sync(member.Name, ref refIntBuffer); - currentValue = refIntBuffer; - break; - case "Point": - refPointX = ((Point)currentValue).X; - refPointY = ((Point)currentValue).Y; - ser.Sync(member.Name + "_X", ref refPointX); - ser.Sync(member.Name + "_Y", ref refPointY); - currentValue = new Point(refPointX, refPointY); - break; - case "Rectangle": - refPointX = ((Rectangle)currentValue).X; - refPointY = ((Rectangle)currentValue).Y; - refRectWidth = ((Rectangle)currentValue).Width; - refRectHeight = ((Rectangle)currentValue).Height; - ser.Sync(member.Name + "_X", ref refPointX); - ser.Sync(member.Name + "_Y", ref refPointY); - ser.Sync(member.Name + "_Height", ref refRectHeight); - ser.Sync(member.Name + "_Width", ref refRectWidth); - currentValue = new Rectangle(refPointX, refPointY, refRectWidth, refRectHeight); - break; - case "SByte": - refSByte = (SByte)currentValue; - ser.Sync(member.Name, ref refSByte); - currentValue = refSByte; - break; - case "UInt16": - refUInt16 = (UInt16)currentValue; - ser.Sync(member.Name, ref refUInt16); - currentValue = refUInt16; - break; - case "UInt32": - refUInt32 = (UInt32)currentValue; - ser.Sync(member.Name, ref refUInt32); - currentValue = refUInt32; - break; - default: - fail = true; - break; - } - } + if (currentValue != null) + { + switch (valueType.Name) + { + case "Bit": + refBit = (Bit)currentValue; + ser.Sync(member.Name, ref refBit); + currentValue = refBit; + break; + case "Boolean": + refBool = (Boolean)currentValue; + ser.Sync(member.Name, ref refBool); + currentValue = refBool; + break; + case "Byte": + refByte = (Byte)currentValue; + ser.Sync(member.Name, ref refByte); + currentValue = refByte; + break; + case "Byte[]": + refByteBuffer = new ByteBuffer((byte[])currentValue); + ser.Sync(member.Name, ref refByteBuffer); + currentValue = refByteBuffer.arr; + break; + case "ByteBuffer": + refByteBuffer = (ByteBuffer)currentValue; + ser.Sync(member.Name, ref refByteBuffer); + currentValue = refByteBuffer; + break; + case "Int16": + refInt16 = (Int16)currentValue; + ser.Sync(member.Name, ref refInt16); + currentValue = refInt16; + break; + case "Int32": + refInt32 = (Int32)currentValue; + ser.Sync(member.Name, ref refInt32); + currentValue = refInt32; + break; + case "Int32[]": + refIntBuffer = new IntBuffer((int[])currentValue); + ser.Sync(member.Name, ref refIntBuffer); + currentValue = refIntBuffer.arr; + break; + case "IntBuffer": + refIntBuffer = (IntBuffer)currentValue; + ser.Sync(member.Name, ref refIntBuffer); + currentValue = refIntBuffer; + break; + case "Point": + refPointX = ((Point)currentValue).X; + refPointY = ((Point)currentValue).Y; + ser.Sync(member.Name + "_X", ref refPointX); + ser.Sync(member.Name + "_Y", ref refPointY); + currentValue = new Point(refPointX, refPointY); + break; + case "Rectangle": + refPointX = ((Rectangle)currentValue).X; + refPointY = ((Rectangle)currentValue).Y; + refRectWidth = ((Rectangle)currentValue).Width; + refRectHeight = ((Rectangle)currentValue).Height; + ser.Sync(member.Name + "_X", ref refPointX); + ser.Sync(member.Name + "_Y", ref refPointY); + ser.Sync(member.Name + "_Height", ref refRectHeight); + ser.Sync(member.Name + "_Width", ref refRectWidth); + currentValue = new Rectangle(refPointX, refPointY, refRectWidth, refRectHeight); + break; + case "SByte": + refSByte = (SByte)currentValue; + ser.Sync(member.Name, ref refSByte); + currentValue = refSByte; + break; + case "UInt16": + refUInt16 = (UInt16)currentValue; + ser.Sync(member.Name, ref refUInt16); + currentValue = refUInt16; + break; + case "UInt32": + refUInt32 = (UInt32)currentValue; + ser.Sync(member.Name, ref refUInt32); + currentValue = refUInt32; + break; + default: + fail = true; + break; + } + } - if (member.MemberType == MemberTypes.Property) - { - if (propInfo.CanWrite && !fail) - { - MethodInfo setMethod = propInfo.GetSetMethod(); - setMethod.Invoke(obj, new object[] { currentValue }); - } - } + if (member.MemberType == MemberTypes.Property) + { + if (propInfo.CanWrite && !fail) + { + MethodInfo setMethod = propInfo.GetSetMethod(); + setMethod.Invoke(obj, new object[] { currentValue }); + } + } - if (member.MemberType == MemberTypes.Field) - { - fieldInfo.SetValue(obj, currentValue); - } - } - } - } - } + if (member.MemberType == MemberTypes.Field) + { + fieldInfo.SetValue(obj, currentValue); + } + } + } + } + } } diff --git a/BizHawk.Emulation/Computers/Commodore64/Tape/VIC1530.cs b/BizHawk.Emulation/Computers/Commodore64/Tape/VIC1530.cs index 382e7be6ba..095cf467bb 100644 --- a/BizHawk.Emulation/Computers/Commodore64/Tape/VIC1530.cs +++ b/BizHawk.Emulation/Computers/Commodore64/Tape/VIC1530.cs @@ -1,4 +1,4 @@ -namespace BizHawk.Emulation.Computers.Commodore64.Tape +namespace BizHawk.Emulation.Cores.Computers.Commodore64 { // common tape drive that works with the C64.