Prev: 989F Up: Map Next: 98CC
98B2: Find World Map Address
Works out the address in the World_Map world map of the entry for the room that the object at IX is in. The address is 7000 plus 20 times the room y plus twice the room x.
The multiplication of the room y by 20 is done as a multiplication of the low three bits of the room y by 20 plus 0100 times the rest of the room y.
Input
IX Object record
Output
HL Address of the world map entry
Find_World_Map_Address 98B2 PUSH BC Stash BC on the stack.
98B3 LD H,(IX+$04) Fetch the room y of the object into H.
98B6 XOR A Start the offset at zero.
98B7 SRL H Move bit 0 of the room y into A.
98B9 RRA
98BA SRL H Move bit 1 of the room y into A.
98BC RRA
98BD SRL H Move bit 2 of the room y into A. (A is now 20 times the low three bits.)
98BF RRA
98C0 LD L,(IX+$02) Fetch the room x of the object into L.
98C3 ADD A,L Add the room x to A.
98C4 ADD A,L Add the room x to A again, to make twice the room x.
98C5 LD L,A Store the low byte of the offset in L.
98C6 LD BC,$7000 Point at the world map (World_Map).
98C9 ADD HL,BC Add the address of the world map to the offset.
98CA POP BC Restore BC from the stack.
98CB RET Return.
Prev: 989F Up: Map Next: 98CC