From 7e74ea90d8ffd7b2ef705bf03c3bacda4b944f0f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Fri, 16 Oct 2026 22:55:56 +0200 Subject: [PATCH] CmdLine: Add --cpu-mhz to lock the emulated CPU clock Overrides the locked CPU speed setting without saving it, so a headless run can reproduce a game at a different frame rate. Co-Authored-By: Claude Opus 5.5 (1M context) --- Core/CmdLine.cpp | 6 ++++++ Core/CmdLine.h | 3 +++ 2 files changed, 9 insertions(+) diff --git a/Core/CmdLine.cpp b/Core/CmdLine.cpp index 756ff6391d..ed01b84d49 100644 --- a/Core/CmdLine.cpp +++ b/Core/CmdLine.cpp @@ -243,6 +243,7 @@ static const CommandLineParam g_autoParams[] = { {POFF(odsLog), CmdParamType::Bool, "odslog", 'o', "Also log through OutputDebugString (Windows)", CmdLineMode::Headless}, {POFF(generateInterpreterDispatch), CmdParamType::Bool, "generate-interpreter-dispatch", '\0', "Generate C++ interpreter dispatch code (ExecInstruction) to stdout and exit", CmdLineMode::Headless}, {POFF(resolutionScale), CmdParamType::Int, "resolution-scale", '\0', "Set the resolution scale factor"}, + {POFF(lockedCPUSpeed), CmdParamType::Int, "cpu-mhz", '\0', "Lock the emulated CPU clock at this many MHz (0 = let the game set it)"}, {POFF(msaa), CmdParamType::Int, "msaa", '\0', "Set the MSAA level (0 = off, 1 = 2x, 2 = 4x, 3 = 8x)"}, {POFF(debuggerPort), CmdParamType::Int, "debugger", '\0', "Enable the WebSocket debugger on this port (0 = pick automatically); see docs/WebSocketDebugger.md"}, {POFF(debuggerRunPort), CmdParamType::Int, "debugger-run", '\0', "Like --debugger, but starts running instead of waiting at the entry point", CmdLineMode::Headless}, @@ -621,6 +622,11 @@ void CommandLineOptions::ApplyToConfig() const { g_logManager.DoNotSaveChannels(); } + if (lockedCPUSpeed.has_value()) { + g_Config.iLockedCPUSpeed = lockedCPUSpeed.value(); + g_Config.DoNotSaveSetting(&g_Config.iLockedCPUSpeed); + } + if (oldAtrac.has_value()) { g_Config.bUseOldAtrac = oldAtrac.value(); g_Config.DoNotSaveSetting(&g_Config.bUseOldAtrac); diff --git a/Core/CmdLine.h b/Core/CmdLine.h index d94024b761..b65522ec0a 100644 --- a/Core/CmdLine.h +++ b/Core/CmdLine.h @@ -106,6 +106,9 @@ struct CommandLineOptions { // way to compare the two without editing a config, and the way out if the real one breaks a game. std::optional forceHLE; + // Overrides g_Config.iLockedCPUSpeed, in MHz. + std::optional lockedCPUSpeed; + // Headless: install the game update in a .pkg (given as the boot filename) into this // directory, then exit without booting anything. The directory is the game folder itself - // the app puts that under PSP/GAME/, but here the caller picks. See