Keen 4-6 are common to stutter in scrolling. There are several different reasons and causes; one of those is due to vertical refresh synchronization code on certain hardware that was extensively discussed in viewtopic.php?t=4084 .
Recently, I have been researching the quirky behavior of different VGA cards and why Keen would stutter specifically on only some of them.
I did get into some insights, more about those in this thread: https://www.vogons.org/viewtopic.php?f=63&t=96028
But if we ignore hardware quirks for the moment, and restrict ourselves to running Keen only on "best possible" or "most compatible" VGA card/PC setup that does not have any of the undesirable hardware behavior, and even if we run any of the community patches that improve the vertical refresh in Keen games, even then, I feel that the scrolling issue has not yet been adequately addressed: in my tests I find that Keen still exhibits this kind of continuous "microstuttering" that I cannot find the source of.
The game intends to draw a new frame every second vblank to obtain 35fps on 70hz VGA. But no matter what VGA card I use on my 80 MHz 486 PC and on vanilla MS-DOS 6.22 without any TSRs, or which version of Keen I try (different versions of Keen 4 1.0-1.4, Keen 5 1.0, 1.4), with King Duke's patches or without, I find that Keen manages to mostly (>99% frames) render in that smooth 35 fps - but every 5-10 seconds, it misses a single frame, which produces this kind of microstuttering effect. There does not seem to be any type of regular periodicity to these frame misses.
Also I find that enabling or disabling the PC turbo button (I think my Turbo button drops the PC to around 25 MHz from 80 MHz) causes no deterioration or improvement to the frequency of these microstutters.
This effect is best seen when Keen is climbing a pole upwards, where I think the game intends to scroll the screen at the slowest possible smooth rate, a constant one pixel every 2 frames (35 pixels/second) pace.
I thought that this issue could have been due to the game vsync code maybe still being subtly buggy, so I broke out Ida disassembler, searched through locations in Keen5 1.4 code that perform accesses to I/O port 3DAh and 3D4h, and attempted to patch those using CK5PATCH with custom assembly code to remove the synchronization altogether. (I found three such locations in that version)
Although I feel that I may have failed to do so properly, since I find I am unable to make the game run unboundedly fast even, so not completely sure what to make of my experiment.
Does anyone know the type of microstuttering that I am talking about? I.e. the game is smooth for the most part, but not 100% butter smooth.
Comparing to my testbench for different hardware panning synchronization behavior at https://github.com/juj/crt_terminator/b ... P#L66-L172 , most of the methods there are able to produce a 100% smooth update with a very deterministic idle time between frames, so I have a good impression at least that the PC would not be stalling.
Do the Keen games just contain that much "lopsided" or "fluctuating" computation that they inevitably need to do too much computation during some frames that will throw them off to miss a frame? (I would find that odd if that's the case since adjusting CPU between 25 MHz -> 80 MHz seemingly has no effect on the frequency) If so, is there any hint on what those heavy computations would be? They don't seem to have a deterministically repeating pattern to them at least. And the microstuttering also happens in the main intro with the big letters scrolling from left to right.
Could it be related to audio processing? Maybe not, since if I disable all audio, the microstuttering is still there, and it does not seem to become more infrequent by removing audio.
Is it just my PC after all? Should I grow my vintage PC catalog with an overkill faster > 100 MHz (> 1 GHz?) box to ensure Keen will never miss a frame?
(btw on the performance front, I find there is some kind of missed performance situation in Keen that it wants to redraw also secret candies that will normally never show up to the player; just to hide them afterwards by painting walls over them. Secret candies could have been completely ignored in the paint routines - though that's unrelated to this microstuttering issue)
I don't have any joysticks connected, just playing with the keyboard.
Any thoughts or clues?
