Prev: 71F8 Up: Map Next: 72BA
7200: Initialise New Level
Used by the routine at 6500.
InitialiseNewLevel 7200 LD HL,$7820 HL=CurrentLevel.
7203 LD A,(HL) Jump to InitialiseLevel if the current level is equal to 07. After level 07 the game just repeats this level.
7204 CP $07
7206 JR Z,InitialiseLevel
Increments both CurrentLevel and A as we use this as an offset for pointing to the level data.
7208 INC (HL) Increment *HL by one.
7209 INC A Increment A by one.
00 E600
01 E640
02 E680
03 E6C0
04 E700
05 E740
06 E780
07 E7C0
InitialiseLevel 720A RRCA Rotate A right two positions (bits 2 to 5 are now in positions 0 to 3) using the carry flag.
720B RRCA
720C LD L,A L=A.
720D AND %00000011 Keep only bits 0-1.
720F ADD A,$E6 A+=E6.
7211 LD H,A H=A.
7212 LD A,L A=L.
7213 AND %11000000 Keep only bits 6-7.
7215 LD L,A L=A.
7216 LD A,$0A A=0A (counter).
7218 NOP No operation.
7219 LD DE,$FA40 DE=FA40.
InitialiseNewLevel_0 721C PUSH HL Stash HL on the stack.
721D LD BC,$0040 BC=0040.
7220 LDIR Copy 0040 bytes of data from *HL to *DE.
7222 POP HL Restore HL from the stack.
7223 DEC A Decrease A by one.
7224 JR NZ,InitialiseNewLevel_0 Jump to InitialiseNewLevel_0 until A is zero.
7226 LD H,A H=A.
7227 LD B,$08 B=08.
7229 LD L,B L=B.
722A EX DE,HL Exchange the DE and HL registers.
InitialiseNewLevel_1 722B LD (HL),H Write H to *HL.
722C ADD HL,DE HL+=DE.
722D DJNZ InitialiseNewLevel_1 Decrease counter by one and loop back to InitialiseNewLevel_1 until counter is zero.
722F LD B,E B=E.
7230 LD H,$FA H=FA.
InitialiseNewLevel_2 7232 LD (HL),H Write H to *HL.
7233 ADD HL,DE HL+=DE.
7234 DJNZ InitialiseNewLevel_2 Decrease counter by one and loop back to InitialiseNewLevel_2 until counter is zero.
7236 LD B,E B=E.
7237 LD E,$10 E=10.
InitialiseNewLevel_3 7239 LD (HL),H Write H to *HL.
723A ADD HL,DE HL+=DE.
723B DJNZ InitialiseNewLevel_3 Decrease counter by one and loop back to InitialiseNewLevel_3 until counter is zero.
723D EXX Switch to the shadow registers.
723E LD BC,$FA46 BC'=FA46.
7241 EXX Switch back to the normal registers.
7242 LD DE,$9F20 DE=9F20.
7245 LD B,$0A B=0A.
InitialiseNewLevel_4 7247 PUSH BC Stash BC on the stack.
7248 LD B,$08 B=08.
InitialiseNewLevel_5 724A CALL GetRandomNumber Call GetRandomNumber.
724D AND %00011111 Keep only bits 0-4.
724F CP $1F Jump to InitialiseNewLevel_5 if A is equal to 1F.
7251 JR Z,InitialiseNewLevel_5
7253 CP $08 Jump to InitialiseNewLevel_5 if A is lower than 08.
7255 JR C,InitialiseNewLevel_5
7257 LD L,A L=A.
7258 CALL GetRandomNumber Call GetRandomNumber.
725B AND %00000011 Keep only bits 0-1.
725D LD H,A H=A.
725E ADD HL,DE HL+=DE.
725F LD A,(HL) A=*HL.
7260 DEC A Decrease A by one.
7261 JR Z,InitialiseNewLevel_6 Jump to InitialiseNewLevel_6 if A is zero.
7263 CP $31 Jump to InitialiseNewLevel_5 if A is higher than 31.
7265 JR NC,InitialiseNewLevel_5
7267 CP $2D Jump to InitialiseNewLevel_5 if A is lower than 2D.
7269 JR C,InitialiseNewLevel_5
InitialiseNewLevel_6 726B PUSH HL Stash HL on the stack.
726C EXX Switch to the shadow registers.
726D LD H,B H=B.
726E LD L,C L=C.
726F POP DE Restore DE from the stack.
InitialiseNewLevel_7 7270 LD A,(HL) A=*HL.
7271 AND A Jump to InitialiseNewLevel_9 if A is zero.
7272 JR Z,InitialiseNewLevel_9
7274 INC L Increment L by one.
7275 CP E Jump to InitialiseNewLevel_8 if A is not equal to E.
7276 JR NZ,InitialiseNewLevel_8
7278 LD A,(HL) A=*HL.
7279 CP D Compare A with D.
727A EXX Switch to the shadow registers.
727B JR Z,InitialiseNewLevel_5 Jump to InitialiseNewLevel_5 if {} is zero.
727D EXX Switch to the shadow registers.
InitialiseNewLevel_8 727E LD A,L L+=07.
727F ADD A,$07
7281 LD L,A
7282 JR InitialiseNewLevel_7 Jump to InitialiseNewLevel_7.
InitialiseNewLevel_9 7284 LD (HL),E Write E to *HL.
7285 INC L Increment L by one.
7286 LD (HL),D Write D to *HL.
7287 EXX Switch to the shadow registers.
7288 DJNZ InitialiseNewLevel_5 Decrease counter by one and loop back to InitialiseNewLevel_5 until counter is zero.
728A EXX Switch to the shadow registers.
728B LD HL,$0040 HL=0040.
728E ADD HL,BC HL+=BC.
728F LD B,H B=H.
7290 LD C,L C=L.
7291 EXX Switch to the shadow registers.
7292 LD A,E E+=20.
7293 ADD A,$20
7295 LD E,A
7296 JR NZ,InitialiseNewLevel_10 Jump to InitialiseNewLevel_10 if E is not zero.
7298 LD A,D D+=05.
7299 ADD A,$05
729B LD D,A
InitialiseNewLevel_10 729C POP BC Restore BC from the stack.
729D DJNZ InitialiseNewLevel_4 Decrease counter by one and loop back to InitialiseNewLevel_4 until counter is zero.
729F CALL PrintLevelName Call PrintLevelName.
72A2 LD HL,$3280 HL=3280.
72A5 LD A,($782D) Jump to InitialiseNewLevel_InDemoMode if the game is in "demo mode" (the high-order byte of ControlMethod_Pointer contains 73).
72A8 CP $73
72AA JR Z,InitialiseNewLevel_InDemoMode
72AC LD H,$0B H=0B.
InitialiseNewLevel_InDemoMode 72AE NOP No operation.
72AF NOP
72B0 LD ($7841),HL Write HL to *7841.
72B3 XOR A Write 00 to *7840.
72B4 LD ($7840),A
72B7 JP $7396 Jump to 7396.
Prev: 71F8 Up: Map Next: 72BA