commit f55286db8effbda747c7c1ef1ebb4f3e597f8280 Author: Seppe De Loore Date: Fri Apr 3 20:46:54 2026 +0200 Initial commit: ZIL source + Python game engine Original ZIL source code for The Hitchhiker's Guide to the Galaxy (Infocom, 1984) plus a native Python text adventure engine with the Earth opening sequence playable (Bedroom → Front Porch → Front of House → Country Lane → Pub). Co-Authored-By: Claude Opus 4.6 (1M context) diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ef7825e --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +__pycache__/ +*.pyc +*.pyo +save.qzl diff --git a/.python-version b/.python-version new file mode 100644 index 0000000..6324d40 --- /dev/null +++ b/.python-version @@ -0,0 +1 @@ +3.14 diff --git a/CLAUDE.md b/CLAUDE.md new file mode 100644 index 0000000..0cb5fb6 --- /dev/null +++ b/CLAUDE.md @@ -0,0 +1,56 @@ +# CLAUDE.md + +This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. + +## What This Is + +This is the original source code for **The Hitchhiker's Guide to the Galaxy** (1984), an interactive fiction game by Infocom (designed by Douglas Adams and Steve Meretzky). The code is written in **ZIL** (Zork Implementation Language), Infocom's proprietary Lisp-like language that compiles to Z-machine bytecode. + +Release 60 (October 2, 1986) — the final release version. The compiled game runs as a `.z5` Z-machine story file (a copy is at `docs/The-Hitchhikers-Guide-to-the-Galaxy_DOS_EN_Z5-format/hitchhik.z5`). + +## Building + +ZIL source requires the **ZILF** compiler (open-source ZIL-to-Z-machine compiler) or Infocom's original toolchain. There is no build system or Makefile in this repo. To compile with ZILF: + +``` +zilf s4.zil +zapf s4.zap +``` + +This produces a `.z5` story file playable in any Z-machine interpreter (Frotz, Lectrote, etc.). + +## Architecture + +**Entry point:** `s4.zil` — includes all other source files via ``. + +**Source files by function:** + +| File | Purpose | +|------|---------| +| `s4.zil` | Main file; game title, file includes, property defaults | +| `globals.zil` | Global variables, directions, meta-objects (ROOMS, IT, NOT-HERE-OBJECT, LOCAL-GLOBALS) | +| `parser.zil` | Text parser — tokenizing input, resolving nouns/adjectives, disambiguation | +| `syntax.zil` | Vocabulary: BUZZ words, SYNONYMs, direction aliases, verb SYNTAX definitions | +| `verbs.zil` | Verb handler routines (`V-TAKE`, `V-DROP`, `V-EXAMINE`, etc.) and game commands | +| `misc.zil` | Utility routines, interrupt/clock system, macros | +| `earth.zil` | Earth locations — Arthur's bedroom, front of house, pub, country lane | +| `vogon.zil` | Vogon ship — hold, guard's room, airlock, poetry appreciation | +| `heart.zil` | Heart of Gold — bridge, engine room, corridors, Infinite Improbability Drive | +| `unearth.zil` | Off-Earth locations — Traal (Ravenous Bugblatter Beast), Damogran, Magrathea | + +**Assembly files (`.xzap`):** `s4.xzap` is the assembly include order; `s4freq.xzap` defines frequently-used strings (Huffman-compressed). `s4.errors` is the assembler output log. + +## ZIL Conventions + +- **``** defines game objects with properties (DESC, SYNONYM, FLAGS, ACTION, etc.) +- **``** defines locations (rooms are objects with directional exits) +- **``** defines functions; `-F` suffix indicates an action handler (e.g., `HOME-F`) +- **``** defines global variables; parser globals are prefixed `P-` +- **Flags on objects** control behavior: `TAKEBIT` (takeable), `OPENBIT` (open), `ONBIT` (lit/on), `TOUCHBIT` (seen), etc. +- **`PRSA` / `PRSO` / `PRSI`** — parsed action verb, direct object, indirect object +- **``** outputs text to the player; `CR` = carriage return +- Comments use `;"..."` syntax; `;<...>` comments out an entire form + +## docs/ + +Contains the original MS-DOS executable, Z5 story file, game manuals (PDF), hint book, game maps, and photos of physical game "feelies" (props included with the boxed game). diff --git a/README.md b/README.md new file mode 100644 index 0000000..e69de29 diff --git a/docs/The-Hitchhikers-Guide-to-the-Galaxy_DOS_EN_Z5-format/hitchhik.z5 b/docs/The-Hitchhikers-Guide-to-the-Galaxy_DOS_EN_Z5-format/hitchhik.z5 new file mode 100644 index 0000000..5387993 Binary files /dev/null and b/docs/The-Hitchhikers-Guide-to-the-Galaxy_DOS_EN_Z5-format/hitchhik.z5 differ diff --git a/docs/The-Hitchhikers-Guide-to-the-Galaxy_Manual_DOS_EN.pdf b/docs/The-Hitchhikers-Guide-to-the-Galaxy_Manual_DOS_EN.pdf new file mode 100644 index 0000000..b64b482 Binary files /dev/null and b/docs/The-Hitchhikers-Guide-to-the-Galaxy_Manual_DOS_EN.pdf differ diff --git a/docs/The-Hitchhikers-Guide-to-the-Galaxy_Manual_DOS_EN_Alt-manual.pdf b/docs/The-Hitchhikers-Guide-to-the-Galaxy_Manual_DOS_EN_Alt-manual.pdf new file mode 100644 index 0000000..3ccf0dc Binary files /dev/null and b/docs/The-Hitchhikers-Guide-to-the-Galaxy_Manual_DOS_EN_Alt-manual.pdf differ diff --git a/docs/The-Hitchhikers-Guide-to-the-Galaxy_Map_DOS_EN_Maps/map-1-2.jpg b/docs/The-Hitchhikers-Guide-to-the-Galaxy_Map_DOS_EN_Maps/map-1-2.jpg new file mode 100644 index 0000000..8ff3c77 Binary files /dev/null and b/docs/The-Hitchhikers-Guide-to-the-Galaxy_Map_DOS_EN_Maps/map-1-2.jpg differ diff --git a/docs/The-Hitchhikers-Guide-to-the-Galaxy_Map_DOS_EN_Maps/map-3.jpg b/docs/The-Hitchhikers-Guide-to-the-Galaxy_Map_DOS_EN_Maps/map-3.jpg new file mode 100644 index 0000000..8e5d601 Binary files /dev/null and b/docs/The-Hitchhikers-Guide-to-the-Galaxy_Map_DOS_EN_Maps/map-3.jpg differ diff --git a/docs/The-Hitchhikers-Guide-to-the-Galaxy_Misc_DOS_EN_Hints.pdf b/docs/The-Hitchhikers-Guide-to-the-Galaxy_Misc_DOS_EN_Hints.pdf new file mode 100644 index 0000000..bf38397 Binary files /dev/null and b/docs/The-Hitchhikers-Guide-to-the-Galaxy_Misc_DOS_EN_Hints.pdf differ diff --git a/docs/The-Hitchhikers-Guide-to-the-Galaxy_Misc_DOS_EN_Pictures-of-the-game-goodies/Game Goodies/button.jpg b/docs/The-Hitchhikers-Guide-to-the-Galaxy_Misc_DOS_EN_Pictures-of-the-game-goodies/Game Goodies/button.jpg new file mode 100644 index 0000000..02401ae Binary files /dev/null and b/docs/The-Hitchhikers-Guide-to-the-Galaxy_Misc_DOS_EN_Pictures-of-the-game-goodies/Game Goodies/button.jpg differ diff --git a/docs/The-Hitchhikers-Guide-to-the-Galaxy_Misc_DOS_EN_Pictures-of-the-game-goodies/Game Goodies/fluff.jpg b/docs/The-Hitchhikers-Guide-to-the-Galaxy_Misc_DOS_EN_Pictures-of-the-game-goodies/Game Goodies/fluff.jpg new file mode 100644 index 0000000..edc427d Binary files /dev/null and b/docs/The-Hitchhikers-Guide-to-the-Galaxy_Misc_DOS_EN_Pictures-of-the-game-goodies/Game Goodies/fluff.jpg differ diff --git a/docs/The-Hitchhikers-Guide-to-the-Galaxy_Misc_DOS_EN_Pictures-of-the-game-goodies/Game Goodies/hhgtg-alienorder.jpg b/docs/The-Hitchhikers-Guide-to-the-Galaxy_Misc_DOS_EN_Pictures-of-the-game-goodies/Game Goodies/hhgtg-alienorder.jpg new file mode 100644 index 0000000..1ca78a6 Binary files /dev/null and b/docs/The-Hitchhikers-Guide-to-the-Galaxy_Misc_DOS_EN_Pictures-of-the-game-goodies/Game Goodies/hhgtg-alienorder.jpg differ diff --git a/docs/The-Hitchhikers-Guide-to-the-Galaxy_Misc_DOS_EN_Pictures-of-the-game-goodies/Game Goodies/hhgtg-englishorder.jpg b/docs/The-Hitchhikers-Guide-to-the-Galaxy_Misc_DOS_EN_Pictures-of-the-game-goodies/Game Goodies/hhgtg-englishorder.jpg new file mode 100644 index 0000000..47ca7ff Binary files /dev/null and b/docs/The-Hitchhikers-Guide-to-the-Galaxy_Misc_DOS_EN_Pictures-of-the-game-goodies/Game Goodies/hhgtg-englishorder.jpg differ diff --git a/docs/The-Hitchhikers-Guide-to-the-Galaxy_Misc_DOS_EN_Pictures-of-the-game-goodies/Game Goodies/space-fleet.jpg b/docs/The-Hitchhikers-Guide-to-the-Galaxy_Misc_DOS_EN_Pictures-of-the-game-goodies/Game Goodies/space-fleet.jpg new file mode 100644 index 0000000..a09e79f Binary files /dev/null and b/docs/The-Hitchhikers-Guide-to-the-Galaxy_Misc_DOS_EN_Pictures-of-the-game-goodies/Game Goodies/space-fleet.jpg differ diff --git a/docs/The-Hitchhikers-Guide-to-the-Galaxy_Misc_DOS_EN_Pictures-of-the-game-goodies/Game Goodies/sunglasses.jpg b/docs/The-Hitchhikers-Guide-to-the-Galaxy_Misc_DOS_EN_Pictures-of-the-game-goodies/Game Goodies/sunglasses.jpg new file mode 100644 index 0000000..312dbd8 Binary files /dev/null and b/docs/The-Hitchhikers-Guide-to-the-Galaxy_Misc_DOS_EN_Pictures-of-the-game-goodies/Game Goodies/sunglasses.jpg differ diff --git a/docs/The-Hitchhikers-Guide-to-the-Galaxy_Misc_DOS_EN_Registration-Card.pdf b/docs/The-Hitchhikers-Guide-to-the-Galaxy_Misc_DOS_EN_Registration-Card.pdf new file mode 100644 index 0000000..310fac3 Binary files /dev/null and b/docs/The-Hitchhikers-Guide-to-the-Galaxy_Misc_DOS_EN_Registration-Card.pdf differ diff --git a/docs/hitchhiker-r60.zip b/docs/hitchhiker-r60.zip new file mode 100644 index 0000000..e9bb307 Binary files /dev/null and b/docs/hitchhiker-r60.zip differ diff --git a/docs/hitchhikers-guide-to-the-galaxy/HITCHHIK.DAT b/docs/hitchhikers-guide-to-the-galaxy/HITCHHIK.DAT new file mode 100644 index 0000000..95eeecc Binary files /dev/null and b/docs/hitchhikers-guide-to-the-galaxy/HITCHHIK.DAT differ diff --git a/docs/hitchhikers-guide-to-the-galaxy/HITCHHIK.EXE b/docs/hitchhikers-guide-to-the-galaxy/HITCHHIK.EXE new file mode 100644 index 0000000..2608ca0 Binary files /dev/null and b/docs/hitchhikers-guide-to-the-galaxy/HITCHHIK.EXE differ diff --git a/earth.zil b/earth.zil new file mode 100644 index 0000000..fed0ce1 --- /dev/null +++ b/earth.zil @@ -0,0 +1,2454 @@ +"EARTH for + THE HITCHHIKER'S GUIDE TO THE GALAXY + (c) Copyright 1984 Infocom, Inc. All Rights Reserved." + + + +> + ) + ( + + ) + ( + ) + (T + )>) + ( + + ) + ( + ) + (T + )>) + ( + + ,IN-FRONT-FLAG> + + ) + ( + ,HOUSE-DEMOLISHED> + ) + ( ;"since DESC is YOUR HOME" + )>> + + + + + + ) + (T + + )>> + + + + + + ) + (T + )>> + + + + + > + ) + (> + ,HEADACHE> + ) + (T + )> + > + +> + + + +> + + + + + > + ) + ( + >> + + + ) + (T + )> + ) + ( + ) + ( + )>> + + + + + + + )> + )>> + +> + + + ) + (,HEADACHE + + ) + ( + ) + (T + )> + + ,FRONT-PORCH> + + + + + + + ) + (T + + + + )> + )>) + ( + )>> + + + + + + + + ) + (T + + )>> + + + +)) + + + + > + >> + + )> + ) + ( + > + + + ) + ( + > + + + ) + ( + )>) + (.RARG + ) + ( + ,HEADACHE + ,BED>> + + > + ) + ( + + ) + ( + > + )>> + + + + + + + + )>> + + + + + >> + ) + ( + + + ) + (T + )> + ) + (T + )> + )> + ) + ( + + ,HEADACHE> + + + + ) + ( + ,SLEEVE-TIED> + ) + ( + + )>> + + + +> + ) + ( + + ) + ( + + + ) + (,SLEEVE-TIED + ) + (T + + )>) + ( + > + ) + (T + )>)>> + + + > + > + + + + + ) + ( + >> + + ) + ( + )>> + +>>> + > + + > + + + + > + )> + + ) + ( + + > + ) + (T + )> + > + + + + + + ;"SWALLOW is synonym of DRINK" + + + + > + > + )>> + + + + + + + + + ,FRONT-OF-HOUSE) + (T + + > + + )>> + +