Prev: 61703 Up: Map Next: 61925
61871: Find Key At Position
Used by the routines at Handler_Player and Handler_Pirates.
Walks ReferenceKeysAndLockedDoors looking for a key or locked door at BC.
Input
B Vertical position
C Horizontal position
Output
A Key ID, or 255 if the slot is empty
FindKeyAtPosition 61871 PUSH IX Stash IX on the stack.
61873 LD IX,(23514) Point IX at *ReferenceKeysAndLockedDoors.
61877 LD DE,6 DE=0006 (key entry length).
FindKeyAtPosition_ScanLoop 61880 LD A,255 Jump to Handler_Housekeeping if this key entry is the terminator (255).
61882 CP (IX+0)
61885 JP Z,Handler_Housekeeping
61888 LD A,C Jump to FindKeyAtPosition_NextKey if this is not the tested column.
61889 CP (IX+0)
61892 JR NZ,FindKeyAtPosition_NextKey
61894 LD A,(IX+1) A=the locked-door vertical.
61897 DEC A Move two rows up to the door's foot.
61898 DEC A
61899 CP B Jump to FindKeyAtPosition_NextKey if this is not the tested row.
61900 JR NZ,FindKeyAtPosition_NextKey
61902 LD A,(IX+5) Test whether this key is still in the room.
61905 CP 0
61907 LD A,255 A=255 (no key here).
61909 JP Z,Handler_Housekeeping Jump to Handler_Housekeeping if this key has already been taken.
61912 LD A,(IX+4) A=this key's ID.
61915 PUSH IX HL=IX (using the stack).
61917 POP HL
61918 POP IX Restore IX from the stack.
61920 RET Return.
FindKeyAtPosition_NextKey 61921 ADD IX,DE Move IX on to the next key entry.
61923 JR FindKeyAtPosition_ScanLoop Jump to FindKeyAtPosition_ScanLoop.
Prev: 61703 Up: Map Next: 61925