encountered a text based Star Trek game similar to this one.
I searched for the code to this old game and I found something very close to
the game I remember playing so many years ago.
Code Project had an article about the old game: http://www.codeproject.com/Articles/282 ... -Text-Game
Down at the bottom of the article I found a link to some code: http://newton.freehostia.com/hp/bas/TREKPT.txt
It looks like the original game was written by Mike Mayfield in 1972, perhaps using HP basic.
Comments in the code I found say it was converted to Paper-Tape Basic ( PDP-11 Basic ) by Terry Newton in 2007.
I went ahead and got it running under PureBasic.
If you are a fan of the Goto command you will love this code. Ugh!
Code: Select all
; found this article at codeproject : http://www.codeproject.com/Articles/28228/Star-Trek-Text-Game
; followed code link at bottom to Enhanced Version : http://newton.freehostia.com/hp/bas/TREKPT.txt
; I left comments intact as I found them + adding some of my own.
; I formatted code somewhat to make it more readable.
; Code translated to PureBasic by BasicallyPure 7/2/15
;
;
;
; **** HP BASIC PROGRAM LIBRARY ******************************
;
; STTR1: STAR TREK
;
; 36243 REV B -- 10/73
;
; **** CONTRIBUTED PROGRAM ***********************************
; Shortened To <=72 char lines 3/08
; Converted To paper-tape basic by Terry Newton 9/07
; Strings, PRINT USING And other syntax matters re-coded
; Variable names changed To single letters And arrays...
; A - A$ replacement And general temp use
; C - C$ replacement (status)
; T E P S I J X Y N H left As is
; T0,T9-->T(1),T(2) T7 removed
; D0-->D E0-->K P0-->M H8-->Q R1-->F
; R2-->G W1-->W C1-->B C2-->R
; S1,S2,S3,S9-->S(1),S(2),S(3),S(4)
; Q1,Q2-->Q(1),Q(2)
; B3,B9-->B(1),B(2)
; K3,K7,K9-->P(1),P(2),P(3)
; X1,X2-->X(1),X(2)
; Z1,Z2 And my Z7,Z8,Z9-->V(1),V(2),V(3),V(4),V(5)
; Z3 And original string subs removed Or heavily modified.
; V(6) used To flag calculator use, added WARP UNITS To calc.
; Z And L added For number print subs
; PRINT USING/IMAGE conversions mostly from 9/06 TSBE conversion
; An interesting bug arose.. directions were wrong.. then looked
; at the tsb-e conversion And noticed coords spec'd y,x.. forgot
; about that And had assumed x,y coords so altered the numbers in
; the C(,) Array To compensate. This led To several other changes
; To various display subroutines And docs.. almost wish I hadn't
; done that but I like it better this way (just how it came out).
; Added subs For number printing To display mostly original text.
; Note.. L.R.scan And galaxy Map formatted For paper-tape basic.
; LAST MOD 9/23/07
; **************************************************************
; ***
; *** STAR TREK: BY MIKE MAYFIELD, CENTERLINE ENGINEERING
; ***
; *** TOTAL INTERACTION GAME - ORIG. 20 OCT 1972
; ***
; **************************************************************
OpenConsole("Star Trek")
Macro RND(n) ; macro added by BasicallyPure
; produce a random float number (0 < number < 1)
((Random(2147483645)+1) / 2147483647.0)
EndMacro
For I=1 To 20
PrintN("")
Next I
Print(" STAR TREK ")
PrintN("")
PrintN("")
PrintN("")
Print("ENTER 1 OR 2 FOR INSTRUCTIONS (ENTER 2 TO PAGE) ");
A = Val(Input())
If A<>1 And A<>2 : Goto _210 : EndIf
Gosub _5820
; this useless block removed by BasicallyPure
; randomize query To mix it up, Not in original
;210 PRINT
;211 PRINT "ENTER SEED NUMBER ";
;212 INPUT A
;213 LET A=Int(Abs(A))
;215 PRINT "INITIALIZING..."
;220 For I=0 To A
;222 LET J=RND(1)
;225 Next I
_210:
PrintN("")
PrintN("INITIALIZING...")
_230:
; ***** PROGRAM STARTS HERE *****
PrintN("")
Dim G(8,8) : Dim C(9,2) : Dim K(3,3) : Dim N(3) : Dim Z(8,8)
Dim A(8,8) : Dim D(9) : Dim T(2) : Dim S.f(4) : Dim Q(2)
Dim B(2) : Dim P(3) : Dim X.f(2) : Dim V.f(6)
T=Int(RND(1)*20+20)*100 ;stardate
T(1)=T ;remember begining stardate
T(2)=30 ;game duration
D=0
E=3000
K=E
P=10
M=P
S(4)=200
Q=0
S=0
;DEF FND(D)=Sqr((K[I,1]-S[1])^2+(K[I,2]-S[2])^2)
;function to macro conversion by BasicallyPure
;find distance Klingon to Enterprise
Macro FND(D) : Sqr(Pow((K(I,1)-S(1)),2)+Pow((K(I,2)-S(2)),2)) : EndMacro
;starting location
Q(1)= Int(RND(1)*8+1) ;Enterprise quadrant x
Q(2)= Int(RND(1)*8+1) ;Enterprise quadrant y
S(1)= Int(RND(1)*8+1) ;Enterprise sector x
S(2)= Int(RND(1)*8+1) ;Enterprise sector y
; C Array numbers changed For X,Y notation/display
; dir 1 = X+1,Y right
C(1,1)=1
C(1,2)=0
; dir 2 = X+1,Y-1 right And up
C(2,1)=1
C(2,2)=-1
; dir 3 = X, Y-1 up
C(3,1)=0
C(3,2)=-1
; dir 4 = X-1,Y-1 left And up
C(4,1)=-1
C(4,2)=-1
; dir 5 = X-1,Y left
C(5,1)=-1
C(5,2)=0
; dir 6 = X-1,Y+1 left And down
C(6,1)=-1
C(6,2)=1
; dir 7 = X,Y+1 down
C(7,1)=0
C(7,2)=1
; dir 8 = X+1,Y+1 right And down
C(8,1)=1
C(8,2)=1
; dir 9 = same As dir 1
C(9,1)=1
C(9,2)=0
;MAT D=ZER ;<------------- WHAT IS THIS ???????????????????????????????????????????
FreeArray(D()) : Dim D(9) ; Added by BasicallyPure, a guess, seems to work
_490:
B(2)=0 ;starbase total
P(3)=0 ;Klingon total
;populate galaxy
For I=1 To 8
For J=1 To 8
F = Random(100) ;assign probability of Klingons
If F > 98 : Goto _580 : EndIf ;3
If F > 95 : Goto _610 : EndIf ;2
If F > 80 : Goto _640 : EndIf ;1
P(1)=0 ;0 Klingons this quadrant
Goto _660
_580:
P(1)=3 ;quadrant gets 3 Klingons
P(3)=P(3)+3 ;add 3 Klingons to total
Goto _660
_610:
P(1)=2 ;quadrant gets 2 Klingons
P(3)=P(3)+2 ;add 2 Klingons to total
Goto _660
_640:
P(1)=1 ;quadrant gets 1 Klingon
P(3)=P(3)+1 ;add 1 Klingon to total
_660:
F = Random(100) ;assign probability of starbase
If F > 96 : Goto _700 : EndIf
B(1)=0 ;no starbase this quadrant
Goto _720
_700:
B(1)=1 ;starbase this quadrant
B(2)=B(2)+1 ;add 1 starbase to total
_720:
S(3)=Int(RND(1)*8+1) ;assign number of stars this quadrant
G(I,J)=P(1)*100+B(1)*10+S(3) ;hundreds=Klingons, tens=starbase, ones=stars
Z(I,J)=0 ;computer record of galaxy starts empty
Next J
Next I
P(2)=P(3)
If B(2) <= 0 Or P(3) <= 0 : Goto _490 : EndIf
; mod For number print sub And plurality
Print("YOU MUST DESTROY ");
Z=P(3)
Gosub _9400
Print(" KINGONS IN ");
Z=T(2)
Gosub _9400
Print(" STARDATES WITH ");
Z=B(2)
Gosub _9400
Print(" STARBASE");
If B(2)=1 : Goto _793 : EndIf
Print("S");
_793:
PrintN("")
PrintN("")
_810:
P(1)=0
B(1)=0
S(3)=0
If Q(1)<1 Or Q(1)>8 Or Q(2)<1 Or Q(2)>8 : Goto _920 : EndIf
X.f=G(Q(1),Q(2))*1.00000E-02
P(1)=Int(X)
B(1)=Int((X-P(1))*10)
S(3)=G(Q(1),Q(2))-Int(G(Q(1),Q(2))*0.1)*10
If P(1)=0 : Goto _910 : EndIf
If S>200 : Goto _910 : EndIf
PrintN("COMBAT AREA CONDITION RED")
PrintN(" SHIELDS DANGEROUSLY LOW")
_910:
;MAT K=ZER ;<------- WHAT IS THIS ???????????????????????????????????????
FreeArray(K()) : Dim K(3,3) ; Added by BasicallyPure
_920:
For I=1 To 3
K(I,3)=0
Next I
; string arrays replaced With A(x,y)
; 0=" "
; 1="<*>"
; 2="+++"
; 3=">!<"
; 4=" * "
;MAT A=ZER ;<----- WHAT IS THIS ??????????????????????????????????????????
FreeArray(A()) : Dim A(8,8) ; Added by BasicallyPure , clear sector of old stars
A(Int(S(1)+0.5),Int(S(2)+0.5))=1
For I=1 To P(1)
Gosub _5380
A(F,G)=2
K(I,1)=F
K(I,2)=G
K(I,3)=S(4)
Next I
For I=1 To B(1)
Gosub _5380
A(F,G)=3
Next I
For I=1 To S(3)
Gosub _5380
A(F,G)=4
Next I
_1260:
Gosub _4120
_1270:
Print("COMMAND? ");
A = Val(Input())
If A=0 : Goto _1410 : EndIf
If A=1 : Goto _1260 : EndIf
If A=2 : Goto _2330 : EndIf
If A=3 : Goto _2530 : EndIf
If A=4 : Goto _2800 : EndIf
If A=5 : Goto _3460 : EndIf
If A=6 : Goto _3560 : EndIf
If A=7 : Goto _4630 : EndIf
Print(#CRLF$)
PrintN(" 0 = SET COURSE")
PrintN(" 1 = SHORT RANGE SENSOR SCAN")
PrintN(" 2 = LONG RANGE SENSOR SCAN")
PrintN(" 3 = FIRE PHASERS")
PrintN(" 4 = FIRE PHOTON TORPEDOES")
PrintN(" 5 = SHIELD CONTROL")
PrintN(" 6 = DAMAGE CONTROL REPORT")
PrintN(" 7 = CALL ON LIBRARY COMPUTER")
PrintN("")
Goto _1270
_1410:
Print("COURSE (1-9) ");
B.f = ValF(Input())
If B=0 : Goto _1270 : EndIf
If B<1 Or B >= 9 : Goto _1410 : EndIf
Print("WARP FACTOR (0-8) ");
W.f = ValF(Input())
If W<0 Or W>8 : Goto _1410 : EndIf
If D(1) >= 0 Or W <= 0.2 : Goto _1510 : EndIf
PrintN("WARP ENGINES ARE DAMAGED, MAXIMUM SPEED = WARP 0.2")
Goto _1410
_1510:
If P(1) <= 0 : Goto _1560 : EndIf
Gosub _3790
If P(1) <= 0 : Goto _1560 : EndIf
If S<0 : Goto _4000 : EndIf
Goto _1610
_1560:
If E>0 : Goto _1610 : EndIf
If S<1 : Goto _3920 : EndIf
; mod For number print sub
Print("YOU HAVE ");
Z=E
Gosub _9400
Print(" UNITS OF ENERGY")
Print("SUGGEST YOU GET SOME FROM YOUR SHIELDS WHICH HAVE "+Str(S))
Print("UNITS LEFT")
Goto _1270
_1610:
For I=1 To 8
If D(I) >= 0 : Goto _1640 : EndIf
D(I)=D(I)+1
_1640:
Next I
If RND(1)>0.2 : Goto _1810 : EndIf
F=Int(RND(1)*8+1)
If RND(1) >= 0.5 : Goto _1750 : EndIf
D(F)=D(F)-(RND(1)*5+1)
PrintN("")
Print("DAMAGE CONTROL REPORT: ");
Gosub _5610
PrintN(" DAMAGED")
PrintN("")
Goto _1810
_1750:
D(F)=D(F)+(RND(1)*5+1)
PrintN("")
Print("DAMAGE CONTROL REPORT: ");
Gosub _5610
PrintN(" STATE OF REPAIR IMPROVED")
PrintN("")
_1810:
N=Int(W*8)
; string " " insertion removed
A(Int(S(1)+0.5),Int(S(2)+0.5))=0
X=S(1)
Y.f=S(2)
R=Int(B)
X(1)=C(R,1)+(C(R+1,1)-C(R,1))*(B-R)
X(2)=C(R,2)+(C(R+1,2)-C(R,2))*(B-R)
For I=1 To N
S(1)=S(1)+X(1)
S(2)=S(2)+X(2)
If S(1)<0.5 Or S(1) >= 8.5 Or S(2)<0.5 Or S(2) >= 8.5 : Goto _2170 : EndIf ;jumps out of loop :(
; string " " comparison removed
If A(Int(S(1)+0.5),Int(S(2)+0.5))=0 : Goto _2070 : EndIf
; print using removed
Print("WARP ENGINES SHUTDOWN AT SECTOR");
V(4)=S(1)
V(5)=S(2)
Gosub _9000
PrintN("DUE TO BAD NAVIGATION")
S(1)=S(1)-X(1)
S(2)=S(2)-X(2)
Goto _2080 ;jumps out of loop :(
_2070:
Next I
_2080:
; string "<*>" insertion removed
S(1)=Int(S(1)+0.5)
S(2)=Int(S(2)+0.5)
A(Int(S(1)),Int(S(2)))=1
E=E-N+5
If W<1 : Goto _2150 : EndIf
T=T+1
_2150:
If T>T(1)+T(2) : Goto _3970 : EndIf ;time expired
Goto _1260
_2170:
X=Q(1)*8+X+X(1)*N
Y=Q(2)*8+Y+X(2)*N
Q(1)=Int(X/8)
Q(2)=Int(Y/8)
S(1)=Int(X-Q(1)*8+0.5)
S(2)=Int(Y-Q(2)*8+0.5)
If S(1)<>0 : Goto _2260 : EndIf
Q(1)=Q(1)-1
S(1)=8
_2260:
If S(2)<>0 : Goto _2290 : EndIf
Q(2)=Q(2)-1
S(2)=8
_2290:
T=T+1
E=E-N+5
If T>T(1)+T(2) : Goto _3970 : EndIf
Goto _810
_2330:
If D(3) >= 0 : Goto _2370 : EndIf
PrintN("LONG RANGE SENSORS ARE INOPERABLE")
Goto _1270
; print using/image converted
_2370:
Print("LONG RANGE SENSOR SCAN FOR QUADRANT");
V(4)=Q(1)
V(5)=Q(2)
Gosub _9000
PrintN("")
; converted To X,Y display
PrintN("-------------------")
For J=Q(2)-1 To Q(2)+1
;MAT N=ZER ;<------ WHAT IS THIS ??????????????????????????????????????????????
FreeArray(N()) : Dim N(3) ; Added by BasicallyPure, a guess, seems to work
For I=Q(1)-1 To Q(1)+1
If I<1 Or I>8 Or J<1 Or J>8 : Goto _2460 : EndIf
N(I-Q(1)+2)=G(I,J)
If D(7)<0 : Goto _2460 : EndIf
Z(I,J)=G(I,J)
_2460:
Next I
;2470 PRINT N[1]":"N[2]":"N[3]
;text for long range scan, formatted by BasicallyPure
PrintN(RSet(Str(N(1)),3,"0")+" : "+RSet(Str(N(2)),3,"0")+" : "+RSet(Str(N(3)),3,"0"))
PrintN("-------------------")
Next J
Goto _1270
_2530:
If P(1) <= 0 : Goto _3670 : EndIf
If D(4) >= 0 : Goto _2570 : EndIf
PrintN("PHASER CONTROL IS DISABLED")
Goto _1270
_2570:
If D(7) >= 0 : Goto _2590 : EndIf
PrintN(" COMPUTER FAILURE HAMPERS ACCURACY")
_2590:
PrintN("PHASERS LOCKED ON TARGET. ENERGY AVAILABLE = "+Str(E))
Print("NUMBER OF UNITS TO FIRE ");
X = Val(Input())
If X <= 0 : Goto _1270 : EndIf
If E-X<0 : Goto _2570 : EndIf
E=E-X ;subtract phaser energy used
Gosub _3790
If D(7) >= 0 : Goto _2680 : EndIf
X=X*RND(1) ;scale down the phaser energy
_2680:
For I=1 To 3
Delay(1000) ;added by BasicallyPure
If K(I,3) <= 0 : Goto _2770 : EndIf
;calculate phaser damage [H]
H=(X/P(1)/FND(0))*(2*RND(1)) ;X[phaserEnergy] / P(1)[num Klingons] / FND(0)[distance]
K(I,3)=K(I,3)-H
PrintN("") ;added by BasicallyPure
Z=H ; print using/image converted
Gosub _9400
Print(" UNIT HIT ON KLINGON AT SECTOR ");
V(4)=K(I,1) ;sector x
V(5)=K(I,2) ;sector y
Gosub _9000
;Print(Space(41)+"(");
PrintN("") : Print(Space(27)+"("); changed by BasicallyPure
Z=K(I,3)
Gosub _9400
PrintN(" LEFT)")
If K(I,3)>0 : Goto _2770 : EndIf
Gosub _3690 ;Klingon destroyed
If P(3) <= 0 : Goto _4040 : EndIf
_2770:
Next I
If E<0 : Goto _4000 : EndIf
Goto _1270
_2800:
If D(5) >= 0 : Goto _2830 : EndIf
PrintN("PHOTON TUBES ARE NOT OPERATIONAL")
Goto _1270
_2830:
If P>0 : Goto _2860 : EndIf
PrintN("ALL PHOTON TORPEDOES EXPENDED")
Goto _1270
_2860:
Print("TORPEDO COURSE (1-9) ");
B = ValF(Input())
If B=0 : Goto _1270 : EndIf
If B<1 Or B >= 9 : Goto _2860 : EndIf
R=Int(B)
X(1)=C(R,1)+(C(R+1,1)-C(R,1))*(B-R)
X(2)=C(R,2)+(C(R+1,2)-C(R,2))*(B-R)
X=S(1)
Y=S(2)
P=P-1
PrintN("TORPEDO TRACK:")
_2960:
Delay(1000) ;added by BasicallyPure
X=X+X(1)
Y=Y+X(2)
If X<0.5 Or X >= 8.5 Or Y<0.5 Or Y >= 8.5 : Goto _3420 : EndIf
; print using/image converted
V(4)=X
V(5)=Y
Gosub _9000
PrintN("")
; string " " comparison removed
If A(Int(X+0.5),Int(Y+0.5))<>0 : Goto _3070 : EndIf
Goto _2960
_3070:
; string "+++" comparison removed
If A(Int(X+0.5),Int(Y+0.5))<>2 : Goto _3220 : EndIf
PrintN("*** KLINGON DESTROYED ***")
P(1)=P(1)-1
P(3)=P(3)-1
If P(3) <= 0 : Goto _4040 : EndIf
For I=1 To 3
If Int(X+0.5)<>K(I,1) : Goto _3190 : EndIf
If Int(Y+0.5)= K(I,2) : Goto _3200 : EndIf
_3190:
Next I
_3200:
K(I,3)=0
Goto _3360
_3220:
; string " * " comparison removed
If A(Int(X+0.5),Int(Y+0.5))<>4 : Goto _3290 : EndIf
PrintN("YOU CAN'T DESTROY STARS SILLY")
Goto _3420
; string ">!<" comparison removed
_3290:
If A(Int(X+0.5),Int(Y+0.5))<>3 : Goto _2960 : EndIf
PrintN("*** STAR BASE DESTROYED *** .......CONGRATULATIONS")
B(1)=B(1)-1
_3360:
; string " " insertion removed
V(1)=Int(X+0.5)
V(2)=Int(Y+0.5)
A(Int(V(1)),Int(V(2)))=0
G(Q(1),Q(2))=P(1)*100+B(1)*10+S(3)
Goto _3430
_3420:
PrintN("TORPEDO MISSED")
_3430:
Gosub _3790
If E<0 : Goto _4000 : EndIf
Goto _1270
_3460:
If D(7) >= 0 : Goto _3490 : EndIf
PrintN("SHIELD CONTROL IS NON-OPERATIONAL")
Goto _1270
; added Return
_3490:
PrintN("ENERGY AVAILABLE = "+Str(E+S))
Print("NUMBER OF UNITS TO SHIELDS ");
X = Val(Input())
If X <= 0 : Goto _1270 : EndIf
If E+S-X<0 : Goto _3490 : EndIf
E=E+S-X
S=X
Goto _1270
_3560:
If D(6) >= 0 : Goto _3590 : EndIf
PrintN("DAMAGE CONTROL REPORT IS NOT AVAILABLE")
Goto _1270
_3590:
PrintN("")
PrintN("DEVICE STATE OF REPAIR")
For F=1 To 8
Gosub _5610
PrintN(" "+Str(D(F)))
Next F
PrintN("")
Goto _1270
_3670:
PrintN("SHORT RANGE SENSORS REPORT NO KLINGONS IN THIS QUANDRANT")
Goto _1270
_3690: ;subroutine
; print using/image converted, changed text slightly
Print("*** KLINGON AT SECTOR ");
V(4)=K(I,1)
V(5)=K(I,2)
Gosub _9000
PrintN("DESTROYED ***")
P(1)=P(1)-1
P(3)=P(3)-1
; string " " insertion removed
A(Int(K(I,1)+0.5),Int(K(I,2)+0.5))=0
G(Q(1),Q(2))=P(1)*100+B(1)*10+S(3)
Return
_3790: ;subroutine
If C<>3 : Goto _3820 : EndIf
PrintN("STAR BASE SHIELDS PROTECT THE ENTERPRISE")
Return
_3820:
If P(1) <= 0 : Goto _3910 : EndIf
For I=1 To 3
Delay(1000) ;added by BasicallyPure
If K(I,3) <= 0 : Goto _3900 : EndIf
H=(K(I,3)/FND(0))*(2*RND(1))
S=S-H
PrintN("") ;added by BasicallyPure
; print using/image converted
Z=H
Gosub _9400
Print(" UNIT HIT ON ENTERPRISE AT SECTOR ");
V(4)=K(I,1)
V(5)=K(I,2)
Gosub _9000
;Print(Space(41)+"(");
PrintN("") : Print(Space(30)+"("); changed by BasicallyPure
Z=S
Gosub _9400
PrintN(" LEFT)")
If S<0 : Goto _4000 : EndIf
_3900:
Next I
_3910:
Return
_3920:
Print("THE ENTERPRISE IS DEAD IN SPACE. IF YOU SURVIVE ALL");
PrintN(" IMPENDING")
PrintN("ATTACK YOU WILL BE DEMOTED TO THE RANK OF PRIVATE")
_3940:
If P(1) <= 0 : Goto _4020 : EndIf
Gosub _3790
Goto _3940
_3970:
PrintN("")
PrintN("IT IS STARDATE "+Str(T))
Goto _4020
_4000:
PrintN("")
Print("THE ENTERPRISE HAS BEEN DESTROYED. THE FEDERATION WILL");
PrintN(" BE CONQUERED")
; mod For number print
_4020:
Print("THERE ARE STILL ");
Z=P(3)
Gosub _9400
PrintN(" KLINGON BATTLE CRUISERS")
Goto _230 ;restart game
_4040:
PrintN("")
Print("THE LAST KLIGON BATTLE CRUISER IN THE GALAXY HAS BEEN");
PrintN(" DESTROYED")
PrintN("THE FEDERATION HAS BEEN SAVED !!!")
PrintN("")
;4080 PRINT "YOUR EFFICIENCY RATING ="((P[2]/(T-T[1]))*1000)
;efficiency formula changed by BasicallyPure 7/2/15
;efficiency = 100 * KlingonsDestroyed / ElapsedStardates
PrintN("YOUR EFFICIENCY RATING = "+StrF( 100.0*P(2)/(T-T(1)),1 ))
Goto _230
_4120: ;subroutine
For I=S(1)-1 To S(1)+1
For J=S(2)-1 To S(2)+1
If I<1 Or I>8 Or J<1 Or J>8 : Goto _4200 : EndIf
; string ">!<" comparison removed
If A(Int(I+0.5),Int(J+0.5))=3 : Goto _4240 : EndIf ;jumps out of for/next loop :(
_4200:
Next J
Next I
D=0
Goto _4310
_4240:
D=1
; docked
C=3
E=3000
P=10
PrintN("SHIELDS DROPPED FOR DOCKING PURPOSES")
S=0
Goto _4380
_4310:
If P(1)> 0 : Goto _4350 : EndIf
If E<K*0.1 : Goto _4370 : EndIf
; green
C=0
Goto _4380
; red
_4350:
C=2
Goto _4380
; yellow
_4370:
C=1
_4380:
If D(2) >= 0 : Goto _4430 : EndIf
PrintN("")
Print("*** SHORT RANGE SENSORS ARE OUT ***")
PrintN("")
Goto _4530
; this section has been compely rewritten
; sub at 9000 prints coordinates As in other print using conv.
; sub at 9200 prints Next line of D(x,y) replacing strings
; V(3) indexes Y line, start at 0 (9200 increments first)
; changed some of the text ordering And formatting here
_4430:
PrintN("-=--=--=--=--=--=--=--=-")
V(3)=0
Gosub _9200
PrintN("")
Gosub _9200
PrintN(" STARDATE "+Str(T))
Gosub _9200
Print(" CONDITION ");
If C=1 : Goto _4467 : EndIf
If C=2 : Goto _4469 : EndIf
If C=3 : Goto _4471 : EndIf
PrintN("GREEN")
Goto _4472
_4467:
PrintN("YELLOW")
Goto _4472
_4469:
PrintN("RED")
Goto _4472
_4471:
PrintN("DOCKED")
_4472:
Gosub _9200
Print(" QUADRANT ");
V(4)=Q(1)
V(5)=Q(2)
Gosub _9000
PrintN("")
Gosub _9200
Print(" SECTOR ");
V(4)=S(1)
V(5)=S(2)
Gosub _9000
PrintN("")
Gosub _9200
PrintN(" ENERGY "+Str(Int(E)))
Gosub _9200
PrintN(" SHIELDS "+Str(Int(S)))
Gosub _9200
PrintN(" PHOTON TORPEDOES "+Str(P))
PrintN("-=--=--=--=--=--=--=--=-")
_4530:
Return
; ................. computer......................
_4630:
If D(8) >= 0 : Goto _4660 : EndIf
PrintN("COMPUTER DISABLED")
Goto _1270
_4660:
Print("COMPUTER ACTIVE AND AWAITING COMMAND ");
A = Val(Input())
; added, calc mode off
V(6)=0
If A=0 : Goto _4740 : EndIf
If A=1 : Goto _4830 : EndIf
If A=2 : Goto _4880 : EndIf
PrintN("")
PrintN("FUNCTIONS AVAILABLE FROM COMPUTER")
PrintN(" 0 = CUMULATIVE GALATIC RECORD")
PrintN(" 1 = STATUS REPORT")
PrintN(" 2 = PHOTON TORPEDO DATA")
Goto _4660
_4740: ; print using/image statements converted
Print("COMPUTER RECORD OF GALAXY FOR QUADRANT");
V(4)=Q(1)
V(5)=Q(2)
Gosub _9000
PrintN("")
; converted To x,y Array specs
PrintN("----- ----- ----- ----- ----- ----- ----- -----")
For I=1 To 8 ; galaxy text formatted by BasicallyPure
PrintN(" "+RSet(Str(Z(1,I)),3,"0")+" "+
" "+RSet(Str(Z(2,I)),3,"0")+" "+
" "+RSet(Str(Z(3,I)),3,"0")+" "+
" "+RSet(Str(Z(4,I)),3,"0")+" "+
" "+RSet(Str(Z(5,I)),3,"0")+" "+
" "+RSet(Str(Z(6,I)),3,"0")+" "+
" "+RSet(Str(Z(7,I)),3,"0")+" "+
" "+RSet(Str(Z(8,I)),3,"0"))
PrintN("----- ----- ----- ----- ----- ----- ----- -----")
Next I
Goto _1270
_4830:
PrintN("")
PrintN("STATUS REPORT")
PrintN("")
PrintN("NUMBER OF KLINGONS LEFT = "+Str(P(3)))
PrintN("NUMBER OF STARDATES LEFT = "+Str((T(1)+T(2))-T))
PrintN("NUMBER OF STARBASES LEFT = "+Str(B(2)))
Goto _3560
_4880:
; PRINT removed
Q=0
For I=1 To 3
If K(I,3) <= 0 : Goto _5260 : EndIf
; reversed For x/y mods
A=S(1)
B=S(2)
X=K(I,1)
W=K(I,2)
Goto _5010
_4970: ; print using/image converted
Print("YOU ARE AT QUADRANT");
V(4)=Q(1)
V(5)=Q(2)
Gosub _9000
Print("SECTOR");
V(4)=S(1)
V(5)=S(2)
Gosub _9000
PrintN("")
PrintN("ENTER 4 COMMA SEPARATED VALUES")
Print("SHIP'S & TARGET'S COORDINATES ARE ?");
; reversed For x,y entry, int mod
;INPUT A,B,X,W ;<---- adapted to parse input string by BasicallyPure
I$ = Input()
A = 0 : B = 0 : X = 0 : W = 0
A = Val(StringField(I$,1,","))
B = Val(StringField(I$,2,","))
X = Val(StringField(I$,3,","))
W = Val(StringField(I$,4,","))
_5010:
X=Int(X-A+0.5)
A=Int(B-W+0.5)
If X<0 : Goto _5130 : EndIf
If A<0 : Goto _5190 : EndIf
If X>0 : Goto _5070 : EndIf
If A=0 : Goto _5150 : EndIf
_5070:
B=1
_5080:
If Abs(A) <= Abs(X) : Goto _5110 : EndIf
PrintN("DIRECTION = "+StrF(B+(((Abs(A)-Abs(X))+Abs(A))/Abs(A)),2))
Goto _5240
_5110:
PrintN("DIRECTION = "+StrF(B+(Abs(A)/Abs(X)),2))
Goto _5240
_5130:
If A>0 : Goto _5170 : EndIf
If X=0 : Goto _5190 : EndIf
_5150:
B=5
Goto _5080
_5170:
B=3
Goto _5200
_5190:
B=7
_5200:
If Abs(A) >= Abs(X) : Goto _5230 : EndIf
PrintN("DIRECTION = "+StrF(B+(((Abs(X)-Abs(A))+Abs(X))/Abs(X)),2))
Goto _5240
_5230:
PrintN("DIRECTION = "+StrF(B+(Abs(X)/Abs(A)),2))
_5240:
Print("DISTANCE = "+StrF((Sqr(X*X+A*A)),2));
; added warp units To aid With navigation
If V(6)<>1 : Goto _5253 : EndIf
L=Abs(X)
If L>Abs(A) : Goto _5246 : EndIf
L=Abs(A)
_5246:
Print(Space(28)+"(");
Print(Str(L))
Print(" WARP UNIT");
If L=1 : Goto _5251 : EndIf
Print("S");
_5251:
Print(")");
_5253:
PrintN("")
If Q=1 : Goto _5320 : EndIf
_5260:
Next I
Q=0
Print("ENTER 1 TO USE THE CALCULATOR ");
V(6) = Val(Input())
If V(6)=1 : Goto _4970 : EndIf
_5320:
Goto _1270
_5380: ;subroutine
; find-empty-location sub, strings removed
F=Int(RND(1)*8+1)
G=Int(RND(1)*8+1)
If A(F,G)<>0 : Goto _5380 : EndIf
Return
_5610: ;subroutine
; **** PRINTS DEVICE NAME FROM Array *****
; recoded To remove strings
If F=1 : Goto _5635 : EndIf
If F=2 : Goto _5640 : EndIf
If F=3 : Goto _5645 : EndIf
If F=4 : Goto _5650 : EndIf
If F=5 : Goto _5655 : EndIf
If F=6 : Goto _5660 : EndIf
If F=7 : Goto _5665 : EndIf
Print("COMPUTER") : Return
_5635: : Print("WARP ENGINES") : Return
_5640: : Print("S.R. SENSORS") : Return
_5645: : Print("L.R. SENSORS") : Return
_5650: : Print("PHASER CNTRL") : Return
_5655: : Print("PHOTON TUBES") : Return
_5660: : Print("DAMAGE CNTRL") : Return
_5665: : Print("SHIELD CNTRL")
Return
_5820: ;subroutine
; instructions modified To notify of use of X,Y coordinates
; If A=2 then ENTER # prompts inserted To avoid scrolling
; messed With the course graphic.
PrintN("")
PrintN("")
PrintN(" INSTRUCTIONS:")
PrintN("")
PrintN("<*> = ENTERPRISE")
PrintN("+++ = KLINGON")
PrintN(">!< = STARBASE")
PrintN(" * = STAR")
PrintN("")
PrintN("COMMAND 0 = WARP ENGINE CONTROL")
PrintN(" 'COURSE IS IN A CIRCULAR NUMERICAL 4 3 2")
PrintN(" VECTOR ARRANGEMENT AS SHOWN. `. : .'")
PrintN(" INTERGER AND REAL VALUES MAY BE `.:.'")
PrintN(" USED. THEREFORE COURSE 1.5 IS 5---<*>---1")
PrintN(" HALF WAY BETWEEN 1 AND 2. .':`.")
PrintN(" .' : `.")
PrintN(" A VECTOR OF 9 IS UNDEFINED, BUT 6 7 8")
PrintN(" VALUES MAY APPROACH 9.")
PrintN(" COURSE")
PrintN(" ONE 'WARP FACTOR' IS THE SIZE OF")
PrintN(" ONE QUADRANT. THEREFORE TO GET FROM")
PrintN(" QUADRANT 5,6 TO 5,5 YOU WOULD USE COURSE 3, WARP")
PrintN(" FACTOR 1. COORDINATES ARE SPECIFIED USING X,Y NOTATION")
PrintN(" WITH X 1-8 FROM LEFT-RIGHT AND Y 1-8 FROM TOP-BOTTOM.")
If A<>2 : Goto _6009 : EndIf
PrintN("")
Print("ENTER A NUMBER TO CONTINUE... ");
I = Val(Input())
PrintN("")
_6009:
PrintN("")
PrintN("COMMAND 1 = SHORT RANGE SENSOR SCAN")
PrintN(" PRINTS THE QUADRANT YOU ARE CURRENTLY IN, INCLUDING")
PrintN(" STARS, KLINGONS, STARBASES, AND THE ENTERPRISE; ALONG")
PrintN(" WITH OTHER PERTINATE INFORMATION.")
PrintN("")
PrintN("COMMAND 2 = LONG RANGE SENSOR SCAN")
PrintN(" SHOWS CONDITIONS IN SPACE FOR ONE QUADRANT ON EACH SIDE")
PrintN(" OF THE ENTERPRISE IN THE MIDDLE OF THE SCAN. THE SCAN")
PrintN(" IS CODED IN THE FORM XXX, WHERE THE UNITS DIGIT IS THE")
PrintN(" NUMBER OF STARS, THE TENS DIGIT IS THE NUMBER OF STAR-")
PrintN(" BASES, THE HUNDREDS DIGIT IS THE NUMBER OF KLINGONS.")
PrintN("")
PrintN("COMMAND 3 = PHASER CONTROL")
PrintN(" ALLOWS YOU TO DESTROY THE KLINGONS BY HITTING HIM WITH")
PrintN(" SUITABLY LARGE NUMBERS OF ENERGY UNITS TO DEPLETE HIS ")
PrintN(" SHIELD POWER. KEEP IN MIND THAT WHEN YOU SHOOT AT")
PrintN(" HIM, HE GONNA DO IT TO YOU TOO.")
If A<>2 : Goto _6159 : EndIf
For I=1 To 5
PrintN("")
Next I
Print("ENTER A NUMBER TO CONTINUE... ");
I = Val(Input())
PrintN("")
_6159:
PrintN("")
PrintN("COMMAND 4 = PHOTON TORPEDO CONTROL")
PrintN(" COURSE IS THE SAME AS USED IN WARP ENGINE CONTROL")
PrintN(" IF YOU HIT THE KLINGON, HE IS DESTROYED AND CANNOT FIRE")
PrintN(" BACK AT YOU. IF YOU MISS, HE WILL SHOOT HIS PHASERS AT")
PrintN(" YOU.")
PrintN(" NOTE: THE LIBRARY COMPUTER (COMMAND 7) HAS AN OPTION")
PrintN(" TO COMPUTE TORPEDO TRAJECTORY FOR YOU (OPTION 2).")
PrintN("")
PrintN("COMMAND 5 = SHIELD CONTROL")
PrintN(" DEFINES NUMBER OF ENERGY UNITS TO ASSIGN TO SHIELDS")
PrintN(" ENERGY IS TAKEN FROM TOTAL SHIP'S ENERGY.")
PrintN("")
PrintN("COMMAND 6 = DAMAGE CONTROL REPORT")
Print(" GIVES STATE OF REPAIRS OF ALL DEVICES.");
PrintN(" A STATE OF REPAIR")
PrintN(" LESS THAN ZERO SHOWS THAT THAT DEVICE IS TEMPORARALY")
PrintN(" DAMAGED.")
If A<>2 : Goto _6299 : EndIf
For I=1 To 6
PrintN("")
Next I
Print("ENTER A NUMBER TO CONTINUE... ");
I = Val(Input())
PrintN("")
_6299:
PrintN("")
PrintN("COMMAND 7 = LIBRARY COMPUTER")
PrintN(" THE LIBRARY COMPUTER CONTAINS THREE OPTIONS:")
PrintN(" OPTION 0 = CUMULATIVE GALACTIC RECORD")
PrintN(" SHOWS COMPUTER MEMORY OF THE RESULTS OF ALL PREVIOUS")
PrintN(" LONG RANGE SENSOR SCANS")
PrintN(" OPTION 1 = STATUS REPORT")
PrintN(" SHOWS NUMBER OF KLINGONS, STARDATESC AND STARBASES")
PrintN(" LEFT.")
PrintN(" OPTION 2 = PHOTON TORPEDO DATA")
PrintN(" GIVES TRAJECTORY AND DISTANCE BETWEEN THE ENTERPRISE")
PrintN(" AND ALL KLINGONS IN YOUR QUADRANT")
If A<>2 : Goto _6408 : EndIf
For I=1 To 9
PrintN("")
Next I
_6408:
PrintN("")
Return
_9000: ;subroutine
; sub To help convert PRINT USING, displays " x,y "
; coordinates (V(4),V(5))
Print(" ");
L=Int(V(4)+0.5)
Gosub _9700
Print(",");
L=Int(V(5)+0.5)
Gosub _9700
Print(" ");
Return
_9200: ;subroutine
; print display line from A(x,y)
; y coord spec'd by V(3), inc;ented
V(3)=V(3)+1
For I=1 To 8
A=A(I,Int(V(3)))
If A=1 : Goto _9240 : EndIf
If A=2 : Goto _9242 : EndIf
If A=3 : Goto _9244 : EndIf
If A=4 : Goto _9246 : EndIf
Print(" ");
Goto _9250
_9240:
Print("<*>");
Goto _9250
_9242:
Print("+++");
Goto _9250
_9244:
Print(">!<");
Goto _9250
_9246:
Print(" * ");
_9250:
Next I
Return
_9400: ;subroutine
; Integer print subroutine
; up To 4 digits -9999 To 9999, no spaces
; Number To print in Z, L used For digit
If Z >= 0 : Goto _9420 : EndIf
Print("-");
_9420:
Z=Abs(Z)
Z=Int(Z)
If Z<10 : Goto _9560 : EndIf
If Z<100 : Goto _9530 : EndIf
If Z<1000 : Goto _9500 : EndIf
L=Int(Z/1000)
Z=Z-L*1000
Gosub _9700
_9500:
L=Int(Z/100)
Z=Z-L*100
Gosub _9700
_9530:
L=Int(Z/10)
Z=Z-L*10
Gosub _9700
_9560:
L=Z
Gosub _9700
Return
_9700: ;subroutine
; Digit print subroutine, digit in L
If L=1 : Goto _9810 : EndIf
If L=2 : Goto _9830 : EndIf
If L=3 : Goto _9850 : EndIf
If L=4 : Goto _9870 : EndIf
If L=5 : Goto _9890 : EndIf
If L=6 : Goto _9910 : EndIf
If L=7 : Goto _9930 : EndIf
If L=8 : Goto _9950 : EndIf
If L=9 : Goto _9970 : EndIf
Print("0") : Return
_9810: : Print("1") : Return
_9830: : Print("2") : Return
_9850: : Print("3") : Return
_9870: : Print("4") : Return
_9890: : Print("5") : Return
_9910: : Print("6") : Return
_9930: : Print("7") : Return
_9950: : Print("8") : Return
_9970: : Print("9")
Return
CloseConsole()
End