Skip to Content
The Alchemy Project

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

Pause menu and saving UI

The Pause menu in Daila opens Save your quest, selects slot 1, and confirms Your game was saved
The Pause menu in Daila opens Save your quest, selects slot 1, and confirms Your game was saved

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.hParent translation unit #includeing the window_*.c parts below in ROM order
window_windows.c, window_borders.c, window_icons.c, window_sprites.cWindow lifecycle, zoom borders, icons, portraits, and cursor sprites
window_decode.c, window_messages.c, window_typing.c, window_measure.cContext-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.cGlyph blitting, tile-strip text, selectors, shortcuts, and debug window helpers
window_settings_menu.c, screens_save.cPause menu, save-lock flag checks, Settings, Save workflow, and File Screen summaries
screens.c, screens_internal.h, screens_battle_*.cShared 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.cParty 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_*.sFast 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*.pngEuropean grammar tables, text speeds, localised keyboards, progress bars, and stubs.s

Source files

src/window/

FileDescription
articles.cWindow text tables: each edition's articles and possessives, the kana marks and the sprite motion curves.
counted_nouns.cThe German counted nouns, singular and plural, by kind.
debug_labels.cThe debug screens' labels: the flag and destination browsers' colon and hex digits, and the icon browser's headings (mnDebugBrowserIcons).
debug_tables.cThe debug menus' tables: the warp menu's presets and the abilities the shortcut grid offers.
expand_nibble_table.cThe colour map of the page number tiles, built twice from the UI's digits, and the link battle timer's label.
fixed_tile_blocks.cThe window sprites' fixed tile blocks.
glyph_arm.cThe 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.cThe 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.cThe 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.cThe message speed tables, indexed by the player's message speed setting (MainRoutineStateWork.msgSpeed, MESSAGE_SPEED).
progress_bar_rows.cThe 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.cSprite 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.cThe 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.cThe 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.cThe row of command icons the player picks a command from.
screens_battle_djinn_menu.cThe battle Djinn menu.
screens_battle_djinn_preview.cThe preview of what setting or removing a Djinni changes.
screens_battle_item_menu.cThe battle item menu.
screens_battle_party_commands.cAn ability classified for target selection, and a reserve member chosen for a party slot.
screens_battle_psynergy_menu.cThe battle Psynergy menu.
screens_battle_status.cThe 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.cThe battle summon menu.
screens_battle_targets.cChoosing a battle target.
screens_debug.cThe debug destination menu, the flag browser, the Pause menu's choices, and the debug browsers of icons and portraits.
screens_icon_menu.cCollecting 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.hWhat every part of the screens object shares: its includes, macros, local types and tables.
screens_joined.cThe 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.cThe link battle timer and the no-flee check.
screens_menu_titles.cPictures and command icons loaded for the menus, and BG1's priority.
screens_name_entry.cThe 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.cThe party status window.
screens_save.cSave files, the file list and the saving screen's progress bar.
screens_set_text_tile_rect.cSwitching a rectangle of a window's text to another palette.
screens_window_sprites.cThe sprites a window carries (icons, cursors and the speakers' portraits), and the window spans the screen transition reads.
status_tables.cThe Status screen's tables: its cursor stops and its labels.
text_tables.cThe text's tables: each glyph's width, the text colours' pens, and the party status's divider columns.
window.cThe 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.cWindow zoom and borders, and opening and waiting on message windows.
window_debug.cThe 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.cThe 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.cCharacters drawn into a glyph sprite's tiles, strings measured and drawn into windows, and numbers written as text.
window_icons.cThe 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.hWhat the parts of the window object share: their includes, the codes of decoded message text and the sizes several parts read.
window_measure.cSizing windows to their text and fitting them on the screen.
window_messages.cMessages 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.cThe 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.cThe 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.cThe window that shows the area's name, and removing an item from the party's inventory.
window_spans.cThe 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.cCharacters 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.cText 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.cThe per-tick message update: typing text and running its control codes.
window_windows.cThe window system's setup and tilemap upload, the pool of window sprites, opening and closing windows, and starting a message typing into one.

include/window/

FileDescription
articles.hThe 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.hThe Status screen's cursors and labels, and the party status window's flags.
cursor.hThe cursor that approaches its target, shared by shops, the name entry screen, the settings menu and the file screen's sprites.
djinn_preview.hThe Djinn preview's stat arrow tiles.
glyph_arm.hThe text canvas renderer, run from RAM as ARM code (glyph_arm.c).
icon_menu.hThe 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.hThe battle menus' shared state, and the sprite shapes the menus queue.
message_reader.hFinding a message in the game's compressed text.
message_speed.hThe message speed setting and the typing tables it picks a row of (message_speed.c).
scales.hThe 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.hThe 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.hThe selection screen: the row of icons a command, item or Psynergy is picked from, its icons and their sprites.
settings_menu.hThe settings menu's state, which the Pause menu and the debug menus also use, and the sound test's starting values.
stubs.hThe stub calls into the window module, as the other modules' code calls them.
text_font.hThe Japanese font's kanji, and the voiced marks drawn over its kana.
window.hWindows, 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.hSprites as OAM takes them, and the window sprites: the characters, icons and portraits a window carries.