Alchemy
Loading...
Searching...
No Matches

transition.c File Reference

The opening transition: the curtain, or the Venus Lighthouse storm. More...

Go to the source code of this file.

Data Structures

struct  DisplayRegisters
 The display control and green swap registers, REG_DISPCNT onward. More...

Macros

#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.
#define TRANSITION_CURTAIN_ENTRY(n)
 The curtain's map entries: tile 128 + n of CURTAIN_TILE, palette 15.

Functions

s32 BattlePres_RunMosaicFadeOut (void)
 Fades the screen to black over sixteen frames as every background's mosaic grows, then shows no layer.
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.
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.
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.
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.
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.
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.
void Graphics_ClearBg0Vofs (void)
 Clears REG_BG0VOFS, so that BG0's scroll applies only above the line the interrupt fires on.
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.

Detailed Description

The opening transition: the curtain, or the Venus Lighthouse storm.

Part of battle.c, the battle object, compiled only through it.

Definition in file transition.c.

Macro Definition Documentation

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

Definition at line 10 of file transition.c.

Referenced by BattlePres_RunEntryTransition().

◆ TRANSITION_CURTAIN_ENTRY

#define TRANSITION_CURTAIN_ENTRY ( n)
Value:
(0xf080 + (n))

The curtain's map entries: tile 128 + n of CURTAIN_TILE, palette 15.

Definition at line 13 of file transition.c.

Referenced by BattlePres_RunEntryTransition().

Function Documentation

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

Definition at line 22 of file transition.c.

Referenced by BattlePres_RunMosaicFadeOut().

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

Definition at line 75 of file transition.c.

Referenced by BattleBackground_Load(), BattlePresentation_ConfigurePaletteFade(), and Graphics_BuildSequentialTileTable().

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

Definition at line 106 of file transition.c.

Referenced by BattleBackground_Load(), BattlePresentation_BuildTilemap(), and 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, added by BattleBackground_Load and BattlePresentation_ConfigurePaletteFade; BattleCamera_SetRange builds the pages.

Definition at line 132 of file transition.c.

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

Definition at line 153 of file transition.c.

Referenced by BattlePresentation_UploadTileVariant().

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

Definition at line 167 of file transition.c.

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

Definition at line 202 of file transition.c.

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

Definition at line 252 of file transition.c.

Referenced by BattlePres_RunEntryTransition(), and Graphics_ClearBg0Vofs().

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

Definition at line 272 of file transition.c.

Referenced by Battle_RunEncounter(), and BattlePres_RunEntryTransition().