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 Count three right shifts.
CalculateBitAddress_Loop A15C SRL H Shift HL right by one bit.
A15E RR L
A160 DJNZ CalculateBitAddress_Loop Decrease the counter by one and loop back to CalculateBitAddress_Loop until the counter is zero.
A162 POP AF Restore AF from the stack.
A163 RET Return.
Prev: A149 Up: Map Next: A164