 STTR1 20171121 15:47:59.000000000 +0100
+++ STTR1_TAH.bas 20171123 11:21:08.000000000 +0100
@@ 1,12 +1,49 @@
REM Extracted from HP tape image 16Nov2003 by Pete Turnbull

1 REM **** HP BASIC PROGRAM LIBRARY ******************************
2 REM
3 REM STTR1: STAR TREK
4 REM
5 REM 36243 REV B  10/73
6 REM
7 REM **** CONTRIBUTED PROGRAM ***********************************
+10 REM (TAH) \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
+11 REM (TAH) Original code of STTR1 for HP 2000 TimeShared BASIC (http://bitsavers.trailingedge.com/pdf/hp/2000TSB/0200090016_2000C_A_Guide_To_TimeShared_BASIC_Apr71.pdf) taken from http://www.dunnington.info/public/startrek/STTR1
+12 REM (TAH) Fully documented and modified by Till A. Heilmann (mail@tillheilmann.info) in 2017 to make it run on modern BASIC interpreters.
+13 REM (TAH) This version was tested with Chipmunk BASIC (http://www.nicholson.com/rhn/basic/).
+20 REM (TAH) Comments to the code are in lines starting with REM (TAH), changes are marked by enclosing comments lines REM (TAH) \\\... and REM (TAH) ///... .
+21 REM (TAH) Changes try to mimic the style of the original code as closely as possible (only one statement per line, all uppercase statements etc.).
+22 REM (TAH) Changes due to the BASIC dialect concern:
+23 REM (TAH)  HP 2000 BASIC statements PRINT USING... and IMAGE...
+24 REM (TAH)  HP 2000 BASIC statement GOTO...OF...
+25 REM (TAH)  HP 2000 BASIC statement MAT...ZER
+26 REM (TAH)  HP 2000 BASIC function TIM
+27 REM (TAH)  HP 2000 BASIC string handling
+28 REM (TAH)  Jumps out of/into FOR...NEXT loops (see lines 20602063, 31803183, 38903903, 41904195, 49605250 and 69707250)
+29 REM (TAH)  Multiple variable assignments
+30 REM (TAH) Changes affecting the look of the game are:
+31 REM (TAH)  Formatting of output (especially for LONG RANGE SENSOR SCAN and CUMULATIVE GALACTIC RECORD)
+32 REM (TAH)  Corrected and homogenized spelling
+33 REM (TAH)  Added info about format of input to ship calculator (line 6990).
+34 REM (TAH)  Removed colons at end of PRINT statements followed by INPUT statements (because most interpreters print a question mark for INPUT statements).
+35 REM (TAH)  Time of mission is given in actual minutes (see line 4103).
+40 REM (TAH) Changes affecting the gameplay are:
+41 REM (TAH)  Galaxy wraps around at borders (so ship cannot leave it); long range sensor and cumulative galactic record work accordingly (see lines 823824, 2433, 2452)
+42 REM (TAH)  Shields can be reset to zero (see line 3513)
+43 REM (TAH)  Added option to quit game (see line 1293, 1383)
+44 REM (TAH)  User input for game instructions and calculator can be given in both uppercase and lowercase (see lines 213, 5303, 5313)
+45 REM (TAH)  Adjusted amount of energy used by warp engine (see lines 21222302).
+50 REM (TAH) To make the code run correctly on interpreters other than Chipmunk BASIC, you may have to check the following:
+51 REM (TAH)  Handling of strings using LEFT$, RIGHT$, MID$ functions and + operator (line 473)
+52 REM (TAH)  Formatting of output using PRINT statement with STR$() function
+53 REM (TAH)  Use of ON...GOTO... syntax
+54 REM (TAH)  Use of RND() function and seeding it with TIMER() function (line 204)
+55 REM (TAH)  Use of TIME$ function (lines 413, 4092)
+56 REM (TAH)  Use of MOD function (lines 823824, 2433, 2452)
+60 REM (TAH) For a description of variables used in the code see lines 80308560.
+61 REM (TAH) For a more authentic experience, play the game on a simulated HP2000 machine: https://16kram.com/page/3/
+62 REM (TAH) More information about the game can be found on https://gamesoffame.wordpress.com/startrek/
+90 REM (TAH) Changed line numbers of following lines 9198...
+91 REM Extracted from HP tape image 16Nov2003 by Pete Turnbull
+92 REM **** HP BASIC PROGRAM LIBRARY ******************************
+93 REM
+94 REM STTR1: STAR TREK
+95 REM
+96 REM 36243 REV B  10/73
+97 REM
+98 REM **** CONTRIBUTED PROGRAM ***********************************
+99 REM (TAH) //////////////////////////////////////////////////////////
100 REM *****************************************************************
110 REM *** ***
120 REM *** STAR TREK: BY MIKE MAYFIELD, CENTERLINE ENGINEERING ***
@@ 14,118 +51,326 @@
140 REM *** TOTAL INTERACTION GAME  ORIG. 20 OCT 1972
150 REM *** ***
160 REM *****************************************************************
+166 REM (TAH)
+167 REM (TAH) ***** WELCOME SCREEN *****
+168 REM (TAH)
+169 REM (TAH) Flush screen.
170 GOSUB 5460
+179 REM (TAH) Print welcome message.
180 PRINT " STAR TREK "
+189 REM (TAH) Ask user about game instructions.
190 PRINT "DO YOU WANT INSTRUCTIONS (THEY'RE LONG!)";
200 INPUT A$
210 IF A$ <> "YES" THEN 230
+201 REM (TAH) \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
+202 REM (TAH) Use Chipmunk BASIC function TIMER() to construct a (somewhat random) number for seeding RND().
+203 REM (TAH) We have to do this so the galaxy is not created using the same recurring random numbers (see lines 370400 and 500760).
+204 T=RND(TIMER()*1)
+210 REM (TAH)  IF A$ <> "YES" THEN 230
+211 REM (TAH) Changed conditional so that user input can be both uppercase and lowercase (see line 213).
+212 REM (TAH) If user wants game instructions, then print them.
+213 IF A$ <> "YES" AND A$ <> "Yes" AND A$ <> "yes" AND A$ <> "Y" AND A$ <> "y" THEN 230
+214 REM (TAH) //////////////////////////////////////////////////////////
220 GOSUB 5820
230 REM ***** PROGRAM STARTS HERE *****
240 Z$=" "
+239 REM (TAH) \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
+240 REM (TAH)  Z$=" "
+241 REM (TAH) Make Z$ 72 space characters long to match its size (see line 280). Z$ is used to clear other string variables.
+242 Z$=" "
+248 REM (TAH) //////////////////////////////////////////////////////////
+249 REM (TAH) Flush screen.
250 GOSUB 5460
+259 REM (TAH) Initialize multiple variables (see lines 80308560 for description).
260 DIM G[8,8],C[9,2],K[3,3],N[3],Z[8,8]
270 DIM C$[6],D$[72],E$[24],A$[3],Q$[72],R$[72],S$[48]
280 DIM Z$[72]
290 T0=T=INT(RND(1)*20+20)*100
+289 REM (TAH) \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
+290 REM (TAH)  T0=T=INT(RND(1)*20+20)*100
+291 REM (TAH) Changed multiple variable assignment to two separate assignments.
+292 REM (TAH) Set initial stardate (see also line 415).
+293 T=INT(RND(1)*20+20)*100
+294 REM (TAH) Remember initial stardate (for computing amount of time elapsed at end of game).
+295 T0=T
+298 REM (TAH) //////////////////////////////////////////////////////////
+299 REM (TAH) Set stardate limit for game.
300 T9=30
+309 REM (TAH) D0 seems to indicate whether ship is DOCKED or not, but is never used in original code (see lines 4220 and 4240).
310 D0=0
320 E0=E=3000
330 P0=P=10
+319 REM (TAH) \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
+320 REM (TAH)  E0=E=3000
+321 REM (TAH) Changed multiple variable assignment to two separate assignments.
+322 REM (TAH) Set initial ship energy.
+323 E=3000
+324 REM (TAH) Remember initial ship energy.
+325 E0=E
+330 REM (TAH)  P0=P=10
+331 REM (TAH) Changed multiple variable assignment to single assignment.
+332 REM (TAH) Remember initial number of photon torpedoes. This is never used in original code.
+333 P0=10
+334 REM (TAH) Set initial number of photon torpedoes.
+335 P=10
+336 REM (TAH) //////////////////////////////////////////////////////////
+339 REM (TAH) Set initial shields for Klingons.
340 S9=200
350 S=H8=0
+349 REM (TAH) \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
+350 REM (TAH)  S=H8=0
+351 REM (TAH) Changed multiple variable assignment to two separate assignments.
+352 REM (TAH) It is not clear what H8 is supposed to indicate since it never changes during the game (see lines 355, 4890, 5250 and 5270).
+353 H8=0
+354 REM (TAH) Set ship shields to H8 (zero).
+355 S=H8
+356 REM (TAH) //////////////////////////////////////////////////////////
+359 REM (TAH) Define function to compute distance between Klingon I and ship (i.e. length of hypotenuse of the right triangle formed by Y,X sector coordinates of Klingon I and ship).
360 DEF FND(D)=SQR((K[I,1]S1)^2+(K[I,2]S2)^2)
+369 REM (TAH) Determine random initial Y,X quadrant coordinate (18) of ship in galaxy.
370 Q1=INT(RND(1)*8+1)
380 Q2=INT(RND(1)*8+1)
+389 REM (TAH) Determine random initial Y,X sector coordinate (18) of ship in quadrant.
390 S1=INT(RND(1)*8+1)
400 S2=INT(RND(1)*8+1)
410 T7=TIM(0)+60*TIM(1)
420 C[2,1]=C[3,1]=C[4,1]=C[4,2]=C[5,2]=C[6,2]=1
430 C[1,1]=C[3,2]=C[5,1]=C[7,2]=C[9,1]=0
440 C[1,2]=C[2,2]=C[6,1]=C[7,1]=C[8,1]=C[8,2]=C[9,2]=1
450 MAT D=ZER
+409 REM (TAH) \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
+410 REM (TAH)  T7=TIM(0)+60*TIM(1)
+411 REM (TAH) Changed from HP 2000 TimeShared BASIC function TIM (see line 2, ref. p. 329) giving T7 as number of minutes elapsed since midnight to Chipmunk BASIC function time$ (see line 4) and generic string functions.
+412 REM (TAH) Set stardate at which game begins (see also line 293).
+413 T7=INT(MID$(TIME$,4,2))+60*INT(LEFT$(TIME$,2))
+420 REM (TAH)  C[2,1]=C[3,1]=C[4,1]=C[4,2]=C[5,2]=C[6,2]=1
+421 REM (TAH) Changed multiple variable assignment to six separate assignments.
+422 REM (TAH) Initialize C[m,n] holding change of 1 in Y,X coordinates (n=1 meaning Y, n=2 meaning X) by moving in direction m (see lines 58805960).
+423 C[2,1]=1
+424 C[3,1]=1
+425 C[4,1]=1
+426 C[4,2]=1
+427 C[5,2]=1
+428 C[6,2]=1
+430 REM (TAH)  C[1,1]=C[3,2]=C[5,1]=C[7,2]=C[9,1]=0
+431 REM (TAH) Changed multiple variable assignment to five separate assignments.
+432 REM (TAH) Initialize C[m,n] holding change of 0 in Y,X coordinates (n=1 meaning Y, n=2 meaning X) by moving in direction m (see lines 58805960).
+434 C[1,1]=0
+435 C[3,2]=0
+436 C[5,1]=0
+437 C[7,2]=0
+438 C[9,1]=0
+440 REM (TAH)  C[1,2]=C[2,2]=C[6,1]=C[7,1]=C[8,1]=C[8,2]=C[9,2]=1
+441 REM (TAH) Changed multiple variable assignment to seven separate assignments.
+442 REM (TAH) Initialize C[m,n] holding change of +1 in Y,X coordinates (n=1 meaning Y, n=2 meaning X) by moving in direction m (see lines 58805960).
+443 C[1,2]=1
+444 C[2,2]=1
+445 C[6,1]=1
+446 C[7,1]=1
+447 C[8,1]=1
+448 C[8,2]=1
+449 C[9,2]=1
+450 REM (RAH)  MAT D=ZER
+451 REM (TAH) Changed from HP 2000 TimeShared BASIC statement MAT...ZER (see line 2, ref. p. 53) to generic DIM statement and FOR...NEXT loop.
+452 REM (TAH) Initialize variable for keeping track of damage to ship devices.
+453 DIM D[9]
+454 FOR I=1 TO 9
+455 D[I]=0
+456 NEXT I
+458 REM (TAH) //////////////////////////////////////////////////////////
+459 REM (TAH) Set names of ship devices (each is exactly 12 chars long).
460 D$="WARP ENGINESS.R. SENSORSL.R. SENSORSPHASER CNTRL"
470 D$[49]="PHOTON TUBESDAMAGE CNTRL"
+469 REM (TAH) \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
+470 REM (TAH)  D$[49]="PHOTON TUBESDAMAGE CNTRL"
+471 REM (TAH) Changed from HP 2000 TimeShared BASIC string statement to generic string concatenation.
+472 REM (TAH) Add names of more ship devices (each is exactly 12 chars long).
+473 D$=D$+"PHOTON TUBESDAMAGE CNTRL"
+477 REM (TAH) //////////////////////////////////////////////////////////
+478 REM (TAH) Set even more names of ship devices (12 and 8 chars long).
+479 REM (TAH) A second variable E$ is needed because HP 2000 TimeShared BASIC only allowed string variables with 72 chars.
480 E$="SHIELD CNTRLCOMPUTER"
490 B9=K9=0
+489 REM (TAH) \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
+490 REM (TAH)  B9=K9=0
+491 REM (TAH) Changed multiple variable assignment to two separate assignments.
+492 REM (TAH) Initialize number of starbases in galaxy.
+493 B9=0
+494 REM (TAH) Initialize number of Klingons in galaxy.
+495 K9=B9
+497 REM (TAH) //////////////////////////////////////////////////////////
+498 REM (TAH) Create galaxy with Klingons, starbases and stars...
+499 REM (TAH) Do it for every quadrant I,J.
500 FOR I=1 TO 8
510 FOR J=1 TO 8
+519 REM (TAH) Determine number of Klingons in quadrant I,J by randomly picking a number between 0 and 1.
520 R1=RND(1)
+529 REM (TAH) In ~2%, ~3%, ~15% and ~80% of cases...
530 IF R1>.98 THEN 580
540 IF R1>.95 THEN 610
550 IF R1>.8 THEN 640
+559 REM (TAH) ...there are zero Klingons in quadrant I,J.
560 K3=0
570 GOTO 660
+579 REM (TAH) ...there are 3 Klingons in quadrant I,J (see line 530).
580 K3=3
+589 REM (TAH) Add this number to the total number of Klingons in galaxy.
590 K9=K9+3
+599 REM (TAH) Go to code determining number of starbases.
600 GOTO 660
+609 REM (TAH) ...there are 2 Klingons in quadrant I,J (see line 540).
610 K3=2
+619 REM (TAH) Add this number to the total number of Klingons in galaxy.
620 K9=K9+2
+629 REM (TAH) Go to code determining number of starbases.
630 GOTO 660
+639 REM (TAH) ...there is 1 Klingon in quadrant I,J (see line 550).
640 K3=1
+649 REM (TAH) Add this number to the total number of Klingons in galaxy.
650 K9=K9+1
+659 REM (TAH) Determine number of starbases in quadrant I,J by randomly picking a number between 0 and 1.
660 R1=RND(1)
+669 REM (TAH) In ~5% of cases...
670 IF R1>.96 THEN 700
+679 REM (TAH) ...there is no starbase in quadrant I,J.
680 B3=0
+689 REM (TAH) Go to code determining number of stars.
690 GOTO 720
+699 REM (TAH) ...there is a starbase in quadrant I,J (see line 670).
700 B3=1
+709 REM (TAH) Increment the total number of starbases in galaxy by one.
710 B9=B9+1
+719 REM (TAH) Determine number of stars in quadrant I,J by randomly picking a number between 1 and 8.
720 S3=INT(RND(1)*8+1)
+727 REM (TAH) Construct the integer holding the number of Klingons, starbases and stars in quadrant I,J.
+728 REM (TAH) Hundreds digit is number of Klingons, tens digit is number of starbases, ones digit is number of stars.
+729 REM (TAH) Y,X sector coordinates of Klingons, starbases and stars are not set here but will be determined randomly upon entering a quadrant.
730 G[I,J]=K3*100+B3*10+S3
+739 REM (TAH) Initialize variable for the cumulative galactic record (derived from G[I,J]).
740 Z[I,J]=0
750 NEXT J
760 NEXT I
+769 REM (TAH) Remember initial number of Klingons in galaxy.
770 K7=K9
+779 REM (TAH) If galaxy has no Klingons or starbases in it, then recreate it.
775 IF B9 <= 0 OR K9 <= 0 THEN 490
780 PRINT "YOU MUST DESTROY"K9;" KLINGONS IN"T9;" STARDATES WITH"B9;" STARBASES"
810 K3=B3=S3=0
820 IF Q1<1 OR Q1>8 OR Q2<1 OR Q2>8 THEN 920
+789 REM (TAH) \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
+780 REM (TAH) PRINT "YOU MUST DESTROY "K9;" KLINGONS IN"T9;" STARDATES WITH"B9;" STARBASES"
+781 REM (TAH) Changed formatting out output using generic string functions.
+782 REM (TAH) Print mission goal message.
+783 PRINT "YOU MUST DESTROY "STR$(K9)" KLINGONS IN "STR$(T9)" STARDATES WITH "STR$(B9)" STARBASES"
+807 REM (TAH)
+808 REM (TAH) ***** SET UP QUADRANT THAT SHIP HAS MOVED TO *****
+809 REM (TAH)
+810 REM (TAH)  K3=B3=S3=0
+811 REM (TAH) Changed multiple variable assignment to three separate assignments.
+812 REM (TAH) Reset number of Klingons, starbases and stars in current quadrant to zero.
+813 K3=0
+814 B3=K3
+815 S3=B3
+816 REM (TAH) This seems unnecessary as K3, B3 and S3 will be computed next.
+820 REM (TAH)  IF Q1<1 OR Q1>8 OR Q2<1 OR Q2>8 THEN 920
+821 REM (TAH) Fixed code using Chipmunk BASIC function mod(ulo) so that ship cannot leave galaxy by traveling to quadrant coordinates other than 1 to 8.
+822 REM (TAH) Galaxy now wraps around at borders so that from coordinates ...6,7,8 you move back to 1, and from ...3,2,1 back to 8.
+823 IF Q1<1 OR Q1>8 THEN Q1=((Q1+7) MOD 8)+1
+824 IF Q2<1 OR Q2>8 THEN Q2=((Q2+7) MOD 8)+1
+825 REM (TAH) //////////////////////////////////////////////////////////
+828 REM (TAH) Determine number of Klingons, starbases and stars in current quadrant by extracting the hundreds, tens and ones digit from G[Q1,Q2] (see line 730).
+829 REM (TAH) Set X to one hundreth of integer holding the number of Klingons, starbases and stars in current quadrant.
830 X=G[Q1,Q2]*.01
+839 REM (TAH) Number of Klingons in current quadrant is integer of X (i.e. the hundreds digit of G[Q1,Q2]).
840 K3=INT(X)
+849 REM (TAH) Number of starbases in current quadrant is integer of X minus its ones digit times 10 (i.e. the tens digit of G[Q1,Q2]).
850 B3=INT((XK3)*10)
+859 REM (TAH) Number of stars in current quadrant is G[Q1,Q2] minus the integer of its tenth times 10 (i.e. the ones digit of G[Q1,Q2]).
860 S3=G[Q1,Q2]INT(G[Q1,Q2]*.1)*10
+869 REM (TAH) If there are no Klingons in current quadrant OR if ship shields are greater than 200, then skip printing warning message (and go to code for resetting Klingons).
870 IF K3=0 THEN 910
880 IF S>200 THEN 910
+889 REM (TAH) Else, print warning message.
890 PRINT "COMBAT AREA CONDITION RED"
900 PRINT " SHIELDS DANGEROUSLY LOW"
910 MAT K=ZER
+908 REM (TAH) Initialize variable holding Y,X sector coordinates and shields of each Klingon in current quadrant.
+909 REM (TAH) \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
+910 REM (TAH)  MAT K=ZER
+911 REM (TAH) Changed from HP 2000 TimeShared BASIC statement MAT...ZER (see line 2, p. 53) to nested FOR...NEXT loops.
+912 FOR I=1 TO 3
+913 FOR J=1 TO 2
+914 K[I,J]=0
+915 NEXT J
+916 NEXT I
+917 REM (TAH) //////////////////////////////////////////////////////////
+919 REM (TAH) Set shields of Klingon I to zero.
920 FOR I=1 TO 3
930 K[I,3]=0
940 NEXT I
+949 REM (TAH) Initialize quadrant strings Q$, R$ and Z$ for printing current quadrant map (by setting them to Z$, i.e. empty spaces).
950 Q$=Z$
960 R$=Z$
970 S$=Z$[1,48]
+969 REM (TAH) \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
+970 REM (TAH)  S$=Z$[1,48]
+971 REM (TAH) Changed from HP 2000 TimeShared BASIC string statement to generic LEFT$ function
+972 S$=LEFT$(Z$,48)
+973 REM (TAH) //////////////////////////////////////////////////////////
+978 REM (TAH) Insert ship at right sector in current quadrant...
+979 REM (TAH) Set up A$ for inserting ship into quadrant string (Q$, R$ or S$).
980 A$="<*>"
+989 REM (TAH) Set Z1,Z2 (for determining right point of insertion into strings Q$, R$ or S$) to Y,X sector coordinate of ship.
990 Z1=S1
1000 Z2=S2
+1009 REM (TAH) Insert ship into quadrant string (Q$, R$ or S$).
1010 GOSUB 5510
+1018 REM (TAH) Insert Klingons at randomly chosen sectors in current quadrant...
+1019 REM (TAH) Do it for each Klingon (K3 is number of Klingon) in current quadrant.
1020 FOR I=1 TO K3
+1029 REM (TAH) Determine random Y,X sector coordinates of Klingon.
1030 GOSUB 5380
+1039 REM (TAH) Set up A$ for inserting Klingon into quadrant string (Q$, R$ or S$).
1040 A$="+++"
+1049 REM (TAH) Set Z1,Z2 (for determining right point of insertion into strings Q$, R$ or S$) to Y,X sector coordinate of Klingon.
1050 Z1=R1
1060 Z2=R2
+1069 REM (TAH) Insert Klingon into quadrant string (Q$, R$ or S$).
1070 GOSUB 5510
+1079 REM (TAH) Store Y,X sector coordinate of Klingon.
1080 K[I,1]=R1
1090 K[I,2]=R2
+1099 REM (TAH) Set initial shields of Klingon to 200.
1100 K[I,3]=S9
1110 NEXT I
+1118 REM (TAH) Insert starbases at randomly chosen sectors in current quadrant...
+1119 REM (TAH) Do it for every starbase (B3 is number of starbases) in current quadrant.
1120 FOR I=1 TO B3
+1129 REM (TAH) Determine random Y,X sector coordinates of starbase.
1130 GOSUB 5380
+1139 REM (TAH) Set up A$ for inserting starbase into quadrant string (Q$, R$ or S$).
1140 A$=">!<"
+1149 REM (TAH) Set Z1,Z2 (for determining right point of insertion into strings Q$, R$ or S$) to Y,X sector coordinate of starbase.
1150 Z1=R1
1160 Z2=R2
+1169 REM (TAH) Insert starbase into quadrant string (Q$, R$ or S$).
1170 GOSUB 5510
1180 NEXT I
+1188 REM (TAH) Insert stars at randomly chosen sectors in current quadrant...
+1189 REM (TAH) Do it for every star (S3 is number of stars) in current quadrant.
1190 FOR I=1 TO S3
+1199 REM (TAH) Determine random Y,X sector coordinates of star.
1200 GOSUB 5380
+1209 REM (TAH) Set up A$ for inserting star into quadrant string (Q$, R$ or S$).
1210 A$=" * "
+1219 REM (TAH) Set Z1,Z2 (for determining right point of insertion into strings Q$, R$ or S$) to Y,X sector coordinate of star.
1220 Z1=R1
1230 Z2=R2
+1239 REM (TAH) Insert star into quadrant string (Q$, R$ or S$).
1240 GOSUB 5510
1250 NEXT I
+1256 REM (TAH)
+1257 REM (TAH) ***** NEW TURN *****
+1258 REM (TAH)
+1259 REM (TAH) Print ship condition, quadrant map and detailed info.
1260 GOSUB 4120
1270 PRINT "COMMAND:";
+1268 REM (TAH) \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
+1270 REM (TAH)  PRINT "COMMAND:";
+1271 REM (TAH) Removed colon from user prompt message (see line 1273).
+1272 REM (TAH) Print user prompt message.
+1273 PRINT "COMMAND";
+1274 REM (TAH) //////////////////////////////////////////////////////////
+1279 REM (TAH) Prompt user for command.
1280 INPUT A
1290 GOTO A+1 OF 1410,1260,2330,2530,2800,3460,3560,4630
+1289 REM (TAH) \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
+1290 REM (TAH)  GOTO A+1 OF 1410,1260,2330,2530,2800,3460,3560,4630
+1291 REM (TAH) Changed from HP 2000 TimeShared BASIC GOTO...OF... statement to generic ON...GOTO... statement and added option to quit game.
+1292 REM (TAH) Go to code according to user input.
+1293 ON A+1 GOTO 1410,1260,2330,2530,2800,3460,3560,4630,7999
+1294 REM (TAH) //////////////////////////////////////////////////////////
+1299 REM (TAH) If user input is not a valid command (i.e. integer from 0 to 8), then print command message.
1300 PRINT
1310 PRINT " 0 = SET COURSE"
1320 PRINT " 1 = SHORT RANGE SENSOR SCAN"
@@ 135,451 +380,1100 @@
1360 PRINT " 5 = SHIELD CONTROL"
1370 PRINT " 6 = DAMAGE CONTROL REPORT"
1380 PRINT " 7 = CALL ON LIBRARY COMPUTER"
+1381 REM (TAH) \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
+1382 REM (TAH) Added message about option to quit game (see line 1294).
+1383 PRINT " 8 = QUIT GAME"
+1384 REM (TAH) //////////////////////////////////////////////////////////
1390 PRINT
+1399 REM (TAH) Go to command prompt.
1400 GOTO 1270
1410 PRINT "COURSE (19):";
+1405 REM (TAH)
+1406 REM (TAH) ***** SHIP MOVES *****
+1407 REM (TAH)
+1408 REM (TAH) ***** SET COURSE *****
+1409 REM (TAH) \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
+1410 REM (TAH)  PRINT "COURSE (19):";
+1411 REM (TAH) Removed colon from user prompt message (see line 1413).
+1412 REM (TAH) Print user prompt message.
+1413 PRINT "COURSE (19)";
+1414 REM (TAH) //////////////////////////////////////////////////////////
+1419 REM (TAH) Prompt user for course.
1420 INPUT C1
+1429 REM (TAH) If input is 0, then abort (i.e. go to command prompt).
1430 IF C1=0 THEN 1270
+1439 REM (TAH) If input is invalid (i.e. less than 1 or equal to or greater than 9), then prompt again for course.
1440 IF C1<1 OR C1 >= 9 THEN 1410
1450 PRINT "WARP FACTOR (08):";
+1449 REM (TAH) \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
+1450 REM (TAH)  PRINT "WARP FACTOR (08):";
+1451 REM (TAH) Removed colon from user prompt message (see line 1453).
+1452 REM (TAH) Print user prompt message.
+1453 PRINT "WARP FACTOR (08)";
+1454 REM (TAH) //////////////////////////////////////////////////////////
+1459 REM (TAH) Prompt user for warp factor.
1460 INPUT W1
+1469 REM (TAH) If input is invalid (i.e. less than 0 or greater than 8), then go to prompt for course.
1470 IF W1<0 OR W1>8 THEN 1410
+1478 REM (TAH) If warp engine is working or warp factor is (only) equal to or less than .2, then skip warning message (and go to code for computing damage by Klingon attack).
+1479 REM (TAH) So, the following code is executed ONLY when the warp engine is damaged AND warp factor is greater than .2!
1480 IF D[1] >= 0 OR W1 <= .2 THEN 1510
+1489 REM (TAH) Print warp engine warning message.
1490 PRINT "WARP ENGINES ARE DAMAGED, MAXIMUM SPEED = WARP .2"
+1499 REM (TAH) Go to prompt for course. (But why ask for course? Ship cannot move when warp engine is not working.)
1500 GOTO 1410
+1508 REM (TAH) ***** KLINGONS ATTACK *****
+1509 REM (TAH) If there are no Klingons in current quadrant, then skip executing subroutine for computing damage by Klingon attack (and go to code for checking ship energy and shields).
1510 IF K3 <= 0 THEN 1560
+1519 REM (TAH) Compute damage done by Klingon attack.
1520 GOSUB 3790
+1529 REM (TAH) If there are no Klingons in current quadrant, then skip checking whether ship has been destroyed (and go to code for checking ship energy and shields).
1530 IF K3 <= 0 THEN 1560
+1539 REM (TAH) If ship has been destroyed, then go to code for printing message about destruction of ship.
1540 IF S<0 THEN 4000
+1549 REM (TAH) If not, then skip code checking whether shields should be raised (and go to code for repairing damage to ship devices).
1550 GOTO 1610
+1559 REM (TAH) If you have ship energy left, then skip code for printing warning message about ship energy (and go to code for repairing damage to ship devices).
1560 IF E>0 THEN 1610
+1569 REM (TAH) Else, if shields are less than 1, then go to printing message about marooning of ship.
1570 IF S<1 THEN 3920
1580 PRINT "YOU HAVE"E" UNITS OF ENERGY"
1590 PRINT "SUGGEST YOU GET SOME FROM YOUR SHIELDS WHICH HAVE"S" UNITS LEFT"
+1579 REM (TAH) \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
+1580 REM (TAH)  PRINT "YOU HAVE"E" UNITS OF ENERGY"
+1590 REM (TAH)  PRINT "SUGGEST YOU GET SOME FROM YOUR SHIELDS WHICH HAVE"S" UNITS LEFT"
+1591 REM (TAH) Changed formatting out output using generic string functions.
+1592 REM (TAH) Print energy warning message.
+1593 PRINT "YOU HAVE "STR$(E)" UNITS OF ENERGY"
+1594 PRINT "SUGGEST YOU GET SOME FROM YOUR SHIELDS WHICH HAVE "STR$(S)" UNITS LEFT"
+1595 REM (TAH) //////////////////////////////////////////////////////////
+1599 REM (TAH) Go to command prompt.
1600 GOTO 1270
+1608 REM (TAH) ***** REPAIR SHIP *****
+1609 REM (TAH) Repair existing damage to ship devices.
1610 FOR I=1 TO 8
+1619 REM (TAH) If device is not damaged, then skip repairing (and go to code for next iteration of FOR...NEXT loop).
1620 IF D[I] >= 0 THEN 1640
+1629 REM (TAH) If device is damaged, then decrease damage by 1.
1630 D[I]=D[I]+1
1640 NEXT I
+1647 REM (TAH) ***** RANDOM DAMAGE AND REPAIR *****
+1648 REM (TAH) Compute random damage/additional repair to ship devices...
+1649 REM (TAH) With a chance of 80%, there is no damage/additional repair to any device.
1650 IF RND(1)>.2 THEN 1810
+1659 REM (TAH) If there is damage/additional repair to the ship, determine the affected device by randomly picking a number between 1 and 8.
1660 R1=INT(RND(1)*8+1)
+1669 REM (TAH) With a chance of 50%, the device is additionaly repaired (go to code for additional repairing device).
1670 IF RND(1) >= .5 THEN 1750
+1679 REM (TAH) If not, then the device is damaged, so subtract a random damage value from it.
1680 D[R1]=D[R1](RND(1)*5+1)
+1689 REM (TAH) Print message about damage.
1690 PRINT
1700 PRINT "DAMAGE CONTROL REPORT:";
+1699 REM (TAH) \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
+1700 REM (TAH)  PRINT "DAMAGE CONTROL REPORT:";
+1701 REM (TAH) Changed formatting of output.
+1702 PRINT "DAMAGE CONTROL REPORT: ";
+1703 REM (TAH) //////////////////////////////////////////////////////////
+1709 REM (TAH) Execute subroutine for printing device name.
1710 GOSUB 5610
1720 PRINT " DAMAGED"
1730 PRINT
+1739 REM (TAH) Skip computing additional repair to the ship (since we already computed random damage).
1740 GOTO 1810
+1749 REM (TAH) Add a random repair value to the affected device.
1750 D[R1]=D[R1]+(RND(1)*5+1)
+1759 REM (TAH) Print message about repair.
1760 PRINT
1770 PRINT "DAMAGE CONTROL REPORT:";
+1769 REM (TAH) \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
+1770 REM (TAH)  PRINT "DAMAGE CONTROL REPORT:";
+1771 REM (TAH) Changed formatting of output.
+1772 PRINT "DAMAGE CONTROL REPORT: ";
+1773 REM (TAH) //////////////////////////////////////////////////////////
+1779 REM (TAH) Execute subroutine for printing device name.
1780 GOSUB 5610
1790 PRINT " STATE OF REPAIR IMPROVED"
1800 PRINT
+1807 REM (TAH) ***** MOVE SHIP *****
+1808 REM (TAH) Compute movement of ship through sectors/quadrants...
+1809 REM (TAH) Set N to number of sectors that ship travels through space (= warp factor * 8 because warp 1 moves ship across 8 sectors or 1 quadrant).
1810 N=INT(W1*8)
+1819 REM (TAH) Set up A$ for inserting empty space into quadrant string (Q$, R$ or S$).
1820 A$=" "
+1829 REM (TAH) Set Z1,Z2 (for determining right point of insertion into strings Q$, R$ or S$) to Y,X sector coordinate of ship.
1830 Z1=S1
1840 Z2=S2
+1849 REM (TAH) Insert empty space into quadrant string (Q$, R$ or S$) to remove ship from original position.
1850 GOSUB 5510
+1869 REM (TAH) Remember original Y,X sector coordinate of ship.
1870 X=S1
1880 Y=S2
+1884 REM (TAH) Set C2 to integer of C1 (i.e. course entered by user). Line number 1885 suggests later addition/change to original code!
1885 C2=INT(C1)
+1889 REM (TAH) Compute change in Y,X sector coordinate of ship in one of N steps (determined by warp factor W1 and course C1,C2; see lines 1810 and 19102070).
1890 X1=C[C2,1]+(C[C2+1,1]C[C2,1])*(C1C2)
1900 X2=C[C2,2]+(C[C2+1,2]C[C2,2])*(C1C2)
+1909 REM (TAH) Compute sector in current quadrant that ship moves to next. Do it for every step of N (see line 1810).
1910 FOR I=1 TO N
+1919 REM (TAH) Determine new Y,X sector coordinate.
1920 S1=S1+X1
1930 S2=S2+X2
+1939 REM (TAH) If ship has now moved outside of current quadrant (i.e. Y,X coordinates are not between 1 and 8), then go to code computing new quadrant.
1940 IF S1<.5 OR S1 >= 8.5 OR S2<.5 OR S2 >= 8.5 THEN 2170
+1949 REM (TAH) Set up A$ for checking for empty space in quadrant string (Q$, R$ or S$).
1950 A$=" "
+1959 REM (TAH) Set Z1,Z2 (for determining right point of checking in strings Q$, R$ or S$) to new Y,X sector coordinate of ship.
1960 Z1=S1
1970 Z2=S2
+1979 REM (TAH) Compare empty space to new ship position Z1,Z2 (i.e. sector that ship tries to move to).
1980 GOSUB 5680
+1989 REM (TAH) If check was successful (i.e. if ship has not tried to move into a sector occupied by Klingon, starbase or star), then go to next iteration of ship movement.
1990 IF Z3 <> 0 THEN 2070
2030 PRINT USING 5370;S1,S2
+2029 REM (TAH) \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
+2030 REM (TAH)  PRINT USING 5370;S1,S2
+2031 REM (TAH) Changed from HP 2000 TimeShared BASIC PRINT USING... and IMAGE... statements to generic PRINT statement and formatting of output using generic string functions.
+2032 REM (TAH) Print message about engine shutdown.
+2033 PRINT "WARP ENGINES SHUTDOWN AT SECTOR "STR$(S1)","STR$(S2)" DUE TO BAD NAVIGATION"
+2034 REM (TAH) //////////////////////////////////////////////////////////
+2039 REM (TAH) Reset Y,X sector coordinates to earlier state (because ship tried to move into sector occupied by Klingon, starbase or star).
2040 S1=S1X1
2050 S2=S2X2
2060 GOTO 2080
+2059 REM (TAH) \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
+2060 REM (TAH)  GOTO 2080
+2061 REM (TAH) Jumping out of FOR...NEXT loop is considered illegal by some BASIC interpreters.
+2062 REM (TAH) Workaround is to set I to N (to terminate loop).
+2063 I=N
+2064 REM (TAH) //////////////////////////////////////////////////////////
2070 NEXT I
+2079 REM (TAH) Set up A$ for inserting ship into new position in quadrant string (Q$, R$ or S$).
2080 A$="<*>"
+2082 REM (TAH) Round up Y,X sector coordinates of ship (because it could be noninteger, see lines 18901930, but why here and not earlier?).
2083 S1=INT(S1+.5)
2086 S2=INT(S2+.5)
+2089 REM (TAH) Set Z1,Z2 (for determining right point of insertion into strings Q$, R$ or S$) to new Y,X sector coordinate of ship.
2090 Z1=S1
2100 Z2=S2
+2109 REM (TAH) Insert ship at new position into quadrant string (Q$, R$ or S$).
2110 GOSUB 5510
2120 E=EN+5
+2118 REM (TAH) ***** ADJUST ENERGY AND STARDATE *****
+2119 REM (TAH) \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
+2120 REM (TAH)  E=EN+5
+2121 REM (TAH) Changed amount of energy used by warp engine (see line 1810). E=EN+5 just seems wrong.
+2122 E=EN*5
+2123 REM (TAH) //////////////////////////////////////////////////////////
+2129 REM (TAH) If ship traveled at less than warp factor 1, then skip adjusting stardate.
2130 IF W1<1 THEN 2150
+2139 REM (TAH) Else, adjust stardate.
2140 T=T+1
+2149 REM (TAH) If stardate limit has been reached, then go to code for ending and restarting game.
2150 IF T>T0+T9 THEN 3970
+2159 REM (TAH) Else, go to code for new turn.
2160 GOTO 1260
+2166 REM (TAH) ***** SHIP HAS MOVED TO NEW QUADRANT *****
+2167 REM (TAH) Compute total number of sectors that ship travels through galaxy along Y,X axis.
+2168 REM (TAH) Q1 is (original) Y quadrant coord., X is (original) Y [!] sector coord., X1 is 1/0/+1 sector change along Y axis, N is warp factor * 8 (see line 1810).
+2169 REM (TAH) Q2 is (original) X quadrant coord., Y is (original) X [!] sector coord., X1 is 1/0/+1 sector change along X axis, N is warp factor * 8 (see line 1810).
2170 X=Q1*8+X+X1*N
2180 Y=Q2*8+Y+X2*N
+2189 REM (TAH) Determine new Y,X quadrant coord. by dividing total number of sectors traveled along Y,X axis through 8 (because each quadrant is 8 by 8 sectors).
2190 Q1=INT(X/8)
2200 Q2=INT(Y/8)
+2209 REM (TAH) Determine new Y,X sector coord. by subtracting number of traversed quadrants * 8 from total number of sectors traveled along Y,X axis (rounding up).
2210 S1=INT(XQ1*8+.5)
2220 S2=INT(YQ2*8+.5)
+2229 REM (TAH) If shipped has not traveled to the exact Y edge of quadrant, go to code for adjusting stardate.
2230 IF S1 <> 0 THEN 2260
+2239 REM (TAH) Else, correct Y quadrant and sector coordinate.
2240 Q1=Q11
2250 S1=8
+2259 REM (TAH) If shipped has not traveled to the exact X edge of quadrant, go to code for adjusting stardate.
2260 IF S2 <> 0 THEN 2290
+2269 REM (TAH) Else, correct X quadrant and sector coordinate.
2270 Q2=Q21
2280 S2=8
+2289 REM (TAH) Adjust stardate.
2290 T=T+1
2300 E=EN+5
+2299 REM (TAH) \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
+2300 REM (TAH)  E=EN+5
+2301 REM (TAH) Changed amount of energy used by warp engine (see line 1810). E=EN+5 just seems wrong.
+2302 E=EN*5
+2304 REM (TAH) //////////////////////////////////////////////////////////
+2309 REM (TAH) If stardate limit has been reached, then go to code for ending and restarting game.
2310 IF T>T0+T9 THEN 3970
+2319 REM (TAH) Go to code setting up new quadrant that ship has just traveled to.
2320 GOTO 810
+2326 REM (TAH)
+2327 REM (TAH) ***** LONG RANGE SENSOR SCAN *****
+2328 REM (TAH)
+2329 REM (TAH) If long range scanner is not damaged, then go to code for printing scanner results.
2330 IF D[3] >= 0 THEN 2370
+2339 REM (TAH) Else, print message about damaged device.
2340 PRINT "LONG RANGE SENSORS ARE INOPERABLE"
2350 IMAGE "LONG RANGE SENSOR SCAN FOR QUADRANT",D,",",D
+2349 REM (TAH) \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
+2350 REM (TAH)  IMAGE "LONG RANGE SENSOR SCAN FOR QUADRANT",D,",",D
+2351 REM (TAH) HP 2000 BASIC IMAGE... statement replaced by generic PRINT statements (see line 2374)
+2352 REM (TAH) //////////////////////////////////////////////////////////
+2353 REM (TAH) Go to command prompt.
2360 GOTO 1270
2370 PRINT USING 2350;Q1,Q2
2380 PRINT USING 2520
+2369 REM (TAH) \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
+2370 REM (TAH)  PRINT USING 2350;Q1,Q2
+2371 REM (TAH) Changed from HP 2000 TimeShared BASIC PRINT USING... and IMAGE... statements to generic PRINT statement and formatting of output using generic string functions.
+2372 REM (TAH) Print message about Y,X quadrant coordinates.
+2373 PRINT "LONG RANGE SENSOR SCAN FOR QUADRANT "STR$(Q1)","STR$(Q2)
+2380 REM (TAH)  PRINT USING 2520
+2381 REM (TAH) Changed from HP 2000 TimeShared BASIC PRINT USING... and IMAGE... statements to generic PRINT statement and adjusted length of dashstring
+2382 PRINT ""
+2383 REM (TAH) //////////////////////////////////////////////////////////
+2385 REM (TAH) Perform scan for 3 Y quadrant coordinates with ship at center and next to it.
2390 FOR I=Q11 TO Q1+1
2400 MAT N=ZER
+2399 REM (TAH) \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
+2400 REM (TAH)  MAT N=ZER
+2401 REM (TAH) Changed from HP 2000 TimeShared BASIC statement MAT...ZER (see line 2, p. 53) to generic variable assignments.
+2402 REM (TAH) Initialize variables that will give number of Klingons, starbases and stars in quadrant I,J for long range scan.
+2403 N[1]=0
+2404 N[2]=0
+2405 N[3]=0
+2406 REM (TAH) //////////////////////////////////////////////////////////
+2409 REM (TAH) Perform scan for 3 X quadrant coordinates with ship at center and next to it.
2410 FOR J=Q21 TO Q2+1
2420 IF I<1 OR I>8 OR J<1 OR J>8 THEN 2460
2430 N[JQ2+2]=G[I,J]
+2419 REM (TAH) \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
+2420 REM (TAH)  IF I<1 OR I>8 OR J<1 OR J>8 THEN 2460
+2430 REM (TAH)  N[JQ2+2]=G[I,J]
+2431 REM (TAH) Fixed code using Chipmunk BASIC function mod(ulo) so that long range sensors wrap at borders of galaxy (see also lines 823824).
+2432 REM (TAH) Read variable G[I,J] holding number of Klingons, starbases and stars in quadrant I,J into variable N[0,1,2].
+2433 N[JQ2+2]=G[((I+7) MOD 8)+1,((J+7) MOD 8)+1]
+2434 REM (TAH) //////////////////////////////////////////////////////////
+2439 REM (TAH) If ship computer is not working, skip updating cumulative galactic record and go to code for next iteration of loop.
2440 IF D[7]<0 THEN 2460
2450 Z[I,J]=G[I,J]
+2449 REM (TAH) \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
+2450 REM (TAH)  Z[I,J]=G[I,J]
+2451 REM (TAH) Fixed code using Chipmunk BASIC function mod(ulo) so that cumulative galactic record is constructed from right quadrant coordinates (see also lines 823824).
+2452 Z[((I+7) MOD 8)+1,((J+7) MOD 8)+1]=G[((I+7) MOD 8)+1,((J+7) MOD 8)+1]
+2453 REM (TAH) //////////////////////////////////////////////////////////
2460 NEXT J
2470 PRINT USING 2510;N[1],N[2],N[3]
2480 PRINT USING 2520
+2469 REM (TAH) \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
+2470 REM (TAH)  PRINT USING 2510;N[1],N[2],N[3]
+2471 REM (TAH) Changed from HP 2000 TimeShared BASIC PRINT USING... and IMAGE... statements to generic PRINT statement, FOR...NEXT loop and string functions.
+2472 REM (TAH) Print results of long range scan.
+2473 PRINT ": ";
+2474 FOR J=1 TO 3
+2475 REM (TAH) Add 1000 to variable holding number of Klingons, starbases and stars so we get leading zeroes (if no Klingons and, possibly, starbases are in quadrant).
+2476 PRINT RIGHT$(STR$(N[J]+1000),3);" : ";
+2477 NEXT J
+2478 PRINT
+2480 REM (TAH)  PRINT USING 2520
+2481 REM (TAH) Changed from HP 2000 TimeShared BASIC PRINT USING... and IMAGE... statements to generic PRINT statement and adjusted length of dashstring.
+2482 PRINT ""
+2483 REM (TAH) //////////////////////////////////////////////////////////
2490 NEXT I
+2491 REM (TAH) Go to command prompt.
2500 GOTO 1270
2510 IMAGE ": ",3(3D," :")
2520 IMAGE ""
+2509 REM (TAH) \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
+2510 REM (TAH)  IMAGE ": ",3(3D," :")
+2520 REM (TAH)  IMAGE ""
+2521 REM (TAH) HP 2000 BASIC IMAGE... statements replaced by generic PRINT statements (see lines 24732483).
+2522 REM (TAH) //////////////////////////////////////////////////////////
+2526 REM (TAH)
+2527 REM (TAH) ***** PHASER ATTACK *****
+2528 REM (TAH)
+2529 REM (TAH) If there are no Klingons in this quadrant, then go to code for printing message about no Klingons in this quadrant.
2530 IF K3 <= 0 THEN 3670
+2539 REM (TAH) Else, if phaser control is not damaged, then go to code for checking ship computer
2540 IF D[4] >= 0 THEN 2570
+2549 REM (TAH) Else, print message about damaged device.
2550 PRINT "PHASER CONTROL IS DISABLED"
+2559 REM (TAH) Go to command prompt.
2560 GOTO 1270
+2569 REM (TAH) If ship computer is not damaged, then go to code for prompting for energy used.
2570 IF D[7] >= 0 THEN 2590
+2579 REM (TAH) Else, print message about damaged ship computer.
2580 PRINT " COMPUTER FAILURE HAMPERS ACCURACY"
2590 PRINT "PHASERS LOCKED ON TARGET. ENERGY AVAILABLE="E
2600 PRINT "NUMBER OF UNITS TO FIRE:";
+2589 REM (TAH) \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
+2590 REM (TAH)  PRINT "PHASERS LOCKED ON TARGET. ENERGY AVAILABLE="E
+2591 REM( (TAH) Changed formatting of output using generic string functions.
+2592 PRINT "PHASERS LOCKED ON TARGET. ENERGY AVAILABLE = "STR$(INT(E))
+2600 REM (TAH)  PRINT "NUMBER OF UNITS TO FIRE:";
+2601 REM (TAH) Removed colon from user prompt message (see line 2603).
+2602 REM (TAH) Print user prompt message.
+2603 PRINT "NUMBER OF UNITS TO FIRE";
+2604 REM (TAH) //////////////////////////////////////////////////////////
+2609 REM (TAH) Prompt user for amount of energy to be used in phaser attack.
2610 INPUT X
+2619 REM (TAH) If no energy is used, then go to command prompt.
2620 IF X <= 0 THEN 1270
+2629 REM (TAH) Else, if user asked for too much energy, go to code for prompting for energy again.
2630 IF EX<0 THEN 2570
+2639 REM (TAH) Compute energy spent on phaser attack.
2640 E=EX
+2649 REM (TAH) Compute damage done by Klingon (counter)attack. (Klingons get to fire first!)
2650 GOSUB 3790
+2659 REM (TAH) If ship computer is not damaged, then go to code for computing results of phaser attack.
2660 IF D[7] >= 0 THEN 2680
+2669 REM (TAH) Else, determine random malfunction of ship computer negatively affecting energy spent on phaser attack.
2670 X=X*RND(1)
+2679 REM (TAH) Compute results of phaser attack affecting each of the up to 3 Klingons in current quadrant.
2680 FOR I=1 TO 3
+2689 REM (TAH) If Klingon I is nonexistant, then it cannot be attacked.
2690 IF K[I,3] <= 0 THEN 2770
+2699 REM (TAH) Else, compute damage done by phaser attack (depending on energy spent [X], number of Klingons [K3], distance to Klingon and some element of chance).
2700 H=(X/K3/FND(0))*(2*RND(1))
+2709 REM (TAH) Apply damage done by phaser attack to Klingon I.
2710 K[I,3]=K[I,3]H
2720 PRINT USING 2730;H,K[I,1],K[I,2],K[I,3]
2730 IMAGE 4D," UNIT HIT ON KLINGON AT SECTOR ",D,",",D," (",3D," LEFT)"
+2719 REM (TAH) \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
+2720 REM (TAH)  PRINT USING 2730;H,K[I,1],K[I,2],K[I,3]
+2730 REM (TAH)  IMAGE 4D," UNIT HIT ON KLINGON AT SECTOR ",D,",",D," (",3D," LEFT)"
+2731 REM (TAH) Changed from HP 2000 TimeShared BASIC PRINT USING... and IMAGE... statements to generic PRINT statement and formatting of output using generic string functions.
+2732 REM (TAH) Print message about damage done to Klingon.
+2733 PRINT INT(H);"UNIT HIT ON KLINGON AT SECTOR "STR$(K[I,1])","STR$(K[I,2])" ("STR$(INT(K[I,3]))" LEFT)"
+2734 REM (TAH) //////////////////////////////////////////////////////////
+2739 REM (TAH) If attacked Klingon is still alife, then go to code for next iteration of phaser attack.
2740 IF K[I,3]>0 THEN 2770
+2749 REM (TAH) Print message about destroyed Klingon and erase it from records.
2750 GOSUB 3690
+2759 REM (TAH) If destroyed Klingon was last remaining Klingon in galaxy, then go to code for ending game victoriously.
2760 IF K9 <= 0 THEN 4040
2770 NEXT I
+2779 REM (TAH) If energy has dropped below zero, then go to code for ending game.
2780 IF E<0 THEN 4000
+2789 REM (TAH) Go to command prompt.
2790 GOTO 1270
+2796 REM (TAH)
+2797 REM (TAH) ***** PHOTON TORPEDO ATTACK *****
+2798 REM (TAH)
+2799 REM (TAH) If photon tubes are not damaged, then go to code for checking number of torpedoes left.
2800 IF D[5] >= 0 THEN 2830
+2809 REM (TAH) Else, print message about damaged photon tubes.
2810 PRINT "PHOTON TUBES ARE NOT OPERATIONAL"
+2819 REM (TAH) Go to command prompt.
2820 GOTO 1270
+2829 REM (TAH) If there is at least one torpedo to be fired left, then go to code for prompting for torpedo course.
2830 IF P>0 THEN 2860
+2839 REM (TAH) Else, print message about expended torpedoes.
2840 PRINT "ALL PHOTON TORPEDOES EXPENDED"
+2849 REM (TAH) Go to command prompt.
2850 GOTO 1270
2860 PRINT "TORPEDO COURSE (19):";
+2859 REM (TAH) \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
+2860 REM (TAH)  PRINT "TORPEDO COURSE (19):";
+2861 REM (TAH) Removed colon from user prompt message (see line 2863).
+2862 REM (TAH) Print user prompt message.
+2863 PRINT "TORPEDO COURSE (19)";
+2864 REM (TAH) //////////////////////////////////////////////////////////
+2869 REM (TAH) Prompt user for torpedo course.
2870 INPUT C1
+2879 REM (TAH) If torpedo course is 0, then go to command prompt (i.e. abort torpedo attack).
2880 IF C1=0 THEN 1270
+2889 REM (TAH) If user input lies outside possible course range, then go to code for prompting for torpedo course (again).
2890 IF C1<1 OR C1 >= 9 THEN 2860
+2894 REM (TAH) Set C2 to integer of C1 (i.e. torpedo course entered by user). Line number 2895 suggests later addition/change to original code!
2895 C2=INT(C1)
+2899 REM (TAH) Compute change in Y,X sector coordinate of torpedo (determined by course C1,C2).
2900 X1=C[C2,1]+(C[C2+1,1]C[C2,1])*(C1C2)
2910 X2=C[C2,2]+(C[C2+1,2]C[C2,2])*(C1C2)
+2919 REM (TAH) Set initial Y,X sector coordinates of torpedo to those of ship (that fires torpedo).
2920 X=S1
2930 Y=S2
+2939 REM (TAH) Decrease number of torpedoes left by 1.
2940 P=P1
+2949 REM (TAH) Print message about torpedo track.
2950 PRINT "TORPEDO TRACK:"
+2959 REM (TAH) Compute (next) position (i.e. Y,X sector coordinates) of torpedo (see lines 29002910).
2960 X=X+X1
2970 Y=Y+X2
+2979 REM (TAH) If torpedo has left current quadrant, go to code for printing message about missed hit.
2980 IF X<.5 OR X >= 8.5 OR Y<.5 OR Y >= 8.5 THEN 3420
2990 PRINT USING 3000;X,Y
3000 IMAGE 15X,D,",",D
+2989 REM (TAH) \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
+2990 REM (TAH)  PRINT USING 3000;X,Y
+3000 REM (TAH)  IMAGE 15X,D,",",D
+3001 REM (TAH) Changed from HP 2000 TimeShared BASIC PRINT USING... and IMAGE... statements to generic PRINT statement.
+3002 REM (TAH) Print position of torpedo.
+3003 PRINT " "STR$(X)","STR$(Y)
+3004 REM (TAH) //////////////////////////////////////////////////////////
+3009 REM (TAH) Set up A$ for checking for empty space in quadrant string (Q$, R$ or S$).
3010 A$=" "
+3019 REM (TAH) Set Z1,Z2 (for determining right point of checking in strings Q$, R$ or S$) to new Y,X sector coordinate of torpedo.
3020 Z1=X
3030 Z2=Y
+3039 REM (TAH) Compare empty space to new torpedo position Z1,Z2 (i.e. sector that torpedo moves to).
3040 GOSUB 5680
+3049 REM (TAH) If check was not successful (i.e. if torpedo hit something), then go to code for checking hit.
3050 IF Z3=0 THEN 3070
+3059 REM (TAH) Else (i.e. if torpedo did not hit anything), go to code for computing next position (i.e. Y,X sector coordinate) of torpedo.
3060 GOTO 2960
+3069 REM (TAH) Set up A$ for checking for Klingon in quadrant string (Q$, R$ or S$).
3070 A$="+++"
+3079 REM (TAH) Set Z1,Z2 (for determining right point of checking in strings Q$, R$ or S$) to new Y,X sector coordinate of torpedo.
3080 Z1=X
3090 Z2=Y
+3099 REM (TAH) Compare Klingon to new torpedo position Z1,Z2 (i.e. sector that torpedo moves to).
3100 GOSUB 5680
+3109 REM (TAH) If check was not successful (i.e. if torpedo did not hit Klingon), then go to code for checking hit.
3110 IF Z3=0 THEN 3220
+3119 REM (TAH) Print message about destroyed Klingon.
3120 PRINT "*** KLINGON DESTROYED ***"
+3129 REM (TAH) Decrease number of Klingons in current quadrant and in galaxy.
3130 K3=K31
3140 K9=K91
+3149 REM (TAH) If all Klingons have been destroyed now, then go to code for printing message about game success.
3150 IF K9 <= 0 THEN 4040
+3159 REM (TAH) Determine which of the up to 3 Klingons in current quadrant was hit by looping through their Y,X sector coordinates.
3160 FOR I=1 TO 3
+3169 REM (TAH) If Y (!) sector coordinates of Klingon I and torpedo do not match, then go to code for next iteration of loop.
3170 IF INT(X+.5) <> K[I,1] THEN 3190
3180 IF INT(Y+.5)=K[I,2] THEN 3200
+3179 REM (TAH) \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
+3180 REM (TAH)  IF INT(Y+.5)=K[I,2] THEN 3200
+3181 REM (TAH) Jumping out of FOR...NEXT loop is considered illegal by some BASIC interpreters.
+3182 REM (TAH) Workaround is to set shields of Klingon I to zero here if X (!) sector coordinates of Klingon I and of torpedo match.
+3183 IF INT(Y+.5)=K[I,2] THEN K[I,3]=0
+3184 REM (TAH) //////////////////////////////////////////////////////////
3190 NEXT I
3200 K[I,3]=0
+3199 REM (TAH) \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
+3200 REM (TAH)  K[I,3]=0
+3201 REM (TAH) Removed line because setting shields of Klingon I occurs in loop (see line 3183).
+3202 REM (TAH) //////////////////////////////////////////////////////////
+3209 REM (TAH) Go to code for removing destroyed Klingon ship from map.
3210 GOTO 3360
+3219 REM (TAH) Set up A$ for checking for star in quadrant string (Q$, R$ or S$).
3220 A$=" * "
+3229 REM (TAH) Set Z1,Z2 (for determining right point of checking in strings Q$, R$ or S$) to new Y,X sector coordinate of torpedo.
3230 Z1=X
3240 Z2=Y
+3249 REM (TAH) Compare star to new torpedo position Z1,Z2 (i.e. sector that torpedo moves to).
3250 GOSUB 5680
+3259 REM (TAH) If check was not successful (i.e. if torpedo did not hit star), then go to code for checking hit.
3260 IF Z3=0 THEN 3290
+3269 REM (TAH) Else print message about trying to destroy stars.
3270 PRINT "YOU CAN'T DESTROY STARS SILLY"
+3279 REM (TAH) go to code for printing message about missed hit.
3280 GOTO 3420
+3289 REM (TAH) Set up A$ for checking for starbase in quadrant string (Q$, R$ or S$).
3290 A$=">!<"
+3299 REM (TAH) Set Z1,Z2 (for determining right point of checking in strings Q$, R$ or S$) to new Y,X sector coordinate of torpedo.
3300 Z1=X
3310 Z2=Y
+3319 REM (TAH) Compare starbase to new torpedo position Z1,Z2 (i.e. sector that torpedo moves to).
3320 GOSUB 5680
+3329 REM (TAH) If check was not successful (i.e. if torpedo did not hit starbase), then go to code for computing (next) position of torpedo.
3330 IF Z3=0 THEN 2960
3340 PRINT "*** STAR BASE DESTROYED *** .......CONGRATULATIONS"
+3339 REM (TAH) \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
+3340 REM (TAH)  PRINT "*** STAR BASE DESTROYED *** .......CONGRATULATIONS"
+3341 REM (TAH) Changed spelling to make it consistent throughout game.
+3342 REM (TAH) Print message about destruction of starbase.
+3343 PRINT "*** STARBASE DESTROYED *** .......CONGRATULATIONS"
+3344 REM (TAH) //////////////////////////////////////////////////////////
3350 B3=B31
+3358 REM (TAH) Remove destroyed Klingon or starbase from map...
+3359 REM (TAH) Set up A$ for inserting empty space into quadrant string (Q$, R$ or S$).
3360 A$=" "
+3369 REM (TAH) Set Z1,Z2 (for determining right point of checking in strings Q$, R$ or S$) to last Y,X sector coordinate of torpedo.
3370 Z1=INT(X+.5)
3380 Z2=INT(Y+.5)
+3389 REM (TAH) Insert empty space into quadrant string (Q$, R$ or S$).
3390 GOSUB 5510
+3399 REM (TAH) Update the integer holding the number of Klingons, starbases and stars in quadrant I,J.
3400 G[Q1,Q2]=K3*100+B3*10+S3
+3409 REM (TAH) Go to code for computing damage by Klingon attack.
3410 GOTO 3430
+3419 REM (TAH) Print message about missed hit.
3420 PRINT "TORPEDO MISSED"
+3429 REM (TAH) Compute damage done by Klingon attack.
3430 GOSUB 3790
+3439 REM (TAH) If energy has dropped below zero, then go to code for ending game.
3440 IF E<0 THEN 4000
+3449 REM (TAH) Go to command prompt.
3450 GOTO 1270
+3456 REM (TAH)
+3457 REM (TAH) ***** SHIELD CONTROL *****
+3458 REM (TAH)
+3459 REM (TAH) If shield control is not damaged, then go to code for prompting for energy.
3460 IF D[7] >= 0 THEN 3490
+3469 REM (TAH) Else, print message about damaged shield control.
3470 PRINT "SHIELD CONTROL IS NONOPERATIONAL"
+3479 REM (TAH) Go to command prompt.
3480 GOTO 1270
3490 PRINT "ENERGY AVAILABLE ="E+S" NUMBER OF UNITS TO SHIELDS:";
+3489 REM (TAH) \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
+3490 REM (TAH)  PRINT "ENERGY AVAILABLE ="E+S" NUMBER OF UNITS TO SHIELDS:";
+3491 REM (TAH) Changed formatting of output using generic string functions and removed colon from user prompt message.
+3492 PRINT "ENERGY AVAILABLE = "STR$(INT(E+S))" NUMBER OF UNITS TO SHIELDS";
+3493 REM (TAH) //////////////////////////////////////////////////////////
+3499 REM (TAH) Prompt user for amount of energy to be redirected to shields.
3500 INPUT X
3510 IF X <= 0 THEN 1270
+3509 REM (TAH) \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
+3510 REM (TAH)  IF X <= 0 THEN 1270
+3511 REM (TAH) Changed so that user can reset shields to zero.
+3512 REM (TAH) If input is less than zero, then go to command prompt.
+3513 IF X < 0 THEN 1270
+3514 REM (TAH) //////////////////////////////////////////////////////////
+3519 REM (TAH) If total of energy and shields minus amount to be directed to shields is less than zero, then go to code for prompting user for energy (again).
3520 IF E+SX<0 THEN 3490
+3529 REM (TAH) Else, adjust energy and shields according to user input.
3530 E=E+SX
3540 S=X
+3549 REM (TAH) Go to command prompt.
3550 GOTO 1270
+3556 REM (TAH)
+3557 REM (TAH) ***** DAMAGE CONTROL REPORT *****
+3558 REM (TAH)
+3559 REM (TAH) If damage control is not damaged, then go to code for printing damage control report.
3560 IF D[6] >= 0 THEN 3590
+3569 REM (TAH) Else, print message about damaged damage control.
3570 PRINT "DAMAGE CONTROL REPORT IS NOT AVAILABLE"
+3579 REM (TAH) Go to command prompt.
3580 GOTO 1270
+3589 REM (TAH) Print header of damage control report.
3590 PRINT
3600 PRINT "DEVICE STATE OF REPAIR"
+3609 REM (TAH) Loop through all 8 devices.
3610 FOR R1=1 TO 8
+3619 REM (TAH) Print name of device R1.
3620 GOSUB 5610
3630 PRINT "",D[R1]
+3629 REM (TAH) \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
+3630 REM (TAH)  PRINT "",D[R1]
+3631 REM (TAH) Changed formatting of output using generic string functions.
+3632 REM (TAH) Print state of repair of device R1.
+3633 PRINT "",INT(D[R1])
+3634 REM (TAH) //////////////////////////////////////////////////////////
3640 NEXT R1
3650 PRINT
+3659 REM (TAH) Go to command prompt.
3660 GOTO 1270
+3666 REM (TAH)
+3667 REM (TAH) ***** NO KLINGONS HERE *****
+3668 REM (TAH)
+3669 REM (TAH) Print message about no Klingons in current quadrant.
3670 PRINT "SHORT RANGE SENSORS REPORT NO KLINGONS IN THIS QUADRANT"
+3679 REM (TAH) Go to command prompt.
3680 GOTO 1270
3690 PRINT USING 3700;K[I,1],K[I,2]
3700 IMAGE "KLINGON AT SECTOR ",D,",",D," DESTROYED ****"
+3684 REM (TAH)
+3685 REM (TAH) ***** KLINGON DESTROYED *****
+3686 REM (TAH)
+3687 REM (TAH) Print message about destroyed Klingon and erase it from records...
+3688 REM (TAH) This subroutine is called only when Klingon is destroyed by phaser attack (not by torpedo, see lines 31203210).
+3689 REM (TAH) \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
+3690 REM (TAH)  PRINT USING 3700;K[I,1],K[I,2]
+3700 REM (TAH)  IMAGE "KLINGON AT SECTOR ",D,",",D," DESTROYED ****"
+3701 REM (TAH) Changed from HP 2000 TimeShared BASIC PRINT USING... and IMAGE... statements to generic PRINT statement and formatting of output using generic string functions.
+3702 REM (TAH) Print message about destruction of Klingon.
+3703 PRINT "KLINGON AT SECTOR "STR$(K[I,1])","STR$(K[I,2])" DESTROYED ****"
+3704 REM (TAH) //////////////////////////////////////////////////////////
+3709 REM (TAH) Decrease number of Klingons in current quadrant and in galaxy.
3710 K3=K31
3720 K9=K91
+3729 REM (TAH) Set up A$ for inserting empty space into quadrant string (Q$, R$ or S$).
3730 A$=" "
+3739 REM (TAH) Set Z1,Z2 (for determining right point of checking in strings Q$, R$ or S$) to Y,X sector of Klingon.
3740 Z1=K[I,1]
3750 Z2=K[I,2]
+3759 REM (TAH) Insert empty space into quadrant string (Q$, R$ or S$).
3760 GOSUB 5510
+4769 REM (TAH) Update the integer holding the number of Klingons, starbases and stars in quadrant I,J.
3770 G[Q1,Q2]=K3*100+B3*10+S3
3780 RETURN
+3788 REM (TAH) Compute damage done by Klingon attack...
+3789 REM (TAH) If ship is not DOCKED skip printing message and returning from subroutine (and go to code for computing damage).
3790 IF C$ <> "DOCKED" THEN 3820
3800 PRINT "STAR BASE SHIELDS PROTECT THE ENTERPRISE"
+3799 REM (TAH) \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
+3800 REM (TAH)  PRINT "STAR BASE SHIELDS PROTECT THE ENTERPRISE"
+3801 REM (TAH) Changed spelling to make it consistent throughout game.
+3802 REM (TAH) Print message about protection by starbase.
+3803 PRINT "STARBASE SHIELDS PROTECT THE ENTERPRISE"
+3804 REM (TAH) //////////////////////////////////////////////////////////
3810 RETURN
+3819 REM (TAH) If there are no Klingons in current quadrant skip damage computing (and go to code for returning from subroutine).
3820 IF K3 <= 0 THEN 3910
+3829 REM (TAH) Determine damage to ship by each of up to the max. 3 Klingons in current quadrant.
3830 FOR I=1 TO 3
+3839 REM (TAH) If Klingon I is nonexistant (i.e. K[I,3] equal/less than 0), then it cannot do any damage.
3840 IF K[I,3] <= 0 THEN 3900
3850 H=(K[I,3]/FND(0))*(2*RND(1))
+3859 REM (TAH) Apply damage done to ship shields.
3860 S=SH
3870 PRINT USING 3880;H,K[I,1],K[I,2],S
3880 IMAGE 4D," UNIT HIT ON ENTERPRISE AT SECTOR ",D,",",D," (",4D," LEFT)"
3890 IF S<0 THEN 4000
+3831 REM (TAH) \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
+3870 REM (TAH)  PRINT USING 3880;H,K[I,1],K[I,2],S
+3880 REM (TAH)  IMAGE 4D," UNIT HIT ON ENTERPRISE AT SECTOR ",D,",",D," (",4D," LEFT)"
+3881 REM (TAH) Changed from HP 2000 TimeShared BASIC PRINT USING... and IMAGE... statements to generic PRINT statement and use of INT.
+3882 PRINT INT(H);"UNIT HIT ON ENTERPRISE AT SECTOR "STR$(K[I,1])","STR$(K[I,2])" ("STR$(INT(S))" LEFT)"
+3890 REM (TAH)  IF S<0 THEN 4000
+3891 REM (TAH) Jumping out of FOR...NEXT loop (see line 3890) is considered illegal by some BASIC interpreters.
+3892 REM (TAH) The problem is that once ship has been destroyed (i.e. when S is less than 0), no more damage from other Klingons should be computed and no more according messages should be printed.
+3893 REM (TAH) Workaround is to terminate loop once S drops below 0 by setting I to 3 (see line 3892) and to check for S less than 0 after the loop (see line 3902).
+3894 IF S<0 THEN I=3
+3895 REM (TAH) //////////////////////////////////////////////////////////
3900 NEXT I
+3901 REM (TAH) \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
+3902 REM (TAH) Added conditional to check whether ship has been destroyed (compensating for removed line 3890).
+3903 IF S<0 THEN 4000
+3904 REM (TAH) //////////////////////////////////////////////////////////
3910 RETURN
+3916 REM (TAH)
+3917 REM (TAH) ***** ENTERPRISE MAROONED / DESTROYED *****
+3918 REM (TAH)
+3919 REM (TAH) Print message about marooning of ship.
3920 PRINT "THE ENTERPRISE IS DEAD IN SPACE. IF YOU SURVIVE ALL IMPENDING"
3930 PRINT "ATTACK YOU WILL BE DEMOTED TO THE RANK OF PRIVATE"
+3929 REM (TAH) \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
+3930 REM (TAH)  PRINT "ATTACK YOU WILL BE DEMOTED TO THE RANK OF PRIVATE"
+3931 REM (TAH) Fixed typo.
+3932 PRINT "ATTACKS YOU WILL BE DEMOTED TO THE RANK OF PRIVATE"
+3933 REM (TAH) //////////////////////////////////////////////////////////
+3939 REM (TAH) If there are no Klingons in current quadrant go to printing message about remaining Klingons in galaxy.
3940 IF K3 <= 0 THEN 4020
+3949 REM (TAH) If there are Klingons in current quadrant, then compute damage done by Klingon attack.
3950 GOSUB 3790
+3959 REM (TAH) Go to code checking whether there are Klingons in current quadrant.
3960 GOTO 3940
3970 PRINT
3980 PRINT "IT IS STARDATE"T
+3979 REM (TAH) \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
+3980 REM (TAH)  PRINT "IT IS STARDATE"T
+3981 REM (TAH) Changed formatting of output using generic string functions.
+3982 REM (TAH) Print stardate.
+3983 PRINT "IT IS STARDATE "STR$(T)
+3984 REM (TAH) //////////////////////////////////////////////////////////
+3989 REM (TAH) Go to printing message about remaining Klingons in galaxy.
3990 GOTO 4020
+3999 REM (TAH) Print message about destruction of ship.
4000 PRINT
4010 PRINT "THE ENTERPRISE HAS BEEN DESTROYED. THE FEDERATION WILL BE CONQUERED"
4020 PRINT "THERE ARE STILL"K9" KLINGON BATTLE CRUISERS"
+4019 REM (TAH) \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
+4020 REM (TAH)  PRINT "THERE ARE STILL"K9" KLINGON BATTLE CRUISERS"
+4021 REM (TAH) Changed formatting of output using generic string functions.
+4022 PRINT "THERE ARE STILL "STR$(K9)" KLINGON BATTLE CRUISERS"
+4028 REM (TAH) //////////////////////////////////////////////////////////
+4029 REM (TAH) Go to start of game.
4030 GOTO 230
+4036 REM (TAH)
+4037 REM (TAH) ***** GAME WON *****
+4038 REM (TAH)
+4039 REM (TAH) Print message about game success...
4040 PRINT
4050 PRINT "THE LAST KLINGON BATTLE CRUISER IN THE GALAXY HAS BEEN DESTROYED"
4060 PRINT "THE FEDERATION HAS BEEN SAVED !!!"
4070 PRINT
4080 PRINT "YOUR EFFICIENCY RATING ="((K7/(TT0))*1000)
4090 T1=TIM(0)+TIM(1)*60
4100 PRINT "YOUR ACTUAL TIME OF MISSION ="INT((((T1T7)*.4)T7)*100)" MINUTES"
+4079 REM (TAH) \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
+4080 REM (TAH)  PRINT "YOUR EFFICIENCY RATING ="((K7/(TT0))*1000)
+4081 REM (TAH) Changed formatting of output using generic string functions.
+4082 REM (TAH) Print message about efficiency rating which is ratio of total number of Klingons to ingame time.
+4083 PRINT "YOUR EFFICIENCY RATING = "STR$(INT((K7/(TT0))*1000))
+4090 REM (TAH)  T1=TIM(0)+TIM(1)*60
+4091 REM (TAH) Changed from HP 2000 TimeShared BASIC function TIM (see line 2, p. 329) giving T1 as elapsed minutes since midnight to Chipmunk BASIC function time$ (see line 4) and generic string functions.
+4092 T1=INT(MID$(TIME$,4,2))+60*INT(LEFT$(TIME$,2))
+4100 REM (TAH)  PRINT "YOUR ACTUAL TIME OF MISSION ="INT((((T1T7)*.4)T7)*100)" MINUTES"
+4101 REM (TAH) Changed formatting of output using generic string functions.
+4102 REM (TAH) Print game time in minutes.
+4103 PRINT "YOUR ACTUAL TIME OF MISSION = "STR$(T1T7)" MINUTES"
+4104 REM (TAH) //////////////////////////////////////////////////////////
+4109 REM (TAH) Go to start of game.
4110 GOTO 230
+4115 REM (TAH)
+4116 REM (TAH) ***** PRINT MAIN SCREEN (SHIP CONDITION, QUADRANT MAP, DETAILS) *****
+4117 REM (TAH)
+4118 REM (TAH) Check if ship is docked on starbase, i.e. if a starbase (>!<) is next to ship (at S1,S2)...
+4119 REM (TAH) Perform check for 9 Y,X sector coordinates with ship at center and next to it.
4120 FOR I=S11 TO S1+1
4130 FOR J=S21 TO S2+1
+4139 REM (TAH) Skip this sector if it is outside current quadrant (i.e. Y,X sector coordinate is less than 1 or greater then 8).
4140 IF I<1 OR I>8 OR J<1 OR J>8 THEN 4200
+4149 REM (TAH) Set up A$ for checking for starbase.
4150 A$=">!<"
+4159 REM (TAH) Set Z1,Z2 (for determining right point of checking inside strings Q$, R$ or S$) to Y,X sector coordinate to be checked.
4160 Z1=I
4170 Z2=J
+4179 REM (TAH) Compare starbase to sector coordinates Z1,Z2.
4180 GOSUB 5680
4190 IF Z3=1 THEN 4240
+4181 REM (TAH) \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
+4190 REM (TAH)  IF Z3=1 THEN 4240
+4191 REM (TAH) Jumping out of FOR...NEXT loop (see line 4190) is considered illegal by some BASIC interpreters.
+4192 REM (TAH) Calling the subroutine in line 4180 in every iteration of the loop can reset Z3 to 0 (meaning no starbase was found) after a starbase has been found on an earlier iteration of the loop!
+4193 REM (TAH) The workaround is to terminate the loop as soon as starbase has been found (i.e. when Z3=1) by setting I and J to the max value and check for Z3=1 after the loop (see line 4214).
+4194 IF Z3=1 THEN J=S2+1
+4195 IF Z3=1 THEN I=S1+1
+4199 REM (TAH) //////////////////////////////////////////////////////////
4200 NEXT J
4210 NEXT I
+4211 REM (TAH) Determine condition of ship (DOCKED, GREEN, YELLOW or RED)...
+4212 REM (TAH) \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
+4213 REM (TAH) Added conditional to check whether ship is next to starbase (compensating for removed line 4190).
+4214 IF Z3=1 THEN 4240
+4215 REM (TAH) //////////////////////////////////////////////////////////
+4219 REM (TAH) Ship is not docked on starbase. Curiously, this variable is never checked/used anywhere in the code!
4220 D0=0
+4229 REM (TAH) Skip code for ship condition DOCKED (and go to code for determining status RED, YELLOW or GREEN).
4230 GOTO 4310
+4239 REM (TAH) Ship is docked on starbase. Curiously, this variable is never checked/used anywhere in the code!
4240 D0=1
+4249 REM (TAH) Set ship condition to DOCKED.
4250 C$="DOCKED"
+4259 REM (TAH) Replenish ship energy.
4260 E=3000
+4269 REM (TAH) Replenish torpedoes.
4270 P=10
+4279 REM (TAH) Print message about dropped shields.
4280 PRINT "SHIELDS DROPPED FOR DOCKING PURPOSES"
+4281 REM (TAH) Set ship shields to zero.
4290 S=0
+4299 REM (TAH) Skip code for ship condition GREEN, RED or YELLOW (because it is DOCKED; go to code for checking short range sensors).
4300 GOTO 4380
+4309 REM (TAH) Go to condition RED if one or more Klingons are present in current quadrant.
4310 IF K3>0 THEN 4350
+4319 REM (TAH) Go to condition YELLOW if ship energy is less than one tenth of initial ship energy.
4320 IF E= 0 THEN 4430
+4389 REM (TAH) Print warning message about damaged short range sensors.
4390 PRINT
4400 PRINT "*** SHORT RANGE SENSORS ARE OUT ***"
4410 PRINT
+4419 REM (TAH) Skip printing of quadrant map and detailed info if short range sensors are not working (and go to code for returning from subroutine).
4420 GOTO 4530
4430 PRINT USING 4540
4440 PRINT USING 4550;Q$[1,3],Q$[4,6],Q$[7,9],Q$[10,12],Q$[13,15],Q$[16,18],Q$[19,21],Q$[22,24]
4450 PRINT USING 4560;Q$[25,27],Q$[28,30],Q$[31,33],Q$[34,36],Q$[37,39],Q$[40,42],Q$[43,45],Q$[46,48],T
4460 PRINT USING 4570;Q$[49,51],Q$[52,54],Q$[55,57],Q$[58,60],Q$[61,63],Q$[64,66],Q$[67,69],Q$[70,72],C$
4470 PRINT USING 4580;R$[1,3],R$[4,6],R$[7,9],R$[10,12],R$[13,15],R$[16,18],R$[19,21],R$[22,24],Q1,Q2
4480 PRINT USING 4590;R$[25,27],R$[28,30],R$[31,33],R$[34,36],R$[37,39],R$[40,42],R$[43,45],R$[46,48],S1,S2
4490 PRINT USING 4600;R$[49,51],R$[52,54],R$[55,57],R$[58,60],R$[61,63],R$[64,66],R$[67,69],R$[70,72],E
4500 PRINT USING 4610;S$[1,3],S$[4,6],S$[7,9],S$[10,12],S$[13,15],S$[16,18],S$[19,21],S$[22,24],P
4510 PRINT USING 4620;S$[25,27],S$[28,30],S$[31,33],S$[34,36],S$[37,39],S$[40,42],S$[43,45],S$[46,48],S
4520 PRINT USING 4540
4530 RETURN
4540 IMAGE ""
4550 IMAGE 8(X,3A)
4560 IMAGE 8(X,3A),8X,"STARDATE",8X,5D
4570 IMAGE 8(X,3A),8X,"CONDITION",8X,6A
4580 IMAGE 8(X,3A),8X,"QUADRANT",9X,D,",",D
4590 IMAGE 8(X,3A),8X,"SECTOR",11X,D,",",D
4600 IMAGE 8(X,3A),8X,"ENERGY",9X,6D
4610 IMAGE 8(X,3A),8X,"PHOTON TORPEDOES",3D
4620 IMAGE 8(X,3A),8X,"SHIELDS",8X,6D
+4428 REM (TAH) ***** PRINT QUADRANT MAP AND DETAILED INFO *****
+4429 REM (TAH) \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
+4430 REM (TAH)  PRINT USING 4540
+4431 REM (TAH) Changed from HP 2000 TimeShared BASIC PRINT USING... and IMAGE... statements (see lines 4540 to 4620) to FOR...NEXT loops, generic PRINT statements and string functions and formatting of output.
+4433 REM (TAH) Every row of sectors (x,1 to x,8) is printed using a stepped FOR...NEXT loop of eight iterations, printing the three chars representation of each sector from Q$, R$ and S$. Detailed info is appended at the end of sector lines.
+4435 REM (TAH) Lines above and below quadrant map are printed using generic PRINT statements.
+4436 PRINT ""
+4440 REM (TAH)  PRINT USING 4550;Q$[1,3],Q$[4,6],Q$[7,9],Q$[10,12],Q$[13,15],Q$[16,18],Q$[19,21],Q$[22,24]
+4441 FOR I=1 TO 22 STEP 3
+4442 PRINT " ";MID$(Q$,I,3);
+4443 NEXT I
+4444 PRINT " "
+4450 REM (TAH)  PRINT USING 4560;Q$[25,27],Q$[28,30],Q$[31,33],Q$[34,36],Q$[37,39],Q$[40,42],Q$[43,45],Q$[46,48],T
+4451 FOR I=25 TO 46 STEP 3
+4452 PRINT " ";MID$(Q$,I,3);
+4453 NEXT I
+4454 PRINT " ","STARDATE "STR$(T)
+4460 REM (TAH)  PRINT USING 4570;Q$[49,51],Q$[52,54],Q$[55,57],Q$[58,60],Q$[61,63],Q$[64,66],Q$[67,69],Q$[70,72],C$
+4461 FOR I=49 TO 70 STEP 3
+4462 PRINT " ";MID$(Q$,I,3);
+4463 NEXT I
+4464 PRINT " ","CONDITION "C$
+4470 REM (TAH)  PRINT USING 4580;R$[1,3],R$[4,6],R$[7,9],R$[10,12],R$[13,15],R$[16,18],R$[19,21],R$[22,24],Q1,Q2
+4471 FOR I=1 TO 22 STEP 3
+4472 PRINT " ";MID$(R$,I,3);
+4473 NEXT I
+4474 PRINT " ","QUADRANT "STR$(Q1)","STR$(Q2)
+4480 REM (TAH)  PRINT USING 4590;R$[25,27],R$[28,30],R$[31,33],R$[34,36],R$[37,39],R$[40,42],R$[43,45],R$[46,48],S1,S2
+4481 FOR I=25 TO 46 STEP 3
+4482 PRINT " ";MID$(R$,I,3);
+4483 NEXT I
+4484 PRINT " ","SECTOR "STR$(S1)","STR$(S2)
+4490 REM (TAH)  PRINT USING 4600;R$[49,51],R$[52,54],R$[55,57],R$[58,60],R$[61,63],R$[64,66],R$[67,69],R$[70,72],E
+4491 FOR I=49 TO 70 STEP 3
+4492 PRINT " ";MID$(R$,I,3);
+4493 NEXT I
+4494 PRINT " ","ENERGY "INT(STR$(E))
+4500 REM (TAH)  PRINT USING 4610;S$[1,3],S$[4,6],S$[7,9],S$[10,12],S$[13,15],S$[16,18],S$[19,21],S$[22,24],P
+4501 FOR I=1 TO 22 STEP 3
+4502 PRINT " ";MID$(S$,I,3);
+4503 NEXT I
+4504 PRINT " ","PHOTON TORPEDOES "STR$(P)
+4510 REM (TAH)  PRINT USING 4620;S$[25,27],S$[28,30],S$[31,33],S$[34,36],S$[37,39],S$[40,42],S$[43,45],S$[46,48],S
+4511 FOR I=25 TO 46 STEP 3
+4512 PRINT " ";MID$(S$,I,3);
+4513 NEXT I
+4514 PRINT " ","SHIELDS "INT(STR$(S))
+4520 REM (TAH)  PRINT USING 4540
+4521 PRINT ""
+4522 REM (TAH) //////////////////////////////////////////////////////////
+4530 RETURN
+4539 REM (TAH) \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
+4540 REM (TAH)  IMAGE ""
+4550 REM (TAH)  IMAGE 8(X,3A)
+4560 REM (TAH)  IMAGE 8(X,3A),8X,"STARDATE",8X,5D
+4570 REM (TAH)  IMAGE 8(X,3A),8X,"CONDITION",8X,6A
+4580 REM (TAH)  IMAGE 8(X,3A),8X,"QUADRANT",9X,D,",",D
+4590 REM (TAH)  IMAGE 8(X,3A),8X,"SECTOR",11X,D,",",D
+4600 REM (TAH)  IMAGE 8(X,3A),8X,"ENERGY",9X,6D
+4610 REM (TAH)  IMAGE 8(X,3A),8X,"PHOTON TORPEDOES",3D
+4620 REM (TAH)  IMAGE 8(X,3A),8X,"SHIELDS",8X,6D
+4621 REM (TAH) HP 2000 BASIC IMAGE... statements replaced by generic PRINT statements (see lines 44374521).
+4622 REM (TAH) //////////////////////////////////////////////////////////
+4624 REM (TAH)
+4625 REM (TAH) ***** SHIP COMPUTER *****
+4628 REM (TAH)
+4629 REM (TAH) If ship computer is not damaged, then go to code for prompting user for function.
4630 IF D[8] >= 0 THEN 4660
+4639 REM (TAH) Else, print message about damages ship computer.
4640 PRINT "COMPUTER DISABLED"
+4649 REM (TAH) Go to command prompt.
4650 GOTO 1270
+4659 REM (TAH) Prompt user for function to be performed.
4660 PRINT "COMPUTER ACTIVE AND AWAITING COMMAND";
4670 INPUT A
4680 GOTO A+1 OF 4740,4830,4880
+4679 REM (TAH) \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
+4680 REM (TAH)  GOTO A+1 OF 4740,4830,4880
+4681 REM (TAH) Changed from HP 2000 TimeShared BASIC GOTO...OF... statement to generic ON...GOTO... statement.
+4682 REM (TAH) Go to code for galactic record, status report and photon torpedo data.
+4683 ON A+1 GOTO 4740,4830,4880
+4684 REM (TAH) //////////////////////////////////////////////////////////
+4689 REM (TAH) If user input allowed no jump in code (see lines 4684), then print message about available functions.
4690 PRINT "FUNCTIONS AVAILABLE FROM COMPUTER"
4700 PRINT " 0 = CUMULATIVE GALACTIC RECORD"
4710 PRINT " 1 = STATUS REPORT"
4720 PRINT " 2 = PHOTON TORPEDO DATA"
+4729 REM (TAH) Go to code prompting user for function to be performed.
4730 GOTO 4660
4740 PRINT USING 4750;Q1,Q2
4750 IMAGE "COMPUTER RECORD OF GALAXY FOR QUADRANT ",D,",",D
4760 PRINT USING 5330
4770 PRINT USING 5360
+4736 REM (TAH)
+4737 REM (TAH) ***** GALACTIC RECORD *****
+4738 REM (TAH)
+4739 REM (TAH) \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
+4740 REM (TAH)  PRINT USING 4750;Q1,Q2
+4750 REM (TAH)  IMAGE "COMPUTER RECORD OF GALAXY FOR QUADRANT ",D,",",D
+4751 REM (TAH) Changed from HP 2000 TimeShared BASIC PRINT USING... and IMAGE... statements to generic PRINT statements and string functions.
+4752 REM (TAH) Print header of galactic record.
+4753 PRINT "COMPUTER RECORD OF GALAXY FOR QUADRANT "STR$(Q1)","STR$(Q2)
+4760 REM (TAH)  PRINT USING 5330
+4761 PRINT " 1 2 3 4 5 6 7 8"
+4770 REM (TAH)  PRINT USING 5360
+4771 PRINT "        "
+4772 REM (TAH) //////////////////////////////////////////////////////////
+4779 REM (TAH) Loop through all 8 rows of quadrants (Y axis).
4780 FOR I=1 TO 8
4790 PRINT USING 5350;I,Z[I,1],Z[I,2],Z[I,3],Z[I,4],Z[I,5],Z[I,6],Z[I,7],Z[I,8]
4800 PRINT USING 5360
+4789 REM (TAH) \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
+4790 REM (TAH)  PRINT USING 5350;I,Z[I,1],Z[I,2],Z[I,3],Z[I,4],Z[I,5],Z[I,6],Z[I,7],Z[I,8]
+4791 REM (TAH) Changed from HP 2000 TimeShared BASIC PRINT USING... and IMAGE... statements to FOR...NEXT loops, generic PRINT statements and string functions.
+4792 REM (TAH) Print number of row.
+4793 PRINT I;
+4794 REM (TAH) Loop through all 8 columns of quadrants (X axis).
+4795 FOR J = 1 TO 8
+4796 REM (TAH)Print the 3 digit code (with leading zeroes, if necessary) for number of Klingons, starbase and stars for every quadrant.
+4797 PRINT " ";RIGHT$(STR$(Z[I,J]+1000),3);
+4798 NEXT J
+4799 PRINT
+4800 REM (TAH)  PRINT USING 5360
+4801 PRINT "        "
+4802 REM (TAH) //////////////////////////////////////////////////////////
4810 NEXT I
+4819 REM (TAH) Go to command prompt.
4820 GOTO 1270
4830 PRINT "\012 STATUS REPORT\012"
4840 PRINT "NUMBER OF KLINGONS LEFT ="K9
4850 PRINT "NUMBER OF STARDATES LEFT ="(T0+T9)T
4860 PRINT "NUMBER OF STARBASES LEFT ="B9
+4829 REM (TAH) \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
+4830 REM (TAH)  PRINT "\012 STATUS REPORT\012"
+4831 REM (TAH) Changed from single PRINT statement with control codes for line feed to three separate PRINT statements.
+4832 PRINT
+4833 PRINT " STATUS REPORT"
+4834 PRINT
+4840 REM (TAH)  PRINT "NUMBER OF KLINGONS LEFT ="K9
+4841 PRINT "NUMBER OF KLINGONS LEFT = "STR$(K9)
+4850 REM (TAH)  PRINT "NUMBER OF STARDATES LEFT ="(T0+T9)T
+4851 PRINT "NUMBER OF STARDATES LEFT = "STR$((T0+T9)T)
+4860 REM (TAH)  PRINT "NUMBER OF STARBASES LEFT ="B9
+4861 PRINT "NUMBER OF STARBASES LEFT = "STR$(B9)
+4862 REM (TAH) Changed formatting of output using generic string functions.
+4863 REM (TAH) //////////////////////////////////////////////////////////
+4869 REM (TAH) Go to code for printing damage control report...
4870 GOTO 3560
4880 PRINT
+4877 REM (TAH)
+4878 REM (TAH) ***** SHIP COMPUTER: TORPEDO DIRECTION / DISTANCE *****
+4879 REM (TAH)
+4880 PRINT
+4889 REM (TAH) It is not clear what H8 is supposed to indicate since it never changes during the game (see lines 355, 4890, 5250 and 5270).
4890 H8=0
+4999 REM (TAH) Loop through all (up to) 3 Klingons in current quadrant.
4900 FOR I=1 TO 3
+4909 REM (TAH) If Klingon I is nonexistant, then go to code for next iteration of loop.
4910 IF K[I,3] <= 0 THEN 5260
+4919 REM (TAH) Set C1, A, W1 and X to Y,X sector coordinates of ship and Klingon I.
4920 C1=S1
4930 A=S2
4940 W1=K[I,1]
4950 X=K[I,2]
4960 GOTO 5010
4970 PRINT USING 4980;Q1,Q2,S1,S2
4980 IMAGE "YOU ARE AT QUADRANT ( ",D,",",D," ) SECTOR ( ",D,",",D," )"
4990 PRINT "SHIP'S & TARGET'S COORDINATES ARE";
5000 INPUT C1,A,W1,X
5010 X=XA
5020 A=C1W1
5030 IF X<0 THEN 5130
5040 IF A<0 THEN 5190
5050 IF X>0 THEN 5070
5060 IF A=0 THEN 5150
5070 C1=1
5080 IF ABS(A) <= ABS(X) THEN 5110
5090 PRINT "DIRECTION ="C1+(((ABS(A)ABS(X))+ABS(A))/ABS(A))
5100 GOTO 5240
5110 PRINT "DIRECTION ="C1+(ABS(A)/ABS(X))
5120 GOTO 5240
5130 IF A>0 THEN 5170
5140 IF X=0 THEN 5190
5150 C1=5
5160 GOTO 5080
5170 C1=3
5180 GOTO 5200
5190 C1=7
5200 IF ABS(A) >= ABS(X) THEN 5230
5210 PRINT "DIRECTION ="C1+(((ABS(X)ABS(A))+ABS(X))/ABS(X))
5220 GOTO 5240
5230 PRINT "DIRECTION ="C1+(ABS(X)/ABS(A))
5240 PRINT "DISTANCE ="(SQR(X^2+A^2))
5250 IF H8=1 THEN 5320
+4956 REM (TAH) \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
+4957 REM (TAH) The following code segment inside the FOR...NEXT loop from lines 4900 to 5260 had to be removed and placed into two new subroutines (see lines 69707001 and 70107250).
+4958 REM (TAH) This had to be done because in the original code there is a jump into the loop from outside (see line 5300) which is considered illegal by some BASIC interpreters.
+4959 REM (TAH) Workaround is to call the code as two subroutines here (see line 4962) and from outside this loop (see lines 53235325).
+4960 REM (TAH)  GOTO 5010
+4961 REM (TAH) Compute direction and distance to Y,X sector coordinates of Klingon I.
+4962 GOSUB 7010
+4970 REM (TAH)  PRINT USING 4980;Q1,Q2,S1,S2
+4980 REM (TAH)  IMAGE "YOU ARE AT QUADRANT ( ",D,",",D," ) SECTOR ( ",D,",",D," )"
+4990 REM (TAH)  PRINT "SHIP'S & TARGET'S COORDINATES ARE";
+5000 REM (TAH)  INPUT C1,A,W1,X
+5010 REM (TAH)  X=XA
+5020 REM (TAH)  A=C1W1
+5030 REM (TAH)  IF X<0 THEN 5130
+5040 REM (TAH)  IF A<0 THEN 5190
+5050 REM (TAH)  IF X>0 THEN 5070
+5060 REM (TAH)  IF A=0 THEN 5150
+5070 REM (TAH)  C1=1
+5080 REM (TAH)  IF ABS(A) <= ABS(X) THEN 5110
+5090 REM (TAH)  PRINT "DIRECTION ="C1+(((ABS(A)ABS(X))+ABS(A))/ABS(A))
+5100 REM (TAH)  GOTO 5240
+5110 REM (TAH)  PRINT "DIRECTION ="C1+(ABS(A)/ABS(X))
+5120 REM (TAH)  GOTO 5240
+5130 REM (TAH)  IF A>0 THEN 5170
+5140 REM (TAH)  IF X=0 THEN 5190
+5150 REM (TAH)  C1=5
+5160 REM (TAH)  GOTO 5080
+5170 REM (TAH)  C1=3
+5180 REM (TAH)  GOTO 5200
+5190 REM (TAH)  C1=7
+5200 REM (TAH)  IF ABS(A) >= ABS(X) THEN 5230
+5210 REM (TAH)  PRINT "DIRECTION ="C1+(((ABS(X)ABS(A))+ABS(X))/ABS(X))
+5220 REM (TAH)  GOTO 5240
+5230 REM (TAH)  PRINT "DIRECTION ="C1+(ABS(X)/ABS(A))
+5240 REM (TAH)  PRINT "DISTANCE ="(SQR(X^2+A^2))
+5250 REM (TAH)  IF H8=1 THEN 5320
+5251 REM (TAH) //////////////////////////////////////////////////////////
5260 NEXT I
+5269 REM (TAH) It is not clear what H8 is supposed to indicate since it never changes during the game (see lines 355, 4890, 5250 and 5270).
5270 H8=0
+5279 REM (TAH) Prompt user for calculator.
5280 PRINT "DO YOU WANT TO USE THE CALCULATOR";
5290 INPUT A$
5300 IF A$="YES" THEN 4970
5310 IF A$ <> "NO" THEN 5280
+5298 REM (TAH) \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
+5299 REM (TAH) Replaced target line of conditional because we have to call two new subroutines (see lines 49574959).
+5300 REM (TAH)  IF A$="YES" THEN 4970
+5301 REM (TAH) Changed conditional so that user input can be both uppercase and lowercase (see line 5303).
+5302 REM (TAH) If user wants to use calculator, then go to code for prompting for input and computing direction and distance for torpedo to Klingon I.
+5303 IF A$="YES" OR A$="Yes" OR A$="yes" OR A$="Y" OR A$="y" THEN 5321
+5310 REM (TAH)  IF A$ <> "NO" THEN 5280
+5311 REM (TAH) Changed conditional so that user input can be both uppercase and lowercase (see line 5313).
+5312 REM (TAH) If user does not _not_ want to use calculator, then go to code for prompting user about calculator (again).
+5313 IF A$ <> "NO" AND A$ <> "No" AND A$ <> "no" AND A$ <> "N" AND A$ <> "n" THEN 5280
+5314 REM (TAH) //////////////////////////////////////////////////////////
+5319 REM (TAH) Go to command prompt.
5320 GOTO 1270
5330 IMAGE " 1 2 3 4 5 6 7 8"
5340 IMAGE ""
5350 IMAGE D,8(3X,3D)
5360 IMAGE "        "
5370 IMAGE " WARP ENGINES SHUTDOWN AT SECTOR ",D,",",D," DUE TO BAD NAVIGATION"
+5321 REM (TAH) \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
+5322 REM (TAH) Prompt user for calculator input.
+5323 GOSUB 6970
+5324 REM (TAH) Compute direction and distance for torpedo to Klingon I.
+5325 GOSUB 7010
+5326 REM (TAH) Go to code for prompting for calculator use (again).
+5327 GOTO 5270
+5330 TAH (REM)  IMAGE " 1 2 3 4 5 6 7 8"
+5340 TAH (REM)  IMAGE ""
+5350 TAH (REM)  IMAGE D,8(3X,3D)
+5360 TAH (REM)  IMAGE "        "
+5370 TAH (REM)  IMAGE " WARP ENGINES SHUTDOWN AT SECTOR ",D,",",D," DUE TO BAD NAVIGATION"
+5371 REM (TAH) HP 2000 BASIC IMAGE... statements replaced by generic PRINT statements (see lines 47614801).
+5372 REM (TAH) IMAGE... statement in line 5340 is never used in original code!
+5373 REM (TAH) //////////////////////////////////////////////////////////
+5376 REM (TAH)
+5377 REM (TAH) ***** CHOOSE SPOTS FOR KLINGONS, STARBASE, STARS ON QUADRANT MAP *****
+5378 REM (TAH)
+5379 REM (TAH) Determine Y,X sector coordinate by randomly picking a number from 1 to 8.
5380 R1=INT(RND(1)*8+1)
5390 R2=INT(RND(1)*8+1)
+5399 REM (TAH) Set up A$ for checking for empty space in quadrant string (Q$, R$ or S$).
5400 A$=" "
+5409 REM (TAH) Set Z1,Z2 (for determining right position of checking inside string Q$, R$ or S$) to random Y,X sector coordinates.
5410 Z1=R1
5420 Z2=R2
+5429 REM (TAH) Compare empty space to sector coordinates Z1,Z2.
5430 GOSUB 5680
+5439 REM (TAH) If position at sector coordinates Z1,Z2 is _not_ empty space, then go to code for trying another one (i.e. choosing new random Y,X sector coordinates).
5440 IF Z3=0 THEN 5380
5450 RETURN
+5457 REM (TAH)
+5458 REM (TAH) ***** FLUSH SCREEN *****
+5459 REM (TAH)
5460 FOR I=1 TO 11
5470 PRINT
5480 NEXT I
5490 PRINT
5500 RETURN
5510 REM ****** INSERTION IN STRING ARRAY FOR QUADRANT ******
+5517 REM (TAH) Determine position of insertion into quadrant string Q$, R$ or S$.
+5518 REM (TAH) Every quadrant measures 8 by 8 sectors, stored sequentially in Q$, R$ and S$, with every sector cell being three chars long (for <*>, >!<, +++ or * ).
+5519 REM (TAH) Therefore, position of insertion is Y axis pos (Z1) multiplied by 24 (= 8 sectors of 3 chars per row) plus X axis pos (Z2) multiplied by 3 (= chars per column) minus 26 (= offset).
5520 S8=Z1*24+Z2*326
+5529 REM (TAH) If position of insertion is outside first 72 chars (i.e. outside Q$), then go to code for checking insertion into R$ or S$.
5530 IF S8>72 THEN 5560
5540 Q$[S8,S8+2]=A$
+5539 REM (TAH) \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
+5540 REM (TAH)  Q$[S8,S8+2]=A$
+5541 REM (TAH) Changed from HP 2000 BASIC string function to generic string function.
+5542 REM (TAH) Else, insert A$ at right position into Q$.
+5543 MID$(Q$,S8,3)=A$
+5544 REM (TAH) //////////////////////////////////////////////////////////
+5549 REM (TAH) Go to code for returning from subroutine.
5550 GOTO 5600
+5559 REM (TAH) If position of insertion is outside first 144 chars (i.e. outside Q$ and R$), then go to code insertion into S$.
5560 IF S8>144 THEN 5590
5570 R$[S872,S870]=A$
+5569 REM (TAH) \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
+5570 REM (TAH)  R$[S872,S870]=A$
+5571 REM (TAH) Changed from HP 2000 BASIC string function to generic string function.
+5572 REM (TAH) Else, insert A$ at right position into R$.
+5573 MID$(R$,S872,3)=A$
+5574 REM (TAH) //////////////////////////////////////////////////////////
+5579 REM (TAH) Go to code for returning from subroutine.
5580 GOTO 5600
5590 S$[S8144,S8142]=A$
+5589 REM (TAH) \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
+5590 REM (TAH)  S$[S8144,S8142]=A$
+5591 REM (TAH) Changed from HP 2000 BASIC string function to generic string function.
+5592 REM (TAH) Insert A$ at right position into S$.
+5593 MID$(S$,S8144,3)=A$
+5594 REM (TAH) //////////////////////////////////////////////////////////
5600 RETURN
5610 REM **** PRINTS DEVICE NAME FROM ARRAY *****
+5618 REM (TAH) Determine position from which to read device name from string D$ or E$.
+5619 REM (TAH) Since all names are exactly 12 chars long (except the last one), the position is an integer multiple of 12 minus 11.
5620 S8=R1*1211
+5629 REM (TAH) If position from which to read is outside first 72 chars (i.e. outside D$), then go to code for reading from E$.
5630 IF S8>72 THEN 5660
5640 PRINT D$[S8,S8+11];
+5639 REM (TAH) \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
+5640 REM (TAH)  PRINT D$[S8,S8+11];
+5641 REM (TAH) Changed from HP 2000 BASIC string function to generic string function.
+5642 REM (TAH) Else, print the device name (i.e. 12 chars starting at position S8) from D$.
+5643 PRINT MID$(D$,S8,11);
+5644 REM (TAH) //////////////////////////////////////////////////////////
+5649 REM (TAH) Go to code for returning from subroutine.
5650 GOTO 5670
5660 PRINT E$[S872,S861];
+5659 REM (TAH) \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
+5660 REM (TAH)  PRINT E$[S872,S861];
+5661 REM (TAH) Changed from HP 2000 BASIC string function to generic string function.
+5662 REM (TAH) Print the device name (i.e. 12 chars starting at position S8 minus 72) from E$.
+5663 PRINT MID$(E$,S872,11);
+5664 REM (TAH) //////////////////////////////////////////////////////////
5670 RETURN
5680 REM ******* STRING COMPARISON IN QUADRANT ARRAY **********
+5682 REM (TAH) Round up Y,X sector coordinates (because they could be noninteger?).
5683 Z1=INT(Z1+.5)
5686 Z2=INT(Z2+.5)
+5687 REM (TAH) Determine position where to compare in quadrant string Q$, R$ or S$.
+5688 REM (TAH) Every quadrant measures 8 by 8 sectors, stored sequentially in Q$, R$ and S$, with every sector cell being three chars long (for <*>, >!<, +++ or * ).
+5689 REM (TAH) Therefore, position to compare is Y axis pos (Z1) multiplied by 24 (= 8 sectors of 3 chars per row) plus X axis pos (Z2) multiplied by 3 (= chars per column) minus 26 (= offset).
5690 S8=Z1*24+Z2*326
+5699 REM (TAH) Set Z3 for result of comparison being true of false to 0 (= false).
5700 Z3=0
+5709 REM (TAH) If position at which to compare strings is outside first 72 chars (i.e. outside Q$), then go to code for checking to compare in R$ or S$.
5710 IF S8>72 THEN 5750
5720 IF Q$[S8,S8+2] <> A$ THEN 5810
+5719 REM (TAH) \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
+5720 REM (TAH)  IF Q$[S8,S8+2] <> A$ THEN 5810
+5721 REM (TAH) Changed from HP 2000 BASIC string function to generic string function.
+5722 REM (TAH) If A$ does not match string Q$ at right position, then go to code for comparing in R$ or S$.
+5723 IF MID$(Q$,S8,3) <> A$ THEN 5810
+5724 REM (TAH) //////////////////////////////////////////////////////////
+5725 REM (TAH) Else (i.e. if A$ matches string Q$ at right position), set Z3 for result of comparison to 1 (= true).
5730 Z3=1
+5739 REM (TAH) Go to code for returning from subroutine.
5740 GOTO 5810
+5749 REM (TAH) If position at which to compare strings is outside first 144 chars (i.e. outside Q$ and R$), then go to code for comparing in S$.
5750 IF S8>144 THEN 5790
5760 IF R$[S872,S870] <> A$ THEN 5810
+5759 REM (TAH) \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
+5760 REM (TAH)  IF R$[S872,S870] <> A$ THEN 5810
+5761 REM (TAH) Changed from HP 2000 BASIC string function to generic string function.
+5762 REM (TAH) If A$ does not match string R$ at right position, then go to code for comparing in S$.
+5763 IF MID$(R$,S872,3) <> A$ THEN 5810
+5764 REM (TAH) //////////////////////////////////////////////////////////
+5769 REM (TAH) Else (i.e. if A$ matches string R$ at right position), set Z3 for result of comparison to 1 (= true).
5770 Z3=1
+5779 REM (TAH) Go to code for returning from subroutine.
5780 GOTO 5810
5790 IF S$[S8144,S8142] <> A$ THEN 5810
+5789 REM (TAH) \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
+5790 REM (TAH)  IF S$[S8144,S8142] <> A$ THEN 5810
+5791 REM (TAH) Changed from HP 2000 BASIC string function to generic string function.
+5792 REM (TAH) If A$ does not match string S$ at right position, then go to code for returning from subroutine.
+5793 IF MID$(S$,S8144,3) <> A$ THEN 5810
+5794 REM (TAH) //////////////////////////////////////////////////////////
+5799 REM (TAH) Else (i.e. if A$ matches string S$ at right position), set Z3 for result of comparison to 1 (= true).
5800 Z3=1
5810 RETURN
+5817 REM (TAH)
+5818 REM (TAH) ***** PRINT GAMES INSTRUCTIONS *****
+5819 REM (TAH)
5820 PRINT " INSTRUCTIONS:"
5830 PRINT "<*> = ENTERPRISE"
5840 PRINT "+++ = KLINGON"
@@ 588,7 +1482,11 @@
5870 PRINT "COMMAND 0 = WARP ENGINE CONTROL"
5880 PRINT " 'COURSE' IS IN A CIRCULAR NUMERICAL 4 3 2"
5890 PRINT " VECTOR ARRANGEMENT AS SHOWN. \ ^ /"
5900 PRINT " INTERGER AND REAL VALUES MAY BE \^/"
+5899 REM (TAH) \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
+5900 REM (TAH)  PRINT " INTERGER AND REAL VALUES MAY BE \^/"
+5901 REM (TAH) Fixed typo.
+5902 PRINT " INTEGER AND REAL VALUES MAY BE \^/"
+5903 REM (TAH) //////////////////////////////////////////////////////////
5910 PRINT " USED. THEREFORE COURSE 1.5 IS 5  1"
5920 PRINT " HALF WAY BETWEEN 1 AND 2. /^\"
5930 PRINT " / ^ \"
@@ 598,11 +1496,19 @@
5970 PRINT " ONE 'WARP FACTOR' IS THE SIZE OF"
5980 PRINT " ONE QUADRANT. THEREFORE TO GET"
5990 PRINT " FROM QUADRANT 6,5 TO 5,5 YOU WOULD"
6000 PRINT " USE COURSE 3, WARP FACTOR 1"
+5999 REM (TAH) \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
+6000 REM (TAH)  PRINT " USE COURSE 3, WARP FACTOR 1"
+6001 REM (TAH) Added period.
+6002 PRINT " USE COURSE 3, WARP FACTOR 1."
+6003 REM (TAH) //////////////////////////////////////////////////////////
6010 PRINT "COMMAND 1 = SHORT RANGE SENSOR SCAN"
6020 PRINT " PRINTS THE QUADRANT YOU ARE CURRENTLY IN, INCLUDING"
6030 PRINT " STARS, KLINGONS, STARBASES, AND THE ENTERPRISE; ALONG"
6040 PRINT " WITH OTHER PERTINATE INFORMATION."
+6039 REM (TAH) \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
+6040 REM (TAH)  PRINT " WITH OTHER PERTINATE INFORMATION."
+6041 REM (TAH) Fixed typo.
+6042 PRINT " WITH OTHER PERTINENT INFORMATION."
+6043 REM (TAH) //////////////////////////////////////////////////////////
6050 PRINT "COMMAND 2 = LONG RANGE SENSOR SCAN"
6060 PRINT " SHOWS CONDITIONS IN SPACE FOR ONE QUADRANT ON EACH SIDE"
6070 PRINT " OF THE ENTERPRISE IN THE MIDDLE OF THE SCAN. THE SCAN"
@@ 613,31 +1519,185 @@
6120 PRINT " ALLOWS YOU TO DESTROY THE KLINGONS BY HITTING HIM WITH"
6130 PRINT " SUITABLY LARGE NUMBERS OF ENERGY UNITS TO DEPLETE HIS "
6140 PRINT " SHIELD POWER. KEEP IN MIND THAT WHEN YOU SHOOT AT"
6150 PRINT " HIM, HE GONNA DO IT TO YOU TOO."
+6149 REM (TAH) \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
+6150 REM (TAH)  PRINT " HIM, HE GONNA DO IT TO YOU TOO."
+6151 REM (TAH) Added verb.
+6152 PRINT " HIM, HE IS GONNA DO IT TO YOU TOO."
+6153 REM (TAH) //////////////////////////////////////////////////////////
6160 PRINT "COMMAND 4 = PHOTON TORPEDO CONTROL"
6170 PRINT " COURSE IS THE SAME AS USED IN WARP ENGINE CONTROL"
+6169 REM (TAH) \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
+6170 REM (TAH)  PRINT " COURSE IS THE SAME AS USED IN WARP ENGINE CONTROL"
+6171 REM (RAH) Added period.
+6172 PRINT " COURSE IS THE SAME AS USED IN WARP ENGINE CONTROL."
+6173 REM (TAH) //////////////////////////////////////////////////////////
6180 PRINT " IF YOU HIT THE KLINGON, HE IS DESTROYED AND CANNOT FIRE"
6190 PRINT " BACK AT YOU. IF YOU MISS, HE WILL SHOOT HIS PHASERS AT"
6200 PRINT " YOU."
6210 PRINT " NOTE: THE LIBRARY COMPUTER (COMMAND 7) HAS AN OPTION"
6220 PRINT " TO COMPUTE TORPEDO TRAJECTORY FOR YOU (OPTION 2)."
6230 PRINT "COMMAND 5 = SHIELD CONTROL"
6240 PRINT " DEFINES NUMBER OF ENERGY UNITS TO BE ASSIGNED TO SHIELDS"
+6239 REM (TAH) \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
+6240 REM (TAH)  PRINT " DEFINES NUMBER OF ENERGY UNITS TO BE ASSIGNED TO SHIELDS"
+6241 REM (TAH) Added period.
+6242 PRINT " DEFINES NUMBER OF ENERGY UNITS TO BE ASSIGNED TO SHIELDS."
+6243 REM (TAH) //////////////////////////////////////////////////////////
6250 PRINT " ENERGY IS TAKEN FROM TOTAL SHIP'S ENERGY."
6260 PRINT "COMMAND 6 = DAMAGE CONTROL REPORT"
6270 PRINT " GIVES STATE OF REPAIRS OF ALL DEVICES. A STATE OF REPAIR"
6280 PRINT " LESS THAN ZERO SHOWS THAT THAT DEVICE IS TEMPORARALY"
+6279 REM (TAH) \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
+6280 REM (TAH)  PRINT " LESS THAN ZERO SHOWS THAT THAT DEVICE IS TEMPORARALY"
+6281 REM (TAH) Fixed typo.
+6282 PRINT " LESS THAN ZERO SHOWS THAT THAT DEVICE IS TEMPORARILY"
+6283 REM (TAH) //////////////////////////////////////////////////////////
6290 PRINT " DAMAGED."
6300 PRINT "COMMAND 7 = LIBRARY COMPUTER"
6310 PRINT " THE LIBRARY COMPUTER CONTAINS THREE OPTIONS:"
6320 PRINT " OPTION 0 = CUMULATIVE GALACTIC RECORD"
6330 PRINT " SHOWS COMPUTER MEMORY OF THE RESULTS OF ALL PREVIOUS"
6340 PRINT " LONG RANGE SENSOR SCANS"
+6339 REM (TAH) \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
+6340 REM (TAH)  PRINT " LONG RANGE SENSOR SCANS"
+6341 REM (TAH) Added period.
+6342 PRINT " LONG RANGE SENSOR SCANS."
+6343 REM (TAH) //////////////////////////////////////////////////////////
6350 PRINT " OPTION 1 = STATUS REPORT"
6360 PRINT " SHOWS NUMBER OF KLINGONS, STARDATES AND STARBASES"
6370 PRINT " LEFT."
6380 PRINT " OPTION 2 = PHOTON TORPEDO DATA"
6390 PRINT " GIVES TRAJECTORY AND DISTANCE BETWEEN THE ENTERPRISE"
6400 PRINT " AND ALL KLINGONS IN YOUR QUADRANT"
+6399 REM (TAH) \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
+6400 REM (TAH)  PRINT " AND ALL KLINGONS IN YOUR QUADRANT"
+6401 REM (TAH) Added period and message about option to quit game.
+6402 PRINT " AND ALL KLINGONS IN YOUR QUADRANT."
+6403 PRINT "COMMAND 8 = QUIT GAME"
+6404 REM (TAH) //////////////////////////////////////////////////////////
6410 RETURN
6420 END
+6419 REM (TAH) \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
+6420 REM (TAH)  END
+6421 REM (TAH) Moved END statement to line 7999 because we had to add some new code here (see lines 49574959).
+6500 REM (TAH)
+6510 REM (TAH) +++++ ADDITIONAL CODE +++++
+6520 REM (TAH)
+6530 REM (TAH) The following code is an almost exact copy of lines 49605250 above.
+6960 REM (TAH)
+6961 REM (TAH) ***** PROMPT FOR COORDINATES TO CALCULATE DIRECTION / DISTANCE *****
+6962 REM (TAH)
+6969 REM (TAH) Print message about location of ship and calculator input. Added info about format of input.
+6970 PRINT "YOU ARE AT QUADRANT ( "STR$(Q1)","STR$(Q2)" ) SECTOR ( "STR$(S1)","STR$(S2)" )"
+6990 PRINT "SHIP'S & TARGET'S COORDINATES ARE (4 INTEGERS SEPARATED BY COMMAS)"
+6998 REM (TAH) //////////////////////////////////////////////////////////
+6999 REM (TAH) Prompt user for ship and target coordinates.
+7000 INPUT C1,A,W1,X
+7001 RETURN
+7006 REM (TAH)
+7007 REM (TAH) ***** CALCULATE DIRECTION TO / DISTANCE FROM TARGET *****
+7008 REM (TAH)
+7009 REM (TAH) Set X and A to difference in Y,X sector coordinates between ship and target along.
+7010 X=XA
+7020 A=C1W1
+7029 REM (TAH) If target has smaller X sector coordinate than ship, then go to code for comparing Y sector coordinates.
+7030 IF X<0 THEN 7130
+7039 REM (TAH) If target has greater Y sector coordinate than ship, then go to code for setting general direction to target to 7.
+7040 IF A<0 THEN 7190
+7049 REM (TAH) If target has greater X sector coordinate than ship, then go to code for setting general direction to target to 1.
+7050 IF X>0 THEN 7070
+7059 REM (TAH) If target has same Y sector coordinate as ship, then go to code for setting general direction to target to 5.
+7060 IF A=0 THEN 7150
+7069 REM (TAH) Else, target has same X sector coordinate than and smaller/same Y sector coordinate as ship, so set general direction to target to 1 (see lines 58706002).
+7070 C1=1
+7079 REM (TAH) If absolute difference along Y axis less than/equal to absolute difference along X axis, then go to code for adjusting general direction to target.
+7080 IF ABS(A) <= ABS(X) THEN 7110
+7089 REM (TAH) Print message about direction to target.
+7090 PRINT "DIRECTION = "STR$(C1+(((ABS(A)ABS(X))+ABS(A))/ABS(A)))
+7099 REM (TAH) Go to code for printing message about distance between ship and target.
+7100 GOTO 7240
+7109 REM (TAH) Print message about direction to target.
+7110 PRINT "DIRECTION = "STR$(C1+(ABS(A)/ABS(X)))
+7119 REM (TAH) Go to code for printing message about distance between ship and target.
+7120 GOTO 7240
+7129 REM (TAH) If target has smaller Y sector coordinate than ship, then go to code for setting general direction to target to 3.
+7130 IF A>0 THEN 7170
+7139 REM (TAH) If target has same X sector coordinate as ship, then go to code for setting general direction to target to 7.
+7140 IF X=0 THEN 7190
+7149 REM (TAH) Set general direction to target to 5 (see lines 58706002).
+7150 C1=5
+7159 REM (TAH) Go to code for adjusting general direction to target.
+7160 GOTO 7080
+7169 REM (TAH) Set general direction to target to 3 (see lines 58706002).
+7170 C1=3
+7179 REM (TAH) Go to code for comparing distances along Y,X axis.
+7180 GOTO 7200
+7189 REM (TAH) Set general direction to target to 7 (see lines 58706002).
+7190 C1=7
+7199 REM (TAH) If absolute distance along Y axis is greater than/equal to absolute distance along X axis, then go to code for printing message about direction to target.
+7200 IF ABS(A) >= ABS(X) THEN 7230
+7209 REM (TAH) Print message about direction to target.
+7210 PRINT "DIRECTION = "STR$(C1+(((ABS(X)ABS(A))+ABS(X))/ABS(X)))
+7219 REM (TAH) Go to code for printing message about distance between ship and target.
+7220 GOTO 7240
+7229 REM (TAH) Print message about direction to target.
+7230 PRINT "DIRECTION = "STR$(C1+(ABS(X)/ABS(A)))
+7239 REM (TAH) Print message about distance to target (being the square root of the sum of distances along Y,X axis cubed, i.e. length of hypotenuse of the right triangle formed by Y,X axis differences).
+7240 PRINT "DISTANCE = "STR$(SQR(X^2+A^2))
+7250 RETURN
+7996 REM (TAH)
+7997 REM (TAH) ***** END OF CODE (see line 6421) *****
+7998 REM (TAH)
+7999 END
+8000 REM (TAH)
+8010 REM (TAH) ***** DESCRIPTION OF VARIABLES *****
+8020 REM (TAH)
+8030 REM (TAH) A$[3] User input and string for reading from/writing to quadrant map (see Q$, R$ and S$)
+8040 REM (TAH) B3 Number of starbases in current quadrant
+8050 REM (TAH) B9 Number of starbases in galaxy
+8060 REM (TAH) C[m,n] Change of Y (n=1) and X sector coordinates (n=2) when moving one step by course m (see C2), namely 1, 0 or +1
+8070 REM (TAH) C$[6] Ship condition ("GREEN", "RED", "YELLOW" or "DOCKED")
+8080 REM (TAH) C1 Course of ship or torpedo (user input, 18.999...), also used for calculating direction of torpedo with ship computer
+8090 REM (TAH) C2 C1 rounded up to integer, used for computing course (see C[m,n])
+8100 REM (TAH) D[m] Repair/damage status of ship device m
+8110 REM (TAH) D$[72] Names of ship devices, part I (see E$)
+8120 REM (TAH) D0 Indicates whether ship is docked (1) or not (0). THIS IS NEVER CHECKED IN PROGRAM!
+8130 REM (TAH) E Ship energy
+8140 REM (TAH) E$[24] Names of ship devices, part II (see D$)
+8150 REM (TAH) E0 Initial amount of ship energy (see E)
+8160 REM (TAH) G[m,n] Number of Klingons (hundreds digit), starbases (tens digit) and stars (ones digit) in quadrant m,n
+8170 REM (TAH) H Damaged done by phaser attack and by Klingon to ship
+8180 REM (TAH) H8 Purpose unclear. Is checked in subroutine for ship computer function BUT NEVER CHANGES ITS INITIAL VALUE OF 0!
+8190 REM (TAH) I Counter in FOR...NEXT loops
+8200 REM (TAH) J Counter in FOR...NEXT loops
+8210 REM (TAH) K[m,n] Y sector coordinate (n=1), X sector coordinate (n=2) and shields (n=3) of Klingon m in current quadrant
+8220 REM (TAH) K3 Number of Klingons in current quadrant
+8230 REM (TAH) K7 Initial number of Klingons in galaxy
+8240 REM (TAH) K9 Number of remaining Klingons in galaxy
+8250 REM (TAH) N Number of sectors ship moves through using warp drive (see W1), used as upper limit for counter in FOR...NEXT loop
+8260 REM (TAH) N[m] Results of lange range scan of quadrant m for number of Klingons (hundreds digit), starbases (tens digit) and stars (ones digit)
+8270 REM (TAH) P Number of photon torpedoes
+8280 REM (TAH) P0 Initial number of photon torpedoes. THIS IS NEVER USED IN PROGRAM!
+8290 REM (TAH) Q$[72] Map of current quadrant sequentially storing sectors 1,1 through 3,8 (each three chars wide), part I (see R$ and S$)
+8300 REM (TAH) Q1 Y quadrant coordinate of ship
+8310 REM (TAH) Q2 X quadrant coordinate of ship
+8320 REM (TAH) R$[72] Map of current quadrant sequentially storing sectors 4,1 through 6,8 (each three chars wide), part II (see Q$ and S$)
+8330 REM (TAH) R1 Integer for random number, mostly used for Y sector coordinate of objects when setting up current quadrant
+8340 REM (TAH) R2 Integer for random number used for X sector coordinate of objects when setting up current quadrant
+8350 REM (TAH) S Shields of ship
+8360 REM (TAH) S$[48] Map of current quadrant sequentially storing sectors 7,1 through 8,8 (each three chars wide), part III (see Q$ and R$)
+8370 REM (TAH) S1 Y sector coordinate of ship
+8380 REM (TAH) S2 X sector coordinate of ship
+8390 REM (TAH) S3 Number of stars in current quadrant
+8400 REM (TAH) S8 Point at which to read object from/write object to in quadrant map (see Q$, R$ or S$) and in ship device names array (see D$ and E$)
+8410 REM (TAH) S9 Initial shield level of Klingons
+8420 REM (TAH) T Stardate
+8430 REM (TAH) T0 Initial stardate
+8440 REM (TAH) T1 Number of minutes since midnight at end of game
+8450 REM (TAH) T7 Number of minutes since midnight at start of game
+8460 REM (TAH) T9 Units of stardate to finish game
+8470 REM (TAH) W1 Warp factor (user input, 0.1...8)
+8480 REM (TAH) X Integer used for storing Y (!) sector coordinate of some object
+8490 REM (TAH) X1 Number of sectors ship or torpedo moves along Y (!) axis
+8500 REM (TAH) X2 Number of sectors ship or torpedo moves along X (!) axis
+8510 REM (TAH) Y Integer used for storing X (!) sector coordinate of some object
+8520 REM (TAH) Z[m,n] Galactic record for number of Klingons (hundreds digit), starbases (tens digit) and stars (ones digit) in quadrant m,n
+8530 REM (TAH) Z$[72] Empty string to erase (parts of) the quadrant map (see Q$, R$ and S)
+8540 REM (TAH) Z1 Y sector coordinate of object (ship, torpedo, Klingon etc.) to be read from/written quadrant map (see Q$, R$, S$ and S8)
+8550 REM (TAH) Z2 X sector coordinate of object (ship, torpedo, Klingon etc.) to be read from/written to quadrant map (see Q$, R$, S$ and S8)
+8560 REM (TAH) Z3 Indicates whether looking for an object within the quadrant map (see Q$, R$ and S$) tests true (1) or false (0)
+9000 REM (TAH) //////////////////////////////////////////////////////////