Prev: A149 Up: Map Next: A164
A155: Calculate Bit Address
Used by the routine at BuildFlagMask.
Divides the bit index in HL by 08.
The byte offset is left in HL and the bit number in C.
Input
HL Bit index
Output
HL Byte offset
C Bit number within the byte
CalculateBitAddress A155 PUSH AF Stash AF on the stack.
A156 LD A,L Keep the bit number within the byte (bits 0-2 of the bit index) in C.
A157 AND %00000111
A159 LD C,A
A15A LD B,$03 Divide the bit index in HL by eight (three passes, counted in B) to give the offset of the byte holding the flag.
CalculateBitAddress_0 A15C SRL H
A15E RR L
A160 DJNZ CalculateBitAddress_0
A162 POP AF Restore AF from the stack.
A163 RET Return.
Prev: A149 Up: Map Next: A164