Prev: 9147 Up: Map Next: 917D
915F: Handle Door Open
The handler for the doors that are open (sprite IDs 21 and 23 in HandlerTable2) and that close after a time, as made by RandomiseDoors. On every other frame (when bit 0 of CounterLow is reset) the door timer at DoorTimer is counted down. When it has reached zero, and the player is not in a doorway (see CheckDoorway), HandlerDoor_Toggle closes the door. Otherwise the door is just checked for being used as an exit (see HandlerDoorExit).
Input
IX The door entity
HandlerDoorOpen 915F LD A,($5E12) Fetch the counter from CounterLow.
9162 AND %00000001 Keep only bit 0.
9164 JP NZ,HandlerDoorExit Jump to HandlerDoorExit on every other frame.
9167 LD A,($5E2E) Fetch the door timer from DoorTimer.
916A AND A Test whether the door timer is zero.
916B JR Z,HandlerDoorOpen_CheckDoorway Jump to HandlerDoorOpen_CheckDoorway if it is.
916D DEC A Decrease the door timer by one.
916E LD ($5E2E),A Update the door timer in DoorTimer.
9171 JP HandlerDoorExit Jump to HandlerDoorExit to handle the exit of the door.
HandlerDoorOpen_CheckDoorway 9174 LD A,($5E2D) Fetch the doorway flag from InDoorway.
9177 AND A Test whether the player is in a doorway.
9178 JP NZ,HandlerDoorExit Jump to HandlerDoorExit if the player is.
917B JR HandlerDoor_Toggle Jump to HandlerDoor_Toggle to restart the door timer and toggle both halves of the door.
Prev: 9147 Up: Map Next: 917D