Prev: 37215 Up: Map Next: 37308
37245: Handle Door Closed
The handler for the doors that are closed (sprite IDs 32 and 34 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 37245 LD A,(24082) Fetch the counter from CounterLow.
37248 AND %00000001 Keep only bit 0.
37250 JP NZ,HandlerRoomItem Jump to HandlerRoomItem on every other frame.
37253 LD A,(24110) Fetch the door timer from DoorTimer.
37256 AND A Test whether the door timer is zero.
37257 JP Z,HandlerDoor_Toggle Jump to HandlerDoor_Toggle if it is.
37260 DEC A Decrease the door timer by one.
37261 LD (24110),A Update the door timer in DoorTimer.
37264 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 37267 LD A,94 Restart the door timer by writing 94 to DoorTimer.
37269 LD (24110),A
37272 LD A,(IX+5) Fetch the attribute of the door.
37275 PUSH AF Stash it on the stack.
37276 OR %00000011 Set bits 0-1, which is temporary.
37278 LD (IX+5),A Update the attribute of the door.
37281 CALL DrawItemGraphic Call DrawItemGraphic to erase the door.
37284 LD A,(IX+0) Fetch the sprite ID of the door.
37287 XOR %00000001 Flip bit 0, which changes the door from open to closed or the other way round.
37289 CALL SetDoorSprites Call SetDoorSprites to write A to both halves of the door.
37292 CALL DrawItemGraphic Call DrawItemGraphic to draw the door.
37295 POP AF Restore the attribute of the door from the stack.
37296 LD (IX+5),A Write it to the attribute of the door.
37299 CALL UpdateDoorway Call UpdateDoorway to set whether the doorway can be used.
37302 CALL HandlerRoomItem Call HandlerRoomItem to handle a room item that does nothing.
37305 JP SoundsDoor Jump to SoundsDoor to make the sound of a door.
Prev: 37215 Up: Map Next: 37308