Alchemy

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.

Line 17

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.

Line 50

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.

Line 59

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.

Line 68

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.

Line 78

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.

Line 88

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.

Line 100

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.

Line 118

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.

Line 206

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_BANE0smoke
CASTING_IMPACT_IMPACT_SMOGsmoke
CASTING_IMPACT_IMPACT_MISTsmoke
CASTING_IMPACT_IMPACT_FEVERsmoke
CASTING_IMPACT_IMPACT_FLINTnothing
CASTING_IMPACT_IMPACT_SCORCHflash bursts rise from the target
CASTING_IMPACT_IMPACT_SQUALLtwo bolts strike among glints
CASTING_IMPACT_IMPACT_SAPmotes fly back to the caster
CASTING_IMPACT_IMPACT_TERRA_STRIKEa rock spire grows and sinks
CASTING_IMPACT_IMPACT_POISON_CLOUDsmoke
CASTING_IMPACT_IMPACT_DEADLY_POISONsmoke
CASTING_IMPACT_IMPACT_MORTAL_DANGERalso Death Size; a large picture rises and breaks
CASTING_IMPACT_IMPACT_BAD_OMENskulls rise from the target
CASTING_IMPACT_IMPACT_LIFE_NOURISHmotes fly back to the caster
CASTING_IMPACT_IMPACT_AQUA_SOCKa blue flame column falls onto the target
CASTING_IMPACT_IMPACT_15hands off
CASTING_IMPACT_IMPACT_FROST_BITEice chips converge on the target
CASTING_IMPACT_IMPACT_17hands off
CASTING_IMPACT_IMPACT_LIFE_LEECHmotes fly back to the caster
CASTING_IMPACT_IMPACT_PSY_LEECHmotes fly back to the caster
CASTING_IMPACT_IMPACT_BROILember streaks spread sideways
CASTING_IMPACT_IMPACT_MELTDOWNnothing; hands to the stat reduction
CASTING_IMPACT_IMPACT_HEAT_MIRAGEalso Heat Flash; smoke
CASTING_IMPACT_IMPACT_BARRAGEflash bursts rise from the target
CASTING_IMPACT_IMPACT_24hands off
CASTING_IMPACT_IMPACT_ACID_BATHsmoke
CASTING_IMPACT_IMPACT_26hands off
CASTING_IMPACT_IMPACT_STUN_VOLTAGEtwo bolts strike among glints
CASTING_IMPACT_IMPACT_BLINDING_SMOGsmoke
CASTING_IMPACT_IMPACT_MURKsmoke
CASTING_IMPACT_IMPACT_CYCLONE_SLASHa tornado stands over the target
CASTING_IMPACT_IMPACT_PSYPHON_SEALa rune opens over the target
CASTING_IMPACT_IMPACT_ASURAa beast scrolls across and breaks
CASTING_IMPACT_IMPACT_FORCIBLE_ARMa flame falls diagonally
CASTING_IMPACT_IMPACT_TRUNCHEON_FISTa flame falls diagonally
CASTING_IMPACT_IMPACT_SEVERE_BLOWhands off

Line 137

Macros

CASTING_IMPACT_ORB_CELLS

#define CASTING_IMPACT_ORB_CELLS 0x5100

The impact orb, 20x48 pictures packed at half width.

Used by BattleFx_RunCastingImpact.

Line 179

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.

Line 181

CASTING_IMPACT_IMPACT_PARTICLES

#define CASTING_IMPACT_IMPACT_PARTICLES

The impact pictures' particles, in Ram_MapCellBuffer after the Djinni.

Used by BattleFx_RunCastingImpact.

Line 185

CASTING_IMPACT_IMAGE_X

#define CASTING_IMPACT_IMAGE_X(side, image)

gCastingImpact_ImageX has seven pictures for each side.

Used by BattleFx_RunCastingImpact.

Line 190

Also, macros without a comment: CASTING_IMPACT_GATHER_FRAMES, CASTING_IMPACT_SPARKS, CASTING_IMPACT_IMPACT_PARTICLE_COUNT.

On this page