28 s32 i, x, y, row, end, speed;
31 u8 *delays, *p, *pixel;
40 *palette++ =
RGB(half, half, i);
53 }
while (p != delays + 256);
66 ((y & 7) << 3) + ((y / 8) << 11));
72 green = (color >> 5) & 31;
73 blue = (color >> 10) & 31;
98 *palette++ =
RGB(half, half, i);
105 }
while (i != 0x7800);
174 work->sheet + 0x1000);
181 shift = 64 - anchor.
x;
185 for (frame = 0; frame != work->
effect->
count * 20 + 72; frame++) {
199 x = ((
Trig_Sin(frame << 11) * 20) >> 16) + originX + shift - 20;
200 y = (((
Trig_Cos(frame << 11) * 4)) >> 16) + originY - 24;
203 y =
y - frame * 2 + 64;
204 draw[0](canvas, work->sheet + 0x2000,
x,
y, 40, 40);
206 draw[1](canvas, work->sheet + 0x2000,
x,
y, 40, 40);
216 if (frame > 16 && (frame & 15) == 0)
220 for (member = 0; member != 1; member++) {
221 tick = frame - member * 8;
223 if (tick >= 0 && tick < 96) {
225 position.world.x =
object->x;
226 position.world.y =
object->y;
227 position.world.z =
object->z;
231 screen.
x = anchor.
x + shift;
239 for (j = 0; j != 3; j++) {
240 point = &work->
particles[member * 32 + j];
243 scale.
x = 0x2a000 - (tick * 3 << 9);
244 scale.
y = 0x2a000 - (tick * 3 << 9);
245 scale.
z = 0x2a000 - (tick * 3 << 9);
252 point->
velocityX = position.projected.x + screen.
x;
253 point->
velocityY = position.projected.y + screen.
y + 16;
255 for (j = 0; j != 3; j++) {
260 size = 5 - tick / 16;
261 for (k = 0; k != 24; k++) {
269 x - size,
y - size, size * 2, size * 2);
275 draw[0](canvas, work->sheet, screen.
x - 24, screen.
y - 24, 24, 48);
276 draw[1](canvas, work->sheet, screen.
x, screen.
y - 24, 24, 48);
344 shift = 64 - anchor.
x;
348 for (frame = 0; frame != work->
effect->
count * 20 + 72; frame++) {
361 if (frame > 16 && (frame & 15) == 0)
365 for (member = 0; member != 1; member++) {
366 tick = frame - member * 8;
368 if (tick >= 0 && tick < 96) {
370 position.world.x =
object->x;
371 position.world.y =
object->y;
372 position.world.z =
object->z;
374 screen.
x = anchor.
x + shift;
377 for (j = 0; j != 3; j++) {
378 point = &work->
particles[member * 32 + j];
381 scale.
x = 0x2a000 - (tick * 3 << 9);
382 scale.
y = 0x2a000 - (tick * 3 << 9);
383 scale.
z = 0x2a000 - (tick * 3 << 9);
390 &position.projected);
391 point->
velocityX = position.projected.x + screen.
x;
392 point->
velocityY = position.projected.y + screen.
y + 16;
394 for (j = 0; j != 3; j++) {
398 size = 5 - tick / 16;
399 for (k = 0; k != 24; k++) {
407 x - size,
y - size, size * 2, size * 2);
413 draw[0](canvas, work->sheet, screen.
x - 24, screen.
y - 24, 24, 48);
414 draw[1](canvas, work->sheet, screen.
x, screen.
y - 24, 24, 48);
BattleEffectDrawRectangle DrawRectangle
void BattleFx_RunBind(struct BattleEffectArgument *effect)
A triangle of light spins and shrinks onto the first target for 64 frames, then a rune stands on the ...
void BattleFx_RunTriangleStrike(struct BattleEffectArgument *effect)
The spinning triangle and rune of BattleFx_RunBind without the Djinni; on frame 46 the user steps up ...
UNUSED void Graphics_ConvertBackgroundToBlueRamp(void)
Turns the screen into shades of blue, top down, with a ragged edge.
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,...
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 BLUE_RAMP_PIXELS
The full-screen picture Graphics_ConvertBackgroundToBlueRamp (bind.c) works on, which Condemn draws t...
@ CANVAS_COPY_AND_DARKEN
copy, then darken the canvas by transferValue
#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_SLOT(slots, slot)
A work slot read through a pointer to the effect's own slot, gWorkSlot[HEAP_SLOT_BATTLE_EFFECT].
#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_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 Vector3 gBind_Vertex[]
The spinning triangle's first vertex, 24 up from its centre.
u16 gBattleFx_FlareCells[]
Flare cells: the first ten are squares 2x2 to 20x20, cell n (from 0) n + 1 pixels from its centre to ...
struct Vector3 gBind_TriangleStrikeVertex[]
The striking triangle's first vertex, the same.
struct BattleObj * GetBattleObjectSlotFar(s32 objectId)
Far call to BattleObjGet.
void BattleMotion_ApproachTargetFar(s32 actorId, s32 targetId, s32 travel_divisor, s32 initial_velocity_y)
void AudioCommand_PlayFar(s32 id)
void WaitFrames(s32 frames)
The game's frame loop: runs frames frames and returns.
@ HEAP_SLOT_BATTLE_EFFECT
@ HEAP_SLOT_BLITTER_ALTERNATE
#define WORK_SLOT(n)
Reads slots through their own addresses; adjacent slots are reached by offsets.
#define Q_8_8(n)
The BG2/BG3 affine matrix entries are signed 8.8 fixed point: texels stepped per screen pixel.
#define RGB(r, g, b)
A 15-bit colour from its red, green and blue levels (0 to 31 each), as the palette stores it: blue in...
#define BG_PLTT_COLOR(palette, color)
static s32 Iwram_CopyWords(volatile void *destination, const volatile void *source, s32 size)
u32 Random16(void)
Advances the game's random number generator (the C library's classic linear congruential one),...
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.
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 ...
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...
char ResourceId_ParticleSpritesD
char ResourceId_ParticleSpritesA
char ResourceId_JupiterDjinnSheet
char ResourceId_RuneSheet
s32 Resource_DecodeType01(const void *source, void *destination)
Decodes a type-01 resource and returns its unpacked byte count.
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
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 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 velocityX
16.16 fixed-point pixels per frame
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,...
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.
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.