From def60b25c57597551e027d940fd91e8aa27d11b8 Mon Sep 17 00:00:00 2001 From: Dirk Hoffmann Date: Sat, 20 Jan 2024 15:23:15 +0100 Subject: [PATCH] Serialization cleanup --- Emulator/Cartridges/Cartridge.h | 22 ++++++----- Emulator/Cartridges/CartridgeRom.h | 11 ++++-- .../Cartridges/CustomCartridges/EasyFlash.h | 10 +++-- Emulator/Cartridges/CustomCartridges/Expert.h | 9 +++-- .../Cartridges/CustomCartridges/FinalIII.h | 12 +++++- Emulator/Cartridges/CustomCartridges/GeoRam.h | 11 ++++-- Emulator/Cartridges/CustomCartridges/Isepic.h | 12 ++++-- .../Cartridges/CustomCartridges/PageFox.h | 9 +++-- Emulator/Cartridges/CustomCartridges/Reu.h | 13 ++++--- Emulator/Cartridges/FlashRom.h | 11 ++++-- Emulator/Components/C64.h | 12 ++++-- Emulator/Components/CIA/CIA.h | 14 ++++--- Emulator/Components/LogicBoard/ControlPort.h | 11 ++---- .../Components/LogicBoard/ExpansionPort.h | 15 +++++--- Emulator/Components/LogicBoard/PowerSupply.h | 10 +---- Emulator/Components/Memory/C64Memory.h | 16 +++++--- Emulator/Components/SID/Muxer.h | 24 +++++++----- Emulator/Components/SID/ReSID.h | 16 ++++---- Emulator/Components/SID/fastsid/FastSID.h | 14 ++++--- Emulator/Components/VICII/Recorder/Recorder.h | 1 - Emulator/Components/VICII/VICII.h | 30 ++++++++------- Emulator/Peripherals/Datasette/Datasette.h | 10 +++-- Emulator/Peripherals/Drive/Disk.h | 14 ++++--- Emulator/Peripherals/Drive/Drive.h | 38 ++++++++++--------- Emulator/Peripherals/Drive/DriveMemory.h | 11 ++++-- Emulator/Peripherals/Mouse/Mouse.h | 7 +++- 26 files changed, 218 insertions(+), 145 deletions(-) diff --git a/Emulator/Cartridges/Cartridge.h b/Emulator/Cartridges/Cartridge.h index ec0fe640f..5db8fa78c 100644 --- a/Emulator/Cartridges/Cartridge.h +++ b/Emulator/Cartridges/Cartridge.h @@ -172,15 +172,7 @@ class Cartridge : public SubComponent { template void applyToPersistentItems(T& worker) { - worker - - << gameLineInCrtFile - << exromLineInCrtFile - << numPackets - << ramCapacity - << battery - << control - << switchPos; + } template @@ -195,6 +187,18 @@ class Cartridge : public SubComponent { << offsetL << offsetH << led; + + if (util::isResetter(worker)) return; + + worker + + << gameLineInCrtFile + << exromLineInCrtFile + << numPackets + << ramCapacity + << battery + << control + << switchPos; } protected: diff --git a/Emulator/Cartridges/CartridgeRom.h b/Emulator/Cartridges/CartridgeRom.h index cb568df54..898f2b107 100644 --- a/Emulator/Cartridges/CartridgeRom.h +++ b/Emulator/Cartridges/CartridgeRom.h @@ -60,15 +60,18 @@ class CartridgeRom : public SubComponent { template void applyToPersistentItems(T& worker) { - worker - - << size - << loadAddress; + } template void serialize(T& worker) { + if (util::isResetter(worker)) return; + + worker + + << size + << loadAddress; } isize _size() override; diff --git a/Emulator/Cartridges/CustomCartridges/EasyFlash.h b/Emulator/Cartridges/CustomCartridges/EasyFlash.h index 2c822e9a7..7682dd194 100644 --- a/Emulator/Cartridges/CustomCartridges/EasyFlash.h +++ b/Emulator/Cartridges/CustomCartridges/EasyFlash.h @@ -65,9 +65,7 @@ class EasyFlash : public Cartridge { template void applyToPersistentItems(T& worker) { - worker - - << jumper; + } template @@ -78,6 +76,12 @@ class EasyFlash : public Cartridge { << bankReg << modeReg << bank; + + if (util::isResetter(worker)) return; + + worker + + << jumper; } isize __size() override { COMPUTE_SNAPSHOT_SIZE } diff --git a/Emulator/Cartridges/CustomCartridges/Expert.h b/Emulator/Cartridges/CustomCartridges/Expert.h index 0460e36d3..b88f277a5 100644 --- a/Emulator/Cartridges/CustomCartridges/Expert.h +++ b/Emulator/Cartridges/CustomCartridges/Expert.h @@ -48,14 +48,17 @@ class Expert : public Cartridge { template void applyToPersistentItems(T& worker) { - worker - - << active; + } template void serialize(T& worker) { + if (util::isResetter(worker)) return; + + worker + + << active; } isize __size() override { COMPUTE_SNAPSHOT_SIZE } diff --git a/Emulator/Cartridges/CustomCartridges/FinalIII.h b/Emulator/Cartridges/CustomCartridges/FinalIII.h index 2b212ed69..8104eb408 100644 --- a/Emulator/Cartridges/CustomCartridges/FinalIII.h +++ b/Emulator/Cartridges/CustomCartridges/FinalIII.h @@ -59,13 +59,21 @@ class FinalIII : public Cartridge { template void applyToPersistentItems(T& worker) { - worker << freeezeButtonIsPressed; + } template void serialize(T& worker) { - worker << qD; + worker + + << qD; + + if (util::isResetter(worker)) return; + + worker + + << freeezeButtonIsPressed; } isize __size() override { COMPUTE_SNAPSHOT_SIZE } diff --git a/Emulator/Cartridges/CustomCartridges/GeoRam.h b/Emulator/Cartridges/CustomCartridges/GeoRam.h index a0e4c4e35..a8ea3eb9a 100644 --- a/Emulator/Cartridges/CustomCartridges/GeoRam.h +++ b/Emulator/Cartridges/CustomCartridges/GeoRam.h @@ -56,15 +56,18 @@ class GeoRAM : public Cartridge { template void applyToPersistentItems(T& worker) { - worker - - << bank - << page; + } template void serialize(T& worker) { + if (util::isResetter(worker)) return; + + worker + + << bank + << page; } isize __size() override { COMPUTE_SNAPSHOT_SIZE } diff --git a/Emulator/Cartridges/CustomCartridges/Isepic.h b/Emulator/Cartridges/CustomCartridges/Isepic.h index 4c731ea6b..4197863c7 100644 --- a/Emulator/Cartridges/CustomCartridges/Isepic.h +++ b/Emulator/Cartridges/CustomCartridges/Isepic.h @@ -52,10 +52,7 @@ class Isepic : public Cartridge { template void applyToPersistentItems(T& worker) { - worker - - << oldPeekSource - << oldPokeTarget; + } template @@ -64,6 +61,13 @@ class Isepic : public Cartridge { worker << page; + + if (util::isResetter(worker)) return; + + worker + + << oldPeekSource + << oldPokeTarget; } isize __size() override { COMPUTE_SNAPSHOT_SIZE } diff --git a/Emulator/Cartridges/CustomCartridges/PageFox.h b/Emulator/Cartridges/CustomCartridges/PageFox.h index 0bdd6044a..b94f68ecd 100644 --- a/Emulator/Cartridges/CustomCartridges/PageFox.h +++ b/Emulator/Cartridges/CustomCartridges/PageFox.h @@ -51,14 +51,17 @@ class PageFox : public Cartridge { template void applyToPersistentItems(T& worker) { - worker - - << ctrlReg; + } template void serialize(T& worker) { + if (util::isResetter(worker)) return; + + worker + + << ctrlReg; } isize __size() override { COMPUTE_SNAPSHOT_SIZE } diff --git a/Emulator/Cartridges/CustomCartridges/Reu.h b/Emulator/Cartridges/CustomCartridges/Reu.h index c9aa54020..87d5fea09 100644 --- a/Emulator/Cartridges/CustomCartridges/Reu.h +++ b/Emulator/Cartridges/CustomCartridges/Reu.h @@ -87,6 +87,14 @@ class Reu : public Cartridge { template void applyToPersistentItems(T& worker) { + + } + + template + void serialize(T& worker) + { + if (util::isResetter(worker)) return; + worker << sr @@ -101,11 +109,6 @@ class Reu : public Cartridge { << memTypeF; } - template - void serialize(T& worker) - { - } - isize __size() override { COMPUTE_SNAPSHOT_SIZE } u64 __checksum() override { COMPUTE_SNAPSHOT_CHECKSUM } isize __load(const u8 *buffer) override { LOAD_SNAPSHOT_ITEMS } diff --git a/Emulator/Cartridges/FlashRom.h b/Emulator/Cartridges/FlashRom.h index 57775f8ca..81c41620d 100644 --- a/Emulator/Cartridges/FlashRom.h +++ b/Emulator/Cartridges/FlashRom.h @@ -86,15 +86,18 @@ class FlashRom : public SubComponent { template void applyToPersistentItems(T& worker) { - worker - - << state - << baseState; + } template void serialize(T& worker) { + if (util::isResetter(worker)) return; + + worker + + << state + << baseState; } isize _size() override { return [&](){COMPUTE_SNAPSHOT_SIZE}() + romSize; } diff --git a/Emulator/Components/C64.h b/Emulator/Components/C64.h index ff1a4e20a..df4d49368 100644 --- a/Emulator/Components/C64.h +++ b/Emulator/Components/C64.h @@ -342,11 +342,9 @@ class C64 : public Thread { template void applyToPersistentItems(T& worker) { - worker - - << durationOfOneCycle; + } - + template void serialize(T& worker) { @@ -362,6 +360,12 @@ class C64 : public Thread { << scanline << rasterCycle << ultimax; + + if (util::isResetter(worker)) return; + + worker + + << durationOfOneCycle; } public: diff --git a/Emulator/Components/CIA/CIA.h b/Emulator/Components/CIA/CIA.h index 792f8f460..f0c8d206c 100755 --- a/Emulator/Components/CIA/CIA.h +++ b/Emulator/Components/CIA/CIA.h @@ -314,12 +314,9 @@ class CIA : public SubComponent { template void applyToPersistentItems(T& worker) { - worker - - << config.revision - << config.timerBBug; + } - + template void serialize(T& worker) { @@ -355,6 +352,13 @@ class CIA : public SubComponent { << sleeping << sleepCycle << wakeUpCycle; + + if (util::isResetter(worker)) return; + + worker + + << config.revision + << config.timerBBug; } isize _size() override { COMPUTE_SNAPSHOT_SIZE } diff --git a/Emulator/Components/LogicBoard/ControlPort.h b/Emulator/Components/LogicBoard/ControlPort.h index 4061b9d00..94e06d205 100644 --- a/Emulator/Components/LogicBoard/ControlPort.h +++ b/Emulator/Components/LogicBoard/ControlPort.h @@ -66,15 +66,10 @@ class ControlPort : public SubComponent { void _reset(bool hard) override { RESET_SNAPSHOT_ITEMS(hard) }; template - void applyToPersistentItems(T& worker) - { - } - + void applyToPersistentItems(T& worker) { } + template - void serialize(T& worker) - { - } - + void serialize(T& worker) { } isize _size() override { COMPUTE_SNAPSHOT_SIZE } u64 _checksum() override { COMPUTE_SNAPSHOT_CHECKSUM } isize _load(const u8 *buffer) override { LOAD_SNAPSHOT_ITEMS } diff --git a/Emulator/Components/LogicBoard/ExpansionPort.h b/Emulator/Components/LogicBoard/ExpansionPort.h index 56e084ceb..5d6d4de2d 100644 --- a/Emulator/Components/LogicBoard/ExpansionPort.h +++ b/Emulator/Components/LogicBoard/ExpansionPort.h @@ -72,16 +72,19 @@ class ExpansionPort : public SubComponent { template void applyToPersistentItems(T& worker) { - worker - - << crtType - << gameLine - << exromLine; + } - + template void serialize(T& worker) { + if (util::isResetter(worker)) return; + + worker + + << crtType + << gameLine + << exromLine; } isize _size() override; diff --git a/Emulator/Components/LogicBoard/PowerSupply.h b/Emulator/Components/LogicBoard/PowerSupply.h index 71b739d58..d7a25fdfc 100644 --- a/Emulator/Components/LogicBoard/PowerSupply.h +++ b/Emulator/Components/LogicBoard/PowerSupply.h @@ -48,15 +48,9 @@ class PowerSupply : public SubComponent { private: template - void applyToPersistentItems(T& worker) - { - } - + void applyToPersistentItems(T& worker) { } template - void serialize(T& worker) - { - } - + void serialize(T& worker) { } isize _size() override { COMPUTE_SNAPSHOT_SIZE } u64 _checksum() override { COMPUTE_SNAPSHOT_CHECKSUM } isize _load(const u8 *buffer) override { LOAD_SNAPSHOT_ITEMS } diff --git a/Emulator/Components/Memory/C64Memory.h b/Emulator/Components/Memory/C64Memory.h index 5c9011e15..6a9ff5bc6 100644 --- a/Emulator/Components/Memory/C64Memory.h +++ b/Emulator/Components/Memory/C64Memory.h @@ -91,12 +91,7 @@ class C64Memory : public SubComponent { template void applyToPersistentItems(T& worker) { - worker - - << ram - << colorRam - << peekSrc - << pokeTarget; + } template @@ -105,6 +100,15 @@ class C64Memory : public SubComponent { worker << rom; + + if (util::isResetter(worker)) return; + + worker + + << ram + << colorRam + << peekSrc + << pokeTarget; } template diff --git a/Emulator/Components/SID/Muxer.h b/Emulator/Components/SID/Muxer.h index 3ff0e3f3e..923154c29 100644 --- a/Emulator/Components/SID/Muxer.h +++ b/Emulator/Components/SID/Muxer.h @@ -153,8 +153,22 @@ class Muxer : public SubComponent { template void applyToPersistentItems(T& worker) { + + } + + template + void serialize(T& worker) + { + if (util::isSoftResetter(worker)) return; + worker + << cycles; + + if (util::isResetter(worker)) return; + + worker + << config.revision << config.enabled << config.address @@ -173,16 +187,6 @@ class Muxer : public SubComponent { << pan; } - template - void serialize(T& worker) - { - if (util::isSoftResetter(worker)) return; - - worker - - << cycles; - } - isize _size() override { COMPUTE_SNAPSHOT_SIZE } u64 _checksum() override { COMPUTE_SNAPSHOT_CHECKSUM } isize _load(const u8 *buffer) override { LOAD_SNAPSHOT_ITEMS } diff --git a/Emulator/Components/SID/ReSID.h b/Emulator/Components/SID/ReSID.h index 9d7d68668..539ce65f8 100755 --- a/Emulator/Components/SID/ReSID.h +++ b/Emulator/Components/SID/ReSID.h @@ -93,6 +93,14 @@ class ReSID : public SubComponent { template void applyToPersistentItems(T& worker) { + + } + + template + void serialize(T& worker) + { + if (util::isResetter(worker)) return; + worker << st.sid_register @@ -115,19 +123,13 @@ class ReSID : public SubComponent { << st.envelope_state << st.hold_zero << st.envelope_pipeline - + << model << clockFrequency << samplingMethod << emulateFilter; } - template - void serialize(T& worker) - { - - } - isize _size() override { COMPUTE_SNAPSHOT_SIZE } u64 _checksum() override { COMPUTE_SNAPSHOT_CHECKSUM } isize _load(const u8 *buffer) override { LOAD_SNAPSHOT_ITEMS } diff --git a/Emulator/Components/SID/fastsid/FastSID.h b/Emulator/Components/SID/fastsid/FastSID.h index 63616c550..a85e037e6 100755 --- a/Emulator/Components/SID/fastsid/FastSID.h +++ b/Emulator/Components/SID/fastsid/FastSID.h @@ -134,11 +134,7 @@ class FastSID : public SubComponent { template void applyToPersistentItems(T& worker) { - worker - - << model - << cpuFrequency - << emulateFilter; + } template @@ -156,6 +152,14 @@ class FastSID : public SubComponent { << executedCycles << computedSamples; + + if (util::isResetter(worker)) return; + + worker + + << model + << cpuFrequency + << emulateFilter; } isize _size() override { COMPUTE_SNAPSHOT_SIZE } diff --git a/Emulator/Components/VICII/Recorder/Recorder.h b/Emulator/Components/VICII/Recorder/Recorder.h index 26653815c..af1ff13c9 100644 --- a/Emulator/Components/VICII/Recorder/Recorder.h +++ b/Emulator/Components/VICII/Recorder/Recorder.h @@ -95,7 +95,6 @@ class Recorder : public SubComponent { template void serialize(T& worker) { } - isize _size() override { COMPUTE_SNAPSHOT_SIZE } u64 _checksum() override { COMPUTE_SNAPSHOT_CHECKSUM } isize _load(const u8 *buffer) override { LOAD_SNAPSHOT_ITEMS } diff --git a/Emulator/Components/VICII/VICII.h b/Emulator/Components/VICII/VICII.h index 2f20b9d72..c97038254 100755 --- a/Emulator/Components/VICII/VICII.h +++ b/Emulator/Components/VICII/VICII.h @@ -614,20 +614,9 @@ class VICII : public SubComponent { template void applyToPersistentItems(T& worker) { - worker - - << config.revision - << config.powerSave - << config.grayDotBug - << config.glueLogic - << isPAL - << isNTSC - << is856x - << is656x - - << memSrc; + } - + template void serialize(T& worker) { @@ -699,6 +688,21 @@ class VICII : public SubComponent { >> gAccessResult << delay << bufferoffset; + + if (util::isResetter(worker)) return; + + worker + + << config.revision + << config.powerSave + << config.grayDotBug + << config.glueLogic + << isPAL + << isNTSC + << is856x + << is656x + + << memSrc; } isize _size() override { COMPUTE_SNAPSHOT_SIZE } diff --git a/Emulator/Peripherals/Datasette/Datasette.h b/Emulator/Peripherals/Datasette/Datasette.h index 4448d9fea..619391184 100644 --- a/Emulator/Peripherals/Datasette/Datasette.h +++ b/Emulator/Peripherals/Datasette/Datasette.h @@ -114,9 +114,7 @@ class Datasette : public SubComponent { template void applyToPersistentItems(T& worker) { - worker - - << type; + } template @@ -130,6 +128,12 @@ class Datasette : public SubComponent { << motor << nextRisingEdge << nextFallingEdge; + + if (util::isResetter(worker)) return; + + worker + + << type; } isize _size() override; diff --git a/Emulator/Peripherals/Drive/Disk.h b/Emulator/Peripherals/Drive/Disk.h index 0bf6d1d07..97dcfbd69 100644 --- a/Emulator/Peripherals/Drive/Disk.h +++ b/Emulator/Peripherals/Drive/Disk.h @@ -146,18 +146,20 @@ class Disk : public CoreObject { template void applyToPersistentItems(T& worker) { - worker - - << writeProtected - << modified - >> data - >> length; + } template void serialize(T& worker) { + if (util::isResetter(worker)) return; + worker + + << writeProtected + << modified + >> data + >> length; } diff --git a/Emulator/Peripherals/Drive/Drive.h b/Emulator/Peripherals/Drive/Drive.h index 090ebd57a..1fb28134c 100644 --- a/Emulator/Peripherals/Drive/Drive.h +++ b/Emulator/Peripherals/Drive/Drive.h @@ -250,23 +250,7 @@ class Drive : public SubComponent { template void applyToPersistentItems(T& worker) { - worker - - << config.type - << config.ram - << config.parCable - << config.powerSave - << config.connected - << config.switchedOn - << config.ejectDelay - << config.swapDelay - << config.insertDelay - << config.pan - << config.powerVolume - << config.stepVolume - << config.insertVolume - << config.ejectVolume - << insertionStatus; + } template @@ -291,6 +275,26 @@ class Drive : public SubComponent { << sync << byteReady << watchdog; + + if (util::isResetter(worker)) return; + + worker + + << config.type + << config.ram + << config.parCable + << config.powerSave + << config.connected + << config.switchedOn + << config.ejectDelay + << config.swapDelay + << config.insertDelay + << config.pan + << config.powerVolume + << config.stepVolume + << config.insertVolume + << config.ejectVolume + << insertionStatus; } isize _size() override; diff --git a/Emulator/Peripherals/Drive/DriveMemory.h b/Emulator/Peripherals/Drive/DriveMemory.h index 4e6a883ab..fe0297550 100644 --- a/Emulator/Peripherals/Drive/DriveMemory.h +++ b/Emulator/Peripherals/Drive/DriveMemory.h @@ -72,15 +72,18 @@ class DriveMemory : public SubComponent { template void applyToPersistentItems(T& worker) { - worker - - << ram - << usage; + } template void serialize(T& worker) { + if (util::isResetter(worker)) return; + + worker + + << ram + << usage; } template diff --git a/Emulator/Peripherals/Mouse/Mouse.h b/Emulator/Peripherals/Mouse/Mouse.h index 1f477a7e8..9fc7791c1 100644 --- a/Emulator/Peripherals/Mouse/Mouse.h +++ b/Emulator/Peripherals/Mouse/Mouse.h @@ -112,12 +112,17 @@ class Mouse : public SubComponent { template void applyToPersistentItems(T& worker) { - worker << config.model; + } template void serialize(T& worker) { + if (util::isResetter(worker)) return; + + worker + + << config.model; } isize _size() override { COMPUTE_SNAPSHOT_SIZE }