C64: Try counting IRQ and BA correctly

This commit is contained in:
SaxxonPike 2019-07-13 15:28:57 -05:00
parent f22c9b7abd
commit db38d5e65b
2 changed files with 6 additions and 9 deletions

View File

@ -214,7 +214,6 @@
_intSpriteCollision = false;
if ((val & 0x08) != 0)
_intLightPen = false;
UpdatePins();
break;
case 0x1E:
case 0x1F:
@ -358,14 +357,12 @@
_intSpriteDataCollision = (val & 0x02) != 0;
_intSpriteCollision = (val & 0x04) != 0;
_intLightPen = (val & 0x08) != 0;
UpdatePins();
break;
case 0x1A:
_enableIntRaster = (val & 0x01) != 0;
_enableIntSpriteDataCollision = (val & 0x02) != 0;
_enableIntSpriteCollision = (val & 0x04) != 0;
_enableIntLightPen = (val & 0x08) != 0;
UpdatePins();
break;
case 0x1B:
_sprite0.Priority = (val & 0x01) != 0;

View File

@ -26,7 +26,7 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.MOS
public bool ReadAec() { return _pinAec; }
public bool ReadBa() { return _pinBa; }
public bool ReadIrq() { return (_irqBuffer & 1) != 0; }
public bool ReadIrq() { return (_irqBuffer & 1) == 0; }
private readonly int _cyclesPerSec;
private readonly int[] _rasterXPipeline;
@ -320,7 +320,7 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.MOS
{
if (_ba)
_baCount = BaResetCounter;
else if (_baCount >= 0)
else if (_baCount > 0)
_baCount--;
}
@ -334,16 +334,16 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.MOS
private void UpdatePins()
{
var irqTemp = !(
var irqTemp =
(_enableIntRaster & _intRaster) |
(_enableIntSpriteDataCollision & _intSpriteDataCollision) |
(_enableIntSpriteCollision & _intSpriteCollision) |
(_enableIntLightPen & _intLightPen));
(_enableIntLightPen & _intLightPen);
// IRQ buffer is treated as a delay line
_irqBuffer >>= 1;
_irqBuffer |= irqTemp ? 0x1 : 0;
_pinAec = _ba || _baCount >= 0;
_irqBuffer |= irqTemp ? 0x8 : 0;
_pinAec = _ba || _baCount > 0;
_pinBa = _ba;
}