src/field/field_engine_screen_transition.c
The screen transitions: windows that close over the screen or open it, line by line, and the dissolve. More…
Included by field_engine.c.
Macros
| Name | Description | |
|---|---|---|
#define | TRANSITION_OPEN 32 | A window transition's value: from 0, the screen covered, it opens to TRANSITION_OPEN and closes again to TRANSITION_CLOSED; a mode draws the opening half and the closing half mirrored. |
#define | TRANSITION_CLOSED 64 | |
#define | TRANSITION_NOISE_EDGE_MAX 255 | The widest a line's window reaches from the left edge in WINDOW_TRANSITION_NOISE: WIN0H's right edge is a byte. |
#define | TRANSITION_RIPPLE_LINES_MAX 120 | WINDOW_TRANSITION_RIPPLE measures a line further than this from its centre as this far. |
#define | TRANSITION_EDGE_OFFSETS 32 | ScreenTransitionEdgeOffsets' entries, the ripple's period in lines. |
#define | CENTER_LINE_HIDDEN_FIRST 200 | Where the centre-line transition puts its two lines once they meet: below the screen, so no switch happens. |
#define | CENTER_LINE_HIDDEN_SECOND 250 | |
#define | DISSOLVE_COVER_COLOR 15 | The colour the dissolve covers the screen in, the window palette's last. |
#define | WINOUT_WINOBJ_MASK 0xff00 | REG_WINOUT's high byte, what the sprite window shows, which a window transition keeps as it was. |
#define | CLAMP_SPAN_TO_SCREEN (left, right) | Keeps a line's window edges on the screen, 0 to DISPLAY_WIDTH. |
#define | WRITE_ELLIPSE_LINES (squash) | Writes every line's window edges for an ellipse round (centerX, centerY) whose half-width on a line dy from its centre is sqrt(r * r - squash * dy * dy), with r * r in radiusSquaredFixed (squash in 16.16). |
Enumerations
| Name | Description | |
|---|---|---|
enum | SCREEN_TRANSITION_IRQ_PHASE { DISPLAY_TRANSITION_IRQ_WAIT_SCREEN, DISPLAY_TRANSITION_IRQ_W … } | Where the centre-line transition's HBlank interrupt is. |
Functions
| Name | Description | |
|---|---|---|
void | fdEffectStartWindowHBlankDMA (void) | Each VBlank, 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 | fdScreenTransitionUpdateScanlineTable (void) | Each tick 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 | fdScreenTransitionStartWindowHeld (Sint32 mode) | Starts window transition mode at value 0, with no duration: the caller moves it. |
void | fdScreenTransitionSuspendCallbacks (void) | Unused: suspends the window transition's two events. |
SCREEN_TRANSITION_STATE * | fdScreenTransitionAllocateAndClearState (void) | Allocates the screen transition state (HEAP_SLOT_SCREEN_TRANSITION) and clears it. |
void | fdScreenTransitionStart (Sint32 mode, Sint32 ticks) | Fades the screen in over ticks ticks. mode is a SCENE_TRANSITION: its high byte an SCREEN_TRANSITION_STYLE (from black, from the backdrop colour, a window transition whose low byte is an WINDOW_TRANSITION_MODE, a dissolve, or opening from the centre line, which a non-zero low byte makes flicker). |
void | fdScreenTransitionFinish (Sint32 mode, Sint32 ticks) | Fades the screen out over ticks ticks, as fdScreenTransitionStart fades it in. |
Bool | fdScreenTransitionIsScanlineActive (void) | Returns 1 while fdScreenTransitionUpdateScanline is the HBlank handler, that is, while a centre-line transition runs. |
void | fdScreenTransitionHideBackgrounds (Sint32 clearBg3, Sint32 clearBg2, Sint32 clearBg1) | Clears the map's display-control bits for backgrounds 3, 2 and 1 (DISPCNT_BG3_ON, DISPCNT_BG2_ON and DISPCNT_BG1_ON) for each argument that is set. |
void | fdScreenTransitionUpdate (void) | Each tick of the centre-line transition: moves the value toward its end and sets the two lines where the screen switches between shown and blank; at the end the map draws its usual three extra tiles again. |
void | fdScreenTransitionUpdateFromCenter (void) | As fdScreenTransitionUpdate, but the lines flicker every other tick. |
void | fdScreenTransitionUpdateScanline (void) | The HBlank interrupt of the centre-line transition: switches the display to DISPCNT_MODE_2 (nothing shown) at the first line and back to DISPCNT_MODE_0 at the second. |
void | fdScreenTransitionUpdateDissolve (void) | Each tick of the dissolve: moves the value toward its end and sets two more of the solid tile's 64 pixels, in the order of ScreenTransitionDitherTable: to colour 0 while the screen opens (values up to TRANSITION_OPEN clear the cover fdScreenTransitionStart filled with DISSOLVE_COVER_COLOR), and to DISSOLVE_COVER_COLOR while it closes (values after it fill the clear tile fdScreenTransitionFinish starts from). |
void | fdScreenTransitionFillTilemapAndColorTile (Sint32 color) | Fills background screen block 4 with tile 0 in WINDOW_PALETTE and, unless color is -1, makes tile 0 solid color. |
void | fdScreenTransitionStartDissolveHeld (Sint32 mode) | Starts a dissolve of the given mode, its value held at 0, and waits two seconds. |
Description
The screen transitions: windows that close over the screen or open it, line
by line, and the dissolve. Part of field_engine.c.
Macros in detail
TRANSITION_OPEN
#define TRANSITION_OPEN 32
A window transition's value: from 0, the screen covered, it opens to
TRANSITION_OPEN and closes again to TRANSITION_CLOSED; a mode draws the
opening half and the closing half mirrored.
Referenced by fdScreenTransitionFinish(), fdScreenTransitionStart(), fdScreenTransitionUpdateDissolve() and fdScreenTransitionUpdateScanlineTable().
Definition at line 7 of file field_engine_screen_transition.c.
TRANSITION_CLOSED
#define TRANSITION_CLOSED 64
Referenced by fdScreenTransitionFinish() and fdScreenTransitionUpdateScanlineTable().
Definition at line 8 of file field_engine_screen_transition.c.
TRANSITION_NOISE_EDGE_MAX
#define TRANSITION_NOISE_EDGE_MAX 255
The widest a line's window reaches from the left edge in
WINDOW_TRANSITION_NOISE: WIN0H's right edge is a byte.
Referenced by fdScreenTransitionUpdateScanlineTable().
Definition at line 11 of file field_engine_screen_transition.c.
TRANSITION_RIPPLE_LINES_MAX
#define TRANSITION_RIPPLE_LINES_MAX 120
WINDOW_TRANSITION_RIPPLE measures a line further than this from its centre as
this far.
Referenced by fdScreenTransitionUpdateScanlineTable().
Definition at line 14 of file field_engine_screen_transition.c.
TRANSITION_EDGE_OFFSETS
#define TRANSITION_EDGE_OFFSETS 32
ScreenTransitionEdgeOffsets' entries, the ripple's period in lines.
Referenced by fdScreenTransitionUpdateScanlineTable().
Definition at line 16 of file field_engine_screen_transition.c.
CENTER_LINE_HIDDEN_FIRST
#define CENTER_LINE_HIDDEN_FIRST 200
Where the centre-line transition puts its two lines once they meet: below the screen, so no switch happens.
Referenced by fdScreenTransitionUpdate() and fdScreenTransitionUpdateFromCenter().
Definition at line 19 of file field_engine_screen_transition.c.
CENTER_LINE_HIDDEN_SECOND
#define CENTER_LINE_HIDDEN_SECOND 250
Referenced by fdScreenTransitionUpdate() and fdScreenTransitionUpdateFromCenter().
Definition at line 20 of file field_engine_screen_transition.c.
DISSOLVE_COVER_COLOR
#define DISSOLVE_COVER_COLOR 15
The colour the dissolve covers the screen in, the window palette's last.
Referenced by fdScreenTransitionStart() and fdScreenTransitionUpdateDissolve().
Definition at line 22 of file field_engine_screen_transition.c.
WINOUT_WINOBJ_MASK
#define WINOUT_WINOBJ_MASK 0xff00
REG_WINOUT's high byte, what the sprite window shows, which a window
transition keeps as it was.
Referenced by fdScreenTransitionFinish(), fdScreenTransitionStart() and fdScreenTransitionStartWindowHeld().
Definition at line 25 of file field_engine_screen_transition.c.
CLAMP_SPAN_TO_SCREEN
#define CLAMP_SPAN_TO_SCREEN(left, right)
Keeps a line's window edges on the screen, 0 to DISPLAY_WIDTH.
Referenced by fdScreenTransitionUpdateScanlineTable().
Definition at line 28 of file field_engine_screen_transition.c.
WRITE_ELLIPSE_LINES
#define WRITE_ELLIPSE_LINES(squash)
Writes every line's window edges for an ellipse round (centerX, centerY) whose half-width on a line dy from its centre is sqrt(r * r - squash * dy * dy), with r * r in radiusSquaredFixed (squash in 16.16).
Referenced by fdScreenTransitionUpdateScanlineTable().
Definition at line 42 of file field_engine_screen_transition.c.
Enumerations in detail
SCREEN_TRANSITION_IRQ_PHASE
enum SCREEN_TRANSITION_IRQ_PHASE
Where the centre-line transition's HBlank interrupt is.
| Enumerator | Value | Description |
|---|---|---|
DISPLAY_TRANSITION_IRQ_WAIT_SCREEN | 0 | waits for a line on screen |
DISPLAY_TRANSITION_IRQ_WAIT_EITHER | 1 | Waits for whichever edge line comes first |
DISPLAY_TRANSITION_IRQ_WAIT_SECOND | 2 | The first line has passed: waits for the second |
DISPLAY_TRANSITION_IRQ_WAIT_FIRST | 3 | The second line has passed: waits |
DISPLAY_TRANSITION_IRQ_DONE | 9 | for the first |
Definition at line 802 of file field_engine_screen_transition.c.
Functions in detail
fdEffectStartWindowHBlankDMA
void fdEffectStartWindowHBlankDMA(void)
Each VBlank, 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.
References syDMAXCopy().
Referenced by fdScreenTransitionFinish(), fdScreenTransitionStart(), fdScreenTransitionStartWindowHeld(), fdScreenTransitionSuspendCallbacks() and fdScreenTransitionUpdateScanlineTable().
Definition at line 59 of file field_engine_screen_transition.c.
fdScreenTransitionUpdateScanlineTable
void fdScreenTransitionUpdateScanlineTable(void)
Each tick 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.
References fdActorLookup(), fdEffectStartWindowHBlankDMA(), fdMapStateView(), fdPartyGetLeaderActor(), mnScanlineWindowFillSpansStub(), ScreenTransitionBarWidths, ScreenTransitionEdgeOffsets, ScreenTransitionShapes, Sint32, syCloseEvent(), syIntegerDivide(), syRandom(), sySquartIWRAM() and TickCount.
Referenced by fdScreenTransitionFinish(), fdScreenTransitionStart(), fdScreenTransitionStartWindowHeld() and fdScreenTransitionSuspendCallbacks().
Definition at line 88 of file field_engine_screen_transition.c.
fdScreenTransitionStartWindowHeld
void fdScreenTransitionStartWindowHeld(Sint32 mode)
Starts window transition mode at value 0, with no duration: the caller moves it.
References fdEffectStartWindowHBlankDMA(), fdScreenTransitionUpdateScanlineTable(), Sint32, syHeapSlotAllocateEWRAM() and sySetEvent().
Referenced by fdPsynergyReveal().
Definition at line 446 of file field_engine_screen_transition.c.
fdScreenTransitionSuspendCallbacks
void fdScreenTransitionSuspendCallbacks(void)
Unused: suspends the window transition's two events. Nothing calls it, by name, stub call entry or table.
References fdEffectStartWindowHBlankDMA(), fdScreenTransitionUpdateScanlineTable() and sySuspendEvent().
Definition at line 462 of file field_engine_screen_transition.c.
fdScreenTransitionAllocateAndClearState
SCREEN_TRANSITION_STATE *fdScreenTransitionAllocateAndClearState(void)
Allocates the screen transition state (HEAP_SLOT_SCREEN_TRANSITION) and
clears it.
References syHeapSlotAllocateEWRAM().
Referenced by fdScreenTransitionFinish() and fdScreenTransitionStart().
Definition at line 470 of file field_engine_screen_transition.c.
fdScreenTransitionStart
void fdScreenTransitionStart(Sint32 mode, Sint32 ticks)
Fades the screen in over ticks ticks. mode is a SCENE_TRANSITION: its high
byte an SCREEN_TRANSITION_STYLE (from black, from the backdrop colour, a
window transition whose low byte is an WINDOW_TRANSITION_MODE, a dissolve, or
opening from the centre line, which a non-zero low byte makes flicker).
References fdEffectStartWindowHBlankDMA(), fdPaletteFadeSetBackdrop(), fdPaletteFadeSetSource(), fdPaletteFadeStartInterpolation(), fdScreenTransitionAllocateAndClearState(), fdScreenTransitionFillTilemapAndColorTile(), fdScreenTransitionUpdate(), fdScreenTransitionUpdateDissolve(), fdScreenTransitionUpdateFromCenter(), fdScreenTransitionUpdateScanline(), fdScreenTransitionUpdateScanlineTable(), Sint32, syIntFunction(), syScreenFadeFromBlack(), syScreenFadeToBlack(), sySetEvent() and sySynch().
Referenced by fdEngineRun(), fdScriptStartScreenTransition(), scFireballCarryLeader() and scMarsLighthouseEntranceRideFireball().
Definition at line 484 of file field_engine_screen_transition.c.
fdScreenTransitionFinish
void fdScreenTransitionFinish(Sint32 mode, Sint32 ticks)
Fades the screen out over ticks ticks, as fdScreenTransitionStart fades it
in.
References fdEffectStartWindowHBlankDMA(), fdPaletteFadeSetTarget(), fdPaletteFadeStartInterpolation(), fdScreenTransitionAllocateAndClearState(), fdScreenTransitionFillTilemapAndColorTile(), fdScreenTransitionUpdate(), fdScreenTransitionUpdateDissolve(), fdScreenTransitionUpdateFromCenter(), fdScreenTransitionUpdateScanline(), fdScreenTransitionUpdateScanlineTable(), Sint32, syIntFunction(), syScreenFadeFromBlack(), syScreenFadeToBlack(), sySetEvent() and sySynch().
Referenced by fdEngineRun(), fdScriptFinishScreenTransition() and fdStartEncounterTransition().
Definition at line 585 of file field_engine_screen_transition.c.
fdScreenTransitionIsScanlineActive
Bool fdScreenTransitionIsScanlineActive(void)
Returns 1 while fdScreenTransitionUpdateScanline is the HBlank handler, that
is, while a centre-line transition runs.
References fdScreenTransitionUpdateScanline() and IrqHandlers.
Definition at line 666 of file field_engine_screen_transition.c.
fdScreenTransitionHideBackgrounds
void fdScreenTransitionHideBackgrounds(Sint32 clearBg3, Sint32 clearBg2, Sint32 clearBg1)
Clears the map's display-control bits for backgrounds 3, 2 and 1
(DISPCNT_BG3_ON, DISPCNT_BG2_ON and DISPCNT_BG1_ON) for each argument that is
set.
References Sint32.
Definition at line 676 of file field_engine_screen_transition.c.
fdScreenTransitionUpdate
void fdScreenTransitionUpdate(void)
Each tick of the centre-line transition: moves the value toward its end and sets the two lines where the screen switches between shown and blank; at the end the map draws its usual three extra tiles again.
References Sint32, syCloseEvent(), syIntegerDivide() and syIntFunction().
Referenced by fdScreenTransitionFinish() and fdScreenTransitionStart().
Definition at line 703 of file field_engine_screen_transition.c.
fdScreenTransitionUpdateFromCenter
void fdScreenTransitionUpdateFromCenter(void)
As fdScreenTransitionUpdate, but the lines flicker every other tick.
References Sint32, syCloseEvent(), syIntegerDivide(), syIntFunction() and TickCount.
Referenced by fdScreenTransitionFinish() and fdScreenTransitionStart().
Definition at line 751 of file field_engine_screen_transition.c.
fdScreenTransitionUpdateScanline
void fdScreenTransitionUpdateScanline(void)
The HBlank interrupt of the centre-line transition: switches the display to
DISPCNT_MODE_2 (nothing shown) at the first line and back to DISPCNT_MODE_0
at the second.
Referenced by fdScreenTransitionFinish(), fdScreenTransitionIsScanlineActive() and fdScreenTransitionStart().
Definition at line 817 of file field_engine_screen_transition.c.
fdScreenTransitionUpdateDissolve
void fdScreenTransitionUpdateDissolve(void)
Each tick of the dissolve: moves the value toward its end and sets two more
of the solid tile's 64 pixels, in the order of ScreenTransitionDitherTable:
to colour 0 while the screen opens (values up to TRANSITION_OPEN clear the
cover fdScreenTransitionStart filled with DISSOLVE_COVER_COLOR), and to
DISSOLVE_COVER_COLOR while it closes (values after it fill the clear tile
fdScreenTransitionFinish starts from).
References ScreenTransitionDitherTable, Sint32, syCloseEvent() and syIntegerDivide().
Referenced by fdScreenTransitionFinish(), fdScreenTransitionStart() and fdScreenTransitionStartDissolveHeld().
Definition at line 873 of file field_engine_screen_transition.c.
fdScreenTransitionFillTilemapAndColorTile
void fdScreenTransitionFillTilemapAndColorTile(Sint32 color)
Fills background screen block 4 with tile 0 in WINDOW_PALETTE and, unless
color is -1, makes tile 0 solid color.
References Sint32 and syDMAXCopy().
Referenced by fdScreenTransitionFinish(), fdScreenTransitionStart() and fdScreenTransitionStartDissolveHeld().
Definition at line 932 of file field_engine_screen_transition.c.
fdScreenTransitionStartDissolveHeld
void fdScreenTransitionStartDissolveHeld(Sint32 mode)
Starts a dissolve of the given mode, its value held at 0, and waits two seconds.
References fdScreenTransitionFillTilemapAndColorTile(), fdScreenTransitionUpdateDissolve(), Sint32, syHeapSlotAllocateEWRAM(), sySetEvent() and sySynch().
Definition at line 959 of file field_engine_screen_transition.c.