SUB-HUNT Games Computing, Issue Oct. 1984 - Pages 82 to 87 By I & B Billups. Note: Program only works under Issue 2 keyboard emulation (IN commands on program to read keyboard). It can be easily adapted to work on rest of ZX models/boards by changing IN parameters in lines 200 and 240. "Sub-Hunt" is an arcade type game that will Run on the 16K ZX Spectrum. It has full arcade features including high score table and extended play. The idea of the game is to destroy the submarines by lining up the greater-than sign at the side of the screen with the submarine and then dropping your depth charge. The depth charge will explode at the height set by the greater-than sign. Use keys 'Q' and 'Z' to move the greater-than sign up and down the side of the screen respectively. Key 'I' will drop a depth charge. At the top of the screen is PRINTed two scores. Your score and the high score. If your score is greater than the high score, your score will go white. When you hit a submarine you will be given points; the deeper the submarine is the more points you will get. You will get double points if you hit the submarine in the centre. At the side of the screen is a fuel scale that will gradually go down. When the fuel runs out the game will end, unless you have achieved extended play. Extended play is awarded at 5000 points. When your score reaches 5000 "extended play" will be PRINTed on the screen momentarily, and when your fuel runs out "extended play" will again be PRINTed and you will be given twice as much fuel as you had when you reached 5000 points; once into an extended play your fuel will be PRINTed in red. Occasionally a white submarine will appear at the bottom of the screen. This is a bonus 'Ghost Sub' and it is worth 1000 points or even 2000 if you can hit it in the centre. If you press key 'M' your ship will thrust but you will use up a lot more fuel. When the game starts, a tune will be played. A different tune will be played at the end of the game. When the game has finished, providing your score is greater than and you are in the top ten scores, you will be asked to enter your initials. The letters will rotate in alphabetical order, forwards or backwards, when you press keys 'Q' or 'I'. When the correct letter is selected, press key 'M' and go on to the next letter. When you have entered all three initials, the high score table will be displayed. The initials that you have just entered will appear on the table in white. Another game will start after 1 second or when any key is pressed. RUNdown Lines Action Pre-game routine 130-150 Clear the screen and fill it with cyan (5) water and the blue (1) fuel scale. 170-180 Initialize all variables that require re-setting before each game. Other variables are set during the initialisation routine (line 1000 onwards). Main game loop 190 PRINT cursor (>) at correct position and PRINT spaces above and below it to erase its last image. 200 Allow cursor's position to be altered by keys 'Q' and 'Z'. Note that whenever necessary, IN has been used instead of INKEY$ (see chapter 23 of manual) so that one or more keys can be read simultaneously. 210 PRINT boat followed by 2 spaces to erase its last image. 220 PRINT submarine followed by a space to erase its last image, if submarine is at maximum depth (20) then PRINT it in white (7). 230 If a depth charge is in the water then GOTO the relevant sub-routine (336-380, see next section). Note that this routine returns to line 250, thus not allowing 290 two depth charges in the water at the same time. 240 Allow a new depth charge to be dropped. (key 'I'). 250 Increment variables 'tf' and if player wishes to abort game then GOTO 390, the after game routine. 260 If 'tf' is now greater than or equal to 3 then reset it to 0, erase the top part of the fuel scale and decrement the 320 variable 't' (fuel remaining.) 265 If extended play has just been achieved then call routine at line 720 to indicate this to the player and LET the variable 'Z' equal the amount of fuel you have remaining (t). 270 If fuel has run out, extended play has not yet been used, and score is over or equal to 5000 points then call the routine to line 720 again and GOTO 680, which gives extended play. 275 If fuel has run out then GOTO 390, the after game routine. 280 Move submarine and boat and check if hold (key 'H') is pressed. 290 If thrust (key 'M') is pressed then move boat another step and decrease fuel by another 2 steps. 300 If the submarine has reached the far right of the screen, then erase it, reset it to the start of its path and give it a new, random height. 310 If the ship has reached the far left of the screen, then erase it, and reset it to the start of its path. 320 PRINT score and high score. If score is greater than high score, then PRINT it in white (7). 325 If this is the first time around the loop, then play introductory tune (line 560 ) before continuing. 327 Return to the start of the loop (line 190). Depth charge routine 330 Set all variables used by this section. 340 Increment the variable that controls the depth of the missile. PRINT relevant character (first character of a$) below a space to erase its last image. 350 Re-shuffle the characters of a$ to bring the next character needed to the front of the string. 360 If a depth charge has reached the bottom of the screen or the height of the cursor then erase it. 370 Check for hits, award scores. BEEP, erase any sunken submarines, reset them to the far left of the screen and give them a new random height. 380 Return from routine (line 250). After game routines 390-400 Call depressing tune (line 570) and compare last score with the 10 held in the table in turn. If the score does not rank then GOTO 530. 410 Clear the screen. 420-422 PRINT instructions in teletype style. Note that in all such routines a key press will terminate the effect and simply PRINT (though without colour) the remaining text. 425-490 Form the arcade style entering of the initials. Line 430 PRINTs the letters, lines 440-460 alter them according to key presses, line 470 is a simple delay loop, line 480 fixes an initial, moving to the next, and line 490 returns to line 430 completing the cycle. 500 Shift all the scores in the table below the latest one down 1 position in the table, discarding the lowest score. 510-520 Place latest score and initials in the table at the correct point. 530 Tow on words 'todays greatest' behind the ship, which then chugs off. 540 PRINT scores (preceeded by 0's if necessary) and initials of top 10 players. PRINT latest score initials in white. 550 PAUSE (10 seconds), clear the screen and start a new game. Game tunes 560 Play before game 'cheery' tune. 570 Play after game 'depressing' tune. Instructions 580-590 Tow on words 'sub hunt' behind the submarine (line 580) which then chugs off (line 590). 620-660 PRINT the first sheet of instructions in teletype style. 670-675 Wait for a key press then PRINT the second sheet of instructions in teletype style. Wait for a key press then clear the screen and RETURN (line 1170). Extended play routine 680-710 Decrease extremely large figure (z). 681 Increase extremely small figure (z). 685 Redraw fuel scale to the required height. 690-700 Reset variables. 710 GOTO 280. PRINT 'EXTENDED PLAY' routine 720 Set PAPER colour to cyan (5) 730-780 PRINT and erase the words 'EXTENDED PLAY' five times. 790 Set PAPER colour back to green (4) 800 RETURN. Initialise 1010 Set screen colours. 1020-1040 Create graphics. Note that my method of creating graphics is shorter than the usual ones used. 1050-1110 Data for U.D.G's. 1130-1160 Initialise strings containing instructions. 1165 Initialise graphic strings and the arrays which hold the high scores and initials. If instructions are required then GOTO the subroutine at line 580. GRAPHICS Lines Graphic 130 29 inverse spaces, 1 space, 1 inverse space 210 Graphics A,B,C and 2 spaces. 220 1 space and Graphics D,E,F. 530 Graphics A,B,C and 1 space, Graphics B,C and 1 space, Graphic C and one space, 1 space. 590 1 space and Graphics D,E,F, 1 space and Graphics D,E, 1 space and Graphic D, 1 space 1165 Graphics A,B,C,G and 8 spaces, 12 spaces and Graphics G,D,E,F. VARIABLES a Used for defining graphics. a$ String containing the four stages of the rotating bomb. c(x) Three element array containing the character codes of the three letters being entered as initials minus 65. d 'x' co-ordinate of depth charge. dc 'y' co-ordinate of depth charge. d(x) Eleven element array containing the 11 highest scores. d$(x,y) Eleven by 3 element array containing the initials of the 11 high scorers. ef Flag to show if extended play has been awarded (1 = yes) e$ High score table title f Flag to show if depth charge has been dropped. f Control variable of delay loop (independent of its other use). f$ Instructions title. g First set of instructions. hc Height of cursor. hs Height of submarine. h$ Second set of instructions. i$ Terminator of first screen of instructions. j$ Second screen of instructions. k$ Terminator of instructions. l$ High score instructions title. m$ High score instructions. n General purpose control variable. n Position of latest score in table. pb 'x' co-ordinate of boat. pf Flag to show if 'EXTENDED PLAY' message has been shown. ps 'x' co-ordinate of submarine. s Score of current player. sf Flag to show if this is the first revolution of the main loop. t Fuel remaining: Also corresponds to the 'y' coordinate of the next points of the fuel scale to be erased. tf Counter of number of times the main loop has been executed: used in decreasing the players fuel. z Value of 't' when extended play achieved. (CC) 2021, TAP and info created by Ignacio Prini (Spain)