Mesen-SX/Core/RewindData.cpp

33 lines
782 B
C++
Raw Normal View History

2019-03-12 12:06:42 -04:00
#include "stdafx.h"
#include "RewindData.h"
#include "Console.h"
#include "SaveStateManager.h"
#include "../Utilities/miniz.h"
2020-12-19 23:30:09 +03:00
void RewindData::GetStateData(stringstream& stateData)
2019-03-12 12:06:42 -04:00
{
stateData.write((char*)SaveStateData.data(), SaveStateData.size());
2019-03-12 12:06:42 -04:00
}
2020-12-19 23:30:09 +03:00
void RewindData::LoadState(shared_ptr<Console>& console)
2019-03-12 12:06:42 -04:00
{
2020-12-19 23:30:09 +03:00
if (SaveStateData.size() > 0)
{
2019-03-12 12:06:42 -04:00
stringstream stream;
stream.write((char*)SaveStateData.data(), SaveStateData.size());
2019-03-12 12:06:42 -04:00
stream.seekg(0, ios::beg);
console->Deserialize(stream, SaveStateManager::FileFormatVersion);
}
}
2020-12-19 23:30:09 +03:00
void RewindData::SaveState(shared_ptr<Console>& console)
2019-03-12 12:06:42 -04:00
{
std::stringstream state;
console->Serialize(state);
string data = state.str();
2020-12-19 23:30:09 +03:00
SaveStateData = vector<uint8_t>(data.c_str(), data.c_str() + data.size());
2019-03-12 12:06:42 -04:00
FrameCount = 0;
}