36#define PLANET_DIVER_IMPACT_CHIPS ((struct ImpactChip *)Ram_MapCellBuffer)
38#define PLANET_DIVER_FRAMES 88
39#define PLANET_DIVER_CLEARED_CHIPS 1024
40#define PLANET_DIVER_CHIPS 256
104 if (frame > 17 || frame == 0) {
106 screenPosition.
x /= 2;
111 if (frame >= 2 && frame <= 3)
112 draw[0](canvas, work->sheet, screenPosition.
x - 16, screenPosition.
y - 64,
114 if (frame >= 4 && frame <= 15) {
115 for (i = 0; i != 16; i++) {
116 s32 x = screenPosition.
x + (frame *
Trig_Sin(i << 12) >> 16);
117 s32 y = screenPosition.
y + (frame *
Trig_Cos(i << 12) >> 16) - frame;
119 draw[0](canvas, work->sheet + ((frame - 4) / 2 << 11), x - 16, y - 64,
148 actor->
z = target->
z;
164 draw[0](canvas, work->sheet, screenPosition.
x - 20,
165 screenPosition.
y - 52, 40, 64);
166 screenPosition.
x -= 8;
168 draw[1](canvas, work->sheet, screenPosition.
x - 26,
169 screenPosition.
y - 52, 40, 64);
170 screenPosition.
y += 8;
185 chip->
x = screenPosition.
x << 16;
186 chip->
y = (screenPosition.
y - 24) << 16;
206 if (chip->
life > 0) {
213 if (chip->
y > 112 << 16) {
215 }
else if ((chip->
x >= 0 && chip->
x < 127 << 16) && chip->
y >= 0) {
219 (chip->
y >> 16), size);
232#define HAUNT_SCATTERED 512
233#define HAUNT_SKULLS 8
234#define HAUNT_SLOTS 64
292 for (frame = 0; frame != work->
effect->
count * 32 + 96; frame++) {
304 row = work->bg2xLines;
306 for (i = 0; i != 160; i++)
307 *row++ = (0x60000 -
Trig_Sin((frame + i) << 11) * 6) >> 10;
309 for (i = 0; i != 160; i++)
310 *row++ =
Trig_Sin((frame + i) << 11) * 6 >> 10;
323 if (frame > k * 32) {
325 if (frame == k * 32 + 32)
336 if (frame > (k * 8 + i) * 4) {
337 s32 x = (skull->
x >> 8) * (skull->
x >> 8);
338 s32 y = (skull->
y >> 8) * (skull->
y >> 8);
339 s32 z = (skull->
z >> 8) * (skull->
z >> 8);
344 screenPosition.
x >>= 1;
345 draw[0](canvas, work->sheet + i % 3 * (24 * 24),
346 screenPosition.
x - 12, screenPosition.
y - 12, 24, 24);
347 skull->
x -= skull->
x / dist;
348 skull->
y -= skull->
y / dist;
349 skull->
z -= skull->
z / dist;
366#define ORBITING_SPIRALS_LIFE 60
416 for (frame = 0; frame != (work->
effect->
count * 16) + 48; frame++) {
425 row = work->bg2xLines;
430 for (i = 0, base = 0x80000, angle = frame << 10; i != 160; i++) {
431 *row++ = (base - ((
Trig_Sin(angle) * 8))) >> 10;
437 for (i = 0, angle = frame << 10; i != 160; i++) {
438 *row++ = (((
Trig_Sin(angle) * 8)) >> 10) - 0x7000;
451 if (frame > member * 16 &&
455 if (frame == (member * 16) + 32) {
464 for (i = 0; i != 4; i++) {
469 spin = (frame << 9) + (i << 14);
470 x = (screen.
x + (((
Trig_Sin(spin) * 16)) >> 16)) + offsetX;
471 y = screen.
y + (((
Trig_Cos(spin) * 16)) >> 16);
473 draw[half & 1](canvas,
474 work->sheet + (((frame / 4) - (half * 4)) << 10),
475 x - 16,
y - 16, 32, 32);
490#undef PLANET_DIVER_IMPACT_CHIPS
491#undef PLANET_DIVER_FRAMES
492#undef PLANET_DIVER_CLEARED_CHIPS
493#undef PLANET_DIVER_CHIPS
494#undef HAUNT_SCATTERED
497#undef ORBITING_SPIRALS_LIFE
@ SPRITE_COLOR_WHITE
solid colour 15, white
@ POSE_DAMAGE
taking damage
struct BattleCamera * gCameraWork
#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 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_DRAW_MOTE(draw, canvas, sheet, x, y, size)
Particle sheets hold ten mote cells, 1x2 to 10x20 pixels.
#define EFFECT_PRESENT_FRAME(work)
Ends a frame of a canvas effect: marks the canvas ready for the transfer callback,...
@ CANVAS_COPY_AND_DARKEN
copy, then darken the canvas by transferValue
@ 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_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_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...
struct BattleObj * GetBattleObjectSlotFar(s32 objectId)
Far call to BattleObjGet.
void BattleMotion_ApplyVariantMotionFar(s32 id, s32 variant)
void ObjectDispatch_SelectAnimationFar(void *raw, s32 no)
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_BLITTER_ALTERNATE
static s32 Iwram_CopyWords(volatile void *destination, const volatile void *source, s32 size)
static s32 Iwram_Sqrt(s32 value)
#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),...
#define PLANET_DIVER_IMPACT_CHIPS
Ram_MapCellBuffer seen as Planet Diver's chips.
void BattleFx_RunHaunt(struct BattleEffectArgument *effect)
Skulls close in on each target in turn.
#define PLANET_DIVER_CLEARED_CHIPS
map-buffer chip slots cleared first
#define HAUNT_SCATTERED
skull slots scattered at the start
#define HAUNT_SKULLS
skulls drawn around each target
#define PLANET_DIVER_CHIPS
chips the fireball bursts into
#define HAUNT_SLOTS
particles reserved for each target
#define ORBITING_SPIRALS_LIFE
frames each target's spirals turn
void BattleFx_RunOrbitingSpirals(struct BattleEffectArgument *effect)
Four spirals circle 40 pixels above each target in turn, 16 frames apart, for 60 frames each,...
#define PLANET_DIVER_FRAMES
void BattleFx_RunPlanetDiver(struct BattleEffectArgument *effect)
The user flashes and leaps into the air, turns into a ball of fire, falls onto the first target and b...
void EffectPosition_ProjectBattler(s32 id, struct EffectPosition *position)
The screen position of a battler, 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_SkullSheet
char ResourceId_SpiralSheet
char ResourceId_ParticleSpritesA
char ResourceId_FlashBurstSheet
char ResourceId_FlameballSheet
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 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
struct BattleEffectArgument * effect
the command being run
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 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
One chip of the impact, laid over the same 28-byte records as PARTICLES but with its velocities in ot...
s32 x
canvas position, 16.16 fixed point
s32 velocityX
16.16 pixels a frame, damped to 56/64 each frame
s32 velocityY
16.16 pixels a frame, with 1/8 pixel of gravity
s32 y
canvas position, 16.16; the ground is y 112
s32 unused14
an EffectStep's velocityZ; never read
s32 life
frames left; 0 is free
s32 unused0c
an EffectStep's velocityX; never read
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 velocityX
16.16 fixed-point pixels per frame
s32 z
16.16 fixed-point pixels
u8 snapToTarget
nonzero: lands exactly on the target, else brakes in
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,...
s32 z
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.
#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...