Text Book: Difference between revisions
No edit summary |
No edit summary |
||
| Line 57: | Line 57: | ||
== Control Characters == | == Control Characters == | ||
The text stored in '''Text Cards''' support using control characters for | The text stored in '''Text Cards''' support using control characters for certain interactive or visual behaviours. | ||
{| class="wikitable" | {| class="wikitable" | ||
|+ | |+ | ||
| Line 68: | Line 68: | ||
|<code>\n</code> | |<code>\n</code> | ||
|Creates a new line in the text entity. | |Creates a new line in the text entity. | ||
|- | |||
|<code>$</code> | |||
|Creates a placeholder marker for a variable to be inserted in the text entity. If no variable exists for this marker, it'll display as <code>$</code>. | |||
|} | |} | ||
Revision as of 18:03, 30 April 2026
Text Book is a file format used in Sonic the Hedgehog (2006) for storing text with friendly names and variables.
These files are located in cache.arc and text.arc under the ./text/ directory from platform root as *.mst files.
Specification
Text Book uses a Binary Resource container. The text to be displayed is encoded as UTF-16, whereas the names and variables are encoded as Shift-JIS.
Header
The header consists of the following data structure:
| Offset | Type | Name | Description |
|---|---|---|---|
| 0x00 | Char[4] | Signature | Always "WTXT" (referring to UTF-16). |
| 0x04 | UInt32 | NameOffset | The offset of the name of this Text Book. |
| 0x08 | UInt32 | CardCount | The total number of Text Cards in this Text Book. |
Text Card
Text Cards consist of the following data structure:
| Offset | Type | Name | Description |
|---|---|---|---|
| 0x00 | UInt32 | NameOffset | The offset of the name of this Text Card. |
| 0x04 | UInt32 | TextOffset | The offset of the UTF-16 text for this Text Card. |
| 0x08 | UInt32 | VariablesOffset | The offset of the variables for this Text Card. |
Control Characters
The text stored in Text Cards support using control characters for certain interactive or visual behaviours.
| Character | Description |
|---|---|
\f
|
Creates a new page in the message window. The next page is switched to automatically after the voice line started by a sound variable has finished, otherwise it waits for player input. |
\n
|
Creates a new line in the text entity. |
$
|
Creates a placeholder marker for a variable to be inserted in the text entity. If no variable exists for this marker, it'll display as $.
|
Variables
Variables are stored as comma-separated values, there should be one for each '$' character in the actual text to be displayed.
| Variable | Parameters | Description |
|---|---|---|
| blue | None | Once encountered, starts colouring characters blue. |
| color | None | Once encountered, starts colouring characters white. |
| color! | None | Once encountered, starts colouring characters yellow. Presumably this is meant as the "warning" colour, hence the exclamation mark. |
| gray | None | Once encountered, starts colouring characters grey. |
| green | None | Once encountered, starts colouring characters green. |
| picture | String | Once encountered, draws the specified picture defined in the game's Text Font Picture file. |
| red | None | Once encountered, starts colouring characters red. |
| rgba | Byte, Byte, Byte | Once encountered, starts colouring characters the specified colour. Despite the name, this does not support setting the alpha colour of the text. |
| sound | String | Once encountered, plays the specified sound effect if the Sound Bank containing it is loaded. |
| text | Unknown | Unknown. |
| value | Unknown | Unknown. |
| yellow | None | Once encountered, starts colouring characters yellow. |
$The quick $brown$ fox jumps over the $lazy$ dog.\nPress the $ button to continue.
And the following variables:
sound(all01_a00_sn),rgba(127,51,0),color,red,color,picture(button_a)
The game should first play the sound all01_a00_sn, then draw something akin to the following text:
The quick brown fox jumps over the lazy dog. Press the Ⓐ button to continue.