Prev: 41289 Up: Map Next: 41316
41301: Calculate Bit Address
Used by the routine at BuildFlagMask.
Divides the bit index in HL by 8.
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 41301 PUSH AF Stash AF on the stack.
41302 LD A,L Keep the bit number within the byte (bits 0-2 of the bit index) in C.
41303 AND %00000111
41305 LD C,A
41306 LD B,3 Count three right shifts.
CalculateBitAddress_Loop 41308 SRL H Shift HL right by one bit.
41310 RR L
41312 DJNZ CalculateBitAddress_Loop Decrease the counter by one and loop back to CalculateBitAddress_Loop until the counter is zero.
41314 POP AF Restore AF from the stack.
41315 RET Return.
Prev: 41289 Up: Map Next: 41316