Prev: 50002 Up: Map Next: 50051
50034: Convert Cell
Used by the routines at DrawTown and FindObjectsInCell.
Converts the column and the row of a cell between the map and the view. They are the same unless the view is rotated by a half turn, when each is replaced by fifteen minus itself, so that cell (x, y) on the map of sixteen by sixteen is (fifteen minus x, fifteen minus y) in the view. It does nothing when the view is not rotated.
Input
L The column
H The row
Output
L The column to use
H The row to use
Return if the view is not rotated.
ConvertCell 50034 LD A,(41576) Fetch ViewRotation.
50037 AND %00000001 Keep the bit which says that the view is rotated.
50039 RET Z Return if it is not.
Replace the column with fifteen minus the column.
50040 LD A,L Invert the column.
50041 CPL
50042 AND %00001111 Keep the low four bits, which is fifteen minus the column.
50044 LD L,A Set the column.
Replace the row with fifteen minus the row.
50045 LD A,H Invert the row.
50046 CPL
50047 AND %00001111 Keep the low four bits, which is fifteen minus the row.
50049 LD H,A Set the row.
50050 RET Return.
View the equivalent code in;
Prev: 50002 Up: Map Next: 50051