Alchemy
Loading...
Searching...
No Matches

transition.c File Reference

Window transitions and dissolves between scenes. More...

Go to the source code of this file.

Data Structures

struct  TransitionSpan
 A run of screen lines in a transition shape: one window edge pair for every line, or, when that is 0, edges moving from left x0 and right y0 to left x1 and right y1 down the run. More...
struct  TransitionShape
 One step of the shape window transition: the WININ and WINOUT values, swapped as the transition opens or closes, and three runs of lines. More...

Functions

void BattleFx_StartWindowHBlankDma (void)
 Each frame, before drawing: turns windows 0 and 1 on, writes the first four values of the shown page into WININ, WINOUT, WIN0H and WIN1H, and has DMA 0 copy the rest into WIN0H and WIN1H one word each HBlank, so that every line of the screen gets its own window edges.
void DisplayTransition_UpdateScanlineTable (void)
 Each frame of a window transition: advances its value toward its end (and at the end turns the windows off, or moves to the next mode), then builds the next page of window edges, WININ and WINOUT first and then a (left << 8 | right) pair for each of the 160 lines.
void DisplayTransition_InitializeBattleEffectState (s32 mode)
 Starts window transition mode at value 0, with no duration: the caller moves it.
void DisplayTransition_SuspendCallbacks (void)
 Suspends the window transition's two callbacks.
struct DisplayTransitionState * DisplayTransition_AllocateAndClearState (void)
 Allocates the display transition state (heap block 31) and clears it.
void DisplayTransition_Start (s32 mode, s32 frames)
 Fades the screen in over frames frames.
void DisplayTransition_Finish (s32 mode, s32 frames)
 Fades the screen out over frames frames, as DisplayTransition_Start fades it in.
void DisplayState_ClearFlags (s32 clearBg3, s32 clearBg2, s32 clearBg1)
 Clears the map's display-control bits for backgrounds 3, 2 and 1 (0x0800, 0x0400 and 0x0200) for each argument that is set.
void DisplayTransition_Update (void)
 Each frame of the centre-line transition: moves the value toward its end and sets the two lines where the screen switches between shown and blank.
void DisplayTransition_UpdateFromCentre (void)
 As DisplayTransition_Update, but the lines flicker every other frame.
void DisplayTransition_UpdateScanline (void)
 The VCount interrupt of the centre-line transition: switches the display to mode 2 (nothing shown) at the first line and back to mode 0 at the second.
void DisplayTransition_UpdateFrame (void)
 Each frame of the dissolve: moves the value toward its end and sets two more of the solid tile's 64 pixels, in the order of gDisplayTransition_DitherTable, to colour 15 (or 0 when closing).
void DisplayTransition_FillTilemapAndSolidTile (s32 color)
 Fills background screen block 4 with tile 0 in palette 15 and, unless color is -1, makes tile 0 solid color.
void DisplayTransition_InitializeState (s32 value)
 Starts a dissolve of the given mode and waits 120 frames.

Variables

struct TransitionShape gDisplayTransition_Shapes []

Detailed Description

Window transitions and dissolves between scenes.

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

Definition in file transition.c.

Function Documentation

◆ BattleFx_StartWindowHBlankDma()

void BattleFx_StartWindowHBlankDma ( void )

Each frame, before drawing: turns windows 0 and 1 on, writes the first four values of the shown page into WININ, WINOUT, WIN0H and WIN1H, and has DMA 0 copy the rest into WIN0H and WIN1H one word each HBlank, so that every line of the screen gets its own window edges.

A scheduler callback (priority 0x480) that DisplayTransition_Start, DisplayTransition_Finish and DisplayTransition_InitializeBattleEffectState add for a window transition, and DisplayTransition_UpdateScanlineTable removes when it ends.

Definition at line 16 of file transition.c.

Referenced by BattleFx_ClearRandomParticles(), BattleFx_StartWindowHBlankDma(), DisplayTransition_Finish(), DisplayTransition_InitializeBattleEffectState(), DisplayTransition_Start(), DisplayTransition_SuspendCallbacks(), and DisplayTransition_UpdateScanlineTable().

◆ DisplayTransition_UpdateScanlineTable()

void DisplayTransition_UpdateScanlineTable ( void )

Each frame of a window transition: advances its value toward its end (and at the end turns the windows off, or moves to the next mode), then builds the next page of window edges, WININ and WINOUT first and then a (left << 8 | right) pair for each of the 160 lines.

Bit 5 of the value says whether the transition opens or closes; its low 5 bits are its progress. Modes: 0 random bars, 1 a shape from gDisplayTransition_Shapes, 2 random horizontal noise, 3 a circle at the screen's centre, 4 alternate lines wiping in from the left and the right, 7 and 9 an ellipse wider than tall around the party leader (7 flickers), 8 a wobbling ellipse around a point, 77 an ellipse a little taller than wide, centred 8 pixels lower on the leader.

A scheduler callback (priority 0xc80), added with BattleFx_StartWindowHBlankDma; it removes both and stops DMA 0 when a transition with no next mode ends. Writes the hidden page of the transition state (heap slot 31) and then flips state->page.

Definition at line 75 of file transition.c.

Referenced by BattleFx_ClearRandomParticles(), DisplayTransition_Finish(), DisplayTransition_InitializeBattleEffectState(), DisplayTransition_Start(), DisplayTransition_SuspendCallbacks(), and DisplayTransition_UpdateScanlineTable().

◆ DisplayTransition_InitializeBattleEffectState()

void DisplayTransition_InitializeBattleEffectState ( s32 mode)

Starts window transition mode at value 0, with no duration: the caller moves it.

Called by Reveal's effect (mode 8) and, through DisplayTransition_InitializeBattleEffectStateFar, by three scenes (Altmiller Cave, Tret Tree's branch and Babi's palace). Allocates and clears the transition state in heap slot 31 and adds both window callbacks; mask 0x3f3f shows every layer in both windows.

Definition at line 559 of file transition.c.

Referenced by AltmillerCave_InitializeDarkness(), BabiPalace_WakeAfterFinals(), BattleFx_ClearRandomParticles(), DisplayTransition_InitializeBattleEffectState(), Event_CastReveal(), FieldFx_RunReveal(), and TretTreeBranch_Initialize().

◆ DisplayTransition_SuspendCallbacks()

void DisplayTransition_SuspendCallbacks ( void )

Suspends the window transition's two callbacks.

XXX: nothing in ☀️ names it and it has no far-call entry, yet it is not marked UNUSED; a caller through a table or ⚓️'s twin would settle it.

Definition at line 576 of file transition.c.

Referenced by BattleFx_ClearRandomParticles(), and DisplayTransition_SuspendCallbacks().

◆ DisplayTransition_AllocateAndClearState()

struct DisplayTransitionState * DisplayTransition_AllocateAndClearState ( void )

Allocates the display transition state (heap block 31) and clears it.

Called by DisplayTransition_Start and DisplayTransition_Finish for every kind but the two fades.

Definition at line 585 of file transition.c.

Referenced by BattleFx_ClearRandomParticles(), DisplayTransition_AllocateAndClearState(), DisplayTransition_Finish(), and DisplayTransition_Start().

◆ DisplayTransition_Start()

void DisplayTransition_Start ( s32 mode,
s32 frames )

Fades the screen in over frames frames.

mode's high byte chooses how: 0 from black, 1 from the backdrop colour, 2 a window transition (its low byte the mode), 3 a dissolve, 4 opening from the centre line (low byte 1 flickers).

Called by Field_RunScene to fade a scene in with work->transition and work->transitionFrames, and by Event_StartScreenTransition for scene scripts. Kinds 2 to 4 add a scheduler callback (and kind 4 the VCount handler, IRQ 1) that runs the transition; every kind ORs the map's display bits into DISPCNT through the I/O write queue.

Definition at line 603 of file transition.c.

Referenced by BattleFx_ClearRandomParticles(), DisplayTransition_Start(), Event_StartScreenTransition(), and Field_RunScene().

◆ DisplayTransition_Finish()

void DisplayTransition_Finish ( s32 mode,
s32 frames )

Fades the screen out over frames frames, as DisplayTransition_Start fades it in.

Called by Field_RunScene as a scene ends, by Field_StartEncounterTransition before a battle (kinds 0x401 and 0x207), and by Event_FinishScreenTransition for scene scripts. The window and dissolve kinds run from value 32 to 64, the centre line from 0 to 80.

Definition at line 698 of file transition.c.

Referenced by BattleFx_ClearRandomParticles(), DisplayTransition_Finish(), Event_FinishScreenTransition(), Field_RunScene(), and Field_StartEncounterTransition().

◆ DisplayState_ClearFlags()

void DisplayState_ClearFlags ( s32 clearBg3,
s32 clearBg2,
s32 clearBg1 )

Clears the map's display-control bits for backgrounds 3, 2 and 1 (0x0800, 0x0400 and 0x0200) for each argument that is set.

Reached only through its unnamed far-call veneer. DisplayTransition_Start ORs these bits into DISPCNT.

Definition at line 771 of file transition.c.

Referenced by BattleFx_ClearRandomParticles(), and DisplayState_ClearFlags().

◆ DisplayTransition_Update()

void DisplayTransition_Update ( void )

Each frame of the centre-line transition: moves the value toward its end and sets the two lines where the screen switches between shown and blank.

A scheduler callback added by DisplayTransition_Start and DisplayTransition_Finish for kind 4, variant 0; when its run ends it removes itself and the VCount handler.

Definition at line 794 of file transition.c.

Referenced by BattleFx_ClearRandomParticles(), DisplayTransition_Finish(), DisplayTransition_Start(), and DisplayTransition_Update().

◆ DisplayTransition_UpdateFromCentre()

void DisplayTransition_UpdateFromCentre ( void )

As DisplayTransition_Update, but the lines flicker every other frame.

The kind 4 callback for a non-zero variant.

Definition at line 834 of file transition.c.

Referenced by BattleFx_ClearRandomParticles(), DisplayTransition_Finish(), DisplayTransition_Start(), and DisplayTransition_UpdateFromCentre().

◆ DisplayTransition_UpdateScanline()

void DisplayTransition_UpdateScanline ( void )

The VCount interrupt of the centre-line transition: switches the display to mode 2 (nothing shown) at the first line and back to mode 0 at the second.

Installed as IRQ handler 1 by DisplayTransition_Start and DisplayTransition_Finish for kind 4. Phases: 0 waits for a line on screen, 1 for whichever edge line comes first, 2 and 3 for the other one; 9 is done.

Definition at line 879 of file transition.c.

Referenced by BattleFx_ClearRandomParticles(), DisplayTransition_Finish(), DisplayTransition_Start(), and DisplayTransition_UpdateScanline().

◆ DisplayTransition_UpdateFrame()

void DisplayTransition_UpdateFrame ( void )

Each frame of the dissolve: moves the value toward its end and sets two more of the solid tile's 64 pixels, in the order of gDisplayTransition_DitherTable, to colour 15 (or 0 when closing).

The dissolve's scheduler callback (kind 3 of DisplayTransition_Start and DisplayTransition_Finish, and DisplayTransition_InitializeState). Queues the changed tile into character block 0 each frame.

Definition at line 930 of file transition.c.

Referenced by BattleFx_ClearRandomParticles(), DisplayTransition_Finish(), DisplayTransition_InitializeState(), DisplayTransition_Start(), and DisplayTransition_UpdateFrame().

◆ DisplayTransition_FillTilemapAndSolidTile()

void DisplayTransition_FillTilemapAndSolidTile ( s32 color)

Fills background screen block 4 with tile 0 in palette 15 and, unless color is -1, makes tile 0 solid color.

Sets up the dissolve for DisplayTransition_Start (colour 15), DisplayTransition_Finish and DisplayTransition_InitializeState (colour 0).

Definition at line 979 of file transition.c.

Referenced by BattleFx_ClearRandomParticles(), DisplayTransition_FillTilemapAndSolidTile(), DisplayTransition_Finish(), DisplayTransition_InitializeState(), and DisplayTransition_Start().

◆ DisplayTransition_InitializeState()

void DisplayTransition_InitializeState ( s32 value)

Starts a dissolve of the given mode and waits 120 frames.

It sets no duration, so the dissolve stays at value 0 until a caller moves it. Reached only through its unnamed far-call veneer.

Definition at line 1000 of file transition.c.

Referenced by BattleFx_ClearRandomParticles(), and DisplayTransition_InitializeState().

Variable Documentation

◆ gDisplayTransition_Shapes

struct TransitionShape gDisplayTransition_Shapes[]
extern