Skip to Content
The Alchemy Project

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

Slowed-down view of a dialogue box in Vale growing from its centre to full size, displaying text, and shrinking back to its centre on close
Slowed-down view of a dialogue box in Vale growing from its centre to full size, displaying text, and…

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

Isaac asks Bilibin's innkeeper for a room; the night's price is dynamically filled into the sentence beside Yes/No and Your Coins
Isaac asks Bilibin's innkeeper for a room; the night's price is dynamically filled into the sentence beside…

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:

  1. 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.
  2. 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

Isaac opens the field menu in Vale, steps from Psynergy to Item to Status, browses Status pages, and backs out
Isaac opens the field menu in Vale, steps from Psynergy to Item to Status, browses Status pages, and backs out

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 so fdEngineRun casts the spell out on the field.

Shops, sanctums, inns, and saving UI

Isaac talks to Bilibin's item shopkeeper across the counter and buys an Herb. Watch the coins window drop from 500 to 490.
Isaac talks to Bilibin's item shopkeeper across the counter and buys an Herb
  • 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 Start opens 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