
The DUNGEON (Zork I) source - geospeck
https://github.com/devshane/zork
======
__david__
Not exactly Zork 1. Zork was originally written on MIT mainframes, but when
they decided to start Infocom and release the game for profit they couldn't
get it all to fit on the personal computers of the time, and so they split it
into 3 parts. Zork 2 had the coal mine and the Bank of Zork, I think, and Zork
3 had the endgame. They then added some extra stuff to Zork 2 and 3 that
wasn't in the original mainframe version.

The history of the source code is interesting. It was called Zork and written
in MDL. At some point they renamed it to Dungeon, but then a little while
later named it back to Zork. During the time it was called Dungeon, a DEC
engineer logged into their system (open to the world on purpose so people
could play the game) but instead of playing the game copied the source code
off. Then they translated the game into Fortran so they could run it on
PDP-11s. This source code is the descendant of that translation.

~~~
davidjhall
A version of it has been ported to the z-machine ( available on almost every
platform) :
[http://penguincentral.com/retrocomputing/zdungeon/](http://penguincentral.com/retrocomputing/zdungeon/)

Also referenced here:
[http://ifdb.tads.org/viewgame?id=4gxk83ja4twckm6j](http://ifdb.tads.org/viewgame?id=4gxk83ja4twckm6j)

------
larrykwg
reading old C like this, I always wonder how could people code like this back
then but apparently it was transpiled from fortran. So I'd assume the original
code looked better. I dug around and found it, for comparison here is the
original rooms.f vs. rooms.c:

[https://paste.ubuntu.com/25458063/](https://paste.ubuntu.com/25458063/)

[https://github.com/mgius/zork/blob/master/rooms.c](https://github.com/mgius/zork/blob/master/rooms.c)

Here is the full fortran code:
[http://gunkies.org/wiki/Zork#Source_code](http://gunkies.org/wiki/Zork#Source_code)

~~~
DonHopkins
The original MDL source code is beautiful to read:

[https://github.com/itafroma/zork-mdl](https://github.com/itafroma/zork-mdl)

~~~
lispm
Notice that MDL is almost Common Lisp:

    
    
        <DEFINE WAIT ("OPTIONAL" (NUM 3))
            #DECL ((NUM) FIX)
            <TELL "Time passes...">
            <REPEAT ((N .NUM))
                #DECL ((N) FIX)
                <COND (<OR <L? <SET N <- .N 1>> 0>
                           <CLOCK-DEMON ,CLOCKER>
                           <FIGHTING ,FIGHT-DEMON>>
                       <RETURN>)>>>
    
    
        (defun wait (&optional (num 3))         ; same arglist
          (declare (fixnum num))                ; similar declaration
          (tell "Time passes...")               ; some call
          (repeat ((n num))                     ; some loop macro, see below
            (declare (fixnum n))                ; declaration
            (cond ((or (< (setq n (- n 1)) 0)   ; old-style COND, OR, <, SETQ, -
                       (clock-demon clocker)    ; some call
                       (fighting fight-demon))  ; some call
                   (return)))))                 ; return from loop
    

Where REPEAT would be implemented as:

    
    
        (defmacro repeat (vars decl &body body)
          `(let ,vars
             ,decl
             (loop (progn ,@body))))
    
    

Common Lisp basically got type declarations, rich argument lists, ... from
MDL.

~~~
bluefox
Indeed... as soon as I saw this, I skimmed the (smug towards Lispers!) MDL
primer [0] and wrote a few (broken) esrap rules to parse some MDL into Lisp.
For example yours gives:

    
    
        DEMUDDLE> (parse 'expr *lispm-expr*)
        (DEFINE 'WAIT ("OPTIONAL" (NUM 3)) (TYPED DECL ((NUM) FIX))
         (TELL "Time passes...")
         (REPEAT ((N (LVAR NUM))) (TYPED DECL ((N) FIX))
          (COND
           ((OR (L? (SET 'N (- (LVAR N) 1)) 0) (CLOCK-DEMON (GVAR CLOCKER))
                (FIGHTING (GVAR FIGHT-DEMON)))
            (RETURN)))))
    

Someone more determined could write a small MDL->CL translator and produce a
CL port of Zork (chock full of special declarations, since MDL uses dyamic
scoping).

I also found the following interesting remark in the primer: "One of the
implementors of Zork has been heard to say that Zork is a huge conditional".

[0] [http://publications.csail.mit.edu/lcs/pubs/pdf/MIT-LCS-
TR-29...](http://publications.csail.mit.edu/lcs/pubs/pdf/MIT-LCS-TR-292.pdf)

------
homarp
In [http://blog.zarfhome.com/2017/08/your-load-is-too-heavy-
zork...](http://blog.zarfhome.com/2017/08/your-load-is-too-heavy-zork-deep-
reading.html) , Andrew Plotkin was pointing to an Inform 6 version of Zork by
Allen Garvin ,
[http://plover.net/~agarvin/zork1.txt](http://plover.net/~agarvin/zork1.txt)
derived from the original decompiled Z-machine code.

~~~
homarp
And
[http://plover.net/~agarvin/zorkbugs.txt](http://plover.net/~agarvin/zorkbugs.txt)
is a list of Zork bugs.

------
teddyh
See also Open Adventure:

[https://gitlab.com/esr/open-adventure](https://gitlab.com/esr/open-adventure)

“ _This code is a forward-port of the Crowther /Woods Adventure 2.5 from 1995,
last version in the main line of Colossal Cave Adventure development written
by the original authors. The authors have given permission and encouragement
for this release, it obsolesces all the 350-point versions and previous 2.x
(430-point) ports._”

~~~
taeric
Knuth has a version of this game. Fun read: [http://www-cs-
faculty.stanford.edu/~knuth/programs/advent.w....](http://www-cs-
faculty.stanford.edu/~knuth/programs/advent.w.gz)

~~~
teddyh
“ _What a thrill it was when I first got past the green snake! Clearly the
game was potentially addictive, so I forced myself to stop playing — reasoning
that it was great fun, sure, but traditional computer science research is
great fun too, possibly even more so._ ”

I wish more people had this attitude to distracting things.

~~~
taeric
Which aspect? The respect, or the interest in research that equaled it? :)

I suspect you mean both. And I agree. I'd probably agree with all permutations
of meaning here, actually.

------
JoeDaDude
This was also discussed a couple of days ago:

[https://news.ycombinator.com/item?id=15138114](https://news.ycombinator.com/item?id=15138114)

------
crocal
That Makefile made my day...

    
    
      # On SCO Unix Development System 3.2.2a, the const type qualifier does
      # not work correctly when using cc.  The following line will cause it
      # to not be used and should be uncommented.
    

Write once, run anywhere provided all the tweaking is done properly. Those
were the days.

EDIT: formatting.

------
spilk
Neat. compiled right up on my SunOS 4.1.4 machine with only a slight
modification (dsub.c had some C++ style comments that the old BSD cc didn't
like).

    
    
      phoenix$ zork
      Welcome to Dungeon.                     This version created 11-MAR-91.
      You are in an open field west of a big white house with a boarded
      front door.
      There is a small mailbox here.
      >

~~~
DonHopkins
4.1.4? Yummy, my favorite! Is it running on real hardware or in a VM? If the
former, what software do I need and how can I get an image please?

~~~
spilk
I'm running it on the real deal - a 1991-ish SPARCstation IPC. 25MHz of SPARC
goodness.

Most of these machines are dead because the power supply output capacitors
have failed, but a fairly easy soldering job and they are back up and running.
My original SCSI HD also failed (a 424MB Seagate ST1480N), but I've subbed in
a SCSI2SD. Works a treat. I basically just play Nethack on it. I've also been
experimenting with TeX 3.141 on it.

As far as a VM, I believe it is possible to run 4.1.4 within QEMU. I haven't
personally tried, but I have had success in the past running some versions of
Solaris 2.x for sun4m in QEMU. I believe you can emulate a SPARCstation 5 with
tcx graphics fairly well with that.

------
rhspeer
It would be interesting to refactor zork into HTML+CSS and set it up like
cssZenGarden.com so folks could add their own designs.

Although a much smaller text adventure game would me more achievable.

~~~
throwanem
That's basically Twine: [https://twinery.org](https://twinery.org)

~~~
rhspeer
that's new to me, thanks!

------
scelerat
A cavalcade of GOTOs

~~~
smegel
Might have been ported from assembly, this is not really the very original
source. As someone said, version one was for mainframe or something.

~~~
Narishma
It was ported from Fortran, and that version itself was ported from the
original written in a LISP derivative called MDL.

