Tie Fighter

Type
Game
Category
First-person space shooter
Author
Jimmy and Tommy Sa
Published in
The Best of Antic, Volume 1 (Antic Publishing), one of the book's new games
Language
Atari BASIC
Requirements
16K RAM (cassette) or 24K (disk), joystick in port 1, Atari BASIC
Tie Fighter title screen in GRAPHICS 17: LEVEL - 1, the title in angle brackets and prompts to press SELECT for level and START to play

About the program

Tie Fighter by Jimmy and Tommy Sa was one of the new games in The Best of Antic, Volume 1. It sits nicely next to David Plotkin's Attack on the Death Star, which the book also reprinted. You look out of a fighter's cockpit at a GRAPHICS 7 starfield, with a sighting frame and crosshairs in the middle. An enemy Tie fighter appears and dodges about. Steer to bring it into the centre and press the button to fire twin lasers from the corners of the screen.

Each shot uses one unit of your 40 units of energy. A fighter that escapes off the screen, or survives until the timer runs out, counts as a miss and joins the attack on your base. Ten misses and the rebel base is overrun. Run out of energy and you can't fight at all. Every 10 hits refuels you to 40, clears the misses and raises the level. There are four starting levels, and the game keeps speeding up beyond level four.

What you need

A joystick in port 1. The book asks for 16K with cassette or 24K with a disk drive.

Typing it in

The listing uses inverse video ({inv}…{/inv}, toggled with the Atari key) and a few control characters. {CLEAR} is ESC then SHIFT-CLEAR. {UP} is ESC then CTRL-minus. {TAB} is ESC then TAB. {CTRL-,} is CTRL and comma, the heart character. Lines 590 and 760 need 12 of them, as their REMs say. Lines 1080–1090 are the machine code for the title screen's colour effect. The DATA in lines 1210–1240 is never READ, so you can leave it out.

How to play

On the title screen, SELECT changes the level and START begins. Push the joystick to steer. The Tie fighter moves the opposite way across your sights. Fire when it sits under the crosshairs, since a direct hit is needed to bring it down. The space bar pauses and resumes the game. After the game ends, press the trigger to play again.

How it works

  • The Tie fighter is player 0. As the book explained, PM$ is a string DIMmed to 2048 bytes and aligned so that it lies exactly on the player/missile area (lines 400–460). Moving the player up or down is one fast string assignment, PM$(P0+Y,P0+Y+7)=P0$, which is far quicker than a loop of POKEs.
  • When you fire, line 170 moves player 1, a tiny dot, to the centre of the screen and reads the player-to-player collision register at 53260. Any value there means the shot hit.
  • Lines 270–290 find the text window in the display list and change its lines to ANTIC mode 6, so the status lines appear in large GRAPHICS 1-sized letters.
  • RAINBOW$ (lines 1070–1090) is a 32-byte routine called by USR. It writes a stream of changing values to a colour register, waiting for WSYNC between each, so the title text shimmers with bands of colour.

Listing

10 REM ***TIE-FIGHTER***
20 REM BY JIMMY AND TOMMY SA
30 GOSUB 1040:GOSUB 250:GOSUB 400:GOTO 110
40 REM {inv}PLOT LASER ROUTINE{/inv}
50 SOUND 0,1,4,6:FOR I=1 TO 4 STEP 3:COLOR I:PLOT 0,89:DRAWTO 75,37:PLOT 159,89:DRAWTO 75,37:NEXT I:E=E-1
60 POKE 53278,15:POKE 53249,0
70 IF A>0 THEN SOUND 0,0,0,0:GOSUB 540
80 IF E=0 THEN POP :POKE 53248,0:GOTO 990
90 ? "{UP}{UP}{inv}energy{/inv}  {inv}HITS{/inv}  MISSES";"  ";E;"     ";SC;"     ";MI;" ":? "    {inv}time{/inv} :";" "
100 REM {inv}MAIN LOOP{/inv}
110 POKE 77,0:POKE 53248,X:PM$(P0+Y,P0+Y+7)=P0$:SOUND 0,100,24,4*(S<>15):POKE 709,110-(R<0.1)*110
120 SOUND 1,20,8,1:C=C+1:T=T-1:R=RND(0):Y=Y+V:X=X+H*HARDERS:S=STICK(0)
130 IF T<1 THEN GOSUB 750:GOTO 110
140 IF C>6-HARDERS THEN SOUND 1,230,10,4:C=0
150 ? "{UP}    {inv}time{/inv} :";T;" "
160 IF X>204 OR X<47 OR Y>90 OR Y<14 THEN GOSUB 750
170 IF STRIG(0)=0 THEN POKE 53249,119:A=PEEK(53260):GOSUB 50:SOUND 0,0,0,0
180 V=-(S=13 OR S=5)+(S=14 OR S=10)
190 H=-(S=7 OR S=6)+(S=9 OR S=11)
200 IF V=0 THEN V=-(R>0.98)+(R<0.97)
210 IF H=0 THEN H=-(R>0.98)+(R<0.97)
220 IF PEEK(764)<>255 THEN GOSUB 810
230 GOTO 110
240 REM {inv}DRAW PLAYFIELD{/inv}
250 GRAPHICS 7:POKE 752,1:POKE 82,0
260 POKE 708,106:SETCOLOR 2,6,0:COLOR 1
270 A=PEEK(560)+PEEK(561)*256+4
280 IF PEEK(A)<>66 THEN A=A+1:GOTO 280
290 POKE A,70:POKE A+3,6:POKE A+4,6:POKE A+5,6
300 RESTORE
310 FOR I=1 TO 28:READ A,R:PLOT A,R:READ A,R:DRAWTO A,R:NEXT I
320 DATA 75,0,75,33,75,42,75,76,78,42,83,42,83,42,83,40,83,38,139,38,67,42,67,40,67,38,19,38,67,36,67,33,67,33
330 DATA 72,33,78,33,83,33,83,33,83,36,67,42,72,42,113,34,113,42,105,41,105,35,97,36,97,40,90,39,90,37,59,37
340 DATA 59,39,52,40,52,36,44,35,44,41,35,42,35,34,71,48,79,48,77,53,73,53,71,58,79,58,73,63,77,63
350 DATA 77,14,73,14,71,18,79,18,73,23,77,23,71,28,79,28,72,28
360 COLOR 2:FOR A=1 TO 10:PLOT RND(0)*159,RND(0)*89:NEXT A
370 COLOR 1:FOR A=1 TO 20:PLOT RND(0)*159,RND(0)*89:NEXT A
380 RETURN
390 REM {inv}SET UP PLAYER-MISSILE GRAPHICS{/inv}
400 DIM PM$(2048),P0$(7):X=70:Y=20
410 A=ADR(PM$)
420 PMBASE=INT(A/1024)*1024
430 IF PMBASE<A THEN PMBASE=PMBASE+1024
440 S=PMBASE-A
450 POKE 559,46:POKE 54279,PMBASE/256:POKE 704,102:POKE 53277,3
460 PM$=CHR$(0):PM$(2048)=CHR$(0):PM$(2)=PM$
470 RESTORE 490
480 FOR I=1 TO 7:READ A:P0$(I,I)=CHR$(A):NEXT I
490 DATA 0,153,189,255,189,153,0
500 P0=S+512:PM$(P0+Y,P0+Y+7)=P0$:POKE 53248,X:PM$(P0+183,P0+183)=CHR$(28)
510 GOSUB 660
520 RETURN
530 REM {inv}EXPLOSION{/inv}
540 SOUND 1,0,0,0
550 FOR I=1 TO 30:POKE 704,RND(0)*200+14:NEXT I
560 FOR I=1 TO 30:POKE 704,RND(0)*200+14:PM$(P0+Y+I/3,P0+Y+I/3)=CHR$(RND(0)*20)
570 SOUND 0,200+I,8,16-I/2:SOUND 1,9*I,16,16-I/2:SOUND 2,200+I,8,15:NEXT I
580 SOUND 0,0,0,0:SOUND 1,0,0,0:SOUND 2,0,0,0
590 PM$(P0+Y,P0+Y+12)="{CTRL-,}{CTRL-,}{CTRL-,}{CTRL-,}{CTRL-,}{CTRL-,}{CTRL-,}{CTRL-,}{CTRL-,}{CTRL-,}{CTRL-,}{CTRL-,}":REM 12 HEART-CHARACTERS
600 SC=SC+1
610 IF SC/10<>INT(SC/10) OR SC=0 THEN 640
620 HARDERS=HARDERS+1:E=40:MI=0
630 FOR I=1 TO 60:POKE 53279,RND(0)*2:NEXT I
640 X=INT(RND(0)*100+70):Y=20:PM$(P0+Y,P0+Y+7)=P0$:POKE 704,102:POKE 53248,0
650 REM {inv}WARNING ROUTINE{/inv}
660 ? "{CLEAR}     RED {inv}ALERT{/inv}"
670 FOR R=1 TO 2:FOR I=1 TO 2:SOUND 0,116*I,10,8:FOR A=1 TO 20:NEXT A:SETCOLOR 4,4,6
680 FOR A=1 TO I*28:NEXT A:NEXT I
690 SOUND R,0,0,0:FOR A=1 TO 50:NEXT A:NEXT R
700 T=100+HARDERS*10+100*(HARDERS=1):V=1:SETCOLOR 4,0,0:SOUND 0,0,0,0
710 ? "{CLEAR}{inv}energy{/inv}  {inv}HITS{/inv}  MISSES";"  ";E;"     ";SC;"     ";MI:? "    {inv}time{/inv} :";" "
720 FOR I=1 TO 100:NEXT I
730 SOUND 1,24,8,1:POKE 53248,X:RETURN
740 REM {inv}ESCAPE ROUTINE{/inv}
750 SOUND 0,0,0,0:SOUND 1,0,0,0:MI=MI+1
760 PM$(P0+Y,P0+Y+12)="{CTRL-,}{CTRL-,}{CTRL-,}{CTRL-,}{CTRL-,}{CTRL-,}{CTRL-,}{CTRL-,}{CTRL-,}{CTRL-,}{CTRL-,}{CTRL-,}":REM 12 HEART-CHARACTER
770 FOR I=1 TO 10:POKE 53279,RND(0)*1:NEXT I
780 IF MI=10 THEN POKE 53248,0:POP :GOTO 920
790 GOSUB 640:SOUND 1,20,8,1:RETURN
800 REM {inv}STOP ROUTINE{/inv}
810 SOUND 0,0,0,0:SOUND 1,0,0,0:POKE 764,255
820 IF PEEK(764)=255 THEN 820
830 SOUND 1,20,8,1:POKE 764,255:RETURN
840 REM {inv}GAME OVER ROUTINE{/inv}
850 SOUND 0,0,0,0:POKE 53248,0:POKE 53278,15
860 ? :? "    {inv}score{/inv}    {inv}:{/inv}";SC:?
870 ? " {inv}press{/inv} {inv}trigger{/inv}{TAB}{inv}to{/inv} {inv}play{/inv} {inv}again!{/inv}":POP
880 POKE 77,128:X=USR(ADR(RAINBOW$),1)
890 IF STRIG(0)=1 THEN 880
900 RUN
910 REM {inv}REBEL BASE DESTROYED{/inv}
920 ? "{CLEAR}    {inv}rebel{/inv} base {inv}IS{/inv}      under {inv}attack!!!{/inv}"
930 COLOR 4:FOR I=0 TO 80:PLOT 0,I:DRAWTO 159,I:POKE 712,(RND(0)<0.5)*50:SOUND 0,I*6,8,4:NEXT I
940 SOUND 0,0,0,0:FOR I=1 TO 3
950 FOR A=0 TO 30:SOUND 0,A*8,8,20-A/2+I:SOUND 1,A*8,16,20-A/2+I:POKE 712,RND(0)*255:NEXT A
960 NEXT I:SETCOLOR 4,0,0
970 GRAPHICS 17:POKE 87,0:POKE 82,2
980 ? :? " {inv}rebel base is{/inv}{TAB}   {inv}overran...{/inv}":? :? " {inv}all is lost!!{/inv}":GOTO 850
990 SOUND 1,0,0,0:SOUND 0,0,0,0
1000 ? "{CLEAR} you {inv}DON'T{/inv} have {inv}ANY{/inv}  {inv}energy{/inv} to {inv}fight!!!{/inv}"
1010 FOR I=1 TO 200:NEXT I
1020 GOTO 920
1030 REM {inv}SELECT ROUTINE{/inv}
1040 GRAPHICS 17:DIM RAINBOW$(32)
1050 HARDERS=1:E=40:SC=0:MI=0:V=1:H=1
1060 RESTORE 1080
1070 FOR I=1 TO 32:READ A:RAINBOW$(I,I)=CHR$(A):NEXT I
1080 DATA 104,104,104,72,162,57,160,0,173,0,210,101,20,141,25,208,141,10,212
1090 DATA 136,208,242,202,208,237,104,56,233,1,208,228,96
1100 POSITION 2,3:? #6;" {inv}level{/inv} - "
1110 POSITION 2,15:? #6;"{inv}press{/inv}":? #6
1120 ? #6;"  {inv}select for level{/inv}"
1130 ? #6;"  {inv}start  to  play{/inv}"
1140 SOUND 0,254,10,10:SOUND 1,255,10,10
1150 POSITION 4,10:? #6;"<{inv}tie{/inv}-{inv}fighter{/inv}>"
1160 POSITION 11,3:? #6;HARDERS:A=PEEK(53279)
1170 IF A=6 THEN T=100+HARDERS*10+100*(HARDERS=1):SOUND 0,0,0,0:SOUND 1,0,0,0:RETURN
1180 IF A=5 THEN HARDERS=HARDERS+1:IF HARDERS>4 THEN HARDERS=1
1190 A=USR(ADR(RAINBOW$),1)
1200 GOTO 1160
1210 DATA 202,189,1,6,157,2,6
1220 DATA 224,0,208,245,173,61,6
1230 DATA 141,1,6,162,0,189,10,6,157,9,6,232,224,7,208,245,173,62,6,141,16,6,169,0
1240 DATA 141,60,6,238,60,6,104,170,104,76,98,228

Download

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

Credits