Alchemy

dispatch.c

Running scene and table effects, and shared target helpers.

games/tbs/src/effect/parts/dispatch.c on GitHub

Running scene and table effects, and shared target helpers. Part of effect.c, the battle effect object, compiled only through it.

Functions

BattleFx_CallDoNothing

void BattleFx_CallDoNothing(s32 count)

Calls the empty BattleFx_DoNothing count times, without waiting for a frame: a busy delay that changes no state.

Called only by BattleFx_RunAnnihilation (annihilation.c), with 10000, before it releases the blitter it has just drawn with.

Used by BattleFx_RunAnnihilation.

Line 12

BattleFx_RunSceneEffect

void BattleFx_RunSceneEffect(struct BattleEffectArgument *effect)

Runs one of the large battle effects, the ones whose presentation flags have bit 15 set: takes the effect's sheet, work and canvas, runs the effect chosen by its kind to the end, and frees them again.

Called through BattleFx_RunSceneEffectFar by BattlePresentation_RunUnitTransition (battle/staging.c), when the plan's presentation flags have STAGING_SCENE, and by BattlePresentation_RunPairedUnitTransition (battle/auto_battle.c).

Each scene is named for the summon whose gBattle_ActionFlags entry selects its kind, as the handlers of gBattleFx_EffectHandlers are; kind 0, which no ability selects, runs Meteor's scene too. Takes heap slots HEAP_SLOT_BATTLE_SHEET, HEAP_SLOT_BATTLE_EFFECT and HEAP_SLOT_BATTLE_CANVAS and releases them in reverse, so the scene must have removed every callback that reads them. Unlike BattleFx_RunTableEffect it does not set work->effect: each scene does that itself.

Line 45

BattleFx_RunTableEffect

void BattleFx_RunTableEffect(struct BattleEffectArgument *effect)

Runs an ordinary battle effect: takes the effect's sheet, work and canvas, runs the entry of gBattleFx_EffectHandlers for its kind, and frees them again.

Called through BattleFx_RunTableEffectFar by BattlePres_RunAttack, BattlePres_RunItem, BattlePres_RunPsynergyCast and BattlePresentation_RunUnitTransition (battle/staging.c, the last when the plan sets neither STAGING_SCENE nor STAGING_BY_ID_RANGE), and by BattlePres_RunUnitAction (battle/auto_battle.c).

Sets work->effect before the handler runs, which every handler and callback reads the effect through. Kind 0 is no effect and only clears effect->variant.

Line 112

BattleFx_BuildWindowEdgeTable

void BattleFx_BuildWindowEdgeTable(void)

Builds window 0's right edge for every scanline and restarts the HBlank DMA that writes it to WIN0H each line.

Runs each frame as a scheduler callback added by BattleFx_RunNeptune (neptune.c) and BattleFx_RunBoreas (boreas.c), which fill the edge offsets and remove the callback again. Writes the WIN0H table and stops and re-arms DMA channel 0.

Ram_MapCellBuffer + 0    : the base right edge (u16)
Ram_MapCellBuffer + 2    : how far each of lines 8 to 135 pulls the edge in
                           (u8 x 128)
Ram_MapCellBuffer + 0x82 : the WIN0H table built here (u16 x 160)
Lines outside 8 to 135 get 0xfff1, a left edge past the right, so nothing
of them is in the window. Edges are clamped to 0 to 240.

Used by BattleFx_RunBoreas, BattleFx_RunNeptune.

Line 148

BattleFx_SelectLivingTargets

void BattleFx_SelectLivingTargets(struct BattleEffectArgument *effect)

Shows the battle objects of every unit with HP left on the targets' side: the enemies (units 128 to 133) when the first target is one, otherwise the party (units 0 to 7).

Called by the summon scenes (Ramses, Nereid, Kirin, Atalanta, Cybele, Neptune, Tiamat, Procne, Judgment, Boreas, Thor) and the particle streams as they open. Spawns the objects through BattleActor_SpawnObjectsForListFar.

Used by BattleFx_RunAtalanta, BattleFx_RunBoreas, BattleFx_RunCybele, BattleFx_RunJudgment, BattleFx_RunKirin, BattleFx_RunNeptune, BattleFx_RunNereid, BattleFx_RunPaletteParticles, BattleFx_RunParticleStreams, BattleFx_RunProcne, BattleFx_RunRamses, BattleFx_RunThor.

Line 184

BattleFx_SetupBlendedDisplay

void BattleFx_SetupBlendedDisplay(void)

Shows the BG1 battle background behind a cleared canvas: clears the canvas buffer and the 16 KiB of VRAM it is copied to, then blends BG2 over the rest at 14/16 and moves the projection centre down to line 120.

Called by the summon scenes (Ramses, Kirin, Atalanta, Neptune, Procne, Judgment, Boreas, Thor) and the particle streams as they close, to give the battle back its own background. Sets gBgScroll[1].y to 32, reloads BG1 with the battle's background, waits one frame with the display off but for mode 1, then writes REG_BLDALPHA, REG_BLDCNT and REG_DISPCNT and gProjection.centerY.

Used by BattleFx_RunAtalanta, BattleFx_RunBoreas, BattleFx_RunJudgment, BattleFx_RunKirin, BattleFx_RunNeptune, BattleFx_RunParticleStreams, BattleFx_RunProcne, BattleFx_RunRamses, BattleFx_RunThor.

Line 217

ObjectGroup_UpdateMembers

void ObjectGroup_UpdateMembers(s32 actorId, s32 palette, s32 animation, s32 timerSlot, s32 timerFrames)

Updates every animation group of one battler's object.

actorId: the battler whose object is updated.
palette: the colour mode each sprite part takes (enum SpriteColorMode), 0
         for the battler's own, or -1 to leave the parts alone. A part
         that changes colours also restarts its frame.
animation: the pose each group switches to (enum BattlePose), or -1 for
           none.
timerSlot: the actor timer (gBattleFxWork's actorTimers) to set, or -1;
           ObjectGroup_TickMemberTimers restores the battler's palette
           when it runs out.
timerFrames: the frames that timer counts.
The parts and animations of a battler that is fading out stay as they are,
but its timer is still set.

Called throughout the effects, most often through EFFECT_STRIKE_TARGET when a hit lands. Writes work->actorTimers[timerSlot] and each part's param and frame (0xff restarts it).

Used by BattleFx_RunAnnihilation, BattleFx_RunAstralBlast, BattleFx_RunAtalanta, BattleFx_RunBladeRain, BattleFx_RunBolt, BattleFx_RunBoreas, BattleFx_RunBreak, BattleFx_RunBurstScene, BattleFx_RunBurstShower, BattleFx_RunCastingImpact, BattleFx_RunCondemn, BattleFx_RunCybele, BattleFx_RunDeathPlunge, BattleFx_RunDjinnBeams, BattleFx_RunDjinnHeal, BattleFx_RunDjinniEntrance, BattleFx_RunDouse, BattleFx_RunDragonCloud, BattleFx_RunDrain, BattleFx_RunElementBurst, BattleFx_RunElementPillar, BattleFx_RunEruption, BattleFx_RunFire, BattleFx_RunFlare, BattleFx_RunFrost, BattleFx_RunFroth, BattleFx_RunGaia, BattleFx_RunGatheringLights, BattleFx_RunGrowingColumns, BattleFx_RunHail, BattleFx_RunHaunt, BattleFx_RunHealingMotes, BattleFx_RunHelmSplitter, BattleFx_RunIce, BattleFx_RunJudgment, BattleFx_RunKirin, BattleFx_RunLobbedShells, BattleFx_RunMirroredWall, BattleFx_RunMoteFountain, BattleFx_RunNeptune and 33 more.

Line 254

BattleFx_InitTilemapAndFlushQueue

UNUSED void BattleFx_InitTilemapAndFlushQueue(void)

Writes the tiled canvas tilemap for BG2 (priority 1), then closes the canvas layer again, which fades the background palette back in.

Nothing in The Broken Seal calls it; The Lost Age keeps it too.

Line 308

On this page