Skip to main content

Sublevels

The world · Changing level · Levels with a second sublevel record

In brief​

Six levels have two sublevel records in their INF file: 1, 3, 7, 8, 11 and 16. Both records of a level name the same map, graphics, palette and sound; the second one has other monster images and types and, depending on the level, other doors, wall mappings, decorations, step limit or timers. Changing sublevel is an ordinary level change to the same level number: the walls, the monsters and the temporary walls carry over, and everything else comes from the new record.

Positions are written [XX:YY], column then row, both counted from 00; the block index is YY × 32 + XX.

What a change of sublevel keeps and what it takes from the new record. Carried over through the level record: the walls, the 30 monster slots and the temporary walls. From the new sublevel record: resources and doors, monster images and types, wall mappings and decorations, the step limit and the timers. Read again and shared by both records: the scripts and the cell bindings.
The level record keeps what changed in play; the new record brings everything else.

The two records​

An INF file can hold more than one sublevel record. Six levels have two (1, 3, 7, 8, 11 and 16), and both name the same map, graphics, palette and sound. The second record always has other monster images and types; depending on the level, it also has other doors, wall mappings, decorations, a different step limit or other timers. Each record can name only two monster images, so the second one most likely lets a part of the level show other monsters (inferred).1 Levels with a second sublevel record lists the monsters each change keeps, by type and bank, and the type entries it rewrites.

The game selects the record by its index: the sublevel of the level-change instruction, of the saved game, or 0 for a new game. In the original scripts, 11 instructions select a second record:

LevelTaken fromBack to the first record
1Stairs at [17:05] and [23:01]; stairs from level 2Stairs at [19:05]
3Stairs at [08:01]Stairs at [06:01]
7Stairs at [09:13]; stairs from level 8Stairs at [08:13]
8The switch in place at [12:14] (three instructions)Only by leaving the level
11Teleporter at [01:18]Teleporter at [06:23]
16Stairs at [25:08]Stairs at [26:08]

Changing sublevel​

Changing sublevel is an ordinary level change to the same level number, and a level has a single record in LEVELS.TMP whatever its sublevel. So the change writes the level's record and reads it straight back: the walls, the 30 monster slots and the temporary walls carry over unchanged. What comes from the new sublevel record is everything that level data marks "every load": resources, doors, monster images and types, wall mappings and decorations, the step limit and the timers. The scripts and cell bindings are shared by all the records of a level and are read again.

Each monster slot remembers the sublevel that was current when the monster was placed, but only the script conditions that count monsters read it. After a change, the monsters kept in the slots are unchanged (type and image numbers, block, position, hit points and state) and go on moving and are drawn like the others, so their type and image numbers now select the new record's types and images. The loader writes only the type entries the new record defines and never clears the table, so the other entries keep the values of the last record that defined them. It releases the shapes of both image banks and loads only the images the new record names. The second records of levels 1, 3, 7, 8 and 11 name a single image, in bank 0, so after the change the kept monsters of bank 1 have no image (released shapes). Coming back to the first record loads its types and images again.

Sources​

Locations refer to the game executable reference; comparative sources are listed in the technical references.

Footnotes​

  1. Select a sublevel, write a level record, the map reader, the initial monster states, the sublevel and the count of monsters for a condition, the only reader of a slot's sublevel; the records are compared with the INF schema. ↩