Windows & Text
This page is a guide to the games/tbs/src/window/ folder of the Alchemy
project. Its code draws every dialogue box, proportional text line, save menu,
and shared battle or debug screen in Golden Sun: The Broken Seal.
At its core is the window system in mnWindowSystemUpdate, paired with a
Huffman message decoder and a proportional text typer. It also builds the Pause
and Save screens, character name entry, shared battle command menus, and the
debug overlays used across the game's engines.
Whenever a villager's portrait slides up beside a zooming border and text types out letter by letter, this code does the work without stalling the game loop. The sections below cover the decoding and typing mechanics, the Pause and Save UI, and a full file map. The conceptual architecture is described in Dialogue, Menus & Shops.
How it works, and decoding

- Window capacity (
window_windows.c):WINDOW_COUNTis 12 intbs-jaand 8 in international editions.mnWindowSystemUpdatesteps border zooms, advances up to 3 active messages per tick, and queues the tilemap without ever callingsySynch(). - Message decoding (
window_decode.c,message_decode.s): Unpacks Huffman strings fromtextinto a 512-entry 16-bit ring buffer (textBuf). As it decodes, it resolves state blanks ({actor_name:2}), reorderable typed arguments ({argument_signed_number}), and European grammar metadata (articles.c,counted_nouns.c,item_genders.c) while passing control codes ({page_break},{end_wait}) to the typer. - Typing and rendering (
window_typing.c,window_measure.c,glyph_arm.c): Justifies lines against proportional widths from Graphics Assets, rendering through OAM sprites on the field, a shared sprite-free tile strip in battle, or instant direct-tile blits in menus.
Pause menu and saving UI

window_settings_menu.c implements Save, Sleep, and global Settings (every box
shares one palette). screens_save.c drives Save and the File Screen slot list
from compact summary headers without reading full save slots (see
System library for flash write
safety).
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 | Huffman decoding, message queue, per-tick typing, and right-edge justification |
window_glyphs.c, window_text_tiles.c, window_selection.c, window_shortcuts.c | Glyph blitting, tile-strip text, list selectors, and shortcut bindings |
window_settings_menu.c, screens_save.c | Pause menu settings, Sleep, Save workflow, and File Screen summaries |
screens.c, screens_internal.h, screens_battle_*.c | Shared battle menus (command row, Psynergy, Djinn, Item, Summon, target cursor, and status) |
screens_party_status.c, screens_name_entry.c, screens_icon_menu.c, screens_debug.c | Party status panel, name entry, icon menus, joined and link timers, and debug windows |
message_decode.s, glyph_arm.c, decompress_4bpp.s, expand_opaque.s | Fast ARM assembly Huffman decoding and 1bpp-to-4bpp glyph blitting |
articles.c, counted_nouns.c, item_genders.c, message_speed.c, keyboard*.tsv | European grammar tables, message speeds, debug labels, name-entry keyboards, 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. |
expand_nibble_table.c | The colour map mnGraphicsExpandVRAMTilesByColorTable draws the UI's digits through, and the link battle timer's heading. |
file_list_sprites.c | The four Djinn sprites the File Screen shows in a row. |
fixed_tile_blocks.c | The window sprites' fixed tile blocks. |
glyph_arm.c | The text canvas renderer, which runs as ARM code from a copy in RAM: mnGlyphDraw copies it into RAM for each call (RAM_CODE_LOAD), into IWRAM when the copy fits: its 32-bit bus fetches an ARM instruction in one read, where the cartridge's 16-bit bus takes two. |
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, by item id, in the German and Italian releases (ITEM_GENDER), which picks the possessive a message writes before the item. |
message_speed.c | The message speed tables, indexed by the player's message speed setting (MainRoutineStateWork.msgSpeed, MESSAGE_SPEED). |
scales.c | Sprite scales, motion curves and lookup tables of the window and menu code. |
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, and the window sprites' motions. |
screens.c | The menu object of the window module: the screens built on the window system (window.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 | Collecting the party's battle commands. |
screens_battle_psynergy_menu.c | The battle Psynergy menu. |
screens_battle_status.c | The battle's Status screen, which the Status command opens. |
screens_battle_summon_menu.c | The battle summon menu. |
screens_battle_targets.c | Choosing a battle target. |
screens_debug.c | The debug menus (scenes, flags, icon browsers) and the Pause menu's choices. |
screens_icon_menu.c | The command icon menus of the field, title and transfer screens. |
screens_internal.h | What every part of the menu object shares: its includes, edition values, macros and the link turn state. |
screens_joined.c | The Colosso choice and the joined-party messages. |
screens_link_timer.c | The link battle timer and the no-flee check. |
screens_menu_titles.c | The pictures the menus show: the headings and command icons, with their bob and pulse, the range icons of the battle lists, the page arrows, icons and portraits loaded into the VRAM cache, the link battle timer's window, and the battle command row's icons on BG1 with its priority. |
screens_name_entry.c | The name entry screen. |
screens_party_status.c | The party status window. |
screens_save.c | Saving, loading, copying and erasing the three save files, and the file list the player picks one from: for the file under the cursor, its summary, its party and its Djinn, in that file's own window colours. |
screens_window_sprites.c | The sprites that sit on windows: item, Psynergy and command icons and the speakers' portraits beside their messages. |
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 UI windows drawn into a shared BG tilemap, the messages that type text into them, the message decoder and the formatting behind it, the sprites (window sprites) that windows carry, icons, the selection screen and the option and pause menus. |
window_borders.c | Window zoom and borders, and opening and waiting on message windows. |
window_decode.c | The message decoder: articles, names and numbers written out. |
window_glyphs.c | Characters rendered into tiles, string widths and number formatting. |
window_icons.c | Item, Psynergy and command icons. |
window_internal.h | What every part of the window object shares: its includes, edition values, macros and the codes of decoded text. |
window_measure.c | Sizing windows to their text and fitting them on the screen. |
window_messages.c | Message strings and arguments, symbol decoding and portrait windows. |
window_selection.c | The selection screen: a row of icons along the bottom of the screen with the name of the one under the cursor in a window above it, arrows at its ends when the list runs past them, the icons already chosen gathered at the top left, and in battle the spinning cursor over the target. |
window_settings_menu.c | Window colours, the settings menu and the Pause menu. |
window_shortcuts.c | The area name shown on entering an area, the debug Psynergy shortcut picker and the unused selection state. |
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, and the per-tick sprite update. |
window_text_tiles.c | Text drawn as tiles, text tile ownership and divider lines. |
window_typing.c | The per-tick message update: typing text and running its control codes. |
window_windows.c | The window sprite pool, opening and closing windows, starting messages. |
| 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 the party status window's flags. |
cursor.h | The cursor that approaches its target, shared by shops, the name entry screen and the settings menu. |
djinn_preview.h | The Djinn preview's sprites and arrow tiles. |
glyph_arm.h | The ARM functions copied to RAM to run: a character drawn into a text window's canvas, and the screen transition's window edges read from the windows' borders (window/glyph_arm.c). |
icon_menu.h | The icon menu's entries and state. |
menu_list.h | The menus' sprites and cursors, the party status window's layout, and the battle command menus' state, with its remembered page and row. |
message_reader.h | MESSAGE_READER, a cursor through message text. |
message_speed.h | The message speed setting and how fast each speed types a message. |
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 functions of window/screens.c and its parts: window sprites and portraits, the party status window, the file list and saving, name entry, the joined-party messages, the battle menus, the icon menus and the debug menus. |
select.h | The selection screen's sprites and nodes. |
settings_menu.h | The state of the settings menu and the Pause menu. |
stubs.h | The window module's stub calls: windows, text and portraits, the menus and screens built from them (Pause menu, File Screen, Yes/No), and the debug selectors. |
text_font.h | The kanji glyphs and the text marks drawn with characters. |
window.h | Windows, the messages that type into them, and the window renderer's state. |
window_sprite.h | Sprites as the windows draw them: a sprite's OAM attributes, and the lists of characters, icons and portraits each window shows as sprites. |