Z-machine: Difference between revisions

From Wikipedia, the free encyclopedia
Jump to navigation Jump to search
imported>SchlurcherBot
m Bot: http → https
 
imported>Dgpop
See also: copyediting
 
Line 1: Line 1:
{{Short description|Virtual machine for interactive fiction games}}
{{Short description|Virtual machine for interactive fiction games}}
{{about|the Infocom virtual machine|the x-ray generator informally known as the "Z machine"|Z Pulsed Power Facility|the IBM mainframe architecture|IBM Z}}
{{about|the Infocom virtual machine|the x-ray generator informally known as the "Z machine"|Z Pulsed Power Facility|the IBM mainframe architecture|IBM Z|operating signals used in radio communication|Z code|intermediate language used in ALGOL 68C |ZCODE}}
{{refimprove|date=December 2009}}


{{Infobox CPU architecture
{{Infobox CPU architecture
Line 40: Line 39:
To complement the Z-machine, Infocom developed the high-level [[computer language]] Zork Implementation Language (ZIL) by streamlining MDL,<ref name=CrCo-1980>{{cite magazine |url=https://archive.org/details/creativecomputing-1980-07/page/n81/mode/2up |title=How to Fit a Large Program Into a Small Machine or How to fit the Great Underground Empire on your desk-top |first1=Marc S. |last1=Blank |first2=S. W. |last2=Galley |date=July 1980 |magazine=Creative Computing |pages=80–87 |access-date=7 January 2025}}</ref> and the Z-language Interpreter Program (ZIP), which compiles 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.<ref name=Infocom-story/>{{rp|12–13}} ZIP consists of a [[compiler]] (ZILCH, short for ZIL Compiler Hack) and an [[Assembly language#assembler|assembler]] (ZAP, the Z-machine Assembler Program).<ref>{{cite web |url=https://eblong.com/infocom/ |title=The Obsessively Complete INFOCOM Catalog |first=Andrew |last=Plotkin |website=eblong.com |access-date=3 January 2025}}</ref>
To complement the Z-machine, Infocom developed the high-level [[computer language]] Zork Implementation Language (ZIL) by streamlining MDL,<ref name=CrCo-1980>{{cite magazine |url=https://archive.org/details/creativecomputing-1980-07/page/n81/mode/2up |title=How to Fit a Large Program Into a Small Machine or How to fit the Great Underground Empire on your desk-top |first1=Marc S. |last1=Blank |first2=S. W. |last2=Galley |date=July 1980 |magazine=Creative Computing |pages=80–87 |access-date=7 January 2025}}</ref> and the Z-language Interpreter Program (ZIP), which compiles 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.<ref name=Infocom-story/>{{rp|12–13}} ZIP consists of a [[compiler]] (ZILCH, short for ZIL Compiler Hack) and an [[Assembly language#assembler|assembler]] (ZAP, the Z-machine Assembler Program).<ref>{{cite web |url=https://eblong.com/infocom/ |title=The Obsessively Complete INFOCOM Catalog |first=Andrew |last=Plotkin |website=eblong.com |access-date=3 January 2025}}</ref>


ZILCH has never been released, although documentation of ZIL still exists, and an open-source replacement "ZILF"<ref name="ZILF">{{cite web |url=http://zilf.io/|title=ZILF|first=Jesse|last=McGrew|website=zilf.io|access-date=22 November 2020}}</ref> 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".<ref name = "CGW">{{cite magazine |date = September 1989| issue=63 | magazine = [[Computer Gaming World]] | title = Inside the Industry: Infocom's West Coast Move Stirs Controversy | pages = 10 | url=https://archive.org/details/Computer_Gaming_World_Issue_63/page/n9/mode/1up}}</ref>
ZILCH has never been released, although documentation of ZIL still exists, and an open-source replacement "ZILF"<ref name="ZILF">{{cite web |url=https://foss.heptapod.net/zilf/zilf|title=ZILF|first=Tara|last=McGrew|website=foss.heptapod.net|access-date=22 August 2025}}</ref> 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".<ref name = "CGW">{{cite magazine |date = September 1989| issue=63 | magazine = [[Computer Gaming World]] | title = Inside the Industry: Infocom's West Coast Move Stirs Controversy | pages = 10 | url=https://archive.org/details/Computer_Gaming_World_Issue_63/page/n9/mode/1up}}</ref>


===Graham Nelson and ''Inform''===
===Graham Nelson and ''Inform''===
Line 49: Line 48:
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.
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 file format|Quetzal]]" savefile format.<ref name="standard">{{cite web|title=Inform - ZMachine - Standards|url=https://inform-fiction.org/zmachine/standards/index.html|website=inform-fiction.org|access-date=26 March 2018}}</ref> 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.<ref>{{cite web |title=Glk, Glulx, and Blorb Specifications |url=https://github.com/iftechfoundation/ifarchive-if-specs |publisher=Interactive Fiction Technology Foundation |date=16 November 2022}}</ref>
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 and the "[[Quetzal file format|Quetzal]]" savefile format.<ref name="standard">{{cite web|title=Inform - ZMachine - Standards|url=https://inform-fiction.org/zmachine/standards/index.html|website=inform-fiction.org|access-date=26 March 2018}}</ref> 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.<ref>{{cite web |title=Glk, Glulx, and Blorb Specifications |url=https://github.com/iftechfoundation/ifarchive-if-specs |publisher=Interactive Fiction Technology Foundation |date=16 November 2022}}</ref>


==ZIL (Zork Implementation Language)==
==ZIL (Zork Implementation Language)==
Line 88: Line 87:
[[File:Zork on Frotz on iPhone.jpg|right|thumb|An implementation of Frotz running on an [[iPhone]], playing the [[MIT]] version of ''[[Zork]]''.]][[Interpreter (computing)|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 {{nowrap|[[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".<ref name="inform-interpreters">{{cite web |url=https://www.inform-fiction.org/zmachine/interpreters.html |first=Graham |last=Nelson |title=About Interpreters |work=Inform website |access-date=2009-11-07}}</ref>
[[File:Zork on Frotz on iPhone.jpg|right|thumb|An implementation of Frotz running on an [[iPhone]], playing the [[MIT]] version of ''[[Zork]]''.]][[Interpreter (computing)|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 {{nowrap|[[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".<ref name="inform-interpreters">{{cite web |url=https://www.inform-fiction.org/zmachine/interpreters.html |first=Graham |last=Nelson |title=About Interpreters |work=Inform website |access-date=2009-11-07}}</ref>


Popular interpreters include Nitfol and Frotz. Nitfol makes use of the [[Glk (software)|Glk]] [[application programming interface|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 file format|Quetzal]] save format. [[executable|Binary]] files are available for several different [[operating systems]], including the [[classic Mac OS]], [[Unix-like]] systems, [[DOS]], and [[Microsoft Windows|Windows]].<ref name="if-archive-infocom-interpreters-nitfol">{{cite web |url=https://www.ifarchive.org/indexes/if-archiveXinfocomXinterpretersXnitfol.html |title=if-archive/infocom/interpreters/nitfol |access-date=2016-10-29}}</ref>
Popular interpreters include Nitfol and Frotz. Nitfol makes use of the [[Glk (software)|Glk]] [[application programming interface|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 file format|Quetzal]] save format. [[executable|Binary]] files are available for several different [[operating systems]], including [[classic Mac OS]], [[Unix-like]] systems, [[Windows]].<ref name="if-archive-infocom-interpreters-nitfol">{{cite web |url=https://www.ifarchive.org/indexes/if-archiveXinfocomXinterpretersXnitfol.html |title=if-archive/infocom/interpreters/nitfol |access-date=2016-10-29}}</ref>


Frotz was written in [[C (programming language)|C]] by Stefan Jokisch in 1995 for DOS. Over time it was ported to other platforms, such as [[Unix-like]] systems,<ref name="frotz-history">{{cite web |url=https://gitlab.com/DavidGriffith/frotz/blob/master/README |title=Frotz README file on Gitlab |access-date=2019-02-19}}</ref> [[RISC OS]],<ref>{{cite web|url=http://www.zen22994.zen.co.uk/musus/frotz/|title=The RISC OS Frotz Home Page|date=1999-09-18|archive-url=https://web.archive.org/web/20211015144705/http://www.zen22994.zen.co.uk/musus/frotz/|archive-date=2021-10-15}}</ref> and [[iOS]].<ref>{{cite web|url=https://apps.apple.com/us/app/frotz/id287653015|title=Frotz on the App Store|website=App Store}}</ref> 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]] [[Internet bot|bot]] is wrapped around a version of Frotz with the minimum [[Input/output|I/O]] functionality creating a bot with which one can play most Z-machine games using an instant messaging client.<ref name="frotz-dumb">{{cite web |url=https://gitlab.com/DavidGriffith/frotz/blob/master/DUMB |title=Frotz DUMB file on Gitlab |access-date=2019-02-19}}</ref>
Frotz was written in [[C (programming language)|C]] by Stefan Jokisch in 1995 for DOS. Over time it was ported to other platforms, such as [[Unix-like]] systems,<ref name="frotz-history">{{cite web |url=https://gitlab.com/DavidGriffith/frotz/blob/master/README |title=Frotz README file on Gitlab |access-date=2019-02-19}}</ref> [[RISC OS]],<ref>{{cite web|url=http://www.zen22994.zen.co.uk/musus/frotz/|title=The RISC OS Frotz Home Page|date=1999-09-18|archive-url=https://web.archive.org/web/20211015144705/http://www.zen22994.zen.co.uk/musus/frotz/|archive-date=2021-10-15}}</ref> and [[iOS]].<ref>{{cite web|url=https://apps.apple.com/us/app/frotz/id287653015|title=Frotz on the App Store|website=App Store}}</ref> 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]] [[Internet bot|bot]] is wrapped around a version of Frotz with the minimum [[Input/output|I/O]] functionality creating a bot with which one can play most Z-machine games using an instant messaging client.<ref name="frotz-dumb">{{cite web |url=https://gitlab.com/DavidGriffith/frotz/blob/master/DUMB |title=Frotz DUMB file on Gitlab |access-date=2019-02-19}}</ref>


Another popular client for [[macOS]] and other [[Unix-like]] systems is Zoom.<ref name="logicalshift-zoom">{{cite web |url=http://www.logicalshift.co.uk/unix/zoom/ |title=Logical Shift Zoom |access-date=2016-10-29}}</ref> It supports the same [[Quetzal file format|Quetzal]] save-format, but the packaging of the file-structure is different.
Another popular client for [[macOS]] and other Unix-like systems is Zoom.<ref name="logicalshift-zoom">{{cite web |url=http://www.logicalshift.co.uk/unix/zoom/ |title=Logical Shift Zoom |access-date=2016-10-29}}</ref> It supports the same [[Quetzal file format|Quetzal]] save-format, but the packaging of the file-structure is different.


==See also==
==See also==
*[[Glulx]] – Similar to the Z-machine, but relieves several legacy limitations
*[[Glulx]] – Similar to the Z-machine, but relieves several limitations
*[[Inform]] – A computer language that can produce Z-machine programs
*[[Inform]] – A programming language that can produce Z-machine programs
*[[SCUMM]] – '''S'''cript '''C'''reation '''U'''tility for [[Maniac Mansion|'''M'''aniac '''M'''ansion]] by [[LucasArts]], a graphical system similar to Z-machine
*[[SCUMM]] – by [[LucasArts]], a graphical system similar to Z-machine
*[[TADS]] – Like Glulx, made to address some of its limitations
*[[TADS]] – Made to address some of the Z-machine's limitations


== References ==
== References ==

Latest revision as of 15:50, 29 October 2025

Template:Short description Script error: No such module "about".

Template:Infobox CPU architecture

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.

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]Template:Rp 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]Template:Rp Eventually, the developers split Zork into two games for personal computers.[4]

The compression required to run Zork from floppy disks 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]Template:Rp The resulting Z-machine used an object tree structure for in-game items, locations, characters, and weapons.[3]Template:Rp 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 compiles 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]Template:Rp 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

Script error: No such module "Labelled list hatnote". 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 and the "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]

<OBJECT LANTERN                 #_Defines the LANTERN object
  (LOC LIVING-ROOM)             #_Defines the initial object location
  (SYNONYM LAMP LANTERN LIGHT)  #_Defines synonyms that can be used instead of LANTERN
  (ADJECTIVE BRASS)             #_Optional adjective to distinguish this lantern from other lanterns
  (DESC "brass lantern")        #_Short description in inventory list
  (FLAGS TAKEBIT LIGHTBIT)      #_What is this object capable of? It can be TAKEN. It provides LIGHT.
  (ACTION LANTERN-F)            #_Subroutine which defines special actions with this object
  (FDESC "A battery-powered lantern is on the trophy case.")  #_Description during first encounter
  (LDESC "There is a brass lantern (battery-powered) here.")  #_Later description in other locations
  (SIZE 15)>                    #_Defines weight to limit inventory capacity

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."
         OSIZE 15
         OLINT [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

File: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 classic Mac OS, Unix-like systems, 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

  • Glulx – Similar to the Z-machine, but relieves several limitations
  • Inform – A programming language that can produce Z-machine programs
  • SCUMM – by LucasArts, a graphical system similar to Z-machine
  • TADS – Made to address some of the Z-machine's limitations

References

Template:Reflist

External links

Script error: No such module "Navbox". Template:Video game engines

  1. Script error: No such module "citation/CS1".
  2. Script error: No such module "Citation/CS1".
  3. a b c d e Script error: No such module "citation/CS1".
  4. Template:Cite magazine
  5. a b Template:Cite magazine
  6. Script error: No such module "citation/CS1".
  7. Script error: No such module "citation/CS1".
  8. Template:Cite magazine
  9. Script error: No such module "citation/CS1".
  10. Script error: No such module "citation/CS1".
  11. Script error: No such module "citation/CS1".
  12. Script error: No such module "citation/CS1".
  13. Script error: No such module "citation/CS1".
  14. Script error: No such module "citation/CS1".
  15. Script error: No such module "citation/CS1".
  16. Script error: No such module "citation/CS1".
  17. Script error: No such module "citation/CS1".
  18. Script error: No such module "citation/CS1".
  19. Script error: No such module "citation/CS1".