transition.c
The opening transition: the curtain, or the Venus Lighthouse storm.
games/tbs/src/battle/battle/transition.c on GitHub
The opening transition: the curtain, or the Venus Lighthouse storm. Part of battle.c, the battle object, compiled only through it.
Functions
BattlePres_RunMosaicFadeOut
s32 BattlePres_RunMosaicFadeOut(void)
Fades the screen to black over sixteen frames as every background's mosaic grows, then shows no layer. Reached only through its entry in the battle bank's far-call table (FarCall_BattleTable), which no code in TBS names. Sets REG_BLDCNT to darken the backgrounds, leaves REG_MOSAIC at its largest and REG_DISPCNT in mode 1 with every layer off; the four BGxCNT are put back as they were. It draws four random numbers a frame, which only advances the sequence. Returns 0.
Graphics_BuildSequentialTileTable
void Graphics_BuildSequentialTileTable(void *tilemap)
Builds the perspective plane's 32 by 32 affine map: tiles 0 to 255 in its first eight rows, 0 to 223 in the next seven, and 0xff in the rest. The two runs show the background picture's two halves, which the scanline BG2CNT values (BattleCamera_SetRange) read from character blocks 2 and 3. Called with screen block 7 by BattleBackground_Load and BattlePresentation_ConfigurePaletteFade.
Used by BattleBackground_Load, BattlePresentation_ConfigurePaletteFade.
BattlePresentation_BuildTilemap
void BattlePresentation_BuildTilemap(void *tilemap)
Builds BG1's flat map of the same picture: rows 0 to 3 0xffff, rows 4 and 5 tile 0x3ff, rows 6 to 20 tiles 0x200 to 0x3df in order, then tile 0x3ff. In 256 colours from character block 0, tile 0x200 is the start of block 2, where BattleBackground_Load decodes the picture. Called with screen block 31 (BATTLE_BG1CNT) by BattleBackground_Load and BattlePresentation_ConfigurePaletteFade.
Used by BattleBackground_Load, BattlePresentation_ConfigurePaletteFade.
BattlePres_UpdateHBlankScroll
void BattlePres_UpdateHBlankScroll(void)
Shows the perspective plane's finished page each frame while the background is in mode 2: its first line's BG2CNT now, the rest by HBlank DMA 0, and its affine parameters into BG2PA to BG2Y. Runs each frame as a scheduler callback, in the VBlank pass at its highest rank (order 0x4ff), added by BattleBackground_Load and BattlePresentation_ConfigurePaletteFade; BattleCamera_SetRange builds the pages.
Used by BattleBackground_Load, BattlePresentation_ConfigurePaletteFade.
BattlePresentation_UploadTileVariant
void BattlePresentation_UploadTileVariant(void)
Copies one of eight curtain tiles from gBattlePres_TileVariants into CURTAIN_TILE(0), a new one every four frames while the transition timer (gDisp) runs from 1 to 32. XXX: no code in TBS names it; a scheduler or table entry that reaches it would show which transition used it.
BattlePres_AdvanceTransitionTimer
void BattlePres_AdvanceTransitionTimer(void)
Advances the curtain opening by a frame: scrolls BG0 from 32 pixels to 0 over frames 20 to 52, and over frames 0 to 80 turns the camera round to YAW_PARTY_TURN and zooms it from 180 to 100 percent. Runs each frame as a scheduler callback added by BattlePres_RunEntryTransition, which removes it once the encounter is announced. Advances the timer in gDisp's slot (heap slot 42), and writes gBgScroll[0].y and the camera's yaw.
Used by BattlePres_RunEntryTransition.
BattlePres_DrawTransitionRows
void BattlePres_DrawTransitionRows(void)
Draws a frame of the curtain opening on BG1: over 80 frames a row moves up from row 13 to row 4 and its vertically flipped twin down to row 20, the row's tile stepping through CURTAIN_TILE(1) to (8), the last one clear. Runs each frame as a scheduler callback added by BattlePres_RunEntryTransition, reading the frame from gDisp's timer; writes BG1's map in screen block 12.
Used by BattlePres_RunEntryTransition.
Graphics_ClearBg0Vofs
void Graphics_ClearBg0Vofs(void)
Clears REG_BG0VOFS, so that BG0's scroll applies only above the line the interrupt fires on. Installed by BattlePres_RunEntryTransition as the VCount interrupt's handler at line 32, while gBgScroll[0].y holds BG0 scrolled.
Used by BattlePres_RunEntryTransition.
BattlePres_RunEntryTransition
void BattlePres_RunEntryTransition(s32 enemyCount, s32 encounterId)
Opens a battle: the curtain opening, or for the Fusion Dragon the storm on the Venus Lighthouse aerie; then announces the enemies and leaves the battle's display set. Called once by Battle_RunEncounter with the enemy count and formation. Uses heap slot 42 for the opening's frame timer and frees it; leaves BG1 on BATTLE_BG1CNT, BG0's priority lowered by 2 again, REG_DISPCNT showing BG0, BG2 and the sprites, and no VCount handler. The storm also sets BattleWork.background to the aerie's storm backdrop.
Used by Battle_RunEncounter.
Structures
DisplayRegisters
struct DisplayRegisters
The display control and green swap registers, REG_DISPCNT onward.
| Field | Declared as | |
|---|---|---|
control | u16 control | REG_DISPCNT |
greenSwap | u16 greenSwap | the undocumented green swap register after it |
Used by BattlePres_RunEntryTransition.
Macros
TRANSITION_STORM_FORMATION
#define TRANSITION_STORM_FORMATION 0x15b
The formation the Fusion Dragon leads (row 347 of formatn.tsv, whose first member is enemy 140), fought on the Venus Lighthouse aerie: it opens with the storm instead of the curtain.
Used by BattlePres_RunEntryTransition.
TRANSITION_CURTAIN_ENTRY
#define TRANSITION_CURTAIN_ENTRY(n) (0xf080 + (n))
The curtain's map entries: tile 128 + n of CURTAIN_TILE, palette 15.
Used by BattlePres_RunEntryTransition.