diff --git a/BizHawk.Emulation/Computers/Commodore64/C64.Motherboard.cs b/BizHawk.Emulation/Computers/Commodore64/C64.Motherboard.cs index f114ee7ebc..866859f6c5 100644 --- a/BizHawk.Emulation/Computers/Commodore64/C64.Motherboard.cs +++ b/BizHawk.Emulation/Computers/Commodore64/C64.Motherboard.cs @@ -179,6 +179,8 @@ namespace BizHawk.Emulation.Computers.Commodore64 pla.PokeMemory = ram.Poke; pla.PokeSid = sid.Poke; pla.PokeVic = vic.Poke; + pla.ReadAEC = Pla_ReadAEC; + pla.ReadBA = Pla_ReadBA; pla.ReadBasicRom = Pla_ReadBasicRom; pla.ReadCartridgeHi = Pla_ReadCartridgeHi; pla.ReadCartridgeLo = Pla_ReadCartridgeLo; diff --git a/BizHawk.Emulation/Computers/Commodore64/C64.MotherboardInterface.cs b/BizHawk.Emulation/Computers/Commodore64/C64.MotherboardInterface.cs index 0c6f0ef7ae..b4844492d3 100644 --- a/BizHawk.Emulation/Computers/Commodore64/C64.MotherboardInterface.cs +++ b/BizHawk.Emulation/Computers/Commodore64/C64.MotherboardInterface.cs @@ -154,6 +154,16 @@ namespace BizHawk.Emulation.Computers.Commodore64 return vic.BA; } + bool Pla_ReadAEC() + { + return vic.AEC; + } + + bool Pla_ReadBA() + { + return vic.BA; + } + byte Pla_ReadBasicRom(ushort addr) { address = addr; diff --git a/BizHawk.Emulation/Computers/Commodore64/MOS/MOSPLA.cs b/BizHawk.Emulation/Computers/Commodore64/MOS/MOSPLA.cs index 8e04519dd5..485e666955 100644 --- a/BizHawk.Emulation/Computers/Commodore64/MOS/MOSPLA.cs +++ b/BizHawk.Emulation/Computers/Commodore64/MOS/MOSPLA.cs @@ -32,6 +32,7 @@ namespace BizHawk.Emulation.Computers.Commodore64.MOS public Action PokeMemory; public Action PokeSid; public Action PokeVic; + public Func ReadAEC; public Func ReadBA; public Func ReadBasicRom; public Func ReadCartridgeLo; @@ -130,6 +131,7 @@ namespace BizHawk.Emulation.Computers.Commodore64.MOS bool va13; bool va12; bool aec; + bool ba; bool cas; bool casram; bool basic; @@ -155,8 +157,9 @@ namespace BizHawk.Emulation.Computers.Commodore64.MOS va14 = a14; va13 = a13; va12 = a12; - aec = false; - cas = false; + aec = !ReadAEC(); + ba = ReadBA(); + cas = !true; p0 = loram && hiram && a15 && !a14 && a13 && !aec && read && game; p1 = hiram && a15 && a14 && a13 && !aec && read && game; diff --git a/BizHawk.Emulation/Computers/Commodore64/MOS/Vic.cs b/BizHawk.Emulation/Computers/Commodore64/MOS/Vic.cs index 1355517e6f..8492beeb1e 100644 --- a/BizHawk.Emulation/Computers/Commodore64/MOS/Vic.cs +++ b/BizHawk.Emulation/Computers/Commodore64/MOS/Vic.cs @@ -150,9 +150,9 @@ namespace BizHawk.Emulation.Computers.Commodore64.MOS // ------------------------------------ private int cyclesPerSec; - private bool pinAEC; - private bool pinBA; - private bool pinIRQ; + private bool pinAEC = true; + private bool pinBA = true; + private bool pinIRQ = true; private int[][] pipeline; private int totalCycles; private int totalLines; @@ -197,7 +197,7 @@ namespace BizHawk.Emulation.Computers.Commodore64.MOS { pinAEC = true; pinBA = true; - pinIRQ = false; + pinIRQ = true; bufOffset = 0; @@ -282,7 +282,6 @@ namespace BizHawk.Emulation.Computers.Commodore64.MOS baCount = baResetCounter; else if (baCount > 0) baCount--; - pinAEC = (baCount > 0); } } @@ -326,7 +325,7 @@ namespace BizHawk.Emulation.Computers.Commodore64.MOS protected const int rasterIrqLine0Cycle = 1; protected const int rasterIrqLineXCycle = 0; - protected const int baResetCounter = 4; + protected const int baResetCounter = 7; // ------------------------------------ @@ -380,6 +379,7 @@ namespace BizHawk.Emulation.Computers.Commodore64.MOS // if the BA counter is nonzero, allow CPU bus access UpdateBA(); + pinAEC = false; // must always come last UpdatePins(); @@ -413,6 +413,8 @@ namespace BizHawk.Emulation.Computers.Commodore64.MOS } Render(); + UpdateBA(); + pinAEC = (baCount > 0); // must always come last UpdatePins();