Retrocomputing

Super startrek

The Super startrek program is one of the games in the famous The Best of Creative Computing Volume 1 published in 1976. In the book it is called Super Star Trek. This version of Star Trek was created for a Data General Nova 800 system with 32k of core. It appears to have been written for Extended BASIC.

Program listing

0010 REM (VERSION "STREK7", 1/12/75 RCL)
0020 REM 
0030 REM 
0040 REM ***  *** STAR TREK *** ***
0050 REM *** SIMULATION OF A MISSION OF THE STARSHIP ENTERPRISE.
0060 REM *** AS SEEN ON THE STAR TREK TV SHOW.
0070 REM *** ORIGINAL PROGRAM BY MIKE MAYFIELD, MODIFIED VERSION
0080 REM *** PUBLISHED IN DEC'S "101 BASIC GAMES", BY DAVE AHL.
0090 REM *** MODIFICATIONS TO THE LATTER (PLUS DEBUGGING) BY
0100 REM *** BOB LEEDOM -- APRIL & DECEMBER 1974,
0110 REM *** WITH A LITTLE HELP FROM HIS FRIENDS ...
0120 REM *** COMMENTS, EPITHETS, AND SUGGESTIONS SOLICITED
0130 REM *** ADDRESS TO: R.C.LEEDOM
0140 REM *** WESTINGHOUSE DEFENSE & ELECTRONIC SYSTEMS CNTR.
0150 REM *** BOX 745, M.S. 338 BALTIMORE, MD 21203
0160 RANDOMIZE
0170 PRINT TAB(15); "* * * STAR TREK * * *"
0180 PRINT
0190 PRINT " DO YOU NEED INSTRUCTIONS (YES/NO)";
0200 DIM A$[20]
0210 INPUT A$
0220 IF A$<>"YES" THEN GOTO 0240
0230 CHAIN "STINST"
0240 REM PROGRAM BEGINS HERE .....
0250 DIM Z$[72],Q$[72],R$[72],S$[72]
0260 DIM G1$[150],G2$[16],G3$[3],G4$[3]
0270 FOR I=1 TO 72
0280   LET Z$[I,I]=" "
0290   LET Q$[I,I]=" "
0300   LET R$[I,I]=" "
0310   LET S$[I,I]=" "
0320 NEXT I
0330 DIM G[8,8],C[9,2],K[3,3],N[3],Z[8,8]
0340 DIM O1$[40],C$[10]
0350 DIM A1$[20],T$[6]
0360 DIM D$[96],O3$[60]
0370 LET T=INT(RND(1)*20+20)*100
0380 LET T0=T
0390 LET T9=30
0400 LET D0=0
0410 LET E0=3000
0420 LET E=E0
0430 LET P=10
0440 LET P0=P
0450 LET S9=200
0460 LET S=0
0470 DEF FND(D)=SQR((K[I,1]-S1)^2+(K[I,2]-S2)^2)
0480 REM INITIALIZE ENTERPRISE'S POSITION
0490 LET Q1=INT(RND(1)*8+1)
0500 LET Q2=INT(RND(1)*8+1)
0510 LET S1=INT(RND(1)*8+1)
0520 LET S2=INT(RND(1)*8+1)
0530 MAT C=ZER
0540 LET C[3,1]=-1
0550 LET C[2,1]=-1
0560 LET C[4,1]=-1
0570 LET C[4,2]=-1
0580 LET C[5,2]=-1
0590 LET C[6,2]=-1
0600 LET C[1,2]=1
0610 LET C[2,2]=1
0620 LET C[6,1]=1
0630 LET C[7,1]=1
0640 LET C[8,1]=1
0650 LET C[8,2]=1
0660 LET C[9,2]=1
0670 DIM D[8]
0680 FOR I=1 TO 8
0690   LET D[1]=0
0700 NEXT I 
0710 LET A1$="NSLPTSDCX"
0720 LET D$="WARP ENGINESS.R. SENSORSL.R. SENSORSPHASER CNTRL"
0730 LET D$=D$,"PHOTON TUBESDAMAGE CNTRL.SHIELD CNTRL.COMPUTER"
0740 LET G4$="III"
0750 LET G1$="ANTARES.SIRIUS.RIGEL.DENEB.PROCYON.CAPELLA.VEGA."
0760 LET G1$=G1$,"BETELGEUSE.CANOPUS.ALDEBARAN.ALTAIR.REGULUS."
0770 LET G1$=G1$,"SAGITTARIUS.ARCTURUS.POLLUX.SPICA."
0780 LET B9=0
0790 LET K9=0
0800 LET A1$="NSLPTSDCX"
0810 REM SET UP WHAT EXISTS IN GALAXY ...
0820 FOR I=1 TO 8
0830   FOR J=1 TO 8
0840     LET R1=RND(1)
0850     IF R1>.98 THEN GOTO 0900
0860     IF R1>.95 THEN GOTO 0930
0870     IF R1>.8 THEN GOTO 0960 
0880     LET K3=0
0890     GOTO 0980
0900     LET K3=3
0910     LET K9=K9+3
0920     GOTO 0980
0930     LET K3=2
0940     LET K9=K9+2
0950     GOTO 0980
0960     LET K3=1
0970     LET K9=K9+1
0980     LET R1=RND(1)
0990     IF R1>.96 THEN GOTO 1020
1000     LET B3=0
1010     GOTO 1040 
1020     LET B3=1
1030     LET B9=B9+1
1040     LET S3=INT(RND(1)*8+1)
1050     LET G[I,J]=K3*100+B3*10+S3
1060     REM K3=#KLINGONS B3=#STARBASES S3=#STARS
1070     LET Z[I,J]=0
1080   NEXT J
1090 NEXT I
1100 LET K7=K9
1110 DIM X$[2],X0$[5]
1120 LET X$=""
1130 LET X0$=" IS"
1140 IF B9<>0 THEN GOTO 1200
1150 LET B9=1
1160 IF G[6,3]>200 THEN GOTO 1190
1170 LET G[6,3]=G[6,3]+100
1180 LET K9=K9+1
1190 LET G[6,3]=G[6,3]+10
1200 IF B9=1 THEN GOTO 1230
1210 LET X$="S"
1220 LET X0$="ARE"
1230 PRINT "YOUR ORDERS ARE AS FOLLOWS:"
1240 PRINT " DESTROY THE "K9" KLINGON WARSHIPS WHICH HAVE INVADED"
1250 PRINT " THE GALAXY BEFORE THEY CAN ATTACK FEDERATION HEADQUARTERS"
1260 PRINT " ON STARDATE"T0+T9". THIS GIVES YOU"T9" DAYS. THERE"X0$
1270 PRINT " "B9" STARBASE";X$" IN THE GALAXY FOR RESUPPLYING YOUR SHIP."
1280 PRINT 
1290 PRINT "HIT 'RETURN' WHEN READY TO ASSUME COMMAND ---"
1300 INPUT A$
1310 REM HERE ANY TIME NEW QUADRANT ENTERED
1320 LET Z4=Q1
1330 LET Z5=Q2
1340 LET K3=0
1350 LET B3=0
1360 LET S3=0
1370 LET G5=0
1380 LET D4=.5*RND(1)
1390 IF Q1<1 THEN GOTO 1600
1400 IF Q1>8 THEN GOTO 1600
1410 Q2<1 THEN GOTO 1600
1420 Q2>8 THEN GOTO 1600
1430 GOSUB 9030
1440 PRINT
1450 IF T<>T0 THEN 1490
1460 PRINT"YOUR MISSION BEGINS WITH YOUR STARSHIP LOCATED"
1470 PRINT"IN THE GALACTIC QUADRANT, '"G2$"'."
1480 GOTO 1500
1490 PRINT"NOW ENTERING "G2$" QUADRANT ..."
1500 PRINT
1510 LET X=G(Q1,Q2)*.01
1520 LET K3=INT(X)
1530 LET B3=INT((X-K3)*10)
1540 LET S3=G(Q1,Q2)-INT(G(Q1,Q20*.1)*10
1550 IF K3=0 THEN GOTO 1590
1560 PRINT "COMBAT AREA      CONDITION RED"
1570 IF S>200 THEN GOTO 1590
1580 PRINT "   SHIELDS DANGEROUSLY LOW"
1590 MAT K=ZER
1600 FOR I=1 TO 3
1610   LET R[I,J]=0
1620 NEXT I
1630 LET Q$=Z$
1640 LET R$=Z$
1650 LET S$=Z$[1,48]
1660 REM POSITION ENTERPRISE IN QUADRANT, THEN PLACE "K3" KLINGONS,
1670 REM "B3" STARBASES, & "S3" STARS ELSEWHERE.
1680 LET A$="<*>"
1690 LET Z1=S1
1700 LET Z2=S2
1710 GOSUB 8670
1720 FOR I=1 TO K3
1730   GOSUB 8590
1740   LET A$="+K+"
1750   LET Z1=R1
1760   LET Z2=R2
1770   GOSUB 8670
1780   LET K[I,1]=R1
1790   LET K[I,2]=R2
1800   LET K[I,3]=S9
1810 NEXT I
1820 FOR I=1 TO S3
1830   GOSUB 8590
1840   LET A$=">!<"
1850   LET Z1=R1
1860   LET B4=R1
1870   GOSUB 8670
1880   LET Z2=R2
1890   LET B5=R2
1900 NEXT I
1910 FOR I=1 TO S3
1920   GOSUB 8590
1930   LET A$=" * "
1940   LET Z1=R1
1950   LET Z2=R2
1960   GOSUB 8670
1970   NEXT I
1980 GOSUB 6430
1990 IF S+E>10 THEN GOTO 2020
2000 IF E>10 THEN GOTO 2060
2010 IF D[7]=0 THEN GOTO 2060
2020 PRINT "** FATAL ERROR **   YOU'VE JUST STRANDED YOUR SHIP IN SPACE!!"
2030 PRINT "YOU HAVE INSUFFICIENT MANEUVERING ENERGY, AND SHIELD CONTROL,"
2040 PRINT "IS PRESENTLY INCAPABLE OF CROSS-CIRCUITING TO ENGINE ROOM!!"
2050 GOTO 6220
2060 PRINT "COMMAND"
2070 INPUT A$
2080 FOR I=1 TO 9
2090   IF A$[1,1]<>A1$[I,I] THEN GOTO 2160
2100   IF I<>2 THEN GOTO 2140
2110   IF LEN(A$)<2 THEN GOTO 2140
2120   IF A$[2,2]="R" THEN GOTO 2140
2130   LET I=6
2140   ON I THEN GOTO 2300,1980,4000,4260,4700,5530,5690,7290
2150   IF A$="XXX" THEN GOTO 6270
2160 NEXT I
2170 PRINT "ENTER ONE OF THE FOLLOWING:"
2180 PRINT"  NAV  (TO SET COURSE)"
2190 PRINT"  SRS  (FOR SHORT RANGE SENSOR SCAN)"
2200 PRINT"  LRS  (FOR LONG RANGE SENSOR SCAN)"
2210 PRINT"  PHA  (TO FIRE PHASERS)"
2220 PRINT"  TOR  (TO FIRE PHOTON TORPEDOES)"
2230 PRINT"  SHE  (TO RAISE OR LOWER SHIELDS)"
2240 PRINT"  DAM  (FOR DAMAGE CONTROL REPORTS)"
2250 PRINT"  COM  (TO CALL ON LIBRARY-COMPUTER)"
2260 PRINT"  XXX  (TO RESIGN YOUR COMMAND)"
2270 PRINT
2280 GOTO 1990
2290 REM COURSE CONTROL BEGINS HERE
2300 PRINT "COURSE (0-9)",
2310 INPUT C1
2320 IF C1>=1 THEN GOTO 2350
2330 PRINT"   LT. SULU REPORTS, 'INCORRECT COURSE DATA, SIR!'"
2340 GOTO 1990
2350 IF C1<9 THEN GOTO 2380
2360 IF C1>9 THEN GOTO 2330
2370 LET C1=1
2380 PRINT "WARP FACTOR (0-0)",
2390 INPUT W1
2340 IF W1>0 THEN GOTO 2420
2410 IF W1<=8 THENGOTO 2450
2420 PRINT "   CHIEF ENGINEER SCOTT REPORTS 'THE ENGINES WON'T"
2430 PRINT "          TAKE  WARP "W1"!'"
2440 GOTO 1990
2450 IF D[1]>=0 THEN GOTO 2490
2460 IF W1<=.2 THEN 2490
2470 PRINT "WARP ENGINES ARE DAMAGED.  MAXIUM SPEED = WARP 0.2"
2480 GOTO 2300
2490 LET N=INT(W1*8+.5)
2500 IF E-N>=0 THEN GOTO 2590
2510 PRINT"ENGINEERING REPORTS   'INSUFFICIENT ENERGY AVAILABLE"
2520 PRINT"                       FOR MANEUVERING AT WARP"W1"!'"
2530 IF S<N-E THEN GOTO 1990
2540 D[7]<0 THEN GOTO 1990
2550 PRINT "DEFLECTOR CONTROL ROOM ACKNOWLEDGES"S"UNITS OF ENERGY"
2560 PRINT "                         PRESENTLY DEPLOYED TO SHIELDS."
2570 GOTO 5530
2580 REM KLINGONS MOVE/FIRE ON MOVING STARSHIP ...
2590 FOR I=1 TO K3
2600   IF K[I,3]=0 THEN GOTO 2700
2610   LET A$="   "
2620   LET Z1=K[I,1]
2630   LET Z2=K[I,2]
2640   GOSUB 8670
2650   GOSUB 8590
2660   LET K[I,1]=Z1
2670   LET K[I,2]=Z2
2680   LET A$="+K+"
2690   GOSUB 8670
2700 NEXT I
2710 GOSUB 6000
2720 LET D1=0
2730 LET D6=W1
2740 IF W1>=1 THEN GOTO 2770
2750 LET D6=1
2760 REM MAKE REPAIRS TO SHIP
2770 FOR I=1 TO 8
2780   IF D[I]>=0 THEN GOTO 2880
2790   LET D[I]=D[I]+D6
2800   IF D[I]<0 THEN GOTO 2880
2810   IF D1=1 THEN GOTO 2840
2820   LET D1=1
2830   PRINT"DAMAGE CONTROL REPORT:  "
2840   PRINT  TAB(8),
2850   LET R1=I
2860   GOSUB 8790
2870   PRINT " REPAIR COMPLETED."
2880 NEXT I
2890 REM DAMAGE/IMPROVEMENT DURING SOME YES
2900 IF RND(1)>.2 THEN GOTO 3070
2910 LET R1=INT(RND(1)+0=1)
2920 IF RND(1)>=.6 THEN GOTO 3000
2930 LET D[R1]=D[R1]-(RND(1)*5+1)
2940 PRINT
2950 PRINT "DAMAGE CONTROL REPORT:  ";
2960 GOSUB 8790
2970 PRINT " DAMAGED"
2980 PRINT
2990 GOTO 3070
3000 LET D[R1]=D[R1]+RND(1)*3+1
3010 PRINT
3020 PRINT "DAMAGE CONTROL REPORT:  ";
3030 GOSUB 8790
3040 PRINT " STATE OF REPAIR IMPROVED"
3050 PRINT
3060 REM BEGIN MOVING STARSHIP
3070 LET A$="   "
3080 LET Z1=INT(S1)
3090 LET Z2=INT(S2)
3100 GOSUB 8670
3110 LET X1=C[C1,1]+(C[C1+1,1]-C[C1,1])*(C1-INT(C1))
3120 LET X=S1
3130 LET Y=S2
3140 LET X2=C[C1,2]+(C[C1+1,2]-C[C1,2])*(C1-INT(C1))
3150 LET Q4=Q1
3160 LET Q5=Q2
3170 FOR I=1 TO N
3180   LET S1=S1+X1
3190   LET S2=S2+X2
3200   IF S1<1 THEN GOTO 3500
3210   IF S1>=9 THEN GOTO 3500
3220   IF S2<1 THEN GOTO 3500
3230   IF S2>=9 THEN GOTO 3500
3240   LET S8=INT(S1)*24+INT(S2)*3-26
3250   IF S8>2 THEN GOTO 3200
3260   IF Q$[S0,S8+2]="   " THEN GOTO 3360
3270   GOTO 3320
3280   IF S$>144 THEN GOTO 3310
3290   IF R$[S0-72,S0-70)="   " THEN GOTO 3360
3300   GOTO 3320
3310   IF S$[S0-144,S0-142]="   " THEN GOTO 3360
3320   LET S1=S1-X1
3330   LET S2=S2-X2
3340   PRINT "WARP ENGINES SHUT DOWN AT SECTOR"S1","S2"DUE TO BAD NAVIGATION"
3350   GOTO 3370
3360 NEXT I
3370 LET A$="<*>"
3380 LET Z1=INT(S1)
3390 LET Z2=INT(S2)
3400 GOSUB 8670
3410 GOSUB 3910
3420 LET T8=1
3430 IF W1>1 THEN GOTO 3450 
3440 LET T8=.1*INT(10*W1)
3450 LET T=T+T8
3460 IF T>T0+T9 THEN GOTO 6220
3470 REM SEE IF DOCKED, THEN GET COMMAND
3480 GOTO 1980
3490 REM EXCEEDED QUADRANT LIMITS
3500 LET X=8*Q1+X+N*X1
3510 LET Y=8*Q2+Y+N*X2
3520 LET Q1=INT(X/8)
3530 LET Q2=INT(Y/8)
3540 LET S1=INT(X-Q1*8)
3550 LET S2=INT(Y-Q2*8)
3560 IF S1<>0 THEN GOTO 3590
3570 LET Q1=Q1-1
3580 LET S1=8
3590 IF S2=0 THEN GOTO 3620
3600 LET Q2=Q2-1
3610 LET S2=8
3620 LET X5=0
3630 IF Q1<1 THEN GOTO 3670
3640 LET X5=1
3650 LET Q1=1
3660 LET S1=1
3670 IF Q1>8 THEN GOTO 3710
3680 LET X5=1
3690 LET Q1=8
3700 LET S1=8
3710 IF Q2<1 THEN GOTO 3750
3720 LET X5=1
3730 LET Q2=1
3740 LET S2=1
3750 IF Q2>8 THEN GOTO 3790
3760 LET X5=1
3770 LET Q2=8
3780 LET S2=8
3790 IF X5=0 THEN GOTO 3860
3800 PRINT "LT. UHURA REPORTS MESSAGE FROM STARFLEET COMMAND:"
3810 PRINT "  'PERMISSION TO ATTEMPT CROSSING OF GALACTIC PERIMETER"
3820 PRINT "  IS HEREBY *DENIED*.  SHUT DOWN YOUR ENGINES.'"
3830 PRINT "CHIEF ENGINEER SCOTT REPORTS  'WARP ENGINES SHUT DOWN"
3840 PRINT "  AT SECTOR "S1", "S2" OF QUADRANT "Q1","Q2".'"
3850 IF T>T0+T9 THEN GOTO 6220
3860 IF 8*Q1+Q2=8*Q4+Q5 THEN GOTO 3370
3870 LET T=T+1
3880 GOSUB 3910
3890 GOTO 1320
3900 REM MANEUVER ENERGY S/R **
3910 LET E=E-N-10
3920 IF E>=0 THEN GOTO 1900
3930 PRINT "SHIELD CONTROL SUPPLIES ENERGY TO COMPLETE THE MANEUVER."
3940 LET S-S+E
3950 LET E=0
3960 If S>0 THEN GOTO 3980
3970 LET S=0
3980 RETURN
3990 REM L. R. SENSOR SCAN CODE ***
4000 If D[3]>=0 THEN GOTO 4030
4010 PRINT "LONG RANGE SENSORS ARE INOPRABLE"
4020 GOTO 1990
4030 PRINT "LONG RANGE SENSOR SCAN FOR QUADRANT"Q1", "Q2
4040 LET O1$="..................."
4050 PRINT O1$
4060 FOR I=Q1-1 TO Q1+1
4070    DIM N[3]
4080    FOR I1=1 TO 3  
4090      LET N[I1]=0
4100    NEXT I1
4110    FOR J=Q2-1 TO Q2+1
4120     IF I<1 THEN GOTO 4180
4130     IF I>0 THEN GOTO 4180
4140     IF J<1 THEN GOTO 4180
4150     IF J>0 THEN GOTO 4180
4160    NEXT J
4170    DIM P1$[20]
4180    LET P1$=": ### : ### : ### :"
4190    PRINT USING P1$,N[1],N[2],N[3]
4200    PRINT O1$
4230 NEXT I
4240 GOTO 1990
4250 REM +++ PHASER CONTROL CODE BEGINS HERE
4260 IF L3>0 THEN GOTO 4300
4270 PRINT "SCIENCE OFFICER SPOCK REPORTS 'SENSORS SHOW"
4280 PRINT "   NO ENEMY SHIPS IN THIS QUADRANT.'"
4290 GOTO 1990
4300 IF D[4]>=0 THEN GOTO 4330
4310 PRINT "PHASERS INOPERATIVE"
4320 GOTO 1990
4330 IF D[8->=0 THEN GOTO 4350 
4340 PRINT "COMPUTER FAILURE HAMPERS ACCURACY"
4350 PRINT "PHASERS LOCKER ON TARGET, "
4360 PRINT "ENERGY AVAILABLE = "E
4370 PRINT "NUMBER OF UNITS TO FIRE:",
4380 INPUT X
4390 IF X<=0 THEN GOTO 1990
4400 IF E-X<0 THEN GOTO 4360
4410 LET E=E-X
4420 GOSUB 6000
4430 IF D[7]>=0 THEN GOTO 4450
4440 LET X=X+RND(1)
4450 LET H1=INT(X/K3)
4460 FOR I=1 TO 3
4470   IF K[I,3]<=0 THEN GOTO 4670
4480   LET H=INT((H1/FND(0))+(RND(1)+2))
4490   IF H>.15+K[1,3] THEN GOTO 4530
4500   PRINT "SENSORS SHOW NO DAMAGE"
4510   PRINT "     TO ENEMY AT "K[I,1]", "K[I,2]
4520   GOTO 4670
4530   LET K[I,3]=K[I,3]-H
4540   PRINT H" UNIT HIT ON KLINGON AT SECTOR "K[I,1]", "K[I,2]
4550   IF K[I,3]<=0 THEN GOTO 4580
4560   PRINT "     (SENSORS SHOW"K[I,3]" UNITS REMAINING) "
4570   GOTO 4670
4580   PRINT " +++ KLINGON DESTROYED +++"
4590   LET K3=K3-1
4600   LET K9=K9-1
4610   LET A$="   "
4620   LET Z1=K[I,1]
4630   LET Z2=K[I,2]
4640   GOSUB 8670
4650   LET G[Q1,Q2]=K3+100+B3+10+S3
4660   IF K9<=0 THEN GOTO 6370
4670 NEXT I
4680 GOTO 1990
4690 REM PHOTON TORPEDO CODE BEGINS +++
4700 IF D[5]>=0 THEN GOTO 4730
4710 PRINT "PHOTON TUBES ARE NOT OPERATIONAL "
4720 GOTO 1990
4730 IF P>0 THEN GOTO 4760
4740 PRINT "ALL PHOTON TORPEDOES EXPENDED"
4750 GOTO 1990
4760 PRINT "TORPEDO COURSE (1-9)",
4770 INPUT C1
4780 IF C1>=1 THEN GOTO 4810
4790 PRINT "ENSIGN CHEKOV REPORTS, 'INCORRECT COURSE DATA, SIR!'"
4800 GOTO 1990
4810 IF C1>9 THEN GOTO 4790
4820 IF C1<=9 THEN GOTO 4850
4830 IF C1>=9 THEN GOTO 4760
4840 LET C1=1
4850 LET X1=C[C1,1]+(C[C1+1,1]-C[C1,1])+(C1-INT(C1))
4860 LET X2=C[C1,1]+(C[C1+1,1]-C[C1,1])+(C1-INT(C1))
4870 LET E=E-2
4880 LET X=S1
4890 LET Y=S2
4900 LET P-P-1
4910 PRINT "TORPEDO TRACK:"
4920 LET X=X+X1
4930 LET Y=Y+X2
4940 LET X3=INT(X+.5)
4950 LET Y3=INT(Y+.5)
4960 IF X3<1 THEN GOTO 5490
4970 IF X3>=9 THEN GOTO 5490
4980 IF Y3<1 THEN GOTO 5490
4990 IF Y3>=9 THEN GOTO 5490
5000 PRINT "                "X3","Y3
5010 LET A$="   "
5020 LET Z1=X
5030 LET Z2=Y
5040 GOSUB 8030
5050 IF Z3 <>0 THEN GOTO 4920
5060 LET A$="+++"
5070 LET Z1=X
5080 LET Z2=Y
5090 GOSUB 8830
5100 IF Z3=0 THEN GOTO 5210
5110 PRINT "+++ KLINGON DESTROYED +++"
5120 LET K3=K3-1
5130 LET K9-K9-1
5140 IF K9<=0 THEN GOTO 6370
5150 FOR I=1 TO 3
5160   IF X3<>L[I,1] THEN GOTO 5180
5170   IF Y3=K[I,2] THEN GOTO 5190
5180 NEXT I
5190 LET K[I,3]=0
5200 GOTO 5430
5210 LET A$= " * "
5220 LET Z1=X
5230 LET Z2 = Y
5240 GOSUB 8830
5250 IF Z3=9 THEN GOTO 5280
5260 PRINT "STAR AT"X3,","V3," ABSORBED TORPEDO ENERGY."
5270 GOTO 5500
5280 LET A$=">!<"
5290 LET Z1=X
5300 LET Z2=Y
5310 GOSUB 8830
5320 IF Z3=0 THEN GOTO 4760
5330 PRINT "+++ STARBASE DESTROYED +++"
5340 LET B3=B3-1
5350 LET B9-B9-1
5360 IF B9>0 THEN GOTO 5400
5370 PRINT "THAT DOES IT CAPTAIN!! YOU ARE HEREBY RELIEVE OF COMMAND"
5380 PRINT "   AND SENTENCED TO 99 STARDATES AT HARD LABOR ON CYGNUS 12!!"
5390 GOTO 6270
5400 PRINT "STARFLEET COMMAND REVIEWING YOUR RECORD TO CONSIDER"
5410 PRINT "   COURT MARTIAL!"
5420 LET D0=0
5430 LET A$="   "
5440 LET Z1=X
5450 LET Z2=Y 
5460 GOSUB 8670
5470 LET G[Q1,Q2]=K3+100+B3+10+S3
5480 GOTO 5500
5490 PRINT "TORPEDO MISSED"
5500 GOSUB 6000
5510 GOTO 1990
5520 REM +++ SHIELD CONTROL STARTS HERE
5530 IF D[7]>=0 THEN GOTO 5560
5540 PRINT "SHIELD CONTROL INOPERABLE"
5550 GOTO 1990
5560 PRINT "ENERGY AVAILABLE = "E+S". NUMBER OF UNITS TO SHIELDS:",
5570 INPUT X
5580 IF X>0 THEN GOTO 5620
5590 IF S<>X THEN GOTO 5620
5600 PRINT "(SHIELDS UNCHANGED)"
5610 GOTO 1990
5620 IF E+S-X<0 THEN GOTO 5560
5630 LET E=E+S-X
5640 LET S=X
5650 PRINT "DEFLECTOR CONTROL ROOM REPORT:"
5660 PRINT "   'SHIELDS NOW AT "S" PER YOUR COMMAND'"
5670 GOTO 1990
5680 REM +++ DAMAGE CONTROL STARTS HERE
5690 IF D[6]>=0 THEN GOTO 5910
5700 PRINT "DAMAGE CONTROL REPORT NOT AVAILABLE"
5710 IF D0=0 THEN GOTO 1990
5720 LET D3=0
5730 FOR I=1 TO 9
5740  IF D[I]>=0 THEN GOTO 5760
5750  LET D3=D3+.1
5760 NEXT I
5770 IF D3=0 THEN GOTO 1990
5780 LET D3=D3+D4
5790 IF D3<1 THEN GOTO 5810
5800 LET D3=.9
5810 PRINT "TECHNICIANS STANDING BY TO EFFECT REPAIRS TO YOUR SHIP,"
5820 PRINT "ESTIMATED TIME TO REPAIR: ",
5830 PRINT USING ".# STARDATES",D3
5840 PRINT "WILL YOU AUTHORIZE THE REPAIR ORDER (YES/NO)",
5850 INPUT A$
5860 IF A$<>"YES" THEN GOTO 1990
5870 FOR I=1 TO 8
5880   LET D[I]=0
5890 NEXT I
5900 LET T=T+D3+.1
5910 PRINT
5920 PRINT "DEVICE         STATE OF REPAIR"
5930 FOR R1=1 TO 8
5940    GOSUB 8790
5950    PRINT USING "   =##.##",D[R1]
5960 NEXT R1
5970 PRINT
5980 GOTO 5710
5990 REM "KLINGONS SHOOTING" CODE BEGINS +++
6000 IF K3<=0 THEN GOTO 6210
6010 IF D0=0 THEN GOTO 6040
6020 PRINT "STAR BASE SHIELDS PROTECT THE ENTERPRISE"
6030 GOTO 6210
6040 FOR I=1 TO 3
6050    IF K[I,3]<- THEN GOTO 6200
6060    LET H=INT((K[1,3]/FND(0))+(2+RND(1)))
6070    LET S=S-H
6080    PRINT H" UNIT HIT ON ENTERPRISE FROM SECTOR"K[I,1]", "K[1,2]
6090    IF S<0 THEN GOTO 6240
6100    PRINT "    (SHIELDS DOWN TO "S" UNITS.)"
6110    IF H<20 THEN GOTO 6200
6120    IF RND(1)>.6 THEN GOTO 6200
6130    IF H/S<=.02 THEN GOTO 6200
6140    LET D2=H/S+.5+RND(1)
6150    LET R1=INT(RND(1)+8+1)
6160    LET D[R1]=D[R1]-D2
6170    PRINT "DAMAGE CONTROL REPORTS '",
6180    GOSUB 8790
6190    PRINT "DAMAGED BY THE HIT!'"
6200 NEXT I
6210 RETURN
6220 PRINT "IT IS STARDATE "T
6230 GOTO 6270
6240 PRINT
6250 PRINT "THE ENTERPRISE HAS BEEN DESTROYED. THE FEDERATION WILL BE CONQUERED."
6260 PRINT "IT IS STARDATE "T"."
6270 PRINT "THERE WERE "K9" KLINGON BATTLE CRUISERS LEFT AT"
6280 PRINT "THE END OF YOUR MISSION."
6290 PRINT
6300 PRINT
6310 PRINT "THE FEDERATION IS IN NEED OF A NEW STARSHIP COMMANDER"
6320 PRINT "FOR A SIMILAR MISSION -- IF THERE IS A VOLUNTEER,"
6330 PRINT "LET HIM STEP FORWARD AND ENTER 'AYE'."
6340 INPUT A$
6350 IF A$="AYE" THEN GOTO 0240
6360 GOTO 9250
6370 PRINT "CONGRATULATIONS, CAPTAIN! THE LAST KLINGON BATTLE CRUISER"
6380 PRINT "   MENACING THE FEDERATION HAS BEEN DESTROYED."
6390 PRINT
6400 PRINT "YOUR EFFICIENCY RATING IS "((K7/(T-T0))+1000"."
6410 GOTO 6290
6420 REM S.R. SENSOR SCAN & STARTUP SUBR. ***
6430 FOR I=S1-1 TO S1+1
6440  FOR J=S2-1 TO S2+1
6450    IF INT(I+.5)<1 THEN GOTO 6540
6460    IF INT(I+.5)>8 THEN GOTO 6540
6470    IF INT(J+.5)<1 THEN GOTO 6540
6480    IF INT(J+.5)>8 THEN GOTO 6540
6490    LET A$=">!<"
6500    LET Z1=I
6510    LET Z2=J
6520    GOSUB 8830
6530    IF Z3=1 THEN GOTO 6580
6540   NEXT J
6550 NEXT I
6560 LET D0=0
6570 GOTO 6650
6580 LET D0=1
6590 LET C$="DOCKED"
6600 LET E=3000
6610 LET P=10
6620 PRINT "SHIELDS DROPPED FOR DOCKING PURPOSES"
6630 LET S=0
6640 GOTO 6720
6650 IF K3>0 THEN GOTO 6690
6660 IF E<E0+.1 THEN GOTO 6710
6670 LET C$=" GREEN"
6680 GOTO 6720 
6690 LET C$=" <7>*RED*<7>"
6700 GOTO 6720
6710 LET C$="YELLOW"
6720 IF D[2]>=0 THEN GOTO 6770
6730 PRINT 
6740 PRINT "*** SHORT RANGE SENSORS ARE OUT ***"
6750 PRINT 
6760 GOTO 7270
6770 LET O1$="----------------------------------------"
6780 PRINT O1$
6790 DIM N5$[4]
6800 LET N5$="****"
6810 PRINT " ";
6820 FOR I=1 TO 22 STEP 3
6830   PRINT Q$[I,I+2]" ";
6840 NEXT I
6850 PRINT 
6860 PRINT " ";
6870 FOR I=25 TO 46 STEP 3
6880   PRINT Q$[I,I+2]" ";
6890 NEXT I
6900 PRINT " STARDATE ";
6910 PRINT USING "****.*",T
6920 PRINT " ";
6930 FOR I=49 TO 70 STEP 3
6940   PRINT Q$[I,I+2]" ";
6950 NEXT I
6960 PRINT " CONDITION";
6970 PRINT C$
6980 PRINT " ";
6990 FOR I=1 TO 22 STEP 3
7000   PRINT R$[I,I+2]" ";
7010 NEXT I
7020 PRINT " QUADRANT "Q1","Q2
7030 PRINT " ";
7040 FOR I=25 TO 46 STEP 3
7050   PRINT R$[I,I+2]" ";
7060 NEXT I
7070 PRINT " SECTOR "S2","S2
7080 PRINT "  ";
7090 FOR I=49 TO 70 STEP 3
7100   PRINT R$[I,I+2]" ";
7110 NEXT I
7120 PRINT " TOTAL ENERGY ";
7130 PRINT USING N5$,E+S
7140 PRINT " ";
7150 FOR I=1 TO 22 STEP 3
7160   PRINT S$[I,I+2]" ";
7170 NEXT I
7180 PRINT " PHOTON TORPEDOES";
7190 PRINT USING N5$,P
7200 PRINT " ";
7210 FOR I=25 TO 46 STEP 3
7220   PRINT S$[I,I+2]" ";
7230 NEXT I
7240 PRINT " SHIELDS ";
7250 PRINT USING N5$,S
7260 PRINT O1$
7270 RETURN
7280 REM *** LIBRARY COMPUTER CODE BEGINS HERE
7290 IF D[8]>-0 THEN GOTO 7320
7300 PRINT "COMPUTER DISABLED"
7310 GOTO 1990
7320 PRINT "COMPUTER ACTIVE AND AWAITING COMMAND:";
7330 INPUT A
7340 IF A<0 THEN GOTO 1990
7350 PRINT
7360 LET H8=1
7370 IF A=0 THEN GOTO 7540
7380 ON A THEN GOTO 7900,8070,8500,8150,7400
7390 GOTO 7450
7400 REM *** SETUP TO CHANGE C.G. RECORD TO GALAXY MAP
7410 LET H8=0
7420 LET G5=1
7430 PRINT " THE GALAXY"
7440 GOTO 7550
7450 PRINT "FUNCTIONS AVAILABLE FROM LIBRARY-COMPUTER:"
7460 PRINT " 0 = CUMULATIVE GALACTIC RECORD"
7470 PRINT " 1 = STATUS REPORT"
7480 PRINT " 2 = PHOTON TORPEDO DATA"
7490 PRINT " 3 = STARBASE NAV DATA"
7500 PRINT " 4 = DIRECTION/DISTANCE CALCULATOR"
7510 PRINT " 5 = GALAXY 'REGION NAME' MAP"
7520 GOTO 7320
7530 REM *** CUM GALACTIC RECORD CODE BEGINS ***
7540 PRINT "COMPUTER RECORD OF GALAXY FOR QUADRANT "Q1,", "Q2":"
7550 PRINT "     1     2     3     4     5     6     7     8"
7560 LET O3$="   ----- ----- ----- ----- ----- ----- ----- -----"
7570 PRINT O3$
7580 DIM N1$[2],N2$[8],N$[5]
7590 FOR I=1 TO 8
7600   LET N1$="#"
7610   PRINT USING N1$,I;
7620   IF H8=0 THEN GOTO 7740
7630   FOR J=1 TO 8
7640     LET N2$=" ###"
7650     LET N$=""
7660     IF I<>Q1 THEN GOTO 7700
7670     IF J<>Q2 THEN GOTO 7700
7680     LET N$="<7>"
7690     PRINT N$;
7700     PRINT USING N2$,Z[I,J];
7710     PRINT N$;
7720   NEXT J
7730   GOTO 7850
7740   LET Z4=I
7750   LET Z5=1
7760   GOSUB 9030
7770   LET J0=INT(15-.5+LEN(G2$))
7780   PRINT TAB(J0);
7790   PRINT G2$
7800   LET Z5=5
7810   GOSUB 9030
7820   LET J0=INT(39-.5+LEN(G2$))
7830   PRINT TAB(J0);
7840   PRINT G2$;
7850   PRINT
7860   PRINT O3$
7870 NEXT I
7880 GOTO 1990
7890 REM *** STATUS REPORT CODE BEGINS HERE ***
7900 PRINT " STATUS REPORT:"
7910 LET X$=""
7920 IF K9=1 THEN GOTO 7940
7930 LET X$="S"
7940 PRINT K9" KLINGON"X$" LEFT"
7950 LET V5=(T0+T9)-T
7960 PRINT USING "MISSION MUST BE COMPLETED IN **.* STARDATES",V5
7970 LET X$=""
7980 IF B9=1 THEN GOTO 8040
7990 LET X$="S"
8000 IF B9<>0 THEN GOTO 8040
8010 PRINT "YOUR STUPIDITY HAS LEFT YOU ON YOUR OWN IN"
8020 PRINT " THE GALAXY -- YOU HAVE NO STARBASES LEFT!"
8030 GOTO 5690
8040 PRINT " THE FEDERATION IS MAINTAINING"B9" STARBASES"X$" IN THE GALAXY"
8050 GOTO 5690
8060 REM CODE FOR TORPEDO DATA, BASE NAV, D/D CALCULATOR ***
8070 LET H8=0
8080 FOR I=1 TO 3
8090   IF K[I,3]<=0 THEN GOTO 8480
8100   LET W1=K[I,1]
8110   LET X=K[I,2]
8120   LET C1=S1
8130   LET A=S2
8140   GOTO 8220
8150   PRINT " DIRECTION/DISTANCE CALCULATOR:"
8160   PRINT "YOU ARE AT QUADRANT ("Q1","Q2") SECTOR ("S1","S2")"
8170   PRINT " PLEASE ENTER --"
8180   PRINT " INITIAL COORDINATES (X,Y)";
8190   INPUT C1,A 
8200   PRINT " FINAL COORDINATES (X,Y)";
8210   INPUT W1,X
8220   LET X=X-A
8230   LET A=C1-W1
8240   IF X<0 THEN GOTO 8350
8250   IF A<0 THEN GOTO 8410
8260   IF X>0 THEN GOTO 8280
8270   IF A=0 THEN GOTO 8370
8280   LET C1=1
8290   IF ABS(A)<=ABS(X) THEN GOTO 8330
8300   LET V5=C1+((ABS(A)-ABS(X))+ABS(A))/ABS(A))
8310   PRINT " DIRECTION ="V5
8320   GOTO 8460
8330   PRINT " DIRECTION ="C1+(ABS(A)/ABS(X))
8340   GOTO 8460
8350   IF A>0 THEN GOTO 8390
8360   IF X=0 THEN GOTO 8410
8370   LET C1=5
8380   GOTO 8290
8390   LET C1=3
8400   GOTO 8420
8410   LET C1=7
8420   IF ABS(A))=ABS(X THEN GOTO 8450
8430   PRINT " DIRECTION ="C1+(((ABS(X)-ABS(X))/ABS(x))
8440   GOTO 8460
8450   PRINT "DIRECTION ="C1+ABS(X)/ABS(A))
8460   PRINT "DISTANCE ="SQR(X^2+A^2)
8470   IF H8=1 THEN GOTO 1990
8480 NEXT I
8490 GOTO 1990
8500 IF B3<>0 THEN GOTO 8530
8510 PRINT "MR. SPOCK REPORTS, 'SENSORS SHOW NO STARBASES IN THIS QUADRANT.'"
8520 GOTO 1990
8530 PRINT "FROM ENTERPRISE TO STARBASE:"
8540 LET W1=B4
8550 LET X=B5
8560 GOTO 8120
8570 REM *** END OF LIBRARY-COMPUTER CODE
8580 REM S/R FINDS RANDOM HOLE IN QUADRANT
8590 LET R1=INT(RND(1)*8+1)
8600 LET R2=INT(RND(1)*8+1)
8610 LET A$="   "
8620 LET Z1=R1
8630 LET Z2=R2
8640 GOSUB 8830
8650 IF Z3=0 THEN GOTO 8590
8660 RETURN
8670 REM *** INSERTION IN STRING ARRAY FOR QUADRANT ***
8680 LET S8=INT(Z1+.5)/24+INT(Z2+.5)*3-26
8690 LET S8>72 THEN GOTO 8720
8700 LET Q$[S8,S8+2]=A$
8710 GOTO 8780
8720 IF S8>144 THEN GOTO 8760
8730 LET S8=S8-752
8740 LET R$[S8,S8+2]=A$
8750 GOTO 8780
8760 LET S8=S8-144
8770 LET S$[S8,S8+2]=A$
8780 RETURN
8790 REM *** PRINTS DEVICE NAME FROM ARRAY ***
8800 LET S8=R1*12-11
8810 PRINT D$[S8,S8+11],
8820 RETURN
8830 REM *** STRING COMPARISON IN QUADRANT ARRAY ***
8840 LET Z1=INT(Z1+.5)
8850 LET Z2=INT(Z2+.5)
8860 LET S8=Z1*Z4+Z2+*3-26
8870 LET Z3=0
8880 IF S8>72 THEN GOTO 8920
8890 IF Q$[S8,S8+2]<>A$ THEN GOTO 9000
8900 LET Z3=1
8910 GOTO 9000
8920 IF S8>144 THEN GOTO 8970
8930 LET S8=S8-72
8940 IF R$[S8,S8+2]<>A$ THEN GOTO 9000
8950 LET Z3=1
8960 GOTO 9000
8970 LET S8=S8-144
8980 IF S$[S8,S8+2]<>A$ THEN GOTO 9000
8990 LET Z3=1
9000 RETURN
9010 REM ** S/R PRODUCES QUADRANT NAME IN G2$ FROM Z4,Z5(=Q1,Q2)
9020 REM ** (CALL WITH G5=1 TO GET REGION NAME ONLY)
9030 LET L2=2
9040 LET Z5>=5 THEN GOTO 9060
9050 LET L2=1
9060 LET L3=2*(Z4-1)+L2
9070 LET I3=1 
9080 LET I0=1
9090 FOR L=1 TO LEN(G1$)
9100   IF G1$[L,L]<>"." THEN GOTO 9140
9110   IF I3=L3 THEN GOTO 9150
9120   LET I0=L+1
9130   LET I3=I3+1
9140 NEXT L
9150 LET G2$=G1$[I0,L-1]
9160 IF G5=1 THEN GOTO 9240
9170 LET L3=Z5
9180 IF Z5<=4 THEN GOTO 9200 
9190 LET L3=Z5-4
9200 LET G3$="IV"
9210 IF L3=4 THEN GOTO 9230
9220 LET G3$=G4$[1,L3]
9230 LET G2$=G2$," ",G3$
9240 RETURN
9250 STOP
9260 END