Living Tool
Browse the docs
Docs/Reference

Text control codes

Dialogue is plain ASCII with a few control bytes for boxes, pages and inserted names. Here is every code and the limits a line must fit.

v0.1.27 · updated 16 Oct 2026 · 7 min read

The font and the box

Every line in a dialogue box is plain ASCII that ends in a 00 byte. The game draws it with one fixed 8×12 font from SYS14 (sys/2), so most characters are 8 px wide. There is no colour, speed or portrait code. The speaker's name bubble comes from the event script (opcode 1F), not from the string.

Dialogue window232 × 52 px, centred at x 44–276
Glyph8 × 12 px cell, 8 px advance
Width exceptions' is 3 px · ^ is a 12 px ruby icon · space is 8 px
Lines per page3 (a 4th crosses the bottom border)
Characters per line24 safe (192 px) · 25 retail max (200 px) · 26+ overflows
Box positionstop y 16 · middle y 90 · bottom y 164
Text & dialogue shows each line with its box and name chips, the page being edited, and an in-game preview drawn with SYS14.
Text & dialogue shows each line with its box and name chips, the page being edited, and an in-game preview drawn with SYS14.

Control codes

The printer reads a handful of bytes as commands instead of glyphs. Living Tool shows each one as a chip in the line table and stores it as markup, the same markup AI agents write with edit_dialogue.

BytesMarkupWhat it does
00(end)Ends the string.
05 n 00{box:n}Opens a box. n sets the position (3 top, 5 middle, any other value bottom) and the frame style.
04 05 n 00{brk:n}Ends this box and opens the next one mid-string.
06{wait}Shows the bouncing cursor and waits for Cross, then starts a new page in the same box.
07{nl}Starts a new line, 12 px down.
$ # ~$A #nnn ~nnInserts a name or other string; see below.
any other byte{XX}Kept as one raw byte, in hex.

Retail text uses box 3 most often (1,551 times), then 0 (638) and 5 (340). The top box also plays a different sound effect. Most strings start with 05 n 00, but not all. In npc/7, 7 of 92 dialogue strings have no prefix and keep the previous box. The editor tags them no box. Keep a line's own prefix when you rewrite it.

Some older notes swap 06 and 07. The decomp is clear: 06 waits for a page turn and 07 starts a new line.

Name and item tokens

Three characters start a token instead of printing: $, # and ~. That is why dialogue can't show them as text. The game looks up the string and draws it raw, so codes inside an inserted name are not parsed.

TokenInsertsNotes
$AKnight namePlayer-entered. 174 uses in retail.
$BBaby namePlayer-entered. 62 uses.
$C"Nehani"2 uses.
$DKnight name, stutteredRendering unverified.
$EThird name from the naming screenMeaning unverified.
$F $G"Yes", "No"Fixed strings.
$H"Save game data?"Fixed string.
#nnnItem name3 digits. Ids from 500 map to id − 302. Unused in retail dialogue.
~nnLiving Toy name2 digits. One retail use: ~15, Jupiter.

Names are player-entered, so their width varies. Living Tool measures each line with an 8-letter name, and warns when it would overflow at 11 letters, the most the naming screen allows.

A string, byte by byte

A dialogue string is a box code, then text and control bytes, then 00. This one has two pages in the top box, then moves to the middle box. Each ... stands for ASCII text.

String layout: bytes, markup, effect
05 03 00      {box:3}   open the top box
...           text      up to 3 lines, {nl} between them
06            {wait}    bouncing cursor, wait for Cross
...           text      next page, same box
04 05 05 00   {brk:5}   close it, open the middle box
...           text
00            (end)     end of string

In an NPC pack, strings sit in the D-block text pool as C strings, each aligned to 4 bytes. Choice menus (opcodes 3A and 3B) use the same format, with 07 between the options. A quest objective (opcode 44) is copied, 05 n 00 prefix and all, into a 0x68-byte buffer.

Living Tool names each string by its pack and retail offset, such as npc/7@07A8. The id stays the same after you edit the string, even if it moves. The Say a line form in Events & scripts writes the same markup.

The Say a line form in Events & scripts writes {nl} and $A into the line and previews the box.
The Say a line form in Events & scripts writes {nl} and $A into the line and previews the box.

Size limits and moving text

Dialogue lives in the 50 NPC packs, roughly 2,700 to 3,000 lines in all. Script opcodes reach each string through a u16 offset from the pack's D-block. An edit that fits the string's old slot is written in place. A longer string has to move.

Line width192 px safe · 200 px retail max · error above 200
Lines per page3 · a 4th before {wait} or {brk:n} is an error
Objective (opcode 44)0x68 B with 05 n 00 and NUL · 100 characters
Choice menuup to 16 options
NPC pack≤ 0x31000 B (98 sectors)
D-span reachtargets below D + 0x10000 · retail max 0x7A50 (npc/23)

When a string moves, every opcode that points at it has to be repointed. These are the opcodes that hold text references:

OpcodePoints at
01 02 03A dialogue line
1FThe speaker name
3A 3BChoice menu text, options split by 07
44A quest objective

Opcodes 1C and 34 also hold offsets, but they point at walk programs, not text. 2E and 2F point at script code. 21 and 22 hold no offsets at all.

Living Tool appends the longer string at the end of the D-span and repoints every operand to the new copy. It then shifts the model data behind it and fixes the pack's model table. The old string stays where it was, so a reference the tool missed shows the old text instead of crashing the game. Edits are always laid out again from the retail pack, so the result depends on your set of edits, not on the order you saved them.

As you type, Living Tool checks:

  • The fit of each line's worst page: 24 characters is green, 25 amber, 26 or a fourth line red.
  • Whether the line still fits its slot and is written in place, or grows and is appended, with the number of operands repointed.
  • The pack budget: its size against the 0x31000 cap, and its furthest target against the u16 reach, with your pending edits included.