Windows & Text
This page is a guide to the games/tla/src/window/ folder of the Alchemy
project. Every text box, dialogue line, Pause screen, Save menu, and battle
command window in Golden Sun: The Lost Age is drawn by its code.
Whenever a villager talks in Daila, a damage line scrolls in combat, or Start is
pressed to save the quest, this 12-window system handles box zooms,
context-Huffman message decoding (mnMessageDecode), and proportional text
typing. Unlike The Broken Seal, The Lost Age keeps all 12 windows active across
every language edition.
The sections below cover the window event hooks, context-Huffman decoding, text rendering backends, the Pause and Save UI, and a file map of shared battle and debug screens. The conceptual architecture is described in Dialogue, Menus & Shops.
How it works, and context-Huffman decoding
- 12 windows across all editions (
window_borders.c):WINDOW_COUNT = 12holds across all six language editions.mnWindowSystemUpdateanimates borders and types dialogue on the field without callingsySynch(). - Battle window event (
mnWindowSystemUpdateBattle): WhileRamHeapSlots->battleMenuState != 0, this callback runsmnWindowUpdateZooms(),mnMessageUpdateAll(), andmnWindowSpriteUpdateAll(). Otherwise, it runsmnMessageUpdateAll()alone at 8 characters per tick. - Context-Huffman decoding (
mnMessageDecodeinwindow_decode.c): Unpacks first-order Markov Huffman strings fromtext(one Huffman tree per preceding character) into a 512-entry 16-bit ring buffer (textBuf). As it decodes, it expands custom names, reorderable typed arguments, and European grammar metadata (articles.c,counted_nouns.c,item_genders.c) while leaving{page_break}and{end_wait}for the typer. - Typing and glyphs (
window_typing.c,mnTextMeasureDecoded): Justifies lines against proportional glyph widths from Graphics Assets. Text renders through OAM sprites on the field, a shared tile strip in battle, or instant direct-tile blits in menus.
Pause menu and saving UI

window_settings_menu.c implements the Pause menu (Save, Sleep, and Settings),
with every box sharing one palette. Two game flags let restricted scenes block
saving (Cannot save here or This is no place for that!). screens_save.c
lists all three slots from compact summary headers without reading full 12 KB
save slots (flash write safety is covered in
System library).
File map
| File(s) | Role |
|---|---|
window.c, window_internal.h | Parent translation unit #includeing the window_*.c parts below in ROM order |
window_windows.c, window_borders.c, window_icons.c, window_sprites.c | Window lifecycle, zoom borders, icons, portraits, and cursor sprites |
window_decode.c, window_messages.c, window_typing.c, window_measure.c | Context-Huffman decoding, message queue, per-tick typing, and line measurement |
window_glyphs.c, window_text_tiles.c, window_selection.c, window_shortcuts.c, window_debug.c | Glyph blitting, tile-strip text, selectors, shortcuts, and debug window helpers |
window_settings_menu.c, screens_save.c | Pause menu, save-lock flag checks, Settings, Save workflow, and File Screen summaries |
screens.c, screens_internal.h, screens_battle_*.c | Shared battle menus (command row, Psynergy, Djinn, Item, Summon, preview, reserves, and more) |
screens_party_status.c, screens_name_entry.c, screens_icon_menu.c, screens_debug.c | Party status, name entry, icon menus, joined and link timers, and scene and flag debug editors |
message_decode.s, glyph_arm.c, window_spans.c, decompress_4bpp.s, expand_*.s | Fast ARM and assembly Huffman decoding, span drawing, and 1bpp-to-4bpp glyph blitting |
articles.c, counted_nouns.c, item_genders.c, message_speed.c, keyboard*.tsv, progress*.png | European grammar tables, text speeds, localised keyboards, progress bars, and stubs.s |
Source files
| File | Description |
|---|---|
articles.c | Window text tables: each edition's articles and possessives, the kana marks and the sprite motion curves. |
counted_nouns.c | The German counted nouns, singular and plural, by kind. |
debug_labels.c | The debug screens' labels: the flag and destination browsers' colon and hex digits, and the icon browser's headings (mnDebugBrowserIcons). |
debug_tables.c | The debug menus' tables: the warp menu's presets and the abilities the shortcut grid offers. |
expand_nibble_table.c | The colour map of the page number tiles, built twice from the UI's digits, and the link battle timer's label. |
fixed_tile_blocks.c | The window sprites' fixed tile blocks. |
glyph_arm.c | The text canvas renderer, compiled as ARM code and copied to RAM to run, entered in Thumb through mnGlyphDrawCode (glyph_arm_entries.s). |
icon_menu_tables.c | The Djinn menu's element icon offsets and the icon menus' tables: the waits of a choice made for the player to watch, and the field menu's and the File Screen's choices by icon position. |
item_genders.c | The grammatical gender of each item's name in the German and Italian releases, which picks the possessive ("your") a message writes before the item (LocalizedWordItemPossessives): "dein" or "deine" in German, "Il tuo" or "la tua" in Italian. |
message_speed.c | The message speed tables, indexed by the player's message speed setting (MainRoutineStateWork.msgSpeed, MESSAGE_SPEED). |
progress_bar_rows.c | The saving screen's progress bar, laid out by step: its own file, between the progress bar's tiles and the word-aligned tables after it. |
scales.c | Sprite scales, motion curves and lookup tables of the window and menu code, the sound test's labels and the debug warps' names; The Broken Seal's scales.c. |
screen_tables.c | The screens' tables from the save summary's level label to the range icons' patterns: the name entry's marks and labels, the Djinn and party sprites, the summons' abilities and the window sprites' motions. |
screens.c | The screens object: the screens built on the windows, from the window sprites, the party status window and the file list to the battle menus, the icon menus and the Pause menu, as in The Broken Seal's screens.c. |
screens_battle_command_row.c | The row of command icons the player picks a command from. |
screens_battle_djinn_menu.c | The battle Djinn menu. |
screens_battle_djinn_preview.c | The preview of what setting or removing a Djinni changes. |
screens_battle_item_menu.c | The battle item menu. |
screens_battle_party_commands.c | An ability classified for target selection, and a reserve member chosen for a party slot. |
screens_battle_psynergy_menu.c | The battle Psynergy menu. |
screens_battle_status.c | The Status screen of a battle: a party member's stats and conditions, Psynergy, Djinn and items, on four pages that A turns. |
screens_battle_summon_menu.c | The battle summon menu. |
screens_battle_targets.c | Choosing a battle target. |
screens_debug.c | The debug destination menu, the flag browser, the Pause menu's choices, and the debug browsers of icons and portraits. |
screens_icon_menu.c | Collecting the party's battle commands, then the icon menus: a row of command icons with a label window, the selected icon pulsing, as the field menu, the File Screen, the transfer screens, the shops, the sanctums, Yes or No and Coins or Lucky Medals use it. |
screens_internal.h | What every part of the screens object shares: its includes, macros, local types and tables. |
screens_joined.c | The messages that a Djinni or a party member has joined, and that a summon can now be used, each shown with the join jingle. |
screens_link_timer.c | The link battle timer and the no-flee check. |
screens_menu_titles.c | Pictures and command icons loaded for the menus, and BG1's priority. |
screens_name_entry.c | The name entry screen, where the player names a party member on a keyboard of letters, with a DEL key that takes back the last letter and an END key that keeps the name. |
screens_party_status.c | The party status window. |
screens_save.c | Save files, the file list and the saving screen's progress bar. |
screens_set_text_tile_rect.c | Switching a rectangle of a window's text to another palette. |
screens_window_sprites.c | The sprites a window carries (icons, cursors and the speakers' portraits), and the window spans the screen transition reads. |
status_tables.c | The Status screen's tables: its cursor stops and its labels. |
text_tables.c | The text's tables: each glyph's width, the text colours' pens, and the party status's divider columns. |
window.c | The window object: the windows drawn into a shared BG tilemap, the messages typed into them and the decoder behind them, the sprites windows carry, icons, the selection screen, the settings and Pause menus, the debug menus and text drawn as tiles. |
window_borders.c | Window zoom and borders, and opening and waiting on message windows. |
window_debug.c | The debug menus, none of which the game opens: the sound test, a debug menu of five rows ("Full PP and Money" to "Change of hero"), the warp menu's nine story presets, and the grid of field Psynergy to set as a shortcut. |
window_decode.c | The message decoder: a stored message expanded into the ring of decoded text, its arguments, names and numbers written out, and outside Japanese the articles, plurals and possessives each language puts around them. |
window_glyphs.c | Characters drawn into a glyph sprite's tiles, strings measured and drawn into windows, and numbers written as text. |
window_icons.c | The 16x16 icons of items, Psynergy and commands, built from their pictures, a tick under them and the marks over them, and the 32x32 icons and portraits loaded with their colours. |
window_internal.h | What the parts of the window object share: their includes, the codes of decoded message text and the sizes several parts read. |
window_measure.c | Sizing windows to their text and fitting them on the screen. |
window_messages.c | Messages copied out as strings, the message arguments, closing windows, a message's flash, the story crawl's text, the symbol decoder and the portrait windows. |
window_selection.c | The selection screen, the row of icons a command, item or Psynergy is picked from in battle and on the field, and the field menu. |
window_settings_menu.c | The window colours the player picks, the settings menu that picks them with the message speed, speech and auto-sleep, and the Pause menu. |
window_shortcuts.c | The window that shows the area's name, and removing an item from the party's inventory. |
window_spans.c | The windows' outline for a screen transition: for each scan line, the left and right edge of the windows on it, read off the UI tilemap by ARM code that mnScanlineWindowFillSpans copies into RAM for each call. |
window_sprites.c | Characters drawn into windows, as glyph sprites, into a text canvas or as tilemap tiles, and the per-tick update that moves and shows the sprites windows carry. |
window_text_tiles.c | Text drawn as tilemap tiles of its own (the menus' labels, names and numbers), the text tiles taken and freed, divider lines, and the functions that draw a message, string or number into a window. |
window_typing.c | The per-tick message update: typing text and running its control codes. |
window_windows.c | The window system's setup and tilemap upload, the pool of window sprites, opening and closing windows, and starting a message typing into one. |
| File | Description |
|---|---|
articles.h | The words messages put before and after a name in each edition (articles, possessives, the German counted nouns), the kana marks and the window sprites' motion curves (window/articles.c). |
battle_status.h | The Status screen's cursors and labels, and the party status window's flags. |
cursor.h | The cursor that approaches its target, shared by shops, the name entry screen, the settings menu and the file screen's sprites. |
djinn_preview.h | The Djinn preview's stat arrow tiles. |
glyph_arm.h | The text canvas renderer, run from RAM as ARM code (glyph_arm.c). |
icon_menu.h | The icon menu's state: the row of command icons the field menu, the File Screen, the shops and the Yes/No menu are chosen from. |
menu_list.h | The battle menus' shared state, and the sprite shapes the menus queue. |
message_reader.h | Finding a message in the game's compressed text. |
message_speed.h | The message speed setting and the typing tables it picks a row of (message_speed.c). |
scales.h | The window sprites' and cursors' motion curves, the window colour wheel, the settings and Pause menus' icons and colour presets, and the speakers' portraits (window/scales.c). |
screens.h | The screens object's functions and tables that code outside it uses: the Status screen's cursor stops, the file list and File Screen choices, the battle menus, the menu headings and the Yes/No menu. |
select.h | The selection screen: the row of icons a command, item or Psynergy is picked from, its icons and their sprites. |
settings_menu.h | The settings menu's state, which the Pause menu and the debug menus also use, and the sound test's starting values. |
stubs.h | The stub calls into the window module, as the other modules' code calls them. |
text_font.h | The Japanese font's kanji, and the voiced marks drawn over its kana. |
window.h | Windows, the messages that type into them, and the window system's state, as window.c declares them for the files that use them. |
window_sprite.h | Sprites as OAM takes them, and the window sprites: the characters, icons and portraits a window carries. |