99 }
else if (kind == 3) {
134 scrollX = 96 - anchor.
x;
136 scrollX = 32 - anchor.
x;
150 for (i = 0; i != 64; i++) {
164 for (frame = 0; frame != 32; frame++) {
181 screenPosition.
y += 16;
185 draw[1](canvas, work->sheet + (5 - frame / 2) * (48 * 16),
186 screenPosition.
x + scrollX - 48, screenPosition.
y - 8, 48,
189 draw[1](canvas, work->sheet + (5 - frame / 2) * (48 * 16),
190 screenPosition.
x + scrollX, screenPosition.
y - 8, 48, 16);
192 }
else if ((
u32)kind <= 2 || kind == 5) {
195 draw[1](canvas, work->sheet + frame / 2 * (48 * 72),
196 screenPosition.
x + scrollX - 48, screenPosition.
y - 40, 48,
199 draw[1](canvas, work->sheet + frame / 2 * (48 * 72),
200 screenPosition.
x + scrollX, screenPosition.
y - 40, 48, 72);
204 s32 cell = frame / 3;
221 if (frame >= 4 && frame <= 15)
223 anchor.
x - 16, anchor.
y - 24, 40, 48);
229 if (frame >= 4 && frame <= 31) {
230 for (i = 0; i != 64; i++) {
294 void *colors = (
void *)
BG_PLTT;
307 if (effect->
kind <= 199)
340 work->imageStorage, 1, 0);
366 for (i = 0; i != 64; i++) {
377 strength =
object->verticalMotionStrength;
378 acceleration =
object->acceleration;
380 object->acceleration = 0;
381 object->verticalMotionStrength = 0;
383 scrollX = 64 - screenPosition.
x;
391 for (frame = 0; frame != 32; frame++) {
394 for (i = 0; i != 64; i++) {
397 if (mote->
x >= 0 && frame >= i / 4) {
398 s32 size = (i & 1) + 5;
406 point.
y = point.
y + screenPosition.
y + 24;
418 object->acceleration = acceleration;
419 object->verticalMotionStrength = strength;
432 scrollX = 32 - anchor.
x;
434 scrollX = 96 - anchor.
x;
444 for (i = 0; i != 64; i++) {
455 for (frame = 0; frame != 32; frame++) {
461 screenPosition.
y += 16;
465 draw[0](canvas, work->imageStorage, 0, 0, 120, 120);
467 draw[0](canvas, work->imageStorage + (120 * 120), 0, 0, 120, 120);
475 if (frame >= 4 && frame <= 31) {
476 for (i = 0; i != 64; i++) {
BattleEffectDrawRectangle DrawRectangle
struct BattleWork * gBattleWork
void BattleFx_RunRingAndSparkScene(struct BattleEffectArgument *effect)
Plays the selected ring-and-spark strike, restoring the user motion after it.
void BattleFx_RunBeamSequence(struct BattleEffectArgument *effect)
Draws the selected beam and its projected sparks over the first target: a beam, arc or wave shoots fr...
void Palette_StepFadeTransfer(void)
Darkens the battle backdrop while the canvas is open: for fadeFrames frames, writes the backdrop's co...
void BattleFx_SetupCanvasTileMap(void)
Shows the canvas on BG1 instead of BG2, at its own size: BG1 becomes a 256-colour layer whose map poi...
void BattleFx_ProcessPendingGraphicsTransfer(void)
Copies the canvas to VRAM once the effect has finished drawing a frame (transferPending): the 128x128...
void BattleFx_HideBg1AndRestoreBackdrop(void)
Hides BG1 and the windows and starts bringing the backdrop's palette back.
void BattleFx_ConfigureEffectDisplay(void)
Puts the battle screen back into the display state every effect starts from and ends with: no blendin...
void Resource_LoadAndDecompress(s32 id, void *dst, s32 skipPalette, s32 copyPalette)
Decompresses a resource whose first 128 bytes may be a palette.
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,...
#define EFFECT_SET_TRANSFER(work, mode, value)
Sets how the canvas transfer treats what is left in the canvas after each copy: mode with value (see ...
@ 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 CANVAS_BYTES
The canvas: 128x128 pixels, one byte each, in its heap slot and in VRAM at BG_CHAR_BLOCK(1).
#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_PLAYBACK_ORDER
The order where the battle's own playback runs, which the palette fade and the element streaks take.
#define EFFECT_VIEW_FROM_CAMERA(camera)
Starts a frame's 3D projection from the battle camera: resets the transform, then looks from camera->...
static s32 * EffectPosition_Coordinates(struct EffectPosition *position)
Returns the position's three coordinates as an array.
struct BattleObj * GetBattleObjectSlotFar(s32 objectId)
Far call to BattleObjGet.
s32 Summon_IsEntrySecondaryFlaggedFar(s32 index)
s32 BattleUnit_GetEffectHeightFar(s32 id)
void BattleMotion_ApplyVariantMotionFar(s32 id, s32 variant)
void BattlePres_SetupTransitionAtPairMidpointFar(s32 a, s32 b, s32 zoom)
void BattlePresentation_SetPaletteLevelFar(s32 unused, s32 level)
void ObjectDispatch_SetAnimationSpeedFar(struct DispatchObject *obj, s32 val)
struct BattleUnit * UnitGetFar(u32 owner)
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 BGCNT_CHAR_BASE(block)
#define BGCNT_PRIORITY(n)
#define BGCNT_SCREEN_BASE(block)
static s32 Iwram_CopyWords(volatile void *destination, const volatile void *source, s32 size)
static s32 Iwram_ClearWords(void *destination, s32 size)
#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),...
void EffectPosition_ProjectScaledBattler(s32 id, struct EffectPosition *position)
The screen position of a battler, scaled for the battle view, 16 pixels higher.
void EffectPosition_ProjectSprite(s32 id, struct EffectPosition *position)
The screen position of a battler's sprite, at its scaled height, 16 pixels higher.
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...
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_MarsDjinnSmallSheet
char ResourceId_CrescentSheet
char ResourceId_BlueArcSheetB
char ResourceId_YellowOrbSheet
char ResourceId_BlueArcSheetA
char ResourceId_BeamSequenceImage
char ResourceId_ParticleSpritesD
char ResourceId_WaveSheet
char ResourceId_StarBurstSheet
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
s32 kind
handler table index; 200 more for a critical hit
s16 actors[8]
the targets' unit ids, count of them
s32 firstTarget
the action's first target, standing or not
The running battle effect's work: its canvas image, 64 particles, the display registers it stages and...
s32 fadeFrames
backdrop fade frames left (Palette_StepFadeTransfer)
s32 fadeStep
CANVAS_FADE_STEPs the backdrop has darkened so far.
struct BattleEffectArgument * effect
the command being run
struct EffectStep particles[64]
free while variant is -1
struct MotionObject * object
NULL once released.
A unit in battle: a party member's or an enemy's stats, Psynergy, items, Djinn and ailments.
u8 classId
Who the unit is: a character's id (ISAAC to JENNA, below 8) or an enemy's id (BattleUnitSet).
u16 background
the battle background's id
A field object as the object dispatcher's far calls take it.
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 variant
each effect's own: a size, a countdown, -1 for idle
s32 x
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...