Skip to Content
The Alchemy Project

src/battle/battle_transition.c

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

Included by battle.c.

Macros

NameDescription
#defineTRANSITION_CURTAIN_FIRST_TILE 128The curtain's first tile, CURTAIN_TILE(0), as BG1 numbers it from character block 1.
#defineTRANSITION_CURTAIN_ENTRY (n)The curtain's map entries: its tile n, in WINDOW_PALETTE.
#defineTRANSITION_CURTAIN_COLOR 3The closed curtain's colour, which fills its first tile.
#defineTRANSITION_CURTAIN_SCREEN 12The screen block of the curtain's map, and its middle row, from which it opens a row up and a row down every eight ticks for TRANSITION_OPEN_TICKS.
#defineTRANSITION_CURTAIN_MIDDLE_ROW 13
#defineTRANSITION_CURTAIN_LAST_ROW 20
#defineTRANSITION_OPEN_TICKS 80
#defineTRANSITION_CURTAIN_VARIANTS 8Eight variants of the curtain's first tile, a new one every four ticks (btTransitionUploadTileVariant).
#defineTRANSITION_VARIANT_TICKS 4
#defineTRANSITION_BG0_BAND 32BG0's top 32 lines, which roll down into place as the curtain opens: BG0 starts scrolled up by as many, and the VCount interrupt at the band's bottom clears the scroll for the lines below.
#defineTRANSITION_TURN_SPEED 360The camera turns 360 of TRIG_TURN's 65,536 a tick (about 2 degrees) as the curtain opens, ending at DEGtoANG(45) as the zoom ends.
#defineTRANSITION_START_YAW
#defineMOSAIC_SIZE_MAX 15REG_MOSAIC's largest block size, 16 pixels: each of its sizes is a four-bit field holding the size less one.
#defineMAP_ROW_WORDS (MAP_ROW_BYTES / 4)The words that hold a background map row's 32 entries two at a time.
#defineAFFINE_MAP_ENTRIES (first, second, third, fourth)Four affine map entries side by side, a byte each, written a word at a time.
#defineBACKGROUND_TILE_ROWS 15The battle background's image: 32 by 15 tiles of 256 colours, 256 by 120 pixels.
#defineBACKGROUND_TILES (BG_SCREEN_WIDTH * BACKGROUND_TILE_ROWS)
#defineBACKGROUND_UPPER_TILES (BG_CHAR_SIZE / TILE_SIZE_8BPP)
#defineBACKGROUND_LOWER_TILES (BACKGROUND_TILES - BACKGROUND_UPPER_TILES)
#defineBACKGROUND_AFFINE_MAP_BYTES (32 * 32)The zoomed background's affine map: 32 by 32 tiles, a byte each.
#defineBACKGROUND_BG1_FIRST_TILE (2 * BG_CHAR_SIZE / TILE_SIZE_8BPP)The picture's first tile on BG1, numbered from BG1's character base 0: character block 2.
#defineBG1_EDGE_TILE TILE_NUMBER_MASKThe last tile, which BG1's flat map shows in the rows around the picture.
#defineBACKGROUND_SCROLL_X ((BG_SCREEN_WIDTH * 8 - DISPLAY_WIDTH) / 2)BG1's horizontal scroll at rest, which centres the 256-pixel picture on the screen (battle_background.c's BACKGROUND_PAN_X, in whole pixels).

Functions

NameDescription
Sint32btTransitionRunMosaicFadeOut (void)Fades the screen to black over sixteen ticks as every background's mosaic blocks grow wider, then shows no layer.
voidbtTransitionBuildAffineTilemap (void *tilemap)Builds the zoomed background's 32 by 32 affine map, in which the background picture's two halves come from character blocks 2 and 3.
voidbtTransitionBuildFlatTilemap (void *tilemap)Builds BG1's flat map of the same picture: its tiles in rows 6 to 20, from screen line 16 at BATTLE_BACKGROUND_SCROLL_Y, and the last tile in the rows around them.
voidbtBackgroundShowZoomedPage (void)Shows the zoomed background's finished page each VBlank.
voidbtTransitionUploadTileVariant (void)Unused: steps the curtain's solid tile through eight variants, a new one every four ticks.
voidbtTransitionAdvanceOpening (void)Advances the curtain opening by a tick: BG0 slides into place as the camera turns round to the party and zooms out.
voidbtTransitionDrawRows (void)Draws the curtain opening from the middle of the screen, one row up and one down every eight ticks.
voidbtTransitionClearBg0Vofs (void)Clears BG0's scroll from the line the interrupt fires on.
voidbtTransitionRun (Sint32 enemyCount, Sint32 encounterId)Opens a battle: the curtain opening, or for the Fusion Dragon the storm on the Venus Lighthouse aerie; then announces the enemies.

Description

The opening transition: the curtain, or the Venus Lighthouse storm. Part of battle.c.

Macros in detail

TRANSITION_CURTAIN_FIRST_TILE

#define TRANSITION_CURTAIN_FIRST_TILE 128

The curtain's first tile, CURTAIN_TILE(0), as BG1 numbers it from character block 1.

Definition at line 8 of file battle_transition.c.

TRANSITION_CURTAIN_ENTRY

#define TRANSITION_CURTAIN_ENTRY(n)

The curtain's map entries: its tile n, in WINDOW_PALETTE.

Referenced by btTransitionDrawRows() and btTransitionRun().

Definition at line 10 of file battle_transition.c.

TRANSITION_CURTAIN_COLOR

#define TRANSITION_CURTAIN_COLOR 3

The closed curtain's colour, which fills its first tile.

Referenced by btTransitionRun().

Definition at line 13 of file battle_transition.c.

TRANSITION_CURTAIN_SCREEN

#define TRANSITION_CURTAIN_SCREEN 12

The screen block of the curtain's map, and its middle row, from which it opens a row up and a row down every eight ticks for TRANSITION_OPEN_TICKS.

Referenced by btTransitionDrawRows() and btTransitionRun().

Definition at line 16 of file battle_transition.c.

TRANSITION_CURTAIN_MIDDLE_ROW

#define TRANSITION_CURTAIN_MIDDLE_ROW 13

Referenced by btTransitionDrawRows().

Definition at line 17 of file battle_transition.c.

TRANSITION_CURTAIN_LAST_ROW

#define TRANSITION_CURTAIN_LAST_ROW 20

Referenced by btTransitionDrawRows() and btTransitionRun().

Definition at line 18 of file battle_transition.c.

TRANSITION_OPEN_TICKS

#define TRANSITION_OPEN_TICKS 80

Referenced by btTransitionAdvanceOpening(), btTransitionDrawRows() and btTransitionRun().

Definition at line 19 of file battle_transition.c.

TRANSITION_CURTAIN_VARIANTS

#define TRANSITION_CURTAIN_VARIANTS 8

Eight variants of the curtain's first tile, a new one every four ticks (btTransitionUploadTileVariant).

Referenced by btTransitionUploadTileVariant().

Definition at line 22 of file battle_transition.c.

TRANSITION_VARIANT_TICKS

#define TRANSITION_VARIANT_TICKS 4

Referenced by btTransitionUploadTileVariant().

Definition at line 23 of file battle_transition.c.

TRANSITION_BG0_BAND

#define TRANSITION_BG0_BAND 32

BG0's top 32 lines, which roll down into place as the curtain opens: BG0 starts scrolled up by as many, and the VCount interrupt at the band's bottom clears the scroll for the lines below.

Referenced by btTransitionAdvanceOpening() and btTransitionRun().

Definition at line 27 of file battle_transition.c.

TRANSITION_TURN_SPEED

#define TRANSITION_TURN_SPEED 360

The camera turns 360 of TRIG_TURN's 65,536 a tick (about 2 degrees) as the curtain opens, ending at DEGtoANG(45) as the zoom ends.

Referenced by btTransitionAdvanceOpening().

Definition at line 30 of file battle_transition.c.

TRANSITION_START_YAW

#define TRANSITION_START_YAW

Referenced by btTransitionAdvanceOpening().

Definition at line 31 of file battle_transition.c.

MOSAIC_SIZE_MAX

#define MOSAIC_SIZE_MAX 15

REG_MOSAIC's largest block size, 16 pixels: each of its sizes is a four-bit field holding the size less one.

Referenced by btTransitionRunMosaicFadeOut().

Definition at line 36 of file battle_transition.c.

MAP_ROW_WORDS

#define MAP_ROW_WORDS (MAP_ROW_BYTES / 4)

The words that hold a background map row's 32 entries two at a time.

Referenced by btTransitionBuildFlatTilemap().

Definition at line 39 of file battle_transition.c.

AFFINE_MAP_ENTRIES

#define AFFINE_MAP_ENTRIES(first, second, third, fourth)

Four affine map entries side by side, a byte each, written a word at a time.

Referenced by btTransitionBuildAffineTilemap().

Definition at line 41 of file battle_transition.c.

BACKGROUND_TILE_ROWS

#define BACKGROUND_TILE_ROWS 15

The battle background's image: 32 by 15 tiles of 256 colours, 256 by 120 pixels. The first 256 tiles fill character block 2 and the rest block 3.

Referenced by btTransitionBuildFlatTilemap().

Definition at line 45 of file battle_transition.c.

BACKGROUND_TILES

#define BACKGROUND_TILES (BG_SCREEN_WIDTH * BACKGROUND_TILE_ROWS)

Referenced by btTransitionBuildAffineTilemap().

Definition at line 46 of file battle_transition.c.

BACKGROUND_UPPER_TILES

#define BACKGROUND_UPPER_TILES (BG_CHAR_SIZE / TILE_SIZE_8BPP)

Referenced by btTransitionBuildAffineTilemap().

Definition at line 47 of file battle_transition.c.

BACKGROUND_LOWER_TILES

#define BACKGROUND_LOWER_TILES (BACKGROUND_TILES - BACKGROUND_UPPER_TILES)

Referenced by btTransitionBuildAffineTilemap().

Definition at line 48 of file battle_transition.c.

BACKGROUND_AFFINE_MAP_BYTES

#define BACKGROUND_AFFINE_MAP_BYTES (32 * 32)

The zoomed background's affine map: 32 by 32 tiles, a byte each.

Referenced by btTransitionBuildAffineTilemap().

Definition at line 50 of file battle_transition.c.

BACKGROUND_BG1_FIRST_TILE

#define BACKGROUND_BG1_FIRST_TILE (2 * BG_CHAR_SIZE / TILE_SIZE_8BPP)

The picture's first tile on BG1, numbered from BG1's character base 0: character block 2.

Referenced by btTransitionBuildFlatTilemap().

Definition at line 53 of file battle_transition.c.

BG1_EDGE_TILE

#define BG1_EDGE_TILE TILE_NUMBER_MASK

The last tile, which BG1's flat map shows in the rows around the picture.

Referenced by btTransitionBuildFlatTilemap().

Definition at line 55 of file battle_transition.c.

BACKGROUND_SCROLL_X

#define BACKGROUND_SCROLL_X ((BG_SCREEN_WIDTH * 8 - DISPLAY_WIDTH) / 2)

BG1's horizontal scroll at rest, which centres the 256-pixel picture on the screen (battle_background.c's BACKGROUND_PAN_X, in whole pixels).

Referenced by btTransitionRun().

Definition at line 58 of file battle_transition.c.

Functions in detail

btTransitionRunMosaicFadeOut

Sint32 btTransitionRunMosaicFadeOut(void)

Fades the screen to black over sixteen ticks as every background's mosaic blocks grow wider, then shows no layer.

References Sint32, syRandom(), syScreenFadeToBlack() and sySynch().

Definition at line 62 of file battle_transition.c.

btTransitionBuildAffineTilemap

void btTransitionBuildAffineTilemap(void *tilemap)

Builds the zoomed background's 32 by 32 affine map, in which the background picture's two halves come from character blocks 2 and 3.

References syWordsFill().

Referenced by btBackgroundLoad() and btBackgroundSetMode().

Definition at line 110 of file battle_transition.c.

btTransitionBuildFlatTilemap

void btTransitionBuildFlatTilemap(void *tilemap)

Builds BG1's flat map of the same picture: its tiles in rows 6 to 20, from screen line 16 at BATTLE_BACKGROUND_SCROLL_Y, and the last tile in the rows around them.

References syWordsFill().

Referenced by btBackgroundLoad() and btBackgroundSetMode().

Definition at line 134 of file battle_transition.c.

btBackgroundShowZoomedPage

void btBackgroundShowZoomedPage(void)

Shows the zoomed background's finished page each VBlank.

References line and syDMAXCopy().

Referenced by btBackgroundLoad() and btBackgroundSetMode().

Definition at line 158 of file battle_transition.c.

btTransitionUploadTileVariant

void btTransitionUploadTileVariant(void)

Unused: steps the curtain's solid tile through eight variants, a new one every four ticks.

Open question (no evidence in reach): which transition used it; nothing in either game calls it, and The Lost Age keeps an unused copy too.

References BattleTransitionCurtainVariants and syDMAXCopy().

Definition at line 178 of file battle_transition.c.

btTransitionAdvanceOpening

void btTransitionAdvanceOpening(void)

Advances the curtain opening by a tick: BG0 slides into place as the camera turns round to the party and zooms out.

References BgScrollWork, btCameraSetView(), HeapSlots and Sint32.

Referenced by btTransitionRun().

Definition at line 191 of file battle_transition.c.

btTransitionDrawRows

void btTransitionDrawRows(void)

Draws the curtain opening from the middle of the screen, one row up and one down every eight ticks.

References Sint32 and tileRow.

Referenced by btTransitionRun().

Definition at line 218 of file battle_transition.c.

btTransitionClearBg0Vofs

void btTransitionClearBg0Vofs(void)

Clears BG0's scroll from the line the interrupt fires on.

Referenced by btTransitionRun().

Definition at line 252 of file battle_transition.c.

btTransitionRun

void btTransitionRun(Sint32 enemyCount, Sint32 encounterId)

Opens a battle: the curtain opening, or for the Fusion Dragon the storm on the Venus Lighthouse aerie; then announces the enemies.

References BattleTransitionCurtainTiles, BgScrollWork, btCameraSetView(), btEffectRunShatteringOpeningStub(), btHighlightSetSpriteMode(), btIntroAnnounceEncounter(), btObjectGet(), btObjectSpawnObjectsForList(), btTransitionAdvanceOpening(), btTransitionClearBg0Vofs(), btTransitionDrawRows(), btUnitListIds(), gmUnitGetStub(), mnPartyStatusCreateWindowStub(), Sint32, state, syCloseEvent(), syDMAXCopy(), syHeapSlotAllocate(), syHeapSlotRelease(), syIntFunction(), syIOWriteQueueClearBits16(), syIOWriteQueueSetBits16(), syIOWriteQueueStore16(), sySetEvent() and sySynch().

Referenced by btRun().

Definition at line 259 of file battle_transition.c.