Saturday, May 28, 2016

Dopefish goes NTSC: Commander Keen 4 Composite CGA Patch Notes

If you're just landing here at random and wondering about the title: this is a 16-color 'remaster' of the original CGA version of Commander Keen IV: Secret of the Oracle, with code patched and graphics redrawn and reworked to take optimal advantage of CGA's composite output capabilities.

For more info (plus the download link), see the VOGONS thread - all sorts of cool stuff in there, like videos recorded from real hardware, and a DOSBox build patched with some useful additions for running this.  However, I've had a request or two for the technical nitty-gritty, so here's where I'm gonna dump it (careful what you wish for? ;-))



This patch started out as direct modification of the .EXE, following some disassembly and analysis.  I "ported" it to the CKPATCH format (for in-memory patching) only when I was done, by generating a binary diff.  This is why my notes will follow the disassembly, which is easier to comment on; all offsets are relative to the beginning of the load image (=file offset minus 2C00h) in v1.4-Apogee of the CGA executable.


Patch space


For new data, I found some 119 bytes that could be reused at offset 31548h.  In KEEN4C.EXE this has the color tables for the EGA fade routines - they're still present in the CGA executable for no discernible reason.  I ended up using only 36 bytes here, for extending the color tables used by various CGA drawing routines.