1#ifndef ALCHEMY_EFFECT_INTERNAL_H
2#define ALCHEMY_EFFECT_INTERNAL_H
83#define EFFECT_DISPCNT \
84 (DISPCNT_MODE_1 | DISPCNT_OBJ_1D_MAP | DISPCNT_BG0_ON | DISPCNT_BG1_ON | \
85 DISPCNT_BG2_ON | DISPCNT_OBJ_ON | DISPCNT_WIN0_ON | DISPCNT_WIN1_ON)
89#define EFFECT_WIN0_LAYERS \
90 (WININ_WIN0_BG0 | WININ_WIN0_BG1 | WININ_WIN0_BG2 | WININ_WIN0_OBJ | \
94#define EFFECT_WINOUT (WINOUT_WIN01_BG0 | WINOUT_WIN01_CLR | WINOUT_WINOBJ_ALL)
98#define EFFECT_SLOT(slots, slot) ((slots)[(slot) - HEAP_SLOT_BATTLE_EFFECT])
101#define CANVAS_SLOT(slots, slot) ((slots)[(slot) - HEAP_SLOT_BATTLE_CANVAS])
104#define DMA_CONTROL_HALF 5
107#define DMA_FILL_WORDS(n) ((DMA_ENABLE | DMA_32BIT | DMA_SRC_FIXED) << 16 | (n))
133#define EFFECT_GET_WORK_AND_CANVAS(cursor, work, canvas) \
134 ((work) = *(cursor)++, (canvas) = *(cursor))
138#define EFFECT_GET_SLOTS(slots, cursor, work, canvas) \
139 ((slots) = &gWorkSlot[HEAP_SLOT_BATTLE_EFFECT], (cursor) = (slots), \
140 EFFECT_GET_WORK_AND_CANVAS(cursor, work, canvas))
144#define EFFECT_FREE_PARTICLES(i, particles, count) \
145 for ((i) = 0; (i) != (count); (i)++) \
146 (particles)[i].variant = -1
151#define EFFECT_VIEW_FROM_CAMERA(camera) \
152 (Render_ResetTransformState(), \
153 Transform_SetLookAt((camera)->eye, (camera)->pos))
158#define EFFECT_STRIKE_TARGET(effect, i, frames, motion) \
159 (ObjectGroup_UpdateMembers((effect)->actors[i], SPRITE_COLOR_WHITE, \
160 POSE_DAMAGE, i, frames), \
161 BattleMotion_ApplyVariantMotionFar((effect)->actors[i], motion))
170#define EFFECT_SHOW_DAMAGE(hitSound) BattleEventRuntime_BeginPhaseFar(hitSound)
174#define CANVAS_BYTES (128 * 128)
178#define EFFECT_BEGIN_NARROW_CANVAS(bgControl) \
179 (BattleFx_BeginCanvasLayer(bgControl), REG_BG2PA = Q_8_8(1))
184#define EFFECT_LOAD_BLITTER(slot, flags, mode) \
185 BattleFx_BuildBlitter(slot, 7, 7, flags, mode)
189#define EFFECT_SET_TRANSFER(work, mode, value) \
190 ((work)->transferMode = (mode), (work)->transferValue = (value))
193#define EFFECT_START_TRANSFER(work, mode, value) \
194 (EFFECT_SET_TRANSFER(work, mode, value), \
195 Scheduler_AddOrUpdateCallback(BattleFx_ProcessPendingGraphicsTransfer, \
196 EFFECT_CALLBACK_ORDER))
200#define EFFECT_PRESENT_FRAME(work) ((work)->transferPending = 1, WaitFrames(1))
204#define EFFECT_END_FRAME(work) \
205 (ObjectGroup_TickMemberTimers(), EFFECT_PRESENT_FRAME(work))
208#define EFFECT_RELEASE_BLITTERS() \
209 (Runtime_ReleaseHeapBlock(HEAP_SLOT_BLITTER_ALTERNATE), \
210 Runtime_ReleaseHeapBlock(HEAP_SLOT_BLITTER))
214#define EFFECT_FINISH_CANVAS() \
215 (Scheduler_RemoveCallback(BattleFx_ProcessPendingGraphicsTransfer), \
216 EFFECT_RELEASE_BLITTERS(), BattleFx_EndCanvasLayer())
219#define EFFECT_FINISH_CANVAS_ONE_BLITTER() \
220 (Scheduler_RemoveCallback(BattleFx_ProcessPendingGraphicsTransfer), \
221 Runtime_ReleaseHeapBlock(HEAP_SLOT_BLITTER), BattleFx_EndCanvasLayer())
224#define MOTE_SET_BYTES 770
230#define EFFECT_DRAW_MOTE(draw, canvas, sheet, x, y, size) \
231 (draw)(canvas, (sheet) + gBattleFx_MoteCells[(size) - 1], (x) - (size) / 2, \
232 (y) - (size), size, (size) * 2)
237#define EFFECT_DRAW_FLARE(draw, canvas, sheet, x, y, size) \
238 (draw)(canvas, (sheet) + gBattleFx_FlareCells[(size) - 1], (x) - (size), \
239 (y) - (size), (size) * 2, (size) * 2)
245#define EFFECT_SHOW_WIDE_CANVAS(top) \
246 (REG_DISPCNT = EFFECT_DISPCNT, REG_BG2PA = Q_8_8(0.5), \
247 REG_BLDALPHA = BLEND_ALPHA(top, 16), \
248 REG_BLDCNT = BLDCNT_TGT1_BG2 | BLDCNT_EFFECT_BLEND | BLDCNT_TGT2_ALL)
253#define WINDOW_SPAN_INVERTED WIN_RANGE(1, 0)
257#define EFFECT_CALLBACK_ORDER 0x480
260#define EFFECT_PLAYBACK_ORDER 0xc80
264#define BLUE_RAMP_PIXELS Ram_MapCellBuffer
269#define EFFECT_CAP_LEVEL(level, cap) \
271 if ((level) > (cap)) \
278#define LIGHTNING_BOLT_CELL_BYTES 2880
282#define EFFECT_SET_BATTLE_WINDOWS() \
283 (REG_WIN0H = WIN_RANGE(0, 240), REG_WIN0V = WIN_RANGE(16, 136), \
284 REG_WIN1H = WIN_RANGE(0, 240), REG_WIN1V = WIN_RANGE(16, 136))
288#define EFFECT_SET_CANVAS_AFFINE() \
289 (REG_BG2X = 0, REG_BG2Y = -0x1000, REG_BG2PA = Q_8_8(0.5), REG_BG2PB = 0, \
290 REG_BG2PC = 0, REG_BG2PD = Q_8_8(1))
295#define EFFECT_WRITE_CANVAS_MAP_ROW(row, column, offset) \
296 for ((column) = 0; (column) != 8; (column)++, (offset) += 2) { \
300 tileIndex = (row) * 16 + (column) * 2; \
301 pair = ((tileIndex + 1) << 8) | tileIndex; \
302 *(volatile s16 *)((u8 *)BG_CANVAS_MAP + (offset)) = pair; \
Animated sprites: their layers, frames and colour modes, and the resource slots they draw from.
B5Context, the object context a battle routine reads; most of its fields are still unnamed.
The battle camera and the presentation's transition, background and affine work.
The battle effect argument and the rectangle-drawing routines effects call.
BattleEffectWork, the running battle effect's work, and its animation objects.
A battle's objects and sprites, each unit's command and action record, and the spoils.
BattleUnit_Recalculate, which recalculates a unit's stats.
BattlePlan, an action planned for its targets: the hits, criticals and multipliers rolled.
BattleUnit, a party member's or enemy's battle state, with the elements, abilities and actions it use...
BattleWork, the battle's own work, and the battle display work.
Calls through a function pointer, by argument count.
The task scheduler: tasks, their order and the scheduler's state.
Declares nothing of its own: it only includes types.h and battle_effect.h.
The engine calls the debug menus import, and their palette swatch tiles.
DMA channel registers, and the DMA and CPU fills.
CanvasTransferMode
How BattleFx_ProcessPendingGraphicsTransfer moves the effect's 128x128 canvas into VRAM once a frame ...
@ 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
static void Dma_Stop(volatile u16 *channel)
Stops a DMA channel: clears its repeat and start timing bits, then its enable bit,...
#define DMA_CONTROL_HALF
Index of DMAxCNT_H, the control half, in a channel's 16-bit registers.
EffectStep and EffectPosition, the positions effects move through.
The scene script layer: the engine services a scene's events call, declared once (Engine_EventBegin,...
16.16 fixed-point constants, sine and cosine, and the library division.
FixedPointPosition, a position in 16.16 fixed point.
The work slots of gWorkSlot, read through their own names.
The screen blend's globals and the graphics routines.
The heap's work slots and HeapState.
The hardware's I/O registers and their bits, as pret names them.
#define DMA_START_TIMING_DRQ_REPEAT
A DMA control's start timing (bits 12 and 13), cartridge request (bit 11) and repeat (bit 9): the bit...
The register write queue that VBlank carries out after each finished frame.
The hardware's interrupt sources and the interrupt handler table.
The IWRAM call layer: the routines the game keeps resident in IWRAM, each at its fixed address,...
The keypad state the VBlank interrupt keeps.
Small statement macros both games use for positions, velocities and bounds.
The heaps: allocating and freeing blocks.
The reel game's title lettering.
MotionObject, an effect object that moves and draws one sprite.
The work pointers in the gWorkSlot table, by name.
Resource numbers, named where their contents are known.
FIELD_AT_OFFSET and the entity and camera views older scene code reads.
Song and sound effect ids, indices into gSound_SongTable.
The system's routines and globals: interrupts, BIOS sound bias, random numbers and sleep.
The integer types, TRUE, UNUSED and the fixed-address macros.