Alchemy

mind_read.c

Mind Read: scanline waves, shifting colours and flowing particles.

games/tbs/src/object/psynergy_effects/mind_read.c on GitHub

Mind Read: scanline waves, shifting colours and flowing particles. Part of psynergy_effects.c, compiled only through it.

Functions

RunSceneTransitionEffect

void RunSceneTransitionEffect(s32 x, s32 y)

Starts the wave effect of caster x on target y (actor ids): fades the palettes toward a hue that shifts with the frame counter, and starts its per-frame update (FieldFx_UpdateMindReadWave) after 8 frames.

Abilities: Mind Read (field kind 2).

The effect stays up until BattleFx_ClearChildValueOnMismatch ends it after the after event; meanwhile the message windows show thoughts (Ui_FillBank15PaletteGrey sets the window mode).

Used by BattleFx_DispatchRequestKind, BattleFx_Run, Event_PullJillFromRiver.

Line 35

BattleFx_FinishSceneAndReleaseHeapBlock

void BattleFx_FinishSceneAndReleaseHeapBlock(void)

Stops the wave effect: restores the caster's colours and the palettes and releases the effect's work.

Used by BattleFx_ClearChildValueOnMismatch.

Line 56

FieldFx_UpdateMindReadWave

void FieldFx_UpdateMindReadWave(void)

Scheduler callback of the wave effect: once its delay has run out, writes the next page of scanline offsets (a sine wave of 4 pixels either way), steps the colour fade and the hue, keeps the caster's colours lit, and every 60 frames sends three particles (object 281) from the target to the caster, with sound 130.

Used by BattleFx_FinishSceneAndReleaseHeapBlock, RunSceneTransitionEffect.

Line 74

BattleFx_ArmBg0HBlankDma

void BattleFx_ArmBg0HBlankDma(void)

Scheduler callback: restarts the HBlank DMA that writes BG0's horizontal scroll for each scanline from the wave's shown page.

Used by Ui_FillBank15PaletteGrey, Ui_SetBank15PaletteAndClearRenderMode.

Line 156

BattleFx_AdvanceHueCycle

void BattleFx_AdvanceHueCycle(void)

Moves the wave's hue on 4 degrees and works out its colour, each channel 4 to 11.

Used by FieldFx_UpdateMindReadWave, RunSceneTransitionEffect.

Line 172

FieldFx_ComputeHueChannels

void FieldFx_ComputeHueChannels(s32 hue, s32 *r, s32 *g, s32 *b)

Works out red, green and blue (0 to 31 each, 16.16) for a hue in degrees (16.16).

Used by BattleFx_AdvanceHueCycle.

Line 208

BattleFx_HueChannelRamp

s32 BattleFx_HueChannelRamp(s32 angle, s32 low, s32 high)

One colour channel's strength at a hue angle: rising from 0 to 60 degrees, high from 60 to 180, falling from 180 to 240, low elsewhere.

Used by FieldFx_ComputeHueChannels.

Line 216

Fixed_Remainder

s32 Fixed_Remainder(s32 value, s32 divisor)

The 16.16 remainder of value divided by divisor (0 for a zero divisor).

Used by BattleFx_HueChannelRamp.

Line 228

BattleFx_SetCallbackWhenTargetUnset

void BattleFx_SetCallbackWhenTargetUnset(union FieldObject *fieldObject)

Per-frame update: once the object has arrived (no destination left on any axis), frees it: gBattleFx_UntargetedObjectScript is a lone SC_FREE. Mind Read's particles end this way at the caster.

Used by FieldFx_UpdateMindReadWave.

Line 243

Ui_FillBank15PaletteGrey

void Ui_FillBank15PaletteGrey(void)

Turns colours 1 and 3 to 12 of BG palette 15 grey and starts the BG0 scanline scroll (BattleFx_ArmBg0HBlankDma) at each VBlank.

Used by RunSceneTransitionEffect.

Line 261

Ui_SetBank15PaletteAndClearRenderMode

void Ui_SetBank15PaletteAndClearRenderMode(void)

Stops the BG0 scanline scroll and restores BG palette 15.

Used by BattleFx_FinishSceneAndReleaseHeapBlock, Event_ReadCorneredSuspectsMinds, VaultInteriors_DefeatThieves, VaultInteriors_IvanJoinsRodSearch.

Line 294

Structures

WaveFxWork

struct WaveFxWork

Work slot 22 of the wave effect, 0x298 bytes (gBattleBgFxWork). It lives from RunSceneTransitionEffect to BattleFx_FinishSceneAndReleaseHeapBlock, after the conversation Mind Read reads.

FieldDeclared as
linesu16 lines[2][162]Each scanline's BG0 horizontal scroll in pixels, two pages written in turn; 160 of each page's 162 are used.
phaseu16 phasethe wave's phase, 4 more a frame
pageu8 pagethe page shown (the HBlank DMA's); the other is written
reds8 redthe hue as a colour (red, green, blue, 4 to 11 each)
greens8 green
blues8 blue
hueu16 huehue, 0 to 359 degrees
sourceIdu16 sourceIdthe caster
targetIdu16 targetIdthe target
delayu8 delayframes before it starts
counteru8 counterparticle spawn cycle (0 to 60)

Used by BattleFx_AdvanceHueCycle, BattleFx_ArmBg0HBlankDma, BattleFx_FinishSceneAndReleaseHeapBlock, FieldFx_UpdateMindReadWave, RunSceneTransitionEffect, gBattleBgFxWork.

Line 10

Macros, without a comment: MIND_READ_GREY.

On this page