title
games/tbs/src/graphics/title on GitHub
intro.c
games/tbs/src/graphics/title/intro.c
Functions
Title_UpdateIntroSprites
void Title_UpdateIntroSprites(void)
A VBlank task of the title intro, scheduled by Title_ShowIntro: places the rising sprites along the slope of the scrolling background, alternating two sets every other frame so twice as many show, hides the rest and copies the list to OAM.
Used by Title_ShowIntro.
Title_LoadIntroBackgrounds
void Title_LoadIntroBackgrounds(void)
Loads the title intro's two scrolling backgrounds and its sprite tiles, builds their maps and sets the blending and windows. Called by Title_ShowIntro.
Used by Title_ShowIntro.
Title_ShowIntro
s32 Title_ShowIntro(s32 prompt)
Plays the title intro: the backgrounds scroll down and the sprites rise
until frame 278 (A or Start skips ahead), then the screen flashes white
into the title picture. With prompt set the "Press Start" prompt pulses
for up to a minute, otherwise the picture stays five seconds. Reached
through the palette far-call table from the title screen. Returns 1 when A
or Start was pressed on the title picture.
Title_NoOpPalette
UNUSED void Title_NoOpPalette(void)
Unused palette entry retained in the far-call table.
Title_ShowSplashScreen
s32 Title_ShowSplashScreen(s32 mode)
Shows the Nintendo logo with its jingle. With mode 0 it fades in and
holds two seconds; otherwise it waits a second, fades in, holds three
seconds and fades out, faster once skipped. Called by Title_Run. Returns -1
when A or Start skipped it.
Used by Title_Run.
Title_ShowAnimatedSplash
s32 Title_ShowAnimatedSplash(void)
Shows the Camelot logo for two seconds, cycling its four frames of tiles. A or Start ends it early. Reached through the palette far-call table from the title sequence. Returns 0.
Graphics_NoOpColor
UNUSED void Graphics_NoOpColor(void)
Unused color entry retained in the far-call table.
PaletteFade_ComputeSteps
void PaletteFade_ComputeSteps(s16 *sourceComponents, s16 *targetComponents, s16 *componentSteps, s32 frames)
Computes each of the 1536 colour components' change per frame from the
current components to the target (nothing when frames is not
positive). Called by PaletteFade_Start.
Used by PaletteFade_Start.
PaletteFade_Update
void PaletteFade_Update(void)
A task scheduled by PaletteFade_Init: steps the palette fade each frame, adding the step to every colour component until the fade is done, packs the components into the spare RGB555 copy of the palettes and queues both halves for VBlank.
Used by PaletteFade_Init, PaletteFade_Release.
Palette_Transform
void Palette_Transform(u32 mode, u16 *source, u16 *destination, s32 paletteHalf)
Transforms 512 source colours into destination components (three
per colour, each in the high bits of a halfword). mode picks the
transform: a colour below 0x8000 fills every colour with it; 0x8000 takes
that colour from source[0]; 0x10000 to 0x10007 are the whole-palette filters
(plain, grey, sepia and the others); the TINT, BLEND and SPLIT flags carry
a colour in their low bits; anything else is the address of components to
copy. paletteHalf 1 does only the background palettes, 2 only the sprites'.
Called by PaletteFade_Init and the palette fade's setters.
Used by PaletteFade_Init, PaletteFade_SetCurrent, PaletteFade_SetTarget.
PaletteFade_Init
void PaletteFade_Init(void)
Allocates the palette fade, saves both hardware palettes in it as the starting colours and schedules PaletteFade_Update. Called by Title_ShowIntro.
Used by Title_ShowIntro.
PaletteFade_Release
UNUSED void PaletteFade_Release(void)
Unschedules the palette fade and frees its buffers. Nothing in ☀️ calls it.
PaletteFade_SetTarget
UNUSED void PaletteFade_SetTarget(s32 mode, s32 paletteHalf)
Sets the fade target by transforming the saved background and/or sprite palettes through the requested mode. Nothing in ☀️ calls it.
PaletteFade_SetCurrent
void PaletteFade_SetCurrent(s32 mode, s32 paletteHalf)
Sets the colours shown now by transforming the saved palettes. Called by Title_ShowIntro.
Used by Title_ShowIntro.
PaletteFade_SetBackdrop
UNUSED void PaletteFade_SetBackdrop(s32 color)
Replaces the first saved colour, the backdrop. Nothing in ☀️ calls it.
PaletteFade_Start
void PaletteFade_Start(s32 frames)
Starts fading the shown colours to the target over the requested frames. Called by Title_ShowIntro for the opening fade from black.
Used by Title_ShowIntro.
Graphics_ClampRgb555Channel
s32 Graphics_ClampRgb555Channel(s32 value)
Clamps a five-bit colour channel to 0..31. Called by Palette_Transform.
Used by Palette_Transform.
Graphics_ClampRgb555Component
s32 Graphics_ClampRgb555Component(s32 value)
Caps a colour component at 0x7c00, the largest a five-bit channel shifted into the high bits reaches. There is no lower bound. Called by Palette_Transform.
Used by Palette_Transform.
Structures
IntroSprite
struct IntroSprite
A sprite of the "Press Start" prompt, linked into a render slot each frame: OAM attributes 0 to 2 with the position split out.
| Field | Declared as | |
|---|---|---|
next | u32 next | the render slot link |
y | u8 y | |
attr0High | u8 attr0High | shape and mode bits of attribute 0 |
x | u16 x : 9 | |
attr1High | u16 attr1High : 7 | flip and size bits of attribute 1 |
tile | s32 tile |
Used by Title_ShowIntro.
IntroWork
struct IntroWork
The title intro's state, in heap slot 43.
| Field | Declared as | |
|---|---|---|
backRows | s32 backRows | rows of the far background copied in as it scrolls |
frontRows | s32 frontRows | rows of the near background copied in |
frame | s32 frame | |
tick | s32 tick | |
state | s32 state | |
rise | s32 rise | how far the sprites have risen |
objects, introObjects, sprites, prompt, area | union { struct OamShadow objects[120]; struct { u8 introObjects[0x68]; ///< objects[0] to [12], still the intro's struct IntroSprite sprites[8]; } prompt; } area |
Used by Title_LoadIntroBackgrounds, Title_ShowIntro, Title_UpdateIntroSprites.
Macros
WRAP_TO_BYTE
#define WRAP_TO_BYTE(v)
Brings v into 0..255 by whole turns of 256
Used by Title_UpdateIntroSprites.
PLACE_ON_SLOPE
#define PLACE_ON_SLOPE(column, half)
Sets x and y to the top left of a sprite of half-width half centred on
column column, between slopeBaseY at x = 104 and slopeTopY at x = 184.
Used by Title_UpdateIntroSprites.
MIRRORED_QUAD
#define MIRRORED_QUAD(i, size, shape, tile)
Writes OAM entries i to i + 3: four sprites of size pixels, mirrored into
the four quarters of one picture at (x, y)
Used by Title_UpdateIntroSprites.
Also, macros without a comment: INTRO_OBJ, PROMPT_TILES, PROMPT_TILES, PROMPT_ROWS, PROMPT_SPRITES, PROMPT_X, PROMPT_Y, PROMPT_SPRITES, PROMPT_X, PROMPT_Y, PROMPT_SPRITES, PROMPT_X, PROMPT_Y, PROMPT_SPRITES, PROMPT_X, PROMPT_Y.
Globals
gTitle_IntroSpriteColumns
const u8 gTitle_IntroSpriteColumns[]
The x of each of the six columns of intro sprites
gPalette_ChannelCurveLight
u16 gPalette_ChannelCurveLight[32]
A brighter curve
Used by Palette_Transform.
gPalette_ChannelCurveContrast
u16 gPalette_ChannelCurveContrast[32]
A high-contrast curve (25 and above are full)
Used by Palette_Transform.
Also, globals without a comment: gTitle_PromptBlendLevels, gPalette_ChannelCurve.