commodore64: Tie AEC between Vic and Cpu, tie BA from Vic to RDY on Cpu. Results in better emulation of CPU bus shutdown

This commit is contained in:
saxxonpike 2012-11-25 06:33:04 +00:00
parent 9de7ee3336
commit 557f2c8815
4 changed files with 34 additions and 18 deletions

View File

@ -155,7 +155,7 @@ namespace BizHawk.Emulation.Computers.Commodore64
private byte ReadMemoryCPU(ushort addr)
{
if (!signal.CpuAEC)
if (!signal.CpuRDY || !signal.CpuAEC)
haltCPU = true;
return mem.Read(addr);
}
@ -164,6 +164,13 @@ namespace BizHawk.Emulation.Computers.Commodore64
{
mem.Write(addr, value);
}
public void WriteMemoryCPU(ushort addr, byte value)
{
if (!signal.CpuAEC)
haltCPU = true;
mem.Write(addr, value);
}
}
public class ChipSignals
@ -172,6 +179,7 @@ namespace BizHawk.Emulation.Computers.Commodore64
private bool[] _CiaIRQOutput = new bool[2];
private bool _KeyboardNMIOutput;
private bool _VicAECOutput;
private bool _VicBAOutput;
private bool _VicIRQOutput;
private bool _VicLPInput;
@ -182,9 +190,11 @@ namespace BizHawk.Emulation.Computers.Commodore64
public bool CpuAEC { get { return _VicAECOutput; } }
public bool CpuIRQ { get { return _VicIRQOutput | _CiaIRQOutput[0]; } }
public bool CpuNMI { get { return _CiaIRQOutput[1] | _KeyboardNMIOutput; } }
public bool CpuRDY { get { return !_VicBAOutput; } }
public bool KeyboardNMI { get { return _KeyboardNMIOutput; } set { _KeyboardNMIOutput = value; } }
public bool LPOutput { get { return _VicLPInput; } set { _VicLPInput = value; } }
public bool VicAEC { get { return _VicAECOutput; } set { _VicAECOutput = value; } }
public bool VicBA { get { return _VicBAOutput; } set { _VicBAOutput = value; } }
public bool VicIRQ { get { return _VicIRQOutput; } set { _VicIRQOutput = value; } }
public bool VicLP { get { return _VicLPInput; } }
}

View File

@ -103,11 +103,13 @@ namespace BizHawk.Emulation.Computers.Commodore64
for (int i = 0; i < cyclesPerFrame; i++)
{
if (!haltCPU)
{
cpu.IRQ = signal.CpuIRQ;
cpu.NMI = signal.CpuNMI;
cpu.ExecuteOne();
}
vic.PerformCycle();
cpu.IRQ = signal.CpuIRQ;
cpu.NMI = signal.CpuNMI;
cia0.PerformCycle();
signal.CiaIRQ0 = cia0.IRQ;
cia1.PerformCycle();

View File

@ -50,7 +50,7 @@ namespace BizHawk.Emulation.Computers.Commodore64
displayEnabled = (displayEnabled | DEN);
if (RASTER >= 0x030 && RASTER < 0x0F8)
badline = badline | ((YSCROLL == (RASTER & 0x07)) && displayEnabled);
badline = ((YSCROLL == (RASTER & 0x07)) && displayEnabled);
else
badline = false;
@ -555,7 +555,8 @@ namespace BizHawk.Emulation.Computers.Commodore64
badline = false;
}
PipelineBA(baCount > 0);
signal.VicBA = (baCount > 0);
PipelineBA(signal.VicBA);
if (baCount > 0)
{
if (fetchCounter > 0)
@ -640,25 +641,28 @@ namespace BizHawk.Emulation.Computers.Commodore64
private void PipelineFetchSpriteP(int index)
{
VicIISprite spr = sprites[index];
ushort pointerOffset = (ushort)((VM << 10) | 0x3F8 | index);
sprites[index].MPTR = mem.VicRead(pointerOffset);
if (sprites[index].MDMA)
spr.MPTR = mem.VicRead(pointerOffset);
if (spr.MDMA)
{
sprites[index].MSR = mem.VicRead((ushort)((sprites[index].MPTR << 6) | (sprites[index].MC)));
sprites[index].MC++;
spr.MSR = mem.VicRead((ushort)((spr.MPTR << 6) | (spr.MC)));
spr.MC++;
}
}
private void PipelineFetchSpriteS(int index)
{
if (sprites[index].MDMA)
VicIISprite spr = sprites[index];
if (spr.MDMA)
{
for (int i = 0; i < 2; i++)
{
sprites[index].MSR <<= 8;
sprites[index].MSR |= mem.VicRead((ushort)((sprites[index].MPTR << 6) | (sprites[index].MC)));
sprites[index].MC++;
spr.MSR <<= 8;
spr.MSR |= mem.VicRead((ushort)((spr.MPTR << 6) | (spr.MC)));
spr.MC++;
}
}
}

View File

@ -58,7 +58,8 @@ namespace BizHawk.Emulation.Computers.Commodore64
{
0x0845, 0x0885, 0x0856, 0x0886, 0x0867,
0x0887, 0x0887, 0x0888, 0x0888, 0x0888,
0x0888, 0x1888, 0x1888, 0x1888, 0x1888,
0x0888, 0x0888, 0x1888, 0x1888, 0x1888,
0x1888, 0x1888, 0x1888, 0x1888, 0x1888,
0x1888, 0x1888, 0x1888, 0x1888, 0x1888,
0x1888, 0x1888, 0x1888, 0x1888, 0x1888,
0x1888, 0x1888, 0x1888, 0x1888, 0x1888,
@ -66,7 +67,6 @@ namespace BizHawk.Emulation.Computers.Commodore64
0x1888, 0x1888, 0x1888, 0x1888, 0x1888,
0x1888, 0x1888, 0x1888, 0x1888, 0x1888,
0x1888, 0x1888, 0x1888, 0x1888, 0x1888,
0x1888, 0x1888, 0x1888, 0x1888, 0x0888,
0x0880, 0x0880, 0x0801, 0x0881, 0x0812,
0x0882, 0x0823, 0x0883, 0x0834, 0x0884
},
@ -129,8 +129,8 @@ namespace BizHawk.Emulation.Computers.Commodore64
new uint[] // ba (flg/spr/spr/spr 8=none)
{
0x0884, 0x0845, 0x0885, 0x0856, 0x0886,
0x0867, 0x0887, 0x0888, 0x0888, 0x0888,
0x0888, 0x1888, 0x1888, 0x1888, 0x1888,
0x0867, 0x0887, 0x0887, 0x0888, 0x0888,
0x0888, 0x0888, 0x1888, 0x1888, 0x1888,
0x1888, 0x1888, 0x1888, 0x1888, 0x1888,
0x1888, 0x1888, 0x1888, 0x1888, 0x1888,
0x1888, 0x1888, 0x1888, 0x1888, 0x1888,
@ -138,7 +138,7 @@ namespace BizHawk.Emulation.Computers.Commodore64
0x1888, 0x1888, 0x1888, 0x1888, 0x1888,
0x1888, 0x1888, 0x1888, 0x1888, 0x1888,
0x1888, 0x1888, 0x1888, 0x1888, 0x1888,
0x1888, 0x1888, 0x1888, 0x1888, 0x0880,
0x1888, 0x1888, 0x1888, 0x1888, 0x1880,
0x0880, 0x0801, 0x0881, 0x0812, 0x0882,
0x0823, 0x0883, 0x0834
},