Level data
From files to the game · The world · INF · MAZ
In brief
A level comes from two files and the game's own tables. The level's INF file, packed in a CPS container, holds one or two sublevel records, the level's scripts and the bindings between blocks and scripts; the sublevel record names the MAZ map, which gives each block its four walls, and the graphics, palette and sounds. Every load reads the whole INF file again, but the walls and the monsters come from the files only on the first visit: afterwards the level record supplies them. The items lying in the blocks never come from the level files.
Loading a level
The game builds the INF file name from the level number, decodes the file's container and selects a sublevel record. That record names the MAZ map to load (its number need not match the INF number) and other resources, including a VMP file.1
The diagram shows which data feeds which, not the order of every step. The container is described by the CPS schema. For the initial state of monsters, see the monster slot.
The map loader reads the six header bytes, then exactly 4,096 bytes of map
data, and copies 1,024 four-byte records into the blocks. It never looks at
the header as a size: a MAZ file with other dimensions can be well formed
and still not load correctly in the original game. It does not check how
many bytes either read returns either; with a shorter file, the missing
cells would keep whatever the read buffer held before (inferred). The header
is read into the first block of the level, where it leaves a value in the
state of [00:00]; see
the map header anomaly.2
Positions are written [XX:YY], column then row, both counted from 00; the
block index is YY × 32 + XX.
What each part of the files becomes
Every load reads the whole INF file again, but some of its parts only matter the first time the party enters a level: afterwards the level record supplies them.3
| Part of the files | What the game makes of it | Used on |
|---|---|---|
| MAZ header | Nothing; see the anomaly above. | — |
| MAZ cells | The four wall_references of each block. | The first visit only |
| Sublevel record: map, graphics, palette and sound names | The files loaded for the level. | Every load |
| Door records | The two door graphics, their DoorKind and switches, and whether small projectiles pass their closed and partly open doors. | Every load |
| Step-script limit | The step count that runs the step-triggered script; the step counter restarts. | Every load |
| Monster images and types | The images and the type properties shared by the level's monsters. | Every load |
| Decorations and wall mappings | The graphics, decoration, interaction type and properties of the wall references they name; the others keep their values. | Every load |
| Timed scripts | The timed block scripts, restarted. | Every load |
| Level state: monster update intervals | The update cadence of the level's monster groups. | Every load |
| Level state: initial monsters | The 30 monster slots. | The first visit only |
| Level state: script data | The script buffer. | Every load |
| Cell bindings | The event flags and script offset of each block. | Every load |
The items lying in the blocks do not come from the level files: they are rebuilt on every load from the item table shared by the whole game. A saved game holds the level records and the current level's number and sublevel, not the level files' contents; see saving and restoring.
Sources
Locations refer to the game executable reference; comparative sources are listed in the technical references.