Skip to Content
The Alchemy Project

src/battle_effect/blitter_fragments.c

The pieces btEffectBuildBlitter (battle_effect_blitter.c) builds canvas blitters from. More…

Macros

NameDescription
#defineFRAGMENT void __attribute__((naked))A fragment: no entry or exit code, since only its body is copied.
#defineCANVAS_WORD_NEXT (((Uint32 *)(canvas += 4))[-1])A current GCC takes no cast as an lvalue.

Functions

NameDescription
FRAGMENTBattleEffectCopyReverse (void)Copy, one pixel, right to left.
FRAGMENTBattleEffectCopyForward (void)Copy, one pixel, left to right.
FRAGMENTBattleEffectTransparentForward (void)Transparent, one pixel, left to right.
FRAGMENTBattleEffectTransparentReverse (void)Transparent, one pixel, right to left.
FRAGMENTBattleEffectTransparent8Forward (void)Transparent, a full cell's eight pixels, left to right.
FRAGMENTBattleEffectTransparent8Reverse (void)Transparent, a full cell's eight pixels, right to left.
FRAGMENTBattleEffectMaxForward (void)Max, one pixel, left to right.
FRAGMENTBattleEffectMaxReverse (void)Max, one pixel, right to left.
FRAGMENTBattleEffectMax4Forward (void)Max over the four pixels of one canvas word, read once: each canvas byte is taken into cap.
FRAGMENTBattleEffectMax4Reverse (void)The pixel fragments btEffectBuildBlitter copies into its blitters, from blitter_fragments.c: Forward reads the picture left to right and Reverse right to left.
FRAGMENTBattleEffectAdditiveForward (void)Additive, one pixel, left to right.
FRAGMENTBattleEffectAdditiveReverse (void)Additive, one pixel, right to left.
FRAGMENTBattleEffectMask (void)Loads the cap mask the colour fragments use: CANVAS_LEVEL_BRIGHTEST + 1 in every byte.

Description

The pieces btEffectBuildBlitter (battle_effect_blitter.c) builds canvas blitters from. None of this code runs where it is: the builder copies its words into a heap block, one function per canvas size, mirroring, clip and mode, after the template's entry code (blitter_template.s) has set up the picture and canvas pointers. So each fragment is a function with no entry or exit of its own, working on the blitter's registers.

Each pixel fragment combines picture pixels into the canvas: Copy writes them, Transparent skips zeros, Max keeps the brighter of the two, Additive adds them a pixel at a time, capped at the brightest canvas level. Forward fragments read the picture left to right and Reverse ones right to left; canvas rows stay in tile order. The 8 variants do eight pixels a pass. For whole cells the additive mode uses the colour fragments (blitter_color_fragments.c), which add four pixels a word at a time, capped with the mask BattleEffectMask loads.

Macros in detail

FRAGMENT

#define FRAGMENT void __attribute__((naked))

A fragment: no entry or exit code, since only its body is copied.

Referenced by BattleEffectAdditiveForward(), BattleEffectAdditiveReverse(), BattleEffectColorForward(), BattleEffectColorReverse(), BattleEffectCopyForward(), BattleEffectCopyReverse(), BattleEffectMask(), BattleEffectMax4Forward(), BattleEffectMax4Reverse(), BattleEffectMaxForward(), BattleEffectMaxReverse(), BattleEffectTransparent8Forward(), BattleEffectTransparent8Reverse(), BattleEffectTransparentForward() and BattleEffectTransparentReverse().

Definition at line 30 of file blitter_fragments.c.

CANVAS_WORD_NEXT

#define CANVAS_WORD_NEXT (((Uint32 *)(canvas += 4))[-1])

#define CANVAS_WORD_NEXT (*((Uint32 *)canvas)++)

A current GCC takes no cast as an lvalue.

Referenced by BattleEffectColorForward(), BattleEffectColorReverse(), BattleEffectMax4Forward() and BattleEffectMax4Reverse().

Definition at lines 35 and 37 of file blitter_fragments.c.

Functions in detail

BattleEffectCopyReverse

FRAGMENT BattleEffectCopyReverse(void)

Copy, one pixel, right to left.

References pixel.

Definition at line 40 of file blitter_fragments.c.

BattleEffectCopyForward

FRAGMENT BattleEffectCopyForward(void)

Copy, one pixel, left to right.

References pixel.

Definition at line 46 of file blitter_fragments.c.

BattleEffectTransparentForward

FRAGMENT BattleEffectTransparentForward(void)

Transparent, one pixel, left to right.

References pixel.

Definition at line 52 of file blitter_fragments.c.

BattleEffectTransparentReverse

FRAGMENT BattleEffectTransparentReverse(void)

Transparent, one pixel, right to left.

References pixel.

Definition at line 60 of file blitter_fragments.c.

BattleEffectTransparent8Forward

FRAGMENT BattleEffectTransparent8Forward(void)

Transparent, a full cell's eight pixels, left to right.

References pixel.

Definition at line 68 of file blitter_fragments.c.

BattleEffectTransparent8Reverse

FRAGMENT BattleEffectTransparent8Reverse(void)

Transparent, a full cell's eight pixels, right to left.

References pixel.

Definition at line 97 of file blitter_fragments.c.

BattleEffectMaxForward

FRAGMENT BattleEffectMaxForward(void)

Max, one pixel, left to right.

References pixel.

Definition at line 126 of file blitter_fragments.c.

BattleEffectMaxReverse

FRAGMENT BattleEffectMaxReverse(void)

Max, one pixel, right to left.

References pixel.

Definition at line 134 of file blitter_fragments.c.

BattleEffectMax4Forward

FRAGMENT BattleEffectMax4Forward(void)

Max over the four pixels of one canvas word, read once: each canvas byte is taken into cap.

References pixel.

Definition at line 144 of file blitter_fragments.c.

BattleEffectMax4Reverse

FRAGMENT BattleEffectMax4Reverse(void)

The pixel fragments btEffectBuildBlitter copies into its blitters, from blitter_fragments.c: Forward reads the picture left to right and Reverse right to left. None of them runs where it is. Max, four pixels (one canvas word), right to left; a full cell's row takes it twice.

References pixel.

Definition at line 164 of file blitter_fragments.c.

BattleEffectAdditiveForward

FRAGMENT BattleEffectAdditiveForward(void)

Additive, one pixel, left to right.

References pixel.

Definition at line 184 of file blitter_fragments.c.

BattleEffectAdditiveReverse

FRAGMENT BattleEffectAdditiveReverse(void)

Additive, one pixel, right to left.

References pixel.

Definition at line 195 of file blitter_fragments.c.

BattleEffectMask

FRAGMENT BattleEffectMask(void)

Loads the cap mask the colour fragments use: CANVAS_LEVEL_BRIGHTEST + 1 in every byte.

Definition at line 208 of file blitter_fragments.c.