Alchemy
Loading...
Searching...
No Matches

stat_change.c

Go to the documentation of this file.
1/// @file
2/// Stat boosts and reductions (Impact, Guard, Ward, Dull, Weaken ...).
3/// Part of effect.c, the battle effect object, compiled only through it.
4
6
7/// Gathers stat-boost light and displays a dagger in Mars colours.
8///
9/// Abilities: Impact, High Impact, Demon Spear, Angel Spear (kind 26); Forge
10/// (kind 210); kind 46 is used by no ability.
12 BattleFx_RunStatBoost(effect, 0);
13}
14/// Gathers stat-boost light and displays a shield in Mars colours.
15///
16/// Abilities: Guard, Protect, Guardian, Protector (kind 28); Corona (kind 211).
18 BattleFx_RunStatBoost(effect, 1);
19}
20/// Gathers stat-boost light and displays a shield in Jupiter colours.
21///
22/// Abilities: Ward, Resist, Magic Shell, Magic Shield (kind 30); Breeze (kind
23/// 215).
25 BattleFx_RunStatBoost(effect, 2);
26}
27/// Gathers stat-boost light and displays a violet streak in Venus colours.
28///
29/// Abilities: Granite (kind 200).
31 BattleFx_RunStatBoost(effect, 3);
32}
33/// Gathers stat-boost light and displays a violet streak in Mars colours.
34///
35/// Abilities: Flash (kind 213).
37 BattleFx_RunStatBoost(effect, 5);
38}
39/// Gathers stat-boost light and displays a wisp without replacing its palette.
40///
41/// Abilities: Zephyr (kind 216).
43 BattleFx_RunStatBoost(effect, 4);
44}
45/// Where each picture sits in the sheet.
47 STAT_BOOST_FLARES = 0x0000, ///< flares (ParticleSpritesD)
48 STAT_BOOST_BURST = 0x060e, ///< six 40x40 bursts of light (GlowOrb)
49 STAT_BOOST_PICTURE = 0x2b8e, ///< the picture the mode picks
50 STAT_BOOST_DJINNI = 0x65c0 ///< the 40x40 djinni
51};
52
53#define STAT_BOOST_SCATTERED 512 ///< flares scattered at the start
54#define STAT_BOOST_DRAWN 32 ///< flares drawn for each target
55#define STAT_BOOST_SLOTS 64 ///< particles reserved for each target
56
57/// Flares of light swirl in to the centre of each target, one target every
58/// 8 frames, burst, and the mode's picture plays. Target n's flares appear
59/// from frame 8n + 1; it glows white on 8n + 48, the burst plays from
60/// 8n + 52 and the picture, with a sound, from 8n + 80. The canvas is shown
61/// at 1.25 times its width (canvas x is 4/5 of screen x).
62/// PARTICLES holds the gathering flares, 64 for each target.
63///
64/// Reached through the six wrappers above, Impact to Zephyr. Copies the mode's
65/// palette over the first 128 bytes of BG palette RAM (all but Zephyr), writes
66/// REG_BG2PA and REG_BG2X, and ends with the transfer callback removed and the
67/// canvas layer closed; the blitters are built and freed within each frame.
68///
69/// effect: the targets. With prelude 1, a Djinni appears first, sways and
70/// rises.
71/// mode: the picture: 0 a dagger, 1 and 2 a shield, 3 and 5 a violet
72/// streak, 4 a wisp. The palette comes from the Venus djinni in mode
73/// 3, the Jupiter djinni in mode 2, the Mars djinni in modes 0, 1 and
74/// 5; mode 4 keeps the palette. The Djinni is Venus in mode 3,
75/// Jupiter in modes 2 and 4, Mars otherwise.
77 void **cursor;
78 struct BattleEffectWork *work;
79 void *canvas;
80 BlitterPair draw;
81 s32 member;
82 s32 canvasShiftX;
83 s32 drawFlags;
84 s32 frame;
85 s32 i;
86 struct EffectPosition base;
87 s32 center[3];
88 struct EffectPosition screen;
89 s32 point[3];
90 s32 originX;
91 s32 originY;
92
93 cursor = gBattleFxWork;
94 EFFECT_GET_WORK_AND_CANVAS(cursor, work, canvas);
95 work->effect = effect;
97
98 // Bring out the Djinni (its element: Venus 0, Jupiter 3, Mars 2); origin
99 // receives where it appears, and x is scaled to the canvas, shown 1.25
100 // times as wide.
101 if (work->effect->prelude == 1) {
102 if (mode == 3)
103 BattleFx_RunDjinniEntrance(effect, 0, work->effect->side ^ 1, 1, &originX,
104 &originY);
105 else if (mode == 2 || mode == 4)
106 BattleFx_RunDjinniEntrance(effect, 3, work->effect->side ^ 1, 1, &originX,
107 &originY);
108 else
109 BattleFx_RunDjinniEntrance(effect, 2, work->effect->side ^ 1, 1, &originX,
110 &originY);
111 originX = originX * 4 / 5;
112 }
113 REG_BG2PA = Q_8_8(0.8); // 1.25 times the width
114
115 // Pictures and palette: the flares, the burst, the mode's picture, then the
116 // Djinni, whose sheet also lends its palette in modes 0, 1, 2, 3 and 5.
118 work->sheet + STAT_BOOST_FLARES, 0, 0);
120 work->sheet + STAT_BOOST_BURST, 1, 1);
121 if (mode == 3 || mode == 5) {
123 work->sheet + STAT_BOOST_PICTURE, 1, 1);
124 if (mode == 3)
125 Iwram_CopyWords((void *)BG_PLTT,
127 128);
128 else
129 Iwram_CopyWords((void *)BG_PLTT,
131 128);
132 } else if (mode == 4) {
134 work->sheet + STAT_BOOST_PICTURE, 1, 1);
135 } else {
136 void *palette;
137
138 if (mode == 0)
140 work->sheet + STAT_BOOST_PICTURE, 1, 0);
141 else
143 work->sheet + STAT_BOOST_PICTURE, 1, 0);
144 if (mode == 0)
146 else if (mode == 2 || mode == 4)
148 else if (mode == 1)
150 else
152 Iwram_CopyWords((void *)BG_PLTT, palette, 128);
153 }
154 if (mode == 3)
156 work->sheet + STAT_BOOST_DJINNI, 1, 0);
157 else if (mode == 2 || mode == 4)
159 work->sheet + STAT_BOOST_DJINNI, 1, 0);
160 else
162 work->sheet + STAT_BOOST_DJINNI, 1, 0);
163
164 // Scatter the flares around the centre: x and z within 25 pixels, y
165 // within 50. All 512 are placed, though each target draws only its first
166 // 32 of 64.
167 for (i = 0; i != STAT_BOOST_SCATTERED; i++) {
168 struct EffectStep *flare = &PARTICLES[i];
169
170 SET_POSITION(flare, (Random16() % 200 - 100) << 14,
171 (Random16() % 200 - 100) << 15,
172 (Random16() % 200 - 100) << 14);
173 flare->variant = 0;
174 }
175
176 // With one target, shift the canvas so that target is at its centre
177 // (64); with several, show the half of the screen on the targets' side.
178 if (work->effect->count == 1) {
180 canvasShiftX = -base.x * 4 / 5 + 64;
181 } else {
182 if (work->effect->side == 1)
183 canvasShiftX = -64;
184 else
185 canvasShiftX = 0;
186 }
187 REG_BG2X = canvasShiftX << 8;
188 // Each transfer keeps half of every level, so the flares leave trails.
190 work->transferValue = 50;
193 if (work->effect->side == 1)
195 else
196 drawFlags = EFFECT_CLIP_BOUNDS;
198
199 for (frame = 0; frame != work->effect->count * 8 + 108; frame++) {
200 struct BattleCamera *camera = WORK_SLOT(HEAP_SLOT_CAMERA);
201
202 // The battle plays its messages from frame 80, as the first target's
203 // picture appears.
204 if (frame == 80)
206
207 // The Djinni, facing the other way from the flares, sways 20 pixels from
208 // side to side over 32 frames and, after frame 32, rises 2 pixels a frame.
209 // For the first 4 frames it is also added on top, a flash as it appears.
210 if (work->effect->prelude == 1) {
211 s32 x =
212 ((Trig_Sin(frame << 11) * 20) >> 16) + originX + canvasShiftX - 20;
213 s32 y = ((Trig_Cos(frame << 11) * 4) >> 16) + originY - 24;
214
217 draw[0] = gWorkSlot[HEAP_SLOT_BLITTER];
221 if (frame > 32)
222 y = y - frame * 2 + 64;
223 draw[0](canvas, work->sheet + STAT_BOOST_DJINNI, x, y, 40, 40);
224 if (frame <= 3)
225 draw[1](canvas, work->sheet + STAT_BOOST_DJINNI, x, y, 40, 40);
227 }
228
229 // Each target's own timeline, starting 8 frames after the one before.
230 EFFECT_FOR_EACH_TARGET(member, work->effect) {
231 struct MotionObject *object =
233 s32 height =
234 BattleUnit_GetEffectHeightFar(work->effect->actors[member]) * 2 / 3;
235
236 if (frame == member * 8 + 80)
239 // Centre on two thirds of the target's height.
240 SET_VECTOR(point, object->x, height, object->z);
242 if (frame == member * 8 + 48)
244 SPRITE_COLOR_WHITE, -1, member, 16);
245
246 // Turn the flares and move them 2 pixels a frame towards the centre;
247 // flare i appears i frames after the target's turn starts. Mode 0
248 // turns them by pitch, mode 1 not at all, mode 2 by yaw, the others
249 // by yaw and roll.
250 if (frame > member * 8) {
252 draw[0] = gWorkSlot[HEAP_SLOT_BLITTER];
256 if (mode == 0) {
257 SceneTransform_ApplyPitch(-frame << 10);
258 } else if (mode == 1) {
259 } else if (mode == 2) {
260 SceneTransform_ApplyYaw(frame << 10);
261 } else {
262 SceneTransform_ApplyYaw(frame << 10);
263 SceneTransform_ApplyRoll(frame << 10);
264 }
265 for (i = 0; i != STAT_BOOST_DRAWN; i++) {
266 struct EffectStep *flare = &PARTICLES[member * STAT_BOOST_SLOTS + i];
267
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);
272 s32 distance = Iwram_Sqrt(xx + yy + zz) >> 9;
273
274 if (distance != 0) {
275 s32 size;
276
277 // The size (half the width) runs 6 to 1 over depths 314 to 634.
278 EffectPosition_ProjectPoint(flare, &screen);
279 screen.x = screen.x * 4 / 5 + canvasShiftX;
280 CLAMP(screen.depth, 314, 634);
281 size = 6 - (screen.depth - 314) / 64;
282 EFFECT_DRAW_FLARE(draw[1], canvas, work->sheet, screen.x,
283 screen.y, size);
284 flare->x -= flare->x / distance;
285 flare->y -= flare->y / distance;
286 flare->z -= flare->z / distance;
287 }
288 }
289 }
291 }
292
293 // The burst and the picture are drawn at the centre's screen position.
294 SET_VECTOR(center, 0, 0, 0);
295 EffectPosition_ProjectPoint(center, &screen);
296 screen.x = screen.x * 4 / 5 + canvasShiftX;
297
298 // The burst: six frames of 4 frames each, from frame 52.
299 if (frame >= member * 8 + 52 && frame < member * 8 + 76) {
300 s32 cell = (frame - member * 8 - 52) / 4 % 6;
301
303 draw[0] = gWorkSlot[HEAP_SLOT_BLITTER];
304 draw[0](canvas, work->sheet + cell * (40 * 40) + STAT_BOOST_BURST,
305 screen.x - 20, screen.y - 20, 40, 40);
307 }
308
309 // The mode's picture, from frame 80.
310 if (mode == 0) {
311 // Seven 24x40 frames, 4 frames each.
312 if (frame >= member * 8 + 80 && frame < member * 8 + 108) {
313 s32 cell = (frame - member * 8 - 80) / 4 % 7;
314
316 draw[0] = gWorkSlot[HEAP_SLOT_BLITTER];
317 draw[0](canvas, work->sheet + cell * (24 * 40) + STAT_BOOST_PICTURE,
318 screen.x - 12, screen.y - 20, 24, 40);
320 }
321 } else if (mode == 3 || mode == 5) {
322 // Six 32x64 frames, 4 frames each.
323 if (frame >= member * 8 + 80 && frame < member * 8 + 104) {
324 s32 cell = (frame - member * 8 - 80) / 4 % 6;
325
327 draw[0] = gWorkSlot[HEAP_SLOT_BLITTER];
328 draw[0](canvas, work->sheet + cell * (32 * 64) + STAT_BOOST_PICTURE,
329 screen.x - 16, screen.y - 32, 32, 64);
331 }
332 } else if (mode == 4) {
333 // 64x32 frames, 2 frames each, mirrored below into 64x64.
334 if (frame >= member * 8 + 80 && frame < member * 8 + 104) {
335 s32 cell = (frame - member * 8 - 80) / 2 % 6;
336
338 draw[0] = gWorkSlot[HEAP_SLOT_BLITTER];
340 drawFlags | COMPOSITE_FLIP_Y, COMPOSITE_MAX);
342 draw[0](canvas, work->sheet + cell * (64 * 32) + STAT_BOOST_PICTURE,
343 screen.x - 32, screen.y - 24, 64, 32);
344 draw[1](canvas, work->sheet + cell * (64 * 32) + STAT_BOOST_PICTURE,
345 screen.x - 32, screen.y + 8, 64, 32);
347 }
348 } else {
349 // Six 40x40 frames, 4 frames each, added.
350 if (frame >= member * 8 + 80 && frame < member * 8 + 104) {
351 s32 cell = (frame - member * 8 - 80) / 4 % 6;
352
354 draw[0] = gWorkSlot[HEAP_SLOT_BLITTER];
355 draw[0](canvas, work->sheet + cell * (40 * 40) + STAT_BOOST_PICTURE,
356 screen.x - 20, screen.y - 20, 40, 40);
358 }
359 }
360 }
361 EFFECT_END_FRAME(work);
362 }
363
366}
367
368// Stat-reduction shards, flame arcs, rock pillars and erupting particles.
369// The folder README describes them under "Effect families".
370
371/// Breaks the dagger picture into shards that fade through darker copies.
372///
373/// Abilities: Dull, Blunt (kind 27).
375 BattleFx_RunStatReduction(effect, 0);
376}
377/// A shield appears over each target and breaks into shards that fade through
378/// darker copies, in the glow orb's colours (style 1).
379///
380/// Abilities: Impair, Debilitate (kind 29); kind 47 is used by no ability.
381/// Casting impact 21 (Meltdown) also ends by calling it.
383 BattleFx_RunStatReduction(effect, 1);
384}
385/// A shield appears over each target and breaks into fading shards, in the pink
386/// burst's colours (style 2).
387///
388/// Abilities: Weaken, Enfeeble (kind 31).
390 BattleFx_RunStatReduction(effect, 2);
391}
392/// Breaks the shield picture into fading shards with style 3, which plays as
393/// style 2 does. No effect table entry reaches it.
394UNUSED void
396 BattleFx_RunStatReduction(effect, 3);
397}
398// The shard picture in the sheet, followed by seven copies of it, each
399// with its colour levels capped 7 lower than the one before.
400#define STAT_REDUCTION_SHARD_CELLS 0x2580
401#define STAT_REDUCTION_SHARD_BYTES 696 ///< bytes in each copy
402#define STAT_REDUCTION_SHARDS 24 ///< shards drawn for each target
403#define STAT_REDUCTION_SLOTS 32 ///< particles reserved for each target
404
405/// Stat cuts: a dagger (mode 0) or a shield (other modes) appears over each
406/// target, 4 frames apart, and then breaks into 24 shards that fly off and
407/// fade out through the darker copies. In each target's own frames the
408/// picture plays until about frame 24, then breaks with a sound; the shards
409/// darken from frame 29 and are gone after frame 60.
410///
411/// Reached through Dull, Impair, Weaken and the unused mode 3 wrapper above.
412/// Copies the mode's palette over the first 128 bytes of BG palette RAM,
413/// writes REG_BG2PA and REG_BG2X, and ends with the transfer callback
414/// removed, both blitters freed and the canvas layer closed.
415///
416/// effect: the targets.
417/// mode: 0 the dagger and the pink burst palette, 1 the shield and the
418/// glow orb palette, 2 and 3 the shield and the pink burst palette.
420 void **cursor;
421 struct BattleEffectWork *work;
422 void *canvas;
423 s32 frame;
424 s32 j;
425 s32 xOffset;
426 DrawRectangle *draw;
427 struct BattleCamera *camera;
428 s32 origin[3];
429 struct EffectPosition screen;
430 s32 point[3];
431 BlitterPair blitters;
432 s32 i;
433 s32 paletteId;
434
435 cursor = gBattleFxWork;
436 EFFECT_GET_WORK_AND_CANVAS(cursor, work, canvas);
437 work->effect = effect;
439 if (mode == 0)
441 else
443 if (mode == 0)
444 paletteId = (s32)&ResourceId_PinkBurstSheet;
445 else if (mode == 1)
446 paletteId = (s32)&ResourceId_GlowOrbSheet;
447 else
448 paletteId = (s32)&ResourceId_PinkBurstSheet;
449 Iwram_CopyWords((void *)BG_PLTT, Resource_GetTableEntry(paletteId), 128);
451 work->sheet + STAT_REDUCTION_SHARD_CELLS, 0, 0);
452
453 // Build the seven darker copies of the shard picture.
454 for (i = 1; i != 8; i++) {
455 for (j = 0; j != STAT_REDUCTION_SHARD_BYTES; j++) {
456 s32 level = work->sheet[STAT_REDUCTION_SHARD_CELLS + j];
457
458 EFFECT_CAP_LEVEL(level, 64 - i * 7);
460 j] = level;
461 }
462 }
463
464 // On side 1 the canvas moves 112 pixels right, so everything is drawn
465 // 112 pixels further left on it.
466 if (work->effect->side == 1) {
467 REG_BG2X = -0x7000;
468 xOffset = -112;
469 } else {
470 REG_BG2X = 0;
471 xOffset = 0;
472 }
473
474 // The shards start in a grid of eight rows and four columns and fly
475 // away from the user's side, scattering in a random direction; variant
476 // is a random start in their turning. All 512 are placed, enough for 16
477 // targets of 32 slots.
478 for (i = 0; i != 512; i++) {
479 struct EffectStep *shard = &PARTICLES[i];
480 s32 radius = 192;
481 s32 angle;
482
483 angle = Random16() & 0xffff;
484 shard->x = 0;
485 if (mode == 0) {
486 shard->y = ((i & 31) / 4 * 6 - 10) << 16;
487 shard->z = (i % 4 * 2 - 2) << 16;
488 } else {
489 shard->y = ((i & 31) / 4 * 6 - 10) << 16;
490 shard->z = (i % 4 * 8 - 16) << 16;
491 }
492 if (work->effect->side == 1)
493 shard->velocityX = 0x20000;
494 else
495 shard->velocityX = -0x20000;
496 shard->velocityY = ((Trig_Cos(angle) * radius) >> 6) + 0x10000;
497 shard->velocityZ = (Trig_Sin(angle) * radius) >> 6;
498 shard->variant = Random16() & 0xff;
499 }
500
501 BattleFx_FetchRectangleBlitters(work->effect->side, draw = blitters);
503
504 for (frame = 0; frame != work->effect->count * 4 + 64; frame++) {
505 camera = gCameraWork;
506 // XXX: the loop runs count * 4 + 64 frames, so frame 72 comes only with
507 // three or more targets; whether the battle shows the damage some other
508 // way for one or two would settle whether this is a bug.
509 if (frame == 72)
512 struct MotionObject *object;
513 s32 targetFrame;
514 s32 x;
515 s32 y;
516
517 targetFrame = frame - j * 4;
518 object = GetBattleObjectSlotFar(work->effect->actors[j])->object;
519 // Each target's timeline starts 4 frames after the one before.
520 if (targetFrame > 0) {
522 // Centre on the point 20 pixels above the target; the view is set
523 // from the camera twice.
524 SET_VECTOR(point, object->x, 160 << 13, object->z);
527 SET_VECTOR(origin, 0, 0, 0);
528 EffectPosition_ProjectPoint(origin, &screen);
529 x = screen.x + xOffset;
530 y = screen.y;
531 if (mode == 0) {
532 if (targetFrame <= 26)
533 blitters[0](canvas, work->sheet + targetFrame / 4 % 7 * (24 * 40),
534 x - 12, y - 20, 24, 40);
535 } else {
536 if (targetFrame <= 23)
537 draw[1](canvas, work->sheet + targetFrame / 4 % 6 * (40 * 40),
538 x - 20, y - 20, 40, 40);
539 }
540 if (targetFrame == 24)
542 // From frame 24 the picture breaks; the shards darken one copy
543 // every 4 frames after frame 28.
544 if (targetFrame >= 24 && targetFrame <= 60) {
545 s32 level;
546
547 level = 0;
548 if (targetFrame > 28) {
549 level = (targetFrame - 24) / 4;
550 if (level > 7)
551 level = 7;
552 }
553 for (i = 0; i != STAT_REDUCTION_SHARDS; i++) {
554 struct EffectStep *shard = &PARTICLES[j * STAT_REDUCTION_SLOTS + i];
555 s32 cell;
556
557 // Shard i takes shape i % 4, turning through its three frames
558 // every 8 frames from a random start.
559 cell = i % 4 * 3 + (shard->variant + targetFrame) / 8 % 3;
560 EffectPosition_ProjectPoint(shard, &screen);
561 x = screen.x + xOffset;
562 y = screen.y;
563 blitters[0](canvas,
564 work->sheet +
571 }
572 }
573 }
574 }
576 }
577
579}
580
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
Definition animspr.h:26
void * gBattleFxWork[]
struct BattleCamera * gCameraWork
@ COMPOSITE_FLIP_X
@ COMPOSITE_FLIP_Y
@ COMPOSITE_ADDITIVE
@ COMPOSITE_MAX
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...
Definition canvas.c:103
void BattleFx_BeginCanvasLayer(s32 bgControl)
Opens the canvas layer: starts the background palette fade, makes BG2 the canvas, alpha-blended over ...
Definition canvas.c:314
void BattleFx_EndCanvasLayer(void)
Closes the canvas layer: plays the closing sound, restores BG1's scroll and the projection centre,...
Definition canvas.c:490
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.
Definition dispatch.c:254
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)
s32 Trig_Cos(s32 angle)
s32 Trig_Sin(s32 angle)
@ HEAP_SLOT_BLITTER_ALTERNATE
Definition heap_state.h:47
@ HEAP_SLOT_CAMERA
Definition heap_state.h:38
@ HEAP_SLOT_BLITTER
Definition heap_state.h:46
#define WORK_SLOT(n)
Reads slots through their own addresses; adjacent slots are reached by offsets.
Definition heap_state.h:14
#define Q_8_8(n)
The BG2/BG3 affine matrix entries are signed 8.8 fixed point: texels stepped per screen pixel.
Definition io_reg.h:59
#define REG_BG2X
Definition io_reg.h:65
#define BG_PLTT
Definition io_reg.h:157
#define REG_BG2PA
Definition io_reg.h:61
static s32 Iwram_CopyWords(volatile void *destination, const volatile void *source, s32 size)
Definition iwram_call.h:85
static s32 Iwram_Sqrt(s32 value)
Definition iwram_call.h:63
#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.
Definition macros.h:16
#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,...
Definition macros.h:12
#define CLAMP(v, low, high)
Keeps v within low to high, the low bound tested first.
Definition macros.h:23
u32 Random16(void)
Advances the game's random number generator (the C library's classic linear congruential one),...
Definition math.c:10
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.
Definition positions.c:88
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...
Definition positions.c:29
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...
Definition positions.c:64
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...
Definition projectiles.c:29
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...
Definition scheduler.c:102
s32 Scheduler_RemoveCallback(SchedulerCallback callback)
Unschedules the task running callback: clears its routine and gives it order 0x7fff,...
Definition scheduler.c:146
#define SE_143
Definition songs.h:136
#define SE_142
Definition songs.h:135
#define SE_212
Definition songs.h:207
void * gWorkSlot[]
#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.
Definition stat_change.c:30
StatBoostSheet
Where each picture sits in the sheet.
Definition stat_change.c:46
@ STAT_BOOST_PICTURE
the picture the mode picks
Definition stat_change.c:49
@ STAT_BOOST_FLARES
flares (ParticleSpritesD)
Definition stat_change.c:47
@ STAT_BOOST_BURST
six 40x40 bursts of light (GlowOrb)
Definition stat_change.c:48
@ STAT_BOOST_DJINNI
the 40x40 djinni
Definition stat_change.c:50
#define STAT_REDUCTION_SHARD_CELLS
#define STAT_BOOST_SCATTERED
flares scattered at the start
Definition stat_change.c:53
#define STAT_BOOST_DRAWN
flares drawn for each target
Definition stat_change.c:54
void BattleFx_RunWard(struct BattleEffectArgument *effect)
Gathers stat-boost light and displays a shield in Jupiter colours.
Definition stat_change.c:24
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.
Definition stat_change.c:42
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.
Definition stat_change.c:36
void BattleFx_RunGuard(struct BattleEffectArgument *effect)
Gathers stat-boost light and displays a shield in Mars colours.
Definition stat_change.c:17
#define STAT_BOOST_SLOTS
particles reserved for each target
Definition stat_change.c:55
void BattleFx_RunImpact(struct BattleEffectArgument *effect)
Gathers stat-boost light and displays a dagger in Mars colours.
Definition stat_change.c:11
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,...
Definition stat_change.c:76
#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.
Definition effect_step.h:46
s32 y
screen pixels
Definition effect_step.h:59
s32 depth
projected depth, larger further away
Definition effect_step.h:60
s32 x
screen pixels
Definition effect_step.h:58
A moving point of an effect: its position, its velocity and a value each effect uses its own way (a s...
Definition effect_step.h:13
s32 velocityX
16.16 fixed-point pixels per frame
Definition effect_step.h:28
s32 z
16.16 fixed-point pixels
Definition effect_step.h:26
s32 variant
each effect's own: a size, a countdown, -1 for idle
Definition effect_step.h:31
s32 x
16.16 fixed-point pixels
Definition effect_step.h:24
s32 y
16.16 fixed-point pixels
Definition effect_step.h:25
s32 velocityY
16.16 fixed-point pixels per frame
Definition effect_step.h:29
s32 velocityZ
16.16 fixed-point pixels per frame
Definition effect_step.h:30
An effect object that moves and draws one sprite: its position, scale, velocity and target,...
Definition motobj.h:20
s32 z
16.16 fixed-point pixels
Definition motobj.h:25
s32 y
16.16 fixed-point pixels
Definition motobj.h:24
u16 height
half the sprite's box height; FieldActor's radius
Definition motobj.h:29
s32 x
16.16 fixed-point pixels
Definition motobj.h:23
void * Resource_GetTableEntry(s32 index)
Returns the ROM address of resource index from the resource directory.
Definition system.c:150
void SceneTransform_ApplyYaw(s32 angle)
Rotates gTransform about the Y axis by angle.
Definition transform.c:113
void SceneTransform_ApplyPitch(s32 angle)
Rotates gTransform about the X axis by angle.
Definition transform.c:97
void SceneTransform_ApplyPosition(const s32 *position)
Translates gTransform by position (x, y, z in 16.16).
Definition transform.c:145
void SceneTransform_ApplyRoll(s32 angle)
Rotates gTransform about the Z axis by angle.
Definition transform.c:129
signed int s32
Definition types.h:14
unsigned int u32
Definition types.h:15
#define UNUSED
Definition types.h:22
#define EFFECT_CLIP_BOUNDS
Clips overflow on all four sides.
Definition effect.h:224
#define PARTICLES
The map cell buffer (gMapCellBuffer), which the effects borrow, has two views here: Ram_MapCellBuffer...
Definition effect.h:221
DrawRectangle BlitterPair[2]
A blitter pair: [0] built in HEAP_SLOT_BLITTER and [1] in HEAP_SLOT_BLITTER_ALTERNATE (BattleFx_Fetch...
Definition effect.h:244