10 CLEAR,&HC9EF
20 DEFINT I, J, V
30 FOR I = &HC9F0 TO &HCA02
40 READ J: POKE I, J
50 NEXT
60 IRANDOM = &HC9F0
70 CALL IRANDOM(INTEGER)
80 DATA &HE5,&HCD,&HFA,&HC9,&H23,&HCD,&HFA,&HC9,

	&HE1,&HC9,&HED,&H5F,&H17,&H77,&HED,&H5F,

	&HAE,&H77,&HC9
90 RANDOMIZE(INTEGER)
100 DIM I,Q$,A,A$,G2$,X,X$,K3,J,Q1,Q2,S1,S2,B9,R1,

	S,T,W1,Y,Z1,Z2
110 DIM G(8,8), C(9,2), K(3,3), N(3), Z(8,8), D(8)
120 CLS$ = CHR$(26)
130 ESC$ = CHR$(27)
140 ENTERPRISE$ = "(" + CHR$(140) + ")"
150 KLINGON$ = "[k]"
160 STARBASE$ = CHR$(128) + CHR$(151) + CHR$(128)
170 SCANLINE$ = STRING$(19,"-")
180 REPORT.LINE$ = STRING$(25,"-")
190 RECORD.LINE$ = "    --- --- --- --- --- --- --- ---"
200 GALAXY.LINE$ = "     ----- ----- ----- ----- ----- ----- ----- -----"
205 YES% = 1:NO% = 0
210 PRINT CLS$
220 PRINT TAB(10)"STARTREK -- VERSION 1.2  01/02/80"
230 PRINT TAB(18) "Revised 09/09/80"
240 PRINT TAB(13) "Moved to Osborne  09/26/81"
250 PRINT: PRINT: PRINT
260 PRINT "                                     \-------*------/"

:PRINT
270 PRINT "\----------------------/              \-----/  /---/":

PRINT "                                           /  /"
280 PRINT "   \-------|   |-----/                    /  /":

PRINT"           |   |                         /  /"
290 PRINT "     \-----|   |------------------------/  /-------/":

PRINT
300 PRINT "        \----------------------------------------/
310 PRINT: PRINT: PRINT:

PRINT TAB(10) "THE USS ENTERPRISE --- NCC-1701"
320 Z$ = SPACE$(25)
330 T0 = INT (RND * 20 + 20) * 100: T = 0:

	T9 = 25 + INT(RND * 10) : D0 = 0: E = 3000:

	E0 = E
340 P = 10: P0 = P: S9 = 200: S = 0: B9 = 0: K9 = 0:

	X$ = "": X0$ = " IS "
350 DEF FND = SQR((K(I,1) - S1) ^ 2 + (K(I,2) -

	S2) ^ 2)
360 DEF FNR(R) = INT(INT(RND * R) * 7.98 + 1.01)
370 DEF FNR0 = INT(RND * 7.98 + 1.01)
400 '-----INITIALIZE ENTERPRISE'S POSITION
410 Q1 = FNR0
420 Q2 = FNR0
430 S1 = FNR0
440 S2 = FNR0
450 FOR I = 1 TO 9: C(I,2) = 0: NEXT
460 C(3,1) = -1: C(2,1) = -1: C(4,1) = -1:

	C(4,2) = -1: C(5,2) = -1: C(6,2) = -1
470 C(1,2) = 1: C(2,2) = 1: C(6,1) = 1: C(7,1) = 1:

	C(8,1) = 1: C(8,2) = 1: C(9,2) = 1
480 FOR I = 1 TO 8: D(I) = 0: NEXT
490 A1$ = "NAVSRSLRSPHATORSHEDAMCOMXXX"
500 '-----SET UP WHAT EXISTS IN GALAXY
510 '-----K3 = KLINGONS. B3 = STARBASES. S3 = STARS
520 FOR I = 1 TO 8: FOR J = 1 TO 8
530 K3 = 0: Z(I,J) = 0: R1 = RND
540 IF R1 > .98 THEN K3 = 3: K9 = K9 + 3: GOTO 570
550 IF R1 > .95 THEN K3 = 2: K9 = K9 + 2: GOTO 570
560 IF R1 > .8 THEN K3 = 1: K9 = K9 + 1
570 B3 = 0: IF RND > .96 THEN B3 = 1: B9 = B9 + 1
580 G(I,J) = K3 * 100 + B3 * 10 + FNR0
590 NEXT J, I
600 IF B9 <> 0 THEN 640
610 V1 = INT(Q1): V2 = INT(Q2)
620 IF G(V1,V2) < 200 THEN G(V1,V2) = G(V1,V2) +

	100: K9 = K9 + 1
630 B9 = 1: G(V1,V2) = G(V1,V2) + 10: Q1 = FNR0:

	Q2 = FNR0
640 T9 = T9 - B3:IF T9 < K9 * 1.1 THEN

	T9 = K9 * 1.1 - B3
650 K7 = K9: IF B9 <> 1 THEN X$ = "S":

	X0$ = "ARE"
660 PRINT:PRINT:PRINT"THERE ARE";K9;"KLINGONS IN";:

	PRINT" THE GALAXY":PRINT
670 PRINT"YOU HAVE";T9;"DAYS TO COMPLETE YOUR MISSION":PRINT
680 PRINT"THERE ";X0$;B9;;"STARBASE";X$;" IN THE GALAXY":PRINT
690 PRINT"INDICATE WHEN READY TO TAKE COMMAND";
700 I = RND: INPUT SR$
800 '-----JUMP HERE ANY TIME NEW QUADRANT ENTERED
810 Z4 = Q1:Z5 = Q2: K3 = 0: B3 = 0: S3 = 0: G5 = 0
820 D4 = .5 * RND
830 Z(Q1,Q2) = G(Q1,Q2)
840 IF Q1 < 1 OR Q1 > 8 OR Q2 < 1 OR Q2 > 8 THEN 980
850 GOSUB 7420: PRINT: IF T <> 0 THEN 890
860 PRINT CLS$: PRINT: PRINT:

	PRINT"YOUR MISSION BEGINS WITH YOUR STARSHIP"
870 PRINT"LOCATED IN THE GALACTIC QUADRANT, '";G2$;"'."
880 GOTO 900
890 PRINT"NOW ENTERING ";G2$;" QUADRANT . . ."
900 V1 = INT(Q1): V2 = INT(Q2):PRINT: K3 = INT(G(V1,V2) * .01)
910 B3 = INT(G(Q1,Q2) * .1) - 10 * K3
920 S3 = G(V1,V2) - 100 * K3 - 10 * B3
930 IF K3 = 0 THEN 970
940 PRINT"COMBAT AREA      CONDITION RED"
950 IF S > 200 THEN 970
960 PRINT"   SHIELDS DANGEROUSLY LOW"
970 FOR I = 1 TO 3: K(I,1) = 0: K(I,2) = 0: NEXT
980 FOR I = 1 TO 3: K(I,3) = 0: NEXT
990 Q$ = SPACE$(192)
1000 '-----POSITION ENTERPRISE IN QUADRANT. THEN
1010 '-----PLACE K3 KLINGONS, B3 BASES AND S3 STARS.
1020 A$ = ENTERPRISE$: Z1 = S1: Z2 = S2
1030 GOSUB 7110: IF K3 < 1 THEN 1090
1040 FOR I = 1 TO K3: GOSUB 7010
1050 A$ = KLINGON$: Z1 = R1: Z2 = R2
1060 GOSUB 7110: K(I,1) = R1: K(I,2) = R2
1070 K(I,3) = S9 * (.5 + RND)
1080 NEXT
1090 IF B3 < 1 THEN 1130
1100 GOSUB 7010
1110 A$ = STARBASE$: Z1 = R1: B4 = R1: Z2 = R2
1120 B5 = R2: GOSUB 7110
1130 FOR I = 1 TO S3: GOSUB 7010
1140 A$ = " * ": Z1 = R1: Z2 = R2: GOSUB 7110
1150 NEXT
1160 GOSUB 5610
2000 DFLAG% = NO%:

	IF S + E > 10 THEN IF E > 10 OR D(7) = 0

	THEN 2050
2010 PRINT:PRINT"** FATAL ERROR  **":

	PRINT"YOU ARE STRANDED IN SPACE."
2020 PRINT"YOU HAVE INSUFFICIENT MANEUVERING ENERGY,"
2030 PRINT"AND SHIELD CONTROL PRESENTLY IS INCAPABLE"
2040 PRINT"OF CROSS-CIRCUITING TO THE ENGINE ROOM!!":

	GOTO 5410
2050 INPUT"COMMAND";A$
2060 FOR I = 1 TO 9: IF LEFT$(A$,3)

	<> MID$(A1$, 3 * I - 2, 3) THEN 2080
2070 ON I GOTO 2210, 1160, 3610, 3810, 4210, 4710,

	4910, 6010, 5430
2080 NEXT: PRINT"ENTER ONE OF THE FOLLOWING:"
2090 PRINT"   NAV (TO SET COURSE)"
2100 PRINT"   SRS (FOR SHORT-RANGE SCAN)"
2110 PRINT"   LRS (FOR LONG-RANGE SCAN)"
2120 PRINT"   PHA (TO FIRE PHASERS)"
2130 PRINT"   TOR (TO FIRE PHOTON TORPEDO)"
2140 PRINT"   SHE (TO RAISE OR LOWER SHIELDS)"
2150 PRINT"   DAM (FOR DAMAGE CONTROL REPORTS)"
2160 PRINT"   COM (TO CALL LIBRARY - COMPUTER)"
2170 PRINT"   XXX (TO RESIGN YOUR COMMAND)"
2180 PRINT: GOTO 2000
2200 '-----COURSE CONTROL BEGINS HERE
2210 INPUT"COURSE (1 - 9)";C1: IF C1 = 9 THEN C1 = 1
2220 IF C1 >= 1 AND C1 < 9 THEN 2240
2230 PRINT"** INCORRECT COURSE **": GOTO 2000
2240 X$ = "8": IF D(1) < 0 THEN X$ = "0.2"
2250 PRINT"WARP FACTOR (0 - "; X$;")";: INPUT W1
2260 IF D(1) < 0 AND W1 > .2 THEN 2310
2270 IF W1 > 0 AND W1 <= 8 THEN 2330
2280 IF W1 = 0 THEN 2000
2290 PRINT"INCORRECT WARP FACTOR ";W1
2300 GOTO 2000
2310 PRINT"WARP ENGINES DAMAGED. MAX WARP 0.2"
2320 GOTO 2000
2330 N = INT(W1 * 8 + .5): IF E - N >= 0 THEN 2410
2340 PRINT"INSUFFICIENT ENERGY AVAILABLE"
2350 PRINT"FOR WARP"; W1; "!"
2360 IF S < N - E OR D(7) < 0 THEN 2000
2370 PRINT S; "UNITS OF ENERGY DEPLOYED TO SHIELDS"
2380 GOTO 2000
2400 '-----KLINGONS MOVE/FIRE ON STARSHIP
2410 FOR I = 1 TO K3
2420 IF K(I,3) = 0 THEN 2500
2430 A$ = "   "
2440 Z1 = K(I,1): Z2 = K(I,2)
2450 GOSUB 7110
2460 GOSUB 7010
2470 K(I,1) = Z1: K(I,2) = Z2
2480 A$ = KLINGON$
2490 GOSUB 7110
2500 NEXT
2510 GOSUB 5210: D1 = 0: D6 = W1
2520 IF W1 >= 1 THEN D6 = 1
2530 FOR I = 1 TO 8
2540 IF D(I) >= 0 THEN 2600
2550 D(I) = D(I) + D6: IF D(I) > -.1 AND D(I) < 0

	THEN D(I) = -.1: GOTO 2600
2560 IF D(I) < 0 THEN 2600
2570 IF D1 <> 1 THEN D1 = 1:

	PRINT"DAMAGE CONTROL REPORT:   ":
2580 PRINT TAB(8);: R1 = I: GOSUB 7210
2590 PRINT ESC$; ")"; G2$;" REPAIR COMPLETED"; ESC$; "("
2600 NEXT
2610 IF RND > .2 THEN 2810
2620 R1 = FNR0: RANDOM = RND: IF RANDOM >.5

	THEN 2680
2630 D(R1) = D(R1) - (RND * 5 + 1)
2640 PRINT"DAMAGE CONTROL REPORT:  ":
2650 GOSUB 7210
2660 PRINT ESC$; "l"; G2$;" DAMAGED"; ESC$; "m": PRINT
2670 GOTO 2810
2680 D(R1) = D(R1) + RND * 3 + 1
2690 PRINT"DAMAGE CONTROL REPORT:   ":
2700 GOSUB 7210
2710 PRINT G2$;" STATE OF REPAIR IMPROVED": PRINT
2800 '-----BEGIN MOVING STARSHIP
2810 A$ = "   "
2820 Z1 = INT(S1)
2830 Z2 = INT(S2)
2840 GOSUB 7110
2850 X1 = C(INT(C1),1) + (C(INT(C1+1),1) - C(INT(C1),1)) *

	(C1 - INT(C1))
2860 X = S1: Y = S2
2870 X2 = C(INT(C1),2) + (C(INT(C1+1),2) - C(INT(C1),2)) *

	(C1 - INT(C1))
2880 Q4 = Q1: Q5 = Q2
2890 FOR I = 1 TO N
2900 S1 = S1 + X1
2910 S2 = S2 + X2
2920 IF S1 < 1 OR S1 >= 9 OR S2 < 1 OR S2 >= 9

	THEN 3210
2930 S8 = INT(S1) * 24 + INT(S2) * 3 - 26
2940 IF MID$(Q$,S8,2) = "  " THEN 2990
2950 S1 = INT(S1 - X1)
2960 S2 = INT(S2 - X2)
2970 PRINT"WARP ENGINES SHUT DOWN AT"
2980 PRINT"SECTOR";S1;",";S2;"DUE TO BAD NAVIGATION":

	GOTO 3000
2990 NEXT: S1 = INT(S1): S2 = INT(S2)
3000 A$ = ENTERPRISE$
3010 Z1 = INT(S1): Z2 = INT(S2)
3020 GOSUB 7110: GOSUB 3510: T8 = 1
3030 IF W1 < 1 THEN T8 = .1 * INT(10 * W1)
3040 T = T + T8
3050 IF T > T9 THEN 5410
3100 '-----SEE IF DOCKED. THEN GET COMMAND
3110 GOTO 1160
3200 '-----PAST QUADRANT LIMITS
3210 X = 8 * Q1 + X + N * X1
3220 Y = 8 * Q2 + Y + N * X2
3230 Q1 = INT(X / 8)
3240 Q2 = INT(Y / 8)
3250 S1 = INT(X - Q1 * 8)
3260 S2 = INT(Y - Q2 * 8)
3270 IF S1 = 0 THEN Q1 = Q1 - 1: S1 = 8
3280 IF S2 = 0 THEN Q2 = Q2 - 1: S2 = 8
3290 X5 = 0
3300 IF Q1 < 1 THEN X5 = 1: Q1 = 1: S1 = 1
3310 IF Q1 > 8 THEN X5 = 1: Q1 = 8: S1 = 8
3320 IF Q2 < 1 THEN X5 = 1: Q2 = 1: S2 = 1
3330 IF Q2 > 8 THEN X5 = 1: Q2 = 8: S2 = 8
3340 IF X5 = 0 THEN 3380
3350 PRINT"WARP ENGINES SHUT DOWN AT:"
3360 PRINT"SECTOR";S1;",";S2;"OF QUADRANT";

	Q1;","Q2"
3370 IF T > T9 THEN 5410
3380 IF 8 * Q1 + Q2 = 8 * Q4 + Q5 THEN 3000
3390 T = T + 1
3400 GOSUB 3510
3410 GOTO 810
3500 '-----MANEUVER ENERGY S/R **
3510 E = E - N - 10: IF E > 0 THEN RETURN
3520 PRINT"SHIELD CONTROL SUPPLIES ENERGY":

	PRINT"TO COMPLETE THE MANEUVER"
3530 S = S + E
3540 E = 0
3550 IF S <= 0 THEN S = 0
3560 RETURN
3600 '-----LONG RANGE SENSOR SCAN CODE
3610 IF D(3) < 0 THEN PRINT

	"LONG RANGE SENSORS ARE INOPERABLE":

	GOTO 2000
3620 PRINT"LONG RANGE SCAN FOR QUADRANT";Q1;",";Q2
3630 PRINT SCANLINE$
3640 FOR I = INT(Q1)-1 TO INT(Q1)+1
3650 N(1) = -1: N(2) = -2: N(3) = -3
3660 FOR J = Q2-1 TO Q2+1
3670 IF I > 0 AND I < 9 AND J > 0 AND J < 9

	THEN N(J-Q2+2) = G(I,J): Z(I,J) = G(I,J)
3680 NEXT: FOR L = 1 TO 3: PRINT"| ";
3690 IF N(L) < 0 THEN PRINT"*** ";: GOTO 3710
3700 PRINT RIGHT$(STR$(N(L)+1000),3);" ";
3710 NEXT: PRINT"|": PRINT SCANLINE$
3720 NEXT: GOTO 2000
3800 '-----PHASER CONTROL CODE BEGINS HERE
3810 IF D(4) < 0 THEN PRINT"PHASERS INOPERATIVE":

	GOTO 2000
3820 IF K3 > 0 THEN 3860
3830 PRINT"SENSORS SHOW NO ENEMY SHIPS";
3840 PRINT" IN THIS QUADRANT"
3850 GOTO 2000
3860 IF D(8) < 0 THEN PRINT"COMPUTER FAILURE HAMPERS ACCURACY"
3870 PRINT"PHASERS LOCKED ON TARGET: "
3880 PRINT"ENERGY AVAILABLE =";E;" UNITS"
3890 INPUT"NUMBER OF UNITS TO FIRE";X
3900 IF X <= 0 THEN 2000
3910 IF E - X < 0 THEN 3880
3920 E = E - X: IF D(7) < 0 THEN X = X * RND
3930 H1 = INT(X/K3)
3940 FOR I = 1 TO 3
3950 IF K(I,3) <= 0 THEN 4100
3960 H = INT((H1/FND) * (RND + 2))
3970 IF H > .15 * K(I,3) THEN 4000
3980 PRINT"SENSORS SHOW NO DAMAGE TO ENEMY AT ";

	K(I,1);",";K(I,2)
3990 GOTO 4100
4000 K(I,3) = K(I,3) - H
4010 PRINT H;"UNIT HIT ON KLINGON AT SECTOR";

	K(I,1);",";
4020 PRINT K(I,2): IF K(I,3) <= 0 THEN

	PRINT ESC$; "l";"*** KLINGON DESTROYED ***" ESC$; "m":

	GOTO 4050
4030 PRINT"   (SENSORS SHOW";K(I,3);"UNITS REMAINING)"
4040 GOTO 4100
4050 K3 = K3 - 1: K9 = K9 - 1
4060 Z1 = K(I,1): Z2 = K(I,2)
4070 A$ = "   ": GOSUB 7110
4080 K(I,3) = 0: G(Q1,Q2) = G(Q1,Q2) - 100
4090 Z(Q1,Q2) = G(Q1,Q2): IF K9 <= 0 THEN 5500
4100 NEXT: GOSUB 5210
4110 GOTO 2000
4200 '-----PHOTON TORPEDO CODE BEGINS HERE
4210 IF P <= 0 THEN PRINT"ALL PHOTON TORPEDOS EXPENDED":

	GOTO 2000
4220 IF D(5) < 0 THEN

	PRINT"PHOTON TUBES NOT OPERATIONAL": GOTO 2000
4230 INPUT"PHOTON TORPEDO COURSE (1 - 9)";C1
4240 IF C1 = 9 THEN C1 = 1
4250 IF C1 >= 1 AND C1 < 9 THEN 4280
4260 PRINT"INCORRECT COURSE DATA"
4270 GOTO 2000
4280 X1 = C(INT(C1),1) + (C(INT(C1+1),1) - C(INT(C1),1)) *

	(C1 - INT(C1)): E = E - 2: P = P - 1
4290 X2 = C(INT(C1),2) + (C(INT(C1+1),2) - C(INT(C1),2)) *

	(C1 - INT(C1)): X = S1: Y = S2
4300 PRINT"TORPEDO TRACK:"
4310 X = X + X1: Y = Y + X2
4320 X3 = INT(X+.5)
4330 Y3 = INT(Y+.5)
4340 IF X3 < 1 OR X3 > 8 OR Y3 <1 OR Y3 > 8 THEN 4650
4350 PRINT"          ";X3;","Y3
4360 A$ = "   "
4370 Z1 = X: Z2 = Y
4380 GOSUB 7310
4390 IF Z3 <> 0 THEN 4310
4400 A$ = KLINGON$
4410 Z1 = X: Z2 = Y
4420 GOSUB 7310: IF Z3 = 0 THEN 4490
4430 PRINT ESC$; "l";"*** KLINGON DESTROYED ***"; ESC$; "m"
4440 K3 = K3 - 1: K9 = K9 - 1: IF K9 <= 0 THEN 5500
4450 FOR I = 1 TO 3
4460 IF X3 = K(I,1) AND Y3 = K(I,2) THEN 4480
4470 NEXT: I = 3
4480 K(I,3) = 0: GOTO 4620
4490 A$ = " * ": Z1 = X: Z2 = Y
4500 GOSUB 7310: IF Z3 = 0 THEN 4530
4510 PRINT"STAR AT";X3;",";Y3;

	"ABSORBED TORPEDO ENERGY"
4520 GOSUB 5210: GOTO 2000
4530 A$ = STARBASE$
4540 Z1 = X: Z2 = Y
4550 GOSUB 7310: IF Z3 = 0 THEN 4230
4560 PRINT"*** STARBASE DESTROYED ***"
4570 B3 = B3 - 1: B9 = B9 -1
4580 IF B9 > 0 OR K9 > T9 - T THEN 4610
4590 PRINT"THAT'S IT. YOU ARE RELIEVED OF COMMAND"
4600 GOTO 5430
4610 D0 = 0
4620 Z1 = X: Z2 = Y: A$ = "   ": GOSUB 7110
4630 G(Q1,Q2) = K3 * 100 + B3 * 10 + S3
4640 Z(Q1,Q2) = G(Q1,Q2): GOSUB 5210: GOTO 2000
4650 PRINT"TORPEDO MISSED": GOSUB 5210: GOTO 2000
4700 '-----SHIELD CONTROL
4710 IF D(7) < 0 THEN

	PRINT"SHIELD CONTROL INOPERABLE": GOTO 2000
4720 PRINT"ENERGY AVAILABLE =";E+S
4730 INPUT"NUMBER OF UNITS TO SHIELDS";X
4740 IF X < 0 OR S = X THEN

	PRINT"<SHIELDS UNCHANGED>": GOTO 2000
4750 IF X <= E + S THEN 4780
4760 PRINT"ENERGY NOT AVAILABLE"
4770 PRINT"<SHIELDS UNCHANGED>": GOTO 2000
4780 E = E + S - X: S = X
4790 PRINT"SHIELDS NOW AT";INT(S);"UNITS"
4800 GOTO 2000
4900 '-----DAMAGE CONTROL
4910 IF D(6) >= 0 THEN 5080
4920 PRINT"DAMAGE CONTROL REPORT NOT AVAILABLE"
4930 IF D0 = 0 THEN 2000
4940 D3 = 0: FOR I = 1 TO 8
4950 IF D(I) < 0 THEN D3 = D3 + .1
4960 NEXT
4970 IF D3 = 0 THEN 2000
4980 PRINT: D3 = D3 + D4
4990 IF D3 >= 1 THEN D3 = .9
5000 PRINT"ESTIMATED TIME TO REPAIR SHIP:";
5010 PRINT .01 * INT(100 * D3);"DAYS"
5020 INPUT"DO YOU DESIRE REPAIR (Y/N)";A$
5030 IF A$ <> "Y" THEN 2000
5040 FOR I = 1 TO 8
5050 IF D(I) < 0 THEN D(I) = 0
5060 NEXT
5070 T = T + D3
5080 PRINT:PRINT

	"DEVICE             STATE OF REPAIR":

	FOR R1 = 1 TO 8
5090 GOSUB 7210
5100 PRINT G2$; LEFT$(Z$,25-LEN(G2$));

	INT(D(R1) * 100) * .01
5110 NEXT R1: PRINT: IF D0 <> 0 THEN 4940
5120 GOTO 2000
5200 '-----KLINGONS SHOOTING
5210 IF K3 <= 0 THEN RETURN
5220 IF D0 <> 0 THEN

	PRINT"STARBASE SHIELDS PROTECT THE SHIP":

	RETURN
5230 FOR I = 1 TO 3
5240 IF K(I,3) <= 0 THEN 5350
5250 H = INT((K(I,3) / FND) * (2 + RND))
5260 S = S - H: K(I,3) = K(I,3) / (3 + RND)
5270 PRINT H;"UNIT HIT ON SHIP FROM SECTOR";

	K(I,1);","K(I,2)
5280 IF S <= 0 THEN 5420
5290 PRINT"     <SHIELDS DOWN TO";S;"UNITS>"
5300 IF H < 20 THEN 5350
5310 IF RND > .6 OR H/S <= .02 THEN 5350
5320 R1 = FNR0: D(R1) = D(R1) - H/S - .5 * RND
5330 GOSUB 7210
5340 PRINT ESC$; "l"; G2$;" DAMAGED BY THE HIT"; ESC$; "m"
5350 NEXT: RETURN
5400 '-----END OF GAME
5410 PRINT:PRINT STRING$(52,"+"): PRINT"THERE ARE";T9-T;"DAYS REMAINING":

	GOTO 5430
5420 PRINT:PRINT STRING$(52,"]"):PRINT"YOUR SHIP DESTROYED": GOTO 5410
5430 PRINT"THERE WERE";K9;"KLINGONS":

	PRINT" LEFT AT THE END OF YOUR MISSION"
5440 PRINT: PRINT
5450 IF B9 = 0 THEN 5490
5460 PRINT"DO YOU WANT TO TRY AGAIN (Y/N)";
5470 INPUT A$
5480 IF A$ = "Y" THEN 210
5490 END
5500 PRINT:PRINT STRING$(52,"^"): PRINT"CONGRATULATIONS":

	PRINT"YOU HAVE DESTROYED THE LAST KLINGON"
5510 PRINT"YOUR EFFICIENCY RATING IS: ";

	1000 * (K7/T)^2: GOTO 5440
5600 '-----SHORT-RANGE SENSOR SCAN AND STARTUP
5610 FOR I = S1 - 1 TO S1 + 1
5620 FOR J = S2 - 1 TO S2 + 1
5630 IF INT(I+.5) <1 OR INT(I+.5) > 8 OR

	INT(J+.5) < 1 OR INT(J+.5) > 8 THEN 5670
5640 A$ = STARBASE$
5650 Z1 = I: Z2 = J
5660 GOSUB 7310: IF Z3 = 1 THEN 5700
5670 NEXT J, I
5680 D0 = 0
5690 GOTO 5730
5700 D0 = 1: C$ = "DOCKED": E = E0: P = P0
5710 PRINT"SHIELDS DROPPED FOR DOCKING"
5720 S = 0: GOTO 5750
5730 IF K3 > 0 THEN C$ = "RED": GOTO 5750
5740 C$ = "GREEN": IF E < E0 THEN C$ = "YELLOW"
5750 IF D(2) >= 0 THEN 5780
5760 PRINT: PRINT"*** SHORT-RANGE SENSORS ARE OUT ***"
5770 PRINT: RETURN
5780 PRINT REPORT.LINE$
5790 FOR I = 1 TO 8
5800 FOR J = (I-1) * 24+1 TO (I-1) * 24+22 STEP 3:

	PRINT MID$(Q$,J,3);:NEXT J:PRINT" ";
5810 ON I GOTO 5820, 5830, 5840, 5850, 5860, 5870,

	5880, 5890
5820 PRINT"DAYS REMAINING     ";

	INT((T9-T) * 10) * .1: GOTO 5900
5830 PRINT"CONDITION           ";C$: GOTO 5900
5840 PRINT"QUADRANT           ";

	Q1;","Q2: GOTO 5900
5850 PRINT"SECTOR             ";

	S1;",";S2: GOTO 5900
5860 PRINT"PHOTON TORPEDOS    ";INT(P):

	GOTO 5900
5870 PRINT"TOTAL ENERGY       ";INT(E+S):

	GOTO 5900
5880 PRINT"SHIELDS            ";INT(S):

	GOTO 5900
5890 PRINT"KLINGONS REMAINING ";INT(K9)
5900 NEXT I: PRINT REPORT.LINE$: RETURN
6000 '-----LIBRARY COMPUTER CODE
6010 IF D(8) < 0 THEN PRINT"COMPUTER DISABLED":

	GOTO 2000
6020 A = 9: INPUT"COMPUTER COMMAND";A
6030 IF A < 0 THEN 2000
6040 PRINT: H8 = 1: ON A+1 GOTO 6310, 6510, 6610,

	6920, 6670, 6210
6050 PRINT"AVAILABLE COMPUTER FUNCTIONS:"
6060 PRINT"    0 = CUMULATIVE GALACTIC RECORD"
6070 PRINT"    1 = STATUS REPORT"
6080 PRINT"    2 = TORPEDO COURSE DATA"
6090 PRINT"    3 = STARBASE COURSE DATA"
6100 PRINT"    4 = COURSE CALCULATOR"
6110 PRINT"    5 = GALACTIC REGION NAME MAP":

	PRINT: GOTO 6020
6200 '-----SETUP TO CHANGE CUM GALACTIC RECORD

	TO GALAXY MAP
6210 H8 = 0: G5 = 1:

	PRINT STRING$(24," ");"THE GALAXY"
6220 PRINT"       1     2     3     4     5     6     7     8"
6230 PRINT GALAXY.LINE$
6240 GOTO 6370
6300 '-----CUMULATIVE GALACTIC RECORD
6310 '
6320 PRINT:PRINT"        ";
6330 PRINT"COMPUTER RECORD FOR QUADRANT";Q1;",";Q2
6340 PRINT
6350 PRINT"     1   2   3   4   5   6   7   8"
6360 PRINT RECORD.LINE$
6370 FOR I = 1 TO 8: PRINT I;: IF H8 = 0 THEN 6430
6380 FOR J = 1 TO 8:PRINT" ";: IF Z(I,J) = 0

	THEN PRINT"***";: GOTO 6420
6390 IF I = Q1 AND J = Q2 THEN PRINT ESC$;")";
6400 PRINT RIGHT$(STR$(Z(I,J)+1000),3);
6410 IF I = Q1 AND J = Q2 THEN PRINT ESC$;"(";
6420 NEXT J: GOTO 6470
6430 Z4 = I: Z5 = 1
6440 GOSUB 7420: J0 = INT(15-.5 * LEN(G2$))
6450 PRINT TAB(J0);G2$;
6460 Z5 = 5:GOSUB 7420: J0 = INT(39-.5*LEN(G2$)):

	PRINT TAB(J0);G2$
6470 PRINT: NEXT I: PRINT: GOTO 2000
6500 '-----STATUS REPORT
6510 PRINT"    STATUS REPORT:"
6520 X$ = "": IF K9 > 1 THEN X$ = "S"
6530 PRINT"KLINGON";X$;" LEFT: ";K9
6540 PRINT"MISSION MUST BE COMPLETED IN";

	.1 * INT((T9 - T) * 10);"DAYS"
6550 X$ = "S": IF B9 < 2 THEN X$ = "":

	IF B9 < 1 THEN 6580
6560 PRINT"THERE ARE";B9;"BASE";X$;" IN THE GALAXY"
6570 GOTO 4910
6580 PRINT"YOU ARE ON YOUR OWN IN THE GALAXY"
6590 PRINT"YOU HAVE NO STARBASES LEFT!": GOTO 4910
6600 '-----TORPEDO, BASE NAV, D/D CALCULATOR
6610 IF K3 <= 0 THEN 3830
6620 X$ = "": IF KE > 1 THEN X$ = "S"
6630 PRINT"FROM ENTERPRISE TO KLINGON BATTLE CRUISER";

	X$
6640 H8 = 0: FOR I = 1 TO 3: IF K(I,3) <= 0 THEN 6910
6650 W1 = K(I,1): X = K(I,2)
6660 C1 = S1: A = S2: DFLAG% = YES%: GOTO 6710
6670 PRINT"NAVIGATION CALCULATOR:"
6680 PRINT"YOU ARE AT QUADRANT ";Q1;",";Q2;

	" SECTOR ";S1;",";S2
6690 C1 = Q1: A = Q2
6700 INPUT"DESTINATION COORDINATES (X,Y)";W1, X
6710 X = X - A: A = C1 - W1: IF X < 0 THEN 6810
6720 IF A < 0 THEN 6830
6730 IF X > 0 THEN 6750
6740 IF A = 0 THEN C1 = 5: GOTO 6760
6750 C1 = 1
6760 IF ABS(A) <= ABS(X) THEN 6790
6770 PRINT"DIRECTION =";

	C1 + (((ABS(A) - ABS(X)) + ABS(A))/ABS(A))
6780 GOTO 6880
6790 PRINT"DIRECTION =";

	C1 + (ABS(A)/ABS(X))
6800 GOTO 6880
6810 IF A > 0 THEN C1 = 3: GOTO 6840
6820 IF X <> 0 THEN C1 = 5: GOTO 6760
6830 C1 = 7
6840 IF ABS(A) >= ABS(X) THEN 6870
6850 PRINT"DIRECTION =";

	C1 + (((ABS(X) - ABS(A))+ ABS(X))/ABS(X))
6860 GOTO 6880
6870 PRINT"DIRECTION ="; C1 + (ABS(X)/ABS(A))
6880 IF ABS(X) > ABS(A) THEN DI = ABS(X) ELSE

	DI = ABS(A)
6890 PRINT"DISTANCE =";: IF DFLAG% THEN

	PRINT DI/10 ELSE PRINT DI
6900 IF H8 = 1 THEN 2000
6910 NEXT I: GOTO 2000
6920 IF B3 <> 0 THEN

	PRINT"FROM ENTERPRISE TO STARBASE:":

	W1 = B4: X = B5: GOTO 6660
6930 PRINT"NO STARBASES IN THIS QUADRANT"
6940 GOTO 2000
7000 '-----FIND EMPTY PLACE IN QUADRANT
7010 R1 = FNR0: R2 = FNR0: A$ = "   ": Z1 = R1:

	Z2 = R2: GOSUB 7310: IF Z3 = 0 THEN 7010
7020 RETURN
7100 '-----INSERT STRING IN QUADRANT ARRAY
7110 S8 = INT(Z2-.5) * 3 + INT(Z1-.5) * 24 + 1
7120 IF LEN(A$) <> 3 THEN PRINT"ERROR IN 8675": STOP
7130 IF S8 = 1 THEN Q$ = A$ + RIGHT$(Q$,189): RETURN
7140 IF S8 = 190 THEN Q$ = LEFT$(Q$,189) + A$:

	RETURN
7150 Q$ = LEFT$(Q$,S8-1) + A$ + RIGHT$(Q$,190-S8):

	RETURN
7200 '-----PRINT DEVICE NAME
7210 ON R1 GOTO 7220, 7230, 7240, 7250, 7260,

	7270, 7280, 7290
7220 G2$ = "WARP ENGINES": RETURN
7230 G2$ = "SHORT-RANGE SENSORS": RETURN
7240 G2$ = "LONG-RANGE SENSORS": RETURN
7250 G2$ = "PHASER CONTROL": RETURN
7260 G2$ = "PHOTON TUBES": RETURN
7270 G2$ = "DAMAGE CONTROL": RETURN
7280 G2$ = "SHIELD CONTROL": RETURN
7290 G2$ = "LIBRARY-COMPUTER": RETURN
7300 '-----STRING COMPARISON IN QUADRANT ARRAY
7310 Z1 = INT(Z1+.5): Z2 = INT(Z2+.5)
7320 S8 = (Z2-1) * 3 + (Z1-1) * 24 + 1: Z3 = 0
7330 IF MID$(Q$,S8,3) <> A$ THEN RETURN
7340 Z3 = 1: RETURN
7400 '-----QUADRANT NAME IN G2$ FROM Z4, Z5

	(= Q1, Q2)
7410 '-----CALL WITH G5 = 1 TO GET REGION NAME ONLY
7420 IF Z5 <= 4 THEN ON Z4 GOTO 7440, 7450, 7460,

	7470, 7480, 7490, 7500, 7510
7430 GOTO 7520
7440 G2$ = "ANTARES": GOTO 7610
7450 G2$ = "RIGEL": GOTO 7610
7460 G2$ = "PROCYON": GOTO 7610
7470 G2$ = "VEGA": GOTO 7610
7480 G2$ = "CANOPUS": GOTO 7610
7490 G2$ = "ALTAIR": GOTO 7610
7500 G2$ = "SAGITTARIUS": GOTO 7610
7510 G2$ = "POLLUX": GOTO 7610
7520 ON Z4 GOTO 7530, 7540, 7550, 7560, 7570,

	7580, 7590, 7600
7530 G2$ = "SIRIUS": GOTO 7610
7540 G2$ = "DENEB": GOTO 7610
7550 G2$ = "CAPELLA": GOTO 7610
7560 G2$ = "BETELGEUSE": GOTO 7610
7570 G2$ = "ALDEBARAN": GOTO 7610
7580 G2$ = "REGULUS": GOTO 7610
7590 G2$ = "ARCTURUS": GOTO 7610
7600 G2$ = "SPICA"
7610 IF G5 <> 1 THEN ON Z5 GOTO 7630, 7640, 7650,

	7660, 7630, 7640, 7650, 7660
7620 RETURN
7630 G2$ = G2$ + " I": RETURN
7640 G2$ = G2$ + " II": RETURN
7650 G2$ = G2$ + " III": RETURN
7660 G2$ = G2$ + " IV": RETURN
630 G2$ = G2$ + " I": RETURN
7640 G2$ = G2$ + " II": RE