Prev: 9710 Up: Map Next: 9774
9731: Fall Through Trapdoor
Used by the routine at HandlerTrapOpen.
Used by HandlerTrapOpen for a trapdoor that is open. If the player is in range of the trapdoor (18 in each direction), the screen is cleared and the frame of room 96 is drawn. Then for 80 frames of rings of colour (see RippleAttributes) spread out from the centre of the screen, while the centre flashes and clicks are made. Then the player goes through the door with EnterDoor. If the player is not in range then the trapdoor is just shown by HandlerRoomItem.
Input
IX The trapdoor entity
FallThroughTrapdoor 9731 LD BC,$1818 BC=1818 (the range of the trapdoor).
9734 CALL CheckPlayerInRange Call CheckPlayerInRange to see whether the player is in range.
9737 JP NC,HandlerRoomItem Jump to HandlerRoomItem if the player is not.
973A CALL ClearPlayArea Call ClearPlayArea to clear the play area.
973D LD A,$96 A=96 (the room to draw the frame of).
973F PUSH IX Stash IX on the stack.
9741 CALL DrawRoomFrame_Room Call DrawRoomFrame_Room to draw the frame of the room.
9744 POP IX Restore IX from the stack.
9746 LD B,$80 B=80 (the number of frames to fall for, which also sets the pitch of the clicks).
FallThroughTrapdoor_Loop 9748 LD A,($5C78) Fetch FRAMES and keep FRAMES in C.
974B LD C,A
Make clicks until FRAMES has changed.
FallThroughTrapdoor_Wait 974C PUSH BC Stash the fall counter and FRAMES on the stack.
974D LD A,B Fetch the fall counter.
974E CPL Flip the bits of the fall counter.
974F LD B,A Keep the pitch of the click in B.
9750 CALL SoundsClick Call SoundsClick to make a click.
9753 POP BC Restore the fall counter and FRAMES from the stack.
9754 LD A,($5C78) Fetch FRAMES.
9757 CP C Jump to FallThroughTrapdoor_Wait if FRAMES has not changed.
9758 JR Z,FallThroughTrapdoor_Wait
Flash the centre of the screen on every eighth frame.
975A AND %00000111 Keep only bits 0-2.
975C LD A,$00 A=00 (the attribute for black).
975E JR NZ,FallThroughTrapdoor_Flash Jump to FallThroughTrapdoor_Flash if FRAMES is not a multiple of eight.
9760 LD A,$47 A=47 (the attribute for bright white ink on black).
FallThroughTrapdoor_Flash 9762 LD L,A Keep the attribute in L.
9763 LD H,A Keep the attribute in H.
9764 LD ($596B),HL Write the attribute to the two cells at 596B.
9767 LD ($598B),HL Write the attribute to the two cells at 598B.
976A PUSH BC Stash the fall counter on the stack.
976B CALL RippleAttributes Call RippleAttributes to spread the colours out.
976E POP BC Restore the fall counter from the stack.
976F DJNZ FallThroughTrapdoor_Loop Decrease the fall counter by one and loop back to FallThroughTrapdoor_Loop until the fall has finished.
9771 JP EnterDoor Jump to EnterDoor to enter the door.
Prev: 9710 Up: Map Next: 9774