Prev: BF85 Up: Map Next: BFE3
BFB8: Choose the mirrored drawer for a sprite when the ship faces left
Used by the routines at draw_carried_piece and draw_ship_image.
The drawing half of mirror_ship_sprite: when the ship faces left (bit 7 of its facing byte, ship_facing) the image is drawn mirrored. The mirrored drawers (direct_draw_row_mirrored on, beside the plain ones that draw_direct_pair jumps into) work from right to left and look each byte up in the bit-reversal table that build_bit_reverse builds at the start (page $F9), through BC with B the table's page. So this moves L to the last byte of the row and picks the mirrored drawer for the width. Facing right, it returns with IX as the caller left it.
Input
L The low byte of the screen address of the image's first row (its left end)
IX The plain drawer the caller chose
Output
IX The drawer to use: the mirrored one for a width of 6, 5, 4, or anything less
B $F9 when mirrored: the bit-reversal table's page
set_mirrored_drawer BFB8 LD A,(ship_facing) Facing right: keep the plain drawer.
BFBB BIT 7,A
BFBD RET Z
BFBE LD B,$F9 B is the page of the bit-reversal table (build_bit_reverse), for the mirrored drawer's LD A,(BC).
BFC0 LD A,(sprite_width_drawn) Start at the right-hand byte of the row: L plus the new width (sprite_width_drawn) less one.
BFC3 DEC A
BFC4 ADD A,L
BFC5 LD L,A
BFC6 LD A,(sprite_width_drawn) The mirrored drawer for the width: each is entered further in for a narrower image, as the plain ones are.
BFC9 LD IX,direct_draw_row_mirrored
BFCD CP $06
BFCF RET Z
BFD0 LD IX,mirrored_draw_five
BFD4 CP $05
BFD6 RET Z
BFD7 LD IX,mirrored_draw_four
BFDB CP $04
BFDD RET Z
BFDE LD IX,mirrored_draw_three
BFE2 RET
Prev: BF85 Up: Map Next: BFE3