Movement and geometry routines
Routines · Data · Address index
The movement buttons, the party's step, and the computations of neighboring blocks, directions and distances. The routines page explains how the entries are written.
0x1bfe0, 0x1c018, 0x1c0a5, 0x1c0ed, 0x1c05f, 0x1c082 — Movement buttons
- Range:
0x1bfe0–0x1c134 - Role: Callbacks of the six movement buttons, the
button records at
DS:0x4570toDS:0x469c, entries 30 to 35 of the main button listDS:0x5038; their callback pointers are atDS:0x45a0toDS:0x46cc. Step in the facing direction (0x1bfe0), behind (0x1c018) or to the left (0x1c0a5: facing − 1) or right (0x1c0ed: facing + 1), or turn left (0x1c05f: facing − 1) or right (0x1c082: facing + 1); seeDirection. A step asks the step test for the target block, then calls move the party or, when refused, refuse a step. A turn changes the party's facing and requests a redraw. Their only stored pointers are six consecutive0x3c-byte records,DS:0x45a0toDS:0x46cc(see the front-block action pointer). - Used by: Moving the party › The step test, Directions, Blocks, directions and positions › Directions and coordinates, The play screen › Click areas
0x1bb3f — Refuse a step
- Range:
0x1bb3f–0x1bb60 - Role: Prints the "can't go that way" message through text output and plays sound 29.
- Used by: Moving the party › The step test, Sound effects
0x1e2d1 — Test whether a block can be entered
- Range:
0x1e2d1–0x1e36e(file offsets0x114d1–0x1156e) - Role: For a starting block and a direction, takes the
next block and its wall on the side facing back. When that wall
is
WALL_REFERENCE_TEMPORARY_WALL(SpecialWallReference) and the starting block is the party's, it looks for the target in the five temporary-wall slots (0x1e31d–0x1e343): for each slot that holds it, it removes that wall and takes the properties of wall 0. Without a matching slot the properties of reference 74 stay, and every original level maps it withoutWALL_RUNTIME_PASSAGE. It returns −1 when the wall lacks bit0x01of the wall properties or the target holds a monster (occupancy bits), and the target block otherwise. - Comparative source: REF-SCUMM-013,
calcNewBlockPositionAndTestPassability. - Used by: Moving the party › The step test, Wall mapping flags, Wall properties › Where each bit is tested, Wall references with built-in effects, Level 15: reference tables › Insal
0x1e36f — Next block in a direction
- Range:
0x1e36f–0x1e386 - Role: Returns the block adjacent to a given block in a given
Direction: the block index plus the direction step, wrapped to 0–1,023 without a row check. Party moves, monster patrols and wandering, and the block ahead of the party all use it. - Used by: Directions, Blocks, directions and positions › Directions and coordinates, Level maps (MAZ) › Organization, The dungeon view › The 18 visible blocks, Level 12: the guarded halls, On the floor and in the air
0x24f36 — Move the party
- Role: Moves the party to a block. Around the update of the party's
block, it runs the notice check over all monster slots and
triggers the leave and enter events of the blocks involved. At
0x24f8d–0x24fa9it sets the four walls of the new block to 0 when its side 0 isWALL_REFERENCE_CLEARED_ON_ENTRY(SpecialWallReference). Between the two events, every fourth call prints a line end (DS:0x5b29, counterDS:0x5a28,0x24f58–0x24f71). It also increments the step counter and resets the keyboard pick-up zone. It ends with the flying-object pass (0x24fbf). - Used by: Block events › Who sends each event, The engine › How the systems connect, The game loop › One pass of the game loop, Moving the party › The step test, Noticing the party › The check, Move the party, monsters or items › Moving the party, Events that start scripts, Scripted movement, monsters and items › Moving the party, monsters and items, Events that start scripts › Which events a block accepts, Timed scripts › Step-triggered script, Wall references with built-in effects, Script virtual machine › How a run starts, Values passed on to other routines › The routines, How the systems affect one another, Level 3: reference tables › The ant nest, Level 7: reference tables › Arrival and the way down, Level 9: reference tables › Level data, Level 10: reference tables › Level data, Level 15: reference tables › Stairs
0x2a996 — Direction between two blocks
- Range:
0x2a996–0x2a9ff - Role: Returns one of eight directions from one block to another, using
the direction table. With dy = row of the first block −
row of the second and dx = column of the second − column of the first, it
sets bit 8 when 2 × dy ≥ |dx|, 4 when −2 × dy ≥ |dx|, 2 when 2 × dx ≥ |dy|
and 1 when −2 × dx ≥ |dy| (
0x2a9cd–0x2a9f2), and reads the table at that index: 8 north, 10 northeast, 2 east, 6 southeast, 4 south, 5 southwest, 1 west, 9 northwest, which the table turns into 0 to 7 clockwise from north. A direction is thus diagonal when twice each difference is at least the other. Two equal blocks set all four bits and give0xff, returned in AL with AH cleared (0x00ff,0x2a9f3–0x2a9f5). - Comparative source: REF-SCUMM-008,
REF-SCUMM-020,
getNextMonsterDirection. - Used by: Noticing the party › The check
0x2b658 — Distance between two blocks
- Range:
0x2b658–0x2b693 - Role: Converts each block index to a column (
index & 31) and a row (index >> 5) and returnsmax(dx, dy) + floor(min(dx, dy) / 2). - Used by: Level maps (MAZ) › Organization, Blocks, directions and positions › Directions and coordinates, Noticing the party › The check, Resting: special cases › Anomalies while resting, Resting › Resting, Resting › Whether the party can rest, Place a monster › Sublevels and eviction, Place a monster › Choosing the slot, Place a monster › When nothing happens, Play a sound › Behavior, Values passed on to other routines › The routines, Level data (INF)