Starbase 13

Type
Game
Category
Fixed-base space shoot-'em-up
Author
Mark Lewis Baldwin
Published in
SoftSide (listed as a 1982 SoftSide Publications title); the listing is dated May 1981 and also circulated on the BELLCOM public domain disks
Year
1981
Language
Atari BASIC
Requirements
Any 8-bit Atari with 16K+ and Atari BASIC; joystick in port 1
Title screen on a blue background: STARBASE 13 in large orange letters, the last stand! in green, and By Mark Lewis Baldwin in small text

About the program

Starbase 13: the last stand! is a compact defence game in pure Atari BASIC, dated May 1981 in its header. A cross-shaped star base sits in the middle of a GRAPHICS 7 star field. Alien ships appear at the edges above, below, left and right, launch missiles at you, and gradually move in closer. You have one laser, which can fire in any of the four directions. Shooting an alien scores 50 and stopping a missile scores 5, and every pass of the main loop that you survive adds a point. If a single missile reaches the base, the game is over. The program was sold as a SoftSide Publications title and also turned up on the BELLCOM public domain disks.

What you need

Any Atari with Atari BASIC and 16K or more, and a joystick in port 1. There are no machine-language routines, so it's an easy, safe type-in.

Typing it in

  • The listing is plain ASCII with no special characters. The lower-case the last stand! and your base was destroyed!!! are printed in large text modes, where lower case simply gives a different colour.
  • Several groups of lines are mirror images (1010–1040, 3010–3040, 4100–4410). Each handles one of the four directions, so an error in one direction only shows up when an alien attacks from that side.

How to play

Press the joystick button to start. Push the stick up, right, down or left to swing your gun turret to that side of the base, and press fire to shoot a laser beam out in that direction. Then release the button before you fire again. Watch the edges: an alien appears, launches a missile with a whoosh, and the missile creeps towards the base one step at a time. Hit the missile or, better, the ship.

Two details make it more than a reflex test:

  • Don't fire wildly. Every sixth shot the program sets a flag (lines 250 and 400). The next time no aliens are on screen, they move two pixels closer, down to a minimum distance, which leaves you less time to react.
  • The pace increases. Every 20 passes of the main loop, the delay between attacks (AT) drops by one.

Pressing any console key (START, SELECT or OPTION) switches the fire button between joystick 1 and joystick 2. One beep means port 1 and two beeps mean port 2. Steering always uses joystick 1. After the explosion the screen shows your score and the best score so far. Press fire to play again.

How it works

The title screen is a hand-built display list. Lines 10–20 turn the first rows of the GRAPHICS 0 list into large-text modes 6 and 7, so the title and the credit line share one screen. The game is driven by one big loop (lines 200–730) that does a little of everything on each pass: it reads the stick, draws or erases the turret (lines 3000–3040), moves each of the four possible missiles stored in MI(1)–MI(4), and counts down two independent alien timers. Aliens and missiles are simply plotted and unplotted pixels in GRAPHICS 7. Collision detection is pure arithmetic: a shot hits whatever is stored for that direction.

Variations to try

  • Make the missiles faster by raising MS=4 in line 180, or slower by lowering it.
  • Change TSPD=20 in line 190 to adjust how quickly the attacks speed up.

Listing

0 REM *****************************
1 REM *** STARBASE 13           ***
2 REM *** BY MARK LEWIS BALDWIN ***
3 REM *** MAY 1981              ***
4 REM *****************************
5 DIM MI(4):CONSOL=53279
10 GRAPHICS 0:SETCOLOR 2,6,1:SETCOLOR 4,6,1:UB=PEEK(560)+PEEK(561)*256+4:POKE UB-1,70:POKE UB+2,7:POKE UB+3,7
20 FOR I=4 TO 8:POKE UB+I,6:NEXT I:POKE UB+22,65:POKE UB+23,PEEK(560):POKE UB+24,PEEK(561):SETCOLOR 3,8,6
30 POSITION 4,1:? #6;"STARBASE 13"
40 POKE 87,1:POSITION 2,7:? #6;"the last stand!"
50 POKE 752,1:POKE 87,0:POSITION 5,14:? "By Mark Lewis Baldwin"
60 IF PEEK(CONSOL)<>7 THEN GOSUB 5500
70 IF STRIG(0)<>0 THEN 60
100 GRAPHICS 23:SETCOLOR 0,1,10:SETCOLOR 1,6,8:SETCOLOR 2,12,6:SETCOLOR 4,0,0:COLOR 1:FOR I=1 TO 40
110 PLOT 159*RND(0),95*RND(0):NEXT I
120 PLOT 74,42:DRAWTO 76,42:PLOT 84,42:DRAWTO 86,42
130 PLOT 74,43:DRAWTO 76,43:PLOT 84,43:DRAWTO 86,43
140 PLOT 74,44:DRAWTO 86,44:FOR I=45 TO 51:PLOT 76,I:DRAWTO 84,I:NEXT I:PLOT 74,52:DRAWTO 86,52
150 PLOT 74,53:DRAWTO 76,53:PLOT 84,53:DRAWTO 86,53
160 PLOT 74,54:DRAWTO 76,54:PLOT 84,54:DRAWTO 86,54
170 FOR I=1 TO 4:MI(I)=0:NEXT I
180 AT=20:ALNT1=2+RND(0)*5:ALNP1=0:ALNT2=RND(0)*AT:ALNP2=0:MS=4
190 TSPD=20:S3=200:ESTP=5:ARNG=47:SC=0:POKE 77,0
200 SC=SC+1:GOSUB 5310:T=T+1:IF T>TSPD THEN AT=AT-1:T=0:IF AT<1 THEN AT=1
205 GOSUB 2000:IF FF=1 AND BASE<>0 THEN 250
210 IF BASE=0 THEN 225
215 IF P=0 OR P=BASE THEN 300
220 COLOR 0:GOSUB 3000:BASE=0:GOTO 300
225 IF P=0 THEN 300
230 COLOR 1:BASE=P:GOSUB 3000:GOTO 300
250 FF=2:E=E+1:IF E>ESTP THEN E=0:RNGF=1
260 R=47:HF=1:IF ABS(ALNP1)=BASE THEN HF=2:R=ARNG-3:AF=1:GOTO 280
270 IF ABS(ALNP2)=BASE THEN HF=2:R=ARNG-3:AF=2
280 IF MI(BASE)>6 THEN HF=3:R=MI(BASE)
290 GOSUB 1000:IF STRIG(TRIG)<>0 THEN FF=0
300 Q=Q+1:IF Q>4 THEN GOTO 400
310 IF MI(Q)=0 THEN 200
315 MI(Q)=MI(Q)-MS:IF MI(Q)<2 THEN 1500
320 ON Q GOTO 330,340,350,360
330 COLOR 0:PLOT 80,48-MI(Q)-MS:COLOR 3:PLOT 80,48-MI(Q):GOTO 200
340 COLOR 0:PLOT 80+MI(Q)+MS,48:COLOR 3:PLOT 80+MI(Q),48:GOTO 200
350 COLOR 0:PLOT 80,48+MI(Q)+MS:COLOR 3:PLOT 80,48+MI(Q):GOTO 200
360 COLOR 0:PLOT 80-MI(Q)-MS,48:COLOR 3:PLOT 80-MI(Q),48:GOTO 200
400 IF RNGF=1 THEN IF ALNP1=0 AND ALNP2=0 AND ARNG>10 THEN ARNG=ARNG-2:RNGF=0
410 IF Q>5 THEN Q=0:GOTO 600
500 ALNT1=ALNT1-1:IF ALNT1>0 THEN 200
530 IF ALNP1>0 THEN 570
540 IF ALNP1<0 THEN COLOR 0:GOSUB 4000:ALNP1=0:ALNT1=INT(RND(0)*AT)+1:GOTO 200
550 ALNP1=INT(RND(0)*4+1):ALNT1=AT:IF MI(ALNP1)<>0 OR ALNP2=ALNP1 THEN ALNP1=0:ALNT1=0:GOTO 200
560 COLOR 3:GOSUB 4000:IF RND(0)*AT>0.5 THEN 200
570 MI(ALNP1)=ARNG-4:GOSUB 5100:ALNT1=AT:ALNP1=-ALNP1:COLOR 3:ON -ALNP1 GOTO 700,710,720,730
600 ALNT2=ALNT2-1:IF ALNT2>0 THEN 200
630 IF ALNP2>0 THEN 670
640 IF ALNP2<0 THEN COLOR 0:GOSUB 4010:ALNP2=0:ALNT2=INT(RND(0)*AT)+1:GOTO 200
650 ALNP2=INT(RND(0)*4+1):ALNT2=AT:IF MI(ALNP2)<>0 OR ALNP2=ABS(ALNP1) THEN ALNP2=0:ALNT2=0:GOTO 200
660 COLOR 3:GOSUB 4010:IF RND(0)*AT>0.5 THEN 200
670 MI(ALNP2)=ARNG-4:GOSUB 5100:ALNT2=AT:ALNP2=-ALNP2:COLOR 3:ON -ALNP2 GOTO 700,710,720,730
700 PLOT 80,52-ARNG:GOTO 200
710 PLOT 76+ARNG,48:GOTO 200
720 PLOT 80,44+ARNG:GOTO 200
730 PLOT 84-ARNG,48:GOTO 200
1000 COLOR 2:ON BASE GOTO 1010,1020,1030,1040
1010 PLOT 80,41:DRAWTO 80,48-R:GOSUB 5000:COLOR 0:PLOT 80,41:DRAWTO 80,48-R:GOTO 1050
1020 PLOT 87,48:DRAWTO 80+R,48:GOSUB 5000:COLOR 0:PLOT 87,48:DRAWTO 80+R,48:GOTO 1050
1030 PLOT 80,55:DRAWTO 80,48+R:GOSUB 5000:COLOR 0:PLOT 80,55:DRAWTO 80,48+R:GOTO 1050
1040 PLOT 73,48:DRAWTO 80-R,48:GOSUB 5000:COLOR 0:PLOT 73,48:DRAWTO 80-R,48
1050 ON HF GOTO 1060,1080,1070
1060 RETURN 
1070 MI(BASE)=0:SC=SC+5:GOSUB 5200:RETURN 
1080 SETCOLOR 4,0,14:GOSUB 5300:COLOR 0:SC=SC+50
1090 IF AF=1 THEN GOSUB 4000:SETCOLOR 4,0,0:ALNP1=0:ALNT1=AT:RETURN 
1100 GOSUB 4010:SETCOLOR 4,0,0:ALNP2=0:ALNT2=AT:RETURN 
1500 SETCOLOR 1,0,14:COLOR 2:FOR I=0 TO 12:A=80-I:B=80+I:C=48-I:D=48+I:SETCOLOR 4,0,14*BC:BC=1-BC:SOUND 0,6,0,I+3
1510 SOUND 1,21,0,I+3:SOUND 2,27,0,I+3:SOUND 3,40,0,I+3:PLOT A,C:DRAWTO B,C:DRAWTO B,D:DRAWTO A,D:DRAWTO A,C:NEXT I
1515 COLOR 0:FOR I=15 TO 0 STEP -1:A=80-I:B=80+I:C=48-I:D=48+I:SOUND 0,2,0,I:SOUND 1,15,0,I:SOUND 2,20,0,I
1520 SOUND 3,30,0,I:PLOT A,C:DRAWTO B,C:DRAWTO B,D:DRAWTO A,D:DRAWTO A,C:FOR J=1 TO 20:NEXT J:NEXT I
1530 GRAPHICS 18:POSITION 2,2:? #6;"your base was        destroyed!!!":POSITION 2,5:? #6;"YOUR SCORE WAS"
1540 POSITION 5,6:? #6;SC:POSITION 1,8:? #6;"THE TOP SCORE WAS":POSITION 5,9:? #6;SCT
1550 IF SC>SCT THEN SCT=SC
1560 IF PEEK(CONSOL)<>7 THEN GOSUB 5500
1570 IF STRIG(0)<>0 THEN 1560
1580 GOTO 100
2000 IF STRIG(TRIG)=0 THEN 2100
2005 ST=STICK(0):IF ST=11 THEN P=4:GOTO 2035
2010 IF ST=14 THEN P=1:GOTO 2035
2020 IF ST=13 THEN P=3:GOTO 2035
2030 IF ST=7 THEN P=2:GOTO 2035
2035 IF FF=2 THEN FF=0
2040 RETURN 
2100 IF FF=0 THEN FF=1
2110 RETURN 
3000 ON BASE GOTO 3010,3020,3030,3040
3010 PLOT 80,42:PLOT 79,43:DRAWTO 81,43:RETURN 
3020 PLOT 86,48:PLOT 85,47:DRAWTO 85,49:RETURN 
3030 PLOT 80,54:PLOT 81,53:DRAWTO 79,53:RETURN 
3040 PLOT 74,48:PLOT 75,49:DRAWTO 75,47:RETURN 
4000 ON ABS(ALNP1) GOTO 4100,4200,4300,4400
4010 ON ABS(ALNP2) GOTO 4100,4200,4300,4400
4100 PLOT 78,48-ARNG:DRAWTO 82,48-ARNG:PLOT 82,49-ARNG:PLOT 80,49-ARNG:PLOT 78,49-ARNG:PLOT 80,50-ARNG
4110 PLOT 79,51-ARNG:DRAWTO 81,51-ARNG:RETURN 
4200 PLOT 80+ARNG,46:DRAWTO 80+ARNG,50:PLOT 79+ARNG,50:PLOT 79+ARNG,48:PLOT 79+ARNG,46:PLOT 78+ARNG,48
4210 PLOT 77+ARNG,47:DRAWTO 77+ARNG,49:RETURN 
4300 PLOT 78,48+ARNG:DRAWTO 82,48+ARNG:PLOT 78,47+ARNG:PLOT 80,47+ARNG:PLOT 82,47+ARNG:PLOT 80,46+ARNG
4310 PLOT 79,45+ARNG:DRAWTO 81,45+ARNG:RETURN 
4400 PLOT 80-ARNG,46:DRAWTO 80-ARNG,50:PLOT 81-ARNG,50:PLOT 81-ARNG,48:PLOT 81-ARNG,46:PLOT 82-ARNG,48
4410 PLOT 83-ARNG,49:DRAWTO 83-ARNG,47:RETURN 
5000 FOR II=10 TO 30:SOUND 0,II,10,10:NEXT II:SOUND 0,0,0,0:RETURN 
5100 FOR II=15 TO 0 STEP -1:SOUND 1,50-2*II,10,II:NEXT II:SOUND 0,0,0,0:RETURN 
5200 SOUND 3,200,12,14:FOR II=1 TO 10:NEXT II:SOUND 3,0,0,0:RETURN 
5300 S3=40
5310 S3=S3+5:IF S3>120 THEN SOUND 2,0,0,0:RETURN 
5320 SOUND 2,S3,8,(150-S3)/10:RETURN 
5500 TRIG=1-TRIG:FOR ITR=0 TO TRIG:SOUND 0,100,10,8:FOR II=1 TO 20:NEXT II:SOUND 0,0,0,0:FOR II=1 TO 20:NEXT II
5510 NEXT ITR:RETURN 

Credits