C64: Writes to some registers on the VIC in phase 2 by the CPU should only take effect on the following cycle

This commit is contained in:
SaxxonPike 2019-07-14 10:44:56 -05:00
parent e8902b829a
commit 8e8d3a6a1b
3 changed files with 11 additions and 26 deletions

View File

@ -280,34 +280,13 @@
_sprite7.X = (_sprite7.X & 0xFF) | ((val & 0x80) << 1);
break;
case 0x11:
_yScroll = val & 0x07;
_yScrollNext = val & 0x07;
_rowSelect = (val & 0x08) != 0;
_displayEnable = (val & 0x10) != 0;
_displayEnableNext = (val & 0x10) != 0;
_bitmapMode = (val & 0x20) != 0;
_extraColorMode = (val & 0x40) != 0;
_rasterInterruptLine &= 0xFF;
_rasterInterruptLine |= (val & 0x80) << 1;
if (_rasterLine == BadLineEnableRaster)
_badlineEnable |= _displayEnable;
if (_badlineEnable)
{
if ((_rasterLine & 0x7) == _yScroll)
{
_badline = true;
_idle = false;
}
else
{
_badline = false;
}
}
else
{
_badline = false;
}
UpdateBorder();
UpdateVideoMode();
break;

View File

@ -49,9 +49,7 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.MOS
private int _pointerCb;
private int _pointerVm;
private int _rasterInterruptLine;
private bool _rasterInterruptTriggered;
private int _rasterLine;
private int _rasterLineInterruptCompare;
private int _rasterX;
private bool _rasterXHold;
private int _rc;
@ -79,6 +77,8 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.MOS
private int _vmli;
private int _xScroll;
private int _yScroll;
private int _yScrollNext;
private bool _displayEnableNext;
public void HardReset()
{
@ -104,6 +104,7 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.MOS
_borderOnVertical = true;
_columnSelect = false;
_displayEnable = false;
_displayEnableNext = false;
_enableIntLightPen = false;
_enableIntRaster = false;
_enableIntSpriteCollision = false;
@ -134,6 +135,7 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.MOS
_vmli = 0;
_xScroll = 0;
_yScroll = 0;
_yScrollNext = 0;
_cycle = 0;
_cycleIndex = 0;
@ -186,6 +188,7 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.MOS
ser.Sync(nameof(_dataC), ref _dataC);
ser.Sync(nameof(_dataG), ref _dataG);
ser.Sync(nameof(_displayEnable), ref _displayEnable);
ser.Sync(nameof(_displayEnableNext), ref _displayEnableNext);
ser.Sync(nameof(_enableIntLightPen), ref _enableIntLightPen);
ser.Sync(nameof(_enableIntRaster), ref _enableIntRaster);
ser.Sync(nameof(_enableIntSpriteCollision), ref _enableIntSpriteCollision);
@ -230,6 +233,7 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.MOS
ser.Sync(nameof(_vmli), ref _vmli);
ser.Sync(nameof(_xScroll), ref _xScroll);
ser.Sync(nameof(_yScroll), ref _yScroll);
ser.Sync(nameof(_yScrollNext), ref _yScrollNext);
ser.Sync(nameof(_bufOffset), ref _bufOffset);
ser.Sync(nameof(_pixBuffer), ref _pixBuffer, useNull: false);
ser.Sync(nameof(_pixBufferIndex), ref _pixBufferIndex);

View File

@ -314,6 +314,8 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.MOS
UpdatePins();
Render();
_extraColorModeBuffer = _extraColorMode;
_yScroll = _yScrollNext;
_displayEnable = _displayEnableNext;
}
private void UpdateBa()
@ -336,7 +338,7 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.MOS
{
// IRQ is treated as a delay line
var intIrq = (_enableIntRaster && _intRaster) ? 0x0008 : 0x0000;
var intIrq = (_enableIntRaster && _intRaster) ? 0x0002 : 0x0000;
var sdIrq = (_enableIntSpriteDataCollision & _intSpriteDataCollision) ? 0x0001 : 0x0000;
var ssIrq = (_enableIntSpriteCollision & _intSpriteCollision) ? 0x0001 : 0x0000;
var lpIrq = (_enableIntLightPen & _intLightPen) ? 0x0001 : 0x0000;