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 Stash DE on the stack.
9BB8 LD DE,$B9E0 DE=LocationTable
9BBB PUSH HL Stash HL on the stack.
9BBC LD L,A Store offset in the HL register pair.
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 HL=(HL * $02)+DE
9BC0 ADD HL,DE
9BC1 LD E,(HL) DE=the location from the pointer in HL.
9BC2 INC HL
9BC3 LD D,(HL)
9BC4 PUSH DE IX=DE using the stack.
9BC5 POP IX
9BC7 POP HL Restore HL and DE off the stack.
9BC8 POP DE
9BC9 RET Return.
Prev: 9BA9 Up: Map Next: 9BCA