Skip to main content

Item routines

Routines · Data · Address index

Holding, giving, throwing, dropping and using items, inventory slots, and the item chains of blocks. The routines page explains how the entries are written.

0x18c77, 0x1e5bc — Give the held item​

0x1bb6d, 0x1bcc5, 0x1bcfe, 0x1bd22, 0x1befa, 0x1cd81, 0x1bbf9, 0x1bc3e — Inventory buttons​

  • Ranges: 0x1bb6d–0x1bbc6, 0x1bcc5–0x1bcfd, 0x1bcfe–0x1bd21, 0x1bd22–0x1bd9b, 0x1befa–0x1bf7a, 0x1cd81–0x1cdb3
  • Status: nothing calls 0x1cd81: no far call in any segment form, including the overlays' fixed-up segments, no near call and no far pointer in the file.
  • Role: Button handlers of the character panel, which set the panel state. A portrait click opens the inventory page of a present character (0x1bb6d, which also stores the character in DS:0x9317 when the button trigger is a mouse click); 0x1bbf9 and 0x1bc3e, the previous and next buttons (helper 0x1bbc7), select the previous or next present character, or with their key shortcuts a given one; 0x1bcc5 switches between the two pages; 0x1bd22 closes the panel and brings the keyboard slot back to a hand. A slot button (0x1bcfe) passes its slot to 0x1d897. A portrait hand button (0x1befa) takes the hand from the mouse row and, for a present character, exchanges it with the held item (0x1d987) when DS:0x6385 & 0x7f is 1, or uses the item otherwise. DS:0x6385 is the state of the first mouse button, set by the button processing: 1 when the event is its press (0x41), 3 for its release (0x2f984–0x2f9e1); DS:0x6387 is the same for the second button. A click with the first button therefore exchanges, and the second button or a key uses the item. 0x1cd81 is the keyboard equivalent on the selected slot. 0x1bbf9 (F1 and F2) selects characters 0 and 1 without testing that they are present; 0x1bc3e (F3 to F6) restores the previous character when the target is absent. Key I on a face skips the presence test and keeps the selection.
  • Used by: The inventory › Moving and equipping items, The inventory › The selected character, The play screen › Click areas, The play screen › The character panel

0x1c289, 0x1e280 — Select a character​

  • Ranges: 0x1c289–0x1c2e0; 0x1e280–0x1e2b4
  • Role: 0x1c289 is the callback of the six character boxes (63 × 50 at x 184 and 256, y 2, 54 and 106), the first buttons of the main button list after the front-block action. For a present character (mask 1) it calls 0x1e280 and returns 0, so that the button processing goes on to the name, face or hand button under the pointer; otherwise it returns 1. Its two other calls, 0x1e2b5 and 0x1e2c6, return at once. 0x1e280 makes its argument the selected character and redraws the old and new portraits; the swap of two characters (0x1be55) and overlay 247 0x428d0 call it too.
  • Used by: The inventory › The selected character, The play screen › Click areas

0x1bf7b — Throw the held item​

0x1c135 — Drop or pick up an item on the floor​

0x1c58f, 0x1c6d9 — Keyboard drop, throw and take​

  • Ranges: 0x1c58f–0x1c6d8; 0x1c6d9–0x1c8dd
  • Anomaly: the anomalies are in 0x1c6d9–0x1c8dd, which never reads the wall properties, and at 0x1c840–0x1c886.
  • Role: 0x1c58f (argument 0 drop, key D; 1 throw, key T) takes the top quiver item when slot 16 is selected, otherwise the held item, and does nothing for an item with ITEM_RUNTIME_CURSED (0x1c5bf). It drops it in the party's block, or launches it, at the keyboard position of the character's side; a quiver item whose launch fails goes back into the quiver (0x1c6bf). 0x1c6d9 (key G) cycles over the four floor zones (zone blocks, positions) and takes the top item of the first non-empty one into the selected slot when the placement check accepts it, appending the previously held item, or the refused one, at the same position (block events 8 and 4). The taken item is given to the slot (0x1c801) before the removal event is sent (0x1c87e), so a script reacting to it sees it as the held item. It reads the block ahead without testing the face in between, and an arrow taken into the quiver (0x1c840–0x1c86a) skips the removal event. Neither routine tests the condition of the selected character, the thrower.
  • Used by: Block events › Who sends each event, On the floor and in the air › Items on the floor, Anomalies and bugs, The inventory › Moving and equipping items, Item state flags

0x1cbe5, 0x1cc3a — Lose an item to a monster​

0x1cce1 — Remove the selected inventory item​

0x1cf67 — Search or count a block's items​

0x1d00d — Identify a chain of items​

0x1d586, 0x1d73b — Draw an inventory slot​

  • Ranges: 0x1d586–0x1d73a; 0x1d73b–0x1d76f
  • Role: 0x1d586(slot, frame, page) draws one inventory slot of the selected character at its position (DS:0x2127, DS:0x215d). With frame set it first draws the box: 16 pixels square, 8 for the two rings. On the quiver it also prints how many items the slot holds, at x = 233 below 10 and x = 227 from then on, and in keyboard control it outlines the selected hand. It then draws the item's icon, except on the quiver, 4 pixels up and left on a ring. 0x1d73b(restore) can put the saved panel background back (0x1d75b), then redraws the selected character.
  • Used by:

0x1d054 — Append an item to a block chain​

0x1d0a6 — Delete a block's items by type​

0x1d1b1 — Print an item's name​

0x1d50b — Duplicate an item​

0x1d770 — Check an item placement​

0x1d897 — Click an inventory slot​

0x1d987 — Swap the held item with a portrait hand​

0x1da2f — Drink a potion​

  • Range: 0x1da2f–0x1dc51; jump table 0x1dc52–0x1dc61
  • Role: Arguments: a character and a slot. Removes the potion, whose value v selects the effect, and plays sound 10; for v 0 to 7 (unsigned test) it animates the portrait and: 0 sets strength to 22 and exceptional_strength to 0 with a timer of 546 × (1d4 + 4) ticks, event 7; 1 heals 2d4 + 2; 2 heals 3d8 + 3; 3 poisons (saving-throw category 0, one unit, event 8, no refresh) and clears SPELL_EFFECT_SLOW_POISON (0x1db35); 4 sets food to 100; 5 sets SPELL_EFFECT_HASTE (0x1db7c) with a timer of 546 × (1d4 + 4) ticks, event 12; 6 sets SPELL_EFFECT_INVISIBILITY (0x1dbda) without a timer; 7 neutralizes poison. Prints "%s feels %s!" (DS:0x3880) with string v of the potion messages, read without a bound, except for v 3 when the character is poisoned afterwards (0x1dc06–0x1dc13).
  • Used by: Potions, scrolls and wands › Potions, Lasting spell effects, Sound effects, Saving-throw categories, Anomalies and bugs

0x1dc62, 0x1dccc — Use a wand, blow a horn​

0x1dd20 — Use an inventory item​

0x1df8f — Class restriction check​

0x1dfd8, 0x1eaee — Hand checks​

0x1ebcb — Check for a holy symbol in a hand​

  • Range: 0x1ebcb–0x1ec1e; the comparison is at 0x1ec07
  • Status: no reference was found in the executable (resident near and far calls, overlay calls through the segment table, stored far or near pointers); it is never called (inferred).
  • Role: Argument: a character record. Returns 1 when inventory slot 0 or 1 holds an item whose type's whole properties_raw word equals 6, that is ITEM_KIND_HOLY_SYMBOL with no other bit, and 0 otherwise. It is the only read of that word that does not mask the kind with 0x7f.
  • Used by: Item kinds › Anomaly, Item types (ITEMTYPE.DAT), Anomalies and bugs

0x1e388 — Search the inventory​

0x1e3fe — Look for a worn ring​

0x1e452 — Delete inventory items by type and value​

0x1e592 — Held item​

0x1ee39 — Remove items from the party​

  • Range: 0x1ee39–0x1ef58
  • Role: Takes up to a given number of items of one type from the present characters, in slot order, from every inventory slot but 16: the value must be at most (mode −1), equal to (0) or at least (1) a given value. A taken item leaves the inventory and its location word becomes −1. Passes repeat while items are still wanted and the last pass found one; returns the number taken.
  • Comparative source: REF-SCUMM-019, stripPartyItems and restParty_npc.
  • Used by: Item types › Where it is used, Resting: special cases › Insal leaves

0x1f6e2 — Item damage dice​

0x2105d — Reserve a conjured-weapon type​

0x210e5, 0x21125 — Free and reserve a conjured-weapon item​

  • Range: 0x210e5–0x21124; the type write is at 0x21100 (file offset 0x14300). 0x21125 follows it.
  • Callers: the spell routines of Shocking Grasp, Vampiric Touch and Flame Blade call 0x21125 with flags 0x10, 0x18 and 0; the end routine 0x23d54 calls 0x210e5.
  • Role: 0x210e5 frees one item: it writes −30 (0xe2) to defense_adjustment_raw of the item's type, sets the item's location_raw to 0xfffe and its level_raw to 0xff. 0x21125 searches items 11 to 16 for one whose location_raw is 0xfffe and returns −1 when there is none. Otherwise it fills that item, setting its flags to its first argument plus 0x20; it also writes 0 to DS:0x71cf, byte +0x05 of item 0.
  • Comparative source: REF-SCUMM-013, removeMagicWeaponItem and createMagicWeaponItem.
  • Used by: Item type entry › Changes during play, Item entry, Anomalies and bugs