Prev: 53695 Up: Map Next: 53948
53836: Stage Next Wave
Used by the routines at CheckScoreAwardLife and PlayerDeath.
Entry point for wave staging. Resets the entity list write pointer to Entity_List_Base and writes a terminator. If Active_Enemy_Count is non-zero the current wave set is re-populated (Stage_Next_Wave_Populate); otherwise a fresh wave is loaded: enemy parameters are cleared, the next entry in the wave definition table (Wave_Definition_Pointer) is read, the display is reinitialised via Clear_Screen_And_Render_HUD, and the main game loop is entered via Main_Game_Loop with the playfield entity handler 52834 in place.
Stage_Next_Wave 53836 LD HL,24832 Reset the entity list write pointer to Entity_List_Base.
53839 LD (50441),HL Write the entity list terminator routine address 53668 and the 255 sentinel; store the updated write pointer at Entity_List_Write_Pointer.
53842 LD DE,53668
53845 LD (HL),E
53846 INC HL
53847 LD (HL),D
53848 INC HL
53849 LD (HL),255
53851 LD A,(50204) Check whether the wave counter at Active_Enemy_Count is non-zero; if so, jump to Stage_Next_Wave_Populate to re-populate the current wave set.
53854 AND A
53855 JR NZ,Stage_Next_Wave_Populate
New wave: clear enemy parameters, read the next wave definition entry, and reinitialise the display.
53857 LD HL,50211 Clear the enemy parameter block at Wave_Enemy_Count (12 bytes) ready for the incoming wave.
53860 LD DE,50212
53863 LD (HL),0
53865 LD BC,12
53868 LDIR
53870 LD HL,(50185) Read the new wave number from Wave_Definition_Pointer into WaveNumber, then reinitialise the display via Clear_Screen_And_Render_HUD.
53873 LD A,(HL)
53874 LD (50184),A
53877 CALL Clear_Screen_And_Render_HUD
53880 LD HL,(50185) Advance the wave definition pointer in Wave_Definition_Pointer past the current entry via DispatchWordFromHL.
53883 INC HL
53884 CALL DispatchWordFromHL
53887 LD (50185),HL Store the updated wave definition pointer back to Wave_Definition_Pointer.
Stage_Next_Wave_Activate 53890 LD HL,24576 Point the playfield write pointer (Playfield_Entity_List_Pointer) to Entity_List and write the playfield entity handler address 52834 to the entity list.
53893 LD DE,52834
53896 LD (50385),HL
53899 LD (HL),E Write the 255 end-of-list sentinel after the handler address.
53900 INC HL
53901 LD (HL),D
53902 INC HL
53903 LD (HL),255
53905 LD HL,50398 Set the wave active flag at Wave_Active_Flag to 1 and jump to the main game loop at Main_Game_Loop.
53908 LD (HL),1
53910 JP Main_Game_Loop
Re-populate: clear the wave counter, redraw the HUD, and spawn all enemy types for the current wave before restarting the game loop.
Stage_Next_Wave_Populate 53913 XOR A Clear the wave counter at Active_Enemy_Count and redraw the HUD via RenderHUD.
53914 LD (50204),A
53917 CALL RenderHUD
53920 LD HL,50211 Call Spawn_Primary_Wave_Enemies using Wave_Enemy_Count.
53923 CALL Spawn_Primary_Wave_Enemies
53926 CALL Spawn_Wave_Enemies_Class2 Spawn the secondary wave enemies via Spawn_Wave_Enemies_Class2.
53929 CALL Spawn_Wave_Enemies Run the entity update pass via Spawn_Wave_Enemies.
53932 CALL Spawn_Horizontal_Wave_Enemies Call Spawn_Horizontal_Wave_Enemies.
53935 CALL Evaluate_And_Spawn_Tracked_Enemies Call Evaluate_And_Spawn_Tracked_Enemies.
53938 CALL Apply_Wave_Border_Colour Call Apply_Wave_Border_Colour.
53941 CALL Spawn_Wall_Bouncing_Enemies Call Spawn_Wall_Bouncing_Enemies.
53944 XOR A Clear A and restart the playfield via Stage_Next_Wave_Activate.
53945 JP Stage_Next_Wave_Activate
Prev: 53695 Up: Map Next: 53948