Prev: C418 Up: Map Next: C556
C522: Flip Block Data
Used by the routines at DrawBlockRow and TestBlockRow_Draw.
Flips the data of a block horizontally, by reversing the bits of each byte with the table at F900 and swapping the bytes. The flag in bit 7 of the first byte is changed to record the flip. This version is for blocks that are 10 pixels wide.
Input
HL The address of the data of the block
IY The shape
The first byte of the tile is a flag. A row size other than 10 is flipped by FlipWideBlockData instead. The mirror of each byte is on page F9.
FlipBlockData C522 LD A,(HL) Read the tile's flag.
C523 XOR %10000000 Toggle its top bit.
C525 LD (HL),A Write the flag back.
C526 PUSH HL Remember the tile and move past the flag.
C527 INC HL
C528 PUSH DE Remember the addresses.
C529 PUSH BC
C52A LD A,(IY+$05) Read the row size.
C52D CP $10 The narrow flip is for a row size of 10.
C52F LD ($C550),SP Remember the stack pointer.
C533 JP NZ,FlipWideBlockData Flip a wide tile when the row size differs.
C536 LD A,(IY+$06) Read the tile through the stack. The count is the position byte.
C539 LD SP,HL
C53A LD H,$F9 Use the mirror table on page F9.
FlipBlockData_Loop C53C EX AF,AF' Remember how many rows remain.
C53D POP DE Mirror four bytes of the tile.
C53E POP BC
C53F LD L,E
C540 LD E,(HL)
C541 LD L,D
C542 LD D,(HL)
C543 LD L,C
C544 LD C,(HL)
C545 LD L,B
C546 LD B,(HL)
C547 PUSH DE
C548 PUSH BC
C549 POP DE
C54A POP DE
C54B EX AF,AF' Bring the count back.
C54C DEC A Repeat for the remaining rows.
C54D JR NZ,FlipBlockData_Loop
This entry point is used by the routine at FlipWideBlockData.
FlipBlockData_Exit C54F LD SP,$0000 Restore the stack pointer.
C552 POP BC Restore the saved registers.
C553 POP DE
C554 POP HL
C555 RET Return.
Prev: C418 Up: Map Next: C556