77 for (i = 0, point = work->
particles; i != 3; i++) {
83 point->
velocityY = (target->
y - point->
y + 0x280000) / 12;
90 for (frame = 0; frame != 60; frame++) {
99 speed = 0x300 - frame * 16;
105 for (i = 0; i != 3; i++) {
107 if (frame >= start) {
109 size = (frame - start) / 4 + 2;
117 for (j = 0; j != 10; j++) {
123 scale.
x = ((frame - start) << 12) + 0x1000;
124 if (scale.
x > 0x10000)
134 screenPosition.
x >>= 1;
138 trails[i * 10 + j].
velocityX = screenPosition.
x + base.
x;
139 trails[i * 10 + j].
velocityY = screenPosition.
y + base.
y;
141 trails[i * 10 + j].
velocityX = screenPosition.
x;
142 trails[i * 10 + j].
velocityY = screenPosition.
y;
147 if (peak <= 399999) {
148 for (j = 0; j != 10; j++) {
154 for (k = 0; k != 16; k++) {
170 if (frame == start + i + 10) {
179 target->x - 0x280000, 0, target->z);
182 target->x + 0x280000, 0, target->z);
256 for (i = 0, point = work->
particles; i != 8; i++) {
262 (target->
x + ((
s32)((
Random16() & 0x7f) - 64) * 65536) - point->
x) / 12;
263 point->
velocityY = (target->
y - point->
y + 0x140000) / 12;
271 for (frame = 0; frame != 128; frame++) {
276 for (i = 0; i != 8; i++) {
281 screenPosition.
x >>= 1;
284 if (screenPosition.
x >= -8 && screenPosition.
x <= 127) {
285 if (screenPosition.
y <= 127) {
286 if (screenPosition.
y >= -8) {
287 for (j = 0; j != 10; j++) {
300 for (j = 0; j != 10; j++) {
301 struct EffectStep *from = &trails[j + i * 10];
302 struct EffectStep *to = &trails[i * 10 + (j + 1) % 10];
304 for (k = 0; k != 12; k++) {
317 if (step->
y <= 0x1dffff) {
@ 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_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 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_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_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_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->...
static const s32 * EffectStep_Coordinates(const struct EffectStep *step)
Returns the step's three coordinates as an array.
struct Vector3 gStars_Points[]
The two star points, 48 and 28 pixels up (16.16).
struct BattleObj * GetBattleObjectSlotFar(s32 objectId)
Far call to BattleObjGet.
void ObjectDispatch_SelectAnimationFar(void *raw, s32 no)
void ObjectDispatch_SetAnimationSpeedFar(struct DispatchObject *obj, s32 val)
void Object_SetMoveTargetFar(struct ObjectRuntime *object, s32 x, s32 y, s32 z)
void ObjectDispatch_StartIdleFar(struct DispatchObject *obj)
void AudioCommand_PlayFar(s32 id)
void Camera_ApplyShake(s32 rangeX, u32 rangeY)
Shakes the battle view while gBattleFxWork's shakeFrames lasts, moving BG1 and the projection centre ...
@ HEAP_SLOT_BATTLE_EFFECT
@ HEAP_SLOT_BATTLE_CANVAS
#define WORK_SLOT(n)
Reads slots through their own addresses; adjacent slots are reached by offsets.
static s32 Iwram_CopyWords(volatile void *destination, const volatile void *source, s32 size)
#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 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 Graphics_UpdatePhasePalette(s32 frame, s32 redPhase, s32 greenPhase, s32 bluePhase)
Rebuilds the background palette's first ramp as a grey ramp whose red, green and blue each sway with ...
char ResourceId_ParticleSpritesA
char ResourceId_RuneSheet
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...
void BattleFx_RunShiningStar(struct BattleEffectArgument *effect)
Eight spinning star outlines fall from 120 pixels above the user towards the first target,...
void BattleFx_RunAstralBlast(struct BattleEffectArgument *effect)
Three star-shaped rings of light fly from 40 pixels above the user at the first target,...
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 actor
the user's unit id
s32 side
1 when the targets are the party, 0 for enemies
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
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 EffectStep particles[64]
free while variant is -1
struct MotionObject * object
NULL once released.
A field object as the object dispatcher's far calls take it.
A point projected onto the screen, with its depth.
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 speedLimit
16.16 fixed-point pixels per frame
s32 z
16.16 fixed-point pixels
s32 y
16.16 fixed-point pixels
s32 velocityY
16.16 fixed-point pixels per frame
s32 acceleration
Horizontal speed gained each frame towards the target, or lost braking without one,...
s32 x
16.16 fixed-point pixels
s32 verticalMotionStrength
Gravity: taken from velocityY each frame above the ground with motionFlags bit 1, in 16....
u8 autoFaceMotion
bit 0 turns the object to face where it moves
One of the 64 field objects in the object pool (heap slot 5): its script, position,...
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.