C64: VC count enable seems to need to be delayed by 1 cycle after badline

- which doesn't affect normal operation
- which DOES affect VSP
This commit is contained in:
SaxxonPike 2019-07-14 20:22:07 -05:00
parent 4d6ed8d6c8
commit a119420c79
4 changed files with 15 additions and 28 deletions

View File

@ -101,7 +101,7 @@
_parseAddr &= AddressMaskEc;
_dataG = ReadMemory(_parseAddr);
if (!_idle)
if (!_idle && _vcEnable)
{
_vmli = (_vmli + 1) & 0x3F;
_vc = (_vc + 1) & 0x3FF;

View File

@ -184,19 +184,16 @@
public void Write(int addr, int val)
{
_writtenData = val & 0xFF;
_writtenRegister = addr & 0x3F;
}
addr &= 0x3F;
val &= 0xFF;
private void DoWrite()
{
switch (_writtenRegister)
switch (addr)
{
case 0x17:
// vic-ii addendum rule 7
foreach (var spr in _sprites)
{
if ((_writtenData & 1) == 0 && !spr.YCrunch)
if ((val & 1) == 0 && !spr.YCrunch)
{
if (_parseIsSprCrunch)
{
@ -207,17 +204,17 @@
}
}
WriteRegister(_writtenRegister, _writtenData);
WriteRegister(addr, val);
break;
case 0x19:
// interrupts are cleared by writing a 1
if ((_writtenData & 0x01) != 0)
if ((val & 0x01) != 0)
_intRaster = false;
if ((_writtenData & 0x02) != 0)
if ((val & 0x02) != 0)
_intSpriteDataCollision = false;
if ((_writtenData & 0x04) != 0)
if ((val & 0x04) != 0)
_intSpriteCollision = false;
if ((_writtenData & 0x08) != 0)
if ((val & 0x08) != 0)
_intLightPen = false;
break;
case 0x1E:
@ -244,7 +241,7 @@
// not connected
break;
default:
WriteRegister(_writtenRegister, _writtenData);
WriteRegister(addr, val);
break;
}
}

View File

@ -73,13 +73,11 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.MOS
private int _vblankStart;
private int _vc;
private int _vcbase;
private bool _vcEnable;
private int _vmli;
private int _xScroll;
private int _yScroll;
private int _writtenRegister;
private int _writtenData;
public void HardReset()
{
_backgroundColor0 = 0;
@ -134,13 +132,11 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.MOS
_spriteMulticolor1 = 0;
_vc = 0;
_vcbase = 0;
_vcEnable = false;
_vmli = 0;
_xScroll = 0;
_yScroll = 0;
_writtenRegister = -1;
_writtenData = 0;
// reset sprites
for (var i = 0; i < 8; i++)
{
@ -232,10 +228,9 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.MOS
ser.Sync(nameof(_vc), ref _vc);
ser.Sync(nameof(_vcbase), ref _vcbase);
ser.Sync(nameof(_vcEnable), ref _vcEnable);
ser.Sync(nameof(_videoMode), ref _videoMode);
ser.Sync(nameof(_vmli), ref _vmli);
ser.Sync(nameof(_writtenData), ref _writtenData);
ser.Sync(nameof(_writtenRegister), ref _writtenRegister);
ser.Sync(nameof(_xScroll), ref _xScroll);
ser.Sync(nameof(_yScroll), ref _yScroll);

View File

@ -289,6 +289,7 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.MOS
}
// badline compare
_vcEnable = !_idle;
if (_badlineEnable)
{
if ((_rasterLine & 0x7) == _yScroll)
@ -312,12 +313,6 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.MOS
ParseCycle();
UpdatePins();
Render();
if (_writtenRegister >= 0)
{
DoWrite();
_writtenRegister = -1;
}
}
private void UpdateBa()