Prev: 44019 Up: Map Next: 44073
44040: Find Cell Bit
Used by the routines at UpdateBeams and MarkCellDestroyed.
Finds the byte of the bitmap at CurrentPlayerState_MapCells and the bit within it for a cell of the planet. Each of the three bytes of the bitmap holds the bits for four zones of the map, and each zone has two bits: one for the left half and one for the right half.
Input
D Map zone
E Horizontal position
Output
HL Address of the byte
B The bit number multiplied by eight
FindCellBit 44040 LD HL,62954 The current player's map cells.
44043 LD A,D A=D.
44044 SUB 1 Subtract 1 from A.
44046 LD D,A D=A.
44047 AND %00001100 Keep the bits of A that are set in 12.
44049 SRL A Shift A right.
44051 SRL A Shift A right.
44053 CALL AddAToHL Call AddAToHL.
44056 LD A,D A=D.
44057 AND %00000011 Keep the bits of A that are set in 3.
44059 ADD A,A Double A.
44060 ADD A,A Double A.
44061 ADD A,A Double A.
44062 ADD A,A Double A.
44063 LD B,A B=A.
44064 LD A,E A=E.
44065 CP 48 Return if A is less than 48.
44067 RET C
44068 LD A,B A=B.
44069 ADD A,8 Add 8 to A.
44071 LD B,A B=A.
44072 RET Return.
Prev: 44019 Up: Map Next: 44073