Prev: 915F Up: Map Next: 91BC
917D: Handle Door Closed
The handler for the doors that are closed (sprite IDs 20 and 22 in HandlerTable2) and that open after a time, as made by RandomiseDoors. This is the same as HandlerDoorOpen, except that the door is shown (see HandlerRoomItem) instead of being used as an exit, there is no check for the player being in a doorway, and HandlerDoor_Toggle opens the door.
Input
IX The door entity
HandlerDoorClosed 917D LD A,($5E12) Fetch the counter from CounterLow.
9180 AND %00000001 Keep only bit 0.
9182 JP NZ,HandlerRoomItem Jump to HandlerRoomItem on every other frame.
9185 LD A,($5E2E) Fetch the door timer from DoorTimer.
9188 AND A Test whether the door timer is zero.
9189 JP Z,HandlerDoor_Toggle Jump to HandlerDoor_Toggle if it is.
918C DEC A Decrease the door timer by one.
918D LD ($5E2E),A Update the door timer in DoorTimer.
9190 JP HandlerRoomItem Jump to HandlerRoomItem to handle a room item that does nothing.
This entry point is used by the routine at HandlerDoorOpen.
Restart the door timer, and change both halves of the door from open to closed or the other way round. The door is erased and drawn again with a temporary attribute.
HandlerDoor_Toggle 9193 LD A,$5E Restart the door timer by writing 5E to DoorTimer.
9195 LD ($5E2E),A
9198 LD A,(IX+$05) Fetch the attribute of the door.
919B PUSH AF Stash it on the stack.
919C OR %00000011 Set bits 0-1, which is temporary.
919E LD (IX+$05),A Update the attribute of the door.
91A1 CALL DrawItemGraphic Call DrawItemGraphic to erase the door.
91A4 LD A,(IX+$00) Fetch the sprite ID of the door.
91A7 XOR %00000001 Flip bit 0, which changes the door from open to closed or the other way round.
91A9 CALL SetDoorSprites Call SetDoorSprites to write A to both halves of the door.
91AC CALL DrawItemGraphic Call DrawItemGraphic to draw the door.
91AF POP AF Restore the attribute of the door from the stack.
91B0 LD (IX+$05),A Write it to the attribute of the door.
91B3 CALL UpdateDoorway Call UpdateDoorway to set whether the doorway can be used.
91B6 CALL HandlerRoomItem Call HandlerRoomItem to handle a room item that does nothing.
91B9 JP SoundsDoor Jump to SoundsDoor to make the sound of a door.
Prev: 915F Up: Map Next: 91BC