Prev: F107 Up: Map Next: F1E5
F1AF: 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 FF if the slot is empty
FindKeyAtPosition F1AF PUSH IX Stash IX on the stack.
F1B1 LD IX,($5BDA) Point IX at *ReferenceKeysAndLockedDoors.
F1B5 LD DE,$0006 DE=0006 (key entry length).
FindKeyAtPosition_ScanLoop F1B8 LD A,$FF Jump to Handler_Housekeeping if this key entry is the terminator (FF).
F1BA CP (IX+$00)
F1BD JP Z,Handler_Housekeeping
F1C0 LD A,C Jump to FindKeyAtPosition_NextKey if this is not the tested column.
F1C1 CP (IX+$00)
F1C4 JR NZ,FindKeyAtPosition_NextKey
F1C6 LD A,(IX+$01) A=the locked-door vertical.
F1C9 DEC A Move two rows up to the door's foot.
F1CA DEC A
F1CB CP B Jump to FindKeyAtPosition_NextKey if this is not the tested row.
F1CC JR NZ,FindKeyAtPosition_NextKey
F1CE LD A,(IX+$05) Test whether this key is still in the room.
F1D1 CP $00
F1D3 LD A,$FF A=FF (no key here).
F1D5 JP Z,Handler_Housekeeping Jump to Handler_Housekeeping if this key has already been taken.
F1D8 LD A,(IX+$04) A=this key's ID.
F1DB PUSH IX HL=IX (using the stack).
F1DD POP HL
F1DE POP IX Restore IX from the stack.
F1E0 RET Return.
FindKeyAtPosition_NextKey F1E1 ADD IX,DE Move IX on to the next key entry.
F1E3 JR FindKeyAtPosition_ScanLoop Jump to FindKeyAtPosition_ScanLoop.
Prev: F107 Up: Map Next: F1E5