Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Symbolic Labels

This file records project-local symbolic names for interpreter routines, tables, and globals. The names are intended to survive comparison with later interpreter versions whose code may move to different offsets.

Addresses in this chapter are observations from the current Space Quest 2 build. They are not part of the portable specification. When a later executable has a matching routine at a different address, map that address to the same symbolic label and note any behavioral differences in the evidence trail.

Naming Rules

  • code.* labels name executable routines or overlay entry points.
  • data.* labels name runtime globals, data tables, or pointers.
  • table.* labels name dispatch or lookup tables.
  • opcode.action.* and opcode.cond.* labels name bytecode operations. The complete opcode catalog lives in the logic bytecode chapter and in tools/disassemble_logic.py.
  • Prefer symbolic labels in prose once a label exists, followed by the SQ2 address when useful for verification.
  • Mark uncertain labels as provisional in the notes/evidence column rather than encoding uncertainty in the label itself.

Address columns use these meanings:

  • SQ2 image offset: offset in build/cleanroom/AGI.decrypted.exe.
  • SQ2 data offset: runtime DS offset in SQ2/AGIDATA.OVL unless otherwise noted.
  • SQ2 overlay offset: near offset in the named overlay file.

Core Logic Interpreter

LabelSQ2 addressNotes/evidence
code.engine.main_cycleimage 0x0150Top-level interpreter cycle. Calls input/system helpers, mirrors object-0 direction/global direction state ([0x0139] == 0 copies object0 +0x21 to [0x000f], nonzero copies [0x000f] to object0), runs pre-motion mode updates, invokes logic 0 through code.logic.call_logic, restores object0 +0x21 from [0x000f], then runs code.object.frame_timer_update unless text-attribute mode byte [0x1757] is nonzero.
code.engine.wait_for_cycle_counterimage 0x7f78Top-level cycle throttle called near the start of code.engine.main_cycle; reads byte DS:0x0013 (v10), spins until word [0x1784] is at least that value, then clears [0x1784].
code.input.clear_status_bytesimage 0x4c23Clears 50 bytes at data.input.mapped_status_bytes before each synchronous input phase.
code.input.update_timed_eventsimage 0x61f2Updates enabled timed input sources against the tick counter and enqueues changed movement/status events before ordinary cycle input dispatch.
code.input.process_cycle_eventsimage 0x357cClears v19 and v9, services requested modal menu interaction, drains pending events, and updates raw-key, direction, and mapped-status state for the cycle.
code.control.save_abort_contextimage 0x7ee0Saves the current control context used by room/restart-style nonlocal returns so logic 0 can be re-entered without repeating pre-logic cycle phases.
code.logic.interpret_mainimage 0x293cMain logic bytecode loop. Reads opcodes from current logic bytecode and dispatches actions/conditions.
code.logic.action_dispatchimage 0x02c4Action dispatcher. Uses table.logic.action_dispatch.
code.logic.condition_dispatchimage 0x07e3Condition dispatcher. Uses table.logic.condition_dispatch.
code.logic.condition_input_word_sequenceimage 0x095cCondition handler for 0x0e; matches the parsed word ID table against variable-length word ID operands, with 0x0001 as a wildcard and 0x270f as an immediate successful terminator.
table.logic.action_dispatchdata 0x061dFour-byte action table entries for opcodes 0x00..0xaf.
table.logic.condition_dispatchdata 0x08fdFour-byte condition table entries for opcodes 0x00..0x12 in this build.
code.logic.message_xor_rangeimage 0x07abXORs logic message text in place.
data.logic.message_xor_keydata 0x08f1Zero-terminated XOR key bytes, observed as Avis Durgan.
code.logic.resolve_messageimage 0x21f0Resolves a current-logic message number through the message pointer table.
code.logic.load_cachedimage 0x117dLoads a logic resource and keeps it linked in the logic cache.
code.logic.load_resourceimage 0x119aReads, initializes, and message-decodes a logic resource.
code.logic.truncate_cache_to_headimage 0x10f7If data.logic.cache_root is nonzero, stores zero in the first logic cache record’s +0x00 next-link field. Room-switch cache reset uses this to preserve the first logic record while unlinking later cached logic records.
code.logic.call_logicimage 0x12aeTemporarily switches current logic, runs code.logic.interpret_main, and may unlink a transient record.
code.logic.save_resume_ip_actionimage 0x1335Action handler for 0x91; stores the current bytecode pointer in the current logic record’s resume pointer field +0x06.
code.logic.restore_entry_ip_actionimage 0x134aAction handler for 0x92; copies the current logic record’s entry pointer field +0x04 back to resume pointer field +0x06.
code.logic.serialize_resume_tableimage 0x1364Serializes the static cache-head record and each linked logic cache record as four-byte logic-number/relative-resume pairs at data.logic.resume_table, then appends a 0xffff terminator record and returns the byte length.
code.logic.restore_resume_from_tableimage 0x13a5Scans data.logic.resume_table for the first entry matching a loaded logic’s byte resource number and rebuilds its resume pointer as bytecode entry plus saved offset. Stops without changing it at the 0xffff terminator.
code.startup.allocate_runtime_memoryimage 0x43eaStartup memory setup around DOS AH=4a/AH=48h; seeds data.heap.current_top_0a55 and data.heap.base_0a57 from the allocated segment converted to a DS-relative byte offset, then computes data.heap.limit_0a5b.
code.heap.allocateimage 0x13d6Bump-allocates from data.heap.current_top_0a55 up to data.heap.limit_0a5b. On success it returns the old top, advances the current top, refreshes data.vars.free_memory_pages_0011 through code.heap.update_free_memory_var, and updates data.heap.high_water_0a5f. On exhaustion it displays the out-of-memory message and calls the restart/exit helper at 0x02ae; no recoverable failure return was observed.
code.heap.current_topimage 0x1430Returns data.heap.current_top_0a55.
code.heap.rewind_toimage 0x143cStores a caller-supplied pointer in data.heap.current_top_0a55; unlike allocation/reset paths, this helper does not refresh the free-memory byte.
code.heap.save_temporary_markimage 0x144bCopies data.heap.current_top_0a55 to data.heap.temporary_mark_0a5d.
code.heap.restore_temporary_markimage 0x145aIf data.heap.temporary_mark_0a5d is nonzero, rewinds data.heap.current_top_0a55 to that mark and clears the mark.
code.heap.save_room_reset_markimage 0x1476Copies data.heap.current_top_0a55 to data.heap.room_reset_mark_0a59. Startup calls this after initial object/inventory setup and logic 0 load.
code.heap.reset_dynamic_stateimage 0x1485Flushes object update lists through code.object.flush_update_lists_restore, clears the temporary heap mark, restores the current heap pointer from data.heap.room_reset_mark_0a59, and refreshes the free-memory byte. Used by room switch, restart, and restore paths.
code.heap.update_free_memory_varimage 0x14a0Computes data.heap.limit_0a5b - data.heap.current_top_0a55, stores the high byte at data.vars.free_memory_pages_0011, and returns the free-byte count.
code.heap.show_status_actionimage 0x14bdAction handler for 0x87; formats heap size, current usage, high-water usage, room/reset mark usage, and max resource-event/script count.

Resources and DOS Files

LabelSQ2 addressNotes/evidence
code.resource.load_all_directoriesimage 0x4305Loads LOGDIR, VIEWDIR, PICDIR, and SNDDIR.
code.resource.reset_room_cachesimage 0x10d0Room-switch cache reset helper. Calls code.logic.truncate_cache_to_head, clears the view cache root, clears the sound cache root, and clears the picture cache root.
code.resource.read_volume_payload_retryimage 0x2e32Retries the generic volume reader until it returns data or reports failure.
code.resource.read_volume_payload_onceimage 0x2e56Reads one resource payload from a volume file using a directory entry.
code.resource.logic_dir_entryimage 0x4371Resolves logic directory entries from data.resource.logic_dir.
code.resource.view_dir_entryimage 0x43a5Resolves view-like directory entries from data.resource.view_dir.
code.resource.picture_dir_entryimage 0x43d9Resolves picture-like directory entries from data.resource.picture_dir.
code.resource.sound_dir_entryimage 0x440dResolves sound-like directory entries from data.resource.sound_dir.
code.view.clear_cache_rootimage 0x396dClears the view-like resource cache root at [0x0ffa]; called by room-switch cache reset.
code.picture.clear_cache_rootimage 0x49dcClears the picture-like resource cache root at [0x120e]; called by room-switch cache reset.
code.sound.clear_cache_rootimage 0x50ccClears the sound-like resource cache root at [0x125a]; called by room-switch cache reset.
code.dos.create_fileimage 0x5cadDOS int 21h wrapper for AH=0x3c. Returns 0xffff on carry/error.
code.dos.open_fileimage 0x5cceDOS int 21h wrapper for AH=0x3d. Returns 0xffff on carry/error.
code.dos.read_fileimage 0x5cefDOS int 21h wrapper for AH=0x3f. Returns zero on carry/error, so callers compare the returned byte count with the requested count.
code.dos.write_fileimage 0x5d12DOS int 21h wrapper for AH=0x40. Returns zero on carry/error, so callers compare the returned byte count with the requested count.
code.dos.delete_fileimage 0x5d35DOS int 21h wrapper for AH=0x41. Returns zero on carry/error.
code.dos.close_fileimage 0x5d52DOS int 21h wrapper for AH=0x3e; callers observed so far do not inspect an error return.
code.dos.seek_fileimage 0x5d6bDOS int 21h wrapper for AH=0x42. Returns 0xffff:0xffff in DX:AX on carry/error.
code.dos.duplicate_handleimage 0x5d94DOS int 21h wrapper for AH=0x45. Returns 0xffff on carry/error.
code.dos.get_current_directoryimage 0x5db2Writes a leading slash/backslash then calls DOS AH=0x47 for the default drive. Used by save-path prompting.
code.dos.get_current_drive_letterimage 0x5deaCalls DOS AH=0x19 and returns lowercase drive letter a plus the zero-based drive number.
code.dos.find_firstimage 0x5e01Sets the DTA with AH=0x1a, then calls DOS AH=0x4e; returns 0xffff on carry/error.
code.dos.find_nextimage 0x5e26DOS int 21h wrapper for AH=0x4f. Returns 0xffff on carry/error.
code.dos.probe_drive_selectableimage 0x5e3eSaves the current drive, attempts to select a requested lowercase drive letter, checks whether DOS reports it as current, restores the original drive, and returns 1 on success.
code.dos.get_file_timeimage 0x5e73DOS int 21h wrapper for AH=0x57, AL=0; selector code uses the returned time word from CX.
code.dos.prepare_callimage 0x5e8dShared pre-call helper that temporarily switches DS to segment 0x0a01 and clears word [0x184d].
code.event.disable_recordingimage 0x705eClears data.event.recording_enabled; restore replay and temporary view-resource display use this so replay/internal loads do not append new resource-event pairs.
code.event.enable_recordingimage 0x706dSets data.event.recording_enabled; room switch enables recording after resetting the pair buffer, restore/display-mode replay calls it from the post-table finish target at 0x6927, and temporary view-resource display re-enables it before returning.
code.event.reset_pair_bufferimage 0x707cAllocates the pair buffer when data.event.pair_capacity > 0 and no buffer exists, then resets write pointer and active pair count.
code.event.record_pairimage 0x70b1Appends a two-byte (kind, value) pair when flag 7 is clear and recording is enabled; enforces data.event.pair_capacity and updates data.event.pair_high_water.
code.event.prepare_replay_cursorimage 0x712fSets replay read cursor to data.event.pair_buffer_base and recomputes the write/end cursor from data.event.pair_count.
code.event.next_replay_pairimage 0x714cReturns the current replay pair pointer and advances by two bytes, or returns zero at end.
table.restore.replay_event_dispatchimage 0x6915Nine-word jump table for resource-event replay kinds 0..8. Linear disassembly from before the table can swallow the following call 0x706d; disassemble at 0x6927 to see the post-loop re-enable.
code.restore.finish_replay_and_reenable_recordingimage 0x6927Exit target reached when code.event.next_replay_pair returns zero. Calls code.event.enable_recording, then rebinds object view payloads, restores saved object flags, refreshes display/input state, and returns from replay.
code.event.set_pair_capacity_actionimage 0x716aAction handler for 0x8e; writes data.event.pair_capacity, calls code.event.reset_pair_buffer inside update-list flush/rebuild calls, and thereby resets the pair-buffer write cursor and active count.
code.event.save_pair_count_actionimage 0x718bAction handler for 0xab; copies data.event.pair_count to data.event.saved_pair_count.
code.event.restore_pair_count_actionimage 0x719dAction handler for 0xac; restores data.event.pair_count and recomputes data.event.pair_buffer_write.

Pictures and Display

LabelSQ2 addressNotes/evidence
code.picture.load_resourceimage 0x4a3bLoads/caches a picture-like payload.
code.picture.prepareimage 0x4acfSelects cached picture payload and prepares decode state.
code.picture.overlay_prepareimage 0x4b3bOverlay picture path used before decoder entry code.picture.decode_no_clear.
code.picture.discardimage 0x4bceFinds the picture cache record, clears the preceding link slot so that record and later picture records become unreachable, then rewinds the shared heap to the selected record around update-list flush/rebuild.
code.picture.decode_with_clearimage 0x6445Fills logical buffer, then falls into picture command decoding.
code.picture.decode_no_clearimage 0x6440Decodes picture commands without the extra clear/fill entry work.
code.picture.command_scanimage 0x6475Walks picture command bytes from data.picture.current_payload.
table.picture.command_dispatchdata 0x15d6Dispatch table for picture command bytes 0xf0..0xfa.
code.picture.cmd_set_visual_draw_nibbleimage 0x6494Picture command 0xf0; enables low-nibble drawing state.
code.picture.cmd_disable_visual_draw_nibbleimage 0x64b5Picture command 0xf1; disables low-nibble drawing state.
code.picture.cmd_set_control_draw_nibbleimage 0x64c7Picture command 0xf2; enables high-nibble control drawing state.
code.picture.cmd_disable_control_draw_nibbleimage 0x64edPicture command 0xf3; disables high-nibble control drawing state.
code.picture.cmd_draw_corner_path_y_firstimage 0x6612Picture command 0xf4; draws alternating vertical/horizontal corner paths.
code.picture.cmd_draw_corner_path_x_firstimage 0x6603Picture command 0xf5; draws alternating horizontal/vertical corner paths.
code.picture.cmd_draw_absolute_linesimage 0x6646Picture command 0xf6; draws point-to-point absolute lines.
code.picture.cmd_draw_relative_linesimage 0x665ePicture command 0xf7; draws relative vector steps.
code.picture.cmd_seed_fillimage 0x66abPicture command 0xf8; seed-fill entry.
code.picture.cmd_set_pattern_modeimage 0x6524Picture command 0xf9; stores pattern mode byte.
code.picture.cmd_pattern_plotimage 0x64ffPicture command 0xfa; patterned plot/fill-family command.
code.picture.read_coord_pairimage 0x66b8Reads clamped X/Y coordinate pair for picture commands.
code.picture.draw_lineimage 0x66e1Draws a line between current and target picture coordinates.
code.picture.seed_fillimage 0x533bExpands from a seed coordinate through matching buffer nibbles.
data.picture.seed_fill_span_scratchdata 0x126c..0x1279Scratch bytes/words used by code.picture.seed_fill to track current span limits, vertical direction, saved row/column state, and deferred branch bounds. Field meanings are source-backed but intertwined, so keep this as a conservative block label unless a future version requires per-field names.
code.display.clear_logical_bufferimage 0x5528Clears the logical graphics/control buffer.
code.display.full_refreshimage 0x5546Copies/rebuilds the visible display from logical buffers.
code.display.fill_buffer_wordimage 0x5257Fills the logical buffer segment with a caller-supplied word.
code.display.draw_horizontal_lineimage 0x526fDraws a horizontal line in the logical buffer using active picture draw state.
code.display.draw_vertical_lineimage 0x52abDraws a vertical line in the logical buffer using active picture draw state.
code.display.pixel_writeimage 0x52f9Writes pixel/control nibbles into the logical buffer.
code.display.map_visual_color_for_adapterimage 0x5685Maps picture visual color bytes before they are stored in draw masks. Returns the input unchanged for the EGA target path; delegates to the graphics overlay at 0x9815 only for hardware selector [0x112e] == 0 with modes other than 2 or 3.
code.display.shake_screen_actionimage 0x7a00Action handler for 0x6e; reads a count byte and performs display-mode-specific transient screen-shake work. The normal path writes CRT controller registers 0x02 and 0x07 from data.display.shake_offset_table.
overlay.cga.map_visual_color_for_modeCGA_GRAF.OVL near 0x9815CGA overlay color mapper called by code.display.map_visual_color_for_adapter; indexes three-byte entries in data.display.cga_color_map and returns either a duplicated byte for mode 0 or a two-byte word for mode 1.

Objects, Views, and Motion

LabelSQ2 addressNotes/evidence
code.view.load_resourceimage 0x39f7Loads/caches a view-like payload.
code.view.discardimage 0x3f0dFinds the selected view record, clears the preceding link slot so that record and later view records become unreachable, then rewinds the shared heap to the selected record around update-list flush/rebuild. Actions 0x20 and 0x99 enter through immediate/variable wrappers at 0x3ecd and 0x3ee9.
code.object.bind_viewimage 0x3ae7Binds a cached view payload to an object record.
code.object.select_groupimage 0x3bb7Selects a top-level view subresource/group.
code.object.select_group_tableimage 0x3c1bComputes a group table pointer from the view payload.
code.object.select_frameimage 0x3ccbSelects a derived frame/entry and updates object size/pointers.
code.object.setup_transient_display_objectimage 0x2d52Builds/draws the temporary object-like record rooted at 0x0eb4 from staged bytes 0x0eae..0x0eb3; records event kind 5 plus three parameter pairs for restore replay.
code.object.placeimage 0x593aPlaces an object and performs priority/control collision adjustment. If the initial candidate fails bounds/collision/control tests, it searches in a widening spiral: left 1, down 1, right 2, up 2, then repeats with increasing segment lengths.
code.object.collision_testimage 0x4719Object-object rectangle/crossing test used by placement and movement. Returns zero when object flag bit 0x0200 bypasses collision; otherwise scans eligible objects and rejects overlapping/crossing candidates.
code.object.control_acceptanceimage 0x56b8Tests an object’s proposed footprint against high-nibble control/priority classes in data.display.logical_buffer_segment; source and QEMU probes validate selected 0x0002, 0x0100, and 0x0800 flag effects, including the final scanned class state.
code.object.frame_timer_updateimage 0x0563Per-cycle active-object scan that decrements frame timer byte +0x20, calls code.object.advance_frame_by_mode at zero, and reloads +0x20 from +0x1f.
code.object.advance_frame_by_modeimage 0x48b3Dispatches object frame mode byte +0x23; modes loop or stop frames and may set completion flag byte +0x27.
data.object.group_for_direction_two_or_three_groupsdata 0x08ddDirection-to-group table used by code.object.frame_timer_update when object byte +0x0b is 2 or 3 and bit 0x2000 is clear.
data.object.group_for_direction_four_plus_groupsdata 0x08e7Direction-to-group table used by code.object.frame_timer_update when object byte +0x0b is at least 4 and bit 0x2000 is clear.
code.object.build_update_list_sortedimage 0x0358Shared update-list builder. It scans the object table, accepts records through a callback, computes a draw key from baseline Y or code.control.priority_to_y, selection-sorts by ascending key, and inserts nodes through code.object.insert_update_node_head.
code.object.insert_update_node_headimage 0x042fAllocates a 16-byte render/update node and inserts it at the head of the supplied root list while preserving the first inserted node as the tail.
code.object.draw_update_list_tail_to_headimage 0x045eDraws a root list from tail toward head, saving each backing rectangle and then drawing the object’s selected frame.
code.object.refresh_update_list_saved_posimage 0x0488Walks a root list from head toward tail, calls code.object.update_dirty_rect, and updates saved-position fields plus stationary bit 0x4000.
code.object.build_active_update_listimage 0x6a26Builds update-list root 0x16ff using callback code.object.accept_active_root_16ff.
code.object.build_inactive_partition_listimage 0x6a3dBuilds update-list root 0x1703 using callback code.object.accept_root_1703.
code.object.flush_update_lists_restoreimage 0x6a54Flushes roots 0x16ff and 0x1703 through helper 0x0307, restoring saved backing rectangles and freeing nodes.
code.object.rebuild_draw_update_listsimage 0x6a8eRebuilds/draws root 0x1703, then rebuilds/draws root 0x16ff.
code.object.refresh_update_listsimage 0x6aabRuns dirty-rectangle/saved-position refresh helper 0x0488 over root 0x1703, then root 0x16ff.
code.object.clear_root_16ff_membershipimage 0x6b44Clears object bit 0x0010 when set, moving an active object from root 0x16ff eligibility to root 0x1703 eligibility after a flush/rebuild.
code.object.set_root_16ff_membershipimage 0x6b62Sets object bit 0x0010 when clear, moving an active object from root 0x1703 eligibility to root 0x16ff eligibility after a flush/rebuild.
code.object.update_dirty_rectimage 0x5762Refreshes object dirty-rectangle state.
code.object.save_rect_overlay_entryoverlay IBM_OBJS.OVL:0x9db0Entry jump to rectangle save routine.
code.object.restore_rect_overlay_entryoverlay IBM_OBJS.OVL:0x9db3Entry jump to rectangle restore routine.
code.object.draw_overlay_entryoverlay IBM_OBJS.OVL:0x9db6Entry jump to selected-frame drawing routine.
code.object.rewrite_frame_orientationimage 0x587dRewrites bit-0x80 frame data when cached orientation bits differ from object +0x0a.
code.control.priority_to_yimage 0x4cbbMaps a priority/control value back to a Y-like sort key. In SQ2’s normal table mode it scans downward from sentinel index 0xa8; the direct formula branch appears source-present but no SQ2 write has been found that enables it.
code.motion.update_objectsimage 0x150aPer-cycle object movement/update pass.
code.motion.pre_mode_and_boundary_updateimage 0x0644Scans active objects with countdown byte +0x01 == 1, dispatches mode byte +0x22, then applies rectangle-boundary helper code.motion.rectangle_boundary_check when enabled.
code.motion.rectangle_boundary_checkimage 0x06d9Compares current and next baseline points against script rectangle globals [0x0131..0x013d], setting bit 0x0080 and clearing direction on crossing when bit 0x0002 is clear.
code.motion.dispatch_mode_stepimage 0x067aDispatches object mode byte +0x22 to random, approach-first-object, or target-direction helpers when countdown byte +0x01 is ready.
code.motion.start_target_directionimage 0x1672Computes initial direction toward object target fields.
code.motion.compute_directionimage 0x16edDirection lookup from current and target coordinates.
code.motion.complete_target_motionimage 0x16b9Restores step state, sets completion flag, clears target mode.
code.motion.random_mode_stepimage 0x3f5aPer-cycle random-motion mode handler.
code.motion.random_directionimage 0x3fa3Picks a random direction-like byte.
code.motion.approach_first_object_stepimage 0x0b36Per-cycle approach-first-object mode handler.

Text, Input, and Save State

LabelSQ2 addressNotes/evidence
code.text.display_stringimage 0x1ce8Displays a resolved string and returns an interaction result in some paths.
code.text.display_message_windowimage 0x1d96Builds a modal message window: closes any prior active saved window, formats the message, computes packed save/restore rectangle coordinates, calls code.text.draw_boxed_window, sets data.text.window_active_0d1d, prints the formatted text, and refreshes text/input areas.
code.text.close_window_stateimage 0x1f2bRestores/clears active text-window state and always clears data.input.width_flag_0d0f. If data.text.window_active_0d1d is set, it restores the rectangle saved by code.text.display_message_window through code.text.restore_saved_rectangle; QEMU close_text_window_state_clears_input_width_flag validates the inactive-window clear side.
code.text.format_stringimage 0x2374Formats text into caller-provided buffers.
code.text.format_message_to_bufferimage 0x1f54Formats/copies a resolved logic message into a stack buffer.
code.text.draw_boxed_windowimage 0x5590Helper called by the modal message window path with packed rectangle coordinates and attribute word 0x040f; it delegates to overlay save/fill helpers around 0x9812.
code.text.restore_saved_rectangleimage 0x560cHelper called by code.text.close_window_state with the packed saved-window rectangle words. It loads those words and delegates to overlay restore helper 0x980c.
code.text.clear_rowsimage 0x2b78Helper used by action 0x69; wraps code.text.clear_bounds with left column 0 and right column 0x27. QEMU text_rect_clear_rows_removes_formatted_text validates rows 5..6 clearing logical Y 40..55 to visual color 0.
code.text.clear_rowimage 0x2ba6Wraps code.text.clear_rows with top row equal to bottom row. Used by status-line hide (0x71) and input-line disable (0x77); QEMU text_hide_clear_behaviour_001 validates a configured row clearing to visual color 0.
code.text.clear_boundsimage 0x2bc4BIOS int 10h scroll/clear wrapper used by action 0x9a; arguments map to top, left, bottom, right, attribute. QEMU validates text columns as four logical pixels wide and rows as eight logical pixels tall in the EGA target.
code.text.redraw_status_lineimage 0x34bdRedraws the status-line-like area when data.text.status_line_enabled is nonzero, using the current text attribute globals and the status row global. QEMU status_line_show_draws_configured_row validates visible output on the configured row.
code.text.show_status_lineimage 0x3547Action handler for 0x70; sets data.text.status_line_enabled and calls code.text.redraw_status_line. QEMU status_line_show_draws_configured_row validates the row draw.
code.text.hide_status_lineimage 0x355cAction handler for 0x71; clears data.text.status_line_enabled and clears the configured status row.
code.text.set_attribute_pairimage 0x77d5Shared helper for action 0x6d and text-mode transitions. Stores derived text/window attributes in globals [0x05d1], [0x05cd], and [0x05cf]. QEMU text_attribute_pair_changes_attr_mode_clear_color validates that pair (0, 1) changes the later 0x6a clear to visual color 15.
code.input.set_width_flag_actionimage 0x3939Action handler for 0xa3; sets data.input.width_flag_0d0f. QEMU validates the wider live-input path with a long blank string slot 0.
code.input.clear_width_flag_actionimage 0x394bAction handler for 0xa4; clears data.input.width_flag_0d0f. QEMU validates the narrowed live-input path after 0xa3.
data.input.width_flag_0d0fdata 0x0d0fWord tested by input helper code.input.handle_input_char; when set, the helper uses a fixed 0x24 character cap, otherwise it derives the cap from fixed string slot 0. Also cleared by code.text.close_window_state.
data.text.configured_message_width_0d09data 0x0d09One-shot modal-message width override used by actions 0x97 and 0x98; a zero operand is replaced with 0x1e, and the value resets to 0xffff after the display action.
data.text.configured_message_row_0d0bdata 0x0d0bOne-shot modal-message row override used by actions 0x97 and 0x98; the display-window helper adds the current display base row when computing the text cursor row.
data.text.configured_message_column_0d0ddata 0x0d0dOne-shot modal-message column override used by actions 0x97 and 0x98; without it the helper centers the window horizontally from the formatted line width.
data.text.window_active_0d1ddata 0x0d1dWord set after a modal message window saves/draws its rectangle. code.text.display_message_window closes an existing active window before opening a new one; code.text.close_window_state tests this word before restoring the saved rectangle, then clears it.
data.text.window_saved_lower_right_0d23data 0x0d23Packed rectangle word computed by code.text.display_message_window and passed as the first restore argument to code.text.restore_saved_rectangle.
data.text.window_saved_upper_left_0d25data 0x0d25Packed rectangle word computed by code.text.display_message_window and passed as the second restore argument to code.text.restore_saved_rectangle.
code.text.enter_attr_modeimage 0x76caAction handler for 0x6a; erases the prompt marker, sets byte [0x1757], derives attributes, enters the overlay text mode through entry 0x9803, then clears a text rectangle. QEMU text_attribute_enable_clears_visible_surface validates a black visible logical surface with the default pair, and text_attribute_pair_changes_attr_mode_clear_color validates the stored pair path.
code.text.leave_attr_modeimage 0x78cbShared cleanup for action 0x6b; clears byte [0x1757], recomputes attributes, calls overlay entry 0x9806, then redraws status and input-line areas. QEMU text_attribute_disable_restores_picture_draw validates that ordinary picture/object drawing is visible again after this action.
code.input.edit_stringimage 0x0da9Blocking string editor used by 0x73 and 0x76. It copies the destination buffer to a local edit buffer, displays it, waits through code.input.wait_event, dispatches keys through data.input.edit_key_table, copies accepted text back on Enter, and returns without copying on Escape.
code.input.handle_input_charimage 0x3652Shared input-line character helper. Normal characters append to visible buffer 0x0fa4; backspace erases one visible character; Enter copies the visible buffer into source buffer 0x0fce, parses it, clears visible length [0x0ff8], and redraws the input row.
code.input.erase_input_lineimage 0x3726Action handler for 0x8a; loops code.input.handle_input_char(0x08) while visible length [0x0ff8] is nonzero. QEMU input_line_erase_clears_typed_buffer validates the visible-row erase.
code.input.refresh_input_lineimage 0x3753Action handler for 0x89; when input is enabled, calls the source-to-visible refresh helper in the normal EGA path. QEMU input_line_refresh_repaints_entered_buffer validates repaint from source buffer 0x0fce after Enter.
code.input.append_source_to_visibleimage 0x37a5Appends bytes from source input buffer 0x0fce into visible buffer 0x0fa4 until visible length [0x0ff8] reaches the source length, drawing each byte through 0x29f6.
code.input.wait_for_event_or_tickimage 0x4529Blocks until an event queue record is available or timer globals [0x0129]/[0x012b] change, then returns the event record pointer. Menu interaction uses this before normalizing raw and movement events.
code.input.wait_eventimage 0x45d7Blocking event wait helper. Calls the event normalizer at 0x459e until the returned word is neither 0x0000 nor 0xffff.
code.input.enqueue_eventimage 0x44a9Enqueues an input/event record with a type word and value word in the circular queue rooted near data.input.event_queue. Menu selection uses this to enqueue type 3 item ids.
code.input.dequeue_eventimage 0x44f9Dequeues one 4-byte event record from data.input.event_queue_base, returning zero when read and write pointers match.
code.input.reset_event_stateimage 0x4482Resets input-related state around helper calls 0x466f and 0x6326, then resets event queue write/read pointers [0x120a] and [0x120c] to base 0x11ba. Used by room switch and pause/calibration paths.
code.input.keyboard_irq_hookimage 0x6036Keyboard interrupt hook. Handles selected raw scan codes, tracks pressed/released latches, and when data.input.key_release_enqueue_gate_1530 is nonzero can enqueue (type=2, value=0) through code.input.enqueue_event on selected key releases. Local model tools/agi_input.py pins the tracked-key latch contract.
code.input.drain_bios_keysimage 0x467fRepeatedly polls BIOS-key helper 0x5a89, maps known movement keys through code.input.map_raw_direction_key, and enqueues type-2 movement events or type-1 raw key events.
code.input.map_raw_direction_keyimage 0x46b6Scans data.input.menu_direction_event_map for a raw key word and returns the movement value, or 0xffff when unmapped.
code.input.remap_display_adapter_eventimage 0x46e8When display adapter word [0x112e] == 2, scans data.input.display_adapter_event_map and converts matching type-1 events to type-2 movement events.
code.input.normalize_confirm_eventimage 0x4634Normalizes type-1 event values for confirm/editor paths: observed mappings include 0x0101/0x0301 to Enter (0x0d) and 0x0201/0x0401 to Escape (0x1b).
code.input.show_prompt_markerimage 0x37f7Draws the configured prompt marker byte from data.input.prompt_marker_char when the marker is not already visible and the display-mode gates allow it.
code.input.erase_prompt_markerimage 0x382eClears the prompt-marker visible flag and echoes backspace when a prompt marker byte is configured.
code.input.set_prompt_marker_charimage 0x38b4Action handler for 0x6c; resolves a message and stores its first byte in data.input.prompt_marker_char. QEMU input_prompt_empty_message_suppresses_marker validates that an empty message stores zero and suppresses marker drawing on input-line redraw.
code.input.redraw_input_lineimage 0x38d7Redraws the configured input-line area when enabled, including the prompt marker, fixed string slot 0, and the visible input buffer. QEMU input_line_enable_clears_configured_row validates the configured row clear with empty prompt/input text.
code.input.set_line_configimage 0x78f0Action handler for 0x6f; stores input/status row globals and computes display offset global [0x1379] from the first operand.
code.input.map_key_eventimage 0x4c3dAction handler for 0x79; appends a key/event mapping word and mapped value to the first free four-byte slot rooted at data.input.key_event_map.
code.words.parse_string_slot_actionimage 0x1958Action handler for 0x75; clears parser flags 2 and 4, validates slot index < 12, and parses fixed string slot data.strings.slots + index * 0x28.
code.words.parse_bufferimage 0x18acClears parsed word ID/pointer tables, normalizes the source string, looks up up to ten output words, sets parser flag 2 when any recognized or unknown output slot exists, and records count/error position in data.words.parsed_count_or_error_position.
code.words.normalize_string_for_parseimage 0x199dCollapses separator runs to spaces, drops ignored punctuation, trims a trailing space, and writes data.words.normalized_parse_buffer.
code.words.lookup_next_normalized_wordimage 0x1a6bLooks up the current normalized token in WORDS.TOK, advances data.words.current_parse_pointer_0cd1, returns 0xffff for unknown tokens, returns zero for ignored dictionary words, and returns nonzero dictionary IDs for parsed words.
code.words.terminate_unknown_tokenimage 0x1bc7Replaces the next space or terminator in the normalized parse buffer with zero for an unknown token.
code.words.advance_dictionary_entryimage 0x1be4Advances from one compressed dictionary entry to the next by finding the suffix byte with bit 0x80 and stepping over the two-byte ID.
code.view.display_resource_textimage 0x5edbShared helper for actions 0x81 and 0xa2; disables resource-event recording while it loads, displays, and optionally discards a temporary view resource.
data.input.edit_key_tableimage/data 0x0e64Key dispatch table used by code.input.edit_string. The observed SQ2 bytes map 0x03 and 0x18 to clear-current-input, 0x08 to backspace, 0x0d to accept/copy, and 0x1b to cancel/return. Evidence: xxd -g 1 -s 0x1060 -l 0x20 build/cleanroom/AGI.decrypted.exe.
code.save.restore_game_stateimage 0x2512Restore-game action handler.
code.save.save_game_stateimage 0x2753Save-game action handler.
code.save.copy_description_to_string_actionimage 0x2726Action handler for 0xaa; copies up to 0x1f bytes from runtime save-description buffer [0x0e72] into string slot 0x020d + arg0 * 0x28.
code.save.read_length_prefixed_blockimage 0x26b0Reads a length-prefixed memory block from a save file.
code.save.write_length_prefixed_blockimage 0x28c6Writes a length-prefixed memory block to a save file.
code.save.format_slot_filenameimage 0x5b73Formats a numbered save filename with %s%s%ssg.%d, using data.save.path_buffer_1962, a chosen slash/backslash separator, data.save.signature_prefix_0002, and the slot number.
code.save.select_slot_or_pathimage 0x85e5Shared save/restore slot/path selection helper. Saves/restores text state, stops sound, delegates path prompting, scans selectable save slots, formats the selected filename, and returns zero for cancel/no selection.
code.save.check_drive_or_path_availableimage 0x86a3Selector helper that compares the selected drive/path state and displays the insert-disk style message when the target is unavailable.
code.save.prompt_path_if_neededimage 0x8705Selector helper that fills a default path when needed, displays the save/restore path prompt, edits data.save.path_buffer_1962, validates it through the path validator at 0x5bdd, and returns zero on cancel/failure.
code.save.edit_modal_text_fieldimage 0x8794Modal edit helper used by the save selector. Draws a prompt window, clears the edit row, calls the line editor with a 31-character cap, closes the window, and returns one only when Enter accepted the edit.
code.save.select_numbered_slotimage 0x8814Scans up to 12 numbered save files, displays description rows, handles Enter/Escape/up/down selection, and returns the selected slot number or zero. In save mode it prompts for a new description before accepting an empty-description slot.
code.save.read_slot_summaryimage 0x8b9fFormats a numbered save filename, opens it, records the file timestamp, reads the 31-byte description, seeks past the first block length prefix, compares a short signature fragment with data.save.signature_prefix_0002, and returns whether the slot is a valid candidate.
code.restore.replay_resource_eventsimage 0x681cRestore/display-mode state rebuild. Stops sound, clears resource caches, disables resource-event recording while replaying saved resource/event pairs, then reaches code.restore.finish_replay_and_reenable_recording at 0x6927 to re-enable recording, rebind active object views, and refresh display/input/status state.
code.dos.validate_pathimage 0x5bddSave-selector path validator. Skips leading spaces, fills an empty path with the current directory, strips a trailing slash/backslash for multi-character paths, accepts a single separator, probes drive-only paths, and otherwise calls DOS find-first with directory attributes.

Inventory and Menus

LabelSQ2 addressNotes/evidence
code.inventory.show_selection_actionimage 0x31d8Action handler for 0x7c. Enters a text/list mode, builds the carried-item list through code.inventory.build_selection_list, restores text state, and returns to the caller after acknowledgement or selection.
code.inventory.build_selection_listimage 0x3203Builds a stack-local 8-byte-per-row list from the 3-byte metadata table rooted at data.inventory.table_root; includes only entries with marker byte 0xff.
code.inventory.draw_selection_listimage 0x3346Draws the inventory header, carried item names or fallback text, and optional highlighted row/prompt depending on flag 13.
code.inventory.initialize_metadata_and_objectsimage 0x0fa5Loads and decodes the inventory metadata file, consumes its three-byte header, establishes the item-table end and runtime block length, and allocates/initializes the 43-byte drawable-object table from the header’s maximum object index.
data.inventory.selection_result_bytedata 0x0022Absolute byte written by code.inventory.build_selection_list on interactive Enter/Escape. Since script byte variables begin at data.vars.byte_variables (0x0009), this is script variable 0x19. QEMU inventory_selection_001 validates Enter and Escape effects.
code.menu.add_headingimage 0x911dAction handler for 0x9c; allocates and links an 18-byte menu heading node.
code.menu.add_itemimage 0x91cfAction handler for 0x9d; allocates and links a 14-byte menu item node and stores the item id at node offset +0x0c.
code.menu.finalize_setupimage 0x92baAction handler for 0x9e; finalizes/freezes menu setup.
code.menu.set_item_enabledimage 0x935fShared helper used by 0x9f and 0xa0 to enable or disable menu items by id.
code.menu.interactimage 0x93d1Interactive menu path. Draws the menu, waits for input, and enqueues type-3 events with selected item ids for enabled items; QEMU menu_interaction_001 validates one-item Enter selection and menu_edges_002 validates Escape, disabled Enter, and re-enable behavior.
table.menu.navigation_dispatchimage 0x9526Eight-word movement dispatch table used by code.menu.interact for type-2 events. Values 1..8 branch to previous item, first item, next enabled heading, last item, next item, last heading, previous enabled heading, and root heading.
code.menu.draw_headingimage 0x9557Draws a menu heading and its item list, including highlighting the current item through helpers 0x95d0, 0x9625, and 0x95a9.
code.menu.remember_item_and_restore_rectimage 0x95a9Stores the active item pointer in the heading node at +0x0e, redraws/unhighlights the heading, and restores the saved menu rectangle through helper 0x560c. Used when leaving a heading and when exiting the modal menu.
code.menu.draw_itemimage 0x95d0Positions and draws one menu item using row/column fields from an item node.
code.menu.erase_or_unhighlight_itemimage 0x9625Redraws or clears the item’s saved rectangle/highlight state while navigating menu items.
data.menu.finalizeddata 0x1d2aMenu setup finalization flag set by code.menu.finalize_setup.
data.menu.request_interactiondata 0x1d22Word set by action 0xa1 when flag 14 is set; the input/event path enters code.menu.interact and clears this word after handling menu interaction.
data.menu.heading_rootdata 0x1d2cRoot pointer for the circular menu heading list used by setup and interaction routines.
data.menu.current_headingdata 0x1d2eCurrent/remembered heading pointer persisted by code.menu.interact after movement events and initialized by code.menu.finalize_setup.
data.menu.current_itemdata 0x1d30Current/remembered item pointer persisted by code.menu.interact after movement events and initialized from the current heading’s item root.
data.menu.saved_rect_startdata 0x1d32Packed rectangle coordinate computed by helper 0x968b and consumed by menu save/restore rectangle helpers.
data.menu.saved_rect_enddata 0x1d34Packed rectangle coordinate computed by helper 0x968b and consumed by menu save/restore rectangle helpers.

System, Restart, Trace, Sound, and Files

LabelSQ2 addressNotes/evidence
code.system.dos_terminateimage 0x00aeDOS process termination wrapper. Loads exit code byte argument into AL, sets AH=0x4c, and invokes int 21h.
code.system.exit_with_cleanupimage 0x02aeShared fatal/exit helper. Calls code.system.shutdown_cleanup, then calls code.system.dos_terminate(0). Used by 0x86 confirmed exit/restart, restore read failure, verification failure, and allocation failure paths.
code.system.pause_actionimage 0x0257Action handler for 0x88; enters modal state, resets input/event state, stops sound, displays the pause message, and returns to the following bytecode.
code.system.confirm_exit_actionimage 0x027fAction handler for 0x86; stops sound, either exits immediately when operand byte is 1 or displays the confirmation message at 0x05e3 and exits only on confirmation.
code.restart.confirm_restart_actionimage 0x2472Action handler for 0x80; confirmation-gated in-engine restart. On acceptance it clears input, preserves flag 9, rewinds heap/update-list state, reruns initial object/inventory setup, refreshes display/menu state, optionally reloads trace logic, clears timer words, and returns zero to stop the current logic stream. Escape/cancel returns the following bytecode pointer.
code.system.shutdown_cleanupimage 0x8275Cleanup before DOS termination. Closes the log file if open, restores hooked interrupt vectors/timer state, then sets the BIOS video mode from [0x1807].
code.log.close_if_openimage 0x838cIf data.log.file_handle is not 0xffff, closes it and resets the global to 0xffff. Called by code.system.shutdown_cleanup.
code.system.install_interrupt_hooksimage 0x83acSaves original interrupt vectors and installs interpreter hooks for keyboard/timer/critical-error style services.
code.system.restore_interrupt_hooksimage 0x849fRestores interrupt vectors saved by code.system.install_interrupt_hooks and resets the timer PIT divisor before DOS termination.
code.video.set_modeimage 0x5a5eBIOS video-mode wrapper used by shutdown cleanup; calls int 10h with AH=0 and mode byte argument.
code.room.switch_stateimage 0x1792Shared helper for actions 0x12 and 0x13; stops sound, resets heap/update/input state, seeds selected object fields, resets room caches through code.resource.reset_room_caches, updates room variables, loads destination logic, handles entry-boundary placement, sets flag 5, redraws status/input state, and returns zero. QEMU now validates re-entry/current-room dispatch, current/previous/boundary variables, all four boundary placements, and visible absence of a pre-switch persistent object. Exact object/cache field effects are source-backed from disassembly.
code.restart.initialize_game_tablesimage 0x0fa5Initial object/inventory/setup routine called during startup and accepted in-engine restart. It prepares inventory/object metadata, allocates or clears the object table, resets flags/input/display defaults, clears resource caches/update lists, and seeds room-entry globals.
code.display.show_priority_screen_actionimage 0x731bAction handler for 0x1d; sets data.display.priority_screen_mode, refreshes the screen, waits for an event, refreshes again, then clears the mode. QEMU priority_diag_sound_001 validates return after Enter.
data.display.priority_screen_modedata 0x1755Word tested by the full-screen refresh path to display priority/control nibbles instead of normal visual nibbles.
code.object.display_diagnostics_actionimage 0x72b5Action handler for 0x85; formats object fields into the diagnostic template at data 0x1713 and displays the text. QEMU priority_diag_sound_001 validates return after Enter.
code.trace.enable_window_actionimage 0x8c91Action handler for 0x95; when the trace window is already active, consumes one extra byte, otherwise calls code.trace.enable_window_if_flagged.
code.trace.enable_window_if_flaggedimage 0x8caeEnables and draws the trace window only when flag 10 is set. QEMU trace_window_enable_002 validates the enabled red-border/white-fill/black-text path; system_dialog_001 covers the flag-clear dispatch path.
code.trace.configure_window_actionimage 0x8d3dAction handler for 0x96; stores trace logic/resource, row offset, and height globals, clamping height to at least 2. QEMU validates 0x96(0,1,2) feeding the enabled trace-window draw path.
data.trace.active_statedata 0x1d10Trace-window state word tested by 0x95 and cleared by helper 0x8d79.
data.trace.logic_resourcedata 0x1d12Optional logic resource number used by trace formatting and by restart/room-switch reload paths.
data.trace.row_offsetdata 0x1d08Row offset configured by action 0x96.
data.trace.heightdata 0x1d0aTrace-window height configured by action 0x96, clamped upward to at least 2.
code.sound.start_with_flagimage 0x51d3Action handler for 0x63; stops prior sound, stores/clears completion flag, locates a loaded sound resource, and starts playback. QEMU sound_completion_001 validates load/start/stop dispatch after a prior 0x62.
code.sound.stop_or_clear_stateimage 0x5234Shared stop helper used by 0x64 and before starting another sound. Clears active state and sets the configured completion flag when a sound was active; QEMU priority_diag_sound_001 validates that stop sets flag 77 after 0x63(1,77).
code.sound.find_loaded_resourceimage 0x50d8Looks up a loaded sound cache record by resource number for code.sound.start_with_flag; a zero result triggers an error path.
code.sound.load_resourceimage 0x5126Loads/caches a sound-like payload. Restore-time resource replay calls this for saved sound load events.
code.sound.driver_startimage 0x7f96Hardware/driver-facing sound start helper called after code.sound.start_with_flag finds a loaded sound record.
code.sound.driver_tickimage 0x801cTimer-driven playback tick. Tests flag 9, advances active channel countdowns, consumes duration/tone/control records, and stops/completes playback when all active channels terminate.
code.sound.driver_stopimage 0x80afHardware/driver-facing sound stop helper called by code.sound.stop_or_clear_state when sound state had been active.
code.sound.driver_stop_coreimage 0x80c1Shared low-level stop/completion helper. Silences hardware, clears data.sound.active_state, and sets data.sound.completion_flag.
code.sound.driver_write_toneimage 0x80f3Hardware-specific tone/control output helper called after an event record is consumed and by the stop path for silence writes. Selector 0/8 uses PIT/PC-speaker ports and computes divisor 12 * (((tone_word & 0x3f) << 4) + ((tone_word >> 8) & 0x0f)); other observed selectors write encoded tone bytes to port 0xc0.
code.sound.driver_write_attenuationimage 0x8162Hardware-specific attenuation/envelope output helper called on countdown ticks, event reads, and channel termination. Maintains low-nibble attenuation, applies source envelope/delta state, and writes combined channel/attenuation bytes to port 0xc0 on non-PC-speaker paths.
code.sound.timer_irq_hookimage 0x8521Replacement timer interrupt hook. Calls code.sound.driver_tick while sound state is active, then chains to the original timer interrupt every third invocation through divider byte data.sound.timer_irq_divider.
data.sound.active_statedata 0x1258Word set while sound playback state is active.
data.sound.completion_flagdata 0x126aWord holding the flag number set by code.sound.stop_or_clear_state; 0x63 stores and clears this flag before starting playback.
data.sound.channel_stream_pointersdata 0x1788..0x178fFour current stream pointers copied from a sound cache record by code.sound.driver_start; the playback tick advances them through event records.
data.sound.channel_countdownsdata 0x1790..0x1797Four countdown words initialized to 1 and reloaded from event duration words during playback.
data.sound.channel_active_wordsdata 0x1798..0x179fFour nonzero/zero words used by the playback tick to decide whether a channel is still active.
data.sound.channel_attenuationdata 0x17a8..0x17afPer-channel low-nibble attenuation/control values; 0x0f is the silent value used when a channel terminates.
data.sound.active_channel_byte_limitdata 0x1804Tick-loop byte offset limit. Value 2 advances only channel 0; value 8 advances channels 0 through 3.
data.sound.remaining_active_channelsdata 0x1806Byte decremented as channel terminators are consumed; zero triggers the stop/completion path.
data.sound.timer_irq_dividerdata 0x184fTimer-hook countdown byte. The hook acknowledges the interrupt directly until it reaches zero, then resets it to 3 and chains to the original timer interrupt.
code.log.append_messageimage 0x828fAction handler for 0x90; opens/creates logfile, appends a room/input/message record, closes the handle, and returns. QEMU log_file_contents_001 validates the extracted LOGFILE content for a synthetic message.
data.log.file_handledata 0x1823DOS file handle for the log file; 0xffff means closed/unopened.
data.log.filenamedata 0x1825Zero-terminated log filename, observed as logfile.

Runtime Globals and Data Tables

LabelSQ2 addressNotes/evidence
data.vars.byte_variablesdata 0x0009Byte variable array used by many conditions/actions.
data.vars.current_roomdata 0x0009Byte variable 0. code.room.switch_state writes the destination room here; SQ2 logic 0 later dispatches room logic with call_logic_var(v0) at logic bytecode offset 0x053e.
data.vars.previous_roomdata 0x000aByte variable 1. code.room.switch_state copies the prior current-room byte here before overwriting data.vars.current_room. Many room-entry blocks branch on this value.
data.vars.entry_boundarydata 0x000bByte variable 2. code.room.switch_state uses values 1..4 to place object 0 at a room edge, then clears the byte.
data.input.mapped_status_bytesdata 0x1218..0x1249Fifty transient status bytes tested by condition 0x0c; cleared before each cycle’s timed/input event processing.
data.vars.free_memory_pages_0011data 0x0011Byte variable 8. code.heap.update_free_memory_var stores the high byte of available heap bytes here after successful allocations and dynamic-state resets.
data.motion.global_direction_000fdata 0x000fGlobal direction byte mirrored with object0 byte +0x21 by code.engine.main_cycle; also written by first-object motion helpers.
data.motion.direction_mirror_selector_0139data 0x0139Word selector for the pre-logic object0/global direction mirror. Action 0x83 clears it; action 0x84, room switch, and selected first-object stop/reset helpers set it.
data.flags.packed_flagsdata 0x0109Packed flag bitfield; flag 0 is the high bit of byte 0x0109.
data.timer.tick_count_0129data 0x0129Four-byte tick counter included in profile 2.936 save block 1.
data.motion.horizon_012ddata 0x012dWord horizon baseline used by placement and room reset.
data.save.reserved_word_012fdata 0x012fReserved serialized word with no direct reference in the complete executable scan; canonical bytes are zero and loaded bytes are preserved for interchange.
data.motion.rectangle_left_0131data 0x0131Word left bound for the configured movement rectangle.
data.motion.rectangle_top_0133data 0x0133Word top bound for the configured movement rectangle.
data.motion.rectangle_right_0135data 0x0135Word right bound for the configured movement rectangle.
data.motion.rectangle_bottom_0137data 0x0137Word bottom bound for the configured movement rectangle.
data.picture.prepared_number_013bdata 0x013bWord holding the most recently prepared picture number.
data.motion.rectangle_enabled_013ddata 0x013dWord gate for the configured movement rectangle.
data.save.reserved_word_013fdata 0x013fReserved serialized word with no direct reference in the complete executable scan; canonical value is 0x000f and loaded bytes are preserved for interchange.
data.save.reserved_key_map_tail_01e1data 0x01e1..0x0208Ten inactive four-byte key-map records beyond SQ2’s 39-entry loop bound. GR expands the bound to 49 and consumes this exact range.
data.save.reserved_pre_string_padding_0209data 0x0209..0x020cFour reserved bytes retained before the shared string-slot root. Both promoted profiles serialize them as canonical zero bytes.
data.strings.slotsdata 0x020dFixed 40-byte string slots.
data.save.reserved_string_bank_03eddata 0x03ed..0x05ccTwelve reserved 40-byte records beyond the valid 12-slot string range. GR removes this exact bank and places its text attributes at 0x03ed.
data.strings.normalization_drop_charsdata 0x094bZero-terminated bytes skipped during normalized string comparison.
data.words.parser_separators_0c67data 0x0c67Zero-terminated separator bytes used by code.words.normalize_string_for_parse; SQ2 bytes are ,.?!();:[]{}.
data.words.parser_ignored_0c75data 0x0c75Zero-terminated ignored punctuation bytes dropped by code.words.normalize_string_for_parse; SQ2 bytes are apostrophe, backtick, hyphen, and double quote.
data.words.parsed_idsdata 0x0c7bParsed dictionary word IDs.
data.words.parsed_text_pointersdata 0x0c8fPointers into the normalized parse buffer for recognized words and the first unknown output slot.
data.words.parsed_count_or_error_positiondata 0x0ca3Parsed word count, or one-based error position on parse failure.
data.words.dictionary_basepointer global [0x0ca5]Loaded WORDS.TOK base pointer used by dictionary lookup helper 0x1a6b.
data.words.normalized_parse_bufferdata 0x0ca7Parser normalization output buffer consumed one token at a time by dictionary lookup.
data.words.current_parse_pointer_0cd1pointer global [0x0cd1]Current token pointer inside data.words.normalized_parse_buffer, advanced by dictionary lookup helper 0x1a6b.
data.objects.first_objectpointer global [0x096b]Start of 43-byte object record array.
data.objects.endpointer global [0x096d]End pointer for object record array.
data.inventory.table_rootpointer global [0x0971]Root of 3-byte inventory/object metadata entries.
data.inventory.table_endpointer global [0x0973]First byte after the three-byte item-entry table; initialized from the decoded metadata header’s table-size word.
data.inventory.runtime_block_lengthglobal [0x0975]Decoded inventory metadata file length minus its three-byte header; used as save block 3 length.
data.logic.cache_rootpointer global [0x0977]Root of 10-byte logic cache records.
data.logic.cache_head_recorddata 0x0977Static cache-shaped head whose +0x00 word is the linked-list root. code.logic.serialize_resume_table also emits its zero-valued +0x02 logic byte and +0x06 - +0x04 offset as the first block-5 record.
data.logic.current_recordpointer global [0x0981]Current logic record used by message resolution and resume state.
data.logic.resume_tabledata 0x0985Scratch table serialized as save block 5: four-byte logic-number/relative-resume records followed by a 0xffff record.
data.resource.logic_dirpointer global [0x11b2]Loaded logic directory pointer.
data.resource.view_dirpointer global [0x11b4]Loaded view directory pointer.
data.resource.picture_dirpointer global [0x11b6]Loaded picture directory pointer.
data.resource.sound_dirpointer global [0x11b8]Loaded sound directory pointer.
data.resource.view_cache_rootpointer global [0x0ffa]Root of cached view-like resource records. Cleared by code.view.clear_cache_root during room-switch cache reset.
data.resource.picture_cache_rootpointer/global record [0x120e]Picture-like cache root/static first record used by picture loading. Cleared by code.picture.clear_cache_root during room-switch cache reset.
data.resource.sound_cache_rootpointer/global record [0x125a]Sound-like cache root/static first record used by sound loading. Cleared by code.sound.clear_cache_root during room-switch cache reset.
data.save.description_bufferdata 0x0e72Runtime save-description/path buffer consumed by 0xaa and tested by save/restore handlers after slot/path selection.
data.save.signature_prefix_0002data 0x0002Runtime game signature/save filename prefix. Action 0x8f copies a logic message here and verifies it against the embedded SQ2 signature; save filename formatting and slot summary filtering also consume this string.
data.save.path_buffer_1962data 0x1962Path buffer edited by code.save.prompt_path_if_needed and validated by the generic path helper.
data.save.header_description_buffer_1c6cdata 0x1c6c31-byte save-file description/header buffer written before the length-prefixed state blocks. Filled by the empty-slot save-description prompt when needed.
data.save.filename_buffer_1c8cdata 0x1c8cFully formatted save filename/path used by the save and restore DOS file wrappers after slot selection.
data.display.hardware_kindglobal [0x112e]Display adapter/hardware selector used by setup and display branches.
data.display.modeglobal [0x1130]Display mode selector affected by command-line flags and opcode 0x8c.
data.display.shake_low_basedata 0x1779Base value added to the second byte of each normal-path screen-shake table pair before writing CRT controller register 0x07; 0x6e sets it to 0x70 or 0x38 from hardware selector [0x112e].
data.display.shake_offset_tabledata 0x177aByte pairs consumed by the normal-path 0x6e screen shake loop. The first byte plus [0x1365] is written to CRT register 0x02; the second byte plus data.display.shake_low_base is written to register 0x07.
data.display.shake_high_offsetdata 0x1365Offset added to the first byte of each screen-shake table pair before writing CRT controller register 0x02.
data.display.cga_color_mapAGIDATA.OVL:0x1d36Three-byte-per-color table used by the CGA graphics overlay color mapper. Mode 0 uses byte 0 duplicated; mode 1 uses bytes 1 and 2 as the returned word.
data.heap.current_top_0a55data 0x0a55Current top pointer for the interpreter’s bump heap. Seeded with data.heap.base_0a57 during startup memory allocation.
data.heap.base_0a57data 0x0a57Heap base used by allocation and heap-status display. Startup derives it from the DOS allocated segment relative to the interpreter data segment.
data.heap.room_reset_mark_0a59data 0x0a59Mark used by room switch, restart, and restore cleanup; code.heap.reset_dynamic_state rewinds the heap to this pointer.
data.heap.limit_0a5bdata 0x0a5bHeap limit pointer used by code.heap.allocate and code.heap.update_free_memory_var; startup sets it to data.heap.base_0a57 + requested_runtime_paragraphs * 16.
data.heap.temporary_mark_0a5ddata 0x0a5dOptional one-shot temporary heap mark saved by code.heap.save_temporary_mark and consumed by code.heap.restore_temporary_mark.
data.heap.high_water_0a5fdata 0x0a5fHighest current-top value observed after successful allocations; reported by code.heap.show_status_action.
data.control.priority_tabledata 0x127aRuntime 168-byte row-to-priority/control table.
data.display.logical_buffer_segmentglobal [0x136f]Segment of logical graphics/control buffer.
data.picture.current_payloadglobal [0x1377]Pointer to selected picture payload during decode.
data.picture.draw_stateglobal [0x1369]Active picture low/high nibble draw state.
data.picture.visual_draw_valueglobal [0x136b]Current low-nibble picture draw value.
data.picture.control_draw_valueglobal [0x136c]Current high-nibble picture draw value.
data.picture.odd_y_write_maskglobal [0x136d]Mask selected by code.display.pixel_write for odd Y rows.
data.picture.even_y_write_maskglobal [0x136e]Mask selected by code.display.pixel_write for even Y rows.
data.picture.pattern_bitsdata 0x15f9Bit masks used by patterned picture drawing.
data.picture.pattern_pointer_tabledata 0x1619Pattern pointer table selected by low three bits of picture pattern mode.
data.input.key_event_mapdata 0x0145Up to 39 four-byte key mapping slots populated by code.input.map_key_event; helper 0x4566 consults this table while normalizing events.
data.input.event_queue_basedata 0x11baStart of the 20-record circular raw event queue. Records are 4 bytes: type word, value word.
data.input.event_queue_writedata 0x120aWrite pointer used by code.input.enqueue_event; wraps to data.input.event_queue_base at the queue end.
data.input.event_queue_readdata 0x120cRead pointer used by code.input.dequeue_event; equal read/write pointers mean the queue is empty.
data.input.tracked_scan_enableddata 0x1519Byte table indexed by raw scan code minus 0x47; nonzero entries enable special keyboard IRQ release tracking for selected scan codes.
data.input.tracked_scan_pressed_latchdata 0x1524Byte table indexed like data.input.tracked_scan_enabled; press paths set one latch and clear the others, release paths clear the latch before optionally enqueueing a release event.
data.input.last_irq_scan_codedata 0x152fLast raw scan byte captured by code.input.keyboard_irq_hook before range/latch handling.
data.input.key_release_enqueue_gate_1530data 0x1530Byte gate incremented by action 0xad; nonzero lets code.input.keyboard_irq_hook enqueue a type-2 zero event on selected tracked-key release paths. The source model covers 8-bit wraparound from 0xff to zero.
data.input.menu_direction_event_mapdata 0x16b3Four-byte raw key/event to movement-code table consulted by helper 0x46b6 before type-2 events are enqueued. Observed SQ2 entries map 0x4800, 0x4900, 0x4d00, 0x5100, 0x5000, 0x4f00, 0x4b00, and 0x4700 to movement codes 1..8.
data.input.display_adapter_event_mapdata 0x16d7Four-byte remap table used when display adapter word [0x112e] == 2; observed entries map numeric keypad values 0x38, 0x39, 0x36, 0x33, 0x32, 0x31, 0x34, and 0x37 to movement values 1..8.
data.input.prompt_marker_chardata 0x05d7Prompt/input marker character configured by action 0x6c; code.input.show_prompt_marker and code.input.erase_prompt_marker use it when drawing or erasing the marker.
data.text.foreground_attribute_05cddata 0x05cdDerived foreground text attribute included in profile 2.936 save block 1.
data.text.background_attribute_05cfdata 0x05cfDerived background text attribute included in profile 2.936 save block 1.
data.text.packed_attribute_05d1data 0x05d1Packed current text/window attribute included in profile 2.936 save block 1.
data.text.status_line_enableddata 0x05d9Word flag controlled by actions 0x70 and 0x71; code.text.redraw_status_line only draws the status line when this is nonzero.
data.text.input_line_enableddata 0x05d3Word flag controlled by actions 0x77 and 0x78; input-line redraw/erase helpers test it before updating the visible input area.
data.text.input_row_05d5data 0x05d5Configured input-line text row.
data.save.reserved_text_padding_05d8data 0x05d8Reserved byte aligning the following word state; all 11 local saves contain the canonical zero value.
data.text.status_row_05dbdata 0x05dbConfigured status-line text row.
data.text.display_base_row_05dddata 0x05ddConfigured base row for the text display area.
data.text.display_bottom_row_05dfdata 0x05dfBottom row derived from the configured display base row.
data.text.attr_mode_enableddata 0x1757Byte flag set by action 0x6a and cleared by code.text.leave_attr_mode; text attribute derivation helpers branch on it.
data.text.attribute_stackdata 0x1759Five-entry stack of triples saved/restored by helpers 0x7989 and 0x79c3; count lives at [0x1777].
data.event.pair_capacityglobal [0x0141]Maximum number of two-byte resource/event pairs. Action 0x8e writes this value before resetting the pair buffer.
data.event.pair_countglobal [0x0143]Active count of event/resource pairs.
data.event.saved_pair_countglobal [0x05e1]Saved pair count slot used by actions 0xab and 0xac.
data.event.pair_buffer_baseglobal [0x1707]Base pointer for resource/event pair buffer.
data.event.pair_buffer_writeglobal [0x1709]Current write pointer for appends and replay end pointer.
data.event.pair_buffer_readglobal [0x170b]Replay read cursor used by code.event.next_replay_pair.
data.event.recording_enabledglobal [0x170d]Word gate checked by code.event.record_pair after flag 7.
data.event.pair_high_waterglobal [0x170f]Maximum observed pair count; heap/status display uses it and overflow error reporting passes it as context.
data.motion.direction_tabledata 0x0a85Nine-word direction lookup used by code.motion.compute_direction.

Gold Rush / AGI v3 Address Associations

These are the first non-SQ2 mappings for existing or newly introduced symbolic labels. They are loaded-image offsets in games/GR/AGI unless otherwise noted. The GR executable has the same 0x200-byte MZ header size as the decrypted SQ2 executable, so file offsets are image offsets plus 0x200.

LabelGR addressNotes/evidence
code.logic.action_dispatchimage 0x02bcSame structural role as SQ2 0x02c4, but the v3 max-action check accepts opcodes through 0xb5 and dispatches through a build-specific AGIDATA action table.
table.logic.action_dispatchGR AGIDATA.OVL:0x0440; KQ4D AGIDATA.OVL:0x0620Four-byte v3 action table. tools/disassemble_logic.py now detects this table by the observed argc/meta signature; GR and KQ4D both parse with their build-specific bases.
code.logic.condition_dispatchimage 0x0a31Same structural role as SQ2 0x07e3. The GR dispatcher compares predicate bytes with 0x26, but the observed structured table at AGIDATA.OVL:0x0762 only covers shared entries 0x00..0x12.
table.logic.condition_dispatchGR AGIDATA.OVL:0x0762; KQ4D AGIDATA.OVL:0x0942Four-byte v3 condition table for entries 0x00..0x12, matching SQ2 table 0x08fd by contract and normalized handler snippets. Bytes after entry 0x12 overlap string/data in GR and are not confirmed predicates. Gold Rush scripts observed so far only use conditions through 0x0e.
opcode.action.reserved_noop_v3_0table slot 0xb0, image 0x5286GR-only action slot. Zero operands, generic no-op/return handler.
opcode.action.set_menu_interaction_gatetable slot 0xb1, image 0x970bGR-only action slot. Reads one immediate byte and stores it in data.menu.interaction_gate_0403; QEMU report build/gr-v3-behavior/menu_gate_suite.json validates zero as blocked and nonzero as modal-menu entry.
opcode.action.reserved_noop_v3_2table slot 0xb2, image 0x5286GR-only action slot. Zero operands, generic no-op/return handler.
opcode.action.reserved_noop_v3_4argstable slot 0xb3, image 0x5286GR-only action slot. Four fixed operands are consumed by table-driven scanning, but the handler performs no state change.
opcode.action.reserved_noop_v3_2varargstable slot 0xb4, image 0x5286GR-only action slot. Two variable operands are declared with metadata 0xc0, but the handler performs no state change.
opcode.action.clear_key_release_event_gatetable slot 0xb5, image 0x63b0GR-only action slot. Stores zero in data.input.key_release_enqueue_gate_0405; GR action 0xad stores one in the same byte. Local model tools/agi_input.py covers the set/clear gate.
code.menu.interactimage 0x9724GR address association for the interactive menu path. Tests data.menu.interaction_gate_0403 before drawing/waiting; returns immediately while the gate is zero. QEMU menu_gate_suite confirms that only a nonzero gate lets a later 0xa1 request enter the modal menu.
code.input.keyboard_irq_hookimage 0x63b8GR keyboard interrupt hook. Tests data.input.key_release_enqueue_gate_0405 before enqueueing (type=2, value=0) on selected key-release paths. The tracked-key latch contract matches SQ2 after relocation.
code.input.set_line_configimage 0x7c24GR association for SQ2 action 0x6f. Stores the same input-line row/bounds roles at relocated globals and computes display offset [0x11b1] = arg0 << 3 without SQ2’s display-mode-2 branch.
code.input.edit_stringimage 0x0fb7GR association for SQ2 image 0x0da9; blocking string editor used by GR prompt actions 0x73 and 0x76.
code.input.handle_input_charimage 0x3961GR association for SQ2 image 0x3652; visible/source input buffer character helper.
code.input.erase_input_lineimage 0x3a29GR association for SQ2 action 0x8a. Loops on visible input length [0x0e19]; no SQ2 display-mode-2/input-width skip branch.
code.input.refresh_input_lineimage 0x3a48GR association for SQ2 action 0x89. Calls the relocated source-to-visible helper when input is enabled; no SQ2 alternate display-mode-2/input-width path.
code.input.append_source_to_visibleimage 0x3a5eGR association for SQ2 image 0x37a5; appends source input buffer bytes into the visible buffer.
code.input.show_prompt_markerimage 0x3ab0GR association for SQ2 image 0x37f7; draws prompt marker byte [0x03f7] when marker state [0x0dc3] is clear and the byte is nonzero.
code.input.erase_prompt_markerimage 0x3ad9GR association for SQ2 image 0x382e; clears the prompt-marker visible state and backspaces the marker when configured.
code.input.prompt_marker_visible_stateimage 0x3b00GR association for SQ2 helper 0x3863; returns prompt-marker visible word [0x0dc3].
code.input.set_prompt_marker_charimage 0x3b43GR association for SQ2 action 0x6c; stores the first byte of a resolved message in prompt-marker byte [0x03f7].
code.input.redraw_input_lineimage 0x3b66GR association for SQ2 image 0x38d7; redraws the configured input row, prompt marker, fixed prompt string, and visible input buffer.
code.input.set_width_flag_actionimage 0x5286GR maps SQ2 action 0xa3 to the generic no-op/return handler.
code.input.clear_width_flag_actionimage 0x5286GR maps SQ2 action 0xa4 to the generic no-op/return handler.
code.input.map_key_eventimage 0x4e98GR association for SQ2 action 0x79; same three-operand key/event mapping shape, but scans 0x31 four-byte slots instead of SQ2’s 0x27. QEMU probe build/gr-v3-behavior/key_map_capacity_qemu_pic001_002.json validates slot 48 with a typed-key positive case and no-key control.
code.text.close_window_stateimage 0x21a2GR association for SQ2 action 0xa9. Restores a saved rectangle when data.text.window_active_0b24 is nonzero and clears that active flag; it does not clear a GR input-width flag.
code.text.restore_saved_rectangleimage 0x582bGR association for SQ2 image 0x560c; rectangle restore helper consumed by code.text.close_window_state.
code.room.switch_room_actionimage 0x19d4GR association for SQ2 action 0x12; calls code.room.remap_reserved_room_target before the relocated room-switch helper 0x1a0a.
code.room.remap_reserved_room_targetimage 0x0062GR-only helper used by action 0x12: bytes 0x7e..0x80 return 0x49; all other target bytes pass through unchanged. QEMU probe build/gr-v3-behavior/room_remap_all_qemu_pic001_001.json validates 0x7e, 0x7f, and 0x80 as aliases for 0x49 with matching nonblank captures.
code.inventory.show_selection_actionimage 0x351eGR association for SQ2 action 0x7c; relocated carried-item selector plus temporary word data.inventory.selection_event_gate_0dc1.
code.save.save_game_stateimage 0x29e5GR association for SQ2 action 0x7d; relocated five-block save writer with an XOR pass over the object/inventory chunk before and after save-file writes. QEMU report build/gr-v3-behavior/save_xor_extract_qemu_001.json validates a blank-prefix SG.1 extraction, and build/gr-v3-behavior/save_xor_extract_signed_qemu_001.json validates 0x8f("GR") producing GRSG.1 with first-block prefix GR\0; both have third block length 1811 and round-trip through the modeled XOR transform.
code.save.restore_game_stateimage 0x2792GR association for SQ2 action 0x7e; relocated five-block restore reader. After loading the third block into [0x07d6], the success path calls code.save.object_inventory_xor_range over [0x07d6]..[0x07d6]+[0x07da], refreshes display/resource state, clears the caller return pointer, and returns through restored script state. QEMU report build/gr-v3-behavior/signed_restore_roundtrip_suite.json validates a signed GRSG.1 restore by matching the restored capture to a direct saved-state control and differing from an unrestored control.
code.save.object_inventory_xor_rangeimage 0x07bcGR helper called by save and object/inventory setup paths. XORs bytes in a caller-supplied range with repeating key bytes at 0x072c until a zero key byte.
data.save.object_inventory_block_start_07d6GR data [0x07d6]Pointer to the GR save block that is XOR-transformed before writing and transformed again before returning from action 0x7d.
data.save.object_inventory_block_length_07daGR data [0x07da]Length of the GR save block rooted at data.save.object_inventory_block_start_07d6; save action 0x7d writes this as the third length-prefixed state block.
data.save.object_inventory_xor_key_072cGR data 0x072cZero-terminated repeating key bytes used by code.save.object_inventory_xor_range; observed in AGIDATA.OVL as Avis Durgan. This is a data-segment address, not a main-code image offset.
code.restart.confirm_restart_actionimage 0x26e0GR association for SQ2 action 0x80; records prompt-marker visible state before confirmation, then redraws after accepted restart or after canceled restart only when the marker had been visible. QEMU report build/gr-v3-behavior/restart_prompt_marker_qemu_001.json confirms the canceled branch.
code.resource.load_all_directoriesimage 0x44dev3 combined-directory loader. Formats "%sdir", reads a whole combined directory, derives four section pointers from the first eight bytes, and falls back to separate logdir/picdir/viewdir/snddir loads if the combined open fails.
code.resource.dir_entry_or_nullimage 0x4599v3 shared absent-entry helper. Returns null only for exact ff ff ff, unlike SQ2’s high-nibble 0xf check.
code.resource.logic_dir_entryimage 0x45bcUses v3 logic directory base [0x0fda]; missing-resource string logic at AGIDATA.OVL:0x0f5e.
code.resource.view_dir_entryimage 0x45f0Uses v3 view directory base [0x0fdc]; missing-resource string view at AGIDATA.OVL:0x0f64.
code.resource.picture_dir_entryimage 0x4624Uses v3 picture directory base [0x0fde]; missing-resource string picture at AGIDATA.OVL:0x0f69.
code.resource.sound_dir_entryimage 0x4658Uses v3 sound directory base [0x0fe0]; missing-resource string sound at AGIDATA.OVL:0x0f71.
code.resource.open_volume_handlesimage 0x33c2Opens sixteen possible prefixed volume files with "%svol.%d", explaining observed GRVOL.9 through GRVOL.12 entries.
code.resource.close_volume_handlesimage 0x341cCloses the sixteen v3 handle slots and resets them to 0xffff.
code.resource.read_volume_payload_retryimage 0x30acv3 retry wrapper around code.resource.read_volume_payload_once.
code.resource.read_volume_payload_onceimage 0x30d0v3 generic reader. Decodes 7-byte record headers, allocates expanded length, and selects direct, dictionary, or picture-nibble payload paths.
code.resource.decompress_lzw_likeimage 0x07f4General v3 dictionary decompressor for compressed logic/view/sound records. Uses reset code 0x100, end code 0x101, and 9-to-11-bit codes.
code.resource.decompress_picture_nibbleimage 0x9a5bv3 picture transform that expands packed nibbles after 0xf0/0xf2 into ordinary byte operands and stops after emitting 0xff.
code.view.load_resourceimage 0x3c5bGR address association for SQ2 image 0x39f7; normalized static comparison matches after resource-reader relocation.
code.object.bind_viewimage 0x3d4bGR address association for SQ2 image 0x3ae7; normalized static comparison matches.
code.object.select_groupimage 0x3e1bGR address association for SQ2 image 0x3bb7; normalized static comparison matches.
code.object.select_group_tableimage 0x3e7fGR address association for SQ2 image 0x3c1b; normalized static comparison matches.
code.object.select_frameimage 0x3f2fGR address association for SQ2 image 0x3ccb; normalized static comparison matches.
code.view.discardimage 0x4131GR address association for SQ2 image 0x3ecd; normalized static comparison matches.
code.picture.load_resourceimage 0x4c96GR address association for SQ2 image 0x4a3b; normalized static comparison matches after resource-reader relocation.
code.picture.prepareimage 0x4d2aGR address association for SQ2 image 0x4acf; normalized static comparison matches.
code.picture.overlay_prepareimage 0x4d96GR address association for SQ2 image 0x4b3b; normalized static comparison matches.
code.picture.discardimage 0x4e29GR address association for SQ2 image 0x4bce; normalized static comparison matches.
code.picture.decode_no_clearimage 0x67c2GR address association for SQ2 image 0x6440; differs because GR returns after command scan where SQ2 checks display mode 2 and calls an overlay refresh path.
code.picture.command_scanimage 0x67edGR address association for SQ2 image 0x6475; normalized static comparison matches.
table.picture.command_dispatchAGIDATA.OVL:0x140dGR dispatch table for picture command bytes 0xf0..0xfa; corresponds to SQ2 data table 0x15d6.
code.picture.cmd_set_visual_draw_nibbleimage 0x680cGR address association for SQ2 image 0x6494; normalized static comparison matches.
code.picture.cmd_disable_visual_draw_nibbleimage 0x682dGR address association for SQ2 image 0x64b5; normalized static comparison matches.
code.picture.cmd_set_control_draw_nibbleimage 0x683fGR address association for SQ2 image 0x64c7; normalized static comparison matches.
code.picture.cmd_disable_control_draw_nibbleimage 0x6865GR address association for SQ2 image 0x64ed; normalized static comparison matches.
code.picture.cmd_draw_corner_path_y_firstimage 0x698aGR address association for SQ2 image 0x6612; normalized static comparison matches.
code.picture.cmd_draw_corner_path_x_firstimage 0x697bGR address association for SQ2 image 0x6603; normalized static comparison matches.
code.picture.cmd_draw_absolute_linesimage 0x69beGR address association for SQ2 image 0x6646; normalized static comparison matches.
code.picture.cmd_draw_relative_linesimage 0x69d6GR address association for SQ2 image 0x665e; normalized static comparison matches.
code.picture.cmd_seed_fillimage 0x6a23GR address association for SQ2 image 0x66ab; normalized static comparison matches.
code.picture.cmd_set_pattern_modeimage 0x689cGR address association for SQ2 image 0x6524; normalized static comparison matches.
code.picture.cmd_pattern_plotimage 0x6877GR address association for SQ2 image 0x64ff; normalized static comparison matches.
code.picture.read_coord_pairimage 0x6a30GR address association for SQ2 image 0x66b8; normalized static comparison matches.
code.picture.draw_lineimage 0x6a59GR address association for SQ2 image 0x66e1; normalized static comparison matches.
code.display.fill_buffer_wordimage 0x548aGR address association for SQ2 image 0x5257; the memory fill skeleton matches, but GR omits SQ2’s display-mode-2 overlay refresh call.
code.display.draw_horizontal_lineimage 0x5498GR address association for SQ2 image 0x526f; normalized static comparison matches.
code.display.draw_vertical_lineimage 0x54d4GR address association for SQ2 image 0x52ab; normalized static comparison matches.
code.display.pixel_writeimage 0x5522GR address association for SQ2 image 0x52f9; normalized static comparison matches.
code.picture.seed_fillimage 0x5564GR address association for SQ2 image 0x533b; normalized static comparison matches.
code.display.clear_logical_bufferimage 0x5751GR address association for SQ2 image 0x5528; normalized static comparison matches.
code.display.full_refreshimage 0x576fGR address association for SQ2 image 0x5546; GR omits SQ2’s display-mode-2 overlay refresh branch.
code.object.build_update_list_sortedimage 0x0351GR address association for SQ2 image 0x0358; normalized static comparison matches.
code.object.insert_update_node_headimage 0x0428GR address association for SQ2 image 0x042f; normalized static comparison matches.
code.object.draw_update_list_tail_to_headimage 0x0457GR address association for SQ2 image 0x045e; normalized static comparison matches, but GR calls main-image rectangle save/draw routines instead of SQ2 overlay entries.
code.object.refresh_update_list_saved_posimage 0x0481GR address association for SQ2 image 0x0488; normalized static comparison matches.
code.object.frame_timer_updateimage 0x055cGR address association for SQ2 image 0x0563; differs by sending exactly-four-loop views directly through the four-plus direction table, but gating views with more than four loops on flag 0x14. QEMU report build/gr-v3-behavior/frame_selection_gate_qemu_001.json validates exact-four view 177 selecting group 1 regardless of flag 0x14, and more-than-four view 39 selecting group 1 only when flag 0x14 is set.
code.object.advance_frame_by_modeimage 0x4b0eGR address association for SQ2 image 0x48b3; apparent straight-line differences are embedded jump-table bytes, while manually inspected branch bodies match as relocated skeletons.
code.object.collision_testimage 0x4974GR address association for SQ2 image 0x4719; normalized static comparison matches.
code.object.control_acceptanceimage 0x58e5GR address association for SQ2 image 0x56b8; normalized static comparison matches.
code.object.update_dirty_rectimage 0x598fGR address association for SQ2 image 0x5762; normalized static comparison matches.
code.object.placeimage 0x5cb3GR address association for SQ2 image 0x593a; normalized static comparison matches.
code.object.build_active_update_listimage 0x6d9eGR address association for SQ2 image 0x6a26; normalized static comparison matches.
code.object.build_inactive_partition_listimage 0x6db5GR address association for SQ2 image 0x6a3d; normalized static comparison matches.
code.object.flush_update_lists_restoreimage 0x6dccGR address association for SQ2 image 0x6a54; normalized static comparison matches.
code.object.rebuild_draw_update_listsimage 0x6e06GR address association for SQ2 image 0x6a8e; normalized static comparison matches.
code.object.refresh_update_listsimage 0x6e23GR address association for SQ2 image 0x6aab; normalized static comparison matches.
code.object.clear_root_16ff_membershipimage 0x6ebcGR address association for SQ2 image 0x6b44; normalized static comparison matches.
code.object.set_root_16ff_membershipimage 0x6edaGR address association for SQ2 image 0x6b62; normalized static comparison matches.
code.motion.update_objectsimage 0x1720GR address association for SQ2 image 0x150a; normalized static comparison matches.
code.motion.pre_mode_and_boundary_updateimage 0x0654GR address association for SQ2 image 0x0644; normalized static comparison matches.
code.motion.dispatch_mode_stepimage 0x068aGR address association for SQ2 image 0x067a; GR accepts motion mode 4 and dispatches it to the same target-direction helper as mode 3 before falling through to the same boundary-check tail. Instrumented QEMU report build/gr-v3-behavior/motion_mode_4_qemu_pic001_001.json confirms this internal branch by patching a copied action-0x51 setup byte from mode 3 to mode 4.
code.motion.rectangle_boundary_checkimage 0x06ebGR address association for SQ2 image 0x06d9; apparent straight-line differences are embedded direction jump-table bytes, while manually inspected post-table body matches as a relocated skeleton.
code.motion.seed_first_object_mode4_targetimage 0x1975GR helper-shaped code that writes object 0 byte +0x22 = 4, seeds target X/Y bytes +0x27/+0x28, and preserves the current step in +0x29 when data.motion.direction_mirror_selector_0139 is nonzero. A direct near-call scan found no ordinary call into this address in the local GR main image, so the natural entry path remains unresolved/source-only.
code.object.save_rect_overlay_entryimage 0x5b67GR packages the rectangle-save routine in the main executable image; SQ2 reaches this role through IBM_OBJS.OVL:0x9db0.
code.object.restore_rect_overlay_entryimage 0x5ba6GR packages the rectangle-restore routine in the main executable image; SQ2 reaches this role through IBM_OBJS.OVL:0x9db3.
code.object.draw_overlay_entryimage 0x5be3GR packages the selected-frame draw routine in the main executable image; SQ2 reaches this role through IBM_OBJS.OVL:0x9db6.
data.resource.logic_dirGR data [0x0fda]Loaded v3 logic directory section pointer.
data.resource.view_dirGR data [0x0fdc]Loaded v3 view directory section pointer.
data.resource.picture_dirGR data [0x0fde]Loaded v3 picture directory section pointer.
data.resource.sound_dirGR data [0x0fe0]Loaded v3 sound directory section pointer.
data.menu.interaction_gate_0403GR data [0x0403]Word written by GR-only action 0xb1; code.menu.interact returns immediately while this word is zero. QEMU menu_gate_suite validates zero and nonzero observable branches.
data.input.key_release_enqueue_gate_0405GR data [0x0405]Byte set by GR action 0xad, cleared by GR-only action 0xb5, and tested by code.input.keyboard_irq_hook before selected key-release event enqueue. Local model tools/agi_input.py covers this gate against the shared latch state machine.
data.input.prompt_marker_charGR data [0x03f7]Relocated prompt-marker byte used by GR input-line redraw helpers.
data.input.visible_bufferGR data [0x0dc5]Relocated visible input buffer used by GR code.input.handle_input_char and refresh helpers.
data.input.source_bufferGR data [0x0def]Relocated accepted/source input buffer used by GR refresh and parser paths.
data.input.visible_lengthGR data [0x0e19]Relocated visible input length tested by GR input erase/append helpers.
data.input.display_offsetGR data [0x11b1]Relocated display offset written by GR action 0x6f; computed as arg0 << 3.
data.text.input_line_enabledGR data [0x03f3]Relocated input-line enabled word controlled by GR actions 0x77 and 0x78.
data.text.window_active_0b24GR data [0x0b24]Relocated active text-window state consumed and cleared by GR code.text.close_window_state.
data.text.window_saved_lower_right_0b2aGR data [0x0b2a]Relocated packed saved-window rectangle word passed to GR rectangle restore helper.
data.text.window_saved_upper_left_0b2cGR data [0x0b2c]Relocated packed saved-window rectangle word passed to GR rectangle restore helper.
data.inventory.selection_event_gate_0dc1GR data [0x0dc1]Temporary word set while GR’s interactive carried-item selector waits/handles events and cleared before action 0x7c returns.

KQ4 full game / AGI 3.002.086 Address Associations

These loaded-image offsets come from games/KQ4/AGI. They identify the full game’s earlier 3.002.086 build separately from the KQ4D demo.

LabelKQ4 addressNotes/evidence
code.logic.action_dispatchimage 0x02c4Accepts action bytes through 0xb1; later bytes are invalid action opcodes in this build.
code.logic.load_recordimage 0x13d9Loads a logic resource and conditionally applies the repeating-key XOR to its message region when data.resource.direct_record_flag_0f5e is nonzero.
code.resource.read_recordimage 0x311bReads a v3 record. The direct branch sets data.resource.direct_record_flag_0f5e; dictionary expansion clears it.
data.resource.direct_record_flag_0f5edata [0x0f5e]Nonzero after a direct resource read and zero after dictionary expansion. Logic setup uses it to distinguish encoded direct-record messages from plain expanded messages.
table.logic.action_dispatchAGIDATA.OVL:0x061d178 four-byte records for actions 0x00..0xb1; the count follows from the fixed v3 trailer before the condition table.
table.logic.condition_dispatchAGIDATA.OVL:0x092fNineteen common condition records.
opcode.action.increment_key_release_event_gateaction 0xad, image 0x6468Increments byte [0x15a0], unlike KQ4D’s set-to-one variant.
opcode.action.reserved_noop_v3_0action 0xb0, image 0x5467Consumes one ignored operand and otherwise has no effect.
opcode.action.set_menu_interaction_gateaction 0xb1, image 0x9812Stores its immediate byte as a word in [0x1d9e].
data.input.key_release_enqueue_gate_15a0data [0x15a0]Incremented by action 0xad; outside KQ4’s serialized block 1.
data.menu.interaction_gate_1d9edata [0x1d9e]Written by action 0xb1; outside KQ4’s serialized block 1.
code.save.save_game_stateimage 0x2a30Writes the five-block envelope with first-block length 0x05e1 and XOR-transforms block 3 around the write.
code.save.restore_game_stateimage 0x27ddReads the same five block roles and decodes the restored block-3 range.
code.save.object_inventory_xor_rangeimage 0x07adRepeats the zero-terminated key at data 0x08f9 over a caller-supplied range.
data.save.object_inventory_xor_key_08f9data 0x08f9Zero-terminated Avis Durgan key.
code.view.load_resourceimage 0x3d94Relocation match for KQ4D 0x3daa.
code.object.bind_viewimage 0x3e84Relocation match for KQ4D 0x3e9a.
code.object.select_groupimage 0x3f54Relocation match for KQ4D 0x3f6a.
code.object.select_group_tableimage 0x3fb8Relocation match for KQ4D 0x3fce.
code.object.select_frameimage 0x4068Relocation match for KQ4D 0x407e.
code.view.discardimage 0x426aRelocation match for KQ4D 0x4280.
code.picture.load_resourceimage 0x4e69Relocation match for KQ4D 0x4e7f.
code.picture.prepareimage 0x4efdRelocation match for KQ4D 0x4f13.
code.picture.overlay_prepareimage 0x4f69Relocation match for KQ4D 0x4f7f.
code.picture.discardimage 0x4ffcRelocation match for KQ4D 0x5012.
code.picture.decode_no_clearimage 0x6879Primary full-EGA path matches KQ4D after relocation.
code.picture.command_scanimage 0x68aeAll picture command and raster branch bodies match KQ4D after relocation.
code.display.fill_buffer_wordimage 0x566bPrimary full-EGA path matches KQ4D after relocation.
code.display.draw_horizontal_lineimage 0x5683Relocation match for KQ4D 0x568b.
code.display.draw_vertical_lineimage 0x56bfRelocation match for KQ4D 0x56c7.
code.display.pixel_writeimage 0x570dRelocation match for KQ4D 0x5715.
code.picture.seed_fillimage 0x574fRelocation match for KQ4D 0x5757.
code.display.full_refreshimage 0x595aPrimary full-EGA path matches KQ4D after relocation.
code.object.build_update_list_sortedimage 0x0358Same entry as KQ4D.
code.object.insert_update_node_headimage 0x042fSame entry as KQ4D.
code.object.draw_update_list_tail_to_headimage 0x045eSame entry as KQ4D.
code.object.refresh_update_list_saved_posimage 0x0488Same entry as KQ4D.
code.object.frame_timer_updateimage 0x0563Uses the four-direction loop table for loop counts of four or more, unlike KQ4D’s later greater-than-four gate.
code.object.collision_testimage 0x4b47Relocation match for KQ4D 0x4b5d.
code.object.advance_frame_by_modeimage 0x4ce1Branch bodies match KQ4D; normalized mismatch is embedded jump-table data.
code.object.control_acceptanceimage 0x5ad3Relocation match for KQ4D 0x5ae2.
code.object.update_dirty_rectimage 0x5b7dRelocation match for KQ4D 0x5b8c.
code.object.placeimage 0x5d55Relocation match for KQ4D 0x5d64.
code.object.build_active_update_listimage 0x6e5fRelocation match for KQ4D 0x6e77.
code.object.build_inactive_partition_listimage 0x6e76Relocation match for KQ4D 0x6e8e.
code.object.flush_update_lists_restoreimage 0x6e8dRelocation match for KQ4D 0x6ea5.
code.object.rebuild_draw_update_listsimage 0x6ec7Relocation match for KQ4D 0x6edf.
code.object.refresh_update_listsimage 0x6ee4Relocation match for KQ4D 0x6efc.
code.object.clear_root_membershipimage 0x6f7dRelocation match for KQ4D 0x6f95.
code.object.set_root_membershipimage 0x6f9bRelocation match for KQ4D 0x6fb3.
code.motion.update_objectsimage 0x1751Exact proposed X zero enters the clamp/report-left-edge branch; KQ4D accepts zero without a report.
code.motion.pre_mode_and_boundary_updateimage 0x0644Relocation match for KQ4D 0x065b.
code.motion.dispatch_mode_stepimage 0x067aAccepts modes 1 through 4; branch bodies match KQ4D.
code.motion.rectangle_boundary_checkimage 0x06dbBranch bodies match KQ4D; normalized mismatch is embedded direction-table data.

KQ4D demo / AGI 3.002.102 Address Associations

These loaded-image offsets come from games/KQ4D/AGI. The generic table comparison reports preserve build-specific addresses while relating them to the same role labels used for SQ2 and GR.

LabelKQ4D addressNotes/evidence
code.room.switch_room_actionimage 0x1a1bReads the immediate operand and calls the ordinary room-switch helper directly; unlike GR it has no reserved-room remap call.
code.input.map_key_eventimage 0x5081Uses the shared key-map root and stops at 0x27 four-byte records, matching SQ2’s 39-entry capacity.
code.input.set_width_flag_actionimage 0x3cecAction 0xa3; stores one in KQ4D width word [0x0d58].
code.input.clear_width_flag_actionimage 0x3cfeAction 0xa4; clears KQ4D width word [0x0d58].
code.text.close_window_stateimage 0x21faRestores active window state, then clears both width word [0x0d58] and active-window word [0x0d66], matching SQ2’s two-state cleanup shape.
opcode.action.set_menu_interaction_gatetable slot 0xb1, image 0x9838Stores its immediate byte as a word in [0x05e3]; menu interaction at 0x9851 returns while zero.
opcode.action.clear_key_release_event_gatetable slot 0xb5, image 0x647fClears byte [0x05e5]; shared action 0xad at 0x6477 sets it to one.
code.save.save_game_stateimage 0x2a46Writes the five-block envelope, with first-block range DS:0x0002..0x05e5, and XORs block 3 before and after the write.
code.save.restore_game_stateimage 0x27f3Reads the same five block roles and XORs the restored block-3 range.
code.save.object_inventory_xor_rangeimage 0x07c3Same instruction skeleton as GR 0x07bc; repeats key bytes at data 0x090c across a caller-supplied range.
data.save.object_inventory_xor_key_090cdata 0x090cZero-terminated Avis Durgan key in KQ4D AGIDATA.OVL.
data.save.object_inventory_block_start_09b6data [0x09b6]KQ4D runtime inventory block pointer written after the decoded three-byte metadata header.
data.save.object_inventory_block_length_09badata [0x09ba]Decoded metadata file length minus three; written as block 3 length.
data.menu.interaction_gate_05e3data [0x05e3]KQ4D menu gate appended after the 2.936-shaped save block-1 state.
data.input.key_release_enqueue_gate_05e5data [0x05e5]KQ4D set/clear release gate and final byte of the 0x05e4-byte first save block.
code.view.load_resourceimage 0x3daaRelocation match for GR 0x3c5b.
code.object.bind_viewimage 0x3e9aRelocation match for GR 0x3d4b.
code.object.select_groupimage 0x3f6aRelocation match for GR 0x3e1b.
code.object.select_group_tableimage 0x3fceRelocation match for GR 0x3e7f.
code.object.select_frameimage 0x407eRelocation match for GR 0x3f2f.
code.view.discardimage 0x4280Relocation match for GR 0x4131.
code.picture.load_resourceimage 0x4e7fRelocation match for GR 0x4c96.
code.picture.prepareimage 0x4f13Relocation match for GR 0x4d2a.
code.picture.overlay_prepareimage 0x4f7fRelocation match for GR 0x4d96.
code.picture.discardimage 0x5012Relocation match for GR 0x4e29.
code.picture.decode_no_clearimage 0x6891Primary EGA path matches GR 0x67c2; KQ4D retains the older display-mode-2 refresh branch.
code.picture.command_scanimage 0x68c6Relocation match for GR 0x67ed.
code.picture.cmd_set_visual_draw_nibbleimage 0x68e5Relocation match for GR 0x680c.
code.picture.cmd_disable_visual_draw_nibbleimage 0x6906Relocation match for GR 0x682d.
code.picture.cmd_set_control_draw_nibbleimage 0x6918Relocation match for GR 0x683f.
code.picture.cmd_disable_control_draw_nibbleimage 0x693eRelocation match for GR 0x6865.
code.picture.cmd_pattern_plotimage 0x6950Relocation match for GR 0x6877.
code.picture.cmd_set_pattern_modeimage 0x6975Relocation match for GR 0x689c.
code.picture.cmd_draw_corner_path_x_firstimage 0x6a54Relocation match for GR 0x697b.
code.picture.cmd_draw_corner_path_y_firstimage 0x6a63Relocation match for GR 0x698a.
code.picture.cmd_draw_absolute_linesimage 0x6a97Relocation match for GR 0x69be.
code.picture.cmd_draw_relative_linesimage 0x6aafRelocation match for GR 0x69d6.
code.picture.cmd_seed_fillimage 0x6afcRelocation match for GR 0x6a23.
code.picture.read_coord_pairimage 0x6b09Relocation match for GR 0x6a30.
code.picture.draw_lineimage 0x6b32Relocation match for GR 0x6a59.
code.display.fill_buffer_wordimage 0x5673Primary EGA path matches GR 0x548a; KQ4D retains the older display-mode-2 refresh branch.
code.display.draw_horizontal_lineimage 0x568bRelocation match for GR 0x5498.
code.display.draw_vertical_lineimage 0x56c7Relocation match for GR 0x54d4.
code.display.pixel_writeimage 0x5715Relocation match for GR 0x5522.
code.picture.seed_fillimage 0x5757Relocation match for GR 0x5564.
code.display.full_refreshimage 0x5962Primary EGA path matches GR 0x576f; KQ4D retains the older display-mode-2 refresh branch.
code.object.build_update_list_sortedimage 0x0358Relocation match for GR 0x0351.
code.object.insert_update_node_headimage 0x042fRelocation match for GR 0x0428.
code.object.draw_update_list_tail_to_headimage 0x045eRelocation match for GR 0x0457.
code.object.refresh_update_list_saved_posimage 0x0488Relocation match for GR 0x0481.
code.object.frame_timer_updateimage 0x0563Relocation match for GR 0x055c.
code.object.collision_testimage 0x4b5dRelocation match for GR 0x4974.
code.object.advance_frame_by_modeimage 0x4cf7Branch bodies match GR 0x4b0e; the normalized difference is embedded jump-table data.
code.object.control_acceptanceimage 0x5ae2Relocation match for GR 0x58e5.
code.object.update_dirty_rectimage 0x5b8cRelocation match for GR 0x598f.
code.object.placeimage 0x5d64Relocation match for GR 0x5cb3.
code.object.build_active_update_listimage 0x6e77Relocation match for GR 0x6d9e.
code.object.build_inactive_partition_listimage 0x6e8eRelocation match for GR 0x6db5.
code.object.flush_update_lists_restoreimage 0x6ea5Relocation match for GR 0x6dcc.
code.object.rebuild_draw_update_listsimage 0x6edfRelocation match for GR 0x6e06.
code.object.refresh_update_listsimage 0x6efcRelocation match for GR 0x6e23.
code.object.clear_root_16ff_membershipimage 0x6f95Relocation match for GR 0x6ebc.
code.object.set_root_16ff_membershipimage 0x6fb3Relocation match for GR 0x6eda.
code.motion.update_objectsimage 0x1767Relocation match for GR 0x1720, including collision, control acceptance, placement, and edge reporting.
code.motion.pre_mode_and_boundary_updateimage 0x065bRelocation match for GR 0x0654.
code.motion.dispatch_mode_stepimage 0x0691Branch bodies match GR 0x068a; the normalized difference is embedded jump-table data.
code.motion.rectangle_boundary_checkimage 0x06f2Branch bodies and post-table state changes match GR 0x06eb; the normalized difference is embedded direction-table data.

KQ2 / 2.411 and LSL1 / 2.440 Address Associations

KQ2 addresses refer to build/cross-version/kq2_agi.decrypted.exe; LSL1 addresses refer to the complete MZ image in games/LSL1/LL.COM.

LabelKQ2 / LSL1 addressNotes/evidence
code.logic.action_dispatchimage 0x0291 / 0x0291Both accept actions through 0xa9.
table.logic.action_dispatchdata 0x061b / 0x061b170 four-byte records for 0x00..0xa9.
table.logic.condition_dispatchdata 0x08e3 / 0x08e3Nineteen common condition records.
code.system.confirm_restart_actionimage 0x241f / 0x2435KQ2 always prompts; LSL1 tests f16 before prompting.
code.text.configured_message_action_helperimage 0x1c43 / 0x1c59Reads row, column, and width after the wrapper consumes the message selector.
code.system.heap_diagnostic_actionimage 0x1474 / 0x148aFormats the early three-line diagnostic without the later rm.0, etc. line.
code.save.save_game_stateimage 0x2693 / 0x26b9Writes five blocks with first-block length 0x05df.
code.save.restore_game_stateimage 0x24af / 0x24d5Reads the same early block grammar.
code.resource.load_all_directoriesimage 0x41cf / 0x4201Normalized relocation match.
code.resource.read_volume_payload_onceimage 0x2d60 / 0x2d86Normalized relocation match for direct v2 records.
code.view.load_resourceimage 0x38f5 / 0x3927Normalized relocation match.
code.object.bind_viewimage 0x39e5 / 0x3a17Normalized relocation match.
code.object.select_groupimage 0x3ab5 / 0x3ae7Normalized relocation match.
code.object.select_frameimage 0x3bc9 / 0x3bfbNormalized relocation match.
code.picture.load_resourceimage 0x4905 / 0x4937Normalized relocation match.
code.picture.prepareimage 0x4999 / 0x49cbNormalized relocation match.
code.picture.overlay_prepareimage 0x4a05 / 0x4a37Normalized relocation match.
code.picture.decode_no_clearimage 0x61a3 / 0x61d5Normalized relocation match.
code.picture.command_scanimage 0x61d8 / 0x620aDispatches 0xf0..0xfa through data tables 0x1564 / 0x1552.
code.picture.cmd_set_pattern_modeimage 0x61f5 / 0x62b9KQ2 consumes and ignores the mode; LSL1 stores it.
code.picture.cmd_pattern_plotimage 0x625e / 0x6294KQ2 plots one pixel per pair; LSL1 implements shaped/stippled patterns.
code.picture.read_coord_pairimage 0x6320 / 0x644dNormalized relocation match.
code.picture.draw_lineimage 0x6351 / 0x6476Normalized relocation match.
code.picture.seed_fillimage 0x513d / 0x516fNormalized relocation match.
code.display.full_refreshimage 0x5348 / 0x537aNormalized relocation match.
code.object.frame_timer_updateimage 0x0530 / 0x0530Both apply the four-direction loop table only at exactly four loops.
code.object.advance_frame_by_modeimage 0x477d / 0x47afBranch bodies match; normalized difference is embedded jump-table data.
code.object.collision_testimage 0x45e3 / 0x4615Normalized relocation match.
code.object.control_acceptanceimage 0x549f / 0x54d1Normalized relocation match.
code.object.placeimage 0x5721 / 0x5753Normalized relocation match.
code.object.build_active_update_listimage 0x6696 / 0x67bbNormalized relocation match.
code.object.refresh_update_listsimage 0x671b / 0x6840Normalized relocation match.
code.motion.update_objectsimage 0x14b9 / 0x14cfNormalized relocation match.
code.motion.dispatch_mode_stepimage 0x0647 / 0x0647Both accept modes 1 through 3.
code.motion.rectangle_boundary_checkimage 0x06a6 / 0x06a6Same branch bodies and post-table state.
code.sound.driver_startimage 0x7bc9 / 0x7cecInitializes streams, countdowns, and active words without envelope state.
code.sound.driver_tickimage 0x7c2b / 0x7d4eShared event/countdown scheduler.
code.sound.driver_stop_coreimage 0x7cca / 0x7dedShared early silence/completion core.
code.sound.driver_write_eventimage 0x7ce9 / 0x7e0cKQ2 always writes the low tone byte; LSL1 conditionally suppresses it. Both emit direct event attenuation without envelopes.
code.sound.timer_irq_hookimage 0x809a / 0x81c3Calls the relocated early sound tick while playback is active.

KQ1 / AGI 2.917 Address Associations

These loaded-image offsets come from the KQ1-key-decoded image at build/cross-version/kq1_agi.decrypted.exe. The complete normalized role pass is recorded in the evidence notes; this table preserves its principal anchors and the one observable renderer/object delta.

LabelKQ1 addressNotes/evidence
code.logic.action_dispatchimage 0x02c4Accepts action bytes through 0xad; otherwise matches SQ2’s dispatcher skeleton.
table.logic.action_dispatchAGIDATA.OVL:0x061d174 four-byte records for 0x00..0xad.
table.logic.condition_dispatchAGIDATA.OVL:0x08f5Nineteen common condition records.
code.resource.load_all_directoriesimage 0x4305Normalized match for SQ2 0x4305.
code.resource.read_volume_payload_onceimage 0x2e56Normalized match for SQ2 0x2e56.
code.view.load_resourceimage 0x39f7Normalized match for SQ2 0x39f7.
code.object.bind_viewimage 0x3ae7Normalized match for SQ2 0x3ae7.
code.object.select_groupimage 0x3bb7Normalized match for SQ2 0x3bb7.
code.object.select_group_tableimage 0x3c1bNormalized match for SQ2 0x3c1b.
code.object.select_frameimage 0x3ccbNormalized match for SQ2 0x3ccb.
code.view.discardimage 0x3ecdNormalized match for SQ2 0x3ecd.
code.picture.load_resourceimage 0x4a3bNormalized match for SQ2 0x4a3b.
code.picture.prepareimage 0x4acfNormalized match for SQ2 0x4acf.
code.picture.overlay_prepareimage 0x4b3bNormalized match for SQ2 0x4b3b.
code.picture.discardimage 0x4bceNormalized match for SQ2 0x4bce.
code.picture.decode_no_clearimage 0x6379Relocation match for SQ2 0x6440.
code.picture.command_scanimage 0x63aeRelocation match for SQ2 0x6475; all command handlers share the same displacement band.
code.display.fill_buffer_wordimage 0x518fRelocation match for SQ2 0x5257.
code.display.pixel_writeimage 0x5231Relocation match for SQ2 0x52f9.
code.picture.seed_fillimage 0x5273Relocation match for SQ2 0x533b.
code.display.full_refreshimage 0x547eRelocation match for SQ2 0x5546.
code.object.frame_timer_updateimage 0x0563Differs from SQ2 only at the loop-count-4 branch: equality in 2.917 versus four-or-more in 2.936.
code.object.advance_frame_by_modeimage 0x48b3Normalized match for SQ2 0x48b3.
code.object.collision_testimage 0x4719Normalized match for SQ2 0x4719.
code.object.control_acceptanceimage 0x55f0Relocation match for SQ2 0x56b8.
code.object.update_dirty_rectimage 0x569aRelocation match for SQ2 0x5762.
code.object.placeimage 0x5872Relocation match for SQ2 0x593a.
code.object.build_active_update_listimage 0x695fRelocation match for SQ2 0x6a26; the remaining list helpers share this displacement band.
code.motion.update_objectsimage 0x150aNormalized match for SQ2 0x150a.
code.motion.pre_mode_and_boundary_updateimage 0x0644Normalized match for SQ2 0x0644.
code.motion.dispatch_mode_stepimage 0x067aNormalized match for SQ2 0x067a.
code.motion.rectangle_boundary_checkimage 0x06d9Normalized match for SQ2 0x06d9.
code.save.save_game_stateimage 0x2753Writes the common five-block envelope with first-block length 0x05e1.
code.save.restore_game_stateimage 0x2512Reads the same five block roles and rebuilds restored references.

Same-version SQ1.22, PQ1, and KQ3 Associations

SQ1.22/2.917 and PQ1/2.917 use the same loaded-image addresses as KQ1/2.917 for every mapped role above. Each loaded image differs only at three bytes in the expected-game signature literal. The SQ1.22 controller dynamically confirmed code.engine.main_cycle image 0x0150 with its repeated-cycle hook at 0x015b, code.input.edit_string image 0x0da9 with visible loop 0x0df2 and wait return 0x0df8, and code.text.display_string image 0x1ce8 with modal loop 0x1d1b and wait return 0x1d25. KQ3/2.936 likewise uses every existing SQ2/2.936 address; its loaded image differs from SQ2 at only two signature bytes. These exact same-address matches are stronger than relocation matches and require no new role labels.

Additional Build Associations

These associations preserve the new-build addresses without treating an address as part of the portable behavior.

LabelBuild associationNotes/evidence
table.logic.action_dispatchSQ1 2.089 data 0x03e7; XMAS.230 2.230 data 0x03e7; XMAS 2.272 data 0x0417Geometry yields 155, 155, and 161 action entries respectively.
table.logic.condition_dispatchSQ1 2.089 data 0x0679; XMAS.230 2.230 data 0x0673; XMAS 2.272 data 0x06bbNineteen condition entries in all three builds.
code.system.confirm_exit_actionSQ1/XMAS image 0x01e8SQ1 has no operand and exits unconditionally; XMAS consumes the later selector and confirmation branch.
code.system.confirm_exit_actionXMAS.230 image 0x01e8Same zero-operand unconditional exit as SQ1.
opcode.action.set_object_posSQ1 image 0x7141; XMAS.230 image 0x70fa; XMAS image 0x7196SQ1 erases drawn old state before snapshot update; both XMAS builds write current/snapshot coordinates directly.
opcode.action.set_object_pos_varSQ1 image 0x7199; XMAS.230 image 0x7137; XMAS image 0x71d3Variable-coordinate form of the same ordering difference.
code.view.select_loopXMAS.230 image 0x350dStores loop_header & 0x0f as cel count and applies packed loop orientation bits 0xc0.
code.view.mirror_loop_rowsXMAS.230 image 0x50afMirrors every cel row in the selected packed loop, iterating by the header low nibble.
opcode.action.get_object_resource_loop_countXMAS.230 image 0x36e2Action 0x31 masks the selected loop header with 0x0f before subtracting one.
code.menu.operand_advance_stubsXMAS image 0x8400..0x8404Actions 0x9c..0xa0 consume declared operands and otherwise return without menu state.
code.picture.decode_with_clearSQ1 image 0x5b84; XMAS.230 image 0x5b7f; XMAS image 0x5c0dEarly decoders clear state before entering relocated command scanners.
code.picture.command_scanSQ1 image 0x5baf; XMAS.230 image 0x5baa; XMAS image 0x5c38All dispatch only picture commands 0xf0..0xf8.
code.picture.read_coord_pairSQ1 image 0x5ce8; XMAS.230 image 0x5ce3; XMAS image 0x5d71Relocated guarded coordinate reader.
code.picture.draw_lineSQ1 image 0x5d19; XMAS.230 image 0x5d14; XMAS image 0x5da2Relocated line rasterizer.
code.picture.seed_fillSQ1 image 0x4ad4; XMAS.230 image 0x4a3a; XMAS image 0x4aa6Relocated four-connected fill path.
code.object.frame_timer_updateSQ1 image 0x05cc; XMAS.230 image 0x049a; XMAS image 0x04c6Automatic direction-loop selection has no cadence-countdown gate.
code.object.rebuild_draw_update_listsSQ1 image 0x0524; XMAS image 0x6151SQ1 draws the 0x0010-clear partition in object-table order and then selection-sorts the set partition; XMAS builds and selection-sorts both partitions before drawing them in the same partition order.
code.object.flush_update_lists_restoreSQ1 image 0x0515; XMAS image 0x6117Restores prior rectangles for both builds using their respective array/list representations before composition.
code.object.refresh_update_listsSQ1 image 0x0533; XMAS image 0x616eUpdates dirty regions and saved positions for both partitions after drawing.
code.object.flush_update_lists_restoreXMAS.230 image 0x6081Restores both drawing-key-sorted partitions; relocated XMAS 2.272 role.
code.object.rebuild_draw_update_listsXMAS.230 image 0x60bbBuilds and sorts both partitions.
code.object.refresh_update_listsXMAS.230 image 0x60d8Refreshes both partitions after composition.
code.motion.update_objectsSQ1 image 0x13c7; XMAS image 0x13b7The movement body beginning at SQ1 0x13d2 / XMAS 0x13bf matches after relocation; SQ1 additionally brackets it with its older array-based restore/rebuild helpers.
code.motion.update_objectsXMAS.230 image 0x1317Relocated XMAS 2.272 movement core.
opcode.action.show_picture_likeSQ1 image 0x43e7; XMAS image 0x43ccBoth refresh and mark the picture shown without the later f15 clear/text-window close prefix.
opcode.action.show_picture_likeXMAS.230 image 0x436eSame retained-flag/window behavior.
opcode.action.object_distance_to_varSQ1 image 0x4061; XMAS image 0x4043Both store the low byte of the active-object distance without the later saturation to 0xfe.
opcode.action.object_distance_to_varXMAS.230 image 0x3fe5Same low-byte wrapping behavior.
opcode.action.clear_object_fields_21_22SQ1 image 0x652e; XMAS.230 image 0x64e7; XMAS image 0x657dSQ1 and XMAS.230 clear direction only; XMAS clears direction and autonomous-motion mode. All apply the object-0 direction-coupling side effects.
opcode.action.clear_object_field_22_and_globalSQ1 image 0x6567; XMAS.230 image 0x6520; XMAS image 0x65baSQ1 and XMAS.230 leave autonomous-motion mode untouched and change only object-0 coupling/navigation globals; XMAS clears autonomous-motion mode for every selected object.
opcode.action.move_object_toSQ1 image 0x6358; XMAS image 0x63a7Stores target state but does not invoke the target-direction/completion helper added by 2.411.
opcode.action.move_object_to_varSQ1 image 0x63ce; XMAS image 0x641dVariable-target form of the same deferred first-update rule.
opcode.action.move_object_toXMAS.230 image 0x6311Relocated deferred-start target-motion action.
opcode.action.move_object_to_varXMAS.230 image 0x6387Variable-target form.
opcode.action.show_inventory_selectionSQ1 image 0x2e89; XMAS image 0x2e87Early acknowledgement-only carried-item display; it has no interaction-flag branch and does not write v25.
opcode.action.show_inventory_selectionXMAS.230 image 0x2dcfSame acknowledgement-only behavior.
opcode.condition.input_word_sequenceSQ1 image 0x0965; XMAS.230 image 0x0851; XMAS image 0x087dSQ1 is exact-count only; both XMAS builds recognize the 0x270f tail terminator.
opcode.action.parse_stringSQ1 image 0x1817; XMAS.230 image 0x1759; XMAS image 0x17f7All accept six string-slot selectors.
code.sound.driver_startSQ1 image 0x74f5; XMAS.230 image 0x7478; XMAS image 0x7514Early one-versus-four-channel initialization.
code.sound.driver_tickSQ1 image 0x7557; XMAS.230 image 0x74da; XMAS image 0x7576Relocated event/countdown scheduler without envelopes.
code.sound.driver_write_eventSQ1 image 0x7615; XMAS image 0x7634Both apply the device-2 +3 helper; SQ1 then emits directly, while XMAS applies whole-byte adjustment and signed clamp.
code.sound.driver_write_eventXMAS.230 image 0x7598Exact relocated match for the SQ1 direct-output rule.
code.save.save_game_stateSQ1 image 0x2501; XMAS image 0x24f5SQ1 writes four blocks; XMAS writes five.
code.save.restore_game_stateSQ1 image 0x2335; XMAS image 0x2315Reads each build’s corresponding envelope.
code.save.save_game_stateXMAS.230 image 0x2447Relocated XMAS 2.272 five-block writer.
code.save.restore_game_stateXMAS.230 image 0x2279Relocated XMAS 2.272 five-block reader.
code.inventory.initialize_metadata_and_objectsXMAS.230 image 0x0e50Reads the plain OBJECT header, increments its third byte, and allocates that many 0x2b-byte runtime records; relocated XMAS 2.272 role at image 0x0e7c.
data.save.early_block1SQ1/XMAS.230/XMAS DS:0x0002..0x03dcComplete 2.089/2.230/2.272 global-state partition; block-relative fields are specified in the persistence chapter.
data.motion.rectangleSQ1/XMAS DS:0x0133..0x0141Bounds, direction-coupling, prepared-picture, coupled-direction, and enable state used by corresponding script/runtime paths.
data.replay.capacity_countSQ1/XMAS DS:0x0145 / DS:0x0147Configured pair capacity and active pair count; block 4 serializes capacity pairs.
code.object.initialize_metadataMG image 0x0fa5Decodes current OBJECT, increments header byte 0x5a, and allocates 91 records.
code.save.save_game_stateMG image 0x2751Current source-derived blocks begin 0x05e1, 0x0f49, 0x0005; bundled older save differs.
table.logic.action_dispatchBC 2.439 data 0x061b; MG 2.915 data 0x061d; replacement MH1 3.002.102 data 0x0620; MH2 3.002.149 data 0x0440Counts are 170, 174, 182, and 182. The prior MH1 3.002.107 copy used the same data offset.
table.logic.condition_dispatchBC data 0x08e3; MG data 0x08f5; MH1 data 0x0942; MH2 data 0x0762Nineteen entries in each build.
code.room.switch_room_actionMH2 image 0x19d4Reads the immediate room operand and calls ordinary room switch directly.
code.room.remap_reserved_room_targetGR image 0x0062; absent from MH2Gold Rush build helper mapping 0x7e..0x80 to 0x49; not a universal 3.002.149 role.

Cross-Version Picture Brush Associations

These associations were found structurally from each interpreter’s picture scanner and the referenced brush-table signature. They supersede use of SQ2’s data offsets as universal constants.

Build grouptable.picture.command_dispatchdata.picture.pattern_bitsdata.picture.pattern_pointer_tablecode.picture.cmd_set_pattern_modecode.picture.cmd_pattern_plot
BC 2.4390x15520x15750x1595image 0x62b1image 0x628c
LSL1 2.4400x15520x15750x1595image 0x62b9image 0x6294
MG 2.9150x15cc0x15ef0x160fimage 0x6449image 0x6424
KQ1/SQ1.22/PQ1 2.9170x15cc0x15ef0x160fimage 0x645dimage 0x6438
SQ2/KQ3 2.9360x15d60x15f90x1619image 0x6524image 0x64ff
KQ4 3.002.0860x16460x16690x1689image 0x695dimage 0x6938
KQ4D/replacement MH1 3.002.102; prior MH1 3.002.1070x16580x167b0x169bimage 0x6975image 0x6950
GR/MH2 3.002.1490x140d0x14300x1450image 0x689cimage 0x6877

SQ1 2.089, XMAS.230 2.230, and XMAS 2.272 dispatch only through 0xf8, so the pattern labels do not apply. KQ2 2.411 dispatches 0xf9 at image 0x61f5 and 0xfa at 0x625e, but has no shaped-brush tables: the former consumes and ignores one byte and the latter plots coordinate pairs as ordinary pixels.