Prev: AFAE Up: Map Next: AFDD
AFC2: Flip pattern horizontally
Take a pattern pointed to by pattern_address and flip it horizontally (mirrored). Returns address of result in pattern_address. Used by the routine at upload_sprite_patterns.
flip_horizontal AFC2 LD DE,(pattern_address) DE = source address
AFC6 LD HL,$0008 HL = destination address
AFC9 ADD HL,DE ...
AFCA LD (pattern_address),HL Store destination
AFCD EX DE,HL HL = source, DE = destination
AFCE LD B,$08 8 bytes in pattern
flip_horizontal_0 AFD0 LD A,$80 Result starts with 10000000
flip_horizontal_1 AFD2 RL (HL) Shift source byte left, bit 7 to carry
AFD4 RRA Shift right, carry to bit 7, bit 0 to carry
AFD5 JR NC,flip_horizontal_1 Repeat until bit 7 reaches carry (8 times)
AFD7 LD (DE),A Store result
AFD8 INC DE Next destination
AFD9 INC HL Next source
AFDA DJNZ flip_horizontal_0 Repeat 8 times
AFDC RET
Prev: AFAE Up: Map Next: AFDD