Dungeon 3.2B, C port (Glk)

Translated and ported by Andrew Plotkin <erkyrath@netcom.com>
Fortran source for Dungeon by Robert M. Supnik
Dungeon was created by Tim Anderson, Marc Blank, Bruce Daniels, and Dave
Lebling.
Dungeon is copyright 1980, 1990 by Infocom, Inc (now owned by
Activision)

*** Introduction ***

Welcome to Dungeon.

This is a Glk port of a C translation of the Dungeon 3.2B Fortran source
code. Hark, is that the sound of a million hackers crying out "Huh?" and
then falling silent? Let me explain.

Dungeon is the original Zork text adventure. It was later split up and
modified into the Zork trilogy, which was sold for home computers by
Infocom, Inc. It's the game with the troll, the thief, and the white
house with its front door boarded up. 

(If you're looking for nasty little dwarves, "xyzzy", and a black rod
with a rusty star on the end, this isn't it. You want Adventure, also
known as Colossal Cave. Down the valley, follow the stream, on your
right, a well house for a large spring -- you can't miss it.)

There have been many versions and ports of Dungeon. This code is based
on version 3.2, patchlevel B. That's the latest Fortran source code
known to exist. It was released, believe it or not, in 1994.

I translated the 3.2B Fortran source into C, using the translation tool
f2c. This was a hairy and a half, believe me, because Dungeon is written
in a nonstandard dialect of Fortran. I had to modify f2c itself. Thanks
to the miracle of open-source software, this was not unduly difficult.
(Although GNU bison wouldn't compile the yacc source that forms the
heart of f2c... well, I got it worked out.)

I then removed the Fortran compatibility libraries that f2c provides.
This is the code that handles input and output -- both to the player,
and to the data files that come with Dungeon.

Instead, I installed code to handle input/output through Glk. Glk is a
portable I/O library that I created especially for text adventures --
although it may be useful for other tasks as well. I designed Glk to
provide a natural interface on many platforms: text terminals, the
Macintosh GUI, X Windows, Microsoft OSes, even PDAs such as the
PalmPilot. This port of Dungeon is an experiment and a demonstration of
the usefulness of Glk.

*** Modifications ***

This version should be functionally identical to the Fortran version in
nearly every way. I have made a few changes, however.

    Reformatted all the text to remove linebreaks. The Glk library
handles all line-wrapping now. ASCII art, such as the images of the
zorkmids, is preserved (with appropriate Glk commands to display in a
fixed-width font even on graphical displays, which normally use
proportional fonts.)
    Added and removed a few linebreaks for purely aesthetic reasons.
(For example, if you type "take all", the each "object: taken" message
appears on one line, rather than split over two.)
    Added a status line. This displays the room name on the left, and
your score and the number of moves on the right, in classic Infocom
fashion.
    The "restore" command works when you're dead. ("Save" still does
not.)
    If the game cannot determine how long you've been playing, the
"time" command prints an appropriate message.
    With some hesistation, I added a normal command prompt to the Loud
Room.
    Fixed a couple of minor misspellings.
    The data files "dindx.dat" and "dtext.dat" have been unified into
"dundat", with a more compact format.
    The save file format is also changed; don't expect to re-load games
that you saved from the Fortran version. However, the save files are
compatible across all versions of Glk Dungeon 3.2B (Mac, DOS, Unix,
etc.)

*** Building Dungeon ***

Since this is a Glk program, it must be built with a Glk library. See
the Glk home page at

http://www.edoc.com/zarf/glk/index.html

At the present time (Oct. 13, 1998) there are four Glk libraries
available:

    MacGlk: For MacOS
    DOS Glk: For MS-DOS (by Matt Kimball)
    GlkTerm: For text terminal windows, using the curses.h library
    CheapGlk: For any ANSI C environment, using the stdio.h library

The last, of course, cannot support a status line, since stdio.h has no
portable way to control the cursor position. But it does everything
else.

(Note: I've written 80% of an X Windows library, and I really, really
hope to have that finished in the next few weeks.)

The Unix Makefile that comes with this package is designed to link the
GlkTerm library; you can easily modify it to link the CheapGlk library.
Unfortunately, the GlkTerm and CheapGlk packages on my web site don't
*create* libraries! Dungeon is the first large Glk project, and I
haven't gotten all the details sorted out yet. I apologize.

To build the GlkTerm library, download the GlkTerm package; unpack it;
go into the glkterm directory; and type the following commands:

    make model
    ar r libglkterm.a *.o
    ranlib libglkterm.a

Then copy the glkterm directory into the Unix Makefile in this package,
so that it can find the files "libglkterm.a" and "glk.h". Go into the
dungeon directory, and type:

    make dungeon

That should suffice. When the program is built, type

    ./dungeon

to run. The data file "dundat" must be in the current directory when you
do this. (In future releases, I plan to have smarter startup code which
can find the "dundat" file in more sensible ways. Startup behavior is
one of the areas of Glk that needs more work. Again, I apologize. I just
wanted to get this thing out the door.)

*** History ***

(Section I. to V. of this history are drawn from the HISTORY file in the
old C translation of Dungeon version 2.7.)

I. From the original documentation...

To:     Dungeon Players
From:   "The Translator"
Subj:   Game Information
Date:   8-OCT-80

This is the first (and last) source release of the PDP-11 version of
Dungeon.

II. DEC FORTRAN to f77 Conversion (17-nov-81)

The conversion from DEC FORTRAN to Unix f77 was done by Randy Dietrich,
Lynn Cochran and Sig Peterson.  Much hacking was done to get it to fit
in the limited address space of a PDP-11/44 (split I/D). Suffice it to
say that by leaving out the debugging package and not linking in the f77
i/o library they managed to get it to run.

III. PDP to VAX (dec-85)

Based on the work of Randy, Lynn and Sig, Bill Randle folded in the full
save/restore functions and the game debugging package (gdt) into the pdp
version to create a Vax/Unix version.  This version also uses f77 i/o,
thus eliminating the extra speak and listen processes needed on the pdp.

IV. Cleanup I (11-dec-86)

John Gilmore (hoptoad!gnu) cleaned up the source files by moving most of
the common declarations into include files and added comments from the
original (FORTRAN or MDL?) source.  His efforts are greatly appreciated.

V. Cleanup II (9-feb-87)

Bill Randle (billr@tekred.tek.com) added the pdp dependencies back into
the Vax source files with #ifdefs in order to have just one set of
sources.  Previously, there were two sets of source: one for the pdp and
one for the Vax.  In addition, a shell escape of the form !cmd was added
and the wizard can enter the gdt without having to recompile the source. 
Finally, a man page was generated, based on the dungeon.doc file.

VI. Assorted Additions (up to oct-94)

Performed, to the best of my knowledge, by Robert Supnik. This includes
several puzzles, "lots and lots and lots and LOTS" of bug fixes, an
unsatisfying afterlife, and a Last Lousy Point.

VII. C Translation (oct-98)

See my diatribe above.

*** Copyrights and Other Verbiage ***

Please note that Dungeon has been superceded by the game ZORK(tm). The
following is an extract from the new product announcement for ZORK in
the September, 1980 issue of the RT-11 SIG newsletter:

"'ZORK: The Great Underground Empire - Part I' ...was developed by the
original authors based on their ZORK (Dungeon) game for the PDP-10. It
features a greatly improved parser; command input and transcript output
files; SAVEs to any device and file name; and adaptation to different
terminal types, including a status line on VT100s. Note: this is not the
FORTRAN version that has been available through DECUS. This version has
been completely rewritten to run efficiently on small machines - up to
10 times as fast as the DECUS version.

"...ZORK runs under RT-ll, HT-ll, or RSTS/E and requires as little as
20K words of memory and a single floppy disk drive. The game package,
consisting of an RX01-format diskette and an instruction booklet, is
available from Infocom, Inc., P.O. Box 120, Kendall Station, Cambridge,
Ma. 02142."

Copyright on the Dungeon sources is retained by Infocom, and commercial
use is strictly prohibited. ZORK(tm) is a trademark of Infocom, Inc.