'SUPER STAR TREK
'COVERTED TO SMALL BASIC FOR EBOOKMAN BY joeydoa 8/18/2003
'THIS VERSION ORIGINALLY PUBLISHED IN CREATIVE COMPUTING 1976
'BUG FIXED IN ORIGINAL VERSION THAT STARBASE OR KLINGON WOULD NOT APPEAR
'	EVEN THOUGH IT IS PRESENT IN LRS - FIXED
'ALSO SECTOR COORDS GO OUT OF WHACK WHEN ATTEMPT TO LEAVE BOUNDARY - FIXED
'& A GHOST ENTERPRISE WILL APPEAR ONCE IN A WHILE IN THE SAME SECTOR - FIXED
'NOTE - THESE BUGS ARE IN THE ORIGINAL CODE AND HAVE BEEN PROPOGATED OVER THE DECADES - NOW FIXED!
Cls
? Tab(13);"     SUPER STAR TREK":?
? Tab(13);"CONVERTED AND FIXED BY":?
? Tab(17);CAT(3);"JOEYDOA 9/2003";CAT(0):?
? Tab(8);"FROM CREATIVE COMPUTING SOURCE"
? Tab(15);"           1976"
?:? Tab(19);CAT(3);"PRESS ANY KEY";CAT(0):PAUSE
Cls
Print "  THE USS ENTERPRISE --- NCC-1701":
?:?    
Print "                          ,-----*-----,"
Print "  ,------------    '---  ------'"
Print "   '------ ----'       / /"
Print "       ,---' '-------/ /---,"
Print "        '----------------'":PRINT:PRINT

INPUT "DO YOU WISH INSTRUCTIONS (Y/N)";A$
IF UCASE(A$)="Y" 
Cls
? "SUPER STAR TREK INSTRUCTIONS"
? "      COPYRIGHT BY"
? "   CREATIVE COMPUTING"
? "MORRISTOWN, NEW JERSEY 07960"
? CAT(3);"TRANSLATED BY JOEYDOA 8/03";CAT(0):?

?"1. WHEN YOU SEE 'COMMAND ?'"
?"PRINTED, ENTER ONE OF THE "
?"LEGAL COMMANDS (NAV,SRS,LRS,"
?"PHA,TOR,SHE,DAM,COM OR XXX)."
?   
?"2. IF YOU SHOULD TYPE IN AN"
?"ILLEGAL COMMAND, YOU'LL GET A"
?"SHORT LIST OF THE LEGAL"
?"COMMANDS PRINTED OUT."
?   
?"3. SOME COMMANDS REQUIRE YOU TO"
?"ENTER DATA (FOR EXAMPLE, THE"
?"'NAV' COMMAND COMES BACK WITH"
?"'CORSE (1-9) ?'.) IF YOU TYPE"
?"IN ILLEGAL DATA (LIKE NEGATIVE"
?" NUMBERS), THAT COMMAND"
?"WILL BE ABORTED."
? CAT(3);"PRESS ANY KEY";CAT(0):PAUSE:Cls
?"    THE GALAXY IS DIVIDED INTO"
?"AN 8 X 8 QUADRANT GRID, AND EACH"
?"QUADRANT IS FURTHER DIVIDED INTO"
?"AN 8 X 8 SECTOR GRID. YOU WIL BE"
?"ASSIGNED A STARTING POINT SOMEWHERE"
?"IN THE GALAXY TO BEGIN A TOUR OF"
?"DUTY AS COMMANDER OF THE STARSHIP"
?"ENTERPRISE; YOUR MISSION:"
?"TO SEEK AND DESTROY THE FLEET OF"
?"KLINGON WARSHIPS WHICH ARE"
?"MENACING THE UNITED FEDERATION OF"
?"PLANETS."
?"    YOU HAVE THE FOLLOWING COMMANDS"
?"AVAILABLE TO YOU AS CAPTAIN OF THE"
?"STARSHIP ENTERPRISE:"
?" /NAV/ COMMAND = WARP ENGINE CONTROL -"
?"COURSE IS IN A CIRCULAR  4  3  2"
?"NUMERICAL VECTOR            . . ."
?"SCAN SHOWN AS                  ..."
?"INTEGER AND REAL       5 ---*--- 1"
?"VALUES MAY BE USED.          ..."
?"(THUS COURSE 1.5 IS         . . ."
?"HALF-WAY BETWEEN         6  7  8"
? CAT(3);"PRESS ANY KEY";CAT(0):PAUSE:Cls
?"1 AND 2. VALUES MAY APPROACH 9.0,"
?"WHICH ITSELF IS EQUIVALENT TO 1.0"
?"COURSE. ONE WARP FACTOR IS THE SIZE OF"
?"ONE QUARDRANT.  THEREFORE, TO GET"
?"FROM QUARDRANT 6,5 TO 5,5 YOU WOULD"
?"USE COURSE 3, WARP FACTOR 1."
?	
?"/SRS/ COMMAND = SHORT RANGE SENSOR SCAN"
?"SHOWS A SCAN OF YOUR PRESENT QUADRANT."
?"SYMBOLOGY ON YOUR SENSOR SCREEN"
?"IS AS FOLLOWS:"
?" <*> = YOUR STARSHIP'S POSITTION"
?" +K+ = KLINGON BATTLE CRUISER"
?" >!< = FEDERATION STARBASE"
?"      (REFUEL/REPAIR/RE-ARM HERE!)"
?" *  = STAR"
? CAT(3);"PRESS ANY KEY";CAT(0):PAUSE
?
?"A CONDENSED 'STATUS REPORT' WILL ALSO"
?"BE PRESENTED."
?
?"/LRS/ COMMAND = LONG RANGE SENSOR SCAN"
?" SHOWS CONDITIONS IN SPACE FOR ONE"
?"QUADRANT ON EACH SIDE"
?"OF THE ENTERPRISE"
?"(WHICH IS IN THE MIDDLE OF THE SCAN)."
?"THE SCAN IS CODED IN THE FORM /###/,"
?"WHERE THE UNITS DIGIT IS THE NUMBER"
?"OF STARS, THE TENS DIGIT IS THE NUMBER OF"
?"STARBASES, AND THE HUNDREDS DIGIT"
?" IS THE NUMBER OF KLINGONS."
? CAT(3);"PRESS ANY KEY";CAT(0):PAUSE
ENDIF
20 CLS
30 Print "            S U P E R  S T A R  T R E K"
40 PRINT:Print:M$=""
50 'CLEAR 600
60 Z$="                      "
70 DIM G(8,8),C(9,2),K(3,3),N(3),Z(8,8),D(8):Randomize Timer 'RND*10 SEED
80 T=INT(RND*20+20)*100:T0=T:T9=25+INT(RND*10):D0=0:E=3000:E0=E
90 P=10:P0=P:S9=200:S=0:B9=0:K9=0:X$=" ":X0$=" IS "
100 Q1=Int(((8-1+1)*RND+8)-(8-1)):Q2=Int(((8-1+1)*RND+8)-(8-1)):S1=Int(((8-1+1)*RND+8)-(8-1)):S2=Int(((8-1+1)*RND+8)-(8-1))
110 FOR I=1 TO 9:C(I,1)=0:C(I,2)=0:NEXT I
120 C(3,1)=-1:C(2,1)=-1:C(4,1)=-1:C(4,2)=-1:C(5,2)=-1:C(6,2)=-1
130 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
140 FOR I=1 TO 8:D(I)=0:NEXT I
150 A1$="NAVSRSLRSPHATORSHEDAMCOMXXX"
160 FOR I=1 TO 8:FOR J=1 TO 8:K3=0:Z(I,J)=0:R1=RND
170 IF R1>.98 Then K3=3:K9=K9+3:GOTO 200
180 IF R1>.95 THEN K3=2:K9=K9+2:GOTO 200
190 IF R1>.8 THEN K3=1:K9=K9+1
200 B3=0:IF RND>.96 THEN B3=1:B9=B9+1
210 G(I,J)=K3*100+B3*10+Int(((8-1+1)*RND+8)-(8-1)):NEXT J:NEXT I:IF K9>T9 THEN T9=K9+1
220 IF B9<>0 THEN 250
230 IF G(Q1,Q2)<200 THEN G(Q1,Q2)=G(Q1,Q2)+100:K9=K9+1
240 B9=1:G(Q1,Q2)=G(Q1,Q2)+10:Q1=Int(((8-1+1)*RND+8)-(8-1)):Q2=Int(((8-1+1)*RND+8)-(8-1))
250 K7=K9:IF B9<>1 THEN X$="S":X0$=" ARE "
260 PRINT"YOUR ORDERS ARE AS FOLLOWS:"
270 ?:PRINT"DESTROY THE ";K9;" KLINGON WARSHIPS WHICH"
280 ? "HAVE INVADED THE GALAXY BEFORE THEY CAN"
290 ? "ATTACK FEDERATION HEADQUARTERS ON"
291 ? "STARDATE ";T0+T9;".  ";"THIS GIVES YOU ";T9;" DAYS."
300 If B9=1 Then ? "THERE IS ";B9;" STARBASE IN THE" Else ? "THERE ARE ";B9;" STARBASES IN THE"
301 ? "GALAXY FOR RESUPPLYING YOUR SHIP."
310 PRINT
311 ? "ENTER YOUR NAME"
312 INPUT"IN THE CAPTAIN'S LOG";NA$:NA$=UCASE(NA$)
320 Z4=Q1:Z5=Q2:K3=0:B3=0:S3=0:G5=0:D4=.5*RND:Z(Q1,Q2)=G(Q1,Q2)
330 IF Q1<1 OR Q1>8 OR Q2<1 OR Q2>8 THEN 400
340 Rem 
350 K3=INT(G(Q1,Q2)*.01):B3=INT(G(Q1,Q2)*.1)-10*K3
360 S3=G(Q1,Q2)-100*K3-10*B3:If K3=0 Then 390
370 CLS:M$="COMBAT AREA      CONDITION RED":If S>200 Then 390
380 M$="SHIELDS DANGEROUSLY LOW"
390 For I=1 TO 3:K(I,1)=0:K(I,2)=0:Next I
400 For I=1 TO 3:K(I,3)=0:Next I:Q$=Z$+Z$+Z$+Z$+Z$+Z$+Z$+LEFT$(Z$,17)
410 A$="<*>":Z1=S1:Z2=S2:GoSub 3390:If K3<1 Then 440
420 For I=1 TO K3:GoSub 3370:A$="+K+":Z1=R1:Z2=R2
430 GoSub 3390:K(I,1)=R1:K(I,2)=R2:K(I,3)=S9*(.5+RND):Next I
440 If B3<1 Then 460
450 GoSub 3370:A$=">!<":Z1=R1:B4=R1:Z2=R2:B5=R2:GoSub 3390
460 For I=1 TO S3:GoSub 3370
470 A$=" * "
480 Z1=R1
490 Z2=R2
500 GoSub 3390
510 Next I
520 GoSub 2490
530 GS=0:If S+E>10 Then If E>10 OR D(7)=0 Then 580
540 CLS:Print"CAPTAIN ";NA$;"!. YOU'VE JUST STRANDED YOUR SHIP IN SPACE!"
550 PRINT"YOU HAVE INSUFFICIENT MANEUVERING ENERGY,";
560 PRINT" AND SHIELD CONTROL":PRINT"IS PRESENTLY INCAPABLE OF CROSS";
570 PRINT"-CIRCUITING TO ENGINE ROOM!!":GoTo 2340
580 ?:PRINT"YOUR ORDERS, CAPTAIN ";NA$;:Input A$:A$=UCASE(A$)
590 For I=1 TO 9:If LEFT$(A$,3)<>MID$(A1$,3*I-2,3) Then 610
600 ON I GOTO 710,520,1340,1420,1620,1970,2060,2720,2370
610 NEXT I:Print"ENTER ONE OF THE FOLLOWING:"
620 PRINT" NAV  (TO SET COURSE)"
630 PRINT" SRS  (FOR SHORT RANGE SENSOR SCAN)"
640 PRINT" LRS  (FOR LONG RANGE SENSOR SCAN)"
650 PRINT" PHA  (TO FIRE PHASERS)"
660 PRINT" TOR  (TO FIRE PHOTON TORPEDOES)"
670 PRINT" SHE  (TO RAISE OR LOWER SHIELDS)"
680 PRINT" DAM  (FOR DAMAGE CONTROL REPORTS)"
690 PRINT" COM  (TO CALL ON LIBRARY-COMPUTER)"
700 PRINT" XXX  (TO RESIGN YOUR COMMAND)":PRINT:GoTo 530
710 INPUT"COURSE (0-9)";C1:If C1=9 Then C1=1
720 If C1>=1 AND C1<9 Then 740
730 PRINT"  LT. SULU REPORTS, 'INCORRECT COURSE DATA, SIR!'":GoTo 530
740 X$="8":If D(1)<0 Then X$="0.2"
750 PRINT"WARP FACTOR (0-";X$;")";:Input W1:If D(1)<0 AND W1>.2 Then 790
760 If W1>0 AND W1<=8 Then 800
770 If W1=0 Then 530
780 PRINT"  CHIEF ENGINEER SCOTT REPORTS:"
781 ? "THE ENGINES WON'T TAKE WARP ";W1:GOTO 590
790 PRINT"WARP ENGINES ARE DAMAGED.  MAXIMUM SPEED = WARP 0.2":GoTo 530
800 NN=INT(W1*8+.5):If E-NN>=0 Then 870
810 PRINT"ENGINEERING REPORTS:"
811 ? "INSUFFICIENT ENERGY AVAILABLE -"
820 Print "FOR MANEUVERING AT WARP ";W1
830 If S<NN-E OR D(7)<0 Then 530
840 PRINT"DEFLECTOR CONTROL ROOM ACKNOWLEDGES ";S;" UNITS OF ENERGY"
850 Print "PRESENTLY DEPLOYED TO SHIELDS."
860 GoTo 530
870 For I=1 TO K3:If K(I,3)=0 Then 900
880 A$="   ":Z1=K(I,1):Z2=K(I,2):GoSub 3390:GoSub 3370
890 K(I,1)=Z1:K(I,2)=Z2:A$="+K+":GoSub 3390
900 Next I:GoSub 2210:D1=0:D6=W1:If W1>=1 Then D6=1
910 For I=1 TO 8:If D(I)>=0 Then 960
920 D(I)=D(I)+D6:If D(1)>-.1 AND D(I)<0 Then D(I)=-.1:GoTo 960
930 If D(I)<0 Then 960
940 If D1<>1 Then D1=1:PRINT"DAMAGE CONTROL REPORT:"
950 Print TAB(4);:R1=I:GoSub 3440:Print G2$;" REPAIR COMPLETED.":D(R1)=0:? CAT(3);"PRESS ANY KEY";CAT(0):PAUSE
960 Next I:If RND>.2 Then 1020
970 R1=Int(((8-1+1)*RND+8)-(8-1)):If RND>=.6 AND D(R1)<0 Then 1000
980 D(R1)=D(R1)-(RND*5+1):PRINT"DAMAGE CONTROL REPORT:"
990 GoSub 3440:Print G2$;" DAMAGED":PRINT:? CAT(3);"PRESS ANY KEY";CAT(0):PAUSE:GoTo 1020
1000 D(R1)=D(R1)+RND*3+1:PRINT"DAMAGE CONTROL REPORT"
1010 GOSUB 3440:Print G2$;" STATE OF REPAIR IMPROVED":Print:? CAT(3);"PRESS ANY KEY";CAT(0):PAUSE:If D(R1)>0 Then D(R1)=0
1020 A$="   ":Z1=INT(S1):Z2=INT(S2):GoSub 3390
1030 X1=C(C1,1)+(C(C1+1,1)-C(C1,1))*(C1-INT(C1)):X=S1:Y=S2
1040 X2=C(C1,2)+(C(C1+1,2)-C(C1,2))*(C1-INT(C1)):Q4=Q1:Q5=Q2
1050 For I=1 TO NN:S1=S1+X1:S2=S2+X2:If S1<1 OR S1>=9 OR S2<1 OR S2>=9 Then 1140
1060 S8=INT(S1)*24+INT(S2)*3-26:If MID$(Q$,S8,2)="  " Then 1090
1070 S1=INT(S1-X1):S2=INT(S2-X2):PRINT"WARP ENGINE SHUTDOWN AT";
1080 PRINT"SECTOR";S1;", ";S2:?"DO TO BAD NAVIGATION":? CAT(3);"PRESS ANY KEY";CAT(0):PAUSE:GoTo 1100
1090 Next I:S1=INT(S1):S2=INT(S2)
1100 A$="<*>":Z1=INT(S1):Z2=INT(S2):GoSub 3390:GoSub 1300:T8=1
1110 If W1<1 Then T8=.1*INT(10*W1)
1120 T=T+T8:If T>T0+T9 Then 2340
1130 GoTo 520
1140 X=8*Q1+X+NN*X1:Y=8*Q2+Y+NN*X2:Q1=INT(X/8):Q2=INT(Y/8):S1=INT(X-Q1*8)
1150 S2=INT(Y-Q2*8):IF S1=0 Then Q1=Q1-1:S1=8
1160 If S2=0 Then Q2=Q2-1:S2=8
1170 X5=0:If Q1<1 Then X5=1:Q1=1:S1=1
1180 If Q1>8 Then X5=1:Q1=8:S1=8
1190 If Q2<1 Then X5=1:Q2=1:S2=1
1200 If Q2>8 Then X5=1:Q2=8:S2=8
'1210 If X5=0 Then 1280
1210 IF X5=0 THEN 1290
1220 PRINT"LT. UHURA REPORTS,"
1221 ? "MESSAGE FROM STARFLEET COMMAND:"
1230 PRINT"PERMISSION TO ATTEMPT CROSSING"
1231 ? "OF GALACTIC PERIMETER IS HEREBY"
1240 ? "*DENIED*. SHUTDOWN YOUR ENGINES"
1250 PRINT"CHIEF ENGINEER SCOTT REPORTS,"
1251 ? "WARP ENGINES SHUT DOWN"
1260 PRINT"AT SECTOR ";S1;",";S2;" OF QUADRANT ";Q1;",";Q2;".":? CAT(3);"PRESS ANY KEY";CAT(0):PAUSE
1270 IF T>T0+T9 THEN 2340
1280 IF 8*Q1+Q2=8*Q4+Q5 THEN 1100
1290 T=T+1:GOSUB 1300:GoTo 320
1300 E=E-NN-10:IF E>0 THEN RETURN
1310 PRINT "SHIELD CONTROL SUPPLIES ENERGY"
1311 ? "TO COMPLETE THE MANEUVER"
1320 S=S+E:E=0:IF S<0 THEN S=0
1330 RETURN
1340 IF D(3)<0 THEN PRINT"LONG RANGE SENSORS ARE INOPERABLE":GOTO 530
1350 Print "LONG RANGE FOR QUADRANT ";Q1;",";Q2
1360 O1$="--------------------":PRINT O1$
1370 FOR I=Q1-1 TO Q1+1:N(1)=-1:N(2)=-2:N(3)=-3:FOR J=Q2-1 TO Q2+1
1380 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)
1390 Next J:For L=1 TO 3:PRINT": ";:If N(L)<0 Then PRINT"*** ";:GoTo 1410
1400 Print RIGHT$(STR$(N(L)+1000),3);" ";
1410 Next L:PRINT":":Print O1$:Next I:GoTo 530
1420 CLS:PRINT:If D(4)<0 Then PRINT"PHASERS INOPERATIVE":GoTo 530
1430 If K3>0 Then 1460
1440 PRINT"SCIENCE OFFICER SPOCK REPORTS"
1441 ? "SENSORS SHOW NO ENEMY SHIPS"
1450 Print "IN THIS QUADRANT '":GoTo 530
1460 If D(8)<0 Then PRINT"COMPUTER FAILURE HAMPERS ACCURACY"
1470 PRINT"PHASERS LOCKED ON TARGET;  "
1480 PRINT"ENERGY AVAILABLE = ";E;" UNITS"
1490 INPUT"NUMBER OF UNITS TO FIRE";X:If X<=0 Then 530
1500 If E-X<0 Then 1480
1510 E=E-X:If D(7)<0 Then X=X*RND
1520 H1=INT(X/K3):For I=1 TO 3:If K(I,3)<=0 Then 1610
1530 JH=SQR((K(I,1)-S1)^2+(K(I,2)-S2)^2)
1540 H=INT((H1/JH)*(RND+2)):If H>.15*K(I,3) Then 1560
1550 PRINT"SENSORS SHOW NO DAMAGE TO ENEMY"
1551 ? "AT ";K(I,1);",";K(I,2):GoTo 1610
1560 K(I,3)=K(I,3)-H:Print ROUND(H,2);" UNITS HIT ON KLINGON"
1561 ? "AT SECTOR ";K(I,1);",";
1570 Print K(I,2):If K(I,3)<=0 Then Beep:?:Print CAT(3);"*** KLINGON DESTROYED ***";CAT(0):?:GoTo 1590
1580 PRINT"(SENSORS SHOW ";ROUND(K(I,3),2);" UNITS REMAINING)":GoTo 1610
1590 K3=K3-1:K9=K9-1:Z1=K(I,1):Z2=K(I,2):A$="   ":GoSub 3390
1600 K(I,3)=0:G(Q1,Q2)=G(Q1,Q2)-100:Z(Q1,Q2)=G(Q1,Q2):If K9<=0 Then 2450
1610 Next I:GoSub 2210:GoTo 530
1620 FOR X = 1 TO 10:NEXT X
1630 If P<0 THEN PRINT"ALL PHOTON TORPEDOES EXPENDED":GoTo 530
1640 IF D(5)<0 Then PRINT"PHOTON TUBES ARE NOT OPERATIONAL":GoTo 530
1650 INPUT"PHOTON TORPEDOE COURSE (1-9)";C1:If C1=9 Then C1=1
1660 If C1>=1 AND C1<9 Then 1690
1670 PRINT"ENSIGN CHEKOV REPORTS,"
1671 ? "INCORRECT COURSE DATA, SIR!"
1680 GoTo 530
1690 X1=C(C1,1)+(C(C1+1,1)-C(C1,1))*(C1-INT(C1)):E=E-2:P=P-1
1700 X2=C(C1,2)+(C(C1+1,2)-C(C1,2))*(C1-INT(C1)):X=S1:Y=S2
1710 X=X+X1:Y=Y+X2:X3=INT(X+.5):Y3=INT(Y+.5)
1720 If X3<1 OR X3>8 OR Y3<1 OR Y3>8 Then 1960
1730 Print STRING$(63," ")
1740 Print"TRACKING TORPEDO ";X3;",";Y3;:A$="   ":Z1=X:Z2=Y:GoSub 3530
1750 If Z3<>0 Then 1710
1760 PRINT
1770 A$="+K+":Z1=X:Z2=Y:GoSub 3530:If Z3=0 Then 1820
1780 ?:Beep:Print CAT(3);"*** KLINGON DESTROYED ***";CAT(0):?:K3=K3-1:K9=K9-1:If K9<=0 Then 2450
1790 For I=1 TO 3:If X3=K(I,1) AND Y3=K(I,2) Then 1810
1800 Next I:I=3
1810 K(I,3)=0:GoTo 1940
1820 A$=" * ":Z1=X:Z2=Y:GoSub 3530:If Z3=0 Then 1840
1830 PRINT"STAR AT ";X3;",";Y3;" ABSORBED TORPEDO ENERGY.":GoSub 2210:GoTo 530
1840 A$=">!<":Z1=X:Z2=Y:GoSub 3530:If Z3=0 Then 1650
1850 Beep:?:? CAT(3);"*** STARBASE DESTROYED ***";CAT(0):?:B3=B3-1:B9=B9-1
1860 If B9>0 OR K9>T-T0-T9 Then 1920
1870 NA$="WALDO"
1880 PRINT"CAPTAIN ";NA$;", YOU ARE HEREBY"
1881 ? "RELIEVED OF COMMAND AND SENTENCED"
1890 ? "TO 99 STARDATES AT HARD LABOR"
1891 ? "ON CYGNUS 12!!"
1900 ? CAT(3);"PRESS ANY KEY";CAT(0):PAUSE
1910 GOTO 2370
1920 PRINT"STARFLEET COMMAND REVIEWING"
1921 ? "YOUR RECORD TO CONSIDER..."
1930 PRINT"COURT MARTIAL!":D0=0
1940 Z1=X:Z2=Y:A$="   ":GoSub 3390
1950 G(Q1,Q2)=K3*100+B3*10+S3:Z(Q1,Q2)=G(Q1,Q2):GoSub 2210:GoTo 530
1960 PRINT:PRINT"TORPEDO MISSED":GoSub 2210:GoTo 530
1970 If D(7)<0 Then PRINT"SHIELD CONTROL INOPERABLE":GoTo 530
1980 PRINT"ENERGY AVAILABLE= ";E+S:INPUT"NUMBER OF UNITS TO SHIELDS";X
1990 If X<0 OR S=X Then PRINT"(SHIELDS UNCHANGED)":GoTo 530
2000 If X<=E+S Then 2030
2010 PRINT"CAPTAIN ";NA$;"! THIS IS"
2011 ? "NOT THE FEDERATION TREASURY."
2020 PRINT"(SHIELDS UNCHANGED)":GoTo 530
2030 E=E+S-X:S=X:PRINT"DEFLECTOR CONTROL ROOM REPORT:"
2040 PRINT"SHIELDS NOW AT ";INT(S);" UNITS"
2041 ? "PER YOUR COMMAND."
2050 ? CAT(3);"PRESS ANY KEY";CAT(0):PAUSE:CLS:GoSub 2490:GoTo 530
2060 If D(6)>=0 Then 2170
2070 PRINT"DAMAGE CONTROL REPORT NOT AVAILABLE":If D0=0 Then 530
2080 D3=0:For I=1 TO 8:If D(I)<0 Then D3=D3+.1
2090 Next I:If D3=0 Then 530
2100 PRINT:D3=D3+D4:If D3>=1 Then D3=.9
2110 PRINT"TECHNICIANS STANDING BY"
2111 ? "TO EFFECT REPAIRS TO YOUR SHIP;"
2120 PRINT"ESTIMATED TIME TO REPAIR: ";ROUND(.01*INT(100*D3),2);" STARDATES"
2130 INPUT"WILL YOU AUTHORIZE THE REPAIR (Y/N)";A$:A$=UCASE(A$)
2140 If A$<>"Y" Then 530
2150 For I=1 TO 8:If D(I)<0 Then D(I)=0
2160 Next I:T=T+D3+.1
2170 CLS:PRINT:PRINT"DEVICE			STATE OF REPAIR":?:For R1=1 TO 8
'2180 GoSub 3440:Print G2$;LEFT$(Z$,25-LEN(G2$));INT(D(R1)*100)*.01
2180 GoSub 3440:If Len(G2$)<=14 Then Print G2$;"			" ;Int(D(R1)*100)*.01 Else Print G2$;"		" ;Int(D(R1)*100)*.01
2190 Next R1:PRINT:If D0<>0 Then 2080
2200 GoTo 530
2210 If K3<=0 Then RETURN
2220 If D0<>0 Then PRINT"STARBASE SHIELDS PROTECT THE ENTERPRISE":RETURN
2230 For I=1 TO 3:If K(I,3)<=0 Then 2330
2240 JH=SQR((K(I,1)-S1)^2+(K(I,2)-S2)^2)
2250 H=INT((K(I,3)/JH)*(2+RND)):S=S-H:K(I,3)=K(I,3)/(3+RND(O))
2260 Print ROUND(H,2);" UNIT HIT ON ENTERPRISE"
2261 ? "FROM SECTOR ";K(I,1);",";K(I,2)
2270 '? CAT(3);"PRESS ANY KEY";CAT(0):PAUSE
2280 If S<=0 Then 2350
2290 PRINT"(SHIELDS DOWN TO ";S;" UNITS)":If H<20 Then 2330
2300 If RND>.6 OR H/S<=.02 Then 2330
2310 R1=Int(((8-1+1)*RND+8)-(8-1)):D(R1)=D(R1)-H/S-.5*RND:GoSub 3440
2320 ?:PRINT"DAMAGE CONTROL REPORTS"
2321 ? G2$;" DAMAGED BY THE HIT."
2330 Next I:RETURN
2340 PRINT"IT IS STARDATE ";ROUND(T,2):? CAT(3);"PRESS ANY KEY";CAT(0):PAUSE:GoTo 2370
2350 CLS:PRINT:PRINT"THE ENTERPRISE HAS BEEN DESTROYED.":Print"THE FEDERATION";
2360 PRINT"WILL BE CONQUERED":GoTo 2340
2370 CLS:PRINT"THERE WERE ";K9;" KLINGON BATTLE"
2371 ? "CRUISERS LEFT AT THE END"
2380 ? "OF YOUR MISSION."
2390 PRINT:PRINT:If B9=0 Then 2430
2400 PRINT"THE FEDERATION IS IN NEED OF"
2401 ? "A NEW STAR SHIP COMMANDER"
2410 PRINT"FOR A SIMILER MISSION --"
2411 ? "IF THERE IS A VOLUNTEER."
2420 INPUT"STEP FORWARD AND ENTER 'AYE'";A$:A$=UCASE(A$):If A$="AYE" Then 20
2430 END
2440 T=100:B9=1
2450 ' Input "HIT ENTER TO CONTINUE";I$:Cls
2460 Print"CONGRATULATIONS, MON CAPITAN ";NA$;"!"
2461 ? "THE LAST KLINGON BATTLE CRUISER MENACING"
2470 ? "THE FEDERATION HAS BEEN DESTROYED!":PRINT
2480 Print TAB(10)"YOUR EFFICIENCY RATING IS ";ROUND(1000*(K7/(T-T0))^2,2):GoTo 2390
2490 For I=S1-1 TO S1+1:For J=S2-1 TO S2+1
2500 If INT(I+.5)<1 OR INT(I+.5)>8 OR INT(J+.5)<1 OR INT(J+.5)>8 Then 2520
2510 A$=">!<":Z1=I:Z2=J:GoSub 3530:If Z3=1 Then 2530
2520 Next J:Next I:D0=0:GoTo 2550
2530 D0=1:C$="DOCKED":E=E0:P=P0
2540 Print "SHIELDS DROPPED FOR DOCKING PURPOSES":? CAT(3);"PRESS ANY KEY";CAT(0):PAUSE:S=0:GoTo 2570
2550 If K3>0 Then C$="*RED*":GoTo 2570
2560 C$="GREEN":If E<E0*.1 Then C$="YELLOW"
2570 If D(2)>=0 Then 2600
2590 PRINT"*** SHORT RANGE SENSORS ARE OUT ***":PRINT:RETURN
2600 CLS:? M$:M$="":O1$=" ---------------------------------":Print O1$:For I=1 TO 8:? " ";
2610 J1=(I-1)*24+1:J2=(I-1)*24+22:For J=J1 TO J2 STEP 3:PRINT" ";MID$(Q$,J,3);:Next J
2620 Print "":Next I:Print O1$
2630 PRINT"   STARDATE		";INT(T*10)*.1
2640 PRINT"   CONDITION		";C$
2650 PRINT"   QUADRANT		";Q1;",";Q2
2660 PRINT"   SECTOR		";S1;",";S2
2670 PRINT"   PHOTON TORPEDOES	";INT(P)
2680 PRINT"   TOTAL ENERGY		";INT(E+S)
2690 PRINT"   SHIELDS		";INT(S)
2700 PRINT"   KLINGONS REMAINING	";INT(K9)
2710 Return
2720 If D(8)<0 Then PRINT"COMPUTER DISABLED":GoTo 530
2730 INPUT"COMPUTER ACTIVE.  AWAITING COMMAND";A:If A<0 OR A>4 Then 2750
2740 H8=1:On A+1 GoTo 2830,2950,3050,3340,3110
2750 CLS:PRINT"FUNCTIONS AVAILABLE"
2751 ? "FROM LIBRARY-COMPUTER:":?
2760 PRINT"   0 = CUMULATIVE GALACTIC RECORD"
2770 PRINT"   1 = STATUS REPORT"
2780 PRINT"   2 = PHOTON TORPEDO DATA"
2790 PRINT"   3 = STARBASE NAV DATA"
2800 PRINT"   4 = DIRECTION/DISTANCE CACULATOR"
2810 PRINT:GoTo 2730

2820 H8=0:G5=1:CLS:Print TAB(24)"THE GALAXY":GoTo 2860
2830 ?:?'PRINT:PRINT"        ";
2840 CLS:PRINT"      COMPUTER RECORD OF GALAXY"
2841 ? "            FOR QUADRANT ";Q1;",";Q2
2850 Print
2860 PRINT"    1     2     3     4     5     6     7     8"
2870 O1$= "   ---  ---  ---  ---  ---  ---  ---   ---"
2880 Print O1$:For I=1 TO 8:? I;" ";:If H8=0 Then 2920
2890 For J=1 TO 8:If Z(I,J)=0 Then PRINT"***";:? " ";:GoTo 2910
2900 Print RIGHT$(STR$(Z(I,J)+1000),3);" ";
2910 Next J:GoTo 2940

2920 Z4=I:Z5=1:GoSub 3560:J0=INT(15-.5*LEN(G2$)):Print TAB(J0);G2$;
2930 Z5=5:GOSUB 3560:J0=INT(39-.5*LEN(G2$)):Print TAB(J0);G2$;
2940 PRINT:Next I:PRINT:GoTo 530
2950 CLS:PRINT "	     STATUS REPORT:":?:X$="":If K9>1 Then X$="S"
2960 PRINT"	KLINGON";X$;" LEFT: ";K9
2970 PRINT"	MISSION MUST BE COMPLETED"
2971 ? "	IN ";.1*INT((T0+T9-T)*10);" STARDATES"
2980 X$="S":If B9<2 Then X$="":If B9<1 Then 3020
2990 PRINT"	THE FEDERATION IS MANTAINING "
2991 ? "	";B9;" STARBASE";X$;" IN THE GALAXY":?
3000 ?  Tab(23);CAT(3);"PRESS ANY KEY";CAT(0):PAUSE
3010 GoTo 2060
3020 PRINT"CAPTAIN ";NA$;"!  YOUR STUPIDITY HAS LEFT"
3021 ? "YOU ON YOUR OWN IN THE GALAXY --"
3030 ? "YOU HAVE NO STARBASES LEFT!":?
3040 ? CAT(3);"PRESS ANY KEY";CAT(0):PAUSE:GoTo 2060
3050 If K3<=0 Then 1440
3060 X$="":If K3>1 Then X$="S"
3070 PRINT"FROM ENTERPRISE TO KLINGON";X$;":":?
3074 I=1
3075	If K(I,3)>0
		W1=K(I,1)
		X=K(I,2)
		C1=S1
		A=S2
		sub3
	ENDIF
3090 IF I=3 THEN 530 ELSE I=I+1:GOTO 3075 'Next I
	
'DISTANCE ROUTINE REWRITTEN!
3110 CLS:PRINT"DIRECTION/DISTANCE CALCULATOR:":I=3
3120 PRINT"YOU ARE AT QUADRANT ";Q1;",";Q2;" SECTOR ";S1;",";S2
'3130 ? "INITIAL COORDINATES (X,Y) = ";Q1;",";Q2
'3131 Input "X = ";C1
'3132 Input "Y = ";A
3140 C1=Q1:A=Q2:?:? "DESTINATION COORDINATES (X,Y)"
3141 Input "X = ";W1
3142 Input "Y = ";X

3143 If (X-A=0) AND (C1-W1=0) Then ?:? "ENSIGN CHEKOV SAYS,":? "INCORRECT COORDINATES, CAPTAIN!":?:GoTo 3120
3150 sub3:GoTo 530

3340 If B3>0 Then PRINT"FROM ENTERPRISE TO STARBASE:":W1=B4:X=B5:C1=S1:A=S2:sub3:GoTo 530
3350 PRINT"MR SPOCK REPORTS, SENSORS SHOW"
3351 ? "NO STARBASES IN THIS";
3360 PRINT" QUADRANT.":GOTO 530
3370 R1=Int(((8-1+1)*RND+8)-(8-1)):R2=Int(((8-1+1)*RND+8)-(8-1)):A$="   ":Z1=R1:Z2=R2:GoSub 3530:If Z3=0 Then 3370:Print Z3
3380 RETURN
3390 S8=INT(Z2-.5)*3+INT(Z1-.5)*24+1
3400 If LEN(A$)<>3 Then PRINT"ERROR":STOP
3410 If S8=1 Then Q$=A$+RIGHT$(Q$,189):RETURN
3420 If S8=190 Then Q$=LEFT$(Q$,189)+A$:RETURN
3430 Q$=LEFT$(Q$,S8-1)+A$+RIGHT$(Q$,190-S8):RETURN
3440 On R1 GoTo 3450,3460,3470,3480,3490,3500,3510,3520
3450 G2$="WARP ENGINES":RETURN
3460 G2$="SHORT RANGE SENSORS":RETURN
3470 G2$="LONG RANGE SENSORS":RETURN
3480 G2$="PHASER CONTROL":RETURN
3490 G2$="PHOTON TUBES":RETURN
3500 G2$="DAMAGE CONTROL":RETURN
3510 G2$="SHIELD CONTROL":RETURN
3520 G2$="LIBRARY-COMPUTER":Return
3530 Z1=INT(Z1+.5):Z2=INT(Z2+.5):S8=(Z2-1)*3+(Z1-1)*24+1:Z3=0
3540 If MID$(Q$,S8,3)<>A$ Then RETURN
3550 Z3=1:RETURN
3560 GoSub 3490:RETURN

'DISTANCE SUBROUTINE FUNCTIONS
FUNC sub1()
	X=Abs(X):A=Abs(A)
	If A<=X
		Print "DIRECTION = ";ROUND(C1+(A/X),2)
	Else
		Print "DIRECTION = ";ROUND(C1+(((A*2)-X)/A),2)
	ENDIF
	Print" DISTANCE = ";
	IF X>A THEN PRINT ROUND(X,2) ELSE PRINT ROUND(A,2)
	?
End

FUNC sub2()
	X=Abs(X):A=Abs(A)
	If A>=X
		Print "DIRECTION = ";ROUND(C1+(X/A),2)
	Else
		Print "DIRECTION = ";ROUND(C1+(((X*2)-A)/X),2)
	ENDIF
	Print" DISTANCE = ";
	IF X>A THEN PRINT ROUND(X,2) ELSE PRINT ROUND(A,2)
	?
End

FUNC sub3()
	X=X-A
	A=C1-W1
	If X<=0
		If A>0
			C1=3
			sub2	
		Else
			C1=5
			sub1	
		ENDIF
	ElseIf A<0
		C1=7
		sub2
	Else
		C1=1
		sub1	
	ENDIF
End
