9#define PROCNE_DUST_CELLS (3 * (48 * 64))
10#define PROCNE_COMET_CELLS 0x3600
42 static struct SpriteScale unitScale = {{{0x10000, 0x10000}}};
113 object = battleObject->
object;
114 home[index].
x =
object->x;
115 home[index].
y =
object->z;
116 baseAngle[index] =
object->angle;
118 radius[index] =
Iwram_Sqrt((object->
x >> 8) * (object->
x >> 8) +
119 (object->
z >> 8) * (object->
z >> 8)) >>
122 object->verticalMotionStrength = 0;
140 }
while (index != 64);
149 else if (frame <= 394)
173 if (frame > index * 16) {
175 object = battleObject->
object;
176 object->
x = (radius[index] *
Trig_Sin(heading[index])) >> 1;
177 object->z = (radius[index] *
Trig_Cos(heading[index])) >> 1;
180 if (frame > index * 16 + 16)
182 if (radius[index] <= 31)
183 object->y += 0x60000;
186 if (object->
y > 0x7c0000)
187 object->y = 0x7c0000;
191 heading[index] += spin[index];
192 if (heading[index] > 0x10000)
193 heading[index] -= 0x10000;
194 object->angle += spin[index] / 4;
198 object->verticalMotionStrength = 0xab85;
203 object->velocityY = 0;
211 if (radius[index] > 16)
219 if ((
u32)(frame - 16) <= 143) {
220 size = frame * 2 - 32;
224 &work->sheet[frame / 4 % 3 * (48 * 64) + (width - size) * 48], 32,
225 112 - size, width, size);
228 if ((
u32)(frame - 48) <= 111) {
229 size = frame * 2 - 96;
233 &work->sheet[frame / 4 % 3 * (48 * 64) + (64 - size) * 48], 32,
234 64 - size, width, size);
237 if ((
u32)(frame - 160) <= 239) {
238 image = work->sheet + frame / 4 % 3 * (48 * 64);
239 draw[0](canvas, image, 8, 0, width, 64);
240 draw[0](canvas, image, 8, 64, width, 64);
249 if (point[index].variant == 0) {
250 world.
x = point[index].
z *
Trig_Sin(point[index].velocityY);
251 world.
y = point[index].
y;
252 world.
z = point[index].
z *
Trig_Cos(point[index].velocityY);
255 if (point[index].y <= 0x3fffff) {
257 screen.
y - 12, 16, 16);
259 if (point[index].z > 24)
262 if (point[index].velocityY > 0x10000)
265 if (point[index].velocityX > 4096)
269 if (point[index].y > 0x300000) {
271 point[index].
z = 100;
279 }
while (index != 24);
305 }
while (index != 512);
309 object = battleObject->
object;
310 object->
y = ((
Random16() & 15) + 8) << 16;
320 angle = (
Random16() & 0x7fff) + 0x9fff;
326 }
while (index != 32);
339 if (frame - 160 <= 64)
342 wave.
x -= (
Trig_Sin((frame - 160) << 7) * 32) >> 6;
343 wave.
y += (
Trig_Sin((frame - 160) << 9) * size) >> 6;
355 place.
height = 0xff0000 + index * 0x400000;
360 }
while (index != 9);
367 depthOffset.
z = 0x1000000;
384 xx = (point->
x >> 8) * (point->
x >> 8);
385 yy = (point->
y >> 8) * (point->
y >> 8);
386 zz = (point->
z >> 8) * (point->
z >> 8);
390 screen.
x = (screen.
x >> 17) + (wave.
x >> 17) + 32;
391 screen.
y = (screen.
y >> 16) + (wave.
y >> 16) - 4;
393 if (screen.
depth <= 169)
395 if (screen.
depth > 350)
397 span = 6 - (screen.
depth - 170) / 36;
400 point->
x -= point->
x / dist;
401 point->
y -= point->
y / dist;
402 point->
z -= point->
z / dist;
407 }
while (index != 32);
410 span = alive / 10 + 1;
412 (wave.
x >> 17) - span / 2 + 32, (wave.
y >> 16) - span - 4,
437 }
while (index != 96);
446 if (spark[index].variant > 0) {
448 screen.
x = (screen.
x >> 17) + 32;
449 screen.
y = (screen.
y >> 16) + 56;
451 if (screen.
depth <= 169)
453 if (screen.
depth > 350)
455 span = 3 - (screen.
depth - 170) / 90;
464 }
while (index != 512);
476 threshold = index * 12 + 330;
477 if (frame == threshold) {
478 mark->
x = (wave.
x >> 17) + 32;
479 mark->
y = (wave.
y >> 16) - 4;
487 }
while (slot != 28);
494 if (frame >= threshold) {
497 size = (frame - threshold) / 2;
506 if (frame < threshold + 8) {
529 if (screen.
depth <= 169)
531 if (screen.
depth > 350)
533 span = 3 - (screen.
depth - 170) / 90;
537 }
while (slot != 28);
541 }
while (index != 4);
547 }
while (frame != 400);
557 obj = battleObject->
object;
558 obj->
x = home[index].
x;
559 obj->
z = home[index].
y;
560 obj->
angle = baseAngle[index];
571 }
while (index != 9);
576#undef PROCNE_DUST_CELLS
577#undef PROCNE_COMET_CELLS
@ SPRITE_COLOR_WHITE
solid colour 15, white
@ POSE_DAMAGE
taking damage
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_BeginCanvasLayer(s32 bgControl)
Opens the canvas layer: starts the background palette fade, makes BG2 the canvas, alpha-blended over ...
void ObjectGroup_UpdateMembers(s32 actorId, s32 palette, s32 animation, s32 timerSlot, s32 timerFrames)
Updates every animation group of one battler's object.
void BattleFx_SetupBlendedDisplay(void)
Shows the BG1 battle background behind a cleared canvas: clears the canvas buffer and the 16 KiB of V...
void BattleFx_SelectLivingTargets(struct BattleEffectArgument *effect)
Shows the battle objects of every unit with HP left on the targets' side: the enemies (units 128 to 1...
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_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 CANVAS_SLOT(slots, slot)
A work slot read through a pointer to the canvas slot, gWorkSlot[HEAP_SLOT_BATTLE_CANVAS],...
#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->...
u16 gBattleFx_MoteCells[]
Mote cells: particle sheets hold ten, cell n (from 0) n + 1 pixels wide and twice that tall.
void BattleFx_SpawnObjects(s32 entryCount, s32 source, u32 priority)
Creates the effect's animation objects in gBattleFxWork's objects.
struct BattleObj * GetBattleObjectSlotFar(s32 objectId)
Far call to BattleObjGet.
void BattleBackground_LoadFar(s32 mode, s32 resource, s32 level)
void BattlePresentation_ConfigurePaletteFadeFar(s32 mode, s32 value, s32 fade)
void Object_ApplyProjectedPlacementFar(struct AnimationObject *sprite, const struct SpritePlacement *position, const struct SpriteScale *scale, s32 facing)
Far call to Render_ApplyProjectedPlacement.
void ResourceObject_ReleaseFar(struct AnimationObject *sprite)
void AudioCommand_PlayFar(s32 id)
@ HEAP_SLOT_BATTLE_EFFECT
@ HEAP_SLOT_BLITTER_ALTERNATE
@ HEAP_SLOT_BATTLE_CANVAS
static s32 Iwram_CopyWords(volatile void *destination, const volatile void *source, s32 size)
static s32 Iwram_Sqrt(s32 value)
volatile u32 gKeysRepeat
Pressed keys, repeating while held: after 19 frames, then every 6.
#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.
u32 Random16(void)
Advances the game's random number generator (the C library's classic linear congruential one),...
s32 ArcTan2(s32 x, s32 y)
Returns the angle of the vector (x, y), in 1/65536 turns, measured from the y axis: 0 along +y,...
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...
#define PROCNE_COMET_CELLS
void BattleFx_RunProcne(struct BattleEffectArgument *effect)
A whirlwind lifts the targets, then comets from a block of objects in a violet sky strike them.
#define PROCNE_DUST_CELLS
The whirlwind sheet holds three 48x64 frames, then the dust; the violet comets are decoded further on...
struct Projection gProjection
char ResourceId_VioletSkyBackdrop
char ResourceId_WhirlwindSheet
char ResourceId_ParticleSpritesA
char ResourceId_VioletCometSheet
s32 Resource_DecodeType01(const void *source, void *destination)
Decodes a type-01 resource and returns its unpacked byte count.
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.
s16 actors[8]
the targets' unit ids, count of them
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 shakeFrames
shake frames left; Camera_ApplyShake counts down
struct AnimationObject * objects[16]
the effect's animation objects
struct BattleEffectArgument * effect
the command being run
struct EffectStep particles[64]
free while variant is -1
A unit's place on the battlefield: its sprite object, resources and animations, its anchor spot and s...
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
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
s32 x
16.16 fixed-point pixels
Two-dimensional {x, y} pair for position or velocity, a local of the summon scenes (Nereid,...
s32 x
16.16 pixels in every scene that uses it
A sprite's screen position and its two vertical offsets, in 16.16 pixels.
s32 x
screen x of the sprite's centre
s32 y
screen y at the ground; sets the depth slot
s32 groundHeight
how far the shadow is raised above y
s32 height
how far the image is raised above y
Horizontal and vertical sprite scale; 0x10000 is the original size.
Three coordinates, x, y and z: a position, a velocity or a direction.
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...
static const s32 * Vector3_Coordinates(const struct Vector3 *vector)
Returns the vector's three coordinates as an array.