Level maps (MAZ)
File formats · Field reference · Schema
In brief
A MAZ file is the wall plan of a dungeon level: a grid of 32 × 32 cells, and for each cell four numbers, one per side, that say which wall stands there. A number is only a reference: the graphics of a wall, whether monsters or projectiles can pass and any special action it has come from the level's INF file, whose wall mappings fill per-level tables indexed by these numbers.
The DOS game has 15 MAZ files, LEVEL1.MAZ to LEVEL15.MAZ. INF files name
the map they use, and the numbers do not always match: LEVEL6.INF uses
level5.maz, and LEVEL14.INF uses level12.maz.
Which level uses which file.
Organization
Reading the header as width, height and cell size is inferred.
| Part | Size | Contents |
|---|---|---|
| Header | 6 bytes | Three 16-bit numbers: 32, 32 and 4 in every file. |
| Cells | 4096 bytes | 1024 records of four wall references, in row order. |
Record i is the cell in column i mod 32, row i div 32; the game's
distance calculation uses the same split.1 Below, a cell is
written [XX:YY] for column XX and row YY, so record i is cell
[XX:YY] with i = YY × 32 + XX.
Row 00 is the northern edge of the level and column 00 its western edge.
The four bytes of a record are the cell's faces turned north, east, south and
west, in that order (Direction).2
Reading the file
The game reads a level's map each time it loads the level, from the name that the level's INF file gives. The game's loader reads exactly these 6 + 4096 bytes and copies the 1024 records in order into its block table, so a grid of another size would not fit it. It never checks the header: the six bytes are read into the first block of the table, where the copy of the cells overwrites the first two numbers and the third one stays as that block's state (an anomaly). Nor does it check how many bytes the reads return: with a shorter file, the missing cells would come from what the read buffer last held, on a level load the level's compressed INF file (inferred).3 The first two numbers are overwritten before anything reads them, so nothing in the game depends on them or on the order of width and height: the game always reads a 32 × 32 grid. Only the third number has an effect, as that block's state.
On a level change, the game can keep the current level's state in
LEVELS.TMP. If the level being loaded has such a record, the map loader
restores the block table from it instead of using the MAZ data; see
returning to a level.4
What it becomes in memory
The cells become the wall references of the 1,024
blocks of the current level, the
four bytes of each record in the order of the
Direction values. Moving, the
dungeon view, doors
and scripts read and change them there; a level
the party leaves keeps its changed walls in
LEVELS.TMP.
In the original files
A level's INF file names its map, and the numbers do not
always match. LEVEL6.MAZ is named by no INF file and by no string of the
executable, so the game never loads it. Each file has
four references per cell, 4,096 in all.
| File | Used by | Different references | No wall (0) | Solid walls (1, 2) | Closed doors (3, 8, 13, 18) |
|---|---|---|---|---|---|
LEVEL1.MAZ | LEVEL1.INF | 23 | 724 | 3,167 | 20 |
LEVEL2.MAZ | LEVEL2.INF | 32 | 960 | 2,869 | 40 |
LEVEL3.MAZ | LEVEL3.INF | 29 | 1,478 | 2,306 | 44 |
LEVEL4.MAZ | LEVEL4.INF | 7 | 348 | 3,714 | 0 |
LEVEL5.MAZ | LEVEL5.INF, LEVEL6.INF | 34 | 1,002 | 2,773 | 44 |
LEVEL6.MAZ | none | 35 | 1,160 | 2,565 | 42 |
LEVEL7.MAZ | LEVEL7.INF | 34 | 1,152 | 2,537 | 42 |
LEVEL8.MAZ | LEVEL8.INF | 25 | 1,250 | 2,683 | 30 |
LEVEL9.MAZ | LEVEL9.INF | 26 | 1,258 | 2,350 | 10 |
LEVEL10.MAZ | LEVEL10.INF | 15 | 522 | 3,477 | 6 |
LEVEL11.MAZ | LEVEL11.INF | 27 | 1,304 | 2,361 | 22 |
LEVEL12.MAZ | LEVEL12.INF, LEVEL14.INF | 33 | 1,646 | 1,948 | 48 |
LEVEL13.MAZ | LEVEL13.INF | 20 | 1,926 | 1,949 | 26 |
LEVEL14.MAZ | LEVEL15.INF | 23 | 918 | 2,929 | 18 |
LEVEL15.MAZ | LEVEL16.INF | 15 | 732 | 3,218 | 36 |
The 15 files hold 61,440 wall references. References 1 and 2, the plain
solid walls, account
for 20,429 and 20,417 of them; both occur in all 15 files, and no
INF wall mapping names either. Of the references of
closed doors, 3 and 8
occur in every file except LEVEL4.MAZ, 13 in LEVEL2.MAZ, LEVEL5.MAZ and
LEVEL6.MAZ, and 18 in LEVEL2.MAZ and LEVEL6.MAZ.
Example
The first 18 bytes of LEVEL1.MAZ:
offset bytes meaning
0000 20 00 20 00 04 00 header: 32, 32, 4
0006 01 01 02 02 cell [00:00]: four wall references
000a 02 02 01 01 cell [01:00]
000e 01 01 02 02 cell [02:00]
What 01 and 02 stand for depends on the wall mappings of the INF file that
uses this map.
Related pages
- The world and
LevelBlockRuntime: how the game uses the wall references at run time. - Level data (INF): wall mappings, decorations and the scripts attached to cells.
Sources
Locations refer to the game executable reference;
comparative sources are listed in the technical references
(REF-MW-002, REF-SCUMM-004,
REF-SCUMM-005).
The files are identified in the
file inventory.