Prev: 26808 Up: Map Next: 26939
26871: Set Up Next Level
Used by the routines at Initialise_Lives and Handle_Level_Complete.
Prepares the game state for the next level. Increments the current level number, awards an extra life on level 4 loads the worm collection target for the new level from the lookup table, and resets all collected and disabled worm markers in the room attribute data.
Increment the level counter and check for extra life award.
SetUp_NextLevel 26871 LD A,(24497) Fetch the current level from *CurrentLevel.
26874 LD HL,24499 Point HL at LivesDisplayCharacter.
26877 CP 5 Jump to SetWorm_Target if this is level 5 (don't increment past the maximum).
26879 JR Z,SetWorm_Target
26881 INC A Increment the level number and write it back to *CurrentLevel.
26882 LD (24497),A
26885 CP 4 Jump to SetWorm_Target if the new level is not equal to 4.
26887 JR NZ,SetWorm_Target
Award an extra life on level 4.
26889 INC (HL) Increment the lives display character at *HL.
26890 LD A,(HL)
26891 LD HL,20720 Point HL at 20720 (screen buffer position for the lives display).
26894 CALL PrintCharacter Call PrintCharacter.
Load the worm collection target for the new level.
SetWorm_Target 26897 LD A,(24497) Fetch the current level from *CurrentLevel.
26900 LD B,0 Set BC to the level number minus one as a table index.
26902 LD C,A
26903 DEC C
26904 LD HL,26977 Point HL at Table_WormCollectionCount.
26907 ADD HL,BC Add the index to get the table entry address.
26908 LD A,(HL) Write the worm collection count for this level to *WormsRemaining.
26909 LD HL,24498
26912 LD (HL),A
Reset all collected and disabled worm markers in the room object data back to 0.
26913 LD HL,56990 Point HL at Room_Object_Data.
26916 LD BC,352 Set the byte counter to 352 in BC.
ResetWorm_Markers_Loop 26919 LD A,(HL) If *HL equals 31 (delivered marker), write 0 to *HL.
26920 CP 31
26922 JR NZ,ResetWorm_Test_Collected
26924 LD (HL),0
ResetWorm_Test_Collected 26926 CP 30 If *HL equals 30 (collected marker), write 0 to *HL.
26928 JR NZ,ResetWorm_Markers_Next
26930 LD (HL),0
ResetWorm_Markers_Next 26932 INC HL Move to the next data byte.
26933 DEC BC Decrease the byte counter by one.
26934 LD A,C Jump back to ResetWorm_Markers_Loop until all 352 bytes are processed.
26935 OR B
26936 JR NZ,ResetWorm_Markers_Loop
26938 RET Return.
Prev: 26808 Up: Map Next: 26939