Skip to Content
The Alchemy Project

Battle Effects

This page is a guide to the games/tbs/src/battle_effect/ folder of the Alchemy project, where every weapon slash, Psynergy blast, Djinni prelude, and summon animation in Golden Sun: The Broken Seal lives as a self-contained visual effect.

Each animation is a blocking C handler that paints onto a 128×128 brightness canvas. None of these handlers decide combat math, damage numbers, or hit checks. They draw the animation on screen and call btPlaybackStart at the exact impact tick so that the battle engine can resolve the hit.

When a party member casts Fire, calls down Bolt, or unleashes a sword in battle, the code in this folder lights the darkened arena. The sections below cover ability dispatch, palette ramps, glowing trails, assembly blitters, unused effects, and the file map. How effects stay decoupled from combat rules is described in Battle & Effects.

Dispatch, variants, and the 128×128 brightness canvas

Garet casts Heat Wave at Mia: an additive brightness canvas makes fire glow across the darkened battlefield
Garet casts Heat Wave at Mia: an additive brightness canvas makes fire glow across the darkened battlefield

battle_effect_table.c maps every ability to an (effectId, variant) pair, so tiered spells such as Quake, Earthquake, and Quake Sphere share one handler at variants 0, 1, and 2. Families reuse art widely: Herbs borrow Ply's sparkles, Gaia and Rockfall share one rock-wall handler, and battle_effect_casting_impact.c drives 8 Djinn plus many weapon unleashes.

Nearly every effect draws 6-bit brightness values (0..63) onto a 128×128 software canvas, then maps those values through an effect-supplied 64-colour palette ramp. The same drawing routine therefore appears as fire under one ramp and as ice under another. Most spells stretch the canvas 2× horizontally and blend additively so blasts glow like light, while solid effects such as Quake display 1× opaque so pillars hide sprites behind them.

VBlank transfer and glowing trails

Garet casts Fire at Isaac, Mia, and Ivan: watch each fireball leave a fading tail without drawing any trail sprite
Garet casts Fire at Isaac, Mia, and Ivan: watch each fireball leave a fading tail without drawing any trail…

Handlers draw onto a RAM copy of the canvas and wait a tick via sySynch(1). At VBlank, a transfer event copies the canvas to VRAM and immediately applies one of four post-copy decay modes to RAM. This is how Fire's fireballs leave glowing tails that no code draws explicitly: the tail is last tick's fireball, a quarter dimmer.

Post-transfer modeVisual result
Clear to 0Only this tick's drawing (no trail)
Scale pixels to 3/4Long glowing trails (e.g., Fire's fireball tails)
Scale pixels to 1/2Short motion trails
Leave untouchedCumulative buildup across ticks

Blitters, motes, hardware windows, and unused handlers

Ivan casts Bolt at Isaac: purple sparks gather, lightning strikes, and damage text starts while sparks linger
Ivan casts Bolt at Isaac: purple sparks gather, lightning strikes, and damage text starts while sparks linger
  • Assembly blitters (blitter_*): Stamp sprites onto the canvas with replace, additive, or max-brightness blending. Ray keeps max brightness so crossing bolts stay uniform, while stronger variants switch to additive so crossings flare.
  • Motes and particles: Round motes and square flares unpack from graphics/battle_effects/ (Graphics assets) at 10 sizes so particles shrink smoothly as they die.
  • Viewport framing and HBlank lines: Effects use GBA display windows (WIN0 and WIN1) to frame the viewport while darkening the backdrop. They also register temporary HBlank DMA events for per-scanline effects such as Ice's slanted shard band, Heartrender's wave, and Meteor's sky gradient. Every handler unregisters its events before freeing heap memory.
  • Starting point and unused handlers: battle_effect_bolt.c contains a short handler loop. btEffectRunUnusedSevereBlowLeap (battle_effect_thrash.c) goes unused in TBS and becomes Severe Blow in The Lost Age. btEffectRunUnusedTriangleStrike (battle_effect_bind.c) is unused in both games (How The Lost Age Evolved from The Broken Seal).

File map

File(s)Role
battle_effect.cParent translation unit #includeing all battle_effect_*.c parts in ROM order
battle_effect_*.cPer-ability and summon visual handlers (named for their primary ability)
battle_effect_table.cAbility-to-(effectId, variant) dispatch and asset lookup tables
blitter_*.s, stubs.sAssembly canvas blitters and jump-table stubs

Source files

src/battle_effect/

FileDescription
battle_effect.cEverything drawn over the battle while an ability plays: the effects are the parts under battle_effect/, and battle_effect_internal.h holds what they share.
battle_effect_annihilation.cAnnihilation.
battle_effect_atalanta.cThe Atalanta summon.
battle_effect_beams.cThe plain attack's slash, and the critical hit's gathering light and crescent.
battle_effect_bind.cBind and Triangle Strike.
battle_effect_blitter.cThe blitter builder, btEffectBuildBlitter.
battle_effect_bolt.cBolt.
battle_effect_boreas.cThe Boreas summon.
battle_effect_burst_shower.cThe blessings' burst showers.
battle_effect_canvas.cThe canvas layer: opening and closing it, its transfers, the battle background's darkening behind it, the targets' flash timers, and lines.
battle_effect_canvas_wipe.cThe canvas wipe: the ragged sweep that blacks out or clears the canvas as the summons and the larger effects open and close.
battle_effect_casting_impact.cThe casting impacts, the Djinn attacks, weapons' unleashes and enemy abilities that open the same way: sparks close in on the caster, a streak shoots at the target and a ring of light bursts over it in a spray of sparks, and then each impact plays its own effect over the target (enum CASTING_IMPACT).
battle_effect_condemn.cCondemn.
battle_effect_cybele.cThe Cybele summon.
battle_effect_death_plunge.c
battle_effect_dispatch.cThe two ways into an effect, a summon or an ordinary ability, with the sheet, state and canvas they lend it; and the helpers the summons share for window 0's ragged edge and the targets' sprites.
battle_effect_display.cThe display every effect starts from, the timed scroll of BG1 and BG2 the summons' skies use, and the line-by-line feed of window 0's edges.
battle_effect_djinn_attacks.cThe summons that spend one Djinni: Mercury, Jupiter, Venus and Mars.
battle_effect_djinn_beams.cRevive, Water of Life, Quartz and Dew.
battle_effect_djinn_heal.cAn unused Mercury Djinni heal, and the camera turn Fire and Froth share.
battle_effect_dragon_cloud.cDragon Cloud.
battle_effect_drain.cBreak and Drain.
battle_effect_element_pillar.cThe blade rain, the element pillar, the shattering opening, the element burst and the element streaks.
battle_effect_eruption.cSmoke Bomb and Blast.
battle_effect_falling.cIce and Douse: shards and drops of water falling on the targets' side.
battle_effect_fire.cFire.
battle_effect_flare.cFlare.
battle_effect_flurry.cGust, Flying Attack and the rush strikes.
battle_effect_frost.cFrost.
battle_effect_gaia.cThe Gaia and Rockfall Psynergy.
battle_effect_gathering_lights.cDemon Night, Rumble and Haunting.
battle_effect_growth.cGrowth, Punji, Vine and Thorn: columns, vines and thorns spring up one after another, each shaking the screen and throwing up dust from its root, and the targets react a few ticks later.
battle_effect_hail.cHail and Ground.
battle_effect_haunt.cHaunt and the orbiting spirals.
battle_effect_healing.cThe healing motes of Ply, Wish, Cure, Cure Poison, Tonic and Psy Crystal.
battle_effect_helm_splitter.c
battle_effect_internal.hWhat every part of the battle effect object shares: its includes, macros and tick-loop helpers.
battle_effect_judgment.cThe Judgment summon.
battle_effect_kirin.cThe Kirin summon.
battle_effect_lobbed_shells.cLobbed shells (Mad Spatter, Decompose, Bone Chiller ...).
battle_effect_mirrored_wall.cThe walls of Berserk, Spasm and Recovery.
battle_effect_neptune.cThe Neptune summon.
battle_effect_nereid.cThe Nereid summon.
battle_effect_orbiting.cSwirling stars, orbiting skulls and target bursts.
battle_effect_planet_diver.cPlanet Diver.
battle_effect_plasma.cPlasma, and the spark groups of Blast and Dynamite.
battle_effect_positions.cWhere an effect's pieces are: particles moved a tick at a time, and the screen points of units, which effects anchor on; and the runner for a casting impact, a plain attack or a critical hit.
battle_effect_prism.cPrism.
battle_effect_procne.cThe Procne summon.
battle_effect_projectiles.cThe Djinni entrance that opens the Djinn's effects, and the projectile volleys (Slash, Shuriken, Wing Flutter, Blizzard ...).
battle_effect_quake.cQuake.
battle_effect_ragnarok.cRagnarok.
battle_effect_ramses.cThe Ramses summon.
battle_effect_ray.cRay.
battle_effect_rushing_strike.cRushing strikes, where the user charges into its target (Bone Charge, Brute Force, Onslaught, Headbutt).
battle_effect_spider_web.cPoison Beat, Spinning Beat and Spider Web.
battle_effect_spire.cSpire.
battle_effect_starfield_fall.cSummon formations, the impact burst, Meteor and Outer Space.
battle_effect_stars.cAstral Blast and Shining Star.
battle_effect_stat_change.cStat boosts and reductions (Impact, Guard, Ward, Dull, Weaken ...).
battle_effect_streaks.cStreak volleys (Sonic Wave, Shriek, War Cry ...) and mote fountains (Sleep Star, Soothing Star).
battle_effect_table.cPicture layouts, timing rows and handler entries for the battle effects.
battle_effect_target_motes.cThe status motes of Taint, Delude, Paralyze, Heartrender, Mystic Flame, Demon Fire and Drown, then Sleep's sheep and Curse's flames.
battle_effect_target_strike.cMonster bites and slashes on one target.
battle_effect_thor.cThe Thor summon.
battle_effect_thrash.cThrash, Quick Strike and Vorpal Slash.
battle_effect_tiamat.cDragon Driver and the Tiamat summon.
battle_effect_titan_blade.cTitan Blade.
battle_effect_torch.cTorch and Kite.
battle_effect_undead_sword.cUndead Sword, the sword of light that rises under its target.
battle_effect_volcano.cVolcano.
battle_effect_vortices.cFroth's bubbles that burst into whirling vortices, and Whirlwind's tornadoes.
blitter_color_fragments.cThe colour fragments btEffectBuildBlitter (battle_effect_blitter.c) builds canvas blitters from, as it does the others in blitter_fragments.c: each adds four picture pixels to a canvas word at once, forward or reverse, and caps each byte that reaches the cap mask's bit at the brightest canvas level.
blitter_fragments.cThe pieces btEffectBuildBlitter (battle_effect_blitter.c) builds canvas blitters from.
blitter_operands.cThe ARM immediate operands for powers of two, which the blitter builder (battle_effect_blitter.c) adds to its clip words to fit the canvas width.

include/battle_effect/

FileDescription
battle_effect.hThe battle effects: the effect kinds an ability plays, and the runners in src/battle_effect/ that draw them over the battle, part by part.
battle_effect_ids.hThe kinds of battle effect, by AbilityBattleEffects' low twelve bits: the large effects btEffectRunSummon runs, and the effects the table of handlers plays.
battle_effect_table.hThe tables the battle effects read (battle_effect_table.c), in its order: picture offsets, sizes, timings and counts by variant.
blitter_operands.hThe ARM operands for powers of two that the blitter builder adds to its templates (blitter_operands.c).
stubs.hThe battle effects module's stub calls: the Psynergy, summon and element effects a battle plays.