Prev: 50200 Up: Map Next: 50518
50466: 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 63744 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 16 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 16 is flipped by FlipWideBlockData instead. The mirror of each byte is on page 249.
FlipBlockData 50466 LD A,(HL) Read the tile's flag.
50467 XOR %10000000 Toggle its top bit.
50469 LD (HL),A Write the flag back.
50470 PUSH HL Remember the tile and move past the flag.
50471 INC HL
50472 PUSH DE Remember the addresses.
50473 PUSH BC
50474 LD A,(IY+5) Read the row size.
50477 CP 16 The narrow flip is for a row size of 16.
50479 LD (50512),SP Remember the stack pointer.
50483 JP NZ,FlipWideBlockData Flip a wide tile when the row size differs.
50486 LD A,(IY+6) Read the tile through the stack. The count is the position byte.
50489 LD SP,HL
50490 LD H,249 Use the mirror table on page 249.
FlipBlockData_Loop 50492 EX AF,AF' Remember how many rows remain.
50493 POP DE Mirror four bytes of the tile.
50494 POP BC
50495 LD L,E
50496 LD E,(HL)
50497 LD L,D
50498 LD D,(HL)
50499 LD L,C
50500 LD C,(HL)
50501 LD L,B
50502 LD B,(HL)
50503 PUSH DE
50504 PUSH BC
50505 POP DE
50506 POP DE
50507 EX AF,AF' Bring the count back.
50508 DEC A Repeat for the remaining rows.
50509 JR NZ,FlipBlockData_Loop
This entry point is used by the routine at FlipWideBlockData.
FlipBlockData_Exit 50511 LD SP,0 Restore the stack pointer.
50514 POP BC Restore the saved registers.
50515 POP DE
50516 POP HL
50517 RET Return.
Prev: 50200 Up: Map Next: 50518