Nitfol is a portable interpreter for Z-machine code, the game format used by Infocom and more recently, Inform. Nitfol handles versions one through eight of the format, and attempts to comply with version 1.0 of the Z-machine specification.
You will need game files to use nitfol. The "if-archive" contains a large collection of these, available at ftp://ftp.gmd.de/if-archive/games/zcode/ or at the USA mirror http://ifarchive.org/indexes/if-archiveXgamesXzcode.html.
This manual describes how to use nitfol and how it differs from other Z-machine interpreters. This manual was written with UNIX-like systems in mind; ignore that which does not apply to your platform. Comments on and corrections for this manual and nitfol are appreciated and should be sent to nitfol@my-deja.com.
Invoke nitfol with the game filename, and options. If you omit the game filename, nitfol will prompt you for one. The following options are recognized:
-ignore
-no-ignore
-i
-fullname
-no-fullname
-f
-command file
-x file
-pirate
-no-pirate
-P
-quiet
-no-quiet
-q
-spell
-no-spell
oops
command). If you type in a word which isn't in the game's dictionary and have typo correction enabled, nitfol will search for a word which is off by one letter by a substitution, deletion, insertion or transposition.
-expand
-no-expand
-symbols file
-s file
-tandy
-no-tandy
-t
-transcript wfile
-T wfile
-debug
-no-debug
-d
-prompt string
-path string
INFOCOM_PATH
environment variable.
-autoundo
-no-autoundo
@save_undo
is called every turn. If a turn passes with no @save_undo
between, this option performs the @save_undo
automagically. Could cause problems with some games which have a different concept of a turn.
-stacklimit number
-S number
-alias string
-a string
-ralias string
-unalias string
-random number
-r number
@random 0
.
-mapsym string
-mapsize number
-maploc string
-terpnum number
-terpver string
If you don't like the default options and don't want to recompile, you can set your preferences by writing a `.nitfolrc' in your home directory.
Each line should be of the form option=value
. Blank lines and lines starting with a #
are ignored. If you want to specify different options for different copies of nitfol, you can put those options in a block which will only be read by copies of nitfol with a specific name.
Here's an example `.nitfolrc':
path=/usr/local/games/infocom alias=v verbose alias=asierra tone cordial. ask sierra about ignore=true [strictnitfol] ignore=false spell=false expand=false autoundo=false unalias=v unalias=asierra [xnitfol] tandy=true pirate=true
Nitfol will look in `/usr/local/games/infocom' for game files. Copies of nitfol named `strictnitfol' will report Z-machine strictness errors, perform strict tokenisation, and not automatically @save_undo
. All others will ignore strictness errors and have two aliases. `xnitfol' will set the Tandy bit and branch on the piracy opcode.
Options specified in the preference file may be overruled by environment variables and command line options.
Multiple @restore_undo
opcodes with no intervening @save_undo
will restore earlier and earlier saved states. However, Inform games will not do this, so if you want infinite undo, you must enter the commands /undo
and /redo
. The /...
commands are part of the debugger, so you will need to compile in debugger support to use this feature.
Z-machine games prior to version 5 do not provide undo (none of them provide redo), and some version 5 games don't use it (like Wishbringer). If the game performs two @read
opcodes with no intervening @save_undo
or @restore_undo
, nitfol will perform a @save_undo
.
If the game has long words which you wish to abbreviate, you can use aliases. Use the command /alias name value
. All instances of name in line input will be replaced with value. name may not contain whitespace.
Unlike abbreviation expansion and typo correction, alias expansion modifies the text buffer, inserting the requested text. This is necessary to allow multiple commands to be given in an alias through the use of periods.
Aliases are not expanded recursively, so you could do something clever like this:
>/alias e w /alias w e /alias nw ne /alias ne nw /alias sw se /alias se sw
And your east-west movement will be swapped (e will do a w, though east will still do east). Aliases expand on all input the game receives using @read
, including transcripts and directions from the automapper.
If you want the expansion of the alias to be checked for further aliases, you must use the /ralias
command. This expansion is stopped when an alias would expand itself.
>/ralias e w /ralias w e
Would do nothing, as e is expanded to w, which is expanded to e, and then it stops because the rule for expanding e has already taken place.
>/ralias hanoi2 move src to extra. move src to dest. move extra to dest /alias src left /alias dest center /alias extra right hanoi2 You move the small disc from the left peg to the right peg. You move the medium disc from the left peg to the middle peg. You move the small disc from the right peg to the middle peg. >move left to right You move the large disc from the left peg to the right peg. >/alias src center /alias dest right /alias extra left hanoi2 You move the small disc from the middle peg to the left peg. You move the medium disc from the middle peg to the right peg. You move the small disc from the left peg to the right peg.
Ideally you should be able to define an alias which recursively solves any depth by relying on lower levels being solvable, but this isn't yet possible. You must keep the expansion of aliases to a reasonable size, since Inform has a fairly small buffer size.
You can remove aliases using the /unalias
command.
>/unalias hanoi2
Aliases do not effect /...
commands; if they did, it wouldn't be possible to /unalias
.
Early Infocom games don't provide abbreviations like x for examine. If you enable abbreviation expansion, nitfol will attempt to expand one letter words at the beginning of inputs which are not in the game's dictionary.
Nitfol supports the following expansions (note that some are non-standard):
close | d | down | e | east | g | again
|
inventory | k | attack | l | look | n | north
|
oops | p | open | q | quit | r | drop
|
south | t | take | u | up | w | west
|
examine | y | yes | z | wait |
West of House You are standing in an open field west of a white house, with a boarded front door. There is a small mailbox here. >x mailbox [x -> examine] The small mailbox is closed. >p it [p -> open] Opening the small mailbox reveals a leaflet. >t leaflet [t -> take] Taken.
In the Z-machine, the @read
opcode provides the interpreter with a dictionary to search in order to do tokenisation and word matching. If you enable typo correction and enter a word not in the provided dictionary, nitfol will search for near misses.
From Curses:
>ask jemmia about gloves [jemmia -> jemima] "Those are my gloves."
Nitfol takes the following steps to correct typos:
This behavior can be annoying when nitfol "corrects" intentionally entered words which are similar to dictionary words. Usually this has no effect upon the game, perhaps slightly changing the game's error message, but may have negative effects when it causes an undesired action. Games like Beyond Zork expect you to type words not in their dictionary to name things. Nitfol might "correct" your entered word to a dictionary word, which the game might complain about.
If typo correction is getting in your way, run nitfol with `-no-smart', compile it without applying `-DSMART_TOKENISER', or edit `nitfol.opt' to change the compile-time default.
Nitfol has the ability to display an on-screen map showing visited rooms and their connections on the current floor. Below is a map generated from Enchanter.
*-* * | | u-*-*-*-*-------*---* | | * * * | *---* | |/ \ / | /|\ / \ | * * * / | X * \ * / \ | / |/ v| \ | / * *-*-*-*-*---*---u---*-*-*-@ / | / | |\ |\ ^| / | *-* * * | | \ | X * / *-* \ |/ | | \|/ \ / | * * * * *---* * \ / | | | * u-d-*-----------*-u | * \ *
The `*'s designate rooms; the `@' the current room. Rooms containing staircases are shown with a `u' or `d', or `b' if the staircase is bi-directional. If the current room contains a staircase, nitfol draws it with a `U', `D', or `B'. Passageways are shown with lines; the `X's are crossed lines. One-way passages are shown as lines with arrows. Nitfol uses `v', `^', `<', and `>' for arrow heads.
In Glks which provide mouse events, you can click on rooms and it will display the room name (and number) in the upper left hand corner of the map. Note that XGlk is slightly broken, so you need to click on the left-hand side of the room. Clicking on an empty map space clears the name.
In order to use automapping, you must tell nitfol how to calculate the current location. You do this by specifying an Inform expression, so you must have debugging enabled.
Typically the current location is available in a global. In Z-code versions 3 and prior, the current location is always stored in global zero, so typing /automap (global) 0 should work. In later versions, you must figure out an expression which evaluates to the current location.
First, find out where the player object is. Typically, the player object is named `self', `cretin', `self-object', or the name of the PC. You can use the find
command to search object names. If this all fails, try object-tree
to find the location number.
Once you have found the number of the location, you need to figure out which global keeps track of the location. You can use the globals
command to search the globals.
From Spider And Web:
>/find self 20 "(self object)" 25 "yourself" in 91 "End of Alley" 26 "yourself" in 48 "chair" /globals 91 G15 G36 G39 s Mouth of Alley You're in the entrance of a narrow brick alley, which runs further in to the north. To the south a broad street courses by, congested with traffic and bicycles, although none of them seem to notice you. >/find self 20 "(self object)" 25 "yourself" in 94 "Mouth of Alley" 26 "yourself" in 48 "chair" /globals 94 G15 G36 G39 /automap (global) 15
Obviously we have 3 globals tracking the player location. Typically there are only two, but some games have more. In this, we just picked the first one, which is probably the Inform location
variable; another is probably the real_location
variable. Depending on how you want automapping to behave in the dark, or when dealing with game-specific stuff, you may want to pick a different one.
To figure out what is in which direction, nitfol checks the current location, tells the game to go north, checks the new location, undoes the north movement, tries to go northeast, and so on. During all of this, output is disabled.
Drawing the map is more complicated. First nitfol looks for cycles in the graph and makes the cycles connect properly. Then it draws the map. If parts of the map overlapp, it finds a path connecting the overlapping bits and tries increasing the length of each passage in this path by one, and recalculates cycle connections. If this solves the problem, it's done; otherwise, it tries increasing the length of two passages, or of one of the passages by two. If this fails, it gives up.
This technique isn't perfect. The implementation of this technique isn't perfect either. So expect nitfol to misbehave a lot on complex maps, and a little on simple maps. If you clever ideas on how to improve it, let me know.
Nitfol makes an effort to simplify the map. If multiple exits go from the barn to cornfield and you've been to both places, nitfol will draw a single two-way passage if possible. If both up and west go up the stairs and nitfol knows east returns from the top of the stairs, nitfol will draw it as a simple west-east passage ignoring the up/down. If east doesn't return from the top of the staircase, nitfol will draw it as up/down, leaving out the west passage.
If you've been north of a gate, and come up to the gate from the south, and unlock the gate, nitfol will draw it as a one-way passage since last time it was north of the gate, it couldn't go south.
Some games feature reincarnation, perhaps moving you to a new location. If movement leads to your death, this makes nitfol think the reincarnation location is in that direction. Nitfol watches for three asterisks in a row and will assume they mean death instead of a normal passage.
Some of these problems could be avoided by having nitfol explore each neighboring room, but this would make automapping even slower.
Nitfol uses Quetzal version 1.4 for its save format, so you can use your saves between different computers and interpreters. More information about Quetzal is available at http://www.geocities.com/SiliconValley/Vista/6631/.
If you specify a save-file on the command-line on UNIX, nitfol uses a UNIX
IntD
chunk to locate the game file associated with the save name. This chunk is included in save games when nitfol can figure out the current filename. If you compile nitfol with -D__USE_GNU, -D__USE_BSD, or -D__USE_XOPEN_EXTENDED, nitfol will canonicalize the file name, so you don't have to worry about relative file name specifications no longer working if you invoke nitfol from a different directory.
On MacOS, nitfol uses alias records from a MACS
IntD
chunk to locate the game file. This won't work for games built-in to the interpreter.
If no IntD
chunk is included, nitfol searches the environment variable INFOCOM_PATH
for a game with matching release number, serial number, and checksum.
Looking for games without an IntD
chunk isn't foolproof, but it should work most of the time. Serial numbers are basically the date and it's extremely unlikely more than ten games will be compiled on the same day (the only time lots of games are compiled on same day is right before competition time). Assuming they all have the same release number, there's still only a .0686% chance that at least two of these ten will share the same checksum. If someone reports this as a problem, I'll make nitfol ensure the game contains a save
opcode right before the restored PC.
If you wish to hear sounds or see graphics in your games, they must be packaged in Blorb files. The Z-machine game may included in the Blorb file or may be specified separately. Nitfol does not support the traditional Infocom `.mg1' and `.snd' files.
Note that graphics are displayed incorrectly, and sound has not yet been tested.
Nitfol debugging mode tries to imitate the GDB interface. If you're familiar with that, you should have no problem using nitfol (other than dealing with the current incompleteness).
You need inform 6.21 or later, as earlier versions don't produce correct infix files without a patch. You then need to compile infix information for your game. I recommend doing:
inform -k -~S -~X -~D MyGame.inf
Then your debug information will be in `gameinfo.dbg'. If you have a command-line on your platform, run nitfol like nitfol MyGame.z5 -symbols gameinfo.dbg
. Otherwise, start up your game and type /symbol-file gameinfo.dbg
the first time you get a prompt.
When the game stops to read a line of text, you can begin that line with / to give a debug command. If you want to pass a line beginning with a / to the game, double the / and the game will be passed the second one. When at a (nitfol)
prompt, starting commands with / is neither necessary nor recommended.
All expressions are like the ones used in Inform.
You can perform casts to get the result in the form you want:
(number) expression
(object) expression
(routine) expression
(string) expression
(global) expression
(global) 0
is the player location for version 3 Infocom games.
(local) expression
Here are short descriptions of the debugger commands. See Info file `gdb', node `Top', for more information. Some of these were taken/adapted from GDB's help.
info breakpoints
info breakpoints num
quit
show language
condition num exp
restore
break linespec
break linespec if exp
if
clause specifies a condition.
stepi
stepi num
restart
object-tree
object-tree exp
disable display num
select-frame num
alias name value
down-silently
down-silently num
frame
frame num
give exp num
give exp ~ num
set exp
print exp
up
up num
# comment
continue
continue num
dumpmem file
undo
display exp
move exp to exp
up-silently
up-silently num
show copying
recording off
jump linespec
recording on
ralias name value
globals
globals exp
backtrace
backtrace num
backtrace - num
find
finish
down
down num
ignore num num
replay off
nexti
nexti num
help
redo
undo
.
enable num
until
replay
unalias name
remove exp
info sources
delete num
symbol-file file
automap exp
show warranty
disable num
undisplay num
enable display num
step
step num
info source
next
next num
If you're on a UNIX and you don't like the GDB interface, you can compile cheapnitfol and run it as the inferior debugger under Emacs or DDD. You can also try compiling xnitfol
with `-DSTDOUT_DEBUG' and trying that, but I haven't tested that much.
ddd MyGame.z5 --debugger cheapnitfol -s gameinfo.dbg -prompt "(gdb) "
A nitfol bug is any behaviour which makes nitfol reliably misbehave, with the exceptions of bugs in Glk libraries. These include: anything which makes nitfol crash (other than when nitfol reports `FATAL' errors), anything which causes nitfol to contradict the Z-machine standards documents (except for optional enhancements like spelling correction and debug mode), any buffer overflows, and anything which makes nitfol infinite loop other than infinite loops in the game itself.
Before reporting a bug, make sure the bug is not listed below and your copy of nitfol is not compiled with `-DFAST'. Please report the version of nitfol, your system type and a series of commands which reliably cause the bug.
Nitfol is lacking:
Nitfol does incorrectly:
cheapnitfol
can't see them.
@storeb
and @storew
.
Debugger problems:
ofclass
, superclass not implemented.
quit
, run
, etc., don't prompt you for confirmation.
Automapping problems:
@get_cursor
doesn't return the correct value during automapping since output is disabled.
The following people have given comments, suggestions, bug reports, answered questions, or helped port nitfol (in alphabetical order):
Wishbringer Copyright © 1985, 1988 Infocom Inc.
Zork I Copyright © 1981-1986 Infocom Inc.
Curses Copyright © 1993-1994 Graham Nelson.
http://ifarchive.org/if-archive/games/zcode/curses.z5
Beyond Zork Copyright © 1987 Infocom Inc.
Enchanter Copyright © 1983, 1984, 1986 Infocom Inc.
Varicella by Adam Cadre 1999.
http://adamcadre.ac/content/vgame.z8
Spider And Web Copyright © 1997-1998 Andrew Plotkin.
http://ifarchive.org/if-archive/games/zcode/Tangle.z5
This document was generated on 24 October 1999 using the texi2html translator version 1.54.