Author Topic: The author's collection of QB64 demos  (Read 5555 times)

0 Members and 1 Guest are viewing this topic.

Offline anttiylikoski

  • Newbie
  • Posts: 25
    • View Profile
The author's collection of QB64 demos
« on: January 22, 2020, 04:27:32 pm »

Offline DANILIN

  • Forum Regular
  • Posts: 128
    • View Profile
    • Danilin youtube
Re: The author's collection of QB64 demos
« Reply #1 on: January 30, 2020, 10:15:04 am »
I downloading all pages as html
and there was an archive of all BAS

and then testing

and I think it would be farsighted
to post topicstarter one program in this topic weekly
« Last Edit: January 30, 2020, 02:30:11 pm by DANILIN »
Russia looks world from future. big data is peace data.
https://youtube.com/playlist?list=PLBBTP9oVY7IagpH0g9FNUQ8JqmHwxDDDB
i never recommend anything to anyone and always write only about myself

Offline anttiylikoski

  • Newbie
  • Posts: 25
    • View Profile
Re: The author's collection of QB64 demos
« Reply #2 on: March 01, 2020, 10:58:17 am »
I downloading all pages as html
and there was an archive of all BAS

and then testing

and I think it would be farsighted
to post topicstarter one program in this topic weekly

Yes, if the audience wish, I can post the most salient, BAS programs here, for the discourse.



Offline anttiylikoski

  • Newbie
  • Posts: 25
    • View Profile
Re: The author's collection of QB64 demos
« Reply #3 on: March 01, 2020, 11:13:39 am »
The Linear Regression in the QB64.

These r the basic formulas for the linear regression computation.

The program's actually useful in a commercial business, hence its here.

AJY
Europe




Code: QB64: [Select]
  1.  
  2. ' COMPUTING THE LINEAR REGRESSION WITH BASIC
  3. '
  4. ' Antti J Ylikoski 2017-03-07 MikroBITTI-lehdelle
  5. '
  6. ' COMPUTE HOW MANY X/Y PAIRS THERE ARE THERE
  7.  
  8. DIM NRDATA AS INTEGER
  9.  
  10. TRUE = 1
  11. NRDATA = 0
  12. WHILE TRUE
  13.     READ X, Y
  14.     NRDATA = NRDATA + 1
  15.  
  16. 100 REM
  17.  
  18. PRINT "THE NUMBER OF THE DATA ARE"; NRDATA
  19. PRINT "THE DATA ARE:"
  20.  
  21.  
  22. FOR INDX = 1 TO NRDATA
  23.     READ X, Y
  24.     PRINT "X, Y", X, Y
  25. NEXT INDX
  26.  
  27.  
  28. DIM SIGMAXY AS DOUBLE
  29. DIM SIGMAX AS DOUBLE
  30. DIM SIGMAY AS DOUBLE
  31. DIM SIGMAX2 AS DOUBLE
  32.  
  33.  
  34. SIGMAXY = 0
  35. SIGMAX = 0
  36. SIGMAY = 0
  37. SIGMAX2 = 0
  38.  
  39.  
  40. FOR INDX = 1 TO NRDATA
  41.     READ X, Y
  42.     SIGMAXY = SIGMAXY + X * Y
  43.     SIGMAX = SIGMAX + X
  44.     SIGMAY = SIGMAY + Y
  45.     SIGMAX2 = SIGMAX2 + X ^ 2
  46. NEXT INDX
  47.  
  48.  
  49.  
  50. M = (SIGMAXY - SIGMAX * SIGMAY / NRDATA) / (SIGMAX2 - SIGMAX ^ 2 / NRDATA)
  51.  
  52. B = (SIGMAY - M * SIGMAX) / NRDATA
  53.  
  54. DIM MEANX AS DOUBLE
  55. DIM MEANY AS DOUBLE
  56.  
  57.  
  58. MEANX = SIGMAX / NRDATA
  59. MEANY = SIGMAY / NRDATA
  60.  
  61. DX = 0
  62. DY = 0
  63.  
  64.  
  65. FOR INDX = 1 TO NRDATA
  66.     READ X, Y
  67.     DX = DX + (X - MEANX) ^ 2
  68.     DY = DY + (Y - MEANY) ^ 2
  69. NEXT INDX
  70.  
  71.  
  72. SDX = SQR(DX / (NRDATA - 1))
  73. SDY = SQR(DY / (NRDATA - 1))
  74.  
  75. R = M * SDX / SDY
  76.  
  77.  
  78. PRINT "THE MEAN OF THE X VALUES:", MEANX
  79. PRINT "THE MEAN OF THE Y VALUES:", MEANY
  80. PRINT "THE SD OF THE X VALUES:", SDX
  81. PRINT "THE SD OF THE Y VALUES:", SDY
  82. PRINT "Y = M * X + B, WHERE"
  83. PRINT "M = ", M
  84. PRINT "B = ", B
  85. PRINT "THE CORRELATION COEFFICIENT R =", R
  86.  
  87. DATA 0.0,0.5
  88. DATA 2.0,1.0
  89. DATA 1.0,1.0
  90. DATA 5.0,3.0
  91. DATA 10.0,7.0
  92.  
  93.  
  94.  
  95.  


Offline anttiylikoski

  • Newbie
  • Posts: 25
    • View Profile
Re: The author's collection of QB64 demos
« Reply #4 on: March 01, 2020, 11:17:53 am »
The mean, the standard deviation of a set of data in the QB64.

For a European magazine, the comments in Finnish.


Code: QB64: [Select]
  1.  
  2. 1 REM **** LASKETAAN KESKIARVO JA HAJONTA ****
  3. 2 REM
  4. 3 REM **** EDITED, MODIFIED AND DEBUGGED BY A. J. YLIKOSKI
  5. 4 REM **** LAINATTU FROM: OTADATA, PERUSTIETOJA TIETOJENKASITTELYSTA,
  6. 5 REM **** ISBN 951-767-023-0
  7. 6 DEFDBL A-Z: REM ALL VARIABLES ARE DOUBLE PRECISION
  8. 9 REM LUETAAN ALKUARVOT
  9. 10 ON ERROR GOTO 100: REM DATOJEN LOPPUESSA HYPATAAN 100
  10. 11 REM
  11. 30 LET X = 0
  12. 32 LET S = 0
  13. 34 LET D = 0
  14. 36 LET I = 0
  15. 60 READ Y: REM LUETAAN SEURAAVA DATA-ARVO
  16. 70 LET X = X + 1
  17. 80 LET S = S + Y
  18. 90 GOTO 60: REM DATOJEN LOPPUESSA GOTO 100
  19. 100 LET K = S / X: REM SELVA.  DATOJEN LUKUMAARA ON NYT = X
  20. 112 REM **** LASKETAAN HAJONTA
  21. 120 READ C
  22. 130 LET I = I + 1
  23. 140 LET D = D + (K - C) ^ 2
  24. 150 IF I < X THEN 120
  25. 160 LET D = SQR(D / (X - 1))
  26. 165 CLS
  27. 167 PRINT "DATOJA OLI"; X; "KAPPALETTA"
  28. 170 PRINT "KESKIARVO"; K; "HAJONTA"; D
  29. 180 DATA 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
  30. 9999 END
  31.  
  32.  
  33.  
  34.  
  35.  


Offline anttiylikoski

  • Newbie
  • Posts: 25
    • View Profile
Re: The author's collection of QB64 demos
« Reply #5 on: March 01, 2020, 11:22:02 am »
The very classic Star Trek Game, with the QB64.



Code: QB64: [Select]
  1.  
  2.  
  3. 1 REM THE VENERABLE STAR TREK COMPUTER GAME -- ANTTI J YLIKOSKI 12/19/2010
  4. 2 REM ENTERED, MODIFIED AND DEBUGGED BY ANTTI J YLIKOSKI
  5. 3 REM ORIGINALLY FROM: THE BEST OF CREATIVE COMPUTING, VOL 1,
  6. 4 REM EDITED BY DAVID H. AHL, CREATIVE COMPUTING PRESS,
  7. 5 REM P.O.BOX 789-M, MORRISTOWN, N. J. 07960, USA
  8. 6 REM ISBN 0-916688-01-1, (C) 1976 BY CREATIVE COMPUTING
  9. 7 REM
  10. 8 REM THE QB64 VERSION -- SOME IDIOSYNCRACIES FIXED
  11. 9 REM
  12. 10 REM [VERSION "STREK7", 1/12/75 RCL]
  13. 12 REM EDITED AND DEBUGGED BY ANTTI J. YLIKOSKI 02/10/2010 --
  14. 14 REM THE PROGRAM EXHIBITS THE CONTROL STRUCTURE AFFECTIONATELY
  15. 18 REM CALLED A "RAT'S NEST".
  16. 20 REM IT PROBABLY STEMS FROM THE ERA OF THE GOTO AND THE GOSUB
  17. 25 REM ONCOLOGICAL SURGERY WOULD HAVE BEEN POSSIBLE BUT ANYWAY:
  18. 27 REM "IF IT AIN'T BROKEN, DON'T FIX IT!"
  19. 29 REM
  20. 30 REM
  21. 40 REM ***     *** STAR TREK ***
  22. 50 REM *** SIMULATION OF A MISSION OF THE STARSHIP ENTERPRISE,
  23. 60 REM *** AS SEEN ON THE STAR TREK TV SHOW
  24. 70 REM *** ORIGINAL PROGRAM BY MIKE MAYFIELD, MODIFIED VERSION
  25. 80 REM *** PUBLISHED IN DEC'S "101 BASIC GAMES" BY DAVE AHL
  26. 90 REM ***   MODIFICATIONS TO THE LATTER (PLUS DEBUGGINGS) BY
  27. 100 REM ***      BOB LEEDOM -- APRIL & DECEMBER 1974,
  28. 110 REM *** WITH A LITTLE HELP FROM HIS FRIENDS...
  29. 120 REM *** COMMENTS, EPITETHS, AND SUGGESTIONS SOLICITED (IN 1975)
  30. 130 REM *** ADDRESS TO: R. C. LEEDOM
  31. 140 REM ***    WESTINGHOUSE DEFENSE & ELECTRONIC SYSTEMS CNTR.
  32. 150 REM ***    BOX 746, M. S. 338 BALTIMORE, MD 21283, USA
  33. 152 REM
  34. 153 REM ORIGINALLY CONVERTED TO THE FREEBASIC, SEE
  35. 154 REM   HTTP://WWW.FREEBASIC.NET
  36. 155 REM AND THE DOCUMENTATION
  37. 156 REM   HTTP://WWW.FREEBASIC.NET/WIKI/
  38. 157 REM BY ANTTI J YLIKOSKI 10-16-2010
  39. 158 REM
  40. 159 REM QB64 VERSION BY ANTTI J. YLIKOSKI 12-19-2010, UPDATED 03-02-2012.
  41. 160 REM START THE QB64.EXE, OPEN THE PROGRAM FILE AND EXECUTE CTL-F5
  42. 161 REM TO ENJOY THE GAME -- GOOD LUCK, ADMIRAL!!!!!
  43. 164 REM
  44. 165 REM SEE http://www.[abandoned, outdated and now likely malicious qb64 dot net website - don’t go there]/
  45. 166 REM
  46. 167 REM EXISTING BUGS: THE CALCLULATION OF THE PHOTON TORPEDO COURSE
  47. 168 REM IS PARTIALLY FLAWED.
  48. 169 REM
  49. 175 PRINT TAB(15); "* * * STAR TREK * * *"
  50. 180 PRINT
  51. 190 PRINT "DO YOU NEED INSTRUCTIONS (YES/NO)";
  52. 200 DIM A$
  53. 210 INPUT A$
  54. 220 IF UCASE$(A$) = "YES" THEN GOSUB 10000
  55. 240 REM THE PROGRAM BEGINS HERE....
  56. 242 DIM Q9$
  57. 244 DIM R9$
  58. 246 DIM S4$
  59. 250 DIM Z$
  60. 251 DIM Q$(72)
  61. 252 DIM R$(72)
  62. 253 DIM S$(72)
  63. 260 DIM G1$
  64. 261 DIM G2$
  65. 262 DIM G3$
  66. 263 DIM G4$
  67. 265 DIM D7$
  68. 270 LET Z$ = ""
  69. 272 LET Q$ = ""
  70. 274 LET R$ = ""
  71. 276 LET S$ = ""
  72. 278 FOR I = 1 TO 72
  73.    280 LET Z$ = Z$ + " "
  74.    290 LET Q$ = Q$ + " "
  75.    300 LET R$ = R$ + " "
  76.    310 LET S$ = S$ + " "
  77. 320 NEXT I
  78. 322 REM Z$ IS SO TO SPEAK A ZERO STRING -- FULL OF SPACES
  79. 324 REM Q$ + R$ + S$ ARE ALTOGETHER 3*72 = 216 CHARACTERS OF MEMORY
  80. 326 REM THE VIDEO OF THE CURRENT QUADRANT ARE (3*8)*8 CHARACTERS, IE.
  81. 327 REM 192 CHARACTERS, STORED IN THE STRINGS Q$+R$+S$.
  82. 330 DIM G(1 TO 8, 1 TO 8) AS INTEGER
  83. 331 DIM C(1 TO 9, 1 TO 2) AS INTEGER
  84. 332 DIM K(1 TO 3, 1 TO 3) AS INTEGER
  85. 333 DIM N(1 TO 3) AS INTEGER
  86. 334 DIM Z(1 TO 8, 1 TO 8) AS INTEGER
  87. 340 DIM O1$
  88. 341 DIM C$
  89. 350 DIM A1$
  90. 351 DIM T$
  91. 360 DIM D$
  92. 361 DIM O3$
  93. 362 REM THE VARIABLE A1 IS THE GOOD LUCK FACTOR
  94. 363 REM A1 = 1 <=> ALMOST IMPOSSIBLE GAME
  95. 364 REM A1 = 3 <=> POSSIBLE GAME
  96. 365 REM A1 = 5 <=> EASY GAME
  97. 367 LET A1 = 5
  98. 370 DIM C9 AS DOUBLE, A9 AS DOUBLE, W9 AS DOUBLE, D4 AS DOUBLE, D1 AS DOUBLE
  99. 372 DIM P7 AS DOUBLE
  100. 374 DIM A8 AS DOUBLE, X8 AS DOUBLE
  101. 379 LET T = INT(RND(1) * 20 + 20) * 100
  102. 380 LET T0 = T
  103. 390 LET T9 = 30 + 5 * (A1 - 1): REM I WANT THE GAME TO BE WINNABLE
  104. 400 LET D0 = 0
  105. 410 LET E0 = 3000 * A1: REM THE ENERGY AVAILABLE
  106. 420 LET E = E0
  107. 430 LET P = 10
  108. 440 LET P0 = P
  109. 450 LET S9 = 200
  110. 460 LET S = 0
  111. 465 LET F7 = 0
  112. 470 REM AN AUXILIARY FUNCTION DEF FND(Z) SUBSTITUTED IN THE PROGRAM TEXT
  113. 485 REM INITIALIZE ENTERPRISE'S POSITION
  114. 490 LET Q1 = INT(RND(1) * 8 + 1)
  115. 500 LET Q2 = INT(RND(1) * 8 + 1)
  116. 510 LET S1 = INT(RND(1) * 8 + 1)
  117. 520 LET S2 = INT(RND(1) * 8 + 1)
  118. 530 REM MAT C=ZER
  119. 531 FOR F8 = 1 TO 9
  120.    532 FOR F9 = 1 TO 2
  121.        533 LET C(F8, F9) = 0
  122.    534 NEXT F9
  123. 535 NEXT F8
  124. 540 LET C(3, 1) = -1
  125. 550 LET C(2, 1) = -1
  126. 560 LET C(4, 1) = -1
  127. 570 LET C(4, 2) = -1
  128. 580 LET C(5, 2) = -1
  129. 590 LET C(6, 2) = -1
  130. 600 LET C(1, 2) = 1
  131. 610 LET C(2, 2) = 1
  132. 620 LET C(6, 1) = 1
  133. 630 LET C(7, 1) = 1
  134. 640 LET C(8, 1) = 1
  135. 650 LET C(8, 2) = 1
  136. 660 LET C(9, 2) = 1
  137. 670 DIM D(8) AS INTEGER
  138. 680 FOR I = 1 TO 8
  139.    690 LET D(I) = 0
  140. 700 NEXT I
  141. 710 LET A1$ = "NSLPTSDCX"
  142. 720 LET D$ = "WARP ENGINESS.R.SENSORS L.R.SENSORS PHASER CNTRL"
  143. 730 LET D$ = D$ + "PHOTON TUBESDAMAGE CNTRLSHIELD CNTRLCOMPUTER    "
  144. 740 LET G4$ = "III"
  145. 750 LET G1$ = " ANTARES. SIRIUS. RIGEL. DENEB. PROCYON. CAPELLA. VEGA. "
  146. 760 LET G1$ = G1$ + "BETELGEUZE. CANOPUS. ALDEBARAN. ALTAIR. REGULUS. "
  147. 770 LET G1$ = G1$ + "SAGITTARIUS. ARCTURUS. POLLUX. SPICA. "
  148. 780 LET B9 = 0
  149. 790 LET K9 = 0
  150. 800 LET A1$ = "NSLPTSDCX"
  151. 810 REM SET UP WHAT EXISTS IN THE GALAXY....
  152. 820 FOR I = 1 TO 8
  153.    830 FOR J = 1 TO 8
  154.        840 LET R1 = RND(1)
  155.        850 IF R1 > 0.98 THEN GOTO 900
  156.        860 IF R1 > 0.95 THEN GOTO 930
  157.        870 IF R1 > 0.8 THEN GOTO 960
  158.        880 LET K3 = 0
  159.        890 GOTO 980
  160.        900 LET K3 = 3
  161.        910 LET K9 = K9 + 3
  162.        920 GOTO 980
  163.        930 LET K3 = 2
  164.        940 LET K9 = K9 + 2
  165.        950 GOTO 980
  166.        960 LET K3 = 1
  167.        970 LET K9 = K9 + 1
  168.        980 LET R1 = RND(1)
  169.        990 IF R1 > 0.96 THEN GOTO 1020
  170.        1000 LET B3 = 0
  171.        1010 GOTO 1040
  172.        1020 LET B3 = 1
  173.        1030 LET B9 = B9 + 1
  174.        1040 LET S3 = INT(RND(1) * 8 + 1)
  175.        1050 LET G(I, J) = K3 * 100 + B3 * 10 + S3
  176.        1060 REM K3=#KLINGONS; B3=#STARBASES; S3=#STARS
  177.        1070 LET Z(I, J) = 0
  178.    1080 NEXT J
  179. 1090 NEXT I
  180. 1100 LET K7 = K9
  181. 1110 DIM X$
  182. 1111 DIM X0$
  183. 1120 LET X$ = ""
  184. 1130 LET X0$ = " IS "
  185. 1140 IF B9 <> 0 THEN GOTO 1200
  186. 1150 LET B9 = 1
  187. 1160 IF G(6, 3) = 200 THEN GOTO 1190
  188. 1170 LET G(6, 3) = G(6, 3) + 100
  189. 1180 LET K9 = K9 + 1
  190. 1190 G(6, 3) = G(6, 3) + 10
  191. 1200 IF B9 = 1 THEN GOTO 1230
  192. 1210 LET X$ = "S"
  193. 1220 LET X0$ = " ARE "
  194. 1230 PRINT
  195. 1235 PRINT "YOUR ORDERS ARE AS FOLLOWS:"
  196. 1240 PRINT "    DESTROY THE"; K9; " KLINGON WARSHIPS WHICH HAVE INVADED"
  197. 1250 PRINT "  THE GALAXY BEFORE THEY CAN ATTACK FEDERATION HEADQUARTERS"
  198. 1260 PRINT "  ON STARDATE"; T0 + T9; "; THIS GIVES YOU"; T9; " DAYS.  THERE"; X0$
  199. 1270 PRINT "  "; B9; " STARBASE"; X$; " IN THE GALAXY FOR RESUPPLYING YOUR SHIP."
  200. 1280 PRINT
  201. 1290 PRINT "HIT 'RETURN' WHEN READY TO ASSUME COMMAND ----"
  202. 1300 INPUT A$
  203. 1310 REM *** HERE ANY TIME ENTER NEW QUADRANT ***
  204. 1320 LET Z4 = Q1
  205. 1330 LET Z5 = Q2
  206. 1340 LET K3 = 0
  207. 1350 LET B3 = 0
  208. 1360 LET S3 = 0
  209. 1370 LET G5 = 0
  210. 1380 LET D4 = 0.5 * RND(1)
  211. 1385 REM EXCEEDING GALAXY BORDERS?
  212. 1390 IF Q1 < 1 THEN GOTO 1600
  213. 1400 IF Q1 > 8 THEN GOTO 1600
  214. 1410 IF Q2 < 1 THEN GOTO 1600
  215. 1420 IF Q2 > 8 THEN GOTO 1600
  216. 1430 GOSUB 9030
  217. 1440 PRINT
  218. 1450 IF T <> T0 THEN GOTO 1490
  219. 1460 PRINT "YOUR MISSION BEGINS WITH YOUR STARSHIP LOCATED"
  220. 1470 PRINT "IN THE GALACTIC QUADRANT, '"; G2$; "'."
  221. 1472 LET F7 = 1
  222. 1480 GOTO 1505
  223. 1490 PRINT "NOW ENTERING '"; G2$; "' QUARDANT ..."
  224. 1500 PRINT
  225. 1505 LET F7 = 1
  226. 1510 LET X = G(Q1, Q2) * 0.01
  227. 1520 LET K3 = INT(X)
  228. 1530 LET B3 = INT((X - K3) * 10)
  229. 1540 LET S3 = G(Q1, Q2) - INT(G(Q1, Q2) * 0.1) * 10
  230. 1550 IF K3 = 0 THEN GOTO 1590
  231. 1560 PRINT "COMBAT AREA        CONDITION RED"
  232. 1570 IF S > 200 THEN GOTO 1590
  233. 1580 PRINT "      SHIELDS DANGEROUSLY LOW"
  234. 1590 REM MAT K=ZER
  235. 1592 FOR F8 = 1 TO 3
  236.    1594 FOR F9 = 1 TO 3
  237.        1596 LET K(F8, F9) = 0
  238.    1597 NEXT F9
  239. 1598 NEXT F8
  240. 1600 FOR I = 1 TO 3
  241.    1610 LET K(I, 3) = 0
  242. 1620 NEXT I
  243. 1630 LET Q$ = Z$
  244. 1640 LET R$ = Z$
  245. 1650 LET S$ = MID$(Z$, 1, 48)
  246. 1660 REM POSITION ENTERPRISE IN QUADRANT, THEN PLACE 'K3' KLINGONS,
  247. 1670 REM   'B3' STARBASES, AND 'S3' STARS ELSEWHERE
  248. 1680 LET A$ = "<*>"
  249. 1690 LET Z1 = S1
  250. 1700 LET Z2 = S2
  251. 1710 GOSUB 8670
  252. 1715 IF K3 <= 0 THEN GOTO 1815
  253. 1720 FOR I = 1 TO K3
  254.    1730 GOSUB 8590
  255.    1740 LET A$ = "+++"
  256.    1750 LET Z1 = R1
  257.    1760 LET Z2 = R2
  258.    1770 GOSUB 8670
  259.    1780 LET K(I, 1) = R1
  260.    1790 LET K(I, 2) = R2
  261.    1800 LET K(I, 3) = S9
  262. 1810 NEXT I
  263. 1815 IF B3 <= 0 THEN GOTO 1905
  264. 1820 FOR I = 1 TO B3
  265.    1830 GOSUB 8590
  266.    1840 LET A$ = ">!<"
  267.    1850 LET Z1 = R1
  268.    1860 LET Z2 = R2
  269.    1870 GOSUB 8670
  270.    1880 LET B4 = Z1
  271.    1890 LET B5 = Z2
  272. 1900 NEXT I
  273. 1905 IF S3 <= 0 THEN GOTO 1975
  274. 1910 FOR I = 1 TO S3
  275.    1920 GOSUB 8590
  276.    1930 LET A$ = " * "
  277.    1940 LET Z1 = R1
  278.    1950 LET Z2 = R2
  279.    1960 GOSUB 8670
  280. 1970 NEXT I
  281. 1975 REM
  282. 1980 GOSUB 6430
  283. 1985 REM ***** THE LOOP BEGINS HERE ***** CHECK ENERGY, RECEIVE COMMAND
  284. 1986 REM ***** LOOP BEGINS AT STATEMENT 1990
  285. 1990 IF S + E <= 10 THEN GOTO 2020
  286. 2000 IF E > 10 THEN GOTO 2060
  287. 2010 IF D(7) = 0 THEN GOTO 2060
  288. 2020 PRINT "** FATAL ERROR **   YOU'VE JUST STRANDED YOUR SHIP IN SPACE!!"
  289. 2030 PRINT "YOU HAVE INSUFFICIENT MANEUVERING ENERGY, AND SHIELD CONTROL"
  290. 2040 PRINT "IS PRESENTLY INCAPABLE OF CROSS-CIRCUITING TO ENGINE ROOM!"
  291. 2050 GOTO 6260
  292. 2060 PRINT "COMMAND (CAR RET FOR HELP) ";
  293. 2070 INPUT A$
  294. 2072 DIM H9$
  295. 2074 DIM I9$
  296. 2076 DIM J9$
  297. 2080 FOR I = 1 TO 9
  298.    2082 LET H9$ = MID$(A$, 1, 1)
  299.    2084 LET I9$ = MID$(A1$, I, 1)
  300.    2090 IF H9$ <> I9$ THEN GOTO 2160
  301.    2100 IF I <> 2 THEN GOTO 2140
  302.    2110 IF LEN(A$) < 2 THEN GOTO 2140
  303.    2115 LET J9$ = MID$(A$, 2, 1)
  304.    2120 IF J9$ = "R" THEN GOTO 2140
  305.    2130 LET I = 6
  306.    2140 ON I GOTO 2300, 1980, 4000, 4260, 4700, 5530, 5690, 7290
  307.    2150 IF A$ = "XXX" THEN GOTO 6270
  308. 2160 NEXT I
  309. 2170 PRINT "ENTER ONE OF THE FOLLOWING:"
  310. 2180 PRINT "NAV (TO SET COURSE)"
  311. 2190 PRINT "SRS (FOR SHORT RANGE SENSOR SCAN)"
  312. 2200 PRINT "LRS (FOR LONG RANGE SENSOR SCAN)"
  313. 2210 PRINT "PHA (TO FIRE PHASERS)"
  314. 2220 PRINT "TOR (TO FIRE PHOTON TODPEDOS)"
  315. 2230 PRINT "SHE (TO RAISE OR LOWER SHIELDS)"
  316. 2240 PRINT "DAM (FOR DAMAGE CONTROL REPORT)"
  317. 2250 PRINT "COM (TO CALL ON THE LIBRARY-COMPUTER"
  318. 2260 PRINT "XXX (TO RESIGN YOUR COMMAND)"
  319. 2270 PRINT
  320. 2280 GOTO 1990
  321. 2290 REM  COURSE CONTROL BEGINS HERE
  322. 2300 PRINT "COURSE (1-9)      ";
  323. 2310 INPUT C1
  324. 2320 IF C1 >= 1 THEN GOTO 2350
  325. 2330 PRINT "    LT. SULU REPORTS, 'INCORRECT COURSE DATA, SIR!'"
  326. 2340 GOTO 1990
  327. 2350 IF C1 < 9 THEN GOTO 2380
  328. 2360 IF C1 > 9 THEN GOTO 2330
  329. 2370 LET C1 = 1
  330. 2380 PRINT "WARP FACTOR (0-8) ";
  331. 2390 INPUT W1
  332. 2400 IF W1 <= 0 THEN GOTO 2420
  333. 2410 IF W1 <= 8 THEN GOTO 2450
  334. 2420 PRINT "CHIEF ENGINEER SCOTT REPORTS 'THE ENGINES WON'T"
  335. 2430 PRINT "       TAKE WARP "; W1; " !'"
  336. 2440 GOTO 1990
  337. 2450 IF D(1) >= 0 THEN GOTO 2490
  338. 2460 IF (W1 <= 0.2) THEN GOTO 2490
  339. 2465 IF (W1 = 0.2) THEN GOTO 2490
  340. 2470 PRINT "WARP ENGINES ARE DAMAGED.    MAXIMUM SPEED = WARP 0.2"
  341. 2480 GOTO 2300
  342. 2490 LET N7 = INT(W1 * 8 + 0.5)
  343. 2500 IF E - N7 > 0 THEN GOTO 2590
  344. 2510 PRINT "ENGINEERING REPORTS 'INSUFFICIENT ENRGY AVAILABLE"
  345. 2520 PRINT "   FOR MANEUVERING AT WARP "; W1; "!'"
  346. 2530 IF S < N7 - E THEN GOTO 1990
  347. 2540 IF D(7) < 0 THEN GOTO 1990
  348. 2550 PRINT "DEFLECTOR CONTROL ROOM ACKNOWLEDGES "; S; " UNITS"
  349. 2560 PRINT "   OF ENERGY DEPLOYED TO THE SHIELDS."
  350. 2570 GOTO 5530
  351. 2580 REM KLINGONS MOVE/FIRE ON MOVING STARSHIP............
  352. 2590 FOR I = 1 TO K3
  353.    2600 IF K(I, 3) <= 0 THEN GOTO 2700
  354.    2610 LET A$ = "   "
  355.    2620 LET Z1 = K(I, 1)
  356.    2630 LET Z2 = K(1, 2)
  357.    2640 GOSUB 8670
  358.    2650 GOSUB 8570
  359.    2660 LET K(I, 1) = Z1
  360.    2670 LET K(I, 2) = Z2
  361.    2680 LET A$ = "+++"
  362.    2690 GOSUB 8670
  363. 2700 NEXT I
  364. 2710 GOSUB 6000
  365. 2720 LET D1 = 0
  366. 2730 LET D6 = W1
  367. 2740 IF W1 < 1 THEN GOTO 2770
  368. 2750 LET D6 = 1
  369. 2760 REM MAKE REPAIRS TO THE SHIP
  370. 2770 FOR I = 1 TO 8
  371.    2780 IF D(I) >= 0 THEN GOTO 2880
  372.    2790 LET D(I) = D(I) + D6
  373.    2800 IF D(I) < 0 THEN GOTO 2880
  374.    2810 IF D1 = 1 THEN GOTO 2840
  375.    2820 LET D1 = 1
  376.    2830 PRINT "DAMAGE CONTROL REPORT: "
  377.    2840 PRINT "        ";
  378.    2850 LET R1 = I
  379.    2860 GOSUB 8790
  380.    2870 PRINT " REPAIR COMPLETED"
  381. 2880 NEXT I
  382. 2890 REM DAMAGE/IMPROVEMENT DURING SOME VES
  383. 2900 IF (RND(1) > 0.2) THEN GOTO 3070
  384. 2910 LET R1 = INT(RND(1) * 8 + 1)
  385. 2920 IF (RND(1) >= 0.4) THEN GOTO 3000
  386. 2925 REM CHANGED 0.6 TO 0.4 TO MAKE THE GAME LESS IMPOSSIBLE - A. J. Y.
  387. 2930 LET D(R1) = D(R1) - (RND(1) * 5 + 1) / A1
  388. 2932 REM ADDED / A1 TO MAKE THE GAME LESS IMPOSSIBLE
  389. 2940 PRINT
  390. 2950 PRINT "DAMAGE CONTROL REPORT: ";
  391. 2960 GOSUB 8790
  392. 2970 PRINT " DAMAGED"
  393. 2980 PRINT
  394. 2990 GOTO 3070
  395. 3000 LET D(R1) = D(R1) + (RND(1) * 3.0 + 1.0)
  396. 3010 PRINT
  397. 3020 PRINT "DAMAGE CONTROL REPORT: ";
  398. 3030 GOSUB 8790
  399. 3040 PRINT " STATE OF REPAIR IMPROVED"
  400. 3050 PRINT
  401. 3060 REM BEGIN MOVING STARSHIP **
  402. 3070 REM EMPTY THE STARSHIP'S PLACE ON THE SCREEN
  403. 3075 LET A$ = "   "
  404. 3080 LET Z1 = INT(S1 + 0.5)
  405. 3090 LET Z2 = INT(S2 + 0.5)
  406. 3100 GOSUB 8670
  407. 3110 LET X1 = C(C1, 1) + (C(C1 + 1, 1) - C(C1, 1)) * (C1 - INT(C1))
  408. 3120 LET X = S1
  409. 3130 LET Y = S2
  410. 3140 LET X2 = C(C1, 2) + (C(C1 + 1, 2) - C(C1, 2)) * (C1 - INT(C1))
  411. 3150 LET Q4 = Q1
  412. 3160 LET Q5 = Q2
  413. 3164 DIM X8$
  414. 3170 FOR I = 1 TO N7
  415.    3180 LET S1 = S1 + X1
  416.    3190 LET S2 = S2 + X2
  417.    3200 IF S1 < 1 THEN GOTO 3500
  418.    3210 IF S1 >= 9 THEN GOTO 3500
  419.    3220 IF S2 < 1 THEN GOTO 3500
  420.    3230 IF S2 >= 9 THEN GOTO 3500
  421.    3240 LET S8 = INT(S1 + 0.5) * 24 + INT(S2 + 0.5) * 3 - 26
  422.    3250 IF S8 > 72 THEN 3280
  423.    3255 LET X8$ = MID$(Q$, S8, 3)
  424.    3257 REM IF NAVIGATING THRU EMPTY SPACE, GO ON:
  425.    3260 IF X8$ = "   " THEN GOTO 3360
  426.    3270 GOTO 3320
  427.    3280 IF S8 > 144 THEN GOTO 3310
  428.    3285 LET X8$ = MID$(R$, S8 - 72, 3)
  429.    3290 IF X8$ = "   " THEN GOTO 3360
  430.    3300 GOTO 3320
  431.    3310 LET X8$ = MID$(S$, S8 - 144, 3)
  432.    3315 IF X8$ = "   " THEN GOTO 3360
  433.    3320 LET S1 = S1 - X1
  434.    3330 LET S2 = S2 - X2
  435.    3340 PRINT "WARP ENGINES SHUT DOWN AT SECTOR "; S1; ", "; S2; " DUE TO "
  436.    3345 PRINT "BAD NAVIGATION"
  437.    3350 GOTO 3370
  438. 3360 NEXT I
  439. 3370 LET A$ = "<*>"
  440. 3380 LET Z1 = INT(S1 + 0.5)
  441. 3390 LET Z2 = INT(S2 + 0.5)
  442. 3400 GOSUB 8670
  443. 3410 GOSUB 3910
  444. 3420 LET T8 = 1
  445. 3430 IF W1 > 1 THEN GOTO 3450
  446. 3440 LET T8 = 0.1 * INT(10 * W1)
  447. 3450 LET T = T + T8
  448. 3460 IF T > T0 + T9 THEN GOTO 6220
  449. 3470 REM SEE IF DOCKED, THEN GET COMMAND
  450. 3480 GOTO 1980
  451. 3490 REM EXCEED QUADRANT LIMITS
  452. 3500 LET X = 8 * Q1 + X + N7 * X1
  453. 3510 LET Y = 8 * Q2 + Y + N7 * X2
  454. 3520 LET Q1 = INT(X / 8)
  455. 3530 LET Q2 = INT(Y / 8)
  456. 3540 LET S1 = INT(X - Q1 * 8)
  457. 3550 LET S2 = INT(Y - Q2 * 8)
  458. 3560 IF S1 <> 0 THEN GOTO 3590
  459. 3570 LET Q1 = Q1 - 1
  460. 3580 LET S1 = 8
  461. 3590 IF S2 <> 0 THEN GOTO 3620
  462. 3600 LET Q2 = Q2 - 1
  463. 3610 LET S2 = 8
  464. 3620 LET X5 = 0
  465. 3630 IF Q1 >= 1 THEN GOTO 3670
  466. 3640 LET X5 = 1
  467. 3650 LET Q1 = 1
  468. 3660 LET S1 = 1
  469. 3670 IF Q1 <= 8 THEN GOTO 3710
  470. 3680 LET X5 = 1
  471. 3690 LET Q1 = 8
  472. 3700 LET S1 = 8
  473. 3710 IF Q2 >= 1 THEN GOTO 3750
  474. 3720 LET X5 = 1
  475. 3730 LET Q2 = 1
  476. 3740 LET S2 = 1
  477. 3750 IF Q2 <= 8 THEN GOTO 3790
  478. 3760 LET X5 = 1
  479. 3770 LET Q2 = 8
  480. 3780 LET S2 = 8
  481. 3790 IF X5 = 0 THEN GOTO 3860
  482. 3800 PRINT "LT. UHURA REPORTS FROM STARFLEET COMMAND:"
  483. 3810 PRINT "  'PERMISSION TO ATTEMPT CROSSING OF GALACTIC PERIMETER"
  484. 3820 PRINT "  IS HEREBY *DENIED*.  SHUT DOWN YOUR ENGINES.'"
  485. 3830 PRINT "CHIEF ENGINEER SCOTT REPORTS 'WARP ENGINES SHUT DOWN"
  486. 3840 PRINT "       AT SECTOR "; S1; " "; S2; " OF QUADRANT "; Q1; ", "; Q2; ".'"
  487. 3850 IF T > T0 + T9 THEN GOTO 3370
  488. 3860 IF (8*Q1 + Q2) = (8*Q4 + Q5) THEN GOTO 3370
  489. 3870 LET T = T + 1
  490. 3880 GOSUB 3910
  491. 3890 GOTO 1320
  492. 3900 REM MANEUVER ENERGY S/R
  493. 3910 LET E = E - N7 - 10
  494. 3920 IF E > 0 THEN GOTO 3980
  495. 3930 PRINT "SHIELD CONTROL SUPPLIED ENERGY TO COMPLETE THE MANEUVER."
  496. 3940 LET S = S + E
  497. 3950 LET E = 0
  498. 3960 IF S > 0 THEN GOTO 3980
  499. 3970 LET S = 0
  500. 3980 RETURN
  501. 3990 REM L. R. SCAN SENSOR SCAN CODE ***
  502. 4000 IF D(3) >= 0 THEN GOTO 4030
  503. 4010 PRINT "LONG RANGE SENSORS ARE INOPERABLE"
  504. 4020 GOTO 1990
  505. 4030 PRINT "LONG RANGE SENSOR SCAN FOR QUADRANT "; Q1; ", "; Q2
  506. 4040 LET O1$ = "................."
  507. 4050 PRINT O1$
  508. 4060 FOR I = Q1 - 1 TO Q1 + 1
  509.    4070 DIM N(3)
  510.    4080 FOR I1 = 1 TO 3
  511.        4090 LET N(I1) = 0
  512.    4100 NEXT I1
  513.    4110 FOR J = Q2 - 1 TO Q2 + 1
  514.        4120 IF I < 1 THEN GOTO 4180
  515.        4130 IF I > 8 THEN GOTO 4180
  516.        4140 IF J < 1 THEN GOTO 4180
  517.        4150 IF J > 8 THEN GOTO 4180
  518.        4160 LET N(J - Q2 + 2) = G(I, J)
  519.        4170 LET Z(I, J) = G(I, J)
  520.    4180 NEXT J
  521.    4190 DIM P1$
  522.    4200 LET P1$ = ": ### : ### : ### :"
  523.    4210 PRINT USING P1$; N(1), N(2), N(3)
  524.    4220 PRINT O1$
  525. 4230 NEXT I
  526. 4240 GOTO 1990
  527. 4250 REM *** PHASER CONTROL CODE BEGINS HERE
  528. 4260 IF K3 > 0 THEN GOTO 4300
  529. 4270 PRINT "SCIENCE OFFICER SPOCK REPORTS 'SENSORS SHOW"
  530. 4280 PRINT "  NO ENEMY SHIPS IN THIS QUADRANT.'"
  531. 4290 GOTO 1990
  532. 4300 IF D(4) >= 0 THEN GOTO 4330
  533. 4310 PRINT "PHASERS INOPERATIVE"
  534. 4320 GOTO 1990
  535. 4330 IF D(8) >= 0 THEN GOTO 4350
  536. 4340 PRINT "COMPUTER FAILURE HAMPERS ACCURACY"
  537. 4350 PRINT "PHASERS LOCKED ON TARGET;  "
  538. 4360 PRINT "ENERGY AVAILABLE ="; E
  539. 4370 PRINT "NUMBER OF UNITS TO FIRE: ";
  540. 4380 INPUT X
  541. 4390 IF X <= 0 THEN GOTO 1990
  542. 4400 IF E - X < 0 THEN GOTO 4360
  543. 4410 LET E = E - X
  544. 4420 GOSUB 6000
  545. 4430 IF D(7) >= 0 THEN GOTO 4450
  546. 4440 LET X = X * RND(1)
  547. 4450 LET H1 = INT(X / K3)
  548. 4460 FOR I = 1 TO 3
  549.    4470 IF K(I, 3) <= 0 THEN GOTO 4670
  550.    4480 LET H = INT((H1 / (SQR((K(I, 1) - S1) ^ 2 + (K(I, 2) - S2) ^ 2)) * (RND(1) + 2)))
  551.    4490 IF H > 0.15 * K(I, 3) THEN GOTO 4530
  552.    4500 PRINT "SENSORS SHOW NO DAMAGE"
  553.    4510 PRINT "    TO ENEMY AT "; K(I, 1); ", "; K(I, 2)
  554.    4520 GOTO 4670
  555.    4530 LET K(I, 3) = K(I, 3) - H
  556.    4540 PRINT H; " UNIT HIT ON KLINGON AT SECTOR "; K(I, 1); ", "; K(I, 2)
  557.    4550 IF K(I, 3) <= O THEN GOTO 4580
  558.    4560 PRINT "    (SENSORS SHOW "; K(I, 3), " UNITS REMAINING)"
  559.    4570 GOTO 4670
  560.    4580 PRINT " *** KLINGON DESTROYED ***"
  561.    4590 LET K3 = K3 - 1
  562.    4600 LET K9 = K9 - 1
  563.    4610 LET A$ = "   "
  564.    4620 LET Z1 = K(I, 1)
  565.    4630 LET Z2 = K(I, 2)
  566.    4640 GOSUB 8670
  567.    4650 LET G(Q1, Q2) = K3 * 100 + B3 * 10 + S3
  568.    4655 LET Z(Q1, Q2) = G(Q1, Q2)
  569.    4660 IF K9 <= 0 THEN GOTO 6370
  570. 4670 NEXT I
  571. 4680 GOTO 1990
  572. 4690 REM PHOTON TORPEDO CODE BEGINS ***
  573. 4700 IF D(5) >= O THEN GOTO 4730
  574. 4710 PRINT "PHOTON TUBES ARE NOT OPERATIONAL "
  575. 4720 GOTO 1990
  576. 4730 IF P > 0 THEN GOTO 4760
  577. 4740 PRINT "ALL PHOTON TORPEDOS EXPENDED"
  578. 4750 GOTO 1990
  579. 4760 PRINT "TORPEDO COURSE (1-9) ";
  580. 4770 INPUT C1
  581. 4780 IF C1 >= 1 THEN GOTO 4810
  582. 4790 PRINT " ENSIGN CHEKOV REPORTS, 'INCORRECT COURSE DATA, SIR!'"
  583. 4800 GOTO 1990
  584. 4810 IF C1 > 9 THEN GOTO 4790
  585. 4820 IF C1 < 9 THEN GOTO 4850
  586. 4830 IF C1 >= 9 THEN GOTO 4760
  587. 4840 LET C1 = 1
  588. 4850 LET X1 = C(C1, 1) + (C(C1 + 1, 1) - C(C1, 1)) * (C1 - INT(C1))
  589. 4860 LET X2 = C(C1, 2) + (C(C1 + 1, 2) - C(C1, 2)) * (C1 - INT(C1))
  590. 4870 LET E = E - 2
  591. 4880 LET X = S1
  592. 4890 LET Y = S2
  593. 4900 LET P = P - 1
  594. 4910 PRINT "TORPEDO TRACK:"
  595. 4920 LET X = X + X1
  596. 4930 LET Y = Y + X2
  597. 4940 LET X3 = INT(X + 0.5)
  598. 4950 LET Y3 = INT(Y + 0.5)
  599. 4960 IF X3 < 1 THEN GOTO 5490
  600. 4970 IF X3 >= 9 THEN GOTO 5490
  601. 4980 IF Y3 < 1 THEN GOTO 5490
  602. 4990 IF Y3 >= 9 THEN GOTO 5490
  603. 5000 PRINT "               "; X3; ", "; Y3
  604. 5010 LET A$ = "   "
  605. 5020 LET Z1 = X
  606. 5030 LET Z2 = Y
  607. 5040 GOSUB 8830
  608. 5050 IF Z3 <> 0 THEN GOTO 4920
  609. 5060 LET A$ = "+++"
  610. 5070 LET Z1 = X
  611. 5080 LET Z2 = Y
  612. 5090 GOSUB 8830
  613. 5100 IF Z3 = 0 THEN GOTO 5210
  614. 5110 PRINT "*** KLINGON DESTROYED ***"
  615. 5120 LET K3 = K3 - 1
  616. 5130 LET K9 = K9 - 1
  617. 5140 IF K9 <= 0 THEN GOTO 6370
  618. 5150 FOR I = 1 TO 3
  619.    5160 IF X3 <> K(I, 1) THEN GOTO 5180
  620.    5170 IF Y3 = K(I, 2) THEN GOTO 5190
  621. 5180 NEXT I
  622. 5190 LET K(I, 3) = 0
  623. 5200 GOTO 5430
  624. 5210 LET A$ = " * "
  625. 5220 LET Z1 = X
  626. 5230 LET Z2 = Y
  627. 5240 GOSUB 8830
  628. 5250 IF Z3 = 0 THEN GOTO 5280
  629. 5260 PRINT "STAR AT "; X3; ", "; Y3; " ABSORBED TORPEDO ENERGY"
  630. 5270 GOTO 5500
  631. 5280 LET A$ = ">!<"
  632. 5290 LET Z1 = X
  633. 5300 LET Z2 = Y
  634. 5310 GOSUB 8830
  635. 5320 IF Z3 = 0 THEN GOTO 4760
  636. 5330 PRINT "*** STARBASE DESTROYED ***"
  637. 5340 LET B3 = B3 - 1
  638. 5350 LET B9 = B9 - 1
  639. 5360 IF B9 > 0 THEN GOTO 5400
  640. 5370 PRINT "THAT DOES IT, CAPTAIN!!  YOU ARE HEREBY RELIEVED OF COMMMAND"
  641. 5380 PRINT "   AND SENTENCED TO 99 STARDATES AT HARD LABOR ON CYGNUS 12!!"
  642. 5390 GOTO 6270
  643. 5400 PRINT "STARFLEET COMMAND REVIEWING YOUR RECORD TO CONSIDER"
  644. 5410 PRINT "   COURT MARTIAL!"
  645. 5420 LET D0 = 0
  646. 5430 LET A$ = "   "
  647. 5440 LET Z1 = X
  648. 5450 LET Z2 = Y
  649. 5460 GOSUB 8670
  650. 5470 LET G(Q1, Q2) = K3 * 100 + B3 * 10 + S3
  651. 5480 GOTO 5500
  652. 5490 PRINT "TORPEDO MISSED"
  653. 5500 GOSUB 6000
  654. 5510 GOTO 1990
  655. 5520 REM ** SHIELD CONTROL STARTS HERE
  656. 5530 IF D(7) >= 0 THEN GOTO 5560
  657. 5540 PRINT "SHIELD CONTROL INOPERABLE"
  658. 5550 GOTO 1990
  659. 5560 PRINT "ENERGY AVAILABLE = "; E + S; " NUMBER OF UNITS TO SHIELDS: ";
  660. 5570 INPUT X
  661. 5580 IF X >= 0 THEN GOTO 5620
  662. 5590 IF S <> X THEN GOTO 5620
  663. 5600 PRINT "(SHIELDS UNCHANGED)"
  664. 5610 GOTO 1990
  665. 5620 IF E + S - X < 0 THEN GOTO 5560
  666. 5630 LET E = E + S - X
  667. 5640 LET S = X
  668. 5650 PRINT "DEFLECTOR CONTROL ROOM REPORT:"
  669. 5660 PRINT "  'SHIELDS NOW AT "; S; " PER YOUR COMMAND'"
  670. 5670 GOTO 1990
  671. 5680 REM *** DAMAGE CONTROL STARTS HERE
  672. 5690 IF D(6) >= 0 THEN GOTO 5910
  673. 5700 PRINT "DAMAGE CONTROL REPORT NOT AVAILABLE"
  674. 5710 IF D0 = 0 THEN GOTO 1990
  675. 5720 LET D3 = 0
  676. 5730 FOR I = 1 TO 8
  677.    5740 IF D(I) >= 0 THEN GOTO 5760
  678.    5750 LET D3 = D3 + 0.1
  679. 5760 NEXT I
  680. 5770 IF D3 = 0 THEN GOTO 1990
  681. 5780 LET D3 = D3 + D4
  682. 5790 IF D3 < 1 THEN GOTO 5810
  683. 5800 LET D3 = 0.9
  684. 5810 PRINT "TECHNICIANS STANDING BY TO EFFECT REPAIRS TO YOUR SHIP."
  685. 5820 PRINT "ESTIMATED TIME TO REPAIR:";
  686. 5830 PRINT USING ".# STARDATES"; D3
  687. 5840 PRINT "WILL YOU AUTHORIZE THE REPAIR ORDER (YES/NO)";
  688. 5850 INPUT A$
  689. 5860 IF A$ <> "YES" THEN GOTO 1990
  690. 5870 FOR I = 1 TO 8
  691.    5880 LET D(I) = 0
  692. 5890 NEXT I
  693. 5900 LET T = T + D3 + 0.1
  694. 5910 PRINT
  695. 5920 PRINT "DEVICE        STATE OF REPAIR"
  696. 5930 FOR R1 = 1 TO 8
  697.    5940 GOSUB 8790
  698.    5950 PRINT USING "  -##.##"; D(R1)
  699. 5960 NEXT R1
  700. 5970 PRINT
  701. 5980 GOTO 5710
  702. 5990 REM "KLINGONS SHOOTING" CODE BEGINS ***
  703. 6000 IF K3 <= O THEN GOTO 6210
  704. 6010 IF D0 = 0 THEN GOTO 6040
  705. 6020 PRINT "STAR BASE SHIELDS PROTECT THE ENTERPRISE"
  706. 6030 GOTO 6210
  707. 6040 FOR I = 1 TO 3
  708.    6050 IF K(I, 3) <= 0 THEN GOTO 6200
  709.    6060 LET H = INT((K(I, 3) / (SQR((K(I, 1) - S1) ^ 2 + (K(I, 2) - S2) ^ 2)) * (2 + RND(1))))
  710.    6062 REM ADDED THE FOLLOWING TO MAKE THE GAME LESS IMPOSSIBLE
  711.    6064 LET H = INT(H / A1)
  712.    6070 LET S = S - H
  713.    6080 PRINT H; " UNIT HIT ON ENTERPRISE FROM SECTOR "; K(I, 1); ", "; K(I, 2)
  714.    6090 IF S < 0 THEN GOTO 6240
  715.    6100 PRINT "      (SHIELDS DOWN TO "; S; " UNITS.)"
  716.    6110 IF H < 20 THEN GOTO 6200
  717.    6120 IF RND(1) > 0.6 THEN GOTO 6200
  718.    6130 IF H / S <= 0.02 THEN GOTO 6200
  719.    6140 LET D2 = H / S + 0.5 * RND(1)
  720.    6150 LET R1 = INT(RND(1) * 8 + 1)
  721.    6160 LET D(R1) = D(R1) - D2
  722.    6170 PRINT "DAMAGE CONTROL REPORTS '";
  723.    6180 GOSUB 8790
  724.    6190 PRINT "DAMAGED BY THE HIT!'"
  725. 6200 NEXT I
  726. 6210 RETURN
  727. 6220 PRINT "IT IS STARDATE "; T
  728. 6230 GOTO 6270
  729. 6240 PRINT
  730. 6250 PRINT "THE ENTERPRISE HAS BEEN DESTROYED.";
  731. 6255 PRINT "  THE FEDERATION WILL BE CONQUERED."
  732. 6260 PRINT "IT IS STARDATE "; T
  733. 6270 PRINT "THERE WERE "; K9; " KLINGON BATTLE CRUISERS LEFT AT"
  734. 6280 PRINT " THE END OF YOUR MISSION."
  735. 6290 PRINT
  736. 6300 PRINT
  737. 6310 PRINT "THE FEDERATION IS IN NEED OF A NEW STARSHIP COMMANDER"
  738. 6320 PRINT "FOR A SIMILAR MISSION -- IF THERE IS A VOLUNTEER,"
  739. 6330 PRINT "LET HIM STEP FORWARD AND ENTER 'AYE'."
  740. 6335 PRINT "OTHERWISE, DISCONTINUE PLAYING BY ENTERING (CAR RET)."
  741. 6340 INPUT A$
  742. 6350 IF UCASE$(A$) = "AYE" THEN GOTO 240
  743. 6360 GOTO 9250
  744. 6370 PRINT "CONGRATULATIONS, CAPTAIN!  THE LAST KLINGON BATTLE CRUISER"
  745. 6380 PRINT "  MENACING THE FEDERATION HAS BEEN DESTROYED."
  746. 6390 PRINT
  747. 6400 PRINT "YOUR EFFICIENCY RATING IS "; ((K7 / (T - T0)) * 1000); ". "
  748. 6410 GOTO 6290
  749. 6420 REM S. R. SENSOR SCAN & STARTUP SUBR. ***
  750. 6430 FOR I = S1 - 1 TO S1 + 1
  751.    6440 FOR J = S2 - 1 TO S2 + 1
  752.        6450 IF INT(I + 0.5) < 1 THEN GOTO 6540
  753.        6460 IF INT(I + 0.5) > 8 THEN GOTO 6540
  754.        6470 IF INT(J + 0.5) < 1 THEN GOTO 6540
  755.        6480 IF INT(J + 0.5) > 8 THEN GOTO 6540
  756.        6490 LET A$ = ">!<"
  757.        6500 LET Z1 = I
  758.        6510 LET Z2 = J
  759.        6520 GOSUB 8830
  760.        6530 IF Z3 = 1 THEN GOTO 6580
  761.    6540 NEXT J
  762. 6550 NEXT I
  763. 6560 LET D0 = 0
  764. 6570 GOTO 6650
  765. 6580 LET D0 = 1
  766. 6590 LET C$ = "DOCKED"
  767. 6600 LET E = 3000 * A1
  768. 6602 REM THE VARIABLE E == ENERGY
  769. 6610 LET P = 10
  770. 6612 REM THE VARIABLE P == # OF TORPEDOS
  771. 6620 PRINT "SHIELDS DROPPED FOR DOCKING PURPOSES"
  772. 6630 LET S = 0
  773. 6632 REM THE VARIABLE S == ENERGY IN SHIELDS
  774. 6640 GOTO 6720
  775. 6650 IF K3 > 0 THEN GOTO 6690
  776. 6660 IF E < E0 * 0.1 THEN GOTO 6710
  777. 6670 LET C$ = "GREEN"
  778. 6680 GOTO 6720
  779. 6690 LET C$ = "*RED*"
  780. 6700 GOTO 6720
  781. 6710 LET C$ = "YELLOW"
  782. 6720 IF D(2) >= 0 THEN GOTO 6770
  783. 6730 PRINT
  784. 6740 PRINT "*** SHORT RANGE SENSORS ARE OUT ***"
  785. 6750 PRINT
  786. 6760 GOTO 7270
  787. 6770 LET Z4 = Q1
  788. 6771 LET Z5 = Q2
  789. 6772 LET Q5 = 0
  790. 6773 GOSUB 9030
  791. 6774 IF F7 = 1 THEN 6777
  792. 6775 PRINT "YOU ARE LOCATED IN THE GALACTIC QUADRANT, '"; G2$; "'..."
  793. 6777 PRINT
  794. 6778 LET F7 = 0
  795. 6779 LET O1$ = "---------------------------------"
  796. 6780 PRINT O1$
  797. 6790 DIM N5$
  798. 6800 LET N5$ = "#####"
  799. 6810 PRINT " ";
  800. 6820 FOR I = 1 TO 22 STEP 3
  801.    6825 LET Q9$ = MID$(Q$, I, 3)
  802.    6830 PRINT Q9$; " ";
  803. 6840 NEXT I
  804. 6850 PRINT
  805. 6860 PRINT " ";
  806. 6870 FOR I = 25 TO 46 STEP 3
  807.    6875 LET Q9$ = MID$(Q$, I, 3)
  808.    6880 PRINT Q9$; " ";
  809. 6890 NEXT I
  810. 6900 PRINT "               STARDATE        ";
  811. 6910 PRINT USING "####.#"; T
  812. 6920 PRINT " ";
  813. 6930 FOR I = 49 TO 70 STEP 3
  814.    6935 LET Q9$ = MID$(Q$, I, 3)
  815.    6940 PRINT Q9$; " ";
  816. 6950 NEXT I
  817. 6960 PRINT "               CONDITION       ";
  818. 6970 PRINT C$
  819. 6980 PRINT " ";
  820. 6990 FOR I = 1 TO 22 STEP 3
  821.    6995 LET R9$ = MID$(R$, I, 3)
  822.    7000 PRINT R9$; " ";
  823. 7010 NEXT I
  824. 7020 PRINT "               QUADRANT       "; Q1; ", "; Q2
  825. 7030 PRINT " ";
  826. 7040 FOR I = 25 TO 46 STEP 3
  827.    7045 LET R9$ = MID$(R$, I, 3)
  828.    7050 PRINT R9$; " ";
  829. 7060 NEXT I
  830. 7070 PRINT "               SECTOR         "; S1; ", "; S2
  831. 7080 PRINT " ";
  832. 7090 FOR I = 49 TO 70 STEP 3
  833.    7095 LET R9$ = MID$(R$, I, 3)
  834.    7100 PRINT R9$; " ";
  835. 7110 NEXT I
  836. 7120 PRINT "               TOTAL ENERGY    ";
  837. 7130 PRINT USING N5$; E + S
  838. 7140 PRINT " ";
  839. 7150 FOR I = 1 TO 22 STEP 3
  840.    7155 LET S4$ = MID$(S$, I, 3)
  841.    7160 PRINT S4$; " ";
  842. 7170 NEXT I
  843. 7180 PRINT "               PHOTON TORPEDOS ";
  844. 7190 PRINT USING N5$; P
  845. 7200 PRINT " ";
  846. 7210 FOR I = 25 TO 46 STEP 3
  847.    7215 LET S4$ = MID$(S$, I, 3)
  848.    7220 PRINT S4$; " ";
  849. 7230 NEXT I
  850. 7240 PRINT "               SHIELDS        ";
  851. 7250 PRINT USING N5$; S
  852. 7260 PRINT O1$
  853. 7270 RETURN
  854. 7280 REM *** LIBRARY COMPUTER CODE BEGINS HERE
  855. 7290 IF D(8) >= 0 THEN GOTO 7320
  856. 7300 PRINT "COMPUTER DISABLED"
  857. 7310 GOTO 1990
  858. 7320 PRINT "COMPUTER ACTIVE AND AWAITING COMMAND: (9 FOR HELP) ";
  859. 7330 INPUT a
  860. 7340 IF a < 0 THEN GOTO 1990
  861. 7350 PRINT
  862. 7360 LET H8 = 1
  863. 7370 IF a = 0 THEN GOTO 7540
  864. 7380 ON a GOTO 7900, 8070, 8500, 8150, 7400
  865. 7390 GOTO 7450
  866. 7400 REM *** CREATED S/R 20000 TO FIX CRIPPLING BUGS
  867. 7410 LET H8 = 0
  868. 7420 LET Q5 = 1
  869. 7430 PRINT "                         THE GALAXY"
  870. 7440 GOSUB 20000
  871. 7445 GOTO 1990
  872. 7450 PRINT "FUNCTIONS AVAILABLE FROM LIBRARY-COMPUTER:"
  873. 7460 PRINT "   0 = CUMULATIVE GALACTIC RECORD"
  874. 7470 PRINT "   1 = STATUS REPORT"
  875. 7480 PRINT "   2 = PHOTON TORPEDO DATA"
  876. 7490 PRINT "   3 = STARBASE NAV DATA"
  877. 7500 PRINT "   4 = DIRECTION/DISTANCE CALCULATOR"
  878. 7510 PRINT "   5 = GALAXY 'REGION NAME' MAP"
  879. 7520 GOTO 7320
  880. 7530 REM *** CUMULATIVE GALACTIC RECORD CODE BEGINS ***
  881. 7540 PRINT "COMPUTER RECORD OF GALAXY FOR QUADRANT "; Q1; ", "; Q2
  882. 7550 PRINT "     1     2     3     4     5     6     7     8"
  883. 7560 LET O3$ = "   ----- ----- ----- ----- ----- ----- ----- -----"
  884. 7570 PRINT O3$
  885. 7580 DIM N1$
  886. 7582 DIM N2$
  887. 7584 DIM N$
  888. 7590 FOR I = 1 TO 8
  889.    7600 LET N1$ = "#"
  890.    7610 PRINT USING N1$; I;
  891.    7620 IF H8 = 0 THEN GOTO 7740
  892.    7630 FOR J = 1 TO 8
  893.        7640 LET N2$ = "   ###"
  894.        7650 LET N$ = ""
  895.        7660 IF I <> Q1 THEN GOTO 7700
  896.        7670 IF J <> Q2 THEN GOTO 7700
  897.        7680 LET N$ = ""
  898.        7690 PRINT N$;
  899.        7700 PRINT USING N2$; Z(I, J);
  900.        7710 PRINT N$;
  901.    7720 NEXT J
  902.    7730 GOTO 7850
  903.    7740 LET Z4 = I
  904.    7750 LET Z5 = J
  905.    7760 GOSUB 9030
  906.    7770 LET J0 = INT(15 - 0.5 * LEN(G2$))
  907.    7780 PRINT TAB(J0);
  908.    7790 PRINT G2$;
  909.    7800 LET Z5 = 5
  910.    7810 GOSUB 9030
  911.    7820 LET J0 = INT(39 - 0.5 * LEN(G2$))
  912.    7830 PRINT TAB(J0);
  913.    7840 PRINT G2$;
  914.    7850 PRINT
  915.    7860 PRINT O3$
  916. 7870 NEXT I
  917. 7880 GOTO 1990
  918. 7890 REM *** STATUS REPORT CODE BEGINS HERE ***
  919. 7900 PRINT "    STATUS REPORT"
  920. 7910 LET X$ = ""
  921. 7920 IF K9 = 1 THEN GOTO 7940
  922. 7930 LET X$ = "S"
  923. 7940 PRINT K9; " KLINGON"; X$; " LEFT"
  924. 7950 LET V5 = (T0 + T9) - T
  925. 7960 PRINT USING "MISSION MUST BE COMPLETED IN ##.# STARDATES"; V5
  926. 7970 LET X$ = ""
  927. 7980 IF B9 = 1 THEN GOTO 8040
  928. 7990 LET X$ = "S"
  929. 8000 IF B9 <> 0 THEN GOTO 8040
  930. 8010 PRINT "YOUR STUPIDITY HAS LEFT YOU ON YOUR OWN IN"
  931. 8020 PRINT "  THE GALAXY -- YOU HAVE NO STARBASES LEFT!"
  932. 8030 GOTO 5690
  933. 8040 PRINT "THE FEDERATION IS MAINTAINING "; B9; " STARBASE"; X$;
  934. 8045 PRINT " IN THE GALAXY"
  935. 8050 GOTO 5690
  936. 8060 REM CODE FOR TORPEDO DATA, BASE NAV, D/D CALCULATOR
  937. 8070 PRINT "PHOTON TORPEDO SIGINT, PLUS GATHERED HUMINT:"
  938. 8071 IF K3 = 0 THEN GOTO 8492
  939. 8072 LET H8 = 0
  940. 8074 LET K5 = 1
  941. 8080 FOR I = 1 TO 3
  942.    8090 IF K(I, 3) <= 0 THEN GOTO 8480
  943.    8100 LET W9 = CDBL(K(I, 2))
  944.    8110 LET X9 = CDBL(K(I, 1))
  945.    8120 LET C9 = CDBL(S2)
  946.    8130 LET A9 = CDBL(S1)
  947.    8140 GOTO 8220
  948.    8150 PRINT "DIRECTION/DISTANCE CALULATOR:"
  949.    8160 PRINT "YOU ARE AT QUADRANT ("; Q1; ", "; Q2; ") SECTOR (";
  950.    8165 PRINT S1; ", "; S2; ")"
  951.    8170 PRINT "PLEASE ENTER --"
  952.    8180 PRINT "  INITIAL COORDINATES (X, Y) ";
  953.    8190 INPUT C9, A9
  954.    8200 PRINT "  FINAL COORDINATES   (X, Y) ";
  955.    8210 INPUT W9, X9
  956.    8211 REM REWORKED THIS CODE ENTIRELY WITH THE ATN() FUNCTION /AJY
  957.    8212 LET P7 = ATN(1.0#)
  958.    8213 REM ARCUS TANGENS (1.0) = PI / 4.0
  959.    8214 LET P7 = 4.0# * P7
  960.    8215 PRINT "COMPUTER RESPONDS:"
  961.    8220 LET X8 = A9 - X9
  962.    8221 REM THE Y COORDINATE GROWS GOING DOWNWARDS
  963.    8222 REM X8 = DELTA(Y)
  964.    8230 LET A8 = W9 - C9
  965.    8331 REM THE X COORDINATE GROWS GOING LEFTWARDS
  966.    8232 REM A8 = DELTA(X)
  967.    8234 REM    D-Y     AND    D-X
  968.    8250 IF (X8 > 0.0#) AND (A8 > 0.0#) THEN GOTO 8300
  969.    8260 IF (X8 < 0.0#) AND (A8 > 0.0#) THEN GOTO 8360
  970.    8270 IF (X8 < 0.0#) AND (A8 < 0.0#) THEN GOTO 8330
  971.    8280 IF (X8 > 0.0#) AND (A8 < 0.0#) THEN GOTO 8317
  972.    8282 IF (X8 = 0.0#) AND (A8 = 0.0#) THEN GOTO 8370
  973.    8284 IF (X8 = 0.0#) AND (A8 <> 0.0#) THEN GOTO 8401
  974.    8286 IF (X8 <> 0.0#) AND (A8 = 0.0#) THEN GOTO 8380
  975.    8290 PRINT "IMPOSSIBLE, I QUIT!"
  976.    8292 END
  977.    8300 REM HERE D-Y IS POS. AND D-X IS POS.
  978.    8305 GOSUB 30000
  979.    8310 PRINT "'DIRECTION = "; (D1 + 1.0#),
  980.    8315 GOTO 8460
  981.    8317 REM HERE D-Y IS POS. AND D-X IS NEG.
  982.    8318 GOSUB 30000
  983.    8320 PRINT "'DIRECTION = "; (5.0# - D1),
  984.    8322 GOTO 8460
  985.    8330 REM HERE D-Y AND D-Y ARE BOTH NEG.
  986.    8332 GOSUB 30000
  987.    8340 PRINT "'DIRECTION = "; (5.0# + D1),
  988.    8350 GOTO 8460
  989.    8360 REM HERE D-Y IS NEG. AND D-X IS POS.
  990.    8361 GOSUB 30000
  991.    8362 PRINT "'DIRECTION = "; (9.0# - D1),
  992.    8364 GOTO 8460
  993.    8370 PRINT "NO TRAVEL NECESSARY.'"
  994.    8372 GOTO 1990
  995.    8380 PRINT "'DIRECTION = ";
  996.    8382 IF X8 < 0 THEN GOTO 8390
  997.    8384 PRINT 1.0,
  998.    8386 GOTO 8460
  999.    8390 PRINT 5.0,
  1000.    8400 GOTO 8460
  1001.    8401 PRINT "'DIRECTION = ";
  1002.    8402 IF A8 < 0 THEN GOTO 8390
  1003.    8406 PRINT 3.0,
  1004.    8410 GOTO 8460
  1005.    8412 PRINT 7.0,
  1006.    8414 GOTO 8460
  1007.    8460 PRINT " DISTANCE = "; SQR(X8 ^ 2 + A8 ^ 2); "'"
  1008.    8470 IF H8 = 1 THEN GOTO 1990
  1009. 8480 NEXT I
  1010. 8490 GOTO 1990
  1011. 8492 PRINT "NO KLINGONS DETECTED."
  1012. 8494 GOTO 1990
  1013. 8500 IF B3 <> 0 THEN GOTO 8530
  1014. 8510 PRINT "MR. SPOCK REPORTS, 'SENSORS SHOW NO STARBASES IN THIS QUADRANT.'"
  1015. 8520 GOTO 1990
  1016. 8530 PRINT "FROM ENTERPRISE TO STARBASE:"
  1017. 8532 PRINT "'";
  1018. 8540 LET W1 = B4
  1019. 8550 LET X = B5
  1020. 8560 GOTO 8120
  1021. 8570 REM *** END OF LIBRARY-COMPUTER CODE
  1022. 8580 REM S/R FINDS RANDOM HOLE IN QUADRANT
  1023. 8590 LET R1 = INT(RND(1) * 8.0 + 1.0)
  1024. 8600 LET R2 = INT(RND(1) * 8.0 + 1.0)
  1025. 8610 LET A$ = "   "
  1026. 8620 LET Z1 = R1
  1027. 8630 LET Z2 = R2
  1028. 8640 GOSUB 8830
  1029. 8650 IF Z3 = 0 THEN GOTO 8590
  1030. 8660 RETURN
  1031. 8670 REM *** INSERTION IN STRING ARRAY FOR QUARDANT ***
  1032. 8680 LET S8 = INT(Z1 + 0.5) * 24 + INT(Z2 + 0.5) * 3 - 26
  1033. 8690 IF S8 > 72 THEN GOTO 8720
  1034. 8692 MID$(Q$, S8, 3) = A$
  1035. 8710 GOTO 8780
  1036. 8720 IF S8 > 144 THEN GOTO 8760
  1037. 8730 LET S8 = S8 - 72
  1038. 8740 MID$(R$, S8, 3) = A$
  1039. 8750 GOTO 8780
  1040. 8760 LET S8 = S8 - 144
  1041. 8765 REM TO THE LOCATION OF S8 IS ASSIGNED THE CHAR STRING A$
  1042. 8770 MID$(S$, S8, 3) = A$
  1043. 8780 RETURN
  1044. 8790 REM *** PRINTS DEVICE NAME FROM ARRAY ***
  1045. 8800 LET S8 = R1 * 12 - 11
  1046. 8807 LET D7$ = MID$(D$, S8, 12)
  1047. 8810 PRINT D7$; " ";
  1048. 8820 RETURN
  1049. 8830 REM *** STRING COMPARISON IN QUADRANT ARRAY ***
  1050. 8840 LET Z1 = INT(Z1 + 0.5)
  1051. 8850 LET Z2 = INT(Z2 + 0.5)
  1052. 8860 LET S8 = Z1 * 24 + Z2 * 3 - 26
  1053. 8865 DIM X9$
  1054. 8870 LET Z3 = 0
  1055. 8880 IF S8 > 72 THEN GOTO 8920
  1056. 8890 LET X9$ = MID$(Q$, S8, 3)
  1057. 8895 IF X9$ <> A$ THEN GOTO 9000
  1058. 8900 LET Z3 = 1
  1059. 8910 GOTO 9000
  1060. 8920 IF S8 > 144 THEN GOTO 8970
  1061. 8930 LET S8 = S8 - 72
  1062. 8940 LET X9$ = MID$(R$, S8, 3)
  1063. 8945 IF X9$ <> A$ THEN GOTO 9000
  1064. 8950 LET Z3 = 1
  1065. 8960 GOTO 9000
  1066. 8970 LET S8 = S8 - 144
  1067. 8980 LET X9$ = MID$(S$, S8, 3)
  1068. 8985 IF X9$ <> A$ THEN GOTO 9000
  1069. 8990 LET Z3 = 1
  1070. 9000 RETURN
  1071. 9010 REM *** S/R PRODUCES QUADRANT NAME IN G2$ FROM Z4, Z5 (=Q1,Q2)
  1072. 9020 REM *** (CALL WITH Q5=1 TO GET REGION NAME ONLY)
  1073. 9030 LET L2 = 2
  1074. 9035 REM IF Z5 > 5 THEN IT IS THE RIGHTMOST OF A PAIR OF NAMES
  1075. 9040 IF Z5 >= 5 THEN GOTO 9060
  1076. 9050 LET L2 = 1
  1077. 9060 LET L3 = 2 * (Z4 - 1) + L2
  1078. 9070 LET I3 = 1
  1079. 9080 LET I0 = 1
  1080. 9085 DIM Y7$
  1081. 9090 FOR L = 1 TO LEN(G1$)
  1082.    9095 LET Y7$ = MID$(G1$, L, 2)
  1083.    9100 IF Y7$ <> ". " THEN GOTO 9140
  1084.    9110 IF I3 = L3 THEN GOTO 9150
  1085.    9120 LET I0 = L + 1
  1086.    9130 LET I3 = I3 + 1
  1087. 9140 NEXT L
  1088. 9150 LET G2$ = MID$(G1$, I0 + 1, L - 1 - I0)
  1089. 9160 IF Q5 = 1 THEN GOTO 9240
  1090. 9170 LET L3 = 25
  1091. 9180 IF Z5 <= 4 THEN GOTO 9200
  1092. 9190 LET L3 = Z5 - 4
  1093. 9200 LET G3$ = "IV"
  1094. 9210 IF L3 = 4 THEN GOTO 9230
  1095. 9220 LET G3$ = MID$(G4$, 1, L3)
  1096. 9230 LET G2$ = G2$ + " " + G3$
  1097. 9240 RETURN
  1098. 9250 END
  1099. 10000 REM THE INSTRUCTIONS SUBROUTINE
  1100. 10030 DIM A5$
  1101. 10040 FOR I = 1 TO 9
  1102.    10050 ON I GOSUB 10240, 10360, 10540, 10640, 10720, 10780, 10860, 10910, 10960
  1103.    10060 PRINT
  1104.    10070 PRINT "(TO CONTINUE, HIT 'RETURN')"
  1105.    10080 PRINT
  1106.    10090 INPUT A5$: CLS
  1107. 10100 NEXT I
  1108. 10110 PRINT "1. WHEN YOU SEE 'COMMAND ?' PRINTED, ENTER ONE OF THE LEGAL"
  1109. 10120 PRINT "     COMMANDS (NAV, SRS, LRS, PHA, TOR, SHE, DAM, COM, OR XXX)."
  1110. 10130 PRINT "2. IF YOU SHOULD TYPE IN AN ILLEGAL COMMAND, YOU'LL GET A SHORT"
  1111. 10140 PRINT "     LIST OF THE LEGAL COMMANDS PRINTED OUT."
  1112. 10150 PRINT "3. SOME COMMANDS REQUIRE YOU TO ENTER DATA.  (FOR EXAMPLE, THE"
  1113. 10160 PRINT "     'NAV' COMMAND COMES BACK WITH 'COURSE (1-9)?'.  IF YOU"
  1114. 10170 PRINT "     TYPE IN ILLEGAL DATA (LIKE NEGATIVE NUMBERS), THAT COMMAND"
  1115. 10180 PRINT "     WILL BE ABORTED."
  1116. 10190 PRINT
  1117. 10200 PRINT "HIT (CAR RET) TO CONTINUE "
  1118. 10210 INPUT A5$
  1119. 10215 PRINT
  1120. 10220 RETURN
  1121. 10230 REM ***** EXIT HERE *****
  1122. 10240 PRINT
  1123. 10250 PRINT "       INSTRUCTIONS FOR ** STAR TREK **"
  1124. 10260 PRINT
  1125. 10270 PRINT "THE GALAXY IS DIVIDED INTO AN 8 X 8 QUADRANT GRID,"
  1126. 10280 PRINT "AND EACH QUADRANT IS FURTHER DIVIDED INTO AN 8 X 8 SECTOR GRID."
  1127. 10290 PRINT
  1128. 10300 PRINT "   YOU WILL BE ASSIGNED A STARTING POINT SOMEWHERE IN THE GALAXY"
  1129. 10310 PRINT "TO BEGIN A TOUR OF DUTY AS COMMANDER OF THE STARSHIP 'ENTERPRISE';"
  1130. 10320 PRINT "YOUR MISSION: TO SEEK AND DESTROY THE FLEET OF KLINGON WARSHIPS"
  1131. 10330 PRINT "WHICH ARE MENACING THE UNITED FEREDATION OF PLANETS."
  1132. 10340 PRINT
  1133. 10350 RETURN
  1134. 10360 PRINT
  1135. 10370 PRINT "YOU HAVE THE FOLLOWING COMMANDS AVAILABLE TO YOU AS"
  1136. 10380 PRINT "CAPTAIN OF THE STARSHIP:"
  1137. 10390 PRINT "'NAV' COMMAND = WARP ENGINE CONTROL --"
  1138. 10400 PRINT "  COURSE IS IN A CIRCULAR NUMERICAL        4  3  2"
  1139. 10410 PRINT "  VECTOR ARRANGEMENT AS SHOWN.              . . . "
  1140. 10420 PRINT "  INTEGER AND REAL VALUES MAY BE             ...  "
  1141. 10430 PRINT "  USED.  (THUS, COURSE 1.5 IS HALF -       5-----1"
  1142. 10440 PRINT "  WAY BETWEEN 1 AND 2.)                      ...  "
  1143. 10450 PRINT "                                            . . . "
  1144. 10460 PRINT "  VALUES MAY APPROACH 9.0, WHICH           6  7  8"
  1145. 10470 PRINT "  ITSELF IS EQUIVALENT TO 1.0."
  1146. 10480 PRINT "                                           COURSE "
  1147. 10490 PRINT " ONE WARP FACTOR IS THE SIZE OF"
  1148. 10500 PRINT " ONE QUADRANT.  THEREFORE, TO GET"
  1149. 10510 PRINT " FROM QUADRANT 6, 5 TO 5, 5, YOU WOULD"
  1150. 10520 PRINT " USE COURSE 3, WARP FACTOR 1."
  1151. 10530 RETURN
  1152. 10540 PRINT
  1153. 10545 PRINT "'SRS' COMMAND = SHORT RANGE SENSOR SCAN"
  1154. 10550 PRINT "  SHOWS YOU A SCAN OF YOUR PRESENT QUADRANT."
  1155. 10560 PRINT "  SYMBOLOGY ON YOUR SENSOR SCREEN IS A FOLLOWS:"
  1156. 10570 PRINT "      <*> = YOUR STARSHIP'S POSITION"
  1157. 10580 PRINT "      +++ = KLINGON BATTLE CRUISER"
  1158. 10590 PRINT "      >!< = FEDERATION STARBASE (REFUEL/REPAIR/RE-ARM HERE!)"
  1159. 10600 PRINT "       *  = STAR"
  1160. 10610 PRINT "  A CONDENSED 'STATUS REPORT' WILL ALSO BE PRESENTED."
  1161. 10620 PRINT
  1162. 10630 RETURN
  1163. 10640 PRINT
  1164. 10645 PRINT "'LRS' COMMAND = LONG RANGE SENSOR SCAN"
  1165. 10650 PRINT "  SHOWS CONDITIONS IN SPACE FOR ONE QUADRANT ON EACH SIDE"
  1166. 10660 PRINT "  OF THE ENTERPRISE (WHICH IS IN THE MIDDLE OF THE SCAN)"
  1167. 10670 PRINT "  THE SCAN IS CODED IN THE FORM '###', WHERE THE UNITS DIGIT"
  1168. 10680 PRINT "  IS THE NUMBER OF STARS, TENS DIGIT IS THE NUMBER OF STARBASES,"
  1169. 10690 PRINT "  AND HUNDREDS DIGIT IS THE NUMBER OF KLINGONS."
  1170. 10700 PRINT "    EXAMPLE -- 207 = 2 KLINGONS, NO STARBASES, 7 STARS."
  1171. 10710 RETURN
  1172. 10720 PRINT
  1173. 10725 PRINT "'PHA' COMMAND = PHASER CONTROL"
  1174. 10730 PRINT "  ALLOWS YOU TO DESTROY THE KLINGON BATTLE CRUISERS BY"
  1175. 10740 PRINT "  ZAPPING THEM WITH SUITABLY LARGE UNITS OF ENERGY TO"
  1176. 10750 PRINT "  DEPLETE THEIR SHIELD POWER.  (REMEMBER, KLINGONS HAVE"
  1177. 10760 PRINT "  PHASERS, TOO!)"
  1178. 10770 RETURN
  1179. 10780 PRINT
  1180. 10785 PRINT "'TOR' COMMAND = PHOTON TORPEDO CONTROL."
  1181. 10790 PRINT "  TORPEDO COURSE IS THE SAME AS USED IN WARP ENGINE CONTROL."
  1182. 10800 PRINT "  IF YOU HIT THE KLINGON VESSEL, HE IS DESTROYED AND"
  1183. 10810 PRINT "  CANNOT FIRE BACK AT YOU.  IF YOU MISS, YOU ARE SUBJECT TO"
  1184. 10820 PRINT "  HIS PHASER FIRE."
  1185. 10830 PRINT "    NOTE: THE LIBRARY-COMPUTER ('COM' COMMAND) HAS AN"
  1186. 10840 PRINT "      OPTION TO COMPUTE TORPEDO TRAJECTORY FOR YOU (OPTION 2))."
  1187. 10850 RETURN
  1188. 10860 PRINT
  1189. 10865 PRINT "'SHE' COMMMAND = SHIELD CONTROL."
  1190. 10870 PRINT "  DEFINES NUMBER OF ENERGY UNITS TO BE ASSIGNED TO SHIELDS."
  1191. 10880 PRINT "  ENERGY IS TAKEN FROM TOTAL SHIP'S ENERGY.  NOTE THAT THE"
  1192. 10890 PRINT "  TOTAL ENERGY INCLUDES SHIELD ENERGY."
  1193. 10900 RETURN
  1194. 10910 PRINT
  1195. 10915 PRINT "'DAM' COMMAND = DAMAGE CONTROL REPORT"
  1196. 10920 PRINT "  GIVES STATE OF REPAIR OF ALL DEVICES, WHERE A NEGATIVE"
  1197. 10930 PRINT "  'STATE OF REPAIR' SHOWS THAT THE DEVICE IS TEMPORARILY"
  1198. 10940 PRINT "  DAMAGED."
  1199. 10950 RETURN
  1200. 10960 PRINT
  1201. 10965 PRINT "'COM' COMMMAND = LIBRARY-COMPUTER"
  1202. 10970 PRINT "  THE LIBRARY-COMPUTER CONTAINS SIX OPTIONS:"
  1203. 10980 PRINT "  OPTION 0 = CUMULATIVE GALACTIC RECORD"
  1204. 10990 PRINT "     WHICH SHOWS COMPUTER MEMORY OF THE RESULTS OF ALL PREVIOUS"
  1205. 11000 PRINT "     LONG RANGE SENSOR SCANS."
  1206. 11010 PRINT "  OPTION 1 = STATUS REPORT"
  1207. 11020 PRINT "     WHICH THE NUMBER OF KLINGONS, STARDATES, AND STARBASES"
  1208. 11030 PRINT "     REMAINING IN THE GAME."
  1209. 11040 PRINT "  OPTION 2 = PHOTON TORPEDO DATA"
  1210. 11050 PRINT "     WHICH GIVES DIRECTIONS AND DISTANCE FROM THE ENTERPRISE"
  1211. 11060 PRINT "     TO ALL KLINGONS IN YOU QUADRANT"
  1212. 11070 PRINT "  OPTION 3 = STARBASE NAV DATA"
  1213. 11080 PRINT "     WHICH GIVES DIRECTION AND DISTANCE TO ANY STARBASE"
  1214. 11090 PRINT "     WITHIN YOUR QUADRANT"
  1215. 11100 PRINT "  OPTION 4 = DIRECTION/DISTANCE CALCULATOR"
  1216. 11110 PRINT "     WHICH ALLOWS YOU TO ENTER COORDINATES FOR"
  1217. 11120 PRINT "     DIRECTION/DISTANCE CALCULATIONS."
  1218. 11130 PRINT "  OPTION 5 = GALACTIC 'REGION NAME' MAP"
  1219. 11140 PRINT "     WHICH PRINTS THE NAMES OF THE SIXTEEN MAJOR GALACTIC"
  1220. 11150 PRINT "     REGIONS REFERRED TO IN THE GAME."
  1221. 11160 RETURN
  1222. 20000 REM **** PROGRAMMMED A NEW SUBROUTINE TO DISPLAY THE GALAXY
  1223. 20010 PRINT "     1     2     3     4     5     6     7     8"
  1224. 20020 LET O3$ = "   ----- ----- ----- ----- ----- ----- ----- -----"
  1225. 20030 PRINT O3$
  1226. 20040 FOR J = 1 TO 8
  1227.    20050 PRINT USING "#"; J;
  1228.    20060 PRINT "         ";
  1229.    20065 LET Q5 = 1
  1230.    20066 LET Z4 = J
  1231.    20067 LET Z5 = 2
  1232.    20070 GOSUB 9030
  1233.    20080 PRINT G2$;
  1234.    20082 FOR J9 = 1 TO (25 - LEN(G2$))
  1235.        20090 PRINT " ";
  1236.    20092 NEXT J9
  1237.    20100 LET Z5 = 7
  1238.    20110 GOSUB 9030
  1239.    20120 PRINT G2$
  1240.    20130 PRINT "     I    II   III    IV     I    II   III    IV"
  1241. 20200 NEXT J
  1242. 20210 LET Q5 = 0
  1243. 20220 RETURN
  1244. 30000 REM AUX S/R FOR DIRECTION/DISTANCE CALCLULATION
  1245. 30005 REM REWORKED ALL OF THIS CODE TO USE TRIGONOMETRY A. J. Y. 10-18-2010
  1246. 30010 LET D4 = ABS(ATN(ABS(X9) / ABS(A8)))
  1247. 30012 LET P7 = ATN(1.0#)
  1248. 30014 LET P7 = 4.0# * P7
  1249. 30020 LET D1 = (D4 / (2.0# * P7)) * 8.0#
  1250. 30030 RETURN
  1251. 99999 END
  1252.  
  1253.  
  1254.  
  1255.  



Offline anttiylikoski

  • Newbie
  • Posts: 25
    • View Profile
Re: The author's collection of QB64 demos
« Reply #6 on: March 01, 2020, 11:25:01 am »
The U.S. written Super Star Trek in the QB64.

Code: QB64: [Select]
  1.  
  2.  
  3. ' The Super Star Trek, by Antti J Ylikoski 01-07-2011 -- 05-06-2012.
  4. '
  5. ' Adapted for the QB64 by Antti Ylikoski 05-06-2012.
  6. ' Finished corrections and bug fixes, AJY 05-11-2012.
  7. '
  8. ' See http://[abandoned, outdated and now likely malicious qb64 dot net website - don’t go there] for the QB64.EXE BASIC system, which is the
  9. ' best freeware BASIC that I have come across.
  10. '
  11. ' Start the QB64.EXE, Open the file and execute CTL-F5 to run the program --
  12. ' good luck, admiral!!!
  13. '
  14. ' Variable i7 == initial energy; changed from 5000 to 20000 to make the game easier to win
  15. ' variable l2 == 1,2,3 after short, medium, long game
  16. ' variable r5 == remaining time
  17. ' variable i5 == initial remaining time
  18. ' changed i5 to i5 = 10 * l2 to make the game winnable
  19. ' In line 18090, lowered the hitpower of Klingon n [k6(n)] by 325 units
  20. ' in line 18130, lowered the hitpower of a Klingon commander n [k6(n)] by 1000 units
  21. ' In line 14090, added PRINT USING " ###";
  22. ' In lines 3130 and 3150, added PRINT USING " ###";
  23. ' Corrected PRINT statements in lines 3001 and 3010
  24. ' Corrected several points in I/O routines.
  25. '
  26. ' Direction of space travel is in numbers 1.0--12.0 clockwise from
  27. ' 0 degrees, which is Direction 1 and is directly up ("north").
  28. '
  29. ' The direction D: 1 <= D <= 12.  12 == 360 degrees == direction 1.
  30. ' Direction 1 is directly upwards ("north").
  31. ' Direction 3 is directly to the right ("eastwards").
  32. ' Directions are real numbers, counting clockwise from Direction 1.
  33. ' AJY 2014-07-02.
  34. '
  35.  
  36. 1 REM From: whirata@pixi.com (Wayne R Hirata) Newsgroups: comp.lang.basic.misc
  37. 2 REM Subject: Re: Old 1976 Star Trek in BASIC (no graphics)
  38. 3 REM Date: Sun, 17 Sep 1995 08:11:44 GMT
  39. 4 REM
  40. 5 REM  *** SUPER STAR TREK ***
  41. 6 REM   INTELLEC MDS VERSION
  42. 7 REM WRITTEN IN BASIC BY RON WILLIAMS
  43. 8 REM   INTEL CORP. - 5/15/76
  44. 9 REM ADAPTED FROM A FORTRAN VERSION WRITTEN
  45. 10 REM   FOR THE CDC 6600 IN 1974.
  46. 11 REM
  47. 12 DIM g1$(16), v$(5, 5), c$(20), g(8, 8), d$(12), q$(10, 10), d4(12), d9(106)
  48. 13 DIM s2(8, 8), t$(10), s$(10), c2$(10), c5(10), g1(10), f1(10)
  49. 14 DIM s7$(10), c1(10), c2(10), b2(10), b3(10): q$ = "?"
  50. 15 DIM spc$(40)
  51. 16 DIM k6(10): REM how much the k6(n)'th Klingon shoots at us
  52. 19 DATA "S.R. SENSORS","L.R. SENSORS","PHASERS","PHOTON TUBES","LIFE SUPPORT"
  53. 20 DATA "WARP ENGINES","IMPULSE ENGINES","SHIELDS","SUBSPACE RADIO"
  54. 21 DATA "SHUTTLE CRAFT","COMPUTER","TRANSFER PANEL","ABANDON","CHART","COMPUTER"
  55. 22 DATA "DAMAGES","DESTRUCT","DOCK","IDLE","IMPULSE","LRSCAN","NAVIGATE","PHASERS","QUIT"
  56. 23 DATA "SHIELDS","SOS","SRSCAN","STATUS","TORPEDO","TRANSFER","VISUAL","WARP","SHORT"
  57. 24 DATA "MEDIUM","LONG","BEGINNER","NOVICE","SENIOR","EXPERT","COURSE","WCOST","ICOST"
  58. 25 DATA "PEFFECT","SCORE","END","ANTARES","SIRIUS","RIGEL","MERAK","PROCYON","CAPELLA"
  59. 26 DATA "VEGA","DENEB","CANOPUS","ALDEBARAN","ALTAIR","REGULUS","BELLATRIX","ARCTURUS"
  60. 27 DATA "POLLUX","SPICA",10.5,12,1.5,9,0,3,7.5,6,4.5
  61. 30 RANDOMIZE TIME
  62. 35 GOSUB 40000
  63. 40 FOR i = 1 TO 12: READ d$(i): NEXT: FOR i = 1 TO 20: READ c$(i): NEXT
  64. 43 FOR i = 1 TO 3: READ t$(i): NEXT: FOR i = 1 TO 4: READ s$(i): NEXT: FOR i = 1 TO 6
  65. 44 READ c2$(i): NEXT: FOR i = 1 TO 16: READ g1$(i): NEXT: FOR i = 1 TO 9: READ c5(i): NEXT
  66. 45 REM CALL SETUP
  67. 46 GOSUB 24000: s7$(1) = "": s7$(2) = " ": s7$(3) = " ": s7$(4) = ""
  68. 70 IF a2 <> 0 THEN 900
  69. 75 j4 = 0: t1 = 0: PRINT: INPUT "COMMAND "; a$: IF LEN(a$) > 1 THEN 110
  70. 80 PRINT "USE AT LEAST 2 LETTERS, PLEASE.": GOTO 75
  71. 110 FOR i = 1 TO 20
  72.    120 IF a$ = LEFT$(c$(i), LEN(a$)) THEN 150
  73. 130 NEXT
  74. 135 INPUT "ILLEGAL COMMAND - DO YOU NEED A LIST "; b$
  75. 136 IF LEFT$(b$, 1) = "N" THEN 70
  76. 140 PRINT: FOR i = 1 TO 20 STEP 4
  77.    141 PRINT c$(i); TAB(12); c$(i + 1); TAB(22); c$(i + 2); TAB(32); c$(i + 3)
  78. 142 NEXT: PRINT: GOTO 70
  79. 150 ON i GOTO 200, 225, 250, 275, 290, 300, 325, 350, 375, 400
  80. 160 ON i - 10 GOTO 425, 450, 475, 500, 525, 540, 550, 575, 600, 625
  81. 170 PRINT "ERROR AT 170 - SHOULD NOT BE HERE"
  82. 180 END
  83. 200 REM-ABANDON
  84. 201 GOSUB 35000
  85. 210 GOTO 70
  86. 225 REM-CHART
  87. 226 GOSUB 3000
  88. 230 GOTO 70
  89. 250 REM-COMPUTER
  90. 251 GOSUB 5000
  91. 260 GOTO 70
  92. 275 REM-DAMAGES
  93. 276 GOSUB 8000
  94. 280 GOTO 70
  95. 290 REM - DESTRUCT
  96. 291 GOSUB 36000: GOTO 70
  97. 300 REM-DOCK
  98. 301 GOSUB 7000
  99. 310 GOTO 70
  100. 325 REM-IDLE
  101. 326 GOSUB 33000
  102. 330 IF j3 = 0 THEN 70
  103. 331 IF a2 <> 0 THEN 900
  104. 332 IF g(q1, q2) = 1000 THEN 750
  105. 340 GOSUB 1000
  106. 345 GOTO 70
  107. 350 REM-IMPULSE
  108. 351 GOSUB 13000
  109. 352 IF j3 = 0 THEN 70
  110. 353 GOTO 700
  111. 375 REM-LRSCAN
  112. 376 GOSUB 14000
  113. 377 GOTO 70
  114. 400 REM-NAVIGATE
  115. 401 GOSUB 34000
  116. 402 IF j3 = 0 THEN 70
  117. 410 GOTO 700
  118. 425 REM-PHASERS
  119. 426 GOSUB 20000
  120. 427 IF j3 = 0 THEN 70
  121. 428 GOSUB 1000
  122. 429 GOTO 70
  123. 450 REM-QUIT
  124. 455 GOTO 900
  125. 460 PRINT "TOO BAD...WE HATE TO LOSE GOOD ASTRONAUTS!"
  126. 465 GOTO 37010
  127. 475 REM-SHIELDS
  128. 476 GOSUB 26000
  129. 477 IF j3 = 0 THEN 70
  130. 478 IF a2 <> 0 THEN 900
  131. 479 GOSUB 1000
  132. 480 s9 = 0
  133. 485 GOTO 70
  134. 500 REM-SOS
  135. 501 GOSUB 11000
  136. 502 GOTO 70
  137. 525 REM-SRSCAN
  138. 526 GOSUB 29000
  139. 530 GOTO 70
  140. 540 REM - STATUS
  141. 541 PRINT
  142. 545 GOSUB 37000: GOTO 70
  143. 550 REM-TORPEDOS
  144. 551 GOSUB 21000
  145. 552 IF j3 = 0 THEN 70
  146. 555 GOTO 700
  147. 575 REM-TRANSFER
  148. 576 GOSUB 31000
  149. 580 IF j3 = 0 THEN 70
  150. 585 IF a2 <> 0 THEN 900
  151. 590 IF g(q1, q2) <> 1000 THEN 70
  152. 595 GOTO 750
  153. 600 REM-VISUAL
  154. 601 GOSUB 32000
  155. 602 IF j3 = 0 THEN 70
  156. 603 IF a2 <> 0 THEN 900
  157. 610 IF g(q1, q2) <> 1000 THEN 70
  158. 615 GOTO 750
  159. 625 REM-WARP
  160. 627 GOSUB 25000
  161. 630 GOTO 70
  162. 700 REM-AFTERMOVINGSTARSHIP
  163. 710 IF a2 <> 0 THEN 900
  164. 720 IF t1 <> 0 THEN GOSUB 9000
  165. 730 IF a2 <> 0 THEN 900
  166. 740 IF g(q1, q2) < 1000 THEN 790
  167. 750 GOSUB 2000
  168. 760 IF a2 <> 0 THEN 900
  169. 770 GOTO 740
  170. 790 GOSUB 1000
  171. 795 GOTO 70
  172. 900 REM-WE'RE FINISHED
  173. 901 PRINT: PRINT: INPUT "WOULD YOU LIKE TO TRY AGAIN "; a$
  174. 910 IF LEFT$(a$, 1) = "Y" THEN 45
  175. 920 GOTO 460
  176. 940 REM-BEGINSUBROUTINES
  177. 1000 REM-ATTACK
  178. 1010 IF (c3 <> 0) AND (j4 = 0) THEN GOSUB 16000
  179. 1020 IF k3 = 0 THEN RETURN
  180. 1030 IF a2 <> 0 THEN RETURN
  181. 1040 p2 = 1 / i8
  182. 1050 j5 = 0
  183. 1060 PRINT
  184. 1070 IF c5$ = "DOCKED" THEN 1780
  185. 1080 h2 = 0: h3 = 0: c6 = 1
  186. 1090 IF s9 = 1 THEN c6 = 0.5 + 0.5 * RND(1)
  187. 1100 a3 = 0
  188. 1110 FOR l = 1 TO k3
  189.    1120 IF k6(l) < 0 THEN 1540
  190.    1130 a3 = 1
  191.    1140 d6 = 0.8 + 0.05 * RND(1)
  192.    1150 h4 = k6(l) * d6 ^ k8(l)
  193.    1160 IF (s4 = 0) AND (s9 = 0) THEN 1230
  194.    1170 p3 = 0.1: IF p2 * s3 > p3 THEN p3 = p2 * s3
  195.    1180 h5 = p3 * c6 * h4 + 1
  196.    1190 IF h5 > s3 THEN h5 = s3
  197.    1195 s3 = s3 - h5
  198.    1200 h4 = h4 - h5
  199.    1210 IF (p3 > 0.1) AND (h4 < 5.000000E-03 * e1) THEN 1540
  200.    1230 j5 = 1
  201.    1240 PRINT FNR(h4); "UNIT HIT ON THE "; s5$; " FROM ";
  202.    1250 j6 = k4(l): j7 = k5(l)
  203.    1260 IF q$(j6, j7) = "K" THEN PRINT "KLINGON AT";
  204.    1270 IF q$(j6, j7) = "C" THEN PRINT "COMMANDER AT";
  205.    1280 PRINT j6; "-"; j7
  206.    1290 IF h4 > h2 THEN h2 = h4
  207.    1300 h3 = h3 + h4
  208.    1310 IF h4 < (275 - 25 * s8) * (1 + 0.5 * RND(1)) THEN 1530
  209.    1320 n4 = 1 + INT(h4 / (500 + 100 * RND(1)))
  210.    1330 PRINT "***CRITICAL HIT--";
  211.    1340 k9 = 1
  212.    1350 FOR w4 = 1 TO n4
  213.        1360 j9 = INT(12 * RND(1)) + 1
  214.        1370 c5(w4) = j9
  215.        1380 e3 = (h4 * d5) / (n4 * (75 + 25 * RND(1)))
  216.        1390 IF j9 = 6 THEN e3 = e3 / 3
  217.        1395 d4(j9) = d4(j9) + e3
  218.        1400 IF w4 = 1 THEN 1470
  219.        1420 FOR v = 1 TO w4
  220.            1430 IF j9 = c5(v - 1) THEN 1480
  221.        1440 NEXT v
  222.        1450 k9 = k9 + 1
  223.        1460 IF k9 = 3 THEN PRINT
  224.        1465 PRINT " AND ";
  225.        1470 PRINT d$(j9);
  226.    1480 NEXT w4
  227.    1490 PRINT " DAMAGED."
  228.    1500 IF d4(8) = 0 THEN 1530
  229.    1510 IF s4 <> 0 THEN PRINT "*** SHIELDS KNOCKED DOWN."
  230.    1520 s4 = 0
  231.    1530 e1 = e1 - h4
  232. 1540 NEXT l
  233. 1550 IF a3 = 0 THEN RETURN
  234. 1560 IF e1 <= 0 THEN 1750
  235. 1570 p4 = 100 * p2 * s3 + 0.5
  236. 1580 IF j5 <> 0 THEN 1610
  237. 1590 PRINT "KLINGONS ATTACK--SHIELD STRENGTH REDUCED TO ";
  238. 1600 GOTO 1650
  239. 1610 PRINT "ENERGY LEFT:"; FNS(e1); "  SHIELDS ";
  240. 1620 IF s4 <> 0 THEN PRINT "UP,";
  241. 1630 IF (s4 = 0) AND (d4(8) = 0) THEN PRINT "DOWN, ";
  242. 1640 IF d4(8) > 0 THEN PRINT "DAMAGED, ";
  243. 1650 PRINT INT(p4); "%"
  244. 1660 IF (h2 < 200) AND (h3 < 500) THEN 1800
  245. 1670 j8 = INT(h3 * RND(1) * 0.015)
  246. 1680 IF j8 < 2 THEN 1800
  247. 1690 PRINT
  248. 1700 PRINT "MCCOY - 'SICKBAY TO BRIDGE. WE SUFFERED ";
  249. 1710 PRINT j8; "CASUALTIES"
  250. 1720 PRINT "     IN THAT LAST ATTACK'"
  251. 1730 c4 = c4 + j8
  252. 1740 GOTO 1800
  253. 1750 f9 = 5
  254. 1760 GOSUB 10000
  255. 1770 RETURN
  256. 1780 PRINT "*** KLINGONS ATTACK-- STARBASE SHIELDS PROTECT ";
  257. 1790 PRINT "THE "; s5$
  258. 1800 FOR w4 = 1 TO k3
  259.    1810 k8(w4) = k7(w4)
  260. 1820 NEXT w4
  261. 1830 GOSUB 28000
  262. 1840 RETURN
  263. 2000 REM-AUTO VER
  264. 2001 PRINT
  265. 2010 IF j4 = 0 THEN 2050
  266. 2020 PRINT "*** RED ALERT! RED ALERT!"
  267. 2030 PRINT "***THE "; s5$; " HAS STOPPED IN A QUADRANT ";
  268. 2040 PRINT "CONTAINING A SUPERNOVA."
  269. 2050 PRINT "*** EMERGENCY AUTO -OVERRIDE ATTEMPTS TO HURL ";
  270. 2060 PRINT s5$
  271. 2070 PRINT "  SAFELY OUT OF THE QUADRANT."
  272. 2080 s2(q1, q2) = 1
  273. 2090 GOSUB 18000
  274. 2100 IF d4(6) = 0 THEN 2290
  275. 2110 PRINT
  276. 2120 PRINT "WARP ENGINES DAMAGED."
  277. 2130 PRINT
  278. 2140 PRINT "ATTEMPTING TO ENGAGE IMPULSE ENGINES..."
  279. 2150 IF d4(7) = 0 THEN 2190
  280. 2160 PRINT "IMPULSE ENGINES DAMAGED."
  281. 2165 f9 = 8
  282. 2170 GOSUB 10000
  283. 2180 RETURN
  284. 2190 p2 = 0.75 * e1
  285. 2200 d6 = 4.000000E-03 * (p2 - 50)
  286. 2210 d7 = 1.4142 + 1.2 * RND(1)
  287. 2220 d1 = d6
  288. 2230 IF d6 > d7 THEN d1 = d7
  289. 2240 t1 = d1 / 0.4
  290. 2250 d2 = 12 * RND(1)
  291. 2260 j4 = 0
  292. 2270 GOSUB 13200
  293. 2280 GOTO 2400
  294. 2290 w1 = 6 + 2 * RND(1)
  295. 2300 w2 = w1 * w1
  296. 2310 p2 = 0.75 * e1
  297. 2320 d6 = p2 / (w1 * w1 * w1 * (s4 + 1))
  298. 2330 d7 = 1.4142 + 2 * RND(1)
  299. 2340 d1 = d6
  300. 2350 IF d6 > d7 THEN d1 = d7
  301. 2360 t1 = 10 * d1 / w2
  302. 2370 d2 = 12 * RND(1)
  303. 2380 j4 = 0
  304. 2390 GOSUB 34500
  305. 2400 IF j4 <> 0 THEN 2440
  306. 2410 f9 = 8
  307. 2420 GOSUB 10000
  308. 2430 RETURN
  309. 2440 IF r1 <> 0 THEN RETURN
  310. 2450 f9 = 1
  311. 2460 GOSUB 10000
  312. 2470 RETURN
  313. 3000 REM-CHART
  314. 3001 PRINT: PRINT "       1   2   3   4   5   6   7   8"
  315. 3010 PRINT "      --- --- --- --- --- --- --- ---"
  316. 3020 FOR i = 1 TO 8
  317.    3030 PRINT i; "| ";
  318.    3040 FOR j = 1 TO 8
  319.        3060 ON SGN(s2(i, j)) + 2 GOTO 3070, 3090, 3110
  320.        3065 PRINT "ERR AT 3065": END
  321.        3070 PRINT " .1.";
  322.        3080 GOTO 3160
  323.        3090 PRINT " ...";
  324.        3100 GOTO 3160
  325.        3110 IF s2(i, j) > 1000 THEN 3150
  326.        3120 IF g(i, j) < 1000 THEN PRINT USING " ###"; g(i, j);
  327.        3130 IF g(i, j) = 1000 THEN PRINT " ***";
  328.        3140 GOTO 3160
  329.        3150 PRINT " ###";
  330.    3160 NEXT j
  331.    3170 PRINT
  332. 3180 NEXT i: GOSUB 18400
  333. 3185 PRINT
  334. 3190 PRINT "THE "; s5$; " IS CURRENTLY IN "; g2$; " ("; q1; "-"; q2; ")"
  335. 3200 RETURN
  336. 4000 REM-CHOOSE
  337. 4001 FOR i = 1 TO 10: PRINT: NEXT: FOR i = 1 TO 41: PRINT "*";: NEXT: PRINT
  338. 4002 PRINT "**"; TAB(39); "**"
  339. 4003 PRINT "** WELCOME TO THE WORLD OF STAR TREK **"
  340. 4008 PRINT "**"; TAB(39); "**": FOR i = 1 TO 41: PRINT "*";: NEXT: PRINT
  341. 4010 PRINT: PRINT
  342. 4070 s8 = 0: l2 = 0
  343. 4090 PRINT "HOW LONG A GAME WOULD YOU LIKE";
  344. 4095 INPUT a$
  345. 4100 FOR i = 1 TO 3
  346.    4110 IF a$ = LEFT$(t$(i), LEN(a$)) THEN 4150
  347. 4120 NEXT i
  348. 4130 PRINT "WOULD YOU LIKE A SHORT, MEDIUM OR LONG GAME";
  349. 4140 GOTO 4095
  350. 4150 l2 = i
  351. 4160 PRINT "ARE YOU A BEGINNER, NOVICE, SENIOR OR EXPERT PLAYER";
  352. 4170 INPUT a$
  353. 4180 FOR i = 1 TO 4
  354.    4190 IF a$ = LEFT$(s$(i), LEN(a$)) THEN 4220
  355. 4200 NEXT i
  356. 4210 GOTO 4160
  357. 4220 s8 = i
  358. 4230 INPUT "ENTER YOUR MISSION PASSWORD... "; x$
  359. 4244 PRINT
  360. 4245 PRINT "....SETTING UP THE GALAXY...."
  361. 4250 j = RND(1)
  362. 4260 REM-INITIALIZE
  363. 4270 d5 = 0.5 * s8
  364. 4280 i2 = INT(l2 + 1 + RND(1) * 3)
  365. 4290 IF i2 > 5 THEN i2 = 5
  366. 4300 r3 = i2
  367. 4310 i5 = 10 * l2
  368. 4320 r5 = i5
  369. 4340 r7 = (s8 - 2 * RND(1) + 1) * s8 * 0.1 + 0.1
  370. 4350 IF r7 < 0.2 THEN r7 = r7 + 0.1
  371. 4360 i1 = INT(2 * r7 * i5)
  372. 4370 r1 = i1
  373. 4380 i4 = INT(s8 + 0.0625 * i1 * RND(1))
  374. 4390 r2 = i4
  375. 4400 i3 = (i1 + 4 * i4) * i5
  376. 4410 r4 = i3
  377. 4420 RETURN
  378. 5000 REM-COMPUTE
  379. 5001 IF d4(11) = 0 THEN 5030
  380. 5010 PRINT "LIBRARY COMPUTER DISABLED"
  381. 5020 RETURN
  382. 5030 PRINT "----LIBRARY COMPUTER ACTIVE----"
  383. 5040 INPUT "PROGRAM NAME "; b$
  384. 5050 FOR i = 1 TO 6
  385.    5060 IF b$ = LEFT$(c2$(i), LEN(b$)) THEN 5120
  386. 5070 NEXT
  387. 5080 PRINT "VALID PROGRAMS ARE:"
  388. 5090 PRINT " COURSE  WCOST  ICOST"
  389. 5100 PRINT " PEFFECT  SCORE  END"
  390. 5110 GOTO 5040
  391. 5120 ON i GOTO 5200, 5300, 5400, 5500, 5600, 5700
  392. 5200 REM-COURSE&DIRECTION
  393. 5210 INPUT "ENTER QUADRANT AND SECTOR - "; a3, a4
  394. 5220 IF (a3 <> INT(a3)) OR (a4 <> INT(a4)) THEN 5990
  395. 5221 IF a3 < 0 THEN 5040
  396. 5222 IF a3 = 0 THEN a3 = 10 * q1 + q2
  397. 5223 a3 = a3 + 0.5
  398. 5225 k = INT(a3 / 10)
  399. 5226 IF (k < 1) OR (k > 8) THEN 5990
  400. 5227 c6(1) = k: k = INT(a3 - c6(1) * 10)
  401. 5228 IF (k < 1) OR (k > 8) THEN 5990
  402. 5229 c6(2) = k: a4 = a4 + 0.5
  403. 5230 k = INT(a4 / 100)
  404. 5231 IF (k < 1) OR (k > 10) THEN 5990
  405. 5232 c6(1) = c6(1) + (k - 1) / 10: k = INT(a4 - k * 100)
  406. 5233 IF (k < 1) OR (k > 10) THEN 5990
  407. 5234 c6(2) = c6(2) + (k - 1) / 10
  408. 5235 x = q1 + ((s6 - 1) / 10) - c6(1): y = q2 + ((s7 - 1) / 10) - c6(2)
  409. 5236 d1 = 0: d2 = 0: IF (x = 0) AND (y = 0) THEN 5250
  410. 5237 d1 = SQR(x * x + y * y)
  411. 5238 IF x < 0 THEN z7 = SGN(y) * (3.1416 - arctan(ABS(y / x)))
  412. 5239 IF x = 0 THEN z7 = SGN(y) * 1.5708
  413. 5240 IF x > 0 THEN z7 = arctan(y / x)
  414. 5245 d2 = 12 - z7 * 1.909859: IF d2 > 12 THEN d2 = d2 - 12
  415. 5250 PRINT "COURSE IS"; FNS(d2); " FOR A DISTANCE OF";
  416. 5260 PRINT FNS(d1); "QUADRANTS.": GOTO 5040
  417. 5300 REM-COST FOR WARP DRIVE
  418. 5302 INPUT "ENTER DISTANCE AND WARP FACTOR "; d1, a4
  419. 5304 IF (d1 < 0) THEN 5040
  420. 5310 c7 = d1 * a4 * a4 * a4
  421. 5315 t1 = (10 * d1) / (a4 * a4)
  422. 5320 PRINT "IT WOULD TAKE"; FNS(t1); "STARDATES AND USE"
  423. 5325 PRINT FNR(c7); "UNITS OF ENERGY ("; FNR(c7 + c7); " IF SHIELDS ARE UP)"
  424. 5330 GOTO 5040
  425. 5400 REM-COST FOR IMPULSE POWER
  426. 5410 INPUT "ENTER DISTANCE... "; d1
  427. 5420 IF d1 < 0 THEN 5040
  428. 5430 c7 = 250 * d1 + 50: t1 = d1 / 0.4
  429. 5440 PRINT "IT WOULD TAKE"; FNR(t1); "STARDATES AND USE"
  430. 5450 PRINT c7; "UNITS OF ENERGY"
  431. 5460 GOTO 5040
  432. 5500 REM-PHASER EFFECTIVENESS
  433. 5510 INPUT "ENTER PHASER RANGE IN QUADRANTS "; a3
  434. 5520 IF a3 < 0 THEN 5040
  435. 5530 a3 = a3 * 10: c7 = (0.9 ^ a3) * 100
  436. 5540 PRINT "PHASERS ARE "; LEFT$(STR$(c7), 5); "% EFFECTIVE AT THAT RANGE"
  437. 5550 GOTO 5040
  438. 5600 REM- SCORE
  439. 5610 GOSUB 23000
  440. 5620 GOTO 5040
  441. 5700 RETURN
  442. 5990 PRINT " FOR MAT IS MN,XXYY...WHERE MN IS THE QUADRANT"
  443. 5991 PRINT "AND XXYY IS THE SECTOR...E.G. 64,0307 REFERS"
  444. 5992 PRINT "TO QUADRANT 6-4, SECTOR 3-7."
  445. 5993 PRINT "NOTE: SECTOR COORDINATES MUST BE 4 DIGITS."
  446. 5995 GOTO 5040
  447. 6000 REM - DEADKL
  448. 6001 IF t2$ <> "C" THEN 6100
  449. 6010 c3 = 0: PRINT "***COMMANDER AT";
  450. 6020 FOR f = 1 TO r2
  451.    6030 IF (c1(f) = q1) AND (c2(f) = q2) THEN 6050
  452. 6040 NEXT f
  453. 6050 c1(f) = c1(r2): c2(f) = c2(r2): c1(r2) = 0: c2(r2) = 0
  454. 6060 r2 = r2 - 1: f1(2) = 1.000000E+30
  455. 6070 IF r2 <> 0 THEN f1(2) = d0 - (i4 / r2) * LOG(RND(1))
  456. 6080 k2 = k2 + 1
  457. 6090 GOTO 6120
  458. 6100 PRINT "***KLINGON AT";
  459. 6110 k1 = k1 + 1
  460. 6120 PRINT a5; "-"; a6; "DESTROYED."
  461. 6130 q$(a5, a6) = ".": r1 = r1 - 1
  462. 6140 IF r1 = 0 THEN RETURN
  463. 6150 r5 = r4 / (r1 + 4 * r2)
  464. 6160 g(q1, q2) = g(q1, q2) - 100
  465. 6170 FOR f = 1 TO k3
  466.    6180 IF (k4(f) = a5) AND (k5(f) = a6) THEN 6200
  467. 6190 NEXT f
  468. 6200 k3 = k3 - 1
  469. 6210 IF f > k3 THEN 6250
  470. 6220 FOR g = f TO k3
  471.    6230 k4(g) = k4(g + 1): k5(g) = k5(g + 1): k6(g) = k6(g + 1)
  472.    6235 k7(g) = k7(g + 1): k8(g) = k7(g)
  473. 6240 NEXT g
  474. 6250 k4(k3 + 1) = 0: k5(k3 + 1) = 0: k7(k3 + 1) = 0: k8(k3 + 1) = 0: k6(k3 + 1) = 0
  475. 6260 RETURN
  476. 7000 REM-DOCK
  477. 7001 IF c5$ = "DOCKED" THEN 7100
  478. 7010 IF b6 = 0 THEN 7020
  479. 7015 IF (ABS(s6 - b6) <= 1) AND (ABS(s7 - b7) <= 1) THEN 7040
  480. 7020 PRINT s5$; " NOT ADJACENT TO A BASE."
  481. 7030 RETURN
  482. 7040 c5$ = "DOCKED"
  483. 7050 PRINT "HELMSMAN SULU - 'DOCKING MANEUVER COMPLETED.'"
  484. 7060 e1 = i7: s3 = i8: t4 = i9: l1 = j1
  485. 7070 RETURN
  486. 7100 PRINT "MR. SULU - 'BUT CAPTAIN, WE'RE ALREAD Y DOCKED!'"
  487. 7110 RETURN
  488. 8000 REM-DREPORT
  489. 8001 j = 0
  490. 8003 PRINT
  491. 8005 FOR i = 1 TO 12
  492.    8010 IF d4(i) <= 0 THEN 8070
  493.    8020 IF j <> 0 THEN 8060
  494.    8030 PRINT "   DEVICE"; spc$(12); "-REPAIR TIMES-"
  495.    8040 PRINT spc$(21); "IN FLIGHT  DOCKED"
  496.    8050 j = 1
  497.    8060 PRINT " "; d$(i); TAB(23); FNS(d4(i)); TAB(33); FNS(d3 * d4(i))
  498. 8070 NEXT i
  499. 8080 IF j = 0 THEN PRINT "MR. SPOCK - 'ALL DEVICES FUNCTIONAL, CAPTAIN'"
  500. 8090 RETURN
  501. 9000 REM-EVENTS
  502. 9001 m = 0: d7 = d0 + t1
  503. 9010 FOR l = 1 TO 5
  504.    9020 IF f1(l) > d7 THEN 9040
  505.    9030 m = l: d7 = f1(l)
  506. 9040 NEXT l
  507. 9050 x6 = d7 - d0: d0 = d7
  508. 9060 r4 = r4 - (r1 + 4 * r2) * x6
  509. 9070 r5 = r4 / (r1 + 4 * r2)
  510. 9080 IF r5 > 0 THEN 9120
  511. 9090 f9 = 2
  512. 9100 GOSUB 10000
  513. 9110 RETURN
  514. 9120 IF (d4(5) = 0) OR (c5$ = "DOCKED") THEN 9180
  515. 9130 IF (l1 >= x6) OR (d4(5) <= l1) THEN 9160
  516. 9140 f9 = 3: GOSUB 10000
  517. 9150 RETURN
  518. 9160 l1 = l1 - x6
  519. 9170 IF d4(5) <= x6 THEN l1 = j1
  520. 9180 r = x6
  521. 9190 IF c5$ = "DOCKED" THEN r = x6 / d3
  522. 9200 FOR l = 1 TO 12
  523.    9210 IF d4(l) <= 0 THEN 9230
  524.    9220 d4(l) = d4(l) - r
  525.    9225 IF d4(l) < 0 THEN d4(l) = 0
  526.    9226 IF d4(l) <> 0 THEN 9230
  527.    9227 PRINT: PRINT "DAMAGE CONTROL- '"; d$(l); " NOW OPERATIONAL.'"
  528. 9230 NEXT l
  529. 9240 IF m = 0 THEN RETURN
  530. 9250 t1 = t1 - x6
  531. 9260 ON m GOTO 9270, 9290, 9340, 9350, 9470
  532. 9270 REM-SUPERNOVA
  533. 9280 x2 = 0: y2 = 0: GOSUB 27000
  534. 9285 f1(1) = d0 - 0.5 * i5 * LOG(RND(1))
  535. 9286 IF g(q1, q2) = 1000 THEN RETURN
  536. 9287 GOTO 9001
  537. 9290 REM-TRACTOR BEAM
  538. 9291 IF r2 = 0 THEN 9330
  539. 9292 IF c5$ = "DOCKED" THEN 9325
  540. 9293 i = INT(RND(1) * r2) + 1
  541. 9294 y6 = (c1(i) - q1) ^ 2 + (c2(i) - q2) ^ 2
  542. 9295 IF y6 = 0 THEN 9325
  543. 9296 y6 = SQR(y6): t1 = 0.17778 * y6
  544. 9297 PRINT: PRINT "***"; s5$; " CAUGHT IN LONG-RANGE TRACTOR BEAM--"
  545. 9298 q1 = c1(i): q2 = c2(i)
  546. 9299 s6 = FNB(1): s7 = FNB(1)
  547. 9300 PRINT "  PULLED TO QUADRANT"; q1; "-"; q2; ", SECTOR"; s6; "-"; s7
  548. 9301 IF r6 <> 0 THEN PRINT "(REMAINDER OF IDLE PERIOD CANCELLED)"
  549. 9302 r6 = 0
  550. 9303 IF s4 <> 0 THEN 9320
  551. 9304 IF (d4(8) = 0) AND (s3 > 0) THEN 9310
  552. 9305 PRINT "(SHIELDS NOT CURRENTLY USABLE.)"
  553. 9307 GOTO 9320
  554. 9310 GOSUB 26500
  555. 9315 s9 = 0
  556. 9320 GOSUB 18000
  557. 9325 f1(2) = d0 + t1 - 1.5 * (i5 / r2) * LOG(RND(1))
  558. 9326 GOTO 9001
  559. 9330 f1(2) = 1.000000E+30: GOTO 9001
  560. 9340 d9(1) = d0: d9(2) = r1: d9(3) = r2: d9(4) = r3: d9(5) = r4: d9(6) = r5
  561. 9342 d9(7) = s1: d9(8) = b1: d9(9) = k1: d9(10) = k2
  562. 9343 FOR i = 1 TO 8: FOR j = 1 TO 8: d9(i - 1 + 8 * (j - 1) + 11) = g(i, j): NEXT j: NEXT i
  563. 9344 FOR i = 75 TO 84: d9(i) = c1(i - 74): NEXT
  564. 9345 FOR i = 85 TO 94: d9(i) = c2(i - 84): NEXT
  565. 9346 FOR i = 95 TO 99: d9(i) = b2(i - 94): NEXT
  566. 9347 FOR i = 100 TO 104: d9(i) = b3(i - 99): NEXT
  567. 9348 d9(105) = b4: d9(106) = b5
  568. 9349 s0 = 1: f1(3) = d0 - 0.3 * i5 * LOG(RND(1)): GOTO 9001
  569. 9350 REM - STARBASE ATTACK
  570. 9355 IF (r2 = 0) OR (r3 = 0) THEN 9400
  571. 9360 FOR i = 1 TO r3: FOR j = 1 TO r2: IF (b2(i) = c1(j)) AND (b3(i) = c2(j)) THEN 9410
  572. 9370 NEXT j: NEXT i
  573. 9380 f1(4) = d0 + 0.5 + 3 * RND(1)
  574. 9390 f1(5) = 1.000000E+30: GOTO 9001
  575. 9400 f1(4) = 1.000000E+30: f1(5) = 1.000000E+30: GOTO 9001
  576. 9410 b4 = b2(i): b5 = b3(i)
  577. 9420 IF (b4 = q1) AND (b5 = q2) THEN 9380
  578. 9430 f1(5) = d0 + 0.5 + 3 * RND(1)
  579. 9440 f1(4) = f1(5) - 0.3 * i5 * LOG(RND(1))
  580. 9450 IF d4(9) > 0 THEN 9001
  581. 9455 PRINT
  582. 9460 PRINT "LT. UHURA- 'CAPTAIN, THE STARBASE IN"; b4; "-"; b5
  583. 9461 PRINT " REPORTS THAT IT IS UNDER ATTACK AND CAN HOLD OUT"
  584. 9462 PRINT " ONLY UNTIL STARDATE"; FNR(f1(5)); "'"
  585. 9465 IF r6 = 0 THEN 9001
  586. 9466 PRINT
  587. 9467 INPUT "MR. SPOCK- 'CAPTAIN, SHALL WE CANCEL THE IDLE PERIOD"; b$
  588. 9468 IF LEFT$(b$, 1) = "Y" THEN r6 = 0
  589. 9469 GOTO 9001
  590. 9470 REM - STARBASE DESTROYED
  591. 9475 f1(5) = 1.000000E+30: IF (r2 = 0) OR (r3 = 0) THEN 9001
  592. 9485 k = INT(g(b4, b5) / 100): IF g(b4, b5) - k * 100 < 10 THEN 9001
  593. 9490 FOR i = 1 TO r2: IF (c1(i) = b4) AND (c2(i) = b5) THEN 9520
  594. 9510 NEXT: GOTO 9001
  595. 9520 IF s2(b4, b5) = -1 THEN s2(b4, b5) = 0
  596. 9530 IF s2(b4, b5) > 999 THEN s2(b4, b5) = s2(b4, b5) - 10
  597. 9540 IF (b4 <> q1) OR (b5 <> q2) THEN 9630
  598. 9550 FOR i = 1 TO k3: k = k4(i): l = k5(i)
  599.    9560 IF q$(k, l) = "C" THEN 9570
  600. 9565 NEXT
  601. 9570 IF k6(i) < 25 + 50 * RND(1) THEN 9001
  602. 9580 q$(b6, b7) = ".": b6 = 0: b7 = 0
  603. 9590 GOSUB 17000
  604. 9600 PRINT: PRINT "MR. SPOCK- 'CAPTAIN, I BELIEVE THE STARBASE HAS";
  605. 9610 PRINT " BEEN DESTROYED.'"
  606. 9620 GOTO 9680
  607. 9630 IF (r3 = 1) OR (d4(9) > 0) THEN 9680
  608. 9640 PRINT
  609. 9650 PRINT "LT. UHURA- 'CAPTAIN, STARFLEET COMMAND REPORTS THAT"
  610. 9660 PRINT " THE STARBASE IN QUADRANT"; b4; "-"; b5; "HAS BEEN"
  611. 9670 PRINT " DESTROYED BY A KLINGON COMMANDER.'"
  612. 9680 g(b4, b5) = g(b4, b5) - 10
  613. 9690 IF r3 <= 1 THEN 9730
  614. 9700 FOR i = 1 TO r3: IF (b2(i) = b4) AND (b3(i) = b5) THEN 9720
  615. 9710 NEXT
  616. 9720 b2(i) = b2(r3): b3(i) = b3(r3)
  617. 9730 r3 = r3 - 1
  618. 9740 GOTO 9001
  619. 10000 REM-FINISH
  620. 10001 a2 = 1: PRINT: PRINT "IT IS STARDATE"; FNR(d0): PRINT
  621. 10010 ON f9 GOTO 10020, 10130, 10160, 10185, 10195, 10205, 10220, 10235
  622. 10015 ON f9 - 8 GOTO 10245, 10270, 10280
  623. 10020 REM-THE GAME HAS BEEN WON
  624. 10025 PRINT "YOU HAVE DESTROYED THE KLINGON INVASION FLEET"
  625. 10027 PRINT
  626. 10030 PRINT "   ***THE FEDERATION IS SAVED***": g1 = 1
  627. 10035 IF (a1 = 0) OR (b1 <> 0) THEN 10110
  628. 10040 IF LEFT$(s5$, 1) <> "E" THEN 10110
  629. 10045 IF 3 * s1 + 35 * n1 + c4 >= 100 THEN 10110
  630. 10050 IF d0 - j2 <= 6 THEN 10070
  631. 10060 r8 = 0.1 * s8 * (s8 + 1) + 0.1
  632. 10065 IF (k1 + k2) / (d0 - j2) < r8 THEN 10110
  633. 10070 PRINT
  634. 10075 PRINT "IN FACT, YOU HAVE DONE SO WELL THAT STARFLEET COMMAND"
  635. 10076 IF s8 = 4 THEN 10090
  636. 10080 PRINT "PROMOTES YOU ONE STEP  IN RANK, ";
  637. 10085 IF s8 = 1 THEN PRINT "FROM BEGINNER TO NOVICE CLASS!"
  638. 10086 IF s8 = 2 THEN PRINT "FROM NOVICE TO SENIOR CLASS!"
  639. 10087 IF s8 = 3 THEN PRINT "FROM SENIOR TO EXPERT CLASS!"
  640. 10088 PRINT "  ***CONGRATULATIONS***": GOTO 10110
  641. 10090 PRINT "PROMOTES YOU TO 'COMMODORE EMERITUS'."
  642. 10095 PRINT
  643. 10100 PRINT "NOW YOU CAN RETIRE AND WRITE YOUR OWN STAR TREK GAME!"
  644. 10110 GOSUB 23000
  645. 10120 RETURN
  646. 10130 REM-FED RESOURCES DEPLETED
  647. 10135 PRINT "YOUR TIME HAS RUN OUT, AND THE"
  648. 10136 PRINT "FEDERATION HAS BEEN CONQUERED.": PRINT
  649. 10137 PRINT "YOUR STARSHIP IS NOW KLINGON PROPERY, AND YOU ARE PUT"
  650. 10138 PRINT "ON TRIAL AS A WAR CRIMINAL. ON THE BASIS OF YOUR RECORD,"
  651. 10139 IF r1 * 3 > i1 THEN 10150
  652. 10140 PRINT "YOU ARE FOUND GUILTY AND SENTENCED TO DEATH!"
  653. 10145 a1 = 0: GOSUB 23000: RETURN
  654. 10150 PRINT "YOU ARE ACQUITTED": GOSUB 23000: RETURN
  655. 10160 REM- L.S. FAILURE
  656. 10165 PRINT "YOUR LIFE SUPPORT RESERVES HAVE RUN OUT, AND"
  657. 10170 PRINT "YOU WILL SOON DIE OF ASPHYXIATION"
  658. 10172 PRINT
  659. 10175 PRINT "YOUR STARSHIP IS A DERELICT IN SPACE."
  660. 10180 GOTO 10300
  661. 10185 REM-ENERGY GONE
  662. 10190 PRINT "YOUR ENERGY SUPPLY IS EXHAUSTED.": GOTO 10172
  663. 10195 REM-BATTLE DEFEAT
  664. 10200 PRINT "THE "; s5$; " HAS BEEN DESTROYED IN BATTLE."
  665. 10201 GOTO 10300
  666. 10205 PRINT "F9=6 INVALID": RETURN
  667. 10220 REM-NOVA
  668. 10225 PRINT "YOUR STARSHIP HAS BEEN DESTROYED BY A NOVA."
  669. 10230 PRINT "NICE SHOT, YOU HOCKEY PUCK!": GOTO 10300
  670. 10235 REM-SUPERNOVA
  671. 10240 PRINT "THE "; s5$; " HAS BEEN INCINERATED BY A SUPERNOVA."
  672. 10241 GOTO 10300
  673. 10245 REM-ABANDON(NO BASES)
  674. 10250 PRINT "YOU HAVE BEEN CAPTURED BY THE KLINGONS.  IF YOU STILL"
  675. 10255 PRINT "HAD A STARBASE TO BE RETURNED TO , YOU WOULD HAVE BEEN"
  676. 10260 PRINT "REPATRIATED AND GIVEN ANOTHER CHANCE. SINCE YOU HAVE"
  677. 10265 PRINT "NO STARBASES, YOU WILL BE MERCILESSLY TORTURED TO DEATH!"
  678. 10266 GOTO 10300
  679. 10270 REM - SELF-DESTRUCT
  680. 10271 PRINT: PRINT "THE "; s5$; " IS NOW AN EXPANDING CLOUD"
  681. 10272 PRINT "OF SUB-ATOMIC PARTICLES...": GOTO 10300
  682. 10280 REM-NOT REMATERIALIZED
  683. 10285 PRINT "STARBASE WAS UNABLE TO RE-MATERIALIZE YOUR STARSHIP."
  684. 10300 PRINT
  685. 10310 IF LEFT$(s5$, 1) = "F" THEN s5$ = ""
  686. 10315 IF LEFT$(s5$, 1) = "E" THEN s5$ = "FAERIE QUEENE"
  687. 10316 a1 = 0
  688. 10320 IF r1 = 0 THEN 10355
  689. 10325 g3 = r4 / i3: b8 = (r1 + 2 * r2) / (i1 + 2 * i4)
  690. 10326 a3 = g3 / b8
  691. 10327 IF a3 < 1 + 0.5 + RND(1) THEN 10345
  692. 10330 PRINT "AS A RESULT OF YOUR ACTIONS, A TREATY WITH THE KLINGON"
  693. 10331 PRINT "EMPIRE HAS BEEN SIGNED. THE TERMS OF THE TREATY ARE"
  694. 10332 IF a3 < 3 * RND(1) THEN 10340
  695. 10335 PRINT "FAVORABLE TO THE FEDERATION.": PRINT
  696. 10336 PRINT "CONGRATULATIONS.": GOTO 10350
  697. 10340 PRINT "HIGHLY UNFAVORABLE TO THE FEDERATION.": GOTO 10350
  698. 10345 PRINT "THE FEDERATION WILL BE DESTROYED!"
  699. 10350 GOSUB 23000: RETURN
  700. 10355 PRINT "SINCE YOU TOOK THE LAST KLINGON WITH YOU, YOU ARE"
  701. 10360 PRINT "A MARTYR AND A HERO. SOMEDAY MAYBE THEY'LL ERECT"
  702. 10370 PRINT "A STATUE IN YOUR MEMORY. REST IN PEACE AND TRY NOT"
  703. 10380 PRINT "TO THINK ABOUT PIGEONS!": g1 = 1: a1 = 0
  704. 10390 GOSUB 23000: RETURN
  705. 11000 REM - HELP
  706. 11001 IF c5$ <> "DOCKED" THEN 11020
  707. 11010 PRINT "ENSIGN CHEKOV- 'BUT CAPTAIN, WE'RE ALREADY DOCKED!'"
  708. 11015 RETURN
  709. 11020 IF d4(9) = 0 THEN 11030
  710. 11025 PRINT "SUBSPACE RADIO DAMAGED...CANNOT TRANSMIT.": RETURN
  711. 11030 IF r3 <> 0 THEN 11050
  712. 11040 PRINT "LT. UHURA- 'CAPTAIN, I'M NOT GETTING ANY RESPONSE";
  713. 11045 PRINT " FROM STARBASE!'": RETURN
  714. 11050 n1 = n1 + 1: IF b6 = 0 THEN 11070
  715. 11060 GOTO 11130
  716. 11070 d1 = 1.000000E+30
  717. 11080 FOR l = 1 TO r3: x = 10 * SQR((b2(l) - q1) ^ 2 + (b3(l) - q2) ^ 2)
  718.    11090 IF x > d1 THEN 11110
  719.    11100 d1 = x: k = l
  720. 11110 NEXT l
  721. 11120 q1 = b2(k): q2 = b3(k): GOSUB 18000
  722. 11130 q$(s6, s7) = "."
  723. 11135 PRINT
  724. 11140 PRINT "STARBASE IN QUADRANT"; q1; "-"; q2; "RESPONDS --";
  725. 11145 PRINT " "; s5$; " DEMATERIALIZES."
  726. 11146 p2 = (1 - 0.98 ^ d1) ^ 0.333333
  727. 11150 FOR l = 1 TO 3
  728.    11155 IF l = 1 THEN PRINT "1ST ";
  729.    11160 IF l = 2 THEN PRINT "2ND ";
  730.    11170 IF l = 3 THEN PRINT "3RD ";
  731.    11180 PRINT "ATTEMPT TO RE-MATERIALIZE THE "; s5$; ". . . . .";
  732.    11190 IF RND(1) > p2 THEN 11220
  733. 11200 PRINT "FAILS.": NEXT l
  734. 11210 f9 = 11: GOSUB 10000: RETURN
  735. 11220 FOR l = 1 TO 5: i = b6 + INT(3 * RND(1)) - 1
  736.    11230 IF (i < 1) OR (i > 10) THEN 11260
  737.    11235 j = b7 + INT(3 * RND(1)) - 1
  738.    11240 IF (j < 1) OR (j > 10) THEN 11260
  739.    11250 IF q$(i, j) = "." THEN 11270
  740. 11260 NEXT l: PRINT "FAILS.": GOTO 11210
  741. 11270 PRINT "SUCCEEDS.": s6 = i: s7 = j: q$(i, j) = LEFT$(s5$, 1)
  742. 11280 GOSUB 7000: PRINT "LT. UHURA- 'CAPTAIN, WE MADE IT!'": RETURN
  743. 12000 REM-HIT'EM
  744. 12001 p4 = 2: l5 = k3: n = 1
  745. 12010 FOR k = 1 TO l5
  746.    12020 IF h3(k) = 0 THEN 12240
  747.    12030 d6 = 0.9 + 0.01 * RND(1): h2 = h3(k) * d6 ^ k7(n)
  748.    12040 p3 = k6(n)
  749.    12050 p = ABS(p3): IF p4 * h2 < p THEN p = p4 * h2
  750.    12060 k6(n) = p3 - SGN(p3) * ABS(p)
  751.    12070 x8 = k4(n): y8 = k5(n)
  752.    12080 IF h2 > 4.99 THEN 12100
  753.    12090 PRINT "VERY SMALL HIT ON ": GOTO 12110
  754.    12100 PRINT FNR(h2); "UNIT HIT ON ";
  755.    12110 m$ = q$(x8, y8)
  756.    12120 IF m$ = "K" THEN PRINT "KLINGON AT";
  757.    12125 IF m$ = "C" THEN PRINT "COMMANDER AT";
  758.    12130 PRINT x8; "-"; y8
  759.    12140 IF k6(n) <> 0 THEN 12180
  760.    12150 a5 = x8: a6 = y8: t2$ = q$(x8, y8): GOSUB 6000
  761.    12160 IF r1 <> 0 THEN 12250
  762.    12170 f9 = 1: GOSUB 10000: GOTO 12250
  763.    12180 IF k6(n) < 0 THEN 12240
  764.    12190 IF RND(1) < 0.9 THEN 12240
  765.    12200 IF k6(n) > (0.4 + 0.4 * RND(1)) * p3 THEN 12240
  766.    12205 PRINT
  767.    12210 PRINT "***MR. SPOCK - 'CAPTAIN, THE VESSEL AT SECTOR";
  768.    12215 PRINT x8; "-"; y8
  769.    12220 PRINT "  HAS JUST LOST ITS FIREPOWER.'"
  770.    12225 PRINT
  771.    12230 k6(n) = -k6(n)
  772.    12240 n = n + 1
  773. 12250 NEXT k
  774. 12260 RETURN
  775. 13000 REM - IMPULSE
  776. 13001 j3 = 0
  777. 13010 IF d4(7) <> 0 THEN 13250
  778. 13020 IF e1 <= 75 THEN 13070
  779. 13030 INPUT "ENTER COURSE AND DISTANCE "; d2, d1
  780. 13040 IF d2 < 0 THEN RETURN
  781. 13050 p3 = 50 + 250 * d1
  782. 13060 IF p3 < e1 THEN 13140
  783. 13070 PRINT
  784. 13080 PRINT "1ST OFFICER SPOCK- 'CAPTAIN, THE IMPULSE ENGINES"
  785. 13090 PRINT "REQUIRE 50 UNITS OF ENERGY TO ENGAGE, PLUS 250 UNITS"
  786. 13091 PRINT "PER ";
  787. 13100 IF e1 > 75 THEN 13120
  788. 13110 PRINT "QUADRANT. THEY ARE, THEREFORE, USELESS NOW.'": RETURN
  789. 13120 PRINT "QUADRANT. WE CAN GO, THEREFORE, A MAXIMUM OF ";
  790. 13130 PRINT FNR(4.000000E-03 * (e1 - 50) - 0.05); "QUADRANTS.'": RETURN
  791. 13140 t1 = d1 / 0.4
  792. 13150 IF t1 < r5 THEN 13200
  793. 13160 PRINT "1ST OFFICER SPOCK- 'CAPTAIN, OUR SPEED UNDER IMPULSE"
  794. 13170 PRINT "POWER IS ONLY 4 SECTORS PER STARDATE. ARE YOU SURE"
  795. 13180 INPUT "WE DARE SPEND THE TIME' "; b$
  796. 13190 IF LEFT$(b$, 1) <> "Y" THEN RETURN
  797. 13200 GOSUB 15000: j3 = 1
  798. 13210 IF a2 <> 0 THEN RETURN
  799. 13220 e1 = e1 - p3
  800. 13230 IF e1 > 0 THEN RETURN
  801. 13240 f9 = 4: GOSUB 10000: RETURN
  802. 13250 PRINT "IMPULSE ENGINES DAMAGED.": RETURN
  803. 14000 REM - LRSCAN
  804. 14001 n$ = " ###"
  805. 14005 PRINT
  806. 14010 IF d4(2) <> 0 THEN 14180
  807. 14020 PRINT "L.R. SCAN FOR QUADRANT"; q1; "-"; q2: PRINT
  808. 14030 i = q1 - 1: j = q1 + 1: k = q2 - 1: l = q2 + 1
  809. 14040 FOR m = i TO j: FOR n = k TO l
  810.        14050 IF (m <= 0) OR (m > 8) THEN 14110
  811.        14060 IF (n <= 0) OR (n > 8) THEN 14110
  812.        14070 IF d4(11) = 0 THEN s2(m, n) = 1
  813.        14080 IF g(m, n) >= 1000 THEN PRINT " ***";
  814.        14090 IF g(m, n) < 1000 THEN PRINT USING " ###"; g(m, n);
  815.        14100 GOTO 14120
  816.        14110 PRINT n$;
  817.    14120 NEXT n
  818.    14130 PRINT
  819. 14140 NEXT m
  820. 14150 IF d4(11) = 0 THEN RETURN
  821. 14155 PRINT
  822. 14160 PRINT "***WARNING*** - COMPUTER DISABLED - SCAN NOT RECORDED."
  823. 14170 RETURN
  824. 14180 PRINT "LONG RANGE SENSORS DAMAGED.": RETURN
  825. 15000 REM - MOVE
  826. 15001 a5 = (15 - d2) * 0.523599
  827. 15010 d4 = -SIN(a5): d6 = COS(a5)
  828. 15020 b8 = ABS(d4)
  829. 15030 IF ABS(d6) > b8 THEN b8 = ABS(d6)
  830. 15040 d4 = d4 / b8: d6 = d6 / b8: t5 = 0: t6 = 0
  831. 15050 IF d0 + t1 < f1(2) THEN 15080
  832. 15060 t5 = 1: c5$ = "RED": d1 = d1 * (f1(2) - d0) / t1 + 0.1
  833. 15070 t1 = f1(2) - d0 + 1.000000E-05
  834. 15080 q$(s6, s7) = ".": x7 = s6: y7 = s7: h9 = INT(10 * d1 * b8 + 0.5)
  835. 15090 IF h9 = 0 THEN 15115
  836. 15100 FOR l = 1 TO h9
  837.    15102 x7 = x7 + d4: x1 = INT(x7 + 0.5): y7 = y7 + d6: y1 = INT(y7 + 0.5)
  838.    15105 IF (x1 < 1) OR (x1 > 10) THEN 15150
  839.    15106 IF (y1 < 1) OR (y1 > 10) THEN 15150
  840.    15108 IF q$(x1, y1) = "O" THEN 15111
  841.    15109 IF q$(x1, y1) <> "." THEN 15125
  842. 15110 NEXT l
  843. 15111 d1 = 0.1 * SQR((s6 - x1) ^ 2 + (s7 - y1) ^ 2)
  844. 15112 s6 = x1: s7 = y1
  845. 15115 f4 = s6: f5 = s7
  846. 15116 IF q$(x1, y1) <> "O" THEN 15320
  847. 15120 t2 = FNA(1): t3 = FNA(1)
  848. 15122 q1 = FNA(1): q2 = FNA(1): s6 = FNB(1): s7 = FNB(1): PRINT
  849. 15123 PRINT "*** SPACE PORTAL ENTERED ***": GOTO 15307
  850. 15125 t6 = 1: k = 50 * d1 / t1: d1 = 0.1 * SQR((s6 - x1) ^ 2 + (s7 - y1) ^ 2)
  851. 15127 IF (q$(x1, y1) = "K") OR (q$(x1, y1) = "C") THEN 15145
  852. 15129 PRINT: PRINT s5$; " BLOCKED BY ";
  853. 15130 IF q$(x1, y1) = "*" THEN PRINT "STAR AT";
  854. 15131 IF q$(x1, y1) = "B" THEN PRINT "STARBASE AT";
  855. 15132 PRINT " SECTOR"; x1; "-"; y1; "...."
  856. 15133 PRINT "EMERGENCY STOP REQUIRED"; FNR(k); "UNITS OF ENERGY."
  857. 15135 e1 = e1 - k
  858. 15137 s6 = INT(x7 - d4 + 0.5): f4 = s6: s7 = INT(y7 - d6 + 0.5): f5 = s7
  859. 15140 IF e1 > 0 THEN 15320
  860. 15141 f9 = 4: GOSUB 10000: RETURN
  861. 15145 s6 = x1: s7 = y1: GOSUB 22000: f4 = s6: f5 = s7: GOTO 15320
  862. 15150 IF k3 = 0 THEN 15165
  863. 15155 FOR l = 1 TO k3
  864.    15156 f3 = SQR((x1 - k4(l)) ^ 2 + (y1 - k5(l)) ^ 2)
  865. 15158 k8(l) = 0.5 * (f3 + k7(l)): NEXT l
  866. 15160 IF g(q1, q2) <> 1000 THEN GOSUB 1000
  867. 15162 IF a2 <> 0 THEN RETURN
  868. 15165 x7 = 10 * (q1 - 1) + s6: y7 = 10 * (q2 - 1) + s7
  869. 15170 x1 = INT(x7 + 10 * d1 * b8 * d4 + 0.5)
  870. 15175 y1 = INT(y7 + 10 * d1 * b8 * d6 + 0.5): l6 = 0
  871. 15180 l5 = 0
  872. 15185 IF x1 > 0 THEN 15195
  873. 15190 x1 = -x1 + 1: l5 = 1
  874. 15195 IF y1 > 0 THEN 15210
  875. 15200 y1 = -y1 + 1: l5 = 1
  876. 15210 IF x1 <= 80 THEN 15220
  877. 15215 x1 = 161 - x1: l5 = 1
  878. 15220 IF y1 <= 80 THEN 15230
  879. 15225 y1 = 161 - y1: l5 = 1
  880. 15230 IF l5 = 0 THEN 15240
  881. 15235 l6 = 1: GOTO 15180
  882. 15240 IF l6 = 0 THEN 15270
  883. 15260 PRINT: PRINT "*** MESSAGE FROM STARFLEET COMMAND.....STARDATE";
  884. 15261 PRINT FNR(d0): PRINT: PRINT "'PERMISSION TO CROSS GALACTIC ";
  885. 15262 PRINT "PERIMETER IS HEREBY DENIED.'"
  886. 15263 PRINT "    'SHUT DOWN ENGINES IMMMEDIATELY!'"
  887. 15264 PRINT
  888. 15265 PRINT "SCOTT HERE - 'ENGINES SHUT DOWN AT ";
  889. 15266 z1 = INT((x1 + 9) / 10): z2 = INT((y1 + 9) / 10)
  890. 15267 PRINT "QUADRANT"; z1; "-"; z2; ", ";
  891. 15268 PRINT "SECTOR"; x1 - 10 * (z1 - 1); "-"; y1 - 10 * (z2 - 1); "'"
  892. 15270 IF t5 <> 0 THEN RETURN
  893. 15295 q1 = INT((x1 + 9) / 10): q2 = INT((y1 + 9) / 10)
  894. 15296 s6 = x1 - 10 * (q1 - 1): s7 = y1 - 10 * (q2 - 1)
  895. 15307 GOSUB 18400
  896. 15310 PRINT: PRINT "ENTERING THE "; g2$; " QUADRANT ("; q1; "-"; q2; ")"
  897. 15315 q$(s6, s7) = LEFT$(s5$, 1): GOSUB 18000: RETURN
  898. 15320 q$(s6, s7) = LEFT$(s5$, 1)
  899. 15321 IF l6 = 1 THEN RETURN
  900. 15325 IF k3 = 0 THEN 15390
  901. 15330 FOR l = 1 TO k3
  902.    15340 f3 = SQR((f4 - k4(l)) ^ 2 + (f5 - k5(l)) ^ 2)
  903.    15350 k8(l) = 0.5 * (k7(l) + f3)
  904.    15360 k7(l) = f3
  905. 15370 NEXT l
  906. 15380 GOSUB 28000
  907. 15390 GOSUB 17000: RETURN
  908. 16000 REM-MOVECOM
  909. 16001 a = 1: b = 1
  910. 16010 FOR k = 1 TO k3
  911.    16020 c = k4(k): d = k5(k)
  912.    16030 IF q$(c, d) = "C" THEN 16050
  913. 16040 NEXT k
  914. 16050 n = 0: f = k6(k) + 100 * k3
  915. 16060 IF f > 1000 THEN n = INT(RND(1) * k7(k) + 1)
  916. 16065 IF ((c5$ = "DOCKED") AND ((b4 <> q1) OR (b5 <> q2))) THEN n = -s8
  917. 16070 IF n = 0 THEN n = INT(((f + 200 * RND(1)) / 150) - 5)
  918. 16071 IF n = 0 THEN RETURN
  919. 16072 IF (n > 0) AND (k7(k) < 1.5) THEN RETURN
  920. 16075 IF ABS(n) > s8 THEN n = SGN(n) * ABS(s8)
  921. 16080 t = ABS(n): p = s6 - c: q = s7 - d
  922. 16085 IF 2 * ABS(p) < ABS(q) THEN p = 0
  923. 16090 IF 2 * ABS(q) < ABS(p) THEN q = 0
  924. 16095 IF p <> 0 THEN p = SGN(p * n)
  925. 16100 IF q <> 0 THEN q = SGN(q * n)
  926. 16105 r = c: s = d: q$(c, d) = "."
  927. 16110 FOR l2 = 1 TO t: l = r + p: m = s + q
  928.    16115 IF (l > 0) AND (l <= 10) THEN 16120
  929.    16117 ON SGN(n) + 2 GOTO 16240, 16165, 16165
  930.    16120 IF (m > 0) AND (m <= 10) THEN 16130
  931.    16125 ON SGN(n) + 2 GOTO 16240, 16135, 16135
  932.    16130 IF q$(l, m) = "." THEN 16195
  933.    16135 IF (q = b) OR (p = 0) THEN 16165
  934.    16140 m = s + b
  935.    16145 IF (m > 0) AND (m <= 10) THEN 16155
  936.    16150 ON SGN(n) + 2 GOTO 16240, 16160, 16160
  937.    16155 IF q$(l, m) = "." THEN 16195
  938.    16160 b = -b
  939.    16165 IF (p = a) OR (q = 0) THEN 16200
  940.    16170 l = r + a
  941.    16175 IF (l > 0) AND (l <= 10) THEN 16185
  942.    16180 ON SGN(n) + 2 GOTO 16240, 16190, 16190
  943.    16185 IF q$(l, m) = "." THEN 16195
  944.    16190 a = -a: GOTO 16200
  945.    16195 r = l: s = m
  946. 16200 NEXT l2
  947. 16205 q$(r, s) = "C"
  948. 16210 IF (r = c) AND (s = d) THEN RETURN
  949. 16215 k4(k) = r: k5(k) = s: k7(k) = SQR((s6 - r) ^ 2 + (s7 - s) ^ 2)
  950. 16220 k8(k) = k7(k): IF n > 0 THEN PRINT "***COMMANDER ADVANCES TO ";
  951. 16225 IF n < 0 THEN PRINT "***COMMANDER RETREATS TO ";
  952. 16230 PRINT " SECTOR"; r; "-"; s: GOSUB 28000: RETURN
  953. 16240 i = q1 + INT((l + 9) / 10) - 1: j = q2 + INT((m + 9) / 10) - 1
  954. 16245 IF (i < 1) OR (i > 8) THEN 16350
  955. 16250 IF (j < 1) OR (j > 8) THEN 16350
  956. 16260 FOR l3 = 1 TO r2
  957.    16265 IF (c1(l3) = i) AND (c2(l3) = j) THEN 16350
  958. 16270 NEXT l3: PRINT "***COMMANDER ESCAPES TO ";
  959. 16275 PRINT "QUADRANT"; i; "-"; j; " (AND REGAINS STRENGTH)"
  960. 16280 k4(k) = k4(k3): k5(k) = k5(k3): k7(k) = k7(k3): k8(k) = k8(k3)
  961. 16285 k6(k) = k6(k3): k3 = k3 - 1: c3 = 0
  962. 16290 IF c5$ <> "DOCKED" THEN GOSUB 17000
  963. 16300 GOSUB 28000
  964. 16310 g(q1, q2) = g(q1, q2) - 100: g(i, j) = g(i, j) + 100
  965. 16320 FOR l3 = 1 TO r2
  966.    16330 IF (c1(l3) = q1) AND (c2(l3) = q2) THEN 16340
  967. 16335 NEXT l3
  968. 16340 c1(l3) = i: c2(l3) = j: RETURN
  969. 16350 a = -a: b = -b: GOTO 16200
  970. 17000 REM - NEWCOND
  971. 17001 c5$ = "GREEN"
  972. 17010 IF e1 < 1000 THEN c5$ = "YELLOW"
  973. 17020 IF g(q1, q2) > 99 THEN c5$ = "RED"
  974. 17030 RETURN
  975. 18000 REM- NEW QUAD
  976. 18001 j4 = 1: b6 = 0: b7 = 0: k3 = 0: c3 = 0
  977. 18010 u = g(q1, q2)
  978. 18020 IF u > 999 THEN 18290
  979. 18030 k3 = INT(0.01 * u): FOR a = 1 TO 10: FOR b = 1 TO 10: q$(a, b) = ".": NEXT b: NEXT a
  980. 18040 q$(s6, s7) = LEFT$(s5$, 1): u = g(q1, q2): IF u < 100 THEN 18150
  981. 18050 u = u - 100 * k3: FOR a = 1 TO k3
  982.    18060 s = FNB(1): k4(a) = s: t = FNB(1): k5(a) = t
  983.    18070 IF q$(s, t) <> "." THEN 18060
  984.    18080 q$(s, t) = "K": k7(a) = SQR((s6 - s) ^ 2 + (s7 - t) ^ 2): k8(a) = k7(a)
  985. 18090 k6(a) = RND(1) * 150: NEXT a
  986. 18100 IF r2 = 0 THEN 18140
  987. 18110 FOR a = 1 TO r2
  988.    18115 IF (c1(a) = q1) AND (c2(a) = q2) THEN 18130
  989. 18120 NEXT a: GOTO 18140
  990. 18130 q$(s, t) = "C": k6(k3) = 400 * RND(1): c3 = 1
  991. 18140 GOSUB 28000
  992. 18150 IF u < 10 THEN 18190
  993. 18160 u = u - 10
  994. 18170 b6 = FNB(1): b7 = FNB(1): IF q$(b6, b7) <> "." THEN 18170
  995. 18180 q$(b6, b7) = "B"
  996. 18190 GOSUB 17000: IF u < 1 THEN RETURN
  997. 18200 FOR a = 1 TO u
  998.    18210 s = FNB(1): t = FNB(1): IF q$(s, t) <> "." THEN 18210
  999. 18220 q$(s, t) = "*": NEXT a
  1000. 18230 IF (t2 <> q1) OR (t3 <> q2) THEN RETURN
  1001. 18240 s = FNB(1): t = FNB(1): IF q$(s, t) <> "." THEN 18240
  1002. 18250 q$(s, t) = "O": PRINT
  1003. 18260 PRINT "MR. SPOCK - 'CAPTAIN, THE SHORT-RANGE SENSORS DETECT A"
  1004. 18270 PRINT "SPACE WARP SOMEWHERE IN THIS QUADRANT.'"
  1005. 18280 RETURN
  1006. 18290 FOR a = 1 TO 10: FOR b = 1 TO 10: q$(a, b) = ".": NEXT b: NEXT a
  1007. 18300 q$(s6, s7) = LEFT$(s5$, 1): RETURN
  1008. 18400 g4$ = "III": l = 2: IF q2 >= 5 THEN 18420
  1009. 18410 l = 1
  1010. 18420 g2$ = g1$(2 * (q1 - 1) + l): l = q2
  1011. 18425 IF l <= 4 THEN 18440
  1012. 18430 l = q2 - 4
  1013. 18440 g3$ = "IV": IF l = 4 THEN 18460
  1014. 18450 g3$ = LEFT$(g4$, l)
  1015. 18460 g2$ = g2$ + " " + g3$: RETURN
  1016. 19000 REM - NOVA
  1017. 19001 IF RND(1) > 0.1 THEN 19015
  1018. 19010 GOSUB 27000: RETURN
  1019. 19015 q$(a5, a6) = ".": PRINT "***STAR AT SECTOR"; a5; "-"; a6; "NOVAS."
  1020. 19020 g(q1, q2) = g(q1, q2) - 1: s1 = s1 + 1
  1021. 19025 b9 = 1: t6 = 1: t7 = 1: k = 0: x1 = 0: y1 = 0
  1022. 19030 h4(b9, 1) = a5: h4(b9, 2) = a6
  1023. 19035 FOR m = b9 TO t6: FOR q = 1 TO 3: FOR j = 1 TO 3
  1024.            19040 IF j * q = 4 THEN 19260
  1025.            19045 j5 = h4(m, 1) + q - 2: j6 = h4(m, 2) + j - 2
  1026.            19050 IF (j5 < 1) OR (j5 > 10) THEN 19260
  1027.            19055 IF (j6 < 1) OR (j6 > 10) THEN 19260
  1028.            19060 IF q$(j5, j6) = "." THEN 19260
  1029.            19065 IF q$(j5, j6) = "O" THEN 19260
  1030.            19070 IF q$(j5, j6) <> "*" THEN 19105
  1031.            19075 IF RND(1) >= 0.1 THEN 19085
  1032.            19080 x2 = j5: y2 = j6: GOSUB 27000: RETURN
  1033.            19085 t7 = t7 + 1: h4(t7, 1) = j5: h4(t7, 2) = j6: g(q1, q2) = g(q1, q2) - 1
  1034.            19090 s1 = s1 + 1: PRINT "***STAR AT SECTOR"; j5; "-"; j6; "NOVAS."
  1035.            19100 GOTO 19255
  1036.            19105 IF q$(j5, j6) <> "B" THEN 19140
  1037.            19110 g(q1, q2) = g(q1, q2) - 10: FOR v = 1 TO r3
  1038.                19115 IF (b2(v) <> q1) OR (b3(v) <> q2) THEN 19125
  1039.                19120 b2(v) = b2(r3): b3(v) = b3(r3)
  1040.            19125 NEXT v: r3 = r3 - 1: b6 = 0: b7 = 0: b1 = b1 + 1: GOSUB 17000
  1041.            19130 PRINT "***STARBASE AT SECTOR"; j5; "-"; j6; "DESTROYED."
  1042.            19135 GOTO 19255
  1043.            19140 IF (s6 <> j5) OR (s7 <> j6) THEN 19190
  1044.            19145 PRINT "***STARSHIP BUFFETED BY NOVA.": IF s4 <> 0 THEN 19155
  1045.            19150 e1 = e1 - 1000: GOTO 19170
  1046.            19155 IF s3 >= 1000 THEN 19180
  1047.            19160 d6 = 1000 - s3: e1 = e1 - d6: GOSUB 17000: s3 = 0: s4 = 0
  1048.            19165 PRINT "***STARSHIP SHIELDS KNOCKED OUT.": d4(8) = 5.000000E-03 * d5 * RND(1) * d6
  1049.            19170 IF e1 > 0 THEN 19185
  1050.            19175 f9 = 7: GOSUB 10000: RETURN
  1051.            19180 s3 = s3 - 1000
  1052.            19185 x1 = x1 + s6 - h4(m, 1): y1 = y1 + s7 - h4(m, 2): k = k + 1: GOTO 19260
  1053.            19190 IF q$(j5, j6) <> "C" THEN 19250
  1054.            19195 FOR v = 1 TO k3
  1055.                19200 IF (k4(v) = j5) AND (k5(v) = j6) THEN 19210
  1056.            19205 NEXT v
  1057.            19210 k6(v) = k6(v) - 800: IF k6(v) <= 0 THEN 19250
  1058.            19215 n5 = j5 + j5 - h4(m, 1): n6 = j6 + j6 - h4(m, 2)
  1059.            19220 PRINT "***COMMANDER AT SECTOR"; j5; "-"; j6; "DAMAGED";
  1060.            19225 IF (n5 < 1) OR (n5 > 10) OR (n6 < 1) OR (n6 > 10) THEN 19245
  1061.            19230 PRINT " AND BUFFETED TO SECTOR"; n5; "-"; n6
  1062.            19235 q$(n5, n6) = "C": k4(v) = n5: k5(v) = n6
  1063.            19240 k7(v) = SQR((s6 - n5) ^ 2 + (s7 - n6) ^ 2): k8(v) = k7(v)
  1064.            19241 q$(j5, j6) = "."
  1065.            19245 PRINT: GOTO 19260
  1066.            19250 a5 = j5: a6 = j6: t2$ = q$(j5, j6): GOSUB 6000: GOTO 19260
  1067.            19255 PRINT: q$(j5, j6) = "."
  1068. 19260 NEXT j: NEXT q: NEXT m
  1069. 19265 IF t6 = t7 THEN 19280
  1070. 19270 b9 = t6 + 1: t6 = t7: GOTO 19035
  1071. 19280 IF k = 0 THEN RETURN
  1072. 19290 d1 = k * 0.1
  1073. 19300 IF x1 <> 0 THEN x1 = SGN(x1)
  1074. 19310 IF y1 <> 0 THEN y1 = SGN(y1)
  1075. 19320 i = 3 * (x1 + 1) + y1 + 2
  1076. 19330 d2 = c5(i)
  1077. 19340 IF d2 = 0 THEN d1 = 0
  1078. 19350 IF d1 = 0 THEN RETURN
  1079. 19360 PRINT: PRINT "FORCE OF NOVA DISPLACES STARSHIP."
  1080. 19370 GOSUB 15000: RETURN
  1081. 20000 REM-PHASERS
  1082. 20001 p = 2: j3 = 1
  1083. 20020 IF c5$ <> "DOCKED" THEN 20030
  1084. 20025 PRINT "PHASERS CAN'T BE FIRED THRU BASE SHIELDS.": GOTO 20080
  1085. 20030 IF d4(3) = 0 THEN 20050
  1086. 20040 PRINT "PHASER BANKS DAMAGED.": GOTO 20080
  1087. 20050 IF s4 = 0 THEN 20060
  1088. 20055 PRINT "SHIELDS MUST BE DOWN TO FIRE PHASERS.": GOTO 20080
  1089. 20060 IF k3 > 0 THEN 20090
  1090. 20065 PRINT
  1091. 20070 PRINT "MR. SPOCK - 'CAPTAIN, THE SHORT-RANGE SENSORS"
  1092. 20075 PRINT "  DETECT NO KLINGONS IN THIS QUADRANT.'"
  1093. 20080 j3 = 0: RETURN
  1094. 20090 PRINT "PHASERS LOCKED ON TARGET. ENERGY AVAILABLE=";
  1095. 20095 PRINT 0.01 * INT(100 * e1)
  1096. 20100 INPUT "UNITS TO FIRE "; p1: IF p1 < e1 THEN 20120
  1097. 20110 PRINT "ENERGY AVAILABLE =";: GOTO 20095
  1098. 20120 IF p1 > 0 THEN 20140
  1099. 20130 j3 = 0: RETURN
  1100. 20140 e1 = e1 - p1
  1101. 20142 IF d4(11) = 0 THEN 20147
  1102. 20144 p1 = p1 * (RND(1) * 0.5 + 0.5)
  1103. 20145 PRINT: PRINT "COMPUTER MALFUNCTION HAMPERS PHASER ACCURACY.": PRINT
  1104. 20147 e = p1: IF k3 = 0 THEN 20310
  1105. 20150 e = 0: t5 = (k3 * (k3 + 1)) / 2
  1106. 20160 FOR i = 1 TO k3: h3(i) = ((k3 + 1 - i) / t5) * p1
  1107.    20170 h5(i) = ABS(k6(i)) / (p * 0.9 ^ k7(i))
  1108.    20180 IF h3(i) <= h5(i) THEN 20200
  1109.    20190 e = e + (h3(i) - h5(i)): h3(i) = h5(i)
  1110. 20200 NEXT i
  1111. 20210 IF e = 0 THEN 20280
  1112. 20220 FOR i = 1 TO k3: r7 = h5(i) - h3(i)
  1113.    20230 IF r7 <= 0 THEN 20260
  1114.    20240 IF r7 >= e THEN 20270
  1115.    20250 h3(i) = h5(i): e = e - r7
  1116. 20260 NEXT i: GOTO 20280
  1117. 20270 h3(i) = h3(i) + e: e = 0
  1118. 20280 GOSUB 12000
  1119. 20290 IF (e <> 0) AND (a2 = 0) THEN 20310
  1120. 20300 j3 = 1: RETURN
  1121. 20310 PRINT FNR(e); "EXPENDED ON EMPTY SPACE.": j3 = 1: RETURN
  1122. 21000 REM - PHOTONS
  1123. 21001 j3 = 1: IF d4(4) = 0 THEN 21015
  1124. 21010 PRINT "PHOTON TUBES DAMAGED.": GOTO 21035
  1125. 21015 IF t4 <> 0 THEN 21025
  1126. 21020 PRINT "NO TORPEDOS LEFT.": GOTO 21035
  1127. 21025 INPUT "TORPEDO COURSE "; c6
  1128. 21030 IF c6 >= 0 THEN 21040
  1129. 21035 j3 = 0: RETURN
  1130. 21040 INPUT "BURST OF 3 "; b$: n = 1
  1131. 21045 IF LEFT$(b$, 1) = "N" THEN 21066
  1132. 21050 IF LEFT$(b$, 1) <> "Y" THEN 21040
  1133. 21051 IF t4 > 2 THEN 21060
  1134. 21055 PRINT "NO BURST. ONLY"; t4; "TORPEDOS LEFT.": GOTO 21035
  1135. 21060 INPUT "SPREAD ANGLE (3 - 30 DEG) "; g2
  1136. 21061 IF g2 < 0 THEN 21035
  1137. 21062 IF (g2 < 3) OR (g2 > 30) THEN 21060
  1138. 21063 g2 = FND(g2)
  1139. 21065 n = 3
  1140. 21066 REM - CONTINUE
  1141. 21070 FOR z6 = 1 TO n
  1142.    21075 IF c5$ <> "DOCKED" THEN t4 = t4 - 1
  1143.    21080 z7 = z6: r = RND(1)
  1144.    21085 r = (r + RND(1)) * 0.5 - 0.5
  1145.    21090 IF (r >= -0.4) AND (r <= 0.4) THEN 21125
  1146.    21095 r = (RND(1) + 1.2) * r: IF n = 3 THEN 21105
  1147.    21100 PRINT "***TORPEDO MISFIRES...": GOTO 21110
  1148.    21105 PRINT "***TORPEDO NUMBER"; z6; "MISFIRES..."
  1149.    21110 IF RND(1) > 0.2 THEN 21125
  1150.    21115 PRINT "***PHOTON TUBES DAMAGED BY MISFIRE."
  1151.    21120 d4(4) = d5 * (1 + 2 * RND(1)): GOTO 21440
  1152.    21125 IF (s4 <> 0) OR (c5$ = "DOCKED") THEN r = r + 1.000000E-03 * s3 * r
  1153.    21130 a3 = c6 + 0.25 * r: IF n = 1 THEN 21140
  1154.    21135 a8 = (15 - a3 + (2 - z6) * g2) * 0.523599: PRINT
  1155.    21137 PRINT "TRACK FOR TORPEDO NUMBER"; z7; "--": GOTO 21145
  1156.    21140 PRINT: PRINT "TORPEDO TRACK --": a8 = (15 - a3) * 0.523599
  1157.    21145 x4 = -SIN(a8): y4 = COS(a8): b8 = ABS(x4)
  1158.    21146 IF ABS(y4) > ABS(x4) THEN b8 = ABS(y4)
  1159.    21150 x4 = x4 / b8: y4 = y4 / b8: x5 = s6: y5 = s7
  1160.    21155 FOR l9 = 1 TO 15: x5 = x5 + x4: a5 = INT(x5 + 0.5)
  1161.        21160 IF (a5 < 1) OR (a5 > 10) THEN 21430
  1162.        21165 y5 = y5 + y4: a6 = INT(y5 + 0.5)
  1163.        21170 IF (a6 < 1) OR (a6 > 10) THEN 21430
  1164.        21175 IF (l9 = 5) OR (l9 = 9) THEN PRINT
  1165.        21180 PRINT FNR(x5); "-"; FNR(y5); ", ";
  1166.        21185 IF q$(a5, a6) <> "." THEN 21195
  1167.        21190 GOTO 21425
  1168.        21195 PRINT: IF q$(a5, a6) = "K" THEN 21220
  1169.        21200 IF q$(a5, a6) <> "C" THEN 21325
  1170.        21205 IF RND(1) > 0.1 THEN 21220
  1171.        21210 PRINT "***COMMANDER AT SECTOR"; a5; "-"; a6; "USES ANTI-PHOTON";
  1172.        21215 PRINT " DEVICE!": PRINT "  TORPEDO NEUTRALIZED.": GOTO 21435
  1173.        21220 FOR v = 1 TO k3
  1174.            21225 IF (a5 = k4(v)) AND (a6 = k5(v)) THEN 21235
  1175.        21230 NEXT v
  1176.        21235 k = k6(v): w3 = 200 + 800 * RND(1)
  1177.        21240 IF ABS(k) < w3 THEN w3 = ABS(k)
  1178.        21245 k6(v) = k - SGN(k) * ABS(w3): IF k6(v) <> 0 THEN 21255
  1179.        21250 t2$ = q$(a5, a6): GOSUB 6000: GOTO 21435
  1180.        21255 IF q$(a5, a6) = "K" THEN PRINT "***KLINGON AT";
  1181.        21260 IF q$(a5, a6) = "C" THEN PRINT "***COMMANDER AT";
  1182.        21265 PRINT a5; "-"; a6;
  1183.        21270 a7 = a8 + 2.5 * (RND(1) - 0.5)
  1184.        21275 w3 = ABS(-SIN(a7)): IF ABS(COS(a7)) > w3 THEN w3 = ABS(COS(a7))
  1185.        21280 x7 = -SIN(a7) / w3: y7 = COS(a7) / w3
  1186.        21285 p = INT(a5 + x7 + 0.5): q = INT(a6 + y7 + 0.5)
  1187.        21290 IF (p < 1) OR (p > 10) OR (q < 1) OR (q > 10) THEN 21320
  1188.        21295 IF q$(p, q) <> "." THEN 21320
  1189.        21300 q$(p, q) = q$(a5, a6): q$(a5, a6) = ".": PRINT "DAMAGED--"
  1190.        21305 PRINT "  DISPLACED BY BLAST TO SECTOR"; p; "-"; q
  1191.        21310 k4(v) = p: k5(v) = q: k7(v) = SQR((s6 - p) ^ 2 + (s7 - q) ^ 2)
  1192.        21311 k8(v) = k7(v)
  1193.        21315 GOSUB 28000: GOTO 21435
  1194.        21320 PRINT "DAMAGED, BUT NOT DESTROYED.": GOTO 21435
  1195.        21325 IF q$(a5, a6) <> "B" THEN 21365
  1196.        21330 PRINT "***STARBASE DESTROYED...CONGRATULATIONS...YOU TURKEY!"
  1197.        21335 IF s2(q1, q2) < 0 THEN s2(q1, q2) = 0
  1198.        21340 FOR w = 1 TO r3
  1199.            21345 IF (b2(w) <> q1) OR (b3(w) <> q2) THEN 21355
  1200.            21350 b2(w) = b2(r3): b3(w) = b3(r3)
  1201.        21355 NEXT w: q$(a5, a6) = ".": r3 = r3 - 1: b6 = 0: b7 = 0
  1202.        21360 g(q1, q2) = g(q1, q2) - 10: b1 = b1 + 1: GOSUB 17000: GOTO 21435
  1203.        21365 IF q$(a5, a6) <> "*" THEN 21405
  1204.        21370 IF RND(1) > 0.15 THEN 21385
  1205.        21375 PRINT "***STAR AT SECTOR"; a5; "-"; a6; "UNAFFECTED BY PHOTON BLAST"
  1206.        21380 GOTO 21435
  1207.        21385 x2 = a5: y2 = a6: GOSUB 19000: a5 = x2: a6 = y2
  1208.        21390 IF g(q1, q2) = 1000 THEN RETURN
  1209.        21395 IF a2 <> 0 THEN RETURN
  1210.        21400 GOTO 21435
  1211.        21405 PRINT: PRINT "AAAAAIIIIIIIEEEEEEEAAAAAAAUUUUUUGGGGGGGHHHHHHHHHH!!!"
  1212.        21410 PRINT "  HACK!   HACK!  COUGH!   *CHOKE!*"
  1213.        21415 PRINT: PRINT "MR. SPOCK- 'FASCINATING!'": q$(a5, a6) = "."
  1214.        21420 t2 = 0: t3 = 0: GOTO 21435
  1215.    21425 NEXT l9
  1216.    21430 PRINT: PRINT "TORPEDO MISSED!"
  1217. 21435 NEXT z6
  1218. 21440 IF r1 <> 0 THEN RETURN
  1219. 21445 f9 = 1: GOSUB 10000: RETURN
  1220. 22000 REM - RAM
  1221. 22001 PRINT: PRINT "*** RED ALERT!!  RED ALERT!! ***": PRINT
  1222. 22010 PRINT "*** COLLISION IMMINENT!!": PRINT
  1223. 22020 PRINT "*** "; s5$; " RAMS ";: w7 = 1: IF q$(s6, s7) = "C" THEN w7 = 2
  1224. 22030 IF w7 = 1 THEN PRINT "KLINGON AT ";
  1225. 22040 IF w7 = 2 THEN PRINT "COMMANDER AT ";
  1226. 22050 PRINT "SECTOR"; s6; "-"; s7: a5 = s6: a6 = s7: t2$ = q$(s6, s7)
  1227. 22060 GOSUB 6000: PRINT "***"; s5$; " HEAVILY DAMAGED."
  1228. 22070 k = INT(5 + RND(1) * 20): PRINT "***SICKBAY REPORTS"; k; "CASUALTIES!"
  1229. 22080 c4 = c4 + k: FOR l = 1 TO 12: i = RND(1)
  1230.    22090 j = (3.5 * w7 * (RND(1) + i) + 1) * d5
  1231.    22100 IF l = 6 THEN j = j / 3
  1232. 22110 d4(l) = d4(l) + t1 + j: NEXT l: d4(6) = d4(6) - 3
  1233. 22120 IF d4(6) < 0 THEN d4(6) = 0
  1234. 22130 s4 = 0: IF r1 <> 0 THEN RETURN
  1235. 22140 f9 = 1: GOSUB 10000: RETURN
  1236. 23000 REM - SCORE
  1237. 23001 p = d0 - j2: IF (p <> 0) AND (r1 = 0) THEN 23020
  1238. 23010 IF p < 5 THEN p = 5
  1239. 23020 n = (k2 + k1) / p: k = INT(500 * n + 0.5): l = 0
  1240. 23030 IF g1 <> 0 THEN l = 100 * s8
  1241. 23035 i = 0
  1242. 23040 IF LEFT$(s5$, 1) = "E" THEN m = 0
  1243. 23045 IF LEFT$(s5$, 1) = "F" THEN m = 1
  1244. 23050 IF LEFT$(s5$, 1) = "" THEN m = 2
  1245. 23060 IF a1 = 0 THEN i = 200
  1246. 23070 j = 10 * k1 + 50 * k2 + k + l - i - 100 * b1 - 100 * m - 35 * n1 - 3 * s1 - c4
  1247. 23080 PRINT: IF j <> 0 THEN 23100
  1248. 23090 PRINT "AS YET, YOU HAVE NO SCORE.": RETURN
  1249. 23100 PRINT "YOUR SCORE --": PRINT: IF k1 = 0 THEN 23120
  1250. 23110 PRINT k1; TAB(5); "ORDINARY KLINGON(S) DESTROYED"; TAB(36); 10 * k1
  1251. 23120 IF k2 = 0 THEN 23140
  1252. 23130 PRINT k2; TAB(5); "KLINGON COMMANDER(S) DESTROYED"; TAB(36); 50 * k2
  1253. 23140 IF k = 0 THEN 23160
  1254. 23150 PRINT FNR(n); TAB(5); "KLINGONS PER STARDATE, AVERAGE";
  1255. 23155 PRINT TAB(36); k
  1256. 23160 IF s1 = 0 THEN 23180
  1257. 23170 PRINT s1; TAB(5); "STAR(S) DESTROYED"; TAB(36); -3 * s1
  1258. 23180 IF b1 = 0 THEN 23200
  1259. 23190 PRINT b1; TAB(5); "STARBASES DESTROYED"; TAB(36); -100 * b1
  1260. 23200 IF n1 = 0 THEN 23220
  1261. 23210 PRINT n1; TAB(5); "SOS CALL(S) TO A STARBASE"; TAB(36); -35 * n1
  1262. 23220 IF c4 = 0 THEN 23240
  1263. 23230 PRINT c4; TAB(5); "CASUALTIES INCURRED"; TAB(36); -c4
  1264. 23240 IF m = 0 THEN 23260
  1265. 23250 PRINT m; TAB(5); "SHIP(S) LOST OR DESTROYED"; TAB(36); -100 * m
  1266. 23260 IF a1 <> 0 THEN 23280
  1267. 23270 PRINT "PENALTY FOR GETTING YOURSELF KILLED"; TAB(36); -200
  1268. 23280 IF g1 = 0 THEN 23300
  1269. 23290 PRINT TAB(5); "BONUS FOR WINNING "; s$(s8); " GAME"; TAB(36); l
  1270. 23300 PRINT TAB(5); "-------------------------------------"
  1271. 23310 PRINT TAB(28); "TOTAL"; TAB(36); j; "**": RETURN
  1272. 24000 REM-SETUP
  1273. 24001 a2 = 0: g1 = 0: GOSUB 4000: s5$ = "ENTERPRISE"
  1274. 24010 i7 = 20000: e1 = i7: i8 = 2500: s3 = i8: s4 = 0: s9 = s4: j1 = 4: l1 = j1
  1275. 24020 q1 = FNA(1): q2 = FNA(1): s6 = FNB(1): s7 = FNB(1): i9 = 10: t4 = i9
  1276. 24030 w1 = 5: w2 = 25: FOR i = 1 TO 12: d4(i) = 0: NEXT i
  1277. 24040 j2 = 100 * INT(31 * RND(1) + 20): d0 = j2: k1 = 0: k2 = 0: n1 = 0: n2 = 0: r6 = 0: c4 = 0
  1278. 24050 a1 = 1: d3 = 0.25: FOR i = 1 TO 8: FOR j = 1 TO 8: s2(i, j) = 0: NEXT j: NEXT i
  1279. 24060 f1(1) = d0 - 0.5 * i5 * LOG(RND(1)): f1(5) = 1.000000E+30
  1280. 24070 f1(2) = d0 - 1.5 * (i5 / r2) * LOG(RND(1)): i6 = 0
  1281. 24080 f1(3) = d0 - 0.3 * i5 * LOG(RND(1)): f1(4) = d0 - 0.3 * i5 * LOG(RND(1))
  1282. 24090 FOR i = 1 TO 8: FOR j = 1 TO 8: k = INT(RND(1) * 9 + 1): i6 = i6 + k
  1283. 24100 g(i, j) = k: NEXT j: NEXT i: s1 = 0
  1284. 24110 FOR i = 1 TO i2
  1285.    24120 x = INT(RND(1) * 6 + 2): y = INT(RND(1) * 6 + 2)
  1286.    24130 IF g(x, y) >= 10 THEN 24120
  1287.    24140 IF i < 2 THEN 24180
  1288.    24150 k = i - 1: FOR j = 1 TO k: d1 = SQR((b2(j) - x) ^ 2 + (b3(j) - y) ^ 2)
  1289.        24160 IF d1 < 2 THEN 24120
  1290.    24170 NEXT j
  1291. 24180 b2(i) = x: b3(i) = y: s2(x, y) = -1: g(x, y) = g(x, y) + 10: NEXT i
  1292. 24190 b1 = 0: k = i1 - i4: l = INT(0.25 * s8 * (9 - l2) + 1)
  1293. 24200 m = INT((1 - RND(1) ^ 2) * l): IF m > k THEN m = k
  1294. 24210 n = 100 * m
  1295. 24220 x = FNA(1): y = FNA(1): IF g(x, y) + n > 999 THEN 24220
  1296. 24230 g(x, y) = g(x, y) + n: k = k - m: IF k <> 0 THEN 24200
  1297. 24240 FOR i = 1 TO i4
  1298.    24250 x = FNA(1): y = FNA(1): IF (g(x, y) < 99) AND (RND(1) < 0.75) THEN 24250
  1299.    24260 IF g(x, y) > 899 THEN 24250
  1300.    24270 IF i = 1 THEN 24300
  1301.    24280 m = i - 1: FOR j = 1 TO m: IF (c1(j) = x) AND (c2(j) = y) THEN 24250
  1302.    24290 NEXT j
  1303. 24300 g(x, y) = g(x, y) + 100: c1(i) = x: c2(i) = y: NEXT i
  1304. 24305 i = INT(d0): PRINT: s0 = 0
  1305. 24310 t2 = FNA(1): t3 = FNA(1): IF g(t2, t3) < 100 THEN 24310
  1306. 24320 IF s8 <> 1 THEN 24440
  1307. 24330 PRINT "IT IS STARDATE"; i; "...THE ORGANIAN PEACE TREATY BETWEEN"
  1308. 24340 PRINT "THE UNITED FEDERATION OF PLANETS AND THE KLINGON EMPIRE"
  1309. 24350 PRINT "HAS COLLAPSED AND THE FEDERATION IS BEING ATTACKED BY A"
  1310. 24360 PRINT "DEADLY KLINGON INVASION FLEET. AS CAPTAIN OF THE"
  1311. 24361 PRINT "STARSHIP"
  1312. 24370 PRINT "U.S.S. ENTERPRISE, IT IS YOUR MISSION TO SEEK OUT AND"
  1313. 24380 PRINT "DESTROY THIS INVASION FORCE OF"; i1; "BATTLE CRUISERS."
  1314. 24390 PRINT: PRINT "YOU HAVE AN INITIAL ALLOTMENT OF"; INT(i5);
  1315. 24400 PRINT "STARDATES": PRINT "TO COMPLETE YOUR MISSION."
  1316. 24410 PRINT "AS THE MISSION PROCEEDS, YOU MAY BE GIVEN MORE TIME."
  1317. 24420 PRINT: PRINT "YOU WILL HAVE"; i2; "SUPPORTING STARBASE(S).": PRINT
  1318. 24430 GOTO 24515
  1319. 24440 PRINT "STARDATE.............."; i
  1320. 24450 PRINT "NUMBER OF KLINGONS...."; i1
  1321. 24460 PRINT "NUMBER OF STARDATES..."; INT(i5)
  1322. 24470 PRINT "NUMBER OF STARBASES..."; i2
  1323. 24480 PRINT "STARBASE LOCATIONS....";
  1324. 24490 FOR i = 1 TO i2: PRINT b2(i); "-"; b3(i);
  1325.    24500 IF i <> i2 THEN PRINT ", ";
  1326. 24510 NEXT i: PRINT: PRINT
  1327. 24515 GOSUB 18400
  1328. 24520 PRINT "THE "; s5$; " IS CURRENTLY IN THE "; g2$; " QUADRANT."
  1329. 24530 GOSUB 18000: RETURN
  1330. 25000 REM - SETWARP
  1331. 25010 INPUT "WARP FACTOR "; k
  1332. 25020 PRINT
  1333. 25025 IF k < 1 THEN 25140
  1334. 25026 IF k > 10 THEN 25150
  1335. 25030 j = w1: w1 = k: w2 = w1 * w1
  1336. 25040 IF (w1 <= j) OR (w1 <= 6) THEN 25070
  1337. 25050 IF w1 <= 8 THEN 25080
  1338. 25060 IF w1 > 8 THEN 25100
  1339. 25070 PRINT "ENSIGN CHEKOV - 'WARP FACTOR"; w1; "CAPTAIN'": RETURN
  1340. 25080 PRINT "ENGINEER SCOTT - 'AYE, BUT OUR MAXIMUM SAFE SPEED";
  1341. 25090 PRINT " IS WARP 6.'": RETURN
  1342. 25100 IF w1 = 10 THEN 25130
  1343. 25110 PRINT "ENGINEER SCOTT-'AYE, CAPTAIN, BUT OUR ENGINES MAY NOT ";
  1344. 25120 PRINT "TAKE IT.'": RETURN
  1345. 25130 PRINT "ENGINEER SCOTT-'AYE, CAPTAIN, WE'LL GIVE IT A"
  1346. 25131 PRINT "try.'": RETURN
  1347. 25140 PRINT "ENSIGN CHEKOV-'WE CAN'T GO BELOW WARP 1, CAPTAIN.'": RETURN
  1348. 25150 PRINT "ENSIGN CHEKOV-'OUR TO P SPEED IS WARP 10, CAPTAIN.'"
  1349. 25160 RETURN
  1350. 26000 REM - SHIELDS
  1351. 26001 j3 = 0: IF d4(8) <> 0 THEN 26600
  1352. 26010 IF s4 <> 0 THEN 26530
  1353. 26500 INPUT "SHIELDS ARE DOWN. DO YOU WANT THEM UP"; b$
  1354. 26510 IF LEFT$(b$, 1) = "Y" THEN 26560
  1355. 26520 RETURN
  1356. 26530 INPUT "SHIELDS ARE UP. DO YOU WANT THEM DOWN"; b$
  1357. 26540 IF LEFT$(b$, 1) = "Y" THEN 26590
  1358. 26550 RETURN
  1359. 26560 s4 = 1: s9 = 1: IF c5$ <> "DOCKED" THEN e1 = e1 - 50
  1360. 26570 PRINT "SHIELDS RAISED.": IF e1 <= 0 THEN 26610
  1361. 26580 j3 = 1: RETURN
  1362. 26590 s4 = 0: s9 = 1: PRINT "SHIELDS LOWERED.": j3 = 1: RETURN
  1363. 26600 PRINT "SHIELDS DAMAGED AND DOWN.": RETURN
  1364. 26610 PRINT: PRINT "SHIELDS USE UP LAST OF THE ENERGY."
  1365. 26620 f9 = 4: GOSUB 10000: RETURN
  1366. 27000 REM - SUPERNOVA
  1367. 27001 IF x2 <> 0 THEN 27100
  1368. 27010 n = INT(RND(1) * i6 + 1): FOR x = 1 TO 8: FOR y = 1 TO 8
  1369.        27020 n = n - (g(x, y) - INT(g(x, y) / 10) * 10): IF n <= 0 THEN 27040
  1370. 27030 NEXT y: NEXT x: RETURN
  1371. 27040 IF (x <> q1) OR (y <> q2) THEN 27150
  1372. 27050 IF j4 <> 0 THEN 27150
  1373. 27060 n = INT(RND(1) * (g(x, y) - INT(g(x, y) / 10) * 10)) + 1
  1374. 27070 FOR x3 = 1 TO 10: FOR y3 = 1 TO 10: IF q$(x3, y3) <> "*" THEN 27090
  1375.        27080 n = n - 1: IF n = 0 THEN 27100
  1376. 27090 NEXT y3: NEXT x3
  1377. 27100 PRINT: PRINT "*** RED ALERT!! RED ALERT!! ***"
  1378. 27105 x3 = x2: y3 = y2
  1379. 27110 PRINT "*** INCIPIENT SUPERNOVA DETECTED AT SECTOR"; x3; "-"; y3
  1380. 27120 x = q1: y = q2: k = (x2 - s6) ^ 2 + (y2 - s7) ^ 2
  1381. 27130 IF k > 1.5 THEN 27180
  1382. 27140 PRINT "*** EMERGENCY AUTO -OVERRIDE JAMMED ***": a2 = 1: GOTO 27180
  1383. 27150 IF d4(9) <> 0 THEN 27180
  1384. 27160 PRINT: PRINT "MESSAGE FROM STARFLEET COMMAND...STARDATE"; INT(d0)
  1385. 27170 PRINT "'SUPERNOVA IN QUADRANT"; x; "-"; y;
  1386. 27175 PRINT "....CAUTION ADVISED'"
  1387. 27180 n = g(x, y): r = INT(n / 100): q = 0
  1388. 27190 IF (x <> q1) OR (y <> q2) THEN 27210
  1389. 27200 k3 = 0: c3 = 0
  1390. 27210 IF r = 0 THEN 27270
  1391. 27220 r1 = r1 - r: IF r2 = 0 THEN 27270
  1392. 27230 FOR l = 1 TO r2: IF (c1(l) <> x) OR (c2(l) <> y) THEN 27260
  1393.    27240 c1(l) = c1(r2): c2(l) = c2(r2): c1(r2) = 0: c2(r2) = 0
  1394.    27250 r2 = r2 - 1: r = r - 1: q = 1: IF r2 = 0 THEN f1(2) = 1.000000E+30
  1395. 27260 NEXT l
  1396. 27270 IF r3 = 0 THEN 27310
  1397. 27280 FOR l = 1 TO r3: IF (b2(l) <> x) OR (b3(l) <> y) THEN 27300
  1398.    27290 b2(l) = b2(r3): b3(l) = b3(r3): b2(r3) = 0: b3(r3) = 0: r3 = r3 - 1
  1399. 27300 NEXT l
  1400. 27310 IF x2 = 0 THEN 27350
  1401. 27320 n = g(x, y) - INT(g(x, y) / 100) * 100
  1402. 27330 s1 = s1 + (n - INT(n / 10) * 10): b1 = b1 + INT(n / 10)
  1403. 27340 k1 = k1 + r: k2 = k2 + q
  1404. 27350 IF (s2(x, y) <> 0) AND (d4(9) <> 0) THEN s2(x, y) = 1000 + g(x, y)
  1405. 27360 IF (d4(9) = 0) OR ((q1 = x) AND (q2 = y)) THEN s2(x, y) = 1
  1406. 27370 g(x, y) = 1000
  1407. 27380 IF (r1 <> 0) OR ((x = q1) AND (y = q2)) THEN 27430
  1408. 27390 PRINT: PRINT "MR. SPOCK- 'CAPTAIN, A SUPERNOVA IN QUADRANT";
  1409. 27400 PRINT x; "-"; y; "HAS JUST DESTROYED THE LAST OF THE KLINGONS.'"
  1410. 27420 f9 = 1: GOSUB 10000: RETURN
  1411. 27430 IF a2 = 0 THEN RETURN
  1412. 27440 f9 = 8: GOSUB 10000: RETURN
  1413. 28000 REM - SORTKL
  1414. 28001 IF k3 <= 1 THEN RETURN
  1415. 28005 z4 = 0
  1416. 28010 FOR o = 1 TO k3 - 1: IF k7(o) <= k7(o + 1) THEN 28080
  1417.    28020 k = k7(o): k7(o) = k7(o + 1): k7(o + 1) = k
  1418.    28030 k = k8(o): k8(o) = k8(o + 1): k8(o + 1) = k
  1419.    28040 k = k4(o): k4(o) = k4(o + 1): k4(o + 1) = k
  1420.    28050 k = k5(o): k5(o) = k5(o + 1): k5(o + 1) = k
  1421.    28060 k = k6(o): k6(o) = k6(o + 1): k6(o + 1) = k
  1422.    28070 z4 = 1
  1423. 28080 NEXT o
  1424. 28090 IF z4 <> 0 THEN 28005
  1425. 28100 RETURN
  1426. 29000 REM-SRSCAN
  1427. 29001 IF d4(1) <> 0 THEN 29230: REM damage ? rhn
  1428. 29010 PRINT: PRINT "  1 2 3 4 5 6 7 8 9 10"
  1429. 29020 FOR i = 1 TO 10: IF i < 10 THEN PRINT " ";
  1430.    29030 PRINT i;: FOR j = 1 TO 10: PRINT q$(i, j); " ";: NEXT j
  1431.    29040 ON i GOTO 29050, 29060, 29080, 29090, 29140
  1432.    29045 ON i - 5 GOTO 29150, 29160, 29170, 29200, 29210
  1433.    29050 PRINT " STARDATE      "; FNR(d0): GOTO 29220
  1434.    29060 IF c5$ <> "DOCKED" THEN GOSUB 17000
  1435.    29070 PRINT " CONDITION      "; c5$: GOTO 29220
  1436.    29080 PRINT " POSITION      "; q1; "-"; q2; ", "; s6; "-"; s7: GOTO 29220
  1437.    29090 PRINT " LIFE SUPPORT   ";: IF d4(5) <> 0 THEN 29110
  1438.    29100 PRINT "ACTIVE": GOTO 29220
  1439.    29110 IF c5$ <> "DOCKED" THEN 29130
  1440.    29120 PRINT "DAMAGED, SUPPORTED BY STARBASE": GOTO 29220
  1441.    29130 PRINT "DAMAGED, RESERVES="; FNS(l1): GOTO 29220
  1442.    29140 PRINT " WARP FACTOR   "; FNR(w1): GOTO 29220
  1443.    29150 PRINT " ENERGY"; spc$(8); 0.01 * INT(100 * e1): GOTO 29220
  1444.    29160 PRINT " TORPEDOS      "; t4: GOTO 29220
  1445.    29170 PRINT " SHIELDS        ";: b$ = "DOWN,": IF s4 <> 0 THEN b$ = "UP,"
  1446.    29180 IF d4(8) > 0 THEN b$ = "DAMAGED,"
  1447.    29190 PRINT b$; INT(100 * s3 / i8 + 0.5); "%": GOTO 29220
  1448.    29200 PRINT " KLINGONS LEFT "; r1: GOTO 29220
  1449.    29210 PRINT " TIME LEFT     "; FNS(r5)
  1450. 29220 NEXT i: RETURN
  1451. 29230 PRINT "SHORT RANGE SENSORS DAMAGED.": RETURN
  1452. 30000 REM - TIMEWARP
  1453. 30001 PRINT: PRINT "*** TIME WARP ENTERED ***": PRINT "YOU ARE TRAVELING"
  1454. 30002 PRINT ";"
  1455. 30010 IF s0 <> 0 THEN 30050
  1456. 30020 t1 = -0.5 * i5 * LOG(RND(1))
  1457. 30030 PRINT " FORWARD IN TIME"; FNR(t1); "STARDATES."
  1458. 30040 f1(2) = f1(2) + t1: GOTO 30200
  1459. 30050 m = d0: d0 = d9(1)
  1460. 30060 PRINT "BACKWARD IN TIME"; FNR(m - d0); "STARDATES.": s0 = 0
  1461. 30070 r1 = d9(2): r2 = d9(3): r3 = d9(4): r4 = d9(5): r5 = d9(6)
  1462. 30080 s1 = d9(7): b1 = d9(8): k1 = d9(9): k2 = d9(10)
  1463. 30090 FOR i = 1 TO 8: FOR j = 1 TO 8: g(i, j) = d9(i - 1 + 8 * (j - 1) + 11): NEXT j: NEXT i
  1464. 30100 FOR i = 75 TO 84: c1(i - 74) = d9(i): NEXT
  1465. 30110 FOR i = 85 TO 94: c2(i - 84) = d9(i): NEXT
  1466. 30120 FOR i = 95 TO 99: b2(i - 94) = d9(i): NEXT
  1467. 30130 FOR i = 100 TO 104: b3(i - 99) = d9(i): NEXT: b4 = d9(105): b5 = d9(106)
  1468. 30140 f1(1) = d0 - 0.5 * i5 * LOG(RND(1))
  1469. 30150 IF r2 <> 0 THEN f1(2) = d0 - (i5 / r2) * LOG(RND(1))
  1470. 30160 f1(3) = d0 - 0.5 * i5 * LOG(RND(1))
  1471. 30170 FOR i = 1 TO 8: FOR j = 1 TO 8: IF 1 < s2(i, j) THEN s2(i, j) = 1
  1472. 30180 NEXT j: NEXT i
  1473. 30185 PRINT
  1474. 30190 PRINT "SPOCK HAS RECONSTRUCTED A CORRECT STAR CHART FROM MEMORY."
  1475. 30200 GOSUB 18000: RETURN
  1476. 31000 REM - TRANSFER
  1477. 31001 j3 = 0
  1478. 31010 IF d4(12) <> 0 THEN 31120
  1479. 31020 INPUT "NUMBER OF UNITS TO SHIELDS "; z3
  1480. 31030 IF z3 < 0 THEN RETURN
  1481. 31040 IF e1 + s3 - z3 > 0 THEN 31060
  1482. 31050 PRINT "SCOTT HERE- 'WE ONLY HAVE"; FNR(e1 + s3); "UNITS LEFT.'"
  1483. 31051 RETURN
  1484. 31060 e1 = e1 + s3 - z3: s3 = z3: PRINT "--ENERGY TRANSFER COMPLETE--"
  1485. 31070 PRINT "(SHIP ENERGY="; FNR(e1); "  SHIELD ENERGY="; FNR(s3); ")"
  1486. 31075 j3 = 1
  1487. 31080 t1 = 0.1: p5 = (k3 + 4 * c3) / 48: IF p5 < 0.1 THEN p5 = 0.1
  1488. 31090 IF p5 > RND(1) THEN GOSUB 1000
  1489. 31100 IF a2 <> 0 THEN RETURN
  1490. 31110 GOSUB 9000: RETURN
  1491. 31120 PRINT "TRANSFER PANEL DAMAGED.": RETURN
  1492. 32000 REM - VISUAL
  1493. 32001 INPUT "WHICH DIRECTION "; z
  1494. 32005 PRINT
  1495. 32010 j3 = 0: IF z < 0 THEN RETURN
  1496. 32012 IF z <= 12 THEN 32020
  1497. 32014 PRINT "DIRECTIONS ARE FROM 0 TO 12 ONLY": GOTO 32001
  1498. 32020 t1 = 0.05: p = (k3 + 4 * c3) / 48: IF p < 0.05 THEN p = 0.05
  1499. 32030 IF p > RND(1) THEN GOSUB 1000
  1500. 32040 IF a2 <> 0 THEN RETURN
  1501. 32050 GOSUB 9000: j3 = 1: IF a2 <> 0 THEN RETURN
  1502. 32080 d5 = INT((z / 12) * 8 + 1.5): IF d5 > 8 THEN d5 = 1
  1503. 32085 FOR i = 1 TO 5: FOR j = 1 TO 5: v$(i, j) = " ": NEXT j: NEXT i: n = 0
  1504. 32087 v$(3, 3) = LEFT$(s5$, 1)
  1505. 32090 ON d5 GOTO 32100, 32130, 32150, 32170, 32190, 32220, 32260, 32300
  1506. 32100 i = s6 - 2: j = s7 - 2: v$(1, 1) = q$: IF (j > 0) AND (i > 0) THEN v$(1, 1) = q$(i, j)
  1507. 32110 i = s6 - 1: j = s7 - 1: v$(2, 2) = q$: IF (i > 0) AND (j > 0) THEN v$(2, 2) = q$(i, j)
  1508. 32120 n = n + 1: IF n = 3 THEN 32350
  1509. 32125 i = s6 - 2: v$(1, 2) = q$: IF (i > 0) AND (j > 0) THEN v$(1, 2) = q$(i, j)
  1510. 32130 i = s6 - 2: v$(1, 3) = q$: IF i > 0 THEN v$(1, 3) = q$(i, s7)
  1511. 32135 i = s6 - 1: v$(2, 3) = q$: IF i > 0 THEN v$(2, 3) = q$(i, s7)
  1512. 32140 n = n + 1: IF n = 3 THEN 32350
  1513. 32145 i = s6 - 2: j = s7 + 1: v$(1, 4) = q$: IF (i > 0) AND (j < 11) THEN v$(1, 4) = q$(i, j)
  1514. 32150 i = s6 - 2: j = s7 + 2: v$(1, 5) = q$: IF (i > 0) AND (j < 11) THEN v$(1, 5) = q$(i, j)
  1515. 32155 i = s6 - 1: j = s7 + 1: v$(2, 4) = q$: IF (i > 0) AND (j < 11) THEN v$(2, 4) = q$(i, j)
  1516. 32160 n = n + 1: IF n = 3 THEN 32350
  1517. 32165 j = s7 + 2: v$(2, 5) = q$: IF (i > 0) AND (j < 11) THEN v$(2, 5) = q$(i, j)
  1518. 32170 j = s7 + 2: v$(3, 5) = q$: IF j < 11 THEN v$(3, 5) = q$(s6, j)
  1519. 32175 j = s7 + 1: v$(3, 4) = q$: IF j < 11 THEN v$(3, 4) = q$(s6, j)
  1520. 32180 n = n + 1: IF n = 3 THEN 32350
  1521. 32185 i = s6 + 1: j = s7 + 2: v$(4, 5) = q$: IF (i < 11) AND (j < 11) THEN v$(4, 5) = q$(i, j)
  1522. 32190 i = s6 + 2: j = s7 + 2: v$(5, 5) = q$: IF (i < 11) AND (j < 11) THEN v$(5, 5) = q$(i, j)
  1523. 32195 i = s6 + 1: j = s7 + 1: v$(4, 4) = q$: IF (i < 11) AND (j < 11) THEN v$(4, 4) = q$(i, j)
  1524. 32200 n = n + 1: IF n = 3 THEN 32350
  1525. 32210 i = s6 + 2: v$(5, 4) = q$: IF (i < 11) AND (j < 11) THEN v$(5, 4) = q$(i, j)
  1526. 32220 i = s6 + 2: v$(5, 3) = q$: IF i < 11 THEN v$(5, 3) = q$(i, s7)
  1527. 32230 i = s6 + 1: v$(4, 3) = q$: IF i < 11 THEN v$(4, 3) = q$(i, s7)
  1528. 32240 n = n + 1: IF n = 3 THEN 32350
  1529. 32250 i = s6 + 2: j = s7 - 1: v$(5, 2) = q$: IF (i < 11) AND (j > 0) THEN v$(5, 2) = q$(i, j)
  1530. 32260 i = s6 + 2: j = s7 - 2: v$(5, 1) = q$: IF (i < 11) AND (j > 0) THEN v$(5, 1) = q$(i, j)
  1531. 32270 i = s6 + 1: j = s7 - 1: v$(4, 2) = q$: IF (i < 11) AND (j > 0) THEN v$(4, 2) = q$(i, j)
  1532. 32280 n = n + 1: IF n = 3 THEN 32350
  1533. 32290 j = s7 - 2: v$(4, 1) = q$: IF (i < 11) AND (j > 0) THEN v$(4, 1) = q$(i, j)
  1534. 32300 j = s7 - 2: v$(3, 1) = q$: IF j > 0 THEN v$(3, 1) = q$(s6, j)
  1535. 32310 j = s7 - 1: v$(3, 2) = q$: IF j > 0 THEN v$(3, 2) = q$(s6, j)
  1536. 32320 n = n + 1: IF n = 3 THEN 32350
  1537. 32330 i = s6 - 1: j = s7 - 2: v$(2, 1) = q$: IF (i > 0) AND (j > 0) THEN v$(2, 1) = q$(i, j)
  1538. 32340 GOTO 32100
  1539. 32350 FOR i = 1 TO 5
  1540.    32360 IF (v$(i, 1) = " ") AND (v$(i, 3) = " ") AND (v$(i, 5) = " ") THEN 32390
  1541.    32370 PRINT " ";
  1542.    32380 FOR j = 1 TO 5: PRINT v$(i, j); " ";: NEXT j: PRINT
  1543. 32390 NEXT i: RETURN
  1544. 33000 REM - WAIT
  1545. 33001 j3 = 0: INPUT "HOW MANY STARDATES"; z5
  1546. 33010 IF (z5 < r5) AND (k3 = 0) THEN 33030
  1547. 33020 INPUT "ARE YOU SURE? "; b$: IF LEFT$(b$, 1) <> "Y" THEN RETURN
  1548. 33030 r6 = 1
  1549. 33040 IF z5 <= 0 THEN r6 = 0
  1550. 33050 IF r6 = 0 THEN RETURN
  1551. 33060 t1 = z5: z6 = z5
  1552. 33070 IF k3 = 0 THEN 33100
  1553. 33080 t1 = 1 + RND(1): IF z5 < t1 THEN t1 = z5
  1554. 33090 z6 = t1
  1555. 33100 IF t1 < z5 THEN GOSUB 1000
  1556. 33110 IF a2 <> 0 THEN RETURN
  1557. 33120 GOSUB 9000: j3 = 1: IF a2 <> 0 THEN RETURN
  1558. 33130 z5 = z5 - z6: GOTO 33040
  1559. 34000 REM:WARP
  1560. 34001 j3 = 0: IF d4(6) <> 0 THEN 34750
  1561. 34010 INPUT "ENTER COURSE AND DISTANCE "; d2, d1
  1562. 34020 IF d2 < 0 THEN RETURN
  1563. 34030 p = (d1 + 0.05) * w1 * w1 * w1 * (s4 + 1): IF p < e1 THEN 34150
  1564. 34040 j3 = 0: PRINT: PRINT "ENGINEERING TO BRIDGE--"
  1565. 34050 IF (s4 = 0) OR (0.5 * p > e1) THEN 34080
  1566. 34060 PRINT " WE HAVEN'T THE ENERGY TO GO THAT FAR WITH";
  1567. 34070 PRINT " THE SHIELDS UP.": RETURN
  1568. 34080 w = INT((e1 / (d1 + 0.05)) ^ 0.333333): IF w <= 0 THEN 34130
  1569. 34090 PRINT " WE HAVEN'T THE ENERGY. BUT WE COULD DO IT AT WARP"; w
  1570. 34100 IF s4 <> 0 THEN 34120
  1571. 34110 RETURN
  1572. 34120 PRINT "  IF YOU'LL LOWER THE SHIELDS.": RETURN
  1573. 34130 PRINT " WE CAN'T DO IT, CAPTAIN. WE HAVEN'T GOT THE ENERGY."
  1574. 34140 RETURN
  1575. 34150 t1 = 10 * d1 / w2: IF t1 < 0.8 * r5 THEN 34500
  1576. 34160 PRINT: PRINT "MR. SPOCK - 'CAPTAIN, I COMPUTE THAT SUCH A TRIP"
  1577. 34170 PRINT " WILL REQUIRE APPROXIMATELY"; FNR(100 * t1 / r5);
  1578. 34180 PRINT "PERCENT": PRINT "  OF OUR REMAINING TIME. ARE YOU SURE ";
  1579. 34190 INPUT "THIS IS WISE"; b$: IF LEFT$(b$, 1) = "Y" THEN 34500
  1580. 34200 j3 = 0: RETURN
  1581. 34500 q4 = 0: w = 0: IF w1 <= 6 THEN 34660
  1582. 34510 p = d1 * (6 - w1) ^ 2 / 66.66666: IF p > RND(1) THEN q4 = 1
  1583. 34520 IF q4 <> 0 THEN d1 = RND(1) * d1
  1584. 34530 w = 0: IF w1 < 10 THEN 34550
  1585. 34540 IF 0.25 * d1 > RND(1) THEN w = 1
  1586. 34550 IF (q4 = 0) AND (w = 0) THEN 34660
  1587. 34560 a = (15 - d2) * 0.5236: x1 = -SIN(a): x2 = COS(a)
  1588. 34570 b8 = ABS(x1): IF ABS(x2) > ABS(x1) THEN b8 = ABS(x2)
  1589. 34580 x1 = x1 / b8: y1 = y1 / b8: n = INT(10 * d1 * b8 + 0.5): x = s6: y = s7
  1590. 34590 IF n = 0 THEN 34660
  1591. 34600 FOR l = 1 TO n
  1592.    34610 x = x + x1: q = INT(x + 0.5): IF (q < 1) OR (q > 10) THEN 34660
  1593.    34620 y = y + y1: r = INT(y + 0.5): IF (r < 1) OR (r > 10) THEN 34660
  1594.    34630 IF q$(q, r) = "." THEN 34650
  1595.    34640 q4 = 0: w = 0
  1596. 34650 NEXT l
  1597. 34660 GOSUB 15000: IF a2 <> 0 THEN RETURN
  1598. 34670 e1 = e1 - d1 * w1 * w1 * w1 * (s4 + 1): IF e1 > 0 THEN 34690
  1599. 34680 f9 = 4: GOSUB 10000: RETURN
  1600. 34690 t1 = 10 * d1 / w2: IF w <> 0 THEN GOSUB 30000
  1601. 34700 IF q4 = 0 THEN 34740
  1602. 34710 PRINT: PRINT "ENGINEERING TO BRIDGE--": PRINT "  SCOTT HERE- ";
  1603. 34715 PRINT "'WE'VE JUST BLOWN THE WARP ENGINES."
  1604. 34720 PRINT "  WE'LL HAVE TO SHUT 'ER DOWN HERE, CAPTAIN.'"
  1605. 34725 d4(6) = d5 * (3 * RND(1) + 1)
  1606. 34740 j3 = 1: RETURN
  1607. 34750 PRINT "WARP ENGINES DAMAGED.": RETURN
  1608. 35000 REM - ABANDON
  1609. 35001 ON SGN(d4(10)) + 2 GOTO 35010, 35030, 35020
  1610. 35010 PRINT "YE FAERIE QUEENE HAS NO SHUTTLE CRAFT.": RETURN
  1611. 35020 PRINT "SHUTTLE CRAFT DAMAGED.": RETURN
  1612. 35030 PRINT: PRINT "***ABANDON SHIP! ABANDON SHIP!"
  1613. 35040 PRINT "***ALL HANDS ABANDON SHIP!": PRINT
  1614. 35050 PRINT "YOU AND THE BRIDGE CREW ESCAPE IN THE GALILEO."
  1615. 35060 PRINT "THE REMAINDER OF THE CREW BEAMS DOWN"
  1616. 35070 PRINT "TO THE NEAREST HABITABLE PLANET.": IF r3 <> 0 THEN 35090
  1617. 35080 f9 = 9: GOSUB 10000: RETURN
  1618. 35090 PRINT: PRINT "YOU ARE CAPTURED BY KLINGONS AND RELEASED TO "
  1619. 35100 PRINT "THE FEDERATION IN A PRISONER-OF-WAR EXCHANGE."
  1620. 35110 PRINT "STARFLEET PUTS YOU IN COMMAND OF ANOTHER SHIP,"
  1621. 35120 PRINT "THE FAERIE QUEENE WHICH IS ANTIQUATED, BUT"
  1622. 35130 PRINT "STILL USABLE.": n = INT(RND(1) * r3 + 1): q1 = b2(n): q2 = b3(n)
  1623. 35140 s6 = 5: s7 = 5: GOSUB 18000: q$(s6, s7) = "."
  1624. 35145 FOR l = 1 TO 3: s6 = INT(3 * RND(1) - 1 + b6)
  1625.    35150 IF (s6 < 1) OR (s7 > 10) THEN 35180
  1626.    35160 s7 = INT(3 * RND(1) - 1 + b7): IF (s7 < 1) OR (s7 > 10) THEN 35180
  1627.    35170 IF q$(s6, s7) = "." THEN 35190
  1628. 35180 NEXT l: GOTO 35140
  1629. 35190 s5$ = "FAERIE QUEENE": q$(s6, s7) = LEFT$(s5$, 1): c5$ = "DOCKED"
  1630. 35200 FOR l = 1 TO 12: d4(l) = 0: NEXT: d4(10) = -1: e1 = 3000: i7 = e1
  1631. 35210 s3 = 1500: i8 = s3: t4 = 6: i9 = t4: l1 = 3: j1 = l1: s4 = 0: w1 = 5: w2 = 25
  1632. 35220 RETURN
  1633. 36000 REM - DESTRUCT
  1634. 36001 IF d4(11) = 0 THEN 36030
  1635. 36010 PRINT "COMPUTER DAMAGED - CANNOT EXECUTE DESTRUCT SEQUENCE"
  1636. 36020 RETURN
  1637. 36030 PRINT: PRINT "  ---WORKING---"
  1638. 36040 PRINT "IDENTIFICATION-POSITIVE"
  1639. 36050 PRINT "SELF-DESTRUCT-SEQUENCE-ACTIVATED": j = 3
  1640. 36060 FOR i = 10 TO 6 STEP -1: PRINT spc$(j); i: GOSUB 36210: j = j + 3: NEXT
  1641. 36070 PRINT "ENTER-YOUR-MISSION-PASSWORD-TO -CONTINUE"
  1642. 36080 PRINT "SELF-DESTRUCT-SEQUENCE-OTHERWISE-DESTRUCT"
  1643. 36090 PRINT "SEQUENCE-WILL-BE-ABORTED"
  1644. 36100 INPUT b$: IF b$ <> x$ THEN 36190
  1645. 36110 PRINT "PASSWORD-ACCEPTED": j = 10
  1646. 36120 FOR i = 5 TO 1 STEP -1: PRINT spc$(j); i: GOSUB 36210: j = j + 3: NEXT
  1647. 36130 PRINT: PRINT "*****ENTROPY OF "; s5$; " MAXIMIZED*****"
  1648. 36140 PRINT: IF k3 = 0 THEN 36180
  1649. 36150 w = 20 * e1: FOR l = 1 TO k3: IF k6(l) * k7(l) > w THEN 36170
  1650.    36160 a5 = k4(l): a6 = k5(l): t2$ = q$(a5, a6): GOSUB 6000
  1651. 36170 NEXT l
  1652. 36180 f9 = 10: GOSUB 10000: RETURN
  1653. 36190 PRINT "PASSWORD-REJECTED"
  1654. 36200 PRINT "CONTINUITY-EFFECTED": PRINT: RETURN
  1655. 36210 k = 12345: FOR m = 1 TO 90: k = k + 1: NEXT m: RETURN
  1656. 37000 REM - STATUS
  1657. 37001 i = 1: GOTO 29040:
  1658. 37010 REM bye
  1659. 37020 END
  1660. 40000 REM rhn fixup
  1661. 40010 REM filling spc$ with spaces
  1662. 40020 FOR j = 1 TO 40: spc$(j) = ""
  1663. 40030 FOR i = 1 TO j: spc$(j) = spc$(j) + " ": NEXT i: NEXT j
  1664. 40900 RETURN
  1665. 99999 END
  1666.  
  1667. ' The auxiliary functions.
  1668.  
  1669. FUNCTION FNA (X): FNA = INT(8 * RND(X)) + 1: END FUNCTION: FUNCTION FNB (X): FNB = INT(10 * RND(X)) + 1: END FUNCTION
  1670. FUNCTION FND (X): FND = X / 60: END FUNCTION
  1671. FUNCTION FNR (X): FNR = INT(X * 10 + .5) / 10: END FUNCTION: FUNCTION FNS (X): FNS = INT(X * 100 + .5) / 100: END FUNCTION
  1672.  
  1673.  
  1674.  
  1675.  
  1676.  



Offline anttiylikoski

  • Newbie
  • Posts: 25
    • View Profile
Re: The author's collection of QB64 demos
« Reply #7 on: March 01, 2020, 11:28:57 am »
The intellectual MasterMind game.

Immaterial rights ==> Dave Ahl.

Code: QB64: [Select]
  1.  
  2.  
  3. 2 PRINT TAB(30);"MASTERMIND"
  4. 4 PRINT TAB(15);"CREATIVE COMPUTING  MORRISTOWN, NEW JERSEY"
  5. 10 REM
  6. 20 REM     MASTERMIND II
  7. 30 REM     STEVE NORTH
  8. 40 REM     CREATIVE COMPUTING
  9. 50 REM     PO BOX 789-M MORRISTOWN NEW JERSEY 07960
  10. 60 REM
  11. 70 REM
  12. 80 INPUT "NUMBER OF COLORS";C9
  13. 90 IF C9>8 THEN PRINT "NO MORE THAN 8, PLEASE!":GOTO 80
  14. 100 INPUT "NUMBER OF POSITIONS";P9
  15. 110 INPUT "NUMBER OF ROUNDS";R9
  16. 120 P=C9^P9
  17. 130 PRINT "TOTAL POSSIBILITIES =";P
  18. 140 H=0:C=0
  19. 150 DIM Q(P9),S(10,2),S$(10),A$(P9),G$(P9),I(P),H$(P9)
  20. 160 L$="BWRGOYPT"
  21. 170 PRINT
  22. 180 PRINT
  23. 190 PRINT "COLOR     LETTER"
  24. 200 PRINT "=====     ======"
  25. 210 FOR X=1 TO C9
  26. 220 READ X$
  27. 230 PRINT X$;TAB(13);MID$(L$,X,1)
  28. 240 NEXT X
  29. 250 PRINT
  30. 260 FOR R=1 TO R9
  31. 270 PRINT
  32. 280 PRINT "ROUND NUMBER";R;"----"
  33. 290 PRINT
  34. 300 PRINT "GUESS MY COMBINATION.":PRINT
  35. 310 REM     GET A COMBINATION
  36. 320 A=INT(P*RND(1)+1)
  37. 330 GOSUB 3000
  38. 340 FOR X=1 TO A
  39. 350 GOSUB 3500
  40. 360 NEXT X
  41. 370 FOR M=1 TO 10
  42. 380 PRINT "MOVE # ";M;" GUESS ";:INPUT X$
  43. 390 IF X$="BOARD" THEN 2000
  44. 400 IF X$="QUIT" THEN 2500
  45. 410 IF LEN(X$)<>P9 THEN PRINT "BAD NUMBER OF POSITIONS.":GOTO 380
  46. 420 REM     UNPACK X$ INTO G$(1-P9)
  47. 430 FOR X=1 TO P9
  48. 440 FOR Y=1 TO C9
  49. 450 IF MID$(X$,X,1)=MID$(L$,Y,1) THEN 480
  50. 460 NEXT Y
  51. 470 PRINT "'"; MID$(X$,X,1); "' IS UNRECOGNIZED.":GOTO 380
  52. 480 G$(X)=MID$(X$,X,1)
  53. 490 NEXT X
  54. 500 REM     NOW WE CONVERT Q(1-P9) INTO A$(1-P9) [ACTUAL GUESS]
  55. 510 GOSUB 4000
  56. 520 REM     AND GET NUMBER OF BLACKS AND WHITES
  57. 530 GOSUB 4500
  58. 540 IF B=P9 THEN 630
  59. 550 REM     TELL HUMAN RESULTS
  60. 560 PRINT "YOU HAVE ";B;" BLACKS AND ";W;" WHITES."
  61. 570 REM     SAVE ALL THIS STUFF FOR BOARD PRINTOUT LATER
  62. 580 S$(M)=X$
  63. 590 S(M,1)=B
  64. 600 S(M,2)=W
  65. 610 NEXT M
  66. 620 PRINT "YOU RAN OUT OF MOVES!  THAT'S ALL YOU GET!":GOTO 640
  67. 622 GOSUB 4000
  68. 623 PRINT "THE ACTUAL COMBINATION WAS: ";
  69. 624 FOR X=1 TO P9
  70. 625 PRINT A$(X);
  71. 626 NEXT X
  72. 627 PRINT
  73. 630 PRINT "YOU GUESSED IT IN ";M;" MOVES!"
  74. 640 H=H+M
  75. 650 GOSUB 5000
  76. 660 REM
  77. 670 REM     NOW COMPUTER GUESSES
  78. 680 REM
  79. 690 FOR X=1 TO P
  80. 700 I(X)=1
  81. 710 NEXT X
  82. 720 PRINT "NOW I GUESS.  THINK OF A COMBINATION."
  83. 730 INPUT "HIT RETURN WHEN READY:";X$
  84. 740 FOR M=1 TO 10
  85. 750 GOSUB 3000
  86. 760 REM     FIND A GUESS
  87. 770 G=INT(P*RND(1)+1)
  88. 780 IF I(G)=1 THEN 890
  89. 790 FOR X=G TO P
  90. 800 IF I(X)=1 THEN 880
  91. 810 NEXT X
  92. 820 FOR X=1 TO G
  93. 830 IF I(X)=1 THEN 880
  94. 840 NEXT X
  95. 850 PRINT "YOU HAVE GIVEN ME INCONSISTENT INFORMATION."
  96. 860 PRINT "TRY AGAIN, AND THIS TIME PLEASE BE MORE CAREFUL."
  97. 870 GOTO 660
  98. 880 G=X
  99. 890 REM     NOW WE CONVERT GUESS #G INTO G$
  100. 900 FOR X=1 TO G
  101. 910 GOSUB 3500
  102. 920 NEXT X
  103. 930 GOSUB 6000
  104. 940 PRINT "MY GUESS IS: ";
  105. 950 FOR X=1 TO P9
  106. 960 PRINT H$(X);
  107. 970 NEXT X
  108. 980 INPUT "  BLACKS, WHITES ";B1,W1
  109. 990 IF B1=P9 THEN 1120
  110. 1000 GOSUB 3000
  111. 1010 FOR X=1 TO P
  112. 1020 GOSUB 3500
  113. 1030 IF I(X)=0 THEN 1070
  114. 1035 GOSUB 6500
  115. 1040 GOSUB 4000
  116. 1050 GOSUB 4500
  117. 1060 IF B1<>B OR W1<>W THEN I(X)=0
  118. 1070 NEXT X
  119. 1080 NEXT M
  120. 1090 PRINT "I USED UP ALL MY MOVES!"
  121. 1100 PRINT "I GUESS MY CPU IS JUST HAVING AN OFF DAY."
  122. 1110 GOTO 1130
  123. 1120 PRINT "I GOT IT IN ";M;" MOVES!"
  124. 1130 C=C+M
  125. 1140 GOSUB 5000
  126. 1150 NEXT R
  127. 1160 PRINT "GAME OVER"
  128. 1170 PRINT "FINAL SCORE:"
  129. 1180 GOSUB 5040
  130. 1190 STOP
  131. 2000 REM
  132. 2010 REM     BOARD PRINTOUT ROUTINE
  133. 2020 REM
  134. 2025 PRINT
  135. 2030 PRINT "BOARD"
  136. 2040 PRINT "MOVE     GUESS          BLACK     WHITE"
  137. 2050 FOR Z=1 TO M-1
  138. 2060 PRINT Z;TAB(9);S$(Z);TAB(25);S(Z,1);TAB(35);S(Z,2)
  139. 2070 NEXT Z
  140. 2075 PRINT
  141. 2080 GOTO 380
  142. 2500 REM
  143. 2510 REM     QUIT ROUTINE
  144. 2520 REM
  145. 2530 PRINT "QUITTER!  MY COMBINATION WAS: ";
  146. 2535 GOSUB 4000
  147. 2540 FOR X=1 TO P9
  148. 2550 PRINT A$(X);
  149. 2560 NEXT X
  150. 2565 PRINT
  151. 2570 PRINT "GOOD BYE"
  152. 2580 STOP
  153. 3000 REM
  154. 3010 REM     INITIALIZE Q(1-P9) TO ZEROS
  155. 3020 REM
  156. 3030 FOR S=1 TO P9
  157. 3040 Q(S)=0
  158. 3050 NEXT S
  159. 3060 RETURN
  160. 3500 REM
  161. 3510 REM     INCREMENT Q(1-P9)
  162. 3520 REM
  163. 3522 IF Q(1)>0 THEN 3530
  164. 3524 REM  IF ZERO, THIS IS OUR FIRST INCREMENT: MAKE ALL ONES
  165. 3526 FOR S=1 TO P9
  166. 3527 Q(S)=1
  167. 3528 NEXT S
  168. 3529 RETURN
  169. 3530 Q=1
  170. 3540 Q(Q)=Q(Q)+1
  171. 3550 IF Q(Q)<=C9 THEN RETURN
  172. 3560 Q(Q)=1
  173. 3570 Q=Q+1
  174. 3580 GOTO 3540
  175. 4000 REM
  176. 4010 REM     CONVERT Q(1-P9) TO A$(1-P9)
  177. 4020 REM
  178. 4030 FOR S=1 TO P9
  179. 4040 A$(S)=MID$(L$,Q(S),1)
  180. 4050 NEXT S
  181. 4060 RETURN
  182. 4500 REM
  183. 4510 REM     GET NUMBER OF BLACKS (B) AND WHITES (W)
  184. 4520 REM     MASHES G$ AND A$ IN THE PROCESS
  185. 4530 REM
  186. 4540 B=0:W=0:F=0
  187. 4550 FOR S=1 TO P9
  188. 4560 IF G$(S)<>A$(S) THEN 4620
  189. 4570 B=B+1
  190. 4580 G$(S)=CHR$(F)
  191. 4590 A$(S)=CHR$(F+1)
  192. 4600 F=F+2
  193. 4610 GOTO 4660
  194. 4620 FOR T=1 TO P9
  195. 4630 IF G$(S)<>A$(T) THEN 4650
  196. 4640 IF G$(T)=A$(T) THEN 4650
  197. 4645 W=W+1:A$(T)=CHR$(F):G$(S)=CHR$(F+1):F=F+2:GOTO 4660
  198. 4650 NEXT T
  199. 4660 NEXT S
  200. 4670 RETURN
  201. 5000 REM
  202. 5010 REM     PRINT SCORE
  203. 5020 REM
  204. 5030 PRINT "SCORE:"
  205. 5040 PRINT "     COMPUTER ";C
  206. 5050 PRINT "     HUMAN    ";H
  207. 5060 PRINT
  208. 5070 RETURN
  209. 5500 REM
  210. 5510 REM     CONVERT Q(1-P9) INTO G$(1-P9)
  211. 5520 REM
  212. 5530 FOR S=1 TO P9
  213. 5540 G$(S)=MID$(L$,Q(S),1)
  214. 5550 NEXT S
  215. 5560 RETURN
  216. 6000 REM
  217. 6010 REM     CONVERT Q(1-P9) TO H$(1-P9)
  218. 6020 REM
  219. 6030 FOR S=1 TO P9
  220. 6040 H$(S)=MID$(L$,Q(S),1)
  221. 6050 NEXT S
  222. 6060 RETURN
  223. 6500 REM
  224. 6510 REM     COPY H$ INTO G$
  225. 6520 REM
  226. 6530 FOR S=1 TO P9
  227. 6540 G$(S)=H$(S)
  228. 6550 NEXT S
  229. 6560 RETURN
  230. 8000 REM     PROGRAM DATA FOR COLOR NAMES
  231. 8010 DATA BLACK,WHITE,RED,GREEN,ORANGE,YELLOW,PURPLE,TAN
  232. 9998 REM   ...WE'RE SORRY BUT IT'S TIME TO GO...
  233. 9999 END
  234.  
  235.  
  236.  
  237.  
  238.  
  239.  



Offline anttiylikoski

  • Newbie
  • Posts: 25
    • View Profile
Re: The author's collection of QB64 demos
« Reply #8 on: March 01, 2020, 11:32:55 am »
The 3D ticTacToe.

Fixed by the author.

This is a scientific citation ==> the immaterial rights ==> Dave Ahl.


Code: QB64: [Select]
  1.  
  2.  
  3. 50 PRINT CHR$(26): REM WIDTH 80
  4. 100 PRINT TAB(33); "QUBIC": PRINT
  5. 110 PRINT TAB(15); "CREATIVE COMPUTING  MORRISTOWN, NEW JERSEY"
  6. 210 PRINT "DO YOU WANT INSTRUCTIONS";
  7. 220 INPUT C$
  8. 230 IF LEFT$(C$, 1) = "N" THEN 315
  9. 240 IF LEFT$(C$, 1) = "Y" THEN 265
  10. 250 PRINT "INCORRECT ANSWER.  PLEASE TYPE 'YES' OR 'NO'";
  11. 260 GOTO 220
  12. 265 PRINT
  13. 270 PRINT "THE GAME IS TIC-TAC-TOE IN A 4 X 4 X 4 CUBE."
  14. 280 PRINT "EACH MOVE IS INDICATED BY A 3 DIGIT NUMBER, WITH EACH"
  15. 290 PRINT "DIGIT BETWEEN 1 AND 4 INCLUSIVE.  THE DIGITS INDICATE THE"
  16. 300 PRINT "LEVEL, ROW, AND COLUMN, RESPECTIVELY, OF THE OCCUPIED"
  17. 305 PRINT "PLACE.  "
  18. 306 PRINT
  19. 307 PRINT "TO PRINT THE PLAYING BOARD, TYPE 0 (ZERO) AS YOUR MOVE."
  20. 308 PRINT "THE PROGRAM WILL PRINT THE BOARD WITH YOUR MOVES INDI-"
  21. 309 PRINT "CATED WITH A (Y), THE MACHINE'S MOVES WITH AN (M), AND"
  22. 310 PRINT "UNUSED SQUARES WITH A ( ).  OUTPUT IS ON PAPER."
  23. 311 PRINT
  24. 312 PRINT "TO STOP THE PROGRAM RUN, TYPE 1 AS YOUR MOVE."
  25. 315 DIM X(64), L(76), M(76, 4), Y(16)
  26. 320 FOR I = 1 TO 16
  27.    330 READ Y(I)
  28. 340 NEXT I
  29. 350 FOR I = 1 TO 76
  30.    360 FOR J = 1 TO 4
  31.        370 READ M(I, J)
  32.    380 NEXT J
  33. 390 NEXT I
  34. 400 FOR I = 1 TO 64
  35.    410 LET X(I) = 0
  36. 420 NEXT I
  37. 430 LET Z = 1
  38. 440 PRINT "DO YOU WANT TO MOVE FIRST";
  39. 450 INPUT S$
  40. 460 IF LEFT$(S$, 1) = "N" THEN 630
  41. 470 IF LEFT$(S$, 1) = "Y" THEN 500
  42. 480 PRINT "INCORRECT ANSWER.  PLEASE TYPE 'YES' OR 'NO'.";
  43. 490 GOTO 450
  44. 500 PRINT " "
  45. 510 PRINT "YOUR MOVE";
  46. 520 INPUT J1
  47. 521 IF J1 = 1 THEN 2770
  48. 522 IF J1 <> 0 THEN 525
  49. 523 GOSUB 2550
  50. 524 GOTO 500
  51. 525 IF J1 < 111 THEN 2750
  52. 526 IF J1 > 444 THEN 2750
  53. 530 GOSUB 2500
  54. 540 LET K1 = INT(J1 / 100)
  55. 550 LET J2 = (J1 - K1 * 100)
  56. 560 LET K2 = INT(J2 / 10)
  57. 570 LET K3 = J1 - K1 * 100 - K2 * 10
  58. 580 LET M = 16 * K1 + 4 * K2 + K3 - 20
  59. 590 IF X(M) = 0 THEN 620
  60. 600 PRINT "THAT SQUARE IS USED, TRY AGAIN."
  61. 610 GOTO 500
  62. 620 LET X(M) = 1
  63. 630 GOSUB 1640
  64. 640 J = 1
  65. 650 I = 1
  66. 660 IF J = 1 THEN 720
  67. 670 IF J = 2 THEN 790
  68. 680 IF J = 3 THEN 930
  69. 690 I = I + 1: IF I <= 76 THEN 660
  70. 700 J = J + 1: IF J <= 3 THEN 650
  71. 710 GOTO 1300
  72. 720 IF L(I) <> 4 THEN 690
  73. 730 PRINT "YOU WIN AS FOLLOWS";
  74. 740 FOR J = 1 TO 4
  75.    750 LET M = M(I, J)
  76.    760 GOSUB 1570
  77. 770 NEXT J
  78. 780 GOTO 1490
  79. 790 IF L(I) <> 15 THEN 690
  80. 800 FOR J = 1 TO 4
  81.    810 LET M = M(I, J)
  82.    820 IF X(M) <> 0 THEN 860
  83.    830 LET X(M) = 5
  84.    840 PRINT "MACHINE MOVES TO";
  85.    850 GOSUB 1570
  86. 860 NEXT J
  87. 870 PRINT ", AND WINS AS FOLLOWS"
  88. 880 FOR J = 1 TO 4
  89.    890 LET M = M(I, J)
  90.    900 GOSUB 1570
  91. 910 NEXT J
  92. 920 GOTO 1490
  93. 930 IF L(I) <> 3 THEN 690
  94. 940 PRINT "NICE TRY. MACHINE MOVES TO";
  95. 950 FOR J = 1 TO 4
  96.    960 LET M = M(I, J)
  97.    970 IF X(M) <> 0 THEN 1010
  98.    980 LET X(M) = 5
  99.    990 GOSUB 1570
  100.    1000 GOTO 500
  101. 1010 NEXT J
  102. 1020 GOTO 1300
  103. 1030 I = 1
  104. 1040 LET L(I) = X(M(I, 1)) + X(M(I, 2)) + X(M(I, 3)) + X(M(I, 4))
  105. 1050 LET L = L(I)
  106. 1060 IF L < 2 THEN 1130
  107. 1070 IF L >= 3 THEN 1130
  108. 1080 IF L > 2 THEN 2230
  109. 1090 FOR J = 1 TO 4
  110.    1100 IF X(M(I, J)) <> 0 THEN 1120
  111.    1110 LET X(M(I, J)) = 1 / 8
  112. 1120 NEXT J
  113. 1130 I = I + 1: IF I <= 76 THEN 1040
  114. 1140 GOSUB 1640
  115. 1150 I = 1
  116. 1160 IF L(I) = 1 / 2 THEN 2360
  117. 1170 IF L(I) = 1 + 3 / 8 THEN 2360
  118. 1180 I = I + 1: IF I <= 76 THEN 1160
  119. 1190 GOTO 1830
  120. 1200 LET Z = 1
  121. 1210 IF X(Y(Z)) = 0 THEN 1250
  122. 1220 LET Z = Z + 1
  123. 1230 IF Z <> 17 THEN 1210
  124. 1240 GOTO 1720
  125. 1250 LET M = Y(Z)
  126. 1260 LET X(M) = 5
  127. 1270 PRINT "MACHINE MOVES TO";
  128. 1280 GOSUB 1570
  129. 1290 GOTO 500
  130. 1300 LET X = X
  131. 1310 I = 1
  132. 1320 LET L(I) = X(M(I, 1)) + X(M(I, 2)) + X(M(I, 3)) + X(M(I, 4))
  133. 1330 LET L = L(I)
  134. 1340 IF L < 10 THEN 1410
  135. 1350 IF L >= 11 THEN 1410
  136. 1360 IF L > 10 THEN 2230
  137. 1370 FOR J = 1 TO 4
  138.    1380 IF X(M(I, J)) <> 0 THEN 1400
  139.    1390 LET X(M(I, J)) = 1 / 8
  140. 1400 NEXT J
  141. 1410 I = I + 1: IF I <= 76 THEN 1320
  142. 1420 GOSUB 1640
  143. 1430 I = 1
  144. 1440 IF L(I) = .5 THEN 2360
  145. 1450 IF L(I) = 5 + 3 / 8 THEN 2360
  146. 1460 I = I + 1: IF I <= 76 THEN 1440
  147. 1470 GOSUB 2500
  148. 1480 GOTO 1030
  149. 1490 PRINT " "
  150. 1500 PRINT "DO YOU WANT TO TRY ANOTHER GAME";
  151. 1510 INPUT X$
  152. 1520 IF LEFT$(X$, 1) = "Y" THEN 400
  153. 1530 IF LEFT$(X$, 1) = "N" THEN 1560
  154. 1540 PRINT "INCORRECT ANSWER. PLEASE TYPE 'YES' OR 'NO'";
  155. 1550 GOTO 1510
  156. 1560 END
  157. 1570 LET K1 = INT((M - 1) / 16) + 1
  158. 1580 LET J2 = M - 16 * (K1 - 1)
  159. 1590 LET K2 = INT((J2 - 1) / 4) + 1
  160. 1600 LET K3 = M - (K1 - 1) * 16 - (K2 - 1) * 4
  161. 1610 LET M = K1 * 100 + K2 * 10 + K3
  162. 1620 PRINT M;
  163. 1630 RETURN
  164. 1640 FOR S = 1 TO 76
  165.    1650 LET J1 = M(S, 1)
  166.    1660 LET J2 = M(S, 2)
  167.    1670 LET J3 = M(S, 3)
  168.    1680 LET J4 = M(S, 4)
  169.    1690 LET L(S) = X(J1) + X(J2) + X(J3) + X(J4)
  170. 1700 NEXT S
  171. 1710 RETURN
  172. 1720 FOR I = 1 TO 64
  173.    1730 IF X(I) <> 0 THEN 1800
  174.    1740 LET X(I) = 5
  175.    1750 LET M = I
  176.    1760 PRINT "MACHINE LIKES";
  177.    1770 GOSUB 1570
  178.    1780 PRINT " "
  179.    1790 GOTO 500
  180. 1800 NEXT I
  181. 1810 PRINT "THE GAME IS A DRAW."
  182. 1820 GOTO 1490
  183. 1830 FOR K = 1 TO 18
  184.    1840 LET P = 0
  185.    1850 FOR I = 4 * K - 3 TO 4 * K
  186.        1860 FOR J = 1 TO 4
  187.            1870 LET P = P + X(M(I, J))
  188.        1880 NEXT J
  189.    1890 NEXT I
  190.    1900 IF P < 4 THEN 1940
  191.    1910 IF P < 5 THEN 1970
  192.    1920 IF P < 9 THEN 1940
  193.    1930 IF P < 10 THEN 1970
  194. 1940 NEXT K
  195. 1950 GOSUB 2500
  196. 1960 GOTO 1200
  197. 1970 LET S = 1 / 8
  198. 1980 FOR I = 4 * K - 3 TO 4 * K
  199.    1990 GOTO 2370
  200. 2000 NEXT I
  201. 2010 LET S = 0
  202. 2020 GOTO 1980
  203. 2030 DATA 1,49,52,4,13,61,64,16,22,39,23,38,26,42,27,43
  204. 2040 DATA 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20
  205. 2050 DATA 21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38
  206. 2060 DATA 39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56
  207. 2070 DATA 57,58,59,60,61,62,63,64
  208. 2080 DATA 1,17,33,49,5,21,37,53,9,25,41,57,13,29,45,61
  209. 2090 DATA 2,18,34,50,6,22,38,54,10,26,42,58,14,30,46,62
  210. 2100 DATA 3,19,35,51,7,23,39,55,11,27,43,59,15,31,47,63
  211. 2110 DATA 4,20,36,52,8,24,40,56,12,28,44,60,16,32,48,64
  212. 2120 DATA 1,5,9,13,17,21,25,29,33,37,41,45,49,53,57,61
  213. 2130 DATA 2,6,10,14,18,22,26,30,34,38,42,46,50,54,58,62
  214. 2140 DATA 3,7,11,15,19,23,27,31,35,39,43,47,51,55,59,63
  215. 2150 DATA 4,8,12,16,20,24,28,32,36,40,44,48,52,56,60,64
  216. 2160 DATA 1,6,11,16,17,22,27,32,33,38,43,48,49,54,59,64
  217. 2170 DATA 13,10,7,4,29,26,23,20,45,42,39,36,61,58,55,52
  218. 2180 DATA 1,21,41,61,2,22,42,62,3,23,43,63,4,24,44,64
  219. 2190 DATA 49,37,25,13,50,38,26,14,51,39,27,15,52,40,28,16
  220. 2200 DATA 1,18,35,52,5,22,39,56,9,26,43,60,13,30,47,64
  221. 2210 DATA 49,34,19,4,53,38,23,8,57,42,27,12,61,46,31,16
  222. 2220 DATA 1,22,43,64,16,27,38,49,4,23,42,61,13,26,39,52
  223. 2230 FOR J = 1 TO 4
  224.    2240 IF X(M(I, J)) <> 1 / 8 THEN 2330
  225.    2250 LET X(M(I, J)) = 5
  226.    2260 IF L(I) < 5 THEN 2290
  227.    2270 PRINT "LET'S SEE YOU GET OUT OF THIS:  MACHINE MOVES TO";
  228.    2280 GOTO 2300
  229.    2290 PRINT "YOU FOX.  JUST IN THE NICK OF TIME, MACHINE MOVES TO";
  230.    2300 LET M = M(I, J)
  231.    2310 GOSUB 1570
  232.    2320 GOTO 500
  233. 2330 NEXT J
  234. 2340 PRINT "MACHINE CONCEDES THIS GAME."
  235. 2350 GOTO 1490
  236. 2360 LET S = 1 / 8
  237. 2370 IF I - INT(I / 4) * 4 > 1 THEN 2400
  238. 2380 LET A = 1
  239. 2390 GOTO 2410
  240. 2400 LET A = 2
  241. 2410 FOR J = A TO 5 - A STEP 5 - 2 * A
  242.    2420 IF X(M(I, J)) = S THEN 2450
  243. 2430 NEXT J
  244. 2440 GOTO 2000
  245. 2450 LET X(M(I, J)) = 5
  246. 2460 LET M = M(I, J)
  247. 2470 PRINT "MACHINE TAKES";
  248. 2480 GOSUB 1570
  249. 2490 GOTO 500
  250. 2500 FOR I = 1 TO 64
  251.    2510 IF X(I) <> 1 / 8 THEN 2530
  252.    2520 LET X(I) = 0
  253. 2530 NEXT I
  254. 2540 RETURN
  255. 2550 FOR XX = 1 TO 1: NEXT: FOR I = 1 TO 4
  256.    2560 FOR J = 1 TO 4
  257.        2562 FOR I1 = 1 TO J
  258.            2564 PRINT "   ";
  259.        2566 NEXT I1
  260.        2570 FOR K = 1 TO 4
  261.            2600 LET Q = 16 * I + 4 * J + K - 20
  262.            2610 IF X(Q) <> O THEN 2630
  263.            2620 PRINT "( ) ";
  264.            2630 IF X(Q) <> 5 THEN 2650
  265.            2640 PRINT "(M) ";
  266.            2650 IF X(Q) <> 1 THEN 2660
  267.            2655 PRINT "(Y) ";
  268.            2660 IF X(Q) <> 1 / 8 THEN 2670
  269.            2665 PRINT "( ) ";
  270.        2670 NEXT K
  271.        2680 REM: PRINT
  272.        2690 PRINT
  273.    2700 NEXT J
  274.    2710 REM: PRINT
  275.    2720 REM: PRINT
  276. 2730 NEXT I
  277. 2735 REM PRINT CHR$(12)
  278. 2740 RETURN
  279. 2750 PRINT "INCORRECT MOVE, RETYPE IT--";
  280. 2760 GOTO 520
  281. 2770 END
  282.  
  283.  
  284.  
  285.  
  286.  



Offline anttiylikoski

  • Newbie
  • Posts: 25
    • View Profile
Re: The author's collection of QB64 demos
« Reply #9 on: March 01, 2020, 11:36:17 am »
The adaptive Simpson integral.

Useful in a commercial business, therefore here.

Code: QB64: [Select]
  1.  
  2.  
  3. ' THE ADAPTIVE SIMPSON INTEGRAL
  4. '
  5. ' ANTTI YLIKOSKI 2017-03-09 MIKROBITTI-LEHDELLE
  6. '
  7.  
  8.  
  9.  
  10. PRINT "ADAPTIVE SIMPSON INTEGRAL = ", ADSIM1(1.0, 2.0, 0.0000000001)
  11. PRINT "THE EXACT VALUE LN(2)     = ", LOG(2.0)
  12. PRINT "THE VALUE OF EPSILON      = ", 0.0000000001
  13.  
  14.  
  15.  
  16. FUNCTION F (X) ' THE FUNCTION TO BE INTEGRATED = F()
  17. F = 1 / X
  18.  
  19.  
  20. FUNCTION SIMPSON1 (AB, BB)
  21.  
  22.  
  23. C = (AB + BB) / 2.0
  24. H3 = ABS(BB - AB) / 6.0
  25. SIMPSON1 = H3 * (F(AB) + 4.0 * F(C) + F(BB))
  26.  
  27.  
  28. FUNCTION REC_ASR (AB, BB, EPS, W)
  29.  
  30.  
  31. C = (AB + BB) / 2.0
  32.  
  33. DIM RIGHT AS DOUBLE
  34.  
  35. LEFT = SIMPSON1(AB, C)
  36. RIGHT = SIMPSON1(C, BB)
  37.  
  38. IF (ABS(LEFT + RIGHT - W) <= 15.0 * EPS) THEN
  39.     REC_ASR = LEFT + RIGHT + (LEFT + RIGHT - W) / 15.0
  40.  
  41. REC_ASR = REC_ASR(AB, C, EPS / 2.0, LEFT) + REC_ASR(C, BB, EPS / 2.0, RIGHT)
  42.  
  43.  
  44.  
  45. FUNCTION ADSIM1 (AB, BB, EPS)
  46. ADSIM1 = REC_ASR(AB, BB, EPS, SIMPSON1(AB, BB))
  47.  
  48.  
  49.  
  50.  
  51.  
  52.  


Offline _vince

  • Seasoned Forum Regular
  • Posts: 422
    • View Profile
Re: The author's collection of QB64 demos
« Reply #10 on: March 02, 2020, 12:02:27 am »
and I think it would be farsighted
to post topicstarter one program in this topic weekly

I wonder if this will keep bumping the topic to the top or is there a time limit

Offline anttiylikoski

  • Newbie
  • Posts: 25
    • View Profile
Re: The author's collection of QB64 demos
« Reply #11 on: March 03, 2020, 11:23:57 am »
Its considered bad manners to flood the www meeting.

cheers, AJY
Europe


Offline anttiylikoski

  • Newbie
  • Posts: 25
    • View Profile
Re: The author's collection of QB64 demos
« Reply #12 on: March 09, 2020, 06:29:54 am »
The GitHub.com are well-known:

1. Get the git program.

2. Get the Command Interpreter

3. Execute git clone https://github.com/bluejay77/QB64-demo

4. Enjoy


Offline anttiylikoski

  • Newbie
  • Posts: 25
    • View Profile
Re: The author's collection of QB64 demos
« Reply #13 on: March 09, 2020, 06:39:54 am »
The world-famous Interlisp-D:

Is a FORTRAN ==> QB64 port possible?   And, this one exists in the C language.

https://github.com/blakemcbride/LISPF4

The reputable Interlisp-D for the QB64?   It is doable, but will someone(s) have the time to do such a project?