Skip to Content
The Alchemy Project

src/system/system_screen_fade.c

Screen fades through the blend registers: the screen brightens toward white or darkens toward black, BLDY running from 0, the picture as drawn, to FADE_LEVEL_MAX, all white or all black, one step each VBlank. More…

Included by system.c.

Macros

NameDescription
#defineFADE_DEFINE_BLEND (name, brighten, level)Fades BG1 to BG3, the sprites and the backdrop from the current target brightness to level over frames frames.

Enumerations

NameDescription
enumanonymous enum { FADE_GAME_LAYERS, FADE_LAYER_MASK, FADE_BRIGHTEN, FADE_DARKE … }

Functions

NameDescription
voidsyScreenFadeUpdate (void)Steps the screen fade once a VBlank, called by syVBlankHandler: sets BLDCNT to brighten or darken the chosen layers, moves BLDY one step from the start level to the target level and counts ScreenFadeFramesLeft down; at the end it clears ScreenFadeFrames, which syScreenFadeWait waits on.
voidsyScreenFadeStart ( Sint8 bright, Sint32 layer, Uint32 start, Sint32 target, Sint32 frames)
voidsyScreenFadeWait (void)Waits a tick at a time until the running fade has finished.

Description

Screen fades through the blend registers: the screen brightens toward white or darkens toward black, BLDY running from 0, the picture as drawn, to FADE_LEVEL_MAX, all white or all black, one step each VBlank. Part of system.c.

Macros in detail

FADE_DEFINE_BLEND

#define FADE_DEFINE_BLEND(name, brighten, level)

Fades BG1 to BG3, the sprites and the backdrop from the current target brightness to level over frames frames.

Definition at line 59 of file system_screen_fade.c.

Enumerations in detail

anonymous enum

enum { FADE_GAME_LAYERS, FADE_LAYER_MASK, FADE_BRIGHTEN, FADE_DARKEN, … }

EnumeratorValueDescription
FADE_GAME_LAYERSBLDCNT_TGT1_ALL & ~BLDCNT_TGT1_BG0The layers the screen fades take: all but BG0.
FADE_LAYER_MASKBLDCNT_TGT1_ALL
FADE_BRIGHTENBLDCNT_EFFECT_LIGHTEN
FADE_DARKENBLDCNT_EFFECT_DARKEN
FADE_LEVEL_MAXBLEND_FADE_MAXBLDY's strongest: all white or black

Definition at line 6 of file system_screen_fade.c.

Functions in detail

syScreenFadeUpdate

void syScreenFadeUpdate(void)

Steps the screen fade once a VBlank, called by syVBlankHandler: sets BLDCNT to brighten or darken the chosen layers, moves BLDY one step from the start level to the target level and counts ScreenFadeFramesLeft down; at the end it clears ScreenFadeFrames, which syScreenFadeWait waits on.

References ScreenFadeFrames, ScreenFadeFramesLeft, ScreenFadeLayers, ScreenFadeStartLevel, ScreenFadeTargetLevel, ScreenFadeToWhite and Sint32.

Referenced by syVBlankHandler().

Definition at line 20 of file system_screen_fade.c.

syScreenFadeStart

void syScreenFadeStart( Sint8 bright, Sint32 layer, Uint32 start, Sint32 target, Sint32 frames)

Starts a fade of any layers by setting the ScreenFade globals
syScreenFadeUpdate steps. Reached through the stub table.
      bright  : 0 toward black, 1 toward white
      layer   : the BLDCNT layers to fade (low six bits)
      start   : the starting brightness; above 16, the current target
      target  : the brightness to end at
      frames : how long the fade takes, in frames; with 0 nothing is
                        written, but `target` still becomes the current
target

References ScreenFadeFrames, ScreenFadeFramesLeft, ScreenFadeLayers, ScreenFadeStartLevel, ScreenFadeTargetLevel, ScreenFadeToWhite and Sint32.

Definition at line 91 of file system_screen_fade.c.

syScreenFadeWait

void syScreenFadeWait(void)

Waits a tick at a time until the running fade has finished.

References ScreenFadeFrames and sySynch().

Referenced by btRun(), mnTitleShowCamelotLogo(), mnTitleShowPublisherLogo(), mnTitleShowTitleScreen() and scInit().

Definition at line 109 of file system_screen_fade.c.