Write the title ID to savestates - and disallow loading savestates from a different title for the moment.

This commit is contained in:
Dr. Chat 2016-09-28 18:33:25 -05:00
parent 880835d9b5
commit f5995474b1
1 changed files with 9 additions and 1 deletions

View File

@ -338,7 +338,7 @@ bool Emulator::SaveToFile(const std::wstring& path) {
filesystem::CreateFile(path);
auto map = MappedMemory::Open(path, MappedMemory::Mode::kReadWrite, 0,
1024ull * 1024ull * 1024ull * 4ull);
1024ull * 1024ull * 1024ull * 2ull);
if (!map) {
return false;
}
@ -346,6 +346,7 @@ bool Emulator::SaveToFile(const std::wstring& path) {
// Save the emulator state to a file
ByteStream stream(map->data(), map->size());
stream.Write('XSAV');
stream.Write(title_id_);
// It's important we don't hold the global lock here! XThreads need to step
// forward (possibly through guarded regions) without worry!
@ -379,6 +380,13 @@ bool Emulator::RestoreFromFile(const std::wstring& path) {
return false;
}
auto title_id = stream.Read<uint32_t>();
if (title_id != title_id_) {
// Swapping between titles is unsupported at the moment.
assert_always();
return false;
}
if (!processor_->Restore(&stream)) {
XELOGE("Could not restore processor!");
return false;