x868k.com / retro /

Download STTrek.bas

From: Antic - January 1987 - Volume 5, Number 9


by Stephen Everman and Paul Pratt

Here's the breakthrough that all you ST BASIC hobbyists have been waiting for. Super Trek is an ambitious commercial-quality GEM version of the classic public domain Star Trek game-and it's all done with ST BASIC. Nearly nine pages long, this is the biggest ST BASIC program ever published by Antic. But Super Trek is a clean, straightforward listing that should not present any undue typing difficulties. And when you command the Enterprise on a 360-day mission throughout the final frontier, we think you'll agree it was worth every keystroke. Sorry... Super Trek runs on color monitors only.

On the "Star Trek" shows, it all seemed so easy. Captain Kirk and company would hop from planet to planet-sometimes beaming down to vanquish exotic monsters-enter skirmishes with various space scum, occasionally disobey orders from Star Fleet Command or violate the Prime Directive and still come up smelling like a rose. Super Trek-for STs with color monitors only-isn't as simple as that.

Remember those clipboards that the various curvaceous yeomen handed Kirk from time to time? They held energy consumption reports, among other things, and could not be ignored. That's part of what you'll have to deal with here. Your assignment as the new Commander of the United Star Ship Enterprise is to spend the next 360 days doing anything you want-as long as you destroy the prescribed number of Klingon vessels (usually around 25 or 30).

The Atari ST is the final frontier for the classic public domain Star Trek game. Written entirely in ST BASIC it boasts an arcade-quality color display and total mouse control via menu boxes and icons. You'll zoom through the galaxies and do battle with Klingons, just like the old days.

BLAST OFF

The Super Trek screen has one grid showing the entire galaxy and another with just the quadrant you're in at the time. Travel to a new quadrant at Warp Speed by clicking on a quadrant box in the galaxy grid-map. If there is a Klingon ship in the new quadrant, it's time to click on red alert.

A message window gives you status reports during battle. Pie charts show the remaining percentages of phaser power, photon torpedos, computer capability, energy, deflector shields functioning and how much of your 360 days are left. The pie slices removed from the graphs can be huge, so keep a close watch and make sure to warp frequently to a star base for repairs.

The Library Functions window offers the choice of Status & Repair Scheduling, Cumulative Galactic Record, Long-Range Galactic Scanning and leaving a Marker Buoy behind.

While in drydock, repairs can be authorized by clicking on Status & Repairs Scheduling in the Library Functions window. This calls up a small spreadsheet showing present computer capability, shields and phaser status, the goals for these (set by you with the mouse buttons) and the energy units and days needed for repair. When you have set your goals and decided how much time to spend at the star base, click on Authorize Repairs to get set for departure.

The Cumulative Galactic Record shows each galaxy you've visited. But if the computer is damaged, it will show random question marks in places. The Long-Range Scanners take in the area around you. This can help, but it expends a great deal of energy. Marker Buoys can be left to show where you were, but must be replaced whenever you re-enter those areas.

In combat, click on the square for either the phaser or photon torpedo. When the cross-hair cursor appears, click on the Kiingon ship. The phaser beam is more powerful than the photon, but it loses strength as it and the computer take damage. Since the photon torpedos are physical bombs, they won't lose power. But, again, they won't do as much damage as the phaser and you can only carry six at a time.

Super Trek will be a lot easier to play if you remember these hints: Keep your shields up. Make small galactic moves and make repairs often. Be careful of quadrants with more than one Klingon ship, because they'll gang up on you. Remember, the game becomes more and more difficult after each successful voyage.

TYPING IT IN

Carefully type in Listing 1, STARTREK.BAS, using either the editor built into ST BASIC or your favorite ST word processor. If you use a word processor, be sure and save the file in ASCII format. (See this issue's Tech Tips page for more information about using word processors to type in ST BASIC listings.) When you finish, run TYPO ST and generate the TYPO Table for Super Trek. Check each line entry. If one of the checksums doesn't match, recheck how you typed that line.

(NOTE: We've discovered ST BASIC will drop the very first character of a textfile when it tries to read the file. For this reason, ST BASIC sees line 1000 as line 000 and calculates the incorrect checksum. The fix is to either disregard the first line or insert a single carriage return as the first character in the file.-ANTIC ED)

Antic Disk owners: STARTREK.BAS is on SIDE B of the January monthly disk. Follow the ST Help file instructions to transfer the programs from the 8-bit disk to your ST.

PROGRAM BREAKDOWN

Lines 1000-1040 make up the title and copyright information. Line 1060 through 1590 hold program initialization information. This is where the screen is drawn and colored. Lines 1610 through 1960 contain the MAIN loop, where the game logic actually lies.

The work is done inside the while...wend loop. Here we watch where the mouse is pointing, and respond appropriately if a mouse button is pressed. When both buttons are pressed, the program will fall out of the while...wend loop and determine the outcome of your battle with the Kiingons. You are asked if you wish to play again.

The next four subroutines support your final outcome. One of these is called for each condition possible, either Success, Failure, Incompetence, and Play Again. Between lines 2270 and 2350 is the subroutine that draws the pie charts used for the onscreen power indicators.

The subroutine GALAXY updates the active quadrant when you change position on the galaxy grid. PHOTON and PHASER are called when you select either weapon to use against the Klingon slime. DESTROY is called when you finally defeat a Klingon ship.

Between lines 3470 and 3550, the subroutines HIT.SHIELDS, HIT.PHASERS, and HIT.COMPUTER are activated whenever the Klingons manage to land a hit on the Enterprise. Down at line 4120, the subroutine LIBRARY is called whenever you move the mouse pointer into the Library Box below the two position maps on-screen. If you choose one of the Library Functions, control is passed to DO.LIBRARY, where the proper function is determined and control is passed on to the proper routine, either REPAIR, GALAXYMAP, SCAN.GALAXY, or SETMARKER.BUOY.

FINAL FRONTIER

Whenever you select a new destination for the Enterprise, control is passed to MOVESHIP, at line 4780. The destination is scanned to check for occupancy and, if the area is unoccupied, the Enterprise's location is changed. If you move the Enterprise to a star base, the subroutine DOCK is called, allowing you to repair systems-if there are no Klingons attacking.

Should you desire repair service while docked at a starbase, the subroutine REPAIR is called. In the Library Box, the repairable functions will appear, along with the amount they need to be repaired. Point at the function you want repaired, and press the left mouse button to increase, or the right button to decrease, the level of repair.

The subroutine SETUP in lines 6270 to 6410 reseeds the Galaxy with stars, star bases, Klingons, and the Enterprise. FLASH causes the screen to flash whenever you destroy a Klingon. This routine and the following one, KOLOR, perform something interesting on the ST.

First, they read four color values into an array where each entry is 16 bits wide, then poke the address of the array into where GEM keeps track of where its current color palette is located. This instantly changes the available colors on the ST screen, much faster than the color statement.

Next, we find subroutines to perform some of the common GEM functions. The SET.MOUSE.SHAPE subroutine actually do just that, given the desired mouse shape number (0-7) in the variable POINTER. SHRINKBOX and GROWBOX perform the "moving box" effect whenever you warp the Enterprise to another section of the Galaxy. POLYLINE and PSTRING perform GEM functions for drawing a line and placing graphic text on the screen.

Super Trek is the third in a series of classic public domain games rewritten in ST BASIC by Paul Pratt and Stephen Everman of Hayward, California. ST BASIC Hangman appeared in the November, l986 Antic, and Deduction appeared in December 1986.

1000  '
1010  ' ST Super Trek
1020  ' (c) 1986 Antic Publishing
1030  ' Version 100286  Thursday
1040  ' Written by Paul Pratt and Steve Everman
1050  '
1060   HANDLE=2: fullw 2: clearw 2: BELL$=chr$( 7 ): A.BLANK$=chr$( 32 )
1070   TRUE=1: FALSE=0: NONE=0: LEFT=1: RIGHT=2: BOTH=3
1080   ARROW=0: FINGER=3: HOLLOW.CROSSHAIR=6: FILLED.CROSSHAIR=7
1090   randomize 0: QX=294: QY=64: PLX=32: PLY=4: EMPTY=0
1100   STAR=42: KLINGON=221: STARBASE=5: ENTERPRISE=224
1110   ACTIVE=TRUE: HOME=OFF: CO=2: option base 0: RED.ALERT=FALSE
1120   dim MAP%( 8,8 ),SECT%( 8,8 ),KOL%( 6 ),KLING%( 3,3 )
1130   restore 6560: POINTER=ARROW: gosub KOLOR
1140   PLAYING=TRUE: DOSET=OFF: BON=ACTIVE
1150   GRAF.SHRINKBOX=74: GRAF.GROWBOX=73: GRAF.MOUSE=78
1160   color 2: restore AUTHOR.STRING
1170   for X=0 to 16: read Z: gotoxy 2,X: next
1180  AUTHOR.STRING:
1190   data 189,32,80,82,65,84,84,32,38,32,69,86,69,82,77,65,78
1200   GX=10: GY=4: gosub SETUP
1210  '
1220   color 1,2,2,1: PN=6: X=0: gosub POLYLINE
1230   color 1,2,0,1: for X=1 to 30: gosub POLYLINE: next
1240   color 3,2,3,1: PN=2: X=10: gosub POLYLINE
1250   gotoxy 40, 17:  print "%Energy    %Shields     %Date";
1260   gotoxy 40 ,13:  print "%Phaser    %Photon    %Computer"
1270  '
1280   color 1,1,3,1: for Y=1 to 73 step 9: linef 13,Y,157,Y: next
1290   for X=13 to 157 step 18: linef X,1,X,73: next
1300   color 2,1,3,1: for Y=1 to 73 step 9: linef 175,Y,318,Y: next
1310   for X=175 to 319 step 18: linef X,1,X,73: next
1320  '
1330   color 3: gotoxy 45 ,6: print "Phaser      Photon": color 2,2,3,2
1340   for X=0 to 98 step 98
1350      restore PUSH.BOX.DATUM
1360      read X1,Y1,X2,Y2
1370      linef X1+X,Y2,X2+X,Y2: linef X1+X,Y1,X2+X,Y1
1380      linef X1+X,Y1,X1+X,Y2: linef X2+X,Y1,X2+X,Y2
1390      fill X1+X+2,Y1+2
1400   next
1410  PUSH.BOX.DATUM:
1420   data 400,65,455,85
1430  '
1440   restore LIB.BOX.DATUM
1450   read X1,Y1,X2,Y2
1460   linef X1,Y2,X2,Y2: linef X1,Y1,X2,Y1
1470   linef X1,Y1,X1,Y2: linef X2,Y1,X2,Y2
1480  LIB.BOX.DATUM:
1490   data 13,81,319,155
1500  '
1510   restore STAT.BOX.DATUM
1520   read X1,Y1,X2,Y2
1530   linef X1,Y2,X2,Y2: linef X1,Y1,X2,Y1
1540   linef X1,Y1,X1,Y2: linef X2,Y1,X2,Y2
1550  STAT.BOX.DATUM:
1560   data 350,50,606,1
1570  '
1580   color 1: restore PSTRING.001: gosub PRSTRING
1590   color 2: restore PSTRING.002: gosub PRSTRING
1600  '
1610  MAIN:
1620   while PLAYING
1630      DATE=0: PI=0: SHE=0: COMP=0: PHASE=0: PHOT=0: TMPDAM=0
1640      gosub CLEAN: gosub ALT.XREPAIR
1650      gosub ALT.LIBRARY: gosub ALT.GALAXY
1660      color 2: gotoxy 42,1: print "Sir, there are";FOE;"Klingons"
1670      color 2: gotoxy 42,2: print "  and 360 days to kill them."
1680      color 1: gotoxy 45,4: print " G O O D   L U C K  !"
1690  '
1700      while BUTTON<>BOTH and PI<3600 and DATE<3600 and FOE>0
1710        gosub GET.MOUSE: IN.RANGE=FALSE
1720        if MY<95 and MY>22 and BUTTON=LEFT then IN.RANGE=TRUE
1730        if MX>13 and MX<157 and IN.RANGE then gosub GALAXY
1740        if MX>175 and MX< 319 and IN.RANGE then gosub MOVESHIP
1750        if MX>13 and MX<319 and MY>102 and MY<178 then gosub LIBRARY
1760        if MX>498 and MX<553 and MY>86 and MY<107 then gosub PHOTON
1770        if MX>400 and MX<453 and MY>86 and MY<107 then gosub PHASER
1780      wend
1782  '
1790      color 2: restore COLOR.STRING.3: gosub KOLOR: gosub CLEAN
1800      IT=( FOE=0 )*-1+( DATE>=3600 )*-2+( PI>=3600 )*-3
1810      on IT gosub SUCCESS,FAILURE,INCOMPETENCE,SUCCESS,FAILURE
1820      for X=10 to 16 step 2
1830           gotoxy 2,X: print "                                     "
1840      next
1850      gotoxy 2,11: print  " Will you accept another commission?"
1860      color 3: gotoxy 2,13
1870      print  "        Left Button for   ";: color 1
1872      print "YES        "
1880      color 3: gotoxy 2,15
1890      print  "        Right Button for  ";: color 1
1892      print " NO        "
1900      gosub GET.MOUSE
1910      while BUTTON=NONE or BUTTON=BOTH or FALL=FALSE
1920           gosub GET.MOUSE
1930      wend
1940      if BUTTON=RIGHT then PLAYING=FALSE
1950      if BUTTON=LEFT then gosub MORE
1960   wend
1970  end
1980  '
1990  SUCCESS:
2000   restore COLOR.STRING.4
2010   for X=0 to 12
2020      gosub KOLOR
2030      gotoxy 2,9
2032      print "   Congratulations! Invasion Stopped! ";BELL$
2040   next
2050   restore COLOR.STRING.0: gosub KOLOR: HCAP=HCAP+5
2060  return
2070  '
2080  FAILURE:
2090   gotoxy 2,9: print " You Failed. ";FOE;"Klingons remain. "
2100   HCAP=HCAP-6
2110  return
2120  '
2130  INCOMPETENCE:
2140   gotoxy 2,9: print " Found drifting: Systems Dead   "
2142   HCAP=HCAP-6
2150  return
2160  '
2170  MORE:
2180   gosub CLEAN
2182   gotoxy 43,4: print "Stand By for Assignment";BELL$
2190   gosub ALT.LIBRARY: gosub SETUP: color 1,0,0,0
2200   for Y=3 to 72 step 9
2210      for X=15 to 155 step 18
2220         fill X,Y
2230      next
2240   next
2250  return
2260  '
2270  PIE:
2280   color 1,1,2,1
2290   pcircle 383, 140, 25, 0, PI
2300   pcircle 573, 140, 25, 0, DATE
2310   pcircle 573, 103, 25, 0, COMP*36
2320   pcircle 383, 103, 25, 0, PHASE*36
2330   pcircle 478, 103, 25, 0, PHOT
2340   pcircle 478, 140, 25, 0, SHE*36
2350  return
2360  '
2370  GET.MOUSE:
2380   GINTOUT=peek( A#+12 ): gemsys( 79 )
2390   MX=peek( GINTOUT+2 ): MY=peek( GINTOUT+4 )
2400   BUTTON=peek( GINTOUT+6 )
2410   if OLDBUTTON<>BUTTON then FALL=TRUE else FALL=FALSE 
2420   OLDBUTTON=BUTTON
2430  return
2440  '
2450  ENGY:
2460   gosub CLEAN
2470   color 1: gotoxy 44,4: print "Energy Level too Low!";BELL$
2480  return
2490  '
2500  GALAXY:
2510   X=2*int( MX/18+.27 ): Y=int( MY/9-.5 )-2: gosub CLEAN
2520   DIST=int( sqr( ( ( X-GX )/2 )^2+( Y-GY )^2 ) )
2530   TDIST=DIST*500: if DIST=1 then TDIST=30
2540   if PI+TDIST>3599 then gosub ENGY: return
2550   PI=PI+TDIST: DATE=DATE+DIST*4
2560   gotoxy GX,GY: print A.BLANK$: color 1,0,2
2570   if MK=ACTIVE then MK=OFF: color 1,2,2
2580   for E=-2 to 8 step 5: fill int( GX*9 )+E,int( GY*9 )+2: next
2590   GX=X: GY=Y
2600   MAP.SPOT= MAP%( GY,( GX-2 )/2 )
2610  ALT.GALAXY:
2620   if MAP.SPOT<0 then MAP%( GY,( GX-2 )/2 )=MAP.SPOT*-1-1
2630   color 2: gotoxy GX,GY: print chr$( ENTERPRISE )
2640   gosub SHRINKBOX
2650   gosub GROWBOX: gosub REC: gosub GROWBOX
2660   if RED.ALERT=TRUE and PI>0 then gosub REBUTAL
2670   gosub SET
2680  return
2690  '
2700  GETSHIP:
2710   if BON=ACTIVE then BON=OFF: gosub CLEAN
2720   gosub REBUTAL: gosub SET.MOUSE.SHAPE: gosub SHOW
2730   while MX<175 or MX>319 or MY>95 or MY<22 or BUTTON<>LEFT
2740      gosub GET.MOUSE
2750   wend
2760   PI=PI+55: TX=2*int( MX/18+.27 ): TY=int( MY/9-.5 )-2
2770   for Z=0 to 2 
2780      if KLING%( Z,0 )=( TX-20 )/2 and KLING%( Z,1 )=TY then SHP=Z
2790   next
2800   DIST=int( SQR( ( ( TX-PLX )/2 )^2+( TY-PLY )^2 )^2.3 ) 
2810  return
2820  '
2830  PHOTON:
2840   if BUTTON<>LEFT or FALL=0 or ( RED.ALERT=FALSE ) then return
2850   if PHOT>3100 then gosub CLEAN
2860   if PHOT>3100 then gotoxy 44,2: print "No Photon Bombs": return
2870   PHOT=PHOT+600: POINTER=HOLLOW.CROSSHAIR: gosub GETSHIP
2880   DAMAGE=25+int( RND*200 )-DIST*2: color 2: gosub ALT.PHASER
2890  return
2900  '
2910  PHASER:
2920   if BUTTON<>LEFT or FALL=FALSE or RED.ALERT=FALSE then return
2930   if PHASE>99 then color 1: gotoxy 46,1: ?"No Phasers": return
2940   DAMAGE=40+( rnd*200 )-DIST*4-PHASE/1.2-( COMP/1.7 ): color 2
2950   POINTER=FILLED.CROSSHAIR: gosub GETSHIP
2960  ALT.PHASER:
2970   if SECT%( ( TX-20 )/2,TY )<>KLINGON then DAMAGE=FALSE
2980   if DAMAGE<15 then gotoxy 40,4: ? "           M I S S           "
2990   if DAMAGE<15 then gosub SET: return
3000   KLING%( SHP,2 )=KLING%( SHP,2 )-DAMAGE
3010   if KLING%( SHP,2 )<1 then NUMBER.KLINGONS=NUMBER.KLINGONS-1
3020   if KLING%( SHP,2 )<1 then gosub DESTROY: return
3030   restore COLOR.STRING.2: gosub KOLOR
3040   for D=0 to 20: next
3050   restore COLOR.STRING.1: gosub KOLOR: gotoxy 41,4
3060   HIT.AT=KLING%( SHP,2 )/2
3070   print using "Hit: Klingon at ##.#_% power";HIT.AT: print BELL$
3080  '
3090  SET:
3100   POINTER=ARROW: gosub SET.MOUSE.SHAPE
3110   gosub SHOW: gosub GET.MOUSE: gosub PIE
3120  return
3130  '
3140  CLEAN:
3150   for E=1 to 4
3160      gotoxy 40,E: print "                              "
3170   next
3180  return
3190  '
3200  DESTROY:
3210   gotoxy ( KLING%( SHP,0 )+10 )*2,KLING%( SHP,1 ): print A.BLANK$
3220   FOE=FOE-1: for X=0 to 8: gosub FLASH: next
3230   restore COLOR.STRING.0: gosub KOLOR: RED.ALERT=FALSE
3240   for X=0 to 5
3250      CO=CO+1: color CO: if CO=3 then CO=1
3260      gotoxy 40,4: print "       Klingon Destroyed      ";BELL$
3270   next
3280   if NUMBER.KLINGONS>0 then restore COLOR.STRING.1
3290   if NUMBER.KLINGONS>0 then gosub KOLOR: RED.ALERT=TRUE
3300   SECT%( ( TX-20 )/2,TY )=FALSE
3310   MAP%( GY,( GX-2 )/2 )=MAP%( GY,( GX-2 )/2 )-10
3320   if KEP=OFF then gosub CLEAN: gosub SET else KEP=OFF: gosub SET
3330   gosub REDALERT
3340  return
3350  '
3360  REBUTAL:
3370   if int( rnd*12 )<5 and NUMBER.KLINGONS<2 then return
3380   if BON=ACTIVE then BON=OFF: gosub CLEAN
3390   sound 1,12,3,4,0
3400   CO=CO+1: color CO: if CO=3 then CO=1
3410   DAM=int( rnd*11+SHE/4-DIST/5 )
3412   if DAM<1 then DAM=int( rnd*5 )+1
3420   if NUMBER.KLINGONS>1 then DAM=int( DAM*( NUMBER.KLINGONS/1.4 ) )
3430   on rnd*3+1 gosub HIT.SHIELDS,HIT.PHASERS,HIT.COMPUTER
3440   sound 1,0,0,0,0
3450  return
3460  '
3470  HIT.SHIELDS:
3480   SHE=SHE+DAM : if SHE>100 then SHE=100: gosub EMINENT: return
3490   gotoxy 40,2: print  "   Shields took";DAM;"% damage.": return
3492  '
3500  HIT.PHASERS:
3510   PHASE=PHASE+DAM: if PHASE>100 then PHASE=100
3520   gotoxy 40,2: print "   Phaser took";DAM;"% damage.": return
3522  '
3530  HIT.COMPUTER:
3540   COMP=COMP+DAM
3542   if COMP>100 then COMP=100: gosub EMINENT: return
3550   gotoxy 40,2: print "   Computer took";DAM;"% damage.  ": return
3560  '
3570  EMINENT:
3580   TMPDAM=TMPDAM+DAM: gosub CLEAN
3590   color 2: gotoxy 44,1: print "DANGER! Systems Weak";BELL$
3600   X=int( RND*10 )+1: gotoxy 43,2
3610   print X;"Days used for repair.": DATE=DATE+X*10
3620   color 1
3630   if TMPDAM>50 then gotoxy 40,3: print " DANGER! System Warning. "
3640   if TMPDAM>90 then PI=3700
3650   color 2
3660  return
3670  '
3680  REC:
3690   restore COLOR.STRING.0: gosub KOLOR: HOME=OFF: RED.ALERT=FALSE
3700   for X=0 to 7
3710      for Y=0 to 7
3720           gotoxy ( X+10 )*2,Y: print A.BLANK$: SECT%( X,Y )=EMPTY
3730      next
3740   next
3750   SECT%( ( PLX-20 )/2,PLY )=ENTERPRISE: X=( GX-2 )/2: Y=GY
3760   TOTAL.BASES=int( MAP%( Y, X )/100 )
3770   NUMBER.KLINGONS=int( MAP%( Y,X )/10 )-( TOTAL.BASES*10 )
3780   NUMBER.STARS=MAP%( Y,X )-(NUMBER.KLINGONS*10)-(TOTAL.BASES*100)
3790   Z=0: color 1
3800   while Z13 and MX<319 and MY>102 and MY<178
4150      gosub GET.MOUSE
4160      if BUTTON=LEFT then gosub DO.LIBRARY
4170   wend
4180   if WR=OFF then POINTER=ARROW: gosub SET.MOUSE.SHAPE: return
4190  ALT.LIBRARY:
4200   color 2
4210   gotoxy 2,9:  print "  L i b r a r y  F u n c t i o n s   "
4220   gotoxy 2,10: print "_____________________________________"
4230   gotoxy 2,11: print "     Status & Repair Scheduling      "
4240   gotoxy 2,12: print "     Cumulative Galactic Record      "
4250   gotoxy 2,13: print "    Long Range Galactic Scanning     "
4260   gotoxy 2,14: print "      Leave Marker Buoy Behind       "
4270   gotoxy 2,15: print "                                     "
4280   color 3
4290   gotoxy 2,16: print "   Exit Library to clear Function    "
4300   POINTER=ARROW: gosub SET.MOUSE.SHAPE: WR=OFF
4310  return
4320  '
4330  DO.LIBRARY:
4340   if MY>120 and MY<130 then WR=ACTIVE: gosub REPAIR
4350   if MY>130 and MY<140 then WR=ACTIVE: gosub GALAXYMAP
4360   if MY>140 and MY<150 then WR=ACTIVE: gosub SCAN.GALAXY
4370   if FALL=1 and MY>149 and MY<160 then gosub SET.MARKER.BUOY
4380  return
4390  '
4400  SCAN.GALAXY:
4410   gosub SCAN: gosub GALAXYMAP: gosub SCAN
4420  return
4430  '
4440  SET.MARKER.BUOY:
4450   gosub CLEAN: gotoxy 50,2: print " Buoy Set ";BELL$
4460   MK=ACTIVE
4470  return
4480  '
4490  GALAXYMAP:
4500   if FALL<>1 then return
4510   for Y=9 to 16
4520      gotoxy 2,Y: print "                                     "
4530   next
4540   color 3
4550   for X=0 to 7
4560      for Y=0 to 7
4570           if GY=X and ( GX-2 )/2=Y then color 2
4580           gotoxy 2+4*Y,X+9
4590           if MAP%(X,Y)<0 then print " ..." else print  MAP%(X,Y)
4600           IT=int( rnd*( 500-COMP ) )
4610           if IT<5*COMP then gotoxy 2+4*Y,X+9: print  " .?."
4620           color 3
4630      next
4640   next
4650  return
4660  '
4670  SCAN:
4680   if PI+1200 >3600 then gosub ENGY: return
4690   for Y=GX/2-2 to GX/2
4700      for X=GY-1 to GY+1
4710           if X>7 or X<0 or Y>7 or Y<0 then 4730
4720           if GY<>X or (GX-2)/2<>Y then MAP%(X,Y)=MAP%(X,Y)*-1-1
4730      next
4740   next
4750   PI=PI+600: gosub PIE
4760  return
4770  '
4780  MOVESHIP:
4790   if FALL=0 then return
4800   gosub CLEAN: if RED.ALERT=TRUE then gosub REBUTAL
4810   X=2*int( MX/18+.27 ): Y=int( MY/9-.5 )-2
4820   color 1
4830   IT=SECT%(( X-20 )/2, Y )
4840   if IT=STAR or IT=KLINGON then gotoxy 44,4
4842   if IT=STAR then print "Sir, that's a Star.": return
4852   if IT=KLINGON then print "Sir, that's a Klingon.": return
4860   QX=MX: QY=MY
4870   if HOME=OFF then gotoxy PLX,PLY: print A.BLANK$
4880   DIST=int( sqr( ( X-PLX )^2+( Y-PLY )^2 ) )^2.10: PI=PI+DIST
4890   PLX=X: PLY=Y
4900   if ( BX<>PLX or BY<>PLY ) and HOME=ACTIVE then HOME=OFF
4910   if IT=STARBASE then gosub DOCK
4920   if HOME=OFF then gotoxy PLX,PLY: print chr$( ENTERPRISE )
4930   gosub SET
4940  return
4950  '
4960  DOCK:
4970   PHOT=0: PI=0: gosub ALT.XREPAIR: gosub PIE
4980   HOME=ACTIVE: color 1
4990   gotoxy 44,1: print "Welcome to Star Base";BELL$
5000   if RED.ALERT=FALSE then restore COLOR.STRING.0: gosub KOLOR
5010   if RED.ALERT=FALSE then gotoxy 46,2: print " Repair Available "
5020   BX=PLX: BY=PLY: BON=ACTIVE
5030  return
5040  '
5050  REPAIR:
5060   CS=int( 100-COMP ): PS=int( 100-PHASE )
5070   TS=int( 100-TOR ): SS=int( 100-SHE )
5080   CG=CS: SG=SS: TG=TS: PG=PS
5090   color 2
5100   gosub STATUS
5110   gosub SHOW.STATUS.LINE
5120   gosub UPDATE.SHIELDS
5130   gosub UPDATE.PHASERS
5140   gosub STAT.UPDATE
5150   gosub SHOW.AUTHORIZATION.MESSAGE
5160   while MX>13 and MX<319 and MY>102 and MY<178
5170      color int( rnd*3 )+1
5180      if SG>90 or SG90 or PG90 or CG20 and TMPT>20 then gosub MORE.LEFT
5310   if MY>145 and MY<180 then gosub XREPAIR: gosub PIE: MY=10
5320  return
5330  '
5340  MORE.LEFT:
5350   if MY>110 and MY<120 and CG<=99 then gosub C.LEFT
5360   if MY>120 and MY<130 and SG<=99 then gosub S.LEFT 
5370   if MY>130 and MY<140 and PG<=99 then gosub P.LEFT
5380  return
5390  '
5400  DO.RIGHT:
5410   if MY>110 and MY<120 and CG>CS then gosub C.RIGHT
5420   if MY>120 and MY<130 and SG>SS then gosub S.RIGHT
5430   if MY>130 and MY<140 and PG>PS then gosub P.RIGHT
5440  return
5450  '
5460  C.LEFT:
5470   CG=CG+C: TMPDAM=0: gosub STATUS
5480   gosub UPDATE.COMPUTER: gosub STAT.UPDATE
5490  return
5500  '
5510  S.LEFT:
5520   SG=SG+S: TMPDAM=0: gosub STATUS
5530   gosub UPDATE.SHIELDS: gosub STAT.UPDATE
5540  return
5550  '
5560  P.LEFT:
5570   PG=PG+P: gosub STATUS
5580   gosub UPDATE.PHASERS: gosub STAT.UPDATE
5590  return
5600  '
5610  C.RIGHT:
5620   CG=CG-C: gosub STATUS
5630   gosub UPDATE.COMPUTER: gosub STAT.UPDATE
5640  return
5650  '
5660  S.RIGHT:
5670   SG=SG-S: gosub STATUS
5680   gosub UPDATE.SHIELDS: gosub STAT.UPDATE
5690  return
5700  '
5710  P.RIGHT:
5720   PG=PG-P: gosub STATUS
5730   gosub UPDATE.PHASERS: gosub STAT.UPDATE
5740  return
5750  '
5760  STATUS:
5770   NPI=int( ( 3600-PI )/10 ): NDATE=int( ( 3600-DATE )/10 )
5780   CE=int( ( CG-CS )*1.5 )
5782   SE=int( ( SG-SS )*1.7 )
5790   PE=int( ( PG-PS )*1.6 )
5800   CT=int( ( CG-CS )*0.5 )
5802   ST=int( ( SG-SS )*.34 )
5810   PT=int( ( PG-PS )*.42 )
5820   TOTE=int( CE+SE+PE+TE )
5822   TOTT=int( CT+ST+PT+TT )
5830   if HOME=ACTIVE then TOTE=0
5840   TMPI=NPI-TOTE: TMPT=NDATE-TOTT
5850  return
5860  '
5870  SHOW.STATUS.LINE:
5880   color 2
5890   gotoxy 2,9: print "           STATUS  GOAL  ENERGY  DAYS"
5900   color 3
5910  '
5920  UPDATE.COMPUTER:
5930   gotoxy 2,10: print " Computer->  ";
5940   print using"###_%  ";CS,CG;
5942   print using"   ###";CE,CT: return
5950  '
5960  UPDATE.SHIELDS:
5970   gotoxy 2,11: print " Shields ->  ";
5980   print using"###_%  ";SS,SG;
5982   print using"   ###";SE,ST: return
5990  '
6000  UPDATE.PHASERS:
6010   gotoxy 2,12: print " Phaser  ->  ";
6020   print using"###_%  ";PS,PG;
6022   print using"   ###";PE,PT: return
6030  '
6040  STAT.UPDATE:
6050   color 2: gotoxy 2,13: print " New Total ------------->";
6060   print using"   ###";TMPI,TMPT: color 3
6070  return
6080  '
6090  SHOW.AUTHORIZATION.MESSAGE:
6100   color 1: gotoxy 2,14
6102   print "            # AUTHORIZE #          "
6110   color 1: gotoxy 2,15
6112   print "            #  REPAIRS  #          "
6120   color 2: gotoxy 2,16
6130   print  FOE;"Klingons  ";NPI;"Energy   ";NDATE;"Days"
6140  return
6150  '
6160  XREPAIR:
6170   if RED.ALERT=TRUE then return
6180   PI=PI+TOTE*10: DATE=DATE+TOTT*10: gotoxy 44,2: print  BELL$
6190   if HOME=ACTIVE then PI=0
6200   COMP=100-CG: PHASE=100-PG: TOR=100-TG: SHE=100-SG
6210  ALT.XREPAIR:
6220   color 3,3,3,1: KY=140
6230   for KX=383 to 590 step 95: pcircle KX,KY,28: next
6240   KY=103: for KX=383 to 590 step 95: pcircle KX,KY,28: next
6250  return
6260  '
6270  SETUP:
6280   for X=0 to 7: for Y=0 to 7: MAP%( X,Y )=-1: next: next
6290   for XX=0 to 450
6300      X=int( RND*8 ): Y=int( RND*8 )
6310      if MAP%( X,Y )>-9 then MAP%( X,Y )=MAP%( X,Y )-1
6320   next
6322   FOE=0
6330   for XX=0 to int( RND*3 )+30+HCAP
6340      X=int( RND*8 ): Y=int( RND*8 )
6342      IT=MAP%( X,Y )
6350      if IT>-30 then MAP%( X,Y )=( IT-10 ): FOE=FOE+1
6360   next
6370   for XX=0 to int( RND*3 )+3
6380      X=int( RND*8 ): Y=int( RND*8 )
6390      if MAP%( X,Y )>-100 then MAP%( X,Y )=MAP%( X,Y )-100
6400   next
6410  return
6420  '
6430  FLASH:
6440   KOL=KOL+256: if KOL>1792 then KOL=0
6450   KOL%( 0 )=KOL: for A=1 to 3: KOL%( A )=KOL+1: next
6460   defdbl K: K = 1114: poke K,varptr( KOL%( 0 ) )
6470  return
6480  '
6490  KOLOR:
6500   A#=GB: CONTROL=peek( A# ): GINTIN=peek( A#+8 )
6510   for A=0 to 3: read B: KOL%( A )=B: next
6520   defdbl K: K = 1114: poke K,varptr( KOL%( 0 ) )
6530  return
6540  '
6550  COLOR.STRING.0:
6560   data 2,1287,7,1891
6570  COLOR.STRING.1:
6580   data 1,1536,7,1891
6590  COLOR.STRING.2:
6600   data 1600,1600,1600,2
6610  COLOR.STRING.3:
6620   data 2,83,7,1891
6630  '
6640  SET.MOUSE.SHAPE:
6650   poke CONTRL,78: poke CONTRL+2,1
6660   poke CONTRL+4,1: poke CONTRL+6,1
6670   poke CONTRL+8,0: poke GINTIN,POINTER
6680   gemsys( GRAF.MOUSE )
6690  return
6700  '
6710  SHOW:
6720   poke CONTRL,122: poke CONTRL+2,0
6730   poke CONTRL+6,1: poke CONTRL+12,HANDLE
6740   poke INTIN,0
6750   vdisys( 0 )
6760  return
6770  '
6780  SHRINKBOX:
6790   poke CONTROL,74: poke CONTROL+2,8
6800   poke CONTROL+4,1: poke CONTROL+6,0
6810   poke CONTROL+8,0: poke GINTIN,QX
6820   poke GINTIN+2,QY: poke GINTIN+4,6
6830   poke GINTIN+6,6: poke GINTIN+8,16
6840   poke GINTIN+10,24: poke GINTIN+12,142
6850   poke GINTIN+14,70
6860   gemsys( GRAF.SHRINKBOX )
6870  return
6880  '
6890  GROWBOX:
6900   poke CONTROL,73: poke CONTROL+2,8
6910   poke CONTROL+4,1: poke CONTROL+6,0
6920   poke CONTROL+8,0: poke GINTIN,QX
6930   poke GINTIN+2,QY: poke GINTIN+4,6
6940   poke GINTIN+6,6: poke GINTIN+8,177
6950   poke GINTIN+10,24: poke GINTIN+12,142
6960   poke GINTIN+14,70
6970   gemsys( GRAF.GROWBOX )
6980  return
6990  '
7000  POLYLINE:
7010   poke CONTRL,6: poke CONTRL+2,PN
7020   poke CONTRL+4,0: poke CONTRL+12,HANDLE
7030   poke PTSIN,0+X: poke PTSIN+2,0+X
7040   poke PTSIN+4,639-X: poke PTSIN+6,0+X
7050   poke PTSIN+8,639-X: poke PTSIN+10,199-X: poke PTSIN+12,0+X
7060   poke PTSIN+14,199-X: poke PTSIN+16,0+X: poke PTSIN+18,0+X
7070   vdisys( 0 )
7080  return
7090  '
7100  PRSTRING:
7110   read ST,XST,YST
7120   poke CONTRL,8: poke CONTRL+2,1
7130   poke CONTRL+6,ST: poke CONTRL+12,HANDLE
7140   for X=0 to ST*2-1 step 2: read CH: poke INTIN+X,CH: next
7150   poke PTSIN,XST: poke PTSIN+2,YST
7160   vdisys( 0 )
7170  return
7180  '
7190   data 23,226,8,9,0,0,0,70,0,85,0,69
7200   data 0,76,0,0,0,76,0,79,0,87,0,0,0,9
7210  PSTRING.001:
7220   data 23,226,8,237,0,0,0,83,0,84,0,65,0,82,0,84,0,82,0,69
7230  COLOR.STRING.4:
7240   data 0,75,0,0,0,237
7250  PSTRING.002:
7260   data 34,42,20,84,72,69,0,0,71,65,76,65,88,89,0,0,0,0,0,0,0
7270   data 80,82,69,83,69,78,84,0,81,85,65,68,82,65,78,84
7280  RED.MESSAGE:
7290   data 23,388,20,42,0,0,82,0,69,0,68
7300   data 0,0,0,65,0,76,0,69,0,82,0,84,0,0,42