Keen 4 Mystery Code Demystified

In my post on Keen 4 I mentioned a seemingly-unused routine in v1.4-CGA, which I ended up using as patch space for my own code.  Having no idea what it was for, I consulted the sources for Keen Dreams, and found that it looked an awful lot like a KDR routine which caches level data - specifically, CA_CacheMarks in ID_CA.C.  At some point during Keen 4's initialization, a single pointer gets set to this code; but immediately afterwards the address is replaced so this function is never executed.

NY00123 took a closer look at it, and it turns out that that's exactly what it is: leftover level-loading code from Keen Dreams.  It's still fully-functional, too: for whatever reason, id left it lying around as a placeholder in later versions of their engine, and simply reset the pointer at runtime to whatever new thing they came up with.

Amusingly, you can bring it back into action by NOPing out the pointer overwrites - this replaces Keen's finger-counting with a KDR-style progress bar (or a "thermometer" in contemporary Id parlance):

Keen Dreams progress bar in Keen 4 (CGA) Keen Dreams progress bar in Keen 4 (EGA)

In the EGA version, this is done by changing 36 bytes to 90h, starting at offset 66FFh in the .EXE (=38FFh in the load image).  Same for the CGA version, except that the file offset is 6492h (=3892h in the load image).

Or, if you prefer using CK4PATCH, here's a .PAT file courtesy of NY00123.  This is for the EGA version; for CGA just change the offset as above.

# Patch file for Keen - use with CK4PATCH.EXE
%ext ck4
%version 1.4
# Use alternative cache-box from ID_CA.C
%patch $38FF $90 $90 $90 $90 $90 $90 $90 $90 $90 $90 $90 $90 $90 $90 $90 $90 $90 $90
             $90 $90 $90 $90 $90 $90 $90 $90 $90 $90 $90 $90 $90 $90 $90 $90 $90 $90

At this point, you may interject with the suggestion that this is one of the most utterly pointless things you've ever heard of.  In that case - to quote one of George R. R. Martin's ridiculously overused stock phrases - "you're not wrong" (dude's gotta have a macro for that in his often-mentioned copy of WordStar for DOS).


Raven Singularity says:

Great web site overall, and this is a fun article!

Minor typo with parlance, and Id Software should be uppercase:

"in contemporary id palance"
"in contemporary Id parlance"

VileR says:

Thanks, fixed. I've always seen "id Software" stylized with the lowercase 'i', but it does look odd in a sentence.

Write a response:

* Required.
Your email address will not be published.