53#define STAT_BOOST_SCATTERED 512
54#define STAT_BOOST_DRAWN 32
55#define STAT_BOOST_SLOTS 64
105 else if (mode == 2 || mode == 4)
111 originX = originX * 4 / 5;
121 if (mode == 3 || mode == 5) {
132 }
else if (mode == 4) {
146 else if (mode == 2 || mode == 4)
157 else if (mode == 2 || mode == 4)
180 canvasShiftX = -base.
x * 4 / 5 + 64;
199 for (frame = 0; frame != work->
effect->
count * 8 + 108; frame++) {
212 ((
Trig_Sin(frame << 11) * 20) >> 16) + originX + canvasShiftX - 20;
213 s32 y = ((
Trig_Cos(frame << 11) * 4) >> 16) + originY - 24;
222 y = y - frame * 2 + 64;
236 if (frame == member * 8 + 80)
242 if (frame == member * 8 + 48)
250 if (frame > member * 8) {
258 }
else if (mode == 1) {
259 }
else if (mode == 2) {
268 if (frame > member * 8 + i) {
269 s32 xx = (flare->
x >> 8) * (flare->
x >> 8);
270 s32 yy = (flare->
y >> 8) * (flare->
y >> 8);
271 s32 zz = (flare->
z >> 8) * (flare->
z >> 8);
279 screen.
x = screen.
x * 4 / 5 + canvasShiftX;
281 size = 6 - (screen.
depth - 314) / 64;
284 flare->
x -= flare->
x / distance;
285 flare->
y -= flare->
y / distance;
286 flare->
z -= flare->
z / distance;
296 screen.
x = screen.
x * 4 / 5 + canvasShiftX;
299 if (frame >= member * 8 + 52 && frame < member * 8 + 76) {
300 s32 cell = (frame - member * 8 - 52) / 4 % 6;
305 screen.
x - 20, screen.
y - 20, 40, 40);
312 if (frame >= member * 8 + 80 && frame < member * 8 + 108) {
313 s32 cell = (frame - member * 8 - 80) / 4 % 7;
318 screen.
x - 12, screen.
y - 20, 24, 40);
321 }
else if (mode == 3 || mode == 5) {
323 if (frame >= member * 8 + 80 && frame < member * 8 + 104) {
324 s32 cell = (frame - member * 8 - 80) / 4 % 6;
329 screen.
x - 16, screen.
y - 32, 32, 64);
332 }
else if (mode == 4) {
334 if (frame >= member * 8 + 80 && frame < member * 8 + 104) {
335 s32 cell = (frame - member * 8 - 80) / 2 % 6;
343 screen.
x - 32, screen.
y - 24, 64, 32);
345 screen.
x - 32, screen.
y + 8, 64, 32);
350 if (frame >= member * 8 + 80 && frame < member * 8 + 104) {
351 s32 cell = (frame - member * 8 - 80) / 4 % 6;
356 screen.
x - 20, screen.
y - 20, 40, 40);
400#define STAT_REDUCTION_SHARD_CELLS 0x2580
401#define STAT_REDUCTION_SHARD_BYTES 696
402#define STAT_REDUCTION_SHARDS 24
403#define STAT_REDUCTION_SLOTS 32
454 for (i = 1; i != 8; i++) {
478 for (i = 0; i != 512; i++) {
486 shard->
y = ((i & 31) / 4 * 6 - 10) << 16;
487 shard->
z = (i % 4 * 2 - 2) << 16;
489 shard->
y = ((i & 31) / 4 * 6 - 10) << 16;
490 shard->
z = (i % 4 * 8 - 16) << 16;
504 for (frame = 0; frame != work->
effect->
count * 4 + 64; frame++) {
517 targetFrame = frame - j * 4;
520 if (targetFrame > 0) {
529 x = screen.
x + xOffset;
532 if (targetFrame <= 26)
533 blitters[0](canvas, work->sheet + targetFrame / 4 % 7 * (24 * 40),
534 x - 12,
y - 20, 24, 40);
536 if (targetFrame <= 23)
537 draw[1](canvas, work->sheet + targetFrame / 4 % 6 * (40 * 40),
538 x - 20,
y - 20, 40, 40);
540 if (targetFrame == 24)
544 if (targetFrame >= 24 && targetFrame <= 60) {
548 if (targetFrame > 28) {
549 level = (targetFrame - 24) / 4;
559 cell = i % 4 * 3 + (shard->
variant + targetFrame) / 8 % 3;
561 x = screen.
x + xOffset;
581#undef STAT_BOOST_SCATTERED
582#undef STAT_BOOST_DRAWN
583#undef STAT_BOOST_SLOTS
584#undef STAT_REDUCTION_SHARD_CELLS
585#undef STAT_REDUCTION_SHARD_BYTES
586#undef STAT_REDUCTION_SHARDS
587#undef STAT_REDUCTION_SLOTS
@ SPRITE_COLOR_WHITE
solid colour 15, white
struct BattleCamera * gCameraWork
BattleEffectDrawRectangle DrawRectangle
#define EFFECT_FOR_EACH_TARGET(i, effect)
Loops i over the effect's targets, effect->actors[0] to effect->actors[effect->count - 1]: the loops ...
void BattleFx_ProcessPendingGraphicsTransfer(void)
Copies the canvas to VRAM once the effect has finished drawing a frame (transferPending): the 128x128...
void BattleFx_BeginCanvasLayer(s32 bgControl)
Opens the canvas layer: starts the background palette fade, makes BG2 the canvas, alpha-blended over ...
void BattleFx_EndCanvasLayer(void)
Closes the canvas layer: plays the closing sound, restores BG1's scroll and the projection centre,...
void Resource_LoadAndDecompress(s32 id, void *dst, s32 skipPalette, s32 copyPalette)
Decompresses a resource whose first 128 bytes may be a palette.
void ObjectGroup_UpdateMembers(s32 actorId, s32 palette, s32 animation, s32 timerSlot, s32 timerFrames)
Updates every animation group of one battler's object.
What every part of the battle effect object shares: its includes, macros and frame-loop helpers.
#define EFFECT_RELEASE_BLITTERS()
Frees the two blitters, the alternate first.
#define EFFECT_PRESENT_FRAME(work)
Ends a frame of a canvas effect: marks the canvas ready for the transfer callback,...
#define EFFECT_DRAW_FLARE(draw, canvas, sheet, x, y, size)
Draws flare cell size of sheet, a square size pixels from its centre to each edge,...
@ CANVAS_COPY_AND_FADE
copy, keeping 50% or 75% (transferValue) of each pixel in the canvas for the next frame
#define EFFECT_GET_WORK_AND_CANVAS(cursor, work, canvas)
The work block and canvas occupy adjacent slots, starting at HEAP_SLOT_BATTLE_EFFECT.
#define EFFECT_CALLBACK_ORDER
The scheduler order of every per-frame effect callback (Scheduler_AddOrUpdateCallback sorts the frame...
#define EFFECT_FINISH_CANVAS()
The usual end of a canvas effect: stops the transfer callback before freeing what it reads,...
#define EFFECT_SHOW_DAMAGE(hitSound)
Lets the battle show the damage: resumes its paused playback, which plays hitSound (an SE_ id; 0 keep...
#define EFFECT_START_TRANSFER(work, mode, value)
Sets the transfer, then starts copying the canvas to VRAM once a frame.
#define EFFECT_LOAD_BLITTER(slot, flags, mode)
Builds a blitter for the 128x128 canvas (1 << 7 pixels each way) in work slot slot: BattleFx_BuildBli...
#define EFFECT_CAP_LEVEL(level, cap)
Caps a colour level at cap, and at 0 from below.
#define EFFECT_END_FRAME(work)
The usual end of an effect frame: counts down the targets' flash timers (ObjectGroup_TickMemberTimers...
#define EFFECT_VIEW_FROM_CAMERA(camera)
Starts a frame's 3D projection from the battle camera: resets the transform, then looks from camera->...
#define EFFECT_BEGIN_NARROW_CANVAS(bgControl)
Opens the canvas layer at the canvas's own width, one texel per pixel, where BattleFx_BeginCanvasLaye...
u8 gStatChange_ShardWidths[]
u16 gStatChange_ShardCells[]
u8 gStatChange_ShardHeights[]
struct BattleObj * GetBattleObjectSlotFar(s32 objectId)
Far call to BattleObjGet.
s32 BattleUnit_GetEffectHeightFar(s32 id)
void AudioCommand_PlayFar(s32 id)
@ HEAP_SLOT_BLITTER_ALTERNATE
#define WORK_SLOT(n)
Reads slots through their own addresses; adjacent slots are reached by offsets.
#define Q_8_8(n)
The BG2/BG3 affine matrix entries are signed 8.8 fixed point: texels stepped per screen pixel.
static s32 Iwram_CopyWords(volatile void *destination, const volatile void *source, s32 size)
static s32 Iwram_Sqrt(s32 value)
#define SET_POSITION(p, px, py, pz)
Sets the position or the velocity of a particle, a piece of debris or an object in one statement.
#define SET_VECTOR(v, x, y, z)
Sets the x, y and z of a three-part vector: a position about to be projected, a per-frame step,...
#define CLAMP(v, low, high)
Keeps v within low to high, the low bound tested first.
u32 Random16(void)
Advances the game's random number generator (the C library's classic linear congruential one),...
void Runtime_ReleaseHeapBlock(s32 slot)
void BattleFx_FetchRectangleBlitters(s32 flip, BlitterPair out)
Builds the two usual routines that draw onto the 128x128 canvas, both clipped on both axes.
void EffectPosition_ProjectScaledBattler(s32 id, struct EffectPosition *position)
The screen position of a battler, scaled for the battle view, 16 pixels higher.
void EffectStep_AdvanceWithGravity3D(struct EffectStep *step, s32 damping, s32 gravity)
Moves a particle one frame in three dimensions: adds its velocity, then gravity to its vertical speed...
s32 EffectPosition_ProjectPoint(const void *point, struct EffectPosition *position)
Projects a point in the current transform onto the screen, 16 pixels higher, and returns the projecti...
void BattleFx_RunDjinniEntrance(struct BattleEffectArgument *effect, s32 mode, s32 side, s32 anchor, s32 *outX, s32 *outY)
Djinni entrance: sparks swirl around a point that travels from the user to the goal and gather into t...
char ResourceId_PinkBurstSheet
char ResourceId_WispSheet
char ResourceId_VenusDjinnSheet
char ResourceId_MarsDjinnSheet
char ResourceId_ShieldSheet
char ResourceId_ParticleSpritesD
char ResourceId_VioletStreakSheet
char ResourceId_JupiterDjinnSheet
char ResourceId_DaggerSheet
char ResourceId_GlowOrbSheet
char ResourceId_PaletteRampImage
s32 Scheduler_AddOrUpdateCallback(SchedulerCallback callback, s32 order)
Schedules callback with order, or gives a task already running it the new order, and re-sorts the tab...
s32 Scheduler_RemoveCallback(SchedulerCallback callback)
Unschedules the task running callback: clears its routine and gives it order 0x7fff,...
#define STAT_REDUCTION_SHARDS
shards drawn for each target
void BattleFx_RunGranite(struct BattleEffectArgument *effect)
Gathers stat-boost light and displays a violet streak in Venus colours.
StatBoostSheet
Where each picture sits in the sheet.
@ STAT_BOOST_PICTURE
the picture the mode picks
@ STAT_BOOST_FLARES
flares (ParticleSpritesD)
@ STAT_BOOST_BURST
six 40x40 bursts of light (GlowOrb)
@ STAT_BOOST_DJINNI
the 40x40 djinni
#define STAT_REDUCTION_SHARD_CELLS
#define STAT_BOOST_SCATTERED
flares scattered at the start
#define STAT_BOOST_DRAWN
flares drawn for each target
void BattleFx_RunWard(struct BattleEffectArgument *effect)
Gathers stat-boost light and displays a shield in Jupiter colours.
void BattleFx_RunDull(struct BattleEffectArgument *effect)
Breaks the dagger picture into shards that fade through darker copies.
#define STAT_REDUCTION_SLOTS
particles reserved for each target
void BattleFx_RunZephyr(struct BattleEffectArgument *effect)
Gathers stat-boost light and displays a wisp without replacing its palette.
UNUSED void BattleFx_RunStatReductionMode3(struct BattleEffectArgument *effect)
Breaks the shield picture into fading shards with style 3, which plays as style 2 does.
void BattleFx_RunImpair(struct BattleEffectArgument *effect)
A shield appears over each target and breaks into shards that fade through darker copies,...
void BattleFx_RunWeaken(struct BattleEffectArgument *effect)
A shield appears over each target and breaks into fading shards, in the pink burst's colours (style 2...
void BattleFx_RunFlash(struct BattleEffectArgument *effect)
Gathers stat-boost light and displays a violet streak in Mars colours.
void BattleFx_RunGuard(struct BattleEffectArgument *effect)
Gathers stat-boost light and displays a shield in Mars colours.
#define STAT_BOOST_SLOTS
particles reserved for each target
void BattleFx_RunImpact(struct BattleEffectArgument *effect)
Gathers stat-boost light and displays a dagger in Mars colours.
void BattleFx_RunStatBoost(struct BattleEffectArgument *effect, u32 mode)
Flares of light swirl in to the centre of each target, one target every 8 frames, burst,...
#define STAT_REDUCTION_SHARD_BYTES
bytes in each copy
void BattleFx_RunStatReduction(struct BattleEffectArgument *effect, s32 mode)
Stat cuts: a dagger (mode 0) or a shield (other modes) appears over each target, 4 frames apart,...
The battle camera: its eye, the focus it turns about, and its pitch, yaw and distance.
The command shared by an effect's caller, dispatcher and handlers.
s32 side
1 when the targets are the party, 0 for enemies
s16 actors[8]
the targets' unit ids, count of them
s32 count
targets in actors, at least 1
s32 prelude
1 plays a prelude: in some effects a Djinni appears
The running battle effect's work: its canvas image, 64 particles, the display registers it stages and...
s32 frame
frame counter some effects keep, from 0
s32 transferMode
How the canvas transfer callbacks treat the canvas after each copy (enum CanvasTransferMode in effect...
s32 transferValue
The transfer mode's argument: the fill value, the share kept (50 or 75 percent) or the darken or brig...
struct BattleEffectArgument * effect
the command being run
struct MotionObject * object
NULL once released.
A point projected onto the screen, with its depth.
s32 depth
projected depth, larger further away
A moving point of an effect: its position, its velocity and a value each effect uses its own way (a s...
s32 velocityX
16.16 fixed-point pixels per frame
s32 z
16.16 fixed-point pixels
s32 variant
each effect's own: a size, a countdown, -1 for idle
s32 x
16.16 fixed-point pixels
s32 y
16.16 fixed-point pixels
s32 velocityY
16.16 fixed-point pixels per frame
s32 velocityZ
16.16 fixed-point pixels per frame
An effect object that moves and draws one sprite: its position, scale, velocity and target,...
s32 z
16.16 fixed-point pixels
s32 y
16.16 fixed-point pixels
u16 height
half the sprite's box height; FieldActor's radius
s32 x
16.16 fixed-point pixels
void * Resource_GetTableEntry(s32 index)
Returns the ROM address of resource index from the resource directory.
#define EFFECT_CLIP_BOUNDS
Clips overflow on all four sides.
#define PARTICLES
The map cell buffer (gMapCellBuffer), which the effects borrow, has two views here: Ram_MapCellBuffer...
DrawRectangle BlitterPair[2]
A blitter pair: [0] built in HEAP_SLOT_BLITTER and [1] in HEAP_SLOT_BLITTER_ALTERNATE (BattleFx_Fetch...