home *** CD-ROM | disk | FTP | other *** search
/ ftp.barnyard.co.uk / 2015.02.ftp.barnyard.co.uk.tar / ftp.barnyard.co.uk / cpm / walnut-creek-CDROM / SIMTEL / CPMUG / CPMUG080.ARK / TREK.STB < prev    next >
Text File  |  1984-04-29  |  24KB  |  547 lines

  1.  
  2.    10   Rem 02/28/81
  3.    20   Deg : Set 0,-1 : Imode : I=2.5 : If I=2.5 Then Run
  4.    30   Dim Quadrant(10,10),Sector(10,10),Command$(1),Command2$(20),Device$(152),Plot$(5)
  5.    40   Long Damage(7),Number(3),X,Y,Posx,Posy,Delta'x,Delta'y,Total'hits,Fire'power,Direction,Distance,Stardate,Time'left,T
  6.    50   Device$="Short range sensorsLong range sensors Warp engines       Impulse engines"
  7.    60   Device$(76)="Phasers            Photon torpedoes   Shields            Ship computer"
  8.    70   Def Fnklingons(X)=Binand(X,%000F%)
  9.    80   Def Fncommander(X)=Binand(X,%0010%)<>0
  10.    90   Def Fnenemy(X)=Binand(X,31)<>0
  11.   100   Def Fnstars(X)=Binand(X,%01E0%)/%0020%
  12.   110   Def Fnbase(X)=Binand(X,%0200%)<>0
  13.   120   Def Fnscanned(X)=Binand(X,%0400%)<>0
  14.   130   Def Fndistance(X1,Y1,X2,Y2)=Sqr((X1-X2)*(X1-X2)+(Y1-Y2)*(Y1-Y2))
  15.   140   Stardate=2500 : Time'left=4.99 : Plot$=".*KCBE" : Energy=5000 : Warp=6 : Shield'strength=100 : Torpedoes=10
  16.   150   Randomize : Gosub Title : Gosub Screen'erase : Gosub Create'sector : Gosub Grid : Gosub Score'board : Goto Enter'command
  17.   160 *Grid
  18.   170   Screen=1
  19.   180   If Damage(0)>0 Then  Do
  20.   190     Call .Cursor (10,3) : @"Short Range Sensor Damaged";
  21.   200     Else
  22.   210       For J=1 To 10
  23.   220       Print Using"## ",J;
  24.   230         For I=1 To 10
  25.   240         @"  ";Plot$(Sector(I,J),Sector(I,J));" ";
  26.   250         Next I
  27.   260       @ : @
  28.   270       Next J
  29.   280     @"     1   2   3   4   5   6   7   8   9  10"
  30.   290     Quadrant(Quadx,Quady)=Binor(Quadrant(Quadx,Quady),1024)
  31.   300     Enddo
  32.   310   Return
  33.   320 Procedure .Random'ij 
  34.   330   Local I,J
  35.   340   I=Int(Rnd(0)*10+1) : J=Int(Rnd(0)*10+1)
  36.   350   If Sector(I,J)>0 Then Goto 340
  37.   360   Endproc (I,J)
  38.   370 *Create'sector
  39.   380   Mat Sector=0 : Sector(Sectorx,Sectory)=5
  40.   390   If Fncommander(Quadrant(Quadx,Quady)) Then Call .Random'ij (;I,J) : Sector(I,J)=3
  41.   400   If Fnbase(Quadrant(Quadx,Quady)) Then Call .Random'ij (;I,J) : Sector(I,J)=4
  42.   410   If Fnklingons(Quadrant(Quadx,Quady))=0 Then Goto 450
  43.   420     For L=1 To Fnklingons(Quadrant(Quadx,Quady))
  44.   430     Call .Random'ij (;I,J) : Sector(I,J)=2
  45.   440     Next L
  46.   450   If Fnstars(Quadrant(Quadx,Quady))=0 Then 490
  47.   460     For L=1 To Fnstars(Quadrant(Quadx,Quady))
  48.   470     Call .Random'ij (;I,J) : Sector(I,J)=1
  49.   480     Next L
  50.   490   Return
  51.   500 *Create'universe
  52.   510   Call .Random'ij (;Quadx,Quady)
  53.   520   Call .Random'ij (;Sectorx,Sectory)
  54.   530     For I=1 To 10
  55.   540       For J=1 To 10
  56.   550       Quadrant(I,J)=Int(Rnd(0)*9)*32 : K=Rnd(0)*100
  57.   560       If K<5 Then Quadrant(I,J)=Quadrant(I,J)+512
  58.   570       K=Rnd(0)*100
  59.   580       If K<(10+Level*5) Then  Do
  60.   590         If K<15 Then M=Rnd(0)*(2+Level*1.5)
  61.   600         If K>=15 Then M=Rnd(0)*(Level)+1
  62.   610         Quadrant(I,J)=Quadrant(I,J)+M : Klingons=Klingons+M : L=Rnd(0)*100
  63.   620         If L<(Level*2+1) Then Quadrant(I,J)=Quadrant(I,J)+16 : Klingons=Klingons+1
  64.   630         Enddo
  65.   640       Next J
  66.   650     Next I
  67.   660   Total'klingons=Klingons
  68.   670   Return
  69.   680 *Score'board
  70.   690   If Screen=0 Then Return
  71.   700   Call .Cursor (52,0) : @ Using"STARDATE: ####.##",Stardate;
  72.   710   Call .Cursor (52,2) : @"POSITION";
  73.   720   Call .Cursor (53,3) : @" QUADRANT ";Quadx;",";Quady;
  74.   730   Call .Cursor (53,4) : @" SECTOR   ";Sectorx;",";Sectory;
  75.   740   Call .Cursor (52,6) : @ Using"TIME REMAINING: ##.##",Time'left
  76.   750   Call .Cursor (52,8) : @"KLINGONS: ";Klingons;" ";
  77.   760   Call .Cursor (52,10) : @"ENERGY: ";Energy;"   ";
  78.   770   Call .Cursor (52,12) : If Shield'status=0 Then @"SHIELDS DOWN";
  79.   780   If Shield'status=1 Then @"SHIELDS UP  ";
  80.   790   Call .Cursor (52,13) : @ Using" SHIELD STRENGTH: ###%",Shield'strength;
  81.   800   Call .Cursor (52,15) : @"TORPEDOES: ";Torpedoes;" ";
  82.   810   Call .Cursor (52,17) : @"WARP: ";Warp;
  83.   820   Call .Cursor (52,19) : If Fnenemy(Quadrant(Quadx,Quady)) Then  Do
  84.   830     @ Chr$(126);Chr$(31);"CONDITION: RED  ";Chr$(126);Chr$(25)
  85.   840     Else
  86.   850     @"CONDITION: GREEN";
  87.   860     Enddo
  88.   870   Return
  89.   880 *Enter'command
  90.   890   Call .Erase'line (2,22)
  91.   900   Input"Command: ",Command$;
  92.   910   Com=(Pos("SRLRMOIMPHPTSUCHSDDAREWAQGHEDO",Command$(0,1),0)+2)/2
  93.   920   On Com Goto Short'range,Long'range,Warp'drive,Impulse,Phasers,Torpedoes,Shields'up
  94.   930   On Com-7 Goto Galaxy,Shields'down,Damage'report,Repair,Set'warp,No'time,Help,Docked
  95.   940   Call .Erase'line (2,23)
  96.   950   @"Type 'HELP' for a list of commands.";
  97.   960   Goto Enter'command
  98.   970 *Short'range : Gosub Screen'erase : Gosub Grid : Gosub Score'board : Goto Enter'command
  99.   980 *Warp'drive
  100.   990   If Damage(2)>0 Then Goto Damaged
  101.  1000   Call .Erase'bottom (2,22)
  102.  1010   Input"Enter direction,distance for warp travel. ",Command2$
  103.  1020   Call .Get'numbers (;Direction,Distance,I)
  104.  1030   If Direction<0 Or Direction>12 Or Distance<0.1 Then Goto Enter'command
  105.  1040   If Energy<(Distance*Warp*10+100+Distance*Warp*10*Shield'status) Then Goto Not'enough
  106.  1050   Gosub Destination
  107.  1060   If X>11 Or Y>11 Or X<=1 Or Y<=1 Then Call .Erase'line (2,23) : @"You can't leave the galaxy."; : Goto Enter'command
  108.  1070   Energy=Energy-Distance*Warp*10-100-Distance*Warp*10*Shield'status
  109.  1080   Time'left=Time'left-Distance*(1.0/(Warp*Warp))
  110.  1090   Stardate=Stardate+Distance*(1.0/(Warp*Warp))
  111.  1100   Goto New'location
  112.  1110 *New'location
  113.  1120   Docked=0
  114.  1130   If Energy<0 Then Goto No'energy
  115.  1140   If Time'left<0 Then Goto No'time
  116.  1150   If Quadx=Endxx And Quady=Endyy Then Goto Sector'travel
  117.  1160   Goto Quadrant'travel
  118.  1170 *Destination
  119.  1180   Delta'x=Distance*Sin(Direction*30) : Delta'y=-Distance*Cos(Direction*30)
  120.  1190   X=Delta'x+Sectorx/10.0+Quadx : Y=Delta'y+Sectory/10.0+Quady
  121.  1200   Endxx=Int(X) : Endyy=Int(Y)
  122.  1210   If Fra(X)<0.05 Then Endx=10 : Endxx=Endxx-1
  123.  1220   If Fra(Y)<0.05 Then Endy=10 : Endyy=Endyy-1
  124.  1230   If Fra(X)>=0.05 Then Endx=Fra(X)*10
  125.  1240   If Fra(Y)>=0.05 Then Endy=Fra(Y)*10
  126.  1250   If Fra(X)>=0.95 Then Endx=10
  127.  1260   If Fra(Y)>=0.95 Then Endy=10
  128.  1270   Return
  129.  1280 *Quadrant'travel
  130.  1290   If Fnenemy(Quadrant(Quadx,Quady))*(Level>1) Then Gosub Klingon'attack
  131.  1300   Quadx=Endxx : Quady=Endyy : Sectorx=Endx : Sectory=Endy
  132.  1310   Gosub Create'sector : Gosub Screen'erase : Gosub Grid : Gosub Score'board
  133.  1350   If Level>2 And Fnklingons(Quadrant(Quadx,Quady))>0 Then Call .Attackers (25)
  134.  1360   If Fnenemy(Quadrant(Quadx,Quady))*(Level>4) Then Gosub Klingon'attack
  135.  1370   If Warp>6 And Com=3 Then  Do
  136.  1380     I=Rnd(0)*150
  137.  1410     If I<(Warp*Distance) Then Damage(2)=Rnd(0)*Warp : Call .Erase'line (2,23) : @"Warp drive is damaged from high speed.";
  138.  1440     Enddo
  139.  1450   Goto Enter'command
  140.  1460 *Set'warp : Com=3
  141.  1470   If Damage(2)>0 Then Goto Damaged
  142.  1480   Call .Erase'bottom (2,22)
  143.  1490   Input"Set warp speed to? ",Command2$
  144.  1500   If Command2$="" Then Goto Enter'command
  145.  1510   I=Val(Command2$)
  146.  1520   Call .Erase'line (2,23)
  147.  1530   If I<1 Or I>10 Then @"The Enterprise won't go that fast."; : Goto Enter'command
  148.  1540   Warp=I
  149.  1550   If Warp<=6 Then @"Warp speed set to ";I;".";
  150.  1560   If Warp>6 Then @"A warp speed of ";I;"May damage the drive .";
  151.  1570   Gosub Score'board : Goto Enter'command
  152.  1590 *Galaxy
  153.  1600   If Damage(7)>0 Then Goto Damaged
  154.  1610   Gosub Screen'erase
  155.  1620   Screen=0
  156.  1630     For J=1 To 10
  157.  1640     Print Using"##",J;
  158.  1650       For I=1 To 10
  159.  1660       If Fnscanned(Quadrant(I,J))=0 And Fnbase(Quadrant(I,J)) Then @"  .1. "; : Goto 1690
  160.  1670       If Fnscanned(Quadrant(I,J))=0 Then @"  ... "; : Goto 1690
  161.  1680       @ Using" ##",Fnklingons(Quadrant(I,J))+Fncommander(Quadrant(I,J));
  162.  1685       @ Fnbase(Quadrant(I,J));Fnstars(Quadrant(I,J));" ";
  163.  1690       Next I
  164.  1700     @ : @
  165.  1710     Next J
  166.  1720   @"     1     2     3     4     5     6     7     8     9    10"
  167.  1730   X=Quadx*6-1 : Y=Quady*2-2 : Call .Cursor (X,Y+1) : @"=";
  168.  1740   If Y>1 Then Call .Cursor (X,Y-1) : @"=";
  169.  1750   Call .Cursor (X-3,Y) : @"|";
  170.  1760   Call .Cursor (X+2,Y) : @"|";
  171.  1770   Goto Enter'command
  172.  1780 *Long'range
  173.  1790   Screen=2
  174.  1800   If Damage(1)>0 Then Goto Damaged
  175.  1810   Gosub Screen'erase
  176.  1820   @"LONG RANGE SCAN FROM QUADRANT ";Quadx;",";Quady;"." : @ : @
  177.  1830   @ : @
  178.  1840     For J=(Quady-1) To(Quady+1)
  179.  1850     Print Using" ##",J;
  180.  1860       For I=(Quadx-1) To(Quadx+1)
  181.  1870       If I<1 Or J<1 Or I>10 Or J>10 Then @ Spc(5);"```"; : Goto 1900
  182.  1880       @ Using"    ##",Fnklingons(Quadrant(I,J))+Fncommander(Quadrant(I,J));
  183.  1885       @ Fnbase(Quadrant(I,J));Fnstars(Quadrant(I,J));
  184.  1890       Quadrant(I,J)=Binor(Quadrant(I,J),1024)
  185.  1900       Next I
  186.  1910     @ : @ : @
  187.  1920     Next J
  188.  1930   @ Tab(9);Quadx-1;Tab(17);Quadx;Tab(25);Quadx+1
  189.  1940   Gosub Score'board : Goto Enter'command
  190.  1960 *Killed : Gosub Screen'erase : Call .Cursor (23,4) : @"THE ENTERPRISE HAS BEEN DESTROYED" : Goto Prisoner
  191.  2010 *Collision
  192.  2020   Gosub Screen'erase : Call .Cursor (8,4) : @"THEN ENTERPRISE HAS BEEN DESTROYED BY A COLLISION WITH A ";
  193.  2050   If Sector(Endx,Endy)=1 Then @"STAR."
  194.  2060   If Sector(Endx,Endy)=2 Then @"KLINGON."
  195.  2070   If Sector(Endx,Endy)=3 Then @"KLINGON COMMANDER."
  196.  2080   If Sector(Endx,Endy)=4 Then @"STARBASE."
  197.  2090   Goto Prisoner
  198.  2100 *No'energy : Gosub Screen'erase : Call .Cursor (12,4) : @"THE ENTERPRISE DOES NOT HAVE ENOUGH ENERGY TO MOVE.";
  199.  2140   Goto Prisoner
  200.  2150 *Prisoner
  201.  2170   Call .Cursor (5,10) : @"YOU ARE TAKEN PRISONER BY THE KLINGONS UNTIL THE END OF THE CONFLICT."
  202.  2190   Call .Cursor (24,18) : Input"PRESS RETURN FOR A NEW COMMAND.",Command2$ : Run
  203.  2210 *Phasers
  204.  2220   If Damage(4)>0 Then Goto Damaged
  205.  2230   Call .Erase'bottom (2,22)
  206.  2240   Input"Enter direction,energy. ",Command2$
  207.  2250   Call .Get'numbers (;Direction,Fire'power,I)
  208.  2260   If Direction<0 Or Direction(1)>12 Then Goto Enter'command
  209.  2270   If Fire'power<=0 Or Fire'power>Energy Then Goto Not'enough
  210.  2280   Energy=Energy-Fire'power
  211.  2290   Call .Check'path (Direction,0,Sectorx,Sectory,1)
  212.  2300   X=Posx : Y=Posy
  213.  2310   Fire'power=(5/Fndistance(Sectorx,Sectory,X,Y))*Fire'power
  214.  2320   If(Fire'power>=500 And Sector(X,Y)=2) Or(Fire'power>=1500 And Sector(X,Y)=3) Then  Do
  215.  2330     Gosub Hit
  216.  2340     Else
  217.  2350     Gosub Miss
  218.  2360     Enddo
  219.  2370   Gosub Klingon'attack : Goto Enter'command
  220.  2390 *Hit
  221.  2400   Klingons=Klingons-1
  222.  2410   If Klingons<1 Then Goto Won
  223.  2420   Time'left=Time'left+(0.01+0.1*(Sector(X,Y)=3))*(Total'klingons/Klingons)
  224.  2430   If Sector(X,Y)=2 Then Quadrant(Quadx,Quady)=Quadrant(Quadx,Quady)-1
  225.  2440   If Sector(X,Y)=3 Then Quadrant(Quadx,Quady)=Quadrant(Quadx,Quady)-16
  226.  2450   Call .Cursor (1+(X*4),(Y-1)*2) : @".";
  227.  2460   Call .Erase'line (2,23)
  228.  2470   If Sector(X,Y)=2 Then @"You eliminated the Klingon ship with a ";
  229.  2480   If Sector(X,Y)=3 Then @"You eliminated the Klingon commander with a ";
  230.  2490   If Com=5 Then @ Int(Fire'power);" giga erg hit.";
  231.  2500   If Com=6 Then @"torpedo.";
  232.  2510   Sector(X,Y)=0
  233.  2520   Return
  234.  2530 *Miss
  235.  2540   Call .Cursor (1+(X*4),(Y-1)*2)
  236.  2550   Call .Erase'line (2,23)
  237.  2560   If Hit<0 And Com=6 Then @"You missed!!!  ";
  238.  2570   If Sector(X,Y)=0 Then @"You fired into empty space!";
  239.  2580   If Sector(X,Y)=1 Then @"You hit a star!";
  240.  2590   If Sector(X,Y)=2 Or Sector(X,Y)=3 Then @"A ";Int(Fire'power);" giga erg hit failed to break the Klingon's screens.";
  241.  2600   If Sector(X,Y)=4 Then @"You hit your own base!";
  242.  2610   Call .Wait (1000)
  243.  2620   Return
  244.  2630 *Torpedoes
  245.  2640   If Damage(5)>0 Then Goto Damaged
  246.  2650   Call .Erase'line (2,23)
  247.  2660   If Torpedoes<1 Then @"You have no torpedoes"; : Goto Enter'command
  248.  2670   If Torpedoes>0 Then @"You may fire up to ";3*(Torpedoes>2)+Torpedoes*(Torpedoes<3);" torpedoes.";
  249.  2680   Call .Erase'line (2,22)
  250.  2690   Input"Directions to fire? ",Command2$;
  251.  2700   Call .Get'numbers (;I,J,K)
  252.  2710   If Number(1)<0 Then Goto Enter'command
  253.  2720   Distance=15
  254.  2730     For I=1 To 3
  255.  2740     If Number(I)<0 Or Number(I)>12 Then Goto 2810
  256.  2750     If Torpedoes<1 Then Call .Erase'line (2,23) : @"You have no more torpedoes"; : Goto 2810
  257.  2760     Torpedoes=Torpedoes-1
  258.  2770     Call .Check'path (Number(I),0,Sectorx,Sectory,0)
  259.  2780     X=Posx : Y=Posy
  260.  2790     If Hit=2 Or Hit=3 Then Gosub Hit
  261.  2800     If Hit<>2 And Hit<>3 Then Gosub Miss
  262.  2810     Next I
  263.  2820   Gosub Klingon'attack : Goto Enter'command
  264.  2850 *Klingon'attack
  265.  2860   If Level>3 Then Call .Attackers (5*Level)
  266.  2870   Total'hits=0
  267.  2880     For I=1 To 10
  268.  2890       For J=1 To 10
  269.  2900       If Sector(J,I)=2 Or Sector(J,I)=3 Then  Do
  270.  2910         L=Rnd(0)*100
  271.  2920         If L>30 Or Level<4 Then  Do
  272.  2930           Direction=Atn((Sectorx-J)/(I-Sectory+1E-30))/30
  273.  2940           If I<Sectory Then Direction=Direction+6
  274.  2950           Com=0
  275.  2960           If Screen=1 Then Call .Check'path (Direction,0,J,I,4)
  276.  2970           Fire'power=501.0/Fndistance(Sectorx,Sectory,J,I)
  277.  2980           If Sector(J,I)=3 Then Fire'power=Fire'power*3
  278.  3030           If Shield'status=1 Then Shield'strength=Shield'strength-Fire'power/25
  279.  3040           If Shield'strength<0 Then Shield'strength=0
  280.  3050           If Shield'status=1 Then Fire'power=Fire'power*(1-(Shield'strength/100.0))
  281.  3060           If Com=6 Then Fire'power=Fire'power*1.5
  282.  3065           If Docked Then Fire'power=Fire'power*Level*0.15
  283.  3070           Energy=Energy-Fire'power
  284.  3080           Total'hits=Total'hits+Fire'power
  285.  3090           If Energy<0 Then Goto Killed
  286.  3100           Call .Erase'line (2,23)
  287.  3110           @"You lost ";Int(Fire'power);" giga ergs from the Klingon attacking at ";J;",";I;".";
  288.  3120           If Fire'power>100 Then  Do
  289.  3125             Call .Wait (500)
  290.  3130             K=Int(Rnd(0)*15+1)-1
  291.  3140             If K>7 Then Goto 3210
  292.  3150             Damage(K)=((Fire'power-100.0)*Rnd(0))/75.0+Damage(K)
  293.  3160             If Damage(K)<1E-03 Then Damage(K)=0
  294.  3170             Call .Erase'line (2,23)
  295.  3180             @"Klingon attack damaged ";Device$(K*19,K*19+18);
  296.  3190             If K=6 Then Shield'status=0
  297.  3200             Call .Wait (750)
  298.  3210             Enddo
  299.  3230           Else
  300.  3240           Call .Random'ij (;M,N)
  301.  3250           If Fndistance(Sectorx,Sectory,M,N)>5 Then Goto 3240
  302.  3260           Call .Move (J,I,M,N,Sector(J,I))
  303.  3270           Enddo
  304.  3280         Enddo
  305.  3290       Next J
  306.  3300     Next I
  307.  3330   Call .Erase'line (2,23) : If Total'hits Then @"You lost ";Int(Total'hits);" giga ergs from the Klingon attack.";
  308.  3340   If Level>3 Then Call .Attackers (5*Level)
  309.  3345   Gosub Score'board
  310.  3350   Return
  311.  3360 *Docked
  312.  3370     For J=Sectory-1 To Sectory+1
  313.  3380       For I=Sectorx-1 To Sectorx+1
  314.  3390       If I<1 Or J<1 Or I>10 Or J>10 Then 3410
  315.  3400       If Sector(I,J)=4 Then Docked=1
  316.  3410       Next I
  317.  3420     Next J
  318.  3430   If Docked=1 Then  Do
  319.  3440     Energy=5000 : Torpedoes=10 : Shield'strength=100 : Call .Erase'line (2,23) : @"Enterprise docked at starbase.";
  320.  3490     Gosub Score'board : Gosub Damage'numbers
  321.  3500     Else
  322.  3520     Call .Erase'line (2,23) : @"Enterprise not adjacent to starbase.";
  323.  3530     Enddo
  324.  3540   Goto Enter'command
  325.  3550 *Impulse
  326.  3560   Call .Erase'bottom (2,22)
  327.  3570   If Damage(3)>0 Then Goto Damaged
  328.  3580   Input"Enter direction,distance for impulse travel. ",Command2$
  329.  3590   Call .Get'numbers (;Direction,Distance,I)
  330.  3600   If Direction<0 Or Direction>12 Or Distance<0.1 Then Goto Enter'command
  331.  3610   If Energy<Distance*250 Then Goto Not'enough
  332.  3620   Gosub Destination
  333.  3630   If X<1 Or Y<1 Or X>11 Or Y>11 Then Call .Erase'line (2,23) : @"You can't leave the galaxy."; : Goto Enter'command
  334.  3640   If Screen=1 Then Call .Cursor (1+(Sectorx)*4,(Sectory-1)*2) : @". ";
  335.  3650   Call .Check'path (Direction,Distance*10,Sectorx,Sectory,0)
  336.  3660   If Hit>0 Then  Do
  337.  3680     Call .Erase'line (2,23) : @"Safety system stops collision.";
  338.  3690     Endx=Posx-Delta'x : Endy=Posy-Delta'y
  339.  3700     Endxx=Quadx : Endyy=Quady
  340.  3720     Enddo
  341.  3730   Energy=Energy-Distance*250 : Time'left=Time'left-0.05*Distance : Stardate=Stardate+Distance*0.05
  342.  3760   Goto New'location
  343.  3770 *Sector'travel
  344.  3780   If Sector(Endx,Endy)>0 And Sector(Endx,Endy)<5 Then Goto Collision
  345.  3790   Call .Move (Sectorx,Sectory,Endx,Endy,5)
  346.  3800   Sectorx=Endx : Sectory=Endy
  347.  3810   If Level>3 Then Call .Attackers (5*Level)
  348.  3820   Gosub Score'board
  349.  3830   If Fnenemy(Quadrant(Quadx,Quady)) Then Gosub Klingon'attack
  350.  3840   Goto Enter'command
  351.  3850 Procedure .Move (Sectorx,Sectory,Endx,Endy,I)
  352.  3860   If Screen=1 Then  Do
  353.  3870     Call .Cursor (1+(Sectorx*4),(Sectory-1)*2) : @".";
  354.  3880     Call .Cursor (1+(Endx*4),(Endy-1)*2) : @ Plot$(I,I);
  355.  3890     Enddo
  356.  3900   Sector(Sectorx,Sectory)=0 : Sector(Endx,Endy)=I
  357.  3920   Endproc 
  358.  3930 *Repair
  359.  3940   Call .Erase'bottom (2,22)
  360.  3950   Input"Work on repairs for how long? ",Command2$
  361.  3960   If Command2$="" Then Goto Enter'command
  362.  3970   T=Val(Command2$)
  363.  3980   If T=0 Then Goto Enter'command
  364.  3990   Call .Erase'line (2,23)
  365.  4000   If Fnenemy(Quadrant(Quadx,Quady)) Then T=0.01+Rnd(0)*0.2
  366.  4010   Time'left=Time'left-T
  367.  4020   Stardate=Stardate+T
  368.  4030   If Time'left<0 Then Goto No'time
  369.  4040   If Docked=1 Then T=T*10
  370.  4050     For I=0 To 7
  371.  4060     Damage(I)=Damage(I)-T
  372.  4070     If Damage(I)<0.01 Then Damage(I)=0
  373.  4080     Next I
  374.  4090   If Fnenemy(Quadrant(Quadx,Quady)) Then  Do
  375.  4100     @"Repairs interrupted by Klingon attack.";
  376.  4110     Gosub Klingon'attack
  377.  4120     Else
  378.  4130     @"Repairs worked on for time ordered.";
  379.  4140     Enddo
  380.  4150   Gosub Damage'numbers : Gosub Score'board : Goto Enter'command
  381.  4180 *Damage'report
  382.  4190   Screen=-1
  383.  4200   Gosub Screen'erase
  384.  4210   @
  385.  4220   @ Tab(13);"DAMAGE REPORT" : @
  386.  4230   @ Tab(10);"System";Tab(28);"Repair Time" : @
  387.  4240     For I=0 To 7
  388.  4250     @ Tab(10);Device$(I*19,I*19+18) : @
  389.  4260     Next I
  390.  4270   Gosub Damage'numbers : Gosub Score'board : Goto Enter'command
  391.  4275 *Damage'numbers
  392.  4280   If Screen<>-1 Then Return
  393.  4290     For I=0 To 7
  394.  4300     Y=I*2+5
  395.  4310     Call .Cursor (30,Y)
  396.  4320     If Damage(I)>0 And Docked=0 Then @ Using"##&.&&&&",Damage(I)
  397.  4330     If Damage(I)>0 And Docked=1 Then @ Using"##&.&&&&",Damage(I)/10
  398.  4340     If Damage(I)=0 Then @"  OK    "
  399.  4350     Next I
  400.  4360   Return
  401.  4370 *Help
  402.  4380   Call .Erase'bottom (0,21)
  403.  4390   @"SR=Short range scan  MO=Warp drive     PH=Phasers        RE=Repair      DO=Dock"
  404.  4400   @"LR=Long range scan   WA=Warp speed     PT=Torpedoes      SU=Shields up"
  405.  4410   @"CH=Chart of Galaxy   IM=Impulse drive  DA=Damage report  SD=Shields down";
  406.  4420   Open\1\"$SY" : Get\1\Command2$(0,0) : Close\1\
  407.  4450   Call .Erase'bottom (0,21) : Goto Enter'command
  408.  4470 *Damaged
  409.  4480   Call .Erase'line (2,23)
  410.  4490   @"Damage to ";Device$((Com-1)*19,(Com-1)*19+18);
  411.  4500   Goto Enter'command
  412.  4510 *Shields'up
  413.  4520   Call .Erase'line (2,23)
  414.  4530   If Shield'status=1 Then @"Shields already up."; : Goto Enter'command
  415.  4540   If Damage(6)>0 Then Goto Damaged
  416.  4550   If Energy<=50 Then @"Not enough energy to raise shields."; : Goto Enter'command
  417.  4560   @"Shields raised.";
  418.  4570   Shield'status=1 : Energy=Energy-50 : Gosub Score'board : Goto Enter'command
  419.  4610 *Shields'down
  420.  4620   Call .Erase'line (2,23)
  421.  4630   If Shield'status=0 Then @"Shields already down."; : Goto Enter'command
  422.  4640   @"SHIELDS LOWERED."; : Shield'status=0 : Gosub Score'board : Goto Enter'command
  423.  4680 *Won
  424.  4690   Gosub Screen'erase
  425.  4700   Call .Cursor (28,4)
  426.  4710   @"CONGRATULATIONS CAPTAIN!!"
  427.  4720   Call .Cursor (21,11)
  428.  4730   @"THE KLINGON THREAT HAS BEEN ELIMINATED."
  429.  4740   Call .Cursor (24,18)
  430.  4750   Input"PRESS RETURN FOR ANOTHER COMMAND.",Command$
  431.  4760   Run
  432.  4770 *No'time
  433.  4780   Gosub Screen'erase
  434.  4790   Call .Cursor (12,4)
  435.  4800   @"YOU HAVE FAILED TO ELIMINATE THE KLINGON THREAT IN TIME."
  436.  4810   Call .Cursor (25,11)
  437.  4820   @"THE FEDERATION HAS SURRENDERED."
  438.  4830   Call .Cursor (25,18)
  439.  4840   Input"PRESS RETURN FOR A NEW COMMAND.",Command$
  440.  4850   Run
  441.  4860 *Title
  442.  4870   Gosub Screen'erase
  443.  4880   Call .Cursor (20,4)
  444.  4890   @"STARTREK"
  445.  4900   Call .Cursor (20,6)
  446.  4910   @"copyright 1980"
  447.  4920   Call .Cursor (20,8)
  448.  4930   @"by"
  449.  4940   Call .Cursor (20,10)
  450.  4950   @"David E. Trachtenbarg."
  451.  4960   Call .Erase'line (28,18)
  452.  4970   Input"Enter your expertise level (1-5). ",Command$
  453.  4980   If Command$="" Then Goto 4960
  454.  4990   Level=Val(Command$)
  455.  5000   If Level<1 Or Level>5 Then Goto 4960
  456.  5010   Call .Erase'line (28,18)
  457.  5020   @"Creating the universe.";
  458.  5030   Gosub Create'universe
  459.  5040   Call .Cursor (24,18)
  460.  5050   Input"Press RETURN to assume command.",Command$
  461.  5060   Return
  462.  5070 *Not'enough
  463.  5080   Call .Erase'line (2,23)
  464.  5090   @"Not enough energy.";
  465.  5100   Goto Enter'command
  466.  5110 *Screen'erase
  467.  5120   Out 1,126 : Out 1,28
  468.  5130   Return
  469.  5140 Procedure .Cursor (X1,Y1)
  470.  5150   Out 1,126 : Out 1,17
  471.  5160   Out 1,X1 : Out 1,Y1
  472.  5170   Endproc 
  473.  5180 Procedure .Get'numbers 
  474.  5190   Mat Number=-1
  475.  5200   I=0
  476.  5210     For J=1 To 3
  477.  5220     K=Asc(Command2$(I))
  478.  5230     If K=47 Or K<46 Or K>57 Then 5270
  479.  5240     Number(J)=Val(Command2$(I))
  480.  5250     I=Pos(Command2$,",",I)+1
  481.  5260     If I=0 Then J=3
  482.  5270     Next J
  483.  5280   Endproc (Number(1),Number(2),Number(3))
  484.  5290 Procedure .Check'path (Direction,Distance,Sectorx,Sectory,Miss)
  485.  5300   Local J
  486.  5310   Delta'x=Sin(Direction*30.0)
  487.  5320   Delta'y=-1*Cos(Direction*30.0)
  488.  5330   Hit=0
  489.  5340     While Hit=0
  490.  5350     J=J+1
  491.  5360     Posx=Sectorx+Delta'x*J
  492.  5370     Posy=Sectory+Delta'y*J
  493.  5380     If Distance>0 Then  Do
  494.  5390       T=Fndistance(Delta'x*J,Delta'y*J,0,0)
  495.  5400       If T>=Distance Then Hit=-1
  496.  5410       Enddo
  497.  5420     If Posx<0.9 Or Posy<0.9 Or Posx>10.1 Or Posy>10.1 Then  Do
  498.  5430       If Posx<1 Then Posx=1
  499.  5440       If Posy<1 Then Posy=1
  500.  5450       If Posx>10 Then Posx=10
  501.  5460       If Posy>10 Then Posy=10
  502.  5470       Hit=-1
  503.  5480       Enddo
  504.  5490     Call .Cursor (1+Posx*4,(Posy-1)*2)
  505.  5500     If Sector(Posx,Posy)>Miss And((Abs(Sectorx-Posx)>0.5) Or(Abs(Sectory-Posy)>0.5)) Then Hit=Sector(Posx,Posy)
  506.  5510     Endwhile
  507.  5520   Posx=Int(Posx)+1*(Fra(Posx)>=0.5)
  508.  5530   Posy=Int(Posy)+1*(Fra(Posy)>=0.5)
  509.  5540   Endproc 
  510.  5550 Procedure .Attackers (Move)
  511.  5560   Local I,J,K,L,M,N
  512.  5570     For J=(Quady-1) To(Quady+1)
  513.  5580       For I=(Quadx-1) To(Quadx+1)
  514.  5590       If I<1 Or J<1 Or I>10 Or J>10 Or(Quadx=I And Quady=J) Then 5750
  515.  5600       K=Fnklingons(Quadrant(I,J))
  516.  5610       If K>0 Then  Do
  517.  5620           For L=1 To K
  518.  5630           M=Rnd(0)*100
  519.  5640           If M<Move Then  Do
  520.  5645             If Fnklingons(Quadrant(Quadx,Quady))>(4+Level*2) Then 5720
  521.  5650             Quadrant(I,J)=Quadrant(I,J)-1
  522.  5660             Quadrant(Quadx,Quady)=Quadrant(Quadx,Quady)+1
  523.  5670             Quadrant(I,J)=Binand(Quadrant(I,J),%FBFF%)
  524.  5680             Call .Random'ij (;M,N)
  525.  5690             If Fndistance(Sectorx,Sectory,M,N)>5 Then Goto 5680
  526.  5700             Sector(M,N)=2
  527.  5710             If Screen=1 Then Call .Cursor (1+(M*4),(N-1)*2) : @"K";
  528.  5720             Enddo
  529.  5730           Next L
  530.  5740         Enddo
  531.  5750       Next I
  532.  5760     Next J
  533.  5770   Endproc 
  534.  5780 Procedure .Wait (Delay)
  535.  5790     For T=1 To Delay
  536.  5800     Next T
  537.  5810   Endproc 
  538.  5820 Procedure .Erase'line (X1,Y1)
  539.  5830   Out 1,126 : Out 1,17 : Out 1,X1 : Out 1,Y1
  540.  5840   Out 1,126 : Out 1,15
  541.  5850   Endproc 
  542.  5860 Procedure .Erase'bottom (X1,Y1)
  543.  5870   Out 1,126 : Out 1,17 : Out 1,X1 : Out 1,Y1
  544.  5880   Out 1,126 : Out 1,24
  545.  5890   Endproc 
  546.