Prev: 37395 Up: Map Next: 37444
37410: 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 37410 LD A,(IX+0) Fetch the sprite ID of the door.
37413 AND %00000011 Keep only bits 0-1.
37415 LD HL,37468 Point HL at the door key colours at DoorKeyColours.
37418 CALL AddAToHL Call AddAToHL to find the key that is needed in the table.
37421 LD D,(HL) Fetch the attribute of the key that is needed.
37422 LD E,129 E=129 (the sprite ID of the key).
37424 CALL FindInventoryItem Call FindInventoryItem to look for the key in the inventory.
37427 JP NZ,CheckDoorKey_NoKey Jump to CheckDoorKey_NoKey if the player does not have it.
37430 CALL OpenDoorway Call OpenDoorway to open the doorway.
37433 LD BC,4369 BC=4369 (the range of the door).
37436 JP CheckPlayerInRange Jump to CheckPlayerInRange to check whether the player is in range of the door.
CheckDoorKey_NoKey 37439 CALL CloseDoorway Call CloseDoorway to close the doorway.
37442 AND A Clear the carry flag.
37443 RET Return.
Prev: 37395 Up: Map Next: 37444