Home Base

Developer(s): David Naylor
Date: 1984
Type: Program
Platform(s): TS 2068
Tags: Game

Guide a diamond-shaped ship from the bottom-left corner of the screen up to HOME BASE on the top line, through a field of X obstacles. The ship climbs one row on each turn that no key is held. Keys 0 and 9 move it right and left instead, and 1 moves it down. A power pack (#), a star (.), a flying saucer (^) and a shooting star (*) are scattered across the field, and each one is worth points and an extra life. Hitting an X costs a life, and a new X appears somewhere on every turn. As your score rises, red < and > marks close in on the base line from both sides. Touching one is fatal, and past a final threshold the base disappears altogether. There are seven skill levels. You can pick one, or answer a to the opening question and have the levels build up automatically.

The REM credits David Naylor and ZX Computing (“M/A 84”), and the title screen reads “DAVID NAYLOR 1983”. It is a type-in from a British Spectrum magazine, written in plain Sinclair BASIC, and runs unchanged on the TS2068.

Program Analysis

Structure

  • Lines 1010–1130: the title, scoring table and key instructions, the automatic-level question, and the ship UDG (n) from DATA.
  • Lines 40–230: build the field with 50 Xs per level, place the four bonus objects at random and print the base line.
  • Lines 280–680: the main loop, which runs for 350/level turns and is counted on screen as “TIME GONE”.
  • Lines 690–940: death, running out of time, reaching the base, the closed base (“TOO LATE”) and the play-again prompt.
  • Lines 950–1000: bonus pickups and the X collision.

Gameplay Details

Collisions are found with SCREEN$ at the ship’s new position before the ship is redrawn, and lines 540–600 chain through each object type. Moving forward, left or right scores 2 points per level. Bonuses score 50 to 150, and reaching the base adds 200. Lives start at twice the level, up to 9. The closing marks are driven by a random multiplier x from 2 to 9, chosen afresh each turn. The score thresholds in lines 390–450 (20×, 30× and up to 280×) therefore close the base at irregular points. Past the last threshold the game ends with “TOO SLOW, YOUR BASE DISAPPEARED”. The high score is kept for the session.

Notable Techniques

  • SCREEN$ collision detection. Every object is an ordinary character, so the test is a simple string comparison.
  • PAUSE NOT PI and PRINT AT 9,NOT PI use NOT PI for 0, a common byte-saving idiom.
  • The border and paper flash through random colours in the victory sequence.

Potential Issues

  • In automatic mode, line 860 raises the level after each base is reached and ends the game with “You’re the greatest!!” as soon as it reaches 7. The build-up therefore stops after level 6, and level 7 is never played.
  • Line 40 accepts only a lower-case a for automatic mode, while lines 850 and 900 accept A as well. Typing A asks for a starting level and then advances automatically from it.

This program came from an Oliger (JLO SAFE) disk in the SNUG library set and was converted for tape. It has no disk commands, so no changes were needed. It was tested in ZEsarUX on a stock TS2068 through the instructions, the playing field and a successful “YOU’VE DONE IT!!” return to base.

Image Gallery

Source Code

   10 REM >> HOME BASE  <<                                       by David Naylor                           * ZX COMPUTING, M/A 84 
   20 GO SUB 1010: GO TO 40
   30 FOR s=0 TO sp: PRINT AT 2,s; INK 2;"<";AT 2,31-s;">": NEXT s: RETURN 
   40 IF l$="a" THEN LET di=1: GO TO 70
   50 INPUT "Level of difficulty (1-7)? ";di
   60 IF di<1 OR di>7 THEN GO TO 50
   70 LET sc=0
   80 LET l=di*2
   90 IF l>9 THEN LET l=9
  100 BORDER 1: PAPER 4: CLS 
  110 PRINT TAB 9;"PLEASE  WAIT"
  120 FOR q=0 TO 50*di
  130 LET s=INT (RND*31): LET k=INT (RND*21)+3
  140 IF k>21 THEN LET k=21
  150 PRINT AT k,s;"X"
  160 BEEP .05,RND*50
  170 IF q=50*di THEN GO TO 200
  180 PRINT AT 21,0;" "
  190 NEXT q
  200 LET c=0: LET r=21: LET sp=c
  210 FOR s=1 TO 4: PRINT AT RND*17+3,RND*31;p$(s): NEXT s
  220 PRINT AT 0,5;"PRESS ANY KEY TO MOVE "
  230 PRINT AT 2,0;" H * O * M * E    B * A * S * E  "
  240 PRINT AT r,c;"n"
  250 PAUSE 0
  260 PRINT AT 0,0; INVERSE 1,,,,
  270 PRINT AT r,c;" "
  280 FOR w=1 TO INT 350/di
  290 IF w=INT (350/di) THEN GO TO 760
  300 PRINT AT r,c;"n"
  310 IF l>9 THEN LET l=9
  320 PRINT AT 0,25; INVERSE 1;"LIVES:";l
  330 PRINT AT 0,12; INVERSE 1;"LEVEL:";di
  340 PRINT AT 0,0; INVERSE 1;"SCORE:";sc
  350 IF hi<sc THEN LET hi=sc
  360 PRINT #2; INVERSE 1;"HI SCORE:";hi
  370 LET x=INT (RND*10)
  380 IF x<2 THEN GO TO 370
  390 IF sc>20*x THEN LET sp=3: GO SUB 30
  400 IF sc>30*x THEN LET sp=6: GO SUB 30
  410 IF sc>90*x THEN LET sp=8: GO SUB 30
  420 IF sc>120*x THEN LET sp=9: GO SUB 30
  430 IF sc>180*x THEN LET sp=12: GO SUB 30
  440 IF sc>220*x THEN LET sp=14: GO SUB 30
  450 IF sc>280*x THEN PRINT AT 2,0;"       T O O     L A T E        ": PAUSE 200: GO TO 920
  460 PRINT AT r,c;" "
  470 IF INKEY$="0" THEN LET c=c+1: LET sc=sc+(di*2)
  480 IF INKEY$="1" THEN LET r=r+1
  490 IF INKEY$="9" THEN LET c=c-1: LET sc=sc+(di*2)
  500 IF INKEY$="" THEN LET r=r-1: LET sc=sc+(di*2)
  510 IF r>20 THEN LET r=21
  520 IF c<0 THEN LET c=0
  530 IF c>31 THEN LET c=31
  540 IF SCREEN$ (r,c)="#" THEN GO TO 950
  550 IF SCREEN$ (r,c)="." THEN GO TO 960
  560 IF SCREEN$ (r,c)="^" THEN GO TO 970
  570 IF SCREEN$ (r,c)="*" THEN GO TO 980
  580 IF SCREEN$ (r,c)="X" THEN GO TO 990
  590 IF SCREEN$ (r,c)="<" THEN GO TO 690
  600 IF SCREEN$ (r,c)=">" THEN GO TO 690
  610 PRINT AT 1,18; INVERSE 1;"TIME GONE: ";w
  620 IF r=2 THEN GO TO 790
  630 LET x=INT (RND*31)
  640 LET z=INT (RND*21)
  650 IF z<3 THEN GO TO 630
  660 PRINT AT z,x;"X"
  670 IF r<2 THEN LET r=2
  680 NEXT w
  690 PRINT AT 10,9;"YOU'RE DEAD!!!"
  700 FOR a=0 TO -20 STEP -1: BEEP .05,a: NEXT a
  710 CLS : PRINT AT 10,9;"AGAIN? (Y or N)"
  720 INPUT LINE a$
  730 IF hi<scs THEN LET hi=scs
  740 IF a$="Y" OR a$="y" THEN LET scs=0: CLS : GO TO 40
  750 STOP 
  760 PRINT AT 10,6;"YOU RAN OUT OF TIME"
  770 FOR a=0 TO 25: BEEP .01,a-10: BEEP .01,a+10: NEXT a
  780 GO TO 710
  790 LET sc=sc+200: PRINT AT 10,8;"YOU'VE DONE IT!!"
  800 FOR a=1 TO 3: FOR s=1 TO 15
  810 BORDER RND*6: PAPER RND*6
  820 BEEP .05,s: NEXT s: NEXT a
  830 CLS : LET scs=scs+sc
  840 IF hi<scs THEN LET hi=scs
  850 IF l$<>"a" AND l$<>"A" THEN GO TO 880
  860 LET di=di+1: IF di<7 THEN GO TO 880
  870 PRINT AT 10,7; PAPER 7; INK 4;"You're the greatest!!": PAUSE 50: PRINT AT 15,6;"Your final score is ";scs: LET scs=0: PAUSE 200: GO TO 710
  880 PRINT AT 10,8; PAPER 7; FLASH 1;"Your score is: ";scs: PAUSE 200
  890 LET scs=0
  900 PAPER 7: CLS : IF l$="a" OR l$="A" THEN GO TO 80
  910 GO TO 50
  920 PRINT AT 10,0;"TOO SLOW, YOUR BASE DISAPPEARED"
  930 FOR a=1 TO 30: BEEP .01,1+20: BEEP .01,a-30: NEXT a
  940 GO TO 710
  950 LET sc=sc+100: LET l=l+1: BEEP .01,30: GO TO 550
  960 LET sc=sc+50: LET l=l+1: BEEP .01,20: GO TO 560
  970 LET sc=sc+150: LET l=l+1: BEEP .01,10: GO TO 570
  980 LET sc=sc+50: LET l=l+1: BEEP .01,40: GO TO 580
  990 LET l=l-1: BEEP .01,50: IF l=0 THEN GO TO 690
 1000 GO TO 590
 1010 PAPER 7: CLS : LET hi=0: LET scs=hi
 1020 PRINT AT 21,6;"DAVID NAYLOR   1983"
 1030 PRINT AT 9,NOT PI; INK 1;"                                 H * O * M * E    B * A * S * E                                 "
 1040 FOR r=1 TO 20: BEEP .05,r: BEEP .01,r+10: BEEP .001,r-20: NEXT r
 1050 PAUSE 50: CLS : PRINT "SCORING :"'"2,4,6,8,10,12,14pts depending onlevel for moving: forwards",,"  left",,"  right"," 50pts for a shooting star (*)         for a star (.)","100pts for a power pack (#)","150pts for a flying saucer (^)  200pts on completing return"''"SKILL LEVELS:"'"1...50*(X) ,350 secs"'"2..100*(X) ,175 secs"'"3..150*(X) ,113 secs","4..200*(X) , 85 secs"
 1060 PRINT "5..250*(X) , 70 secs","6..300*(X) , 58 secs","7..350*(X) , 50 secs"
 1070 PRINT AT 21,9;"PRESS A KEY": PAUSE 0: CLS : PRINT '''''"USE"'"'0' for right"'"'9' for left"'"'1' for down"'"You move forwards automatically"
 1080 PRINT #1;"     PRESS A KEY TO START": PAUSE NOT PI: CLS 
 1090 INPUT "If you want skill levels to"'"build up automatically (1-7),   then press 'a'."; LINE l$
 1100 LET P$="#.^*"
 1110 FOR l=0 TO 7
 1120 DATA 24,60,126,255,126,60,24,0
 1130 READ n: POKE USR "n"+l,n: NEXT l: RETURN

Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.