mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-10-14 15:00:30 +02:00
Debugger: Add game.state.load
Queues loading a savestate file, for scripting repros that load a state partway through a run. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
648766dad4
commit
9720041ecf
3 files changed
+33
-1
No files matched your search
@@ -38,6 +38,7 @@
|
||||
#include "Core/ELF/ParamSFO.h"
|
||||
#include "Core/HLE/sceDisplay.h"
|
||||
#include "Core/RetroAchievements.h"
|
||||
#include "Core/SaveState.h"
|
||||
#include "Core/System.h"
|
||||
|
||||
// Declared rather than included from Core/HLE/sceNet.h, which reaches winsock and so windows.h
|
||||
@@ -58,6 +59,7 @@ static uint32_t GetOwnProcessID() {
|
||||
DebuggerSubscriber *WebSocketGameInit(DebuggerEventHandlerMap &map) {
|
||||
map["game.reset"] = &WebSocketGameReset;
|
||||
map["game.status"] = &WebSocketGameStatus;
|
||||
map["game.state.load"] = &WebSocketGameStateLoad;
|
||||
map["game.speed.get"] = &WebSocketGameSpeedGet;
|
||||
map["game.speed.set"] = &WebSocketGameSpeedSet;
|
||||
map["version"] = &WebSocketVersion;
|
||||
@@ -125,6 +127,35 @@ void WebSocketGameStatus(DebuggerRequest &req) {
|
||||
});
|
||||
}
|
||||
|
||||
// Load a savestate file (game.state.load)
|
||||
//
|
||||
// The load is queued, and happens at the end of the next frame the CPU runs, so follow this with
|
||||
// something that runs it, like cpu.runUntilTime.
|
||||
//
|
||||
// Parameters:
|
||||
// - path: string, path to the .ppst file.
|
||||
//
|
||||
// Response (same event name) with no extra data, once queued.
|
||||
void WebSocketGameStateLoad(DebuggerRequest &req) {
|
||||
std::string path;
|
||||
if (!req.ParamString("path", &path))
|
||||
return;
|
||||
|
||||
bool running = false;
|
||||
Core_RunOnCPUThread([&] {
|
||||
running = PSP_GetBootState() == BootState::Complete;
|
||||
});
|
||||
if (!running)
|
||||
return req.Fail("Game not running");
|
||||
|
||||
SaveState::Load(Path(path), -1, [](SaveState::Status status, std::string_view message, std::string_view) {
|
||||
if (status == SaveState::Status::FAILURE) {
|
||||
ERROR_LOG(Log::System, "game.state.load: %.*s", STR_VIEW(message));
|
||||
}
|
||||
});
|
||||
req.Respond();
|
||||
}
|
||||
|
||||
// Percentages are relative to 60 FPS, matching how the in-app settings present the alternative
|
||||
// speeds (see GameSettingsScreen.cpp) - so a client and the UI agree on what "200%" means.
|
||||
static int PercentToFps(int percent) {
|
||||
|
||||
Reference in new issue
Block a user