Camp menu and spells
Overlay 247 · image 0x428d0–0x44f1e (9,807 bytes) · 8 stub entries
All overlays · ← 246 · Setting up the new party · 248 · Resting →
In brief
Overlay 247 is the camp menu and everything it opens for spellcasters: choosing a caster, the memorize and pray menus with their spell lists and slots, and copying a scroll into a spell book. From the camp the player can also rest, save, load, remove a character or leave the game. The overlay also holds the small menu toolkit these screens share: building a menu from its table, drawing a button, a timed message box and a yes/no question, which the rest overlay uses as well. The rules are described in magic and the party.
Every address on this page is a file offset in START.EXE; calls into resident code are given as analysis addresses. See how addresses are written.
How it fits together
Where the camp menu leads. Dashed boxes are outside this overlay.
The spell slots, selection lists and scroll copy are listed below; which menu calls each of them is not recorded here.
Menu tables
Build and show a menu reads two tables:
| Location | Contents |
|---|---|
DS:0xb98 | Menu definitions, 5 bytes each: title string, text window, first button definition, button count, title colour. Menus 0 to 6 are used. |
File 0x275e0 | Button definitions, 10 bytes each: label string, x (word), y, width, height, key code (word), flags (word: bit 0 draws a box, bit 1 lets the pointer highlight the button, bit 2 centres the label). |
The menus are: 0 the camp menu (Rest Party, Memorize Spells, Pray for
Spells, Scribe Scrolls, Preferences, Game Options, Exit); 1 the game
options (Load Game, Save Game, Drop Character, Quit Game, Exit); 2
the preferences; 3 the choice of a character (Exit and the six portrait
boxes); 4 the spell menu (Clear, Exit, the list and six tabs); 5 the
yes/no question (Yes, No); 6 the scroll menu (Exit and the list). The
camp menu rewrites the title bytes of menus 0, 1 and 2 to "Camp:", "Game
Options:" and "Preferences:" before building them (0x4465b–0x44678).
Strings are read from the camp string list at file offset 0x2c170, whose
entries 21 and 22 are "ON" and "OFF".
Entry points
Stub entries whose target is resolved, from the stub bytes or another independent anchor, or through the portal reading.
| Encoded entry | Target | Role |
|---|---|---|
| entry 0 | 0x4448c | Camp menu, called through the camp button of the button lists |
| entry 1 | 0x43af8 | Build and show a menu |
0x7b8:0x2a (entry 2) | 0x43a98 | Save the strip below the view |
0x7b8:0x2f (entry 3) | 0x43ac8 | Restore the strip below the view |
| entry 4 | 0x43ef7 | Draw a menu button |
| entry 5 | 0x43d92 | Message box |
| entry 6 | 0x43eb9 | Free a button list |
0x7b8:0x43 (entry 7) | 0x44cc9 | Yes/no question |
All eight targets are read from the stub bytes. Entries 2 and 3 are also
called by the dream sequence (0x4bd4c,
0x4bccf), entry 7 by the
rest; the other entries are reached only from
inside the overlay.
Routines at a glance
| Routine | Address |
|---|---|
| Remove a character and fill its slot | 0x428d0 |
| Character spell slots | 0x4295c, 0x429ec, 0x42ae2 |
| Spell selection lists | 0x42a65, 0x42ba5 |
| Choose a spellcaster | 0x42cb4 |
| Draw a spell-list line | 0x431ae |
| Memorize and pray menus | 0x432af |
| Camp menu | 0x4448c |
| Copy a scroll | 0x4403c |
| On/off label | 0x43a6f |
| Save and restore the strip below the view | 0x43a98, 0x43ac8 |
| Build and show a menu | 0x43af8 |
| Draw a menu button | 0x43ef7 |
| Free a button list | 0x43eb9 |
| Message box | 0x43d92 |
| Yes/no question | 0x44cc9 |
Spell slots and scrolls. The routines at 0x42xxx lie inside the image of
overlay 247, which has function prologues at 0x4295c, 0x42ae2 and
0x42cb4.
Routines
Remove a character and fill its slot
| Address | Range |
|---|---|
0x428d0 | 0x428d0–0x4295b (image start) |
Its only caller is 0x4481b, in the same overlay.
Argument: a character. For a present character (mask 1), calls
the removal of a character; then, for a character
in slots 0 to 3, exchanges its record with that of
slot 5, or of slot 4 when no character is present in slot 5 (0x4293c);
finally makes character 0 the
selected character (0x42947) and redraws.
Used by: Recruiting and dismissing characters
Character spell slots
| Address | Range |
|---|---|
0x4295c, 0x429ec, 0x42ae2 | 0x4295c–0x42ae1 (reader), 0x42ae2–0x42cb3 (writer) |
Read and write the two 80-byte spell-slot arrays of a
character for the
menu. The reader 0x4295c(character, slot counts, allowed
mask, kind) clears the menu tables (DS:0x6c9a page lists, of which it
clears only 0x50 of the 88 bytes, 0x4297e; DS:0x6cf2 copies per
level; DS:0x6cfa two bytes per spell ID, total and ready copies),
copies the group bytes to DS:0x6c76, then counts every
nonzero slot of the array of that kind (0x42a18–0x42a5c): the level is
the ID's group, a positive value is also counted as ready, and the value
29 is skipped for both kinds (0x42a28, ANOMALY-65). It then builds the
page lists. The writer 0x42ae2(character, kind) clears the
array, writes 29 into cleric entry 0 for kind 1 only (0x42b32–0x42b42),
then for IDs 1 to 32 writes min(ready, total) copies as +ID
(0x42bd0, 0x42bfc) and the remaining copies as −ID (0x42c64,
0x42c91, setting DS:0x6d42 to 1 at 0x42c2f), each into the first
zero entry of the ten entries of the ID's group (0x42b96–0x42ba1,
0x42c24–0x42c2d); a copy with no free entry is dropped. Lay on Hands
(cleric ID 28, group 8), which the rest writes among the first ten cleric
entries, is thus moved to entries 70 to 79 (ANOMALY-70).
Anomaly: ANOMALY-151: the
writer computes the ten-slot block as group − 1 with no test for group 0
(0x42b96–0x42ba1, 0x42c24–0x42c2d), whereas the list builder has one
(0x42aa0). The group table is copied with a string copy (0x429e4, routine
0x17570), which stops at the zero at index 28 of
DS:0x0bdc, so cleric IDs 29 to 32 have group 0. With group
0 the reader's count goes to DS:0x6cf1 (0x42a4a–0x42a51). The book's cast
leaves value 29 unchanged (0x22632, resident code). Of the page lists, bytes
DS:0x6cea–0x6cf1 are not cleared (0x4297e); the rows read list entries 1 to 8
only (0x43571–0x4359b).
Used by: Anomalies and bugs, Anomalies and bugs, Character record › In brief, Character record › Spell slots, Magic › How the game stores spells, Learning and memorizing spells › Memorizing and praying, Mage and cleric spells › Special entries, Learning and memorizing spells
Spell selection lists
| Address | Range |
|---|---|
0x42a65, 0x42ba5 | — |
0x42a65–0x42ada, in the slot reader, builds one list per
spell level (DS:0x6c9a, 11 bytes each: a count, then up to ten IDs):
IDs 1 to 32 in order whose bit is set in the allowed mask, for kind 1
only on levels with slots (0x42a8b–0x42a9e), skipping group 0
(0x42aa0). 0x42ba5 lies inside the writer, at its search
for a free entry.
Used by: Character record › In brief, Learning and memorizing spells › Memorizing and praying
Choose a spellcaster
| Address | Range |
|---|---|
0x42cb4 | 0x42cb4–0x431ad |
Its argument is the prompt, an index of the string list at
file offset 0x2c170: 23 to memorize, 26 to pray, 49 to copy a scroll
(0x4403c, 0x440f0), 53 to drop a character (0x44814); with prompt 53 every present character
qualifies, without the class, food and consciousness tests
(0x42d1b–0x42d36), and the paladin and spellbook tests are skipped
(0x43116). Prompt 26 selects clerics and paladins (class mask 0x14),
any other mages (0x02; 0x42cbc–0x42cca). A character qualifies when
present, of a matching class, with food above 0 and conscious; otherwise strings 27 or 28 ("No party members are capable
of …"), or 72 and 73 when no character of the class is in the party.
When exactly one qualifies it is returned at once (0x42eae–0x42f00)
after the paladin test only: a paladin of level 8 or less gets string 24
"Your Paladin is too low a level for spells." (0x42ee6). After a choice
among several, the same test (0x43144) and, for a mage, a search of its
inventory for an item of type 29, the spellbook (0x4315b–0x43184,
string 25 "The Mage has no Spell Book!"); the single-character path skips
that search (ANOMALY-68).
The input loop takes W, A, keypad 4 and keypad 8 as "back", S, Z, keypad 2
and keypad 6 as "forward", Enter and keypad 5 as "choose", F1 to F6 or a click
as the buttons 0x8011–0x8016, and E or Escape as "leave"; its jump table is
at file offset 0x431a0.
Used by: Learning and memorizing spells › Memorizing and praying, Anomalies and bugs, Camp menus › Choosing a character, Recruiting and dismissing characters
Draw a spell-list line
| Address | Range |
|---|---|
0x431ae, 0x431ec | 0x431ae–0x432ae |
0x431ae(spell ID, row, kind, overlay, highlight) draws one line of the
spell menu list, 9 rows per line from y 50. For a spell, it
formats the name, chosen at 0x431ec–0x4321a between the cleric (kind
≠ 0) and mage spell name tables, with the spell's
total copies, and draws it at x 8 in colour 6 when highlighted, 15
otherwise; with overlay set it draws without a background, otherwise
over the window background. ID 0 clears the line. 0x431ec is a branch
inside this routine, not a routine of its own.
Used by: Magic › How the game stores spells, Mage and cleric spells › Special entries, Spell name entry › Layout
Memorize and pray menus
| Address | Range |
|---|---|
0x432af | 0x432af–0x43a3b; slot counts at 0x432c0–0x4346c. |
Opens the spell menu of a character, for mage spells (second
argument 0) or cleric spells (1). It first computes the slots of each spell
level from the slot tables and the level of the casting
class component: mage, cleric with the wisdom bonus
indexed by wisdom − 12 without an upper bound (0x43341–0x4334e), or
paladin. It passes them with the allowed spells — the known mage spells,
or the masks 0xf7ffffff (cleric) and 0x0a9bbd1d (paladin) — to the
slot routines. With an ITEM_TYPE_RING of value 1 in a ring
slot (ring search), the mage branch doubles the
slots of spell levels 4 and 5 (0x43447–0x43469); the cleric and paladin
branches do not test it. The menu record DS:0x0bac gives the title
"Spells Available:", Clear, Exit, the list area and six tabs. Each
page draws its list (0x431ae, format DS:0x0e6d, the name and the total
copies) and "%d of %d Remaining." (DS:0x0e77, 0x435e2–0x43628). Input
(0x436b8–0x439dd, jump tables at 0x43a41 and 0x43a55): add
(0x43911: free slots and a highlight ≥ 0 needed; increments the
spell's total and the level's count), remove (0x43977: the level has
slots and the spell a copy), clear (0x43873), pages (0x801a–0x8020;
keypad 4 from page 0 to code 0x8020 at 0x436f8, keypad 6 modulo 8 at
0x436e5, ANOMALY-67), highlight (the pointer, keypad 8, 2, 7, 1;
clamped to 0 when the list is empty, 0x43648–0x4365b, ANOMALY-66), exit
(0x438d3). After the loop it redraws the portrait and always calls the
writer (0x439eb–0x43a38).
Comparative source: REF-SCUMM-014, GUI_EoB::runMemorizePrayMenu.
Used by: Anomalies and bugs, Anomalies and bugs, What worn items change › Defense and rings, Spell slots, Learning and memorizing spells › Memorizing and praying, Spell slots › Spell slots per level, Attributes and classes › Attributes, Texts, Character record
Camp menu
| Address | Range |
|---|---|
0x4448c | 0x4448c–0x44c96 |
Reached only as the callback of the camp button (record DS:0x3ae4, keys C
and Esc), whose far pointer 0x2ad2:0x20, entry 0 of the stub, is stored in
the record at DS:0x3b14; no code calls it directly. Among its choices,
asks for a character with 0x42cb4 and opens
the memorize menu (0x448b3) or the pray menu
(0x448ce). Leaving it (0x4495d) shows " Your party needs to rest to
gain spells." (string 44) while DS:0x6d42, set by the
slot writer for a waiting copy, is nonzero. The
rest is called at 0x44884: a result of 0 clears the
flag (0x44894) and stays in the camp; a nonzero result sets the loop variable
to 0 (0x4488d), which closes the camp without passing 0x4495d and keeps the
flag. It stops the shared counter on entry
(0x4449d) and restarts it on leaving (0x44c7c). The save choice calls
the save menu at 0x44941 and stays in the menu afterwards
(0x44957); a successful load (0x4491b) leaves it (0x4492c–0x44930).
The exit choice asks string 46, whether to exit the game, through
the yes/no question and on yes ends the program
(0x4499e–0x449b5). On leaving, it runs the
party status check with argument 1 (0x44c87).
The key table DS:0xe69 maps Escape (key 0x6e) to the button code 0x8007,
the code of the camp's Exit. Two jump tables select the code of a button:
file offset 0x44c97 for the button codes 0x8006–0x800f, then 0x8001–0x8004,
and 0x44cb3 for the keys 0x5b–0x65. The Exit buttons of the game options
and preferences menus (0x800c, 0x800f) jump to 0x4496e, past the rest
reminder at 0x4495d, which only the camp's Exit and Escape reach. The
Sounds and Bar Graphs lines toggle their option at 0x448df and 0x448f6.
Keypad 7 and 9 (0x449c1) select the first button. Keypad 1 and 3
(0x449e9) find the last button of the menu, store it in [bp-0x16] and set
the key to 0x60, then fall through into 0x44a25–0x44ab8, the code of
keypad 8, which moves up from the highlighted button and replaces that
aim (ANOMALY-159).
Comparative source: REF-SCUMM-014, GUI_EoB::runCampMenu.
Used by: Anomalies and bugs, Learning and memorizing spells › Memorizing and praying, Spell slots › Spell slots per level, The game clock › Pauses, The game loop › How the game ends, The game loop › When the party is defeated, Camp menus › The camp menu, Recruiting and dismissing characters, The start menu, questions and text, The play screen
Copy a scroll
| Address | Range |
|---|---|
0x4403c | 0x4403c–0x4448b |
Copies a scroll: filters the known spell bits, updates the character and consumes the item.
Used by: Character record › Known mage spells, Item entry › Layout, Item types › Where it is used, Learning and memorizing spells › Learning from scrolls, Spell name entry › Layout
On/off label
| Address | Range |
|---|---|
0x43a6f | 0x43a6f–0x43a97 |
Returns the camp string "ON" for a nonzero argument and "OFF" otherwise.
The camp menu formats four preference lines with it: tunes, sounds, bar
graphs and mouse (0x44585–0x44620). Only the lines "Sounds" and "Bar
Graphs" are shown, by the button definitions 12 and 13 (labels 18 and 19);
no button shows the strings 17 "Tunes" and 20 "Mouse".
Used by: Camp menu, Camp menus › The camp menu
Save and restore the strip below the view
| Address | Range |
|---|---|
0x43a98, 0x43ac8 | 0x43a98–0x43ac7, 0x43ac8–0x43af7 |
0x43a98 saves the 176 × 24 strip of the screen below the dungeon view
(x 0, y 120) into the shared buffer at offset 20,000,
through driver slot 44, which reads
page 0; 0x43ac8 copies it back through slot 8, the
restore routine. The camp menu saves the strip when it
opens (0x44509), again after a game is loaded (0x4492c) or a character
dropped (0x44834), and restores it when it closes (0x44bd7). The
dream sequence restores the strip before its
dialogue (0x4bccf) and saves it again after (0x4bd4c).
Used by: Camp menu, Camp menus › The camp menu
Build and show a menu
| Address | Range |
|---|---|
0x43af8 | 0x43af8–0x43d91 |
0x43af8(menu) builds menu n of the menu definitions
on page 2: when the menu has a text window, it sets the window's background
to the interface colour DS:0xe606, selects the window and draws its box;
it prints the title in the title colour at (5, 5); then, for each button,
allocates a 60-byte button record from a template (DS:0x39b8), fills its
number (definition + 1), key code, position, size and flags from the
button definition, draws it and links it into
a list. It copies the window to the screen, flushes the input queue and
returns the list. Callers: the camp menu (menus 0 to 2, 0x4467e), the
spellcaster choice (menu 3, 0x42f0e), the
spell menu (menu 4, 0x434ab), the scroll menu (menu 6,
0x441f0) and the yes/no question (menu 5).
Comparative source: REF-SCUMM-014, GUI_EoB::initMenu.
Used by: Camp menu, Menu tables, Camp menus › The camp menu, Camp menus › How the camp menus work, Choosing a spell in the book, How input works › The active button list
Draw a menu button
| Address | Range |
|---|---|
0x43ef7 | 0x43ef7–0x4403b |
0x43ef7(button, pressed, highlighted, plain) draws a button's box when
its flag bit 0 is set (raised or pressed), then its label at offset (4, 3),
or centred when flag bit 2 is set, in colour 6 when highlighted and 15
otherwise. A null button is ignored.
Comparative source: REF-SCUMM-014, GUI_EoB::drawMenuButton.
Used by: Build and show a menu, Yes/no question, Camp menus › How the camp menus work, The start menu, questions and text
Free a button list
| Address | Range |
|---|---|
0x43eb9 | 0x43eb9–0x43ef6 |
Follows the link of each button record and frees it, to the end of the
list built by 0x43af8.
Comparative source: REF-SCUMM-014, GUI_EoB::releaseButtons.
Used by: Build and show a menu
Message box
| Address | Range | Status |
|---|---|---|
0x43d92 | 0x43d92–0x43eb8 | The duration in seconds depends on the display's refresh rate |
0x43d92(string) shows a camp string in text window 11 (a 160 × 56 box
at (8, 20)) with the small font, then waits until a key or button is
pressed, or at most 120 screen refreshes
(0x43e6c–0x43e8f), and restores the page, font and window. Messages shown this way include the refusals of
the spellcaster choice, "You cannot have less than four
characters." when the party has fewer than five characters to drop one
from (0x447fd–0x44808), "Game saved." and "Your party needs to rest to
gain spells.".
Used by: Choose a spellcaster, Camp menu, The start menu, questions and text › Questions and messages, Camp menus
Yes/no question
| Address | Range |
|---|---|
0x44cc9 | 0x44cc9–0x44f1e (image end) |
0x44cc9(string) asks a camp string in text window 11 with the Yes and
No buttons of menu 5, and returns 1 for yes and 0 for no. Yes is
highlighted first. Keypad 5, Enter and Space choose the highlighted button;
keypad 4 and 6 move the highlight; Y and N, or a click on a button, choose
directly; outside keyboard mode the pointer moves the highlight. The
highlighted button is then drawn pressed for a moment (0x44e99–0x44ee3),
even when the answer came from the other button's key: this is
ANOMALY-90. The camp menu asks
whether to exit the game (0x449a3); the rest
asks four questions with it.
Comparative source: REF-SCUMM-014, GUI_EoB::confirmDialogue.
Used by: Camp menu, The start menu, questions and text › Questions and messages, The start menu, questions and text, Anomalies and bugs
Sources
The executable is identified in the file inventory; the overlay layout is described on the overlays page. Comparative sources are listed in the technical references.