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 80 jump to LocateLocation_Action to process it.
39859 JR C,LocateLocation_Action
39861 XOR A Reset A to 0.
39862 RET Return.
Work out the location now A is validated as a legitimate location ID.
LocateLocation_Action 39863 PUSH DE Point at the location table.
39864 LD DE,47584
39867 PUSH HL Store offset in the HL register pair.
39868 LD L,A
39869 LD H,0
Calculate Location address, some examples would be;
Location ID Sum Location Table Entry Location Data
005 (005*2) + 47584 47594 47804
032 (032*2) + 47584 47648 48557
051 (051*2) + 47584 47686 48990
39871 ADD HL,HL Multiply the offset by 2 and add the table base.
39872 ADD HL,DE
39873 LD E,(HL) Read the low byte of the token.
39874 INC HL Step to the next letter.
39875 LD D,(HL) Read the high byte of the token.
39876 PUSH DE Copy DE into IX, restore HL and DE.
39877 POP IX
39879 POP HL
39880 POP DE
39881 RET Return.
View the equivalent code in;
Prev: 39849 Up: Map Next: 39882