Skip to main content

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.

ProgramWhat it producesReadsUsed by
uncps.pyThe unpacked contents of a CPS containerAny CPS file, LEVELn.INFEvery tool that reads an INF file
script_decoder.pyListings of the level scripts and statistics on their instructionsLEVELn.INFThe levels, script virtual machine
make_level_maps.pyOne SVG map per level and sublevel record, and the key of their symbolsLEVELn.MAZ, LEVELn.INF, ITEM.DATLevel maps
extract_view_tables.pyThe tables of the dungeon view, as JSONSTART.EXEThe dungeon view
make_view_figures.pyThe figures of the dungeon-view chapterNothing: its numbers are written in the programThe dungeon view
make_party_figures.pyThe modifier, experience, condition, starting-items and melee-target figuresSTART.EXE; the item names are written in the programThe party
make_engine_figures.pyThe block-event, game-loop, clock and timed-update figuresSTART.EXE; the event sources are written in the programThe engine
make_world_figures.pyThe level-connection, coordinate, sublevel, door and door-forcing figuresSTART.EXE; the level changes are written in the programThe world
make_combat_figures.pyThe attack-flow, hand-recovery, modifier, saving-throw and party-quarter figuresSTART.EXE; the timer durations are written in the programCombat
make_monster_figures.pyThe pursuit, noticing, movement, mode, block-position, ranged-wait, melee and death figuresNothing: it follows the rules of the monster pagesMonsters
make_bestiary.pyThe 29 monster sheets of the bestiary, their figures and its comparison tableLEVELn.INF, with inf_records.py and uncps.py; its data file bestiary.jsonBestiary
make_item_figures.pyThe slot, defense, use, item-cast, flight, pile and location figures, and two charts of the item typesNothing: it follows the rules of the item pages and reads their type tableItems
make_magic_figures.pyThe spell-life, slot-state, slot-table, casting and lasting-spell figuresSTART.EXE; the other figures follow the rules of the magic pagesMagic
make_script_figures.pyThe figures of the scripts chapter and of the script virtual machineNothing: it follows the rules of their pagesScripts, script virtual machine
make_save_figures.pyThe saved-game layout, level-change and loading figuresNothing: it follows the rules of its pagesSaving and restoring
make_file_figures.pyThe figure of each file page, of when the files are read and of four family pagesNothing: it follows its file pagesFrom files to the game
make_reference_figures.pyThe figure of the reference entry pageNothingReference
make_interface_figures.pyThe input, play-screen, spell-book, camp-menu and start-menu figuresNothing: it follows the button rectangles and rules of its pagesThe interface
make_sequence_figures.pyThe figure of the two sequencesNothingIntroduction 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.

CommandOutput
script_decoder.pyOne 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 NEvery decoded instruction of level N: its offset in the script data, its opcode byte, its name and its operands.
script_decoder.py --gaps NThe ranges of level N's script data that no path reaches, with their first bytes and a classification.
script_decoder.py --usageFor 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:

  1. unpacks LEVELn.INF and reads its sublevel records — maze name, door records, monster graphics and types, wall mappings, timers — following the INF schema;
  2. 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;
  3. reads the initial monster block of the INF file and the items of ITEM.DAT lying on that level, following the ITEM.DAT schema;
  4. 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;
  5. writes one SVG file per level, or per sublevel record with --all-sublevels.
OptionEffect
N …Draw only these levels (default: all 16).
--sublevel KDraw the record K of each level instead of the first.
--all-sublevelsDraw every record of each level.
--keyDraw only the key of the symbols, on made-up blocks, read from no game file.
--out DIRWrite the SVG files to DIR.
--game DIRRead 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.