Z-machine

Last updated
Z-machine
Designer Infocom
Bits16
Introduced1979
Version1.1 (2014)
Design CISC
Endianness Big
OpenYes

The Z-machine is a virtual machine that was developed by Joel Berez and Marc Blank in 1979 and used by Infocom for its text adventure games. Infocom compiled game code to files containing Z-machine instructions (called story files or Z-code files) and could therefore port its text adventures to a new platform simply by writing a Z-machine implementation for that platform. With the large number of incompatible home computer systems in use at the time, this was an important advantage over using native code or developing a compiler for each system.

Contents

History and design

Nomenclature and conventions

The "Z" of Z-machine stands for Zork , Infocom's first adventure game. Infocom used file extensions of .dat (Data) and .zip (ZIP = Z-machine Interpreter Program), but the latter clashed with the widespread use of .zip for PKZIP-compatible archive files starting in the 1990s, after Activision had closed Infocom.

Infocom produced six versions of the Z-machine. Files using versions 1 and 2 are very rare. Only two version 1 files are known to have been released by Infocom and only two of version 2. Version 3 covers the majority of Infocom's released games. Later versions had more capabilities, culminating in some graphic support in version 6.

The modern convention for Z-code files usually have names ending in .z1, .z2, .z3, .z4, .z5, .z6, .z7, or .z8, where the number is the version number of the Z-machine on which the file is intended to be run, as given by the first byte of the story file. [1] As previously noted, the Infocom games used the equivalent of .z1 through .z6; .z7 and .z8 were proposed and adopted after Infocom had shut down.

Before Z-machine

The MDL programming language was derived from Lisp at the Massachusetts Institute of Technology by the Dynamic Modeling group of the Laboratory for Computer Science (LCS) in the 1970s; inspired by Colossal Cave Adventure (1977), members of that group went on to write Zork in MDL, completing the initial version two weeks later. [2] [3] :5–6 Like Adventure, Zork was programmed for the DEC PDP-10; the finished version occupies 1 MB of MDL code and requires 512 KB of RAM to run. Because contemporary home computers did not have these resources, considerable effort was needed to port the game. [3] :11 Eventually, the developers split Zork into two games for personal computers. [4]

The compression required to run Zork from floppy discs with approximately 80 KB of storage seemed like an insurmountable barrier to Blank. Berez realized that UCSD Pascal used a virtual machine (VM) model to generate executable files that could be readily ported across platforms, and together with Blank, they devised requirements for a lightweight VM optimized for text adventure games, which would retrieve data and execute instructions as needed from storage to compensate for the relatively small RAM sizes in typical microcomputers. [3] :11 The resulting Z-machine used an object tree structure for in-game items, locations, characters, and weapons. [3] :11 For comparison, the Z-machine parser occupies 3  kB of storage, while the original PDP-10 parser occupies 10  Kwords (36-bit). [5]

ZIL and ZIP, ZILCH and ZAP

To complement the Z-machine, Infocom developed the high-level computer language Zork Implementation Language (ZIL) by streamlining MDL, [5] and the Z-language Interpreter Program (ZIP), which complies ZIL into Z-machine instructions in a two-stage process; this made text adventure development platform-independent and enabled porting to different systems simply by writing an appropriate Z-machine interpreter. [3] :12–13 ZIP consists of a compiler (ZILCH, short for ZIL Compiler Hack) and an assembler (ZAP, the Z-machine Assembler Program). [6]

ZILCH has never been released, although documentation of ZIL still exists, and an open-source replacement "ZILF" [7] has been written. After Mediagenic moved Infocom to California in 1989, Computer Gaming World stated that "ZIL ... is functionally dead", and reported rumors of a "completely new parser that may never be used". [8]

Graham Nelson and Inform

In May 1993, Graham Nelson released the first version of his Inform compiler, which also generates Z-machine story files as its output, even though the Inform source language is quite different from ZIL.

Inform has become popular in the interactive fiction community. A large proportion of interactive fiction is in the form of Z-machine story files. Demand for the ability to create larger game files led Nelson to specify versions 7 and 8 of the Z-machine, though version 7 is rarely used. Because of the way addresses are handled, a version 3 story file can be up to 128K in length, a version 5 story can be up to 256K in length, and a version 8 story can be up to 512k in length. Though these sizes may seem small by today's computing standards, for text-only adventures, these are large enough for elaborate games.

During the 1990s, Graham Nelson drew up a Z-Machine Standard based on detailed studies of the existing Infocom files. The standard also includes extensions used by his newer versions, as well as links to the "Blorb" resource format used by Infocom, and a "Quetzal" savefile format. [9] In 2006, Nelson expanded Z-machine to the 32-bit Glulx format for Inform 7. The Interactive Fiction Technology Foundation, founded 2016, manages all these standards. [10]

ZIL (Zork Implementation Language)

The ZIL is based on MDL from MIT. Here is the definition of Zork I's brass lantern in ZIL, with added comments to illustrate the meaning of each line: [11]

<OBJECTLANTERN#_DefinestheLANTERNobject(LOCLIVING-ROOM)#_Definestheinitialobjectlocation(SYNONYMLAMPLANTERNLIGHT)#_DefinessynonymsthatcanbeusedinsteadofLANTERN(ADJECTIVEBRASS)#_Optionaladjectivetodistinguishthislanternfromotherlanterns(DESC"brass lantern")#_Shortdescriptionininventorylist(FLAGSTAKEBITLIGHTBIT)#_Whatisthisobjectcapableof?ItcanbeTAKEN.ItprovidesLIGHT.(ACTIONLANTERN-F)#_Subroutinewhichdefinesspecialactionswiththisobject(FDESC"A battery-powered lantern is on the trophy case.")#_Descriptionduringfirst encounter(LDESC"There is a brass lantern (battery-powered) here.")#_Laterdescriptioninotherlocations(SIZE15)> #_Definesweighttolimitinventorycapacity

The equivalent object in MDL is defined as:

<OBJECT["LAMP""LANTE""LIGHT"]["BRASS"]"lamp"<+,OVISON,TAKEBIT,LIGHTBIT>LANTERN()(ODESC0"A battery-powered brass lantern is on the trophy case."ODESC1"There is a brass lantern (battery-powered) here."OSIZE15OLINT[0>])>

A more complex example involving combat, along with its MDL Zork equivalent, is presented in a 2019 blog post by Andrew Plotkin. Notably, the Z-machine has no support for garbage collection and ZIL has no concept of Lisp's list system. [12]

Interpreters

An implementation of Frotz running on an iPhone, playing the MIT version of Zork. Zork on Frotz on iPhone.jpg
An implementation of Frotz running on an iPhone, playing the MIT version of Zork .

Interpreters for Z-code files are available on a wide variety of platforms. The Inform website lists links to freely available interpreters for 15 desktop operating systems (including 8-bit microcomputers from the 1980s such as the Apple II, TRS-80, and ZX Spectrum , and grouping "Unix" and "Windows" as one each), 10 mobile operating systems (including Palm OS and the Game Boy), and four interpreter platforms (Emacs, Java, JavaScript, and Scratch). According to Nelson, it is "possibly the most portable virtual machine ever created". [13]

Popular interpreters include Nitfol and Frotz. Nitfol makes use of the Glk API, and supports versions 1 through 8 of the Z-machine, including the version 6 graphical Z-machine. Save files are stored in the standard Quetzal save format. Binary files are available for several different operating systems, including the classic Mac OS, Unix-like systems, DOS, and Windows. [14]

Frotz was written in C by Stefan Jokisch in 1995 for DOS. Over time it was ported to other platforms, such as Unix-like systems, [15] RISC OS, [16] and iOS. [17] Sound effects and graphics were supported to varying degrees. By 2002, development stalled and the program was picked up by David Griffith. The code base was split between virtual machine and user interface portions in such a way that the virtual machine became independent from any user interface. This allowed more variety in porting Frotz. One of the stranger ports is also one of the simplest: an instant messaging bot is wrapped around a version of Frotz with the minimum I/O functionality creating a bot with which one can play most Z-machine games using an instant messaging client. [18]

Another popular client for macOS and other Unix-like systems is Zoom. [19] It supports the same Quetzal save-format, but the packaging of the file-structure is different.

See also

Related Research Articles

Infocom was an American software company based in Cambridge, Massachusetts, that produced numerous works of interactive fiction. They also produced a business application, a relational database called Cornerstone.

Interactive fiction (IF) is software simulating environments in which players use text commands to control characters and influence the environment. Works in this form can be understood as literary narratives, either in the form of Interactive narratives or Interactive narrations. These works can also be understood as a form of video game, either in the form of an adventure game or role-playing game. In common usage, the term refers to text adventures, a type of adventure game where the entire interface can be "text-only", however, graphical text adventure games, where the text is accompanied by graphics still fall under the text adventure category if the main way to interact with the game is by typing text. Some users of the term distinguish between interactive fiction, known as "Puzzle-free", that focuses on narrative, and "text adventures" that focus on puzzles.

<i>Zork</i> 1977 video game

Zork is a text adventure game first released in 1977 by developers Tim Anderson, Marc Blank, Bruce Daniels, and Dave Lebling for the PDP-10 mainframe computer. The original developers and others, as the company Infocom, expanded and split the game into three titles—Zork I: The Great Underground Empire, Zork II: The Wizard of Frobozz, and Zork III: The Dungeon Master—which were released commercially for a range of personal computers beginning in 1980. In Zork, the player explores the abandoned Great Underground Empire in search of treasure. The player moves between the game's hundreds of locations and interacts with objects by typing commands in natural language that the game interprets. The program acts as a narrator, describing the player's location and the results of the player's commands. It has been described as the most famous piece of interactive fiction.

<span class="mw-page-title-main">SCUMM</span> Game engine developed by LucasArts

Script Creation Utility for Maniac Mansion (SCUMM) is a video game engine developed at Lucasfilm Games, later renamed LucasArts, to ease development on their graphic adventure game Maniac Mansion (1987). It was subsequently used as the engine for later LucasArts adventure games and Humongous Entertainment games.

Inform is a programming language and design system for interactive fiction originally created in 1993 by Graham Nelson. Inform can generate programs designed for the Z-code or Glulx virtual machines. Versions 1 through 5 were released between 1993 and 1996. Around 1996, Nelson rewrote Inform from first principles to create version 6. Over the following decade, version 6 became reasonably stable and a popular language for writing interactive fiction. In 2006, Nelson released Inform 7, a completely new language based on principles of natural language and a new set of tools based around a book-publishing metaphor.

Text Adventure Development System (TADS) is a prototype-based domain-specific programming language and set of standard libraries for creating interactive fiction (IF) games.

Glulx is a 32-bit portable virtual machine intended for writing and playing interactive fiction. It was designed by Andrew Plotkin to relieve some of the restrictions in the venerable Z-machine format. For example, because the Z-machine uses 16-bit integers its RAM is limited to 64KB, while Glulx natively supports 32-bit integers and has a 32-bit address space, allowing gigabytes of memory. Glulx programs typically use the Glk API for input and output. In recent years Glulx has overtaken the Z-machine in terms of published works in each format.

<span class="mw-page-title-main">Phoenix (computer)</span> IBM mainframe computer

Phoenix was an IBM mainframe computer at Cambridge University's Computer Laboratory. "Phoenix/MVS" was also the name of the computer's operating system, written in-house by Computer Laboratory members. Its DNS hostname was phx.cam.ac.uk.

MDL is a programming language, a descendant of the language Lisp. Its initial purpose was to provide high-level programming language support for the Dynamic Modeling Group at Massachusetts Institute of Technology's (MIT) Project MAC. It was developed in 1971 on a PDP-10 running ITS and later ran on TENEX, TOPS-20, BSD, and AEGIS.

<i>The Lost Treasures of Infocom</i> 1991 video game

The Lost Treasures of Infocom is a 1991 compilation of 20 previously-released interactive fiction games developed by Infocom. It was published by Activision for MS-DOS, Macintosh, Amiga, and Apple IIGS versions. It was later re-released on CD-ROM, and in 2012 on iOS.

<i>Zork: Grand Inquisitor</i> 1997 video game

Zork: Grand Inquisitor is a graphic adventure game developed and published by Activision, and released for Windows in 1997; a second edition for Macintosh was released in 2001. The game is the twelfth in the Zork series, and builds upon both this and the Enchanter series of interactive fiction video games originally released by Infocom. The game's story focuses on the efforts of a salesperson who becomes involved in restoring magic to Zork while thwarting the plots of a tyrannical figure seeking to stop this. The game features the performances of Erick Avari, Michael McKean, Amy D. Jacobson, Marty Ingels, Earl Boen, Jordana Capra, Dirk Benedict, David Lander and Rip Taylor.

<span class="mw-page-title-main">Level 9 Computing</span> Video game developer and publisher

Level 9 was a British developer of computer software, active between 1981 and 1991. Founded by Mike, Nicholas and Pete Austin, the company produced software for the BBC Micro, Nascom, ZX Spectrum, Commodore 64, Oric, Atari 8-bit computers, Camputers Lynx, RML 380Z, Amstrad CPC, MSX, Amiga, Apple II, Memotech MTX, and Enterprise platforms and is best known for its successful text adventure games until a general decline in the text adventure market forced their closure in June 1991.

Tim Anderson is an American computer programmer best known for co-creating the adventure game Zork, one of the first works of interactive fiction and an early descendant of ADVENT.

<i>Enchanter</i> (video game) 1983 video game

Enchanter is an interactive fiction game written by Marc Blank and Dave Lebling and published by Infocom in 1983. The first fantasy game published by Infocom after the Zork trilogy, it was originally intended to be Zork IV. The game has a parser that understands over 700 words, making it the most advanced interactive fiction game of its time. It was Infocom's ninth game.

<i>Beyond Zork</i> 1987 video game

Beyond Zork: The Coconut of Quendor is an interactive fiction video game written by Brian Moriarty and released by Infocom in 1987. It was one of the last games in the Zork series developed by Infocom. It signified a notable departure from the standard format of Infocom's earlier games which relied purely on text and puzzle-solving: among other features, Beyond Zork incorporated a crude on-screen map, the use of character statistics and levels, and RPG combat elements.

<i>The Witness</i> (1983 video game) 1983 video game

The Witness is an interactive fiction video game published by Infocom in 1983. Like Infocom's earlier title Deadline, it is a murder mystery. The Witness was written in the ZIL language for the Z-machine, which allowed it to be released simultaneously on many systems. It is Infocom's seventh game.

<span class="mw-page-title-main">Marc Blank</span> American game developer

Marc Blank is an American game developer and software engineer. He is best known as part of the team that created one of the first commercially successful text adventure computer games, Zork. In 2009, he was chosen by IGN as one of the top 100 game creators of all time.

<i>Zork Anthology</i> 1994 video game

The Zork Anthology is a text adventure video game compilation developed by Infocom and published in 1994 by Activision for the PC. A version compatible with modern computers was published by digital distribution platforms GOG.com and Steam in 2011 and 2017 respectively.

<span class="mw-page-title-main">Command-line interface</span> Computer interface that uses text

A command-line interface (CLI) is a means of interacting with a computer program by inputting lines of text called command lines. Command-line interfaces emerged in the mid-1960s, on computer terminals, as an interactive and more user-friendly alternative to the non-interactive mode available with punched cards.

References

  1. "The Z-Machine Standards Document". inform-fiction.org. Retrieved 26 March 2018.
  2. Lebling, P. David; Blank, Marc S.; Anderson, Timothy A. (April 1979). "Zork: A Computerized Fantasy Simulation Game". Computer. 12. IEEE Computer Society: 51–59. doi:10.1109/MC.1979.1658697.
  3. 1 2 3 4 5 Briceno, Hector; Chao, Wesley; Glenn, Andrew; Hu, Stanley; Krishnamurthy, Ashwin; Tsuchida, Bruce (December 15, 2000). "Down From the Top of Its Game: The Story of Infocom, Inc" (PDF). MIT Course 6.933J/STS.420J (Structure of Engineering Revolutions). Retrieved 3 January 2025.
  4. Lebling, P. David (December 1980). "Zork and the Future of Computerized Fantasy Simulations". BYTE. pp. 172–182.
  5. 1 2 Blank, Marc S.; Galley, S. W. (July 1980). "How to Fit a Large Program Into a Small Machine or How to fit the Great Underground Empire on your desk-top". Creative Computing. pp. 80–87. Retrieved 7 January 2025.
  6. Plotkin, Andrew. "The Obsessively Complete INFOCOM Catalog". eblong.com. Retrieved 3 January 2025.
  7. McGrew, Jesse. "ZILF". zilf.io. Retrieved 22 November 2020.
  8. "Inside the Industry: Infocom's West Coast Move Stirs Controversy". Computer Gaming World . No. 63. September 1989. p. 10.
  9. "Inform - ZMachine - Standards". inform-fiction.org. Retrieved 26 March 2018.
  10. "Glk, Glulx, and Blorb Specifications". Interactive Fiction Technology Foundation. 16 November 2022.
  11. Maher, Jimmy (January 7, 2012). "ZIL and the Z-Machine". The Digital Antiquarian. Retrieved 3 January 2025.
  12. Plotkin, Andrew (April 17, 2019). "What is ZIL anyway?". Zarf.
  13. Nelson, Graham. "About Interpreters". Inform website. Retrieved 2009-11-07.
  14. "if-archive/infocom/interpreters/nitfol" . Retrieved 2016-10-29.
  15. "Frotz README file on Gitlab" . Retrieved 2019-02-19.
  16. "The RISC OS Frotz Home Page". 1999-09-18.
  17. "Frotz on the App Store". App Store.
  18. "Frotz DUMB file on Gitlab" . Retrieved 2019-02-19.
  19. "Logical Shift Zoom" . Retrieved 2016-10-29.