1 DEG :TF=24:DR=9000:O=0:I=1:L=100:T=10:C2=2:POKE 16,112:POKE 53774,112
2 SETCOLOR C2,O,C2:SETCOLOR 4,5,5:GOSUB 10400:GOTO L
3 ? "↰":? :? "EMERGENCY!":? :RETURN 
10 IF TA>O OR DI$="D" OR RND(O)<0.97 THEN RETURN 
12 F=Q+I:G=O
14 IF F=65 THEN F=I
16 IF CM(F)=I THEN GOTO TF
18 F=F+I:G=G+I
20 IF G=63 THEN RETURN 
22 GOTO 14
24 ? :? N$;" CAUGHT IN TRACTOR BEAM..":? 
25 IF V$="R" THEN ? "REST PERIOD CANCELED..":V$="X":? 
26 Q=F:QY=INT((Q+7)/8):QX=Q-((QY-I)*8)
28 EY=(QY-I)+(INT(RND(O)*T)/T)+0.05:EX=(QX-I)+(INT(RND(O)*T)/T)+0.05
30 GOSUB 8350
32 IF SH$="DOWN" THEN CQ=O:GOSUB 700:CQ=I
34 IF RND(O)<I/C2+P THEN GOSUB 2320
35 IF RND(O)>I/C2+P THEN CQ=O
36 GOSUB 3000:CQ=I
38 TA=RND(O)*T+3:RETURN 
40 IF U=I OR V=O THEN RETURN 
41 IF DAM(8,I)>O THEN RETURN 
43 TD=(INT(RND(O)*300)/L)+I
44 D=V:GOSUB 9010:GOSUB 2300
46 ? "STARBASE IN QUADRANT ";E;",";F;" UNDER":? "ATTACK. THEY CAN HOLD OUT"
48 ? "FOR ";TD;" STAR DAYS.":U=I
60 RETURN 
61 RETURN 
62 RETURN 
70 FOR J=I TO 3
73 POSITION TF-I,I+I:? "BATTLE STATIONS":FOR X=I TO L:NEXT X:POSITION TF-I,I+I:? "               "
75 NEXT J:POSITION 3,5:RETURN 
90 TIME=TIME+(SK-KLG)^3*1.0E-05:RETURN 
100 POP :TRAP 2000:GOTO 170
109 IF RND(O)<0.96 THEN RETURN 
110 A=INT(RND(O)*8)+I:B=INT(RND(O)*8)+I:W=(B-I)*8+A
111 IF QI$(W,W)="N" THEN GOTO L+T
113 IF CM(W)>O OR ST(W)=O OR BA(W)=I THEN RETURN 
115 IF W=Q THEN 120
116 IF DAM(8,I)>O THEN QI$(W,W)="U":GOTO 130
117 GOSUB 2300:? "SUPERNOVA DETECTED IN"
118 ? "QUADRANT ";A;",";B;".  ADVISED TO AVOID."
120 GOSUB 8150
130 IF W=Q THEN GOSUB 4100
131 RETURN 
170 GOSUB T:GOSUB 109:IF RND(O)>0.94 THEN GOSUB 40
460 RESTORE 490:TA=TA-I:? :? "COMMAND ";:INPUT C$
465 FOR X=I TO 18:READ V$,B
470 IF C$=V$ THEN GOSUB B:GOTO 481
479 NEXT X
480 GOSUB L*L:GOTO 460
481 POP :IF X=5 OR X=8 THEN GOTO L
482 GOTO 460
490 DATA SRS,500,WAR,600,SHI,700,STA,800,MOV,900,DAM,2800,CHA,2100,RES,2900,LRS,2400,DOC,2700,COM,2600
491 DATA PHO,4500,PHA,7000,DES,8000,HEL,7500,IMP,8500,ABA,8800,DIV,8950
500 Z=9:GOSUB 2310
511 ? "↰":POSITION 4,I:FOR X=I TO T:? X;" ";:NEXT X
515 FOR X=I TO T:POSITION I,X+C2:? X:NEXT X
530 FOR Y=3 TO 12 STEP I:FOR X=4 TO 22 STEP C2:POSITION X,Y
550 ? CHR$(SEC(((X/C2)-I),Y-C2)):NEXT X:NEXT Y:QI$(Q,Q)="X"
580 POSITION TF,C2+I:? "STARDATE:";INT(STDT*T)/T
581 POSITION TF,4:? "CODE ";CO$
582 POSITION TF,5:? "ENERGY=";INT(ENG)
583 POSITION TF,6:? "RESERVES=";INT(LS*L)/L
585 POSITION TF,7:? "WARP:";WAR
586 POSITION TF,8:? "TORPEDOS=";TOR
587 POSITION TF,T-I:? "KLINGONS=";KLG
588 POSITION TF,T:? "SHIELDS:";SH$
589 POSITION TF,T+I:? " @ ";SH;"%"
590 POSITION TF,T+C2:? "QUADRANT: ";QX;",";QY
591 POSITION TF,13:? "SECTOR: ";SX;",";SY
592 POSITION TF,14:? "TIME LEFT=";INT(TIME*L)/L
599 POSITION I,15:RETURN 
600 ? :? "AT WARP ";WAR;" CAPTAIN..NEW SETTING ";:INPUT A
625 IF A<I OR A>T THEN A=WAR
650 ? :? "WARP ";A;" SHE IS SIR!":WAR=A:RETURN 
700 ? :? "SHIELDS ARE ";SH$;" CAPTAIN."
710 ? "UP OR DOWN ";:INPUT C$
720 IF C$="DOW" THEN SH$="DOWN":GOTO 750
730 IF C$="UP" THEN SH$="UP":ENG=ENG-T:GOTO 750
731 GOTO 710
750 ? :? "SHIELDS ";SH$;" SIR!":IF CQ=O THEN RETURN 
760 GOTO 2320
800 ? "↰":POSITION 13,I:? "USS ";N$
802 POSITION 17,3:? "STATUS":? 
810 ? "STAR DATE",,INT(STDT*L)/L
815 ? "STAR DAYS LEFT",,INT(TIME*L)/L
820 ? "CONDITION CODE",,CO$
830 ? "ENERGY",,,INT(ENG)
835 ? "LIFE SUPPORT RESERVES",INT(LS*L)/L
840 ? "WARP",,,WAR
850 ? "TORPEDOS",,,TOR
860 ? "KLINGONS LEFT",,KLG
870 ? "SHIELDS",,,SH$
871 ? " @",,,SH;"%"
875 ? :? N$;" COORDINATES"
880 ? "  QUADRANT",,QX;",";QY
890 ? "  SECTOR",,,SX;",";SY
899 ? :RETURN 
900 I$=" ":Z=C2:GOSUB 2310
930 CEX=EX:CEY=EY:CQ=Q:DI$=" "
940 ? :? "COURSE ";:INPUT DIR:POKE 84,(PEEK(84)-I):POKE 85,T+T
941 ? "DISTANCE ";:INPUT DIS:IF DIS<0.1 THEN ? :? "MINIMUM .1":? :GOTO 941
942 IF I$="I" THEN GOTO 960
949 A=T*DIS*1.5^WAR/ENG
950 IF SH$="UP" THEN A=C2*A
951 IF A>0.95 THEN V$="ENERGY":GOSUB 8670
959 A=DIS*3/WAR/TIME
960 IF I$="I" THEN A=DIS*T/TIME
961 IF A>0.95 THEN V$="TIME":GOSUB 8670
970 GOSUB 2320
1240 DEG :X=I/T
1250 EX=CEX+(SIN(30*DIR)*X)
1260 EX=INT(T*EX):EX=EX/T+0.05
1280 EY=CEY+((COS(30*DIR)*X)*-I)
1290 EY=INT(T*EY):EY=EY/T+0.05
1310 QX=INT(EX+I):QY=INT(EY+I)
1325 A=(QY-I)*8+QX:GOSUB 8350
1365 IF CQ<>A THEN GOTO 1500
1370 IF SEC(SX,SY)=45 OR SEC(SX,SY)=S THEN 1500
1372 IF SEC(SX,SY)=42 OR SEC(SX,SY)=66 THEN GOSUB 4200:X=X-I/T:DIS=X:GOTO 1250
1374 IF SEC(SX,SY)=67 OR SEC(SX,SY)=75 THEN GOSUB 4210:DIS=X:GOTO 1250
1500 IF X=DIS THEN 1620
1505 IF X>DIS OR CQ<>A THEN 1550
1520 X=X+I/T:GOTO 1250
1550 X=DIS:GOTO 1250
1620 OSX=CEX-INT(CEX):OSX=INT(OSX*T)+I
1630 OSY=CEY-INT(CEY):OSY=INT(OSY*T)+I
1710 SEC(OSX,OSY)=45
1715 IF EY<=O OR EY>8 OR EX<=O OR EX>8 THEN 1810
1720 SEC(SX,SY)=S:Q=(QY-I)*8+QX
1809 IF I$="I" THEN 1828
1810 Z=T*DIS*1.5^WAR:ENG=ENG-Z
1811 IF SH$="UP" THEN ENG=ENG-Z
1825 IF ENG<0 THEN 20050
1828 A=DIS*3/WAR
1829 IF I$="I" THEN A=DIS*T
1840 GOSUB 11000:GOSUB 8550:GOSUB 8600
1890 IF EY<=O OR EY>8 OR EX<=O OR EX>8 THEN GOSUB 4000:GOTO 1902
1900 IF Q<>CQ THEN GOSUB 3000
1902 IF WAR<=7 THEN 1910
1903 IF WAR=T AND RND(O)>0.9 THEN GOSUB 2350
1904 IF RND(O)>0.95 THEN Z=C2:DF=C2:GOSUB 8210:? :? "SCOTT HERE CAPTAIN..THE WARP DRIVE IS":? "DAMAGED..."
1910 IF KL(Q)+CM(Q)=O THEN CO$="GREEN":SETCOLOR 4,12,4
1920 IF ENG<800 THEN CO$="YELLOW":SETCOLOR 4,I,6
1930 IF KL(Q)+CM(Q)>O THEN CO$="RED":SETCOLOR 4,3,4
1940 IF KLG<=O THEN 20200
1999 RETURN 
2000 ? :? "BEG YOUR PARDON CAPTAIN?":GOTO L
2100 ? "↰":A=O
2105 ? "    CHART OF THE KNOWN GALAXY "
2110 POSITION 4,3:FOR X=I TO 8:? " ";X;"  ";:NEXT X
2140 FOR X=I TO 8:POSITION I,C2*X+3:? X:NEXT X
2190 FOR Y=5 TO 19 STEP C2:FOR X=4 TO 32 STEP 4:POSITION X,Y
2201 A=A+I
2202 IF QI$(A,A)="N" THEN 2215
2203 IF QI$(A,A)=" " THEN 2213
2210 ? KL(A)+CM(A);BA(A);ST(A):GOTO 2220
2213 ? "---":GOTO 2220
2215 ? "***":GOTO 2220
2220 NEXT X:NEXT Y
2232 POSITION 4,4:FOR X=I TO 8
2233 IF X=QX THEN ? " ␛↓  ";
2235 IF X<>QX THEN ? "    ";
2236 NEXT X
2237 FOR X=I TO 8:POSITION C2,(C2*X+3)
2239 IF X=QY THEN ? "␛→"
2240 IF X<>QY THEN ? " "
2241 NEXT X
2249 POSITION 3,21:RETURN 
2300 ? :? "MESSAGE FROM STARFLEET, CAPTAIN..":? 
2301 RETURN 
2310 GOSUB 2850:IF DAM(Z,I)>O THEN ? "":? V$;" DAMAGED!":POP :GOTO L
2311 RETURN 
2320 IF CO$="RED" THEN GOSUB 6000
2321 RETURN 
2340 ? :? "CAPTAIN THE VESSEL AT SEC (";HX;",";HY;") HAS":? "LOST ITS FIRE POWER.":RETURN 
2350 A=-5+INT(RND(O)*900)/L:V$=" AHEAD ":IF SGN(A)=-I THEN V$=" BACK "
2352 ? :? "SPOCK HERE CAPTAIN, THE ";N$:? "HAS ENTERED A TIME WARP!":BT=BT+A
2354 ? "WE APPEAR TO HAVE GONE";V$;"IN TIME":? ABS(A);" STAR DAYS..":GOSUB 11000:RETURN 
2370 RETURN 
2375 RETURN 
2380 RETURN 
2390 FOR J=4 TO T:SETCOLOR C2,J,12:FOR JW=I TO T:NEXT JW:NEXT J:SETCOLOR C2,O,C2:RETURN 
2400 Z=T:GOSUB 2310
2405 ? "↰"
2406 POSITION 12,4:? " LONG RANGE SCAN ":B=4
2410 FOR Y=-I TO I:B=B+C2:A=8
2411 FOR X=-I TO I:A=A+5
2420 POSITION A,B
2430 TQ=(QY+Y-1)*8+(QX+X)
2439 IF QY+Y<I OR QY+Y>8 OR QX+X<I OR QX+X>8 THEN 2460
2445 IF QI$(TQ,TQ)="N" OR QI$(TQ,TQ)="U" THEN 2465
2450 ? KL(TQ)+CM(TQ);BA(TQ);ST(TQ):QI$(TQ,TQ)="X":GOTO 2500
2460 ? "...":GOTO 2500
2465 ? "***"
2470 IF QI$(TQ,TQ)="U" THEN QI$(TQ,TQ)="N":KLG=KLG-(KL(TQ)+CM(TQ)):KL(TQ)=O:CM(TQ)=O:BA(TQ)=O:ST(TQ)=O
2500 NEXT X:NEXT Y
2510 POSITION 6,14:? N$;" IN QUADRANT ";QX;",";QY:? 
2599 RETURN 
2600 Z=5:GOSUB 2310
2602 ? "WORKING..";
2604 ? " SUBSYSTEM ";:INPUT C$
2605 IF C$="TAC" THEN V$=" TARGET":A=QX:B=QY:GOSUB 2662:GOTO 2667
2606 IF C$="NAV" THEN V$=" SECTOR":GOSUB 2660:GOTO 2667
2607 IF C$="TIM" THEN 2620
2608 IF C$="ENE" THEN 2640
2609 IF C$="BYE" THEN RETURN 
2610 ? " COMPUTER SUBSYSTEMS ARE:"
2611 ? :? "TIME","TACTICAL"
2612 ? "ENERGY","NAVIGATION"
2613 ? :GOTO 2604
2620 ? " DISTANCE ";:INPUT X
2621 ? " WARP FACTOR ";:INPUT Y
2622 A=X*(3/Y)
2623 ? "TIME= ";INT(A*L*L)/(L*L);" STAR DAYS":RETURN 
2640 ? " DISTANCE ";:INPUT X
2641 ? " WARP FACTOR ";:INPUT Y
2642 ? " SHIELDS ";:INPUT C$
2643 IF C$="DOW" OR C$="UP" THEN 2646
2645 ? "UP OR DOWN?":GOTO 2642
2646 A=T*X*1.5^Y:IF C$="UP" THEN A=C2*A
2647 ? "ENERGY REQUIRED IS ";INT(A*L*L)/(L*L):RETURN 
2660 ? " QUADRANT X COORDINATE ";:INPUT A:IF A<I OR A>8 THEN ? "":GOTO 2660
2661 ? " QUADRANT Y COORDINATE ";:INPUT B:IF B<I OR B>8 THEN ? "":GOTO 2661
2662 ? V$;" X COORDINATE ";:INPUT X:IF X<I OR X>T THEN ? "":GOTO 2662
2663 ? V$;" Y COORDINATE ";:INPUT Y:IF Y<I OR Y>T THEN ? "":GOTO 2663
2664 X=(A-I)+(X/T)-0.05:Y=(B-I)+(Y/T)-0.05
2665 A=(SQR((ABS(X-EX)^C2)+(ABS(EY-Y)^C2)))
2666 Z=INT((A+1.0E-05)*L*L)/(L*L):RETURN 
2667 ? "DISTANCE= ";Z;" ";
2668 IF Y-EY=O AND X-EX>O THEN ? " COURSE= 3":RETURN 
2669 IF Y-EY=O AND X-EX<O THEN ? " COURSE= 9":RETURN 
2670 C=ABS(EX-X)/A:B=ATN(C/SQR(-C*C+I))
2671 IF X-EX>=O AND Y-EY<O THEN A=O:GOTO 2675
2672 IF X-EX>O AND Y-EY>O THEN A=3:GOTO 2676
2673 IF X-EX<=O AND Y-EY>O THEN A=6:GOTO 2675
2674 IF X-EX<O AND Y-EY<O THEN A=9:GOTO 2676
2675 ? "COURSE= ";INT((((B/30)+A)+1.0E-05)*L*L)/(L*L):RETURN 
2676 ? "COURSE= ";INT(((((90-B)/30)+A)+1.0E-05)*L*L)/(L*L):RETURN 
2700 A=O
2710 FOR X=-I TO I:FOR Y=-I TO I
2730 IF SX+X<I OR SX+X>T OR SY+Y<I OR SY+Y>T THEN 2750
2740 IF SEC(SX+X,SY+Y)=66 THEN A=I
2750 NEXT Y:NEXT X
2760 IF A=O THEN ? :? N$;" NOT ADJACENT TO STARBASE":RETURN 
2770 ? :? N$;" DOCKED"
2780 TOR=15:ENG=10000:SH=L:LS=2.5:DI$="D"
2781 IF S=70 THEN ENG=3000:TOR=6:LS=1.5
2799 GOSUB 1910:RETURN 
2800 A=O
2801 FOR X=I TO 11:A=A+DAM(X,I):NEXT X
2804 IF A=O THEN 2898
2810 ? "↰":? ,"   DAMAGE REPORT":? :? ,"STAR DATE: ";INT(STDT*L)/L:? 
2812 ? ,,"  REPAIR TIME"
2813 ? "  SYSTEM           IN SPACE  AT BASE"
2814 ? "  ▔▔▔▔▔▔           ▔▔▔▔▔▔▔▔  ▔▔▔▔▔▔▔ "
2820 FOR Z=I TO T+I
2822 IF DAM(Z,I)=O THEN 2830
2824 GOSUB 2850:B=DAM(Z,I):C=DAM(Z,C2)
2825 ? "● ";V$,INT((B*0.9+RND(O)*0.2*B)*L)/L,INT((C*0.9+RND(O)*0.2*C)*L)/L
2830 NEXT Z
2849 RETURN 
2850 IF Z=I THEN V$="SHIELDS":RETURN 
2851 IF Z=C2 THEN V$="WARP DRIVE":RETURN 
2852 IF Z=3 THEN V$="PHOTON TUBES":RETURN 
2853 IF Z=4 THEN V$="PHASERS":RETURN 
2854 IF Z=5 THEN V$="COMPUTER":RETURN 
2855 IF Z=6 THEN V$="LIFE SUPPORT":RETURN 
2856 IF Z=7 THEN V$="SHUTTLE CRAFT":RETURN 
2857 IF Z=8 THEN V$="SUB SPACE RADIO":RETURN 
2858 IF Z=T-I THEN V$="SHORT RANGE SCAN":RETURN 
2859 IF Z=T THEN V$="LONG RANGE SCAN":RETURN 
2860 IF Z=T+I THEN V$="IMPULSE ENGINES":RETURN 
2898 ? :? "ALL SYSTEMS ARE FUNCTIONAL.":RETURN 
2900 V$="R":IF CO$<>"RED" THEN GOTO 2910
2901 ? :? "THE ";N$;" IS IN BATTLE..ARE YOU":? "SERIOUS (Y/N) ";:INPUT C$
2905 IF C$="Y" THEN 20080
2906 RETURN 
2910 ? "STAR DAYS FOR REST PERIOD ";:INPUT DA:DA=ABS(DA)
2912 A=RND(O):IF A>DA THEN A=DA
2914 GOSUB 8550:GOSUB 8600:GOSUB 11000
2943 GOSUB 109:GOSUB 40:GOSUB T:DA=DA-A:IF V$="X" THEN 2949
2944 IF DA>0 THEN 2912
2948 ? "↰":? :? "** STAR DATE ";INT(STDT*L)/L:? 
2949 V$=" ":RETURN 
3000 ? "↰":? :? "** STAR DATE ";INT(STDT*L)/L:? 
3102 ? "** ";N$;" ENTERING QUADRANT ";QX;",";QY
3200 H=O:FOR X=I TO T:FOR Y=I TO T:SEC(X,Y)=45:NEXT Y:NEXT X
3240 SEC(SX,SY)=S
3300 IF ST(Q)=O THEN 3355
3310 FOR X=I TO ST(Q):GOSUB 8400
3350 SEC(A,B)=42:NEXT X
3355 FOR X=I TO 9:EP(X)=L:NEXT X:EC=I
3356 FOR X=I TO 9:POW(X)=O:NEXT X
3400 IF KL(Q)=O THEN 3500
3410 FOR X=I TO KL(Q):GOSUB 8400
3450 SEC(A,B)=75
3455 GOSUB 8430:POW(EC)=180+500*P*RND(O):EC=EC+I
3460 NEXT X
3500 IF CM(Q)=O THEN 3600
3510 FOR X=I TO CM(Q):GOSUB 8400
3550 SEC(A,B)=67
3555 GOSUB 8430:POW(EC)=500+1200*P*RND(O):EC=EC+I
3560 NEXT X
3600 IF BA(Q)=O THEN 3800
3610 FOR X=I TO BA(Q):GOSUB 8400
3650 SEC(A,B)=66
3660 NEXT X
3800 GOSUB 1910:IF CO$="RED" THEN GOSUB 70
3996 IF CQ=O THEN 3998
3997 GOSUB 2320
3998 IF QI$(Q,Q)="N" OR QI$(Q,Q)="U" THEN GOSUB 4110
3999 RETURN 
4000 GOSUB 3:? N$;" ATTEMPTING TO LEAVE GALAXY"
4010 ? :? "EMERGENCY OVERRIDE CONTROLS ACTIVATED":? "WARPDRIVE SET TO 10....":WAR=T
4025 IF LEAVE=O THEN ? :? "FIRST WARNING!"
4030 IF LEAVE=I THEN ? :? "LAST WARNING!!"
4035 LEAVE=LEAVE+I
4036 IF LEAVE>C2 THEN PTS(4)=PTS(4)+I:GOTO 20000
4040 GOSUB 8300:GOSUB 3000
4080 IF RND(O)>0.9 THEN 4099
4081 DF=C2:GOSUB 8200
4086 ? :? "CAPTAIN, DAMAGE CONTROL REPORT NOW":? "COMING IN AFTER ENCOUNTER WITH THE"
4087 ? "GALATIC BARRIER...":? 
4089 ? "DAMAGE SUSTAINED ON ";V$
4099 RETURN 
4100 GOSUB 3
4102 ? "EMINENT SUPERNOVA DETECTED!":GOTO 4120
4110 GOSUB 3
4112 ? N$;" ENTERING SUPERNOVA AREA"
4114 ? "RADIATION LEVELS EXTREMELY HIGH"
4120 ? :? "AUTOMATIC OVERRIDE IN EFFECT.":? 
4122 WAR=T:DIR=INT((RND(O)*1200)+L)/L:DIS=INT((RND(O)*L)+141)/L
4124 ? " WARP=10":? " COURSE SET AT ";DIR:? " DISTANCE SET TO ";DIS
4127 IF RND(O)>0.7 THEN 4138
4128 DF=3:GOSUB 8200
4132 ? :? "STARSHIP BUFFETED BY INTENSE STELLAR":? "WINDS. ";V$;" DAMAGED.."
4138 IF DAM(C2,I)=O THEN CEX=EX:CEY=EY:CQ=Q:GOSUB 1240
4139 IF CQ=Q OR W=Q THEN 4141
4140 RETURN 
4141 IF DAM(C2,I)>O THEN ? :? N$;" UNABLE TO LEAVE QUADRANT.."
4142 ? "... DESTROYED BY RADIATION..."
4145 GOTO 21000
4200 GOSUB 3:? N$;" BLOCKED BY OBJECT AT":? "SECTOR ";SX;",";SY;".  100 UNITS OF ENERGY"
4201 ? "EXPENDED ON EMERGENCY STOP!":? :ENG=ENG-L:RETURN 
4210 IF SEC(SX,SY)=67 THEN CM(Q)=CM(Q)-I:V$="COMANDER ":PTS(C2)=PTS(C2)+I
4211 IF SEC(SX,SY)=75 THEN KL(Q)=KL(Q)-I:V$="KLINGON VESSEL ":PTS(5)=PTS(5)+I
4212 GOSUB 3:? "SECURE ALL DECKS FOR COLLISION WITH"
4213 ? V$;"AT SECTOR ";SX;",";SY:? 
4214 B=781:GOSUB 2375
4220 ? "THE ";V$;"AT SECTOR ";SX;",";SY:? "HAS BEEN DESTROYED CAPTAIN.. THE"
4221 ? N$;" HAS SUSTAINED EXTENSIVE":? "DAMAGE.."
4226 FOR C=I TO T+I:DAM(C,I)=DAM(C,I)+(RND(O)*30)
4227 DAM(C,C2)=DAM(C,I)/(RND(O)+I):NEXT C
4229 IF S=70 THEN DAM(7,I)=O
4230 KLG=KLG-I:SEC(SX,SY)=45
4250 GOSUB 1910:RETURN 
4500 Z=3:GOSUB 2310
4502 IF TOR=O THEN ? "":? "NO TORPEDOES LEFT":RETURN 
4510 CQ=I:? :? "COURSE ";:INPUT DIR:POKE 84,(PEEK(84)-I):POKE 85,T+T:IF TOR<3 THEN B=O:? :GOTO 4519
4517 ? "BURST > ";:INPUT B
4518 IF B<O OR B>45 THEN ? "1 TO 45 DEGRESS OR":? "0 FOR SINGLE FIRE.":? :GOTO 4517
4519 IF B=O THEN C=I
4520 IF B>O THEN C=C2+I
4523 ? :IF TOR=O THEN 4990
4524 IF RND(O)>0.95 THEN ? "TORPEDO ";CQ;" MISFIRES..":TOR=TOR-I:GOSUB 9020:CQ=CQ+1:GOTO 4523
4525 IF RND(O)>0.95 THEN ? "TORPEDO ";CQ;" MISFIRES..":? "":? " TUBES DAMAGED!":GOTO 4527
4526 GOTO 4530
4527 TOR=TOR-I:Z=3:DF=1:GOSUB 8210:GOTO 4990
4530 ? "TORPEDO ";CQ;" AWAY...";:GOSUB 2380:? "TRACK..";
4540 X=I
4550 DEG :HX=SX+(SIN(30*DIR)*X):POKE 85,25:? "(";INT(HX*T)/T;",";
4560 HX=INT(HX+0.5)
4580 HY=SY+((COS(30*DIR)*X)*-I):? INT(HY*T)/T;")    ":POKE 84,PEEK(84)-I
4590 HY=INT(HY+0.5)
4613 IF HX>T OR HX<I OR HY>T OR HY<I THEN ? :? " MISSED..":GOTO 4670
4614 IF SEC(HX,HY)=75 THEN ? :GOSUB 5000:GOTO 4670
4615 IF SEC(HX,HY)=66 THEN ? :GOSUB 5100:GOTO 4670
4616 IF SEC(HX,HY)=67 THEN ? :GOSUB 5200:GOTO 4670
4617 IF SEC(HX,HY)=42 THEN ? :GOSUB 5300:GOTO 4670
4645 X=X+I
4655 GOTO 4550
4670 IF DI$<>"D" THEN TOR=TOR-I
4671 C=C-I:CQ=CQ+I:IF C=O OR DAM(3,I)>O THEN GOTO 4990
4673 IF C=C2 THEN DIR=DIR-(B/30):GOTO 4523
4674 IF C=I THEN DIR=DIR+2*(B/30):GOTO 4523
4990 GOSUB 1910:GOSUB 2320:A=C2/L:GOSUB 11000
4999 RETURN 
5000 D=75:IF RND(O)<I-P THEN GOTO 5010
5002 ? " KLINGON AT SECTOR ";HX;",";HY;" DAMAGED..":CX=HX:CY=HY:GOSUB 8450:GOSUB 5230
5005 RETURN 
5010 GOSUB 2390:? " KLINGON AT SECTOR ";HX;",";HY;" DESTROYED..":KL(Q)=KL(Q)-I:KLG=KLG-I:PTS(5)=PTS(5)+I:GOSUB 90
5020 SEC(HX,HY)=45:CX=HX:CY=HY:GOSUB 8440:RETURN 
5100 Y=50+INT(RND(O)*L):GOSUB 2390
5101 ? " STARBASE AT SECTOR ";HX;",";HY;" DESTROYED..":BA(Q)=BA(Q)-I:PTS(6)=PTS(6)+Y:SEC(HX,HY)=45:DI$=" "
5102 ? " ALL ";Y;" FEDERATION PERSONNEL LOST!":? :? "NICE GOING CAPTAIN!!":RETURN 
5200 D=67
5205 IF RND(O)>0.8 THEN ? " COMANDER AT SECTOR ";HX;",";HY;" USES ANTI-":? " PHOTON TORPEDO DEVICE..":RETURN 
5207 IF H=O THEN 5220
5210 IF RND(O)>I/T+P THEN 5250
5220 ? " COMMANDER AT SECTOR ";HX;",";HY;" DAMAGED..":CX=HX:CY=HY:GOSUB 8450:H=H+I:IF RND(O)<P THEN H=O
5230 M=I:IF SEC(HX,HY)=S THEN M=C2
5231 A=HX-M*INT(C2*RND(O))*SGN(SX-HX):B=HY-M*INT(2*RND(O))*SGN(SY-HY)
5232 IF SX-HX=O THEN A=(HX-M)+INT(3*RND(O))
5233 IF SY-HY=O THEN B=(HY-M)+INT(3*RND(O))
5234 IF A<I OR A>T OR B<I OR B>T THEN 5240
5235 IF SEC(A,B)<>45 THEN 5240
5236 ? " DISPLACED TO SEC ";A;",";B:SEC(HX,HY)=45:IF D=67 OR D=75 THEN SEC(A,B)=D:GOTO 5238
5237 GOTO 5239
5238 IF M=I THEN CX=HX:CY=HY:HX=A:HY=B:GOSUB 8440:GOSUB 8430:GOTO 5240
5239 IF M=C2 THEN SX=A:SY=B:EX=INT(EX)+SX/T-0.05:EY=INT(EY)+SY/T-0.05:SEC(A,B)=S:RETURN 
5240 IF POW(EC)<30 THEN GOSUB 2340
5241 RETURN 
5250 GOSUB 2390:? " COMANDER AT SECTOR ";HX;",";HY;" DESTROYED..":CM(Q)=CM(Q)-I:KLG=KLG-I:GOSUB 90
5299 PTS(C2)=PTS(C2)+I:SEC(HX,HY)=45:CX=HX:CY=HY:GOSUB 8440:RETURN 
5300 IF RND(O)>0.8 THEN 5310
5301 IF RND(O)<I/T THEN 5370
5302 ? " STAR AT SECTOR ";HX;",";HY;" UNAFFECTED..":RETURN 
5310 GOSUB 2390:? " STAR AT SECTOR ";HX;",";HY;" NOVAS..":ST(Q)=ST(Q)-I:PTS(I)=PTS(I)+I:SEC(HX,HY)=45
5315 RX=HX:RY=HY
5320 FOR X=-I TO I:FOR Y=-I TO I
5330 IF HX+X<I OR HX+X>T OR HY+Y<I OR HY+Y>T THEN GOTO 5350
5340 IF SEC(HX+X,HY+Y)=75 THEN HX=HX+X:HY=HY+Y:GOSUB 5000:HX=RX:HY=RY
5341 IF SEC(HX+X,HY+Y)=67 THEN HX=HX+X:HY=HY+Y:GOSUB 5210:HX=RX:HY=RY
5342 IF SEC(HX+X,HY+Y)=42 THEN HX=HX+X:HY=HY+Y:GOSUB 5400:HX=RX:HY=RY
5343 IF SEC(HX+X,HY+Y)=S THEN HX=HX+X:HY=HY+Y:GOSUB 5600:HX=RX:HY=RY
5350 NEXT Y:NEXT X
5360 RETURN 
5370 GOSUB 2390:? " STAR AT SECTOR ";HX;",";HY;" SUPER NOVAS..":PTS(I)=PTS(I)+ST(Q):PTS(2)=PTS(2)+CM(Q)
5372 PTS(5)=PTS(5)+KL(Q):KLG=KLG-CM(Q)-KL(Q):GOSUB 90:GOSUB 3:POP :W=Q:GOSUB 8150:GOSUB 4120:GOTO L
5400 IF RND(O)<I/T THEN POP :GOTO 5370
5401 IF RND(O)>0.6 THEN ? " STAR AT SECTOR ";HX;",";HY;" UNAFFECTED..":RETURN 
5403 GOSUB 2390:? " STAR AT SECTOR ";HX;",";HY;" NOVAS..":ST(Q)=ST(Q)-I:PTS(I)=PTS(I)+I:SEC(HX,HY)=45
5405 VX=HX:VY=HY
5406 FOR F=-I TO I:FOR G=-I TO I
5410 IF HX+F<I OR HX+F>T OR HY+G<I OR HY+G>T THEN 5418
5412 IF SEC(HX+F,HY+G)=75 THEN HX=HX+F:HY=HY+G:GOSUB 5000:HX=VX:HY=VY
5414 IF SEC(HX+F,HY+G)=67 THEN HX=HX+F:HY=HY+G:GOSUB 5210:HX=VX:HY=VY
5416 IF SEC(HX+F,HY+G)=42 THEN HX=HX+F:HY=HY+G:GOSUB 5450:HX=VX:HY=VY
5417 IF SEC(HX+F,HY+G)=S THEN HX=HX+F:HY=HY+G:GOSUB 5600:HX=VX:HY=VY
5418 NEXT G:NEXT F
5420 RETURN 
5450 IF RND(O)>I/C2 THEN ? " STAR AT SECTOR ";HX;",";HY;" UNAFFECTED..":RETURN 
5452 POP :GOTO 5370
5600 ? :? N$;" BUFFETED BY STELLAR BLAST":D=S:GOSUB 5230
5610 IF RND(O)>I/C2 THEN DF=C2:GOSUB 8200:? " ..";V$;" DAMAGED.."
5620 RETURN 
6000 ? :IF DI$="D" THEN ? "KLINGONS ATTACK..STARBASE SHIELDS":? "PROTECT THE ";N$:RETURN 
6005 C=O:TX=O:TY=O:TE=O
6010 FOR EC=I TO T-I
6015 IF EP(EC)=L THEN 6500
6016 X=INT(EP(EC)/T):Y=EP(EC)-X*T
6017 IF X=O THEN X=T
6018 IF Y=O THEN Y=T
6031 V$="KLINGON"
6032 IF SEC(X,Y)=67 THEN V$="COMMANDER":TX=X:TY=Y:TE=EC
6035 IF POW(EC)<30 THEN 6500
6050 A=SQR((SX-X)^C2+(SY-Y)^C2)
6060 B=INT(POW(EC)/(I+(A-I)*0.3))
6061 IF DAM(I,I)>O THEN GOTO 6065
6062 IF SH$="UP" THEN B=INT(B*30/(SH+30)):SH=SH-INT((B*0.15)*L)/L:IF SH<O THEN SH=O
6065 POW(EC)=POW(EC)*0.98
6200 ? B;" UNIT HIT FROM ";V$;" AT (";X;",";Y;")":GOSUB 2375
6210 ENG=ENG-B:C=C+B
6220 IF ENG<O THEN 20080
6500 NEXT EC
6514 IF RND(O)*C<250 THEN 6525
6515 A=INT(RND(O)*5)+2:PTS(6)=PTS(6)+A
6520 ? :? "McCOY HERE CAPTAIN..WE SUFFERED ";A:? "CASUALITIES IN THE LAST ATTACK.."
6525 IF RND(O)*C>C2*L THEN DF=INT(C/L):GOSUB 8200:? :? V$;" DAMAGED IN THE":? "LAST ATTACK"
6530 IF TX=O THEN RETURN 
6540 IF POW(TE)<150 THEN 6566
6550 A=TX+I*SGN(SX-TX):B=TY+I*SGN(SY-TY):IF SEC(A,B)<>45 THEN RETURN 
6560 ? :? " COMMANDER ADVANCES TO SEC ";A;",";B:SEC(TX,TY)=45:SEC(A,B)=67
6565 CX=TX:CY=TY:GOSUB 8440:GOSUB 8430:POW(EC)=POW(TE):RETURN 
6566 F=C2:G=C2
6570 A=TX-F*SGN(SX-TX):B=TY-G*SGN(SY-TY)
6571 IF A<I THEN D=QX-I:E=QY:GOTO 6590
6572 IF A>T THEN D=QX+I:E=QY:GOTO 6590
6573 IF B<I THEN E=QY-I:D=QX:GOTO 6590
6574 IF B>T THEN E=QY+I:D=QX:GOTO 6590
6577 IF SEC(A,B)<>45 THEN RETURN 
6580 ? :? " COMMANDER RETREATS TO SEC ";A;",";B:SEC(TX,TY)=45:SEC(A,B)=67:CX=TX:CY=TY
6581 GOSUB 8440:GOSUB 8430:POW(EC)=POW(TE):RETURN 
6590 IF E<I OR E>8 OR D<I OR D>8 THEN RETURN 
6592 ? :? " COMMANDER ESCAPES TO QUADRANT ";D;",";E:? " (AND REGAINS STRENGTH)"
6593 Z=((E-I)*8)+D
6594 SEC(TX,TY)=45:CM(Q)=CM(Q)-I:CM(Z)=CM(Z)+I:EP(TE)=L:GOSUB 1910
6595 IF QI$(Z,Z)=" " OR QI$(Z,Z)="X" THEN RETURN 
6596 CM(Z)=O:PTS(C2)=PTS(C2)+I:GOSUB DR
6597 ? :? "CAPTAIN, LONG RANGE SENSORS INDICATE":? "THE COMMANDER HAS BEEN DESTROYED IN":? "QUADRANT ";D;",";E
6599 RETURN 
7000 Z=4:GOSUB 2310
7005 IF DAM(I,I)>O THEN 7020
7010 IF SH$="UP" THEN ? :? "PHASERS CAN NOT BE FIRED WITH SHIELDS":? "UP..":RETURN 
7020 IF DI$="D" THEN ? :? "PHASERS CAN NOT BE FIRED THROUGH":? "STARBASE SHIELDS..":RETURN 
7090 ? :? "UNITS TO FIRE ";:INPUT C:? :C=ABS(C)
7092 IF C>ENG THEN ? "CAPTAIN, YOU ONLY HAVE ";INT(ENG);" UNITS":? "AVAILABLE TO FIRE":? :GOTO 7090
7094 ENG=ENG-C:KP=CM(Q)+KL(Q)
7100 FOR EC=I TO 9
7102 IF KP=O THEN ? C;" UNITS EXPENDED ON EMPTY SPACE"
7104 IF KP=O OR C<=O THEN POP :GOTO 7490
7110 IF EP(EC)=L THEN 7200
7112 X=INT(EP(EC)/T):Y=EP(EC)-X*T
7114 IF X=O THEN X=T
7115 IF Y=O THEN Y=T
7120 V$="COMMANDER"
7130 IF SEC(X,Y)=75 THEN V$="KLINGON"
7140 A=SQR((SX-X)^C2+(SY-Y)^C2)
7150 B=INT(POW(EC)*(I+(A-I)*0.3))+I
7155 IF C<B THEN B=C
7156 F=INT(B/(I+(A-I)*0.3))
7160 POW(EC)=POW(EC)-F
7170 ? F;" UNIT HIT ON ";V$;" AT (";X;",";Y;")":IF U<>L THEN GOSUB 2370
7171 IF POW(EC)<I THEN ? " ";V$;" DESTROYED..":KLG=KLG-I:GOSUB 2390:GOSUB 90:KP=KP-I:POW(EC)=O:EP(EC)=L:GOTO 7173
7172 IF POW(EC)<30 THEN HX=X:HY=Y:GOSUB 2340
7173 IF POW(EC)>O THEN 7180
7174 IF SEC(X,Y)=75 THEN KL(Q)=KL(Q)-I:PTS(5)=PTS(5)+I:SEC(X,Y)=45
7176 IF SEC(X,Y)=67 THEN CM(Q)=CM(Q)-I:PTS(C2)=PTS(C2)+I:SEC(X,Y)=45
7180 C=C-B
7200 NEXT EC
7490 GOSUB 1910:GOSUB 2320:A=C2/L:GOSUB 11000:RETURN 
7500 Z=8:GOSUB 2310
7502 PTS(3)=PTS(3)+I:GOSUB 2301
7503 H=L
7510 FOR C=I TO 64
7520 IF BA(C)=O THEN 7600
7530 X=5:Y=5
7531 B=INT((C+7)/8):A=C-((B-I)*8)
7532 HX=A:HY=B
7540 GOSUB 2664
7550 IF Z<H THEN H=Z:TX=HX:TY=HY
7600 NEXT C
7605 IF H=L THEN ? :? "CAPTAIN, THERE ARE NO STARBASES LEFT!":RETURN 
7607 IF V$="X" THEN 7710
7610 ? :? "CAPTAIN, STARBASE IN QUADRANT ";TX;",";TY:? "IS RESPONDING TO OUR CALL..":A=I:V$="ST":? 
7620 ? "THE ";N$;" DE-MATERIALIZES....":? 
7630 IF A=C2 THEN V$="ND"
7631 IF A=3 THEN V$="RD"
7635 ? A;V$;" ATTEMPT TO RE-MATERIALIZE THE":? N$;" ...";
7640 IF RND(O)/(H+0.01)>C2/T THEN ? "SUCCEEDS!!":GOTO 7700
7650 ? "FAILS!":? :A=A+I
7655 IF A>3 THEN 20090
7660 GOTO 7630
7700 ? :? "CAPTAIN, WE MADE IT!"
7710 SEC(SX,SY)=45:DI$="D"
7715 IF BA(Q)=I THEN 7800
7720 EX=TX-I+0.45:EY=TY-I+0.45
7730 GOSUB 8340
7731 ? "↰":? :? "** STAR DATE ";INT(STDT*L)/L:? 
7732 ? "** ";N$;" AT STARBASE ";QX;",";QY:GOSUB 3200
7800 FOR X=I TO T:FOR Y=I TO T
7810 IF SEC(X,Y)=66 THEN POP :GOTO 7840
7820 NEXT Y:NEXT X
7840 FOR A=-I TO I:FOR B=-I TO I
7845 IF X+A<I OR X+A>T OR Y+B<I OR Y+B>T THEN 7860
7850 IF SEC(X+A,Y+B)=45 THEN POP :GOTO 7870
7860 NEXT B:NEXT A
7870 SEC(X+A,Y+B)=S:SEC(5,5)=45:GOSUB 2780
7871 EX=INT(EX)+(X+A-0.5)/T
7872 EY=INT(EY)+(Y+B-0.5)/T
7873 SX=X+A:SY=Y+B
7999 RETURN 
8000 Z=5:GOSUB 2310
8010 ? :? "ENTER PASSWORD ";:INPUT V$
8020 IF V$<>PASS$ THEN ? "PASSWORD REJECTED!":? "DESTRUCT ABORTED":RETURN 
8030 U=L:? "↰":? "BEGIN DESTRUCT SEQUENCE.."
8040 FOR X=T TO O STEP -I:POSITION 17,10:? X;" ":FOR Y=I TO 31:NEXT Y:NEXT X
8050 C=INT(ENG*T):ENG=O:GOSUB 2390:B=690:GOSUB 2375
8060 ? "↰":? "THE ";N$;" EXPLODES WITH A FORCE":? "EQUIVALENT TO ";C;" UNITS OF ENERGY..":? 
8065 IF DI$="D" THEN GOSUB 5100
8066 PASS$=".POSTHUMOUSLY.":DI$="M"
8090 GOSUB 7094:GOTO 20080
8150 QI$(W,W)="N":KLG=KLG-(KL(W)+CM(W)):BA(W)=O:KL(W)=O:CM(W)=O:ST(W)=O
8152 IF W=Q THEN FOR D=I TO T:FOR E=I TO T:SEC(D,E)=45:NEXT E:NEXT D
8155 RETURN 
8200 Z=INT(RND(O)*T)+I
8205 IF S=70 AND Z=7 THEN 8200
8210 DAM(Z,I)=DAM(Z,I)+(RND(O)*DF)+0.02
8220 DAM(Z,C2)=DAM(Z,I)/(RND(O)+1.5)
8250 GOSUB 2850:RETURN 
8300 EX=(INT(RND(O)*L)/T)+0.05
8310 IF EX>8 THEN 8300
8320 EY=(INT(RND(O)*L)/T)+0.05
8330 IF EY>8 THEN 8320
8340 QX=INT(EX+I):QY=INT(EY+I):Q=(QY-I)*8+QX
8350 SX=EX-INT(EX):SX=INT(SX*T)+I
8390 SY=EY-INT(EY):SY=INT(SY*T)+I:RETURN 
8400 A=INT(RND(O)*T)+I:B=INT(RND(O)*T)+I
8410 IF SEC(A,B)<>45 THEN 8400
8420 RETURN 
8430 IF A=T THEN A=O
8431 IF B=T THEN B=O
8432 EP(EC)=(T*A)+B:RETURN 
8440 IF CX=T THEN CX=O
8441 IF CY=T THEN CY=O
8442 FOR EC=I TO 9:IF EP(EC)=CX*T+CY THEN EP(EC)=L:POP :GOTO 8444
8443 NEXT EC
8444 RETURN 
8450 IF CX=T THEN CX=O
8451 IF CY=T THEN CY=O
8452 FOR EC=I TO T-I:IF EP(EC)=CX*T+CY THEN POW(EC)=POW(EC)*RND(O):POP :GOTO 8454
8453 NEXT EC
8454 RETURN 
8500 I$="I":Z=T+I:GOSUB 2310
8502 GOTO 930
8550 IF DI$="D" THEN RETURN 
8555 IF DAM(6,I)>O THEN LS=LS-A
8557 IF LS>O THEN RETURN 
8560 ? "↰":? "YOUR LIFE SUPPORT RESERVES HAVE BEEN":? "DEPLETED. THE CREW OF THE ";N$
8562 ? "IS NOW GASPING FOR THEIR LAST BREATH":? "OF AIR..":GOTO 20052
8600 IF DI$="D" THEN 8640
8605 FOR X=I TO T+I
8610 IF DAM(X,I)=O THEN 8630
8615 DAM(X,C2)=DAM(X,C2)-(DAM(X,C2)/DAM(X,I)*A)
8620 DAM(X,I)=DAM(X,I)-A
8625 IF INT(DAM(X,I)*L)/L<=O THEN DAM(X,I)=O:DAM(X,C2)=O
8630 NEXT X:RETURN 
8640 FOR X=I TO T+I
8645 IF DAM(X,C2)=O THEN 8665
8650 DAM(X,I)=DAM(X,I)-(DAM(X,I)/DAM(X,C2)*A)
8655 DAM(X,C2)=DAM(X,C2)-A
8660 IF INT(DAM(X,C2)*L)/L<=O THEN DAM(X,I)=O:DAM(X,C2)=O
8665 NEXT X:RETURN 
8670 ? :? "SPOCK HERE CAPTAIN. I CALCULATE THAT":? "SUCH A MOVE WOULD CONSUME "
8671 ? A*L;"% OF OUR AVAILABLE ";V$;"."
8672 ? :? "DO YOU THINK SUCH A MOVE IS WISE":? :INPUT C$
8673 IF C$="YES" THEN RETURN 
8674 IF C$="NO" THEN POP :GOTO L
8675 GOTO 8672
8800 IF S=70 THEN ? :? "THE ";N$;" DOES'T CARRY SHUTTLE":? "CRAFT!":RETURN 
8810 Z=7:GOSUB 2310
8820 S=70:N$="FERRY QUEEN":PTS(4)=I
8830 ? "↰":? "   ABANDON SHIP!","ABANDON SHIP!":GOSUB 4:? 
8850 ? "THE CREW BEAMS DOWN TO A NEARBY PLAN-":? "ET. YOU ARE CAPTURED WITH THE ENTER-"
8852 ? "PRISE BY THE KLINGONS, TRIED AS A WAR":? "CRIMINAL, FOUND GUILTY, AND SENTENCED":? "TO DEATH!"
8853 F=O:FOR G=I TO 64:F=F+BA(G):NEXT G:IF F=O THEN ? "↰":GOTO 20052
8854 ? :? "THE FEDERATION NEGOCIATES FOR YOUR":? "RELEASE WITH THE KLINGONS VIA A PRI-":? "SONER EXCHANGE..":? 
8856 ? "YOU HAVE BEEN REASSIGNED BY THE FE-":? "DERATION TO COMMAND THE FERRY QUEEN."
8860 FOR C=I TO T+I:DAM(C,I)=O:DAM(C,C2)=O:NEXT C:WAR=5
8890 V$="X":GOSUB 7503
8900 V$=" ":RETURN 
8950 ? :? "ENERGY TO OR FROM SHIELDS ";:INPUT C$
8951 IF C$="TO" THEN 8960
8952 IF C$="FRO" THEN 8980
8953 ? "":? " TO OR FROM?":GOTO 8950
8960 ? :? " ENERGY TO SHIELDS ";:INPUT X:X=ABS(X):? 
8961 IF X>ENG-I THEN ? "CAPTAIN, ";INT(ENG)-I;" UNITS ARE AVAILABLE":GOTO 8960
8962 IF SH+X*I/T>L THEN ? "MAXIMUM DIVERSION IS ";(L-SH)/(I/T);" UNITS":GOTO 8960
8970 ENG=ENG-X:SH=SH+X*I/T:IF SH>L THEN SH=L
8971 GOTO 8991
8980 ? :? " ENERGY FROM SHIELDS ";:INPUT X:X=ABS(X):? 
8981 IF X/T>SH THEN ? "CAPTAIN, ";INT(SH*T);" UNITS ARE AVAILABLE":GOTO 8980
8990 ENG=ENG+X:SH=SH-X*I/T:IF SH<O THEN SH=O
8991 ? "ENERGY=";INT(ENG);" UNITS - SHIELDS @ ";SH;"%":GOSUB 1910:RETURN 
9000 RETURN 
9010 F=INT((D+7)/8):E=D-((F-I)*8):RETURN 
9020 IF TOR<>O THEN ? " RELOADING..":RETURN 
9021 IF TOR=O THEN ? " ARSENAL EMPTY..":RETURN 
10000 ? "↰"
10010 ? "LEGAL COMMANDS ARE:":? 
10020 ? "WARP","PHOTON","SHIELDS"
10030 ? "MOVE","PHASERS","HELP"
10040 ? "SRS","LRS","STATUS"
10050 ? "DAMAGE","DOCK","ABANDON SHIP"
10060 ? "DESTRUCT","COMPUTER","CHART"
10070 ? "REST","IMPULSE","DIVERT"
10100 ? :? :RETURN 
10400 ? "↰":DIM C$(3),PASS$(15)
10405 ? :? "SHORT, MEDIUM, OR LONG GAME ";:INPUT C$
10410 IF C$="SHO" THEN A=9:GOTO 10440
10420 IF C$="MED" THEN A=8:GOTO 10440
10430 IF C$="LON" THEN A=7:GOTO 10440
10435 GOTO 10405
10440 ? :? "NOVICE, GOOD, OR EXPERT ";:INPUT C$
10441 IF C$="NOV" THEN P=I/T:GOTO 10450
10442 IF C$="GOO" THEN P=C2/T:GOTO 10450
10443 IF C$="EXP" THEN P=0.3:GOTO 10450
10444 GOTO 10440
10450 ? :? "ENTER A SECRET PASSWORD":? :INPUT PASS$
10500 ? "↰":? "INITIALIZING.."
10520 DIM DAM(T+I,C2),SH$(4),CO$(6),QI$(64),V$(16),DI$(I),I$(I),EP(T-I)
10522 QI$(I)=" ":QI$(64)=" ":QI$(C2)=QI$(I)
10550 DIM SEC(T,T),ST(64),CM(64),KL(64),BA(64),PTS(6),POW(9),N$(T+I)
10555 FOR X=O TO 6:PTS(X)=O:NEXT X
10601 FOR X=I TO 11:DAM(X,I)=O:DAM(X,C2)=O:NEXT X
10620 FOR X=I TO 64:ST(X)=INT(RND(O)*T):NEXT X
10640 FOR X=I TO 64
10645 IF INT(RND(O)*T)<A THEN KL(X)=O:GOTO 10660
10650 KL(X)=INT(RND(O)*8)
10660 NEXT X
10661 FOR X=I TO 64:BA(X)=O:NEXT X
10665 B=RND(O)
10666 IF B>0.67 THEN Y=4:GOTO 10669
10667 IF B>0.33 THEN Y=3:GOTO 10669
10668 Y=C2
10669 ? "↰":? :? "** THE FEDERATION HAS ";Y;" STARBASES"
10670 FOR X=I TO Y
10671 B=INT(RND(O)*L)+I
10672 IF B>64 THEN 10671
10673 IF BA(B)=I THEN 10671
10674 BA(B)=I:NEXT X
10680 FOR X=I TO 64:CM(X)=O:NEXT X
10681 B=RND(O)
10682 IF B<I THEN Y=7
10683 IF B<0.95 THEN Y=6
10684 IF B<0.65 THEN Y=5
10685 IF B<0.44 THEN Y=4
10689 FOR X=I TO Y
10690 B=INT(RND(O)*L)+I
10691 IF B>64 THEN 10690
10692 IF CM(B)=I THEN 10690
10693 CM(B)=I:NEXT X
10699 ENG=10000:TOR=15:WAR=5:SH$="DOWN":N$="ENTERPRISE":S=69:LS=2.5
10700 GOSUB 8300
10705 FOR X=I TO 64:KLG=KLG+KL(X)+CM(X):NEXT X:SK=KLG
10710 SH=L:STDT=2000+INT(RND(O)*L)/T:BT=STDT
10720 TIME=KLG*0.5+14-T*P
10725 ? :? "** YOU HAVE ";TIME;" STAR DAYS TO FIND":? "** AND ELIMINATE ";KLG;" KLINGON VESSELS"
10726 ? :? "DO YOU ACCEPT";:INPUT C$
10727 IF C$<>"YES" THEN RUN 
10800 GOSUB 3000
10850 FOR X=I TO 64
10851 IF BA(X)=I AND KL(X)+CM(X)>O THEN V=X:POP :RETURN 
10852 NEXT X
10900 RETURN 
11000 STDT=STDT+A:TIME=TIME-A:IF TIME<O THEN GOTO 20070
11010 IF V<>O AND U=I THEN TD=TD-A:IF TD<O THEN GOSUB 11100
11015 IF CM(V)+KL(V)=O THEN V=O
11020 RETURN 
11100 D=V:GOSUB 9010:BA(V)=O:V=O
11102 U=O:GOSUB 10850
11105 IF DAM(8,I)=O THEN GOSUB 2300:? "THE STARBASE IN QUADRANT ";E;",";F;" HAS BEEN":? "DESTROYED.."
11106 RETURN 
20000 REM 
20001 ? "↰":? "THE ";N$;" HAS BEEN DESTROYED":? "IN THE GALATIC BARRIER":? :GOTO 21000
20050 ? "↰":? "THE ";N$;"'S ENERGY RESOURCES":? "HAVE BEEN DEPLETED.  YOU ARE NOW"
20051 ? "DRIFTING AIMLESSLY IN SPACE."
20052 ? :? "THE FEDERATION HAS LOST THE WAR WITH":? "THE KLINGON EMPIRE.":GOTO 21000
20070 ? "↰":? "THE ";N$;" HAS RUN OUT OF TIME.":GOTO 20052
20080 GOSUB 2390:B=653:GOSUB 2375:? "↰":? "THE ";N$;" HAS BEEN DESTROYED":? "IN BATTLE WITH THE KLINGON";
20081 ? " EMPIRE.":PTS(4)=PTS(4)+I:GOTO 21000
20090 ? "↰":? "THE ";N$;" IS NOW AN EXPANDING":? "CLOUD OF ATOMIC PARTICLES IN SPACE.":GOTO 20052
20200 ? "↰":? "THE FEDERATION HAS SMASHED THE":? "KLINGON INVASION..CONGRADULATIONS":PTS(O)=400
21000 SETCOLOR 4,5,5:? :? "        *** YOUR SCORE ***":? 
21004 X=PTS(5)*T:Y=X
21005 ? " KLINGONS",PTS(5),X
21009 X=PTS(C2)*50:Y=Y+X
21010 ? " COMMANDERS",PTS(C2),X
21014 X=PTS(I)*-5:Y=Y+X
21015 ? " STARS DESTROYED",PTS(I),X
21019 X=PTS(6)*-I:Y=Y+X
21020 ? " CASUALITIES",PTS(6),X
21024 X=PTS(3)*-L:Y=Y+X
21025 ? " CALLS FOR HELP",PTS(3),X
21034 X=PTS(4)*-200:Y=Y+X
21035 ? " SHIPS LOST",PTS(4),X
21040 IF PTS(O)=400 THEN ? " BONUS FOR WIN",,PTS(O):Y=Y+PTS(O)
21050 IF PTS(5)>O AND STDT-BT>3 THEN X=INT(((PTS(C2)+PTS(5))/(STDT-BT+I))*200):Y=Y+X:? " COMBAT EFFICIENCY",,X
21080 ? :? " TOTAL SCORE",,Y
21091 IF Y>500 THEN V$="COMMODORE"
21092 IF Y>750 THEN V$="REAR ADMIRAL"
21093 IF Y>L*T THEN V$="VICE ADMIRAL"
21094 IF Y>1500 THEN V$="ADMIRAL"
21095 IF PTS(O)=400 AND Y>500 THEN ? :? "PROMOTION TO ";V$;" RECOMMENDED":? "BY STARFLEET.";
21097 IF DI$="M" AND PTS(O)=400 THEN ? PASS$
21098 ? " "
21100 ? :? "PLAY AGAIN ";:INPUT C$
21120 IF C$="YES" THEN RUN 
21130 IF C$="NO" THEN GRAPHICS (0):END 
21140 GOTO 21100