diff --git a/docs/RELEASES.md b/docs/RELEASES.md
index 41d7ed7..359266c 100644
--- a/docs/RELEASES.md
+++ b/docs/RELEASES.md
@@ -197,6 +197,13 @@ the core's settings are unavailable and labels the pad chips generically. Mods r
`include/retcomm/mods.hpp` names (n64lle writes its selection to
`
/mods.toml`).
+For Nintendo 64 titles, **Gameplay diagnostics** appears on the Mods page.
+It records offline gameplay by default, with a saved choice for each title.
+Open Replays to inspect the recordings. A save or load seals the current
+recording and starts a new segment when play resumes. Automatic recording
+requires a compatible runner and stays off during netplay and accessory
+sessions. The usual in-session replay hotkey still works.
+
**The runner.** Direct mode finds `retro-core-runner` the way the launcher does
(`resolve_runner`, `src/update/runtime_update.cpp`), in this order:
diff --git a/src/hub/hub_core_settings.cpp b/src/hub/hub_core_settings.cpp
index 4c8c507..96fb540 100644
--- a/src/hub/hub_core_settings.cpp
+++ b/src/hub/hub_core_settings.cpp
@@ -1160,6 +1160,32 @@ bool save_play_prefs(const fs::path& data_dir, const PlayPrefs& prefs, std::stri
return write_atomically(data_dir / "play.ini", o.str(), error);
}
+namespace {
+fs::path diagnostics_path(const fs::path& data_dir, const std::string& title_key) {
+ return platform_settings_dir(data_dir, "n64") / "diagnostics" / (title_key + ".ini");
+}
+} // namespace
+
+bool load_gameplay_diagnostics(const fs::path& data_dir, const std::string& title_key) {
+ bool enabled = true;
+ for_each_ini(read_text(diagnostics_path(data_dir, title_key)),
+ [&](const std::string& section, const std::string& key, const std::string& value) {
+ if (section == "diagnostics" && key == "record_gameplay") {
+ if (value == "0") enabled = false;
+ else if (value == "1") enabled = true;
+ }
+ });
+ return enabled;
+}
+
+bool save_gameplay_diagnostics(const fs::path& data_dir, const std::string& title_key,
+ bool enabled, std::string* error) {
+ return write_atomically(diagnostics_path(data_dir, title_key),
+ enabled ? "[diagnostics]\nrecord_gameplay = 1\n"
+ : "[diagnostics]\nrecord_gameplay = 0\n",
+ error);
+}
+
// ---- display ------------------------------------------------------------------
namespace {
diff --git a/src/hub/hub_core_settings.hpp b/src/hub/hub_core_settings.hpp
index 71b2010..0b4d5b2 100644
--- a/src/hub/hub_core_settings.hpp
+++ b/src/hub/hub_core_settings.hpp
@@ -386,6 +386,11 @@ struct PlayPrefs {
PlayPrefs load_play_prefs(const fs::path& data_dir);
bool save_play_prefs(const fs::path& data_dir, const PlayPrefs& prefs, std::string* error);
+// The Mods page's host-only recording choice for one Nintendo 64 title.
+bool load_gameplay_diagnostics(const fs::path& data_dir, const std::string& title_key);
+bool save_gameplay_diagnostics(const fs::path& data_dir, const std::string& title_key,
+ bool enabled, std::string* error);
+
// ---- display ------------------------------------------------------------------
// How the hub scales the core's frame to the window (hub_picture.hpp). The
diff --git a/src/hub/hub_main.cpp b/src/hub/hub_main.cpp
index a07da4d..22d8b4b 100644
--- a/src/hub/hub_main.cpp
+++ b/src/hub/hub_main.cpp
@@ -3561,6 +3561,7 @@ struct ModsPageState {
bool focus_list = false; // set by the detail column, consumed next frame
bool pending_rescan = false; // a write landed; re-read once the panel is done
bool detail = false; // the overlay: one feature's page is open
+ bool record_gameplay = true;
};
// Right / Left as a player produces them: d-pad, left stick, or the arrow keys
@@ -3584,11 +3585,26 @@ ModsPageState& mods_page_state() {
return s;
}
+bool has_gameplay_diagnostics(const TitleRow& row) {
+ return row.platform == "n64" && !row.id.empty() &&
+ (row.kind == "core" || !row.core_manifest.empty());
+}
+
void refresh_mods_page(HubModel& hub, const TitleRow& row) {
ModsPageState& st = mods_page_state();
st.scan = retcomm::scan_game_mods(title_game_dir(hub, row), fs::path(row.install_root),
fs::path(row.mods_state_dir));
st.title_id = row.id;
+ if (has_gameplay_diagnostics(row))
+ st.record_gameplay = retcomm::hub::load_gameplay_diagnostics(hub.paths.data_dir, row.id);
+}
+
+void set_gameplay_diagnostics(HubModel& hub, const TitleRow& row, bool enabled) {
+ std::string error;
+ if (retcomm::hub::save_gameplay_diagnostics(hub.paths.data_dir, row.id, enabled, &error))
+ mods_page_state().record_gameplay = enabled;
+ else
+ hub.append_log("Gameplay diagnostics: " + error);
}
// Every (package, feature) pair, flattened and grouped the way the left panel
@@ -3645,6 +3661,13 @@ void draw_mods_page(HubModel& hub, const Theme& th) {
ImGui::TextUnformatted(row.name.c_str());
ImGui::TextColored(th.text_muted, "%s", st.scan.root.string().c_str());
ImGui::Separator();
+ if (has_gameplay_diagnostics(row)) {
+ bool enabled = st.record_gameplay;
+ if (ImGui::Checkbox("Gameplay diagnostics", &enabled))
+ set_gameplay_diagnostics(hub, row, enabled);
+ ImGui::TextWrapped("Record offline gameplay automatically. Find recordings in Replays.");
+ ImGui::Separator();
+ }
auto set_all = [&](bool on) {
std::string err;
@@ -4109,6 +4132,15 @@ void draw_shell_mods(HubModel& hub, const Theme& th, const retcomm::hub::overlay
else if (r == 2) st.search[0] = '\0';
}
const std::string needle = st.search;
+ if (has_gameplay_diagnostics(row)) {
+ retcomm::ModPackageInfo diagnostics;
+ diagnostics.name = "Gameplay diagnostics";
+ if (mod_row_matches(diagnostics, nullptr, needle) &&
+ ov::setting_row(m, "gameplay_diagnostics", "Gameplay diagnostics",
+ st.record_gameplay ? "On" : "Off",
+ "Record offline gameplay automatically. Find recordings in Replays."))
+ set_gameplay_diagnostics(hub, row, !st.record_gameplay);
+ }
if (!st.scan.root_exists)
ov::muted("No mods folder yet. The engine creates mods/bundled at build time; mods/installed is where "
"packages are added.");
@@ -11049,6 +11081,8 @@ void apply_player_settings(retcomm::hub::PlayArgs& args, const fs::path& data_di
const std::string& title_key) {
// The overlay's settings are every core's: loaded whatever the platform.
args.prefs = retcomm::hub::load_play_prefs(data_dir);
+ args.record_gameplay_diagnostics = platform == "n64" && !title_key.empty() &&
+ retcomm::hub::load_gameplay_diagnostics(data_dir, title_key);
args.data_dir = data_dir;
args.exe_dir = exe_dir;
if (platform.empty()) {
@@ -11623,6 +11657,18 @@ std::string core_settings_default(const CoreSettingsPage& p,
return it == p.default_opts.end() ? (o.has_default ? o.default_value : std::string())
: it->second;
}
+// The core ABI carries stored enum values. Friendly text is presentation-only.
+const std::string& core_option_value_label(const retcomm::hub::CoreOptionDecl& option,
+ const std::string& value) {
+ static const std::string fit = "Fit to screen";
+ static const std::string original = "Original (4:3)";
+ if (option.key == "video.aspect") {
+ if (value == "fit") return fit;
+ if (value == "original") return original;
+ }
+ return value;
+}
+
void draw_core_option_row(CoreSettingsPage& p, const retcomm::hub::CoreOptionDecl& o,
const Theme& th) {
std::map& layer = p.title_scope ? p.title_opts : p.plat_opts;
@@ -11639,18 +11685,19 @@ void draw_core_option_row(CoreSettingsPage& p, const retcomm::hub::CoreOptionDec
std::string t, f;
if (o.type == "enum" && !o.values.empty()) {
settings_row(label.c_str(), th, kSettingsCtrlW);
+ const std::string& display = core_option_value_label(o, cur);
const std::string preview =
- !p.title_scope ? (set ? cur : std::string(inherit_word) + ": " + cur)
- : (cur == kTitleDeclaredValue ? std::string("Default") : cur);
+ !p.title_scope ? (set ? display : std::string(inherit_word) + ": " + display)
+ : (cur == kTitleDeclaredValue ? std::string("Default") : display);
if (ImGui::BeginCombo("##v", preview.c_str())) {
if (!p.title_scope &&
- ImGui::Selectable((std::string(inherit_word) + " (" + inherited + ")").c_str(),
+ ImGui::Selectable((std::string(inherit_word) + " (" + core_option_value_label(o, inherited) + ")").c_str(),
!set))
layer.erase(o.key);
for (const std::string& v : o.values) {
if (p.title_scope && v == kTitleDeclaredValue) continue;
const bool chosen = (set || p.title_scope) && v == cur;
- if (ImGui::Selectable(v.c_str(), chosen)) layer[o.key] = v;
+ if (ImGui::Selectable(core_option_value_label(o, v).c_str(), chosen)) layer[o.key] = v;
if (chosen) ImGui::SetItemDefaultFocus();
}
ImGui::EndCombo();
@@ -11683,7 +11730,7 @@ void draw_core_option_row(CoreSettingsPage& p, const retcomm::hub::CoreOptionDec
const std::string default_value = core_settings_default(p, o);
ImGui::SetTooltip("%s\n\n%s%s%s%s", o.description.c_str(), o.key.c_str(),
has_default ? " \xC2\xB7 default " : "",
- has_default ? default_value.c_str() : "",
+ has_default ? core_option_value_label(o, default_value).c_str() : "",
o.restart ? "\nApplies the next time a game starts." : "");
}
ImGui::PopID();
@@ -13480,23 +13527,24 @@ void overlay_option_row(CoreSettingsPage& p, const retcomm::hub::CoreOptionDecl&
ImGui::PushID(o.key.c_str());
std::string t, f;
if (o.type == "enum" && !o.values.empty()) {
+ const std::string& display = core_option_value_label(o, cur);
const std::string shown =
- !p.title_scope ? (set ? cur : std::string(inherit_word) + ": " + cur)
- : (cur == kTitleDeclaredValue ? std::string("Default") : cur);
+ !p.title_scope ? (set ? display : std::string(inherit_word) + ": " + display)
+ : (cur == kTitleDeclaredValue ? std::string("Default") : display);
if (ov::setting_row(m, "row", label.c_str(), shown, desc, true, p.title_scope && set))
ov::open_picker("##pick");
std::vector choices;
std::vector vals; // "" = inherit
int current = -1;
if (!p.title_scope) {
- choices.push_back({std::string(inherit_word) + " (" + inherited + ")", ""});
+ choices.push_back({std::string(inherit_word) + " (" + core_option_value_label(o, inherited) + ")", ""});
vals.push_back("");
if (!set) current = 0;
}
for (const std::string& v : o.values) {
if (p.title_scope && v == kTitleDeclaredValue) continue;
if ((set || p.title_scope) && v == cur) current = static_cast(choices.size());
- choices.push_back({v, ""});
+ choices.push_back({core_option_value_label(o, v), ""});
vals.push_back(v);
}
const int pick = ov::picker(m, "##pick", label.c_str(), choices, current);
@@ -13577,7 +13625,7 @@ std::string option_summary_text(const CoreSettingsPage& p, const retcomm::hub::C
std::string t, f;
if (o.type == "bool" && bool_spelling(o, t, f))
return (o.label.empty() ? o.key : o.label) + (cur == t ? " on" : " off");
- return cur.empty() ? std::string("default") : cur;
+ return cur.empty() ? std::string("default") : core_option_value_label(o, cur);
}
struct CoreSection {
diff --git a/src/hub/hub_play.cpp b/src/hub/hub_play.cpp
index 32b4c08..64b2d5e 100644
--- a/src/hub/hub_play.cpp
+++ b/src/hub/hub_play.cpp
@@ -35,20 +35,28 @@ constexpr std::uint64_t kTurboBudgetNs = 10 * 1000000ull;
constexpr double kTurboSoundLowMs = 40.0;
constexpr double kTurboSoundHighMs = 100.0;
-// Whether the runner can lend a core a GL context (`gl 1` in its --version).
-// A runner built without SDL3 -- the Android APK's -- exits on --gl, so a
-// session asks for one only when the runner says it has one. Asked once per
-// runner for the life of the hub; a runner that cannot be asked keeps the
-// old behaviour (its start will say what is wrong).
-bool runner_lends_gl(const fs::path& runner) {
- static std::map known;
+struct RunnerFeatures {
+ bool gl = true;
+ bool safe_interactive_recording = false;
+};
+
+// Keep the existing GL fallback when a version probe fails. Automatic
+// diagnostics requires a runner that can record without blocking saves.
+RunnerFeatures runner_features(const fs::path& runner) {
+ static std::map known;
const std::string key = corelink::path_utf8(runner);
if (auto it = known.find(key); it != known.end()) return it->second;
corelink::RunnerVersion v;
std::string err;
- const bool gl = corelink::probe_runner(runner, v, &err) ? v.gl : true;
- known.emplace(key, gl);
- return gl;
+ RunnerFeatures features;
+ if (corelink::probe_runner(runner, v, &err)) {
+ features.gl = v.gl;
+#if defined(RETRO_CORELINK_HAS_SAFE_INTERACTIVE_RECORDING)
+ features.safe_interactive_recording = v.safe_interactive_recording;
+#endif
+ }
+ known.emplace(key, features);
+ return features;
}
constexpr double kTurboFadeMs = 4.0;
constexpr int kVolumeStep = 10;
@@ -133,7 +141,9 @@ bool PlaySession::start(const PlayArgs& args, const fs::path& runner, const fs::
spec.gpu_capabilities = gpu_frames_.capabilities();
spec.cpu_pixel_pairs = Picture::supports_pixel_pairs();
spec.save_dir = save_dir;
- spec.gl = args.gl && runner_lends_gl(runner);
+ const RunnerFeatures features = args.gl || args.record_gameplay_diagnostics
+ ? runner_features(runner) : RunnerFeatures{};
+ spec.gl = args.gl && features.gl;
if (args.gl && !spec.gl)
SDL_Log("retro-hub: %s lends no GL context (gl 0); the core runs without one",
corelink::path_utf8(runner).c_str());
@@ -142,6 +152,13 @@ bool PlaySession::start(const PlayArgs& args, const fs::path& runner, const fs::
spec.env = args.env;
spec.extra_args = args.net_args;
netplay_ = !args.net_args.empty();
+ recording_request_.reset();
+ diagnostics_recording_ = false;
+ diagnostics_pending_ = args.record_gameplay_diagnostics &&
+ features.safe_interactive_recording && !netplay_ &&
+ std::none_of(args.tpak_rom.begin(), args.tpak_rom.end(),
+ [](const std::string& rom) { return !rom.empty(); }) &&
+ std::none_of(args.vru_seat.begin(), args.vru_seat.end(), [](bool active) { return active; });
for (std::size_t seat = 0; seat < args.tpak_save.size(); ++seat)
if (!args.tpak_rom[seat].empty() && !args.tpak_save[seat].empty())
spec.save_files["tpak" + std::to_string(seat + 1)] = args.tpak_save[seat];
@@ -381,6 +398,9 @@ void PlaySession::service_states() {
}
const bool sent = save ? link_.request_save_state(state_request_.path, thumbnail)
: link_.request_load_state(state_request_.path);
+ if (sent && diagnostics_recording_ &&
+ link_.replay_status().state == corelink::ReplayState::Recording)
+ diagnostics_pending_ = true;
if (!sent) states_.finish(false, save, "the link could not send the request");
state_request_ = Req{};
}
@@ -693,6 +713,8 @@ void PlaySession::toggle_recording() {
if (state==corelink::ReplayState::Playing) {
osd_.toast("Recording is off during replay playback",SDL_GetTicksNS()); return;
}
+ diagnostics_pending_ = false;
+ diagnostics_recording_ = false;
recording_request_=state!=corelink::ReplayState::Recording;
}
@@ -706,7 +728,16 @@ void PlaySession::service_replays() {
else if (status.state==corelink::ReplayState::TakenOver) replay_message_="Live input took over";
else if (status.state==corelink::ReplayState::Recording) replay_message_="Recording replay";
else replay_message_.clear();
- if (!replay_message_.empty()) osd_.toast(replay_message_,SDL_GetTicksNS(),3000);
+ if (!replay_message_.empty() && !diagnostics_recording_)
+ osd_.toast(replay_message_,SDL_GetTicksNS(),3000);
+ }
+ if (diagnostics_pending_ && !paused() && link_.can_grant()) {
+ diagnostics_pending_ = false;
+ if (link_.replays_supported() && !recording_request_ &&
+ (status.state == corelink::ReplayState::Idle || status.state == corelink::ReplayState::Saved)) {
+ diagnostics_recording_ = true;
+ recording_request_ = true;
+ }
}
if (recording_request_ && link_.can_grant()) {
const bool record=*recording_request_;
@@ -724,14 +755,24 @@ void PlaySession::service_replays() {
if (!pixels.empty()) info.pixels=retro::state::make_thumbnail(pixels.data(),w,h,w*4);
info.aspect=picture_.aspect(); preview=std::move(info);
}
- if (ec || !link_.request_recording(record,path)) {
+#if defined(RETRO_CORELINK_HAS_SAFE_INTERACTIVE_RECORDING)
+ const bool sent = !ec && link_.request_recording(record, path, diagnostics_recording_);
+#else
+ const bool sent = !ec && link_.request_recording(record, path);
+#endif
+ if (!sent) {
replay_message_=ec ? ec.message() : "The replay request could not be sent";
- osd_.toast(replay_message_,SDL_GetTicksNS(),3000);
+ if (!diagnostics_recording_) osd_.toast(replay_message_,SDL_GetTicksNS(),3000);
}
else if (record) replay_preview_=std::move(preview);
recording_request_.reset();
}
if (!replay_play_.empty() && link_.can_grant()) {
+ if (diagnostics_recording_ && status.state==corelink::ReplayState::Recording) {
+ recording_request_ = false;
+ diagnostics_pending_ = false;
+ return;
+ }
const auto path=replay_play_; replay_play_.clear();
if (status.state==corelink::ReplayState::Recording) {
replay_message_="Stop recording before playing a replay"; return;
@@ -792,7 +833,7 @@ void PlaySession::draw_overlay() {
const ImVec2 disp = ImGui::GetIO().DisplaySize;
std::vector layers = osd_.layers(SDL_GetTicksNS());
ImDrawList* dl = ImGui::GetBackgroundDrawList();
- if (link_.replay_status().state==corelink::ReplayState::Recording) {
+ if (!diagnostics_recording_ && link_.replay_status().state==corelink::ReplayState::Recording) {
dl->AddCircleFilled(ImVec2(disp.x-88.f,26.f),6.f,IM_COL32(240,48,48,255));
dl->AddText(ImVec2(disp.x-74.f,18.f),IM_COL32(255,255,255,255),"REC");
}
@@ -928,7 +969,8 @@ void PlaySession::draw_replays_page() {
ImGui::TextDisabled("%s | %s",state_time_text(info.saved_unix).c_str(),replay_duration(info).c_str());
ImGui::TextWrapped("%s",info.path.filename().u8string().c_str());
ImGui::TextWrapped("Play starts a fresh process. Release controls once, then use a button or stick to take over. Playback saves stay private.");
- ImGui::BeginDisabled(!link_.replays_supported() || state==corelink::ReplayState::Recording || !info.sealed);
+ ImGui::BeginDisabled(!link_.replays_supported() ||
+ (state == corelink::ReplayState::Recording && !diagnostics_recording_) || !info.sealed);
if (hov::action_button("Play",true)) replay_play_=info.path;
ImGui::EndDisabled(); ImGui::SameLine();
if (hov::action_button("Export copy",false)) {
diff --git a/src/hub/hub_play.hpp b/src/hub/hub_play.hpp
index 6b46042..b0bdc29 100644
--- a/src/hub/hub_play.hpp
+++ b/src/hub/hub_play.hpp
@@ -72,6 +72,7 @@ struct PlayArgs {
std::map options;
std::map default_options;
bool gl = true;
+ bool record_gameplay_diagnostics = false;
// Extra NAME=value for the runner, which passes its environment on to the
// core: title-app mode sets RETRO_TITLE_STATE_DIR= here.
std::vector env;
@@ -159,6 +160,8 @@ class PlaySession {
corelink::LaunchSpec launch_spec_;
fs::path replays_dir_, replay_play_;
std::optional recording_request_;
+ bool diagnostics_pending_ = false;
+ bool diagnostics_recording_ = false;
corelink::ReplayState replay_seen_ = corelink::ReplayState::Idle;
std::string replay_message_;
fs::path replay_delete_;
diff --git a/tests/hub_core_settings_test.cpp b/tests/hub_core_settings_test.cpp
index 437a2dd..f3a42ee 100644
--- a/tests/hub_core_settings_test.cpp
+++ b/tests/hub_core_settings_test.cpp
@@ -640,6 +640,15 @@ int main(int argc, char** argv) {
test_n64lle_options(dir);
test_transfer_pak(dir);
test_tpak_library(dir);
+ {
+ std::string err;
+ check(load_gameplay_diagnostics(dir, "kart"), "gameplay diagnostics default on");
+ check(save_gameplay_diagnostics(dir, "kart", false, &err), "gameplay diagnostics saves off");
+ check(!load_gameplay_diagnostics(dir, "kart"), "saved off choice is authoritative");
+ check(load_gameplay_diagnostics(dir, "zelda"), "other titles retain their defaults");
+ check(save_gameplay_diagnostics(dir, "kart", true, &err), "gameplay diagnostics saves on");
+ check(load_gameplay_diagnostics(dir, "kart"), "saved on choice reads back");
+ }
{
// The host hotkeys round-trip through play.ini with the overlay's settings.
PlayPrefs pr;
diff --git a/third_party/Retro-Runtime b/third_party/Retro-Runtime
index a77b0e6..8f06c00 160000
--- a/third_party/Retro-Runtime
+++ b/third_party/Retro-Runtime
@@ -1 +1 @@
-Subproject commit a77b0e6317487b44fcb4460f50058be23f6d05e7
+Subproject commit 8f06c00c6cc60f9f1d988f5444ea4b1f79e7358c