Prev: C6DC Up: Map Next: C75C
C738: Get Map Cell
Fetches the code of a cell from TownMap, which is sixteen rows of sixteen. L is the column and H is the row. It sets CellColumn and CellRow. When bit 0 of ViewRotation is set, the map is read from the end.
Input
HL The cell: the column in L and the row in H
Output
A The code for the cell
F The zero flag is set if the cell is empty
Work out the number of the cell.
GetMapCell C738 LD ($A254),HL Set CellColumn and CellRow.
C73B LD A,L Put the column in A and the row in HL.
C73C LD L,H
C73D LD H,$00
C73F ADD HL,HL Multiply the row by 10.
C740 ADD HL,HL
C741 ADD HL,HL
C742 ADD HL,HL
C743 OR L Add the column.
C744 LD L,A
Point at the map.
C745 LD BC,$5FB1 Point BC at TownMap.
C748 LD A,($A268) Fetch ViewRotation.
C74B AND %00000001 Keep the lowest bit.
C74D JR Z,GetMapCell_Fetch Jump to GetMapCell_Fetch if the view is not rotated.
Read from the end.
C74F LD A,L Complement HL.
C750 CPL
C751 LD L,A
C752 LD A,H
C753 CPL
C754 LD H,A
C755 LD BC,$60B1 Point BC one past TownMap.
Fetch the code.
GetMapCell_Fetch C758 ADD HL,BC Add the address of the map.
C759 LD A,(HL) Fetch the code and return.
C75A AND A
C75B RET
View the equivalent code in;
Prev: C6DC Up: Map Next: C75C