Prev: 29703 Up: Map Next: 29860
29708: Initialise Level
Initialises a new level, setting up the phase data, alien colours and player position.
InitialiseLevel 29708 LD HL,26240 Clear 0108 bytes from 26240 onwards.
29711 LD DE,26241
29714 LD BC,108
29717 LD (HL),B
29718 LDIR
Evaluate the last phase.
29720 LD HL,26353 A=*Phase.
29723 LD A,(HL)
29724 SUB 4 Subtract 4 from *Phase.
Self-modifying code; see 28734.
Point to the bullet count.
29726 LD DE,28735 DE=28735.
Is this the last phase?..
29729 JR NZ,NextPhase Jump to NextPhase if *Phase minus 4 is not equal to 0.
The last phase was phase 4 so reset back to phase 0.
29731 LD (HL),A Write 0 to *Phase.
Update the bullet count back to one shot.
29732 INC A Write 1 to *28735.
29733 LD (DE),A
29734 PUSH HL Stash the phase pointer on the stack.
29735 CALL GameIntro Call GameIntro.
29738 POP HL Restore the phase pointer from the stack.
29739 JR SetPhaseAlienCount Jump to SetPhaseAlienCount.
Move onto the next phase.
NextPhase 29741 INC (HL) Increment *Phase by one.
Update the bullet count to four shots.
29742 LD A,4 Write 4 to *28735.
29744 LD (DE),A
Set up the number of aliens.
SetPhaseAlienCount 29745 LD A,(HL) A=*Phase.
29746 PUSH AF Stash the current phase on the stack.
29747 AND %00000110 Keep only bits 1-2 to single out the following phases:
  • 2
  • 3
  • 4
Set the default number of aliens.
29749 LD HL,26239 Set *AlienCount to 8 aliens.
29752 LD (HL),8
29754 JR NZ,SetAlienPhaseData Jump to SetAlienPhaseData if *Phase is either 2 3 or 4.
Else, set the numher of aliens for phases 0 and 1.
29756 LD (HL),15 Set *AlienCount to 15 aliens.
Now set up the phase data.
SetAlienPhaseData 29758 LD HL,26167 HL=Table_AlienPhaseData_02_03.
29761 POP AF Restore the current phase from the stack.
29762 OR A Jump to InitialisePhase01 if the current phase is not 0.
29763 JR NZ,InitialisePhase01
29765 LD HL,26107 HL=Table_AlienPhaseData_00.
29768 JR CopyPhaseData Jump to CopyPhaseData.
If this is phase 1 initialise it.
InitialisePhase01 29770 CP 1 Jump to InitialisePhase04 if the current phase is not 1.
29772 JR NZ,InitialisePhase04
29774 LD HL,26137 HL=Table_AlienPhaseData_01.
29777 JR CopyPhaseData Jump to CopyPhaseData.
If this is phase 4 initialise it.
InitialisePhase04 29779 CP 4 Jump to CopyPhaseData if the current phase is not 4.
29781 JR NZ,CopyPhaseData
29783 LD HL,26183 HL=Table_AlienPhaseData_04.
Copy the phase data to the active phase data.
CopyPhaseData 29786 LD DE,26077 Copy *AlienCount multiplied by 2 bytes from the phase data to Table_CurrentAlienPhaseData.
29789 LD A,(26239)
29792 ADD A,A
29793 LD C,A
29794 LDIR
Is this phase 1?
29796 LD A,(26353) Jump to Initialise_Phase_02 if *Phase is not equal to 1.
29799 CP 1
29801 JR NZ,Initialise_Phase_02
Set the alien colouring for phase 1.
Set the bird alien colouring to produce.
bird-01-green
29803 LD BC,17156 Set B to INK:MAGENTA, PAPER:BLACK (BRIGHT), and C to GREEN.
29806 JR InitialiseLevel_SetColors Jump to InitialiseLevel_SetColors.
Is this phase 2?
Initialise_Phase_02 29808 CP 2 Jump to Initialise_Phase_03 if *Phase is not equal to 2.
29810 JR NZ,Initialise_Phase_03
Set the alien colouring for phase 2.
Set the Pheenix colouring to produce:
pheenix-05-blue
29812 LD B,65 Set both B and C to INK:BLUE, PAPER:BLACK (BRIGHT).
29814 LD C,B
29815 JR InitialiseLevel_SetColors Jump to InitialiseLevel_SetColors.
Is this phase 3?
Initialise_Phase_03 29817 CP 3 Jump to Initialise_Phase_Default if *Phase is not equal to 3.
29819 JR NZ,Initialise_Phase_Default
Set the alien colouring for phase 3.
Set the Pheenix colouring to produce:
pheenix-05-magenta
29821 LD B,67 Set both B and C to INK:MAGENTA, PAPER:BLACK (BRIGHT).
29823 LD C,B
29824 JR InitialiseLevel_SetColors Jump to InitialiseLevel_SetColors.
This is either phase 0 or 4. Set the bird alien colouring to produce:
bird-01-magenta
Initialise_Phase_Default 29826 LD BC,1603 Set B to YELLOW, and C to INK:MAGENTA, PAPER:BLACK (BRIGHT).
Set the alien colourings.
InitialiseLevel_SetColors 29829 LD (26237),BC Write B to *Pheenix_Colour_01 and C to *Pheenix_Colour_02.
Set the players ship starting position.
29833 LD HL,26349 Write 206 to *PlayerAttributeBufferPosition.
29836 LD (HL),206
29838 LD A,(26353) Stash *Phase on the stack.
29841 PUSH AF
The TransitionEffect shouldn't play out for the first phase.
29842 AND %00000110 Call TransitionEffect if *Phase is either 2 3 or 4.
29844 CALL NZ,TransitionEffect
29847 CALL PrintHeader Call PrintHeader.
The alien mothership is only shown in phase 4.
29850 POP AF Call Draw_AlienMothership if *Phase is 4.
29851 CP 4
29853 CALL Z,Draw_AlienMothership
29856 CALL DrawShip Call DrawShip.
29859 RET Return.
Prev: 29703 Up: Map Next: 29860