Prev: 7616 Up: Map Next: 7B67
79B2: Handler: Alien Explosions
Used by the routines at TitleScreen and StartGame.
Handler_AlienExplosions 79B2 LD A,($6695) Return if bit 0 of *Bullet_RateLimiter is not set.
79B5 AND %00000001
79B7 RET Z
79B8 LD HL,$66D5 HL=Table_AlienExplosions.
79BB LD B,$06 Set a counter in B for checking 06 explosion slots.
AlienExplosions_Loop 79BD LD A,(HL) Jump to AlienExplosions_IsActive if this explosion slot is already active.
79BE OR A
79BF JR NZ,AlienExplosions_IsActive
79C1 PUSH BC Stash the explosion slot counter on the stack.
79C2 LD B,$C8 Set a delay loop counter in B of C8 iterations.
AlienExplosions_DelayLoop 79C4 DJNZ AlienExplosions_DelayLoop Decrease the delay loop counter by one and loop back to AlienExplosions_DelayLoop until the counter is zero.
79C6 POP BC Restore the explosion slot counter from the stack.
79C7 JP AlienExplosions_NextSlot Jump to AlienExplosions_NextSlot.
Process the active explosion.
AlienExplosions_IsActive 79CA PUSH AF Stash AF, BC and HL on the stack.
79CB PUSH BC
79CC PUSH HL
Play a sound when the explosion is active (but not in demo mode).
79CD LD A,($66F3) Jump to AlienExplosions_UpdatePosition if *Flag_ActiveDemoMode is active.
79D0 OR A
79D1 JR NZ,AlienExplosions_UpdatePosition
Play the explosion sound effect based on the current phase.
79D3 LD A,($66F1) Jump to AlienExplosions_Sound_02 if bit 1 of *Phase is not zero.
79D6 AND %00000010
79D8 JR Z,AlienExplosions_Sound_02
Play explosion sound 01.
79DA LD A,(HL) DE=*HL*08.
79DB ADD A,A
79DC ADD A,A
79DD ADD A,A
79DE LD E,A
79DF LD D,$00
79E1 LD HL,$00F2 HL=00F2+DE.
79E4 ADD HL,DE
79E5 LD B,$03 B=03.
AlienExplosions_Sound_01 79E7 PUSH BC Stash BC and HL on the stack.
79E8 PUSH HL
79E9 LD DE,$0002 DE=0002.
79EC CALL $03B5 Call BEEPER.
79EF DI Disable interrupts.
79F0 POP HL Restore HL from the stack.
79F1 INC HL Increment HL by two.
79F2 INC HL
79F3 POP BC Restore BC from the stack.
79F4 DJNZ AlienExplosions_Sound_01 Decrease counter by one and loop back to AlienExplosions_Sound_01 until counter is zero.
79F6 JR AlienExplosions_UpdatePosition Jump to AlienExplosions_UpdatePosition.
Play explosion sound 02.
AlienExplosions_Sound_02 79F8 LD A,(HL) Jump to AlienExplosions_UpdatePosition if the explosion type is not 01.
79F9 CP $01
79FB JR NZ,AlienExplosions_UpdatePosition
79FD LD B,$12 Set a counter in B for 12 explosion sound loops.
79FF LD HL,$0064 Set the initial pitch to 0064.
AlienExplosions_Sound_02_Loop 7A02 PUSH BC Stash the explosion sound loops counter and pitch on the stack.
7A03 PUSH HL
7A04 LD A,$64 Calculate the delay counter: 64 - (B × 02).
7A06 SUB B
7A07 SUB B
7A08 LD B,A
7A09 LD A,$10 Enable the speaker (bit 4).
7A0B DI Disable interrupts.
AlienExplosions_Sound_02_DelayLoop 7A0C OUT ($FE),A Decrease the delay counter by one and loop back to AlienExplosions_Sound_02_DelayLoop until the delay counter is zero.
7A0E DJNZ AlienExplosions_Sound_02_DelayLoop
7A10 LD DE,$0001 Set the sound duration to 0001.
7A13 CALL $03B5 Call BEEPER.
7A16 DI Disable interrupts.
7A17 POP HL Restore the pitch from the stack.
7A18 LD BC,$0008 Increase the pitch by 0008.
7A1B ADD HL,BC
7A1C POP BC Restore the explosion sound loops counter from the stack.
7A1D DJNZ AlienExplosions_Sound_02_Loop Decrease the explosion sound loops counter by one and loop back to AlienExplosions_Sound_02_Loop until the explosion sound has finished playing.
Update the explosion position and check for scoring.
AlienExplosions_UpdatePosition 7A1F POP HL Restore HL, BC and AF from the stack.
7A20 POP BC
7A21 POP AF
7A22 PUSH BC Stash BC and HL on the stack.
7A23 PUSH HL
7A24 INC HL Increment HL by one.
7A25 LD E,(HL) E=*HL.
7A26 INC HL Increment HL by one.
7A27 LD D,(HL) D=*HL.
7A28 LD C,A C=A.
7A29 LD A,($66F1) A=*Phase.
7A2C AND %00000010 Keep only bit 1.
7A2E LD A,C A=C.
7A2F JR NZ,Handler_AlienExplosions_6 Jump to Handler_AlienExplosions_6 if bit 1 of *Phase was set.
7A31 CP $01 Jump to Handler_AlienExplosions_0 if A is not equal to 01.
7A33 JR NZ,Handler_AlienExplosions_0
7A35 PUSH DE Stash DE and AF on the stack.
7A36 PUSH AF
7A37 EX DE,HL Exchange the DE and HL registers.
7A38 CALL ConvertAttributeToScreenBufferAddress Call ConvertAttributeToScreenBufferAddress.
7A3B EX DE,HL Exchange the DE and HL registers.
7A3C CALL ClearSpriteArea Call ClearSpriteArea.
7A3F POP AF Restore AF and DE from the stack.
7A40 POP DE
Handler_AlienExplosions_0 7A41 CP $04 Jump to Handler_AlienExplosions_2 if A is not equal to 04.
7A43 JR NZ,Handler_AlienExplosions_2
7A45 PUSH DE Stash DE and AF on the stack.
7A46 PUSH AF
7A47 LD HL,$652D HL=652D.
7A4A LD (HL),$38 Write 38 to *HL.
7A4C LD A,D Jump to Handler_AlienExplosions_1 if D is equal to 5A.
7A4D CP $5A
7A4F JR Z,Handler_AlienExplosions_1
7A51 LD (HL),$32 Write 32 to *HL.
7A53 INC HL Increment HL by one.
7A54 LD (HL),$35 Write 35 to *HL.
Handler_AlienExplosions_1 7A56 CALL Handler_Score Call Handler_Score.
7A59 CALL PrintScore Call PrintScore.
7A5C CALL PrintLives Call PrintLives.
7A5F POP AF Restore AF and DE from the stack.
7A60 POP DE
Handler_AlienExplosions_2 7A61 CP $07 Compare A with 07.
7A63 LD BC,$0344 BC=0344.
7A66 JR C,Handler_AlienExplosions_3 Jump to Handler_AlienExplosions_3 if A is less than 07.
7A68 LD HL,$6535 HL=Table_ExplosionUDGs_03.
7A6B CP $09 Jump to Handler_AlienExplosions_5 if A is less than 09.
7A6D JR C,Handler_AlienExplosions_5
7A6F LD C,$03 C=03.
7A71 JR Handler_AlienExplosions_5 Jump to Handler_AlienExplosions_5.
Handler_AlienExplosions_3 7A73 INC C Increment C by one.
7A74 CP $04 Jump to Handler_AlienExplosions_4 if A is less than 04.
7A76 JR C,Handler_AlienExplosions_4
7A78 LD HL,$6532 HL=Table_ExplosionUDGs_02.
7A7B JR Handler_AlienExplosions_5 Jump to Handler_AlienExplosions_5.
Handler_AlienExplosions_4 7A7D LD C,$47 C=47.
7A7F LD HL,$652F HL=Table_ExplosionUDGs_01.
Handler_AlienExplosions_5 7A82 PUSH DE Stash DE on the stack.
7A83 EX DE,HL Exchange the DE and HL registers.
7A84 CALL ConvertAttributeToScreenBufferAddress Call ConvertAttributeToScreenBufferAddress.
7A87 PUSH HL Stash HL and BC on the stack.
7A88 PUSH BC
7A89 LD BC,$50C0 HL-=50C0.
7A8C AND A
7A8D SBC HL,BC
7A8F POP BC Restore BC and HL from the stack.
7A90 POP HL
7A91 EX DE,HL Exchange the DE and HL registers.
7A92 CALL C,CustomFont_PrintString Call CustomFont_PrintString if A is less than 00.
7A95 POP DE Restore DE from the stack.
7A96 JP Handler_AlienExplosions_14 Jump to Handler_AlienExplosions_14.
Handler_AlienExplosions_6 7A99 CP $01 Jump to Handler_AlienExplosions_7 if A is not equal to 01.
7A9B JR NZ,Handler_AlienExplosions_7
7A9D PUSH DE Stash DE and AF on the stack.
7A9E PUSH AF
7A9F EX DE,HL Exchange the DE and HL registers.
7AA0 CALL ConvertAttributeToScreenBufferAddress Call ConvertAttributeToScreenBufferAddress.
7AA3 EX DE,HL Exchange the DE and HL registers.
7AA4 CALL ClearSpriteArea Call ClearSpriteArea.
7AA7 POP AF Restore AF and DE from the stack.
7AA8 POP DE
7AA9 INC DE Increment DE by one.
7AAA LD (DE),A Write A to *DE.
7AAB DEC DE Decrease DE by one.
7AAC JR Handler_AlienExplosions_10 Jump to Handler_AlienExplosions_10.
Handler_AlienExplosions_7 7AAE CP $02 Jump to Handler_AlienExplosions_10 if A is not equal to 02.
7AB0 JR NZ,Handler_AlienExplosions_10
7AB2 PUSH AF Stash AF and DE on the stack.
7AB3 PUSH DE
7AB4 LD HL,$652C HL=652C.
7AB7 PUSH HL Stash HL on the stack.
7AB8 LD (HL),$31 Write 31 to *HL.
7ABA LD A,($6691) Jump to Handler_AlienExplosions_9 if *6691 is zero.
7ABD OR A
7ABE JR Z,Handler_AlienExplosions_9
7AC0 LD A,D Jump to Handler_AlienExplosions_8 if D is less than 59.
7AC1 CP $59
7AC3 JR C,Handler_AlienExplosions_8
7AC5 LD (HL),$32 Write 32 to *HL.
7AC7 JR Z,Handler_AlienExplosions_9 Jump to Handler_AlienExplosions_9 if A is equal to 59.
Handler_AlienExplosions_8 7AC9 INC HL Increment HL by one.
7ACA LD (HL),$35 Write 35 to *HL.
Handler_AlienExplosions_9 7ACC EX DE,HL Exchange the DE and HL registers.
7ACD CALL ConvertAttributeToScreenBufferAddress Call ConvertAttributeToScreenBufferAddress.
7AD0 PUSH HL Stash HL on the stack.
7AD1 LD BC,$50C0 HL-=50C0.
7AD4 AND A
7AD5 SBC HL,BC
7AD7 POP HL Restore HL from the stack.
7AD8 EX DE,HL Exchange the DE and HL registers.
7AD9 POP HL Restore HL from the stack.
7ADA LD BC,$0345 BC=0345.
7ADD CALL C,Configurable_PrintString Call Configurable_PrintString if A is less than 00.
7AE0 CALL Handler_Score Call Handler_Score.
7AE3 CALL PrintScore Call PrintScore.
7AE6 CALL PrintLives Call PrintLives.
7AE9 POP DE Restore DE and AF from the stack.
7AEA POP AF
Handler_AlienExplosions_10 7AEB PUSH DE Stash DE on the stack.
7AEC LD C,A C=A.
7AED LD A,E A=E.
7AEE INC A Increment A by one.
7AEF AND %00011111 Keep only bits 0-4.
7AF1 SUB C A-=C.
7AF2 JR C,Handler_AlienExplosions_12 Jump to Handler_AlienExplosions_12 if A is less than A.
7AF4 PUSH BC Stash BC and AF on the stack.
7AF5 PUSH AF
7AF6 LD A,E E-=C.
7AF7 SUB C
7AF8 LD E,A
7AF9 INC E Increment E by one.
7AFA CALL Handler_Mask Call Handler_Mask.
7AFD DEC E Decrease E by one.
7AFE POP AF Restore AF from the stack.
7AFF JR Z,Handler_AlienExplosions_11 Jump to Handler_AlienExplosions_11 until E is zero.
7B01 POP BC Restore BC from the stack.
7B02 PUSH BC Stash BC on the stack.
7B03 LD A,C Jump to Handler_AlienExplosions_11 if C is equal to 10.
7B04 CP $10
7B06 JR Z,Handler_AlienExplosions_11
7B08 CALL Handler_EggsplosionLeft Call Handler_EggsplosionLeft.
Handler_AlienExplosions_11 7B0B POP BC Restore BC and DE from the stack.
Handler_AlienExplosions_12 7B0C POP DE
7B0D PUSH DE Stash DE on the stack.
7B0E INC E Increment E by one.
7B0F LD A,E A=E.
7B10 AND %00011111 Keep only bits 0-4.
7B12 ADD A,C A+=C.
7B13 CP $20 Jump to Handler_AlienExplosions_13 if A is greater than or equal to 20.
7B15 JR NC,Handler_AlienExplosions_13
7B17 PUSH BC Stash BC on the stack.
7B18 CP $1F Compare A with 1F.
7B1A PUSH AF Stash AF on the stack.
7B1B LD A,E E+=C.
7B1C ADD A,C
7B1D LD E,A
7B1E DEC DE Decrease DE by one.
7B1F CALL Handler_Mask Call Handler_Mask.
7B22 INC DE Increment DE by one.
7B23 POP AF Restore AF and BC from the stack.
7B24 POP BC
7B25 JR Z,Handler_AlienExplosions_13 Jump to Handler_AlienExplosions_13 if ??? is zero.
7B27 LD A,C Jump to Handler_AlienExplosions_13 if C is equal to 10.
7B28 CP $10
7B2A JR Z,Handler_AlienExplosions_13
7B2C CALL Handler_EggsplosionRight Call Handler_EggsplosionRight.
Handler_AlienExplosions_13 7B2F POP DE Restore DE and HL from the stack.
Handler_AlienExplosions_14 7B30 POP HL
7B31 INC (HL) Increment *HL by one.
The number of frames the explosion persists for varies between the phases, presumably because some phases allow the ship to make "quick shots" and the number of slots may be at risk when the player can fire more rapidly.
7B32 LD A,($66F1) A=*Phase.
7B35 AND %00000010 Keep only bit 1.
7B37 LD A,$0B Set the frame limit in A to 0B frames.
7B39 JR Z,AlienExplosions_CheckComplete Jump to AlienExplosions_CheckComplete if bit 1 of *Phase was not set.
7B3B LD A,$11 Set the frame limit in A to 11 frames.
AlienExplosions_CheckComplete 7B3D CP (HL) Jump to AlienExplosions_Continue if *HL is not equal to the frame limit.
7B3E JR NZ,AlienExplosions_Continue
7B40 LD (HL),$00 Clear the current explosion slot (set to 00).
7B42 PUSH HL Stash the explosion slot pointer on the stack.
7B43 EX DE,HL Exchange the DE and HL registers.
7B44 CALL ConvertAttributeToScreenBufferAddress Call ConvertAttributeToScreenBufferAddress.
7B47 PUSH HL Stash HL on the stack.
7B48 LD BC,$50C0 HL-=50C0.
7B4B AND A
7B4C SBC HL,BC
7B4E POP HL Restore HL from the stack.
7B4F EX DE,HL Exchange the DE and HL registers.
Prints
7B50 LD HL,$3F1B HL=3F1B.
7B53 LD BC,$0300 BC=0300.
7B56 CALL C,SpectrumFont_PrintString Call SpectrumFont_PrintString if ?? is less than 00.
7B59 LD HL,$667F Decrease *AlienCount by one.
7B5C DEC (HL)
7B5D POP HL Restore the explosion slot pointer from the stack.
AlienExplosions_Continue 7B5E POP BC Restore the explosion slot counter from the stack.
Move to the next explosion slot.
AlienExplosions_NextSlot 7B5F INC HL Move the explosion slot pointer to the next explosion slot.
7B60 INC HL
7B61 INC HL
7B62 DEC B Decrease the explosion slot counter by one.
7B63 JP NZ,AlienExplosions_Loop Jump back to AlienExplosions_Loop until all explosion slots have been processed.
7B66 RET Return.
Prev: 7616 Up: Map Next: 7B67