ip_sprite_outer
pop ix
pop bc
pop hl
ret
Alors celle-ci est 39 octets et conserve hl :; INPUT :
; ix:sprite; b:height; c:width/8
; OUTPUT :
; ix=flipped sprite
; destroys a, de
; uses saferam3
flip_sprite:
push hl
push bc
push ix
pop de
ld hl,saferam3
push hl
flip_sprite_outer:
;de = original sprite
;hl = buffer
push bc ;save b (sprite height)
ld b,0 ;bc = width in bytes
add hl,bc ;go to very right of first sprite and draw leftward
push hl
ld b,8
flip_sprite_loop:
dec hl ;go left in buffer
push bc ;c gets overwritten so we need to save it
ld a,(de) ;first byte in a
rrca ;rotate a to the right and rotate the carry left into c
rl c
djnz $-3
ld (hl),c ;save flipped byte
inc de ;next byte of sprite
pop bc ;c = counter (number of bytes to flip)
dec c
jr nz,flip_sprite_loop
pop hl
pop bc ;restore b (height)
djnz fl
