credits
games/tbs/src/graphics/credits on GitHub
credits.c
games/tbs/src/graphics/credits/credits.c
Functions
Graphics_ClearCharacterBlockAndPalette
void Graphics_ClearCharacterBlockAndPalette(s32 alternate)
Fills 30 KB of 256-color tiles with color 1 and clears 128 palette colors.
Called by the credits slideshow before loading a backdrop into a half. The
30 KB are a backdrop's 480 tiles, 256 by 120 pixels.
@param alternate 0 selects the first half (VRAM 0x06000000, palette 0-127).
1 selects the second half (VRAM 0x06008000, palette 128-255, fill 129).Used by DisplayScroll_RunSlideshow, Graphics_LoadCharacterBlockAndPalette.
Graphics_LoadCharacterBlockAndPalette
void Graphics_LoadCharacterBlockAndPalette(u32 resourceId, s32 alternate)
Loads a credits backdrop into one of the two tile/palette halves. A zero resource clears that half; the second half offsets its palette indices. Called by DisplayScroll_RunSlideshow for each picture. A backdrop resource is its 128 colours (256 bytes) and then its packed tiles. The decoder runs from a copy in heap slot CREDITS_DECODER_HEAP_SLOT, released before returning; the colours reach palette RAM at the next VBlank, through the I/O write queue.
Used by DisplayScroll_RunSlideshow.
DisplayScroll_BuildHblankWordTable
void DisplayScroll_BuildHblankWordTable(u32 *destination)
Builds the 512 tilemap words surrounding a sliding credits backdrop: blank margins, 240 consecutive tile pairs, then a zero-filled tail. Called by DisplayScroll_RunSlideshow. In 32-tile rows: two rows of tile 511, the picture's tiles 0 to 479 in fifteen rows, three rows of tile 511 (160 pixels in all, the screen), then twelve rows of zeros below it. Each map follows its picture's 30 KB of tiles in the same 32 KB, so tile 511 is the map's own last 64 bytes, which the zeros keep transparent.
Used by DisplayScroll_RunSlideshow.
DisplayScroll_StepPositionEveryFourFrames
void DisplayScroll_StepPositionEveryFourFrames(void)
A VBlank task of the credits slideshow: drifts both backdrops together, keeping their horizontal offsets aligned throughout the crossfade. Each fourth frame both scrolls fall by one (adding 0xffff to the 16-bit value), moving the pictures a pixel right; a picture is as wide as its map, 256 pixels, so it wraps without a seam.
Used by DisplayScroll_RunSlideshow.
DisplayScroll_RunSlideshow
s32 DisplayScroll_RunSlideshow(void)
Crossfades the credits backdrop sequence through alternating tile banks while the staff names scroll over it, then restores the display for the following screen. Reached through the scroll far-call table at the end of the game: Title_Run calls it as ScrollFar_Entry00 at the title scene's entrance 9, MUS_067 playing, before the clear screen. Its waits come to 11223 frames, about 3 minutes 8 seconds, besides the loads: a 300-frame lead, then 33 slides of a 64-frame fade and a 267-frame hold, the last a fade to black. Returns 0 with BG2, BG3 and blending off and the OAM copy back on; the three tasks it schedules are still scheduled.
DisplayScroll_UpdateObjects
void DisplayScroll_UpdateObjects(void)
A VBlank task scheduled by DisplayScroll_InitObjectTable: maps the visible sixteen rows onto the tile ring and uploads their sprites. Advances one pixel every fourth frame until the end-of-text latch stops the scroll.
Used by DisplayScroll_InitObjectTable.
DisplayScroll_RenderEnteringLine
void DisplayScroll_RenderEnteringLine(void)
A main-loop task scheduled by DisplayScroll_InitObjectTable: renders each entering line sixteen rows ahead of the visible top, into the hidden half of the tile ring. A null table entry latches the end-of-text state.
Used by DisplayScroll_InitObjectTable.
DisplayScroll_InitObjectTable
void DisplayScroll_InitObjectTable(void)
Allocates the credits sprites, builds the blank border and text rows, clears the tile ring and schedules scrolling and line rendering. Called by DisplayScroll_RunSlideshow; the credits keep their state in borrowed flash-library cells (see the graphics README). The 1 KB sprite buffer comes from the alternate bump pool and is never freed; each line buffer is taken from the pool after it and given back.
Used by DisplayScroll_RunSlideshow.
DisplayScroll_DrawLine
s32 DisplayScroll_DrawLine(const u8 *text, s32 firstTile, s32 alignment)
Centers, right-aligns or left-aligns one credits line in a 192-pixel row. Rasterizes its glyphs and shadow, packs 4-bit pixels and uploads 24 tiles beginning at firstTile. Called by the line-rendering task and, for the blank rows, by DisplayScroll_InitObjectTable. Returns -1 at the null end marker, otherwise zero. alignment 1 centres, 2 right-aligns and any other value left-aligns; every caller passes 1. The glyphs are colour 15 with a colour 1 shadow a pixel down and right.
Used by DisplayScroll_InitObjectTable, DisplayScroll_RenderEnteringLine.
Structures
DisplayScrollObject
struct DisplayScrollObject
One eight-byte OAM entry in the credits' private sprite buffer.
| Field | Declared as | |
|---|---|---|
attr01 | u32 attr01 | Attribute 0 in the low half, attribute 1 in the high half. |
attr2 | u32 attr2 | Attribute 2 in the low half; the unused high half stays zero. |
Used by DisplayScroll_InitObjectTable, gFlashNumRemainingBytes.
Types, without a comment: PackedDecoder.
Macros
CREDITS_BUFFER_BYTES
#define CREDITS_BUFFER_BYTES 0x900
A line's raster: nine rows of 256 one-byte pixels, the ninth for the shadow below the eighth.
Used by DisplayScroll_DrawLine.
CREDITS_DECODER_HEAP_SLOT
#define CREDITS_DECODER_HEAP_SLOT 49
The heap slot the backdrop decoder is copied into for each load.
Used by Graphics_LoadCharacterBlockAndPalette.
CREDITS_BORDER_SPRITES
#define CREDITS_BORDER_SPRITES 24
OAM entries 0 to 23: the opaque strips above and below the text.
Used by DisplayScroll_UpdateObjects.
CREDITS_OAM_ENTRIES
#define CREDITS_OAM_ENTRIES 128
The whole OAM: the borders, 96 text sprites and 8 parked off screen.
Used by DisplayScroll_InitObjectTable.
Also, macros without a comment: OWN_Flash_Handler0, OWN_gFlash, OWN_gFlashNumRemainingBytes, CREDITS_LINE_PIXELS, CREDITS_VISIBLE_ROWS, CREDITS_COLUMNS, CREDITS_RING_ROWS, CREDITS_LINE_TILES, CREDITS_RING_TILES, CREDITS_RING_BYTES, CREDITS_RASTER_STRIDE, SCROLL_OBJECTS, CREDITS_LAST_LINE_POSITION, CREDITS_END_OF_TEXT, SCROLL_OBJECTS, CREDITS_LAST_LINE_POSITION, CREDITS_END_OF_TEXT, CREDITS_STAFF_TITLE, CREDITS_FACES_SUBTITLE, CREDITS_SOUND_DIRECTION_LABEL, CREDITS_GRAPHICS_SUPPORT_LABEL, CREDITS_ARTWORK_LABEL, CREDITS_STAFF_TITLE, CREDITS_FACES_SUBTITLE, CREDITS_SOUND_DIRECTION_LABEL, CREDITS_GRAPHICS_SUPPORT_LABEL, CREDITS_ARTWORK_LABEL.
Globals
gFlash_Handler3
extern u16 gFlash_Handler3
Credits scroll position in pixels, in the low half of a flash work cell.
Used by DisplayScroll_InitObjectTable, DisplayScroll_RenderEnteringLine, DisplayScroll_UpdateObjects, EraseAtmelFlashChip, EraseAtmelFlashSector, EraseFlashChip, EraseFlashSector, IdentifyFlash, LzPack_ConsumeSlotBytes, LzPack_CopyBufferedBytes, LzPack_FindWindowMatch, LzPack_InsertSlotNode, LzPack_PackStream, LzPack_RemoveSlotNode, LzPack_ResetSlotBuckets, ProgramAtmelFlashSector, ProgramFlashByte.
sBlankCreditLine
static const u8 sBlankCreditLine[]
Blank credits line
Used by gDisplayScroll_LineTable.
Also, globals without a comment: gDisplayScroll_SlideResources, gFlashNumRemainingBytes, gFlash, gFlash_Handler0, gDisplayScroll_LineTable.