Skip to content

Commit

Permalink
Fixed severe snapshot saving bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
dirkwhoffmann committed Jan 21, 2024
1 parent 4711590 commit 80f28dd
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 30 deletions.
2 changes: 2 additions & 0 deletions Emulator/Base/CoreComponent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ CoreComponent::load(const u8 *buffer)

// Check integrity
if (hash != _checksum() || FORCE_SNAP_CORRUPTED) {

debug(SNP_DEBUG, "Corrupted snapshot detected\n");
throw VC64Error(ERROR_SNAP_CORRUPTED);
}

Expand Down
18 changes: 10 additions & 8 deletions Emulator/Components/CPU/CPU.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,24 +95,26 @@ class CPU : public Peddle {

<< flags
<< next
<< reg.a
<< reg.x
<< reg.y
<< reg.pc
<< reg.pc0
<< reg.sp
<< reg.a
<< reg.x
<< reg.y
<< reg.adl
<< reg.adh
<< reg.idl
<< reg.d
<< reg.ovl
<< reg.sr.n
<< reg.sr.v
<< reg.sr.b
<< reg.sr.d
<< reg.sr.i
<< reg.sr.z
<< reg.sr.c
<< reg.adl
<< reg.adh
<< reg.idl
<< reg.d
<< reg.ovl
<< reg.pport.data
<< reg.pport.direction
<< rdyLine
<< rdyLineUp
<< rdyLineDown
Expand Down
6 changes: 5 additions & 1 deletion Emulator/Components/LogicBoard/ExpansionPort.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,16 @@ ExpansionPort::_load(const u8 *buffer)
util::SerReader reader(buffer);
serialize(reader);

// Delete existing cartridge
cartridge = nullptr;

// Load cartridge (if any)
if (crtType != CRT_NONE) {

cartridge = std::unique_ptr<Cartridge>(Cartridge::makeWithType(c64, crtType));
reader.ptr += cartridge->load(reader.ptr);
}

debug(SNP_DEBUG, "Recreated from %ld bytes\n", isize(reader.ptr - buffer));
return isize(reader.ptr - buffer);
}
Expand Down
9 changes: 4 additions & 5 deletions Emulator/Components/Memory/C64Memory.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,11 @@ class C64Memory : public SubComponent {
worker

<< rom;
}

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

worker
Expand All @@ -104,11 +108,6 @@ class C64Memory : public SubComponent {
<< peekSrc
<< pokeTarget;
}

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

isize _size() override;
u64 _checksum() override;
Expand Down
2 changes: 2 additions & 0 deletions Emulator/Components/VICII/VICII.h
Original file line number Diff line number Diff line change
Expand Up @@ -671,8 +671,10 @@ class VICII : public SubComponent {
<< spriteDmaOnOff
<< expansionFF
<< cleared_bits_in_d017
<< collision
<< lpLine
<< lpIrqHasOccurred
<< memSrc
<< ultimax
<< dataBusPhi1
<< dataBusPhi2
Expand Down
2 changes: 1 addition & 1 deletion Emulator/Misc/RetroShell/InterpreterDebugCmds.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ Interpreter::initDebugShell(Command &root)

for (isize i = 0; i < 2; i++) {

string cia = (i == 0) ? "cia1" : "cia1";
string cia = (i == 0) ? "cia1" : "cia2";

root.add({cia, ""},
"Displays the component state",
Expand Down
39 changes: 24 additions & 15 deletions Emulator/Peripherals/Drive/DiskTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@
#include "Aliases.h"
#include "Reflection.h"

#ifdef __cplusplus
#include "Serialization.h"
#endif

//
// Constants
//
Expand Down Expand Up @@ -220,16 +224,18 @@ struct DiskErrorCodeEnum : util::Reflection<DiskErrorCodeEnum, DiskErrorCode> {
*/

#ifdef __cplusplus
union DiskData
struct DiskData : public util::Serializable
{
struct
{
u8 _pad[maxBytesOnTrack];
u8 halftrack[85][maxBytesOnTrack];
union {

struct
{
u8 _pad[maxBytesOnTrack];
u8 halftrack[85][maxBytesOnTrack];
};

u8 track[43][2 * maxBytesOnTrack];
};

u8 track[43][2 * maxBytesOnTrack];

template <class W>
void operator<<(W& worker)
{
Expand All @@ -248,15 +254,18 @@ union DiskData
*/

#ifdef __cplusplus
union DiskLength
struct DiskLength : public util::Serializable
{
struct
{
isize _pad;
isize halftrack[85];
union {

struct
{
isize _pad;
isize halftrack[85];
};

isize track[43][2];
};

isize track[43][2];

template <class W>
void operator<<(W& worker)
Expand Down

0 comments on commit 80f28dd

Please sign in to comment.