![]() |
Routines |
| Prev: A164 | Up: Map | Next: A181 |
|
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 06 to find that room's record in Table_RoomMap.
|
||||||||||||||
| MultiplyWords | A16D | PUSH BC | Stash BC on the stack. | |||||||||||
| A16E | LD B,$10 | B=10. | ||||||||||||
| A170 | LD A,H | A=H. | ||||||||||||
| A171 | LD C,L | C=L. | ||||||||||||
| A172 | LD HL,$0000 | HL=0000. | ||||||||||||
| MultiplyWords_0 | A175 | 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.
|
||||||||||||||
| A176 | AND A | Fold the next multiplier bit into the product. | ||||||||||||
| A177 | RL C | |||||||||||||
| A179 | RLA | |||||||||||||
| A17A | JR NC,MultiplyWords_1 | |||||||||||||
| A17C | ADD HL,DE | |||||||||||||
| MultiplyWords_1 | A17D | DJNZ MultiplyWords_0 | ||||||||||||
| A17F | POP BC | Restore BC from the stack, leaving the product in HL. | ||||||||||||
| A180 | RET | Return. | ||||||||||||
| Prev: A164 | Up: Map | Next: A181 |