Prev: 54536 Up: Map Next: 54665
54628: Get Map Cell
Used by the routines at DrawView, DrawCell, DrawCellWithWalls, PlaceItems and PlaceMonsters.
Fetches the tile of a cell from Map, which is thirty-two rows of thirty-two. L is the column and H is the row. It sets CellColumn and CellRow. When bit 0 of ViewRotatedFlag 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 tile for the cell
F The zero flag is set if the cell is empty
Work out the number of the cell.
GetMapCell 54628 LD (48052),HL Set CellColumn and CellRow.
54631 LD A,L Put the column in A and the row in HL.
54632 LD L,H
54633 LD H,0
54635 ADD HL,HL Multiply the row by 32.
54636 ADD HL,HL
54637 ADD HL,HL
54638 ADD HL,HL
54639 ADD HL,HL
54640 OR L Add the column.
54641 LD L,A
Point at the map.
54642 LD BC,24068 Point BC at Map.
54645 LD A,(48058) Fetch ViewRotatedFlag.
54648 AND %00000001 Keep the lowest bit.
54650 JR Z,GetMapCell_Tile Jump to GetMapCell_Tile if the view is not rotated.
Read from the end.
54652 LD A,L Complement HL.
54653 CPL
54654 LD L,A
54655 LD A,H
54656 CPL
54657 LD H,A
54658 LD BC,25092 Point BC past Map.
Fetch the tile.
GetMapCell_Tile 54661 ADD HL,BC Add the address of the map.
54662 LD A,(HL) Fetch the tile and return.
54663 AND A
54664 RET
View the equivalent code in;
Prev: 54536 Up: Map Next: 54665