Saving and restoring
Home · The engine in ten minutes · The world · The game clock · Saved games (SAV)
In brief
A saved game is a snapshot of the whole adventure: the six characters, the
party's position, every item in the game, the script flags, the game options
and one record per dungeon level. A level's record keeps what changes there
during play: its walls, its 30 monsters and its temporary walls. The game uses
the same records when the party leaves a level: the level being left is
written to a temporary file, LEVELS.TMP, and restored from it when the party
comes back. Everything else about a level is read again from the level files
each time the level is loaded.
Positions are written [XX:YY], column then row, both counted from 00;
block index = YY × 32 + XX.
What a saved game holds
The save menu writes slot n to EOBDATA<n>.SAV. The file has no header:
it is seven parts, one after the other, each a copy of part of the game's
memory.1
| Part | Size in bytes | Contents |
|---|---|---|
| 1 | 20 | The slot's description, as typed in the save menu. Loading ignores it. |
| 2 | 6 × 345 | The six characters, with each timer stored as the time it has left. |
| 3 | 92 | Party and world variables: current level and sublevel, the party's block and direction, the held item, which levels have a record, the level and global script flags, the rest refusal flag, a spell-related value and one byte whose role is not established. |
| 4 | 600 × 14 | Every item, wherever it is: on any level, carried, or unused. |
| 5 | 17 × 2,130 | One level record per level; only the levels marked in part 3 are used. |
| 6 | 3 | The options: tunes, sounds and bar graphs. |
| 7 | 6 × 16 | The six item types the game creates at run time for conjured weapons, types 51 to 56. |
Every field of each part is described by the
saved-game schema. The only other call to the writer
found in the game passes slot −1, which writes the same layout to
FINAL.SAV at the end of the game.2
What persists, at a glance
| State | When the party changes level | In a saved game |
|---|---|---|
| Characters, their timers and inventories | Kept | Saved; timers keep the time they have left |
| Party block and direction | Set by the level change | Saved |
| Held item | Kept | Saved |
| Level and global script flags, rest refusal | Kept | Saved |
| Items, on every level | Kept in the shared table; block lists rebuilt | Saved |
| Walls, including doors and scripted changes | Kept in the level's record | Saved in the level records |
| Monsters | Kept in the level's record | Saved in the level records |
| Temporary walls | Kept in the level's record, with the time left | Saved in the level records |
| Flying objects | Ended before the change | Ended before saving |
| Doors in motion | Finished before the change | Finished before saving |
| Timed block scripts, step counter | Restarted from the new level's files | Not saved; restarted on loading |
| Scripts, cell bindings, wall properties, monster update intervals | Read again from the level files | Not saved; read again on loading |
| Game counter and periodic updates | Carry on | Not saved; character timer updates scheduled again |
| Move count that scrolls the messages | Carries on | Not saved; loading leaves it as it is |
| Options | Kept | Saved |
| Conjured-weapon item types | Kept | Saved |
The pages of this chapter
| Page | What it covers |
|---|---|
| Level records and level changes | Settling a level, its record, a new game, changing level. |
| Loading, failures and the end of the game | Loading, failed saves and loads, FINAL.SAV, edge cases. |
Sources
Locations refer to the game executable reference; comparative sources are listed in the technical references. File sizes and hashes are in the file inventory.