Expand description
This crate implements an assembler for the Glulx virtual machine for interactive fiction. It supports version 3.1.3 of the Glulx specification.
Currently, the functionality of this crate is limited to generating binary
Glulx files from the in-memory data structures defined herein. It is
designed and suitable as a library for use by translation tools that
generate Glulx, but cannot be used as a standalone assembler. Display
impls are provided for generating human-readable assembly listings, but the
syntax is subject to change and there is no tool which parses what these
impls emit. This crate may be extended with such functionality in the
future.
This crate’s main entry point is the Assembly
struct and its
assemble
method, which outputs a
BytesMut
(see the bytes
crate) from the public
fields you create the Assembly
from.
The bulk of what you provide to the Assembly
is a list of Item
s, each
of which may be tagged with a label. The label parameter is generic; you can
use any type you like provided only that it implements Clone + Eq + Hash
.
Do note that the assembler is a bit indiscriminant about cloning, so if
you’re considering using String
s as labels you may want to use something
like Rc<str>
instead. Every type in this crate which
takes a label parameter is, in the Haskell/loosely-category-theoretical
sense, a functor over its labels. That is, it provides a map
method which
lets you replace every label within it with the output of a callback,
possibly changing the label’s type.
See examples/hello.rs
for an illustration of using this crate to assemble
a story file that prints “Hello, Sailor!” and exits.
Modules§
- concise
- Functions for concisely constructing items.
Structs§
- Assembly
- Collection of all inputs needed to assemble a story file.
- Label
Ref - A reference to a label plus an offset.
- Mystery
String - A string whose encoding is defined by the IO system, but probably treated as Latin-1.
- String
Conversion Error - Error returned when constructing a
Utf32String
orMysteryString
from malformed input. - Utf32
String - A string encoded as UTF-32.
Enums§
- Assembler
Error - Errors that can occur during assembly.
- Calling
Convention - Specifies how a function receives its arguments.
- Decode
Arg - Argument to a function invoked from a decoding table.
- Decode
Node - A node in a decoding table.
- Instr
- Representation of a Glulx instruction.
- Item
- An item of top-level content in a story file assembly.
- Load
Operand - An operand indicating where to get a value from.
- Store
Operand - An operand indicating where to put a value.
- Zero
Item - Placeholder for space in RAM that shoud be allocated at startup with initially-zeroed content.
Functions§
- f32_
to_ imm - Creates an immediate operand out of the given
f32
. - f64_
to_ imm - Creates a pair of immediate operands out of the given
f64
, returned as (hi,lo).