Battle & Effects
The battle engine runs every fight in Golden Sun: The Lost Age through one turn-and-action pipeline decoupled from its 2D and 3D visual effects.
Random encounters on land and sea, Mimics, story bosses, superbosses such as
Dullahan, and Battle Arena matches all run through btRun in battle/. The
sequel scales The Broken Seal's combat engine up to an eight-member roster, 660
enemy formations, multi-action enemies, and a software 3D polygon rasteriser in
battle_effect/ that renders textured models directly in IWRAM.
This page follows a fight from formation spawning and reserve switching through two-phase enemy AI, the action pipeline, the hand-off between 2D and 3D spell animations and hit playback, and zoomed battlefield backdrops.
Entering a battle, formations, and 8-member Switch

Random encounters, Mimics, and story scripts all trigger battle in the same way.
They write a formation ID (Formations,
660 rows) into MainRoutineStateWork, snapshot field actors into
SnapshotObjects, request ENGINE_BATTLE, and return to gmMainRoutineRun.
Formations spawn up to 6 screen slots (large enemies take two slots) into
the same 332-byte UNIT struct as party members. Up to 4 heroes fight in the
front row while up to 4 wait in reserve. The Switch command swaps front and
back members mid-turn, and if the entire front row falls, living reserves take
their place automatically and the fight continues.
Turn loop, two-phase & multi-action AI, and the action pipeline

Each turn collects commands (with select bosses and monsters acting multiple times per turn), sorts by Agility and priority, and checks for victory or defeat after every action. As in The Broken Seal, enemies choose twice. An enemy's turn-start choice counts only if it decides to guard or flee. Otherwise, the AI chooses again at execution time, so that it never spends an attack on a target that has already fallen.
- Build (
battle_action.c):btActionRunBuilddecides final targets, dead-target redirection, spread decay, dodges, critical hits, and weapon unleashes in advance. - Stage (
battle_staging.c):btStagingDispatchActionanimates camera motion, attacker movement, and cast glow, installsbtPlaybackRunon the tick pass, and launches the foreground battle effect. - Impact and resolution (
battle_playback.c,battle_ability.c): At the impact tick, the battle effect signalsbtPlaybackStart().btPlaybackRunresolves each target viabtAbilityApplyToTarget(applying HP and status math immediately and queueing reactions viabtPlaybackPush) and drains flinches, damage numbers, and combat log entries while the effect finishes.
Decoupled battle effects, the playback queue, and 3D models

- 2D brightness canvas and 3D IWRAM rasteriser (
battle_effect/): Every battle effect is foreground blocking C that paints onto a 128×128 6-bit brightness canvas with palette ramps, VBlank trail decay, blitters, and particle motes. In TLA, effects can also draw software-rasterised 3D polygon models (btRenderDrawModelListin IWRAM), a capability absent from TBS, with perspective projection, textured and shaded faces, and depth sorting. That renderer draws summons such as Zagan, Coatlicue, Catastrophe, Charon, and Iris. - Concurrent playback queue (
battle_playback.c): At the impact frame, the battle effect callsbtPlaybackStart(). The call releases a tick-pass event that resolves targets and drains hit shakes, HP drops, damage lines, and enemy dissolves concurrently while the spell animation finishes.
Zoomed backgrounds, spoils, and per-action link battles

- Zoomed two-half backgrounds: 82 battle backdrops scale smoothly on the GBA's single affine background layer via HBlank DMA as the camera orbits.
- Spoils and link battles: Victory gives 100% XP to surviving front-row
fighters and 50% to conscious reserves, alongside coins and drops. Link-cable
Battle Arena matches keep both consoles in lockstep by synchronising
deterministic
gmBattleRandomturns per action.
Code references
- Battle engine (
games/tla/src/battle/): File map, eight-member Switch and reserve swap-in, multi-action enemy AI, weapon unleashes, action, staging, ability, and playback modules, zoomed backgrounds, spoils, and link battles. - Battle effects (
games/tla/src/battle_effect/): The 128×128 brightness canvas, blitters, motes, 29 summons (25 dedicated handlers), and TLA's IWRAM 3D software polygon rasteriser.