Skip to content

Commit

Permalink
Saving size information of each component in snapshot
Browse files Browse the repository at this point in the history
  • Loading branch information
dirkwhoffmann committed Nov 24, 2024
1 parent ac2b586 commit f9c7375
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 26 deletions.
23 changes: 15 additions & 8 deletions Emulator/Base/CoreComponent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -243,9 +243,9 @@ CoreComponent::size(bool recursive)
*this << counter;
isize result = counter.count;

// Add 8 bytes for the checksum
result += 8;
// Add 8 bytes for the size and checksum
result += 16;

// Add size of subcomponents if requested
if (recursive) for (CoreComponent *c : subComponents) { result += c->size(); }

Expand All @@ -263,21 +263,25 @@ CoreComponent::load(const u8 *buffer)

const u8 *ptr = buffer + result;

// Load the checksum for this component
// Load the size and checksum for this component
auto size = read64(ptr);
auto hash = read64(ptr);

// Load the internal state of this component
SerReader reader(ptr); *c << reader;

// Determine the number of loaded bytes
isize count = (isize)(reader.ptr - (buffer + result));
auto count = u64(reader.ptr - (buffer + result));

// Check integrity
if (hash != c->checksum(false) || FORCE_SNAP_CORRUPTED) {
if (size != count || hash != c->checksum(false) || FORCE_SNAP_CORRUPTED) {

msg("Loaded %llu bytes (expected %llu)\n", count, size);
msg("Hash: %llx (expected %llx)\n", hash, c->checksum(false));
if (SNP_DEBUG) { fatalError; } else { throw Error(VAERROR_SNAP_CORRUPTED); }
}

debug(SNP_DEBUG >= 2, "Loaded %ld bytes (expected %ld)\n", count, c->size(false));
debug(SNP_DEBUG >= 2, "Loaded %llu bytes (expected %llu)\n", count, size);
result += count;
});

Expand All @@ -295,7 +299,8 @@ CoreComponent::save(u8 *buffer)

u8 *ptr = buffer + result;

// Save the checksum for this component
// Save the size and the checksum for this component
write64(ptr, c->size(false));
write64(ptr, c->checksum(false));

// Save the internal state of this component
Expand All @@ -306,6 +311,8 @@ CoreComponent::save(u8 *buffer)

// Check integrity
if (count != c->size(false) || FORCE_SNAP_CORRUPTED) {

msg("Saved %ld bytes (expected %ld)\n", count, c->size(false));
if (SNP_DEBUG) { fatalError; } else { throw Error(VAERROR_SNAP_CORRUPTED); }
}

Expand Down
5 changes: 0 additions & 5 deletions Emulator/Components/CPU/Moira/Moira.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,6 @@ class Moira : public SubComponent {

public:

// Floating point unit (not supported yet)
// FPU fpu = FPU(*this);

// Breakpoints, watchpoints, catchpoints, instruction tracing
Debugger debugger = Debugger(*this);

Expand Down Expand Up @@ -107,11 +104,9 @@ class Moira : public SubComponent {

// Jump table holding the instruction handlers
typedef void (Moira::*ExecPtr)(u16);
// ExecPtr exec[65536];
ExecPtr *exec = nullptr;

// Jump table holding the loop mode instruction handlers (68010 only)
// ExecPtr loop[65536];
ExecPtr *loop = nullptr;

// Jump table holding the disassebler handlers
Expand Down
13 changes: 0 additions & 13 deletions Emulator/Components/CPU/Moira/MoiraConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,18 +74,6 @@
*/
#define BUILD_INSTR_INFO_TABLE false

/* Set to true to abort compilation on platforms with no long double support
*
* Some FPU functions make use of the "long double" type which is mapped to the
* standard "double" type on some platforms. On those platforms, the FPU can
* compute imprecise results, e.g., when reading a value in packed BCD format
* from memory. In practice, the implication of this imprecision will most
* likely be neglectable.
*
* Disable to allow small precision errors.
*/
#define REQUIRE_PRECISE_FPU false

/* Set to true to run Moira in a special Musashi compatibility mode.
*
* The compatibility mode is used by the test runner application to compare
Expand Down Expand Up @@ -165,7 +153,6 @@ I == FTANH || \
I == FTENTOX || \
I == FTWOTOX
*/
// I == STOP || I == TAS || I == BKPT

/* The following macro appear at the end of each instruction handler.
* Moira will call 'didExecute(...)' for all listed instructions.
Expand Down
10 changes: 10 additions & 0 deletions Resources/Assets.xcassets/ROMs/rom_demo.imageset/Contents.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,16 @@
{
"filename" : "rom_demo.pdf",
"idiom" : "universal"
},
{
"appearances" : [
{
"appearance" : "luminosity",
"value" : "dark"
}
],
"filename" : "rom_demo_darkMode.pdf",
"idiom" : "universal"
}
],
"info" : {
Expand Down
Binary file not shown.

0 comments on commit f9c7375

Please sign in to comment.