C64: Savestate should include the new variables

This commit is contained in:
SaxxonPike 2019-07-14 16:32:53 -05:00
parent ad7cae8b71
commit 4d6ed8d6c8
8 changed files with 63 additions and 59 deletions

View File

@ -259,8 +259,6 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64
Pla.PokeMemory = Ram.Poke;
Pla.PokeSid = Sid.Poke;
Pla.PokeVic = Vic.Poke;
Pla.ReadAec = Vic.ReadAec;
Pla.ReadBa = Vic.ReadBa;
Pla.ReadBasicRom = BasicRom.Read;
Pla.ReadCartridgeHi = CartPort.ReadHiRom;
Pla.ReadCartridgeLo = CartPort.ReadLoRom;

View File

@ -49,8 +49,6 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.MOS
public Action DebuggerStep;
// ------------------------------------
public Chip6510()
{
// configure cpu r/w
@ -85,7 +83,6 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.MOS
_port.Latch = 0xFF;
}
// ------------------------------------
public void ExecutePhase()
{
_irqDelay >>= 1;

View File

@ -31,8 +31,6 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.MOS
public Action<int, int> PokeMemory;
public Action<int, int> PokeSid;
public Action<int, int> PokeVic;
public Func<bool> ReadAec;
public Func<bool> ReadBa;
public Func<int, int> ReadBasicRom;
public Func<int, int> ReadCartridgeLo;
public Func<int, int> ReadCartridgeHi;

View File

@ -97,7 +97,7 @@
_parseAddr = _rc | ((_dataC & 0xFF) << 3) | (_pointerCb << 11);
}
if (_extraColorModeBuffer)
if (_extraColorMode)
_parseAddr &= AddressMaskEc;
_dataG = ReadMemory(_parseAddr);

View File

@ -181,17 +181,22 @@
return 0xFF;
}
}
public void Write(int addr, int val)
{
addr &= 0x3F;
switch (addr)
_writtenData = val & 0xFF;
_writtenRegister = addr & 0x3F;
}
private void DoWrite()
{
switch (_writtenRegister)
{
case 0x17:
// vic-ii addendum rule 7
foreach (var spr in _sprites)
{
if ((val & 1) == 0 && !spr.YCrunch)
if ((_writtenData & 1) == 0 && !spr.YCrunch)
{
if (_parseIsSprCrunch)
{
@ -202,17 +207,17 @@
}
}
WriteRegister(addr, val);
WriteRegister(_writtenRegister, _writtenData);
break;
case 0x19:
// interrupts are cleared by writing a 1
if ((val & 0x01) != 0)
if ((_writtenData & 0x01) != 0)
_intRaster = false;
if ((val & 0x02) != 0)
if ((_writtenData & 0x02) != 0)
_intSpriteDataCollision = false;
if ((val & 0x04) != 0)
if ((_writtenData & 0x04) != 0)
_intSpriteCollision = false;
if ((val & 0x08) != 0)
if ((_writtenData & 0x08) != 0)
_intLightPen = false;
break;
case 0x1E:
@ -239,7 +244,7 @@
// not connected
break;
default:
WriteRegister(addr, val);
WriteRegister(_writtenRegister, _writtenData);
break;
}
}
@ -280,9 +285,9 @@
_sprite7.X = (_sprite7.X & 0xFF) | ((val & 0x80) << 1);
break;
case 0x11:
_yScrollNext = val & 0x07;
_yScroll = val & 0x07;
_rowSelect = (val & 0x08) != 0;
_displayEnableNext = (val & 0x10) != 0;
_displayEnable = (val & 0x10) != 0;
_bitmapMode = (val & 0x20) != 0;
_extraColorMode = (val & 0x40) != 0;
_rasterInterruptLine &= 0xFF;

View File

@ -12,6 +12,7 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.MOS
public bool Display;
public bool Dma;
public bool Enable;
public int Index;
public int Loaded;
public int Mc;
public int Mcbase;
@ -28,6 +29,11 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.MOS
public bool YCrunch;
public bool YExpand;
public Sprite(int index)
{
Index = index;
}
public void HardReset()
{
CollideData = false;

View File

@ -34,7 +34,6 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.MOS
private bool _enableIntSpriteCollision;
private bool _enableIntSpriteDataCollision;
private bool _extraColorMode;
private bool _extraColorModeBuffer;
private bool _hblank;
private bool _idle;
private bool _intLightPen;
@ -77,22 +76,17 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.MOS
private int _vmli;
private int _xScroll;
private int _yScroll;
private int _yScrollNext;
private bool _displayEnableNext;
private int _writtenRegister;
private int _writtenData;
public void HardReset()
{
_pinAec = true;
_pinBa = true;
_irqBuffer = 0;
_ba = true;
_bufOffset = 0;
_backgroundColor0 = 0;
_backgroundColor1 = 0;
_backgroundColor2 = 0;
_backgroundColor3 = 0;
_ba = true;
_baCount = BaResetCounter;
_badline = false;
_badlineEnable = false;
@ -102,9 +96,13 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.MOS
_borderColor = 0;
_borderOnMain = true;
_borderOnVertical = true;
_bufOffset = 0;
_columnSelect = false;
_cycle = 0;
_cycleIndex = 0;
_dataC = 0;
_dataG = 0;
_displayEnable = false;
_displayEnableNext = false;
_enableIntLightPen = false;
_enableIntRaster = false;
_enableIntSpriteCollision = false;
@ -115,14 +113,18 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.MOS
_intRaster = false;
_intSpriteCollision = false;
_intSpriteDataCollision = false;
_irqBuffer = 0;
_lightPenX = 0;
_lightPenY = 0;
_multicolorMode = false;
_pinAec = true;
_pinBa = true;
_pointerCb = 0;
_pointerVm = 0;
_rasterInterruptLine = 0;
_rasterLine = 0;
_rasterX = 0;
_rasterXHold = false;
_rc = 7;
_refreshCounter = 0xFF;
_rowSelect = false;
@ -135,9 +137,9 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.MOS
_vmli = 0;
_xScroll = 0;
_yScroll = 0;
_yScrollNext = 0;
_cycle = 0;
_cycleIndex = 0;
_writtenRegister = -1;
_writtenData = 0;
// reset sprites
for (var i = 0; i < 8; i++)
@ -151,8 +153,6 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.MOS
_bufferC[i] = 0;
}
_pixBuffer = new int[PixBufferSize];
_pixBorderBuffer = new int[PixBorderBufferSize];
_pixBufferIndex = 0;
_pixBufferBorderIndex = 0;
UpdateBorder();
@ -160,9 +160,6 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.MOS
public void SyncState(Serializer ser)
{
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);
@ -178,34 +175,39 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.MOS
ser.Sync(nameof(_borderColor), ref _borderColor);
ser.Sync(nameof(_borderL), ref _borderL);
ser.Sync(nameof(_borderOnMain), ref _borderOnMain);
ser.Sync(nameof(_borderOnShiftReg), ref _borderOnShiftReg);
ser.Sync(nameof(_borderOnVertical), ref _borderOnVertical);
ser.Sync(nameof(_borderR), ref _borderR);
ser.Sync(nameof(_borderT), ref _borderT);
ser.Sync(nameof(_bufferC), ref _bufferC, useNull: false);
ser.Sync(nameof(_bufOffset), ref _bufOffset);
ser.Sync(nameof(_cycle), ref _cycle);
ser.Sync(nameof(_cycleIndex), ref _cycleIndex);
ser.Sync(nameof(_columnSelect), ref _columnSelect);
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);
ser.Sync(nameof(_enableIntSpriteDataCollision), ref _enableIntSpriteDataCollision);
ser.Sync(nameof(_extraColorMode), ref _extraColorMode);
ser.Sync(nameof(_extraColorModeBuffer), ref _extraColorModeBuffer);
ser.Sync(nameof(_idle), ref _idle);
ser.Sync(nameof(_intLightPen), ref _intLightPen);
ser.Sync(nameof(_intRaster), ref _intRaster);
ser.Sync(nameof(_intSpriteCollision), ref _intSpriteCollision);
ser.Sync(nameof(_intSpriteDataCollision), ref _intSpriteDataCollision);
ser.Sync(nameof(_irqBuffer), ref _irqBuffer);
ser.Sync(nameof(_lightPenX), ref _lightPenX);
ser.Sync(nameof(_lightPenY), ref _lightPenY);
ser.Sync(nameof(_multicolorMode), ref _multicolorMode);
ser.Sync(nameof(_pinAec), ref _pinAec);
ser.Sync(nameof(_pinBa), ref _pinBa);
ser.Sync(nameof(_irqBuffer), ref _irqBuffer);
ser.Sync(nameof(_parseIsSprCrunch), ref _parseIsSprCrunch);
ser.Sync(nameof(_pixBorderBuffer), ref _pixBorderBuffer, useNull: false);
ser.Sync(nameof(_pixBufferBorderIndex), ref _pixBufferBorderIndex);
ser.Sync(nameof(_pixBuffer), ref _pixBuffer, useNull: false);
ser.Sync(nameof(_pixBufferIndex), ref _pixBufferIndex);
ser.Sync(nameof(_pointerCb), ref _pointerCb);
ser.Sync(nameof(_pointerVm), ref _pointerVm);
ser.Sync(nameof(_rasterInterruptLine), ref _rasterInterruptLine);
@ -221,29 +223,25 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.MOS
ser.Sync(nameof(_spriteMulticolor0), ref _spriteMulticolor0);
ser.Sync(nameof(_spriteMulticolor1), ref _spriteMulticolor1);
for (int i = 0; i < _sprites.Length; i++)
foreach (var sprite in _sprites)
{
ser.BeginSection("Sprite" + i);
_sprites[i].SyncState(ser);
ser.BeginSection($"Sprite{sprite.Index}");
sprite.SyncState(ser);
ser.EndSection();
}
ser.Sync(nameof(_vc), ref _vc);
ser.Sync(nameof(_vcbase), ref _vcbase);
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);
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);
ser.Sync(nameof(_pixBorderBuffer), ref _pixBorderBuffer, useNull: false);
ser.Sync(nameof(_pixBufferBorderIndex), ref _pixBufferBorderIndex);
if (ser.IsReader)
{
UpdateBorder();
UpdatePins();
UpdateVideoMode();
}
}

View File

@ -67,9 +67,7 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.MOS
_sprites = new Sprite[8];
for (var i = 0; i < 8; i++)
{
_sprites[i] = new Sprite();
}
_sprites[i] = new Sprite(i);
_sprite0 = _sprites[0];
_sprite1 = _sprites[1];
@ -79,8 +77,9 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.MOS
_sprite5 = _sprites[5];
_sprite6 = _sprites[6];
_sprite7 = _sprites[7];
_bufferC = new int[40];
_pixBuffer = new int[PixBufferSize];
_pixBorderBuffer = new int[PixBorderBufferSize];
}
private void ConfigureBlanking(int lines, int hblankStart, int hblankEnd, int vblankStart, int vblankEnd,
@ -313,9 +312,12 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.MOS
ParseCycle();
UpdatePins();
Render();
_extraColorModeBuffer = _extraColorMode;
_yScroll = _yScrollNext;
_displayEnable = _displayEnableNext;
if (_writtenRegister >= 0)
{
DoWrite();
_writtenRegister = -1;
}
}
private void UpdateBa()