HTML/Z-Machine interpreter? (HHG2G)

Does anyone know how Infocom’s the Hitch-Hiker’s Guide to the Galaxy was ported to the BBC website? It says ‘using HTML5’ but that can’t be it. How did they get the images, and the colors, and all the stuff? And the interpreter? Some of this has to relate to ZIL but some doesn’t. Any help?

1 Like

They have probably analyzed the game file and made a list of memory locations to watch, e.g. player location, each object’s location, etc, and programmed the interpreter to use this information to display images etc.

There are tools to assist in analyzing a Z-code file, such as Ztools, but you can also just open the story file in a hex editor and the follow the Z-machine standards document to understand the contents.

2 Likes

Allen Garvin has done some of this analysis work. See this file: reform-conf/hitch-851108-r059-z3.reform at master · allengarvin/reform-conf · GitHub

I confess I don’t know everything about how that file is organized. Documentation: https://21jswvwz8b.unbox.ifarchive.org/21jswvwz8b/reform_6_070903/reform.html

1 Like

Anyway, the basic principle is actually the same thing I did (in Glulx) for the Hadean Lands app (with dynamic map and journal). The interpreter watches various locations in memory for important state changes (like the player entering a room, or an object gaining a particular attribute). Since the interpreter is written in Javascript and already manages the web page, it can display different images at will.

1 Like

It helps that in ZIL games, as a general rule, the first three globals will always be the location, score, and turn count. In early versions of the Z-machine, the status line was always constructed out of these three variables. So while some games tweaked this in various ways (like Suspended putting the current robot in the first global so it would display in the status line, or Deadline using the second and third globals to show a clock with hours and minutes), ZIL’s default was always to put those three globals first.

Later versions of the Z-machine let the game code handle the status line, but I believe ZIL still put those globals first by default.

3 Likes