![]() |
Routines |
| Prev: 41316 | Up: Map | Next: 41345 |
|
Used by the routine at GetRoomPointer.
Multiplies the word in HL by the word in DE. GetRoomPointer uses it to multiply the current room number by 6 to find that room's record in Table_RoomMap.
|
||||||||||||||
| MultiplyWords | 41325 | PUSH BC | Stash BC on the stack. | |||||||||||
| 41326 | LD B,16 | B=16. | ||||||||||||
| 41328 | LD A,H | A=H. | ||||||||||||
| 41329 | LD C,L | C=L. | ||||||||||||
| 41330 | LD HL,0 | HL=0000. | ||||||||||||
| MultiplyWords_0 | 41333 | ADD HL,HL | HL+=HL. | |||||||||||
|
For each bit of the multiplier, shift it into the carry and add the multiplicand when that bit is set.
|
||||||||||||||
| 41334 | AND A | Fold the next multiplier bit into the product. | ||||||||||||
| 41335 | RL C | |||||||||||||
| 41337 | RLA | |||||||||||||
| 41338 | JR NC,MultiplyWords_1 | |||||||||||||
| 41340 | ADD HL,DE | |||||||||||||
| MultiplyWords_1 | 41341 | DJNZ MultiplyWords_0 | ||||||||||||
| 41343 | POP BC | Restore BC from the stack, leaving the product in HL. | ||||||||||||
| 41344 | RET | Return. | ||||||||||||
| Prev: 41316 | Up: Map | Next: 41345 |