prism.c
Prism.
games/tbs/src/effect/parts/prism.c on GitHub
Prism. Part of effect.c, the battle effect object, compiled only through it.
Functions
BattleFx_RunPrism
void BattleFx_RunPrism(struct BattleEffectArgument *effect)
Crystals drop out of the sky onto the targets' side, 8 frames apart, and shatter on the ground into 16 spinning shards each, flashing the targets and shaking the screen; the battle shows the damage 80 frames before the end, and the canvas darkens away over the last 8.
Abilities: Prism, Hail Prism, Freeze Prism (kind 8).
effect->variant picks the volley from gPrism_Counts (crystals and frames: 1 in 110, 4 in 134, 12 in 166); with variant 2 the camera also swings round for the first 104 frames. The crystals are particles[]: z is 1 once shattered, variant is the frame it starts to fall. The shards are 16 per crystal in PARTICLES: z is how fast it spins.
Positions are canvas pixels in 16.16. Loads the crystal palette into the first 64 background colours and sets REG_BLDALPHA, the camera's yaw (variant 2) and work->shakeFrames, and flashes the targets at each shatter.
Used by gBattleFx_EffectHandlers.
Graphics_UpdatePhasePalette
void Graphics_UpdatePhasePalette(s32 frame, s32 redPhase, s32 greenPhase, s32 bluePhase)
Rebuilds the background palette's first ramp as a grey ramp whose red, green and blue each sway with the frame, out of step by their phases (1/65536ths of a turn), so the effect shimmers through colours.
Called each frame by BattleFx_RunBind and BattleFx_RunTriangleStrike (bind.c), BattleFx_RunShiningStar (stars.c) and BattleFx_RunThor (thor.c). Level n's channel is (n + sway) / 2, the sway up to 32 levels either way, clamped to 0 to 31.
XXX: the 64 entries, black first, are copied to colours 1 to 64, so each level shows in the colour one above it and colour 64, the first of palette 4, is overwritten too. Whether the canvas's levels are meant to be one off would show in a capture of Thor or Bind against this palette.
frame : the effect's frame; the sway turns 1/64 of a circle a frame redPhase, greenPhase, bluePhase : each channel's offset in the sway
Used by BattleFx_RunBind, BattleFx_RunShiningStar, BattleFx_RunThor, BattleFx_RunTriangleStrike.
Macros, without a comment: PRISM_GROUND_Y, PRISM_SHARD_CELLS.