Prev: 9BA9 Up: Map Next: 9BCA
9BB1: Locate Location
Input
A Location ID
Output
IX Pointer to location data
LocateLocation 9BB1 CP $50 If the location ID is less than 50 jump to LocateLocation_Action to process it.
9BB3 JR C,LocateLocation_Action
9BB5 XOR A Reset A to 00.
9BB6 RET Return.
Work out the location now A is validated as a legitimate location ID.
LocateLocation_Action 9BB7 PUSH DE Point at the location table.
9BB8 LD DE,$B9E0
9BBB PUSH HL Store offset in the HL register pair.
9BBC LD L,A
9BBD LD H,$00
Calculate Location address, some examples would be;
Location ID Sum Location Table Entry Location Data
$05 ($05*02) + $B9E0 B9EA BABC
$20 ($20*02) + $B9E0 BA20 BDAD
$33 ($33*02) + $B9E0 BA46 BF5E
9BBF ADD HL,HL Multiply the offset by 02 and add the table base.
9BC0 ADD HL,DE
9BC1 LD E,(HL) Read the low byte of the token.
9BC2 INC HL Step to the next letter.
9BC3 LD D,(HL) Read the high byte of the token.
9BC4 PUSH DE Copy DE into IX, restore HL and DE.
9BC5 POP IX
9BC7 POP HL
9BC8 POP DE
9BC9 RET Return.
View the equivalent code in;
Prev: 9BA9 Up: Map Next: 9BCA