Files
SoulCaliburIII_Recomp/reference/ab/reference_hold_frames.patch

43 lines
1.5 KiB
Diff

--- a/ps2xRuntime/src/lib/Kernel/EeScheduler.cpp
+++ b/ps2xRuntime/src/lib/Kernel/EeScheduler.cpp
@@ -1,3 +1,9 @@
+#include <algorithm>
+#include <chrono>
+#include <cstdio>
+#include <cstdlib>
+#include <thread>
+#include <vector>
#include "runtime/ee_scheduler.h"
#include "runtime/native/native_display.h"
#include "runtime/ps2_determinism.h"
@@ -2091,6 +2097,29 @@
// pad scripts' clock in deterministic mode).
ps2x::capture::frameEnd();
ps2x::reference::frameEnd(m_runtime);
+ {
+ static const std::vector<uint64_t> s_holds = []
+ {
+ std::vector<uint64_t> holds;
+ if (const char *text = std::getenv("PS2X_HOLD_FRAMES"))
+ for (const char *p = text; *p;)
+ {
+ char *end = nullptr;
+ holds.push_back(std::strtoull(p, &end, 10));
+ p = *end ? end + 1 : end;
+ }
+ return holds;
+ }();
+ const uint64_t heldFrame = ps2x::det::frame();
+ if (std::find(s_holds.begin(), s_holds.end(), heldFrame) != s_holds.end())
+ {
+ std::this_thread::sleep_for(std::chrono::milliseconds(700));
+ char name[32];
+ std::snprintf(name, sizeof(name), "held_%06llu", static_cast<unsigned long long>(heldFrame));
+ m_runtime.requestWindowCapture(name);
+ std::this_thread::sleep_for(std::chrono::milliseconds(500));
+ }
+ }
ps2x::det::frameCounter().fetch_add(1u, std::memory_order_relaxed);
}