Prev: D892 Up: Map Next: D97E
D894: Level Complete
Used by the routine at Handler_IsLevelComplete.
LevelComplete D894 LD HL,$D83A HL=Time.
D897 RES 0,(HL) Reset bit 0 of *HL.
D899 LD HL,$D839 HL=D839.
D89C SET 7,(HL) Set bit 7 of *HL.
D89E CALL Colourise_PreviewGrid Call Colourise_PreviewGrid.
D8A1 LD HL,$5825 HL=5825 (attribute buffer location).
D8A4 LD B,$04 B=04.
LevelComplete_0 D8A6 PUSH BC Stash BC on the stack.
D8A7 LD B,$10 B=10.
LevelComplete_1 D8A9 LD (HL),$00 Write 00 to *HL.
D8AB INC HL Increment HL by one.
D8AC DJNZ LevelComplete_1 Decrease counter by one and loop back to LevelComplete_1 until counter is zero.
D8AE LD DE,$0010 HL+=0010.
D8B1 ADD HL,DE
D8B2 POP BC Restore BC from the stack.
D8B3 DJNZ LevelComplete_0 Decrease counter by one and loop back to LevelComplete_0 until counter is zero.
D8B5 LD BC,$00FA BC=00FA.
D8B8 DI Disable interrupts.
LevelComplete_2 D8B9 LD D,$0E D=0E.
D8BB LD A,$05 A=05.
LevelComplete_3 D8BD OUT ($FE),A Send to the speaker.
D8BF XOR %00010000 Flip bit 4.
D8C1 LD E,C E=C.
LevelComplete_4 D8C2 DEC E Decrease E by one.
D8C3 JR NZ,LevelComplete_4 Jump to LevelComplete_4 if E is not zero.
D8C5 DEC D Decrease D by one.
D8C6 JR NZ,LevelComplete_3 Jump to LevelComplete_3 if D is not zero.
D8C8 DEC BC Decrease BC by one.
D8C9 LD A,B Jump to LevelComplete_2 if BC is not zero.
D8CA OR C
D8CB JR NZ,LevelComplete_2
D8CD EI Enable interrupts.
D8CE CALL ExtraLife Call ExtraLife.
D8D1 LD B,$64 B=64.
LevelComplete_5 D8D3 HALT Halt operation (suspend CPU until the next interrupt).
D8D4 DJNZ LevelComplete_5 Decrease counter by one and loop back to LevelComplete_5 until counter is zero.
D8D6 DI Disable interrupts.
D8D7 LD HL,$D83A HL=Time.
D8DA LD (HL),$80 Write 80 to *HL.
LevelComplete_6 D8DC CALL $FC6D Call FC6D.
D8DF LD A,($D85E) A=*TimeBar_Length.
D8E2 INC A Increment A by one.
D8E3 LD D,A D=A.
D8E4 LD E,$7D E=7D.
D8E6 LD H,$01 H=01.
LevelComplete_7 D8E8 LD A,(HL) A=*HL.
D8E9 AND %00011000 Keep only bits 3-4.
D8EB OR %00000101 Set bits 0, 2.
D8ED OUT ($FE),A Set border to the colour held by A.
D8EF INC HL Increment HL by one.
D8F0 LD B,D B=D.
LevelComplete_8 D8F1 DJNZ LevelComplete_8 Decrease counter by one and loop back to LevelComplete_8 until counter is zero.
D8F3 DEC E Decrease E by one.
D8F4 JP NZ,LevelComplete_7 Jump to LevelComplete_7 if E is not zero.
D8F7 LD HL,$D83A HL=Time.
D8FA BIT 4,(HL) Test bit 4 of *HL.
D8FC JR NZ,LevelComplete_10 Jump to LevelComplete_10 if E is not zero.
D8FE LD A,($D840) A=*D840.
D901 AND A Set flags.
D902 INC A Increment A by one.
D903 DAA DAA.
D904 LD ($D840),A Write A to *D840.
D907 JR NC,LevelComplete_9 Jump to LevelComplete_9 if A is higher.
D909 LD A,($D83F) A=*D83F.
D90C CCF Invert the carry flag.
D90D INC A Increment A by one.
D90E DAA DAA.
D90F LD ($D83F),A Write A to *D83F.
LevelComplete_9 D912 CALL Print_Bonus Call Print_Bonus.
D915 JP LevelComplete_6 Jump to LevelComplete_6.
LevelComplete_10 D918 LD HL,$D841 HL=D841.
D91B LD A,($D876) A=*Score_Digit_03.
D91E AND A Set flags.
D91F ADD A,(HL) A+=*HL.
D920 DAA DAA.
D921 LD ($D876),A Write A to *Score_Digit_03.
D924 LD (HL),$00 Write 00 to *HL.
D926 DEC HL Decrease HL by one.
D927 LD A,($D875) A=*Score_Digit_02.
D92A ADC A,(HL) A+=*HL.
D92B DAA DAA.
D92C LD ($D875),A Write A to *Score_Digit_02.
D92F LD (HL),$00 Write 00 to *HL.
D931 DEC HL Decrease HL by one.
D932 LD A,($D874) A=*Score_Digit_01.
D935 ADC A,(HL) A+=*HL.
D936 DAA DAA.
D937 LD ($D874),A Write A to *Score_Digit_01.
D93A LD (HL),$00 Write 00 to *HL.
D93C LD HL,$F0EA HL=F0EA.
D93F LD B,$23 B=23.
D941 CALL $EF4A Call EF4A.
D944 CALL Print_Bonus Call Print_Bonus.
D947 CALL Print_Score Call Print_Score.
D94A LD A,($D86D) Jump to LevelComplete_11 if *D86D is not equal to 00.
D94D CP $00
D94F JR NZ,LevelComplete_11
D951 LD A,($D874) A=*Score_Digit_01.
D954 AND %11110000 Keep only bits 4-7.
D956 RRCA RRCA.
D957 RRCA
D958 RRCA
D959 RRCA
D95A CP $01 Jump to LevelComplete_11 if A is lower than 01 (unsigned comparison).
D95C JP M,LevelComplete_11
D95F LD A,$01 Write 01 to *D86D.
D961 LD ($D86D),A
D964 CALL ExtraLife Call ExtraLife.
D967 CALL $E9DA Call E9DA.
LevelComplete_11 D96A LD A,$80 Write 80 to *Bomb.
D96C LD ($D838),A
LevelComplete_12 D96F CALL Handler_PlayerInput Call Handler_PlayerInput.
D972 CP $00 Jump back to LevelComplete_12 until there's any player input.
D974 JR Z,LevelComplete_12
D976 XOR A Write 00 to *Bomb.
D977 LD ($D838),A
D97A CALL $EE61 Call EE61.
D97D RET Return.
Prev: D892 Up: Map Next: D97E