Skip to content

ADVENT.FOR on the PDP-11

This is a transcript of how to setup simh on a simulated PDP-11, generate a working FORTRAN IV compiler, transfer the original ADVENT source code into the simulator or real PDP-11 hardware, build it and play Colossal Cave Adventure.

Pre-built executables

If you don't want to build the FORTRAN IV compiler, you can download the pre-built executables from github.com/osresearch/advent. You will need ADVENT.SAV, AINDX.DAT,ATEXT.TXT and ATEXT.DAT. To transfer them to a simulated PDP-11, you can use the PC: trick described in simh.

Building FORTRAN.SAV

These instructions are copied from computing history wiki.

tiny:~/simh: curl --remote-name http://simh.trailing-edge.com/kits/rt11swre.tar.Z
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  838k  100  838k    0     0   321k      0  0:00:02  0:00:02 --:--:--  336k
tiny:~/simh: tar zxvf rt11swre.tar.Z
x Licenses/README.txt
x Licenses/pdp11_license.txt
x Disks/rtv4_rk.dsk
tiny:~/simh: curl --remote-name http://www.headcrashers.org/comp/rx01/fortran-iv/fortran-iv-v021-compiler-files.img
   % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                  Dload  Upload   Total   Spent    Left  Speed
 100  250k  100  250k    0     0   192k      0  0:00:01  0:00:01 --:--:--  236k
 tiny:~/simh: curl --remote-name http://www.headcrashers.org/comp/rx01/fortran-iv/fortran-iv-v021-objecttime-system.img
   % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                  Dload  Upload   Total   Spent    Left  Speed
 100  250k  100  250k    0     0   204k      0  0:00:01  0:00:01 --:--:--  222k

tiny:~/simh: ./BIN/pdp11

PDP-11 simulator V3.9-0
sim> set cpu 11/34
Disabling XQ
sim> set cpu 256K
sim> attach rk0 ./Disks/rtv4_rk.dsk
sim> attach rx0 fortran-iv-v021-compiler-files.img
RX: buffering file in memory
sim> boot rk

RT-11SJ  V04.00C

.D 56=5015

.TYPE V4USER.TXT
Welcome to RT-11 Version 4. RT-11 V04 provides new hardware support
and some major enhancements over Version 3B.

Please use the HELP command;  it describes the new options in many
of the utilities.

If you are using a terminal that requires fill characters,
modify location 56 with a Deposit command before proceeding with
system installation. LA36 DECwriter II and VT52 DECscope terminals
do NOT require such modification.


.D 56=0

.ASSIGN RK0: OUP

.ASSIGN DX0: INP

.RUN INP:FORGEN
Answer questions with:
"?" or carriage return () for information,
YES(Y) for affirmation, anything else for NO.


A maximum of   56 lines are allowed per listing page.
Is this acceptable? Y
A maximum of  136 characters are allowed in a formatted
(ASCII) record.  Is this acceptable? Y
A maximum of  6 channels may be open at a given time.
Is this acceptable? Y
The FORTRAN compiler can compile system-specific OPEN and CLOSE
statement keywords for RT-11, RSX-11, and RSTS/E systems.  These
statements are currently compiled for the following system: RT-11
Is this acceptable? Y
FORTRAN can produce inline code for EAE, EIS or FIS hardware,
or it can produce threaded (THR) code which is hardware independent.
Should the compiler produce EAE code? N
Should the compiler produce EIS code? N
Should the compiler produce FIS code? N
Should the compiler produce THR code? Y
The inline compiler can optimize for SPEED or for SIZE. These
optimizations are mutually exclusive. Do you want
the optimization to be for SPEED? SIZE
Do you wish a threaded only compiler? Y
Compiler options selection complete.


.@INP:F4LTHR

.R LINK
*OUP:FORTRA=INP:FROOT///S
*INP:F0,INLINE,OUP:DEFLTS/O:1
*INP:F1/O:1
*INP:F2/O:1
*INP:F3/O:1
*INP:F4/O:1
*INP:F5/O:1
*INP:F6/O:1
*INP:F7/O:1
*INP:F8/O:1
*INP:F9/O:1
*INP:F10/O:1
*INP:LOOP/O:1
*INP:F11/O:1
*INP:F12/O:1
*INP:F13/O:1
*INP:F14/O:1
*INP:F15/O:1
*INP:F16/O:1
*INP:F17/O:1
*INP:CDUMP/O:1//
*^C

.
Simulation stopped, PC: 151374 (TST (R5)+)
sim> att rx0 fortran-iv-v021-objecttime-system.img
RX: writing buffer to file
RX: buffering file in memory
sim> c


.R LIBR
*1=OUP:FORLIB=INP:NHD,OTSCOM,NOVIR,V2NS/G
Global? $ERRS
Global? $ERRTB
Global? $VRINT
Global?
*^C

.

Transferring source files

With simh using PC:

Sources are available from Rick Adam's Colossal Cave page. Suspend simh and fetch the source code. Then attach each file in turn to the PC: device and copy the text from it.

tiny:~/simh: curl --remote-name http://www.ifarchive.org/if-archive/games/pc/adv350kp.zip
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  220k  100  220k    0     0   368k      0 --:--:-- --:--:-- --:--:--  472k
tiny:~/simh: unzip adv350kp.zip RT11SRC.ZIP
Archive:  adv350kp.zip
  inflating: RT11SRC.ZIP
tiny:~/simh: mkdir advent
tiny:~/simh: cd advent
tiny:~/simh/advent: unzip ../RT11SRC.ZIP
Archive:  ../RT11SRC.ZIP
  inflating: AINIT.FOR
  inflating: README.DOC
  inflating: ATEXT.TXT
  inflating: ADVENT.DOC
  inflating: ABUILD.FOR
  inflating: ADVENT.FOR
  inflating: AIOSUB.FOR
  inflating: AMAIN.FOR
  inflating: ASUB.FOR
  inflating: ASUSP.FOR
  inflating: AMAC.MAC
  inflating: ADVENT.ODL
tiny:~/simh/advent: cd ..
time:~/simh: fg
sim> att ptr ./advent/AINIT.FOR
sim> c
COPY PC: AINIT.FOR
 Files copied:
PC:            to DK:AINIT.FOR

.
Simulation stopped, PC: 156066 (MOV (SP)+,R3)
sim> att ptr ./advent/ATEXT.TXT
sim> c
COPY PC: ATEXT.TXT
 Files copied:
PC:            to DK:ATEXT.TXT

.

Repeat for ABUILD.FOR, ADVENT.FOR, AIOSUB.FOR, AMAIN.FOR, ASUB.FOR, ASUSP.FOR, AMAC.MAC and ADVENT.ODL

Using EDIT/CREATE

However, on the real hardware using COPY TT: FOO.TXT won't work. The copy command appears to be too slow to keep up with 1200 baud, much less 9600 baud. However, the RT11 v4 added an EDIT command that seems to cope quite well up to about 6000 baud.

.EDIT/CREATE FOO.TXT
*Ifirst line of input...
second line of input
...
$$    <--- $ is escape, hit it twice
*EX$$ <---- EX to write and then again, escape twice

To send the files slowly, I wrote pdp11cat that slowly writes byte-by-byte and also handles newline translation. Substitute your serial device, depending on what your USB adapter assigns.

./pdp11cat AIOSUB.FOR > /dev/ttyACM0

If you copy in too much data, EDIT unhelpfully says "INSUFFICIENT MEMORY" with you hit the double escape. 16-20KB seems to be the max. To reduce the size of the FORTRAN IV files, I removed all comment and blank lines, and I used /usr/bin/split to break the still-too-large files (ATEXT.TXT and AMAIN.FOR) into smaller chunks and transferred the individually. There is probably a way to use EDIT to do this. After copying the six files, I recombined them:

.COPY XAA.TXT+XAB.TXT+XAC.TXT+XAD.TXT+XAE.TXT+XAF.TXT ATEXT.TXT

Compiling source files

.COMPIL/NOVEC ADVENT,AINIT,ASUB,AIOSUB,ASUSP
ADVENT
INIT
A5TOA1
VOCAB
DSTROY
JUGGLE
MOVE
PUT
CARRY
DROP
BUG
INIRND
RND
SPEAK
PSPEAK
RSPEAK
GETIN
YES
SAVEGM
RSTRGM

.COMPIL/NOVEC AMAIN
MAIN
?FORTRAN-I-[ ](MAIN) Errors: 0, Warnings: 1

.COMPIL AMAC
ERRORS DETECTED:  0

.LINK/PROMPT ADVENT,ASUB,AIOSUB,ASUSP,AMAC
*AINIT/O:1
*AMAIN/O:1
*FORLIB/O:1//

.COMPIL/NOVEC ABUILD
ABUILD

.LINK ABUILD,ASUSP,FORLIB

.DIR ADVENT.SAV

ADVENT.SAV   102
 1 Files, 102 Blocks
 1538 Free blocks

Building cache

To save time at startup, the ATEXT.TXT file is pre-processed into ATEXT.DAT and AINDEX.DAT by ABUILD.FOR.

.R ABUILD

.DIR ATEXT.DAT

ATEXT .DAT   126
 1 Files, 126 Blocks
 1538 Free blocks

.DIR AINDX.DAT

AINDX .DAT    21
 1 Files, 21 Blocks
 1538 Free blocks

If you compile with /ONDEBUG, advent will print as it builds the cache:

.R ADVENT
INITIALIZING...
NOW LOADING SECTION  1
NOW LOADING SECTION  2
NOW LOADING SECTION  3
NOW LOADING SECTION  4
NOW LOADING SECTION  5
NOW LOADING SECTION  6
NOW LOADING SECTION  7
NOW LOADING SECTION  8
NOW LOADING SECTION  9
NOW LOADING SECTION 10
NOW LOADING SECTION 11
NOW LOADING SECTION  0
USED VS MAX TABLE VALUES:
 294 OF   300 VOCAB ENTRIES
  32 OF    35 VERB ENTRIES
  10 OF    12 CLASS ENTRIES
   9 OF    20 HINT ENTRIES
 742 OF   750 TRAVEL ENTRIES
 865 OF   900 FILE RECORDS

PAUSE -- INIT DONE

Playing ADVENT

(Here's a video of the PDP-11/34 booting RT-11 v4 of the RK05 decpack and running ADVENT)

.R ADVENT
Welcome to Adventure!!  Would you like instructions?
>Y
Somewhere nearby is Colossal Cave, where others have found fortunes in
treasure and gold, though it is rumored that some who enter are never
seen again.  Magic is said to work in the cave.  I will be your eyes
and hands.  Direct me with commands of 1 or 2 words.  I should warn
you that I look at only the first four letters of each word, so you'll
have to enter "NORTHEAST" as "NE" to distinguish it from "NORTH".
(Should you get stuck, type "HELP" for some general hints.  For infor-
mation on how to end your adventure, etc., type "INFO".)
                        - - -
This program was originally developed by Willie Crowther.  Most of the
features of the current program were added by Don Woods (DON @ SU-AI).
The current version was done by Kent Blackett and Bob Supnik.
                        - - -
Bug reports and other correspondence should be sent to:

        Digital Equipment Computer Users Society
        One Iron Way, MR2-3/E55
        Marlboro, Mass. 01752
        Attn:  Adventure Maintenance

You are standing at the end of a road before a small brick building.
Around you is a forest.  A small stream flows out of the building and
down a gully.
>ENTER HOUSE
You are inside a building, a well house for a large spring.
There are some keys on the ground here.
There is a shiny brass lamp nearby.
There is food here.
There is a bottle of water here.
>GET LAMP
Ok
>QUIT
Do you really want to quit now?
>Y
Ok

You scored  27 out of a possible 350, using    3 turns.
You are obviously a Rank Amateur.  Better luck next time.
To achieve the next higher rating, you need  9 more points.

.
Simulation stopped, PC: 156062 (MOV (SP)+,R5)
sim> quit
Goodbye
RX: writing buffer to file

Retrocomputing 2014


Last update: November 19, 2020