![]() |
Routines |
| Prev: 41316 | Up: Map | Next: 41345 |
|
Used by the routine at GetRoomPointer.
HL=HL*DE. GetRoomPointer uses it to turn the current room number into an offset of 6 bytes per room in Table_RoomMap.
|
||||||||||||||
| MultiplyWords | 41325 | PUSH BC | Stash BC on the stack. | |||||||||||
| 41326 | LD B,16 | Count 16 bits. | ||||||||||||
| 41328 | LD A,H | Hold the first number in A and C. | ||||||||||||
| 41329 | LD C,L | |||||||||||||
| 41330 | LD HL,0 | HL=0000. | ||||||||||||
| MultiplyWords_Loop | 41333 | ADD HL,HL | Shift the running total left by one bit. | |||||||||||
|
Test the next bit of the first number. When it is set, add the second number into the total.
|
||||||||||||||
| 41334 | AND A | Clear the carry, then shift the next bit of the first number into it. Jump to MultiplyWords_Next when that bit is clear. | ||||||||||||
| 41335 | RL C | |||||||||||||
| 41337 | RLA | |||||||||||||
| 41338 | JR NC,MultiplyWords_Next | |||||||||||||
| 41340 | ADD HL,DE | Add the second number into the total. | ||||||||||||
| MultiplyWords_Next | 41341 | DJNZ MultiplyWords_Loop | Decrease the bit counter by one and loop back to MultiplyWords_Loop until the counter is zero. | |||||||||||
| 41343 | POP BC | Restore BC from the stack. | ||||||||||||
| 41344 | RET | Return. | ||||||||||||
| Prev: 41316 | Up: Map | Next: 41345 |