Prev: D88D Up: Map Next: D8BF
D8A2: Mirror the sprite if its object wants it the other way round
Used by the routine at vflip_sprite_data.
Mirroring a row is two things at once: the order of its bytes is reversed, and so are the bits of each byte. The bytes of a row are pushed as mask and image pairs, each byte reversed through the table at reverse_bits_tbl on the way; popped off again they come back last first, and are written over the same row.
hflip_sprite_data D8A2 POP DE the header's bit 6 against the object's
D8A3 PUSH DE
D8A4 LD A,(DE)
D8A5 XOR (IX+$07)
D8A8 AND $40
D8AA JR Z,flip_done
D8AC LD A,(DE) toggle the header's bit; B and C = the width in bytes
D8AD XOR $40
D8AF LD (DE),A
D8B0 AND $0F
D8B2 LD B,A
D8B3 LD C,A
D8B4 INC DE the height into A'
D8B5 LD A,(DE)
D8B6 EX AF,AF'
D8B7 INC DE
D8B8 EX DE,HL HL' reads and HL writes, both from the first row; B' = $F1, the page of the bit-reversal table
D8B9 PUSH HL
D8BA EXX
D8BB POP HL
D8BC LD B,$F1
D8BE EXX
Prev: D88D Up: Map Next: D8BF