Skip to content

Commit

Permalink
Serialization cleanup (everything is handles in serialize() )
Browse files Browse the repository at this point in the history
  • Loading branch information
dirkwhoffmann committed Jan 20, 2024
1 parent def60b2 commit 4711590
Show file tree
Hide file tree
Showing 50 changed files with 15 additions and 286 deletions.
4 changes: 0 additions & 4 deletions Emulator/Base/CoreComponent.h
Original file line number Diff line number Diff line change
Expand Up @@ -221,26 +221,22 @@ serialize(resetter); \

#define COMPUTE_SNAPSHOT_SIZE \
util::SerCounter counter; \
applyToPersistentItems(counter); \
serialize(counter); \
return counter.count;

#define COMPUTE_SNAPSHOT_CHECKSUM \
util::SerChecker checker; \
applyToPersistentItems(checker); \
serialize(checker); \
return checker.hash;

#define LOAD_SNAPSHOT_ITEMS \
util::SerReader reader(buffer); \
applyToPersistentItems(reader); \
serialize(reader); \
debug(SNP_DEBUG, "Recreated from %zu bytes\n", reader.ptr - buffer); \
return (isize)(reader.ptr - buffer);

#define SAVE_SNAPSHOT_ITEMS \
util::SerWriter writer(buffer); \
applyToPersistentItems(writer); \
serialize(writer); \
debug(SNP_DEBUG, "Serialized to %zu bytes\n", writer.ptr - buffer); \
return (isize)(writer.ptr - buffer);
Expand Down
4 changes: 0 additions & 4 deletions Emulator/Cartridges/Cartridge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,6 @@ isize
Cartridge::_size()
{
util::SerCounter counter;
applyToPersistentItems(counter);
serialize(counter);

isize result = counter.count;
Expand All @@ -264,7 +263,6 @@ u64
Cartridge::_checksum()
{
util::SerChecker checker;
applyToPersistentItems(checker);
serialize(checker);

return util::fnvIt64(checker.hash, __checksum());
Expand All @@ -276,7 +274,6 @@ Cartridge::_load(const u8 *buffer)
dealloc();

util::SerReader reader(buffer);
applyToPersistentItems(reader);
serialize(reader);

// Load ROM
Expand Down Expand Up @@ -306,7 +303,6 @@ isize
Cartridge::_save(u8 *buffer)
{
util::SerWriter writer(buffer);
applyToPersistentItems(writer);
serialize(writer);

// Save ROM
Expand Down
8 changes: 1 addition & 7 deletions Emulator/Cartridges/Cartridge.h
Original file line number Diff line number Diff line change
Expand Up @@ -168,13 +168,7 @@ class Cartridge : public SubComponent {
protected:

void _reset(bool hard) override;

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

}


template <class T>
void serialize(T& worker)
{
Expand Down
3 changes: 0 additions & 3 deletions Emulator/Cartridges/CartridgeRom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ isize
CartridgeRom::_size()
{
util::SerCounter counter;
applyToPersistentItems(counter);
serialize(counter);

return size + counter.count;
Expand All @@ -50,7 +49,6 @@ isize
CartridgeRom::_load(const u8 *buffer)
{
util::SerReader reader(buffer);
applyToPersistentItems(reader);
serialize(reader);

// Delete the old packet and create a new one with the proper size
Expand All @@ -68,7 +66,6 @@ isize
CartridgeRom::_save(u8 *buffer)
{
util::SerWriter writer(buffer);
applyToPersistentItems(writer);
serialize(writer);

// Write packet data
Expand Down
6 changes: 0 additions & 6 deletions Emulator/Cartridges/CartridgeRom.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,6 @@ class CartridgeRom : public SubComponent {

private:

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

}

template <class T>
void serialize(T& worker)
{
Expand Down
6 changes: 0 additions & 6 deletions Emulator/Cartridges/CustomCartridges/EasyFlash.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,7 @@ class EasyFlash : public Cartridge {
//

private:

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

}

template <class T>
void serialize(T& worker)
{
Expand Down
5 changes: 0 additions & 5 deletions Emulator/Cartridges/CustomCartridges/Epyx.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,6 @@ class Epyx : public Cartridge {

private:

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

template <class T>
void serialize(T& worker)
{
Expand Down
6 changes: 0 additions & 6 deletions Emulator/Cartridges/CustomCartridges/Expert.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,6 @@ class Expert : public Cartridge {

private:

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

}

template <class T>
void serialize(T& worker)
{
Expand Down
8 changes: 1 addition & 7 deletions Emulator/Cartridges/CustomCartridges/FinalIII.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,7 @@ class FinalIII : public Cartridge {
//

private:

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

}


template <class T>
void serialize(T& worker)
{
Expand Down
6 changes: 0 additions & 6 deletions Emulator/Cartridges/CustomCartridges/GeoRam.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,7 @@ class GeoRAM : public Cartridge {
//

private:

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

}

template <class T>
void serialize(T& worker)
{
Expand Down
8 changes: 1 addition & 7 deletions Emulator/Cartridges/CustomCartridges/Isepic.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,7 @@ class Isepic : public Cartridge {
//

private:

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

}


template <class T>
void serialize(T& worker)
{
Expand Down
6 changes: 0 additions & 6 deletions Emulator/Cartridges/CustomCartridges/PageFox.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,6 @@ class PageFox : public Cartridge {

private:

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

}

template <class T>
void serialize(T& worker)
{
Expand Down
6 changes: 0 additions & 6 deletions Emulator/Cartridges/CustomCartridges/Reu.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,6 @@ class Reu : public Cartridge {

private:

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

}

template <class T>
void serialize(T& worker)
{
Expand Down
5 changes: 0 additions & 5 deletions Emulator/Cartridges/CustomCartridges/StarDos.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,6 @@ class StarDos : public Cartridge {

private:

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

template <class T>
void serialize(T& worker)
{
Expand Down
5 changes: 0 additions & 5 deletions Emulator/Cartridges/CustomCartridges/SuperGames.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,6 @@ class SuperGames : public Cartridge {

private:

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

template <class T>
void serialize(T& worker)
{
Expand Down
6 changes: 0 additions & 6 deletions Emulator/Cartridges/FlashRom.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,6 @@ class FlashRom : public SubComponent {

void _reset(bool hard) override;

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

}

template <class T>
void serialize(T& worker)
{
Expand Down
6 changes: 0 additions & 6 deletions Emulator/Components/C64.h
Original file line number Diff line number Diff line change
Expand Up @@ -339,12 +339,6 @@ class C64 : public Thread {

private:

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

}

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

private:

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

}

template <class T>
void serialize(T& worker)
{
Expand Down
5 changes: 0 additions & 5 deletions Emulator/Components/CIA/TOD.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,6 @@ class TOD : public SubComponent {
void _reset(bool hard) override;
void _inspect() const override;

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

template <class T>
void serialize(T& worker)
{
Expand Down
5 changes: 0 additions & 5 deletions Emulator/Components/CPU/CPU.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,6 @@ class CPU : public Peddle {
void _inspect() const override;
void _trackOn() override;
void _trackOff() override;

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

template <class T>
void serialize(T& worker)
Expand Down
6 changes: 1 addition & 5 deletions Emulator/Components/LogicBoard/ControlPort.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,7 @@ class ControlPort : public SubComponent {

void _reset(bool hard) override { RESET_SNAPSHOT_ITEMS(hard) };

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

template <class T>
void serialize(T& worker) { }
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
4 changes: 0 additions & 4 deletions Emulator/Components/LogicBoard/ExpansionPort.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ isize
ExpansionPort::_size()
{
util::SerCounter counter;
applyToPersistentItems(counter);
serialize(counter);

if (cartridge) counter.count += cartridge->size();
Expand All @@ -42,7 +41,6 @@ ExpansionPort::_checksum()
{
util::SerChecker checker;

applyToPersistentItems(checker);
serialize(checker);

if (cartridge) {
Expand All @@ -56,7 +54,6 @@ isize
ExpansionPort::_load(const u8 *buffer)
{
util::SerReader reader(buffer);
applyToPersistentItems(reader);
serialize(reader);

// Load cartridge (if any)
Expand All @@ -73,7 +70,6 @@ isize
ExpansionPort::_save(u8 *buffer)
{
util::SerWriter writer(buffer);
applyToPersistentItems(writer);
serialize(writer);

// Save cartridge (if any)
Expand Down
6 changes: 0 additions & 6 deletions Emulator/Components/LogicBoard/ExpansionPort.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,6 @@ class ExpansionPort : public SubComponent {
private:

void _reset(bool hard) override;

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

}

template <class T>
void serialize(T& worker)
Expand Down
5 changes: 0 additions & 5 deletions Emulator/Components/LogicBoard/IEC.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,6 @@ class IEC : public SubComponent {

void _reset(bool hard) override;

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

template <class T>
void serialize(T& worker)
{
Expand Down
7 changes: 2 additions & 5 deletions Emulator/Components/LogicBoard/PowerSupply.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,8 @@ class PowerSupply : public SubComponent {
void _reset(bool hard) override;

private:

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

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
Loading

0 comments on commit 4711590

Please sign in to comment.