RMF commands
6. Layer A: text-engine commands
Section titled “6. Layer A: text-engine commands”Commands 0x00–0x0A. These are the eleven entries of the PutText jump table
at . All of them operate on
the current _MES_DATA block; the offsets in the last column are fields of that
structure. Everything in this section is confirmed from the
jump-table handlers.
| Cmd | Name | Handler | Payload | Effect / state touched |
|---|---|---|---|---|
00 | End | 0x2D5318 | 0 words | Terminates the run. Commits the max line width to |
01 | Space | 0x2D5350 | 0 words | Region-dependent. English builds advance the pen by
|
02 | Color | 0x2D5370 | 2 words |
|
03 | Dimensions | 0x2D53A0 | 2 words | Glyph cell width ( |
04 | Position | 0x2D5400 | 2 words | Two signed 16-bit coordinates. Sub |
05 | TextStyle | 0x2D5498 | 0 words | Stores |
06 | Signal | — | 1 word | No renderer handler; falls through to (§7). |
07 | TextSpeed | 0x2D54C8 | 1 word | Writes the payload word to the typewriter rate |
08 | — | — | — | Jump-table entry points at the skip label. Inert. |
09 | StyleSave / StyleRestore | 0x2D54D8 | 1 word | The payload word is a field mask. Sub |
0A | Newline | 0x2D5660 | 0 words | Updates the running max line width in |
6.1 The 09 save and restore mask
Section titled “6.1 The 09 save and restore mask”Each bit selects one field of _MES_DATA to push or pop. This is a
general-purpose style stack; ruby text (§12)
is simply its most visible user.
| Bit | Field | Meaning |
|---|---|---|
0x01 |
u32 +0x00 |
Text colour |
0x02 |
u32 +0x04 |
Shadow colour |
0x04 |
s16 +0x14 |
Pen X |
0x08 |
s16 +0x16 |
Pen Y |
0x10 |
u16 +0x10 |
Glyph width |
0x20 |
u16 +0x12 |
Glyph height |
0x40 |
u8 +0x0C |
Text style (cmd 05) |
0x80 |
u32 +0x20 |
Text speed |
Ruby annotations use mask 0x00BC = pen position + dimensions + speed,
deliberately omitting the two colour bits so the annotation inherits the base
text’s colour.
7. Layer B: CTalk command dispatch
Section titled “7. Layer B: CTalk command dispatch”Commands 0x0E and 0x0F.
turns a
record into a table index confirmed:
00317EF4 lbu $v1, 0($t0) ; cmd[0]00317EF8 bne $v1, 0x0E, check_0F00317F00 lbu $v0, 1($t0)00317F04 andi $v0, $v0, 0xf ; subcommand nibble00317F08 addiu $v0, $v0, 0x10 ; 0x0E xN -> 0x10 + N; check_0F:00317F24 lbu $v0, 1($t0)00317F28 andi $v0, $v0, 0xf00317F2C addiu $v0, $v0, 0x20 ; 0x0F xN -> 0x20 + N; dispatch: index * 12 into ms_pCommandFuncTable00317F3C sll $v0, $v1, 100317F44 addu $v1, $v0, $v1 ; index * 300317F50 sll $v1, $v1, 2 ; ... * 4 = index * 1200317F4C lui $v0, 0x3b00317F54 addiu $v0, $v0, 0x3a80 ; CTalk::ms_pCommandFuncTable00317F5C jal 0x149400 ; __ptmf_scallDispatch rules:
0x00–0x0D: index is the command byte itself.0x0E: index is0x10 + (cmd[1] & 0x0F).0x0F: index is0x20 + (cmd[1] & 0x0F).
The runtime table
lives
in BSS, size 0x240 = 48 entries × 12 bytes (a Metrowerks pointer-to-member
function). It is populated from a
that uses 16-byte
records shaped { u32 0, u32 0xFFFFFFFF, u32 callback_addr, u32 0 }, 48 of them.
Both forms were dumped and agree. confirmed
Click any callback name for its address in all three builds.
| Index | Record | Callback | Payload | Fields and behaviour |
|---|---|---|---|---|
| Direct commands — 0x00 through 0x0F | ||||
0x00 | 00 00 | 0 words | Ends the message. Writes renderer state | |
0x01 | 01 00 | 0 words | No CTalk action; handled by the renderer as space. | |
0x02 | 02 2x | 2 words | Renderer-only: Color (§6). | |
0x03 | 03 2x | 2 words | Renderer-only: Dimensions (§6). | |
0x04 | 04 2x | 2 words | Renderer-only: Position (§6). | |
0x05 | 05 0x | 0 words | Renderer-only: TextStyle (§6). | |
0x06 | 06 1x | 1 word |
| |
0x07 | 07 1x | 1 word | Renderer-only: TextSpeed (§6). | |
0x08 | 08 xx | — | Unused. | |
0x09 | 09 1x | 1 word | Renderer-only: StyleSave / StyleRestore (§6). | |
0x0A | 0A 00 | 0 words | Renderer-only: Newline (§6). | |
0x0B–0x0D | — | — | Inert in both layers. Never observed in real data. | |
0x0E, 0x0F | — | — | Never reached: these command bytes are always remapped by the subcommand nibble. | |
| 0x0E xN — bustup and speaker control | ||||
0x10 | 0E 20 | 2 words |
| |
0x11 | 0E 1x / 0E 2x | varies |
| |
0x12 | 0E x2 | varies |
| |
0x13 | 0E x3 | varies | Byte-identical to _CbBupDirection here. inferred | |
0x14 | 0E 24 | 2 words |
| |
0x15 | 0E x5 | 2 words |
| |
0x16 | 0E x6 | 2 words |
| |
0x17 | 0E x7 | varies |
| |
0x18, 0x19 | 0E x8 / 0E x9 | — | Assertion trap. Not valid data. | |
0x1A | 0E xA | varies |
| |
0x1B | 0E xB | — | Assertion trap. | |
0x1C | 0E xC | 2 words | u16[2] = speaker index, u8[4] = eye variant index. | |
0x1D | 0E xD | 2 words |
| |
0x1E | 0E 4E | 4 words |
| |
0x1F | 0E xF | — | Assertion trap. | |
| 0x0F xN — flow, sentences and audio | ||||
0x20 | 0F 20 | 2 words |
| |
0x21 | 0F x1 | — | Assertion trap. | |
0x22 | 0F 2x | 2 words |
| |
0x23 | 0F 3x | 1 word |
| |
0x24 | 0F 24 | 2 words | Same field layout as | |
0x25 | 0F 25 | 2 words | The wrapper that introduces a message. | |
0x26 | 0F 6x | see note | Proper-noun substitution. On first encounter it calls
| |
0x27 | 0F 7x | up to 7 words | Reads | |
0x28 | 0F 28 | 2 words |
| |
0x29–0x2F | 0F 9x–0F Fx | — | Assertion trap. Seven unused subcommands. | |
8. Callback return flags
Section titled “8. Callback return flags”Every callback returns a value through this+0x1E0. PutText reads it as a
bitfield — the low byte is a state, the high bits are directives. This is what
makes constructs like _CbProper and _CbSentence possible.
confirmed from the loop tail at 0x002D5CF8.
| Value | Name | Effect on PutText |
|---|---|---|
| low byte = 0 | continue | Keep walking the stream (subject to the typewriter budget). |
| low byte = 1 | pause | Stop for this frame; refund 0x100 of typewriter budget. |
| low byte = 2 | end | Finish this text run. Clears the stream pointer. |
0x100 |
slot_gone | Do not write the pen position back — the block is being freed. |
0x200 |
ptr_owned | The callback already advanced the stream pointer; do not add (payload+1)*2. |
0x400 |
handled | Skip the renderer’s own jump-table handler for this record. |
0x800 |
release | With state 2: also free the sprite lists, the style block and the _MES_DATA itself. |
0xFF |
error | Triggers an assertion and aborts the run. |
Observed combinations: _CbSentence returns 0x802, _CbProper returns
0x200, _CbEnd returns 2, and everything else returns 0.