Skip to Content
The Alchemy Project

Dialogue, Menus & Shops

Every bordered UI box in Golden Sun: The Lost Age runs on one shared interface system.

Villager dialogue, battle messages, the paginated eight-member field menu, the Pause menu, shops, General Stores, sanctums, inns, and Sunshine's Forge all build on the same window primitives across window/, menu/, and shop/. Because every box shares one renderer and palette, changing Window Color in Settings recolours the entire interface at once.

The whole UI rests on two patterns from The system library. One per-tick event (mnWindowSystemUpdate, or mnWindowSystemUpdateBattle in combat) animates and types into every open window, and every menu or shop counter is a blocking C function running its own sySynch(1) input loop and returning directly to its caller.

Shared 12-window system and context-Huffman text

Slowed-down view of a guest's dialogue box in Daila's inn growing from its centre, typing two pages, and shrinking back to its centre
Slowed-down view of a guest's dialogue box in Daila's inn growing from its centre, typing two pages, 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. Unlike The Broken Seal, which reduced international editions to 8, TLA supports 12 simultaneous windows in all six languages.

Context-Huffman messages, placeholders, and three glyph backends

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

All localised strings are held in games/tla/text/<lang>.po, referenced by symbol (MSGNO(...)) and compressed with 1st-order Markov (context-sensitive) Huffman coding. The cartridge stores a separate Huffman tree for each character, and the character most recently decoded selects the tree used for the next one. Sentences carry named placeholders instead of hardcoded names or prices:

Ah! {actor_name:5}, you're awake!
{argument_actor_name:1} takes {argument_signed_number} damage!

Displaying a message takes two steps:

  1. Decode (mnMessageDecode): Decompresses the full string into a 512-entry ring buffer (textBuf), filling custom character names, typed caller arguments, and European grammar tags for articles, counted nouns, item genders, and capitalisation.
  2. Type and render (window_typing.c): Advances glyphs per tick (or 8 per tick in battle) using proportional widths and pauses at {page_break} and {end_wait}. It draws through three backends: one OAM sprite per glyph for field dialogue, a shared sprite-free tile strip for the battle log, and instant direct-tile painting for static menu labels.

Call-stack 8-member field menus

Felix opens the field menu in Daila, steps across the icons to Status, opens the Status screen, and backs out with B
Felix opens the field menu in Daila, steps across the icons to Status, opens the Status screen, and backs out…

Opening the field menu does not switch gameplay engines. fdEngineRun hides actors, suspends overlay events, and calls the menu directly as a C function. Nested blocking prompts descend on A, return on B, and unwind to the icon row when Start sets the shared unwind flag. Party-only actions run inside the menu, while world-affecting Psynergies (Frost, Lash, Scoop, and so on) record a request in FIELD_STATE and close every window, so that fdEngineRun casts on the field.

To support an eight-member party, selectors paginate 4 characters per page. Status lets L and R reorder the active front four, Item adds L + A sorting and hold-R gear previews, and Djinn adds a 7-topic Select reference screen.

Shops, General Stores, Sunshine's Forge, and saving UI

Felix talks to Daila's shopkeeper across the counter and buys an Herb. Watch the coins window drop from 500 to 490.
Felix talks to Daila's shopkeeper across the counter and buys an Herb
  • Counters are talk scripts: Facing a keeper across a counter triggers the shop, sanctum, inn, or forge C call directly from the NPC's talk script.
  • General Stores and Game Tickets: Alongside Weapon, Armor, and Item shops, TLA adds General Stores, which resell global rare artifacts of every equipment category. Buying feeds a hidden coin-spent tally that awards a Game Ticket each time it passes the next threshold. The award has the appearance of chance but is fully deterministic.
  • Sunshine's Forge (shop_forge.c): Handing Sunshine in Yallam a forgeable stone (such as a Tear Stone, which can roll a Cloud Wand, Spirit Ring, and more) or a rusty weapon rolls its weighted recipe from shop_tables.c at once and saves the result in MainRoutineStateWork. Talking to Yallam's innkeeper across the counter, whether or not the party stays the night, finishes the forge, so that Sunshine's wife sells the finished item.
  • Pause menu and save-lock flags: Pressing Start opens Save, Sleep, and Settings. Two game flags let restricted scenes block saving (Cannot save here or This is no place for that!). Compact save summary headers let the File Screen list all three 12 KB slots without loading full saves.

Code references