diff --git a/BizHawk.Emulation/BizHawk.Emulation.csproj b/BizHawk.Emulation/BizHawk.Emulation.csproj
index e25d81f431..5902044d52 100644
--- a/BizHawk.Emulation/BizHawk.Emulation.csproj
+++ b/BizHawk.Emulation/BizHawk.Emulation.csproj
@@ -104,14 +104,19 @@
+
+
+
+
-
+
+
-
+
@@ -123,15 +128,10 @@
-
-
-
-
-
diff --git a/BizHawk.Emulation/Computers/Commodore64/Experimental/C64.Glue.cs b/BizHawk.Emulation/Computers/Commodore64/Experimental/C64.Glue.cs
index cba091d104..a1440806c3 100644
--- a/BizHawk.Emulation/Computers/Commodore64/Experimental/C64.Glue.cs
+++ b/BizHawk.Emulation/Computers/Commodore64/Experimental/C64.Glue.cs
@@ -132,13 +132,6 @@ namespace BizHawk.Emulation.Computers.Commodore64.Experimental
);
}
- bool ReadReset()
- {
- return (
- expansion.Reset
- );
- }
-
bool ReadSerialATN()
{
return (cia2.PortA & 0x08) != 0;
diff --git a/BizHawk.Emulation/Computers/Commodore64/Experimental/C64.cs b/BizHawk.Emulation/Computers/Commodore64/Experimental/C64.cs
index 510a62eac0..43e56d840f 100644
--- a/BizHawk.Emulation/Computers/Commodore64/Experimental/C64.cs
+++ b/BizHawk.Emulation/Computers/Commodore64/Experimental/C64.cs
@@ -33,13 +33,6 @@ namespace BizHawk.Emulation.Computers.Commodore64.Experimental
public void ExecuteFrame()
{
- vic.Clock();
- vic.Clock();
- vic.Clock();
- vic.Clock();
- vic.Precache();
- cpu.Clock();
- cpu.Precache();
}
public byte PeekBasicRom(int addr)
diff --git a/BizHawk.Emulation/Computers/Commodore64/Experimental/C64PAL.cs b/BizHawk.Emulation/Computers/Commodore64/Experimental/C64PAL.cs
index 9dd0eabec7..fd8830b104 100644
--- a/BizHawk.Emulation/Computers/Commodore64/Experimental/C64PAL.cs
+++ b/BizHawk.Emulation/Computers/Commodore64/Experimental/C64PAL.cs
@@ -11,26 +11,26 @@ namespace BizHawk.Emulation.Computers.Commodore64.Experimental
{
static private C64Timing timing;
- public C64PAL() : base(timing)
+ public C64PAL(byte[] basic, byte[] kernal, byte[] character) : base(timing)
{
- this.basicRom = new Rom2364();
+ this.basicRom = Presets.Rom2364(basic);
this.cassette = new Cassette();
- this.characterRom = new Rom2332();
- this.cia1 = new Cia();
- this.cia2 = new Cia();
- this.colorRam = new Ram2114();
+ this.characterRom = Presets.Rom2332(character);
+ this.cia1 = Presets.Cia6526(true);
+ this.cia2 = Presets.Cia6526(true);
+ this.colorRam = Presets.Ram2114();
this.cpu = new Cpu();
this.expansion = new Expansion();
this.joystickA = new Joystick();
this.joystickB = new Joystick();
- this.kernalRom = new Rom2364();
+ this.kernalRom = Presets.Rom2364(kernal);
this.keyboard = new Keyboard();
- this.memory = new Ram4864();
+ this.memory = Presets.Ram4864();
this.pla = new Pla();
this.serial = new Serial();
- this.sid = new MOS6581();
+ this.sid = Presets.Sid6581();
this.user = new Userport();
- this.vic = new MOS6569();
+ this.vic = Presets.Vic6569();
InitializeConnections();
}
}
diff --git a/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Cassette.cs b/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Cassette.cs
index c55329589b..169f2ac1eb 100644
--- a/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Cassette.cs
+++ b/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Cassette.cs
@@ -13,10 +13,7 @@ namespace BizHawk.Emulation.Computers.Commodore64.Experimental.Chips.Internals
virtual public bool Data { get { return true; } }
public bool OutputData() { return Data; }
public bool OutputSense() { return Sense; }
- virtual public int Peek(int addr) { return 0xFF; }
- virtual public void Poke(int addr, int val) { }
- virtual public void Precache() { }
virtual public bool Sense { get { return true; } }
- virtual public void SyncState(Serializer ser) { }
+ virtual public void SyncState(Serializer ser) { Sync.SyncObject(ser, this); }
}
}
diff --git a/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Cia.Interface.cs b/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Cia.Interface.cs
index d455cc82b4..0c32a7edb4 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;
namespace BizHawk.Emulation.Computers.Commodore64.Experimental.Chips.Internals
{
- public partial class Cia
+ sealed public partial class Cia
{
public Func InputCNT;
public Func InputFlag;
@@ -24,9 +24,10 @@ namespace BizHawk.Emulation.Computers.Commodore64.Experimental.Chips.Internals
public bool PC { get { return true; } }
public int PortA { get { return 0xFF; } }
public int PortB { get { return 0xFF; } }
+ public bool PortA0 { get { return true; } }
public bool SP { get { return true; } }
public void Clock() { }
- public void Precache() { }
+ public void SyncState(Serializer ser) { Sync.SyncObject(ser, this); }
}
}
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 3051158da5..7de0583667 100644
--- a/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Cia.Internal.cs
+++ b/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Cia.Internal.cs
@@ -5,25 +5,15 @@ using System.Text;
namespace BizHawk.Emulation.Computers.Commodore64.Experimental.Chips.Internals
{
- public partial class Cia
+ sealed public partial class Cia
{
- public int Peek(int addr)
+ public Cia(CiaSettings settings)
{
- return 0xFF;
+ Reset();
}
- public void Poke(int addr, int val)
+ public void Reset()
{
}
-
- public int Read(int addr)
- {
- return Peek(addr);
- }
-
- public void Write(int addr, int val)
- {
- Poke(addr, val);
- }
}
}
diff --git a/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Cia.Registers.cs b/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Cia.Registers.cs
new file mode 100644
index 0000000000..42b831199c
--- /dev/null
+++ b/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Cia.Registers.cs
@@ -0,0 +1,29 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace BizHawk.Emulation.Computers.Commodore64.Experimental.Chips.Internals
+{
+ sealed public partial class Cia
+ {
+ public int Peek(int addr)
+ {
+ return 0xFF;
+ }
+
+ public void Poke(int addr, int val)
+ {
+ }
+
+ public int Read(int addr)
+ {
+ return Peek(addr);
+ }
+
+ public void Write(int addr, int val)
+ {
+ Poke(addr, val);
+ }
+ }
+}
diff --git a/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Ram2114.cs b/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Cia.Settings.cs
similarity index 60%
rename from BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Ram2114.cs
rename to BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Cia.Settings.cs
index 04d4353edf..a8f2b16629 100644
--- a/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Ram2114.cs
+++ b/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Cia.Settings.cs
@@ -3,10 +3,9 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
-namespace BizHawk.Emulation.Computers.Commodore64.Experimental.Chips
+namespace BizHawk.Emulation.Computers.Commodore64.Experimental.Chips.Internals
{
- public class Ram2114 : Internals.Ram
+ public class CiaSettings
{
- public Ram2114() : base(0x800, 0x7FF, 0xF) { }
}
}
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 dc57b2bc43..7531cf0e12 100644
--- a/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Cpu.Interface.cs
+++ b/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Cpu.Interface.cs
@@ -24,16 +24,15 @@ namespace BizHawk.Emulation.Computers.Commodore64.Experimental.Chips.Internals
public bool OutputPort5() { return Port5; }
public bool OutputPort6() { return Port6; }
public bool OutputPort7() { return Port7; }
- public int Port { get { return cachedPort; } }
- public bool Port0 { get { return (cachedPort & 0x01) != 0; } }
- public bool Port1 { get { return (cachedPort & 0x02) != 0; } }
- public bool Port2 { get { return (cachedPort & 0x04) != 0; } }
- public bool Port3 { get { return (cachedPort & 0x08) != 0; } }
- public bool Port4 { get { return (cachedPort & 0x10) != 0; } }
- public bool Port5 { get { return (cachedPort & 0x20) != 0; } }
- public bool Port6 { get { return (cachedPort & 0x40) != 0; } }
- public bool Port7 { get { return (cachedPort & 0x80) != 0; } }
- public void Precache() { }
- public void SyncState(Serializer ser) { }
+ public int Port { get { return (portLatch | (~portDirection)) & 0xFF; } }
+ public bool Port0 { get { return (Port & 0x01) != 0; } }
+ public bool Port1 { get { return (Port & 0x02) != 0; } }
+ public bool Port2 { get { return (Port & 0x04) != 0; } }
+ public bool Port3 { get { return (Port & 0x08) != 0; } }
+ public bool Port4 { get { return (Port & 0x10) != 0; } }
+ public bool Port5 { get { return (Port & 0x20) != 0; } }
+ public bool Port6 { get { return (Port & 0x40) != 0; } }
+ public bool Port7 { get { return (Port & 0x80) != 0; } }
+ public void SyncState(Serializer ser) { Sync.SyncObject(ser, this); }
}
}
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 2abcebafd2..9e887631ea 100644
--- a/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Cpu.Internal.cs
+++ b/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Cpu.Internal.cs
@@ -11,7 +11,6 @@ namespace BizHawk.Emulation.Computers.Commodore64.Experimental.Chips.Internals
int cachedAddress;
int cachedData;
bool cachedNMI;
- int cachedPort;
int delayCycles;
bool nmiBuffer;
int portDirection;
diff --git a/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Expansion.cs b/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Expansion.cs
index 536551a77e..5c03af9182 100644
--- a/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Expansion.cs
+++ b/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Expansion.cs
@@ -7,36 +7,14 @@ namespace BizHawk.Emulation.Computers.Commodore64.Experimental.Chips.Internals
{
public class Expansion
{
- public Func InputAddress;
- public Func InputBA;
- public Func InputData;
- public Func InputDotClock;
- public Func InputHiExpansion;
- public Func InputHiRom;
- public Func InputIRQ;
- public Func InputLoExpansion;
- public Func InputLoRom;
- public Func InputNMI;
- public Func InputRead;
- public Func InputReset;
-
- virtual public int Address { get { return 0xFFFF; } }
- virtual public int Data { get { return 0xFF; } }
virtual public bool ExRom { get { return true; } }
virtual public bool Game { get { return true; } }
virtual public bool IRQ { get { return true; } }
virtual public bool NMI { get { return true; } }
- public int OutputAddress() { return Address; }
- public int OutputData() { return Data; }
public bool OutputExRom() { return ExRom; }
public bool OutputGame() { return Game; }
public bool OutputIRQ() { return IRQ; }
public bool OutputNMI() { return NMI; }
- public bool OutputRead() { return Read; }
- public bool OutputReset() { return Reset; }
- virtual public void Precache() { }
- virtual public bool Read { get { return true; } }
- virtual public bool Reset { get { return true; } }
- virtual public void SyncState(Serializer ser) { }
+ virtual public void SyncState(Serializer ser) { Sync.SyncObject(ser, this); }
}
}
diff --git a/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Joystick.cs b/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Joystick.cs
index 4039c03f75..cae7c1b705 100644
--- a/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Joystick.cs
+++ b/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Joystick.cs
@@ -7,13 +7,10 @@ namespace BizHawk.Emulation.Computers.Commodore64.Experimental.Chips.Internals
{
public class Joystick
{
- virtual public int Data { get { return 0x1F; } }
+ virtual public int Data { get { return 0xFF; } }
public int OutputData() { return Data; }
- public int OutputPotX() { return PotX; }
- public int OutputPotY() { return PotY; }
- virtual public int PotX { get { return 0xFF; } }
- virtual public int PotY { get { return 0xFF; } }
- virtual public void Precache() { }
- virtual public void SyncState(Serializer ser) { }
+ public int OutputPot() { return Pot; }
+ virtual public int Pot { get { return 0xFF; } }
+ virtual public void SyncState(Serializer ser) { Sync.SyncObject(ser, this); }
}
}
diff --git a/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Keyboard.cs b/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Keyboard.cs
index bfedcff1ef..3c04846d54 100644
--- a/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Keyboard.cs
+++ b/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Keyboard.cs
@@ -11,9 +11,8 @@ namespace BizHawk.Emulation.Computers.Commodore64.Experimental.Chips.Internals
public int OutputColumn() { return Column; }
public bool OutputRestore() { return Restore; }
public int OutputRow() { return Row; }
- virtual public void Precache() { }
virtual public bool Restore { get { return true; } }
virtual public int Row { get { return 0xFF; } }
- virtual public void SyncState(Serializer ser) { }
+ virtual public void SyncState(Serializer ser) { Sync.SyncObject(ser, this); }
}
}
diff --git a/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Pla.cs b/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Pla.cs
index b28ff37f9f..3ad999bb9d 100644
--- a/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Pla.cs
+++ b/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Pla.cs
@@ -79,29 +79,6 @@ namespace BizHawk.Emulation.Computers.Commodore64.Experimental.Chips.Internals
ExpansionHi
}
- bool p0;
- bool p1;
- bool p2;
- bool p3;
- bool p4;
- bool p5;
- bool p6;
- bool p7;
- bool p9;
- bool p11;
- bool p13;
- bool p15;
- bool p17;
- bool p19;
- bool p20;
- bool p21;
- bool p22;
- bool p23;
- bool p24;
- bool p25;
- bool p26;
- bool p27;
- bool p28;
bool loram;
bool hiram;
bool game;
@@ -222,6 +199,7 @@ namespace BizHawk.Emulation.Computers.Commodore64.Experimental.Chips.Internals
loram = InputLoRam();
hiram = InputHiRam();
game = InputGame();
+ exrom = InputExRom();
a15 = (addr & 0x08000) != 0;
a14 = (addr & 0x04000) != 0;
@@ -258,39 +236,31 @@ namespace BizHawk.Emulation.Computers.Commodore64.Experimental.Chips.Internals
}
}
- // cartridge high, banked either at A000-BFFF or E000-FFFF depending
- exrom = InputExRom();
- if (a13 && !game && ((hiram && !a14 && read && !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 && read && !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 && read && (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 && read && 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)
- {
- p24 = !a15 && !a14 && a12;
- p25 = !a15 && !a14 && a13;
- p26 = !a15 && a14;
- p27 = a15 && !a14 && a13;
- p28 = a15 && a14 && !a13 && !a12;
- if (!(p24 || p25 || p26 || p27 || p28))
- return PLABank.RAM;
- }
- else
- return PLABank.RAM;
+ if (exrom && !game && ((a15 && ((!a14 && a13) || (a14 && !a13 && !a12))) || (!a15 && (a14 || (!a14 && (a12 || a13))))))
+ return PLABank.None;
- return PLABank.None;
+ return PLABank.RAM;
}
public int VicRead(int addr)
diff --git a/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Ram.cs b/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Ram.cs
index d8183caf1b..efde441f60 100644
--- a/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Ram.cs
+++ b/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Ram.cs
@@ -5,19 +5,39 @@ using System.Text;
namespace BizHawk.Emulation.Computers.Commodore64.Experimental.Chips.Internals
{
- public class Ram : Rom
+ sealed public class Ram
{
- public Func InputRead;
+ protected int addressMask;
+ protected int dataMask;
+ protected int[] memory;
public Ram(int size, int addressMask, int dataMask)
- : base(size, addressMask, dataMask)
{
+ this.addressMask = addressMask;
+ this.dataMask = dataMask;
+ this.memory = new int[size];
}
- virtual public void Execute()
+ public int Peek(int addr)
{
- if (!InputRead())
- memory[InputAddress() & addressMask] = InputData() & dataMask;
+ return memory[addr & addressMask];
}
+
+ public void Poke(int addr, int val)
+ {
+ memory[addr & addressMask] = val;
+ }
+
+ public int Read(int addr)
+ {
+ return memory[addr & addressMask];
+ }
+
+ public void Write(int addr, int val)
+ {
+ memory[addr & addressMask] = val & dataMask;
+ }
+
+ public void SyncState(Serializer ser) { Sync.SyncObject(ser, this); }
}
}
diff --git a/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Rom.cs b/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Rom.cs
index 046281574e..e8a7d8635d 100644
--- a/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Rom.cs
+++ b/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Rom.cs
@@ -7,30 +7,27 @@ namespace BizHawk.Emulation.Computers.Commodore64.Experimental.Chips.Internals
{
public class Rom
{
- public Func InputAddress;
- public Func InputData;
-
protected int addressMask;
- protected int dataMask;
protected int[] memory;
- public Rom(int size, int addressMask, int dataMask)
+ public Rom(int size, int addressMask, byte[] data)
{
this.addressMask = addressMask;
- this.dataMask = dataMask;
this.memory = new int[size];
+ for (int i = 0; i < size; i++)
+ memory[i] = data[i];
}
- virtual public int Data
+ public int Peek(int addr)
{
- get
- {
- return memory[InputAddress() & addressMask] & dataMask;
- }
+ return memory[addr & addressMask];
}
- public int OutputData() { return Data; }
- virtual public void Precache() { }
- virtual public void SyncState(Serializer ser) { }
+ public int Read(int addr)
+ {
+ return memory[addr & addressMask];
+ }
+
+ public void SyncState(Serializer ser) { Sync.SyncObject(ser, this); }
}
}
diff --git a/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Serial.cs b/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Serial.cs
index cc3ed9220b..50f929d75a 100644
--- a/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Serial.cs
+++ b/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Serial.cs
@@ -17,8 +17,7 @@ namespace BizHawk.Emulation.Computers.Commodore64.Experimental.Chips.Internals
public bool OutputClock() { return Clock; }
public bool OutputData() { return Data; }
public bool OutputSRQ() { return SRQ; }
- virtual public void Precache() { }
virtual public bool SRQ { get { return true; } }
- virtual public void SyncState(Serializer ser) { }
+ virtual public void SyncState(Serializer ser) { Sync.SyncObject(ser, this); }
}
}
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 da1fc0019b..38caec7fa6 100644
--- a/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Sid.Interface.cs
+++ b/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Sid.Interface.cs
@@ -5,15 +5,8 @@ using System.Text;
namespace BizHawk.Emulation.Computers.Commodore64.Experimental.Chips.Internals
{
- public abstract partial class Sid
+ sealed public partial class Sid
{
- public Func InputAddress;
- public Func InputData;
- public Func InputRead;
-
- virtual public int Data { get { return 0xFF; } }
- public int OutputData() { return Data; }
- public void Precache() { }
public void SyncState(Serializer ser) { }
}
}
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 435b322156..15db6cce22 100644
--- a/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Sid.Internal.cs
+++ b/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Sid.Internal.cs
@@ -5,10 +5,19 @@ using System.Text;
namespace BizHawk.Emulation.Computers.Commodore64.Experimental.Chips.Internals
{
- public partial class Sid
+ sealed public partial class Sid
{
+ public Sid(SidSettings settings)
+ {
+ Reset();
+ }
+
public void Clock()
{
}
+
+ public void Reset()
+ {
+ }
}
}
diff --git a/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Sid.Registers.cs b/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Sid.Registers.cs
new file mode 100644
index 0000000000..b041d2e401
--- /dev/null
+++ b/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Sid.Registers.cs
@@ -0,0 +1,29 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace BizHawk.Emulation.Computers.Commodore64.Experimental.Chips.Internals
+{
+ sealed public partial class Sid
+ {
+ public int Peek(int addr)
+ {
+ return 0xFF;
+ }
+
+ public void Poke(int addr, int val)
+ {
+ }
+
+ public int Read(int addr)
+ {
+ return Peek(addr);
+ }
+
+ public void Write(int addr, int val)
+ {
+ Poke(addr, val);
+ }
+ }
+}
diff --git a/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Rom2332.cs b/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Sid.Settings.cs
similarity index 59%
rename from BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Rom2332.cs
rename to BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Sid.Settings.cs
index 4b166f39e6..270f79df4f 100644
--- a/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Rom2332.cs
+++ b/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Sid.Settings.cs
@@ -3,10 +3,9 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
-namespace BizHawk.Emulation.Computers.Commodore64.Experimental.Chips
+namespace BizHawk.Emulation.Computers.Commodore64.Experimental.Chips.Internals
{
- public class Rom2332 : Internals.Rom
+ public class SidSettings
{
- public Rom2332() : base(0x1000, 0xFFF, 0xFF) { }
}
}
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 ed0807e4fb..3d5456522a 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;
namespace BizHawk.Emulation.Computers.Commodore64.Experimental.Chips.Internals
{
- public partial class Sid
+ sealed public partial class Sid
{
public ISoundProvider GetSoundProvider()
{
diff --git a/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Vic.Cache.cs b/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Vic.Cache.cs
deleted file mode 100644
index 5c304d795b..0000000000
--- a/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Vic.Cache.cs
+++ /dev/null
@@ -1,17 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-
-namespace BizHawk.Emulation.Computers.Commodore64.Experimental.Chips.Internals
-{
- public partial class Vic
- {
- public void Precache()
- {
- cachedAEC = (pixelTimer >= 4);
- cachedBA = ba;
- cachedIRQ = irq;
- }
- }
-}
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 789427ed43..5cb1592fd4 100644
--- a/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Vic.Interface.cs
+++ b/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Vic.Interface.cs
@@ -5,7 +5,7 @@ using System.Text;
namespace BizHawk.Emulation.Computers.Commodore64.Experimental.Chips.Internals
{
- public partial class Vic
+ sealed public partial class Vic
{
public Action ClockPhi0;
public Func ReadColorRam;
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 d660882466..7172cda03c 100644
--- a/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Vic.Internal.cs
+++ b/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Vic.Internal.cs
@@ -5,7 +5,7 @@ using System.Text;
namespace BizHawk.Emulation.Computers.Commodore64.Experimental.Chips.Internals
{
- public partial class Vic
+ sealed public partial class Vic
{
bool cachedAEC;
bool cachedBA;
@@ -63,13 +63,9 @@ namespace BizHawk.Emulation.Computers.Commodore64.Experimental.Chips.Internals
int videoCounterBase;
int videoMatrixLineIndex;
- public Vic()
+ public Vic(VicSettings settings)
{
- backgroundColor = new int[4];
- spriteMultiColor = new int[2];
- sprites = new Sprite[8];
- for (int i = 0; i < 8; i++)
- sprites[i] = new Sprite();
+ Reset();
}
public void Clock()
@@ -83,5 +79,14 @@ namespace BizHawk.Emulation.Computers.Commodore64.Experimental.Chips.Internals
}
pixelTimer--;
}
+
+ public void Reset()
+ {
+ backgroundColor = new int[4];
+ spriteMultiColor = new int[2];
+ sprites = new Sprite[8];
+ for (int i = 0; i < 8; i++)
+ sprites[i] = new Sprite();
+ }
}
}
diff --git a/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Vic.Registers.cs b/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Vic.Registers.cs
new file mode 100644
index 0000000000..bf19894c25
--- /dev/null
+++ b/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Vic.Registers.cs
@@ -0,0 +1,29 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace BizHawk.Emulation.Computers.Commodore64.Experimental.Chips.Internals
+{
+ sealed public partial class Vic
+ {
+ public int Peek(int addr)
+ {
+ return 0xFF;
+ }
+
+ public void Poke(int addr, int val)
+ {
+ }
+
+ public int Read(int addr)
+ {
+ return Peek(addr);
+ }
+
+ public void Write(int addr, int val)
+ {
+ Poke(addr, val);
+ }
+ }
+}
diff --git a/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Rom2364.cs b/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Vic.Settings.cs
similarity index 59%
rename from BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Rom2364.cs
rename to BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Vic.Settings.cs
index c0bc7797a5..58b8e5d909 100644
--- a/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Rom2364.cs
+++ b/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Vic.Settings.cs
@@ -3,10 +3,9 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
-namespace BizHawk.Emulation.Computers.Commodore64.Experimental.Chips
+namespace BizHawk.Emulation.Computers.Commodore64.Experimental.Chips.Internals
{
- public class Rom2364 : Internals.Rom
+ public class VicSettings
{
- public Rom2364() : base(0x2000, 0x1FFF, 0xFF) { }
}
}
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 a0ae83be0c..e3f1e052d2 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;
namespace BizHawk.Emulation.Computers.Commodore64.Experimental.Chips.Internals
{
- public partial class Vic
+ sealed public partial class Vic
{
public void SyncState(Serializer ser)
{
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 e1fc91426d..d3049af745 100644
--- a/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Vic.Timing.cs
+++ b/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Vic.Timing.cs
@@ -5,7 +5,7 @@ using System.Text;
namespace BizHawk.Emulation.Computers.Commodore64.Experimental.Chips.Internals
{
- public partial class Vic
+ sealed public partial class Vic
{
protected struct CycleTiming
{
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 96a42d73a6..a40d194cdd 100644
--- a/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Vic.VideoProvider.cs
+++ b/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Vic.VideoProvider.cs
@@ -5,7 +5,7 @@ using System.Text;
namespace BizHawk.Emulation.Computers.Commodore64.Experimental.Chips.Internals
{
- public partial class Vic : IVideoProvider
+ sealed public partial class Vic : IVideoProvider
{
protected int[] videoBuffer;
diff --git a/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/MOS6569.cs b/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/MOS6569.cs
deleted file mode 100644
index 3d77b287c5..0000000000
--- a/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/MOS6569.cs
+++ /dev/null
@@ -1,15 +0,0 @@
-
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-
-namespace BizHawk.Emulation.Computers.Commodore64.Experimental.Chips
-{
- public class MOS6569 : Internals.Vic
- {
- public MOS6569()
- {
- }
- }
-}
diff --git a/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/MOS6581.cs b/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/MOS6581.cs
deleted file mode 100644
index c00548b112..0000000000
--- a/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/MOS6581.cs
+++ /dev/null
@@ -1,12 +0,0 @@
-using BizHawk.Emulation.Computers.Commodore64.Experimental.Chips.Internals;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-
-namespace BizHawk.Emulation.Computers.Commodore64.Experimental.Chips
-{
- sealed public class MOS6581 : Sid
- {
- }
-}
diff --git a/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Presets.cs b/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Presets.cs
new file mode 100644
index 0000000000..9052308c07
--- /dev/null
+++ b/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Presets.cs
@@ -0,0 +1,59 @@
+using BizHawk.Emulation.Computers.Commodore64.Experimental.Chips.Internals;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace BizHawk.Emulation.Computers.Commodore64.Experimental.Chips
+{
+ static public class Presets
+ {
+ static public Cia Cia6526(bool todJumper) { return new Cia(Settings6526(todJumper)); }
+ static public Cia Cia6526A(bool todJumper) { return new Cia(Settings6526A(todJumper)); }
+ static public Cpu Cpu6510() { return new Cpu(); }
+ static public Ram Ram2114() { return new Ram(0x1000, 0x0FFF, 0x0F); }
+ static public Ram Ram4864() { return new Ram(0x10000, 0xFFFF, 0xFF); }
+ static public Rom Rom2332(byte[] data) { return new Rom(0x1000, 0xFFF, data); }
+ static public Rom Rom2364(byte[] data) { return new Rom(0x2000, 0x1FFF, data); }
+ static public Sid Sid6581() { return new Sid(Settings6581()); }
+ static public Sid Sid8580() { return new Sid(Settings8580()); }
+ static public Vic Vic6567() { return new Vic(Settings6567()); }
+ static public Vic Vic6569() { return new Vic(Settings6569()); }
+
+ static private CiaSettings Settings6526(bool todJumper)
+ {
+ CiaSettings result = new CiaSettings();
+ return result;
+ }
+
+ static private CiaSettings Settings6526A(bool todJumper)
+ {
+ CiaSettings result = new CiaSettings();
+ return result;
+ }
+
+ static private VicSettings Settings6567()
+ {
+ VicSettings result = new VicSettings();
+ return result;
+ }
+
+ static private VicSettings Settings6569()
+ {
+ VicSettings result = new VicSettings();
+ return result;
+ }
+
+ static private SidSettings Settings6581()
+ {
+ SidSettings result = new SidSettings();
+ return result;
+ }
+
+ static private SidSettings Settings8580()
+ {
+ SidSettings result = new SidSettings();
+ return result;
+ }
+ }
+}
diff --git a/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Ram4864.cs b/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Ram4864.cs
deleted file mode 100644
index 9769b11edf..0000000000
--- a/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Ram4864.cs
+++ /dev/null
@@ -1,12 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-
-namespace BizHawk.Emulation.Computers.Commodore64.Experimental.Chips
-{
- public class Ram4864 : Internals.Ram
- {
- public Ram4864() : base(0x10000, 0xFFFF, 0xFF) { }
- }
-}
diff --git a/BizHawk.Emulation/Computers/Commodore64/MOS/MOSPLA.cs b/BizHawk.Emulation/Computers/Commodore64/MOS/MOSPLA.cs
index 312be2ca8e..f1294cc913 100644
--- a/BizHawk.Emulation/Computers/Commodore64/MOS/MOSPLA.cs
+++ b/BizHawk.Emulation/Computers/Commodore64/MOS/MOSPLA.cs
@@ -268,18 +268,16 @@ namespace BizHawk.Emulation.Computers.Commodore64.MOS
// ultimax mode ram exclusion
if (exrom && !game)
{
- p24 = !a15 && !a14 && a12;
- p25 = !a15 && !a14 && a13;
- p26 = !a15 && a14;
- p27 = a15 && !a14 && a13;
- p28 = a15 && a14 && !a13 && !a12;
- if (!(p24 || p25 || p26 || p27 || p28))
- return PLABank.RAM;
+ p24 = !a15 && !a14 && a12; //00x1 1000-1FFF, 3000-3FFF
+ p25 = !a15 && !a14 && a13; //001x 2000-3FFF
+ p26 = !a15 && a14; //01xx 4000-7FFF
+ p27 = a15 && !a14 && a13; //101x A000-BFFF
+ p28 = a15 && a14 && !a13 && !a12; //1100 C000-CFFF
+ if (p24 || p25 || p26 || p27 || p28)
+ return PLABank.None;
}
- else
- return PLABank.RAM;
- return PLABank.None;
+ return PLABank.RAM;
}
public byte Peek(int addr)