Alchemy
Loading...
Searching...
No Matches

intro.c File Reference

Go to the source code of this file.

Data Structures

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. More...
struct  IntroWork
 The title intro's state, in heap slot 43. More...

Macros

#define INTRO_OBJ(i)
#define WRAP_TO_BYTE(v)
 Brings v into 0..255 by whole turns of 256.
#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.
#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).
#define PROMPT_TILES   5
#define PROMPT_SPRITES   3
#define PROMPT_X   80
#define PROMPT_Y   124

Functions

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.
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.
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.
UNUSED void Title_NoOpPalette (void)
 Unused palette entry retained in the far-call table.
s32 Title_ShowSplashScreen (s32 mode)
 Shows the Nintendo logo with its jingle.
s32 Title_ShowAnimatedSplash (void)
 Shows the Camelot logo for two seconds, cycling its four frames of tiles.
UNUSED void Graphics_NoOpColor (void)
 Unused color entry retained in the far-call table.
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).
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.
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).
void PaletteFade_Init (void)
 Allocates the palette fade, saves both hardware palettes in it as the starting colours and schedules PaletteFade_Update.
UNUSED void PaletteFade_Release (void)
 Unschedules the palette fade and frees its buffers.
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.
void PaletteFade_SetCurrent (s32 mode, s32 paletteHalf)
 Sets the colours shown now by transforming the saved palettes.
UNUSED void PaletteFade_SetBackdrop (s32 color)
 Replaces the first saved colour, the backdrop. Nothing in ☀️ calls it.
void PaletteFade_Start (s32 frames)
 Starts fading the shown colours to the target over the requested frames.
s32 Graphics_ClampRgb555Channel (s32 value)
 Clamps a five-bit colour channel to 0..31. Called by Palette_Transform.
s32 Graphics_ClampRgb555Component (s32 value)
 Caps a colour component at 0x7c00, the largest a five-bit channel shifted into the high bits reaches.

Variables

const u8 gTitle_IntroSpriteColumns [] = {96, 136, 140, 160, 168, 184}
 The x of each of the six columns of intro sprites.
const u8 gTitle_PromptBlendLevels [60]
 The prompt's blend level over its 60-frame pulse.
u16 gPalette_ChannelCurve [32]
 Maps a channel (0..31) to a component (0..31 << 10).
u16 gPalette_ChannelCurveLight [32]
 A brighter curve.
u16 gPalette_ChannelCurveContrast [32]
 A high-contrast curve (25 and above are full).

Macro Definition Documentation

◆ INTRO_OBJ

#define INTRO_OBJ ( i)
Value:
(work->area.objects[i])

Definition at line 76 of file intro.c.

Referenced by Title_UpdateIntroSprites().

◆ WRAP_TO_BYTE

#define WRAP_TO_BYTE ( v)
Value:
while ((v) > 255) \
(v) -= 256; \
while ((v) < 0) \
(v) += 256

Brings v into 0..255 by whole turns of 256.

Definition at line 79 of file intro.c.

Referenced by Title_UpdateIntroSprites().

◆ PLACE_ON_SLOPE

#define PLACE_ON_SLOPE ( column,
half )
Value:
x = gTitle_IntroSpriteColumns[column] - (half); \
y = (slopeTopY - slopeBaseY) * ((x + (half)) - 104) / 80 + slopeBaseY - \
(half); \
WRAP_TO_BYTE(y)
const u8 gTitle_IntroSpriteColumns[]
The x of each of the six columns of intro sprites.
Definition intro.c:64

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.

Definition at line 87 of file intro.c.

Referenced by Title_UpdateIntroSprites().

◆ MIRRORED_QUAD

#define MIRRORED_QUAD ( i,
size,
shape,
tile )
Value:
INTRO_OBJ(i).attr01 = ((x + 4) << 16) | y | ((shape) + 0x00002400); \
INTRO_OBJ((i) + 1).attr01 = \
((x + 4 + (size)) << 16) | y | ((shape) + 0x10002400); \
INTRO_OBJ((i) + 2).attr01 = \
((x + 4) << 16) | (u8)(y + (size)) | ((shape) + 0x20002400); \
INTRO_OBJ((i) + 3).attr01 = \
((x + 4 + (size)) << 16) | (u8)(y + (size)) | ((shape) + 0x30002400); \
INTRO_OBJ(i).attr2 = (tile); \
INTRO_OBJ((i) + 1).attr2 = (tile); \
INTRO_OBJ((i) + 2).attr2 = (tile); \
INTRO_OBJ((i) + 3).attr2 = (tile)
#define INTRO_OBJ(i)
Definition intro.c:76
unsigned char u8
Definition types.h:11

Writes OAM entries i to i + 3: four sprites of size pixels, mirrored into the four quarters of one picture at (x, y).

Definition at line 95 of file intro.c.

Referenced by Title_UpdateIntroSprites().

◆ PROMPT_TILES

#define PROMPT_TILES   5

Definition at line 268 of file intro.c.

Referenced by Title_ShowIntro().

◆ PROMPT_SPRITES

#define PROMPT_SPRITES   3

Definition at line 284 of file intro.c.

Referenced by Title_ShowIntro().

◆ PROMPT_X

#define PROMPT_X   80

Definition at line 285 of file intro.c.

Referenced by Title_ShowIntro().

◆ PROMPT_Y

#define PROMPT_Y   124

Definition at line 286 of file intro.c.

Referenced by Title_ShowIntro().

Function Documentation

◆ 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.

Definition at line 112 of file intro.c.

Referenced by Title_ShowIntro(), and Title_UpdateIntroSprites().

◆ 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.

Definition at line 177 of file intro.c.

Referenced by Title_LoadIntroBackgrounds(), and 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.

Definition at line 295 of file intro.c.

Referenced by Title_ShowIntro().

◆ Title_NoOpPalette()

UNUSED void Title_NoOpPalette ( void )

Unused palette entry retained in the far-call table.

Definition at line 511 of file intro.c.

Referenced by Title_NoOpPalette().

◆ 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.

Definition at line 517 of file intro.c.

Referenced by Title_Run(), and Title_ShowSplashScreen().

◆ 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.

Definition at line 609 of file intro.c.

Referenced by Title_ShowAnimatedSplash().

◆ Graphics_NoOpColor()

UNUSED void Graphics_NoOpColor ( void )

Unused color entry retained in the far-call table.

Definition at line 665 of file intro.c.

Referenced by Graphics_NoOpColor().

◆ 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.

Definition at line 673 of file intro.c.

Referenced by PaletteFade_ComputeSteps(), and 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.

Definition at line 697 of file intro.c.

Referenced by PaletteFade_Init(), PaletteFade_Release(), and PaletteFade_Update().

◆ 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.

Definition at line 748 of file intro.c.

Referenced by Palette_Transform(), PaletteFade_Init(), PaletteFade_SetCurrent(), and 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.

Definition at line 1005 of file intro.c.

Referenced by PaletteFade_Init(), and Title_ShowIntro().

◆ PaletteFade_Release()

UNUSED void PaletteFade_Release ( void )

Unschedules the palette fade and frees its buffers.

Nothing in ☀️ calls it.

Definition at line 1022 of file intro.c.

Referenced by PaletteFade_Release().

◆ 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.

Definition at line 1029 of file intro.c.

Referenced by PaletteFade_SetTarget().

◆ PaletteFade_SetCurrent()

void PaletteFade_SetCurrent ( s32 mode,
s32 paletteHalf )

Sets the colours shown now by transforming the saved palettes.

Called by Title_ShowIntro.

Definition at line 1038 of file intro.c.

Referenced by PaletteFade_SetCurrent(), and Title_ShowIntro().

◆ PaletteFade_SetBackdrop()

UNUSED void PaletteFade_SetBackdrop ( s32 color)

Replaces the first saved colour, the backdrop. Nothing in ☀️ calls it.

Definition at line 1046 of file intro.c.

Referenced by PaletteFade_SetBackdrop().

◆ 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.

Definition at line 1055 of file intro.c.

Referenced by PaletteFade_Start(), and Title_ShowIntro().

◆ Graphics_ClampRgb555Channel()

s32 Graphics_ClampRgb555Channel ( s32 value)

Clamps a five-bit colour channel to 0..31. Called by Palette_Transform.

Definition at line 1067 of file intro.c.

Referenced by Graphics_ClampRgb555Channel(), and 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.

Definition at line 1078 of file intro.c.

Referenced by Graphics_ClampRgb555Component(), and Palette_Transform().

Variable Documentation

◆ gTitle_IntroSpriteColumns

const u8 gTitle_IntroSpriteColumns[] = {96, 136, 140, 160, 168, 184}

The x of each of the six columns of intro sprites.

Definition at line 64 of file intro.c.

◆ gTitle_PromptBlendLevels

const u8 gTitle_PromptBlendLevels[60]
Initial value:
= {
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0
}

The prompt's blend level over its 60-frame pulse.

Definition at line 68 of file intro.c.

Referenced by Title_ShowIntro().

◆ gPalette_ChannelCurve

u16 gPalette_ChannelCurve[32]
Initial value:
= {
0, 524, 1071, 1643, 2240, 2863, 3513, 4191,
4898, 5635, 6403, 7202, 8035, 8901, 9803, 10740,
11715, 12729, 13783, 14877, 16014, 17195, 18422, 19694,
21015, 22386, 23808, 25283, 26812, 28397, 30041, 31744
}

Maps a channel (0..31) to a component (0..31 << 10).

Definition at line 1089 of file intro.c.

Referenced by Palette_Transform(), and STATIC_ASSERT().

◆ gPalette_ChannelCurveLight

u16 gPalette_ChannelCurveLight[32]
Initial value:
= {
0, 613, 1247, 1902, 2580, 3281, 4005, 4753,
5526, 6324, 7148, 7999, 8876, 9782, 10716, 11680,
12674, 13699, 14755, 15843, 16965, 18121, 19312, 20538,
21801, 23101, 24440, 25818, 27237, 28697, 30199, 31744
}

A brighter curve.

Definition at line 1097 of file intro.c.

Referenced by Palette_Transform(), and STATIC_ASSERT().

◆ gPalette_ChannelCurveContrast

u16 gPalette_ChannelCurveContrast[32]
Initial value:
= {
0, 360, 759, 1201, 1689, 2226, 2817, 3466,
4178, 4957, 5808, 6738, 7752, 8856, 10058, 11365,
12784, 14325, 15996, 17806, 19767, 21888, 24183, 26662,
29340, 31744, 31744, 31744, 31744, 31744, 31744, 31744
}

A high-contrast curve (25 and above are full).

Definition at line 1105 of file intro.c.

Referenced by Palette_Transform(), and STATIC_ASSERT().