ESCAPE FROM THE UNDERWORLD Blast your way out of the caves of Andromeda in Escape from the Underworld by J. Dury of Bristol. The program runs on the 48K Spectrum or Spectrum Plus and sets you the task of destroying five aliens in each cave before your energy runs out. [Neither the program or accompanying program notes bothered to say] [what the control keys are, but they appear to be: ] [O/P=left/right, Q=thrust, Z=fire JimG] Lines 5 to 100 Line 5 is a standard Poke to set the machine in CAPS LOCK mode, and line 20 sets permanent colours in the same way as the colour state- ments. Dury is an economical programmer, as we shall see later, but you could do this sort of thing with ordinary statements. Array A() is set to contain five elements which will correspond to the five aliens. The rest of the lines read in the data for the user-defined graphics characters. Variable h holds the hi-score Lines 100 to 1010 The basic variables are now set up. CAV is the number of the current cavern, L is the number of lives you have left, SC is the score, SL is a score modifier used to decide whether you deserve a bonus life and UP is used to determine whether you are flying up or not. Score, fuel, lives and other details are printed at the bottom of the screen, and the program then goes to the routine at 5000 to set up a new cavern. Lines 1015 to 1220 Some more variables are set up. NA is the number of aliens left, and FL is your fuel level. X and Y are your starting positions. XN, YN and DR are used to determine degree of thrust and direction of movement. Lines 1050 to 1070 position the five aliens on the screen. Line 1060 looks at the colour of the square under examination and if it is not red, that is, if the ATTR function is not 2, the alien is put there. A(N) holds the vertical co-ordinate of the alien which is then printed. N is also used to determine the horizontal position of the alien initially. 1110 copies the X and Y values into X1 and Y1 for future use. Lines 2000 to 2030 Dury starts to get going in the main loop. Instead of using boring old INKEY$ for the input, he is using the IN instruction which scans the keyboard via the signals sent out of the port at the back. This is faster than INKEY$ but difficult to use. BIT is used as a comparison with the number sent out by the keyboard so the key can be checked. A value of 254 is given out if no keys are pressed in the appropriate row, so BIT is subtracted from that to find the actual key pressed. At line 2020 the IF statement makes the whole of the routine to 2220 into a loop to deal with the aliens - if NA is bigger than 0. If it isn't there are no aliens, and to avoid trouble when the program reaches NEXT C that case will be looked after within the loop. This is Basic programming at its most devious and only recommended to those with strong nerves. The net result of all those tortuous IN statements is to decrease horizontal thrust if you move up and down, or remain stationary. Lines 2035 to 2080 Line 2035 adds 0.5 to the horizontal thrust if the way is clear, so you tend to keep moving towards the aliens. Lines 2040 and 2045 work out all the thrust factors and get X1 and Y1 set to the correct values for the new position of your man. At 2050 the horizontal thrust is set to zero if you have bumped into something, and X1 and Y1 revert to their original values since you aren't going to move at all. At 2070 a space is printed over the old position and UDG is printed in the new position. Which UDG? DR and UP and FL - the fuel, remember - are used to decide which version of the man gets printed. The economical Dury has run all this together, to save speed, but you could do it with a bundle of IF .... THEN PRINT "???" type statements. At 2075 the program goes to the routine at 6000 if you have got right through the cavern. Finally, at 2080 the new co-ordinates become the old ones, X and Y, in readiness for another waltz around the loop. Lines 2085 to 2230 Line 2085 invokes the fire routine at line 4000 if the appropriate keys are pressed. Direction of fire is also worked out and stored in PX and PY relative to your current position. 2090 ignores the alien move sequence if there are no aliens. 2095 to 2130 covers the aliens. They will move more or less in your direction and fire if they are level with you at line 2130. Line 2210 checks to see if you are out of fuel, and line 2230 sends you back to the beginning of the main loop if everything has been successfully negotiated. Lines 4000 to 4090 The firing routine first checks to see if the next space in the direction of fire is empty. If so, then at 4032 to 4037 PX and PY are set to the co-ordinates of the furthest point along the line of fire which is not blocked by an alien or cavern wall. At 4040 the colour of that end square - the target - is recorded in ATR. If ATR is 6 the aliens have been firing at you and routine 5100 is called in for your death. The line at 4080 handles the demolition of a stalactite. Lines 4100 to 4192 Lines 4100 to 4120 check for the case where a piece of cavern is blasted, but a stalactite does not fall down. Lines 4150 to 4192 complete the firing section with the death of an alien. In 4165 the number of aliens is decreased, and the alien array from which the alien positions are plotted changes the appropriate element to zero. Line 4166 gives a little Beep and increases your score. The routine at 4182 to 4192 resets co-ordinates. Lines 5000 to 5030 The lines draw a cavern at random. Line 5020 is the important one - two solid squares - in this case red - are printed all the way along the cavern up to nine deep, top and bottom, depending on the random number chosen. Lines 5100 to 5190 Here is the death routine. L is decreased by one life, an appropriate graphic is chosen from the stock held in A$, and your position is worked out. You are eliminated, a tune is played, and if you have any lives left then line 5150 sends you back to the main routine again. Lines 6000 to 6060 This routine is called when you complete a cavern. A bonus score is given and a check made for extra lives at line 6040. Lines 7000 to 7110 Two routine here - the first plays a little tune to congratulate you and the second, at line 7100, tests for an extra life. You get this if you have scored 10000 points since your last extra life. SL is upgraded by 1000 points each time.