Prev: 9A50 Up: Map Next: 9A9D
9A92: Turn a byte back to front
Used by the routines at BLIT_SPRITE_MIRRORED and BLIT_SPRITE_FLIPPED.
Eight rotations: each one shifts a bit off the top of A into the carry and back into the bottom of C, so C ends up holding A's bits in the opposite order. That is a sprite byte mirrored, and mirroring every byte of a row while reading the row's bytes backwards mirrors the whole sprite.
It is what saves the game from storing anything twice. A creature facing left and the same creature facing right are one set of bytes and a different drawing routine.
Input
A The byte
A On exit, the same bits in reverse
REVERSE_BITS 9A92 PUSH BC Eight bits to move.
9A93 LD B,$08
REVERSE_BITS_0 9A95 RLA Off the top of A, into the bottom of C.
9A96 RR C
9A98 DJNZ REVERSE_BITS_0
9A9A LD A,C C now holds it reversed.
9A9B POP BC
9A9C RET
Prev: 9A50 Up: Map Next: 9A9D