Compucolor.org – Virtual Media

Listing of file='STTREK.BAS;0A' on disk='vmedia/taylor_vol_2-sector.ccvf'

0 REM  *** ENHANCED STAR TREK WITH SOUND BY TREVOR TAYLOR ***
1 GOTO 60000:REM  SET UP SOUND/SCROLL PATCHES - COME BACK HERE
2 DIM D(8),X(9),Y(9),G(8,8),Z(8,8),I(9),J(9),K(9),C$(3),P$(6)
3 PLOT 15,29,6,2,12,27,24,27,4:PRINT "LOA STTREK.PIC":PLOT 255
4 X= 0:Y= 21:H= 11:W= 40:C= 1:GOSUB 64000:GOTO  90
5 L= L+ 1:IF L> 31THEN ZZ= CALL (1):L= 31
6 GOSUB 7:PRINT SPC( 40)""
7 PLOT 3,0,L:RETURN
9 GOSUB 5:GOTO 5
10 A= INT (Z/ 100):B= INT ((Z- A* 100)/ 10):C= Z- 100* A- 10* B:RETURN
15 Z= G(U,V):GOSUB 10:RETURN
20 P= INT (Z/ 100):PLOT 3,P,Z- 100* P:RETURN
30 PLOT 3,37+ 3* Q,1+ P+ P:Z= G(P,Q):GOTO 45
35 PLOT 31:GOSUB 36:PLOT 15:RETURN
36 P= U:Q= V:GOTO 30
45 GOSUB 10:PLOT 17:PRINT U$(A);:PLOT 19+ B:PRINT U$(C):RETURN
50 Z(P,Q)= Z
51 PLOT 3,8+ 3* Q,1+ P+ P:PRINT P$(Z):RETURN
55 Z= 0:GOTO 50
56 Z= 2:P= X:Q= Y:GOTO 50
57 P= P2:Q= Q2:GOTO 50
90 DEF FN R(R)= INT (R* RND (1)+ 1):DEF FN D(I)= SQR ((I(I)- X)^ 2+ (J(I)- Y)^ 2)
91 DEF FN P(Q)= INT (Q/ W/ FN D(I)* (2+ RND (1))):DEF FN O(R)= P< 1OR P> 8OR Q< 1OR Q> 8
92 DEF FN X(S)= X(S)+ (S- INT (S))* (X(S+ 1)- X(S)):DEF FN Y(S)= Y(S)+ (S- INT (S))* (Y(S+ 1)- Y(S))
1000 REM  STILL INITIALISING
1001 RESTORE 1001:READ F,H:DATA 30,3000
1002 FOR I= 1TO 9:READ Y(I),X(I):NEXT
1003 DATA 0,1,-1,1,-1,0,-1,-1,0,-1,1,-1,1,0,1,1,0,1
1010 U$(0)= " ":FOR I= 1TO 9:U$(I)= CHR$ (48+ I):NEXT
1020 L= 20:GOSUB 5:INPUT "STAR DATE ? ";D:D= INT (D):IF D< 1OR D> 9900THEN 1020
1030 W= RND (- D):F= F+ D:N= 0
1040 FOR I= 1TO 8:FOR J= 1TO 8:R= RND (1):A= - (R> .8)- (R> .95)- (R> .98):E= E+ A
1042 B= - (RND (1)> .96):G= G+ B:C= FN R(9):G(I,J)= 100* A+ 10* B+ C:NEXT :NEXT
1044 IF G= 0THEN G= 1:P= FN R(8):Q= FN R(8):G(P,Q)= G(P,Q)+ 10
1050 U= FN R(8):V= FN R(8):X= FN R(8):Y= FN R(8)
1060 FOR I= 0TO 6:READ P$(I):NEXT :DATA "  "," *","]O",">-","##","**","**"
1070 FOR I= 1TO 8:GOSUB 2390:NEXT
1080 O= 10:FOR I= 0TO 3:READ C$(I):NEXT :DATA "GRN","YEL","RED","DCK"
1090 GOSUB 2400:GOSUB 2000
1095 GOSUB 9:PRINT "NUMBER OF STARBASES: ";G;
1100 N= 0:IF E= 0THEN 1900
1102 GOSUB 15:IF A> 0AND M+ H< 6AND N< 3THEN 1930
1103 IF H< 8AND D(7)< 0GOTO 1930
1110 GOSUB 2200:GOSUB 2400:GOSUB 2100:GOSUB 2050
1111 GOSUB 9:OUT  8,255:PRINT "COMMAND: ";
1112 GOSUB  40000:T =  QN
1115 IF T< 0OR T> 4THEN 1100
1120 ON  T+ 1 GOSUB 1400,1500,1600,1700,1800
1125 OUT  8,247
1130 GOSUB 5000:GOTO 1100
1400 REM  *** MOVE COMMAND ***
1401 GOSUB 5:INPUT "COURSE (0-360): ";S:IF S< 0THEN RETURN
1402 IF S> 360THEN 1400
1403 S= S/ 45+ 1
1404 IF S= 9THEN S= 1
1406 GOSUB 5:INPUT "WARP FACTOR (0-8): ";T:IF T< 0OR T> 8THEN 1400
1410 IF D(1)< 0AND T> .125THEN GOSUB 9:PRINT "MAXIMUM SPEED = WARP .125":GOTO 1406
1412 OUT  8,247
1414 R= INT (8* T+ .5):IF R= 0THEN R= 1
1415 SR= R
1416 RH= INT (5+ 3* R+ .05* R* R):IF RH< = HTHEN 1430
1422 GOSUB 9:PRINT "MOVE REQUIRES"RH" ENERGY UNITS":RETURN
1430 GOSUB 15:IF A> 0THEN GOSUB 3000
1431 R= SR:GOSUB 2300
1432 IF  T> = 1 THEN  PI= 100:DU= 2:NS= 95:S1= 255:S2= 0:GOSUB  63000
1435 P= X:Q= Y:GOSUB 55
1438 K= 1:GOTO 3400
1440 PI= 900:DU= 10:NS= 10:S1= 254:S2= 2:GOSUB  63000
1441 GOSUB 3490:X= P:Y= Q:GOSUB 9:PRINT "WARP ENGINES SHUTDOWN"
1442 GOSUB 5:PRINT "  AT SECTOR "U$(X)","U$(Y)
1444 GOSUB 5:PRINT "  DUE TO BAD NAVIGATION":GOTO 1452
1450 X= P:Y= Q
1452 GOSUB 56
1453 H= H- RH:IF T> = 1THEN D= D+ 1
1454 GOSUB 35:IF D> = FTHEN 1920
1456 RETURN
1480 GOSUB 36
1482 P2= INT (U* 8+ X+ P1* R+ .5):Q2= INT (V* 8+ Y+ Q1* R+ .5)
1484 P= INT ((P2- 1)/ 8):Q= INT ((Q2- 1)/ 8):IF FN O(P)THEN R= R- 1:GOTO 1482
1486 U= P:V= Q:X= P2- U* 8:Y= Q2- V* 8:GOSUB 2000:GOTO 1453
1500 REM  *** SHIELD COMMAND ***
1501 IF D(7)> = 0GOTO 1510
1505 GOSUB 5:PRINT "SHIELD CONTROL DOWN";:RETURN
1510 GOSUB 5:INPUT "UNITS TO SHIELDS: ";T:IF T< = 0THEN RETURN
1520 IF H+ M< TTHEN 1510
1525 OUT  8,247
1530 T= INT (T):H= H+ M- T:M= T:RETURN
1600 REM  *** PHASER COMMAND ***
1601 GOSUB  15:IF (D(2)> = 0)AND (D(4)> = 0)GOTO 1603
1602 GOSUB 5:PRINT "PHASERS USELESS":RETURN
1603 IF A< > 0GOTO 1605
1604 GOSUB 5:PRINT "NO KLINGONS!":RETURN
1605 IF N< > 3GOTO 1610
1606 GOSUB 5:PRINT "NOT POSSIBLE - DOCKED":RETURN
1610 GOSUB 5:INPUT "UNITS TO FIRE: ";T:IF T< = 0THEN RETURN
1620 IF T> HTHEN GOSUB 5:PRINT "ENERGY NOT AVAILABLE":GOTO 1610
1625 OUT  8,247
1630 T= INT (T):H= H- T:GOSUB 3000:IF D(8)< 0THEN GOSUB 5:PRINT "LOSS OF ACCURACY":T= FN R(T)
1635 W= A
1637 FOR I= 1 TO  W:PI= 15:DU= 10:NS= 30:S1= 1:S2= 0:GOSUB  63000:NEXT  I
1640 FOR I= 1TO 9:IF K(I)< = 0THEN 1690
1650 R= FN P(T):K(I)= K(I)- R:GOSUB 9:PRINT ""R" UNIT HIT ON KLINGON"
1660 GOSUB 3100:IF D(2)> = 0 THEN  PRINT " ("K(I)" LEFT)"
1670 IF K(I)< = 0THEN GOSUB 3300
1690 NEXT :RETURN
1700 REM  *** TORPEDO COMMAND ***
1702 IF N< > 3GOTO 1704
1703 GOSUB 5:PRINT "NOT POSSIBLE - DOCKED":RETURN
1704 IF O> 0GOTO 1706
1705 GOSUB 5:PRINT "NO TORPEDOS LEFT":RETURN
1706 IF D(5)> = 0GOTO 1710
1707 GOSUB 5:PRINT "PHOTON TUBES DOWN":RETURN
1710 REM  OK TO FIRE TORPEDO
1715 GOSUB 5:INPUT "TORPEDO COURSE (0-360): ";S:IF S< 0THEN RETURN
1716 IF S> 360THEN 1715
1717 OUT  8,247
1718 O= O- 1:S= S/ 45+ 1:IF S= 9THEN S= 1
1719 GOSUB 15:IF A> 0THEN GOSUB 3000
1720 PI= 15:DU= 30:NS= 80:S1= 1:S2= 0:GOSUB  63000:K= 2:R= 99:GOTO 3400
1730 GOSUB 1770:Z= 1:GOSUB 57:GOSUB 9:PRINT "YOU CAN'T DESTROY STARS":GOSUB 1780:Z= 1:GOTO 57
1750 GOSUB 1770:Z= 6:GOSUB 57:G(U,V)= G(U,V)- 10:G= G- 1:GOSUB 35:GOSUB 9
1752 PRINT "YOU DESTROYED YOUR STAR BASE":GOSUB 1780:Z= 0:GOSUB 57:GOTO 55
1760 GOSUB 3490:GOSUB 1770:GOSUB 9:PRINT "TORPEDO MISSED":GOTO 1780
1770 P2= P:Q2= Q:GOSUB 1790:GOTO 56
1780 PLOT 30:GOSUB 1790:PLOT 29:GOTO 56
1790 PLOT 6,7
1791 PLOT 2,253,18+ 6* Y,122- 8* X,242,18+ 6* Q2,122- 8* P2,255:RETURN
1800 REM  *** COMPUTER COMMAND ***
1805 IF D(8)> = 0GOTO 1820
1810 GOSUB 5:PRINT "COMPUTER DOWN":RETURN
1820 GOSUB 5:INPUT "TARGET SECTOR: ";P,Q
1821 P= INT (P):Q= INT (Q)
1823 IF (P= X)AND (Q= Y)THEN 1820
1824 IF FN O(R)THEN 1820
1825 OUT  8,247:PX =  X- P:QY =  Q- Y
1826 NS= 1:S1= 0:S2= 0:DU= 50:FOR I= 1TO 10:PI= (10+ RND (1)* 30):GOSUB  63000:NEXT
1827 IF (QY< > 0)THEN 1831
1828 IF PX> 0THEN AG= 90
1829 IF PX< 0THEN AG= 270
1830 GOTO 1840
1831 AG= 180* ATN (PX/ QY)/ 3.14159
1832 IF (PX> = 0)AND (QY> 0)GOTO 1840
1833 IF QY< 0THEN AG= AG+ 180
1835 IF AG< 0THEN AG= AG+ 360
1840 AG= INT (AG+ .25):GOSUB 5:PRINT "COURSE ";AG;" DEGREES"
1841 P1= FN Y(AG/ 45+ 1):Q1= FN X(AG/ 45+ 1)
1842 P2= X:Q2= Y
1843 PX= P:QY= Q
1845 FOR I= 1TO 8
1846 P= INT (P2+ P1+ .5):Q= INT (Q2+ Q1+ .5)
1847 P2= P2+ P1:Q2= Q2+ Q1
1848 IF (PX= P)AND (QY= Q)GOTO 1855
1849 IF FN O(R)THEN 1854
1850 IF Z(P,Q)= 0THEN 1853
1851 GOSUB 5:PRINT "OBSTACLE IN PATH";
1853 NEXT I
1854 GOSUB 5:PRINT "COMPUTER MALFUNCTION":RETURN
1855 AG= I/ 8
1880 GOSUB 5:PRINT "DISTANCE ";AG;" PARSECS";
1890 RETURN
1900 GOSUB 9:PRINT "MISSION ACCOMPLISHED";
1902 GOSUB 5:PLOT  31:PRINT "ALL KLINGONS DESTROYED":PLOT  15
1905 CLEAR  500:GOSUB  50040:GOTO 1992
1920 GOSUB 9:PRINT "OUT OF TIME"
1925 GOSUB 5:PRINT "MISSION FAILED":GOTO  1990
1930 GOSUB 9:PRINT "DEAD IN SPACE"
1935 GOSUB 5:PRINT "YOU WILL DRIFT FOREVER...":GOTO 1990
1940 R= 3:FOR I= 1TO 5:PLOT 30,16+ FN R(R),12
1950 PI= 800+ INT (100* RND (1)):DU= 3:NS= INT (10* RND (2)):S1= 130:S2= 126
1955 GOSUB  63000:NEXT  I
1960 PLOT 6,1,12,14,3,10,10,31:PRINT "ENTERPRISE DESTROYED"
1970 PLOT 15,14,3,10,15:PRINT "MISSION FAILED"
1980 PI= 900:DU= 10:NS= 10:S1= 254:S2= 2:GOSUB  63000
1990 FOR  I= 1 TO  3000:NEXT
1992 PLOT  6,2,12,14
1993 OUT  8,255
1994 PRINT  "ANOTHER MISSION ? (Y/N) ";
1995 AN =  CALL (2)
1996 IF  AN= ASC ("Y") THEN  CLEAR  500:GOTO  2
1997 PLOT  6,2,12,15,27,11
1998 LOAD "MENU":RUN
2000 FOR I= 1TO 8:FOR J= 1TO 8:Z(I,J)= 0:NEXT :NEXT :Z= G(U,V):GOSUB 10
2010 Z(X,Y)= 2:Z= 1:FOR I= 1TO C:GOSUB 2090:NEXT
2020 IF BTHEN Z= 4:GOSUB 2090
2030 FOR I= 1TO 9:I(I)= 0:J(I)= 0:K(I)= 0:NEXT
2040 Z= 3:IF ATHEN FOR I= 1TO A:GOSUB 2090:I(I)= P:J(I)= Q:K(I)= 100+ FN R(200):NEXT
2050 FOR I= 1TO 8:PLOT 3,10,1+ I+ I:FOR J= 1TO 8:PLOT 25:PRINT P$(- (D(2)= 0OR Z(I,J)= 2)* Z(I,J));:NEXT
2060 PRINT :NEXT :RETURN
2090 P= FN R(8):Q= FN R(8):IF Z(P,Q)THEN 2090
2092 Z(P,Q)= Z:RETURN
2100 IF D(3)< 0THEN RETURN
2110 FOR I= U- 1TO U+ 1:FOR J= V- 1TO V+ 1:P= I:Q= J:IF FN O(X)THEN 2130
2120 ON 1- (I= UAND J= V)GOSUB 30,35
2130 NEXT J:NEXT I:RETURN
2200 FOR P= X- 1TO X+ 1:FOR Q= Y- 1TO Y+ 1:IF FN O(X)THEN 2220
2210 IF Z(P,Q)= 4THEN 2280
2220 NEXT Q:NEXT P
2230 GOSUB 15:IF  A< = 0 OR  M> = 200 THEN  RETURN
2235 PI= 50:DU= 100:NS= 20:S1= 20:S2= 236:GOSUB  63000:N= 2:RETURN
2240 IF H< 300THEN N= 1
2250 RETURN
2280 FOR I= 1TO 8:D(I)= 0:NEXT :GOSUB 9:PRINT "  ENTERPRISE DOCKED"
2285 N= 3:GOSUB 2300
2290 H= 2900:M= 100:O= 10:GOSUB 5:PRINT "  SHIELDS DROPPED":RETURN
2300 DC= (D(6)= 0):FOR I= 1TO 8:IF D(I)= 0GOTO 2312
2310 D(I)= D(I)+ 1:IF D(I)> 0THEN D(I)= 0
2312 IF DCTHEN GOSUB 2390
2320 NEXT I:GOSUB 2370:IF N= 3THEN RETURN
2325 IF RND (1)> .325THEN RETURN
2330 I= FN R(8):IF RND (1)> .5THEN 2340
2332 D(I)= D(I)- (5* RND (1)+ 1):GOTO 2390
2340 D(I)= D(I)+ (5* RND (1)+ 1):IF D(I)> 0THEN D(I)= 0
2342 IF DCTHEN GOSUB 2390
2370 IF DCOR D(6)< 0THEN RETURN
2380 FOR I= 1TO 8:GOSUB 2390:NEXT :RETURN
2390 PLOT 3,61,23+ I:IF D(I)> = 0THEN PRINT "UP ":RETURN
2392 IF D(6)< 0THEN PRINT "DN ":RETURN
2394 IF D(I)> = - 1THEN PRINT "DN ":RETURN
2396 PRINT "DN";:DD= ABS (INT (D(I))):IF DD> 9THEN DD= 9
2398 PLOT 48+ DD:RETURN
2400 GOSUB 2420:GOSUB 2430:GOSUB 2440
2410 PLOT 3,3,3,19:PRINT RIGHT$ ("  "+ STR$ (D),4):PLOT 3,60,20:PRINT C$(N):RETURN
2420 PLOT 3,0,9:PRINT ""RIGHT$ ("  "+ STR$ (H),4)"/"RIGHT$ ("  "+ STR$ (M),4)
2422 PLOT 3,3,12,18:PRINT RIGHT$ ("  "+ STR$ (O),4):RETURN
2430 PLOT 3,3,6,19:PRINT RIGHT$ ("  "+ STR$ (F- D),4)
2432 PLOT 3,3,15,17:PRINT RIGHT$ ("  "+ STR$ (E),4):RETURN
2440 PLOT 8,18,14,25,U+ 48,25,V+ 48,25,25,X+ 48,25,Y+ 48,15:RETURN
3000 IF N= 3THEN GOSUB 9:PRINT "STAR BASE SHIELDS ENTERPRISE":RETURN
3010 GOSUB 15:W= A:IF A= 0THEN RETURN
3020 FOR I= 1TO 9:IF K(I)< = 0THEN 3080
3025 PI= 40:DU= 20:NS= 40:S1= 254:S2= 1:GOSUB  63000
3030 R= W* FN P(K(I)):M= M- R:GOSUB 9:PRINT ""R" UNIT HIT ON ENTERPRISE"
3040 GOSUB 3100:PRINT :GOSUB 2420:IF M< 0THEN 1940
3080 NEXT I
3085 GOSUB 2300:RETURN
3100 IF D(2)> = 0THEN GOSUB 5:PRINT "  AT SECTOR "U$(I(I))","U$(J(I));
3110 RETURN
3300 R= 0:P2= I(I):Q2= J(I):GOTO 3315
3310 R= 1:GOSUB 1770:FOR I= 1TO 9:IF INT (P2)= I(I)AND INT (Q2)= J(I)THEN 3315
3312 NEXT I
3315 Z= 5:GOSUB 57
3317 PI= 780:DU= 5:NS= 20:S1= 129:S2= 127:GOSUB  63000
3320 GOSUB 9:PRINT "*** KLINGON DESTROYED ***":GOSUB 3100:A= A- 1:E= E- 1
3330 G(U,V)= G(U,V)- 100:ON RGOSUB 1780:K(I)= 0:Z= 0:GOSUB 57:GOSUB 35:GOTO 2430
3400 P1= FN Y(S):Q1= FN X(S):P2= X:Q2= Y
3410 FOR I= 1TO R:P= INT (P2+ P1+ .5):Q= INT (Q2+ Q1+ .5):ON - FN O(P)* KGOTO 1480,1760
3420 IF K= 2THEN ON Z(P,Q)+ 1GOTO 3450,1730,3450,3310,1750
3430 IF Z(P,Q)< > 0THEN 1440
3450 P2= P2+ P1:Q2= Q2+ Q1:NEXT I:GOTO 1450
3490 P= INT (P2+ .5):Q= INT (Q2+ .5):RETURN
5000 GOSUB 15:IF B< > 0THEN RETURN
5010 FOR I= 1TO 8:FOR J= 1TO 8:S= INT (G(I,J)/ 100):IF S= 0THEN 5090
5020 R= ABS (I- U)+ ABS (J- V):IF R= 0OR R> 3THEN 5090
5030 FOR K= 1TO S:IF RND (1)< .5THEN 5080
5040 P= INT ((I+ U+ SGN (U- I))/ 2):Q= INT ((J+ V+ SGN (V- J))/ 2):T= INT (G(P,Q)/ 100)+ 1
5050 IF T= 10THEN 5090
5060 G(I,J)= G(I,J)- 100:G(P,Q)= G(P,Q)+ 100:IF P< > UOR Q< > VTHEN 5080
5065 Z= 3:GOSUB 2090:IF D(2)> = 0THEN GOSUB 50
5070 FOR T= 1TO 9:IF K(T)= 0THEN 5078
5072 NEXT
5078 I(T)= P:J(T)= Q:K(T)= 100+ FN R(200)
5080 NEXT K
5090 NEXT J:NEXT I:RETURN
40000 REM  READ A DIGIT FROM THE KEYBOARD, WITHOUT A <RETURN>
40010 REM  ONLY A NUMERIC VALUE IS ACCEPTED, AND ONE CHR ONLY.
40020 QN =  CALL (2)
40030 IF  QN< 48 OR  QN> 57 GOTO  40020
40040 PRINT  CHR$ (QN)
40050 QN =  QN- 48
40060 RETURN
50000 REM  DRAW THE ENTERPRISE AND PLAY THE THEME SONG
50010 REM  THIS KEEPS THE USER HAPPY FOR A WHILE IF HE HAS
50020 REM  SOUNDWARE, BUT BORES HIM STIFF IF HE DOESN'T!
50030 PLOT  15,6,2,12,27,4:PRINT  "LOAD SHIP.PIC":PLOT  27,27
50035 PLOT  14,3,12,27:PRINT  "S U P E R   S T A R   T R E K":PLOT  15,3,64,0
50040 REM  *** LOAD THE MUSIC ***
50050 FILE  "R",1,"STTREK.MUS",2
50060 GET  1;CT,CT
50070 DIM  PS(CT),DS(CT):REM  ****** NORMALLY THIS WILL BE ELSEWHERE
50080 FOR  I= 0 TO  CT
50090 GET  1;PS(I),DS(I)
50100 NEXT  I
50110 FILE  "C",1
50115 CT =  CT+ 1
50120 GOSUB  55000
50130 RETURN
55000 REM  *** GENERAL MUSIC REPLAY ROUTINE ***
55010 NS= 0:S1= 0:S2= 0:RL= 1:RH= CT
55020 FOR  I= RL- 1 TO  RH- 1:REM  COULD REPLAY ANY PART OF A TUNE
55030 IF  I> CT- 1 THEN  RETURN
55040 IF  I< 0 GOTO  55100
55050 PI= PS(I):DU= DS(I)
55060 IF  PI> 0 GOTO  55090
55070 FOR  J= 1 TO  DU:NEXT  J:REM  EXECUTE A PAUSE
55080 GOTO  55100
55090 GOSUB  63000:REM  PLAY THE NOTE
55100 NEXT  I
55110 RETURN
60000 REM  *** SOUND PATCH ***
60001 REM  THIS PATCH IS LOADED BY THE NEW COMPUCOLOR GENERAL MENU,
60002 REM  SO IT IS NOT NECESSARY. HOWEVER, THE LINK TO IT MUST
60003 REM  STILL BE SET UP. THE APPROACH HERE IS THE BRUTE FORCE METHOD.
60004 REM  THIS CODE IS TAKEN DIRECTLY FROM CAP ELECTRONICS.
60005 PLOT 6,2,12,14,3,12,15
60006 REM  USER NOTE: CHANGE DA IN STATEMENT 60010 TO:
60008 REM                    48962 FOR 16K MACHINES
60009 REM                 OR 65346 FOR 32K MACHINES
60010 DA= 65346
60011 REM  SHOULD REALLY DETERMINE MAXIMUM RAM AVAILABLE - TOO LAZY
60015 AD= 32940:GOSUB 60100:CLEAR 500
60019 REM   60020 FINDS TOP OF BASIC MEMORY
60020 TM= PEEK (32940)+ PEEK (32941)* 256
60021 POKE TM+ 1,50:POKE TM+ 2,0:POKE TM+ 3,15:POKE TM+ 4,0
60024 REM   60025 SETS THE CALL VECTOR
60025 AD= 33283:DA= TM+ 8:GOSUB 60100
60026 GOTO 60035
60030 REM  THE SOUND PATCH IS ALWAYS LOADED, EVEN IF ALREADY THERE
60035 PRINT "LOADING MACHINE LANGUAGE PATCHES"
60040 RESTORE 60200
60049 REM   60050 LOADS MACHINE LANGUAGE
60050 FOR N= 1TO 200:READ A:IF A> 255THEN N= 220:GOTO 60080
60060 IF A< 0THEN DA= TM- A:AD= TM+ N:GOSUB 60100:GOTO 60080
60070 POKE TM+ N,A
60080 NEXT
60090 GOTO 61000
60100 Z1= INT (DA/ 256):Z2= DA- Z1* 256
60110 POKE AD,Z2:N= N+ 1:POKE AD+ 1,Z1:RETURN
60199 REM        MACHINE LANGUAGE DATA
60200 DATA 50,0,15,0,0,0,0,123,254,0,194,-121,30,8,243
60210 DATA 58,-6,87,58,-7,254,0,194,-33,122,50,-7,42,-1
60220 DATA 34,-49,42,-3,34,-46,33,-22,1,50,0,11,120,177
60230 DATA 194,-51,123,238,2,211,4,95,43,124,181,194
60240 DATA -48,58,-5,254,0,202,-100,61,50,-5,58,-49,130
60250 DATA 50,-49,58,-7,103,122,50,-7,84,195,-45,50,-7
60260 DATA 50,-4,50,-2,62,15,50,-3,62,50,50,-1,251,201
60270 DATA 254,1,194,-158,33,0,0,6,4,14,17,17,128,0,25
60280 DATA 126,17,128,255,25,119,35,0,13,194,-133,17,8
60290 DATA 0,25,5,194,-131,201
60300 DATA 254,2,194,-182,245,229,197,205,36,0,194,-166
60310 DATA 95,175,87,50,255,129,193,225,241,201,201
60320 DATA 300
60330 REM  END OF PATCH
61000 GOSUB  50000:REM  DISPLAY SHIP AND PLAY MUSIC
61010 GOTO  2:REM  "RETURN" TO INITIALISATION
63000 REM  SOUND EXECUTER
63010 TM= PEEK (32940)+ PEEK (32941)* 256
63020 AD= TM+ 1:DA= PI:GOSUB  65400
63040 AD= TM+ 3:DA= DU:GOSUB  65400
63050 POKE  TM+ 5,NS:POKE  TM+ 6,S1:POKE  TM+ 7,S2
63060 XY =  CALL (0)
63070 RETURN
64000 REM  SET UP THE SCROLL PARAMETERS
64002 GOSUB 65410
64005 TM =  TM+ 125
64010 DA= 28672+ 128* Y+ X+ X:AD= TM+ 2:GOSUB 65400
64015 DA= 128- W- W:AD= TM+ 25:GOSUB 65400
64020 POKE TM+ 5,H- 1:POKE TM+ 7,W* (C+ 1):POKE TM+ 19,35* (1- C)
64030 RETURN
65400 ZZ= INT (DA/ 256):POKE AD,DA- 256* ZZ:POKE AD+ 1,ZZ:RETURN
65410 ER= 32940:TM= 256* PEEK (ER+ 1)+ PEEK (ER):RETURN