Stellar Defense

Type
Game
Category
Text-mode shooting gallery
Author
Mike Colvin
Published in
Antic, February 1983 (Vol. 1, No. 6), "In the Public Domain"
Year
1983
Language
Atari BASIC
Requirements
Joystick in port 1, Atari BASIC
A black GRAPHICS 0 screen with a walled firing lane in the middle, the gun at the bottom, and SCORE, SHOTS, WAVE, HITS, HUMANS and HIGH counters at the sides

About the program

Antic's "In the Public Domain" pages often printed games by readers. Stellar Defense, in the February 1983 issue, was by Mike Colvin, a high-school student in Sacramento, California. The magazine said he had polished his early version with suggestions from its technical consultant, Jerry White, and it encouraged other new programmers to "keep hacking".

Invaders drop one at a time from the top of the screen, lurching left and right as they come. You move a gun along the bottom and fire upward, with only 75 shots in each wave. A hit scores more the higher up the invader is. If an invader gets to the bottom, it costs you one of your humans. A wave ends after a set number of hits. Then you get a bonus based on the humans you have left, the wave number and your hits, plus one extra human.

What you need

A joystick in port 1. No machine code, no player/missile graphics: everything is printed characters in GRAPHICS 0.

Typing it in

{CTRL-V} in line 110 is the vertical bar used for the walls. Hold CTRL and press V. {CLEAR} in line 600 is ESC then SHIFT-CLEAR. The {inv} parts of the title and game-over screens are inverse video, typed with the Atari key. The magazine's text says the game gives you four players, but this disk version starts with ten humans (H=10 in lines 830 and 2000).

How to play

At the title screen, press START to play or the fire button to read the instructions. Move left and right with the joystick, and press the button to fire. When the game is over, press the trigger to play again. The high score is kept until you RUN the program again.

How it works

  • The invader is CHR$(16) (the club symbol), the gun is CHR$(24) and the shot is CHR$(124), the vertical bar. Each one is drawn with POSITION and PRINT, and erased by printing a space over its old position.
  • Lines 174–215 are the main loop. Each pass moves the invader down a row and randomly one column left or right (Q10), then reads the joystick.
  • When you fire, the subroutine at line 20 runs the shot all the way up the column while the invader waits. If the shot's row and column ever match the invader's, it is a hit. The score (20-W)*10+100 rewards hits near the top.
  • Line 2010 turns the display off with POKE 559,0 while the screen is drawn, and line 130 turns it back on with POKE 559,34, so the walls and counters appear all at once.
  • After each wave, lines 900–921 play a short tune from DATA.

Listing

1 REM ANTIC MARCH P. 57
10 GOTO 2000
20 FOR W=20 TO 1 STEP -1:ST=0:POSITION A,W+1:? CHR$(32):SOUND 0,1,2,8:POSITION A,W:? CHR$(124);
24 IF A=Q AND W=B THEN SOUND 0,0,0,0:POSITION A,W:? CHR$(32);:POP :POP :GOTO 400
26 SOUND 0,0,0,0:NEXT W:SQ=0:RETURN
100 POKE 752,1:POSITION 1,9:? "SHOTS";:POSITION 2,10:? SHOTS;:? " "
105 POSITION 1,1:? " SCORE":POSITION 2,2:PRINT SCORE
106 POSITION 33,1:? " WAVE"
107 POSITION 34,2:? WAVE
108 POSITION 33,9:? " HITS"
109 POSITION 34,10:? HITS
110 F$="{CTRL-V}                   {CTRL-V}"
120 FOR X=0 TO 23:POSITION 9,X:? F$:NEXT X
130 A=15:POKE 559,34:SETCOLOR 1,0,14
140 Q=INT(RND(0)*33)
150 IF Q<=12 THEN Q=13
160 IF Q>28 THEN Q=28
174 FOR B=1 TO 27:POSITION Q,B-1:? CHR$(32):Q10=INT(RND(0)*51):SOUND 0,96,10,8
177 IF Q10<=20 THEN Q=Q-1:IF Q<=12 THEN Q=12
179 IF Q10>=30 THEN Q=Q+1:IF Q>=28 THEN Q=27
180 POSITION Q,B:? CHR$(16)
182 POSITION Q,B-1:? CHR$(32)
183 ST=STICK(0):SQ=STRIG(0):POSITION A,22:? CHR$(24);
185 IF ST>8 AND ST<15 THEN POSITION A,22:? CHR$(32);:A=A-1
186 IF ST>4 AND ST<9 THEN POSITION A,22:? CHR$(32);:A=A+1
187 IF A<11 THEN A=11
188 IF A=29 THEN A=28
190 POSITION A,22:PRINT CHR$(24);
213 IF B=21 THEN GOSUB 450
214 IF SQ=0 THEN GOTO 250
215 SOUND 0,210,10,8:NEXT B
250 SQ=1:SHOTS=SHOTS+1:IF SHOTS>75 THEN GOTO 800
251 POSITION 2,10:? SHOTS;:GOSUB 20
260 IF PEEK(53270)=5 THEN 9999
281 IF SHOTS=75 THEN GOTO 800
282 POSITION A,W+1:? CHR$(32)
283 SOUND 0,0,0,0
285 NEXT B
290 SQ=1
300 IF SHOTS=75 THEN GOTO 800
310 GOTO 140
400 ST=0:Q=0:S=(20-W)*10+100
401 HITS=HITS+1:POSITION 34,10:PRINT HITS:SCORE=SCORE+S
403 POSITION A-1,B:? S
404 FOR Y10=1 TO 25:SETCOLOR 1,Y10,4:SETCOLOR 2,Y10,4:SETCOLOR 4,Y10,8:SETCOLOR 1,0,14:NEXT Y10:SETCOLOR 2,0,0
405 FOR W=0 TO 120 STEP 10:SOUND 0,W,0,15-W/17:SOUND 1,128+W/2,8,8+7*RND(1):NEXT W:SOUND 1,0,0,0
406 POSITION A-1,B:? "   ":B=0
410 POSITION 2,2:? SCORE;:? " "
420 SQ=1:IF HITS=YP THEN GOSUB 600
425 IF SHOTS=75 THEN SOUND 0,0,0,0:GOTO 800
430 SOUND 0,0,0,0:GOTO 140
450 FOR B=21 TO 1 STEP -1
460 POSITION Q,B:? CHR$(16)
480 POSITION Q,B:? CHR$(32)
490 POSITION Q,B+1:? CHR$(32)
496 SOUND 0,B*10,2,8
500 NEXT B:SQ=1
501 SOUND 0,0,0,0
505 Q=Q+1:IF Q=28 THEN Q=14
506 H=H-1:IF H=0 THEN GOSUB 800
507 POSITION 2,21:? H;:? "     "
508 FOR OL=10 TO 210:SOUND 0,OL,14,8:NEXT OL
510 SOUND 0,0,0,0:RETURN
600 ? "{CLEAR}":SETCOLOR 1,0,0:SETCOLOR 2,0,14:SETCOLOR 4,0,0:POKE 752,1
610 POSITION 12,5:? " ATTACK WAVE ";:? WAVE:POSITION 13,6:? " COMPLETED"
620 BONUS=H*WAVE*HITS*10:POSITION 13,8:? " BONUS ";:? BONUS:SCORE=SCORE+BONUS
622 IF PEEK(53279)=5 THEN 9999
625 IF WAVE>0 THEN H=H+1
630 GOSUB 900
635 WAVE=WAVE+1:SOUND 0,0,0,0:G=0
636 IF WAVE>0 THEN POSITION 13,15:? " FREE HUMAN":POKE 77,0
637 IF WAVE>0 THEN FOR TU=1 TO 15:SOUND 0,35,12,8:FOR TI=1 TO 10:NEXT TI:SOUND 0,0,0,0:NEXT TU
638 SHOTS=0:HITS=0:GOTO 2010
700 GRAPHICS 0:SETCOLOR 2,0,8:SETCOLOR 1,0,0:POKE 752,1
710 ? :? "    THE OBJECT OF THIS GAME IS"
711 ? " TO HIT AS MANY INVADERS AS POSSIBLE.":?
730 ? " AT THE END OF EACH WAVE YOU GET"
731 ? " BONUS POINTS ACCORDING TO THE"
732 ? " NUMBER OF HUMANS YOU HAVE LEFT."
740 ? " YOU GET AN EXTRA HUMAN AFTER "
741 ? " EACH WAVE.":?
742 ? "           GOOD LUCK!!!"
750 ? :? :? "                 ";CHR$(16);" =? points"
751 ? :? :? " YOU HAVE ONLY 75 SHOTS PER WAVE"
752 ? " SO MAKE THEM COUNT.":? :? :? :? :? :? "PRESS THE FIRE BUTTON TO START!!!"
760 IF STRIG(0)<>0 THEN 760
761 GOTO 2008
799 REM END OF GAME
800 IF SCORE>HIGH THEN HIGH=SCORE
805 GRAPHICS 18:SOUND 0,0,0,0
810 ? #6:? #6;" game over...."
815 ? #6:? #6:? #6;"  YOUR SCORE  ";:? #6;SCORE
816 FOR VOL=15 TO 0 STEP -0.2:SOUND 0,0,2,VOL:NEXT VOL
818 ? #6:? #6:? #6;" {inv}press trigger{/inv}":? #6;" {inv}TO REPLAY{/inv}"
820 IF STRIG(0) THEN POKE 711,PEEK(20):GOTO 820
830 SCORE=0:SHOTS=50:H=10:WAVE=1:HITS=0:SHOTS=0:GOTO 2008
899 REM MUSIC FOR END OF ATTACK WAVE
900 FOR P=1 TO 60:READ VR:FOR S9=1 TO 10:SOUND 0,VR,14,8:NEXT S9:NEXT P:RESTORE 920
910 SOUND 0,0,0,0:RETURN
920 DATA 45,40,37,40,37,37,45,40,37,40,45,47,47,45,40,47,60,45,40,37,37,45,40,37,40,45,47,53,40,47,60,45,40,37
921 DATA 40,45,47,45,40,37,40,45,47,45,40,47,60,45,40,37,37,45,47,45,47,60,47,45,45,45
1000 FOR TY=2 TO 250 STEP 2:SOUND 0,TY,2,10:SETCOLOR 1,TY,9:SOUND 1,250-TY,10,4:NEXT TY
1010 SOUND 0,0,0,0:SOUND 1,0,0,0:RETURN
2000 G=0:SQ=1:WAVE=1:HIGH=HIGH:H=10:SCORE=0:SHOTS=0:DIM F$(100),A$(100),B$(100):HITS=0
2001 GRAPHICS 1+16
2002 POSITION 2,1:? #6;" steller defense"
2003 POSITION 1,15:? #6;"TO START PRESS THE  start KEY":POSITION 1,19:? #6;" {inv}FOR DIRECTIONS{/inv}"
2004 POSITION 1,21:? #6;"{inv}PRESS {/inv}fire {inv}BUTTON{/inv}"
2005 FOR U=1 TO 3000:IF STRIG(0)=1 THEN 2007
2006 SOUND 0,0,0,0:GOTO 700
2007 TTU=PEEK(53279):IF TTU<>6 THEN SETCOLOR 1,U,9:SOUND 0,RND(0)*80+50,10,8:NEXT U
2008 SOUND 0,0,0,0:GRAPHICS 2+16:POSITION 1,5:? #6;" steller defense":GOSUB 1000
2010 GRAPHICS 0:POKE 559,0:SETCOLOR 2,0,0:SETCOLOR 1,0,12:YP=INT(RND(0)*15):IF YP<9 THEN YP=9
2011 POSITION 1,20:? " HUMANS"
2012 POSITION 2,21:? H
2013 POSITION 33,20:? "HIGH"
2014 POSITION 33,21:? HIGH
2020 SETCOLOR 1,0,12:SETCOLOR 4,0,6:GOTO 100
2110 GRAPHICS 1+16

Download

The original program from the Antic disk, to LOAD or ENTER instead of typing it: STELLAR.BAS.

Credits