Dialogue, Menus & Shops
Every bordered UI box in Golden Sun: The Broken Seal runs on one shared interface system.
Villager dialogue, battle messages, the field menu, the Pause menu, shops,
sanctums, and inns all share the same window primitives spread across window/,
menu/, and shop/. Because every box is drawn by the same code with one
shared palette, changing the Window Color in Settings immediately recolours
everything from Garet's sister's dialogue box to Bilibin's item shop.
The whole interface rests on two patterns from The system library.
One per-tick event (mnWindowSystemUpdate) animates and types into every open
window, and every menu or shop counter is a blocking C function that runs its
own sySynch(1) input loop and returns directly to its caller.
Shared windows and text rendering

A window draws its border and background
fill as tiles on the UI background layer, while owning sprites or tile strips
for its letters, portrait, and cursor hand. Capacity is 12 simultaneous
windows in the Japanese edition (tbs-ja) and 8 in the five international
editions.
Callers create a window and wait inside sySynch(1). Every tick,
mnWindowSystemUpdate steps zoom animations, advances typing across up to 3
active messages, and prepares the UI tilemap for VBlank upload.
Huffman messages, placeholders, and three glyph backends

All localised text is held in games/tbs/text/<lang>.po, referenced by symbol
(MSGNO(...)) and stored Huffman-compressed on the cartridge. Sentences
carry named placeholders instead of hardcoded names or prices:
You guys are so lucky, {actor_name:2}.
{argument_actor_name:1} takes {argument_signed_number} damage!Displaying a message takes two steps:
- Decode (
window_decode.c): Decompresses the full string into a 512-entry 16-bit ring buffer (textBuf), filling in custom character names, typed caller arguments (which each language can reorder freely), and European grammar tags for articles, genders, and capitalisation. - Type and render (
window_typing.c): Advances glyphs per tick using proportional widths and pauses at{page_break}and{end_wait}, choosing from three rendering backends:- Field dialogue: One OAM sprite per glyph, which supports shaking letters at the cost of OAM slots.
- Battle log: Painted into a shared tile strip so it consumes zero sprites.
- Static menu labels: Painted instantaneously, directly into window tiles.
Call-stack field menus

Opening the field menu does not switch gameplay engines. Instead, fdEngineRun
hides field actors, suspends overlay events, and calls the menu as a normal
blocking C function. Each screen (Psynergy, Djinn, Item, and Status) chains
nested blocking prompts. Pressing A calls deeper, B returns up one level,
and Start sets an unwind flag that every prompt treats as B, backing out of
any nesting depth to the icon bar.
One boundary separates what runs where:
- Party-only actions such as healing Psynergy, equipping gear, and swapping Djinn run inside the menu.
- World-affecting actions such as Move, Frost, and Reveal record the caster
and ability in
FieldStateWork, set a field Psynergy request, and unwind the menu sofdEngineRuncasts the spell out on the field.
Shops, sanctums, inns, and saving UI

- Counters are talk scripts: When Isaac faces a keeper across a counter, the NPC's talk script calls the shop, sanctum, or inn function directly and resumes dialogue once it returns. Talking from behind or beside the counter plays ordinary gossip instead.
- One shop, three voices (
shop_stock.c): Weapon, armour, and item shops run identical code with offset dialogue blocks. Rare artifacts share global counters across all towns (RPG Data & Rules). Buying also feeds a hidden coin-spent tally that hands out a Game Ticket each time it crosses the next threshold. It has the appearance of chance, but it is deterministic. - Pause menu and save headers: Pressing
Startopens Save, Sleep, and Settings. Each save slot keeps a compact summary header (leader, area, and play time) so the File Screen can list all three slots without loading full saves.
Code references
- Windows & text (
games/tbs/src/window/): File map,mnWindowSystemUpdate, Huffman decoding, glyph blitting, Pause and save UI, and shared battle and debug screens. - Field menus, intro & credits (
games/tbs/src/menu/): File map, live-copy Djinn preview, the self-playing Flint tutorial,title_intro.c, andcredits.c. - Shops, sanctums & inns (
games/tbs/src/shop/): File map,shop_stock.c, buy, sell, and repair pricing, Game Tickets, sanctums, inns, and the full-pack item picker.