Tools
Home · File inventory · File formats
In brief
The figures, maps and script listings of this site are produced by nineteen small Python programs. They read your own copy of the DOS game and never modify it; the project distributes no game files, and the programs reproduce no game graphics or texts. Each one needs only Python 3 and its standard library.
| Program | What it produces | Reads | Used by |
|---|---|---|---|
uncps.py | The unpacked contents of a CPS container | Any CPS file, LEVELn.INF | Every tool that reads an INF file |
script_decoder.py | Listings of the level scripts and statistics on their instructions | LEVELn.INF | The levels, script virtual machine |
make_level_maps.py | One SVG map per level and sublevel record, and the key of their symbols | LEVELn.MAZ, LEVELn.INF, ITEM.DAT | Level maps |
extract_view_tables.py | The tables of the dungeon view, as JSON | START.EXE | The dungeon view |
make_view_figures.py | The figures of the dungeon-view chapter | Nothing: its numbers are written in the program | The dungeon view |
make_party_figures.py | The modifier, experience, condition, starting-items and melee-target figures | START.EXE; the item names are written in the program | The party |
make_engine_figures.py | The block-event, game-loop, clock and timed-update figures | START.EXE; the event sources are written in the program | The engine |
make_world_figures.py | The level-connection, coordinate, sublevel, door and door-forcing figures | START.EXE; the level changes are written in the program | The world |
make_combat_figures.py | The attack-flow, hand-recovery, modifier, saving-throw and party-quarter figures | START.EXE; the timer durations are written in the program | Combat |
make_monster_figures.py | The pursuit, noticing, movement, mode, block-position, ranged-wait, melee and death figures | Nothing: it follows the rules of the monster pages | Monsters |
make_bestiary.py | The 29 monster sheets of the bestiary, their figures and its comparison table | LEVELn.INF, with inf_records.py and uncps.py; its data file bestiary.json | Bestiary |
make_item_figures.py | The slot, defense, use, item-cast, flight, pile and location figures, and two charts of the item types | Nothing: it follows the rules of the item pages and reads their type table | Items |
make_magic_figures.py | The spell-life, slot-state, slot-table, casting and lasting-spell figures | START.EXE; the other figures follow the rules of the magic pages | Magic |
make_script_figures.py | The figures of the scripts chapter and of the script virtual machine | Nothing: it follows the rules of their pages | Scripts, script virtual machine |
make_save_figures.py | The saved-game layout, level-change and loading figures | Nothing: it follows the rules of its pages | Saving and restoring |
make_file_figures.py | The figure of each file page, of when the files are read and of four family pages | Nothing: it follows its file pages | From files to the game |
make_reference_figures.py | The figure of the reference entry page | Nothing | Reference |
make_interface_figures.py | The input, play-screen, spell-book, camp-menu and start-menu figures | Nothing: it follows the button rectangles and rules of its pages | The interface |
make_sequence_figures.py | The figure of the two sequences | Nothing | Introduction and ending |
Getting and running the programs
Download all the programs in one archive,
dungeoneye-codex-tools.zip, and
unpack it: the programs keep their folders, scripts/ and tools/, and find
one another there. The links of the table above show each program on its own;
a program saved from its link gets a name with a suffix and does not find the
others. Run the programs from the folder of the unpacked archive, with the game
directory as argument:
python3 -I scripts/maps/make_level_maps.py --game /path/to/eob2 --out maps
python3 -I scripts/inf/script_decoder.py --game /path/to/eob2 --listing 4
python3 -I scripts/view/extract_view_tables.py /path/to/eob2/START.EXE > view-tables.json
The game files are those of the file inventory, whose hashes
identify the release studied; file names may be in upper or lower case. The
programs that read START.EXE check its SHA-256 and stop if it is another
release. The others do not check their input: another release may give
different or wrong results.
In the project repository, the programs keep the paths shown in the links
and read the game from data/originals/eob2/ by default.
Unpacking CPS containers
uncps.py unpacks a CPS container,
the compressed wrapper of the game's images and of its level files. It
decodes methods 0 (stored) and 4 (the LCW method), and checks that the result
has the size the header announces. It rejects method 3 (run lengths), which the
game also decodes and which SKELWAR.CPS uses.
python3 -I tools/uncps.py /path/to/eob2/LEVEL4.INF level4.bin
It writes the unpacked data to the second file and prints the method and the
two sizes. The other tools call its decode_cps function directly, without
writing intermediate files.
Decoding the level scripts
script_decoder.py decodes the scripts of
the 16 LEVELn.INF files with the instruction layouts of the
script virtual machine. It never scans the data for
instruction-like bytes: it starts from the script entry points named by the
level's cell bindings and follows the flow of control — jumps, calls and
both outcomes of each condition — as the game's interpreter does. A byte
below 0xe2 is passed over as a one-byte no-op, as the interpreter does. An
instruction whose layout is not documented stops the path and is reported;
nothing is guessed.
| Command | Output |
|---|---|
script_decoder.py | One line per level: script size, entry points, instructions decoded, bytes covered, unreached ranges and problems; then totals over the 16 levels. |
script_decoder.py --listing N | Every decoded instruction of level N: its offset in the script data, its opcode byte, its name and its operands. |
script_decoder.py --gaps N | The ranges of level N's script data that no path reaches, with their first bytes and a classification. |
script_decoder.py --usage | For each instruction, how often each selector value occurs, and how often each expression token occurs. |
Offsets count from the start of the level's script data, as in the
level pages. Blocks are printed as positions
[XX:YY] (column, row; block index YY × 32 + XX). Names and strings
embedded in instructions are replaced by placeholders such as <13 bytes>,
and messages appear by number, so a listing quotes no game text.
Drawing the level maps
make_level_maps.py draws the
level maps, shown on the level pages. For each level it:
- unpacks
LEVELn.INFand reads its sublevel records — maze name, door records, monster graphics and types, wall mappings, timers — following the INF schema; - reads the walls of the maze named by the record, following the MAZ schema, and classifies each face with the wall properties: the built-in values for references 0 to 24, the record's wall mappings for the others, and, for a second record, the first record's mappings for the references it does not map;
- reads the initial monster block of the INF file and the items of
ITEM.DATlying on that level, following the ITEM.DAT schema; - decodes, with
script_decoder.py, every script that a cell binding names, and summarizes what it can do: the instructions reachable from its entry point, except the outcome a comparison of two constants never takes; - writes one SVG file per level, or per sublevel record with
--all-sublevels.
| Option | Effect |
|---|---|
N … | Draw only these levels (default: all 16). |
--sublevel K | Draw the record K of each level instead of the first. |
--all-sublevels | Draw every record of each level. |
--key | Draw only the key of the symbols, on made-up blocks, read from no game file. |
--out DIR | Write the SVG files to DIR. |
--game DIR | Read the game files from DIR. |
A wall reference that no record of the level maps is drawn as a wall and reported on the error output; see the level maps.
Extracting the view tables
extract_view_tables.py reads the
tables that draw the dungeon view from START.EXE and
prints them as one JSON object: the visible blocks for each direction, the
spots where items, monsters and flying objects stand, their scale steps and
mirrors, the decoration faces and positions, the door frames, and the
clipping of walls and doors. Each key is named after what the table holds.
With this output, a program can draw the view without copying the tables
from this site.
Drawing the figures
make_view_figures.py draws the eleven
figures of the dungeon view: the visible blocks, the faces
drawn, the screen regions, a corridor, the object spots, the tile layers, the
scale steps of items and flying objects, monster frames, door rows, scale
steps and darkening, and the display modes. Its numbers — the view offsets,
the walls drawn by the view setup and the tables of the view pages — are
written in the program, transcribed from START.EXE, so it reads no file.
make_party_figures.py draws the
twelve figures of the party: the dexterity and constitution
modifiers, read from their tables; the experience needed for each level and
the starting experience on each level ladder, read from the level thresholds
of START.EXE; a character's condition; the starting items of each class,
transcribed from the party setup with the names of the ITEM.DAT templates;
the order in which a monster's close attack picks its target, read from
the close-attack tables; the screens of party creation; and five decision
chains.
make_monster_figures.py
draws the eight figures of the monster rules: one
pursuit update; where a monster notices the party, computed with the distance
and sector rules; the order in which a monster tries to move; how it changes
mode; the positions in a block; the wait between ranged attacks; when it
strikes in melee; and what happens when it dies.
make_bestiary.py generates the
bestiary: one sheet per monster image, with the
values of its types read from the monster blocks of the level files, and a
figure that places them among the other monsters; the monsters of each level
and the capabilities of each image; and the comparison table of the bestiary.
What the level files do not give, such as the image that draws each type or
the description of each image, comes from its data file,
bestiary.json. The sheets are never
edited by hand: the program writes them again.
make_engine_figures.py draws the
seven figures of the engine: who can start a block script,
one pass of the game loop, the two tick counters, the timed updates of one pass, whose intervals it
reads from the timed-callback table of START.EXE,
and three decision chains.
make_world_figures.py draws the
seven figures of the world, two of them decision chains: how the levels connect, blocks
and positions, what a change of sublevel keeps, the five references of a
door, read from the wall properties, and the
chance to force a door, read from the
door-forcing chances.
make_item_figures.py draws the
nine figures of the items: the inventory slots, a worked
example of defense, using a hand item, casting from an item, a thrown item in
flight, a pile rebuilt in table order, where an item entry can be, and two
charts read from the table of item types.
make_magic_figures.py draws the
five figures of magic: the life of a spell, the states of a
spell slot, the slot tables of mages, clerics and paladins with the wisdom
bonus, read from START.EXE, the steps of a cast and the life of a lasting
spell.
make_script_figures.py draws
the ten figures of the scripts and of the
script virtual machine: from an event to a change, when
an event reaches a block, a run inside a run, a scripted door, a script move,
a dialogue question, the script buffer, an instruction, a call and its return,
and how much of the scripts a decoder reaches.
make_file_figures.py draws the
figures of From files to the game: for each file page, the
parts of the file, what the game does with them, what they become and who
uses them; when the game reads its files; and the central figure of the
images, dungeon graphics, sound and texts family pages.
make_interface_figures.py
draws the five figures of the interface: the input
chain, the buttons of the play screen and of the spell book, the camp menus
and the start menu. make_save_figures.py
draws the three figures of saving and restoring, and
make_sequence_figures.py the
figure of the introduction and ending.
The engine, world, party, monster, item and magic programs, and
make_script_figures.py and
make_save_figures.py, also draw
decision chains: a column of steps and questions, each question with one
branch to the side. They transcribe the text of their pages and share their
drawing code, flowcharts.py and
svgkit.py, which must be saved next to them.
make_combat_figures.py draws the
five figures of the combat pages: how an attack unfolds; the strength and
dexterity modifiers, the saving-throw thresholds of each class group and the
characters hit in each quarter of the party's block, read from the combat
tables of START.EXE; and the time a hand rests after an attack, whose
durations are written in the program.
python3 -I make_view_figures.py figures
python3 -I make_party_figures.py /path/to/eob2/START.EXE figures
python3 -I make_combat_figures.py /path/to/eob2/START.EXE figures
python3 -I make_engine_figures.py /path/to/eob2/START.EXE figures
python3 -I make_world_figures.py /path/to/eob2/START.EXE figures
python3 -I make_magic_figures.py /path/to/eob2/START.EXE figures
python3 -I make_script_figures.py figures
python3 -I make_save_figures.py figures
python3 -I make_interface_figures.py figures
python3 -I make_sequence_figures.py figures
python3 -I make_file_figures.py
python3 -I make_reference_figures.py figures
The figures are original schematic drawings; no game graphics are read or reproduced.
Sources
The programs follow the formats and locations documented on this site: the file formats and their schemas, the script virtual machine and the game executable reference, in particular the view tables, the experience thresholds, the close-attack tables, the combat tables, the saving-throw thresholds, the quarter and character tables and the starting items. The game files are identified in the file inventory.