Commodore64: Fully implement the interaction between Cpu, Vic and PLA on BA/AEC lines.

This commit is contained in:
saxxonpike 2013-08-12 05:04:50 +00:00
parent 5b488f1be0
commit 842ead8c7e
4 changed files with 25 additions and 8 deletions

View File

@ -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;

View File

@ -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;

View File

@ -32,6 +32,7 @@ namespace BizHawk.Emulation.Computers.Commodore64.MOS
public Action<int, byte> PokeMemory;
public Action<int, byte> PokeSid;
public Action<int, byte> PokeVic;
public Func<bool> ReadAEC;
public Func<bool> ReadBA;
public Func<ushort, byte> ReadBasicRom;
public Func<ushort, byte> 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;

View File

@ -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();