diff --git a/Core/Debugger/WebSocket/ReplaySubscriber.cpp b/Core/Debugger/WebSocket/ReplaySubscriber.cpp index 3a33f90b38..501f1ba256 100644 --- a/Core/Debugger/WebSocket/ReplaySubscriber.cpp +++ b/Core/Debugger/WebSocket/ReplaySubscriber.cpp @@ -15,7 +15,11 @@ // Official git repository and contact information can be found at // https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/. +#include +#include "Common/Swap.h" +#include "Core/HLE/sceRtc.h" #include "Core/Replay.h" +#include "Core/System.h" #include "Core/Debugger/WebSocket/ReplaySubscriber.h" DebuggerSubscriber *WebSocketReplayInit(DebuggerEventHandlerMap &map) { @@ -31,19 +35,42 @@ DebuggerSubscriber *WebSocketReplayInit(DebuggerEventHandlerMap &map) { return nullptr; } +// Begin or resume recording of replay data (replay.begin) +// +// If a replay was previously being played back, this will keep any executed replay data up to +// this point for the next flush. To discard, break the CPU, abort, and then begin. +// +// No parameters. +// +// Empty response. void WebSocketReplayBegin(DebuggerRequest &req) { - // TODO + ReplayBeginSave(); + req.Respond(); } +// Abort any replay execution or recording (replay.abort) +// +// This stops executing any replay and discards any in progress recording. +// +// No parameters. +// +// Empty response. void WebSocketReplayAbort(DebuggerRequest &req) { - // TODO + ReplayAbort(); + req.Respond(); } void WebSocketReplayFlush(DebuggerRequest &req) { + if (!PSP_IsInited()) + return req.Fail("Game not running"); + // TODO } void WebSocketReplayExecute(DebuggerRequest &req) { + if (!PSP_IsInited()) + return req.Fail("Game not running"); + // TODO } @@ -51,10 +78,38 @@ void WebSocketReplayStatus(DebuggerRequest &req) { // TODO } +// Get the base RTC (real time clock) time for replay data (replay.time.get) +// +// The base time is constant during a game session, and represents the "power on" time of the +// emulated PSP. +// +// No parameters. +// +// Response (same event name): +// - value: unsigned integer, may have more than 32 integer bits. void WebSocketReplayTimeGet(DebuggerRequest &req) { - // TODO + if (!PSP_IsInited()) + return req.Fail("Game not running"); + + JsonWriter &json = req.Respond(); + json.writeUint("value", RtcBaseTime()); } +// Overwrite the base RTC time (replay.time.set) +// +// Parameters: +// - value: unsigned integer. +// +// Empty response. void WebSocketReplayTimeSet(DebuggerRequest &req) { - // TODO + if (!PSP_IsInited()) + return req.Fail("Game not running"); + + uint32_t value; + if (!req.ParamU32("value", &value, false)) { + return; + } + + RtcSetBaseTime((int32_t)value); + req.Respond(); } diff --git a/Core/Replay.cpp b/Core/Replay.cpp index bac97e2835..5fd07d7d62 100644 --- a/Core/Replay.cpp +++ b/Core/Replay.cpp @@ -206,6 +206,8 @@ bool ReplayExecuteFile(const Path &filename) { WARN_LOG(SYSTEM, "Replay version %d scary and futuristic, trying anyway", fh.version); } + RtcSetBaseTime((int32_t)fh.rtcBaseSeconds, 0); + data.resize(sz); if (fread(&data[0], sz, 1, fp) != 1) {