Author Topic: How to adjust gMachineSpeed?  (Read 6478 times)

0 Members and 1 Guest are viewing this topic.

Offline swimfan

How to adjust gMachineSpeed?
« on: January 20, 2024, 12:24:25 PM »
Hi all, I'm a Quest for Glory speedrunner and we've discovered a potential big skip for Quest for Glory 2, which as you likely know is an EGA SCI game.

The skip in question checks gMachineSpeed, and a value of <40 will trigger what we're looking for. Trouble is, I have no idea how to adjust my computer so that the game will read gMachineSpeed<40, or even how to view my current gMachineSpeed. I know SpeedChecker.src (room 98) is supposed to calculate this, but I don't know how to view the result. We want to do this with DOSBox, but a ScummVM solution would be helpful too.

Can anyone help us out? Please keep in mind my programming knowledge is very Basic. ;D
Thank you!!!



Offline Kawa

Re: How to adjust gMachineSpeed?
« Reply #1 on: January 20, 2024, 12:58:59 PM »
First, (while (u> (GetTime) -1024)) prepares for foreseen circumstances. I'm not entirely sure what those are, but there's Funny Risks to avoid.

Second, Fred is set up. Fred serves to give the engine some work for each frame, even though Fred is entirely black on a black background. Between the engine and the framework, they have to animate Fred slowly walking from one point to another. Without Fred, each tick would be over near instantly.

Finally, the machine speed counter is reset.

In the speed test's doit, the speed counter is incremented. After the first time this happens, a timer is set to expire in another 60 ticks, or one second (GetTime plus 60). That's the "done time".

Eventually, after doit has ran a couple times and the machine speed counter has increased accordingly, GetTime's return value will equal the done time, so we know one second has passed. When that happens, the test is stopped.

If the machine speed (number of times doit has ran in one second) is under 24, the "how fast" rating (gSeconds in manual decomp) is set to 0 (low). Under 44, it's 1, "medium". Under 80, it's 2, "high". Anything higher than that, it's 3. The "default how fast" global is set to match. QFG2's detail menu will show "low", "medium", or "high" options, with whichever matching the default replaced with "optimal". If I read this correctly, speeds over 80 have it drop to "high", since there's no "max" option.



Just for fun: LSL3's infamous exercise machines want (machineSpeed / 5) + 5 reps each. Except if you have debug mode enabled "to save Carlos' finger for other things", then it's just five reps each. So on a system that manages to run a hundred cycles of speed test in one second, you need 25 reps, four times. A thousand, because you're running DOS games from the late 80s on a Pentium III? 205 reps, four times. 820 in total. No wonder we invented MoSlo and such.


But to properly answer the question: in the ScummVM debugger, try vm_vars g 105 to see the value of gMachineSpeed, add a third parameter to change it. 113 is gHowFast and 183 is gDftHowFast. In my case both are 3 on startup and the machine speed is a whopping 255. If you have a copy of the QFG2 demo you can use its interpreter instead of the full version's to access the original in-game debugger and use the g command to inspect and edit globals, with the same numbers.
« Last Edit: January 20, 2024, 01:10:03 PM by Kawa »

Offline doomlazer

Re: How to adjust gMachineSpeed?
« Reply #2 on: January 20, 2024, 02:15:02 PM »
Just to add to Kawa's excellent and exhaustive answer, I created a quick patch (attached below) that prints gMachineSpeed after it's calculated. Looks like you can start DOSBox at 1002 CPU Cycles to get a value 31. You should be able to increase the DOSBox cycles after it's set with CTRL + F12 to speed things up without altering that value.

Offline swimfan

Re: How to adjust gMachineSpeed?
« Reply #3 on: January 20, 2024, 10:04:12 PM »
Thank you both very much for the detailed explanation and instructions! The patch was very helpful too!

Sorry to report that although this worked, it didn't get us to the magic skip we were hoping for. But we're glad to have run down this lead at last, and who knows? We may figure out how to make use of it someday.  :D

Long story long:
I was able to trigger the targeted script by getting to gMachineSpeed=39, and once the target room (Room 400, Raseir Palace gates) is initialized through starting a new game, it's possible to save the game, restart DOSBox at higher cycles, and restore the game in the same gMachineSpeed<40 state we want. Specifically, there is a "guardsRushIn" script that ends 4 seconds faster in this state, after which the palace gates are technically open and accessible. If we could end up standing right in front of the gates once guardsRushIn finishes, we could move inside the palace before the guards kill us. Unfortunately, this script also pushes the Hero away from the gates. I was hoping we could circumvent that somehow, and we did get closer to the target spot, but it wasn't enough.

Anyway, thanks again!


SMF 2.0.19 | SMF © 2021, Simple Machines
Simple Audio Video Embedder

Page created in 0.044 seconds with 22 queries.