The battle background, its palette and perspective, the camera's zoom and the units' highlights. More...
Go to the source code of this file.
Data Structures | |
| struct | BattleTransitionEntry |
| What BattlePresentation_InitializeTransitionEntries treats as an array of these; Transform_SetIdentity writes over it as a matrix. More... | |
Macros | |
| #define | DEBUG_SELECT_VALUE 0x18f |
| #define | BACKGROUND_LEVEL_STEP 1092 |
| BattlePresentation_SetPaletteLevel's and BattleBackground_Load's darkening step: each level takes 1092 from the 16.16 brightness, so level 60 is almost black. | |
| #define | BACKGROUND_PLANE_UPPER |
| The perspective plane'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 |
| Lines outside the plane read the padded map in screen block 31. | |
Typedefs | |
| typedef void(*) | BitDecoder(const u8 *source, void *destination) |
| The bit decoder BattleBackground_Load copies to RAM and runs. | |
Functions | |
| void | BattlePresentation_SetPaletteLevel (s32 unused, s32 level) |
| Copies the background's saved palette to BG palettes 6 to 13, darkened by level (0 for none). | |
| void | BattlePresentation_ConfigurePaletteFade (s32 mode, s32 unusedResource, s32 fade) |
| Switches the background's display mode, optionally sets its palette, and rebuilds both its maps. | |
| void | BattlePresentation_InitializeWorkAndResetState (void) |
| Allocates the perspective plane's scanline work (heap slot 10) cleared, and sets the background's mode to 0, so the next load adds its scanline callback. | |
| void | Runtime_ReleaseHeapBlock10 (void) |
| Frees the perspective plane's scanline work (heap slot 10); called by Battle_RunEncounter as the battle ends. | |
| void | BattleBackground_Load (s32 mode, s32 resourceId, s32 level) |
| Loads a battle background: its picture into character blocks 2 and 3, its palette into BattleWork.palette and, darkened by level, BG palettes 6 to 13, and both its maps. | |
| void | BattleCamera_SetRange (s32 centerX, s32 centerY, s32 offsetX, s32 offsetY, s32 scale) |
| Builds the perspective plane's next page for a zoom of scale about centerX and centerY (all 16.16), shifted by offsetX and offsetY (8.8 pixels), and shows it. | |
| UNUSED void | BattlePres_SetupTransitionSceneAtDepth (s32 x, s32 depth, s32 y) |
| Sets the camera's eye at its stored distance without taking a zoom; nothing in the source calls it. | |
| void | BattlePres_SetupTransitionScene (s32 x, s32 depth, s32 y, s32 zoom) |
| Points the battle camera at (x, depth, y) with a zoom in percent, and lines the perspective plane up with it. | |
| void | BattlePres_SetupTransitionAtPairMidpoint (s32 firstUnitId, s32 secondUnitId, s32 zoom) |
| Points the battle camera, through BattlePres_SetupTransitionScene, at the ground between two units' battle objects, with a zoom in percent. | |
| void | Graphics_FadeAlphaOut (void) |
| Fades BG2 out over the backdrop in eight frames, its blend weight falling by 2 a frame from 15, while the backdrop's stays 16. | |
| void | Graphics_FadeAlphaIn (void) |
| Fades BG2 in over the backdrop in eight frames, its blend weight rising by 2 a frame from 1, while the backdrop's stays 16. | |
| void | Graphics_SetBlendControl (void) |
| Sets REG_BLDCNT to lighten every layer by REG_BLDY; nothing calls it. | |
| void | BattlePresentation_InitializeTransitionEntries (struct BattleTransitionEntry *entries) |
| Sets entries to the identity transform, then stores the first word's old value plus its new one in the second; nothing calls it. | |
| s32 | BattlePres_DivideBy16 (s32 value) |
| Nothing calls it. | |
| s32 | Runtime_AdjustDebugValueWithButtons (s32 selectedValue) |
| A debug aid: while Start is held, edits BattleWork.debugValue with the d-pad (1 left and right, 100 up and down) until A takes it as the result; with Select held, returns DEBUG_SELECT_VALUE instead. | |
| void | BattlePres_SetActorRecordMode (s32 actorId, s32 mode) |
| Sets the OBJ mode (1 semi-transparent, 0 normal) of every sprite of a unit's battle object, the picture and its shadow. | |
| void | BattlePres_SetOtherActorRecordModes (s32 selectedUnitId) |
| Makes every unit's sprites semi-transparent but selectedUnitId's, which are left as they are; nothing calls it. | |
| void | BattlePres_ClearAllActorRecordModes (void) |
| Returns every unit's sprites to OBJ mode 0; called by BattlePres_SetActorModes when the highlight stops. | |
| void | Graphics_AdvancePaletteCycle (void) |
| Lightens the opaque sprites, the highlighted units, by the next step of gBattleFx_HighlightBlendRamp. | |
| void | BattlePres_SetActorModes (u16 *selectedUnits, s32 mode) |
| Highlights the units in selectedUnits, a list ended by BATTLE_UNIT_LIST_END, or with mode 0 stops the highlight. | |
The battle background, its palette and perspective, the camera's zoom and the units' highlights.
Part of battle.c, the battle object, compiled only through it.
Definition in file background.c.
| #define DEBUG_SELECT_VALUE 0x18f |
Definition at line 12 of file background.c.
Referenced by Runtime_AdjustDebugValueWithButtons().
| #define BACKGROUND_LEVEL_STEP 1092 |
BattlePresentation_SetPaletteLevel's and BattleBackground_Load's darkening step: each level takes 1092 from the 16.16 brightness, so level 60 is almost black.
Definition at line 20 of file background.c.
Referenced by BattleBackground_Load(), and BattlePresentation_SetPaletteLevel().
| #define BACKGROUND_PLANE_UPPER |
The perspective plane's BG2CNT for the first 256 picture tiles: a 256 by 256 affine map in screen block 7, 256 colours, priority 2.
Definition at line 24 of file background.c.
Referenced by BattleCamera_SetRange().
| #define BACKGROUND_PLANE_LOWER |
The same map, reading the remaining picture tiles from character block 3.
Definition at line 28 of file background.c.
Referenced by BattleCamera_SetRange().
| #define BACKGROUND_PLANE_OFF |
Lines outside the plane read the padded map in screen block 31.
Definition at line 32 of file background.c.
Referenced by BattleCamera_SetRange().
| typedef void(*) BitDecoder(const u8 *source, void *destination) |
The bit decoder BattleBackground_Load copies to RAM and runs.
Definition at line 159 of file background.c.
Copies the background's saved palette to BG palettes 6 to 13, darkened by level (0 for none).
Called by BattlePres_RestorePalette with 0, and by effects that dim the background (beams.c, canvas.c). Sets BattleWork.brightness when it darkens; interrupts are off while it writes, as IME_DISABLE turns them off by storing REG_IME's own address, whose bit 0 is clear.
Definition at line 42 of file background.c.
Referenced by BattlePres_RestorePalette(), and BattlePresentation_SetPaletteLevel().
Switches the background's display mode, optionally sets its palette, and rebuilds both its maps.
fade 0x80 restores the saved palette, another nonzero fade takes that much from each colour channel, and 0 leaves the palette alone; mode 1 queues BATTLE_BG1CNT for BG1. Called with mode 1 by BattleFx_PlayUnitElementEffect and the effects' canvas layers (canvas.c), and with mode 2 by BattlePresentation_DispatchAction and Battle_ProcessRoundEnd. Sets BattleBackgroundView.mode, adds BattlePres_UpdateHBlankScroll when the mode was 0, and copies the first sprite palette to BG palette 5. unusedResource is not read.
Definition at line 85 of file background.c.
Referenced by Battle_ProcessRoundEnd(), BattleFx_PlayUnitElementEffect(), BattlePresentation_ConfigurePaletteFade(), and BattlePresentation_DispatchAction().
| void BattlePresentation_InitializeWorkAndResetState | ( | void | ) |
Allocates the perspective plane's scanline work (heap slot 10) cleared, and sets the background's mode to 0, so the next load adds its scanline callback.
Called once by Battle_RunEncounter before BattleBackground_Load.
Definition at line 145 of file background.c.
Referenced by Battle_RunEncounter(), and BattlePresentation_InitializeWorkAndResetState().
| void Runtime_ReleaseHeapBlock10 | ( | void | ) |
Frees the perspective plane's scanline work (heap slot 10); called by Battle_RunEncounter as the battle ends.
Definition at line 156 of file background.c.
Referenced by Battle_RunEncounter(), and Runtime_ReleaseHeapBlock10().
Loads a battle background: its picture into character blocks 2 and 3, its palette into BattleWork.palette and, darkened by level, BG palettes 6 to 13, and both its maps.
A negative level leaves the BG palettes alone. The resource is 256 bytes of palette and then the packed picture, which the RAM copy of BitDecoder_DecodeImage (heap slot 49) unpacks. Called with mode 1 by Battle_RunEncounter as the battle opens, and by the Atalanta and Boreas effects for their violet sky. Sets BattleBackgroundView.mode, and adds BattlePres_UpdateHBlankScroll when the mode was 0.
Definition at line 170 of file background.c.
Referenced by Battle_RunEncounter(), and BattleBackground_Load().
Builds the perspective plane's next page for a zoom of scale about centerX and centerY (all 16.16), shifted by offsetX and offsetY (8.8 pixels), and shows it.
The page holds the affine parameters and each line's BG2CNT: which half of the picture a line shows, or none. At a zoom of 1 or more the plane wraps and turns sideways with the camera's yaw. While the background is in mode 1 (or secondMode is) and not busy, it also sets BG1's horizontal scroll. Called by BattlePres_SetupTransitionScene, by BattlePresentation_UpdateCamera and the shoulder-key camera (DEFINE_ADJUST_CAMERA) while BattlePresentationTransition.flag is 0, by Battle_RunEncounter and by Camera_ConfigureScene. Does nothing before heap slot 10 is allocated, and builds no page unless the mode is 2.
Definition at line 224 of file background.c.
Referenced by Battle_RunEncounter(), BattleCamera_SetRange(), BattlePres_SetupTransitionScene(), BattlePres_SetupTransitionSceneAtDepth(), BattlePresentation_UpdateCamera(), and Camera_ConfigureScene().
Sets the camera's eye at its stored distance without taking a zoom; nothing in the source calls it.
The original zoom is an uninitialized local; UBFIX makes it an explicit percentage argument, as in BattlePres_SetupTransitionScene.
Definition at line 301 of file background.c.
Referenced by BattlePres_SetupTransitionSceneAtDepth().
Points the battle camera at (x, depth, y) with a zoom in percent, and lines the perspective plane up with it.
The camera's eye is set 510 pixels from the focus along its yaw and pitch; where the battlefield's origin then projects decides the plane's offset (BattleCamera_SetRange), and the projection's focal length and depth range are then scaled by the zoom. Called by the battle's staging (BattlePres_RunEntryTransition, Battle_RunEncounter, staging.c, auto_battle.c), BattlePres_SetupTransitionAtPairMidpoint and several effects. Writes the camera's pos and eye, gProjection, and the plane's next page.
Definition at line 359 of file background.c.
Referenced by Battle_RunEncounter(), BattlePres_AdvanceTransitionTimer(), BattlePres_RunAttack(), BattlePres_RunEntryTransition(), BattlePres_SetupTransitionAtPairMidpoint(), BattlePres_SetupTransitionScene(), BattlePresentation_RunPairedUnitTransition(), and BattlePresentation_RunUnitTransition().
Points the battle camera, through BattlePres_SetupTransitionScene, at the ground between two units' battle objects, with a zoom in percent.
Called by the staging of a paired action (staging.c) and by the beam effects (beams.c).
Definition at line 406 of file background.c.
Referenced by BattlePres_RunAttack(), and BattlePres_SetupTransitionAtPairMidpoint().
| void Graphics_FadeAlphaOut | ( | void | ) |
Fades BG2 out over the backdrop in eight frames, its blend weight falling by 2 a frame from 15, while the backdrop's stays 16.
Reached only through its entry in FarCall_BattleTable, which no code in TBS names. Leaves REG_BLDCNT blending BG2 over the backdrop.
Definition at line 424 of file background.c.
Referenced by Graphics_FadeAlphaOut().
| void Graphics_FadeAlphaIn | ( | void | ) |
Fades BG2 in over the backdrop in eight frames, its blend weight rising by 2 a frame from 1, while the backdrop's stays 16.
Reached only through its entry in FarCall_BattleTable, which no code in TBS names. Leaves REG_BLDCNT blending BG2 over the backdrop.
Definition at line 438 of file background.c.
Referenced by Graphics_FadeAlphaIn().
| void Graphics_SetBlendControl | ( | void | ) |
Sets REG_BLDCNT to lighten every layer by REG_BLDY; nothing calls it.
Definition at line 458 of file background.c.
Referenced by Graphics_SetBlendControl().
| void BattlePresentation_InitializeTransitionEntries | ( | struct BattleTransitionEntry * | entries | ) |
Sets entries to the identity transform, then stores the first word's old value plus its new one in the second; nothing calls it.
XXX: what the sum is for; a caller, which TBS lacks, would show it.
Definition at line 465 of file background.c.
Referenced by BattlePresentation_InitializeTransitionEntries().
Nothing calls it.
Definition at line 475 of file background.c.
Referenced by BattlePres_DivideBy16().
A debug aid: while Start is held, edits BattleWork.debugValue with the d-pad (1 left and right, 100 up and down) until A takes it as the result; with Select held, returns DEBUG_SELECT_VALUE instead.
Nothing in TBS calls it; it returns selectedValue unchanged otherwise.
Definition at line 481 of file background.c.
Referenced by Runtime_AdjustDebugValueWithButtons().
Sets the OBJ mode (1 semi-transparent, 0 normal) of every sprite of a unit's battle object, the picture and its shadow.
Does nothing for a unit with no battle object or motion object. Called by BattlePres_SetActorModes and its helpers here, by the opening's storm (BattlePres_RunEntryTransition), by the staging (staging.c) and by auto battle (auto_battle.c).
Definition at line 515 of file background.c.
Referenced by BattlePres_ClearAllActorRecordModes(), BattlePres_RunEntryTransition(), BattlePres_SetActorModes(), BattlePres_SetActorRecordMode(), BattlePres_SetOtherActorRecordModes(), BattlePresentation_RunPairedUnitTransition(), and BattlePresentation_RunUnitTransition().
| void BattlePres_SetOtherActorRecordModes | ( | s32 | selectedUnitId | ) |
Makes every unit's sprites semi-transparent but selectedUnitId's, which are left as they are; nothing calls it.
Definition at line 552 of file background.c.
Referenced by BattlePres_SetOtherActorRecordModes().
| void BattlePres_ClearAllActorRecordModes | ( | void | ) |
Returns every unit's sprites to OBJ mode 0; called by BattlePres_SetActorModes when the highlight stops.
Definition at line 565 of file background.c.
Referenced by BattlePres_ClearAllActorRecordModes(), and BattlePres_SetActorModes().
| void Graphics_AdvancePaletteCycle | ( | void | ) |
Lightens the opaque sprites, the highlighted units, by the next step of gBattleFx_HighlightBlendRamp.
The ramp's first sixteen steps play once, then its second sixteen over and over. Runs each frame as a scheduler callback added by BattlePres_SetActorModes while BattleWork.highlightMode is set; writes REG_BLDCNT, REG_BLDALPHA, REG_BLDY and BattleWork.highlightStep.
Definition at line 580 of file background.c.
Referenced by BattlePres_SetActorModes(), and Graphics_AdvancePaletteCycle().
Highlights the units in selectedUnits, a list ended by BATTLE_UNIT_LIST_END, or with mode 0 stops the highlight.
With an odd mode every other unit's sprites turn semi-transparent and the selected units' stay opaque, so only they take the pulsing lightening of Graphics_AdvancePaletteCycle. Called with the acting unit by BattlePresentation_DispatchAction, with the targets being chosen by the command menu (party_commands.c, targets.c, selection.c), and with 0 when either is done. Sets BattleWork.highlightMode and highlightStep, and adds or removes the callback.
Definition at line 609 of file background.c.
Referenced by BattleCommand_BuildPlan(), BattlePres_RunActorEntries(), BattlePres_RunAttack(), BattlePres_RunEscape(), BattlePres_RunItem(), BattlePres_RunPlainAttack(), BattlePres_RunPsynergyCast(), BattlePres_SetActorModes(), BattlePresentation_DispatchAction(), and BattlePresentation_RunUnitTransition().