Alchemy
Loading...
Searching...
No Matches

star_field.c File Reference

A unit's elemental glow: the star field and the other glows. More...

Go to the source code of this file.

Data Structures

struct  Spark
 One of the star field's sparks, drawn inward to the centre. More...
struct  SparkWork
 The star field's work: its sprite sheet, 16 sparks and 3 rings. More...

Macros

#define STAR_FIELD_UPDATE_CALLBACK   ((SchedulerCallback)BattleFx_UpdateStarField)
#define STAR_FIELD_UPLOAD_CALLBACK   ((SchedulerCallback)BattleFx_UploadStarField)

Typedefs

typedef void(*) DrawFunc(void *dest, u8 *src, s32 x, s32 y, s32 width, s32 height)
 A blitter loaded into a work slot: draws a width by height picture at (x, y) on the canvas.

Functions

 STATIC_ASSERT (offsetof(struct SparkWork, canvasOrigin)==offsetof(struct BattleEffectWork, trackedCanvas.origin))
s32 BattleFx_UpdateStarField (void)
u32 BattleFx_UploadStarField (void)
s32 BattleFx_InitializeStarField (s32 mode)
 Starts a star field of the element mode (0 to 3, enum Element order): sixteen sparks on random rings and three rings 120 degrees apart.
s32 Graphics_ResetVramBlockAndReleaseHeapBlocks (s32 unused)
 Ends a star field: clears BG2's tiles in character block 1, frees its blitters, canvas and work, turns BG2 off and removes both callbacks.
s32 Graphics_ScaleRgb555Clamped (u16 *source, u16 *destination, s32 scale, s32 count)
 Copies count colours from source to destination, each channel scaled by scale (16.16, at most 1), and returns 0.
void BattleFx_PlayUnitElementEffect (s32 unitId, s32 element, s32 mode, s32 variant)
 Plays a glow of the element about a unit, and returns when it is over.
void BattlePres_RestorePalette (void)
 Copies the background's saved palette back undarkened, as the star field of BattleFx_PlayUnitElementEffect leaves it dark.
void Runtime_RemoveIrqHandlerSlot2 (void)
 Removes the VCount interrupt's handler, as BattlePres_RunEntryTransition installs one; nothing calls it.

Detailed Description

A unit's elemental glow: the star field and the other glows.

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

Definition in file star_field.c.

Macro Definition Documentation

◆ STAR_FIELD_UPDATE_CALLBACK

#define STAR_FIELD_UPDATE_CALLBACK   ((SchedulerCallback)BattleFx_UpdateStarField)

◆ STAR_FIELD_UPLOAD_CALLBACK

#define STAR_FIELD_UPLOAD_CALLBACK   ((SchedulerCallback)BattleFx_UploadStarField)

Typedef Documentation

◆ DrawFunc

typedef void(*) DrawFunc(void *dest, u8 *src, s32 x, s32 y, s32 width, s32 height)

A blitter loaded into a work slot: draws a width by height picture at (x, y) on the canvas.

Definition at line 34 of file star_field.c.

Function Documentation

◆ STATIC_ASSERT()

STATIC_ASSERT ( offsetof(struct SparkWork, canvasOrigin) = =offsetof(struct BattleEffectWork, trackedCanvas.origin))

◆ BattleFx_UpdateStarField()

s32 BattleFx_UpdateStarField ( void )

Definition at line 48 of file star_field.c.

Referenced by BattleFx_UpdateStarField().

◆ BattleFx_UploadStarField()

u32 BattleFx_UploadStarField ( void )

Definition at line 168 of file star_field.c.

Referenced by BattleFx_UploadStarField().

◆ BattleFx_InitializeStarField()

s32 BattleFx_InitializeStarField ( s32 mode)

Starts a star field of the element mode (0 to 3, enum Element order): sixteen sparks on random rings and three rings 120 degrees apart.

Allocates the field's work (HEAP_SLOT_BATTLE_EFFECT) and a cleared 128 by 128 canvas (HEAP_SLOT_BATTLE_CANVAS), decodes the blue ring sheet into the work, loads the element's 64 colours over the first of BG palette RAM, sets BG2's affine parameters to no zoom, loads both blitters and adds BattleFx_UpdateStarField and BattleFx_UploadStarField. Also sets BattleBackgroundView.mode to 1. Called by BattleFx_PlayUnitElementEffect; Graphics_ResetVramBlockAndReleaseHeapBlocks undoes it.

Definition at line 198 of file star_field.c.

Referenced by BattleFx_InitializeStarField(), and BattleFx_PlayUnitElementEffect().

◆ Graphics_ResetVramBlockAndReleaseHeapBlocks()

s32 Graphics_ResetVramBlockAndReleaseHeapBlocks ( s32 unused)

Ends a star field: clears BG2's tiles in character block 1, frees its blitters, canvas and work, turns BG2 off and removes both callbacks.

Called by BattleFx_PlayUnitElementEffect once the field has played.

Definition at line 297 of file star_field.c.

Referenced by BattleFx_PlayUnitElementEffect(), and Graphics_ResetVramBlockAndReleaseHeapBlocks().

◆ Graphics_ScaleRgb555Clamped()

s32 Graphics_ScaleRgb555Clamped ( u16 * source,
u16 * destination,
s32 scale,
s32 count )

Copies count colours from source to destination, each channel scaled by scale (16.16, at most 1), and returns 0.

Called to darken the background's palette by BattlePresentation_SetPaletteLevel, BattleBackground_Load, BattleFx_PlayUnitElementEffect, the item staging (staging.c) and the effects' canvas (canvas.c).

Definition at line 315 of file star_field.c.

Referenced by BattleBackground_Load(), BattleFx_PlayUnitElementEffect(), BattlePres_RunItem(), BattlePresentation_SetPaletteLevel(), and Graphics_ScaleRgb555Clamped().

◆ BattleFx_PlayUnitElementEffect()

void BattleFx_PlayUnitElementEffect ( s32 unitId,
s32 element,
s32 mode,
s32 variant )

Plays a glow of the element about a unit, and returns when it is over.

By mode: 0 the star field gathering on the unit while the background darkens (a cast), 1 the element streaks, 2 the element pillar at strength variant (a summon's power boost) and 3 the element burst (a Djinni set). Called with 0 by BattlePresentation_RunUnitTransition and BattlePres_RunPsynergyCast, with 1 by the latter, with 2 by BattleUnit_ProcessTurnEnd and with 3 by Battle_ProcessRoundEnd and BattleCommand_BuildPlan. Every mode first puts the background in mode 1 and opens window 0 over lines 16 to 135, with BG2 blended over the other layers; mode 0 leaves the background's palette and BattleWork.brightness darkened.

Definition at line 363 of file star_field.c.

Referenced by Battle_ProcessRoundEnd(), BattleCommand_BuildPlan(), BattleFx_PlayUnitElementEffect(), BattlePres_RunPsynergyCast(), BattlePresentation_RunUnitTransition(), and BattleUnit_ProcessTurnEnd().

◆ BattlePres_RestorePalette()

void BattlePres_RestorePalette ( void )

Copies the background's saved palette back undarkened, as the star field of BattleFx_PlayUnitElementEffect leaves it dark.

Called by BattlePresentation_RunUnitTransition and BattlePres_RunPsynergyCast once the effect has played.

Definition at line 469 of file star_field.c.

Referenced by BattlePres_RestorePalette(), BattlePres_RunPsynergyCast(), and BattlePresentation_RunUnitTransition().

◆ Runtime_RemoveIrqHandlerSlot2()

void Runtime_RemoveIrqHandlerSlot2 ( void )

Removes the VCount interrupt's handler, as BattlePres_RunEntryTransition installs one; nothing calls it.

Definition at line 475 of file star_field.c.

Referenced by Runtime_RemoveIrqHandlerSlot2().