Keen Dreams

About

Keen Dreams — often known as the lost episode of Commander Keen, was developed in between the original Invasion of the Vorticons trilogy and the later Goodbye Galaxy and Aliens Ate my Babysitter games. Keen Dreams was one of a series of games developed by id Software as part of a deal with their former employers Softdisk. It provides an interesting glimpse at an early version of the Keen 4–6 engine.

This episode of Commander Keen — where Keen falls asleep and dreams of the vegetables he refused to eat for dinner — has always held a fascination for me. So I've occasionally ended up working on various bits of code related to it:

Source release and SDL2 Port

The source code to Keen Dreams was released under the GPL in 2014. The game code can be compiled using Borland C++ 2.0: there's a useful GitHub issue where I describe how to compile it in some detail.

I initally put together a port of the game for Linux using SDL2. This involved porting the 16-bit segmented/real-mode code to 32/64-bit mode with a (mostly) flat address space, as well as emulating the EGA.

The most interesting technical "feature" here is the use of mmap() (or VirualAlloc() on Windows) to imitate the way integer overflow on the 16-bit near pointers in the graphics code. Commander Keen relies on both the CPU-side blitting code and the EGA hardware supporting this wrapping. The code to set this up can be found here

Alas the keen-dreams-sdl2 project was never polished and finished — maybe one day. :-)
If you're looking to run Keen Dreams on modern systems, I'd recommend Reflection Keen.

Steam Port

After the Keen Dreams source code release — and my initial Keen Dreams SDL2 work — the new rightsholder of Keen Dreams contacted me to prepare a version of the game for Valve's Steam service. This would be a modified version of the Keen Dreams SDL2 work, with some bugs fixed and new features added. Additional graphics, as well as some minor level fixes, were made using the original DOS tools, including TED5, DeluxePaint II, and IGRAB. Unlike with the open-source version, we couldn't make use of the DOSBox OPL2 sound emulator, so a new sound system based on DPCM data was written (using a similar huffman compression format to the original game).

The Steam port added several new features, including support for switching between the EGA and CGA graphics modes, support for leaderboards and achievements in-game, and support for the Steam Controller / Steam Overlay's text input features.

Unfortunately, the rightsholder turned out to be very difficult to work with, and his inappropriate behaviour and highly objectionable opinions led to the game being taken down from the Steam store. Nightdive Studios re-released the Steam version, with some bugfixes by Ryan C. Gordon, but this too was taken down due to a dispute with the same individual.

The source code of (an earlier version) of the Steam port is available in the steam branch of the keen-dreams-sdl2 repository. Since the Steam version is not available for purchase, it's likely to be of limited use, but may be interesting. The RefKeen project also has support for the Steam version's data files.

Modding Utilities

In my youth, I added support for the v1.13 shareware version of Keen Dreams to a couple of Commander Keen modding utilities. Keen Dreams had slightly different versions of the various file formats, so was rarely supported by the tools available.

KDRPATCH was a verson of Brian Rodgers' CKPatch utility, which loads the Commander Keen executable, and patches its memory from a script before executing it. CKPatch scripts are the standard way modifications to the Keen executables are distributed in the Commander Keen community.
KDRPATCH 0.9 (DOS/Turbo Pascal) added support for patching Keen Dreams 1.13. See also the Keen:Modding forum thread for it.

ModKeen — Keen Dreams Edition was an updated version of Andrew Durdin's ModKeen utility, which can extract and import the graphics for the Commander Keen games.
ModKeen Dreams 2.0.1 (DOS32/DJGPP) added support for Keen Dreams 1.13. See also the Keen:Modding forum thread for it.

Both of these tools have been obsoleted by newer, better versions or tools, so they're here for historical interest only. I'd recommend using CKPatch 0.11.3 for patching, and either ModId or KeenGraph for graphics exporting and modding.