Prev: ABF3 Up: Map Next: AC29
AC08: 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 AC08 LD HL,$F5EA The current player's map cells.
AC0B LD A,D A=D.
AC0C SUB $01 Subtract 01 from A.
AC0E LD D,A D=A.
AC0F AND %00001100 Keep the bits of A that are set in 0C.
AC11 SRL A Shift A right.
AC13 SRL A Shift A right.
AC15 CALL AddAToHL Call AddAToHL.
AC18 LD A,D A=D.
AC19 AND %00000011 Keep the bits of A that are set in 03.
AC1B ADD A,A Double A.
AC1C ADD A,A Double A.
AC1D ADD A,A Double A.
AC1E ADD A,A Double A.
AC1F LD B,A B=A.
AC20 LD A,E A=E.
AC21 CP $30 Return if A is less than 30.
AC23 RET C
AC24 LD A,B A=B.
AC25 ADD A,$08 Add 08 to A.
AC27 LD B,A B=A.
AC28 RET Return.
Prev: ABF3 Up: Map Next: AC29