Prev: 39849 Up: Map Next: 39882
39857: Locate Location
Input
A Location ID
Output
IX Pointer to location data
LocateLocation 39857 CP 80 If the location ID is less than $50 jump to LocateLocation_Action to process it.
39859 JR C,LocateLocation_Action
39861 XOR A Reset A to $00.
39862 RET Return.
Work out the location now A is validated as a legitimate location ID.
LocateLocation_Action 39863 PUSH DE Stash DE on the stack.
39864 LD DE,47584 DE=LocationTable
39867 PUSH HL Stash HL on the stack.
39868 LD L,A Store offset in the HL register pair.
39869 LD H,0
Calculate Location address, some examples would be;
Location ID Sum Location Table Entry Location Data
005 (005 * $02) + 47584 47594 47804
032 (032 * $02) + 47584 47648 48557
051 (051 * $02) + 47584 47686 48990
39871 ADD HL,HL HL=(HL * $02)+DE
39872 ADD HL,DE
39873 LD E,(HL) DE=the location from the pointer in HL.
39874 INC HL
39875 LD D,(HL)
39876 PUSH DE IX=DE using the stack.
39877 POP IX
39879 POP HL Restore HL and DE off the stack.
39880 POP DE
39881 RET Return.
Prev: 39849 Up: Map Next: 39882