Skip to Content
The Alchemy Project

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 from ItemDefinitionTable[265] and its display name from offset 265 past the first item name in text/<lang>.po.
  • Because ability IDs grow past 255 in TLA, ClassDefinitionTable widens 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

Felix opens the Status screen in Daila: watch his class, derived stats, Echo set on him, and elemental levels update together from one UNIT record
Felix opens the Status screen in Daila: watch his class, derived stats, Echo set on him, and elemental levels…

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

Felix opens the Djinn screen and puts Echo on standby: watch the stat arrows preview his exact recalculated HP, PP, and Attack before Is this OK? confirms
Felix opens the Djinn screen and puts Echo on standby: watch the stat arrows preview his exact recalculated…
  • 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: DjinnDefinitionTable expands to 80 slots (20 per element, 72 named, covering both TBS and TLA Djinn). SummonDefinitionTable grows 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 of UNIT slots, 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–7 alongside 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 with L and R on 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 (gmBattleGetElementMultiplier plus damage and heal formulas) serves both battle/ and menu/, backed by gmBattleRandom seeded identically across linked consoles.

Game flags and auto-clearing puzzle state

In Mikasalla, Felix collects the Mars Djinni Spark; watch the room reload afterward with Spark gone because its game flag is now set
In Mikasalla, Felix collects the Mars Djinni Spark; watch the room reload afterward with Spark gone because…

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