Prev: EDDB Up: Map Next: EE30
EDF8: Open Trap Door
Used by the routine at ScriptRoutine_OpenTrapDoor.
Open the trap door: queue a sound, switch the lever graphic layout to open facing right, and update the related scenery entity types.
Open_TrapDoor EDF8 PUSH IX Stash IX, HL and DE on the stack.
EDFA PUSH HL
EDFB PUSH DE
EDFC CALL Check_EntitiesNearTrapDoor Call Check_EntitiesNearTrapDoor to check whether entities require the trap door to open.
EDFF JP NC,TrapDoor_RestoreAndReturn Jump to TrapDoor_RestoreAndReturn to continue if no open is required.
EE02 LD HL,$72B3 Point HL at the game event flags (GameEventFlags).
EE05 BIT 4,(HL) Is "task-two / upstairs event latch" (bit 04 of GameEventFlags) set? If so, jump to TrapDoor_RestoreAndReturn.
EE07 JR NZ,TrapDoor_RestoreAndReturn
EE09 SET 1,(HL) Set "trap door is open / trap door event armed" (bit 01 of GameEventFlags).
EE0B LD A,$05 Load A with sound index 05.
EE0D CALL Queue_Sound Call Queue_Sound to queue sound.
EE10 LD HL,$A7FA Point HL at the lever open, facing right (GraphicLayout_LeverOpenRight).
EE13 LD ($9177),HL Store HL in the lever layout pointer (Pointer_TrapDoorLayout).
EE16 LD HL,$EDC3 Point HL at the open-trap type list (Data_TrapDoorOpenTypes).
This entry point is used by the routine at Close_TrapDoor.
Rewrite 06 scenery entity types from the open/close type list starting at 8E87.
UpdateTrapDoorEntityTypes EE19 LD IX,$8E87 Point IX at the simple-entity slot at 8E87.
EE1D LD DE,$000E Load DE with 000E.
EE20 LD B,$06 Load B with loop count 06.
Write one type byte into the current trap door scenery slot and advance.
UpdateTrapDoorEntityTypes_WriteType EE22 LD A,(HL) Load A with the next type byte.
EE23 LD (IX+$00),A Write it to the entity.
EE26 INC HL Advance the trap door script pointer.
EE27 ADD IX,DE Advance IX to the next entity.
EE29 DJNZ UpdateTrapDoorEntityTypes_WriteType Decrease the loop counter in B and jump to UpdateTrapDoorEntityTypes_WriteType if more iterations remain.
This entry point is used by the routine at Close_TrapDoor.
Exit open/close trap door after updating scenery types (or early abort).
TrapDoor_RestoreAndReturn EE2B POP DE Restore DE, HL and IX from the stack.
EE2C POP HL
EE2D POP IX
EE2F RET Return.
Prev: EDDB Up: Map Next: EE30