Skip to content

Commit

Permalink
Serialization cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
dirkwhoffmann committed Jan 20, 2024
1 parent 40cf957 commit def60b2
Show file tree
Hide file tree
Showing 26 changed files with 218 additions and 145 deletions.
22 changes: 13 additions & 9 deletions Emulator/Cartridges/Cartridge.h
Original file line number Diff line number Diff line change
Expand Up @@ -172,15 +172,7 @@ class Cartridge : public SubComponent {
template <class T>
void applyToPersistentItems(T& worker)
{
worker

<< gameLineInCrtFile
<< exromLineInCrtFile
<< numPackets
<< ramCapacity
<< battery
<< control
<< switchPos;

}

template <class T>
Expand All @@ -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:
Expand Down
11 changes: 7 additions & 4 deletions Emulator/Cartridges/CartridgeRom.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,18 @@ class CartridgeRom : public SubComponent {
template <class T>
void applyToPersistentItems(T& worker)
{
worker

<< size
<< loadAddress;

}

template <class T>
void serialize(T& worker)
{
if (util::isResetter(worker)) return;

worker

<< size
<< loadAddress;
}

isize _size() override;
Expand Down
10 changes: 7 additions & 3 deletions Emulator/Cartridges/CustomCartridges/EasyFlash.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,7 @@ class EasyFlash : public Cartridge {
template <class T>
void applyToPersistentItems(T& worker)
{
worker

<< jumper;

}

template <class T>
Expand All @@ -78,6 +76,12 @@ class EasyFlash : public Cartridge {
<< bankReg
<< modeReg
<< bank;

if (util::isResetter(worker)) return;

worker

<< jumper;
}

isize __size() override { COMPUTE_SNAPSHOT_SIZE }
Expand Down
9 changes: 6 additions & 3 deletions Emulator/Cartridges/CustomCartridges/Expert.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,17 @@ class Expert : public Cartridge {
template <class T>
void applyToPersistentItems(T& worker)
{
worker

<< active;

}

template <class T>
void serialize(T& worker)
{
if (util::isResetter(worker)) return;

worker

<< active;
}

isize __size() override { COMPUTE_SNAPSHOT_SIZE }
Expand Down
12 changes: 10 additions & 2 deletions Emulator/Cartridges/CustomCartridges/FinalIII.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,21 @@ class FinalIII : public Cartridge {
template <class T>
void applyToPersistentItems(T& worker)
{
worker << freeezeButtonIsPressed;

}

template <class T>
void serialize(T& worker)
{
worker << qD;
worker

<< qD;

if (util::isResetter(worker)) return;

worker

<< freeezeButtonIsPressed;
}

isize __size() override { COMPUTE_SNAPSHOT_SIZE }
Expand Down
11 changes: 7 additions & 4 deletions Emulator/Cartridges/CustomCartridges/GeoRam.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,18 @@ class GeoRAM : public Cartridge {
template <class T>
void applyToPersistentItems(T& worker)
{
worker

<< bank
<< page;

}

template <class T>
void serialize(T& worker)
{
if (util::isResetter(worker)) return;

worker

<< bank
<< page;
}

isize __size() override { COMPUTE_SNAPSHOT_SIZE }
Expand Down
12 changes: 8 additions & 4 deletions Emulator/Cartridges/CustomCartridges/Isepic.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,7 @@ class Isepic : public Cartridge {
template <class T>
void applyToPersistentItems(T& worker)
{
worker

<< oldPeekSource
<< oldPokeTarget;

}

template <class T>
Expand All @@ -64,6 +61,13 @@ class Isepic : public Cartridge {
worker

<< page;

if (util::isResetter(worker)) return;

worker

<< oldPeekSource
<< oldPokeTarget;
}

isize __size() override { COMPUTE_SNAPSHOT_SIZE }
Expand Down
9 changes: 6 additions & 3 deletions Emulator/Cartridges/CustomCartridges/PageFox.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,17 @@ class PageFox : public Cartridge {
template <class T>
void applyToPersistentItems(T& worker)
{
worker

<< ctrlReg;

}

template <class T>
void serialize(T& worker)
{
if (util::isResetter(worker)) return;

worker

<< ctrlReg;
}

isize __size() override { COMPUTE_SNAPSHOT_SIZE }
Expand Down
13 changes: 8 additions & 5 deletions Emulator/Cartridges/CustomCartridges/Reu.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,14 @@ class Reu : public Cartridge {
template <class T>
void applyToPersistentItems(T& worker)
{

}

template <class T>
void serialize(T& worker)
{
if (util::isResetter(worker)) return;

worker

<< sr
Expand All @@ -101,11 +109,6 @@ class Reu : public Cartridge {
<< memTypeF;
}

template <class T>
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 }
Expand Down
11 changes: 7 additions & 4 deletions Emulator/Cartridges/FlashRom.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,15 +86,18 @@ class FlashRom : public SubComponent {
template <class T>
void applyToPersistentItems(T& worker)
{
worker

<< state
<< baseState;

}

template <class T>
void serialize(T& worker)
{
if (util::isResetter(worker)) return;

worker

<< state
<< baseState;
}

isize _size() override { return [&](){COMPUTE_SNAPSHOT_SIZE}() + romSize; }
Expand Down
12 changes: 8 additions & 4 deletions Emulator/Components/C64.h
Original file line number Diff line number Diff line change
Expand Up @@ -342,11 +342,9 @@ class C64 : public Thread {
template <class T>
void applyToPersistentItems(T& worker)
{
worker

<< durationOfOneCycle;

}

template <class T>
void serialize(T& worker)
{
Expand All @@ -362,6 +360,12 @@ class C64 : public Thread {
<< scanline
<< rasterCycle
<< ultimax;

if (util::isResetter(worker)) return;

worker

<< durationOfOneCycle;
}

public:
Expand Down
14 changes: 9 additions & 5 deletions Emulator/Components/CIA/CIA.h
Original file line number Diff line number Diff line change
Expand Up @@ -314,12 +314,9 @@ class CIA : public SubComponent {
template <class T>
void applyToPersistentItems(T& worker)
{
worker

<< config.revision
<< config.timerBBug;

}

template <class T>
void serialize(T& worker)
{
Expand Down Expand Up @@ -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 }
Expand Down
11 changes: 3 additions & 8 deletions Emulator/Components/LogicBoard/ControlPort.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,10 @@ class ControlPort : public SubComponent {
void _reset(bool hard) override { RESET_SNAPSHOT_ITEMS(hard) };

template <class T>
void applyToPersistentItems(T& worker)
{
}

void applyToPersistentItems(T& worker) { }

template <class T>
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 }
Expand Down
15 changes: 9 additions & 6 deletions Emulator/Components/LogicBoard/ExpansionPort.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,16 +72,19 @@ class ExpansionPort : public SubComponent {
template <class T>
void applyToPersistentItems(T& worker)
{
worker

<< crtType
<< gameLine
<< exromLine;

}

template <class T>
void serialize(T& worker)
{
if (util::isResetter(worker)) return;

worker

<< crtType
<< gameLine
<< exromLine;
}

isize _size() override;
Expand Down
10 changes: 2 additions & 8 deletions Emulator/Components/LogicBoard/PowerSupply.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,9 @@ class PowerSupply : public SubComponent {
private:

template <class T>
void applyToPersistentItems(T& worker)
{
}

void applyToPersistentItems(T& worker) { }
template <class T>
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 }
Expand Down
16 changes: 10 additions & 6 deletions Emulator/Components/Memory/C64Memory.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,7 @@ class C64Memory : public SubComponent {
template <class T>
void applyToPersistentItems(T& worker)
{
worker

<< ram
<< colorRam
<< peekSrc
<< pokeTarget;

}

template <class T>
Expand All @@ -105,6 +100,15 @@ class C64Memory : public SubComponent {
worker

<< rom;

if (util::isResetter(worker)) return;

worker

<< ram
<< colorRam
<< peekSrc
<< pokeTarget;
}

template <class T>
Expand Down
Loading

0 comments on commit def60b2

Please sign in to comment.