The blitter builder, BattleFx_BuildBlitter.
Part of effect.c, the battle effect object, compiled only through it. The folder README describes the routine it writes, block by block, under "Blitters"; the fragments' registers and modes are described at the top of battle_effect_composite.s.
Definition in file blitter.c.
| #define BLITTER_PARTIAL_RUN |
( |
| mode, |
|
|
| flags ) |
The words of a partial run, one pixel at a time: the mode's one-pixel fragment, read forwards or, mirrored across, backwards.
Each walk writes a leading and a trailing run.
Definition at line 19 of file blitter.c.
The template walk itself, written once.
BattleFx_BuildBlitter expands it twice under two definitions of PUT, COPY, COPY_FROM, COPY_TWICE, PUT_BRANCH, MARK and PATCH: first to count the words, then to write them. It uses the caller's templateWords, flags, mode, widthShift, heightShift, and the branch sites emptyRowsBranch, emptyColumnsBranch, rowLoop, skipBranch, partialRun and fullCellLoop.
Definition at line 58 of file blitter.c.
Referenced by BattleFx_BuildBlitter().
| s32 BattleFx_BuildBlitter |
( |
s32 | slot, |
|
|
s32 | widthShift, |
|
|
s32 | heightShift, |
|
|
s32 | flags, |
|
|
u32 | mode ) |
Writes a drawing routine for the canvas into heap slot slot, built from the template BattleFx_Composite for one clip, mirroring and blend mode.
Called through EFFECT_LOAD_BLITTER by nearly every canvas effect and by BattleFx_FetchRectangleBlitters, directly by the particle streams for a canvas 256 pixels wide, and from other banks through its far stub, BattleEffect_LoadWorkFar (the star field in battle/star_field.c and object/colorfx.c).
It allocates the slot's block (from IWRAM when it fits) at exactly the routine's size. A slot that already holds a block keeps it, whatever its size, and the routine is written over it: callers release the slot first when the new routine may be longer. The caller calls the slot's block as a DrawRectangle.
widthShift, heightShift: the canvas's width and height as powers of two. flags: the COMPOSITE_CLIP_ and COMPOSITE_FLIP_ bits. mode: how source pixels combine with the canvas (COMPOSITE_COPY, COMPOSITE_TRANSPARENT, COMPOSITE_MAX or COMPOSITE_ADDITIVE).
Returns nonzero when the walk ended exactly at gBattleFx_MoteCells, the end of the template; no caller reads it.
Definition at line 281 of file blitter.c.
Referenced by BattleFx_BuildBlitter(), and BattleFx_RunParticleStreams().