Skip to Content
The Alchemy Project

src/field/script_commands_mind_read.c

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

Included by script_commands.c.

Structures

NameDescription
structMIND_READ_STATEThe HEAP_SLOT_MIND_READ heap slot (MindReadStateWork), 664 bytes.

Macros

NameDescription
#defineHUE_DEGREES 360The hue circle, in whole degrees and in degrees as 16.16.
#defineHUE_CIRCLE toFIXED(HUE_DEGREES)
#defineMIND_READ_WAVE_OFFSET (phase)A line's offset in Mind Read's wave at a phase: a sine 4 pixels either way, a turn every 160 phase steps.
#defineMIND_READ_CYCLE_LAST 60The wave's cycle runs to this count and starts again, 61 ticks; at counts 0, 8 and 16 a particle flies from the target to the caster.
#defineMIND_READ_PARTICLE_GAP 8
#defineMIND_READ_TINT_LEVEL_MIN 4The tint's channels run from this level, a quarter of the hue's own on top.
#defineMIND_READ_GREY RGB(28, 28, 28)The grey Mind Read writes over the window palette's white, and its black and the colours after it.

Functions

NameDescription
voidfdPsynergyStartMindReadWave (Sint32 casterId, Sint32 targetId)Starts the wave effect of casterId on targetId (actor ids): fades the palettes toward a hue that shifts with the tick counter, and starts its per-tick update (fdPsynergyUpdateMindReadWave) after 8 ticks.
voidfdPsynergyStopMindReadWave (void)Stops the wave effect: restores the caster's colours and the palettes and releases the Psynergy's state.
voidfdPsynergyUpdateMindReadWave (void)Event 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 every other tick, keeps the caster's colours cycling, and at the start of each 61-tick cycle sends three particles (SPRITE_CRESCENT), 8 ticks apart, from the target to the caster, with SE_PSYNERGY_START.
voidfdMindReadStartRipple (void)Event: restarts the HBlank DMA that writes BG0's horizontal scroll for each scanline from the wave's shown page.
voidfdMindReadAdvanceTint (void)Moves the wave's hue on 4 degrees and works out its colour, each channel 4 to 11.
voidfdEffectCalculateHueChannels (FIXED hue, FIXED *r, FIXED *g, FIXED *b)Works out red, green and blue (0 to 31 each, 16.16) for a hue in degrees (16.16).
Sint32fdEffectHueChannelRamp (Sint32 angle, Sint32 low, FIXED 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.
FIXEDfdFixedPointRemainder (FIXED value, FIXED divisor)The 16.16 remainder of value divided by divisor (0 for a zero divisor).
voidfdMindReadUpdateCrescent (ACTOR *actor)Per-tick update: once the actor has arrived (no destination left on any axis), releases it: FieldEffectUntargetedActorScript is a lone SC_RELEASE.
voidfdPsynergyGreyMindReadPalette (void)Turns WINDOW_PALETTE's white, black, window colours and border greys one grey, and starts the BG0 line scroll (fdMindReadStartRipple) at each VBlank.
voidfdPsynergyRestoreMindReadPalette (void)Stops the BG0 line scroll and restores WINDOW_PALETTE.

Description

Mind Read: scanline waves, shifting colours and flowing particles. Part of script_commands.c.

Macros in detail

HUE_DEGREES

#define HUE_DEGREES 360

The hue circle, in whole degrees and in degrees as 16.16.

Referenced by fdMindReadAdvanceTint() and fdPsynergyStartMindReadWave().

Definition at line 7 of file script_commands_mind_read.c.

HUE_CIRCLE

#define HUE_CIRCLE toFIXED(HUE_DEGREES)

Referenced by fdEffectCalculateHueChannels() and fdEffectHueChannelRamp().

Definition at line 8 of file script_commands_mind_read.c.

MIND_READ_WAVE_OFFSET

#define MIND_READ_WAVE_OFFSET(phase)

A line's offset in Mind Read's wave at a phase: a sine 4 pixels either way, a turn every 160 phase steps.

Referenced by fdPsynergyUpdateMindReadWave().

Definition at line 12 of file script_commands_mind_read.c.

MIND_READ_CYCLE_LAST

#define MIND_READ_CYCLE_LAST 60

The wave's cycle runs to this count and starts again, 61 ticks; at counts 0, 8 and 16 a particle flies from the target to the caster.

Referenced by fdPsynergyUpdateMindReadWave().

Definition at line 16 of file script_commands_mind_read.c.

MIND_READ_PARTICLE_GAP

#define MIND_READ_PARTICLE_GAP 8

Referenced by fdPsynergyUpdateMindReadWave().

Definition at line 17 of file script_commands_mind_read.c.

MIND_READ_TINT_LEVEL_MIN

#define MIND_READ_TINT_LEVEL_MIN 4

The tint's channels run from this level, a quarter of the hue's own on top.

Referenced by fdMindReadAdvanceTint().

Definition at line 19 of file script_commands_mind_read.c.

MIND_READ_GREY

#define MIND_READ_GREY RGB(28, 28, 28)

The grey Mind Read writes over the window palette's white, and its black and the colours after it.

Referenced by fdPsynergyGreyMindReadPalette().

Definition at line 169 of file script_commands_mind_read.c.

Functions in detail

fdPsynergyStartMindReadWave

void fdPsynergyStartMindReadWave(Sint32 casterId, Sint32 targetId)

Starts the wave effect of casterId on targetId (actor ids): fades the palettes toward a hue that shifts with the tick counter, and starts its per-tick update (fdPsynergyUpdateMindReadWave) after 8 ticks.

References fdMindReadAdvanceTint(), fdPaletteFadeSetTarget(), fdPaletteFadeStartInterpolation(), fdPsynergyFadeToCastColor(), fdPsynergyGreyMindReadPalette(), fdPsynergyUpdateMindReadWave(), Sint32, state, syHeapSlotAllocateEWRAM(), sySetEvent() and TickCount.

Referenced by fdPsynergyDispatch(), fdPsynergyRun() and scBilibinPullJillFromRiver().

Definition at line 43 of file script_commands_mind_read.c.

fdPsynergyStopMindReadWave

void fdPsynergyStopMindReadWave(void)

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

References fdActorGetById(), fdActorSetLayersColorMode(), fdPsynergyFadeFromCastColor(), fdPsynergyRestoreMindReadPalette(), fdPsynergyUpdateMindReadWave(), state, syCloseEvent() and syHeapSlotRelease().

Referenced by fdPsynergyCancel(), fdPsynergyFinishMindRead(), scBilibinPullJillFromRiver(), scLunpaFortressReadStartledOldManMind() and scLunpaReadLeftGuardsThoughts().

Definition at line 67 of file script_commands_mind_read.c.

fdPsynergyUpdateMindReadWave

void fdPsynergyUpdateMindReadWave(void)

Event 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 every other tick, keeps the caster's colours cycling, and at the start of each 61-tick cycle sends three particles (SPRITE_CRESCENT), 8 ticks apart, from the target to the caster, with SE_PSYNERGY_START.

References fdActorCreateStub(), fdActorGetById(), fdActorSetLayersColorMode(), fdActorSetMoveTargetStub(), fdFindActorPlacement(), fdMindReadAdvanceTint(), fdMindReadUpdateCrescent(), fdPaletteFadeSetTarget(), fdPaletteFadeStartInterpolation(), line, state, syAtan(), syResourceGetMetadataRecordStub() and sySoundPlayStub().

Referenced by fdPsynergyStartMindReadWave() and fdPsynergyStopMindReadWave().

Definition at line 84 of file script_commands_mind_read.c.

fdMindReadStartRipple

void fdMindReadStartRipple(void)

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

References line, state and syDMAXCopy().

Referenced by fdPsynergyGreyMindReadPalette() and fdPsynergyRestoreMindReadPalette().

Definition at line 173 of file script_commands_mind_read.c.

fdMindReadAdvanceTint

void fdMindReadAdvanceTint(void)

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

References fdEffectCalculateHueChannels(), Sint32 and state.

Referenced by fdPsynergyStartMindReadWave() and fdPsynergyUpdateMindReadWave().

Definition at line 193 of file script_commands_mind_read.c.

fdEffectCalculateHueChannels

void fdEffectCalculateHueChannels(FIXED hue, FIXED *r, FIXED *g, FIXED *b)

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

References fdEffectHueChannelRamp().

Referenced by fdMindReadAdvanceTint().

Definition at line 231 of file script_commands_mind_read.c.

fdEffectHueChannelRamp

Sint32 fdEffectHueChannelRamp(Sint32 angle, Sint32 low, FIXED 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.

References fdFixedPointRemainder(), Sint32, syDivFX() and syMulFX().

Referenced by fdEffectCalculateHueChannels().

Definition at line 242 of file script_commands_mind_read.c.

fdFixedPointRemainder

FIXED fdFixedPointRemainder(FIXED value, FIXED divisor)

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

References syDivFX() and syMulFX().

Referenced by fdEffectHueChannelRamp().

Definition at line 256 of file script_commands_mind_read.c.

fdMindReadUpdateCrescent

void fdMindReadUpdateCrescent(ACTOR *actor)

Per-tick update: once the actor has arrived (no destination left on any axis), releases it: FieldEffectUntargetedActorScript is a lone SC_RELEASE.

References fdActorStartScriptStub(), FieldEffectUntargetedActorScript and Sint32.

Referenced by fdPsynergyUpdateMindReadWave().

Definition at line 271 of file script_commands_mind_read.c.

fdPsynergyGreyMindReadPalette

void fdPsynergyGreyMindReadPalette(void)

Turns WINDOW_PALETTE's white, black, window colours and border greys one grey, and starts the BG0 line scroll (fdMindReadStartRipple) at each VBlank.

References fdMindReadStartRipple() and sySetEvent().

Referenced by fdPsynergyStartMindReadWave().

Definition at line 289 of file script_commands_mind_read.c.

fdPsynergyRestoreMindReadPalette

void fdPsynergyRestoreMindReadPalette(void)

Stops the BG0 line scroll and restores WINDOW_PALETTE.

References fdMindReadStartRipple(), MainRoutineStateWork, mnWindowColorApplyStub(), state and syCloseEvent().

Referenced by fdPsynergyStopMindReadWave(), scLogRoomsADefeatThieves(), scLogRoomsAIvanJoinsRodSearch() and scLogRoomsAReadCorneredSuspectsMinds().

Definition at line 322 of file script_commands_mind_read.c.