Glulx: A 32-Bit Virtual Machine for IF

[GLULX]


What Is It?

Glulx is a portable VM, like the Z-machine. Unlike the Z-machine, it uses 32-bit data and addresses, so it can handle game files up to four gigabytes long. Also unlike the Z-machine, it has native support for Glk I/O, so game files can use any capability Glk provides. However, like the Z-machine -- again -- you can write games in the Inform language and compile them to Glulx game files.

For more justification (or, perhaps, rationalization) see chapter zero of the Glulx Spec.


Specification

This is the Glulx VM Specification, version 3.1.0.


Glulxe

Glulxe (for "Glulx Execute") is the Glulx interpreter. The current version is 0.4.3.

The official and up-to-date archive of Glulxe ports is on the IF Archive, under if-archive/programming/glulx/interpreters/glulxe. Here is a list of some of them, but it's not a complete list and it is not immune to falling out of date:

Since this is a Glk program, it must be built with a Glk library. See the Glk home page.


Glulx Inform

The standard Inform compiler at inform-fiction.org (and the IF Archive) can generate Glulx binaries.

Note that the current Inform release (6.31) generates Glulx 2.0 binaries -- it cannot yet handle Unicode input and output. Here are a sequence of patches which add newer Glulx features. (Apply them in this order.)

Here is The Game Author's Guide to Glulx Inform. This is what you need to know if you know Inform, and want to compile your new (or old) Inform game for the Glulx VM.

Here is The Glulx Inform Technical Reference, which documents all th internal table formats used by Glulx Inform games. (Dictionary tables, grammar tables, property tables, and so on.)

John Cater <katre@plover.net> has written infglk, an Inform header file for Glk functions, with support for rebuilding it when the glk.h header changes.


Sample Game Files

I've compiled Adventure. This is Graham's Inform source, release 5 serial 961209. I compiled it without any changes at all, except for two constant definitions which will be unnecessary in the final release. (See the Guide to Glulx Inform.)

The Z-code and Glulx game files should behave identically in just about every way. (You should download both of them, so that you're really comparing the same game, library, and compiler version. These use Inform 6.21 and the adapted bi-platform 6/10 library. The version of Advent.z5 on the IF Archive uses an earlier library.)

Known differences:

Sample Program Without Inform Library

In Z-code Inform, you can write a "Hello world" program in one line of code. A print statement will work all by itself.

In Glulx Inform, you have to do a little more work: you have to set Glk up to work, and create a window to print to. It's still only about four lines of code.

Now, don't get confused, most Inform game authors will never need to worry about those four lines of code. The bi-platform Inform library takes care of all this magically. However, if you want to write a Glulx Inform program that doesn't use the library at all, look at helloworld.inf to get started.

Sample Game With Resources

And introducing: Sensory Jam (release 4). This is a tiny demo game which contains sounds, graphics, and all sorts of other nifty things. Well, really just sound and graphics.

You'll need a Glulxe 0.3.3 interpreter to play this, since it was compiled with the latest compiler.

Toni Arnold has extracted some of the graphics code from Sensory Jam into an Inform library extension. It was written to deal with the older bi-platform library, so you will have to diddle it a bit to fit it into current code -- I haven't tried it myself. Nonetheless, it's a handy example.

Sample Game With Parallel Worlds

This is a quick demo of a game concept: it takes place in two parallel worlds, each with its own story window. You enter commands in the left window, and your twin performs analogous actions in the right window. It's a very basic implementation, and a lot of stuff doesn't work right, but it's a start.

Sample Game with Unicode Characters

Sample Games with Memory Opcodes


Glulx Assembler

Simon Stapleton has written glulxa, an assembler for the Glulx VM. Here is his page about it.


Text Compression Sample Code

I've settled on good old-fashioned Huffman encoding for the compression system, allowing either characters or words (or a mixture of both) as the encoding entities.

However, if you want to experiment on your own, these are some simple tests, trying various text-compression algorithms. Here is the source code. You can extend this test platform to try out new compression ideas, if you want.


Before Anybody Asks...

MIME type "application/x-glulx". On the Mac, file type "UlxG", and the standard Glulxe interpreter uses creator code "gUlx".


What's New

Glulxe 0.4.3: includes some bug fixes, and the option to check for memory overruns.

Put out the Glulx 3.1.0 spec, which includes @mzero, @mcopy, @malloc, and @mfree opcodes.

Kicked out the Glulx 3.0.0 spec, which includes the infrastructure needed for Unicode support.

(Fixed typo in spec: the @streamstr opcode can be used for string types E0, E1, or E2. The original 3.0.0 document failed to mention E2.)


Last updated March 17, 2008.

Glk home page

Zarfhome (map) (down)