diff --git a/BizHawk.Emulation/BizHawk.Emulation.csproj b/BizHawk.Emulation/BizHawk.Emulation.csproj
index beead85920..567a5e8a92 100644
--- a/BizHawk.Emulation/BizHawk.Emulation.csproj
+++ b/BizHawk.Emulation/BizHawk.Emulation.csproj
@@ -84,7 +84,9 @@
+
+
diff --git a/BizHawk.Emulation/Computers/Commodore64/C64.Core.cs b/BizHawk.Emulation/Computers/Commodore64/C64.Core.cs
index 3dac6bc654..10fee93354 100644
--- a/BizHawk.Emulation/Computers/Commodore64/C64.Core.cs
+++ b/BizHawk.Emulation/Computers/Commodore64/C64.Core.cs
@@ -167,10 +167,7 @@ namespace BizHawk.Emulation.Computers.Commodore64
public void ExecutePhase1()
{
- // sync cartridge lines (these can change)
- pla.ExRom = cartPort.ExRom;
- pla.Game = cartPort.Game;
-
+ pla.UpdatePins();
cia0.ExecutePhase1();
cia1.ExecutePhase1();
sid.ExecutePhase1();
@@ -180,6 +177,7 @@ namespace BizHawk.Emulation.Computers.Commodore64
public void ExecutePhase2()
{
+ pla.UpdatePins();
cia0.ExecutePhase2();
cia1.ExecutePhase2();
sid.ExecutePhase2();
diff --git a/BizHawk.Emulation/Computers/Commodore64/Cartridges/Cartridge.cs b/BizHawk.Emulation/Computers/Commodore64/Cartridges/Cartridge.cs
index a5d3ce9f1b..6c5de8dbeb 100644
--- a/BizHawk.Emulation/Computers/Commodore64/Cartridges/Cartridge.cs
+++ b/BizHawk.Emulation/Computers/Commodore64/Cartridges/Cartridge.cs
@@ -70,9 +70,15 @@ namespace BizHawk.Emulation.Computers.Commodore64.Cartridges
case 0x0005:
result = new Mapper0005(chipAddress, chipBank, chipData);
break;
+ case 0x000B:
+ result = new Mapper000B(chipAddress, chipBank, chipData);
+ break;
case 0x000F:
result = new Mapper000F(chipAddress, chipBank, chipData);
break;
+ case 0x0011:
+ result = new Mapper0011(chipAddress, chipBank, chipData);
+ break;
case 0x0012:
result = new Mapper0012(chipAddress, chipBank, chipData);
break;
@@ -83,7 +89,7 @@ namespace BizHawk.Emulation.Computers.Commodore64.Cartridges
result = new Mapper0020(chipAddress, chipBank, chipData);
break;
default:
- break;
+ throw new Exception("This cartridge file uses an unrecognized mapper: " + mapper);
}
}
}
diff --git a/BizHawk.Emulation/Computers/Commodore64/Cartridges/Mapper000B.cs b/BizHawk.Emulation/Computers/Commodore64/Cartridges/Mapper000B.cs
new file mode 100644
index 0000000000..d213e379d9
--- /dev/null
+++ b/BizHawk.Emulation/Computers/Commodore64/Cartridges/Mapper000B.cs
@@ -0,0 +1,59 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace BizHawk.Emulation.Computers.Commodore64.Cartridges
+{
+ // Westermann Learning mapper.
+ // Starts up with both banks enabled, any read to DFxx
+ // turns off the high bank by bringing GAME high.
+ // I suspect that the game loads by copying all hirom to
+ // the RAM underneath (BASIC variable values probably)
+ // and then disables once loaded.
+
+ public class Mapper000B : Cartridge
+ {
+ private byte[] rom = new byte[0x4000];
+
+ public Mapper000B(List newAddresses, List newBanks, List newData)
+ {
+ validCartridge = false;
+
+ for (uint i = 0; i < 0x4000; i++)
+ rom[i] = 0xFF;
+
+ if (newAddresses[0] == 0x8000)
+ {
+ Array.Copy(newData[0], rom, Math.Min(newData[0].Length, 0x4000));
+ validCartridge = true;
+ }
+ }
+
+ public override byte Peek8000(int addr)
+ {
+ return rom[addr];
+ }
+
+ public override byte PeekA000(int addr)
+ {
+ return rom[addr | 0x2000];
+ }
+
+ public override byte Read8000(ushort addr)
+ {
+ return rom[addr];
+ }
+
+ public override byte ReadA000(ushort addr)
+ {
+ return rom[addr | 0x2000];
+ }
+
+ public override byte ReadDF00(ushort addr)
+ {
+ pinGame = true;
+ return base.ReadDF00(addr);
+ }
+ }
+}
diff --git a/BizHawk.Emulation/Computers/Commodore64/Cartridges/Mapper000F.cs b/BizHawk.Emulation/Computers/Commodore64/Cartridges/Mapper000F.cs
index 1349679c66..38702d0be7 100644
--- a/BizHawk.Emulation/Computers/Commodore64/Cartridges/Mapper000F.cs
+++ b/BizHawk.Emulation/Computers/Commodore64/Cartridges/Mapper000F.cs
@@ -89,7 +89,7 @@ namespace BizHawk.Emulation.Computers.Commodore64.Cartridges
BankSet(0);
}
- private void BankSet(uint index)
+ protected void BankSet(uint index)
{
bankNumber = index & bankMask;
UpdateState();
diff --git a/BizHawk.Emulation/Computers/Commodore64/Cartridges/Mapper0011.cs b/BizHawk.Emulation/Computers/Commodore64/Cartridges/Mapper0011.cs
new file mode 100644
index 0000000000..94b19c6aa1
--- /dev/null
+++ b/BizHawk.Emulation/Computers/Commodore64/Cartridges/Mapper0011.cs
@@ -0,0 +1,37 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace BizHawk.Emulation.Computers.Commodore64.Cartridges
+{
+ // This mapper comes from Dinamic. It is in fact identical
+ // to the System 3 mapper (000F) except that bank switching is
+ // done by reads to the DExx region instead of writes.
+ // This is why mapper 0011 inherits directly from 000F.
+
+ public class Mapper0011 : Mapper000F
+ {
+ public Mapper0011(List newAddresses, List newBanks, List newData)
+ : base(newAddresses, newBanks, newData)
+ {
+ // required to pass information to base class
+ }
+
+ public override void PokeDE00(int addr, byte val)
+ {
+ // do nothing
+ }
+
+ public override byte ReadDE00(ushort addr)
+ {
+ BankSet((uint)addr);
+ return base.ReadDE00(addr);
+ }
+
+ public override void WriteDE00(ushort addr, byte val)
+ {
+ // do nothing
+ }
+ }
+}
diff --git a/BizHawk.Emulation/Computers/Commodore64/Cartridges/Mapper0013.cs b/BizHawk.Emulation/Computers/Commodore64/Cartridges/Mapper0013.cs
index 2117d2c31b..1f34f3b99f 100644
--- a/BizHawk.Emulation/Computers/Commodore64/Cartridges/Mapper0013.cs
+++ b/BizHawk.Emulation/Computers/Commodore64/Cartridges/Mapper0013.cs
@@ -100,12 +100,12 @@ namespace BizHawk.Emulation.Computers.Commodore64.Cartridges
currentBank = banks[bankNumber];
if (romEnable)
{
- pinExRom = true;
+ pinExRom = false;
pinGame = true;
}
else
{
- pinExRom = false;
+ pinExRom = true;
pinGame = true;
}
}
diff --git a/BizHawk.Emulation/Computers/Commodore64/MOS/MOSPLA.cs b/BizHawk.Emulation/Computers/Commodore64/MOS/MOSPLA.cs
index 4a01c6e264..c87e375d23 100644
--- a/BizHawk.Emulation/Computers/Commodore64/MOS/MOSPLA.cs
+++ b/BizHawk.Emulation/Computers/Commodore64/MOS/MOSPLA.cs
@@ -75,25 +75,25 @@ namespace BizHawk.Emulation.Computers.Commodore64.MOS
public bool Charen
{
get { return pinCharen; }
- set { pinCharen = value; UpdateMap(); }
+ set { if (pinCharen != value) { pinCharen = value; UpdateMap(); } }
}
public bool ExRom
{
get { return pinExRom; }
- set { pinExRom = value; UpdateMap(); }
+ set { if (pinExRom != value) { pinExRom = value; UpdateMap(); } }
}
public bool Game
{
get { return pinGame; }
- set { pinGame = value; UpdateMap(); }
+ set { if (pinGame != value) { pinGame = value; UpdateMap(); } }
}
public bool HiRam
{
get { return pinHiRam; }
- set { pinHiRam = value; UpdateMap(); }
+ set { if (pinHiRam != value) { pinHiRam = value; UpdateMap(); } }
}
public bool InputWasRead
@@ -105,7 +105,7 @@ namespace BizHawk.Emulation.Computers.Commodore64.MOS
public bool LoRam
{
get { return pinLoRam; }
- set { pinLoRam = value; UpdateMap(); }
+ set { if (pinLoRam != value) { pinLoRam = value; UpdateMap(); } }
}
public bool UltimaxMode
@@ -303,6 +303,15 @@ namespace BizHawk.Emulation.Computers.Commodore64.MOS
}
}
+ public void UpdatePins()
+ {
+ // called after all cartridge routines in case
+ // game/exrom configuration changes
+
+ Game = chips.cartPort.Game;
+ ExRom = chips.cartPort.ExRom;
+ }
+
// ------------------------------------
private PLABank Bank(ushort addr)