Crusader_Decomp/docs/usecode-format-specification.md
Marco 1225a3e737 Refactor and enhance documentation and tooling for Crusader USECODE
- Updated retail-debugger-entry-options.md to clarify the status of the debugger in No Remorse and No Regret, including findings from recent investigations.
- Revised usecode-format-specification.md to improve clarity on opcode behavior and historical naming conventions, with added references to Japanese executable analysis.
- Introduced usecode-jp-dispatch-analysis.md to document findings from the Japanese No Remorse executable, detailing opcode dispatch and search object behavior.
- Added ghidra_to_dosbox_memory.py, a new tool for translating Ghidra segment:offset addresses to DOSBox physical memory offsets, including comprehensive address validation.
- Created test_ghidra_to_dosbox_memory.py to ensure the correctness of address translation logic and selector base loading, with unit tests covering various scenarios.
2026-10-08 17:40:59 +02:00

65 KiB

Crusader USECODE Format and Runtime Specification

Status: Evidence-backed working specification
Scope: Crusader: No Remorse and Crusader: No Regret USECODE archives, class records, event dispatch, bytecode, and runtime services
Last consolidated: 2026-10-08

This document is the central format reference for Crusader USECODE in this repository. It combines local retail-binary observations with the ScummVM and Pentagram implementations. It is deliberately explicit about confidence: a shared name or parser convention is not treated as proof of retail behavior when the local binary evidence disagrees.

“Definitive” here means the current, auditable statement of what is known and what remains unsettled. It does not mean every opcode, intrinsic, or event has been semantically recovered. In particular, intrinsic numbers are game/build-specific, some opcode names conflict with observed parser behavior, and parts of class-event records remain unknown.

1. What USECODE is

USECODE is Crusader's object-oriented, event-driven bytecode system. A class has a set of numbered event slots. When the engine or another script dispatches an event, the runtime resolves the class and event slot to bytecode, constructs an interpreter/process context, and runs the event body. Scripts use VM operations for local/member/global data, arithmetic, branching, strings and lists, and process control. They access most game-world and presentation behavior through intrinsics: native functions supplied by the particular game executable.

The complete behavior of a USECODE program is therefore the combination of:

  1. the archive and class/event records;
  2. the bytecode and its VM semantics;
  3. the executable's event-dispatch rules and intrinsic table;
  4. the game data and current world/process state.

Bytecode alone does not define the semantics of an intrinsic ordinal. Remorse and Regret must not be assumed to share the same intrinsic numbering or signatures.

2. Evidence and terminology

Use these terms when reading this specification and related analysis:

  • Observed — directly checked in local Crusader data, bytecode, or executable/runtime evidence.
  • Cross-implementation — present in both ScummVM and Pentagram; strong evidence for intended format design, but not conclusive where it conflicts with local samples.
  • Name hint — a label supplied by a converter, disassembler, or inferred table. It helps navigation but is not itself proof of behavior.
  • Unresolved — competing interpretations or insufficient direct evidence. Preserve the raw value and do not silently choose one interpretation.
  • Intrinsic — a native executable routine called by bytecode, selected by a numeric ordinal.
  • Event — a class-local numbered callback. An event slot is not a globally unique function address.

The strongest local format evidence is the owner-loaded EUSECODE.FLX extractor and sampled class records. The detailed evidence and outstanding count/base disagreement are in usecode-roundtrip-ir.md. Tool implementation differences are compared in usecode-tooling-comparison.md.

3. Archive and class organization

3.1 EUSECODE.FLX

The locally validated FLEX directory interpretation is:

Field Current interpretation
Header area 0x80 bytes
Entry count Little-endian u32 at file offset 0x54
Entry directory Begins at 0x80
Directory row 8 bytes: little-endian u32 data_offset, then little-endian u32 declared_size
Object index Directory row index
Non-class objects Object 0 and object 1 are not class records in the observed layout; object 1 supplies names
Class object Object index class_id + 2
Class name A 13-byte slot in object 1 at 4 + 13 * class_id; name text ends at NUL or the slot boundary

These are structural interpretations of the Crusader file as used by the local extractor, not a claim that every FLEX file in other games has the same layout. The extractor validates table bounds and retains original records: extract_eusecode_flx.py.

3.2 Class record and event table

For owner-loaded Crusader class records sampled locally:

  • The class header is at least 20 bytes.
  • Bytes 8..11 contain a little-endian u32 used in deriving the event-table extent and code addressing.
  • A 6-byte-per-slot event table begins at class-relative offset +20.
  • Each row has the observed shape:
Row-relative bytes Interpretation
+0..+1 Unknown little-endian word; retain as raw data
+2..+5 Little-endian u32 event-code offset field
  • A zero code-offset field is treated by local tooling as an absent event.
  • Nonzero offsets are resolved to body windows using the class code-base anchor and the next greater nonzero event offset. The end of the final body is bounded by the class-record size.
  • Event names are not stored as authoritative semantic names in the row; the slot number is the stable identifier.

The exact meaning of the row's leading word has not been established. Do not discard or rewrite it when round-tripping data.

3.3 Event-count/base-offset disagreement

ScummVM and Pentagram both implement a Crusader class-base calculation that decrements the dword at bytes 8..11, and an event-count formula equivalent to (base_offset + 19) / 6. They resolve an event's offset from class + 20 + 6 * slot + 2.

That shared implementation is valuable evidence, but its event-count arithmetic does not fit the sampled owner-loaded records used by this repository. Locally observed dwords such as 0x00d4, 0x00da, and 0x00e6 yield clean event-table sizes when interpreted as the first code-byte offset: (raw_dword - 20) / 6 gives 32, 33, and 35 rows, respectively. The decremented value then acts as a code_base_minus_one anchor, and the event offsets behave as 1-based displacements from that anchor.

Current local rule: use bounds-checked event-table parsing derived from the raw owner-loaded class record; preserve both the raw bytes-8..11 dword and the derived anchor. Do not apply the shared ScummVM/Pentagram event-count formula blindly to these samples. The discrepancy and evidence are documented in usecode-roundtrip-ir.md.

Ghidra cross-check (Remorse): In the active CRUSADER.EXE, Usecode_ItemCallEvent (1420:0e3a) passes the class id and event ordinal into EntityVmContext::CreateFromSlotIndex (1420:0eec). The downstream EntityVmRuntime path materializes indexed owner/chunk records, including 6-byte runtime entries in EnsureSlotChunkLoaded (1420:19fd). This confirms class/event ordinal dispatch, but the inspected path consumes an already-indexed owner buffer and does not read the original EUSECODE.FLX bytes-8..11 field. It therefore does not decide between the competing archive event-count formulas; the local raw-record arithmetic remains the best fit for the sampled archives, and the formula disagreement remains open.

3.4 Event body and byte order

Integer operands in the observed Crusader bytecode are little-endian. The bytecode is a variable-length instruction stream; the opcode determines operand widths. Branch displacements are signed 16-bit relative offsets in the local decoders. Strings and body trailers require format-aware handling and must not be normalized through a lossy text conversion.

The rebuild interpreter model in this repository starts executing at body offset 14 (usecodeEventBytecodeOffset in usecode_vm.h). That is an implementation/runtime observation, not a substitute for parsing the event body framing. Analysis and round-trip tooling should preserve the complete body window, including prologue, debug metadata, and unknown trailing bytes.

4. Event slots

The event number is a class-local ordinal. The common event-name tables cover 0x00..0x1f, but local class records also contain higher ordinals. The census below covers the main local USECODE/EUSECODE.FLX and USECODE/REGRET/EUSECODE.FLX corpora, not the demo, Japanese, or 1.01 variants. A count is the number of non-empty derived class/slot body windows, not dynamic executions; 0 means no body was found in that corpus, not that the engine lacks a dispatch route.

For per-slot source labels, native callers, corpus coverage, class-local high-slot examples, and follow-up work, see the detailed USECODE event slot catalog.

Slot Common label Remorse bodies Regret bodies Current Crusader interpretation
00 look 1 0 Inspection/look callback.
01 use 66 80 Main object-use or activation callback.
02 anim 0 0 Native Item_Anim dispatch exists, but neither corpus has a body.
03 setActivity 0 0 Native NPC_SetActivity dispatch exists, but neither corpus has a body.
04 cachein 22 35 Object cache/load-in initialization callback.
05 hit 13 12 Outgoing hit/attack callback. Exact caller and parameter contract are class/runtime dependent.
06 gotHit 197 248 Incoming hit/damage reaction callback.
07 hatch 28 26 Spawn/appearance initialization callback.
08 schedule 0 0 Scheduled or periodic callback.
09 release 9 10 Release/cleanup callback.
0A equip 77 125 Ghidra confirms the native Item_Equip route; scripts reuse it for applying modes, arming, setup, and actor initialization, not only wearable equipment.
0B unequip 50 47 Ghidra confirms the native Item_Unequip route; scripts reuse it for disabling, disarming, or reversing state, not only removing wearable equipment.
0C combine 0 0 Ghidra confirms an Item_Combine engine route, but neither inspected archive has a non-empty slot-0C body.
0D func0D 0 0 Unknown. Preserve as an unnamed slot.
0E calledFromAnim 27 43 Callback lane called from animation behavior.
0F enterFastArea 108 107 Proximity/activation-region entry hook; local evidence supports trigger, spawner, and controller uses, not a movement-speed zone.
10 leaveFastArea 52 52 Proximity/activation-region exit hook.
11 cast 1 8 Ghidra confirms the native Item_Cast route; Crusader scripts use it for activation/dispatch, not a general spell system.
12 justMoved 0 0 Post-movement callback.
13 avatarStoleSomething 23 18 Player/avatar theft reaction hook.
14 animGetHit 0 0 Animation-specific hit-reaction callback.
15 unhatch 5 6 Ghidra has an Item_CallUnhatchEvent route; ScummVM's label is supported, while Pentagram's func15 is a placeholder.
16 func16 0 0 Unknown.
17 func17 0 0 Unknown.
18 func18 0 0 Unknown.
19 func19 0 0 Unknown.
1A func1A 0 0 Unknown.
1B func1B 0 0 Unknown.
1C func1C 0 0 Unknown.
1D func1D 0 0 Unknown.
1E func1E 0 0 Unknown.
1F func1F 0 0 Unknown.

In Ghidra's Remorse CRUSADER.EXE, Item_Equip, Item_Unequip, Item_Combine, Item_Cast, and Item_CallUnhatchEvent dispatch UC_Equip, UC_Unequip, UC_Combine, UC_Cast, and UC_Unhatch through Usecode_ItemCallEvent. Their event masks (0x400, 0x800, 0x1000, 0x20000, and 0x200000) confirm ordinals 0x0A, 0x0B, 0x0C, 0x11, and 0x15. This resolves Pentagram converter placeholders func0A, func0B, func11, and func15 for those event names; raw ordinals remain the stable identifiers.

Zero-body slots with native routes (Remorse): A zero census count means no callback body was found, not that the native engine lacks a caller. DList_AnimateShapes (1190:183d) calls Item_Anim (10a0:28e2) for animation type 5; Item_Anim passes UC_Anim with mask 0x4 to Usecode_ItemCallEvent. This animation-type branch only invokes the event and does not advance the frame itself, so with no slot-0x02 body the branch has no usecode animation behavior to run. NPC_SetActivity (10e8:2ba4) similarly offers UC_SetActivity with mask 0x8; if the dispatcher does not handle it, the function calls NPC_StartNextNPCActivityBehaviorProcess to start the ordinary activity behavior. Thus the empty slot-0x03 rows leave that built-in fallback in control.

The anim() and setActivity() names and ordinals are already present in Pentagram's and ScummVM's Ultima 8 event-name tables, and ScummVM's shared Item animation path also calls event 0x02. That supports anim as inherited event machinery retained by Crusader. For setActivity, the name is inherited, and the original Crusader executable demonstrably dispatches it, but the inspected Ultima 8 runtime sources do not show a corresponding event-0x03 producer; Pentagram's Actor::I_cSetActivity is a separate intrinsic, not that event. Whether the callback itself was live in the original Ultima 8 engine therefore remains unverified. Also, Pentagram's Item::callUsecodeEvent explicitly disables Crusader usecode events other than use; that is a limitation of that port and does not contradict the native Crusader call sites. Relevant source paths: misc/scummvm/engines/ultima/ultima8/world/item.cpp, misc/scummvm/engines/ultima/ultima8/convert/u8/convert_usecode_u8.h, misc/pentagram/world/Item.cpp, misc/pentagram/world/actors/Actor.cpp, and misc/pentagram/convert/u8/ConvertUsecodeU8.h.

Outside the common table, the extracted Remorse corpus has non-empty body windows at every slot 0x20..0x4B (44 ordinals), and Regret at every slot 0x20..0x51 (50 ordinals). These higher slots remain unnamed and class-specific; do not infer a common semantic label from the ordinal alone.

Event dispatch forms

The observed bytecode includes class/event calls (0x11) and spawned class/event processes (0x57, 0x58). The target is a class id plus event ordinal; the VM resolves the ordinal through that class's event table. Thus the same event ordinal can mean different behavior in different classes, and a decompiler's label does not prove the target row is present.

The opcode called FAR_ROUTINE_CALL in the historical opcode-name list is decoded locally as this class/event dispatch. In Crusader, this is an event-number-based dispatch, not a call using a raw bytecode address.

5. Bytecode instruction set

The historical-name column is copied from the Japanese No Remorse disassembly corpus. The current-behavior column combines local decoder interpretations with verified native executable behavior. This is the broadest recovered opcode vocabulary currently in this workspace, not a claim that every named token is executable or fully understood in every build.

Legend:

  • Decoded locally means the map-viewer/research parser recognizes the opcode and its current operand shape.
  • Name only / unresolved means an opcode name exists in the historical table, but local decoding or semantics are absent, conflicting, or incomplete.
  • The word “stack” below refers to the VM evaluation/temporary data model; exact ownership/lifetime rules for managed strings and list variants are not fully specified here.

Detailed Japanese-executable dispatch evidence, search-selector internals, and open interpretation questions are recorded in the JP dispatch and search analysis.

Opcode Historical name Current behavior / status
00 ASSIGN_LOCAL_CHAR Pop/store byte-sized value to a BP-relative local. Decoded locally as pop_local_byte.
01 ASSIGN_LOCAL_INT Pop/store word-sized value to a BP-relative local.
02 ASSIGN_LOCAL_LONG Pop/store dword-sized value to a BP-relative local.
03 ASSIGN_LOCAL_HUGE Pop/store an opaque-sized value to a BP-relative local; size is an operand.
04 ASSIGN_MEMBER_CHAR Pop/store byte-sized value to a BP-relative member slot.
05 ASSIGN_MEMBER_INT Pop/store word-sized value to a BP-relative member slot.
06 ASSIGN_MEMBER_LONG Pop/store dword-sized value to a BP-relative member slot.
07 ASSIGN_MEMBER_HUGE Pop/store an opaque-sized value to a BP-relative member slot; size is an operand.
08 ASSIGN_RESULT Assign/pop the current result value.
09 ASSIGN_ELEMENT Assign a list/aggregate element; operands include local offset, element size, and list-kind flag.
0A CHAR_CONSTANT Push byte immediate.
0B INT_CONSTANT Push little-endian 16-bit immediate.
0C LONG_CONSTANT Push little-endian 32-bit immediate.
0D STRING_CONSTANT Push length-prefixed/NUL-terminated string data; exact encoded-length convention should be preserved from raw bytes.
0E LIST_CONST Construct a list from element-size and count operands.
0F C_ROUTINE_CALL Call intrinsic/native routine. Operand shape locally: argument-byte count (u8), intrinsic ordinal (u16).
10 NEAR_ROUTINE_CALL Call near routine at a u16 body-relative offset. Full use and return convention not fully recovered.
11 FAR_ROUTINE_CALL In Crusader, locally decoded as class id (u16) plus event slot (u16); performs class/event dispatch.
12 TEMP_POP_INT Pop/store word result in VM temporary.
13 TEMP_POP_LONG Pop/store dword result in VM temporary.
14 ADD_INT Word/integer addition.
15 ADD_LONG Dword/long addition.
16 ADD_STRING String concatenation.
17 ADD_LIST List concatenation/append operation.
18 EXCLUSIVE_ADD_LIST Add list element(s) with uniqueness semantics; element size is an operand.
19 EXCLUSIVE_ADD_STRING_LIST String-list variant of unique append.
1A SUB_STRING_LIST Remove matching string/list element(s); element size is an operand.
1B SUB_LIST Remove matching list element(s); element size is an operand.
1C SUBTRACT_INT Word/integer subtraction.
1D SUBTRACT_LONG Dword/long subtraction.
1E MULTIPLY_INT Word/integer multiplication.
1F MULTIPLY_LONG Dword/long multiplication.
20 DIVIDE_INT Word/integer division.
21 DIVIDE_LONG Dword/long division.
22 MODULO_INT Word/integer modulo.
23 MODULO_LONG Dword/long modulo.
24 EQUALS_INT Word/integer equality comparison.
25 EQUALS_LONG Dword/long equality comparison.
26 EQUALS_STRING String equality comparison.
27 EQUALS_HUGE Opaque/aggregate equality comparison; representation is not fully documented.
28 LT_INT Integer less-than comparison.
29 LT_LONG Dword less-than comparison.
2A LE_INT Integer less-than-or-equal comparison.
2B LE_LONG Dword less-than-or-equal comparison.
2C GT_INT Integer greater-than comparison.
2D GT_LONG Dword greater-than comparison.
2E GE_INT Integer greater-than-or-equal comparison.
2F GE_LONG Dword greater-than-or-equal comparison.
30 NOT_INT Integer logical NOT.
31 NOT_LONG Dword logical NOT.
32 AND_INT Integer logical AND.
33 AND_LONG Dword logical AND.
34 OR_INT Integer logical OR.
35 OR_LONG Dword logical OR.
36 NE_INT Integer not-equal comparison.
37 NE_LONG Dword not-equal comparison.
38 IN_LIST Test list membership; local decoder reads element-size and list-kind operands.
39 BIT_AND_INT Bitwise AND.
3A BIT_OR_INT Bitwise OR.
3B BIT_NOT_INT Bitwise NOT.
3C SHIFT_LEFT Left shift.
3D SHIFT_RIGHT Right shift.
3E BYTE_LOCAL_REFERENCE Push byte-sized BP-relative local.
3F INT_LOCAL_REFERENCE Push word-sized BP-relative local.
40 LONG_LOCAL_REFERENCE Push dword-sized BP-relative local.
41 STRING_LOCAL_REFERENCE Push local string reference.
42 LIST_LOCAL_REFERENCE Push local list reference; element size is an operand.
43 S_L_LOCAL_REFERENCE Push local special/string-list reference.
44 LIST_ELEMENT_REF Push list element; local decoder reads element-size and list-kind operands.
45 HUGE_LOCAL_REFERENCE Push opaque/aggregate local; two operand bytes are retained.
46 BYTE_MEMBER_REFERENCE Push byte-sized BP-relative member.
47 INT_MEMBER_REFERENCE Push word-sized BP-relative member.
48 LONG_MEMBER_REFERENCE Push dword-sized BP-relative member.
49 HUGE_MEMBER_REFERENCE Push opaque/aggregate BP-relative member.
4A THIS_REFERENCE Current “this” reference. Not fully modeled by the local decoder.
4B ADDRESS_OF Push address of a BP-relative local.
4C INDIRECT_REFERENCE Dereference pointer/reference for the specified byte size.
4D INDIRECT_ASSIGN Store indirectly through a pointer/reference for the specified byte size.
4E GLOBAL_DATA_REFERENCE Push global value by global id and size.
4F GLOBAL_DATA_ASSIGN Store global value by global id and size.
50 RETURN Return from current routine/event.
51 IF Conditional branch; local decoder represents it as jne with signed relative displacement.
52 JUMP Unconditional relative branch.
53 SUSPEND Yield/suspend the current process.
54 IMPLIES Native handler exists; operand and runtime semantics remain unresolved.
55 AND_IMPLIES JP No Remorse pushes word 0x0402; the historical mnemonic is unverified.
56 OR_IMPLIES JP No Remorse pushes word 0x0404; the historical mnemonic is unverified.
57 SPAWN Spawn a class/event process; operands include argument bytes, this size, class id, and slot.
58 SPAWN_INLINE Spawn a class/event process using inline argument data; exact use of all operands remains partly unresolved.
59 THIS_PID Push/current-process identifier.
5A INIT_ROUTINE Routine setup; local decoder reads local-byte count.
5B LINE_NUMBER Consume a 16-bit line-metadata operand.
5C SYMBOL_INFO Consume a two-byte offset and nine-byte symbol record; may emit the name.
5D PUSH_RETURN_BYTE Push byte-sized return value.
5E PUSH_RETURN_INT Push word-sized return value.
5F PUSH_RETURN_LONG Push dword-sized return value.
60 INT_TO_LONG Convert word to dword.
61 LONG_TO_INT Convert dword to word.
62 LOCAL_STRING_DELETE Release/delete BP-relative local string.
63 LOCAL_STRING_LIST_DELETE Release/delete BP-relative local string-list.
64 LOCAL_LIST_DELETE Release/delete BP-relative local list.
65 STRING_REL_DELETE Release stack-relative string; local decoder reads an SP-relative displacement.
66 LIST_REL_DELETE Release stack-relative list.
67 STRING_LIST_REL_DELETE Release stack-relative string-list.
68 COPY_STRING Copy/duplicate string value.
69 STRING_ADDRESS Push address/reference for a BP-relative string.
6A CVT_POINTER_TO_STRING Convert pointer/reference to string.
6B CVT_STRING_TO_POINTER Convert string to pointer/reference.
6C PARAM_PID_CHANGE Change a process parameter; local operands include BP-relative location and copy-type byte.
6D RESULT Push process/routine result.
6E MOVE_SP Adjust stack pointer by an operand byte.
6F REL_ADDRESS_OF Push stack-relative address/reference.
70 SEARCH Create a typed search object from a result variable, predicate bytes, and selector type (2..6). Types 2/3 scan map cells, 4/5 traverse item links, and 6 searches within shape-footprint bounds.
71 SEARCH_RECURSIVE Unsupported in the inspected Japanese executable; dispatches to the invalid-token path.
72 SEARCH_SURFACE Unsupported in the inspected Japanese executable; dispatches to the invalid-token path.
73 SEARCH_NEXT Advance the active search and store its current candidate in the selector's loop variable.
74 REAL_CHAR_CONSTANT Push the following byte onto the evaluation stack; used in selector expressions.
75 FOREACH Iterate a list; local decoder reads BP-relative variable, element size, and relative branch.
76 FOREACH_STRING Iterate a string-list variant; same broad local operand shape as 0x75.
77 SET_PROCESS Local decoder identifies this as set_info, a process/world notification operation. Exact native-side contract is engine-specific.
78 PROCESS_EXCLUDE Exclude current process from a subsequent process operation/selection; exact lifecycle effects depend on runtime.
79 GLOBAL_ADDRESS_OF Push address/reference of global id.
7A END Event/body framing terminator in local parsing; not an executable opcode in the inspected Japanese interpreter.
7B REGRESS Historical name only; outside the inspected Japanese interpreter's dispatch range.

Decoder coverage is not VM coverage

The table records the combined opcode vocabulary, not a claim that every byte is executable in every Crusader version. Current parsers stop and preserve unknown/unsupported instruction bytes rather than guessing their lengths. The local C++ interpreter is explicitly partial; its enum/results and handlers should not be mistaken for a complete retail VM implementation.

Opcode names and local parser labels do not always match native behavior. Detailed executable comparisons and unresolved mappings are kept in the JP dispatch and search analysis.

Until direct runtime/disassembly evidence reconciles these, raw opcodes and operands are authoritative. Do not rewrite or compile these operations based only on a mnemonic.

6. Intrinsics and native capabilities

6.1 Call contract

Opcode 0x0F calls an intrinsic by ordinal. The local decoder reads:

u8  argument_byte_count
u16 intrinsic_ordinal

The argument-byte count is important evidence for call-site shape, but does not by itself recover parameter types, ownership, or return type. Intrinsic names/signatures shown by tools are metadata hints. The native implementation selected by the running executable is authoritative.

6.2 Variant-specific tables

Remorse and Regret have separate intrinsic tables. Do not copy a Regret ordinal name/signature into Remorse or vice versa without matching evidence. Development builds/versions may also differ. ScummVM's source separates the runtime tables (remorse_intrinsics.h, regret_intrinsics.h) from converter naming/signature hints (convert_usecode_crusader.h, convert_usecode_regret.h). Pentagram also has a Remorse runtime table, but local notes identify it as sparse/older.

Current related artifacts:

The hint tables and converter names are useful for navigation, but they are not a complete substitute for validating the live executable's dispatch table and a representative call site. An intrinsic id with no current name hint remains a valid raw call, not necessarily an invalid opcode. The hint tables and converter names are useful for navigation, but they are not a complete substitute for validating the live executable's dispatch table and a representative call site. An intrinsic id with no current name hint remains a valid raw call, not necessarily an invalid opcode.

Corpus census

The raw 0x0F call operands were counted from all non-empty derived event-body windows using the local parser and the variant-specific Remorse/Regret hint sets. The scan parsed 977 Remorse bodies and 1,152 Regret bodies with zero parser exceptions.

Variant Non-empty bodies parsed 0x0F call sites Distinct ordinals present
Remorse 977 8,389 310
Regret 1,152 10,625 349
Intrinsic ordinal interval Remorse bytecode Regret bytecode
0x0000..0x0135 Used; all 310 ordinals observed Used; all 310 ordinals observed
0x0136..0x015C Not observed Used; all 39 ordinals observed

Here, used means the raw ordinal occurs in a decoded intrinsic-call instruction; it does not assert runtime reachability or execution frequency. Ghidra's Remorse Item_Equip annotation identifies intrinsic ordinals 0x006/0x0B5, and its Item_Cast annotation identifies 0x0E8; their decompilations dispatch UC_Equip and UC_Cast, agreeing with ScummVM's Remorse runtime table. The local Remorse corpus also calls 0x134 and 0x135, beyond Pentagram's 308-entry RemorseIntrinsics array configured in GUIApp.cpp. Treat that older sparse table's omissions as incomplete coverage, not proof that those calls are absent. Pentagram's converter intrinsic names are explicitly for Regret 1.21 and must not be used as Remorse mappings. Keep the raw ordinal authoritative and the selected variant's engine table as a naming hint; this Ghidra pass does not validate every intrinsic's semantics or Regret's native dispatch table.

Corpus ordinal name hints

The inventory below lists each ordinal observed in either main corpus, using the ScummVM Remorse and Regret converter-name arrays linked above. Parenthesized argument lists are omitted for compactness. These are name hints, not verified native signatures or semantics; repeated labels at different ordinals remain distinct entries. not scanned means the ordinal is outside the Remorse corpus range counted above, not that Remorse's runtime rejects it.

Ordinal Remorse name hint Regret name hint
0x0000 byte World::I_getAlertActive World::I_getAlertActive
0x0001 int16 Item::I_getFrame Item::getFrame
0x0002 void Item::I_setFrame Item::setFrame
0x0003 int16 Item::I_getMapArray Item::getMapNum
0x0004 int16 Item::I_getStatus Item::getStatus
0x0005 void Item::I_orStatus Item::orStatus
0x0006 int16 Item::I_equip Item::equip
0x0007 byte Item::I_isOnScreen Item::isEntirelyOnScreen
0x0008 byte Actor::I_isNPC Item::isNpc
0x0009 byte Item::I_getZ Item::getZ
0x000A void Item::I_destroy World::I_gameDifficulty
0x000B int16 Actor::I_GetNPCDataField0x63_00B Item::getQLo
0x000C void Ultima8Engine::I_setAvatarInStasis Item::destroy
0x000D byte Item::I_getDirToItem Actor::I_getUnkByte
0x000E int16 Actor::I_turnToward Item::getX
0x000F void I_playFlic Item::getY
0x0010 int16 Item::I_getQLo Item::playSfxCru
0x0011 int16 Actor::I_getMap Item::getShape
0x0012 void MusicProcess:I_playMusic Item::I_explode
0x0013 int16 Item::I_getX UCMachine::I_rndRange
0x0014 int16 Item::I_getY Item::legalCreateAtCoords
0x0015 void AudioProcess::I_playSFXCru Item::andStatus
0x0016 int16 Item::I_getShape World::I_getControlledNPCNum
0x0017 void Item::I_explode Actor::I_getDir
0x0018 int16 UCMachine::I_rndRange Actor::I_getLastAnimSet
0x0019 byte Item::I_legalCreateAtCoords Item::I_fireWeapon
0x001A void Item::I_andStatus Item::create
0x001B int16 World::I_getControlledNPCNum Item::popToCoords
0x001C byte Actor::I_getDir Actor::I_setDead
0x001D int16 Actor::I_getLastAnimSet Item::push
0x001E int16 Item::I_fireWeapon Item::I_getEtherealTop
0x001F byte Item::I_create Item::getQLo
0x0020 void Item::I_popToCoords Item::setQLo
0x0021 void Actor::I_setDead Item::getQHi
0x0022 void Item::I_push Item::setQHi
0x0023 int16 Item::I_getEtherealTop Item::I_getClosestDirectionInRange
0x0024 void Item::I_setShape Item::hurl
0x0025 void Item::I_touch Item::getCY
0x0026 int16 Item::I_getQHi Item::getCX
0x0027 int16 I_getClosestDirectionInRange SpriteProcess::I_createSprite
0x0028 int16 Item::I_hurl Item::setNpcNum
0x0029 int16 World::I_gameDifficulty AudioProcess::I_playSFXCru
0x002A void AudioProcess::I_playAmbientSFXCru Item::setShape
0x002B int16 Item::I_getQLo Item::pop
0x002C byte Item::I_inFastArea AudioProcess::I_stopSFXCru
0x002D void Item::I_setQHi Item::isCompletelyOn
0x002E byte Item::I_legalMoveToPoint Item::popToContainer
0x002F byte CurrentMap::I_canExistAtPoint Actor::I_getHp
0x0030 void Item::I_pop Actor::I_getMana
0x0031 void Item::I_andStatus Item::getFamily
0x0032 void Item::I_receiveHit Actor::destroyContents
0x0033 byte Actor::I_isBusy AudioProcess::I_setVolumeForItemSFX
0x0034 int16 Item::I_getDirFromTo16 Item::getDirToItem
0x0035 byte Actor::I_isKneeling AudioProcess::I_isSfxPlayingForObject
0x0036 int16 Actor::I_doAnim Item::I_getRangeIfVisible
0x0037 byte MainActor::I_addItemCru AudioProcess::I_playSFXCru
0x0038 void AudioProcess::I_stopSFXCru Item::andStatus
0x0039 byte Actor::I_isDead Kernel::resetRef
0x003A byte AudioProcess::I_isSFXPlayingForObject Item::touch
0x003B void Item::I_setQLo Egg::getEggId
0x003C int16 Item::I_getItemFamily MainActor::I_addItemCru
0x003D void Container::I_destroyContents Actor::I_getMap
0x003E void Item::I_fallProbably_03E Item::callEvent11
0x003F int16 Egg::I_getEggId CameraProcess::I_somethingAboutCameraUpdate
0x0040 void CameraProcess::I_moveTo AudioProcess::I_stopSFXCru
0x0041 void CameraProcess::I_setCenterOn Item::isOn
0x0042 byte Item::I_getRangeIfVisible Item::getQHi
0x0043 void AudioProcess::I_playSFXCru Item::isOn
0x0044 byte Item::I_IsOn Item::getQHi
0x0045 int16 Item::I_getQHi Item::isOn
0x0046 byte Item::I_IsOn Item::getQHi
0x0047 int16 Item::I_getQHi Item::isOn
0x0048 byte Item::I_IsOn Item::getQHi
0x0049 int16 Item::I_getQHi Item::isOn
0x004A byte Item::I_IsOn Item::getQHi
0x004B int16 Item::I_getQHi Item::isOn
0x004C byte Item::I_IsOn Item::getQHi
0x004D int16 Item::I_getQHi Actor::I_getCurrentActivityNo
0x004E byte Item::I_IsOn Actor::isDead
0x004F int16 Item::I_getQHi Actor::I_clrInCombat
0x0050 int16 Actor::I_getCurrentActivityNo Actor::I_setDefaultActivity0
0x0051 void Actor::I_clrInCombat Actor::I_setDefaultActivity1
0x0052 void Actor::I_setDefaultActivity0 Actor::I_setDefaultActivity2
0x0053 void Actor::I_setDefaultActivity1 Actor::I_setActivity
0x0054 void Actor::I_setDefaultActivity2 World::I_setControlledNPCNum
0x0055 void Actor::I_setActivity Item::I_receiveHit
0x0056 void World::I_setControlledNPCNum Game::I_isReleaseBuild
0x0057 int16 Item::I_getSurfaceWeight MainActor::I_setMana
0x0058 byte Item::I_isCentreOn Item::use
0x0059 void Item::I_setFrame Item::setUnkEggType
0x005A int16 Actor::I_getLastAnimSet MusicProcess::I_playMusic
0x005B byte Item::I_legalCreateAtPoint Item::getSurfaceWeight
0x005C void Item::I_getPoint Item::I_isCentreOn
0x005D void StatusGump::I_hideStatusGump Item::setFrame
0x005E int16 MovieGump::I_playMovieOverlay Actor::I_getLastAnimSet
0x005F void StatusGump::I_showStatusGump Ultima8Engine::I_setAvatarInStasis
0x0060 void Actor::I_setDead Actor::I_isBusy
0x0061 void Actor::I_create Actor::I_getField0x13Flag2
0x0062 void CameraProcess::I_somethingAboutCameraUpdate Actor::I_doAnim
0x0063 void Actor::I_teleport Item::legalCreateAtPoint
0x0064 void Item::I_getFootpad Item::getPoint
0x0065 byte Item::I_isInNPC Item::legalMoveToPoint
0x0066 int16 Item::I_getQLo Item::fall
0x0067 int16 Item::I_getNPCNum Item::hurl
0x0068 void Item::I_setNpcNum Kernel::getNumProcesses
0x0069 void Item::I_andStatus Item::getCY
0x006A void Item::I_move U8Engine::I_isCfgAnimationOff
0x006B int16 Game::I_isViolenceEnabled ResetKeyboardState
0x006C void Kernel::I_resetRef MusicProcess::I_pauseMusic
0x006D int16 Item::I_getNPCNum MovieGump::I_playMovieCutsceneRegret
0x006E void Item::I_andStatus MusicProcess::I_unpauseMusic
0x006F byte Item::I_isCompletelyOn Item::isInNpc
0x0070 byte Ultima8Engine::I_getCrusaderTeleporting Ultima8Engine::I_setCruStasis
0x0071 void Ultima8Engine::I_setCrusaderTeleporting Ultima8Engine::I_clrCruStasis
0x0072 void Ultima8Engine::I_setCruStasis PaletteFaderProcess::I_jumpToColor
0x0073 void Actor::I_setDead PaletteFaderProcess::I_fadeToGamePal
0x0074 void Ultima8Engine::I_clrCrusaderTeleporting Actor::isDead
0x0075 void Ultima8Engine::I_clrCruStasis Item::getNpcNum
0x0076 void AudioProcess::I_stopSFX IntrinsicReturn0
0x0077 int16 PaletteFaderProcess::I_fadeToBlack Game::I_isViolenceEnabled
0x0078 void MainActor::I_clrKeycards Item::unequip
0x0079 int16 MainActor::I_teleportToEgg Item::andStatus
0x007A int16 PaletteFaderProcess::I_fadeToGamePal Item::move
0x007B void Actor::I_clrImmortal Ultima8Engine::I_getCrusaderTeleporting
0x007C int16 Actor::I_getHp Ultima8Engine::I_setCrusaderTeleporting
0x007D void Actor::I_setActivity Ultima8Engine::I_clrCrusaderTeleporting
0x007E int16 Item::I_getQuality Actor::I_turnToward
0x007F void Item::I_setQuality PaletteFaderProcess::I_fadeToBlack
0x0080 int16 Item::I_use MainActor::I_clrKeycards
0x0081 int16 MainActor::I_getMaxEnergy MusicProcess::I_stopMusic
0x0082 int16 Actor::I_getMana PaletteFaderProcess::I_jumpToAllBlack
0x0083 void Actor::I_setMana I_setUnkFlagA4
0x0084 int16 Item::I_getQLo I_clearUnkFlagA4
0x0085 void Actor::I_setImmortal MainActor::I_switchMap
0x0086 int16 CameraProcess::I_getCameraX teleportToEgg
0x0087 int16 CameraProcess::I_getCameraY PaletteFaderProcess::I_fadeToGamePal
0x0088 void Item::I_setMapArray Actor::I_clrImmortal
0x0089 int16 Item::I_getNpcNum Actor::I_setActivity
0x008A void Item::I_shoot Item::getQuality
0x008B int16 Item::I_enterFastArea Item::setQuality
0x008C void Item::I_setIsBroken MainActor::I_getMaxEnergy
0x008D int16 Item::I_hurl CameraProcess::I_moveTo
0x008E int16 Item::I_getNPCNum Actor::I_setImmortal
0x008F void PaletteFaderProcess::I_jumpToAllBlack Camera::getX
0x0090 void MusicProcess::I_stopMusic Camera::getY
0x0091 void I_setSomeMovieGlobal Item::setMapNum
0x0092 void I_playMovieCutsceneFullscreen Item::getNpcNum
0x0093 void I_clearSomeMovieGlobal Item::shoot
0x0094 void Game::I_playCredits CameraProcess::I_setCenterOn
0x0095 byte Kernel::I_getCurrentKeyDown Item::enterFastArea
0x0096 int16 MainActor::I_teleportToEgg Item::setBroken
0x0097 void PaletteFaderProcess:I_jumpToGreyScale Item::hurl
0x0098 void I_resetVargasShieldTo500 Item::getNpcNum
0x0099 void Item::I_andStatus Ultima8Engine::I_moveKeyDownRecently
0x009A void PaletteFaderProcess::I_jumpToNormalPalette teleportToEgg
0x009B int16 PaletteFaderProcess::I_fadeToGamePal Actor::I_createActor
0x009C int16 PaletteFaderProcess::I_fadeToGamePalWithParam Actor::I_clrInCombat
0x009D int16 PaletteFaderProcess::I_fadeToBlack PaletteFaderProcess::I_jumpToGreyScale
0x009E int16 PaletteFaderProcess::I_fadeToBlackWithParam PaletteFaderProcess::I_jumpToNormalPalette
0x009F int16 PaletteFaderProcess::I_fadeToColor CruStatusGump::I_showStatusGump
0x00A0 void Actor::I_setDead Item::andStatus
0x00A1 int16 Item::I_getQLo Item::getUnkEggType
0x00A2 int16 Item::I_getUnkEggType Egg::setEggXRange
0x00A3 void Egg::I_setEggXRange Item::setFrame
0x00A4 byte Item::I_overlaps Item::overlaps
0x00A5 byte Item::I_isOn Item::isOn
0x00A6 int16 I_getAnimationsEnabled Item::getQHi
0x00A7 int16 Egg::I_getEggXRange Actor::I_getLastAnimSet
0x00A8 void Actor::I_setDead Item::getCY
0x00A9 void I_playMovieCutsceneFullscreen CurrentMap::I_canExistAt
0x00AA void AudioProcess::I_playSFX Item::isOn
0x00AB byte Actor::I_isFalling Actor::isDead
0x00AC int16 Item::I_getFamilyOfType Item::hurl
0x00AD int16 Item::I_getNPCNum Item::I_inFastArea
0x00AE int16 Item::I_getQLo Item::getQHi
0x00AF int16 Item::I_getQHi Item::andStatus
0x00B0 int16 Item::I_unequip Item::hurl
0x00B1 int16 Item::I_spawnUsecodeEvent0x13 Item::andStatus
0x00B2 void Item::I_andStatus Item::hurl
0x00B3 int32 I_getCurrentTimerTick Item::andStatus
0x00B4 void Ultima8Engine::I_setAlertActive Item::getDirToCoords
0x00B5 int16 Item::I_equip MainActor::I_removeItem
0x00B6 void Ultima8Engine::I_clrAlertActive I_updateInventoryUI
0x00B7 int16 Ultima8Engine::I_getAvatarInStasis Item::getNpcNum
0x00B8 byte MainActor::I_addItemCru Item::getCY
0x00B9 int16 Actor::I_getLastAnimSet Item::isOn
0x00BA void Item::I_setQuality Item::getFootpad
0x00BB byte CurrentMap::I_canExistAt Actor::isDead
0x00BC byte Item::I_isOn Actor::I_createActorCru
0x00BD int16 Item::I_hurl Actor::I_setActivity
0x00BE int16 Item::I_getQHi KeypadGump::I_showKeypad
0x00BF void Item::I_andStatus Item::andStatus
0x00C0 int16 Item::I_hurl ComputerGump::I_readComputer
0x00C1 void Item::I_andStatus UCMachine::I_numToStr
0x00C2 int16 Item::I_hurl IntrinsicReturn0
0x00C3 void Item::I_andStatus Actor::I_getDir
0x00C4 int16 KeypadGump::I_showKeypad Item::getQHi
0x00C5 byte Item::I_isOn Item::setQuality
0x00C6 void SpriteProcess::I_createSprite Item::hurl
0x00C7 byte Item::I_getDirFromItem Actor::I_addHp
0x00C8 int16 Item::I_hurl CruHealerProcess::I_create
0x00C9 int16 Item::I_getQHi Item::callEvent0A
0x00CA byte Actor::I_addHp Item::setBroken
0x00CB void MainActor::I_switchMap Item::isOn
0x00CC byte Actor::I_getInCombat Actor::I_teleport
0x00CD void Actor::I_setActivity Item::I_getDirFromTo16
0x00CE int16 Game::I_isReleaseBuild Item::getQHi
0x00CF void Item::I_setQAndCombine Item::isOn
0x00D0 int16 Item::I_use Actor::I_isInCombat
0x00D1 void AudioProcess:I_stopAllSFX Actor::I_getNPCDataField0x4
0x00D2 void I_playMovieCutscene Actor::I_setCombatTactic
0x00D3 void I_clearKeyboardState Actor::I_setDead
0x00D4 void I_playSFX CameraProcess::I_getCameraY
0x00D5 int16 Item::I_use Actor::I_getEquip
0x00D6 byte CameraProcess::I_getCameraZ Actor::I_setEquip
0x00D7 int16 Actor::I_getLastAnimSet Actor::I_getDefaultActivity0
0x00D8 void Actor::I_setDead Actor::I_getDefaultActivity1
0x00D9 int16 Item::I_getQLo Actor::I_getDefaultActivity2
0x00DA void PaletteFaderProcess::I_setPalToAllGrey Actor::I_getLastAnimSet
0x00DB void Actor::I_setActivity Actor::I_isFalling
0x00DC byte Item::I_isOn Item::getQLo
0x00DD int16 Actor::I_getLastActivityNo Item::getQHi
0x00DE void Actor::I_setCombatTactic Item::getNpcNum
0x00DF int16 Actor::I_getEquip Item::I_setField0x81
0x00E0 void Actor::I_setEquip Item::hurl
0x00E1 int16 Actor::I_getDefaultActivity0 Actor::I_setDead
0x00E2 int16 Actor::I_getDefaultActivity1 Item::getQLo
0x00E3 int16 Actor::I_getDefaultActivity2 Item::getCY
0x00E4 int16 Actor::I_getLastAnimSet Item::getNpcNum
0x00E5 void Actor::I_setTarget Item::hurl
0x00E6 void Actor::I_SetNPCDataField0x63_0E6 Item::getNpcNum
0x00E7 void Actor::I_setDead Item::hurl
0x00E8 int16 Item::I_cast Item::getNpcNum
0x00E9 void Item::I_andStatus Item::hurl
0x00EA int16 Item::I_getQLo Item::getNpcNum
0x00EB int16 I_GetQOfAvatarInventoryItem0x4ed_0EB Item::hurl
0x00EC void Item::I_popToEnd Item::getNpcNum
0x00ED void Item::I_popToContainer Item::hurl
0x00EE void BatteryChargerProcess::I_create Item::getNpcNum
0x00EF int16 Kernel::I_getNumProcesses Item::hurl
0x00F0 int16 Item::I_getQHi Item::getNpcNum
0x00F1 byte Item::I_isOn Item::hurl
0x00F2 void Actor::I_setActivity Item::getNpcNum
0x00F3 int16 Item::I_getQHi Item::hurl
0x00F4 int16 Item::I_getQ Item::getNpcNum
0x00F5 void Item::I_setQ Item::hurl
0x00F6 void CruHealer::I_create_0F6 Item::getNpcNum
0x00F7 int16 Item::I_hurl Item::andStatus
0x00F8 int16 Item::I_getNPCNum Actor::I_setDead
0x00F9 int16 Item::I_hurl Item::getQLo
0x00FA byte Item::I_isOn Actor::I_setDead
0x00FB int16 Item::I_getQHi Dtable::I_getMaxHPForNPC
0x00FC void Item::I_andStatus Actor::I_setHP
0x00FD byte MainActor::I_hasKeycard Item::getQLo
0x00FE void ComputerGump::I_readComputer BatteryChargerProcess::I_create
0x00FF int16 UCMachine::I_numToStr Item::hurl
0x0100 int16 Item::I_getNPCNum Item::andStatus
0x0101 void Item::I_andStatus Item::isOn
0x0102 int16 Item::I_getNPCNum Actor::isDead
0x0103 byte Item::I_isCrusTypeNPC Actor::I_setActivity
0x0104 void Item::I_andStatus Item::getQHi
0x0105 int16 Item::I_getNPCNum Actor::I_getLastAnimSet
0x0106 void Item::I_andStatus Actor::I_setDead
0x0107 int16 Item::I_getNPCNum Item::getQLo
0x0108 void Item::I_andStatus Item::isOn
0x0109 int16 Item::I_getNPCNum Item::getQHi
0x010A void Item::I_andStatus Item::isOn
0x010B int16 Item::I_getNPCNum Item::getQHi
0x010C void Item::I_andStatus Item::hurl
0x010D int16 Item::I_getNPCNum Item::getNpcNum
0x010E void Item::I_andStatus Item::getCY
0x010F int16 Item::I_getNPCNum Item::hurl
0x0110 void Item::I_andStatus Item::isOn
0x0111 int16 Item::I_getNPCNum MainActor::I_hasKeycard
0x0112 byte Actor::I_getDir IntrinsicReturn0
0x0113 int16 UCMachine::I_numToStr Actor::isDead
0x0114 void Item::I_andStatus Actor::I_clrImmortal
0x0115 int16 Item::I_getNPCNum UCMachine::I_numToStr
0x0116 byte Item::I_fireDistance Item::getQHi
0x0117 void Item::I_andStatus Actor::I_setActivity
0x0118 int16 Item::I_hurl Item::andStatus
0x0119 void Item::I_setIsBroken Item::getNpcNum
0x011A void Item::I_andStatus Item::andStatus
0x011B byte Item::I_getTypeFlag Item::getNpcNum
0x011C int16 Item::I_getNPCNum Item::I_isCrusTypeNPC
0x011D int16 Item::I_hurl Item::andStatus
0x011E int16 Item::I_getCY Item::getNpcNum
0x011F byte Item::I_getCZ Item::AvatarStoleSomehting
0x0120 int16 Item::I_getCX Item::andStatus
0x0121 byte Actor::I_getDir Item::getNpcNum
0x0122 byte Actor::I_isDead Item::getQ
0x0123 int16 Item::I_getNPCNum Item::setQ
0x0124 int16 Actor::I_getLastAnimSet Item::andStatus
0x0125 void Item::I_setQuality Item::getNpcNum
0x0126 int16 UCMachine::I_numToStr Item::andStatus
0x0127 byte Item::I_getDirToCoords Item::getNpcNum
0x0128 void Item::I_andStatus Item::andStatus
0x0129 int16 Item::I_getNPCNum Item::getNpcNum
0x012A void Item::I_setIsBroken Item::andStatus
0x012B int16 IItem::I_getCY Item::getNpcNum
0x012C byte Item::I_isOn Item::andStatus
0x012D void Item::I_getFootpadData Item::getNpcNum
0x012E byte Actor::I_isDead Actor::I_getDir
0x012F int16 Actor::I_createActorCru Item::andStatus
0x0130 void Actor::I_clrImmortal Item::getNpcNum
0x0131 void Actor::I_setActivity Intrinsic0131
0x0132 void Item::I_andStatus Item::andStatus
0x0133 int16 Item::I_getQHi Item::hurl
0x0134 void WeaselGump::I_showGump Item::andStatus
0x0135 void Actor::I_setDead Camera::getY
0x0136 not scanned Camera::getZ
0x0137 not scanned CruStatusGump::I_hideStatusGump
0x0138 not scanned Actor::I_clrInCombat
0x0139 not scanned Item::getTypeFlagCrusader
0x013A not scanned Item::getNpcNum
0x013B not scanned Item::hurl
0x013C not scanned Item::getCY
0x013D not scanned Item::getCZ
0x013E not scanned Item::setFrame
0x013F not scanned AudioProcess::I_playAmbientSFX
0x0140 not scanned AudioProcess::I_isSFXPlaying
0x0141 not scanned World::I_clrAlertActiveRegret
0x0142 not scanned PaletteFaderProcess::I_fadeToGivenColor
0x0143 not scanned Actor::isDead
0x0144 not scanned Actor::I_setDead
0x0145 not scanned Game::I_playCredits
0x0146 not scanned PaletteFaderProcess::I_jumpToAllGrey
0x0147 not scanned Item::I_getFamilyOfType
0x0148 not scanned Item::getNpcNum
0x0149 not scanned Item::getQLo
0x014A not scanned Item::andStatus
0x014B not scanned Ultima8Engine::getCurrentTimerTick
0x014C not scanned World::I_setAlertActiveRegret
0x014D not scanned Ultima8Engine::I_getAvatarInStasis
0x014E not scanned MainActor::I_addItemCru
0x014F not scanned Egg::getEggXRange
0x0150 not scanned Actor::I_clrInCombat
0x0151 not scanned PaletteFaderProcess::I_jumpToColor
0x0152 not scanned Item::setFrame
0x0153 not scanned UCMachine::I_numToStr
0x0154 not scanned Actor::I_getDir
0x0155 not scanned UCMachine::I_numToStr
0x0156 not scanned Item::isOn
0x0157 not scanned Actor::I_getDir
0x0158 not scanned Actor::I_setDead
0x0159 not scanned Item::getQHi
0x015A not scanned Item::getQLo
0x015B not scanned UCMachine::I_numToStr
0x015C not scanned Actor::I_getDir

6.3 Capability families exposed through native calls

Across the Crusader runtime tables and observed scripts, intrinsic calls expose or mediate capabilities in these broad families:

  • Items and world objects: read/write item properties; create, destroy, move, push/pop, grab, drop, and transfer objects; query shape/family/type, frame, status/quality/quantity, coordinates, map placement, overlap/reach, and containment.
  • Actors and combat: query or set actor state and statistics, targets, direction, movement/activity, animation, hit/damage behavior, and combat state; create or teleport actors where the variant table provides the operation.
  • Processes and scheduling: inspect process identifiers/results, spawn or coordinate work, suspend/yield, exclude processes, and schedule delayed/tick-driven behavior.
  • Map and trigger systems: query/update eggs, trigger/controller state, map and coordinate relationships, enter/leave activation regions, and spawn or dispatch event-driven effects.
  • User interface and text: interact with game UI, gumps, readable objects, prompts, or other presentation services where supported by that build's intrinsic table.
  • Graphics and camera: camera movement/centering, sprite effects, palette transitions, fades, screen effects, and related presentation operations.
  • Audio and music: play/stop sound effects and music, query sound state, or alter audio parameters where provided.
  • Time, randomness, and game state: query or update selected game-time state, obtain random values, and access variant-specific flags or globals.
  • Global storage and VM-managed values: read/write globals and use the VM's pointer/string/list support. A script-visible pointer is a VM/runtime reference, not an unrestricted host pointer.

These are capabilities of the bytecode plus the installed native table, not all built-in bytecode instructions. A particular game version may leave an ordinal unused, map it differently, or implement it only in one variant. The table is not an operating-system API.

6.4 Events versus intrinsics

Event slots are script entry points. Intrinsics are native callable services. For example, an event handler can be invoked by the engine for use, and that handler can then call item or audio intrinsics. Do not conflate:

  • equip event slot 0x0A with any specific intrinsic ordinal;
  • event cast slot 0x11 with spellcasting;
  • spawn opcode 0x57 with a native intrinsic;
  • class/event dispatch opcode 0x11 with intrinsic call opcode 0x0F.

7. What scripts can do

Subject to the event and intrinsic tables of the active game build, Crusader USECODE can:

  • implement class-specific callbacks and call other class/event handlers;
  • branch, loop, compare, perform integer/dword arithmetic and bit operations;
  • use local/member/global storage, references, indirect access, and result values;
  • manipulate strings, lists, string-lists, and aggregate/“huge” values;
  • create and control asynchronous processes, yield/suspend, and coordinate process results;
  • use native game services to inspect and mutate items, actors, world state, UI, graphics, audio, timing, and trigger behavior;
  • attach behavior to engine lifecycle, interaction, movement, hit, schedule, spawn, and proximity callbacks.

This is an event/process scripting system integrated into the game engine. It can perform substantial gameplay logic because its intrinsic layer gives scripts access to native services.

8. What the format alone cannot establish

These are limits on what can safely be concluded from the file/bytecode representation, not absolute claims that a native executable could never provide the behavior:

  • No intrinsic implementation from an ordinal alone. The number, argument bytes, and optional converter name do not define the native routine's full behavior or guarantee the ordinal exists in another build.
  • No class behavior from a slot label alone. A slot can be absent, empty, repurposed, or class-specific. Event-name tables are vocabulary hints.
  • No lossless source recovery from pseudocode alone. Decompilation can omit exact operand encodings, opaque values, padding, symbol records, and trailers. Original bytes and offsets must be retained for exact round trips.
  • No settled meaning for every header/row field. The leading word in each 6-byte event row and the count/base mismatch remain unresolved.
  • No settled semantics for all instructions. The opcode-name list and local decoder disagree in places; unsupported/unknown opcodes cannot safely be skipped without a proven length rule.
  • No proof of arbitrary host/OS access. The known model calls game-provided intrinsics. No general-purpose file/network/process/OS syscall interface is established by the bytecode specification.
  • No claim that each game feature is script-owned. Engine code performs event selection, VM process management, native operations, and state transitions. A script can request native actions but does not necessarily implement those systems itself.
  • No inheritance or virtual-method guarantee. The established call form names a class and event ordinal. Any higher-level inheritance/dispatch claim needs separate evidence.
  • No guarantee that all listed object-oriented concepts are source-language constructs. Names such as “class,” “member,” and “routine” describe the compiled runtime representation; a complete original source language/compiler specification has not been recovered.

9. Runtime execution model

The most defensible high-level model is:

  1. The engine or another script selects a class and event slot.
  2. Runtime class/event data resolves that slot to a code offset/body.
  3. A usecode process/context is created with item and optional event/context parameters.
  4. The interpreter executes variable-length bytecode against local/member/global state and a VM evaluation stack.
  5. Bytecode may call another event, spawn a process, call an intrinsic, suspend/yield, or return/end.
  6. The engine's process scheduler resumes suspended work and applies native/world side effects.

The local rebuild/remorse model records process/context layout and partial opcode semantics in usecode_vm.h, usecode_vm.cpp, and usecode_vm_tests.cpp. Those are explicitly partial models; passing their tests proves the model's tested behavior, not full equivalence to every retail interpreter path.

10. Remorse, Regret, and other version boundaries

Area Shared evidence Must remain variant-specific
Archive/class indexing FLEX object indexing, class object at class_id + 2, 6-byte event rows, event ordinals Exact class inventory and data bytes
Event vocabulary Shared Crusader event-name table 0x00..0x1f Presence and behavior of each class/slot
Bytecode Broad shared opcode vocabulary Actual use, edge semantics, version-specific opcodes and compiler artifacts
Intrinsics Same general native-call architecture Ordinal-to-function map, signature, availability, return semantics
Debug/symbol data Symbol and line records occur in bodies Exact trailer layout and compiler/version details
Runtime Process-based interpreter model Context fields, startup globals, scheduler details, and implementation differences

Remorse global-index conflict: ScummVM's runtime source initializes global 0x003C to avatar number 1, while Pentagram's scratch dump for Remorse 1.01 starts at 0x003D. The current Ghidra pass traced event dispatch and slot materialization, not a version-matched global initializer, so this remains unresolved and version-qualified. See Pentagram's Crusader reference note for the competing evidence.

Do not infer retail Remorse behavior solely from Regret samples, or vice versa. Demo, regional, and patched executables must likewise be recorded as separate evidence targets where their tables differ.

11. Safe parsing and round-trip requirements

Any parser, editor, or writer claiming to preserve Crusader USECODE should:

  1. preserve the original archive, entry order, sparse entries, class bytes, and unknown objects;
  2. bounds-check FLEX offsets/sizes and class/event tables before reading;
  3. preserve raw event-row bytes, including the unresolved leading word;
  4. store raw event/body byte slices and the exact offsets used to derive them;
  5. distinguish absent rows, valid zero-offset values, malformed rows, and unresolved layouts;
  6. retain unsupported instruction bytes rather than discarding or guessing their lengths;
  7. preserve debug/symbol data and bytes after END;
  8. use the correct Remorse/Regret intrinsic hint table and retain the raw ordinal and argument-byte count regardless of naming;
  9. require unchanged inputs to round-trip byte-for-byte before claiming a lossless format edit path;
  10. write modified archives to a separate output and validate with an independent parser/runtime.

The current product/editor path and remaining round-trip milestones are in usecode-roundtrip-ir.md. The local proof-of-concept parser is poc_crusader_usecode_parser.py; the user-facing map-viewer implementation is usecode-decompiler.js.

12. Primary references

Local evidence

External implementation references

External implementation links describe those projects' code and conventions. For local owner-loaded Crusader data, the raw samples and locally validated extraction rules in this repository take precedence wherever the implementations conflict.

13. Open Mysteries for Investigation

These questions have plausible, testable evidence paths. Keep results qualified by game, executable version, and archive; do not promote a shared-implementation convention to a Crusader fact without local confirmation.

  • Class header and event-table extent: Determine why ScummVM/Pentagram's event-count formula disagrees with sampled owner-loaded records. Compare bytes 8..11, table boundaries, and code anchors across Remorse, Regret, demo, regional, and patched archives; verify any proposed formula against every class record.
  • Leading event-row word: Establish what the unknown u16 at the start of each six-byte row encodes. Correlate values with event presence, slot, class, and build, then trace any runtime or loader use before assigning meaning.
  • Event code-offset convention: Confirm the code_base_minus_one and 1-based displacement interpretation, including zero offsets, duplicate or out-of-order offsets, and how the final body boundary is chosen. Check edge cases against raw class bytes and the runtime's indexed records.
  • Event-body framing: Recover the fields and purpose of the 14-byte execution prefix, debug/symbol records, END, and trailing bytes. Compare bodies from multiple compiler/build variants and verify that parsing preserves all bytes while locating executable instructions correctly.
  • Unresolved call/process opcodes: Determine the target and calling/return conventions of 0x10 (NEAR_ROUTINE_CALL), and the exact operand and inline-data layout of 0x58 (SPAWN_INLINE). Use representative bytecode call sites and the matching executable's interpreter paths.
  • Conflicting or undecoded opcodes: Reconcile historical names and local decoder interpretations for 0x54..0x56, 0x70..0x74, and 0x7B. Trace dispatch in each relevant retail interpreter and validate candidate instruction boundaries against real bodies; do not infer operand lengths from names.
  • VM value and stack semantics: Specify ownership, lifetime, and representation for strings, lists, string-lists, references, and “huge” values; verify stack effects, result propagation, and cleanup behavior using interpreter code plus representative scripts, especially around suspend/return.
  • Intrinsic contracts by build: Validate ordinal-to-native dispatch, argument types/order, return convention, and side effects independently for Remorse and Regret. Prioritize frequently used or ambiguously named ordinals, Remorse 0x134/0x135, and Regret's native table, which is not validated here.
  • High event-slot meanings: Identify behavior for class-local slots above 0x1F (0x20..0x4B in Remorse and 0x20..0x51 in Regret). Cluster bodies by bytecode and class, then trace native callers and observed effects before proposing labels.
  • Event dispatch edge cases: Determine how absent, empty, or unsupported event slots affect native fallbacks, and whether higher-level inheritance or virtual dispatch exists beyond the observed class-id/slot lookup. Trace callers and dispatcher behavior for representative slots, including setActivity.
  • Remorse global-index discrepancy: Resolve whether global 0x003C or 0x003D holds the avatar number in each Remorse release. Inspect version-matched executable initialization and compare with the corresponding data/archive rather than relying on cross-version ScummVM/Pentagram notes.
  • Compiler and source-language model: Establish which source-level constructs are actually supported by evidence, including class/member layout, routine calls, and any inheritance. Seek compiler-produced samples, symbol/debug metadata, or controlled runtime tests; keep representation terminology distinct from proven source-language features.