0 GOSUB 32757
5 GOSUB 20000:REM CHARACTER SET
10 CLR :DIM EN$(10),LIB$(10),GAME$(1),DEST1$(30),DEST2$(30),OBJ$(30),DEST$(30),FEAT$(30),DEADSB(9,9)
12 GOSUB 19000:FOR X=0 TO 3:SOUND X,0,0,0:NEXT X:SP=0:LIB$=""
15 EN$="NONE":PASS=0:SD=2432.1:A=3:DEST$="     ":DEADLINE=2500:NXMS=2432.6
20 P1=355:P2=367:P3=400:C1=P1:C2=P2:C3=P3:DEST$="STARBASE 1"
50 POKE 752,1:SETCOLOR 2,0,0:POKE 82,0:TRAP 50
55 ? "↰";:FOR X=0 TO 23:? "                    ▌":NEXT X:POSITION 0,11
58 IF DEST$(1,2)="SB" THEN DEST$(10,10)=DEST$(3,3):DEST$(1,9)="STARBASE "
60 FOR X=1 TO 20:? "▂";:NEXT X
70 POSITION 21,2:? "SPEED:";:IF SP<1 THEN ? "SL ";SP:GOTO 75
71 ? "wF ";SP
75 POSITION 21,4:? "STARDATE:";SD
77 POSITION 21,17:IF LIB=0 THEN ? "LIBRARY COMPUTER"
78 POSITION 21,21:? "COMMAND REPORT"
79 POSITION 21,7:? "DEST:  ";C1;",";C2;",";C3;:POSITION 28,6:? DEST$;
90 POSITION 21,11:? "DEFLECTORS:DOWN":IF DEF=1 THEN POSITION 21,11:? "DEFLECTORS: UP ":SETCOLOR 2,0,2
92 IF SHI>0 THEN POSITION 21,11:? "D";
95 IF SCAN=0 THEN POSITION 21,0:? "*"
100 IF PHAS=0 THEN POSITION 21,12:? "PHASERS"
105 IF PHOT=0 THEN POSITION 21,13:? "PHOTON TORPS: ";TORP
106 POSITION 21,15:? "ENERGY:";INT(ENERGY)
115 POSITION 21,10:? "ALERT STATUS:"
120 POSITION 21,8:? "POS:"
130 ENERGY=ENERGY-2
140 IF MISSION=1 AND REC=0 THEN POSITION 21,21:? "COMMUNICATIONS"
150 IF SCAN=0 THEN FOR PASS=1 TO 35:X=INT(18*RND(0)):Y=INT(8*RND(0)):POSITION X,Y:? " a ";:NEXT PASS
1000 REM MAIN BODY OF GAME
1010 IF SCAN=0 THEN SOUND 1,20,10,6
1020 IF SENSE=0 THEN SOUND 1,0,0,0:SOUND 2,0,0,0
1030 IF SP=0 THEN X1=0:X2=0:X3=0
1040 SD=SD+0.1:POSITION 30,4:? SD;"  "
1045 P1=P1+X1:P2=P2+X2:P3=P3+X3:IF SCAN<>0 THEN 1060
1050 POSITION 28,8:? "           ":POSITION 28,8:? INT(P1);",";INT(P2);",";INT(P3)
1060 IF SCAN=0 THEN POSITION 21,0:? "*";
1070 KEY=PEEK(764):SOUND 1,0,0,0:SOUND 2,0,0,0:IF KEY=255 THEN 1150
1071 POKE 764,255
1072 IF KEY<>28 THEN 1080
1073 POSITION 32,0:? "PAUSED";
1074 POKE 764,255
1075 KEY=PEEK(764):IF KEY=255 THEN 1075
1076 POSITION 32,0:? "      ";
1080 IF KEY=0 AND LIB=0 THEN 8000
1090 IF KEY=7 AND SCAN=0 THEN 12200
1100 IF KEY=10 AND PHAS=0 THEN 9000
1110 IF KEY=45 AND PHOT=0 THEN 6000
1120 IF KEY=58 AND SHI=0 THEN 5000
1130 IF KEY=62 THEN 11000
1135 IF KEY=18 AND MISSION=1 AND REC=0 THEN 14000
1140 IF KEY=40 THEN GOSUB 3000
1141 IF KEY=43 THEN GOSUB 3000
1142 IF KEY=61 THEN GOSUB 3000
1144 IF KEY=18 THEN 25000
1150 IF SCAN=0 THEN SOUND 1,20,10,5
1160 POSITION 0,13:? "                    "
1170 FOR P=1 TO 9:? "                    "
1180 NEXT P
1190 IF EN$="KLINGON" AND KPW<10 THEN EN$="NONE":LIB$="":KLING=0:IF SCAN=0 THEN POSITION 1,19:? "KLINGON HAS FLED";
1195 GOSUB 10800:GOSUB 17000:GOSUB 13000:GOSUB 15000:GOSUB 7000
1200 IF SCAN=0 THEN POSITION 21,0:? "*";
1205 IF MISSION=1 AND REC=0 THEN POSITION 21,21:? "COMMUNICATIONS"
1210 IF SP=0 THEN SOUND 0,0,0,0:SOUND 3,0,0,0:X1=0:X2=0:X3=0:GOTO 1230
1215 IF A=1 THEN ENERGY=ENERGY-25
1220 SOUND 1,0,0,0:X1=0.5*(SP)^2+0.1:X2=0.5*SP^2+0.1:X3=0.5*SP^2+0.1
1230 IF P1>C1 THEN X1=-X1
1240 IF P2>C2 THEN X2=-X2
1250 IF P3>C3 THEN X3=-X3
1260 SOUND 1,0,0,0:IF ENERGY<5000 THEN POSITION 21,15:? "ENERGY";
1270 IF P1>899 AND P2>899 AND P3>899 AND WARN2=0 THEN GOSUB 16100
1280 IF P1>899 AND P2>899 AND P3>899 AND INT(5*RND(0))>2 THEN EN$="KLINGON":KPW=INT(7000*RND(0))*(DIF/25):KLING=1
1290 IF ENERGY<1000 THEN SETCOLOR 4,3,2
1295 IF SCAN<>0 THEN 1310
1300 IF SP>0.9 THEN FOR PASS=1 TO 35:X=INT(16*RND(0)):Y=INT(8*RND(0)):POSITION X,Y:? "  a  ";:NEXT PASS
1310 IF SP<1 THEN FOR PASS=1 TO 150:NEXT PASS
1320 IF KLING=1 AND SCAN=0 THEN POSITION EX,EY:? "lm":A=1
1325 IF SCAN<>0 THEN 1350
1330 IF (ABS(INT(C1-P1))<50 AND ABS(INT(C2-P2))<50 AND ABS(INT(C3-P3))<50) AND SLOW=0 AND SP>2 THEN SP=2:X=-99:SLOW=1
1340 IF X=-99 THEN POSITION 1,14:? "APPROACHING       ":? " ";DEST$;"     ";
1342 IF X=-99 THEN POSITION 1,16:? "SLOWING TO     ":? " WARP FACTOR 2 ":GOTO 11025
1350 IF ABS(INT(C1-P1))>29 OR ABS(INT(C2-P2))>29 OR ABS(INT(C3-P3))>29 THEN SENSE=0:GOTO 1490
1360 IF ABS(INT(C1-P1))<20 AND ABS(INT(C2-P2))<20 AND ABS(INT(C3-P3))<20 THEN 1385
1365 IF SCAN<>0 THEN 1380
1370 IF ABS(INT(C1-P1))<30 AND ABS(INT(C2-P2))<30 AND ABS(INT(C3-P3))<30 THEN POSITION 5,8:? "d":SENSE=1:GOTO 1460
1380 IF KLING=1 THEN EX=INT(6*RND(0)+4):EY=INT(6*RND(0)+1):IF SCAN=0 THEN POSITION EX,EY:? "lm";
1385 IF SCAN<>0 THEN 1460
1390 IF ABS(INT(C1-P1))<3 AND ABS(INT(C2-P2))<3 AND ABS(INT(C3-P3))<3 THEN 1420
1400 IF ABS(INT(C1-P1))<20 AND ABS(INT(C2-P2))<20 AND ABS(INT(C3-P3))<20 THEN POSITION 5,8:? "c";
1410 SENSE=1
1420 IF ABS(INT(C1-P1))<3 AND ABS(INT(C2-P2))<3 AND ABS(INT(C3-P3))<3 AND IMP=0 THEN O=1
1430 IF O=1 THEN POSITION 5,10:? "efghi↑←←←←kj";:POSITION 5,8:? "  ";:SENSE=1:SP=1:POSITION 5,8:? "  ";
1450 IF C1=INT(P1) AND C2=INT(P2) AND C3=INT(P3) AND IMP=0 THEN POSITION 0,12:? "ORBIT";:SENSE=1:O=1
1460 IF C1<>INT(P1) OR C2<>INT(P2) OR C3<>INT(P3) THEN O=0
1470 IF O=1 AND DEST$="STARFLEET" THEN 18000
1475 IF O=1 THEN SP=0:POSITION 27,2:? "--      ";:IF DEST$(1,4)="STAR" THEN PASS=VAL(DEST$(10,10)):GOTO 1485
1480 PASS=0
1485 IF O=1 AND DEST$(1,4)="STAR" AND DEADSB(PASS,PASS)=0 THEN GOSUB 19030:POSITION 35,13:? TORP;
1490 POSITION 0,13:? "                    "
1500 FOR P=1 TO 9:? "                    ":NEXT P
1510 GOSUB 12000:GOSUB 3020
1530 IF INT(P2)=C2 THEN X2=0
1540 IF INT(P3)=C3 THEN X3=0
1550 IF INT(P1)=C1 THEN X1=0
1560 POSITION EX,EY:? "  ";
1570 IF KLING=1 THEN POSITION EX,EY:? "  ";:EX=INT(6*RND(0)+4):EY=INT(6*RND(0)+1):IF SCAN=0 THEN POSITION EX,EY:? "lm";
1580 IF P1>850 AND P2>850 AND P3>850 AND WARN=0 THEN 16000
1590 IF P1<851 AND P2<851 AND P3<851 THEN WARN=0
1600 IF P1<900 AND P2<900 AND P3<900 THEN WARN2=0
1610 IF P1>980 THEN P1=P1-20
1615 IF P1<0 THEN P1=ABS(P1)
1620 IF P2>980 THEN P2=P2-20
1625 IF P2<0 THEN P2=ABS(P2)
1630 IF P3>980 THEN P3=P3-20
1635 IF P3<0 THEN P3=ABS(P3)
1640 IF SP>6 THEN ENERGY=ENERGY-250
1650 ENERGY=ENERGY-(1*(1+SP)):IF DEF=1 THEN ENERGY=ENERGY-50
1660 IF ENERGY<1 THEN 18000
1670 POSITION 21,15:? "ENERGY:     ←←←←←";INT(ENERGY)
1680 GOTO 1000
3000 REM ALERT STATUS
3005 IF KEY=40 THEN A=1
3010 IF KEY=43 THEN A=2
3015 IF KEY=61 THEN A=3
3020 IF A=1 THEN POSITION 34,10:? "R Y G";:SETCOLOR 4,3,2
3025 IF A=2 THEN POSITION 34,10:? "R Y G";:SETCOLOR 4,1,6
3030 IF A=3 THEN POSITION 34,10:? "R Y G";:SETCOLOR 4,12,4
3040 POSITION 1,14:? "               ":? "                 ":? "               "
3055 IF (A=1 AND LIB$="1") OR EN$="NONE" THEN RETURN 
3060 IF SCAN<>0 THEN RETURN 
3900 FOR X=1 TO 3:FOR Y=40 TO 27 STEP -0.5:SOUND 1,1.4*Y,10,14:SOUND 2,215,10,10:NEXT Y:SOUND 1,0,0,0
3901 SETCOLOR 4,3,2
3902 POSITION 2,13:? "BATTLE STATIONS";
3905 FOR Y=1 TO 100:NEXT Y:NEXT X:SOUND 2,0,0,0:LIB$="1":POSITION 2,13:? "               ";
3910 POP :GOTO 12205
3999 RETURN 
5000 REM DEFLECTORS
5010 IF DEF=1 THEN DEF=0:SETCOLOR 2,0,0:GOTO 5015
5011 IF DEF=0 THEN DEF=1:SETCOLOR 2,0,2
5015 IF DEF=1 THEN POSITION 21,11:? "DEFLECTORS: UP ";:GOTO 1160
5016 IF DEF=0 THEN POSITION 21,11:? "DEFLECTORS:DOWN";:GOTO 1160
5999 GOTO 1160
6000 REM FOTONS
6002 IF PHOT>0 THEN 1160
6005 POSITION 2,13:? "PHOTON CONTROL"
6007 POSITION 2,15:? "1. STANDBY":? "  2. LOCK AND FIRE"
6010 GOSUB 26000:IF KEY<>2 THEN 1160
6011 IF EN$="NONE" AND SCAN=0 THEN 1160
6012 IF TORP<1 THEN POSITION 2,13:? "TUBES EMPTY   ":GOTO 1200
6015 IF KEY=2 THEN POSITION 2,15:? "FIRE HOW MANY":? "                  ";:GOSUB 26000
6020 RNDS=KEY
6022 IF RNDS>TORP THEN RNDS=TORP
6023 IF RNDS>5 THEN RNDS=5
6024 TORP=TORP-RNDS
6025 FOR X=1 TO RNDS
6030 FP=INT(6*RND(0)+4):FY=INT(6*RND(0)+1)
6035 IF SCAN=0 THEN POSITION FP,FY:? "●";:SOUND 1,255,6,8:FOR P=1 TO 55:NEXT P
6036 IF (INT((FP)=EX AND INT(FY)=EY)) OR (INT((FP)=EX+1 AND INT(FY)=EY)) THEN NM=1
6037 IF (INT(FP)=EX-1 AND INT(FY)=EY) OR (INT(FP)=EX+1 AND INT(FY)=EY+1) THEN NM=1
6040 IF (INT(FP)=EX AND INT(FY)=EY-1) OR (INT(FP)=EX+1 AND INT(FY)=EY-1) THEN NM=1
6041 IF (INT(FP)=EX AND INT(FY)=EY+1) OR (INT(FP)=EX+2 AND INT(FY)=EY) THEN NM=1
6042 IF (INT(FP)=EX-1 AND INT(FY)=EY-1) OR (INT(FP)=EX+2 AND INT(FY)=EY-1) THEN NM=1
6043 IF (INT(FP)=EX-1 AND INT(FY)=EY+1) OR (INT(FP)=EX+2 AND INT(FY)=EY+1) THEN NM=1
6137 POSITION FP,FY:? " ";
6138 SOUND 1,0,0,0
6139 IF NM=1 THEN POSITION 1,13:? " KLINGON DAMAGED";:NM=0:KPW=KPW-(ENERGY/20):IF KPW<50 THEN EN$="NONE"
6140 IF EN$="NONE" THEN POSITION 1,13:? " KLINGON DESTROYED":PASS=0:LIB$="":KLING=0
6141 IF SCAN<>0 THEN POSITION 1,13:? "                  "
6145 ENERGY=ENERGY-45
6150 NEXT X:POSITION 35,13:? TORP;" ";
6155 POSITION EX,EY:? "  ";
6160 FOR X=1 TO 100:NEXT X
6999 GOTO 1160
7000 REM  DESTROY A STARBASE! 
7005 IF INT(150*RND(0))<>7 THEN RETURN 
7010 X=INT(8*RND(0))+1
7012 IF DEADSB(X,X)=1 THEN RETURN 
7015 POSITION 1,16:? "STARBASE ";X:? " HAS BEEN":? " DESTROYED..."
7020 DEADSB(X,X)=1
7025 SOUND 1,55,10,8
7030 FOR PASS=1 TO 150:NEXT PASS:RETURN 
8000 REM LIBRARY COMPUTER
8001 TRAP 8022:IF LIB>0 THEN TRAP 40000:GOTO 50
8002 POKE 82,2:RESTORE :FEAT$="":? "↰":SETCOLOR 2,0,0:POSITION 11,0:? "LIBRARY COMPUTER"
8006 ? :? "NOTE: STARBASE 1 = SB1":? 
8007 ? "ENTERING 'ALL' WILL GIVE LIST         OF VALID NAMES.":? 
8009 ? "IF YOU WISH TO RETIRE, SET COURSE FOR 'STARFLEET'"
8010 ? "ENTER OBJECT NAME";:POKE 764,255:FOR X=1 TO 750:IF PEEK(764)=255 THEN NEXT X:GOTO 50
8011 INPUT FEAT$
8012 IF FEAT$="" THEN POKE 82,0:GOTO 50
8013 IF FEAT$="ALL" THEN FOR X=1 TO 27:READ FEAT$,Q,Q,Q:? FEAT$:GOTO 8025
8014 IF FEAT$<>"" THEN DEST$=FEAT$
8015 READ FEAT$,C1,C2,C3:IF FEAT$=DEST$ THEN POKE 82,0:SLOW=0:O=0:GOTO 50
8020 GOTO 8015
8022 IF DEST$<>"ALL" THEN ? :? :? :? "NOT FOUND...TRY AGAIN":TRAP 8022:FOR X=1 TO 200:NEXT X:GOTO 8000
8025 IF X=12 THEN POKE 82,17:POSITION 17,10
8026 IF X=24 THEN POKE 82,30:POSITION 30,10
8027 NEXT X:POKE 82,2:? :RESTORE 8030:POSITION 2,23:FEAT$="":GOTO 8010
8030 DATA ARGELIUS,780,952,648,OMEGA IV,548,970,356,TALOS IV,444,968,252,GIDEON,444,968,252,POLLUX IV,680,244,112
8035 DATA EARTH,276,200,12,KLINGON,956,952,964,ORGANIA,948,860,904,ORION,237,707,545
8040 DATA CETI ALPHA,224,36,292,REGULUS,84,44,204,VEGA IX,180,180,180,ELAS,484,616,700,TROYUS,485,615,698
8045 DATA EMINIAR VII,596,72,460,VINDIKAR,152,84,100,SCALOS,396,212,84,CHERON,744,160,144,RIGEL VII,280,124,32
8050 DATA DENEVA,44,804,640,TRIACUS,300,108,80,TANTALUS,612,432,688,GOTHOS,676,92,276,VULCAN,268,164,24
8055 DATA ZEON,254,119,844,EKOS,260,121,850,CAPELLA,766,243,14
8060 DATA SB1,54,67,100,SB2,212,198,187,SB3,355,367,400,SB4,534,601,499,SB5,722,756,801
8065 DATA SB6,855,866,888,SB7,650,300,110,SB8,108,296,626,SB9,325,111,700,SB10,366,709,126,STARFLEET,50,50,50
9000 REM PHASERS
9002 IF PHAS>0 THEN 1160
9005 POSITION 1,13:? "PHASER CONTROLS"
9010 ? :? " 1. STANDBY       ":? " 2. LOCK AND FIRE"
9015 GOSUB 26000
9020 IF KEY=2 THEN 9025
9021 GOTO 1160
9025 IF EN$="KLINGON" THEN 9040
9026 IF SCAN<>0 THEN 9040
9030 ? :? " THERE IS NOTHING":? " TO SHOOT AT!":FOR P=1 TO 175:NEXT P:GOTO 1160
9040 POSITION 1,15:? "FIRING.....":POSITION 1,16:? "                ":IF SCAN<>0 THEN POSITION 10,15:? "BLIND"
9050 FOR X=15 TO 0 STEP -0.5:FOR Y=2 TO 0 STEP -1:SOUND 1,10-Y,10,X:NEXT Y:NEXT X
9052 IF SCAN<>0 AND INT(5*RND(0))<4 THEN GOTO 9100
9055 IF INT(20*RND(0))<18 THEN X=-1
9060 IF X=-1 THEN FOR Y=12 TO 0 STEP -1:SOUND 1,200,2,Y:SOUND 2,250,2,Y:NEXT Y
9062 IF SCAN<>0 THEN 9100
9065 IF X=-1 THEN POSITION 7,12:? "A HIT";:GOTO 9100
9070 POSITION 8,12:? "MISS":FOR Y=1 TO 150:NEXT Y:POSITION 7,12:? "      ";:GOTO 1160
9100 IF X=-1 THEN KPW=KPW-(ENERGY/30):IF KPW<50 THEN POSITION 0,12:? " KLINGON DESTROYED":EN$="NONE":PASS=0:LIB$=""
9101 IF SCAN<>0 THEN POSITION 0,12:? "                  "
9105 FOR X=1 TO 150:NEXT X:POSITION 7,12:? "       ";
9110 IF EN$="NONE" THEN POSITION 1,12:? "                  ";:POSITION EX,EY:? "  ";:KLING=0
9900 ENERGY=ENERGY-50
9999 GOTO 1160
10000 REM  DAMAGE CONTROL 
10010 IF DEF=0 THEN IF INT(20*RND(0))>1 THEN 10050
10040 IF INT(10*RND(0))*(DIF/25)>2*(DIF/25)+(DIF/25) THEN RETURN 
10050 Y=INT(7*RND(0))+1:ON Y GOTO 10100,10200,10300,10400,10500,10600,10700
10090 RETURN 
10100 REM SCANNERS
10105 IF SCAN<>0 THEN 10040
10110 SCAN=INT(DIF*RND(0))/10+SD+0.2
10115 POSITION 1,14:? "SCANNERS   ":? " DAMAGED   ":FOR PASS=0 TO 10:POSITION 0,PASS:? "                    ";:NEXT PASS
10117 POSITION 21,0:? "                 "
10120 FOR PASS=1 TO 150:NEXT PASS:RETURN 
10200 REM WARP DRIVE
10205 IF WARP<>0 THEN 10040
10210 WARP=INT(DIF*RND(0))/10+SD+0.2
10215 POSITION 1,14:? "WARP DRIVE     ":? " DAMAGED     ":IF SP>0.9 THEN SP=0:POSITION 27,2:? "--  ";
10220 FOR PASS=1 TO 150:NEXT PASS:RETURN 
10300 REM IMPULSE ENGINES
10305 IF IMP<>0 THEN 10040
10310 IMP=INT(DIF*RND(0))/10+SD+0.2
10315 POSITION 1,14:? "IMPULSE ENGINES    ":? " DAMAGED     ":IF SP<1 THEN SP=0:POSITION 27,2:? "--     ";
10320 FOR PASS=1 TO 150:NEXT PASS:RETURN 
10400 REM DEFLECTORS
10405 IF SHI<>0 THEN 10040
10410 SHI=INT(DIF*RND(0))/10+SD+0.2
10415 POSITION 1,14:? "SHIELDS      ":? " DAMAGED    ":DEF=0:POSITION 21,11:? "DEFLECTORS:DOWN":SETCOLOR 2,0,0
10420 FOR PASS=1 TO 150:NEXT PASS:RETURN 
10500 REM PHASERS
10505 IF PHAS<>0 THEN 10040
10510 PHAS=INT(DIF*RND(0))/10+SD+0.2
10515 POSITION 1,14:? "PHASERS     ":? " DAMAGED     "
10517 POSITION 21,12:? "         "
10520 FOR PASS=1 TO 150:NEXT PASS:RETURN 
10600 REM PHOTONS
10605 IF PHOT<>0 THEN 10040
10610 PHOT=INT(DIF*RND(0))/10+SD+0.2
10615 POSITION 1,14:? "PHOTONS     ":? " DAMAGED     "
10617 POSITION 21,13:? "                "
10620 FOR PASS=1 TO 150:NEXT PASS:RETURN 
10700 REM COMPUTER
10705 IF LIB<>0 THEN 10040
10710 LIB=INT(DIF*RND(0))/10+SD+0.2
10715 POSITION 1,14:? "COMPUTER     ":? " DAMAGED     "
10717 POSITION 21,17:? "                "
10720 FOR PASS=1 TO 150:NEXT PASS:RETURN 
10800 REM IS IT FIXED?
10810 IF SCAN<>0 THEN IF SCAN<=SD THEN SCAN=0:POSITION 1,14:? "SCANNERS":? " REPAIRED":POP :GOTO 150
10820 IF WARP<>0 THEN IF WARP<=SD THEN WARP=0:POSITION 1,14:? "WARP DRIVE":? " REPAIRED":RETURN 
10830 IF IMP<>0 THEN IF IMP<=SD THEN IMP=0:POSITION 1,14:? "IMPULSE ENGINES":? " REPAIRED":RETURN 
10840 IF SHI<>0 THEN IF SHI<=SD THEN SHI=0:POSITION 1,14:? "DEFLECTORS":? " REPAIRED":POSITION 21,11:? "D";:RETURN 
10850 IF PHAS<>0 THEN IF PHAS<=SD THEN PHAS=0:POSITION 1,14:? "PHASERS":? " REPAIRED":POSITION 21,12:? "PHASERS";:RETURN 
10860 IF PHOT<>0 THEN IF PHOT<=SD THEN POSITION 1,14:? "PHOTONS":? " REPAIRED":POSITION 21,13:? "PHOTON TORPS: ";TORP
10865 IF PHOT<>0 THEN IF PHOT<=SD THEN PHOT=0
10870 IF LIB<>0 THEN IF LIB<=SD THEN LIB=0:POSITION 1,14:? "COMPUTER":? " REPAIRED":POSITION 21,17:? "LIBRARY COMPUTER"
10999 RETURN 
11000 POSITION 1,15:REM SPEED
11001 IF C1=0 AND C2=0 AND C3=0 THEN ? " WE HAVE NO":? "  WHERE TO GO!":FOR X=1 TO 150:NEXT X:GOTO 1160
11002 TRAP 11022
11010 POSITION 2,14:? "1. WARP DRIVE     ":? "  2. IMPULSE    "
11015 GOSUB 26000:IF KEY=2 THEN 11050
11017 IF WARP>0 THEN 1160
11020 POSITION 2,18:? "WARP FACTOR ? ":GOSUB 26000:IF KEY=255 THEN GOTO 1160
11022 IF KEY>8 THEN ? "THAT'S IMPOSSIBLE!":FOR P=1 TO 150:NEXT P:TRAP 50:GOTO 1160
11023 SP=KEY
11024 IF SP<1 THEN POSITION 27,2:? "--   ":SOUND 0,0,0,0:SOUND 3,0,0,0:GOTO 1200
11025 POSITION 27,2:? "wF ";SP;"   "
11026 IF SP>6 THEN KPW=0
11027 SOUND 0,200/SP,8,2:SOUND 3,95,6,2
11030 GOTO 1200
11050 IF IMP>0 THEN 1160
11100 POSITION 2,14:? "IMPULSE ENGINES ":? "             "
11105 ? " 1. 1/4 LIGHT SPEED":? " 2. 1/2 LIGHT SPEED":? " 3. 3/4 LIGHT SPEED":? " 4. STOP    ";
11106 GOSUB 26000:IF KEY=255 THEN 1160
11107 IF KEY<4 AND KEY>0 THEN SOUND 3,95,6,2
11110 ON KEY GOTO 11120,11130,11140,11150
11115 GOTO 1160
11120 POSITION 27,2:? "SL 1/4"
11121 SP=0.25:SOUND 0,250,8,2:SOUND 3,95,6,2
11125 GOTO 1160
11130 POSITION 27,2:? "SL 1/2"
11131 SP=0.5:SOUND 0,250,8,2:SOUND 3,95,6,2
11135 GOTO 1160
11140 POSITION 27,2:? "SL 3/4"
11141 SP=0.75:SOUND 0,250,8,2:SOUND 3,95,6,2
11145 GOTO 1160
11150 POSITION 27,2:? "--      ":SP=0
11151 SP=0
11999 GOTO 1160
12000 REM SCANNERS
12001 IF SCAN>0 THEN RETURN 
12002 IF KLING=1 THEN 12035
12005 IF SENSE<1 THEN POSITION 23,0:? "        "
12010 IF SENSE=1 THEN POSITION 23,0:? "PLANET ";
12015 IF SD<2433.5 THEN 12035
12020 IF (INT(55*RND(0))*(DIF/25)>(DIF*2)+2 AND EN$="NONE" AND SP<7) THEN EN$="KLINGON":KLING=1
12021 IF KLING=1 THEN KPW=INT(5000*RND(0))*(DIF/25)
12032 IF PASS=0 AND EN$="KLINGON" THEN A=1:PASS=1
12035 IF KLING=1 THEN POSITION 23,0:? "KLINGON";
12040 IF INT(250*RND(0))>235 THEN SETCOLOR 2,0,2:POSITION 2,15:? "ASTEROID";:POSITION 2,16:? "DEFLECTED":GOTO 12050
12045 RETURN 
12050 POSITION 23,0:? "ASTEROID"
12051 FOR X=1 TO 30:NEXT X:POSITION 23,0:? "        ":IF DEF=0 THEN SETCOLOR 2,0,0
12105 RETURN 
12200 PASS=0
12205 IF KLING=1 THEN POSITION 1,16:? "KLINGON WARSHIP":? " WITH ";ABS(INT(KPW)*5);" UNITS":? " OF ENERGY"
12206 IF DEST$="STARFLEET" THEN 12210
12207 IF SENSE=1 AND DEST$(1,4)="STAR" THEN PASS=VAL(DEST$(10,10)):IF DEADSB(PASS,PASS)=1 THEN 12910
12210 IF SENSE=1 AND DEST$(1,4)="STAR" THEN POSITION 1,13:? DEST$:GOTO 12900
12215 IF SENSE=1 THEN POSITION 1,13:? "THE PLANET":? " ";DEST$
12900 IF SENSE=0 AND KLING=0 THEN POSITION 1,13:? "SCANNERS ARE BLANK";
12905 GOTO 1200
12910 IF SENSE=1 THEN POSITION 1,13:? "REMAINS OF":? " ";DEST$
12915 GOTO 1200
13000 REM  MISSION 
13010 IF MISSION=1 THEN RETURN 
13020 IF INT(5*RND(0))<4 THEN RETURN 
13023 IF NXMS>SD THEN RETURN 
13025 DEADLINE=SD+INT((200*RND(0))+30)/10:DEADLINE=DEADLINE+1
13030 RESTORE 8030:X=INT(26*RND(0))+1:FOR Y=1 TO X:READ DEST1$,PASS,PASS,PASS:NEXT Y
13040 RESTORE 8030:X=INT(26*RND(0))+1:FOR Y=1 TO X:READ DEST2$,PASS,PASS,PASS:NEXT Y
13045 IF DEST1$=DEST2$ THEN 13030
13046 IF DEST1$="KLINGON" OR DEST2$="KLINGON" THEN 13030
13050 RESTORE 15900:X=INT(7*RND(0))+1:FOR Y=0 TO X:READ OBJ$:NEXT Y
13060 MISSION=1:REC=0:RETURN 
14000 REM  RECEIVE MISSION 
14010 POKE 764,255
14020 POKE 82,2:? "↰":? "MESSAGE FROM STARFLEET COMMAND.":? 
14030 ? "STARDATE: ";SD:? 
14040 ? "PROCEED TO ";DEST1$;" AND"
14050 ? "PICK UP ";:IF OBJ$(1,3)="THE" THEN ? "A SHIPMENT OF";OBJ$(4,LEN(OBJ$));"."
14055 IF OBJ$(1,3)="THE" THEN 14060
14056 ? OBJ$;"."
14060 ? "YOU ARE THEN TO PROCEED"
14070 ? "TO ";DEST2$;" AND DELIVER"
14080 ? OBJ$;" UPON ARRIVAL."
14100 ? :? "YOU HAVE UNTIL ";DEADLINE
14110 ? :? "STARFLEET OUT....":? 
14120 ? :? "HIT ANY KEY";:POKE 764,255:FOR X=1 TO 700:IF PEEK(764)=255 THEN NEXT X:REC=1:GOTO 50
14125 REC=1:IF PEEK(764)=0 THEN 8000
14130 GOTO 50
15000 REM CHECK MISSION STATUS 
15010 IF MISSION=0 THEN RETURN 
15015 IF SD>DEADLINE THEN GOTO 15400
15020 IF O=0 THEN RETURN 
15030 IF DEST$=DEST1$ THEN DEST1$="YES":GOTO 15300
15040 IF DEST$=DEST2$ AND DEST1$="YES" THEN MISSION=0:REC=0:GOTO 15200
15050 IF DEST$=DEST2$ AND REC=1 THEN POSITION 1,19:? DEST1$;" FIRST!"
15060 POP :GOTO 1200
15200 REM MISSION COMPLETE
15210 POSITION 1,19:? "MISSION COMPLETE":FOR PASS=1 TO 75:NEXT PASS:SCORE=SCORE+1:NXMS=SD+2
15220 POP :GOTO 1200
15300 POSITION 1,18:? OBJ$:POSITION 1,19:? "HAS BEEN":POSITION 1,20:? "BEAMED ABOARD."
15305 FOR PASS=1 TO 150:NEXT PASS
15310 RETURN 
15400 ? "↰":? :? :POKE 82,2
15405 SOUND 1,0,0,0:? "STARDATE ";SD:? 
15410 ? "YOU HAVE NEGLECTED TO COMPLETE        YOUR MISSION, CAPTAIN.  THERE"
15420 ? "WILL BE A FULL INVESTIGATION INTO     THIS SITUATION TO DETERMINE IF A"
15425 ? "COURT MARTIAL IS IN ORDER.":? :? "STARFLEET OUT."
15430 MISSION=0:REC=0:FOR PASS=1 TO 500:NEXT PASS:SCORE=SCORE-1:DEADLINE=2999:POP :POKE 82,0:GOTO 50
15900 DATA THE ZENITE,THE RYETALYN,AMBASSAADOR SAREK,COMMODORE STOCKER,DOHLMAN OF ELAS,THE RODINIUM
15905 DATA MEDUSAN AMBASSADOR,THE DILITHIUM
16000 REM ENTERING NUETRAL ZONE
16001 SOUND 1,55,10,8
16002 WARN=1
16003 IF SCAN<>0 THEN 1160
16005 POSITION 1,14:? "WARNING":? " WE ARE APPROACHING":? " THE KLINGON":? " NEUTRAL ZONE"
16006 FOR X=1 TO 250:NEXT X:SOUND 1,0,0,0
16099 GOTO 1160
16100 REM 
16101 SOUND 1,55,10,8
16102 WARN2=1
16103 IF SCAN<>0 THEN RETURN 
16105 POSITION 1,14:? "WARNING":? " WE HAVE ENTERED":? " THE KLINGON":? " NEUTRAL ZONE"
16106 ? " WE ARE IN":? " VIOLATION OF":? " TREATY";
16110 FOR X=1 TO 250:NEXT X:SOUND 1,0,0,0
16199 RETURN 
17000 REM HAVE WE BEEN HIT?
17005 IF EN$="NONE" THEN RETURN 
17010 X=INT(75*RND(0))
17015 IF WARN2=1 AND X>15 THEN 17040
17020 IF X>45 THEN 17040
17030 RETURN 
17040 FOR Y=14 TO 0 STEP -1
17045 POSITION 0,0:? "";
17050 SOUND 1,230,0,Y:SOUND 1,150,2,Y:POSITION 0,14:KPW=KPW-50
17060 FOR X=1 TO 5:NEXT X:POSITION 0,0:? "";:NEXT Y
17065 SOUND 1,0,0,0
17070 ENERGY=ENERGY-(KPW/2):IF DEF=0 THEN ENERGY=ENERGY-(KPW/2)
17080 IF WARN2=1 THEN ENERGY=ENERGY-(KPW/2)
17090 GOSUB 10000
17999 RETURN 
18000 REM END OF GAME
18001 FOR X=0 TO 3:SOUND X,0,0,0:NEXT X:POKE 764,255:SETCOLOR 4,12,4:SETCOLOR 2,0,0:POKE 752,0
18005 POKE 82,2:? "↰":? "ON STARDATE ";SD
18010 IF KLING=1 THEN 18100
18015 IF DEST$="STARFLEET" THEN 18200
18020 ? "THE ENTERPRISE RAN OUT OF ENERGY":? "WHILE IN ROUTE TO ";DEST$
18099 GOTO 18190
18100 ? "THE ENTERPRISE WAS DESTOYED":? "BY THE KLINGON EMPIRE..."
18190 ? "ALL HANDS WERE LOST..."
18195 GOTO 18995
18200 ? "THE ENTERPRISE RETURNED TO SPACE      DOCK. CAPTAIN KIRK WILL NOW RETIRE."
18205 ? "THE CREW WILL BE REASSIGNED AND THE   ENTERPRISE WILL BE REFITTED FOR"
18210 ? "ANOTHER MISSION."
18995 ? :? "RATING = ";SCORE
18998 ? :? "PLAY AGAIN Y/N";:INPUT DEST$:IF DEST$(1,1)="N" THEN END 
18999 FOR X=1 TO 9:DEADSB(X,X)=0:NEXT X:GOTO 10
19000 REM SET UP
19005 ? "↰":POKE 82,2:POKE 764,255
19010 ? :? "DO YOU WANT AN EASY, STANDARD, OR     DIFFICULT GAME.";
19020 CLOSE #1:OPEN #1,4,0,"K:":GET #1,X:GAME$=CHR$(X)
19030 IF GAME$="E" THEN ENERGY=75000:TORP=40:DIF=25:RETURN 
19040 IF GAME$="S" THEN ENERGY=60000:TORP=35:DIF=50:RETURN 
19050 IF GAME$="D" THEN ENERGY=45000:TORP=10:DIF=100:RETURN 
19060 GOTO 19020
20000 RESTORE 20056:P=57344
20005 X=PEEK(106)-5
20010 C3=(X+1)*256
20015 POKE 106,X:GOSUB 21000:C1=1036
20020 FOR X=0 TO 1023
20021 POSITION 18,13:? C1;"  "
20025 POKE C3+X,PEEK(P+X):C1=C1-1:NEXT X
20030 POKE 756,C3/256
20035 FOR Y=97 TO 109
20040 FOR X=C3+Y*8 TO C3+Y*8+7
20041 POSITION 18,13:? C1;"   "
20045 READ A
20050 POKE X,A:NEXT X
20055 C1=C1-1:NEXT Y
20062 DATA 0,0,0,16,0,0,0,0
20063 DATA 0,0,0,48,0,0,0,0
20064 DATA 0,126,255,255,255,255,126,0
20065 DATA 0,0,0,24,60,24,0,0
20066 DATA 0,1,7,15,31,63,127,255
20067 DATA 127,255,255,255,255,255,255,255
20068 DATA 255,255,255,255,255,255,255,255
20069 DATA 240,252,254,255,255,255,255,255
20070 DATA 0,0,0,128,192,224,240,248
20080 DATA 0,0,0,0,0,0,0,254
20081 DATA 0,0,0,0,0,0,0,31
20082 DATA 0,1,31,51,49,48,48,0
20083 DATA 0,128,248,204,140,12,12,0
20100 POSITION 10,14:? "PRESS START TO PLAY"
20105 IF PEEK(53279)<>6 THEN 20065
20135 RETURN 
21000 REM 
21505 GRAPHICS 0
21510 SETCOLOR 2,0,0:POKE 752,1:SETCOLOR 1,0,15:SETCOLOR 0,6,8
21520 POSITION 14,4:? "STAR  TREK":POSITION 18,6:? "BY":POSITION 14,7:? "E.D. SPOON"
21530 POSITION 17,9:? "1984":POSITION 7,10:? "INITIALIZING, PLEASE WAIT":POSITION 13,8:? "(73117,3024)"
21540 POKE 559,34
21570 RETURN 
25000 POKE 82,2:? "↰":RESTORE 25900:POKE 764,255:SETCOLOR 2,0,0
25010 POSITION 2,0:? "SHIP'S SYSTEMS      EST. REPAIR DATE"
25020 POSITION 2,1:? "─────────────────┬──────────────────":FOR X=2 TO 9:POSITION 19,X:? "|":NEXT X
25030 POSITION 2,9:? "─────────────────┴─────────────────"
25040 POSITION 15,10:? "STARBASES":POSITION 2,22:? "MISSION ASSIGNED: ":POSITION 16,23:? "BY: ";
25050 POSITION 2,2:? "SCANNERS";:IF SCAN=0 THEN POSITION 17,2:? "OK";
25055 IF SCAN<>0 THEN POSITION 22,2:? SCAN
25060 POSITION 2,3:? "WARP DRIVE";:IF WARP=0 THEN POSITION 17,3:? "OK";
25065 IF WARP<>0 THEN POSITION 22,3:? WARP
25070 POSITION 2,4:? "IMPULSE ENG";:IF IMP=0 THEN POSITION 17,4:? "OK";
25075 IF IMP<>0 THEN POSITION 22,4:? IMP
25080 POSITION 2,5:? "DEFLECTORS";:IF SHI=0 THEN POSITION 17,5:? "OK";
25085 IF SHI<>0 THEN POSITION 22,5:? SHI
25090 POSITION 2,6:? "PHASERS";:IF PHAS=0 THEN POSITION 17,6:? "OK";
25095 IF PHAS<>0 THEN POSITION 22,6:? PHAS
25100 POSITION 2,7:? "PHOTONS";:IF PHOT=0 THEN POSITION 17,7:? "OK";
25105 IF PHOT<>0 THEN POSITION 22,7:? PHOT
25110 POSITION 2,8:? "COMPUTER";:IF LIB=0 THEN POSITION 17,8:? "OK";
25115 IF LIB<>0 THEN POSITION 22,8:? LIB
25120 FEAT$="STARBASE":FOR X=1 TO 9
25130 POSITION 2,X+10:FOR Y=1 TO 8:? FEAT$(Y,Y);:NEXT Y
25140 ? " ";X;"          ";:IF DEADSB(X,X)=0 THEN ? "OPERATIONAL";:NEXT X:GOTO 25160
25150 ? " DESTROYED ";:NEXT X
25160 IF MISSION=0 THEN POSITION 2,22:? "NEXT MISSION:";NXMS;:POSITION 16,23:? "   ";:GOTO 25997
25165 IF DEST1$="YES" THEN POSITION 19,22:GOTO 25175
25170 POSITION 19,22:FOR X=1 TO LEN(DEST1$):? DEST1$(X,X);:NEXT X:? "/";
25175 FOR X=1 TO LEN(DEST2$):? DEST2$(X,X);:NEXT X:POSITION 19,23:? DEADLINE;
25997 POKE 764,255:FOR X=1 TO 500:IF PEEK(764)=255 THEN NEXT X:GOTO 50
25998 IF PEEK(764)=0 THEN 8000
25999 GOTO 50
26000 POKE 764,255:FOR X=1 TO 250:IF PEEK(764)=255 THEN NEXT X:RETURN 
26001 KEY=PEEK(764):IF KEY=30 THEN KEY=2
26002 IF KEY=26 THEN KEY=3
26003 IF KEY=24 THEN KEY=4
26004 IF KEY=29 THEN KEY=5
26005 IF KEY=27 THEN KEY=6
26006 IF KEY=51 THEN KEY=7
26007 IF KEY=53 THEN KEY=8
26008 IF KEY=31 THEN KEY=1
26009 POKE 764,255:RETURN 
32757 GRAPHICS 1:SETCOLOR 2,0,0:POKE 752,1
32758 BEGIN=PEEK(560)+PEEK(561)*256+4
32759 POKE BEGIN+8,7:POKE BEGIN+20,2:POKE BEGIN+21,2
32760 ? #6;"  SPOON ENTERPRISES":? #6:? #6;"      PRESENTS"
32761 POSITION 1,7:? #6;"    star  trek ":? #6:? #6;"      the game  "
32762 POSITION 8,19:? #6;"1986  by Spoon Enterprises"
32763 ? #6;"           Press START to begin"
32764 FOR PAUSE=1 TO 25:IF PEEK(53279)=6 OR STRIG(0)=0 THEN RETURN 
32765 NEXT PAUSE:POKE 755,0
32766 FOR PAUSE=1 TO 25:IF PEEK(53279)=6 OR STRIG(0)=0 THEN RETURN 
32767 NEXT PAUSE:POKE 755,2:GOTO 32764