From 762a35773cb472990ac522715401bda6697e6dff Mon Sep 17 00:00:00 2001 From: adelikat Date: Sat, 13 May 2017 09:37:11 -0500 Subject: [PATCH] C64 - convert VIC and sublasses to not use SyncObject --- .../Computers/Commodore64/C64.Motherboard.cs | 5 +- .../Computers/Commodore64/MOS/Vic.Sprite.cs | 22 ++++- .../Computers/Commodore64/MOS/Vic.State.cs | 98 +++++++++++++++++-- 3 files changed, 113 insertions(+), 12 deletions(-) diff --git a/BizHawk.Emulation.Cores/Computers/Commodore64/C64.Motherboard.cs b/BizHawk.Emulation.Cores/Computers/Commodore64/C64.Motherboard.cs index a5d05ffb46..da745c65ee 100644 --- a/BizHawk.Emulation.Cores/Computers/Commodore64/C64.Motherboard.cs +++ b/BizHawk.Emulation.Cores/Computers/Commodore64/C64.Motherboard.cs @@ -308,7 +308,10 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64 Sid.SyncState(ser); ser.EndSection(); - ser.BeginSection("Vic"); SaveState.SyncObject(ser, Vic); ser.EndSection(); + ser.BeginSection("Vic"); + Vic.SyncState(ser); + ser.EndSection(); + ser.BeginSection("CartPort"); SaveState.SyncObject(ser, CartPort); ser.EndSection(); // TODO: only if cart ser.BeginSection("Cassette"); SaveState.SyncObject(ser, Cassette); ser.EndSection(); diff --git a/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/Vic.Sprite.cs b/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/Vic.Sprite.cs index 70665c9ae4..dd7ff7944f 100644 --- a/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/Vic.Sprite.cs +++ b/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/Vic.Sprite.cs @@ -59,7 +59,27 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.MOS public void SyncState(Serializer ser) { - SaveState.SyncObject(ser, this); + ser.Sync("CollideData", ref CollideData); + ser.Sync("CollideSprite", ref CollideSprite); + ser.Sync("Color", ref Color); + ser.Sync("Display", ref Display); + ser.Sync("Dma", ref Dma); + ser.Sync("Enable", ref Enable); + ser.Sync("Loaded", ref Loaded); + ser.Sync("Mc", ref Mc); + ser.Sync("Mcbase", ref Mcbase); + ser.Sync("Multicolor", ref Multicolor); + ser.Sync("MulticolorCrunch", ref MulticolorCrunch); + ser.Sync("Pointer", ref Pointer); + ser.Sync("Priority", ref Priority); + ser.Sync("ShiftEnable", ref ShiftEnable); + ser.Sync("Sr", ref Sr); + ser.Sync("X", ref X); + ser.Sync("XCrunch", ref XCrunch); + ser.Sync("XExpand", ref XExpand); + ser.Sync("Y", ref Y); + ser.Sync("YCrunch", ref YCrunch); + ser.Sync("YExpand", ref YExpand); } } } diff --git a/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/Vic.State.cs b/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/Vic.State.cs index f6df6dcd90..9a72ed6c8e 100644 --- a/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/Vic.State.cs +++ b/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/Vic.State.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using System.Text; - -using BizHawk.Common; +using BizHawk.Common; namespace BizHawk.Emulation.Cores.Computers.Commodore64.MOS { @@ -27,8 +21,8 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.MOS private bool _borderOnVertical; private int _borderR; private int _borderT; - private readonly int[] _bufferC; - private readonly int[] _bufferG; + private int[] _bufferC; + private int[] _bufferG; private int _cycle; private int _cycleIndex; private bool _columnSelect; @@ -164,7 +158,91 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.MOS public void SyncState(Serializer ser) { - SaveState.SyncObject(ser, this); + ser.Sync("_cyclesExecuted", ref _cyclesExecuted); + ser.Sync("_parseIsSprCrunch", ref _parseIsSprCrunch); + ser.Sync("_srSync", ref _srSync); + ser.Sync("_srColorSync", ref _srColorSync); + ser.Sync("_srColorIndexLatch", ref _srColorIndexLatch); + ser.Sync("_videoMode", ref _videoMode); + ser.Sync("_borderOnShiftReg", ref _borderOnShiftReg); + ser.Sync("_backgroundColor0", ref _backgroundColor0); + ser.Sync("_backgroundColor1", ref _backgroundColor1); + ser.Sync("_backgroundColor2", ref _backgroundColor2); + ser.Sync("_backgroundColor3", ref _backgroundColor3); + ser.Sync("_baCount", ref _baCount); + ser.Sync("_badline", ref _badline); + ser.Sync("_badlineEnable", ref _badlineEnable); + ser.Sync("_bitmapMode", ref _bitmapMode); + ser.Sync("_borderB", ref _borderB); + ser.Sync("_borderCheckLEnable", ref _borderCheckLEnable); + ser.Sync("_borderCheckREnable", ref _borderCheckREnable); + ser.Sync("_borderColor", ref _borderColor); + ser.Sync("_borderL", ref _borderL); + ser.Sync("_borderOnMain", ref _borderOnMain); + ser.Sync("_borderOnVertical", ref _borderOnVertical); + ser.Sync("_borderR", ref _borderR); + ser.Sync("_borderT", ref _borderT); + ser.Sync("_bufferC", ref _bufferC, useNull: false); + ser.Sync("_bufferG", ref _bufferG, useNull: false); + ser.Sync("_cycle", ref _cycle); + ser.Sync("_cycleIndex", ref _cycleIndex); + ser.Sync("_columnSelect", ref _columnSelect); + ser.Sync("_dataC", ref _dataC); + ser.Sync("_dataG", ref _dataG); + ser.Sync("_displayEnable", ref _displayEnable); + ser.Sync("_displayC", ref _displayC); + ser.Sync("_enableIntLightPen", ref _enableIntLightPen); + ser.Sync("_enableIntRaster", ref _enableIntRaster); + ser.Sync("_enableIntSpriteCollision", ref _enableIntSpriteCollision); + ser.Sync("_enableIntSpriteDataCollision", ref _enableIntSpriteDataCollision); + ser.Sync("_extraColorMode", ref _extraColorMode); + ser.Sync("_extraColorModeBuffer", ref _extraColorModeBuffer); + ser.Sync("_idle", ref _idle); + ser.Sync("_intLightPen", ref _intLightPen); + ser.Sync("_intRaster", ref _intRaster); + ser.Sync("_intSpriteCollision", ref _intSpriteCollision); + ser.Sync("_intSpriteDataCollision", ref _intSpriteDataCollision); + ser.Sync("_lightPenX", ref _lightPenX); + ser.Sync("_lightPenY", ref _lightPenY); + ser.Sync("_multicolorMode", ref _multicolorMode); + ser.Sync("_pinAec", ref _pinAec); + ser.Sync("_pinBa", ref _pinBa); + ser.Sync("_pinIrq", ref _pinIrq); + ser.Sync("_pointerCb", ref _pointerCb); + ser.Sync("_pointerVm", ref _pointerVm); + ser.Sync("_rasterInterruptLine", ref _rasterInterruptLine); + ser.Sync("_rasterInterruptTriggered", ref _rasterInterruptTriggered); + ser.Sync("_rasterLine", ref _rasterLine); + ser.Sync("_rasterX", ref _rasterX); + ser.Sync("_rasterXHold", ref _rasterXHold); + ser.Sync("_rc", ref _rc); + ser.Sync("_refreshCounter", ref _refreshCounter); + ser.Sync("_renderEnabled", ref _renderEnabled); + ser.Sync("_rowSelect", ref _rowSelect); + ser.Sync("_spriteBackgroundCollisionClearPending", ref _spriteBackgroundCollisionClearPending); + ser.Sync("_spriteSpriteCollisionClearPending", ref _spriteSpriteCollisionClearPending); + ser.Sync("_spriteMulticolor0", ref _spriteMulticolor0); + ser.Sync("_spriteMulticolor1", ref _spriteMulticolor1); + + for (int i = 0; i < _sprites.Length; i++) + { + ser.BeginSection("Sprite" + i); + _sprites[i].SyncState(ser); + ser.EndSection(); + } + + ser.Sync("_sr", ref _sr); + ser.Sync("_vc", ref _vc); + ser.Sync("_vcbase", ref _vcbase); + ser.Sync("_vmli", ref _vmli); + ser.Sync("_xScroll", ref _xScroll); + ser.Sync("_yScroll", ref _yScroll); + ser.Sync("_bufOffset", ref _bufOffset); + ser.Sync("_pixBuffer", ref _pixBuffer, useNull: false); + ser.Sync("_pixBufferIndex", ref _pixBufferIndex); + ser.Sync("_pixBorderBuffer", ref _pixBorderBuffer, useNull: false); + ser.Sync("_pixBufferBorderIndex", ref _pixBufferBorderIndex); + if (ser.IsReader) { UpdateBorder();