Haunted House by Jenny Tyler and Les Howarth
The Usborne book Write Your Own Adventure Programs for Your Microcomputer used Haunted House as a worked example for constructing an adventure game in BASIC. This page provides the original BASIC programs, plus a couple of ports.
Original listing
The original program was supplied in Microsoft BASIC format. The version here was typed in and tested under Disk BASIC on an IBM XT.
haunted.bas (9k) is the original listing.
hauntx.bas (10k) includes the additional SAVE, LOAD and QUIT functions.
hauntx.tzx (10k) is a TZX file for Cassette BASIC on the IBM 5150 PC. Connect the 5150's "EAR" connector to a more recent PC's loudspeaker socket, and use a utility such as PlayTZX to play back the TZX file. The BASIC command to load from tape is LOAD "CAS1:"
The listing may require some tweaks, small or large, for Microsoft-compatible BASICs on other computers. For example:
- The functions to open external files (in the LOAD and SAVE handlers) may require amendment.
- The VIC-20 and Oric have a restricted line length, requiring line 460 to
be split in two. The book provides alternative lines on page 37:
455 IF VB>14 THEN GOTO 465 460 ON VB GOSUB 500,570,640,640,640,640,640,640,640,980,980,1030,1070,1140 463 GOTO 470 465 ON VB-14 GOSUB 1180,1220,1250,1300,1340,1380,1400,1430,1460,1490,1510,1590
- Mallard BASIC under CP/M has no CLS command; replace line 90 with an
appropriate clear screen command for your terminal. This will work on
ANSI terminals:
90 PRINT CHR$(27)+"[2J"+CHR$(27)+"[2H" + "HAUNTED HOUSE"
and this will work on VT-52 compatible terminals like the Amstrad PCW:90 PRINT CHR$(27)+"E"+CHR$(27)+"H" + "HAUNTED HOUSE"
Spectrum version
The Spectrum version was created with zmakebas. It includes the optional SAVE / LOAD / QUIT commands, but not the optional BEEP commands (page 28 of the book).
hauntzx.bas (11k) is the listing in text form.
hauntzx.tap (11k) is the game as a ready-to-run tape file.
ZX81 version
The ZX81 version is reduced in size (36 rooms as opposed to 64).
The original version needs to be initialised with the object locations at the start of each game. Type the following numbers, pressing ENTER after each: 30 24 21 32 5 8 16 26 2 13 14 36 18 11 35 3 27 6
If the game is broken into, it must be restarted with GOTO 10 rather than RUN.
haunted.p (12k)
This version, which I have not tested particularly thoroughly, adds an additional array of initial object positions, so does not need to be manually initialised.
hauntx.p (12k)
C
This is a simplistic port of the original BASIC version to ANSI C (with a little conditional code for clearing the screen under DOS).
haunted.c (27k) is the C source code.
haunted.exe (19k) is a compiled version for DOS (it will also run on 32-bit versions of Windows; for 64-bit versions, you will need to use a virtualisation or emulation solution such as DOSBox).
Inform
This is an adaptation of Haunted House to the Inform 6 adventure-writing language. It takes a somewhat looser approach than the other ports on this page; instead of trying to replicate the exact structure and behaviour of the BASIC original, it takes full advantage of the Inform library and its support for doors, vehicles, containers, supporters and so on.
haunted.inf (46k)
haunted.z5 (93k)
John Elliott 2014-06-10