*NAME ** STAR TREK **  = This version altered and massaged into working order by ( Matthew^2. March 1988 2 9< **** Anglicised and tidied up for the **** 9F **** Z88 USERS' CLUB SOFTWARE LIBRARY **** 9P **** and lots of pretty bits added by **** 9Z **** Ian Braby MRPharmS **** 9d **** Software Librarian - June 1990 **** n 9x **** **** STAR TREK **** **** > **** Simulation of a mission of the starship ENTERPRISE - **** as seen on the Star Trek tv show. 2 **** Original program in Creative Computing - **** Basic Computer Games by Dave Ahl. 7 **** Modifications by Bob Fritz and Sharon Fritz @ **** for the IBM Personal Computer, October-November 1981 B **** Bob Fritz, 9915 Caninito Cuadro, San Diego, Ca., 92129  **** (714) 484-2955   ;" _____________" ;" _____________ (____________/" 2" \___________/ / /" 4" _\ \_________/ /___" 4" {__________________/" I: (1)"B THE USS ENTERPRISE --- NCC-1701";(1)"B" ""Z$=" " +, G(8,8),C(9,2),K(3,3),N(3),Z(8,8),D(8) >6T=((1)*20+20)*100:T0=T:T9=25+((1)*10):D0=0:E=3000:E0=E 3@P=10:P0=P:S9=200:S=0:B9=0:K9=0:X$="":X0$=" is " *J D(D)=((K(I,1)-S1)^2+(K(I,2)-S2)^2) T R(R)=((R)*7.98+1.01) &^ initialize enterprise's position 'hQ1=R(1):Q2=R(1):S1=R(1):S2=R(1) #r I=1 9:C(I,1)=0:C(I,2)=0: I ?|C(3,1)=-1:C(2,1)=-1:C(4,1)=-1:C(4,2)=-1:C(5,2)=-1:C(6,2)=-1 BC(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  I=1 8:D(I)=0: I %A1$="NAVSRSLRSPHATORSHEDAMCOMRES" " set up what exists in galaxy , k3=#klingons b3=#starbases s3=#stars - I=1 8: J=1 8:K3=0:Z(I,J)=0:R1=(1) ( R1>.9799999 K3=3:K9=K9+3: d`A # R1>.95 K3=2:K9=K9+2: d`A  R1>.8 K3=1:K9=K9+1 "B3=0: (1)>.96 B3=1:B9=B9+1 7G(I,J)=K3*100+B3*10+R(1): J: I: K9>T9 T9=K9+1  B9<>0 TRB 2 G(Q1,Q2)<200 G(Q1,Q2)=G(Q1,Q2)+100:K9=K9+1 /B9=1:G(Q1,Q2)=G(Q1,Q2)+10:Q1=R(1):Q2=R(1) &K7=K9: B9<>1 X$="s":X0$=" are " ""Your orders are as follows:" & =0"Destroy the ";K9;" Klingon warships which have invaded" @:"the galaxy before they can attack Federation headquarters" ED"on stardate ";T0+T9;" this gives you ";T9;" days. There ";X0$ FN "";B9;" starbase";X$;" in the galaxy for re-supplying your ship" X b "Press a key to start"; lI=(1): (5)=-1 DlB (v here any time new quadrant entered  @Z4=Q1:Z5=Q2:K3=0:B3=0:S3=0:G5=0:D4=.5*(1):Z(Q1,Q2)=G(Q1,Q2) & Q1<1 Q1>8 Q2<1 Q2>8 TVC  djP:: T0 <>T t|B 5"Your mission begins with your starship located" 9"in the galactic quadrant ";G2$;".":MM=(200): dPB )"Now entering ";G2$;" quadrant. . ." MM=(100) 1:K3=(G(Q1,Q2)*1E-2):B3=(G(Q1,Q2)*.1)-10*K3 *S3=G(Q1,Q2)-100*K3-10*B3: K3=0 TLC 0 (1)"B COMBAT AREA!! Condition";(1)"B" :: (1)"F";(1)"B RED ";(1)"B";(1)"F"  ddQ: S>200 TLC 2: (1)"B SHIELDS DANGEROUSLY LOW";(1)"B" #  I=1 3:K(I,1)=0:K(I,2)=0: I ; I=1 3:K(I,3)=0: I:Q$=Z$+Z$+Z$+Z$+Z$+Z$+Z$+Z$,17) A  position enterprise in quadrant, then place "k3" klingons,& +* "b3" starbases &"s3" stars elsewhere. -4A$="<*>":Z1=S1:Z2=S2: TXP: K3<1 DRC *> I=1 K3: dzO:A$="+K+":Z1=R1:Z2=R2 6H TXP:K(I,1)=R1:K(I,2)=R2:K(I,3)=S9*(.5+(1)): I R B3<1 DpC +\ dzO:A$=">!<":Z1=R1:B4=R1:Z2=R2:B5=R2 f TXP 5p I=1 S3: dzO:A$=" * ":Z1=R1:Z2=R2: TXP: I z dtK % S+E>10 E>10 D(7)=0 d@C / (1)"B*** FATAL ERROR ***";(1)"B": ddQ E"You've just stranded your ship in space. You have insufficient" >"manoeuvring energy, and Deflector Control is presently"; @"incapable of cross-circuiting to the Engine Room!!": DTK  COMPASS  70,7);"Command: "A$  . I=1 9: A$,3)<> A1$,3*I-2,3) drC 6 I DVD,DzC,T\G,t@G,DfH,tzI,TTJ,TLM,DrK & I:"Enter one of the following:" " NAV (to set course)" ," SRS (for short range sensor scan)" +" LRS (for long range sensor scan)" " PHA (to fire phasers)" )$" TOR (to fire photon torpedoes)" *." SHE (to raise or lower shields)" +8" DAM (for damage control reports)" 4B" COM (to call on library-computer)";: tDC L course control begins here VCOMPASS:"Course (1-8)";C1 ` C1>=1 C1<9 DtD Aj" Lt. Sulu reports, 'Incorrect course data, sir!'": tDC tX$="8": D(1)<0 X$="0.2" :~"Warp factor(0-";X$;")";: W1: D(1)<0 W1>.2 tpD  W1>0 W1<8 tzD  W1=0 tDC C::" Chief Engineer Scott reports 'The engines won't take"; !" warp ";W1;", Sir!'": tDC A"Warp engines are damaged. Maximum speed = warp 0.2": tDC N=(W1*8+.5): E-N>=0 TJE ;"Engineering reports 'Insufficient energy available" =" for manoeuvring at warp";W1;"!'"  S=1 D6=1 2 I=1 8: D(I)>=0 DdE 8<D(I)=D(I)+D6: D(I)>-.1 D(I)<0 D(I)=-.1: DdE F D(I)<0 DdE :P D1<>1 D1=1: (1)"BDAMAGE CONTROL REPORT:";(1)"B" 1Z 8);:R1=I: DTP: G2$;" Repair completed." d I: (1)>.2 tjE nR1=R(1): (1)>=.6 tLE BxD(R1)=D(R1)-((1)*5+1): (1)"BDAMAGE CONTROL REPORT:";(1)"B" $ DTP: G2$;" damaged":: tjE @D(R1)=D(R1)+(1)*3+1: (1)"BDAMAGE CONTROL REPORT:";(1)"B" . DTP: G2$;" State of repair improved":  begin moving starship &A$=" " :Z1=(S1):Z2=(S2): TXP 7X1=C(C1,1)+(C(C1+1,1)-C(C1,1))*(C1-(C1)):X=S1:Y=S2 9X2=C(C1,2)+(C(C1+1,2)-C(C1,2))*(C1-(C1)):Q4=Q1:Q5=Q2 D I=1 N:S1=S1+X1:S2=S2+X2: S1<1 S1>=9 S2<1 S2>=9 D@F 2S8=(S1)*24+(S2)*3-26: Q$,S8,2)=" " dpE :S1=(S1-X1):S2=(S2-X2):"Warp engines shut down at "; : "sector ";S1;",";S2;" due to bad navigation.": dzE  I:S1=(S1):S2=(S2) A$="<*>" (Z1=(S1):Z2=(S2): TXP: djF:T8=1  W1<1 T8=.1*(10*W1) T=T+T8: T>T0+T9 DTK $" see if docked then get command , DzC 6 exceeded quadrant limits @@X=8*Q1+X+N*X1:Y=8*Q2+Y+N*X2:Q1=(X/8):Q2=(Y/8):S1=(X-Q1*8) &JS2=(Y-Q2*8): S1=0 Q1=Q1-1:S1=8 T S2=0 Q2=Q2-1:S2=8 ^X5=0: Q1<1 X5=1:Q1=1:S1=1 h Q1>8 X5=1:Q1=8:S1=8 r Q2<1 X5=1:Q2=1:S2=1 | Q2>8 X5=1:Q2=8:S2=8  X5=0 dLF 8"Lt. Uhura reports message from Starfleet Command:" >" 'Permission to attempt crossing of galactic perimeter" 7" is hereby *DENIED*. Shut down your engines.'" ;"Chief Engineer Scott reports 'Warp engines shut down" <" at sector ";S1;",";S2;" of quadrant ";Q1;",";Q2".'"  T>T0 DTK  8*Q1+Q2=8*Q4+Q5 dzE T=T+1: djF: tJB  manoeuvre energy s/r ** E=E-N-10: E>0 C"Deflector Control supplies energy to complete the manoeuvre." S=S+E:E=0: S<=0 S=0  ! long range sensor scan code H D(3)<0 (1)"BLong Range Sensors are inoperable";(1)"B": tDC & X0"Long Range Scan for Quadrant: ";Q1;",";Q2::"ABC; A=Klingon B=Starbase C=Stars": : ;D I=Q1-1 Q1+1:N(1)=-1:N(2)=-2:N(3)=-3: J=Q2-1 Q2+1 0 I<9 J>0 J<9 N(J-Q2+2)=G(I,J):Z(I,J)=G(I,J) 3X J: L=1 3:": ";: N(L)<0 "*** ";: DlG b (N(L)+1000),3);" "; l L: ":": I: tDC %v phaser control code begins here : D(4)<0 (1)"BPhasers Inoperative";(1)"B": tDC  K3>0 thG B"Science Officer Spock reports 'Sensors show no enemy ships" ?" in this quadrant'": tDC 3 D(8)<0 "Computer failure hampers accuracy" !"Phasers locked on target:"; %"Energy available = ";E;" units" 1"Numbers of units to fire: ";X: X<=0 tDC  E-X<0 t|G %E=E-X: T`R: D(8)<0 X=X*(1) +H1=(X/K3): I=1 3: K(I,3)<=0 DHH 2H=((H1/D(0))*((1)+2)): H>.15*K(I,3) TBH C"Sensors show no damage to enemy at ";K(I,1);",";K(I,2): DHH KK(I,3)=K(I,3)-H: H;" unit hit on Klingon at sector ";K(I,1);",";K(I,2)   K(I,3) > 0 TjH E 10);(1)"F";(1)"B**** KLINGON DESTROYED ****";(1)"B";(1)"F"  TtH :*" (Sensors show ";K(I,3);" units remaining)": DHH 74K3=K3-1:K9=K9-1:Z1=K(I,1):Z2=K(I,2):A$=" ": TXP C>K(I,3)=0:G(Q1,Q2)=G(Q1,Q2)-100:Z(Q1,Q2)=G(Q1,Q2): K9<=0 dBK H I: dHJ R tDC %\ photon torpedo code begins here Bf P<=0 (1)"BAll photon torpedoes expended";(1)"B": tDC Gp D(5)<0 (1)"BPhoton tubes are not operational";(1)"B": tDC .zCOMPASS:"Photon torpedo course (1-8)";C1  C1>=1 C1<9 tbH <"Ensign Chekov reports, 'Incorrect course data, sir!'"  tDC 9X1=C(C1,1)+(C(C1+1,1)-C(C1,1))*(C1-(C1)):E=E-2:P=P-1 7X2=C(C1,2)+(C(C1+1,2)-C(C1,2))*(C1-(C1)):X=S1:Y=S2 :"Torpedo track:" 'X=X+X1:Y=Y+X2:X3=(X+.5):Y3=(Y+.5) & X3<1 X3>8 Y3<1 Y3>8 tfI 9" ";X3;",";Y3:A$=" ":Z1=X:Z2=Y: txP  Z3<>0 d@H +A$="+K+":Z1=X:Z2=Y: txP: Z3=0 TdI L 10);(1)"F";(1)"B**** KLINGON DESTROYED ****";(1)"B";(1)"F": TBR "K3=K3-1:K9=K9-1: K9<=0 dBK , I=1 3: X3=K(I,1) Y3=K(I,2) TZI  I:I=3  K(I,3)=0: tRI +$ A$=" * ":Z1=X:Z2=Y: txP: Z3=0 TxI C. "Star at ";X3;",";Y3;" absorbed torpedo energy.": dHJ: tDC +8 A$=">!<":Z1=X:Z2=Y: txP: Z3=0 DzH GB : 10);(1)"F"; (1)"B*** STARBASE DESTROYED ***";(1)"B";(1)"F" L B3=B3-1 : B9=B9-1 V B9>0 K9>T-T0-T9 D~I B` "THAT DOES IT, CAPTAIN!! You are hereby reliev%d of command" ?j "and sentenced to 99 stardates hard labour on CYGNUS 12!!" t DrK H~ "Starfleet reviewing your record to consider a court martial!":D0=0   Z1=X:Z2=Y:A$=" ": TXP < G(Q1,Q2)=K3*100+B3*10+S3:Z(Q1,Q2)=G(Q1,Q2): dHJ: tDC # "Torpedo missed": dHJ: tDC  shield control @ D(7)<0 (1)"BShield control inoperable";(1)"B": tDC @ "Energy available = ";E+S : "Number of units to shields";X 4 X<0 S=X " ": tDC  X": TpG 1 E=E+S-X:S=X:"Deflector Control Room report:" A " 'Shields now at ";(S);" units per your command.'": tDC  damage control  D(6)>=0 tBJ F (1)"BDamage Control report not available";(1)"B": D0=0 tDC %( D3=0: I=1 8: D(I)<0 D3=D3+1 2 I: D3=0 tDC $< :D3=D3+D4: D3>=1 D3=.9000001 >F "Technicians standing by to effect repairs to your ship;" >P "estimated time to repair: ";1E-2*(100*D3);" stardates." 3Z "Will you authorize the repair order (Y/N)";A$ d A$<>"Y" tDC n I=1 8: D(I)<0 D(I)=0 x I:T=T+D3+.1 C : (1)"BDevice state of repair";(1)"B": R1=1 8  - DTP: G2$;:GG2$=Z$,25-(G2$)): GG2$; GG2=(D(R1)*100)*1E-2: GG2;  R1: D0<>0 ThJ tDC  klingons shooting  K3<=0 ; D0<>0 "Starbase shields protect the ENTERPRISE": * "We're being fired on.....":MM=(200) I=1 3: K(I,3)<=0 D@K = H=((K(I,3)/D(1))*(2+(1))):S=S-H:K(I,3)=K(I,3)/(3+(0)) I 10);(1)"F";(1)"B *** ENTERPRISE HIT! ***";(1)"B";(1)"F": T~R @ H;" unit hit on ENTERPRISE from sector ";K(I,1);",";K(I,2)  S<=0 D^K 7 " ": H<20 D@K " (1)>.6 H/S<=.02 D@K +, R1=R(1):D(R1)=D(R1)-H/S-.5*(1): DTP ;6 "Damage Control reports '";G2$;" damaged by the hit'" @ I: J end of game T "It is stardate ";T: DrK f^ : (1)"BThe ENTERPRISE has been destroyed.";(1)"B";" The Federation will be conquered.": DTK h Qr "There were ";K9;" Klingon battle cruisers left at the end of your mission." | MM=(200)  : B9=0 txK U "The Federation is in need of a new starship commander for a similar mission --"  _ "if there is a volunteer, let him or her step forward and enter 'AYE': ";A$: A$="AYE"  Q (1)"BCongratulations, Captain!";(1)"B";" The last Klingon battle cruiser" 4 "menacing the Federation has been destroyed.": ; "Your efficiency rating is ";1000*(K7/(T-T0))^2: tPK 3 short range sensor scan & start-up subroutine MM=(200) ( MM=: I=S1-1 S1+1: J=S2-1 S2+1 : (I+.5)<1 (I+.5)>8 (J+.5)<1 (J+.5)>8 T\L  A$=">!<" " Z1=I:Z2=J: txP: Z3=1 MM=  J: I & MM= TzL 0 D0=0: DNL : D0=1:C$="DOCKED":E=E0:P=P0 6D "Shields dropped for docking purposes":S=0: DbL AN K3>0 C$=(1)+"F"+(1)+"B* RED *"+(1)+"B"+(1)+"F": DbL &X C$="GREEN": E=0 DvL Al :: (1)"B*** Short Range Sensors are out ***";(1)"B":: v I=1 8 $ J=(I-1)*24+1 (I-1)*24+22 3  QQ$=Q$,J,3): " ";QQ$;: J 1 I t^L,t|L,dFL,dPL,dZL,ddL,dnL,dxL   TT=T*10:TT=(TT)*.1 , " Stardate ";TT: TBM , " Condition ";C$: TBM 3 " Quadrant ";Q1;",";Q2: TBM 3 " Sector ";S1;",";S2: TBM . " Photon torpedoes ";(P): TBM 0 " Total energy ";(E+S): TBM . " Shields ";(S): TBM * " Klingons remaining ";(K9);  I:  library computer code  CM1$="GALSTATORBASDIRREG" 8 D(8)<0 (1)"BComputer Disabled";(1)"B": tDC 4* "Computer active and awaiting command";CM$:H8=1 4 > K= 1 6 $H CM$,3)<>CM1$,3*K-2,3) D\M 'R K dJM,DjN,dDN,dHO,T@O,tvM \ K 1f "Functions available from library-computer:" -p " GAL RCD = Record of charted sectors" !z " STATUS = Status report" ' " TOR DATA= Photon torpedo data" , " BASE NAV= Starbase navigation data" 4 " DIR/DIST=Direction and distance calculator" 0 " REG MAP =Galaxy region name map": TjM 2 setup to change cum gal record to galaxy map : H8=0:G5=1:" the galaxy": d|M  cum galactic record " This was a hardcopy routine!  This was the rest of it!  :" "; 8 "Computer record of galaxy for quadrant";Q1;",";Q2  : " 1 2 3 4 5 6 7 8"  I=1 8:  " ";I;: H8=0 TxN 1 J=1 8:" ";: Z(I,J)=0 "***";: TnN $ (Z(I,J)+1000),3); . J: DLN 38Z4=I:Z5=1: djP:J0=(15-.5*(G2$)): J0);G2$; .BZ5=5: djP:J0=(39-.5*(G2$)): J0);G2$; L I V tDC ` status report :j (1)"BStatus Report: ";(1)"B":X$="": K9>1 X$="s" t"Klingon";X$;" left: ";K9 E~"Mission must be completed in ";.1*((T0+T9-T)*10);" stardates." 'X$="s": B9<2 X$="": B9<1 tfN I"The federation is maintaining ";B9;" starbase";X$;" in the galaxy."  tDC 1"Your stupidity has left you on your own in" 7"the galaxy -- you have no starbases left!": TTJ ' torpedo, base nav, d/d calculator  K3<=0 tTG X$="": K3>1 X$="s" 3"From ENTERPRISE to Klingon battle cruiser";X$ %H8=0: I=1 3: K(I,3)<=0 t~O W1=K(I,1):X=K(I,2) C1=S1:A=S2: ThO & "Direction/Distance Calculator:" : "You are at quadrant ";Q1;",";Q2;" sector ";S1;",";S2 ?"Please enter:";: 15);"Initial Co-ordinates (x,y): "C1,A - 15);" Final Co-ordinates (x,y): "W1,X (X=X-A: A=C1-W1: X<0 DxO 2 A<0 tLO < X>0 DPO F A=0 C1=5: DZO PC1=1 Z (A)<=(X) DnO 7d"Direction = ";C1+((((A)-(X))+(A))/(A)): ttO )n"Direction = ";C1+((A)/(X)): ttO x A>0 C1=3: tVO  X<>0 C1=5: DZO C1=7  (A)>=(X) tjO 7"Direction = ";C1+((((X)-(A))+(X))/(X)): ttO -"Direction = ";:CC1=C1+((X)/(A)): CC1 +"Distance = ";(X^2+A^2): H8=1 tDC  I: tDC 9 B3<>0 "From ENTERPRISE to Starbase: ":W1=B4:X=B5  dvN N"Mr. Spock reports, 'Sensors show no starbases in this quadrant.'": tDC  / find empty place in quadrant (for things) ?R1=R(1):R2=R(1):A$=" ":Z1=R1:Z2=R2: txP: Z3=0 dzO  ) insert in string array for quadrant S8=(Z2-.5)*3+(Z1-.5)*24+1 " (A$)<>3 "ERROR": , S8=1 Q$=A$+Q$,189): 6 S8=190 Q$=Q$,189)+A$: "@Q$=Q$,S8-1)+A$+Q$,190-S8): J prints device name 2T R1 D^P,DhP,DrP,D|P,tFP,tPP,tZP,tdP ^G2$="Warp Engines": hG2$="Short Range Sensors": rG2$="Long Range Sensors": |G2$="Phaser Control": G2$="Photon Tubes": G2$="Damage Control": G2$="Shield Control": G2$="Library-Computer": ) string comparison in quadrant array 8Z1=(Z1+.5):Z2=(Z2+.5):S8=(Z2-1)*3+(Z1-1)*24+1:Z3=0  Q$,S8,3)<>A$ Z3=1: . quadrant name in g2$ from z4,z5 (=q1,q2) , call with g5=1 to get region name only < Z5<+4 Z4 d~P,THQ,TRQ,T\Q,TfQ,TpQ,TzQ,DDQ  DNQ G2$="Antares": thQ G2$="Rigel": thQ G2$="Procyon": thQ G2$="Vega": thQ &G2$="Canopus": thQ 0G2$="Altair": thQ :G2$="Sagittarius": thQ DG2$="Pollux": thQ 2N Z4 DXQ,DbQ,DlQ,DvQ,t@Q,tJQ,tTQ,t^Q XG2$="Sirius": thQ bG2$="Deneb": thQ lG2$="Capella": thQ vG2$="Betelgeuse": thQ G2$="Aldebaran": thQ G2$="Regulus": thQ G2$="Arcturus": thQ G2$="Spica" < G5<>1 Z5 t|Q,dFQ,dPQ,dZQ,t|Q,dFQ,dPQ,dZQ  G2$=G2$+" i": G2$=G2$+" ii": G2$=G2$+" iii": G2$=G2$+" iv":  red alert sound # 7:MM=(100): 7:MM=(100): 7   torpedo sound   7    phaser sound * 7 4 > alarm sound H 7 R \ f COMPASS p 75,0);(1)"B3";(1)"B" !z 73,1);(1)"B4 | 2";(1)"B" # 72,2);(1)"B5--+--1";(1)"B" ! 73,3);(1)"B6 | 8";(1)"B"  75,4);(1)"B7";(1)"B"