Mesen-SX/Core/RewindData.cpp

32 lines
778 B
C++
Raw Permalink 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"
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
}
void RewindData::LoadState(shared_ptr<Console> &console)
2019-03-12 12:06:42 -04: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);
}
}
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();
SaveStateData = vector<uint8_t>(data.c_str(), data.c_str()+data.size());
2019-03-12 12:06:42 -04:00
FrameCount = 0;
}