Prev: D508 Up: Map Next: D589
D564: The type of a cell of the town
Reads a cell from the map (TOWN, 32 rows of 32 bytes) and keeps its column and row in CELL_LOOKED_UP for PROJECT_CELL. The cell comes in the view's terms: with the town turned round the offset into the map is complemented and added to the address one past its end, which reads the map backwards from its last byte -- the same as turning the cell round with TURN_CELL. The listing would otherwise call that address DRAW_ORDER, the table that follows the map.
Input
L the column
H the row
Output
A the cell's type: 0 open ground, 1 and 2 solid, 3 up built on
F Z for open ground
LOOK_UP_CELL D564 LD (CELL_LOOKED_UP),HL Kept for the projection
D567 LD A,L HL = the row times 32, plus the column
D568 LD L,H
D569 LD H,$00
D56B ADD HL,HL
D56C ADD HL,HL
D56D ADD HL,HL
D56E ADD HL,HL
D56F ADD HL,HL
D570 OR L
D571 LD L,A
D572 LD BC,TOWN Turned round?
D575 LD A,(VIEW)
D578 AND $01
D57A JR Z,LOOK_UP_CELL_0
D57C LD A,L The offset complemented, from one past the map's end: the map read backwards
D57D CPL
D57E LD L,A
D57F LD A,H
D580 CPL
D581 LD H,A
D582 LD BC,DRAW_ORDER
LOOK_UP_CELL_0 D585 ADD HL,BC The type; Z if open
D586 LD A,(HL)
D587 AND A
D588 RET
Prev: D508 Up: Map Next: D589