src/menu/credits.c
The credits at the end of the game: the staff names, drawn line by line into a ring of sprite tiles, scroll up over battle backgrounds that crossfade behind them.
#include "menu/menu.h"#include "flags.h"#include "resource_ids.h"#include "battle/battle_state.h"#include "field/map_grid.h"#include "game/stubs.h"#include "sdk/flash.h"#include "sdk/flash_data.h"#include "graphics/graphics.h"
Structures
| Name | Description | |
|---|---|---|
struct | CREDITS_OAM_ENTRY | One eight-byte OAM entry in the credits' private sprite buffer. |
Macros
| Name | Description | |
|---|---|---|
#define | CREDITS_LINE_PIXELS 192 | Credits text uses six 32-pixel sprites across each 192-pixel line. |
#define | CREDITS_VISIBLE_ROWS 16 | |
#define | CREDITS_COLUMNS 6 | |
#define | CREDITS_RING_ROWS 32 | |
#define | CREDITS_LINE_TILES 24 | A line's 4bpp tiles, 192 / 8. |
#define | CREDITS_RING_TILES (CREDITS_RING_ROWS * CREDITS_LINE_TILES) | |
#define | CREDITS_RING_BYTES (CREDITS_RING_TILES * TILE_SIZE_4BPP) | |
#define | CREDITS_BUFFER_BYTES 2304 | A line's raster: nine rows of 256 one-byte pixels, the ninth for the shadow below the eighth. |
#define | CREDITS_RASTER_STRIDE 256 | |
#define | CREDITS_BORDER_SPRITES 24 | OAM entries 0 to 23: the opaque strips above and below the text. |
#define | CREDITS_OAM_ENTRIES 128 | The whole OAM: the borders, 96 text sprites and 8 parked off screen. |
#define | CREDITS_BORDER_TILE_BYTES (8 * TILE_SIZE_4BPP) | The border sprites' one 32x16 picture, solid in colour 1, after the ring. |
#define | CREDITS_RING_LINE_TILE (line) | The first tile of the ring line a scroll line is drawn into, CREDITS_VISIBLE_ROWS below the top. |
#define | CREDITS_TEXT_TOP 16 | The text sprites' rows start below the top strip, and their 192 pixels stand in the middle of the screen. |
#define | CREDITS_TEXT_LEFT ((DISPLAY_WIDTH - CREDITS_LINE_PIXELS) / 2) | |
#define | CREDITS_PARKED 192 | The x and the y at which the eight spare sprites wait, below the screen. |
#define | CREDITS_TEXT_COLOR 15 | The colour a line's letters are drawn in, and the colour of the shadow a pixel below and to the right of each, the strips' black. |
#define | CREDITS_SHADOW_COLOR 1 | |
#define | BATTLE_BACKGROUND_PALETTE_BYTES (BATTLE_BACKGROUND_COLORS * 2) | A battle background resource begins with its BATTLE_BACKGROUND_COLORS colours, the palette half it takes; its packed tiles follow. |
#define | BATTLE_BACKGROUND_TILES 480 | A battle background's tiles of 256 colours, 256 by 120 pixels. |
#define | BATTLE_BACKGROUND_TILE_BYTES (BATTLE_BACKGROUND_TILES * TILE_SIZE_8BPP) | |
#define | CREDITS_BG3_SCREEN_BLOCK 15 | The two pictures' screen blocks, each holding the same tilemap: BG3's, over character block 0, and BG2's, over character block 2. |
#define | CREDITS_BG2_SCREEN_BLOCK 31 | |
#define | TILEMAP_ROW_WORDS (BG_SCREEN_WIDTH / 2) | A tilemap row's words. |
#define | CREDITS_BLANK_TILE 511 | The tile the margins show: the character block's last, which lies in the screen block's own zeroed tail and so is clear. |
#define | SCROLL_OBJECTS CreditsScrollObjects | The three cells, as the credits read them. |
#define | CREDITS_LAST_LINE_POSITION CreditsLastLinePosition | |
#define | CREDITS_END_OF_TEXT CreditsEndOfText | |
#define | CREDITS_STAFF_TITLE "OUGON NO TAIYO STAFF" | |
#define | CREDITS_FACES_SUBTITLE "& Faces" | |
#define | CREDITS_SOUND_DIRECTION_LABEL "Sound Direction" | |
#define | CREDITS_GRAPHICS_SUPPORT_LABEL "Graphic Support" | |
#define | CREDITS_ARTWORK_LABEL "Artwork Design" | |
#define | FLAG_CREDITS_LINE_DRAWN FLAG_SCENE_TEMP(0x00) | A credits line has been drawn, so its scratch buffer holds the shadow row to carry. |
#define | OBJ_TILE_ROW (tile, row) | Row row (4 bytes, 8 pixels) of sprite tile tile in OBJ VRAM. |
Typedefs
| Name | Description | |
|---|---|---|
typedef Sint32 (* | PACKED_DECODER )(const Uint8 *source, void *destination, Uint32 fill); |
Enumerations
| Name | Description | |
|---|---|---|
enum | CREDITS_ALIGNMENT { CREDITS_ALIGN_LEFT, CREDITS_ALIGN_CENTER, CREDITS_ALIGN_RIGH … } | Where mnCreditsDrawLine starts a line in its 192-pixel row. |
Functions
| Name | Description | |
|---|---|---|
void | mnCreditsClearBuffer (Sint32 alternate) | Fills a battle background's 256-colour tiles with colour 1 of its half, black once its palette is cleared and opaque, for the next crossfade, and clears the half's palette colours. alternate is 0 for the first half (character block 0, the low palette half), 1 for the second (character block 2, the high palette half). |
void | mnCreditsLoadBackground (Uint32 resourceId, Sint32 alternate) | Loads a credits battle background into one of the two tile/palette halves. |
void | mnCreditsBuildBackgroundTilemap (Uint32 *dest) | Builds a battle background's tilemap: two blank rows, its tiles in order over fifteen rows, three blank rows, then a zeroed tail. |
void | mnCreditsScrollBackgrounds (void) | A VBlank event of the credits: drifts both pictures together, keeping their horizontal offsets aligned throughout the crossfade. |
void | mnCreditsUpdateTextSprites (void) | A VBlank event added by mnCreditsInitTextSprites: maps the visible sixteen rows onto the tile ring and uploads their sprites. |
void | mnCreditsDrawEnteringLine (void) | A tick-pass event added by mnCreditsInitTextSprites: renders each entering line sixteen rows ahead of the visible top, into the hidden half of the tile ring. |
void | mnCreditsInitTextSprites (void) | Allocates the credits sprites, builds the blank border and text rows, clears the tile ring and adds the scrolling and line-rendering events. |
Sint32 | mnCreditsDrawLine (const Uint8 *text, Sint32 firstTile, Sint32 alignment) | Centers, right-aligns or left-aligns one credits line in a 192-pixel row. |
Sint32 | mnCreditsRun (void) | Crossfades the credits' battle backgrounds through alternating tile banks while the staff names scroll over it, then restores the display for the following screen. |
Variables
| Name | Description | |
|---|---|---|
extern const Uint32 | CreditsBackgrounds [] | The battle backgrounds shown in turn, ending with 0, which clears. |
extern const void * | CreditsLines [] | The credits' lines, one per 8 pixels of scroll, ending with NULL. |
extern const Uint8 | CreditsGlyphWidths [96] | The credits font's widths in pixels, for characters 32 to 127. |
extern Uint16 | CreditsScrollPosition | Credits scroll position in pixels, in the low half of WaitForFlashWriteWork. |
extern CREDITS_OAM_ENTRY * | CreditsScrollObjects | The sprite buffer, in FlashNumRemainingBytes. |
extern Sint16 | CreditsLastLinePosition | The last line drawn, as a pixel position, in the low half of FlashWork. |
extern Sint16 | CreditsEndOfText | 0 until the text ends, then -1, in the low half of ProgramFlashSectorWork. |
static const Uint8 | BlankCreditLine [] |
Description
The credits at the end of the game: the staff names, drawn line by line into a ring of sprite tiles, scroll up over battle backgrounds that crossfade behind them.
Macros in detail
CREDITS_LINE_PIXELS
#define CREDITS_LINE_PIXELS 192
Credits text uses six 32-pixel sprites across each 192-pixel line.
Referenced by mnCreditsDrawLine().
Definition at line 34 of file credits.c.
CREDITS_VISIBLE_ROWS
#define CREDITS_VISIBLE_ROWS 16
Referenced by mnCreditsInitTextSprites() and mnCreditsUpdateTextSprites().
Definition at line 35 of file credits.c.
CREDITS_COLUMNS
#define CREDITS_COLUMNS 6
Referenced by mnCreditsInitTextSprites() and mnCreditsUpdateTextSprites().
Definition at line 36 of file credits.c.
CREDITS_RING_ROWS
#define CREDITS_RING_ROWS 32
Referenced by mnCreditsInitTextSprites() and mnCreditsUpdateTextSprites().
Definition at line 37 of file credits.c.
CREDITS_LINE_TILES
#define CREDITS_LINE_TILES 24
A line's 4bpp tiles, 192 / 8.
Referenced by mnCreditsInitTextSprites() and mnCreditsUpdateTextSprites().
Definition at line 38 of file credits.c.
CREDITS_RING_TILES
#define CREDITS_RING_TILES (CREDITS_RING_ROWS * CREDITS_LINE_TILES)
Referenced by mnCreditsInitTextSprites() and mnCreditsUpdateTextSprites().
Definition at line 39 of file credits.c.
CREDITS_RING_BYTES
#define CREDITS_RING_BYTES (CREDITS_RING_TILES * TILE_SIZE_4BPP)
Referenced by mnCreditsInitTextSprites().
Definition at line 40 of file credits.c.
CREDITS_BUFFER_BYTES
#define CREDITS_BUFFER_BYTES 2304
A line's raster: nine rows of 256 one-byte pixels, the ninth for the shadow below the eighth.
Referenced by mnCreditsDrawLine().
Definition at line 43 of file credits.c.
CREDITS_RASTER_STRIDE
#define CREDITS_RASTER_STRIDE 256
Referenced by mnCreditsDrawLine().
Definition at line 44 of file credits.c.
CREDITS_BORDER_SPRITES
#define CREDITS_BORDER_SPRITES 24
OAM entries 0 to 23: the opaque strips above and below the text.
Referenced by mnCreditsUpdateTextSprites().
Definition at line 46 of file credits.c.
CREDITS_OAM_ENTRIES
#define CREDITS_OAM_ENTRIES 128
The whole OAM: the borders, 96 text sprites and 8 parked off screen.
Referenced by mnCreditsInitTextSprites().
Definition at line 48 of file credits.c.
CREDITS_BORDER_TILE_BYTES
#define CREDITS_BORDER_TILE_BYTES (8 * TILE_SIZE_4BPP)
The border sprites' one 32x16 picture, solid in colour 1, after the ring.
Referenced by mnCreditsInitTextSprites().
Definition at line 50 of file credits.c.
CREDITS_RING_LINE_TILE
#define CREDITS_RING_LINE_TILE(line)
The first tile of the ring line a scroll line is drawn into,
CREDITS_VISIBLE_ROWS below the top.
Referenced by mnCreditsDrawEnteringLine().
Definition at line 53 of file credits.c.
CREDITS_TEXT_TOP
#define CREDITS_TEXT_TOP 16
The text sprites' rows start below the top strip, and their 192 pixels stand in the middle of the screen.
Referenced by mnCreditsInitTextSprites() and mnCreditsUpdateTextSprites().
Definition at line 58 of file credits.c.
CREDITS_TEXT_LEFT
#define CREDITS_TEXT_LEFT ((DISPLAY_WIDTH - CREDITS_LINE_PIXELS) / 2)
Referenced by mnCreditsInitTextSprites() and mnCreditsUpdateTextSprites().
Definition at line 59 of file credits.c.
CREDITS_PARKED
#define CREDITS_PARKED 192
The x and the y at which the eight spare sprites wait, below the screen.
Referenced by mnCreditsInitTextSprites().
Definition at line 61 of file credits.c.
CREDITS_TEXT_COLOR
#define CREDITS_TEXT_COLOR 15
The colour a line's letters are drawn in, and the colour of the shadow a pixel below and to the right of each, the strips' black.
Referenced by mnCreditsDrawLine().
Definition at line 64 of file credits.c.
CREDITS_SHADOW_COLOR
#define CREDITS_SHADOW_COLOR 1
Referenced by mnCreditsDrawLine().
Definition at line 65 of file credits.c.
BATTLE_BACKGROUND_PALETTE_BYTES
#define BATTLE_BACKGROUND_PALETTE_BYTES (BATTLE_BACKGROUND_COLORS * 2)
A battle background resource begins with its BATTLE_BACKGROUND_COLORS
colours, the palette half it takes; its packed tiles follow.
Referenced by mnCreditsClearBuffer() and mnCreditsLoadBackground().
Definition at line 69 of file credits.c.
BATTLE_BACKGROUND_TILES
#define BATTLE_BACKGROUND_TILES 480
A battle background's tiles of 256 colours, 256 by 120 pixels.
Referenced by mnCreditsBuildBackgroundTilemap().
Definition at line 71 of file credits.c.
BATTLE_BACKGROUND_TILE_BYTES
#define BATTLE_BACKGROUND_TILE_BYTES (BATTLE_BACKGROUND_TILES * TILE_SIZE_8BPP)
Referenced by mnCreditsClearBuffer().
Definition at line 72 of file credits.c.
CREDITS_BG3_SCREEN_BLOCK
#define CREDITS_BG3_SCREEN_BLOCK 15
The two pictures' screen blocks, each holding the same tilemap: BG3's, over character block 0, and BG2's, over character block 2.
Referenced by mnCreditsRun().
Definition at line 76 of file credits.c.
CREDITS_BG2_SCREEN_BLOCK
#define CREDITS_BG2_SCREEN_BLOCK 31
Referenced by mnCreditsRun().
Definition at line 77 of file credits.c.
TILEMAP_ROW_WORDS
#define TILEMAP_ROW_WORDS (BG_SCREEN_WIDTH / 2)
A tilemap row's words.
Referenced by mnCreditsBuildBackgroundTilemap().
Definition at line 79 of file credits.c.
CREDITS_BLANK_TILE
#define CREDITS_BLANK_TILE 511
The tile the margins show: the character block's last, which lies in the screen block's own zeroed tail and so is clear.
Referenced by mnCreditsBuildBackgroundTilemap().
Definition at line 82 of file credits.c.
SCROLL_OBJECTS
#define SCROLL_OBJECTS CreditsScrollObjects
#define SCROLL_OBJECTS (*(CREDITS_OAM_ENTRY **)&FlashNumRemainingBytes)
The three cells, as the credits read them.
Referenced by mnCreditsInitTextSprites() and mnCreditsUpdateTextSprites().
Definition at lines 342 and 346 of file credits.c.
CREDITS_LAST_LINE_POSITION
#define CREDITS_LAST_LINE_POSITION CreditsLastLinePosition
#define CREDITS_LAST_LINE_POSITION (*(Sint16 *)&FlashWork)
Referenced by mnCreditsDrawEnteringLine() and mnCreditsInitTextSprites().
Definition at lines 343 and 347 of file credits.c.
CREDITS_END_OF_TEXT
#define CREDITS_END_OF_TEXT CreditsEndOfText
#define CREDITS_END_OF_TEXT (*(Sint16 *)&ProgramFlashSectorWork)
Referenced by mnCreditsDrawEnteringLine(), mnCreditsInitTextSprites() and mnCreditsUpdateTextSprites().
Definition at lines 344 and 348 of file credits.c.
CREDITS_STAFF_TITLE
#define CREDITS_STAFF_TITLE "OUGON NO TAIYO STAFF"
#define CREDITS_STAFF_TITLE "GOLDEN SUN STAFF CREDITS"
Referenced by CreditsLines.
Definition at lines 356 and 362 of file credits.c.
CREDITS_FACES_SUBTITLE
#define CREDITS_FACES_SUBTITLE "& Faces"
#define CREDITS_FACES_SUBTITLE " & Faces"
Referenced by CreditsLines.
Definition at lines 357 and 363 of file credits.c.
CREDITS_SOUND_DIRECTION_LABEL
#define CREDITS_SOUND_DIRECTION_LABEL "Sound Direction"
#define CREDITS_SOUND_DIRECTION_LABEL "Sound Director"
Referenced by CreditsLines.
Definition at lines 358 and 364 of file credits.c.
CREDITS_GRAPHICS_SUPPORT_LABEL
#define CREDITS_GRAPHICS_SUPPORT_LABEL "Graphic Support"
#define CREDITS_GRAPHICS_SUPPORT_LABEL "Graphic Supports"
Referenced by CreditsLines.
Definition at lines 359 and 365 of file credits.c.
CREDITS_ARTWORK_LABEL
#define CREDITS_ARTWORK_LABEL "Artwork Design"
#define CREDITS_ARTWORK_LABEL "Artwork"
Referenced by CreditsLines.
Definition at lines 360 and 366 of file credits.c.
FLAG_CREDITS_LINE_DRAWN
#define FLAG_CREDITS_LINE_DRAWN FLAG_SCENE_TEMP(0x00)
A credits line has been drawn, so its scratch buffer holds the shadow row to carry.
Referenced by mnCreditsDrawLine().
Definition at line 1002 of file credits.c.
OBJ_TILE_ROW
#define OBJ_TILE_ROW(tile, row)
Row row (4 bytes, 8 pixels) of sprite tile tile in OBJ VRAM.
Referenced by mnCreditsDrawLine().
Definition at line 1132 of file credits.c.
Typedefs in detail
PACKED_DECODER
typedef Sint32 (*PACKED_DECODER)(const Uint8 *source, void *destination, Uint32 fill);
Referenced by mnCreditsLoadBackground().
Definition at line 121 of file credits.c.
Enumerations in detail
CREDITS_ALIGNMENT
enum CREDITS_ALIGNMENT
Where mnCreditsDrawLine starts a line in its 192-pixel row.
| Enumerator | Value | Description |
|---|---|---|
CREDITS_ALIGN_LEFT | ||
CREDITS_ALIGN_CENTER | ||
CREDITS_ALIGN_RIGHT |
Definition at line 85 of file credits.c.
Functions in detail
mnCreditsClearBuffer
void mnCreditsClearBuffer(Sint32 alternate)
Fills a battle background's 256-colour tiles with colour 1 of its half, black once its palette is cleared and opaque, for the next crossfade, and clears the half's palette colours. alternate is 0 for the first half (character block 0, the low palette half), 1 for the second (character block 2, the high palette half).
References Sint32.
Referenced by mnCreditsLoadBackground() and mnCreditsRun().
Definition at lines 15 and 97 of file credits.c.
mnCreditsLoadBackground
void mnCreditsLoadBackground(Uint32 resourceId, Sint32 alternate)
Loads a credits battle background into one of the two tile/palette halves.
References CreditsDecodeBackgroundCodeSize, HeapSlots, mnCreditsClearBuffer(), mnCreditsDecodeBackground, Sint32, syHeapSlotRelease() and syResourceGetTableEntry().
Referenced by mnCreditsRun().
Definition at lines 19 and 165 of file credits.c.
mnCreditsBuildBackgroundTilemap
void mnCreditsBuildBackgroundTilemap(Uint32 *dest)
Builds a battle background's tilemap: two blank rows, its tiles in order over fifteen rows, three blank rows, then a zeroed tail.
References Sint32.
Referenced by mnCreditsRun().
Definition at lines 20 and 211 of file credits.c.
mnCreditsScrollBackgrounds
void mnCreditsScrollBackgrounds(void)
A VBlank event of the credits: drifts both pictures together, keeping their horizontal offsets aligned throughout the crossfade.
References BgScrollWork and FrameCount.
Referenced by mnCreditsRun().
Definition at lines 21 and 234 of file credits.c.
mnCreditsUpdateTextSprites
void mnCreditsUpdateTextSprites(void)
A VBlank event added by mnCreditsInitTextSprites: maps the visible sixteen
rows onto the tile ring and uploads their sprites.
References CreditsScrollPosition, FrameCount, Sint32 and syDMAXCopy().
Referenced by mnCreditsInitTextSprites().
Definition at lines 28 and 1006 of file credits.c.
mnCreditsDrawEnteringLine
void mnCreditsDrawEnteringLine(void)
A tick-pass event added by mnCreditsInitTextSprites: 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.
References CreditsLines, CreditsScrollPosition, mnCreditsDrawLine() and Sint32.
Referenced by mnCreditsInitTextSprites().
Definition at lines 29 and 1041 of file credits.c.
mnCreditsInitTextSprites
void mnCreditsInitTextSprites(void)
Allocates the credits sprites, builds the blank border and text rows, clears the tile ring and adds the scrolling and line-rendering events.
References CreditsLines, CreditsScrollPosition, mnCreditsDrawEnteringLine(), mnCreditsDrawLine(), mnCreditsUpdateTextSprites(), syHeapAllocateEWRAM() and sySetEvent().
Referenced by mnCreditsRun().
Definition at lines 30 and 1065 of file credits.c.
mnCreditsDrawLine
Sint32 mnCreditsDrawLine(const Uint8 *text, Sint32 firstTile, Sint32 alignment)
Centers, right-aligns or left-aligns one credits line in a 192-pixel row.
References CreditsFont, CreditsGlyphWidths, gmFlagGetStub(), gmFlagSetStub(), Sint32, syHeapAllocateEWRAM(), syHeapRelease(), syWordsCopy() and syWordsFill().
Referenced by mnCreditsDrawEnteringLine() and mnCreditsInitTextSprites().
Definition at lines 31 and 1136 of file credits.c.
mnCreditsRun
Sint32 mnCreditsRun(void)
Crossfades the credits' battle backgrounds through alternating tile banks while the staff names scroll over it, then restores the display for the following screen.
References CpuLoadDisplayEnabled, CreditsBackgrounds, DebugTextEnabled, IdleSleepEnabled, mnCreditsBuildBackgroundTilemap(), mnCreditsClearBuffer(), mnCreditsInitTextSprites(), mnCreditsLoadBackground(), mnCreditsScrollBackgrounds(), OamCopyEnabled, Sint32, syInitEvent(), syPrintClear(), sySetEvent(), sySynch() and syWindowLoadGraphics().
Definition at line 248 of file credits.c.
Variables in detail
CreditsBackgrounds
extern const Uint32 CreditsBackgrounds[]
const Uint32 CreditsBackgrounds[]
The battle backgrounds shown in turn, ending with 0, which clears.
Battle backgrounds shown in the credits; 0 clears the display.
Referenced by mnCreditsRun().
Definition at lines 18 and 127 of file credits.c.
CreditsLines
extern const void *CreditsLines[]
const void *CreditsLines[]
The credits' lines, one per 8 pixels of scroll, ending with NULL.
Credits text, one row per line, terminated by 0. A line is 8 pixels of
scroll, 32 ticks; the text is drawn with CreditsFont, ASCII 32 to 127.
References BlankCreditLine.
Referenced by mnCreditsDrawEnteringLine() and mnCreditsInitTextSprites().
Definition at lines 24 and 372 of file credits.c.
CreditsGlyphWidths
extern const Uint8 CreditsGlyphWidths[96]
const Uint8 CreditsGlyphWidths[96]
The credits font's widths in pixels, for characters 32 to 127.
The staff credits font's advance widths in pixels, character codes 32 to 127,
beside the font (font.png).
Referenced by mnCreditsDrawLine().
Definition at lines 27 and 990 of file credits.c.
CreditsScrollPosition
extern Uint16 CreditsScrollPosition
Credits scroll position in pixels, in the low half of WaitForFlashWriteWork.
Referenced by mnCreditsDrawEnteringLine(), mnCreditsInitTextSprites() and mnCreditsUpdateTextSprites().
Definition at line 321 of file credits.c.
CreditsScrollObjects
extern CREDITS_OAM_ENTRY *CreditsScrollObjects
The sprite buffer, in FlashNumRemainingBytes.
Definition at line 335 of file credits.c.
CreditsLastLinePosition
extern Sint16 CreditsLastLinePosition
The last line drawn, as a pixel position, in the low half of FlashWork.
Definition at line 337 of file credits.c.
CreditsEndOfText
extern Sint16 CreditsEndOfText
0 until the text ends, then -1, in the low half of ProgramFlashSectorWork.
Definition at line 339 of file credits.c.
BlankCreditLine
static const Uint8 BlankCreditLine[]
Referenced by CreditsLines.
Definition at line 351 of file credits.c.