17#define HEALING_DJINNI_CELLS 0x1000
75#define HEALING_MOTES 512
76#define HEALING_SLOTS 64
77#define HEALING_STAGGER 8
78#define HEALING_SOUND_DELAY 20
79#define HEALING_TINT_DELAY 36
80#define HEALING_TINT_FRAMES 28
81#define HEALING_DAMAGE_FRAME 40
138 s32 kind = mode == 6 ? 2 : 1;
140 if (mode == 6 || mode == 0)
153 canvasShiftX = 64 - base.
x;
164 if (mode <= 1 || mode == 3 || mode == 4 || mode == 5) {
169 }
else if (mode == 6) {
178 if (doubleWidth == 0) {
198 if (mode == 0 || mode == 6) {
209 }
else if (mode == 1) {
220 }
else if (mode == 2) {
233 }
else if (mode == 3) {
262 motesPerTarget = 128;
270 for (frame = 0; frame != frameCount; frame++) {
279 if (doubleWidth == 0) {
281 ((
Trig_Sin(frame << 11) * 20) >> 16) + originX + canvasShiftX - 20;
282 s32 y = ((
Trig_Cos(frame << 11) * 4) >> 16) + originY - 24;
285 y = y - frame * 2 + 64;
290 s32 x = ((
Trig_Sin(frame << 11) * 10) >> 16) + originX / 2 - 10;
291 s32 y = ((
Trig_Cos(frame << 11) * 4) >> 16) + originY - 24;
294 y = y - frame * 2 + 64;
321 if (mode == 0 || mode == 6) {
323 }
else if (mode == 1) {
326 }
else if (mode == 2) {
328 }
else if (mode == 3) {
337 for (i = 0; i != motesPerTarget; i++) {
341 if (mode == 3 || mode == 4 || mode == 5)
342 endFrame = start + i / 2 + 32;
345 if (frame > start + i / 4 && frame < endFrame) {
346 s32 xx = (spark->
x >> 8) * (spark->
x >> 8);
347 s32 yy = (spark->
y >> 8) * (spark->
y >> 8);
348 s32 zz = (spark->
z >> 8) * (spark->
z >> 8);
358 screen.
x += canvasShiftX;
366 size = 3 - (screen.
depth - 314) / 128;
368 size = (i * 4 + frame) % 9;
369 if (mode == 0 || mode == 3 || mode == 4 || mode == 5) {
372 u32 half = edge >> 1;
374 draw[1](canvas, cell, screen.
x - half, screen.
y - half, edge,
383 if (mode <= 2 || mode == 6) {
384 spark->
x -= spark->
x / distance;
385 spark->
y -= spark->
y / distance;
386 spark->
z -= spark->
z / distance;
399#undef HEALING_DJINNI_CELLS
402#undef HEALING_STAGGER
403#undef HEALING_SOUND_DELAY
404#undef HEALING_TINT_DELAY
405#undef HEALING_TINT_FRAMES
406#undef HEALING_DAMAGE_FRAME
@ 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 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_DRAW_MOTE(draw, canvas, sheet, x, y, size)
Particle sheets hold ten mote cells, 1x2 to 10x20 pixels.
@ CANVAS_COPY_AND_FADE
copy, keeping 50% or 75% (transferValue) of each pixel in the canvas for the next frame
#define EFFECT_CALLBACK_ORDER
The scheduler order of every per-frame effect callback (Scheduler_AddOrUpdateCallback sorts the frame...
#define EFFECT_SLOT(slots, slot)
A work slot read through a pointer to the effect's own slot, gWorkSlot[HEAP_SLOT_BATTLE_EFFECT].
#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_GET_SLOTS(slots, cursor, work, canvas)
Starts at the effect's entry in the whole work-slot array.
#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->...
u8 gBattleFx_PuffSizes[]
Each puff cell's side.
u16 gBattleFx_PuffCells[]
Nine square puff cells, read by the falling, frost, healing, Djinni heal and Boreas parts.
struct BattleObj * GetBattleObjectSlotFar(s32 objectId)
Far call to BattleObjGet.
void AudioCommand_PlayFar(s32 id)
#define HEALING_SOUND_DELAY
frames from a target's start to its sound
void BattleFx_RunCure(struct BattleEffectArgument *effect)
Cure (mode 2): a ring of healing motes below each target closes in on it, in the blast sheet's colour...
#define HEALING_MOTES
motes in PARTICLES
void BattleFx_RunPsyCrystal(struct BattleEffectArgument *effect)
Psy Crystal: healing motes gather around each target in the Mars Djinni palette; with a prelude,...
void BattleFx_RunCurePoison(struct BattleEffectArgument *effect)
Cure Poison: sparkles twinkle around each target, four more a frame, and go out one by one instead of...
#define HEALING_DJINNI_CELLS
the djinni picture in the sheet
#define HEALING_SLOTS
particles reserved for each target
UNUSED void BattleFx_RunHealingMotesMode4(struct BattleEffectArgument *effect)
Healing sparkles with scattering style 4, sent out from each target, as Cure Poison plays them for va...
void BattleFx_RunHealingMotes(struct BattleEffectArgument *effect, u32 mode)
Healing sparkles: motes of light scattered around each target swirl in towards it,...
#define HEALING_TINT_FRAMES
frames a target stays tinted white
void BattleFx_RunPly(struct BattleEffectArgument *effect)
Ply: sparkles of light swirl around each target and close in on it, in the ice shard's or ice block's...
#define HEALING_TINT_DELAY
frames from a target's start to its tint
#define HEALING_DAMAGE_FRAME
the frame the battle shows the recovery
void BattleFx_RunTonic(struct BattleEffectArgument *effect)
Tonic (scattering style 5): sparkles twinkle around each target, turning on two axes,...
void BattleFx_RunWish(struct BattleEffectArgument *effect)
Wish (scattering style 1): healing motes tumble in from all around each target.
#define HEALING_STAGGER
frames between one target's start and the next
#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 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.
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_MarsDjinnSmallSheet
char ResourceId_SparkleDots
char ResourceId_MercuryDjinnSmallSheet
char ResourceId_MarsDjinnSheet
char ResourceId_BlastSheet
char ResourceId_IceShardSheet
char ResourceId_ParticleSpritesA
char ResourceId_IceBlockSheet
char ResourceId_MercuryDjinnSheet
s32 Resource_DecodeType01(const void *source, void *destination)
Decodes a type-01 resource and returns its unpacked byte count.
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...
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 variant
the ability's size, from 0 (Quake, then Earthquake)
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 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
An effect object that moves and draws one sprite: its position, scale, velocity and target,...
s32 z
16.16 fixed-point pixels
s32 x
16.16 fixed-point pixels
void * Resource_GetTableEntry(s32 index)
Returns the ROM address of resource index from the resource directory.
#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...