RPG Data & Rules
Every item, spell, enemy, class, Djinni, summon, and story flag in Golden Sun: The Lost Age is held in dense index-based C tables.
The sequel keeps the same data-driven foundation as The Broken Seal and enlarges almost every table to hold a much larger world. One invariant still governs the whole: derived stats are always recomputed from scratch rather than patched incrementally. Whenever Felix equips a Gaia Blade, sets Echo on standby, or switches Jenna into the front line, one routine recalculates every stat.
This page covers TLA's expanded index tables, the 332-byte fighter record shared across all eight heroes and six battle enemies, item-unlocked classes and multi-element summons, and the 4,096 game flags that track world state and auto-resetting puzzles.
Dense index-based tables
Game structs never embed display names or duplicate static metadata. Every
entity is identified by a dense integer row index defined in include/*_ids.h
(item_ids.h, ability_ids.h, enemy_ids.h, djinn_ids.h, and
include/game/character_ids.h):
ITEM_HEALING_RING(265) reads its stats fromItemDefinitionTable[265]and its display name from offset265past the first item name intext/<lang>.po.- Because ability IDs grow past 255 in TLA,
ClassDefinitionTablewidens learned Psynergy IDs from bytes to 16-bit halfwords.
[ITEM_LONG_SWORD] = {
.price = 200,
.type = ITEM_TYPE_WEAPON,
.equipMask = EQUIP_CHARACTER(ISAAC) | EQUIP_CHARACTER(GARET) | EQUIP_CHARACTER(FELIX) | EQUIP_CHARACTER(PIERS),
.icon = 1,
.attack = 14,
.element = ELEMENT_NONE,
},Unified UNIT records and from-scratch stat recalculation

Every fighter uses the same 332-byte UNIT struct, fetched through
gmUnitGet (which moved into system/system_flags.c in TLA). This covers all 8
playable characters in CharacterUnits and up to 6 active enemies in battle.
Each UNIT holds base stats, effective stats, HP and PP, class, Djinn, learned
Psynergy, status ailments, and 15 packed inventory slots.
Each inventory slot packs the item ID, equipped bit, broken bit, and stack count into one integer, so that passing an item between characters preserves all of its state automatically.
The recalculation invariant (gmUnitCalculate): Derived stats are never
patched incrementally. Whenever equipment, Djinn, levels, or battle buffs
change, gmUnitCalculate discards effective stats and recomputes everything
from scratch using base stats, class multipliers, equipped gear, set Djinn, and
active buffs. That invariant eliminates bonus drift and underlies the Djinn
menu's live-copy preview. Current HP and PP rescale proportionally whenever max
HP or PP changes.
Djinn, classes, item-class series, and summons

- Elemental levels and classes (
gmClassDetermine): Each character starts with 5 innate elemental points in their native element plus +1 per Set Djinni. Jenna and Piers each receive dedicated class series, and carrying the Mysterious Card, Trainer's Whip, or Tomegathericon switches a character into special item-class series. - 72 named Djinn and 29 summons:
DjinnDefinitionTableexpands to 80 slots (20 per element, 72 named, covering both TBS and TLA Djinn).SummonDefinitionTablegrows from 16 single-element summons to 29, adding 13 multi-element summons: Zagan, Megaera, Flora, Moloch, Ulysses, Haures, Coatlicue, Daedalus, Azul, Catastrophe, Charon, Iris, and Eclipse. Fightable field Djinn still spawn on the party side ofUNITslots, so that defeating them plays the kneel pose instead of the dissolve used for monsters.
Eight-member party, levelling, and global rare counters
- Levels, New Game, and Clear Data: Levelling uses 99-level XP tables and growth curves defined every 20 levels. Starting a New Game runs the same level-up loop from level 1 to each character's starting level: Felix, Jenna, and Sheba start at Lv 5, Piers joins at Lv 18 with Spring and Shade, and Isaac's party starts at Lv 28 unless imported from a TBS Clear Data password or link transfer.
- Eight-member roster: Membership is held in party flags
0–7alongside an ordered roster sharing 200 starting coins. The first 4 characters fight in the front line while the remaining 4 wait in reserve. The roster is reordered withLandRon the Status screen, and members are swapped mid-battle with Switch. - Global rare-item counters: Stored in the same object as
ItemDefinitionTable, so that sold artifacts reappear for repurchase in matching town shops and General Stores across Weyard. - Deterministic battle RNG: Shared combat math
(
gmBattleGetElementMultiplierplus damage and heal formulas) serves bothbattle/andmenu/, backed bygmBattleRandomseeded identically across linked consoles.
Game flags and auto-clearing puzzle state

World persistence is held in 4,096 boolean flags (GameFlags). In TLA,
syGameFlag* moved from game/ into system/system_flags.c, wrapping flag
indices modulo 4,096 and adding 8-bit byte and 4-bit nibble counter helpers. As
in TBS, two 256-bit temporary ranges clear themselves automatically:
- 256 scene temp flags clear on every scene entry (for example, Frost pillars).
- 256 area temp flags clear only when entering a different area.
- Battles clear neither range.
Code reference
- Game logic & tables (
games/tla/src/game/): File map, exact row counts across all seven*_table.cfiles,gmMainRoutineRun,gmUnitCalculate,gmClassDetermine, and shared combat math.