Sunday, July 17, 2016

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 palance):



Yet another 16-color CGA makeover: Keen 5

After giving Keen 4's CGA version a 16-color composite overhaul, I figured I'd have a go at the next episode, since the code has nearly everything in common with Keen 4, and the composite enhancements detailed in my previous post could be applied without too many essential changes (other than different offsets/addresses, of course).  Let's strap this one to the rack then: