Skip to content

Commit 373d29e

Browse files
authored
Optimized _TransparentPlot_ASM for speed*
Unrolled each of the opaque and transparent braches into four iterations, so stretches of the same pixel opaqueness/transparency mostly fall through the jumps and execute faster. Before (12 bytes): * opaque->opaque: 41 cc * opaque->trans: 36 cc * trans->opaque: 46 cc * trans->trans: 41 cc After (54 bytes; lists cycles after 1/2/3/4 mod 4 iterations in a row of previous pixel state): * opaque->opaque: 36/36/36/41 cc * opaque->trans: 41/41/41/36 cc * trans->opaque: 38/38/38/46 cc * trans->trans: 33/33/33/38 cc Starts on the fast transparent path based on the assumption that the majority of transparent sprite pixel rows start with a transparent pixel, as transparency is often used to draw "cutout" images.
1 parent 8cb6001 commit 373d29e

File tree

1 file changed

+39
-5
lines changed

1 file changed

+39
-5
lines changed

CEdev/lib/src/libraries/graphics_src/graphx/v2/graphics_lib.asm

Lines changed: 39 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1796,16 +1796,50 @@ ClipSprTransNextAmt =$+1
17961796
pop ix
17971797
ret
17981798

1799-
_: ldi
1799+
_TransparentPlot_ASM_Opaque:
1800+
ldi
1801+
ret po
1802+
cp a,(hl)
1803+
jr z,_TransparentPlot_ASM_Transparent
1804+
ldi
18001805
ret po
1806+
cp a,(hl)
1807+
jr z,_TransparentPlot_ASM_Transparent
1808+
ldi
1809+
ret po
1810+
cp a,(hl)
1811+
jr z,_TransparentPlot_ASM_Transparent
1812+
ldi
1813+
ret po
1814+
cp a,(hl)
1815+
jr nz,_TransparentPlot_ASM_Opaque
1816+
_TransparentPlot_ASM_Transparent:
1817+
inc de
1818+
inc hl
1819+
dec c
1820+
ret z
18011821
_TransparentPlot_ASM:
1802-
_: cp a,(hl)
1803-
jr nz,--_
1822+
cp a,(hl)
1823+
jr nz,_TransparentPlot_ASM_Opaque
18041824
inc de
18051825
inc hl
18061826
dec c
1807-
jr nz,-_ ; 41 cycles
1808-
ret
1827+
ret z
1828+
cp a,(hl)
1829+
jr nz,_TransparentPlot_ASM_Opaque
1830+
inc de
1831+
inc hl
1832+
dec c
1833+
ret z
1834+
cp a,(hl)
1835+
jr nz,_TransparentPlot_ASM_Opaque
1836+
inc de
1837+
inc hl
1838+
dec c
1839+
ret z
1840+
cp a,(hl)
1841+
jr z,_TransparentPlot_ASM_Transparent
1842+
jr _TransparentPlot_ASM_Opaque
18091843

18101844
;-------------------------------------------------------------------------------
18111845
_Sprite:

0 commit comments

Comments
 (0)