70#define TARGET_MOTES_START_WIDE(mode) \
71 ((mode) <= 1 || (mode) == 4 || (mode) == 5 || (mode) == 6 || (mode) == 7)
73#define TARGET_MOTES_CLOSE_IN(mode) \
74 ((mode) <= 1 || (mode) == 4 || (mode) == 5 || (mode) == 6)
78#define TARGET_MOTES_RIPPLE(mode) (!((mode) <= 1 || (mode) == 3))
83#define TARGET_MOTES 512
84#define TARGET_MOTES_SLOTS 64
85#define TARGET_MOTES_CYCLE 24
130 }
else if (mode == 1) {
132 }
else if (mode == 2) {
134 }
else if (mode == 3) {
136 }
else if (mode == 4) {
138 }
else if (mode == 5) {
142 }
else if (mode == 7) {
190 for (frame = 0; frame != total; frame++) {
196 if (frame == total - 46)
199 if (frame == total - 32) {
204 }
else if (frame == total - 32) {
210 row = work->bg2xLines;
211 for (i = 0; i != 160; i++)
212 *row++ = (0x40000 - ((
Trig_Sin((frame << 12) + i * 0x800) * 4))) >> 10;
220 if (mode == 3 && frame > member * 8 && frame < member * 8 + 32) {
223 for (i = 0; i != 2; i++) {
260 if (frame > member * 8) {
262 if (mode <= 1 || mode == 4)
264 for (i = 0; i != count; i++) {
268 if (frame > member * 8 + i) {
269 s32 xx = (mote->
x >> 8) * (mote->
x >> 8);
270 s32 yy = (mote->
y >> 8) * (mote->
y >> 8);
271 s32 zz = (mote->
z >> 8) * (mote->
z >> 8);
274 if (distance != 0 && mote->
variant <= 23) {
282 if (mode == 5 || mode == 7)
283 draw[1](canvas, work->sheet + cell * (40 * 40), screen.
x - 20,
284 screen.
y - 20, 40, 40);
286 draw[1](canvas, work->sheet + 0xc00, screen.
x - 6,
287 screen.
y - 12, 12, 24);
289 draw[1](canvas, work->sheet, screen.
x - 11, screen.
y - 21, 22,
292 draw[(i & 3) != 0](canvas, work->sheet + cell * (24 * 48),
293 screen.
x - 12, screen.
y - 24, 24, 48);
298 mote->
x -= mote->
x / distance;
299 mote->
y -= mote->
y / distance;
300 mote->
z -= mote->
z / distance;
321 if (frame == member * 8 + 16) {
322 s32 delay = total - frame;
341#define SLEEP_FRAMES 148
342#define SLEEP_SEEDED 32
343#define SLEEP_SHEEP 12
388 for (particleIndex = 0; particleIndex !=
SLEEP_SEEDED; particleIndex++) {
389 current = &sheep[particleIndex];
390 current->
x = ((
Random16() & 63) + 32) << 16;
391 current->
y = -0x200000;
416 if (frame == targetIndex * 16 + 64)
421 for (particleIndex = 0; particleIndex !=
SLEEP_SHEEP;
422 particleIndex++, current++) {
423 if (frame > particleIndex * 4 && current->
y <= 0x7fffff) {
428 cell = (current->
variant / 16) & 7;
430 drawUpright(canvas, work->sheet + (cell << 10),
431 (current->
x >> 16) - 16, (current->
y >> 16) - 16, 32, 32);
433 drawFlipped(canvas, work->sheet + (cell << 10) - 0x1000,
434 (current->
x >> 16) - 16, (current->
y >> 16) - 16, 32, 32);
443 if (current->
y > 0x5c0000 && current->
velocityY > 0) {
445 if (current->
y > 0x5c0000 && current->
velocityY == 0) {
448 current->
y = 0x5c0000;
459#define CURSE_MARKER_CELLS 1728
522 if (frame == start) {
525 if (frame >= start && frame < start + 72) {
529 screenPosition.
x -= 112;
531 y = screenPosition.
y;
532 screenPosition.
y =
y - 16;
536 screenPosition.
x - 8,
y - 20, 16, 20);
537 if (frame >= start) {
538 cell = ((frame - start) + marker->
variant) / 6 % 9;
539 draw[0](canvas, work->sheet + cell * (16 * 12),
540 screenPosition.
x - 8, screenPosition.
y - 16, 16, 12);
553#undef TARGET_MOTES_START_WIDE
554#undef TARGET_MOTES_CLOSE_IN
555#undef TARGET_MOTES_RIPPLE
557#undef TARGET_MOTES_SLOTS
558#undef TARGET_MOTES_CYCLE
562#undef CURSE_MARKER_CELLS
@ SPRITE_COLOR_WHITE
solid colour 15, white
@ POSE_DAMAGE
taking damage
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_ArmBg2AffineHBlankDma(void)
Arms DMA 0 to copy one word of gBattleFxWork's bg2xLines table into BG2X at each horizontal blank,...
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,...
@ CANVAS_COPY_AND_CLEAR
copy, then fill the canvas with transferValue
@ 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_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_FINISH_CANVAS_ONE_BLITTER()
The same for an effect that drew through one blitter.
#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_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->...
#define EFFECT_BEGIN_NARROW_CANVAS(bgControl)
Opens the canvas layer at the canvas's own width, one texel per pixel, where BattleFx_BeginCanvasLaye...
u8 gTargetMotes_GlintFlips[]
Glint orientations: none, and mirrored each way and both.
u8 gBattleFx_GlintCellHeights[]
u16 gBattleFx_GlintCells[]
u8 gBattleFx_GlintCellWidths[]
struct BattleObj * GetBattleObjectSlotFar(s32 objectId)
Far call to BattleObjGet.
void BattleMotion_ApproachTargetFar(s32 actorId, s32 targetId, s32 travel_divisor, s32 initial_velocity_y)
void BattleMotion_ApplyVariantMotionFar(s32 id, s32 variant)
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_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)
#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,...
u32 Random16(void)
Advances the game's random number generator (the C library's classic linear congruential one),...
void Runtime_ReleaseHeapBlock(s32 slot)
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...
char ResourceId_PinkBurstSheet
char ResourceId_CyanPalette
char ResourceId_TornadoSheet
char ResourceId_LimePalette
char ResourceId_HeartSheet
char ResourceId_VortexSheet
char ResourceId_MarsDjinnSheet
char ResourceId_BlastSheet
char ResourceId_FlameColumnSheet
char ResourceId_SmokeSheet
char ResourceId_SheepSheet
char ResourceId_GlowOrbSheet
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,...
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
s32 variant
the ability's size, from 0 (Quake, then Earthquake)
s32 count
targets in actors, at least 1
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 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 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
void * Resource_GetTableEntry(s32 index)
Returns the ROM address of resource index from the resource directory.
void BattleFx_RunDelude(struct BattleEffectArgument *effect)
Cyan smoke that rises.
#define TARGET_MOTES
motes scattered at the start
UNUSED void BattleFx_RunTargetMotesMode1(struct BattleEffectArgument *effect)
Pink smoke; no ☀️ effect table entry points here.
void BattleFx_RunParalyze(struct BattleEffectArgument *effect)
Rising smoke with glints.
void BattleFx_RunSleep(struct BattleEffectArgument *effect)
Twelve sheep drop onto the targets' side, one every 4 frames, tumbling through eight images (the last...
void BattleFx_RunHeartrender(struct BattleEffectArgument *effect)
Hearts.
void BattleFx_RunDemonFire(struct BattleEffectArgument *effect)
Glowing orbs in Mars Djinn colours, and the user strikes.
#define CURSE_MARKER_CELLS
the marker picture in the sheet
void BattleFx_RunTargetMotes(struct BattleEffectArgument *effect, u32 mode)
Around each target in turn, 8 frames apart, motes (smoke, hearts, orbs) turn about a point 20 pixels ...
#define TARGET_MOTES_SLOTS
particles reserved for each target
#define TARGET_MOTES_START_WIDE(mode)
Styles whose motes start in a wide ball and last 64 frames more.
#define TARGET_MOTES_RIPPLE(mode)
Modes other than 0, 1 and 3 ripple the canvas: BG2's x is set line by line from work->bg2xLines (Batt...
#define TARGET_MOTES_CYCLE
frames of a mote's image cycle
#define TARGET_MOTES_CLOSE_IN(mode)
Styles whose motes close in on the target; the others rise.
@ TARGET_MOTES_GLINT_CELLS
#define SLEEP_SEEDED
particles cleared at the start
void BattleFx_RunMysticFlame(struct BattleEffectArgument *effect)
Glowing orbs.
void BattleFx_RunDrown(struct BattleEffectArgument *effect)
Vortex motes.
#define SLEEP_SHEEP
sheep dropped
void BattleFx_RunTaint(struct BattleEffectArgument *effect)
Lime smoke (effect->variant 0) or pink smoke.
void BattleFx_RunCurse(struct BattleEffectArgument *effect)
A small flame burns above each target in turn, 16 frames apart, for 72 frames each,...
#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...