0x3 call-script
Opcode 0x3 (3), control. Investigated by OME, with high confidence (from investigation).
load & call another SYS4 script by id; id = RAW index into the SYS4INI file table (asset-index). Pushes a script frame; returns to caller when the callee ends.
Operands
| # | Role | Types seen | Access |
|---|---|---|---|
| 1 | script id = raw SYS4INI file index | imm, g-int, l-ptr | read |
In the port
OME’s port implements it. It never waits: a wait parks the engine until input, a sleep, a transition, a dialog or a movie ends. What it can do with control besides waiting:
falls: it returns to the next instructioncalls: it runs another frame or a callback before it returns: a script, a wait’s callback, a menu’s scriptends: it ends its frame, the scene or the run, itself or because a frame it ran did
OME derives these facts from the port’s handler (its tools/opcode_flow.py), and they over-approximate: a fact some path can reach is given.
By build
Whether each build’s scripts use it, as OME’s survey of the game’s scripts saw them, and how many evidence items name the build.
| Build | Game | Used by its scripts | Evidence |
|---|---|---|---|
4.24J (SYS4422) | Himegari Dungeon Meister | yes | 1 |
4.33G (SYS4433) | Kamidori Alchemy Meister | yes | — |
4.38D (SYS4438) | Soukoku no Arterial | yes | — |
Evidence
- native-re on SYS4422, high confidence; Himegari AGE.EXE Ghidra /v2 and decoded script corpus (
vm-map/opcodes.toml opcode 0x3): native-RE (Ghidra): handler FUN_0041bc90 -> loader script_frame_load_resource@0x40e980 -> resolver asset_open_indexed_entry@0x44f390 indexes an 80-byte record table (FileDB+0x414 base, FileDB+0x40c count) at base+id*0x50 = the SYS4INI record layout {name[64],arc_id@0x40,file_number@0x44,offset@0x48,size@0x4c}. The FileDB is embedded at EngineCtx+0x9c24c, making those EngineCtx+0x9c660/+0x9c658. Confirmed statically: all 297 distinct base-corpus call-script ids resolve to a .BIN script with a semantically-exact name (0x1ab->ADDITEM, 0x2ae7->MES, 0x143->BUNKI, 0x329d->CALCREVISE), 0 out-of-range. See docs/engine-re.md + name-resolution.md #1.
Details
OME’s notes on it, as the registry keeps them.
op 0x03 (call-script, argc 1): `call-script <id>`. RESOLVED — the id is a direct RAW index into
the SYS4INI global file table (the same table parse_sys4ini.py reads, but indexed WITHOUT skipping
'@' placeholders; SYS4INI has 13208 records / 2 placeholders). No separate on-disk id->code registry
exists; SYS4INI *is* the call-script registry.
Native mechanism (dispatch table `handler(op)=ctx[0x26c93+op]`, op 0x03 -> FUN_0041bc90):
1. FUN_0041bc90 fetches operand 1 (id), bounds-checks call depth (<=0x26), pushes a frame.
2. FUN_0040e980 (loader): opens the resource by id, reads the 0x20-byte SYS4 header, checks magic,
allocates per-frame code/local buffers from the header var-counts, reads the bytecode body,
pushes a script frame (stride 0x1e = 30 dwords, indexed by ctx[0x14f45]).
3. asset_open_indexed_entry@0x44f390 (resolver): its `this` is the embedded FileDB, not EngineCtx.
Base record = [FileDB+0x414] + id*0x50. It tries a LOOSE OVERRIDE first (CreateFileA on
record.name -> mod/patch hook point), else opens archive [record.arc_id*0x100 + FileDB+0x410],
SetFilePointer to record.offset, size = record.size.
High-byte-tagged ids select [FileDB+0x3028 + signed_selector*4] and index the chosen AAI by the
low 24 bits. The base corpus has 0/297 explicit high-byte call-script operands; INIT2 op 0x143
supplies mounted record-zero ids dynamically.
Companion op 0x8f `call` is INTRA-script (a local JSR), not cross-script -- see its entry.
This also names the whole call graph statically (build/games/<game>/callscript-names.json).
Errors (2026-11-17, driven on 4.24J): a call from frame 39 shows the fatal box
「ファイルの階層が深すぎます.最大は40です.」 (flags 0x10001, OK ends the program); an id the resource open
refuses shows the loader's 再試行/キャンセル box with its message (「ファイル番号 n は不正な値です.」 and the
rest), where 再試行 opens it again and キャンセル ends the program. The port shows both; it halts for a high
byte of 0x80 and up and for a record that is not a script. See docs/engine-re.md, "The frame limit and load
failures".