src/battle/battle_background.c
The battle background, its palette and modes, the camera's zoom and the units' highlights. More…
Included by battle.c.
Macros
| Name | Description | |
|---|---|---|
#define | BACKGROUND_PLANE_UPPER | The zoomed background's BG2CNT for the first 256 picture tiles: a 256 by 256 affine map in screen block 7, 256 colours, priority 2. |
#define | BACKGROUND_PLANE_LOWER | The same map, reading the remaining picture tiles from character block 3. |
#define | BACKGROUND_PLANE_OFF | BG2's setting on the lines the zoomed picture leaves out: its top lines outside the command choice (BACKGROUND_PLANE_HIDDEN_LINES), and those below BACKGROUND_PLANE_LINES. |
#define | BACKGROUND_PLANE_LINES 136 | The screen lines the plane covers, 0 to 135, above the status window. |
#define | BACKGROUND_PLANE_HIDDEN_LINES 16 | The plane's top lines, left off except while commands are chosen. |
#define | BACKGROUND_UPPER_HALF_LINES 64 | The picture's lines that BACKGROUND_PLANE_UPPER reads: its first 256 tiles, 32 to a row. |
#define | BACKGROUND_PALETTE_BYTES (BATTLE_BACKGROUND_COLORS * 2) | A battle background resource: its BATTLE_BACKGROUND_COLORS colours, then its packed picture. |
#define | BACKGROUND_PAN_X Q_8_8(8) | The fixed background's sideways pan in 8.8 pixels while the zoom is below 1; from 1 on it moves three 8.8 pixels a step of the camera's yaw, so the picture turns with the camera, and is the same when the camera faces the party's actions (YAW_PARTY_ACTION). |
#define | DEBUG_VALUE_SELECT WHEN(DEBUG_VALUE_EDITOR_NEW_SELECT_PRESET, 544, 411) | What Select picks: another value in the Japanese release. |
#define | DEBUG_VALUE_R 399 | What R picks, in every release. |
#define | DEBUG_VALUE_TENS 10 | The digits the debug value steps: left and right step its ones, up and down its tens, L and R its hundreds. |
#define | DEBUG_VALUE_HUNDREDS 100 | |
#define | HIGHLIGHT_RAMP_HALF 16 | The steps of each half of BattleHighlightBlendRamp: the first half plays once, then the second over and over. |
Functions
| Name | Description | |
|---|---|---|
void | btBackgroundSetPaletteLevel (Sint32 unused, Sint32 level) | Darkens the battle background's palette by level steps of a sixtieth; level 0 restores its saved colours. |
void | btBackgroundSetMode (Sint32 mode, Sint32 backgroundId, Sint32 fade) | Switches the battle background's display mode and rebuilds both its maps. |
void | btBackgroundInit (void) | Allocates the zoomed background's scanline state. |
void | btBackgroundFree (void) | Frees the zoomed background's scanline state. |
void | btBackgroundLoad (Sint32 mode, Sint32 resource, Sint32 level) | Loads a battle background: its picture decoded into BG VRAM, its palette darkened by level steps of 1/60 (none when level is negative), its tile table and tilemap, and the HBlank scroll the first time. |
void | btCameraSetRange ( FIXED centerX, FIXED centerY, Sint32 offsetX, Sint32 offsetY, FIXED scale) | Builds the zoomed background's next page for a zoom of scale about centerX and centerY, shifted by offsetX and offsetY, and shows it: below a zoom of 1 the plane lies flat, from 1 it wraps and turns with the camera. |
void | btCameraSetViewAtDepth (Sint32 x, Sint32 depth, Sint32 y) | |
void | btCameraSetView (Sint32 x, Sint32 depth, Sint32 y, Sint32 zoom) | Points the battle camera at (x, depth, y) with a zoom in percent, and lines the zoomed background up with it: where the battlefield's origin falls on the screen moves the plane as much, and the zoom scales the focal length and the far depth. |
void | btCameraSetViewAtPairMidpoint (Sint32 firstUnitId, Sint32 secondUnitId, Sint32 zoom) | Points the battle camera at the ground between two units, with a zoom in percent. |
void | btBackgroundFadeAlphaOut (void) | Fades BG2 out over the backdrop in eight ticks, its blend weight falling by 2 a tick from 15, while the backdrop's stays 16. |
void | btBackgroundFadeAlphaIn (void) | Fades BG2 in over the backdrop in eight ticks, its blend weight rising by 2 a tick from 1, while the backdrop's stays 16. |
void | btBrightenAllLayers (void) | Unused: sets BLDCNT to brighten every layer and the backdrop. |
FIXED | btMulFX (FIXED a, FIXED b) | Unused: returns the 16.16 product of a and b. |
void | btMatrixSetUnit (MATRIX matrix) | Unused: sets matrix to the unit matrix, then puts its old first element plus toFIXED(1) in its second, where the unit matrix has 0. |
Sint32 | btBackgroundDivideBy16 (Sint32 value) | Unused: returns value divided by 16. |
Sint32 | btAdjustDebugValue (Sint32 value) | Unused debug aid: with Start held, the d-pad and L/R step the battle state's debugValue by its ones, tens and hundreds until A takes it; Select held picks DEBUG_VALUE_SELECT and R held DEBUG_VALUE_R; otherwise value comes back unchanged. |
void | btHighlightSetSpriteMode (Sint32 unitId, Sint32 mode) | Sets the sprite mode of a unit's picture and its shadow. |
void | btHighlightSetOtherSpriteModes (Sint32 selectedUnitId) | Unused: makes every unit's sprites semi-transparent but selectedUnitId's. |
void | btHighlightClearAllSpriteModes (void) | Returns every unit's sprites to SPRITE_OPAQUE. |
void | btBackgroundStepHighlightBlend (void) | Steps the highlight's blend: HIGHLIGHT_FADE_IN and HIGHLIGHT_FADE_OUT fade the units listed in or out over 32 frames, HIGHLIGHT_PULSE blends them by the ramp, and HIGHLIGHT_SELECTED lightens them by it: the first sixteen steps once, then the second sixteen over and over. |
void | btHighlightSetModes (Uint16 *unitIds, Sint32 mode) | Highlights the units in unitIds (up to UNIT_MAX, ended by BATTLE_UNIT_LIST_END), the others taking the other blend, or with HIGHLIGHT_OFF stops the highlight. |
Variables
| Name | Description | |
|---|---|---|
extern Sint8 | BattleHighlightBlendRamp [] | BLDY values, the same in both games. |
Description
The battle background, its palette and modes, the camera's zoom and the
units' highlights. Part of battle.c.
Macros in detail
BACKGROUND_PLANE_UPPER
#define BACKGROUND_PLANE_UPPER
The zoomed background's BG2CNT for the first 256 picture tiles: a 256 by 256 affine map in screen block 7, 256 colours, priority 2.
Referenced by btCameraSetRange().
Definition at line 6 of file battle_background.c.
BACKGROUND_PLANE_LOWER
#define BACKGROUND_PLANE_LOWER
The same map, reading the remaining picture tiles from character block 3.
Referenced by btCameraSetRange().
Definition at line 10 of file battle_background.c.
BACKGROUND_PLANE_OFF
#define BACKGROUND_PLANE_OFF
BG2's setting on the lines the zoomed picture leaves out: its top lines
outside the command choice (BACKGROUND_PLANE_HIDDEN_LINES), and those below
BACKGROUND_PLANE_LINES.
Referenced by btCameraSetRange().
Definition at line 16 of file battle_background.c.
BACKGROUND_PLANE_LINES
#define BACKGROUND_PLANE_LINES 136
The screen lines the plane covers, 0 to 135, above the status window.
Referenced by btCameraSetRange().
Definition at line 20 of file battle_background.c.
BACKGROUND_PLANE_HIDDEN_LINES
#define BACKGROUND_PLANE_HIDDEN_LINES 16
The plane's top lines, left off except while commands are chosen.
Referenced by btCameraSetRange().
Definition at line 22 of file battle_background.c.
BACKGROUND_UPPER_HALF_LINES
#define BACKGROUND_UPPER_HALF_LINES 64
The picture's lines that BACKGROUND_PLANE_UPPER reads: its first 256 tiles,
32 to a row.
Referenced by btCameraSetRange().
Definition at line 25 of file battle_background.c.
BACKGROUND_PALETTE_BYTES
#define BACKGROUND_PALETTE_BYTES (BATTLE_BACKGROUND_COLORS * 2)
A battle background resource: its BATTLE_BACKGROUND_COLORS colours, then its
packed picture.
Referenced by btBackgroundLoad().
Definition at line 29 of file battle_background.c.
BACKGROUND_PAN_X
#define BACKGROUND_PAN_X Q_8_8(8)
The fixed background's sideways pan in 8.8 pixels while the zoom is below 1;
from 1 on it moves three 8.8 pixels a step of the camera's yaw, so the
picture turns with the camera, and is the same when the camera faces the
party's actions (YAW_PARTY_ACTION).
Referenced by btCameraSetRange().
Definition at line 35 of file battle_background.c.
DEBUG_VALUE_SELECT
#define DEBUG_VALUE_SELECT WHEN(DEBUG_VALUE_EDITOR_NEW_SELECT_PRESET, 544, 411)
What Select picks: another value in the Japanese release.
Referenced by btAdjustDebugValue().
Definition at line 468 of file battle_background.c.
DEBUG_VALUE_R
#define DEBUG_VALUE_R 399
What R picks, in every release.
Referenced by btAdjustDebugValue().
Definition at line 470 of file battle_background.c.
DEBUG_VALUE_TENS
#define DEBUG_VALUE_TENS 10
The digits the debug value steps: left and right step its ones, up and down its tens, L and R its hundreds.
Referenced by btAdjustDebugValue().
Definition at line 473 of file battle_background.c.
DEBUG_VALUE_HUNDREDS
#define DEBUG_VALUE_HUNDREDS 100
Referenced by btAdjustDebugValue().
Definition at line 474 of file battle_background.c.
HIGHLIGHT_RAMP_HALF
#define HIGHLIGHT_RAMP_HALF 16
The steps of each half of BattleHighlightBlendRamp: the first half plays
once, then the second over and over.
Referenced by btBackgroundStepHighlightBlend().
Definition at line 586 of file battle_background.c.
Functions in detail
btBackgroundSetPaletteLevel
void btBackgroundSetPaletteLevel(Sint32 unused, Sint32 level)
Darkens the battle background's palette by level steps of a sixtieth; level 0 restores its saved colours.
References btColorBufferScale(), Sint32, syDMAXCopy() and syIRQUnlock().
Referenced by btBackgroundRestorePalette().
Definition at line 39 of file battle_background.c.
btBackgroundSetMode
void btBackgroundSetMode(Sint32 mode, Sint32 backgroundId, Sint32 fade)
Switches the battle background's display mode and rebuilds both its maps. A
nonzero fade darkens the saved palette by taking fade from each colour
channel, and BATTLE_BACKGROUND_FADE_RESTORE puts it back undarkened; the
background's id is not read.
References btBackgroundShowZoomedPage(), btTransitionBuildAffineTilemap(), btTransitionBuildFlatTilemap(), Sint32, syDMAXCopy() and sySetEvent().
Referenced by btElementGlowPlay(), btProcessTurnEnd() and btStagingDispatchAction().
Definition at line 69 of file battle_background.c.
btBackgroundInit
void btBackgroundInit(void)
Allocates the zoomed background's scanline state.
References syHeapSlotAllocateEWRAM().
Referenced by btRun().
Definition at line 140 of file battle_background.c.
btBackgroundFree
void btBackgroundFree(void)
Frees the zoomed background's scanline state.
References syHeapSlotRelease().
Referenced by btRun().
Definition at line 151 of file battle_background.c.
btBackgroundLoad
void btBackgroundLoad(Sint32 mode, Sint32 resource, Sint32 level)
Loads a battle background: its picture decoded into BG VRAM, its palette
darkened by level steps of 1/60 (none when level is negative), its tile table
and tilemap, and the HBlank scroll the first time.
References btBackgroundShowZoomedPage(), btColorBufferScale(), btModelDecodeCode, btTransitionBuildAffineTilemap(), btTransitionBuildFlatTilemap(), ModelDecodeCodeSize, Sint32, syDMAXCopy(), syHeapRelease(), syResourceGetTableEntry() and sySetEvent().
Referenced by btRun().
Definition at line 159 of file battle_background.c.
btCameraSetRange
void btCameraSetRange( FIXED centerX, FIXED centerY, Sint32 offsetX, Sint32 offsetY, FIXED scale)
Builds the zoomed background's next page for a zoom of scale about centerX and centerY, shifted by offsetX and offsetY, and shows it: below a zoom of 1 the plane lies flat, from 1 it wraps and turns with the camera.
References BgScrollWork, Sint32, syDivFX() and syGameFlagGet().
Referenced by btCameraAdjustByShoulderKeys(), btCameraSetCommandView(), btCameraSetView(), btCameraSetViewAtDepth(), btCameraUpdate() and btRun().
Definition at line 205 of file battle_background.c.
btCameraSetViewAtDepth
void btCameraSetViewAtDepth(Sint32 x, Sint32 depth, Sint32 y)
References btCameraSetRange(), ProjectionWork, Sint32, syCalcPoint(), syConvert3Dto2D(), syDivFX(), syInitMatrix(), syLookAtLoad(), syMatrixTranslateVector(), syRotX(), syRotY() and sySetScreenDist().
Definition at line 283 of file battle_background.c.
btCameraSetView
void btCameraSetView(Sint32 x, Sint32 depth, Sint32 y, Sint32 zoom)
Points the battle camera at (x, depth, y) with a zoom in percent, and lines the zoomed background up with it: where the battlefield's origin falls on the screen moves the plane as much, and the zoom scales the focal length and the far depth.
References btCameraSetRange(), ProjectionWork, Sint32, syCalcPoint(), syConvert3Dto2D(), syDivFX(), syInitMatrix(), syLookAtLoad(), syMatrixTranslateVector(), syRotX(), syRotY() and sySetScreenDist().
Referenced by btAutoBattleRunPsynergy(), btCameraSetViewAtPairMidpoint(), btRun(), btStagingRunAttack(), btStagingRunFullScreen(), btTransitionAdvanceOpening() and btTransitionRun().
Definition at line 342 of file battle_background.c.
btCameraSetViewAtPairMidpoint
void btCameraSetViewAtPairMidpoint(Sint32 firstUnitId, Sint32 secondUnitId, Sint32 zoom)
Points the battle camera at the ground between two units, with a zoom in percent.
References btCameraSetView(), btObjectGet() and Sint32.
Referenced by btStagingRunAttack().
Definition at line 393 of file battle_background.c.
btBackgroundFadeAlphaOut
void btBackgroundFadeAlphaOut(void)
Fades BG2 out over the backdrop in eight ticks, its blend weight falling by 2
a tick from 15, while the backdrop's stays 16. Leaves REG_BLDCNT blending BG2
over the backdrop.
References Sint32 and sySynch().
Definition at line 412 of file battle_background.c.
btBackgroundFadeAlphaIn
void btBackgroundFadeAlphaIn(void)
Fades BG2 in over the backdrop in eight ticks, its blend weight rising by 2 a
tick from 1, while the backdrop's stays 16. Leaves REG_BLDCNT blending BG2
over the backdrop.
References Sint32 and sySynch().
Definition at line 427 of file battle_background.c.
btBrightenAllLayers
void btBrightenAllLayers(void)
Unused: sets BLDCNT to brighten every layer and the backdrop.
Definition at line 440 of file battle_background.c.
btMulFX
FIXED btMulFX(FIXED a, FIXED b)
Unused: returns the 16.16 product of a and b.
Definition at line 446 of file battle_background.c.
btMatrixSetUnit
void btMatrixSetUnit(MATRIX matrix)
Unused: sets matrix to the unit matrix, then puts its old first element plus
toFIXED(1) in its second, where the unit matrix has 0.
References syUnitMatrix().
Definition at line 453 of file battle_background.c.
btBackgroundDivideBy16
Sint32 btBackgroundDivideBy16(Sint32 value)
Unused: returns value divided by 16.
References Sint32.
Definition at line 462 of file battle_background.c.
btAdjustDebugValue
Sint32 btAdjustDebugValue(Sint32 value)
Unused debug aid: with Start held, the d-pad and L/R step the battle state's
debugValue by its ones, tens and hundreds until A takes it; Select held picks
DEBUG_VALUE_SELECT and R held DEBUG_VALUE_R; otherwise value comes back
unchanged.
References PerWork, Sint32 and sySynch().
Definition at line 480 of file battle_background.c.
btHighlightSetSpriteMode
void btHighlightSetSpriteMode(Sint32 unitId, Sint32 mode)
Sets the sprite mode of a unit's picture and its shadow.
References btObjectGet() and Sint32.
Referenced by btAutoBattleRunPsynergy(), btHighlightClearAllSpriteModes(), btHighlightSetModes(), btHighlightSetOtherSpriteModes(), btMotionCallBeast(), btMotionDismissBeast(), btStagingRunFullScreen() and btTransitionRun().
Definition at line 516 of file battle_background.c.
btHighlightSetOtherSpriteModes
void btHighlightSetOtherSpriteModes(Sint32 selectedUnitId)
Unused: makes every unit's sprites semi-transparent but selectedUnitId's.
References btHighlightSetSpriteMode(), btUnitListIds() and Sint32.
Definition at line 557 of file battle_background.c.
btHighlightClearAllSpriteModes
void btHighlightClearAllSpriteModes(void)
Returns every unit's sprites to SPRITE_OPAQUE.
References btHighlightSetSpriteMode(), btUnitListIds() and Sint32.
Referenced by btHighlightSetModes().
Definition at line 572 of file battle_background.c.
btBackgroundStepHighlightBlend
void btBackgroundStepHighlightBlend(void)
Steps the highlight's blend: HIGHLIGHT_FADE_IN and HIGHLIGHT_FADE_OUT fade
the units listed in or out over 32 frames, HIGHLIGHT_PULSE blends them by the
ramp, and HIGHLIGHT_SELECTED lightens them by it: the first sixteen steps
once, then the second sixteen over and over.
References BattleHighlightBlendRamp.
Referenced by btHighlightSetModes().
Definition at line 592 of file battle_background.c.
btHighlightSetModes
void btHighlightSetModes(Uint16 *unitIds, Sint32 mode)
Highlights the units in unitIds (up to UNIT_MAX, ended by
BATTLE_UNIT_LIST_END), the others taking the other blend, or with
HIGHLIGHT_OFF stops the highlight. Bit 0 of the mode says which are
semi-transparent: every other unit for HIGHLIGHT_SELECTED, the units listed
for the rest.
References btBackgroundStepHighlightBlend(), btHighlightClearAllSpriteModes(), btHighlightSetSpriteMode(), btUnitListIds(), Sint32, syCloseEvent(), syIOWriteQueueStore16(), sySetEvent() and sySynch().
Referenced by btActionRunBuild(), btPartySwapInReserves(), btStagingDispatchAction(), btStagingRunAttack(), btStagingRunFlee(), btStagingRunFullScreen(), btStagingRunItem(), btStagingRunMessages() and btStagingRunPsynergyCast().
Definition at line 651 of file battle_background.c.