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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
| Field | Declared as | |
|---|---|---|
lines | u16 lines[2][162] | Each scanline's BG0 horizontal scroll in pixels, two pages written in turn; 160 of each page's 162 are used. |
phase | u16 phase | the wave's phase, 4 more a frame |
page | u8 page | the page shown (the HBlank DMA's); the other is written |
red | s8 red | the hue as a colour (red, green, blue, 4 to 11 each) |
green | s8 green | |
blue | s8 blue | |
hue | u16 hue | hue, 0 to 359 degrees |
sourceId | u16 sourceId | the caster |
targetId | u16 targetId | the target |
delay | u8 delay | frames before it starts |
counter | u8 counter | particle spawn cycle (0 to 60) |
Used by BattleFx_AdvanceHueCycle, BattleFx_ArmBg0HBlankDma, BattleFx_FinishSceneAndReleaseHeapBlock, FieldFx_UpdateMindReadWave, RunSceneTransitionEffect, gBattleBgFxWork.
Macros, without a comment: MIND_READ_GREY.