Prev: 9710 Up: Map Next: 97A9
9731: Fall through a trapdoor
Used by the routine at TRAPDOOR_CLOSED.
Reached only from the trapdoor's handler, TRAPDOOR, and only while the player is standing on it -- PLAYER_AT_DOOR with a tolerance of $1818. It draws room $96, which is not a room but the trapdoor fall's twelve nested rectangles (see the room types), then runs 128 times: each pass beeps a note whose pitch comes from the frame counter at $5C78 and walks down as the loop counts up, picks black or white from bit 3 of it, writes that into two cells of the attribute file and floods the rest outwards with SPIRAL_FILL. It ends in ENTER_ROOM, which takes the player to the trapdoor's other half -- the landing in the room below.
Never reached in any of the recorded playthroughs, which is why the code map left it as data until it was disassembled by hand.
TRAPDOOR_FALL 9731 LD BC,$1818
9734 CALL PLAYER_AT_DOOR
9737 JP NC,DRAW_DOOR
973A CALL CLEAR_PLAY_AREA
973D LD A,$96
973F PUSH IX
9741 CALL DRAW_ROOM_A
9744 POP IX
9746 LD B,$80
TRAPDOOR_FALL_0 9748 LD A,($5C78) The frame counter, so the pitch follows real time rather than a count of its own.
974B LD C,A
TRAPDOOR_FALL_1 974C PUSH BC
974D LD A,B
974E CPL
974F LD B,A
9750 CALL BEEP One cycle of BEEP with B complemented, which is what walks the pitch down as the loop counts up.
9753 POP BC
9754 LD A,($5C78)
9757 CP C
9758 JR Z,TRAPDOOR_FALL_1
975A AND $07 Low three bits of the counter all clear -- one frame in eight -- gives $47, white; otherwise $00, black.
975C LD A,$00
975E JR NZ,TRAPDOOR_FALL_2
9760 LD A,$47
TRAPDOOR_FALL_2 9762 LD L,A
9763 LD H,A
9764 LD ($596B),HL
9767 LD ($598B),HL
976A PUSH BC
976B CALL SPIRAL_FILL Flood the change outwards from the middle.
976E POP BC
976F DJNZ TRAPDOOR_FALL_0
9771 JP ENTER_ROOM Straight back into the main loop; there is no return.
SPIRAL_FILL 9774 LD BC,$170B
9777 LD HL,$5AE0 $5AE0 is the last row of the attribute file; the spiral is walked backwards from there.
977A LD DE,$0020
TRAPDOOR_FALL_3 977D PUSH HL
977E AND A
977F SBC HL,DE
9781 INC L
9782 LD A,(HL)
9783 POP HL
9784 PUSH BC
TRAPDOOR_FALL_4 9785 LD (HL),A
9786 INC L
9787 DJNZ TRAPDOOR_FALL_4
9789 POP BC
978A PUSH BC
TRAPDOOR_FALL_5 978B LD (HL),A
978C AND A
978D SBC HL,DE
978F DJNZ TRAPDOOR_FALL_5
9791 POP BC
9792 PUSH BC
TRAPDOOR_FALL_6 9793 LD (HL),A
9794 DEC L
9795 DJNZ TRAPDOOR_FALL_6
9797 POP BC
9798 PUSH BC
TRAPDOOR_FALL_7 9799 LD (HL),A
979A ADD HL,DE
979B DJNZ TRAPDOOR_FALL_7
979D LD (HL),A
979E AND A
979F SBC HL,DE
97A1 INC L
97A2 POP BC
97A3 DEC B Two rows and one column shorter each time round.
97A4 DEC B
97A5 DEC C
97A6 JR NZ,TRAPDOOR_FALL_3
97A8 RET
Prev: 9710 Up: Map Next: 97A9