Customized Screen Update Code For Keen 4-6

Here is where to post about the latest Commander Keen fangame or modification you've finished, a new website you've made, or another Keen-related creation.
Post Reply
User avatar
K1n9_Duk3
Vorticon Elite
Posts: 561
Joined: Mon Aug 25, 2008 9:30
Location: Germany
Contact:

Customized Screen Update Code For Keen 4-6

Post by K1n9_Duk3 » Sun Dec 01, 2019 23:21

Since a couple of people have asked for it...
Roobar wrote:
Fri Oct 11, 2019 13:15
That screen update code fix is neat... I think this is so significant change that now this screen update code must be applied to all major galaxy mods.
55Aavenue wrote:
Tue Oct 29, 2019 3:12
Also that screen update code is amazing and now I can't live without it.
Here is a download link for the patch script previously seen in action in Buried in Oblivion v1.3, which in turn is based on some code I wrote for Atroxian Realm v1.1 and above.

This download contains patch scripts for
  • Keen 4 (v1.4)
  • Keen 5 (v1.4)
  • Keen 6 (v1.4)
  • Keen 6 (v1.5)
The updated code fixes some graphical glitches when playing in DOSBox, like
  • jerky scrolling
  • sprites becoming invisible for one frame
  • sprites hidden behind foreground tiles becoming visible
Changing the "Fix Jerky Motion" option in the options menu will change the behavior of the screen update code. This option should be turned OFF (which is the default setting) when playing in DOSBox.

I also tested this code on various old PCs, using an MS-DOS 6.22 boot disk and running the game directly from DOS, and only one my systems had problems with the default setting. That machine was a "Texas Instruments TravelMate 4000E 486 WinSX/25MHz Color" system. Enabling the "Fix Jerky Motion" option fixed the problems on that machine.

Note that this code has NOT been tested on an actual EGA card. The WaitVBL code was designed to stop waiting for a VBL when more than 1/70th of a second has passed since the code started to wait for a VBL. That's because the code can miss the VBL if the CPU was hadling an interrupt while the VBL signal was present and therefore the WaitVBL code didn't get to "see" the VBL signal. But EGA cards use a refresh rate of 60 Hz, not 70 Hz like the (S)VGA cards. That means it is possible for the WaitVBL code to exit a little too early on systems equipped with an EGA card, which means the issues listed above could still pop up.
Last edited by K1n9_Duk3 on Tue Dec 03, 2019 23:37, edited 1 time in total.
Hail to the K1n9, baby!
http://k1n9duk3.shikadi.net

User avatar
Nisaba
Vorticon Elite
Posts: 981
Joined: Fri Jan 01, 2016 23:34
Location: The Outpost
Contact:

Re: Customized Screen Update Code For Keen 4-6

Post by Nisaba » Sun Dec 01, 2019 23:28

fantastic!
thanks a whole lot for sharing.
I think it's about time to add this patch to our beloved KeenWiki as well.
"We have come to conquer you all and bring you lots of candy!" | about me | my current project: play Keen mods on a GameBoy |

User avatar
K1n9_Duk3
Vorticon Elite
Posts: 561
Joined: Mon Aug 25, 2008 9:30
Location: Germany
Contact:

Re: Customized Screen Update Code For Keen 4-6

Post by K1n9_Duk3 » Tue Dec 03, 2019 23:39

Oops. I forgot to put the download link in my original post. Sorry about that.
Hail to the K1n9, baby!
http://k1n9duk3.shikadi.net

User avatar
Tormentor667
Vortininja
Posts: 104
Joined: Sat Mar 29, 2008 14:08
Location: Germany
Contact:

Re: Customized Screen Update Code For Keen 4-6

Post by Tormentor667 » Wed Dec 04, 2019 6:35

What exactly is the difference of this code?

User avatar
Nisaba
Vorticon Elite
Posts: 981
Joined: Fri Jan 01, 2016 23:34
Location: The Outpost
Contact:

Re: Customized Screen Update Code For Keen 4-6

Post by Nisaba » Wed Dec 04, 2019 8:00

Tormentor667 wrote:
Wed Dec 04, 2019 6:35
What exactly is the difference of this code?

The code comes with a readme section.
I'm quoting:
K1n9_Duk3 wrote:#-------------------------------------------------------------------------------
# What does this patch script do? Well, it fixes a few minor glitches when
# playing COMMANDER KEEN 4-6 in DOSBox, such as:
#
# - jerky scrolling
# - sprites becoming invisible for one frame
# - sprites hidden behind foreground tiles becoming visible
#
# Changing the "Fix Jerky Motion" option in the options menu will change the
# behavior of the screen update code. This option should be turned OFF (which
# is the default setting) when playing in DOSBox.
#
# I also tested this code on various old PCs, using an MS-DOS 6.22 boot disk and
# running the game directly from DOS, and only one of them had problems with the
# default setting. That machine was a "Texas Instruments TravelMate 4000E 486
# WinSX/25MHz Color" system. Enabling the "Fix Jerky Motion" option fixed the
# problems on that machine.
#
# Note that this code has NOT been tested on an actual EGA card. The WaitVBL
# code was designed to stop waiting for a VBL when more than 1/70th of a second
# has passed since the code started to wait for a VBL. That's because the code
# can miss the VBL if the CPU was hadling an interrupt while the VBL signal was
# present and therefore the WaitVBL code didn't get to "see" the VBL signal.
# But EGA cards use a refresh rate of 60 Hz, not 70 Hz like the (S)VGA cards.
# That means it is possible for the WaitVBL code to exit a little too early on
# systems equipped with an EGA card, which means the issues listed above could
# still pop up.
#-------------------------------------------------------------------------------
"We have come to conquer you all and bring you lots of candy!" | about me | my current project: play Keen mods on a GameBoy |

User avatar
K1n9_Duk3
Vorticon Elite
Posts: 561
Joined: Mon Aug 25, 2008 9:30
Location: Germany
Contact:

Re: Customized Screen Update Code For Keen 4-6

Post by K1n9_Duk3 » Wed Dec 04, 2019 22:42

Tormentor667 wrote:
Wed Dec 04, 2019 6:35
What exactly is the difference of this code?
Let's take this hairmonster12's Let's Play video for Buried in Oblivion (v1.0) level 1 as an example:

The first glitch appears at around 0:34. Look at the sprites for Keen and the bounder.
The second glitch is at around 1:51. Sprite flickering again. And again at 3:07.
At around 3:10 you can see a jawbreaker that should be hidden in a secret.
More sprite flickering and hidden items becoming visible at 5:38.
Again at 6:54 ...

As you can see, the glitches pop up roughly every 80 seconds in this video. And it's farily consistent behavior when playing (mods of) Keen 4-6 with the original screen update code in DOSBox at the default setting of 3000 cycles. The glitches may be less frequent or less noticeable when you tweak the cycles count in DOSBox, but they're still there. The customized screen update code should fix these issues regardless of your cycles settings, so everybody wins.
Hail to the K1n9, baby!
http://k1n9duk3.shikadi.net

User avatar
proYorp
Vortininja
Posts: 157
Joined: Fri Mar 03, 2017 1:56
Location: mspaint.exe

Re: Customized Screen Update Code For Keen 4-6

Post by proYorp » Fri Dec 06, 2019 3:27

This seems helpful. I usually fix these issues by setting DOSBox to run as "ega" instead of "svga_s3", which works most of the time unless the mod has a changed palette.

Can this be manually added into mods for personal use (like how people patch in infinite lives if the mod doesn't have it by default)? Is it likely to conflict with highly patched mods, or do you think it only changes things that most mods usually don't mess with?
"Friendly. Very friendly. Too friendly." :yorp

Post Reply