Prev: E4DF Up: Map Next: E556
E53A: The buffer address of a pixel position
Used by the routines at PUT_EDGE, PUT_TILE and DRAW_SPRITE.
The buffer's rows are 24 bytes, row 0 the play area's bottom line at y 72, and x 16 the start of a row, so a position's byte is at BUFFER plus (y - 72) * 24 plus x / 8 - 2. It is worked here as y * 24 plus x / 8 plus a constant, the buffer's start less 72 rows and 2 bytes -- which happens to be an address in the code, and means nothing as one. Used by the drawing of sprites (DRAW_SPRITE) and of the town's tiles (PUT_EDGE, PUT_TILE).
Input
L x
H y
Output
HL The address in the buffer
BUFFER_ADDRESS E53A PUSH BC A = the byte's column, x / 8
E53B SRL L
E53D SRL L
E53F SRL L
E541 LD A,L
E542 LD L,H HL = y times 24
E543 LD H,$00
E545 ADD HL,HL
E546 ADD HL,HL
E547 ADD HL,HL
E548 LD C,L
E549 LD B,H
E54A ADD HL,HL
E54B ADD HL,BC
E54C LD C,A Plus the column
E54D LD B,$00
E54F ADD HL,BC
E550 LD BC,$DF02 Plus the buffer's start less 72 rows and 2 bytes
E553 ADD HL,BC
E554 POP BC
E555 RET
Prev: E4DF Up: Map Next: E556