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

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

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:
- 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. - 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

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

- 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 fromshop_tables.cat once and saves the result inMainRoutineStateWork. 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
Startopens Save, Sleep, and Settings. Two game flags let restricted scenes block saving (Cannot save hereorThis 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
- Windows & text (
games/tla/src/window/): File map, 12-window system,mnWindowSystemUpdateBattle, context-Huffman decoding, Pause and save UI, and shared battle and debug screens. - Field menus, intro & credits (
games/tla/src/menu/): File map, eight-member pagination and shortcuts, live-copy Djinn preview, the Echo tutorial,title_intro.c, andcredits.c(prologue crawl and ending scroll). - Shops, sanctums, inns & forge (
games/tla/src/shop/): File map,shop_tables.c, General Stores, pricing and Game Tickets, sanctums, inns,shop_forge.c, and the item picker (reused by Naribwe's fortune teller).