Skip to Content
The Alchemy Project

Battle Effects

This page is a guide to the games/tla/src/battle_effect/ folder of the Alchemy project. Its code draws the spells, weapon unleashes, and summon animations seen on the battlefield.

Each animation runs as a blocking C handler on a shared 128×128 brightness canvas and decides no combat arithmetic. When the strike lands, the handler signals btPlaybackStart so that damage numbers and reactions play in step. For the sequel's summons, The Lost Age also adds IWRAM software-rasterised 3D meshes.

The sections below cover how abilities dispatch into shared variants, how VBlank canvas decay produces motion trails without any trail being drawn, and how the 2D blitters and ARM 3D kernels work, followed by a file map. The broader design is described in Battle & Effects.

Dispatch, variants, and the 128×128 brightness canvas

Jenna casts Heat Wave at Piers: an additive brightness canvas makes flames glow across the darkened battlefield
Jenna casts Heat Wave at Piers: an additive brightness canvas makes flames glow across the darkened…

AbilityBattleEffects in ability_staging.c maps each ability to an effect ID plus a variant (0, 1, 2, ...), so tiered lines such as Quake, Earthquake, and Quake Sphere share one handler. The 4 basic elemental summons run through that same table. The remaining 25 summons (Ramses through Iris, including all 13 multi-element summons) dispatch to dedicated handlers via btEffectRunSummon.

Nearly every effect draws 6-bit brightness intensities (0..63) onto a 128×128 RAM canvas mapped through a 64-colour palette ramp. The same drawing therefore appears as fire under one ramp and ice under another. Most effects stretch the canvas 2× horizontally and blend additively so that blasts glow like light, while solid effects such as Quake draw 1× opaque so that pillars occlude sprites behind them.

VBlank transfer and automatic trails

Jenna casts Fire at Felix, Piers, and Sheba: watch each fireball leave a fading tail without drawing any trail sprite
Jenna casts Fire at Felix, Piers, and Sheba: watch each fireball leave a fading tail without drawing any…

Handlers draw into RAM and wait a tick while btEffectTransferCanvas copies to VRAM during VBlank and applies one post-copy rule:

Post-copy modeVisual result
Wipe cleanOnly this tick's drawing
Decay to 3/4Long fading trail (last tick's fireball, a quarter dimmer)
Decay to 1/2Short crisp trail
Leave untouchedPersistent buildup across ticks

Blitters, particles, and effect families

Sheba casts Bolt at Felix: sparks gather, lightning strikes, and damage text streams while sparks linger
Sheba casts Bolt at Felix: sparks gather, lightning strikes, and damage text streams while sparks linger

Assembly blitters stamp graphics with replace, max-brightness, or additive blending. For example, Ray keeps the brighter pixel so bolts stay uniform, while stronger variants add every other bolt so crossings flare. Shared round motes and square flares unpack at 10 sizes from graphics/battle_effects/, and summon textures are kept in graphics/summon/ (Graphics assets).

Many effects reuse the same routines. Gaia and Rockfall share one rock wall at different widths, Herbs borrow Ply's sparkles, Djinn share a prelude handler, and one shared casting impact handler covers 101 effect IDs. btEffectRunBolt is a compact handler loop suited to a first reading.

IWRAM 3D software-rasterised polygon kernels

New in The Lost Age, btRenderDrawModelList projects 3D meshes through the battle camera using btRenderTransformVertices. It then copies ARM rasteriser kernels (MODEL_KIND) into IWRAM to draw rings, columns, coils (Coatlicue), whirlpools, and pillars (Iris) directly onto the 128×128 canvas:

  • Solid, textured, shaded, and transform kernels (render_kernels.s): Flat-shaded faces (replace, max-brightness, additive), affine texture-mapped faces (replace, max-brightness, additive, narrow-span), shaded texels that discard pixels darkened to 0, narrow solid spans, and btRenderTransformVertices.
  • Unused fill kernels (render_fill_mesh_kernels.s): An unused ARM counterpart of btRenderFillMesh, and textured and shaded max-brightness prototypes that nothing reaches.

File map

File(s)Role
battle_effect.c, battle_effect_internal.hParent translation unit #includeing all battle_effect_*.c parts in ROM order
battle_effect_*.cPer-ability and 25 dedicated summon handlers (btEffectRunBolt, etc.)
battle_effect_table.cEffect asset and handler dispatch tables
render_kernels.s, render_fill_mesh_kernels.sARM IWRAM 3D software polygon rasteriser and vertex transform kernels
Assembly blitters, stubs.s2D canvas blitter fragments and jump-table stubs

Source files

src/battle_effect/

FileDescription
battle_effect.cThe battle effects: what plays on screen when a Psynergy, Djinni, summon, unleash or monster ability is used.
battle_effect_annihilation.cAnnihilation: a fire streak from the user, then a burst of fire and shards on the target.
battle_effect_atalanta.cThe Atalanta summon.
battle_effect_azul.cThe summon Azul: a sea serpent that shatters the battlefield, closes the foes in a sphere of water and bursts it over them.
battle_effect_beams.cThe plain attack's slash, the critical hit's gathering light and crescent, and pushing a unit back in its damage pose.
battle_effect_bind.cBind's spinning triangle and rune, the unused Triangle Strike built on it, and an unused wash of blue down the battlefield.
battle_effect_blitter.cThe canvas blitter builder: loading and building ARM blitters from blitter_template.s and blitter_fragments.c.
battle_effect_bolt.cBolt, Flash Bolt and Blue Bolt: lightning strikes each target in turn.
battle_effect_boreas.cThe Boreas summon: Boreas in a mass of ice under a violet sky, then a torrent of ice crystals over the targets.
battle_effect_breaths.cThe monsters' breaths (Beam, Rolling Flame, Ghost Soldier, Pike Assault and Blast Breath), the crescent slash of Human Hunt and Echo Cut, and the four-way mirrored blit many effects draw their glows with.
battle_effect_burst_shower.cThe burst shower: a stream of shots from the user at the targets, which most monster breaths and a few Djinn play, each with its own picture.
battle_effect_canvas.cEclipse and the Doom Dragon's change of form, then the canvas layer: its transfers, opening and closing it, its maps, 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_cards.cThe Sleep, Baffle, Death and Sword Cards.
battle_effect_casting_impact.cThe casting impacts, the Djinn attacks, unleashes and enemy abilities that open the same way: sparks close in on the caster, a streak shoots at the target and the orb flashes over it in a spray of sparks, and then each impact plays its own effect over the target (CASTING_IMPACT).
battle_effect_catastrophe.cThe Catastrophe summon: the chained demon over a red sky, its sword's orb landing far below, and lightning and smoke sweeping over the foes.
battle_effect_charon.cThe Charon summon, and btRenderBuildQuadStrip, which builds the strip meshes many effects lay their bands, ribbons and flames on (Catastrophe's smoke, Cruel Ruin's ribbons, Megiddo's corona).
battle_effect_condemn.cCondemn.
battle_effect_constants.cThe constants the battle effects copy into their locals, in the order of the effects that read them: mostly the scales their sprites are placed at, and a few corners, points and widths.
battle_effect_cruel_ruin.cCruel Ruin, one of the Doom Dragon's attacks.
battle_effect_crystal.cCrystal.
battle_effect_cybele.cThe Cybele summon, and a routine nothing calls that opens and closes a tiled canvas.
battle_effect_daedalus.cYellow orb packing and the summon Daedalus with its second strike.
battle_effect_death_plunge.cDeath Plunge and Death Leap, the user's leap at a foe.
battle_effect_dispatch.cRunning summon and table effects, and shared target helpers.
battle_effect_display.cDisplay, scroll and window HBlank DMA helpers.
battle_effect_djinn_attacks.cThe summons that spend one Djinni: Mercury, Jupiter, Venus and Mars.
battle_effect_djinn_beams.cCanvas blitter setup and Djinn beams (Revive, Dew, Spark).
battle_effect_djinn_heal.cThe comets and feathers of Balm, Tinder and Phoenix, the Zagan summon, and the camera turn Fire and Froth share.
battle_effect_djinni_charge.cCore and Cannon, a Mars Djinni charging the target, and Rime and Haze, which hand over to the Djinni sign.
battle_effect_dragon_cloud.cDragon Cloud and Epicenter, a flame flown at a foe.
battle_effect_drain.cBreak and Drain.
battle_effect_element_pillar.c
battle_effect_eruption.cSmoke Bomb and Blast, and the function that creates an effect's sprites.
battle_effect_falling.cIce and Douse: shards and drops of water falling on the targets' side.
battle_effect_fire.cFire.
battle_effect_fire_puppet.cFire Puppet and Whiplash.
battle_effect_flare.cFlare, and an unused function that lists the indices around a value.
battle_effect_flora.cThe Flora summon, Sabre Dance and Backstab, with the function that sets a battler's sprite priority and an unused one that sends a unit outward.
battle_effect_flurry.cGust, Flying Attack, the rush bursts and the claws: the flurry of strikes they all play.
battle_effect_frost.cFrost.
battle_effect_fume.cFume.
battle_effect_gaia.cGaia, and the effect sprites with tiles of their own.
battle_effect_gasp.cThe body that sixteen abilities' effects share, named for Gasp, the first of them.
battle_effect_gathering_lights.cDemon Night, Rumble, Haunting and Thorny Grave.
battle_effect_geode.cGeode.
battle_effect_growth.cGrowth, Punji, Vine and Thorn.
battle_effect_hail.cHail and Ground, and the battle camera's shakes.
battle_effect_haunt.cHaunt and the orbiting spirals.
battle_effect_haures.cThe Haures summon, and the open cylinder a summon's band is drawn on.
battle_effect_healing.cThe healing motes of Ply, Wish, Cure, Cure Poison, Tonic and Psy Crystal.
battle_effect_heavy_divide.cThe body of Heavy Divide and Strong Hit, then Cool, Wyrd Curse, Radiant Fire and Hurricane, and the handlers that play Earth Force's and Thunder Mine's bolt trail.
battle_effect_helm_splitter.cHelm Splitter.
battle_effect_internal.hWhat every part of the battle_effect object shares: its includes, the canvas's and the shared sheets' sizes, the modes of the bodies several effects play, and the functions and tables the parts reach across each other.
battle_effect_judgment.cThe Judgment summon.
battle_effect_kirin.cThe Kirin summon.
battle_effect_legend.cLegend, the Bramble, Frost, Flame and Thunder Cards, and the Sleep, Baffle, Death and Sword Cards' entries into their own body.
battle_effect_light_surge.cLight Surge, then the handlers that play the twisting column for Whorl, Gale, Lethe Albion, Poison Flow and Raging Flood.
battle_effect_liquifier.cLiquifier, and the canvas bursts: a glowing ball that strikes the target in flames and sparks.
battle_effect_lobbed_shells.cLobbed shells (Mad Spatter, Mud, Decompose, Bone Chiller, Sticky Goo, Poison Ink, Sticky Poison, Rotten Blood, Rising Venom, Formic Acid).
battle_effect_megiddo.cMegiddo, the Sol Blade's unleash.
battle_effect_meteor_blow.cMeteor Blow: a flight through a sky of stars behind a burning meteor, which then crashes down on the foes.
battle_effect_mirrored_wall.cThe mirrored wall of Spasm, Berserk, Recovery and Sack.
battle_effect_moloch.cThe Moloch and Iris summons: Moloch's snowstorm and frosty breath, and Iris's opening, petals, drops, pillars and fountain of light, with the diagonal canvas line her light bars are drawn with.
battle_effect_neptune.cThe Neptune summon, and the two line functions that set BG2's horizontal scale.
battle_effect_nereid.cThe Nereid summon.
battle_effect_nirvana.cNirvana, Stone Justice, Soul Shatter and Serac, and Heavy Divide's and Strong Hit's ways into the heavy blow.
battle_effect_ocean_fist.cOcean Fist.
battle_effect_odyssey.cOdyssey, a cloud swirl nothing shows, Iris's screen wipe and teardown, and the shade ramps Iris's textures are filled with.
battle_effect_orbiting.cSwirling stars and target bursts, two effects no table names and nothing in the game reaches.
battle_effect_planet_diver.cPlanet Diver, Planetary and leaping strikes.
battle_effect_plasma.cPlasma, and the spark groups of Blast and Dynamite.
battle_effect_positions.cWhere on the screen an effect draws: points and units projected through the battle camera, each set 16 pixels higher.
battle_effect_prism.cPrism.
battle_effect_procne.cThe Procne summon.
battle_effect_projectiles.cThe Djinni entrance that opens the Djinn effects; the projectile volleys, from Slash and Shuriken to the stings, the wing attacks and the fire and ice volleys of Cutting Edge, Heat Wave and Blizzard; and a battler sent leaping toward another.
battle_effect_quake.cQuake.
battle_effect_raging_heat.cRaging Heat and Juggle, then the white band the summons sweep in to white out the battle.
battle_effect_ragnarok.cRagnarok.
battle_effect_ramses.cThe Ramses summon.
battle_effect_ray.cRay.
battle_effect_render.cDrawing models: transforming and projecting their corners, the model list, textures copied to IWRAM, and an unused run of the ARM fill kernel.
battle_effect_render_mesh.cC software mesh renderers: filled, textured and wireframe meshes.
battle_effect_rime.cRime and Haze, whose Djinni rises while its sign turns over the target, then the entry points of the abilities btEffectRunGaspFamily plays.
battle_effect_rising_dragon.cRising Dragon and Heartbreak.
battle_effect_rushing_strike.cRushing strikes (Bone Charge, Brute Force, Onslaught, Headbutt, Stun Muscle, Living Armor).
battle_effect_spider_web.cPoison Beat, Spinning Beat, the swirl swipe and Spider Web.
battle_effect_spire.cSpire.
battle_effect_star_mine.cStar Mine, the enemies' Rising Dragon and the backdrop it scrolls, then the entry points of the rushing strikes.
battle_effect_starfield_fall.cMeteor and Outer Space; the summons' formations and the burst they end in; brightening the background's colours; and an unused knockback and an unused copy of Nereid.
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, Slaver).
battle_effect_table.cBattle effect tables, in the order of the effect code that reads them.
battle_effect_target_motes.cThe status motes of Taint, Delude, Paralyze, Heartrender, Mystic Flame, Demonfire and Drown, then Sleep's sheep, Curse's candles, an unused Mercury Djinni heal, and Balm, Tinder and Phoenix.
battle_effect_target_strike.cTarget strikes (Numbing Sting, Cannibal Fang, Poisonous Bite, ...), Mad Zephyr and Blade Rain.
battle_effect_thor.cThe Thor summon.
battle_effect_thrash.cThrash, Mighty Press and Severe Blow, and the flashing strikes: Quick Strike, Vorpal Slash, Lunar Slash, Boost Hack and Twin Shear.
battle_effect_thunder_mine.cThe body of Thunder Mine and Earth Force, then Megaera and Void Beam.
battle_effect_tiamat.cThe Tiamat summon and Dragon Driver.
battle_effect_titan_blade.cThe great sword that falls onto the target in Titan Blade and Acheron's Grief.
battle_effect_torch.cTorch and Kite.
battle_effect_trident.c
battle_effect_triple_chomp.cTriple Chomp, and the entry points of Beam, Rolling Flame, Ghost Soldier and Blast Breath.
battle_effect_ulysses.cDrawing helpers several effects share (a sprite from the pool, the grey ramp, shaded discs, the mirrored palette), then the Ulysses summon.
battle_effect_undead_sword.cUndead Sword, Plume Edge and Diamond Berg, and the bodies of Dreamtide and Watery Grave and of Waft and Aroma.
battle_effect_vengeance.cVengeance and Life Shear, a geyser, swarms of stars and a column of bubbles, and the Coatlicue summon.
battle_effect_volcano.cVolcano: pillars of fire scroll up among the targets over a flickering flame, each erupting in a fountain of sparks and spitting more.
battle_effect_vortices.cFroth's bubbles that burst into vortices, and Whirlwind's tornadoes.
battle_effect_whorl.cThe twisting column of Whorl, Gale, Lethe Albion, Poison Flow and Raging Flood, and the Djinn Core and Cannon.
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 instructions to fit them to the canvas width, as The Broken Seal's builder does.

include/battle_effect/

FileDescription
battle_effect.hThe battle effects as the rest of the battle calls them: a runner for each Psynergy, Djinni, summon and monster ability, and the canvas, palette, particle and model helpers they share.
battle_effect_ids.hThe kinds of battle effect, by BATTLE_PLAN.battleEffect's low twelve bits: the large effects btEffectRunSummon runs, and the effects the table of handlers plays.
battle_effect_table.hThe rows and columns of the battle effects' tables, which battle_effect_table.c fills and the effects read.
blitter_operands.hThe ARM operands for powers of two that the blitter builder adds to its templates (blitter_operands.c).
render_model.hThe model records the battle effects hand to the ARM model renderer.
stubs.hThe stub calls into the battle effect module, as the other modules' code calls them.