Compiling "Keen Dreams" within DosBox on OS X


The “Commander Keen in Keen Dreams” source code was released in September 2014 (see the Hacker News discussion) and I wanted to see if I could compile it myself, and it turned out to be not that difficult!

For this excercise I used DosBox on OS X, but it should work on any platform that supports DosBox. The mount commands will probably look different if you’re on Windows though.

Things you’ll need

Preparing the environment

Download DosBox and copy it to your Applications folder. Then create a DosBox directory in your home directory (so the full path is /Users/foobar/DosBox) as well as a C and D directory inside it. Then go ahead and download Borland C++ 3.1 and extract it into the A directory.

I picked a naming scheme where the directory names are identical to the mounted drives in DosBox so that I don’t get confused (ノ^_^)ノ You can basically name them any way you want, just be sure to properly adapt the mount commands below.

Now we start up DosBox for the first time. You’ll see a prompt saying Z:\ which is the only drive currently mounted, so we execute the following commands to mount our created directories as drives:

Z:\> mount A /Users/lucas/DosBox/A
Z:\> mount C /Users/lucas/DosBox/C
Z:\> mount D /Users/lucas/DosBox/D

Now we can install Borland C++ by switching to the A: drive and running INSTALL.EXE:

Z:\> A:
A:\> INSTALL.EXE

Following the installation dialog and make sure to install Borland C++ into the C:\BC2 directory, because that is where the “Keen Dreams” Borland project expects it to be installed:

Lastly we need to adjust the PATH environment variable so that the OS knows where to find the Borland binaries. We do this by running SET PATH=Z:\;C:\BC2\BIN. It also contains the Z:\ drive because that is where DosBox stores its binaries! Running BC should now yield the following screen (which you can exit with Alt-X):

Compiling the source

The rest is pretty straight forward. First we need to create the MAKEOBJ.EXE inside the STATIC directory, which is later used to build some of the game’s static files. To do this, run the following:

A:\> D:
D:\> CD KEEN\STATIC
D:\> BC MAKEOBJ.C

This will open Borland C++ with the specified file opened. Now press F9 to compile and link it, thus creating MAKEOBJ.EXE. Exit Borland by pressing Alt+X. Now run MAKE.BAT in the same directory.

We’ve now created the static files, but the game remains to be compiled. So we move on directory up (CD ..) and run BC again. This should automatically find the Keen Dreams project file and open it. Now press F9 again, which builds the project. If everything works as expected, you’ll now have a KDREAMS.EXE binary in your source directory.

Can’t open KDREAMS.MAP

Unfortunately, as with many games that are open-sourced, the actual game content is still licensed differently and is thus not included with the source. As a result, you’ll see a Can't open KDREAMS.MAP error message when you try to start the compiled binary:

In order to run the game, you can download the assets from the shareware version of the game, though. Unpack the downloaded game and copy the following files to the Keen Dreams source directory (this is easier when done from outside DosBox):

KDREAMS.AUD, KDREAMS.CMP, KDREAMS.EGA, KDREAMS.MAP

And voilà, you can now run the game. Have fun playing or fiddling around with the source :)