Prev: 27849 Up: Map Next: 28111
27886: Handler: Player Death/ Game Over
Used by the routines at TitleScreen and StartGame.
Handler_PlayerDeathGameOver 27886 LD HL,26276 Jump to Handler_Shield if *Flag_Collision is zero.
27889 LD A,(HL)
27890 OR A
27891 JP Z,Handler_Shield
27894 INC HL Jump to GameOver if *Explosion_Counter is not equal to 64.
27895 LD A,(HL)
27896 CP 64
27898 JR NZ,GameOver
27900 DEC HL Write 2 ("explosion complete") to *Flag_Collision.
27901 LD (HL),2
27903 RET Return.
Handles the "Game Over" state.
GameOver 27904 LD A,(26261) Jump to Handler_PlayerBullets if *Bullet_RateLimiter is not zero.
27907 OR A
27908 JP NZ,Handler_PlayerBullets
27911 LD A,(26352) Jump to GameOver_Explosion if *Player_Lives is not equal to 1.
27914 CP 1
27916 JR NZ,GameOver_Explosion
27918 LD A,(26355) Jump to GameOver_Explosion if *Flag_ActiveDemoMode is active.
27921 OR A
27922 JR NZ,GameOver_Explosion
27924 PUSH HL Stash HL on the stack.
Prints game
27925 LD HL,25710 HL=Messaging_GameOver.
27928 LD DE,18635 DE=18635 (screen buffer location).
27931 LD BC,1093 Set to print 4 characters in INK:CYAN, PAPER:BLACK (BRIGHT).
27934 CALL Configurable_PrintString Call Configurable_PrintString.
Prints over
27937 LD E,209 Update the screen buffer address.
27939 LD B,4 Set to print 4 characters.
27941 CALL Configurable_PrintString Call Configurable_PrintString.
27944 POP HL Restore HL from the stack.
Animate the explosion effect.
GameOver_Explosion 27945 LD A,(HL) A=*HL.
27946 AND %00000111 Keep only bits 0-2.
27948 BIT 3,(HL) Jump to GameOver_SkipIncrement if bit 3 of *HL is set.
27950 JR NZ,GameOver_SkipIncrement
27952 INC A Increment A by one.
GameOver_SkipIncrement 27953 INC (HL) Increment the explosion counter by two.
27954 INC (HL)
27955 LD C,A Copy the attribute value to C.
27956 LD B,0 B=0.
27958 LD IX,2 IX=2.
GameOver_ExplosionLoop 27962 PUSH BC Stash the colour counter on the stack.
27963 LD HL,(26349) HL=*PlayerAttributeBufferPosition.
27966 LD DE,33 HL+=0033.
27969 ADD HL,DE
27970 LD (HL),D Write D to *HL.
27971 PUSH HL Stash HL on the stack.
27972 LD A,L A=L.
27973 AND %00011111 Keep only bits 0-4.
27975 SUB C A-=C.
27976 PUSH AF Stash AF on the stack.
27977 AND A HL-=BC.
27978 SBC HL,BC
27980 POP AF Restore AF from the stack.
27981 CALL NC,Handler_ShipExplosion Call Handler_ShipExplosion if A is greater than 0.
27984 POP HL Restore HL from the stack.
27985 PUSH HL Stash HL on the stack.
27986 LD A,L A=L.
27987 AND %00011111 Keep only bits 0-4.
27989 ADD A,C A+=C.
27990 CP 32 Compare A with 32.
27992 PUSH AF Stash AF on the stack.
27993 ADD HL,BC HL+=BC.
27994 POP AF Restore AF from the stack.
27995 CALL C,Handler_ShipExplosion Call Handler_ShipExplosion if A is less than 32.
27998 POP HL Restore HL from the stack.
27999 PUSH HL Stash HL on the stack.
28000 LD B,C B=C.
28001 LD DE,32 HL-=0032 (with carry).
Handler_PlayerDeathGameOver_0 28004 AND A
28005 SBC HL,DE
28007 DJNZ Handler_PlayerDeathGameOver_0 Decrease counter by one and loop back to Handler_PlayerDeathGameOver_0 until counter is zero.
28009 CALL Handler_ShipExplosion Call Handler_ShipExplosion.
28012 POP HL Restore HL from the stack.
28013 LD A,C A=C.
28014 SUB 2 A-=2.
28016 LD B,A B=A.
28017 JR C,Handler_PlayerDeathGameOver_2 Jump to Handler_PlayerDeathGameOver_2 if A is less than A.
28019 JR Z,Handler_PlayerDeathGameOver_2 Jump to Handler_PlayerDeathGameOver_2 if A is zero.
28021 PUSH HL Stash HL on the stack.
28022 LD DE,33 DE=0033.
28025 LD A,L A=L.
28026 AND %00011111 Keep only bits 0-4.
28028 ADD A,2 A+=2.
28030 SUB C A-=C.
28031 PUSH AF Stash AF on the stack.
Handler_PlayerDeathGameOver_1 28032 AND A HL-=DE (with carry).
28033 SBC HL,DE
28035 DJNZ Handler_PlayerDeathGameOver_1 Decrease counter by one and loop back to Handler_PlayerDeathGameOver_1 until counter is zero.
28037 POP AF Restore AF from the stack.
28038 CALL NC,Handler_ShipExplosion Call Handler_ShipExplosion if A is greater than 0.
28041 POP HL Restore HL from the stack.
Handler_PlayerDeathGameOver_2 28042 LD A,C A=C.
28043 SUB 2 A-=2.
28045 LD B,A B=A.
28046 JR C,Handler_PlayerDeathGameOver_4 Jump to Handler_PlayerDeathGameOver_4 if A is less than A.
28048 JR Z,Handler_PlayerDeathGameOver_4 Jump to Handler_PlayerDeathGameOver_4 if A is zero.
28050 LD DE,31 DE=0031.
28053 LD A,L A=L.
28054 AND E Merge the bits from E.
28055 ADD A,C A+=C.
28056 CP 34 Compare A with 34.
28058 PUSH AF Stash AF on the stack.
Handler_PlayerDeathGameOver_3 28059 AND A HL-=DE (with carry).
28060 SBC HL,DE
28062 DJNZ Handler_PlayerDeathGameOver_3 Decrease counter by one and loop back to Handler_PlayerDeathGameOver_3 until counter is zero.
28064 POP AF Restore AF from the stack.
28065 CALL C,Handler_ShipExplosion Call Handler_ShipExplosion if A is less than 0.
Handler_PlayerDeathGameOver_4 28068 POP BC Restore BC from the stack.
28069 INC C Increment C by one.
28070 DEC IXl
28072 JR NZ,GameOver_ExplosionLoop Jump to GameOver_ExplosionLoop if ?? is not equal to 0.
28074 LD A,(26355) Jump to Handler_PlayerBullets if *Flag_ActiveDemoMode is not active.
28077 OR A
28078 JP NZ,Handler_PlayerBullets
28081 LD A,(26277) A=*Explosion_Counter.
28084 AND %00000011 Keep only bits 0-1.
28086 JP NZ,Handler_PlayerBullets Jump to Handler_PlayerBullets if the result is not equal to zero.
28089 LD B,8 Set sound loop counter to 8.
GameOver_SoundLoop 28091 LD A,B Copy the sound loop counter into A and add 25.
28092 ADD A,25
28094 AND %00011000 Keep only bits 3-4.
28096 DI Disable interrupts.
28097 OUT (254),A Send to the speaker.
28099 PUSH BC Stash the sound loop counter on the stack.
GameOver_SoundDelay 28100 DJNZ GameOver_SoundDelay Decrease the delay loop counter by one and loop back to GameOver_SoundDelay until the counter is zero.
28102 POP BC Restore the sound loop counter from the stack.
28103 DJNZ GameOver_SoundLoop Decrease the sound loop counter by one and loop back to GameOver_SoundLoop until the sound has played out.
28105 XOR A Turn the speaker off.
28106 OUT (254),A
28108 JP Handler_PlayerBullets Jump to Handler_PlayerBullets.
Prev: 27849 Up: Map Next: 28111