Spotlight › Frotz

os8088 plays Infocom games now

There is a new program on the disk called Frotz. It plays the text adventures Infocom sold in the 1980s -- Zork and its relatives -- on a processor from 1978.

the interpreter
23,722 bytes
story formats
v1 to v8
games it fetches
15
MINIZORK.Z3
A window titled MINIZORK.Z3 filling most of a black and white desktop. An inverted strip across the top of the window reads West of House on the left and Score: 0 Moves: 2 on the right. Below it the game text: MINI-ZORK I: The Great Underground Empire, a 1988 Infocom copyright line, then the description of an open field west of a white house. Two typed commands follow, open mailbox and read leaflet, each with the game's reply under it.
Mini-Zork I, running as an ordinary os8088 program. The dark strip is the status line -- where you are, and how you are doing. Everything under it is the story.

What it is

Two minutes on text adventures, the Z-machine, and what got added.

Text adventures

Before games had graphics, they had prose. The computer describes where you are, and you type what you want to do -- open mailbox, go north, take lamp. It writes back what happened. That is the whole interface, and the screenshots on this page are what it looks like.

Infocom, founded in 1979, made the best-known ones: Zork, The Hitchhiker's Guide to the Galaxy, Planetfall. People still write them today.

The Z-machine, and why a 1982 game still runs

Infocom had a problem. They wanted to sell one game to people who owned an Apple II, a Commodore 64, an IBM PC and a dozen other machines that shared no common ground. Rewriting each game for each computer would have been most of the work, every time.

So they invented a pretend computer and wrote the games for that instead. They called it the Z-machine. It has its own instructions and its own idea of what a screen is, but no Z-machine was ever built out of silicon. To sell a game on a new computer, Infocom wrote one program for that computer -- an interpreter, which reads the pretend computer's instructions and carries them out. The game itself never changed. Java and WebAssembly do the same thing today.

So a game published in 1982 is still a plain file, still fully specified, and still playable on anything somebody writes an interpreter for. Those files are called story files, and they end in .z3, .z5 or .z8 -- the number is which version of the Z-machine they expect.

Frotz is the interpreter

Written for os8088, in 23,722 bytes of 8086 assembly, handling every version of the Z-machine from 1 to 8. Give it a story file and it plays it.

It is not a port of the well-known Frotz. That one is written in C, and this project has no C compiler in it on purpose. This is a separate implementation of the same published standard, written from scratch in assembly, and named the way dfrotz and wfrotz are -- after the spell in Enchanter that makes things glow. The program's own About box says so too.

Watch it run

NostalgiaPC on how the interpreter was built and what it does.

Nothing is sent to YouTube until you press play. The still above is served from this site.

Four stories, running

Every image is a screendump of os8088 in an emulator, driven by a script that opens the interpreter, picks the story off the floppy and types into it.

ADVENT.Z3 -- 66,414 bytes
A window titled ADVENT.Z3. The status line reads Inside Building, Score: 36, Moves: 1. The text below begins Welcome to Adventure! Do you need instructions? answered with n, then a credits block naming Willie Crowther and Don Woods 1977, then the description of the end of a road before a small brick building, the typed command in, and a list of what is inside: a bottle of water, a shiny brass lamp, tasty food and some keys.
Colossal Cave Adventure, 1977. Where the whole form starts -- the small brick building and the brass lamp are the oldest furniture in games. This is a later port of it to the Z-machine, and the interpreter treats it like any other file.
ZTUU.Z5 -- 229,888 bytes
A window titled ZTUU.Z5 filled edge to edge with story text. The Grand Inquisitor sends the player on a mission into the Great Underground Empire, in several paragraphs of dialogue. At the foot of the window a new room heading reads New Excavation, and the last line shows MORE in inverse video where the text has been paused.
Zork: The Undiscovered Underground, 1997. Activision gave this one away. The file is 229,888 bytes -- three times what fits in one of the 8086's 64KB segments -- and all of it is in memory at once. [MORE] at the bottom is the interpreter holding a long passage until you press a key.
PHOTOPIA.Z5 -- 239,616 bytes
A window titled PHOTOPIA.Z5 whose interior is almost entirely black. Two short lines of dialogue sit near the top in black text on white bands: Will you read me a story? and the reply, Read you a story? What fun would that be? I've got a better idea: let's tell a story together.
Photopia, 1998. Adam Cadre's story, which won that year's Interactive Fiction Competition. It sets each of its sections in a different colour; os8088's display is one bit deep, black or white and nothing between, so the colours come out as reversed text.
The story floppy
The os8088 desktop with a file browser window titled INFOCOM open on it, listing four files with their sizes: MINIZORK.Z3 at 52,216 bytes, SAMPLER1.Z3 at 126,902, SAMPLER2.Z3 at 125,315 and ZTUU.Z5 at 229,888. A status line at the foot of the window reads Size 521K, Free 135K.
Where the stories live. Frotz gets a floppy of its own, sorted into folders by era. It is an ordinary FAT12 disk -- the format DOS floppies use -- so you can mount it on a modern computer and copy your own story files onto it.

How it works

The two problems worth describing, what saving gets you, and how it is checked.

Addressing

A story is bigger than the processor can point at

The 8086 reads memory in 64KB chunks called segments, and a single address in a register cannot reach past 65,536 bytes. Zork: The Undiscovered Underground is 229,888 bytes, and the Z-machine expects the whole story to be addressable as one flat run.

So Frotz keeps it as a base segment plus an offset and converts on every access. Two shortcuts carry nearly all the traffic: anything in the first 64KB is reached with no arithmetic at all, and the place the program is currently executing is kept in a register pair that only needs correcting once every 32KB of straight-line code.

Refusing

It says no instead of failing strangely

The whole story sits in memory while you play. There is no reading pieces off the disk as it goes, and that is deliberate: one floppy access costs about 400 milliseconds on the machine this is built for, and working out a single turn's text touches memory hundreds of times. Fetching from disk would not be a slower design, it would be a broken one.

Which means some stories will not fit on some machines. Frotz checks the size before it reads a byte, and says so:

Anchorhead needs 508K and this
machine has 149K free.

On a 640KB machine a story gets about 501KB; on a 256KB one, about 117KB.

Saves

Saved games open on your laptop

Saving writes a Quetzal file, which is the standard format other interpreters use. A game saved in os8088 can be restored in Frotz on a modern computer, and one saved there can be restored here.

Testing

Checked by playing the games

An interpreter is only correct if the games agree, so every story on the disk is played through a fixed script and the transcript is compared line by line against the one a reference interpreter produces from the same script.

A second check compares what is actually on screen, pixel by pixel, against screenshots of the reference -- because two interpreters can print identical text and still draw it differently, and no transcript would ever catch that.

What it will not do

A list that only says yes is not much use.

  • Timed input is turned down, not faked. Some later games can ask "do something within ten seconds". Frotz tells the story up front that it cannot do that, so the story never asks. The alternative is a game waiting forever for a clock that never ticks.
  • Sound is tones. The two standard beeps are exact. A game asking for a recorded sound gets the nearest tone instead.
  • Version 6 graphics are written but not proven. Version 6 games are the ones with pictures, and every one of them is still owned and sold by Activision -- so there is nothing that can ship on the disk to test against. It is checked with a game compiled for the purpose and with made-up picture files, which is a weaker guarantee than the rest of this, and it is listed here rather than left for you to discover.
  • Infocom's own picture files do not draw. The interpreter's own picture format does.

Run it yourself

Three steps, and the first one explains why there is not simply a download.

  1. Build the story floppy from a source checkout. Frotz is not on the software disk that comes with the release: the interpreter alone is most of the free space on the 360KB disk, and an interpreter with no story on the disk is a menu item that disappoints. The games are not in the project either -- they are other people's work, under other people's copyright. So building the disk fetches them, from a list of games whose authors released them freely, checking each against a recorded checksum.

    make zdisk
  2. Boot os8088 with the story disk as the second floppy, then double-click Disk B on the desktop.

  3. Open a story. Open FROTZ.O88, then choose File › Open Story... and pick a game out of INFOCOM, CLASSIC or MODERN. Double-clicking a story file opens it straight away too.

Double-clicking a story that is inside a folder needs a build newer than v1.0.20260810. In that release it only worked for a story in the root of the disk, and anything in a folder reported itself missing -- File › Open Story is the way in there.

The Infocom titles on the disk are Mini-Zork I, both Sampler disks and Zork: The Undiscovered Underground -- the ones Infocom and Activision gave away deliberately. Zork I to III, The Hitchhiker's Guide and Planetfall are still sold and are not included. If you own copies, they can be put on the disk beside these.

Two of the emulated period machines in the project are set up for it, both with a sound card and a full 640KB of memory, because a story has to fit in there all at once: an IBM XT with an 8088 at 4.77MHz, and a 386DX at 25MHz.