casting_impact.c
The casting impact scene and its image helpers.
games/tbs/src/effect/parts/casting_impact.c on GitHub
The casting impact scene and its image helpers. Part of effect.c, the battle effect object, compiled only through it.
Functions
BattleFx_StepPaletteToResource
void BattleFx_StepPaletteToResource(s32 resourceId)
Moves each RGB555 channel of background colours 0 to 63 one level towards the resource palette. Colour 0 always goes towards black, whatever the resource holds.
Called once a frame, so a palette arrives in at most 31 frames: by the casting impacts, Ragnarok, the Titan Blade and Ground (hail.c). Reads and rewrites background palette RAM.
Used by BattleFx_RunCastingImpact, BattleFx_RunGround, BattleFx_RunRagnarok, BattleFx_RunTitanBlade.
CastingImpact_LoadResource
static inline void CastingImpact_LoadResource(const void *id, void *dest, s32 skip, s32 copy)
Loads the impact orb's picture (Resource_LoadAndDecompress).
Used by BattleFx_RunCastingImpact.
CastingImpact_PackRows
static inline void CastingImpact_PackRows(void *src, void *dest, s32 width, s32 height)
Packs a casting impact's picture rows (Graphics_PackTileRows).
Used by BattleFx_RunCastingImpact.
CastingImpact_DrawImage
static inline void CastingImpact_DrawImage(void *canvas, const void *pixels, s32 x, s32 y, s32 width, s32 height, DrawRectangle *draw)
Draws one casting impact image with the given blitter.
Used by BattleFx_RunCastingImpact.
CastingImpact_DrawTallImage
static inline void CastingImpact_DrawTallImage(void *canvas, const void *pixels, s32 x, s32 y, s32 width, DrawRectangle *draw)
Draws a casting-impact image whose height is twice its width.
Used by BattleFx_RunCastingImpact.
CastingImpact_DrawScrolledImage
static inline void CastingImpact_DrawScrolledImage(void *canvas, const void *pixels, s32 x, s32 y, s32 width, s32 height, s32 scroll, DrawRectangle *draw)
Draws only the unscrolled height of a casting-impact image.
Used by BattleFx_RunCastingImpact.
CastingImpact_DrawCroppedImage
static inline void CastingImpact_DrawCroppedImage(void *canvas, const void *pixels, s32 x, s32 y, s32 width, DrawRectangle *draw)
Draws a casting-impact image cropped to 91 pixels high.
Used by BattleFx_RunCastingImpact.
CastingImpact_EndPrelude
static inline void CastingImpact_EndPrelude(struct BattleEffectWork *work, void *canvas)
Clears the prelude image, stops its callbacks and releases its blitters before the next effect takes over.
Called by BattleFx_RunCastingImpact for the impacts that hand off after the gathering (15, 17, 24, 26 and Severe Blow); Meltdown's end does the same inline. Clears the canvas and its VRAM (character block 1) and work->effect->prelude, removes Palette_StepFadeTransfer and the canvas transfer, and frees both blitters.
Used by BattleFx_RunCastingImpact.
BattleFx_RunCastingImpact
void BattleFx_RunCastingImpact(struct BattleEffectArgument *effect, s32 mode)
Gathers sparks around the caster, launches the Djinni and draws the impact on the first target.
Called only by BattleFx_DispatchByIdRange (positions.c), for effect kinds 100 to 135. The phases, the hand-offs and the particle ranges are in the folder README under "Effect families". Opens the canvas layer (tiled for Terra Strike, Mortal Danger and Asura), writes the background palette, BG2's scale and reference and REG_BLDALPHA, holds the caster still while the sparks gather, and adds BattleFx_ArmBg2AffineHBlankDma for the waving impacts; it releases all of them before it returns, or hands them on.
mode: the impact, an enum CastingImpact (the kind less 100). The tests on
mode 100 never hold, as the dispatcher passes 0 to 35.Used by BattleFx_DispatchByIdRange.
Enumerations
CastingImpact
enum CastingImpact
The casting impacts, by kind - 100: each is named for the first ability whose gBattle_ActionFlags entry selects it; the four no ability selects keep their numbers.
The trailing comments give each impact's own animation, drawn over the target after the orb and sparks. Most animations use the 64 particles at Ram_MapCellBuffer + 0x4000, which start at the target; their pictures are in Ram_MapCellBuffer. "Smoke" is puffs of smoke rising from the target; "hands off" impacts stop after gathering and hand the canvas to another effect.
| Value | = | |
|---|---|---|
CASTING_IMPACT_IMPACT_BANE | 0 | smoke |
CASTING_IMPACT_IMPACT_SMOG | smoke | |
CASTING_IMPACT_IMPACT_MIST | smoke | |
CASTING_IMPACT_IMPACT_FEVER | smoke | |
CASTING_IMPACT_IMPACT_FLINT | nothing | |
CASTING_IMPACT_IMPACT_SCORCH | flash bursts rise from the target | |
CASTING_IMPACT_IMPACT_SQUALL | two bolts strike among glints | |
CASTING_IMPACT_IMPACT_SAP | motes fly back to the caster | |
CASTING_IMPACT_IMPACT_TERRA_STRIKE | a rock spire grows and sinks | |
CASTING_IMPACT_IMPACT_POISON_CLOUD | smoke | |
CASTING_IMPACT_IMPACT_DEADLY_POISON | smoke | |
CASTING_IMPACT_IMPACT_MORTAL_DANGER | also Death Size; a large picture rises and breaks | |
CASTING_IMPACT_IMPACT_BAD_OMEN | skulls rise from the target | |
CASTING_IMPACT_IMPACT_LIFE_NOURISH | motes fly back to the caster | |
CASTING_IMPACT_IMPACT_AQUA_SOCK | a blue flame column falls onto the target | |
CASTING_IMPACT_IMPACT_15 | hands off | |
CASTING_IMPACT_IMPACT_FROST_BITE | ice chips converge on the target | |
CASTING_IMPACT_IMPACT_17 | hands off | |
CASTING_IMPACT_IMPACT_LIFE_LEECH | motes fly back to the caster | |
CASTING_IMPACT_IMPACT_PSY_LEECH | motes fly back to the caster | |
CASTING_IMPACT_IMPACT_BROIL | ember streaks spread sideways | |
CASTING_IMPACT_IMPACT_MELTDOWN | nothing; hands to the stat reduction | |
CASTING_IMPACT_IMPACT_HEAT_MIRAGE | also Heat Flash; smoke | |
CASTING_IMPACT_IMPACT_BARRAGE | flash bursts rise from the target | |
CASTING_IMPACT_IMPACT_24 | hands off | |
CASTING_IMPACT_IMPACT_ACID_BATH | smoke | |
CASTING_IMPACT_IMPACT_26 | hands off | |
CASTING_IMPACT_IMPACT_STUN_VOLTAGE | two bolts strike among glints | |
CASTING_IMPACT_IMPACT_BLINDING_SMOG | smoke | |
CASTING_IMPACT_IMPACT_MURK | smoke | |
CASTING_IMPACT_IMPACT_CYCLONE_SLASH | a tornado stands over the target | |
CASTING_IMPACT_IMPACT_PSYPHON_SEAL | a rune opens over the target | |
CASTING_IMPACT_IMPACT_ASURA | a beast scrolls across and breaks | |
CASTING_IMPACT_IMPACT_FORCIBLE_ARM | a flame falls diagonally | |
CASTING_IMPACT_IMPACT_TRUNCHEON_FIST | a flame falls diagonally | |
CASTING_IMPACT_IMPACT_SEVERE_BLOW | hands off |
Macros
CASTING_IMPACT_ORB_CELLS
#define CASTING_IMPACT_ORB_CELLS 0x5100
The impact orb, 20x48 pictures packed at half width.
Used by BattleFx_RunCastingImpact.
CASTING_IMPACT_DJINNI_CELLS
#define CASTING_IMPACT_DJINNI_CELLS 0x3c56
The Djinni pictures, 20x40, in Ram_MapCellBuffer after the impact's own.
Used by BattleFx_RunCastingImpact.
CASTING_IMPACT_IMPACT_PARTICLES
#define CASTING_IMPACT_IMPACT_PARTICLES
The impact pictures' particles, in Ram_MapCellBuffer after the Djinni.
Used by BattleFx_RunCastingImpact.
CASTING_IMPACT_IMAGE_X
#define CASTING_IMPACT_IMAGE_X(side, image)
gCastingImpact_ImageX has seven pictures for each side.
Used by BattleFx_RunCastingImpact.
Also, macros without a comment: CASTING_IMPACT_GATHER_FRAMES, CASTING_IMPACT_SPARKS, CASTING_IMPACT_IMPACT_PARTICLE_COUNT.