Prev: 9213 Up: Map Next: 9244
9222: Check Door Key
Used by the routines at HandlerDoorLocked and HandlerCaveDoorLocked.
Checks whether the player has the key for a locked door. The colour of the key that is needed is found in DoorKeyColours using bits 0-1 of the sprite ID of the door. If the player has it, then the doorway is opened by OpenDoorway and the player is checked for being in range of the door by CheckPlayerInRange. If the player does not have the key then the doorway is closed by CloseDoorway.
Input
IX The locked door entity
Output
F The carry flag is set if the player has the key and is in range
CheckDoorKey 9222 LD A,(IX+$00) Fetch the sprite ID of the door.
9225 AND %00000011 Keep only bits 0-1.
9227 LD HL,$925C Point HL at the door key colours at DoorKeyColours.
922A CALL AddAToHL Call AddAToHL to find the key that is needed in the table.
922D LD D,(HL) Fetch the attribute of the key that is needed.
922E LD E,$81 E=81 (the sprite ID of the key).
9230 CALL FindInventoryItem Call FindInventoryItem to look for the key in the inventory.
9233 JP NZ,CheckDoorKey_NoKey Jump to CheckDoorKey_NoKey if the player does not have it.
9236 CALL OpenDoorway Call OpenDoorway to open the doorway.
9239 LD BC,$1111 BC=1111 (the range of the door).
923C JP CheckPlayerInRange Jump to CheckPlayerInRange to check whether the player is in range of the door.
CheckDoorKey_NoKey 923F CALL CloseDoorway Call CloseDoorway to close the doorway.
9242 AND A Clear the carry flag.
9243 RET Return.
Prev: 9213 Up: Map Next: 9244