Skip to main content

Creating a party

Overlay 245 · image 0x3f860–0x42069 (10,250 bytes) · 25 stub entries

All overlays · ← 244 · Drawing the dungeon view · 246 · Setting up the new party →

In brief​

Overlay 245 is the party creation screen reached from the start menu. It shows four boxes: an empty box creates a character — race, class and alignment menus, generated attributes, stats screen, portrait and name — and a named box shows that character and lets the player delete it. A created character's attributes and hit points can be modified within the creation limits. PLAY is accepted once all four boxes have a name; the party is then set up by overlay 246. The rules are described in creating the party.

The overlay also holds the screen's own display and input layer: it loads the creation images, builds and draws the screen's buttons, shows a character in the side panel, draws the names under the boxes, runs the portrait menu and animates the box being created.

Addresses

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​

Dashed boxes are outside this overlay.

Every screen above builds its buttons with 0x3fc54, reads input through 0x3f910, draws in the side panel and, while a character is being created, animates its box.

Tables​

Read by the routines below; far tables outside the data segment are given as file offsets.

LocationContents
file 0x2733041 button definitions of 8 bytes: x (8-pixel columns), y, width, height, key code. 0–3 the boxes, 4 PLAY, 5 OK, 6 DELETE, 7 a button with key 0x32 at the OK position (the menus' back key), 8–20 menu lines, 21–22 portrait arrows, 23–26 portraits, 27–30 REROLL, MODIFY, FACES, KEEP, 31–37 modify fields, 38–40 +, −, OK.
file 0x27480Button pictures in page 2: column, row, width (columns), height; each button has a normal and a pressed picture.
file 0x274c017 button drawing records of 9 bytes: label position, size and offset in the button, picture number, screen column and row.
DS:0x6d8219 far pointers to the 0x3c-byte button records, built from the template DS:0x39b8.
DS:0x75217 far pointers to the button labels.
DS:0xd0b267 far pointers to shapes, up to DS:0xd1bd: 0–43 the portraits, 50–59 (DS:0xd17a) the ten frames of the box animation; 44–49 and 60–66 are never set, and all 67 are freed when the party is complete.
DS:0x79aPortrait chosen for each box, 0xff until chosen.
DS:0x6c72Sex of the character being created, set by the race menu.
DS:0x742, DS:0x74aBox positions: x 16 or 80, y 63 or 127.
DS:0x732, DS:0x73aName fields under the boxes: x 2 or 66, y 107 or 171.

Entry points​

Stub entries whose target is resolved, from the stub bytes or another independent anchor, or through the portal reading.

Encoded entryTargetRole
0x7a8:0x34 (entry 4)0x41d53Load the creation images; called by the prepared party
0x7a8:0x4d (entry 9)0x41eccParty creation screen; called by the start menu

The stub decodes all 25 entries; the other 23 are reached only by near calls from inside the overlay, and entries 22 (0x4027a) and 23 (0x41838) have no caller found.

Routines at a glance​

RoutineAddressStub entry
Party creation screen0x41ecc9
Load the creation images0x41d534
Party-screen instructions0x408d72
PLAY when the party is complete0x3fd2910
View or delete a character0x407333
Create a character0x41bef15
Race, class and alignment menus0x4174d, 0x41867, 0x41a3d13, 21, 19
Roll an attribute0x4096214
Creation limits0x416901
Generate a character0x414666
Stats screen0x406240
Choose a portrait0x4028a7
Next free portrait0x405a317
Modify a character0x412ea, 0x40b4f16, 18
Show a character in the side panel0x3fe845
Draw a name under its box0x3fde18
Redraw a box0x409ab24
Animate the active box0x40a1611
Build a button list0x3fc54, 0x3fbd012, 20
Draw a button0x3f943—
Press a button0x3fb95—
Read the input0x3f910—
Cut the button labels0x3f860—
Highlight the first portrait0x4027a22
Find the n-th set bit0x4183823
About this overlay

Party creation. In this overlay the current creation box is the word DS:0xcb78, and the record it designates is CharacterRuntime number 0–3.

Routines​

Party creation screen​

AddressRange
0x41ecc0x41ecc–0x42053

Entry 9 of the overlay, called by the start menu at 0x47113. Loops over the four boxes: a box with a name opens view or delete, an empty box creates a character. PLAY is accepted only when boxes 0–3 all have a name (0x4200c–0x42029); the routine then calls party setup at 0x4203e.

Used by: Creating a party › Creating the party, The creation screen › Portraits, names and controls, Sound effects, Sound and music, Texts

View or delete a character​

AddressRange
0x407330x40733–0x408c8

Shows a created character; deleting it clears the first byte of its name (0x4082d), which empties the box.

Used by: Creating a party › Creating the party

Create a character​

AddressRange
0x41bef0x41bef–0x41d52

Runs the race, class and alignment menus in turn, stepping back when a menu returns 0x6e; then generates the character, opens the stats screen and asks for a name through the text input (arguments 24, 100, 10) until the name is not empty. Each round redraws the box and the side panel without buttons and prints "Name:" at (149, 100); the entered name is then drawn under the box with the length the input routine returns.

Comparative source: REF-SCUMM-017, createPartyMember.

Used by: Character record › Initialization, Creating a party › Creating the party, The start menu, questions and text › Typing text

Race, class and alignment menus​

AddressRange
0x4174d, 0x41867, 0x41a3d0x4174d–0x41837, 0x41867–0x41a3c, 0x41a3d–0x41bee

0x4174d outlines the current box (rectangle outline, colour 12), clears the side panel, prints its title, offers the twelve race and sex names and returns the race_and_sex value, keeping its sex (value mod 2) in DS:0x6c72 for the portrait menu (0x4182f). 0x41867 offers the 15 classes masked by the race's class mask (index race_and_sex / 2), minus PALADIN (mask 0xfffb) when one of boxes 0–3 with a name has an alignment of 6 or more (0x41891). 0x41a3d offers the nine alignments masked by the class's alignment mask, minus alignments 6–8 (mask 0xfe3f) when one of boxes 0–3 with a name has class_index 2 (0x41a66). Both return 0x6e for the back button.

Comparative source: REF-SCUMM-017, classMenu and alignmentMenu.

Used by: Creating a party › Race, class and alignment, Races, The start menu, questions and text › Line menus

Roll an attribute​

AddressRange
0x409620x40962–0x409aa

Rolls 1d6 four times and returns the sum minus the lowest die.

Comparative source: REF-SCUMM-017, rollDice.

Used by: Creating a party › Rolling the attributes

Creation limits​

AddressRange
0x416900x41690–0x4174c

For the current box, sets each attribute's minimum (DS:0xcc18) to the larger of the class and race minimums and its maximum (DS:0xcb64) to the race maximum, from the creation tables; the strength maximum becomes 18 when the class's strength-limit byte is not zero (0x4173a). Entry 6 of both arrays, the hit points (DS:0xcc24, DS:0xcb70), is not set here but by modify a character.

Used by: Creating a party › Rolling the attributes

Generate a character​

AddressRange
0x414660x41466–0x4168f

For one box: sets the three levels from the starting-level table and all three experience totals to 69,000 divided by its last byte (0x414b0–0x414d5); calls the creation limits; rolls each attribute with 0x40962, adds the race modifier, raises it to the minimum (0x41527), adds a percentage of 1d100 to a strength of 18 (0x41547) and lowers it to the maximum (0x41575); writes each value into both of its bytes; sets defense to 10 plus the dexterity modifier; and sums hit points for a level once per starting level of each class into hit_points and hit_points_max.

Comparative source: REF-SCUMM-017, generateStats.

Used by: Character record › Initialization, Creating a party › Rolling the attributes

Stats screen​

AddressRange
0x406240x40624–0x40732

Opens the portrait menu first, then shows the character in the side panel with REROLL, MODIFY, FACES and KEEP. Buttons 0x8001 reroll (0x41466, without limit), 0x8002 modify, 0x8003 choose another portrait (0x4028a) and 0x8004 or key 0x61 keep; each is first pressed on screen.

Used by: Creating a party › Creating the party

Modify a character​

AddressRange
0x412ea, 0x40b4f0x412ea–0x41457, 0x40b4f–0x412e9

0x412ea steps through seven fields with a jump table at 0x41458: the six attributes (strength with its percentage) and hit_points, edited through a byte copy (0x413dd–0x41411). 0x40b4f edits one field within the creation limits; when it opens the hit points, it writes the hit-point limits into slot 6 of the limits, computed at 0x40c70–0x40d19 (maximum DS:0xcb70 at 0x40cc3, minimum DS:0xcc24 at 0x40d19). Strength above 18 moves into the percentage (0x40e11–0x40ea5), which is zeroed when the maximum is below 19. A changed constitution recomputes the limits and moves hit_points and hit_points_max inside them (0x40fc5–0x41110); a changed dexterity recomputes defense (0x4118e–0x411b9). Only the first byte of each attribute is written.

Comparative source: REF-SCUMM-017, modifyStat.

Used by: Character record › Initialization, The creation screen › Modifying a character

Load the creation images​

AddressRangeStatus
0x41d530x41d53–0x41ecbThe allocation call is inferred

Entry 4, called by the party creation screen at 0x41eea and by the prepared party at 0x427af. It allocates the 19 button records of DS:0x6d82 (0x3c bytes each, resident 0x2d0eb); loads CHARGENA into page 3 through the CPS image loader and cuts its 44 portraits, ten per row of 32 × 32 pixels, through driver slot 28 into DS:0xd0b2; loads CHARGEN through 0x19338 and copies it to the screen; loads CHARGENB, cuts its first ten 32 × 32 shapes into DS:0xd17a (the box animation) and the button labels, and copies the picture to page 2 (through page 4 in display modes 0 and 1). It finally saves the screen's right-hand panel (144, 64, 160 × 128) at (0, 0) of page 2: the clean panel that every side-panel drawing starts from.

Used by: How it fits together, Prepared party, Images, palettes and fonts, Decoration, door and monster images, Dungeon graphics, Scenes and sequence pictures

Party-screen instructions​

AddressRange
0x408d70x408d7–0x40961

Called by the party creation screen on entry (0x41efe) and after each visit to a box (0x42003). Restores the clean side panel, prints the instruction text DS:0xa51, which asks for a box to create or view, at (168, 16), shows the panel, then calls 0x3fd29.

Used by:

PLAY when the party is complete​

AddressRange
0x3fd290x3fd29–0x3fde0

Counts the boxes 0–3 that have a name. With four, it prints DS:0x9c3 ("Your party is complete…", which also names the P key) at (168, 61) in the panel, copies that text to the screen and draws button 15, PLAY; otherwise it draws button 14, the same area without PLAY. The PLAY button definition stays active in both cases; the party creation screen ignores it while a name is missing.

Used by: The creation screen › Portraits, names and controls

Choose a portrait​

AddressRange
0x4028a0x4028a–0x4059a

Called by the stats screen when it opens (0x4062c) and by its FACES button (0x406c8). It builds buttons 21–26 (two arrows, four portraits), shows the side panel without a portrait and draws the arrow buttons 12 and 13. The first portrait offered is 0, or 26 when the sex DS:0x6c72 is female, moved to the next free one; four consecutive free portraits are drawn at x = 176, 208, 240, 272, y = 66.

InputEffect
left arrow button (0x8001) or key 0x5cPress button 12; in keyboard control, move the highlight left, otherwise (or from the first position) scroll back by one free portrait
right arrow button (0x8002) or key 0x66Press button 13; in keyboard control, move the highlight right, otherwise (or from the last position) scroll forward by one free portrait
a portrait (0x8003–0x8006, jump table 0x4059b)Choose that portrait
key 0x2b or 0x61Choose the highlighted portrait, the second one when the menu opens

The key codes 0x5c, 0x66, 0x2b and 0x61 are keypad 4, keypad 6, Enter and keypad 5; the grey Left and Right keys and keypad Enter give the same numbers (keyboard handler).

The highlight is the box frame 10 + position, shown only in keyboard control. The choice is stored in DS:0x79a for the box and in portrait of the CharacterRuntime (0x40547), and 0x578 bytes of the portrait shape are copied into the character's face_image buffer through the far copy (0x40581); the side panel is then redrawn with the stats buttons.

Comparative source: REF-SCUMM-017, faceSelectMenu.

Used by: Stats screen, The creation screen › Portraits, names and controls

Next free portrait​

AddressRange
0x405a30x405a3–0x40623

0x405a3(start, sex, step, chosen): from start (a negative value becomes 43), modulo 44, steps by step (±1) until it finds a portrait that no box 0–3 with a name has chosen and that suits the sex: portraits 0–28 for a male, 26–43 for a female, so 26–28 are offered to both. Called four times by the portrait menu.

Comparative source: REF-SCUMM-017, getNextFreeFaceShape.

Used by: Choose a portrait, The creation screen › Portraits, names and controls

Show a character in the side panel​

AddressRange
0x3fe840x3fe84–0x40279

0x3fe84(box, mode), entry 5, called from ten places. It restores the clean side panel in page 2 and, except in mode 4, draws the character's face_image at the top of the panel; it prints, centred in the panel by name length, the name, the race and sex name and the class name; the labels STR to CHA (DS:0x1ee6) with the six attributes (strength as strength text), then "AC", "HP" and "LVL" with defense, hit_points_max and the levels, shown as one, two or three numbers depending on levels[1] and levels[2] (formats DS:0xa27–0xa48, through the buffer). The mode adds buttons: 1 REROLL, MODIFY, FACES and KEEP; 2 DELETE and OK; 3 +, − and OK; 0 and 4 none. The panel is then copied to the screen at (144, 64).

Comparative source: REF-SCUMM-017, printStats.

Used by: The creation screen › Portraits, names and controls

Draw a name under its box​

AddressRange
0x3fde10x3fde1–0x3fe83

0x3fde1(box, length, colour): with the font DS:0x9342 (installed for the call), blanks the box's name field (ten spaces in colour 12) and prints the name centred in 60 pixels by length times the font's character advance. Create a character calls it with the value returned by the text input and colour 2, which is −1 when the player ends the name with Escape (0x41d1f–0x41d33; ANOMALY-125); deleting a character (0x40733) calls it with colour 12 after emptying the name, which only clears the field.

Comparative source: REF-SCUMM-017, processNameInput.

Used by: The creation screen › Portraits, names and controls, Anomalies and bugs

Redraw a box​

AddressRange
0x409ab0x409ab–0x40a15

0x409ab(selector) turns the box frame off, then draws button selector − 50 when selector is above 48, or the current character's face_image in its box otherwise. Deleting a character passes box + 50, which draws the empty box. The name step of create a character passes the hit-point minimum DS:0xcc24 (0x41cbf), tested at 0x409c2; the portrait is drawn whenever that minimum is 48 or less. That argument is the proof of ANOMALY-96.

Comparative source: REF-SCUMM-017, processFaceMenuSelection.

Used by: Create a character, View or delete a character, The creation screen, Anomalies and bugs

Animate the active box​

AddressRange
0x40a160x40a16–0x40b4e

Entry 11, called on every pass of the race, class and alignment menus, the stats screen, the portrait menu and the modify editor. It cycles the ten CHARGENB frames of DS:0xd17a in the current box: when the free-running counter is past the time stored in DS:0x6c6e, it takes the next frame (0 after 9) and sets the time two ticks ahead, so a new frame appears at most every third tick. A change of box restarts the timing. Each new frame is drawn over the box's clean background from page 2 and copied into the box.

Comparative source: REF-SCUMM-017, updateMagicShapes.

Used by: The creation screen › Portraits, names and controls

Build a button list​

AddressRange
0x3fc54, 0x3fbd00x3fc54–0x3fd28, 0x3fbd0–0x3fc53

0x3fc54(first, count) (entry 12) fills button records 0 … count − 1 of DS:0x6d82 from the button definitions first onwards through 0x3fbd0 (entry 20), links them in order with the list append routine, sets DS:0x6389, so that the next button-list pass takes the list again although its address has not changed, and returns the first record. 0x3fbd0(index, x, y, w, h, key) copies the template DS:0x39b8 into the record and sets its number (index + 1), its key, its rectangle (x in columns, multiplied by 8) and the flags 0x1100. The screens use the lists (0, 5) party screen, (0, 7) view or delete, (21, 6) portraits and (27, 4) stats. A click on the k-th button of a list, counted from 1, is returned as 0x8000 + k (from the uses).

Comparative source: REF-SCUMM-017, initButtonsFromList and initButton.

Used by: How it fits together

Draw a button​

AddressRange
0x3f9430x3f943–0x3fb94

0x3f943(index, state, mode) draws button index (none for 17 or more, unsigned test at 0x3f94e) from its drawing record: the normal (state

  1. or pressed (1) picture from page 2, then its label. In mode 0 the button is put together at (160, 0) of page 2 and copied to its place on the screen; in mode 2 it is drawn only into the side-panel copy of page 2, at the place that the side panel later shows. The 14 call sites pass only these two modes. Another value would be put together at the panel position, as for mode 2, and then copy (160, 0) of page 2 to the screen (0x3fa8e–0x3fb8a).

Comparative source: REF-SCUMM-017, drawButton.

Used by: How it fits together

Press a button​

AddressRange
0x3fb950x3fb95–0x3fbcf

Draws the button pressed, plays sound 76, waits through the refresh wait (argument 5) and draws it released. Called from 14 places whenever a button or its key is used. While the INTRO sound file is loaded, entry 76 is empty in both INTRO.ADL (255) and INTRO.SND (0), so the request for sound 76 is not heard (ANOMALY-158).

Comparative source: REF-SCUMM-017, processButtonClick.

Used by: How it fits together, Sound effects, Sound effects, Anomalies and bugs

Read the input​

AddressRange
0x3f9100x3f910–0x3f942

Returns the key reader's code for the given button list. Before that, when the byte of the embedded music driver read by the introduction's music waits (resident 0x10250) is 1, it clears it and plays sound 13, the sound the party creation screen starts when it opens (0x41f15). With the AdLib driver, sound 13 of INTRO.ADL is a tune of 69.3 seconds (5,047 driver ticks) that never sets that byte: run on the driver's code it stops and leaves the byte unchanged. The music is therefore restarted at most once, and only when the introduction was skipped between its first and second markers, which leaves the byte at 1; otherwise it plays once and stops.

Comparative source: REF-SCUMM-017, getInput.

Used by: How it fits together, Sound effects

Cut the button labels​

AddressRange
0x3f8600x3f860–0x3f90f

Called once by 0x41d53 after CHARGENB is loaded. For each of the 17 drawing records it clears DS:0x752 and, when the record has a label, cuts it through driver slot 28. The labels are released by overlay 246.

Used by: Load the creation images

Highlight the first portrait​

AddressRangeStatus
0x4027a0x4027a–0x40289No caller found

Entry 22. Calls the resident box frame highlight with frame 10. 0x1e78e(frame) draws a blinking frame from the rectangles at DS:0x545c, stepping through the colours of DS:0x23cc once per tick; a new frame number erases the previous frame and −1 removes it. Frames 6–9 are the four boxes and 10–13 the four portraits of the portrait menu, so frame 10 is its first portrait.

Used by: Choose a portrait

Find the n-th set bit​

AddressRangeStatus
0x418380x41838–0x41866No caller found

Entry 23. 0x41838(mask, n, count) returns the position of the n-th set bit (counting from 1) among the low count bits of the 16-bit mask, or count when there is no such bit.

Used by: Routines at a glance

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.