src/field/field_engine_palette_fade.c
The palette fade: palettes moved toward target colours. More…
Included by field_engine.c.
Macros
| Name | Description | |
|---|---|---|
#define | COLOR_HALF 224 | The colours a palette fade moves: the BG's 224, then the OBJ's 224. |
#define | COLOR_MAX (2 * COLOR_HALF) | |
#define | BLUE_CHANNEL (color) ((color) & BLUE_BITS) | Palette fade state holds each channel of a colour in bits 14..10 of a halfword, where RGB555 keeps blue: green's bits move up BLUE_SHIFT - GREEN_SHIFT to get there, red's BLUE_SHIFT. |
#define | GREEN_CHANNEL (color) | |
#define | RED_CHANNEL (color) (((color) & RED_BITS) << BLUE_SHIFT) | |
#define | RED_CHANNEL_DOUBLED (color) | For the brightness 2R + 4G + B: red's level doubled and green's quadrupled, each in the channel's place. |
#define | GREEN_CHANNEL_QUADRUPLED (color) |
Functions
| Name | Description | |
|---|---|---|
void | fdPaletteFadeCalculateSteps (Sint16 *src, Sint16 *target, Sint16 *step, Sint32 ticks) | Sets each channel of step (three for each of the 448 colours) 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 palette fade colours from the palette src into dest, three channels a colour. mode is one RGB555 colour, below PALETTE_TINT_FROM_SOURCE, for every colour alike; PALETTE_TINT_FROM_SOURCE for the backdrop colour alike; a PALETTE_TINT_* value to tint each colour; or the address of ready channels to copy. half is the palette selection: PALETTES_ALL for all 448 colours, PALETTES_BG for the BG's 224, PALETTES_SPRITES for the OBJ's 224. |
void | fdPaletteFadeInit (void) | Sets up the palette fade (PaletteFadeState) 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 buffer moves toward (see fdPaletteFadeBuild); does nothing without a palette fade. |
void | fdPaletteFadeSetSource (Sint32 mode, Sint32 half) | Sets the colours the buffer shows now (see fdPaletteFadeBuild). |
void | fdPaletteFadeSetBackdrop (Uint32 color) | Sets the buffer's source backdrop colour (BG colour 0 of its palette copy). |
void | fdPaletteFadeStartInterpolation (Sint32 ticks) | Starts moving the shown colours to the target colours over ticks ticks: sets state->duration, clears state->step and fills state->delta. |
Sint32 | fdPaletteFadeClampChannel (Sint32 value) | Clamps a 5-bit colour channel to 0 to 31. |
Sint32 | fdPaletteFadeClampShiftedChannel (Sint32 value) | Clamps a colour channel in its place (bits 14..10) to at most the brightest level. |
Description
The palette fade: palettes moved toward target colours. Part of
field_engine.c.
Macros in detail
COLOR_HALF
#define COLOR_HALF 224
The colours a palette fade moves: the BG's 224, then the OBJ's 224.
Referenced by fdPaletteFadeBuild(), fdPaletteFadeInit() and fdPaletteFadeUpdate().
Definition at line 7 of file field_engine_palette_fade.c.
COLOR_MAX
#define COLOR_MAX (2 * COLOR_HALF)
Referenced by fdPaletteFadeBuild() and fdPaletteFadeUpdate().
Definition at line 8 of file field_engine_palette_fade.c.
BLUE_CHANNEL
#define BLUE_CHANNEL(color) ((color) & BLUE_BITS)
Palette fade state holds each channel of a colour in bits 14..10 of a
halfword, where RGB555 keeps blue: green's bits move up BLUE_SHIFT -
GREEN_SHIFT to get there, red's BLUE_SHIFT.
Referenced by fdPaletteFadeBuild().
Definition at line 12 of file field_engine_palette_fade.c.
GREEN_CHANNEL
#define GREEN_CHANNEL(color)
Referenced by fdPaletteFadeBuild().
Definition at line 13 of file field_engine_palette_fade.c.
RED_CHANNEL
#define RED_CHANNEL(color) (((color) & RED_BITS) << BLUE_SHIFT)
Referenced by fdPaletteFadeBuild().
Definition at line 15 of file field_engine_palette_fade.c.
RED_CHANNEL_DOUBLED
#define RED_CHANNEL_DOUBLED(color)
For the brightness 2R + 4G + B: red's level doubled and green's quadrupled, each in the channel's place.
Referenced by fdPaletteFadeBuild().
Definition at line 18 of file field_engine_palette_fade.c.
GREEN_CHANNEL_QUADRUPLED
#define GREEN_CHANNEL_QUADRUPLED(color)
Referenced by fdPaletteFadeBuild().
Definition at line 20 of file field_engine_palette_fade.c.
Functions in detail
fdPaletteFadeCalculateSteps
void fdPaletteFadeCalculateSteps(Sint16 *src, Sint16 *target, Sint16 *step, Sint32 ticks)
Sets each channel of step (three for each of the 448 colours) 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 27 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 gmFlagGetStub(), Sint32, state and syWordsCopy().
Referenced by fdPaletteFadeInit() and fdPaletteFadeRelease().
Definition at line 53 of file field_engine_palette_fade.c.
fdPaletteFadeBuild
void fdPaletteFadeBuild(Uint32 mode, Uint16 *src, Uint16 *dest, Sint32 half)
Builds palette fade colours from the palette src into dest, three channels a
colour. mode is one RGB555 colour, below PALETTE_TINT_FROM_SOURCE, for every
colour alike; PALETTE_TINT_FROM_SOURCE for the backdrop colour alike; a
PALETTE_TINT_* value to tint each colour; or the address of ready channels to
copy. half is the palette selection: PALETTES_ALL for all 448 colours,
PALETTES_BG for the BG's 224, PALETTES_SPRITES for the OBJ's 224.
References ColorBufferChannelCurve, ColorBufferChannelCurveContrast, ColorBufferChannelCurveLight, fdPaletteFadeClampChannel(), fdPaletteFadeClampShiftedChannel(), Sint32, syDMAXCopy(), syIntegerDivide() and syMulFX().
Referenced by fdPaletteFadeInit(), fdPaletteFadeSetSource(), fdPaletteFadeSetTarget(), fdWeatherStartLightning() and fdWeatherStartLightningFlash().
Definition at line 122 of file field_engine_palette_fade.c.
fdPaletteFadeInit
void fdPaletteFadeInit(void)
Sets up the palette fade (PaletteFadeState) from the BG and OBJ palettes and
starts updating the palettes from it each tick.
References fdPaletteFadeBuild(), fdPaletteFadeUpdate(), state, syDMAXCopy(), syHeapSlotAllocateEWRAM() and sySetEvent().
Referenced by fdEngineRun().
Definition at line 426 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 446 of file field_engine_palette_fade.c.
fdPaletteFadeSetTarget
void fdPaletteFadeSetTarget(Sint32 mode, Sint32 half)
Sets the colours the buffer moves toward (see fdPaletteFadeBuild); does
nothing without a palette fade.
References fdPaletteFadeBuild(), Sint32 and state.
Referenced by fdEngineRun(), fdPaletteFadeApplyTarget(), fdPsynergyEndReveal(), fdPsynergyFadeFromCastColor(), fdPsynergyFadeToCastColor(), fdPsynergyReveal(), fdPsynergyStartMindReadWave(), fdPsynergyUpdateMindReadWave(), fdScreenTransitionFinish(), fdWeatherUpdateLightning(), scKolimaPaletteCurse(), scKolimaPaletteRestore() and scSolSanctumElementalStarRoomBagVenusStar().
Definition at line 454 of file field_engine_palette_fade.c.
fdPaletteFadeSetSource
void fdPaletteFadeSetSource(Sint32 mode, Sint32 half)
Sets the colours the buffer shows now (see fdPaletteFadeBuild).
References fdPaletteFadeBuild(), Sint32 and state.
Referenced by fdPaletteFadeApplySource(), fdPartyAddHp(), fdPartyApplyPoisonDamage(), fdPsynergyEndReveal(), fdPsynergyReveal(), fdScreenTransitionStart() and scKolimaPaletteCapture().
Definition at line 465 of file field_engine_palette_fade.c.
fdPaletteFadeSetBackdrop
void fdPaletteFadeSetBackdrop(Uint32 color)
Sets the buffer's source backdrop colour (BG colour 0 of its palette copy).
References state.
Referenced by fdScreenTransitionStart().
Definition at line 476 of file field_engine_palette_fade.c.
fdPaletteFadeStartInterpolation
void fdPaletteFadeStartInterpolation(Sint32 ticks)
Starts moving the shown colours to the target colours over ticks ticks: sets state->duration, clears state->step and fills state->delta.
References fdPaletteFadeCalculateSteps(), Sint32 and state.
Referenced by fdPaletteFadeInterpolate(), fdPartyAddHp(), fdPartyApplyPoisonDamage(), fdPsynergyEndReveal(), fdPsynergyFadeFromCastColor(), fdPsynergyFadeToCastColor(), fdPsynergyReveal(), fdPsynergyStartMindReadWave(), fdPsynergyUpdateMindReadWave(), fdScreenTransitionFinish(), fdScreenTransitionStart(), scColosseumEntranceExplainPartySupport(), scColosseumNavampaMatchPlayPostBattleReunion(), scFuchinFallsCaveEndRevealLighting(), scFuchinFallsCaveLightDragonWithEye(), scFuchinTempleAnimateRevealLesson(), scFuchinTempleNyunpaOffersTest(), scHammetPalaceIvanReportsToLayana(), scImilFuchinFallsPrepareRoom(), scImilMeetMiaAtOldCouplesHouse(), scInit(), scKolimaForestEntranceWitnessForestCurse(), scKolimaForestTreeRejectHermesWater(), scKolimaForestTreeRestoreTret(), scKolimaForestTreeTalkToTret(), scKolimaForestTreeUpdateHealingPalette(), scKolimaWitnessForestCurse(), scMercuryLighthouseAeriePartyArrives(), scMercuryLighthouseEntranceActivateWithPly(), scMercuryLighthouseMiaOpensEntranceWithPly(), scMercuryLighthousePlyOpensWaterfallPassage(), scSanctumAskQuestAgain(), scSanctumAskToAcceptQuest(), scSanctumChooseRestartOption(), scSanctumLeaveAfterRefusing(), scSanctumReceiveWiseOnesMission(), scSolSanctumElementalStarRoomBagJupiterStar(), scSolSanctumElementalStarRoomBagMercuryStar(), scSolSanctumElementalStarRoomBagVenusStar(), scSolSanctumElementalStarRoomTakeMarsStar(), scSolSanctumEruptionFadeCameraTo(), scSolSanctumEruptionPlayHostageScript(), scSolSanctumEruptionPlayWiseOneRescue(), scSolSanctumEruptionRaiseElementalLights(), scSolSanctumEruptionSetPaleTint(), scSolSanctumLunaSolRoomsArriveAfterWiseOnesRescue(), scSolSanctumLunaSolRoomsOpenOnKradenInLunaRoom(), scSolSanctumLunaSolRoomsRestorePlainTint(), scSolSanctumLunaSolRoomsRiseToElementalStarRoom(), scSolSanctumLunaSolRoomsTintLunaRoom() and 12 more.
Definition at line 488 of file field_engine_palette_fade.c.
fdPaletteFadeClampChannel
Sint32 fdPaletteFadeClampChannel(Sint32 value)
Clamps a 5-bit colour channel to 0 to 31.
References Sint32.
Referenced by fdPaletteFadeBuild().
Definition at line 502 of file field_engine_palette_fade.c.
fdPaletteFadeClampShiftedChannel
Sint32 fdPaletteFadeClampShiftedChannel(Sint32 value)
Clamps a colour channel in its place (bits 14..10) to at most the brightest level.
References Sint32.
Referenced by fdPaletteFadeBuild().
Definition at line 513 of file field_engine_palette_fade.c.