@@ -2709,31 +2709,30 @@ gfx_TransparentSprite:
27092709 push ix ; save ix sp
27102710 call _ClipCoordinates
27112711 jr nc , .culled
2712+ ; iyl = new width (next)
2713+ ; iyh = new height
27122714 ld (.amount) , a
2713- ld a , c ; new width
2714- ld (.next) , a
2715- ld ixh , b ; new height
2716- ld b , 0
27172715.transparent_color := $ + 1
27182716 ld a , TRASPARENT_COLOR
27192717smcByte _TransparentColor
27202718 wait_quick
27212719. loop :
2722- ld c , 0
2723- .next := $ - 1
2724- lea de , iy
2720+ ld c , iyl ; next
2721+ lea de , ix
27252722 call _TransparentPlot ; call the transparent routine
27262723 ld c , 0
27272724.amount := $ - 1
27282725 add hl , bc
27292726 ld de , ti.lcdWidth ; move to next row
2730- add iy , de
2731- dec ixh
2727+ add ix , de
2728+ dec iyh
27322729 jr nz , . loop
27332730.culled:
27342731 pop ix
27352732 ret
27362733
2734+ ; Opaque unrolled 4 times
2735+ ; Transparent unrolled 4 times
27372736_TransparentPlot_Opaque: ; routine to handle transparent plotting
27382737 ldi
27392738 ret po
@@ -2790,26 +2789,22 @@ gfx_Sprite:
27902789; None
27912790 push ix ; save ix sp
27922791 call _ClipCoordinates
2793- pop ix ; restore ix sp
2794- ret nc
2795- ld (.amount) , a
2796- ld a , c ; new width
2797- ld (.next) , a
2798- ld a , b ; new height
2799- ld b , 0
2792+ jr nc , .culled
2793+ ; iyl = new width (next)
2794+ ; iyh = new height
28002795 wait_quick
28012796. loop :
2802- ld c , 0
2803- .next := $ - 1
2804- lea de , iy
2797+ ld c , iyl ; next
2798+ lea de , ix
28052799 ldir
28062800 ld de , ti.lcdWidth
2807- add iy , de
2808- ld c , 0
2809- .amount := $ - 1
2801+ add ix , de
2802+ ld c , a ; amount
28102803 add hl , bc ; move to next line
2811- dec a
2804+ dec iyh
28122805 jr nz , . loop
2806+ .culled:
2807+ pop ix ; restore ix sp
28132808 ret
28142809
28152810;-------------------------------------------------------------------------------
@@ -2928,33 +2923,32 @@ gfx_TransparentSprite_NoClip:
29282923 add iy , sp
29292924 ld hl , (iy + 6 ) ; hl = x coordinate
29302925 ld c , (iy + 9 ) ; c = y coordinate
2931- ld iy , (iy + 3 ) ; iy -> sprite struct
29322926 ld de , (CurrentBuffer)
29332927 add hl , de
29342928 ld b , ti.lcdWidth / 2
29352929 mlt bc
29362930 add hl , bc
29372931 add hl , bc ; hl -> place to draw
29382932 push hl
2939- ld a , (iy + 0 )
2940- ld (.next) , a
2941- ld a , (iy + 1 )
2942- lea hl , iy + 2
2943- pop iy
2944- push ix
2945- ld ixh , a ; ixh = height of sprite
2933+ ld hl , (iy + 3 ) ; hl -> sprite struct
2934+ ld a , (hl)
2935+ inc hl
2936+ ld iyl , a ; (.next)
2937+ ld a , (hl)
2938+ inc hl
2939+ ex ( sp ) , ix ; preserve ix and load it with (sp)
2940+ ld iyh , a ; ixh = height of sprite
29462941 ld b , 0 ; zero mid byte
29472942 ld a , TRASPARENT_COLOR
29482943smcByte _TransparentColor
29492944 wait_quick
29502945. loop :
2951- ld c , 0
2952- .next := $ - 1
2953- lea de , iy
2946+ ld c , iyl ; (.next)
2947+ lea de , ix
29542948 call _TransparentPlot ; call the plotter
29552949 ld de , ti.lcdWidth
2956- add iy , de
2957- dec ixh ; loop for height
2950+ add ix , de
2951+ dec iyh ; loop for height
29582952 jr nz , . loop
29592953 pop ix ; restore stack pointer
29602954 ret
@@ -2969,10 +2963,11 @@ _ClipCoordinates:
29692963; Returns:
29702964; A : How much to add to the sprite per iteration
29712965; BCU: 0
2972- ; B : New sprite height
2973- ; C : New sprite width
2966+ ; B : 0
2967+ ; IYH: New sprite height
2968+ ; IYL: New sprite width
29742969; HL : Sprite pixel pointer
2975- ; IY : Buffer pixel pointer
2970+ ; IX : Buffer pixel pointer
29762971; NC : If offscreen
29772972 ld ix , 6 ; get pointer to arguments
29782973 add ix , sp
@@ -3022,12 +3017,12 @@ smcByte _YMin
30223017.clipbottom:
30233018 inc e
30243019 ld iyh , e ; save new height
3025- .yclipped:
3020+ or a , a
3021+ .yclipped: ; <-- carry already cleared on this path
30263022
30273023 ld bc , 0
30283024smcWord _XMin
30293025 ld hl , (ix + 6 ) ; hl = x coordinate
3030- or a , a
30313026 sbc hl , bc
30323027 ex de , hl ; de = x coordinate relative to min x
30333028 ld hl , ti.lcdWidth ; hl = clip_width
@@ -3070,19 +3065,19 @@ smcWord _XMin
30703065 sub a , e ; calculate bytes to add per iteration
30713066.xclipped:
30723067
3073- lea .s bc , iy
30743068 ld l , (ix + 9 ) ; l = y coordinate
30753069 ld h , ti.lcdWidth / 2
30763070 mlt hl
30773071 add hl , hl
30783072 ld de , (ix + 6 ) ; de = x coordinate
30793073 add hl , de
30803074 ex de , hl
3081- ld iy , (CurrentBuffer)
3082- add iy , de
30833075 ld hl , (ix + 3 ) ; hl -> sprite data
30843076 inc hl
30853077 inc hl
3078+ ld ix , (CurrentBuffer)
3079+ add ix , de
3080+ ld b , 0
30863081 scf ; set carry for success
30873082 ret
30883083
0 commit comments