Prev: 36852 Up: Map Next: 37098
36904: Move to the next cavern
Used by the routines at 34574 and 36805.
Input
Output
36904 LD A,(33799) Pick up the number of the current cavern from 33799
36907 INC A Increment the cavern number
36908 CP 20 Is the current cavern The Final Barrier?
36910 JR NZ,37009 Jump if not
36912 LD A,(33882) Pick up the game mode indicator from 33882
36915 OR A Are we in demo mode?
36916 JP NZ,37008 Jump if so
36919 LD A,(33885) Pick up the 6031769 key counter from 33885
36922 CP 7 Is cheat mode activated?
36924 JR Z,37008 Jump if so
Willy has made it through The Final Barrier without cheating.
36926 LD C,0 Draw Willy at (2,19) on the ground above the portal
36928 LD DE,33376
36931 LD HL,16467
36934 CALL 36852
36937 LD DE,45792 Draw the swordfish graphic (see 45792) over the portal
36940 LD HL,16563
36943 CALL 36852
36946 LD HL,22611 Point HL at (2,19) in the attribute file
36949 LD DE,31 Prepare DE for addition
36952 LD (HL),47 Set the attributes for the upper half of Willy's sprite at (2,19) and (2,20) to 47 (INK 7: PAPER 5)
36954 INC HL
36955 LD (HL),47
36957 ADD HL,DE Set the attributes for the lower half of Willy's sprite at (3,19) and (3,20) to 39 (INK 7: PAPER 4)
36958 LD (HL),39
36960 INC HL
36961 LD (HL),39
36963 ADD HL,DE Point HL at (5,19) in the attribute file
36964 INC HL
36965 ADD HL,DE
36966 LD (HL),69 Set the attributes for the fish at (5,19) and (5,20) to 69 (INK 5: PAPER 0: BRIGHT 1)
36968 INC HL
36969 LD (HL),69
36971 ADD HL,DE Set the attribute for the handle of the sword at (6,19) to 70 (INK 6: PAPER 0: BRIGHT 1)
36972 LD (HL),70
36974 INC HL Set the attribute for the blade of the sword at (6,20) to 71 (INK 7: PAPER 0: BRIGHT 1)
36975 LD (HL),71
36977 ADD HL,DE Set the attributes at (7,19) and (7,20) to 0 (to hide Willy's feet just below where the portal was)
36978 LD (HL),0
36980 INC HL
36981 LD (HL),0
36983 LD BC,0 Prepare C and D for the celebratory sound effect
36986 LD D,50
36988 XOR A A=0 (black border)
36989 OUT (254),A Produce the celebratory sound effect: Willy has escaped from the mine
36991 XOR 24
36993 LD E,A
36994 LD A,C
36995 ADD A,D
36996 ADD A,D
36997 ADD A,D
36998 LD B,A
36999 LD A,E
37000 DJNZ 37000
37002 DEC C
37003 JR NZ,36989
37005 DEC D
37006 JR NZ,36989
37008 XOR A A=0 (the next cavern will be Central Cavern)
37009 LD (33799),A Update the cavern number at 33799
The next section of code cycles the INK and PAPER colours of the current cavern.
37012 LD A,63 Initialise A to 63 (INK 7: PAPER 7)
37014 LD HL,22528 Set the attributes for the top two-thirds of the screen to the value in A
37017 LD DE,22529
37020 LD BC,511
37023 LD (HL),A
37024 LDIR
37026 LD BC,4 Pause for about 0.004s
37029 DJNZ 37029
37031 DEC C
37032 JR NZ,37029
37034 DEC A Decrement the attribute value in A
37035 JR NZ,37014 Jump back until we've gone through all attribute values from 63 down to 1
37037 LD A,(33882) Pick up the game mode indicator from 33882
37040 OR A Are we in demo mode?
37041 JP NZ,34449 If so, demo the next cavern
The following loop increases the score and decreases the air supply until it runs out.
37044 CALL 35388 Decrease the air remaining in the current cavern
37047 JP Z,34449 Move to the next cavern if the air supply is now gone
37050 LD HL,33838 Add 1 to the score
37053 CALL 37118
37056 LD IX,33833 Print the new score at (19,26)
37060 LD C,6
37062 LD DE,20602
37065 CALL 37562
37068 LD C,4 This value determines the duration of the sound effect
37070 LD A,(32956) Pick up the remaining air supply (S) from 32956
37073 CPL D=2*(63-S); this value determines the pitch of the sound effect (which decreases with the amount of air remaining)
37074 AND 63
37076 RLC A
37078 LD D,A
37079 LD A,0 Produce a short note
37081 OUT (254),A
37083 LD B,D
37084 DJNZ 37084
37086 LD A,24
37088 OUT (254),A
37090 LD B,D
37091 DJNZ 37091
37093 DEC C
37094 JR NZ,37079
37096 JR 37044 Jump back to decrease the air supply again
Prev: 36852 Up: Map Next: 37098