From ad9dd28942819a3b4547e0a2abc6d3c8899b2008 Mon Sep 17 00:00:00 2001 From: tomcw Date: Sat, 12 Oct 2019 16:40:07 +0100 Subject: [PATCH] Added new cmd-line switch: -clock-multiplier. --- source/Applewin.cpp | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/source/Applewin.cpp b/source/Applewin.cpp index 6e80e2f2..78a4aa6f 100644 --- a/source/Applewin.cpp +++ b/source/Applewin.cpp @@ -392,6 +392,27 @@ double Get6502BaseClock(void) return (GetVideoRefreshRate() == VR_50HZ) ? CLK_6502_PAL : CLK_6502_NTSC; } +void UseClockMultiplier(double clockMultiplier) +{ + if (clockMultiplier == 0.0) + return; + + if (clockMultiplier < 1.0) + { + if (clockMultiplier < 0.5) + clockMultiplier = 0.5; + g_dwSpeed = (ULONG)((clockMultiplier - 0.5) * 20); // [0.5..0.9] -> [0..9] + } + else + { + g_dwSpeed = (ULONG)(clockMultiplier * 10); + if (g_dwSpeed >= SPEED_MAX) + g_dwSpeed = SPEED_MAX - 1; + } + + SetCurrentCLK6502(); +} + void SetCurrentCLK6502(void) { static DWORD dwPrevSpeed = (DWORD) -1; @@ -1227,6 +1248,7 @@ int APIENTRY WinMain(HINSTANCE passinstance, HINSTANCE, LPSTR lpCmdLine, int) int newVideoStyleDisableMask = 0; VideoRefreshRate_e newVideoRefreshRate = VR_NONE; LPSTR szScreenshotFilename = NULL; + double clockMultiplier = 0.0; // 0 => not set from cmd-line while (*lpCmdLine) { @@ -1477,6 +1499,12 @@ int APIENTRY WinMain(HINSTANCE passinstance, HINSTANCE, LPSTR lpCmdLine, int) szScreenshotFilename = GetCurrArg(lpNextArg); lpNextArg = GetNextArg(lpNextArg); } + else if (strcmp(lpCmdLine, "-clock-multiplier") == 0) + { + lpCmdLine = GetCurrArg(lpNextArg); + lpNextArg = GetNextArg(lpNextArg); + clockMultiplier = atof(lpCmdLine); + } else if (_stricmp(lpCmdLine, "-50hz") == 0) // (case-insensitive) { newVideoRefreshRate = VR_50HZ; @@ -1611,6 +1639,9 @@ int APIENTRY WinMain(HINSTANCE passinstance, HINSTANCE, LPSTR lpCmdLine, int) SetCurrentCLK6502(); } + UseClockMultiplier(clockMultiplier); + clockMultiplier = 0.0; + // Apply the memory expansion switches after loading the Apple II machine type #ifdef RAMWORKS if (uRamWorksExPages)