Skip to main content

Level data (INF)

File formats · Field reference · Schema

In brief​

An INF file holds everything a level needs besides its wall plan: which map and graphics to use, its doors, its kinds of monsters and where the monsters start, what each wall number means, its timed events, its script program, and which cells trigger which scripts. There are 16 of them, LEVEL1.INF to LEVEL16.INF, each compressed in a CPS container that must be unpacked first.

An INF file links the other files of a level by name:

In the reference files, the graphics names match the five dungeon styles (dung, forest, mezz, silver, crimson) with their .VCN, .VMP and .PAL files; the sound names match .ADL and .SND files such as CATACOMB.ADL; and names such as guard1, wolf or door1 match .CPS images. The INF number need not match the map number: LEVEL6.INF uses level5.maz.

From the file LEVELn.INF to the game. The file holds, in order: Header word (2 bytes); Sublevel records (one or two); Level-state section (monsters, scripts); Cell bindings (counted list). The game: Unpack the CPS container; Follow the link to the sublevel record; Load the named files, types and mappings; Copy the scripts, bind the cells. In memory: Monster types and slots, wall properties, script buffer, block bindings, timers. Used by: Monsters, Walls and doors, Scripts, The view.
The game turns it into monster types and slots, wall properties, script buffer, block bindings, timers.

Organization​

Offsets inside an INF file count from the start of the unpacked data.

PartContents
Header wordWhere the level-state section starts.
Sublevel recordsOne or two linked records. Each names a map and its resources and lists doors, the step-script limit, monster images, monster types, wall mappings and decorations, and timed scripts.
Level-state sectionWhere the cell bindings start; the initial monster block (absent from LEVEL10.INF); the script data: the offset of its strings, the script code, then the level's zero-terminated strings.
Cell bindingsA counted list attaching event flags and a script entry point to cells.

Two features make the file hard to read by hand. Names are stored in fixed 13-byte slots, and the bytes after the terminating zero are not always zero. Many parts start with a marker byte that decides whether the part is present; a door record has a second marker, which also lets small projectiles through its doors. Each marker is compared with a single value, or two for a door record: one outcome reads the part and the other skips it, so every value has a defined effect. The marker of a sublevel record covers only the map, graphics and palette names: the game reads the sound name and every later part whatever its value.1

The script data holds nothing but the level's script code and its strings: its first word gives where the strings start, the code fills the bytes before them, and the strings run to the cell bindings. Script offsets, in the cell bindings and in jumps and calls, count from the start of this data; see the script virtual machine.2

Reading the file​

The game reads a level's INF file each time it loads the level: when a game starts, when a saved game is loaded, and when a script changes level; see when the game loads a level. It unpacks the file, follows the link to the selected sublevel record, loads the map and resources it names, then reads the monsters, copies the script data and applies the cell bindings to the level's blocks.3 The record is selected by its index, the sublevel given by the script that changes level or kept in the saved game. Six levels — 1, 3, 7, 8, 11 and 16 — have a second record naming the same map and resources but other monsters, doors, wall mappings and timers; their scripts select it for part of the level. All records share the level-state section and the cell bindings. See sublevels for when each one is used and what a change keeps.

What it becomes in memory​

Each part of a sublevel record is read by its own routine: wall mappings and decorations,4 timed scripts,5 the step-script limit6 and the two door records.7 A door record names the image of one of the level's two door graphics, its DoorKind, whether it shows a switch, and the rectangles of its door and switch shapes; see doors. The initial monster slots are turned into MonsterRuntime slots;8 the cell bindings set the event flags and the script reference of LevelBlockRuntime blocks.2

These tables are what the monsters, the walls and doors, the scripts and the dungeon view work on; what each part of the files becomes follows every part to its run-time use.

Malformed values​

The game trusts the file. The loader checks no offset, count or index: offsets are followed as given, counts are compared as signed numbers, so a count with its high bit set reads nothing, and indices — cell, monster slot, monster type, timer and wall numbers — are used without a range check. An index past its table writes into whatever data follows it, and the script data is copied into an area of fixed size whatever its length. The original files stay within every table; the schema gives, for each field, what an out-of-range value reaches.9

Example​

The first 32 bytes of LEVEL1.INF once unpacked:

offset bytes meaning
0000 0d 04 level-state section at 0x040d
0002 e5 02 next sublevel record at 2 + 0x02e5
0004 ec marker: this record names its resources
0005 6c 65 76 65 6c 31 2e 6d 61 7a 00 00 00 map: "level1.maz"
0012 64 75 6e 67 00 31 2e 6d 61 7a 00 00 00 graphics: "dung", then leftover bytes "1.maz"
001f ff palette: same name as the graphics

Sources​

Locations refer to the game executable reference; comparative sources are listed in the technical references (REF-MW-003, REF-SCUMM-003, REF-SCUMM-004, REF-SCUMM-006, REF-SCUMM-007, REF-SCUMM-013, REF-SCUMM-020). The values quoted in the schema were read from the 16 INF files of the file inventory.

Footnotes​

  1. Sublevel selection, the door records loader, which follows the sound, and the sound-file loader. ↩

  2. Script data and cell bindings, the script buffer, which gives its size, the block event dispatcher and the distance between two blocks. ↩ ↩2

  3. INF loader and sublevel selection. ↩

  4. Decoration and wall-mapping loop, wall mapping and decoration records; special types are run by the record runner. ↩

  5. Timer list, the script timers and their run-time check, the timer interrupt and the block event dispatcher. ↩

  6. Step-script limit, the steps until the step script, the step counter and the step trigger. ↩

  7. Door records loader and door shape loader, the wall group toggle for marker 0xea and the door tables. Comparative source: REF-SCUMM-016, initLevelData and loadDoorShapes. ↩

  8. Monster properties into the monster type properties, which list every reader of each property; initial monster block with the timed-callback table and the monster slots; monster slot initialization, placing a monster on a block, the monster position tables and positions within an occupied block. Monster graphics: the monster graphics slots, the monster image loaders, load monster shapes with the shape layouts, the DCR loader and drawing the monsters of a visible block with its decoration step. Combat and behavior: roll dice, a monster's hit roll, monster attack, target choice of a close attack, item loss, close-range action, environmental sound, ranged action, check a candidate move, move toward a destination, pursuit decision, a character's hit roll, item damage dice, damage calculation with the combat tables, damage a monster, spell effects on a monster, turn undead, kill a monster and award experience. ↩

  9. INF loader, monster properties, initial monster block, timer list, script data and cell bindings and the block event dispatcher. ↩