mirror of
https://github.com/Lime3DS/Lime3DS.git
synced 2024-11-02 00:15:06 +01:00
Fixed TAS movie serialization
This commit is contained in:
parent
ac37de10fc
commit
7ff985cef9
@ -534,6 +534,17 @@ void System::Reset() {
|
|||||||
|
|
||||||
template <class Archive>
|
template <class Archive>
|
||||||
void System::serialize(Archive& ar, const unsigned int file_version) {
|
void System::serialize(Archive& ar, const unsigned int file_version) {
|
||||||
|
if (Archive::is_loading::value) {
|
||||||
|
// When loading, we want to make sure any lingering state gets cleared out before we begin.
|
||||||
|
// Shutdown, but persist a few things between loads...
|
||||||
|
Shutdown(true);
|
||||||
|
|
||||||
|
// Re-initialize everything like it was before
|
||||||
|
auto system_mode = this->app_loader->LoadKernelSystemMode();
|
||||||
|
auto n3ds_mode = this->app_loader->LoadKernelN3dsMode();
|
||||||
|
Init(*m_emu_window, *system_mode.first, *n3ds_mode.first);
|
||||||
|
}
|
||||||
|
|
||||||
u32 num_cores;
|
u32 num_cores;
|
||||||
if (Archive::is_saving::value) {
|
if (Archive::is_saving::value) {
|
||||||
num_cores = this->GetNumCores();
|
num_cores = this->GetNumCores();
|
||||||
@ -565,11 +576,14 @@ void System::serialize(Archive& ar, const unsigned int file_version) {
|
|||||||
|
|
||||||
ar&* memory.get();
|
ar&* memory.get();
|
||||||
ar&* kernel.get();
|
ar&* kernel.get();
|
||||||
|
VideoCore::serialize(ar, file_version);
|
||||||
|
ar& Movie::GetInstance();
|
||||||
|
|
||||||
// This needs to be set from somewhere - might as well be here!
|
// This needs to be set from somewhere - might as well be here!
|
||||||
if (Archive::is_loading::value) {
|
if (Archive::is_loading::value) {
|
||||||
Service::GSP::SetGlobalModule(*this);
|
Service::GSP::SetGlobalModule(*this);
|
||||||
memory->SetDSP(*dsp_core);
|
memory->SetDSP(*dsp_core);
|
||||||
|
cheat_engine->Connect();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <functional>
|
#include <functional>
|
||||||
|
#include <boost/serialization/vector.hpp>
|
||||||
#include "common/common_types.h"
|
#include "common/common_types.h"
|
||||||
|
|
||||||
namespace Service {
|
namespace Service {
|
||||||
@ -41,8 +42,8 @@ public:
|
|||||||
return s_instance;
|
return s_instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
void StartPlayback(const std::string& movie_file,
|
void StartPlayback(
|
||||||
std::function<void()> completion_callback = [] {});
|
const std::string& movie_file, std::function<void()> completion_callback = [] {});
|
||||||
void StartRecording(const std::string& movie_file);
|
void StartRecording(const std::string& movie_file);
|
||||||
|
|
||||||
/// Prepare to override the clock before playing back movies
|
/// Prepare to override the clock before playing back movies
|
||||||
@ -132,5 +133,16 @@ private:
|
|||||||
u64 init_time;
|
u64 init_time;
|
||||||
std::function<void()> playback_completion_callback;
|
std::function<void()> playback_completion_callback;
|
||||||
std::size_t current_byte = 0;
|
std::size_t current_byte = 0;
|
||||||
|
|
||||||
|
template <class Archive>
|
||||||
|
void serialize(Archive& ar, const unsigned int) {
|
||||||
|
// Only serialize what's needed to make savestates useful for TAS:
|
||||||
|
u64 _current_byte = static_cast<u64>(current_byte);
|
||||||
|
ar& _current_byte;
|
||||||
|
current_byte = static_cast<std::size_t>(_current_byte);
|
||||||
|
ar& recorded_input;
|
||||||
|
ar& init_time;
|
||||||
|
}
|
||||||
|
friend class boost::serialization::access;
|
||||||
};
|
};
|
||||||
} // namespace Core
|
} // namespace Core
|
@ -84,13 +84,8 @@ std::vector<SaveStateInfo> ListSaveStates(u64 program_id) {
|
|||||||
void System::SaveState(u32 slot) const {
|
void System::SaveState(u32 slot) const {
|
||||||
std::ostringstream sstream{std::ios_base::binary};
|
std::ostringstream sstream{std::ios_base::binary};
|
||||||
try {
|
try {
|
||||||
|
oarchive oa{sstream};
|
||||||
{
|
oa&* this;
|
||||||
oarchive oa{sstream};
|
|
||||||
oa&* this;
|
|
||||||
}
|
|
||||||
VideoCore::Save(sstream);
|
|
||||||
|
|
||||||
} catch (const std::exception& e) {
|
} catch (const std::exception& e) {
|
||||||
LOG_ERROR(Core, "Error saving: {}", e.what());
|
LOG_ERROR(Core, "Error saving: {}", e.what());
|
||||||
}
|
}
|
||||||
@ -159,24 +154,9 @@ void System::LoadState(u32 slot) {
|
|||||||
std::ios_base::binary};
|
std::ios_base::binary};
|
||||||
decompressed.clear();
|
decompressed.clear();
|
||||||
|
|
||||||
// When loading, we want to make sure any lingering state gets cleared out before we begin.
|
|
||||||
// Shutdown, but persist a few things between loads...
|
|
||||||
Shutdown(true);
|
|
||||||
|
|
||||||
// Re-initialize everything like it was before
|
|
||||||
auto system_mode = this->app_loader->LoadKernelSystemMode();
|
|
||||||
auto n3ds_mode = this->app_loader->LoadKernelN3dsMode();
|
|
||||||
Init(*m_emu_window, *system_mode.first, *n3ds_mode.first);
|
|
||||||
cheat_engine->Connect();
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
iarchive ia{sstream};
|
||||||
{
|
ia&* this;
|
||||||
iarchive ia{sstream};
|
|
||||||
ia&* this;
|
|
||||||
}
|
|
||||||
VideoCore::Load(sstream);
|
|
||||||
|
|
||||||
} catch (const std::exception& e) {
|
} catch (const std::exception& e) {
|
||||||
LOG_ERROR(Core, "Error loading: {}", e.what());
|
LOG_ERROR(Core, "Error loading: {}", e.what());
|
||||||
}
|
}
|
||||||
|
@ -88,15 +88,11 @@ u16 GetResolutionScaleFactor() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Save(std::ostream& stream) {
|
template <class Archive>
|
||||||
oarchive oa{stream};
|
void serialize(Archive& ar, const unsigned int) {
|
||||||
oa& Pica::g_state;
|
ar& Pica::g_state;
|
||||||
}
|
|
||||||
|
|
||||||
void Load(std::istream& stream) {
|
|
||||||
iarchive ia{stream};
|
|
||||||
ia& Pica::g_state;
|
|
||||||
// TODO: Flush/reset things
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace VideoCore
|
} // namespace VideoCore
|
||||||
|
|
||||||
|
SERIALIZE_IMPL(VideoCore)
|
||||||
|
@ -62,7 +62,7 @@ void RequestScreenshot(void* data, std::function<void()> callback,
|
|||||||
|
|
||||||
u16 GetResolutionScaleFactor();
|
u16 GetResolutionScaleFactor();
|
||||||
|
|
||||||
void Save(std::ostream& stream);
|
template <class Archive>
|
||||||
void Load(std::istream& stream);
|
void serialize(Archive& ar, const unsigned int file_version);
|
||||||
|
|
||||||
} // namespace VideoCore
|
} // namespace VideoCore
|
||||||
|
Loading…
Reference in New Issue
Block a user