Prev: A57C Up: Map Next: A59F
A57E: Turn a sprite position into an address in the buffer
Used by the routine at erase_old_draw_new.
The buffer holds the box bottom row first, each row the box's width: a position's byte is (x less the box's left edge) / 8, plus (the box's bottom line less y) rows.
Input
L x
H y
Output
HL The byte in the buffer, page $F8
buffer_address A57E LD A,(piece_x) The byte within the row
A581 LD C,A
A582 LD A,L
A583 SUB C
A584 SRL A
A586 SRL A
A588 SRL A
A58A LD L,A
A58B LD A,(piece_y) Add a row's width for each line above the box's bottom
A58E SUB H
A58F JR Z,buffer_address_1
A591 LD C,A
A592 LD A,(piece_dx)
A595 LD H,A
buffer_address_0 A596 LD A,L
A597 ADD A,H
A598 LD L,A
A599 DEC C
A59A JR NZ,buffer_address_0
buffer_address_1 A59C LD H,$F8
A59E RET
Prev: A57C Up: Map Next: A59F