1 rem From: https://groups.io/g/ET-3400/topic/88950752#2212
10 rem do
20 input "Do you want a difficult game (y or n)? ", a
40 y = 2999
50 if a = 121 y = 999
60 print "Stardate 3200: your mission is",
70 rem do
80 k = 0
90 b = 0
100 d = 30
110 i = 0
120 rem do
130 if i > 63 goto 220
140 j = (rnd(99) + 1) < 5
150 b = b + j
160 m = rnd(y) + 1
170 m = (m < 209) + (m < 99) + (m < 49) + (m < 24) + (m < 9) + (m < 2)
180 k = k + m
190 @(i) = -100 * m - 10 * j - rnd(8) - 1
200 i = i + 1
210 goto 120
220 rem loop
230 if (b < 2) + (k < 4) goto 70
240 rem loop
250 print "to destroy", k, "klingons in 30 stardates."
260 print "There are", b, "starbases."
270 gosub 1100
280 c = 0
290 h = k
300 gosub 6270
310 gosub 6340
320 gosub 870
330 gosub 3230
340 rem do
350 rem do
360 print "r = Report       s = SR. sensor   l = LR. sensor"
370 print "g = Galaxy map   p = Phaser       t = Torpedo"
380 print "w = Warp engine  ***please use one of these commands***"
390 input "Captain? ", a
410 if a = 103 gosub 1370 rem Galaxy map
420 if a = 108 gosub 1820 rem LR sensor
430 if a = 115 gosub 2100 rem SR sensor
440 if a = 112 gosub 2510 rem Phaser
450 if a = 114 gosub 3870 rem Report
460 if a = 119 gosub 4220 rem Warp engine
470 if a = 116 gosub 5130 rem Torpedo
480 if (a = 113) + (a = 27) a = -1
490 if a > 0 goto 350
500 rem loop
510 if a = -1 goto 770
520 gosub 870
530 gosub 3230
540 if k goto 670
550 print "mission accomplished."
560 if d < 3 print "boy, you barely made it."
570 if d > 5 print "good work..."
580 if d > 9 print "fantastic!"
590 if d > 13 print "unbelievable!"
600 d = 30 - d
610 i = h * 100 / d * 10
620 print h, "klingons in", d, "stardates. (", i, ")"
630 j = 100 * (c = 0) - 5 * c
640 print c, "casualties incurred. (", j, ")"
650 print "your score:", i + j
660 goto 770
670 rem end if
680 if d >= 0 goto 710
690 print "it's too late, the federation has been conquered."
700 goto 770
710 rem end if
720 if e >= 0 goto 750
730 print "enterprise destroyed"
740 if h - k > 9 print "but you were a good man"
750 rem end if
760 goto 340
770 rem loop
780 y = 987
790 print
800 input "another game (y or n)? ", a
820 if a = 121 goto 10
830 rem loop
840 print "good bye."
850 end
860 rem
870 rem subroutine 145
880 i = x - (x > 1)
890 rem do
900 if i > x + (x < 8) goto 1010
910 j = y - (y > 1)
920 rem do
930 if j > y + (y < 8) goto 970
940 if @(8 * i + j + 62) = 2 goto 970
950 j = j + 1
960 goto 920
970 rem loop
980 if @(8 * i + j + 62) = 2 goto 1010
990 i = i + 1
1000 goto 890
1010 rem loop
1020 if @(8 * i + j + 62) = 2 goto 1050
1030 o = 0
1040 return
1050 rem end if
1060 if o = 0 print "sulu: 'captain, we are docked at starbase.'"
1070 gosub 1100
1080 return
1090 rem
1100 rem subroutine 160
1110 e = 4000
1120 f = 10
1130 o = 1
1140 i = 64
1150 rem do
1160 if  i > 70 goto 1200
1170 @(i) = 0
1180 i = i + 1
1190 goto 1150
1200 rem loop
1210 return
1220 rem
1230 rem subroutine 165
1240 rem do
1250 s = rnd(8) + 1
1260 t = rnd(8) + 1
1270 a = 8 * s + t + 62
1280 if @(a) goto 1240
1290 rem loop
1300 @(a) = i
1310 return
1320 rem
1330 rem subroutine 175
1340 print "Enterprise in q-"; u; ","; v, " s-"; x; ","; y
1350 return
1360 rem
1370 rem subroutine map
1380 a = 1
1390 gosub 1330
1400 j = 2
1410 gosub 3740
1420 if i return
1430 print "of galaxy map";
1440 i = 0
1450 rem do
1460 if i > 7 goto 1600
1470 print
1480 print i + 1; ":",
1490 j = 0
1500 rem do
1510 if j > 7 goto 1570
1520 m = @(8 * i + j)
1530 m = (m > 0) * m
1540 print m / 100; m / 10 - m / 100 * 10; m - m / 10 * 10,
1550 j = j + 1
1560 goto 1500
1570 rem loop
1580 i = i + 1
1590 goto 1450
1600 rem loop
1610 print
1620 print "  ",
1630 i = 0
1640 rem do
1650 if i > 7 goto 1690
1660 print "...",
1670 i = i + 1
1680 goto 1640
1690 rem loop
1700 print
1710 print "   ",
1720 i = 1
1730 rem do
1740 if i > 8 goto 1780
1750 print i, " ",
1760 i = i + 1
1770 goto 1730
1780 rem loop
1790 print
1800 return
1810 rem
1820 rem subroutine lr
1830 gosub 1330
1840 j = 3
1850 gosub 3740
1860 if i return
1870 print
1880 i = u - 1
1890 rem do
1900 if i > u + 1 goto 2060
1910 j = v - 1
1920 rem do
1930 if j > v + 1 goto 2020
1940 m = 8 * i + j - 9
1950 a = 0
1960 if (i > 0) * (i < 9) * (j > 0) * (j < 9) a = @(m)
1970 if a < 0 a = -a
1980 @(m) = a
1990 print a / 100; a / 10 - a / 100 * 10; a - a / 10 * 10,
2000 j = j + 1
2010 goto 1920
2020 rem loop
2030 print
2040 i = i + 1
2050 goto 1890
2060 rem loop
2070 a = 1
2080 return
2090 rem
2100 rem subroutine SR sensor
2110 a = 1
2120 gosub 1330
2130 j = 1
2140 gosub 3740
2150 if i return
2160 m = 8 * u + v - 9
2170 if @(m) < 0 @(m) = -@(m)
2180 print
2190 i = 1
2200 rem do
2210 if i > 8 goto 2390
2220 print i,
2230 j = 1
2240 rem do
2250 if j > 8 goto 2350
2260 m = @(8 * i + j + 62)
2270 if m = 0 print " .",
2280 if m = 1 print " k",
2290 if m = 2 print " b",
2300 if m = 3 print " *",
2310 if m = 4 print " e",
2320 if (m < 0) + (m > 4) print " ?",
2330 j = j + 1
2340 goto 2240
2350 rem loop
2360 print
2370 i = i + 1
2380 goto 2200
2390 rem loop
2400 print "  ",
2410 i = 1
2420 rem do
2430 if i > 8 goto 2470
2440 print i; " ",
2450 i = i + 1
2460 goto 2420
2470 rem loop
2480 print
2490 return
2500 rem
2510 rem subroutine phaser
2520 j = 4
2530 a = 1
2540 gosub 3740
2550 if i return
2560 input "Energized. Units to fire: ", a
2580 if a >= 1 goto 2610
2590 a = 1
2600 return
2610 rem end if
2620 if a <= e goto 2660
2630 print "spock: 'we have only", e, "units.'"
2640 a = 1
2650 return
2660 rem end if
2670 e = e - a
2680 if n >= 1 goto 2720
2690 print "phaser fired at empty space."
2700 a = 0
2710 return
2720 rem end if
2730 a = a / n
2740 m = 135
2750 rem do
2760 if m > 140 goto 2860
2770 if @(m) goto 2800
2780 m = m + 1
2790 goto 2750
2800 rem end if
2810 gosub 2900
2820 print s, "units hit",
2830 gosub 3030
2840 m = m + 1
2850 goto 2750
2860 rem loop
2870 a = 0
2880 return
2890 rem
2900 rem subroutine 295
2910 if a <= 1090 goto 2970
2920 print "...overloaded..."
2930 j = 4
2940 @(67) = 1
2950 a = 9
2960 gosub 3740
2970 rem end if
2980 i = @(m + 6) -  x
2990 j = @(m + 12) - y
3000 s = a * 30 / (30 + i * i + j * j) + 1
3010 return
3020 rem
3030 rem subroutine 305
3040 print "klingon at s-", @(m + 6); ","; @(m + 12),
3050 @(m) = @(m) - s
3060 if @(m) <= 0 goto 3090
3070 print "**damaged**"
3080 return
3090 rem end if
3100 @(m) = 0
3110 i = 8 * u + v - 9
3120 j = 0
3130 if @(i) > 0 j = 1
3140 if @(i) < 0 j = -1
3150 @(i) = @(i) - 100 * j
3160 k = k - 1
3170 i = 8 * @(m + 6) + @(m + 12) + 62
3180 @(i) = 0
3190 n = n - 1
3200 print "***destroyed***"
3210 return
3220 rem
3230 rem subroutine 325
3240 a = 1
3250 if n = 0 return
3260 print "klingon attack"
3270 if o = 0 goto 3300
3280 print "starbase protects enterprise"
3290 return
3300 rem end if
3310 t = 0
3320 m = 135
3330 rem do
3340 if m > 140 goto 3470
3350 if @(m) goto 3380
3360 m = m + 1
3370 goto 3330
3380 rem end if
3390 a = (@(m) + rnd(@(m)) + 1) / 2
3400 gosub 2900
3410 t = t + s
3420 i = @(m + 6)
3430 j = @(m + 12)
3440 print s, "units hit from klingon at s-", i; ","; j
3450 m = m + 1
3460 goto 3330
3470 rem loop
3480 e = e - t
3490 if e > 0 goto 3520
3500 print "*** bang ***"
3510 return
3520 rem end if
3530 print e, "units of energy left."
3540 if rnd(e / 4) + 1 > t return
3550 gosub 3590
3560 a = 1
3570 return
3580 rem
3590 rem subroutine 360
3600 if @(70) goto 3650
3610 @(70) = rnd(t / 50 + 1) + 1
3620 j = 7
3630 gosub 3740
3640 return
3650 rem end if
3660 j = rnd(6) + 1
3670 @(j + 63) = rnd(t / 99 + 1) + 1 + @(j + 63)
3680 i = rnd(8) + 2
3690 c = c + i
3700 print "mccoy: 'sickbay to bridge, we suffered", i, "casualties.'"
3710 gosub 3740
3720 return
3730 rem
3740 rem subroutine 375
3750 i = @(j + 63)
3760 if j = 1 print "short range sensor",
3770 if j = 2 print "computer display",
3780 if j = 3 print "long range sensor",
3790 if j = 4 print "phaser",
3800 if j = 5 print "warp engine",
3810 if j = 6 print "photon torpedo tubes",
3820 if j = 7 print "shield",
3830 if i = 0 return
3840 print "damaged,", i, "stardates estimated for repair"
3850 return
3860 rem
3870 rem subroutine report
3880 a = 1
3890 print "status report:"
3900 print "stardate", 3230 - d
3910 print "time left", d
3920 print "condition     ",
3930 if o = 0 goto 3960
3940 print "docked"
3950 goto 4060
3960 rem else
3970 if n = 0 goto 4000
3980 print "red"
3990 goto 4060
4000 rem else
4010 if e >= 999 goto 4040
4020 print "yellow"
4030 goto 4060
4040 rem else
4050 print "green"
4060 rem end if
4070 print "position       q-", u; ","; v, " s-", x; ","; y
4080 print "energy", e
4090 print "torpedoes", f
4100 print "klingons left", k
4110 print "starbases", b
4120 j = 1
4130 rem do
4140 if j > 7 goto 4180
4150 if @(j + 63) gosub 3740
4160 j = j + 1
4170 goto 4130
4180 rem loop
4190 a = 1
4200 return
4210 rem
4220 rem subroutine warp
4230 j = 5
4240 a = 1
4250 gosub 3740
4260 if i = 0 print
4270 rem do
4280 input "sector distance: ", w
4300 a = 1
4310 if w < 1 return
4320 if i * (w > 2) = 0 goto 4350
4330 print "chekov: 'we can try 2 at most, sir.'"
4340 goto 4270
4350 rem end if
4360 rem loop
4370 if w <= 91 goto 4400
4380 w = 91
4390 print "spock: 'are you sure, captain?'"
4400 rem end if
4410 if e >= w * w / 2 goto 4440
4420 print "scotty: 'sir, we do not have the energy.'"
4430 return
4440 rem end if
4450 gosub 5950
4460 a = 1
4470 if r = 0 return
4480 d = d - 1
4490 e = e - w * w / 2
4500 @(8 * x + y + 62) = 0
4510 m = 64
4520 rem do
4530 if m > 70 goto 4570
4540 @(m) = (@(m) - 1) * (@(m) > 0)
4550 m = m + 1
4560 goto 4520
4570 rem loop
4580 p = 45 * x + 22
4590 g = 45 * y + 22
4600 w = 45 * w
4610 m = 1
4620 rem do
4630 if m > 8 goto 4810
4640 w = w - r
4650 if w >= -22 goto 4700
4660 @(8 * x + y + 62) = 4
4670 a = 0
4680 gosub 1330
4690 return
4700 rem end if
4710 p = p + s
4720 g = g + t
4730 i = p / 45
4740 j = g / 45
4750 if (i < 1) + (i > 8) + (j < 1) + (j > 8) goto 4810
4760 if @(8 * i + j + 62) goto 4810
4770 x = i
4780 y = j
4790 m = m + 1
4800 goto 4620
4810 rem loop
4820 if @(8 * i + j + 62) = 0 goto 4890
4830 print "**emergency stop**"
4840 print "spock: 'to err is human.'"
4850 @(8 * x + y + 62) = 4
4860 gosub 1330
4870 a = 0
4880 return
4890 rem end if
4900 p = u * 72 + p / 5 + w / 5 * s / r - 9
4910 u = p / 72
4920 g = v * 72 + g / 5 + w / 5 * t / r - 9
4930 v = g / 72
4940 if rnd(9) + 1 >= 2 goto 4980
4950 print "***space storm***"
4960 t = 100
4970 gosub 3590
4980 rem end if
4990 if (u < 1) + (u > 8) + (v < 1) + (v > 8) goto 5050
5000 x = (p + 9 - 72 * u) / 9
5010 y = (g + 9 - 72 * v) / 9
5020 gosub 6340
5030 a = 1
5040 return
5050 rem end if
5060 print "**you wandered outside the galaxy**"
5070 print "on board computer takes over, and saved your life"
5080 gosub 6270
5090 gosub 6340
5100 a = 1
5110 return
5120 rem
5130 rem subroutine torpedo
5140 j = 6
5150 a = 1
5160 gosub 3740
5170 if i return
5180 if f goto 5210
5190 print "empty"
5200 return
5210 rem end if
5220 print "loaded"
5230 gosub 5950
5240 if r = 0 return
5250 print "torpedo track",
5260 f = f - 1
5270 p = 45 * x + 22
5280 g = 45 * y + 22
5290 m = 1
5300 rem do
5310 if m > 8 goto 5900
5320 p = p + s
5330 g = g + t
5340 i = p / 45
5350 j = g / 45
5360 if (i < 1) + (i > 8) + (j < 1) + (j > 8) goto 5900
5370 l = 8 * i + j + 62
5380 w = 8 * u + v - 9
5390 r = 0
5400 if @(w) > 0 r = 1
5410 if @(w) < 0 r = -1
5420 print i; ","; j, " ",
5430 a = 0
5440 if @(l) <> 0 goto 5470
5450 m = m + 1
5460 goto 5300
5470 rem end if
5480 if @(l) <> 1 goto 5590
5490 s = rnd(99) + 1 + 280
5500 m = 135
5510 rem do
5520 if m > 140 goto 5560
5530 if (@(m + 6) = i) * (@(m + 12) = j) gosub 3030
5540 m = m + 1
5550 goto 5510
5560 rem loop
5570 a = 0
5580 return
5590 rem end if
5600 if @(l) <> 2 goto 5680
5610 b = b - 1
5620 @(l) = 0
5630 @(w) = @(w) - 10 * r
5640 print "starbase destroyed"
5650 print "spock: 'i often find human behaviour fascinating.'"
5660 return
5670 a = 0
5680 rem end if
5690 if @(l) <> 3 goto 5880
5700 print "hit a star"
5710 if rnd(9) + 1 >= 3 goto 5750
5720 print "torpedo absorbed"
5730 a = 0
5740 return
5750 rem end if
5760 @(l) = 0
5770 @(w) = @(w) - r
5780 if rnd(9) + 1 >= 6 goto 5820
5790 print "star destroyed"
5800 a = 0
5810 return
5820 rem end if
5830 t = 300
5840 print "it novas ***radiation alarm***"
5850 gosub 3590
5860 a = 0
5870 return
5880 rem end if
5890 goto 5300
5900 rem loop
5910 print "...missed"
5920 a = 0
5930 return
5940 rem
5950 rem subrroutine 615
5960 input "course (0-360): ", i
5980 if (i <= 360) * (i >= 0) goto 6010
5990 r = 0
6000 return
6010 rem end if
6020 s = (i + 45) / 90
6030 i = i - s * 90
6040 r = (45 + i * i) / 110 + 45
6050 if s > 3 s = 0
6060 if s <> 0 goto 6100
6070 s = -45
6080 t = i
6090 return
6100 rem end if
6110 if s <> 1 goto 6150
6120 s = i
6130 t = 45
6140 return
6150 rem end if
6160 if s <> 2 goto 6200
6170 s = 45
6180 t = -i
6190 return
6200 rem end if
6210 if s <> 3 goto 6250
6220 s = -i
6230 t = -45
6240 return
6250 rem end if
6260 rem
6270 rem subroutine 40
6280 u = rnd(8) + 1
6290 v = rnd(8) + 1
6300 x = rnd(8) + 1
6310 y = rnd(8) + 1
6320 return
6330 rem
6340 rem subroutine 45
6350 i = 71
6360 rem do
6370 if i > 152 goto 6410
6380 @(i) = 0
6390 i = i + 1
6400 goto 6360
6410 rem loop
6420 @(8 * x + y + 62) = 4
6430 m = @(8 * u + v - 9)
6440 if m < 0 m = -m
6450 n = m / 100
6460 i = 1
6470 if n = 0 goto 6580
6480 j = 1
6490 rem do
6500 if j > n goto 6570
6510 gosub 1230
6520 @(j + 134) = 300
6530 @(j + 140) = s
6540 @(j + 146) = t
6550 j = j + 1
6560 goto 6490
6570 rem loop
6580 rem end if
6590 gosub 1330
6600 m = m - 100 * n
6610 i = 2
6620 if m / 10 gosub 1230
6630 m = m - m / 10 * 10
6640 i = 3
6650 if m = 0 goto 6730
6660 j = 1
6670 rem do
6680 if j > m goto 6720
6690 gosub 1230
6700 j = j + 1
6710 goto 6670
6720 rem loop
6730 rem end if
6740 a = 1
6750 return
