src/field/field_engine_palette_fade.c
The palette fades: a fade between two built palettes over a number of ticks, and the palettes it builds from the shown one. More…
Included by field_engine.c.
Macros
| Name | Description | |
|---|---|---|
#define | FADE_HALF_COLORS 224 | The palette fade works on 224 BG colours and then 224 OBJ colours, each as B, G, R with every channel moved to where blue is (BLUE_BITS, bits 14..10). |
#define | FADE_COLORS (FADE_HALF_COLORS * 2) | |
#define | FADE_CHANNELS (FADE_COLORS * 3) |
Functions
| Name | Description | |
|---|---|---|
void | fdPaletteFadeCalculateSteps (Sint16 *src, Sint16 *target, Sint16 *step, Sint32 ticks) | Sets each colour channel of step to the amount to add each tick for source to reach target in ticks ticks; with ticks 0 or less step is left as it was. |
void | fdPaletteFadeUpdate (void) | Each tick (unless FLAG_PALETTE_BLEND_HELD is set): moves the palette fade one step toward its target, packs it into RGB555 and queues it for the BG and OBJ palettes. |
void | fdPaletteFadeBuild (Uint32 mode, Uint16 *src, Uint16 *dest, Sint32 half) | Builds colours for the palette fade from the palette src into dest, which holds each colour as B, G and R channels, each where RGB555 keeps blue. mode below PALETTE_TINT_FROM_SOURCE is one colour for all; PALETTE_TINT_FROM_SOURCE the backdrop colour; the other PALETTE_TINT_* values tint each colour; any other value is the address of a ready buffer to copy. half is the palette selection: PALETTES_ALL for every colour, PALETTES_BG for the BG's, PALETTES_OBJECTS for the OBJ's. |
void | fdPaletteFadeInit (void) | Sets up the palette fade (HEAP_SLOT_PALETTE_FADE) from the BG and OBJ palettes and starts updating the palettes from it each tick. |
void | fdPaletteFadeRelease (void) | Stops the palette fade and frees it. |
void | fdPaletteFadeSetTarget (Sint32 mode, Sint32 half) | Sets the colours the palette fade moves toward (see fdPaletteFadeBuild); does nothing without a palette fade. |
void | fdPaletteFadeSetSource (Sint32 mode, Sint32 half) | Sets the colours the palette fade shows now (see fdPaletteFadeBuild). |
void | fdPaletteFadeSetBackdrop (Uint32 color) | Sets the backdrop colour (BG colour 0) of the palette fade's copy of the palettes, from which it builds its colours. |
void | fdPaletteFadePackTarget (void) | Packs the target colours, three channels each, back into the palette copy as RGB555. |
void | fdPaletteFadeStartInterpolation (Sint32 ticks) | Starts the fade from the shown colours to the target colours, over ticks ticks. |
void | fdPaletteFadeLoadPalette (const Uint16 *colors) | Takes colors as the BG colours of the palette copy and makes them, unchanged, the BG colours' target. |
Sint32 | fdPaletteFadeClampComponent (Sint32 value) | Clamps a colour channel to 0 to RGB_LEVEL_MAX. |
Sint32 | fdPaletteFadeClampShiftedComponent (Sint32 value) | Clamps a colour channel held where blue is to at most RGB_LEVEL_MAX there. |
Description
The palette fades: a fade between two built palettes over a number of ticks,
and the palettes it builds from the shown one. Part of field_engine.c.
Macros in detail
FADE_HALF_COLORS
#define FADE_HALF_COLORS 224
The palette fade works on 224 BG colours and then 224 OBJ colours, each as B,
G, R with every channel moved to where blue is (BLUE_BITS, bits 14..10).
Referenced by fdPaletteFadeBuild(), fdPaletteFadeInit(), fdPaletteFadeLoadPalette() and fdPaletteFadeUpdate().
Definition at line 6 of file field_engine_palette_fade.c.
FADE_COLORS
#define FADE_COLORS (FADE_HALF_COLORS * 2)
Referenced by fdPaletteFadeBuild(), fdPaletteFadePackTarget() and fdPaletteFadeUpdate().
Definition at line 7 of file field_engine_palette_fade.c.
FADE_CHANNELS
#define FADE_CHANNELS (FADE_COLORS * 3)
Referenced by fdPaletteFadeCalculateSteps() and fdPaletteFadeUpdate().
Definition at line 8 of file field_engine_palette_fade.c.
Functions in detail
fdPaletteFadeCalculateSteps
void fdPaletteFadeCalculateSteps(Sint16 *src, Sint16 *target, Sint16 *step, Sint32 ticks)
Sets each colour channel of step to the amount to add each tick for source to reach target in ticks ticks; with ticks 0 or less step is left as it was.
References Sint32 and syIntegerDivide().
Referenced by fdPaletteFadeStartInterpolation(), fdWeatherStartLightning() and fdWeatherStartLightningFlash().
Definition at line 12 of file field_engine_palette_fade.c.
fdPaletteFadeUpdate
void fdPaletteFadeUpdate(void)
Each tick (unless FLAG_PALETTE_BLEND_HELD is set): moves the palette fade one
step toward its target, packs it into RGB555 and queues it for the BG and OBJ
palettes.
References Sint32, syGameFlagGet() and syWordsCopy().
Referenced by fdPaletteFadeInit() and fdPaletteFadeRelease().
Definition at line 38 of file field_engine_palette_fade.c.
fdPaletteFadeBuild
void fdPaletteFadeBuild(Uint32 mode, Uint16 *src, Uint16 *dest, Sint32 half)
Builds colours for the palette fade from the palette src into dest, which
holds each colour as B, G and R channels, each where RGB555 keeps blue. mode
below PALETTE_TINT_FROM_SOURCE is one colour for all;
PALETTE_TINT_FROM_SOURCE the backdrop colour; the other PALETTE_TINT_* values
tint each colour; any other value is the address of a ready buffer to copy.
half is the palette selection: PALETTES_ALL for every colour, PALETTES_BG for
the BG's, PALETTES_OBJECTS for the OBJ's.
References fdPaletteFadeClampComponent(), fdPaletteFadeClampShiftedComponent(), FieldEffectChannelCurve, FieldEffectChannelCurveContrast, FieldEffectChannelCurveLight, Sint32, syDMAXCopy() and syIntegerDivide().
Referenced by fdPaletteFadeInit(), fdPaletteFadeLoadPalette(), fdPaletteFadeSetSource(), fdPaletteFadeSetTarget(), fdWeatherStartLightning() and fdWeatherStartLightningFlash().
Definition at line 107 of file field_engine_palette_fade.c.
fdPaletteFadeInit
void fdPaletteFadeInit(void)
Sets up the palette fade (HEAP_SLOT_PALETTE_FADE) from the BG and OBJ
palettes and starts updating the palettes from it each tick.
References fdPaletteFadeBuild(), fdPaletteFadeUpdate(), syDMAXCopy(), syHeapSlotAllocateEWRAM() and sySetEvent().
Referenced by fdEngineRun().
Definition at line 466 of file field_engine_palette_fade.c.
fdPaletteFadeRelease
void fdPaletteFadeRelease(void)
Stops the palette fade and frees it.
References fdPaletteFadeUpdate(), syCloseEvent() and syHeapSlotRelease().
Definition at line 486 of file field_engine_palette_fade.c.
fdPaletteFadeSetTarget
void fdPaletteFadeSetTarget(Sint32 mode, Sint32 half)
Sets the colours the palette fade moves toward (see fdPaletteFadeBuild); does
nothing without a palette fade.
References fdPaletteFadeBuild() and Sint32.
Referenced by fdEngineRun(), fdHeadingClose(), fdHeadingShow(), fdPaletteFadeApplyTarget(), fdPsynergyEndReveal(), fdPsynergyParch(), fdPsynergyReveal(), fdPsynergyStartMindReadWave(), fdPsynergyUpdateMindReadWave(), fdScreenTransitionFinish(), fdStartColorTransition(), fdStartPaletteTransition(), fdWeatherUpdateLightning(), scAirsRockInsideShebaLearnsReveal(), scAirsRockInsideWakeEntranceStatue(), scAirsRockInsideWakeHallStatue(), scAlhafraManorBriggsEscapes(), scAnemosInnerSanctumDullahanShadowChallenges(), scApojiiIslandsDouseAquaStone(), scAquaRockDouseSummitWaterStone(), scAquaRockDouseWaterStone(), scAquaRockInsidePiersLearnsParch(), scContigoBabyThinks(), scGabombaStatueChamberGabombaNamesWitchDoctor(), scGabombaStatueChamberStatueSpeaks(), scGabombaStatueChamberWhereIsTheOrb(), scGaiaRockInsideFelixLearnsSand(), scInit(), scIsletCaveFinishTeleport(), scIsletCaveSentinelAwaits(), scKibomboCeremonyEnds(), scKibomboStatueFlashes(), scKibomboWitchDoctorFeelsPower(), scLemurianShipParchHold(), scMagmaRockInsideLearnBlaze(), scMarsLighthouseHallHearDragonStatue(), scMarsLighthouseHallReadEarthInscription(), scMarsLighthouseHallReadFireInscription(), scMarsLighthouseHallReadWaterInscription(), scMarsLighthouseHallReadWindInscription(), scNorthernReachesShatterIceWall(), scSeaOfTimeAnimateSea(), scTundariaTowerRefluxAppears() and scYampiDesertCaveMeetGuardianOfFire().
Definition at line 494 of file field_engine_palette_fade.c.
fdPaletteFadeSetSource
void fdPaletteFadeSetSource(Sint32 mode, Sint32 half)
Sets the colours the palette fade shows now (see fdPaletteFadeBuild).
References fdPaletteFadeBuild() and Sint32.
Referenced by fdHeadingShow(), fdPaletteFadeApplySource(), fdPartyAddHp(), fdPartyApplyPoisonDamage(), fdPsynergyEndReveal(), fdPsynergyReveal(), fdScreenTransitionStart(), scAirsRockInsideShebaLearnsReveal(), scAirsRockInsideWakeEntranceStatue(), scAirsRockInsideWakeHallStatue(), scAlhafraManorBriggsEscapes(), scAnemosInnerSanctumDullahanShadowChallenges(), scAquaRockInsidePiersLearnsParch(), scContigoBabyThinks(), scGabombaStatueChamberGabombaNamesWitchDoctor(), scGaiaRockInsideFelixLearnsSand(), scKibomboCeremonyEnds(), scKibomboWitchDoctorFeelsPower(), scMagmaRockInsideLearnBlaze(), scPrepareMap() and scTundariaTowerFadeFrom().
Definition at line 505 of file field_engine_palette_fade.c.
fdPaletteFadeSetBackdrop
void fdPaletteFadeSetBackdrop(Uint32 color)
Sets the backdrop colour (BG colour 0) of the palette fade's copy of the palettes, from which it builds its colours.
Referenced by fdScreenTransitionStart().
Definition at line 517 of file field_engine_palette_fade.c.
fdPaletteFadePackTarget
void fdPaletteFadePackTarget(void)
Packs the target colours, three channels each, back into the palette copy as RGB555.
References Sint32.
Referenced by scGarohInitPath(), scGarohInitVillage() and scInit().
Definition at line 529 of file field_engine_palette_fade.c.
fdPaletteFadeStartInterpolation
void fdPaletteFadeStartInterpolation(Sint32 ticks)
Starts the fade from the shown colours to the target colours, over ticks ticks.
References fdPaletteFadeCalculateSteps() and Sint32.
Referenced by fdHeadingClose(), fdHeadingShow(), fdPaletteFadeInterpolate(), fdPartyAddHp(), fdPartyApplyPoisonDamage(), fdPsynergyEndReveal(), fdPsynergyParch(), fdPsynergyReveal(), fdPsynergyStartMindReadWave(), fdPsynergyUpdateMindReadWave(), fdScreenTransitionFinish(), fdScreenTransitionStart(), fdStartColorTransition(), fdStartPaletteTransition(), scAirsRockInsideShebaLearnsReveal(), scAirsRockInsideWakeEntranceStatue(), scAirsRockInsideWakeHallStatue(), scAlhafraManorBriggsEscapes(), scAnemosInnerSanctumDullahanShadowChallenges(), scApojiiIslandsDouseAquaStone(), scAquaRockDouseSummitWaterStone(), scAquaRockDouseWaterStone(), scAquaRockInsidePiersLearnsParch(), scContigoBabyThinks(), scGabombaCatacombsGabombaBestowsPower(), scGabombaStatueChamberGabombaNamesWitchDoctor(), scGabombaStatueChamberStatueSpeaks(), scGabombaStatueChamberWhereIsTheOrb(), scGaiaRockInsideFelixLearnsSand(), scInit(), scIsletCaveFinishTeleport(), scIsletCaveSentinelAwaits(), scKibomboCeremonyEnds(), scKibomboStatueFlashes(), scMagmaRockInsideLearnBlaze(), scMarsLighthouseHallHearDragonStatue(), scMarsLighthouseHallReadEarthInscription(), scMarsLighthouseHallReadFireInscription(), scMarsLighthouseHallReadWaterInscription(), scMarsLighthouseHallReadWindInscription(), scNorthernReachesShatterIceWall(), scTundariaTowerRefluxAppears() and scYampiDesertCaveMeetGuardianOfFire().
Definition at line 553 of file field_engine_palette_fade.c.
fdPaletteFadeLoadPalette
void fdPaletteFadeLoadPalette(const Uint16 *colors)
Takes colors as the BG colours of the palette copy and makes them, unchanged, the BG colours' target.
References fdPaletteFadeBuild() and Sint32.
Definition at line 568 of file field_engine_palette_fade.c.
fdPaletteFadeClampComponent
Sint32 fdPaletteFadeClampComponent(Sint32 value)
Clamps a colour channel to 0 to RGB_LEVEL_MAX.
References Sint32.
Referenced by fdPaletteFadeBuild().
Definition at line 584 of file field_engine_palette_fade.c.
fdPaletteFadeClampShiftedComponent
Sint32 fdPaletteFadeClampShiftedComponent(Sint32 value)
Clamps a colour channel held where blue is to at most RGB_LEVEL_MAX there.
References Sint32.
Referenced by fdPaletteFadeBuild().
Definition at line 594 of file field_engine_palette_fade.c.