@@ -4585,98 +4585,98 @@ d_18: ld bc,(ix-17)
45854585
45864586;-------------------------------------------------------------------------------
45874587gfx_FlipSpriteY:
4588- ; Flips an array horizontally about the center vertical axis
4588+ ; Flips a sprite horizontally about the center vertical axis
45894589; Arguments:
45904590; arg0 : Pointer to sprite struct input
45914591; arg1 : Pointer to sprite struct output
45924592; Returns:
45934593; arg1 : Pointer to sprite struct output
45944594 ld iy , 0
45954595 add iy , sp
4596- push ix
4597- ld ix , (iy + 3 )
4598- ld a , (ix + 0 ) ; a = width of sprite
4596+ ld de , (iy + 3 )
4597+ ld a , (de) ; a = width of sprite
4598+ inc .s bc ; clear UBC
4599+
45994600 sbc hl , hl
46004601 ld l , a
46014602 ld c , a
4602- push hl
4603- ld (.width) , a
4604- add hl , hl
4605- ld (.delta) , hl ; width*2
4606- ld a , (ix + 1 ) ; a = height of sprite
4607- pop hl
4608- lea de , ix + 2
4603+
4604+ inc de
4605+ ld a , (de) ; a = height of sprite
4606+
4607+ inc de
46094608 add hl , de
4610- ld ix , (iy + 6 )
4611- ld (ix + 1 ) , a ; store height to width
4612- ld (ix + 0 ) , c ; store width to height
4613- lea de , ix + 2 ; de -> sprite data
4614- ex ( sp ) , ix ; restore stack frame
4609+ ld de , (iy + 6 ) ; de -> sprite data
4610+ push de
4611+ inc de
4612+ ld (de) , a ; store height
4613+ ld iyh , a
4614+ ; inc de ; use the inc de inside the loop instead
46154615. loop :
4616- ld b , 0
4617- .width := $ - 1
4618- ld c , a
4616+ ld b , c ; width
46194617.pixelloop:
46204618 dec hl
4619+ inc de
46214620 ld a , (hl)
46224621 ld (de) , a ; store the new pixel data
4623- inc de
46244622 djnz .pixelloop
4625- ld a , c
4626- ld bc , 0
4627- .delta := $ - 3
4623+ ; hl += delta * 2
46284624 add hl , bc
4629- dec a
4625+ add hl , bc
4626+ dec iyh
46304627 jr nz , . loop
46314628 pop hl
4629+ ld (hl) , c ; store width (the loop preserves c)
46324630 ret
46334631
46344632;-------------------------------------------------------------------------------
46354633gfx_FlipSpriteX:
4636- ; Flip a sprite vertically about the center horizontal axis
4634+ ; Flips a sprite vertically about the center horizontal axis
46374635; Arguments:
46384636; arg0 : Pointer to sprite struct input
46394637; arg1 : Pointer to sprite struct output
46404638; Returns:
46414639; arg1 : Pointer to sprite struct output
4642- ld iy , 0
4643- add iy , sp
4644- push ix
4645- ld ix , (iy + 3 )
4646- xor a , a
4647- sub a , (ix + 0 )
4648- ld (.delta) , a
4649- neg
4650- ld (.width) , a
4651- ld l , (ix + 1 )
4652- ld c , l
4653- dec l
4654- ld h , a
4655- mlt hl
4656- lea de , ix + 2
4657- add hl , de
4658- ld ix , (iy + 6 )
4659- ld (ix + 0 ) , a
4660- ld (ix + 1 ) , c
4661- lea de , ix + 2
4662- push ix
4640+ ld iy , 6
4641+ lea hl , iy
4642+ ld c , l ; prevent underflow from ldi
4643+ add hl , sp
4644+ ld de , (hl)
4645+ push de ; return value
4646+ dec hl
4647+ dec hl
4648+ dec hl
4649+ ld hl , (hl)
4650+
4651+ xor a , a
4652+ ld b , (hl)
4653+ sub a , b
4654+ ld (.delta) , a
4655+ ld iyl , b ; (.width)
4656+ ldi ; copy width
4657+
4658+ ld a , (hl)
4659+ ld c , a
4660+ ldi ; copy height (and decrement C)
4661+
4662+ mlt bc
4663+ add hl , bc
46634664. loop :
4664- ld bc , 0
4665- .width := $ - 3
4665+ lea bc , iy ; (.width)
46664666 ldir
4667- ld bc ,- 1
4668- .delta := $ - 3
4669- add hl , bc
4670- add hl , bc
4667+ dec bc ; ld bc, -1
4668+ ld c , - 1
4669+ .delta := $ - 1
4670+ add hl , bc
4671+ add hl , bc
46714672 dec a
4672- jr nz , . loop
4673+ jr nz , .loop
46734674 pop hl
4674- pop ix
46754675 ret
46764676
46774677;-------------------------------------------------------------------------------
46784678gfx_RotateSpriteC:
4679- ; Rotates an array 90 degress clockwise
4679+ ; Rotates a sprite 90 degress clockwise
46804680; Arguments:
46814681; arg0 : Pointer to sprite struct input
46824682; arg1 : Pointer to sprite struct output
@@ -4757,29 +4757,33 @@ gfx_RotateSpriteCC:
47574757
47584758;-------------------------------------------------------------------------------
47594759gfx_RotateSpriteHalf:
4760- ; Rotates an array 180 degrees
4760+ ; Rotates a sprite 180 degrees
47614761; Arguments:
47624762; arg0 : Pointer to sprite struct input
47634763; arg1 : Pointer to sprite struct output
47644764; Returns:
47654765; arg1 : Pointer to sprite struct output
4766- ld iy , 0
4767- add iy , sp
4768- ld hl , (iy + 3 )
4769- ld c , (hl) ; c = width
4766+ ld hl , 6
4767+ add hl , sp
4768+ ld de , (hl) ; output sprite
4769+ dec hl
4770+ dec hl
4771+ dec hl
4772+ ld hl , (hl) ; input sprite
4773+ ld c , (hl) ; c = width
47704774 inc hl
4771- ld b , (hl) ; b = height
4772- ld iy , (iy + 6 )
4773- ld (iy + 0 ) , bc
4775+ ld b , (hl) ; b = height
4776+ ex de , hl
4777+ ld (hl) , bc
4778+ ex de , hl
47744779 mlt bc
4775- add hl , bc
4776- lea de , iy
4780+ add hl , bc
47774781 push de
47784782. loop :
47794783 inc de
47804784 inc de
47814785 ldd
4782- jp pe , . loop
4786+ jp pe , .loop
47834787 pop hl
47844788 ret
47854789
0 commit comments