Play Zork on OS X!

Apr 07, '01 02:08:30AM

Contributed by: robg

OS X may be the world?s most advanced operating system, but tonight, I took it back into the early 80?s. In the early days of the internet (or Arpanet, back then), a text-based game known as Zork was all the rage. I remember playing it on a TI Silent 700 dumb terminal with thermal paper, connected to the net at a whopping 300 baud.

Zork was the second big computer adventure game (after Adventure, of course), and it featured an amazingly detailed universe, and a slick English-language command parser. Infocom eventually published the Zork games for the PC, but my memories are strictly from the dumb terminal era. The first three Zork games are available freely on the web; more recent versions are still owned and protected by Activision.

Zork was originally coded in MDL (pronounced muddle), but over the years, it was rewritten in C, so I set out on a mission to get it running on OS X. After some searching, and a little bit of editing, I got it to work (as the screenshot shows; click here for a larger version). It turns out the hardest part was finding all the pieces. Read the rest of this article if you?d like to know how it works, and for step-by-step installation instructions.

If you don't want all the details and just want to play, grab the binary download of a UNIX Zork engine (Jzip), the first three Zork game data files, and a Read Me from my "Griffman's OS Collection" page.

And yes, I know about (and own) "The Lost Treasures of Infocom" I & II for the Mac; that's not the point -- I wanted to see if Zork could be run in a terminal window on OS X -- and it can!

Zork runs courtesy of an interpreter which understands Zork data files. Zork?s developers created a standardized system for handling adventure games (this made it quite easy for them to create follow-on games), which future programmers have used to recode the original game engine. So the first thing we need to do is get a Zork game engine. There are a number of them out there, for a number of platforms.

I used one called Jzip, primarily because it was the first one my search came across. Jzip will run all games written by Infocom except for Zork Zero, Journey, Shogun, and Arthur (remember, only the first three Zork games are free; you?ll have to own other versions in order to use them legally). Other engines may work better, but this article deals solely with Jzip. Here?s how to get the engine running.

NOTE: You need to have the Developer Tools installed to compile Zork yourself. If you don't want to install them, download the precompiled binary.

  1. The Jzip home page has the source available for version 2.1, under the Source Distribution button at the top left. This will place a file called ? in your downloads folder. You can also click on the filename above for a direct download.

  2. Create a temporary working directory for Jzip. We?ll call it ?jzip_work? in this example. This directory can be anywhere you like; I put the sample directory in my ~/Documents folder. NOTE: If StuffIt Expander expands the archive automatically, that?s OK. Just use the folder it created as your working folder.

  3. If you didn?t use Stuffit to expand the file, start a terminal session, and unzip the download into the working directory:
    cd /path/to/your/download/folder
    unzip -d ~/Documents/jzip_work/
  4. Move into the working directory, and copy one data file into a makefile:
    cd ~/Documents/jzip_work
    cp unixio.mak makefile
    This step creates the makefile we?ll use to compile the source. There are three different UNIX .mak files you could use, but this one seemed to be the best option (see the docs on the Jzip home page for more info on the .mak files).

  5. We now need to edit the makefile to change one line:
    vi makefile
    Find the line that reads LIBS = -lz -ltermcap and change it to read LIBS = -lz -lcurses. This changes out one of the libraries we compile Jzip with.

  6. Save your changes and exit the editor.

  7. Type make and watch the screen fill with text for a minute or two. NOTE: You?ll see a couple errors go by, but they didn?t seem to affect my ability to run the compiled code. If anyone can modify the makefile more to remove the errors, I?d be interested in learning what needs to be done. Since there are errors, I feel compelled to say ?Use this at your own risk!? I have no idea if anything bad will come of compile-time errors; my machine seems fine, though.

  8. When the compile is finished, you now have a Zork game engine in the working directory, named simply jzip. I took this file and moved it into my /usr/local/bin, so I could run it from anywhere. If you want other users to have access to it, you?ll also have to change the ownership of the program.

  9. You can delete everything else in the working directory; it's no longer needed.
The working game engine isn?t much good without some game data to display. So we need to go get some Zork data files. You can download the three freely available Zork games here:

Zork 1 Zork 2 Zork 3

NOTE: You can also download a data file called "dungeon," which is based on the original MDL source, and (I believe) contains all the original text and game -- it's about twice as big as the ZORK1.DAT file. Download dungeon to check it out yourself!

Once you?ve downloaded the games, you need to expand them (Stuffit is fine). From the expanded folder, the only thing you need is the ZORKx.DAT file. The path to this is /zorkfolder/DATA/Zorkx.DAT (where ?x? = 1,2, or 3). You can take this file and put it anywhere you like; I stuck it in my ~/Documents/ folder. Throw away everything else; the files aren'tneeded. You may want to view the README.TXT file if you?re new to Zork; it contains a brief ?how to play? guide.

That?s it -- you?re done! To play Zork, open a terminal, and ?cd? to the directory where you stored the ZORKx.DAT file. Then (assuming jzip is in your path), just type jzip ZORKx.DAT, and you?ll be playing!

NOTE: I don't think my compile is perfect, as I don't have access to some color options that Jzip claims to offer (I can?t change background or foreground colors). If anyone can do better, please let me know!

Comments (22)

Mac OS X Hints