Skip to main content

Display routines

Routines · Data · Address index

Portraits, bars, icons and shapes, the tile layers of the view, display modes and drivers, text windows and text output. The routines page explains how the entries are written.

0x292ee, 0x29514 — Bars​

  • Ranges: 0x292ee–0x293b4; 0x29514–0x295b9
  • Role: 0x292ee(x, y, value, max, width, height, colour, empty colour) frames a bar and fills width × value / max pixels, limiting value to 0 and max, with at least one pixel for a value above 0. 0x29514(slot) draws the food bar at (250, 25), 51 × 5 pixels, out of 100, for the selected character while the character panel is open. Its colour is DS:0x5d6f by food: 3 from 33, 5 below 33, 8 below 20.
  • Used by: Timed updates › Food, Hit-point display

0x293b5 — Hit-point display​

0x29b09 — Character portrait and sheet​

0x2901c — Portrait frame of active spells​

  • Role: Draws the frame of a character's portrait (63 × 50 pixels at the portrait position given by DS:0x5d65 and DS:0x5d67) from two tests. The protective test (0x2907c–0x290a9) holds when the character's spell_effects has 0x4818 (Shield, Blur, Protection from Evil, Magical Vestment), its armor reserve +0x145 or byte +0x146 is nonzero, or the party has SPELL_EFFECT_MYSTIC_DEFENSE. The other test (0x290b8–0x290d6) holds for the character's 0x13000 (Aid, Slow Poison, Haste) or the party's 0x8420 (Prayer, Bless, Detect Invisible). With neither, the ordinary frame is drawn; with the protective test only, a rectangle in colour 6, or 4 under mystic defense (0x29024–0x29040); with the other test only, colour 5; with both, the two colours alternate in 8-pixel dashes (0x291b0–0x292e5).
  • Used by: Lasting spell effects, Lasting spells › What lasting effects do, Character record › Unused bytes

0x295ba — Draw a character's face​

  • Range: 0x295ba–0x2973e
  • Role: Draws the face of a present character at its portrait position, or, on the inventory page, of the selected character only. A character at −10 hit points gets the image addressed by DS:0xe400 instead of its face. Otherwise the face (face_image) is drawn through a colour table chosen in this order, the last match winning: DS:0xeee8 for SPELL_EFFECT_INVISIBILITY or SPELL_EFFECT_IMPROVED_INVISIBILITY (0x29654), DS:0xeee4 for CHARACTER_STATUS_POISONED, DS:0xee30 for CHARACTER_STATUS_PETRIFIED; below 1 hit point the image addressed by DS:0xcb60 is drawn over it.
  • Used by: Lasting spell effects, Lasting spells › What lasting effects do

0x1ea08 — Draw an item icon​

  • Role: Draws an item's icon; while the party has SPELL_EFFECT_DETECT_MAGIC (0x1ea23), an item with ITEM_RUNTIME_MAGICAL is drawn through the colour table addressed by DS:0xcc26. Called, as far call 0x0e24:0x07c8, by the inventory drawing at 0x1d727 and by the portrait hand at 0x29a31; the held item has its own test at 0x18cde.
  • Used by: Lasting spell effects

0x2992f — Draw a portrait hand​

  • Range: 0x2992f–0x29b08
  • Role: Draws a hand's item, or the empty-hand image, then marks the hand unavailable when its disabled_slots bit is set, when 0x1eaee refuses it, or when the character has less than 1 hit point or is paralyzed or petrified; a nonzero slot_status shows the result label instead.
  • Used by: The inventory › Two hands

0x2973f — Hand result label​

  • Role: Draws the result of a hand's last use, kept in slot_status: through a jump table at analysis address 0x29925, −1 MISS (DS:0x5da7), −2 HACK, −3 CAN'T REACH (DS:0x5db6, DS:0x5dbc), −4 NO AMMO, −5 BASH; other values are printed as a number. Called at 0x29a14.
  • Comparative source: REF-SCUMM-018, gui_drawWeaponSlotStatus.
  • Used by: Formation › Formation, Texts

0x1941d, 0x1945e, 0x1949f, 0x194e0 — Draw a shape in a window​

  • Ranges: 0x1941d–0x1945d, 0x1945e–0x1949e, 0x1949f–0x194df, 0x194e0–0x19520; they call 0x2da7a–0x2dab9, 0x2daba–0x2daf9, 0x2dafa–0x2db39 and 0x2db3a–0x2db79 respectively.
  • Role: Arguments: a word (2 in the view's calls), a shape far pointer, x, y and a text window whose entry moves the position. The second routine of each pair returns without drawing when the shape pointer is null (0x2da81–0x2da87, 0x2dac1–0x2dac7, 0x2db01–0x2db07, 0x2db41–0x2db47); otherwise it calls 0x2dc86 when the window differs from DS:0x6298, adds the origin DS:0xefd6, DS:0xefd2 and calls a display-driver slot: 18 draws the shape, 39 draws it mirrored, 15 draws it through the replacement colour table and 38 mirrored through that table (VGA driver, EGA driver). Overlay code calls the first two through 0x20:0x6ad and 0x20:0x6ee; the monster drawing picks one of the four from four far pointers at DS:0x049e. The shape drawing routines are two of them.
  • Used by: Doors, teleporters and temporary walls › Released shapes, Run a sequence › Without a level change, MGA.OVL › Game call sites

0x2aa00 — Fill a colour table​

  • Range: 0x2aa00–0x2aa30 (file offsets 0x1dc00–0x1dc30)
  • Role: Arguments: two far pointers. Copies 16 bytes from the first to CS:0x3b1 and 16 bytes from the second to CS:0x3c1 of its code segment (analysis 0x2aa31 and 0x2aa41), the two colour tables that the tile compositor reads (0x2b231, 0x2b238). Its only caller is overlay 250 (0x48235), while loading a level.
  • Used by: Dungeon tiles (VCN) › Organization

0x2b3da, 0x2b50d, 0x33dc4, 0x2b5a8, 0x2b5de, 0x2b77e — Drawing helpers​

  • Role: 0x2b5a8 and 0x2b5de read a block and its mask for the EGA branch of the tile drawing, the mask reversed when mirrored. 0x2b77e(shape, table) translates the 16-colour table of a shape of format 1 (0x18d32). 0x2b3da and 0x2b50d combine the bytes of two tile sources, each optionally mirrored; the branches of the tile drawing for display modes 1 and 0, whose drivers are not in the collection, call them (0x2b157, 0x2aed0). 0x33dc4 steps a 3-byte generator at DS:0x6676 and returns a byte; only the vortex drawing uses it (0x234e4, 0x235c4), so it does not affect the game's other random numbers.
  • Used by: Explosion and vortex animations, Display modes, Screen coordinates, pixel by pixel

0x2aa6d — Draw the tile layers​

0x2b194 — Dungeon tile compositor​

  • Address: 0x2b194 (file offset 0x1e394)
  • Role: Draws VCN tiles in VGA mode from VMP entries: the high bit selects the foreground, bit 0x4000 mirrors the tile and the low 14 bits give the tile index. It walks the 22 × 15 tiles row by row and writes each one 8 pixels to the right of the previous one in a buffer 320 pixels wide. A wall entry of 0 is replaced by the backdrop entry 330 words further, drawn with the backdrop colours; other entries use the wall colours, and an entry with the high bit draws the backdrop tile first. Unusual values: the mirror flag set by a wall entry whose block number is 0 is not cleared before the backdrop entry is read (0x2b1c3–0x2b1ee), so the backdrop is drawn mirrored; an entry 0x8000 draws no wall part (test at 0x2b2c4); bit 0x8000 of a backdrop entry is shifted out when the block address is computed (0x2b1f4); the block number is not range-checked. Also used for the Tandy mode.
  • Used by: Dungeon tiles (VCN) › Organization, Wall layouts (VMP) › Reading the file, Screen coordinates, pixel by pixel › From tiles to pixels, Screen coordinates, pixel by pixel › Unusual entry values

0x1889a — Program start-up settings​

0x312db — Set the display mode and load its driver​

  • Range: 0x312db–0x315d9; jump tables at 0x315da (palette, modes 2 to 5) and 0x315e2 (page segments, modes 0 to 6)
  • Role: Called only at start-up (0x18a66). For mode 3, first clears 64,000 bytes at segment 0xa000. Unless the mode is 8, it loads the display driver named by the driver names for the mode, through a request at DS:0x6371 whose second far pointer is the driver function table. On failure it prints the message at DS:0x6403 ("Could not load overlay …") with the driver's name and returns 0. After a successful load, and for mode 8, it allocates a buffer for each odd page from 3 to 15 that has a size (0x313aa–0x313f2), then sets the page segments of the mode in the page table at DS:0x62a7: in modes 3 and 6, pages 0 and 1 are 0xa000 and pages 2, 4 and 6 take the buffers of pages 3, 5 and 7 (0x31453–0x3146b); in modes 0 and 1 the same, with 0xb800 (0x31402); in modes 4 and 5, pages 0, 2, 4 and 6 are 0xa000, 0xa400, 0xa800 and 0xac00 (0x31439–0x31451); in mode 2, the even pages from 0 to 14 are 0xa000 to 0xae00 in steps of 0x200 (0x31407–0x31431). Unless the mode is 8, it then calls the driver through DS:0x655a (0x31473) and, when its second argument names a file, it loads that font into DS:0xf098 (0x3147f–0x31495) and installs it (0x314e0); a missing file prints a message and makes it return 0. The start-up calls it at 0x18a66 with the display mode and FONT8.FNT (far pointer DS:0x1cc4). Before loading the driver, unless the mode is 8, it sets the BIOS video mode of the display mode (0x3130d); the failure paths (0x3136d, 0x314a2) put the start-up mode back. In every mode it finally allocates the 768-byte palette buffer at DS:0xf168 (0x314e8–0x314ff). Mode 2 copies the 16 bytes at DS:0x638f there and mode 5 those at DS:0x639f, and each gives them to the driver through DS:0x65e2; modes 3 and 4 set colour 15 to (63, 63, 63) and set the palette (0x31515–0x3159f). It then saves the drive in use (0x315a2), sets DS:0x638e to 1, which the shutdown tests (0x315a7, 0x31604), measures the refresh (0x315ac), seeds the random generator from the clock (0x315b7–0x315c0), selects text window 0 (0x315ca) and returns 1.
  • Used by: Fonts (FNT) › Reading the file, Display drivers › Loading a driver, MGA.OVL › Pages, XGA.OVL › Pages, Display modes

0x31a9c, 0x31ac3 — Read and set the BIOS video mode​

  • Range: 0x31a9c–0x31ac2, 0x31ac3–0x31b05
  • Role: 0x31a9c asks the BIOS for the current video mode (AH = 0x0f through call a software interrupt) and returns it. 0x31ac3 takes a display mode m: AX is the BIOS mode of m when m is below 9, otherwise the start-up mode; unless it already equals the start-up mode, it is passed to the BIOS (AH = 0, set mode) through interrupt 0x10 (0x31aed–0x31b00). The start-up (0x316d2) saves the current mode first; the display mode setup sets the mode of the display; the program's exit (0x31636) and several failure paths (0x2d33d, 0x2f398) call it with 9 to put the start-up mode back.
  • Anomaly: the comparison (0x31adf–0x31aeb) always indexes the table with m, also when m is 9 and the value came from the start-up mode: it then reads the word after the nine entries, DS:0x6500, which is 0 (ANOMALY-121).
  • Used by: Display modes, Anomalies and bugs

0x16e5e — Call a software interrupt​

  • Range: 0x16e5e–0x16e8e (with 0x16e8f)
  • Role: Takes an interrupt number and the far addresses of an input and an output register block, builds the interrupt instruction on the stack (0x16ea1–0x16eac) and runs it. The game sets and reads the video mode through it with interrupt 0x10; START.EXE holds no int 0x10 instruction of its own.
  • Used by: Read and set the BIOS video mode, Display modes

0x16db5, 0x16ded — Critical-error handler​

  • Range: 0x16db5–0x16dec, 0x16ded–0x16e0f
  • Role: 0x16ded stores a far callback at DS:0xf2d8 and makes 0x16db5 the handler of interrupt 0x24, which DOS raises on a critical error such as a disk that is not ready (0x16dfd–0x16e06, through the set-vector call 0x16da4). The handler saves the registers, sets the data segment, calls the callback with the error information and returns its result to DOS. The start-up installs it once (0x31737 → 0x2f436), with a callback (0x2f421) that records the error code at DS:0xf0fc and calls 0x16e2b. That routine does not come back: it leaves the handler, sets the carry flag of the interrupted DOS call and returns to the program (0x16e43–0x16e59), so the call fails with no prompt from DOS.
  • Anomaly: in the EGA mode, the stray bytes of ANOMALY-80 land at 0x16dbe + block number, inside this handler and, for block 47, on the first byte of 0x16ded (see colour the VCN blocks).
  • Used by: Display modes, Search the drives for a file

0x310b1 — Select the current page​

0x310c9 — Set a text window's bounds​

  • Range: 0x310c9–0x3111c
  • Role: 0x310c9(window, x, y, width, height) writes the four values into the window's entry of the text window table (+0, +2, +4, +6). When the window is the active one, it selects it again (0x31c33) so that the new bounds take effect. When it is the window installed for shape drawing (DS:0x6298), it installs it again through 0x2dc86 (0x31113), which sets the shape origin and the driver's shape window (slot 46) from the new bounds.
  • Used by: Set a text window in 8-pixel units, Load a saved game, Save menu

0x31cf2 — Select and clear a text window​

0x31c33 — Select a text window​

  • Role: Makes its argument the active text window, copies that window's entry of the table DS:0x1cfc into the text output state and returns the previous window's number. Called with 7, the message area, by the game start (0x1cb9d), after a level load (0x272b8), by the rest (overlay 248) and after a dialogue (overlay 252); other callers select another window for a while and restore the previous one.
  • Used by: The inventory › Moving and equipping items, Dialogue screen

0x31d84 — Text output​

  • Role: Prints text; messages use it with the text colour temporarily replaced. Bytes 1 to 31 are control codes dispatched through a table (0x31e92–0x31ea3), % introduces a d or s argument, and every other byte is buffered at DS:0xf1ec and drawn by the display driver's text routine. Characters are read through 0x323b4 (0x31dde), which expands every byte from 0x80 up into two characters before this routine sees it; a zero character ends the output (0x31de7–0x31deb). The control table is at 0x3209a (cs:0x59a of segment 0x21b0): 0x01 flushes the line and calls the page-wait routine if one is set (0x31f18); 0x02 n and 0x06 n set the background and text colours (0x31f85, 0x31f96); 0x09 and 0x13 advance to a tab column of 8, by moving the cursor or by padding with spaces (0x31fa7, 0x31fd3); 0x0c clears the window (0x31d0f); 0x0d starts a new line (0x31f6f); 0x18 n and 0x19 n set the cursor column and line, clamped to the window (0x31ea8, 0x31ee0); 0x08 is buffered like a printable byte; the other codes are skipped. The colours are restored when the call ends (0x3206f–0x32085), and the cursor is stored back into the window's entry (0x32055). Lines are output by 0x321be.
  • Used by: Print a message › Behavior, Initial items (ITEM.DAT) › Who uses it, Dialogue screen › Text window and pages, Dialogue texts (TEXT.DAT)

0x323b4 — Read the next text character​

  • Range: 0x323b4–0x323f8, with 0x322f3–0x323b3
  • Role: Returns the next character for the text output, keeping one character ahead in DS:0xf1e4–0xf1e5. 0x322f3 takes the next byte of the %s argument string if one is open, otherwise of the main string. A byte with bit 7 set is replaced by two characters: entry (c >> 3) & 15 of a 16-byte table at DS:0x71af, then entry c & 0x7f of a 128-byte table at DS:0xe445 (0x32364–0x3239d). Both tables hold zeros in the executable image, and a zero first character counts as no character. With both tables empty, such a byte gives no character: one that follows an ordinary character is skipped (look-ahead refill, 0x323e6), while one at the start of the text or right after another such byte gives a zero character (refill at the start of the call, 0x323c1), which ends the text, and one at the start of a %s argument gives a zero character that hides the rest of the line. Nothing fills the tables with the original data. No original INF message contains such a byte.
  • Used by: Initial items (ITEM.DAT) › Who uses it

0x321be — Output a line of text​

  • Range: 0x321be–0x322f2
  • Role: Draws the buffered characters of the text output on the current line of the active window. While the cursor line is below the window it first calls the page wait. The room on the line is the window's width in characters, less DS:0x650c (7) when page waits are on and the page already has lines − 3 or more lines (0x32211–0x32227). When the buffer does not fit, it cuts after the last space at or before the room left (0x32245–0x32264); with no space it moves everything to the next line, or, at the start of a line, cuts at the edge. It drops one or two spaces at the cut (0x32298–0x322a6), then starts a new line and repeats while characters remain (0x322db–0x322ea). The text output calls it at each control code, at the end of the text and when the buffer passes the right edge by more than one character (0x32026).
  • Used by: Dialogue screen › Text window and pages

0x320d8 — Page wait and scroll​

0x31c19, 0x31c29 — Turn page waits on and off​

0x31d0f — Clear the text window​

0x308c5 — Load a font​

0x19752, 0x19785, 0x31078, 0x3060e — Centre and draw a number​

  • Role: 0x3060e(int, x, y, colour, background) draws an int in decimal. 0x19752(long) and 0x19785(int) return the decimal digits of the number × 3, half its width in the 6-pixel font. 0x31078(long, x, y, colour, background) draws a long in decimal. The character sheet centres each class's experience on x = 247 and its level on x = 286 with them (0x2a250–0x2a291).
  • Used by: Character portrait and sheet

0x2a37f — Grow the active text window​

  • Range: 0x2a37f–0x2a3d5
  • Role: 0x2a37f(n) moves the active window left by n columns and up by 8n pixels, adds 2n columns and 16n pixels to its size, reselects it and clears the cursor DS:0xf094, DS:0xf096. The disk prompt calls it for its box (0x2a4e5, 0x2a57c).
  • Used by: Disk prompt

0x31b06, 0x31bd3 — Page wait​

  • Ranges: 0x31b06–0x31bd2; 0x31bd3–0x31c18
  • Role: 0x31b06 is the default page wait: it prints <MORE> and waits for a key or a mouse press. 0x31bd3 sets the prompt and its width, or restores the default with a null pointer; no caller is known.
  • Used by: Page waits

0x33d2d, 0x33cda — Load a display driver​

0x3166a — Install a font​

  • Range: 0x3166a–0x316d1
  • Role: Returns the current font and, unless its argument is null, makes the argument the current font, copies its character advance (font byte +0x103) to DS:0x6288 and its line height (+0x102) to DS:0x6289, and recomputes the active window's lines and columns. The start-up loads FONT6.FNT into DS:0x9342 (0x18b22–0x18b33) and the game start installs it (0x1cb76); FONT8.FNT, kept at DS:0xf098, is installed by the display mode setup and again by the two-choice question, the defeat sequence, the ending and a few other routines. The dialogue routines do not call it.
  • Used by: Dialogue screen › Text window and pages, Fonts (FNT) › Reading the file

0x19678 — Print shadowed text​

0x192e1, 0x2d9e0 — Rectangle outline​

  • Range: 0x192e1–0x19337, 0x2d9e0–0x2da36
  • Role: 0x192e1(x1, y1, x2, y2, colour) draws the four edges of the rectangle through driver slot 17 (DS:0x6566): top, bottom, left, right. 0x2d9e0 takes the same arguments and draws the same four lines in the same order; it is the one used by highlight a box frame and by the character panel and the mouse-cursor code (0x2a4d8, 0x3033c–0x305b4).
  • Used by: Race, class and alignment menus

0x1e78e — Highlight a box frame​

0x2d92a — Copy a page area​

0x1edc8 — Rebuild the play screen​

0x1990a — Wait, then wait for input​

  • Range: 0x1990a–0x19955
  • Role: Busy-waits n × 18 ticks of the free-running counter (n the argument), empties the input queue, waits until an input event is queued, then empties the queue again. The parchment reader calls it with 0 after showing a map.
  • Used by: Read a parchment

0x1ecf2 — Draw a button box​

  • Range: 0x1ecf2–0x1ed9a
  • Role: 0x1ecf2(x, y, width, height, flat, hollow) hides the mouse and draws two nested framed boxes. The outer one, one pixel wide on each side, has its top and right edges in the light colour DS:0xeef0 and its left and bottom edges in the dark colour DS:0xe5c2, or both in the interface colour DS:0xe606 when flat is non-zero; the inner one, one pixel in, always uses the light and dark colours and is filled with the interface colour unless hollow is non-zero. Then it shows the mouse. Menus of the overlays, the message box and the slot menus draw their buttons with it; the message box shows its pressed button by redrawing it with flat and hollow set.
  • Used by: Message with one button, Draw a slot button

0x197b5 — Draw a framed box​