39 for (x = 0; x != 128; x++)
56 for (; x != front; x++) {
57 for (y = 0; y != 128; y++) {
58 wipePosition = x - delay[y];
59 if (wipePosition >= 0)
60 if (wipePosition <= 127)
61 canvas[(((y / 8) * 16 + wipePosition / 8) * 8 + (y & 7)) * 8 +
62 (wipePosition & 7)] = 1 - value;
66 }
while (front <= 256);
77 for (; y != front; y++) {
78 for (x = 0; x != 128; x++) {
79 wipePosition = y - delay[x];
80 if (wipePosition >= 0)
81 if (wipePosition <= 127)
82 canvas[(((wipePosition / 8) * 16 + x / 8) * 8 +
89 }
while (front <= 191);
144 nextCounter = *counter + 1;
146 *counter = nextCounter;
200#define CANVAS_FADE_STEP 1092
290 }
while (actorIndex != 8);
371 for (row = 0; row != 16; row++) {
444 for (row = 0; row != 16; row++) {
472 for (row = 0; row != 16; row++) {
474 for (column = 0; column != 8; column++, offset += 2) {
518 for (i = 0; i != 8; i++) {
576 void *canvas = cells[31];
597 for (row = 0; row != 16; row++) {
598 for (column = 0; column != 32; column++, byteOffset += 2) {
603 row * 16 + 0x100 + column;
659 step = (
ABS(x1 - x0) << 8) /
ABS(y1 - y0);
661 for (i = y0; i != y1; i++) {
662 offset = (((((
u32)i >> 3) << 4) + ((
u32)x >> 3)) << 3) + (i & 7);
663 offset = (offset << 3) + (x & 7);
664 if (canvas[offset] < color)
665 canvas[offset] = color;
687 step = (
ABS(y1 - y0) << 8) /
ABS(x1 - x0);
689 for (i = x0; i != x1; i++) {
690 offset = (((((
u32)y >> 3) << 4) + ((
u32)i >> 3)) << 3) + (y & 7);
691 offset = (offset << 3) + (i & 7);
692 if (canvas[offset] < color)
693 canvas[offset] = color;
706#undef CANVAS_FADE_STEP
struct BattleWork * gBattleWork
void Graphics_ApplyWindowBlendRegisters(void)
Writes the window, display and blend registers the effect keeps in its work, all at once.
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 ObjectGroup_TickMemberTimers(void)
Counts down each target's flash timer, which ObjectGroup_UpdateMembers starts; when one runs out,...
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 ...
#define CANVAS_FADE_STEP
One step of the background palette fade, in 1/65536ths of full brightness: 24 steps take it from full...
void Display_ApplyBg2Reference(void)
Writes the effect's BG2 reference point (work->bg2x, work->bg2y) to BG2X and BG2Y.
void BattleFx_EndCanvasLayer(void)
Closes the canvas layer: plays the closing sound, restores BG1's scroll and the projection centre,...
void BattleFx_FlushPendingGraphicsTransfer(void)
Copies a full-screen picture to VRAM once the effect has finished drawing a frame: the 0x7800 bytes o...
void BattleFx_HideBg1AndRestoreBackdrop(void)
Hides BG1 and the windows and starts bringing the backdrop's palette back.
void BattleFx_ClearActorTimers(void)
Clears every target's flash timer (work->actorTimers).
void BattleFx_BeginTiledCanvas(s32 bgControl)
Opens the canvas layer with BG2 a wrapping 256x256 map: each row of the map is the canvas's 16 tiles ...
void BattleFx_OpenCanvasLayer(s32 bgControl)
Opens the canvas layer as BattleFx_BeginCanvasLayer does, but with the windows off until the end,...
void BattleFx_DrawClippedCanvasLine(s32 x0, s32 y0, s32 x1, s32 y1, s32 color)
Draws a line on the 128x128 8bpp canvas (16 tiles across), keeping the brighter colour where it cross...
void BattleFx_WipeCanvas(s32 mode, s32 value)
Wipes the whole canvas to one colour with a ragged edge: each row (or column) lags a random 0 to 63 p...
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_PRESENT_FRAME(work)
Ends a frame of a canvas effect: marks the canvas ready for the transfer callback,...
@ CANVAS_COPY
copy as drawn
@ CANVAS_COPY_AND_BRIGHTEN
copy, then brighten the canvas by transferValue
@ CANVAS_COPY_AND_CLEAR
copy, then fill the canvas with transferValue
@ 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 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_WINOUT
Outside the battle view: BG0 and blending only.
#define EFFECT_DISPCNT
The battle screen's display mode while an effect plays: background mode 1 with BG0 to BG2,...
#define EFFECT_SET_BATTLE_WINDOWS()
Windows 0 and 1 both cover the battle view: the full width, lines 16 to.
#define EFFECT_PLAYBACK_ORDER
The order where the battle's own playback runs, which the palette fade and the element streaks take.
#define EFFECT_WIN0_LAYERS
Window 0, the battle view, shows BG0 to BG2, sprites and blending.
#define EFFECT_WRITE_CANVAS_MAP_ROW(row, column, offset)
Writes one row of BG2's map for the canvas: its 16 tiles of row row in order.
#define EFFECT_SET_CANVAS_AFFINE()
BG2 shows the canvas from screen line 16 down (BG2Y is -16.0), stretched to twice its width: the 128x...
void BattlePres_SetupTransitionSceneFar(s32 x, s32 depth, s32 y, s32 zoom)
s32 Graphics_ScaleRgb555ClampedFar(u16 *source, u16 *destination, s32 scale, s32 count)
void BattlePresentation_ConfigurePaletteFadeFar(s32 mode, s32 value, s32 fade)
void BattlePresentation_SetPaletteLevelFar(s32 unused, s32 level)
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_BATTLE_BACKGROUND
@ HEAP_SLOT_BATTLE_CANVAS
#define WORK_SLOT(n)
Reads slots through their own addresses; adjacent slots are reached by offsets.
void IoWriteQueue_Store16(u32 address, u32 value)
Queues a halfword store.
#define BGCNT_CHAR_BASE(block)
#define BGCNT_PRIORITY(n)
#define BG_SCREEN_BLOCK(n)
#define BGCNT_SIZE(n)
The background's size: for an affine one, 0 to 3 are 128, 256, 512 and 1024 pixels square.
@ DISPCNT_MODE_1
BG0 and BG1 text, BG2 affine.
#define BLDCNT_EFFECT_BLEND
weighted by REG_BLDALPHA
#define BLEND_ALPHA(top, bottom)
A REG_BLDALPHA value: top and bottom are the two targets' weights, out of 16.
#define BGCNT_SCREEN_BASE(block)
#define BG_PLTT_COLOR(palette, color)
#define BGCNT_WRAP
Affine backgrounds only: wrap around instead of showing the backdrop.
#define IO_WRITE_QUEUE_PUSH(address, value, control)
Disables interrupts to add one register write or DMA to the queue; a write to a full queue is dropped...
static s32 Iwram_CopyWords(volatile void *destination, const volatile void *source, s32 size)
static s32 Iwram_FillWords(void *destination, s32 size, u32 value)
static s32 Iwram_ClearWords(void *destination, s32 size)
#define ABS(v)
The magnitude of v. v is read twice.
#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),...
struct Projection gProjection
#define Ram_MapCellBuffer
void ColorBuffer_BackupAndScaleThreeQuarters(u8 *buffer, u8 *backup, u32 bytes)
Scales every pixel to three quarters.
void ColorBuffer_BackupAndHalve(u8 *buffer, u8 *backup, u32 bytes)
Halves every pixel. Called by the battle effect canvas's transfers.
void ColorBuffer_BackupAndBrighten(u8 *buffer, u32 amount, u8 *backup, u32 bytes)
Raises every pixel by amount, stopping at 63.
void ColorBuffer_BackupAndDarken(u8 *buffer, u32 amount, u8 *backup, u32 bytes)
Lowers every pixel by amount, stopping at 0.
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 background's work slot as the background code reads it: its display mode (2 draws it as an...
s32 secondMode
1 also sets BG1's scroll; one effect sets it
s16 actors[8]
the targets' unit ids, count of them
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 savedBg1Y
BG1 scroll restored when a shake ends.
s32 savedBg1X
BG1 scroll restored when a shake ends.
s32 framesSinceTransfer
1 on a canvas copy's frame, then counts up
s32 transferPending
1 once the effect has drawn a frame (EFFECT_PRESENT_FRAME); the canvas transfer callback copies the c...
s32 fadeStep
CANVAS_FADE_STEPs the backdrop has darkened so far.
s32 shakeFrames
shake frames left; Camera_ApplyShake counts down
s32 bg2x
BG2's reference point, written to BG2X and BG2Y by Display_ApplyBg2Reference and BattleFx_AdvanceBg2O...
u16 win0h
Window, display and blend registers, which Graphics_ApplyWindowBlendRegisters writes all at once.
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...
u8 actorTimers[8]
Each target's flash timer in frames, for effect->actors[n]: set by ObjectGroup_UpdateMembers,...
struct BattleEffectArgument * effect
the command being run
The battle's own work: its enemies, units and their objects, the turn's actions, the spoils,...
u16 background
the battle background's id
u16 palette[128]
the backdrop's colours, before scaling