Skip to content

erkyrath/visizork2

Repository files navigation

The Visible Zorker 2: an interactive fiction visualizer

This is a web app that plays Zork 2, and simultaneously displays the code that runs Zork 2 under the hood. It allows you to explore the implementation of Zork in the same way that you explore the game world. Call it an exercise in exploratory coding.

To try the Visible Zorker 2, play it here. You can also try Zork 1. For more about the intent and origins of the project, see my blog post on the subject.

What to do

Type commands in the left pane. (If you’re not familiar with parser games, here’s a quick intro.) As the game responds, the panes on the right will display the current game state and the code that is executing.

Hit the ? button in the top right pane for more help.

Deep links

To refer to specific features of Zork from an external web site, use a link like those below. The app will launch with that item highlighted in the source pane. If a commentary item is associated with that source location, it will be displayed as well.

Deep link formats:

You can also specify any source line by filename and line number:

The contents of this repository

This repo contains quite a lot of material relating to Zork 2. Some of this is needed to run the game; some is used in the app UI; some was just useful to me in creating the app.

The gamedat directory

This contains the Zork 2 game file itself, plus a bonanza of information about how it is organized internally.

  • zork2-r48-s840904.z3: Zork 2, release 48, serial 840904. (This is the playable Z-code file.) It's the version on the Masterpieces of Infocom CD and other modern collections. For other versions, see my Obsessively Complete Infocom Catalog.
  • game-dump.txt: A disassembly listing of the game file, generated by txd from the ztools package. This shows the game functions in the form of Z-machine "assembly", plus the text of the game. But it does not have function names; everything is shown as raw addresses.
  • obj-dump.txt: A listing of the objects in the game file, generated by infodump -o (also from ztools). This shows the object tree layout, the printed names of objects, and their properties as raw numeric data.
  • dict-dump.txt: A listing of the game dictionary, generated by infodump -d. Again, this contains the flags associated with each dict word in raw numeric form.
  • zork2.reform: A text file mapping game object numbers, global variables, and other numeric values to human-readable names. This is taken from the analysis work done in 2007 by Allen Garvin, Ben Rudiak-Gould, and Ethan Dicks. (Original file here.)
  • game-info: A text file mapping game object numbers, global variables, and other numeric values to their ZIL source names. I created this in the course of building the Visible Zorker. It draws on all of the above data sources.
  • zork2-map.svg: The map image. This is an Inkscape document with a rather fussy layout.
  • commentary: A text file containing my commentary and notes on the Zork 2 source.

Note that the human-readable symbol names in zork2.reform do not match the actual ZIL source code. That work was done before the ZIL source was available, so Allen and the others just invented names that made sense. (They tried to be consistent with Inform 6 conventions, which was useful at the time but not for our purposes here.)

The game-info file is my own work, which does associate everything with its original ZIL name.

Also note that I'm using a slight modification of the ztools package, which displays output in ways that are a bit easier to parse. (We have a lot of scripts which imbibe the game-dump.txt, obj-dump.txt, dict-dump.txt files.) See my fork here.

The gamesrc directory

This contains the original ZIL source code for Zork 2.

A version of this source was publicly released in April 2019 by Jason Scott. If you look at that repository up front, you'll see zork2-r63-s860811. The version here, zork2-r48-s840904, can be found in its commit history here.

(Other versions can be found in the Catalog.)

The js directory

Javascript used in running the app. This is all generated, compiled, or minified from the contents of the visiterp/src, gamesrc, and gamedat directories.

The src/game directory

JSON data files describing Zork 2. (JSONP, really.) These are generated by pyana, and then compiled into the app.

The src/custom directory

Code specific to parsing and displaying Zork 2.

The src/visi directory

This is a symlink to visiterp/src/visi; see below. (It's convenient for compilation if all the source files are at the same depth.)

The visiterp submodule

Most of the source code involved in running and displaying the game is collected in visiterp. This is a separate repository so that it can be shared between many games.

If you find that the visiterp directory is empty, you need to fill it out:

git submodule init
git submodule update

Sorry. Submodules are a pain in the ass.

The visiterp repository provides:

The visiterp/pyana directory

Python scripts which parse the gamedat and gamesrc files and convert them into JSON data in js for the Visible Zorker to load.

Roughly, we need to parse all the ZIL source and the disassembled data, match up numeric addresses with source code names, and write it out in a format that the Javascript app can handle. We use a motley boatload of strategies to accomplish this. The game-info gives us a lot of the needed mappings. Others are based on source code order, memory address order, or whatever else works.

The visiterp/src directory

Javascript and Typescript sources for the Visible Zorker app itself.

  • src/visi: The front-end UI of the app. This is React code written in Typescript.
  • src/gnusto: The Gnusto Z-machine engine. This is a part of the Parchment IF web app. I modified Gnusto to track game activity and export it to the visi UI.
  • src/parchment: Another component of Parchment, responsible for loading the game file and launching the app.
  • src/ifvms.js: Another component of Parchment which acts as a glue layer between Gnusto and the browser display. Also a component which is responsible for the save-file format.
  • src/glkio: The GlkOte IF display library. Also a glue layer which allows Gnusto/IFVMS to use GlkOte.
  • src/lib: Low-level JS libraries used by Gnusto and GlkOte. This includes jQuery.
  • src/game: JSON data files describing the Zork game file. This includes the names and addresses of global variables, functions, objects, and everything else needed to make the game's operation visible. This folder also includes the ZIL source and the game commentary, translated into JSON form.

Yeah, there's a lot of glue layers in there. It's the usual software-engineering story. Gnusto was originally written in 2003 as a browser extension. Then it was modified into a browser application, which was turned into a web site, which was expanded to support other formats besides Z-code. Each of these steps added more layers of abstraction.

I unwound a lot of that work in creating the Visible Zorker. I wanted a simple interpreter engine, and I didn't need the web site or any of the newer formats. But there's still traces of some of the layers.

The visiterp/css directory

CSS files. Also some icon images in SVG, PNG, and animated-GIF format.

The visiterp/font directory

Open-source fonts used in the app.

Building the Visible Zorker

This repository comes with everything built. You can load index.html and play right from the repo. (Not on Github, though. You'll have to check it out first.)

If you want to modify the project, you'll need to install some stuff.

As you see above, the Visible Zorker has a lot of moving parts. Some are written in Javascript; others are Typescript, which must be compiled to Javascript. The UI is built with the React display library.

To build everything from a standing start:

npm install
npm run build

This regenerates (almost) everything in the js directory. Hopefully the result will be identical, or almost identical, to what was already there.

If you're doing dev work, you may want to load index-full.html instead of index.html. The index-full.html version uses the non-minified Javascript from the visiterp/src directory. You can edit JS files and reload index-full.html without an npm run build step, which makes for a much faster work loop.

If you edit the Typescript files (*.ts and *.tsx), you do have to recompile them, even when playing from index-full.html. You'll want the following command:

npm run buildts

This recompiles Typescript but skips the JS minification steps, which saves a lot of time.

If you want to rebuild the game data files, do:

npm run recreate-gamedata
npm run recolor-source
npm run regenerate-commentary
npm run reparse-map

There's no reason for you to do this, but I'm documenting it anyway.

Sources and acknowledgements

The Visible Zorker is built on a seriously customized version of the Parchment Z-machine interpreter by Marnanel Thurman, Atul Varma, and Dannii Willis.

Some of the files in gamedat were created by Allen Garvin, Ben Rudiak-Gould, and Ethan Dicks. See links above.

The fonts used are Courier Prime, Lato, and Libre Baskerville. The header background is copied from Infocom's Zork hint maps.

Zork itself was originally written by Tim Anderson, Marc Blank, Bruce Daniels, and Dave Lebling. The commercial versions are copyright 1981 (etc) by Infocom, then Activision, then renamed to Mediagenic, then Bobby Kotick bought it and renamed it Activision, then Vivendi bought it and merged it with Blizzard, then Microsoft consumed the lot.

Thus, the Zork 2 source code is copyright 2025 by Microsoft. As of November 2025, it is open source under the MIT license. Thanks to Microsoft for making this project completely legal!

Aside from the above, the Visible Zorker is copyright 2025-2026 by Andrew Plotkin. My work on this project is under the MIT license.

About

A web app to play Zork 2 with code inspection

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published