C64: Interrupts generated in phase 2 by the VIC won't trigger for the CPU until next cycle, also buffer BA

This commit is contained in:
SaxxonPike 2019-07-09 20:55:14 -05:00
parent b471fdc692
commit e63d10b608
3 changed files with 17 additions and 11 deletions

View File

@ -2,7 +2,7 @@
{
public sealed partial class Vic
{
private const int BaResetCounter = 4;
private const int BaResetCounter = 6;
private const int PipelineUpdateVc = 0x00000001; // vc/rc rule 2
private const int PipelineSpriteCrunch = 0x00000002;
private const int PipelineUpdateMcBase = 0x00000004;
@ -336,13 +336,13 @@
}
// perform BA flag manipulation
_pinBa = true;
_ba = true;
switch (_parseBa)
{
case BaTypeNone:
break;
case BaTypeCharacter:
_pinBa = !_badline;
_ba = !_badline;
break;
default:
_parseCycleBaSprite0 = _parseBa & BaTypeMaskSprite0;
@ -351,7 +351,7 @@
if ((_parseCycleBaSprite0 < 8 && _sprites[_parseCycleBaSprite0].Dma) ||
(_parseCycleBaSprite1 < 8 && _sprites[_parseCycleBaSprite1].Dma) ||
(_parseCycleBaSprite2 < 8 && _sprites[_parseCycleBaSprite2].Dma))
_pinBa = false;
_ba = false;
break;
}

View File

@ -8,6 +8,7 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.MOS
private int _backgroundColor1;
private int _backgroundColor2;
private int _backgroundColor3;
private bool _ba;
private int _baCount;
private bool _badline;
private bool _badlineEnable;
@ -85,6 +86,7 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.MOS
_pinAec = true;
_pinBa = true;
_pinIrq = true;
_ba = true;
_bufOffset = 0;
@ -160,6 +162,7 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.MOS
ser.Sync(nameof(_parseIsSprCrunch), ref _parseIsSprCrunch);
ser.Sync(nameof(_videoMode), ref _videoMode);
ser.Sync(nameof(_borderOnShiftReg), ref _borderOnShiftReg);
ser.Sync(nameof(_ba), ref _ba);
ser.Sync(nameof(_backgroundColor0), ref _backgroundColor0);
ser.Sync(nameof(_backgroundColor1), ref _backgroundColor1);
ser.Sync(nameof(_backgroundColor2), ref _backgroundColor2);

View File

@ -310,20 +310,21 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.MOS
// render
ParseCycle();
UpdateBa();
Render();
ParseCycle();
UpdateBa();
UpdatePins();
Render();
_extraColorModeBuffer = _extraColorMode;
}
// if the BA counter is nonzero, allow CPU bus access
if (_pinBa)
private void UpdateBa()
{
if (_ba)
_baCount = BaResetCounter;
else if (_baCount > 0)
else if (_baCount >= 0)
_baCount--;
_pinAec = _pinBa || _baCount > 0;
// must always come last
UpdatePins();
}
private void UpdateBorder()
@ -343,6 +344,8 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.MOS
(_enableIntLightPen & _intLightPen));
_pinIrq = irqTemp;
_pinAec = _ba || _baCount >= 0;
_pinBa = _ba;
}
private void UpdateVideoMode()