A86: Re: Mirror Sprites
[Prev][Next][Index][Thread]
A86: Re: Mirror Sprites
By mirror, I assume you mean horizontally reverse, so you don't have to draw
both left and right versions, only left. The first routine is the first one
I wrote, using index registers. I decided to try again without using them,
using a zero-cost loop and it turns out to be smaller and much faster.
Since I didn't test 'em, they could have bugs...
; NOT TESTED!
; ix = pointer to sprite
; 34 bytes / 119 t-states for inner loop
MirrorSprite:
ld c,16 ; number of bytes high
MirrorSpriteLoop:
ld d,(ix+0)
ld e,(ix+1)
ld b,8
MirrorSpriteFlip:
rl d
rr l
rl e
rr h
djnz MirrorSpriteFlip
ld (ix+0),h
ld (ix+1),l
inc ix
inc ix
dec c
jr nz,MirrorSpriteLoop
ret
; NOT TESTED!
; hl = pointer to sprite
; 31 bytes / 95 t-states for inner loop
MirrorSprite:
ld a,16 ; number of bytes high
MirrorSpriteLoop:
ld (_@MirrorSpriteLoopC),a
ld d,(hl)
inc hl
ld e,(hl)
ld b,8
MirrorSpriteFlip:
rl d
rr c
rl e
rr a
djnz MirrorSpriteFlip
dec hl
ld (hl),a
inc hl
ld (hl),c
inc hl
_@MirrorSpriteLoopC =$+1
ld a,0
dec a
jr nz,MirrorSpriteLoop
ret
>
> What would be the easiest way to 'mirror' a 16x16 sprite?
>
> Thx,
> Dave
>
>
>
mirrorspr.asm
Follow-Ups:
References: