Skip to content

Commit b67b86b

Browse files
committed
swapped the transparent and opaque loops to improve worst case transparent performance
1 parent 75eec43 commit b67b86b

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
@@ -5048,13 +5048,13 @@ _RotatedScaledSprite_NoClip:
50485048

50495049
;-------------------------------------------------------------------------------
50505050

5051-
.inner_transparent:
5051+
.inner_opaque:
50525052
cp a, h
50535053
jr c, .skip_pixel
50545054
ld c, ixh
50555055
cp a, c
50565056
jr c, .skip_pixel
5057-
.inner_transparent_hijack:
5057+
.inner_opaque_hijack:
50585058
; get pixel and draw to buffer
50595059
push hl ; xs
50605060
ld l, a
@@ -5065,30 +5065,21 @@ _RotatedScaledSprite_NoClip:
50655065
add hl, bc ; y * size + x
50665066

50675067
ld bc, 0
5068-
.dsrs_sprptr_0A := $-3
5068+
.dsrs_sprptr_0B := $-3
50695069
add hl, bc
5070-
ld b, a ; preserve A
5071-
ld a, (hl)
5072-
cp a, TRASPARENT_COLOR
5073-
smcByte _TransparentColor
5074-
jr z, .transparent_pixel
5075-
ld (de), a
5076-
.transparent_pixel:
5077-
ld a, b ; restore A
5078-
pop hl ; ys
5079-
.skip_pixel:
5080-
inc de ; x++s
5070+
ldi
5071+
pop hl
5072+
50815073
ld bc, 0 ; smc = -sinf
5082-
.dsrs_sinf_0A := $-3
5074+
.dsrs_sinf_0B := $-3
50835075
add hl, bc ; ys += -sinf
50845076

50855077
ld bc, 0 ; smc = cosf
5086-
.dsrs_cosf_0A := $-3
5078+
.dsrs_cosf_0B := $-3
50875079
add ix, bc ; xs += cosf
50885080

50895081
dec iyl
5090-
jr nz, .inner_transparent ; x loop
5091-
.dsrs_jump_1 := $-1
5082+
jr nz, .inner_opaque ; x loop
50925083

50935084
dec iyh
50945085
jr z, .finish ; y loop
@@ -5113,14 +5104,14 @@ smcByte _TransparentColor
51135104
.begin_loop:
51145105
.dsrs_size_1 := $+2 ; smc = size * scale / 64
51155106
ld iyl, 0
5116-
.inner_opaque:
5107+
.inner_transparent:
51175108
cp a, h
51185109
jr c, .skip_pixel
51195110
ld c, ixh
51205111
cp a, c
51215112
jr c, .skip_pixel
51225113
; get pixel and draw to buffer
5123-
; SMC: push hl \ ld l, a --> jr inner_transparent_hijack
5114+
; SMC: push hl \ ld l, a --> jr inner_opaque_hijack
51245115
push hl ; xs
51255116
ld l, a
51265117
.dsrs_jump_2 := $-1
@@ -5131,21 +5122,30 @@ smcByte _TransparentColor
51315122
add hl, bc ; y * size + x
51325123

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

51435142
ld bc, 0 ; smc = cosf
5144-
.dsrs_cosf_0B := $-3
5143+
.dsrs_cosf_0A := $-3
51455144
add ix, bc ; xs += cosf
51465145

51475146
dec iyl
5148-
jr nz, .inner_opaque ; x loop
5147+
jr nz, .inner_transparent ; x loop
5148+
.dsrs_jump_1 := $-1
51495149

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

0 commit comments

Comments
 (0)