RPG Data & Rules
Every item, spell, enemy, class, Djinni, and story flag in Golden Sun: The Broken Seal is held in dense index-based C tables.
Rather than scattering game stats across objects or scripts, Camelot keeps every rule in plain C arrays and ties them together with one invariant: derived stats are always recomputed from scratch instead of patched in place. When Isaac equips a new sword, sets Flint on standby, or is poisoned in Goma Cave, one function rebuilds every effective number on the character.
This page describes how those tables link to localised text, how every hero and enemy shares the same 332-byte fighter record, how Djinn derive classes, and how two slices of the 4,096 game flags clear themselves for dungeon puzzles.
Dense index-based tables
Game structs never embed display names or copy static metadata around. Every
entity has 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). That single number indexes both its stats table
and its localised name catalogue:
ITEM_HEALING_RING(265) takes its stats fromItemDefinitionTable[265]and its display name from offset265past the first item name intext/<lang>.po.ABILITY_*,ENEMY_*,CLASS_*,DJINN_*, andSUMMON_*all follow the same rule.
[ITEM_LONG_SWORD] = {
.price = 200,
.type = ITEM_TYPE_WEAPON,
.equipMask = EQUIP_CHARACTER(ISAAC) | EQUIP_CHARACTER(GARET) | EQUIP_CHARACTER(FELIX),
.icon = 1,
.attack = 14,
.element = ELEMENT_NONE,
},Every item, ability, enemy, class, and Djinni definition is held in its
corresponding games/tbs/src/game/*_table.c file
(Codebase Map).
Unified UNIT records and from-scratch stat recalculation

Every fighter uses the same 332-byte UNIT struct, fetched through
gmUnitGet. That covers both the 4 playable characters in
MainRoutineStateWork and up to 5 active enemies in battle. Each UNIT stores
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 a single integer. Handing an item to another party member or dropping it moves its entire state in one copy.
The recalculation invariant (gmUnitCalculate): Derived stats are never
patched incrementally when gear, Djinn, buffs, or levels change. Instead,
gmUnitCalculate wipes effective stats and recomputes everything from scratch
using five inputs:
- Base stats (level growth curves plus stat-boosting items).
- Class multipliers (derived from current elemental levels).
- Equipped weapons, armour, and rings.
- Set Djinn bonuses.
- Active battle buffs.
Current HP and PP rescale proportionally whenever max HP or PP changes. That
single rule makes stat drift impossible. It also lets the Djinn menu show an
exact live preview: it clones the UNIT, applies the real change to the clone,
runs gmUnitCalculate, draws the stat arrows, and discards the clone if the
change is cancelled (Dialogue, Menus & Shops).
Djinn, elemental levels, and class derivation

Every playable character starts with 5 innate elemental points in their native element: Venus for Isaac, Mars for Garet, Jupiter for Ivan, and Mercury for Mia. Each Set Djinni adds +1 point to its element.
Whenever Djinn change, gmClassDetermine reads the character's four element
levels and picks the matching class series and highest eligible tier from
ClassDefinitionTable. That class supplies stat multipliers and learned
Psynergy. 28 named Djinn (7 per element) fuel 16 single-element summons
(4 tiers across 4 elements). When the party fights a wild field Djinni, the game
places it on the party side of UNIT slots so defeating it plays the party
kneel pose and "goes down!" instead of an enemy dissolve animation.
Levelling, party roster, and global rare counters
- Levels and New Game: Levelling uses 99-level XP tables and growth curves defined at 20-level anchor points. Starting a New Game runs the same level-up loop from level 1 to each character's starting level. That is why future party members such as Mia already have their starting stats rolled the moment a new file is started.
- Party and coins: Membership is tracked in party flags
0–7alongside an ordered active roster sharing one coin purse (200 starting coins).character_ids.handcharacter_table.calready allocate slots for all eight GBA characters, including Felix, Jenna, Sheba, and Piers from The Lost Age. - Global rare-item counters: Artifacts sold to shops increment global per-item counters rather than per-shop inventories. Selling a rare weapon in Vault immediately makes it available under Artifacts in any matching weapon shop across Weyard.
- Deterministic battle RNG: Shared combat math
(
gmBattleGetElementMultiplierplus damage and heal formulas) serves both battles and field healing. It uses a dedicated battle PRNG (gmBattleRandom) seeded identically on both consoles for link-cable PvP.
Game flags and auto-clearing puzzle state

World persistence is held in 4,096 boolean flags (GameFlags), accessed
through syGameFlag* in game/game_flags.c. Two special 256-bit slices clear
themselves automatically so dungeon puzzles need no manual reset scripts:
- Scene temp flags (256 bits): Cleared automatically on every scene load. These fit single-room puzzles like rolling a log into Kolima Forest's river.
- Area temp flags (256 bits): Cleared only when entering a different area. A pushed pillar in Vale stays pushed while Isaac steps inside houses and resets only when he walks back onto the World Map.
- Battles clear neither range: Fighting a random encounter never resets the puzzle in progress.
Code reference
- Game logic & tables (
games/tbs/src/game/): File map, exact row counts for all seven*_table.cfiles,gmMainRoutineRun,gmUnitCalculate,gmClassDetermine,syGameFlag*, and combat math.