mirror of
https://github.com/melonDS-emu/melonDS.git
synced 2025-07-24 06:39:58 -06:00
Implement in-memory savestates (#1693)
* Refactor Savestate::Var{8,16,32,64} - They now delegate to VarArray - They're declared in the class header so they're likely to be inlined * First crack at refactoring Savestate to work in-memory - Well, third, but who's counting? * Implement Savestate::Finish * Remove the VersionMajor and VersionMinor fields - Instead, pull their values directly from the savestate buffer * Mark a new constructor as explicit * Rename Reset to Rewind * Fix a linebreak * Implement Savestate::Rewind * Add ROMManager::ClearBackupState * Refactor ROMManager to use the refactored Savestate * Capitalize "Least" - It was driving me nuts * Add a log call * Increase default Savestate buffer length to 32MB * Use C-style file I/O instead of C++-style - Dumping bytes to a file with C++'s standard library is a MONSTROUS PAIN IN THE ASS * Quote the savestate's file path for clarity * Write the savestate's length into the header * Add some extra logging calls * Fix section-loading * Remove the deprecated Savestate constructor * Convert a char* to a u32 with memcpy, not a cast * Fix section-handling in loads * Include <cstring> in Savestate.h - This was causing a build error on Linux
This commit is contained in:

committed by
GitHub

parent
ca7fb4f55e
commit
391ad8c95e
11
src/NDS.cpp
11
src/NDS.cpp
@ -815,7 +815,10 @@ bool DoSavestate(Savestate* file)
|
||||
u32 console;
|
||||
file->Var32(&console);
|
||||
if (console != ConsoleType)
|
||||
{
|
||||
Log(LogLevel::Error, "savestate: Expected console type %d, got console type %d. cannot load.\n", ConsoleType, console);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
file->VarArray(MainRAM, MainRAMMaxSize);
|
||||
@ -870,7 +873,11 @@ bool DoSavestate(Savestate* file)
|
||||
|
||||
file->VarArray(DMA9Fill, 4*sizeof(u32));
|
||||
|
||||
if (!DoSavestate_Scheduler(file)) return false;
|
||||
if (!DoSavestate_Scheduler(file))
|
||||
{
|
||||
Platform::Log(Platform::LogLevel::Error, "savestate: failed to %s scheduler state\n", file->Saving ? "save" : "load");
|
||||
return false;
|
||||
}
|
||||
file->Var32(&SchedListMask);
|
||||
file->Var64(&ARM9Timestamp);
|
||||
file->Var64(&ARM9Target);
|
||||
@ -937,6 +944,8 @@ bool DoSavestate(Savestate* file)
|
||||
}
|
||||
#endif
|
||||
|
||||
file->Finish();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user