From d7f28b9b4952468421bab7ea82427585e7bd5221 Mon Sep 17 00:00:00 2001 From: Mihai Parparita Date: Thu, 8 Oct 2026 17:16:24 -0700 Subject: [PATCH 1/2] main: allow realtime mode to be enabled at startup Adds a --realtime CLI flag to enable realtime mode immediately at startup. Also tweaks documentation to mention the Control-Alt-R realtime toggle and the relationship between the realtime mode and deterministic mode. --- cpu/ppc/ppcemu.h | 3 ++- main.cpp | 8 ++++++++ zdocs/users/manual.md | 13 ++++++++++--- 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/cpu/ppc/ppcemu.h b/cpu/ppc/ppcemu.h index efe2c72f61..4ce1d5944b 100644 --- a/cpu/ppc/ppcemu.h +++ b/cpu/ppc/ppcemu.h @@ -734,7 +734,8 @@ extern int increment_icnt_factor(); extern int decrement_icnt_factor(); extern int get_icnt_factor(); -/* toggle_g_realtime */ +/* realtime clock control */ +extern bool g_realtime; extern bool toggle_g_realtime(); /* force_cycle_counter_reload */ diff --git a/main.cpp b/main.cpp index 53984bc450..e02acb52fe 100644 --- a/main.cpp +++ b/main.cpp @@ -179,6 +179,8 @@ int main(int argc, char** argv) { ->check(WorkingDirectory)->capture_default_str(); auto bootrom_opt = emu->add_option("-b,--bootrom", bootrom_path, "Specifies BootROM path") ->check(CLI::ExistingFile)->capture_default_str(); + emu->add_flag("--realtime", g_realtime, + "Advance guest timers using the host clock"); auto deterministic_opt = emu->add_flag("--deterministic", is_deterministic, "Use deterministic execution"); emu->add_option("--start-date", start_date, @@ -234,6 +236,10 @@ int main(int argc, char** argv) { CLI11_PARSE(app, argc, argv); deterministic_interactive = deterministic_mode == "interactive"; + if (g_realtime && is_deterministic && !deterministic_interactive) { + return app.exit(CLI::ValidationError("--realtime", + "Use --deterministic-mode=interactive with realtime timing")); + } if (*list_cmd) { if (sub_arg == "machines") { @@ -327,6 +333,8 @@ int main(int argc, char** argv) { cout << "BootROM path: " << bootrom_path << endl; cout << "Execution mode: " << execution_mode << endl; + if (g_realtime) + cout << "Guest timers use the host clock." << endl; if (is_deterministic) { cout << "Using deterministic execution mode; disk, NVRAM, and PRAM changes will not be saved." << endl; if (deterministic_interactive) { diff --git a/zdocs/users/manual.md b/zdocs/users/manual.md index d471e8fbbc..b91a22d036 100644 --- a/zdocs/users/manual.md +++ b/zdocs/users/manual.md @@ -73,14 +73,20 @@ Specifies working directory, where `path` is a string for the directory the emul Start the guest RTC on the given date, using the current local time of day. The clock continues ticking, including across midnight. This is useful for running software with an expiration date, such as `--start-date=1997-03-01` for BeOS DR 8.2. Without a date override or deterministic mode, the RTC follows the host clock. +``` +--realtime +``` + +Advance the CPU timebase, decrementer, and device timers using elapsed host time, instead of instruction counts. This keeps double click delays, keyboard repeat, sleeps, and timeouts tied to wall time, improving usability of user interfaces. Control-Alt-R toggles this mode while running. + ``` --deterministic --deterministic-mode strict|interactive ``` -Enables deterministic mode, where the emulator behaves the same way every run. Meant to be a development or debugging aid, to remove variability between runs. Disk, NVRAM, and PRAM changes are not saved. The default `strict` mode ignores mouse and keyboard input; `interactive` mode allows input for interactive debugging. +Enables deterministic mode, where the emulator behaves the same way every run. Meant to be a development or debugging aid, to remove variability between runs. Disk, NVRAM, and PRAM changes are not saved. Audio output is also disabled, since we cannot control when the host would try to access it. The default `strict` mode ignores mouse and keyboard input; `interactive` mode allows input for interactive debugging. -The RTC defaults to `--start-date=2001-03-24`, unless a date is explicitly supplied. It starts at noon and advances the RTC with emulated time. Restarting the emulated machine starts the deterministic RTC from that date and noon again. +The RTC defaults to `--start-date=2001-03-24`, unless a date is explicitly supplied. It starts at noon and advances the RTC with emulated time. Restarting the emulated machine starts the deterministic RTC from that date and noon again. With `--realtime`, it advances at wall-clock rate from that fixed date and noon. ``` --setenv args @@ -209,7 +215,7 @@ The debugger is enabled here, due to the presence of `-d`. The CD ROM image will ## Keyboard Shortcuts -You can use these keyboard commands while the emulator is running in real-time mode: +You can use these keyboard commands while the emulator is running: * Control-G: mouse grab * Control-S: scale quality @@ -219,6 +225,7 @@ You can use these keyboard commands while the emulator is running in real-time m * Control--: smaller * Control-L: log toggle * Control-D: debugger +* Control-Alt-R: toggle realtime guest timing ## Accessing Open Firmware From d1680b36fd56e75f79799c7c1cda47947bdf7895 Mon Sep 17 00:00:00 2001 From: Mihai Parparita Date: Thu, 8 Oct 2026 17:17:43 -0700 Subject: [PATCH 2/2] hostevents_sdl: prevent realtime toggle keyboard shortcut from reaching the guest Matches the behavior of other internal keyboard shortcuts. --- core/hostevents_sdl.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/core/hostevents_sdl.cpp b/core/hostevents_sdl.cpp index 8c9ea07a56..44eca41b74 100644 --- a/core/hostevents_sdl.cpp +++ b/core/hostevents_sdl.cpp @@ -165,6 +165,7 @@ void EventManager::poll_events() { bool g_realtime_status = toggle_g_realtime(); LOG_F(INFO, "g_realtime: %s", g_realtime_status ? "enabled" : "disabled"); } + return; } // Control-L: log toggle