7#define FROTH_MOTE_CELL 0xc00
8#define FROTH_FIRST_TARGET 32
16#define WHIRLWIND_TORNADO_CELLS 0xc56
17#define WHIRLWIND_SECTION_BYTES (40 * 32)
100 if (frame >= 17 && frame < 64)
112 if (frame > i * 2 && flags[i] == 0) {
114 screenPosition.
x >>= 1;
117 screenPosition.
y - 12, 12, 24);
127 if (frame > i * 2 + 48 && flags[i] == 0) {
132 if (frame < i * 2 + 85) {
142 point->
x = screenPosition.
x;
143 point->
y = screenPosition.
y + (
Random16() & 31) - 16;
156 draw[0](canvas, work->sheet + ((point->
variant / 2) % 3 << 10),
157 point->
x - 16, point->
y - 56, 16, 64);
158 draw[1](canvas, work->sheet + ((point->
variant / 2) % 3 << 10),
159 point->
x, point->
y - 56, 16, 64);
224 for (j = 0; j != 16; j++) {
236 for (frame = 0; frame != 80; frame++) {
237 wave = (
Trig_Sin(frame << 10) * 16);
241 for (i = 0; i != 7; i++) {
242 if (frame == i * 8 + 16)
262 Trig_Sin((frame << 11) + i * 0x4000) +
266 y = (
Trig_Cos((frame << 11) + i * 0x4000) * 2) >> 16;
267 segment = (frame / 2) % 3;
280 for (j = 0; j != 4; j++) {
285 cell = point->
variant / 2 + (j / 2) * 3;
287 point->
x +
x, point->
y +
y,
301 for (i = 0; i != 7; i++) {
302 if (frame == i * 8 + j * 3 + 16) {
321#undef FROTH_MOTE_CELL
322#undef FROTH_FIRST_TARGET
324#undef WHIRLWIND_TORNADO_CELLS
325#undef WHIRLWIND_SECTION_BYTES
@ 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 BattleFx_EndCanvasLayer(void)
Closes the canvas layer: plays the closing sound, restores BG1's scroll and the projection centre,...
void Camera_ApplyPhasedDelta(void)
Turns the battle camera by cameraDelta.
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.
@ 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 CANVAS_BYTES
The canvas: 128x128 pixels, one byte each, in its heap slot and in VRAM at BG_CHAR_BLOCK(1).
#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_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_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_GlintCellHeights[]
u8 gVortices_Shapes[][3]
Whirlwind, by variant: the WHIRLWIND_ columns.
u8 gVortices_Counts[][2]
Froth, by variant: motes and frames.
u16 gBattleFx_GlintCells[]
u8 gBattleFx_GlintCellWidths[]
@ FROTH_MOTE_COUNT
motes, at most FROTH_MOTES (vortices.c)
@ FROTH_FRAMES
the effect's frames; the damage shows 16 before
@ WHIRLWIND_SHAKE
Camera_ApplyShake's range.
@ WHIRLWIND_TORNADOES
tornadoes drawn
@ WHIRLWIND_SWAY
how far each sways across, in pixels
struct BattleObj * GetBattleObjectSlotFar(s32 objectId)
Far call to BattleObjGet.
s32 BattleUnit_GetEffectHeightFar(s32 id)
void BattleMotion_ApplyVariantMotionFar(s32 id, s32 variant)
void AudioCommand_PlayFar(s32 id)
void WaitFrames(s32 frames)
The game's frame loop: runs frames frames and returns.
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_BLITTER_ALTERNATE
@ HEAP_SLOT_BATTLE_CANVAS
#define WORK_SLOT(n)
Reads slots through their own addresses; adjacent slots are reached by offsets.
#define BLEND_ALPHA(top, bottom)
A REG_BLDALPHA value: top and bottom are the two targets' weights, out of 16.
static s32 Iwram_CopyWords(volatile void *destination, const volatile void *source, s32 size)
static s32 Iwram_FillWords(void *destination, s32 size, u32 value)
#define SET_VELOCITY(p, vx, vy, vz)
#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 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),...
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 Ram_MapCellBuffer
char ResourceId_TornadoSheet
char ResourceId_VortexSheet
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...
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 cameraDelta
camera yaw turned per effect frame
s32 shakeFrames
shake frames left; Camera_ApplyShake counts down
s32 cameraPhase
The effect sets 1 after a frame; Camera_ApplyPhasedDelta then turns the whole cameraDelta and sets 0,...
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.
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
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 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.
#define EFFECT_CLIP_BOUNDS
Clips overflow on all four sides.
DrawRectangle BlitterPair[2]
A blitter pair: [0] built in HEAP_SLOT_BLITTER and [1] in HEAP_SLOT_BLITTER_ALTERNATE (BattleFx_Fetch...
void BattleFx_RunWhirlwind(struct BattleEffectArgument *effect)
Tornadoes sweep across the targets for 80 frames, sparkling with glints; the canvas flashes and the t...
#define WHIRLWIND_TORNADO_CELLS
The tornado pictures follow the six glint cells (gBattleFx_GlintCells) in the sheet: 40x32 sections,...
#define FROTH_MOTE_CELL
the mote picture in the sheet
#define FROTH_FIRST_TARGET
the first target seat in work->particles
void BattleFx_RunFroth(struct BattleEffectArgument *effect)
Motes fly out of the top of the user, hang, and from 48 frames after each appears home in on the targ...
#define FROTH_MOTES
The motes set up in work->particles, before the target seats: no row of gVortices_Counts may ask for ...
#define WHIRLWIND_SECTION_BYTES