Skip to content

Commit 37e49bb

Browse files
committed
swapped the transparent and opaque loops to improve worst case transparent performance
1 parent 36388f3 commit 37e49bb

File tree

1 file changed

+31
-31
lines changed

1 file changed

+31
-31
lines changed

src/graphx/graphx.asm

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -4881,8 +4881,8 @@ gfx_RotatedScaledSprite_NoClip:
48814881
; Returns:
48824882
; arg1 : Pointer to sprite struct output
48834883
ld a, -1 + _RotatedScaledSprite_NoClip.inner_opaque - _RotatedScaledSprite_NoClip.dsrs_jump_1
4884-
; push hl \ ld l, a \ inc l
4885-
ld bc, $2C6FE5
4884+
; jr .inner_opaque_hijack \ inc l
4885+
ld bc, ($2C0018) or (((-1 + _RotatedScaledSprite_NoClip.inner_opaque_hijack - _RotatedScaledSprite_NoClip.dsrs_jump_2) and $FF) shl 8)
48864886
jr _RotatedScaledSprite_NoClip
48874887
;-------------------------------------------------------------------------------
48884888
gfx_RotatedScaledTransparentSprite_NoClip:
@@ -4895,8 +4895,8 @@ gfx_RotatedScaledTransparentSprite_NoClip:
48954895
; Returns:
48964896
; arg1 : Pointer to sprite struct output
48974897
ld a, -1 + _RotatedScaledSprite_NoClip.inner_transparent - _RotatedScaledSprite_NoClip.dsrs_jump_1
4898-
; jr .inner_transparent_hijack \ inc l
4899-
ld bc, ($2C0018) or (((-1 + _RotatedScaledSprite_NoClip.inner_transparent_hijack - _RotatedScaledSprite_NoClip.dsrs_jump_2) and $FF) shl 8)
4898+
; push hl \ ld l, a \ inc l
4899+
ld bc, $2C6FE5
49004900
_RotatedScaledSprite_NoClip:
49014901
ld iy, .dsrs_base_address
49024902
ld (iy + (_RotatedScaledSprite_NoClip.dsrs_jump_1 - .dsrs_base_address)), a
@@ -5047,13 +5047,13 @@ _RotatedScaledSprite_NoClip:
50475047

50485048
;-------------------------------------------------------------------------------
50495049

5050-
.inner_transparent:
5050+
.inner_opaque:
50515051
cp a, h
50525052
jr c, .skip_pixel
50535053
ld c, ixh
50545054
cp a, c
50555055
jr c, .skip_pixel
5056-
.inner_transparent_hijack:
5056+
.inner_opaque_hijack:
50575057
; get pixel and draw to buffer
50585058
push hl ; xs
50595059
ld l, a
@@ -5064,30 +5064,21 @@ _RotatedScaledSprite_NoClip:
50645064
add hl, bc ; y * size + x
50655065

50665066
ld bc, 0
5067-
.dsrs_sprptr_0A := $-3
5067+
.dsrs_sprptr_0B := $-3
50685068
add hl, bc
5069-
ld b, a ; preserve A
5070-
ld a, (hl)
5071-
cp a, TRASPARENT_COLOR
5072-
smcByte _TransparentColor
5073-
jr z, .transparent_pixel
5074-
ld (de), a
5075-
.transparent_pixel:
5076-
ld a, b ; restore A
5077-
pop hl ; ys
5078-
.skip_pixel:
5079-
inc de ; x++s
5069+
ldi
5070+
pop hl
5071+
50805072
ld bc, 0 ; smc = -sinf
5081-
.dsrs_sinf_0A := $-3
5073+
.dsrs_sinf_0B := $-3
50825074
add hl, bc ; ys += -sinf
50835075

50845076
ld bc, 0 ; smc = cosf
5085-
.dsrs_cosf_0A := $-3
5077+
.dsrs_cosf_0B := $-3
50865078
add ix, bc ; xs += cosf
50875079

50885080
dec iyl
5089-
jr nz, .inner_transparent ; x loop
5090-
.dsrs_jump_1 := $-1
5081+
jr nz, .inner_opaque ; x loop
50915082

50925083
dec iyh
50935084
jr z, .finish ; y loop
@@ -5112,14 +5103,14 @@ smcByte _TransparentColor
51125103
.begin_loop:
51135104
.dsrs_size_1 := $+2 ; smc = size * scale / 64
51145105
ld iyl, 0
5115-
.inner_opaque:
5106+
.inner_transparent:
51165107
cp a, h
51175108
jr c, .skip_pixel
51185109
ld c, ixh
51195110
cp a, c
51205111
jr c, .skip_pixel
51215112
; get pixel and draw to buffer
5122-
; SMC: push hl \ ld l, a --> jr inner_transparent_hijack
5113+
; SMC: push hl \ ld l, a --> jr inner_opaque_hijack
51235114
push hl ; xs
51245115
ld l, a
51255116
.dsrs_jump_2 := $-1
@@ -5130,21 +5121,30 @@ smcByte _TransparentColor
51305121
add hl, bc ; y * size + x
51315122

51325123
ld bc, 0
5133-
.dsrs_sprptr_0B := $-3
5124+
.dsrs_sprptr_0A := $-3
51345125
add hl, bc
5135-
ldi
5136-
pop hl
5137-
5126+
ld b, a ; preserve A
5127+
ld a, (hl)
5128+
cp a, TRASPARENT_COLOR
5129+
smcByte _TransparentColor
5130+
jr z, .transparent_pixel
5131+
ld (de), a
5132+
.transparent_pixel:
5133+
ld a, b ; restore A
5134+
pop hl ; ys
5135+
.skip_pixel:
5136+
inc de ; x++s
51385137
ld bc, 0 ; smc = -sinf
5139-
.dsrs_sinf_0B := $-3
5138+
.dsrs_sinf_0A := $-3
51405139
add hl, bc ; ys += -sinf
51415140

51425141
ld bc, 0 ; smc = cosf
5143-
.dsrs_cosf_0B := $-3
5142+
.dsrs_cosf_0A := $-3
51445143
add ix, bc ; xs += cosf
51455144

51465145
dec iyl
5147-
jr nz, .inner_opaque ; x loop
5146+
jr nz, .inner_transparent ; x loop
5147+
.dsrs_jump_1 := $-1
51485148

51495149
dec iyh
51505150
jr nz, .outer ; y loop

0 commit comments

Comments
 (0)