Compucolor.org – Virtual Media

Listing of file='STTREK.BAS;01' on disk='vmedia/startrek-sector.ccvf'

100 PLOT 27,24:TM= 256* PEEK (32941)+ PEEK (32940)
110 Z= TM+ 8:AD= 33283:GOSUB 160:TM= TM+ 1
120 X= 0:Y= 21:H= 11:W= 40:C= 1
130 Z= 28672+ 128* Y+ X+ X:AD= TM+ 126:GOSUB 160
140 Z= 128- W- W:AD= TM+ 149:GOSUB 160:POKE TM+ 129,H- 1
150 POKE TM+ 131,W* (C+ 1):POKE TM+ 143,35* (1- C):GOTO 170
160 ZZ= INT (Z/ 256):POKE AD,Z- 256* ZZ:POKE AD+ 1,ZZ:RETURN
170 GOTO 420:GOTO 1980
180 DIM D(8),X(9),Y(9),G(8,8),Z(8,8),I(9),J(9),K(9)
190 REM
200 GOTO 370
210 L= L+ 1:IF L= 32THEN ZZ= CALL (1):L= 31
220 GOSUB 230:PRINT SPC( 40)""
230 PLOT 3,0,L:RETURN
240 GOSUB 210:GOTO 210
250 A= INT (Z/ 100):B= INT ((Z- A* 100)/ 10):C= Z- 100* A- 10* B:RETURN
260 Z= G(U,V):GOSUB 250:RETURN
270 P= INT (Z/ 100):PLOT 3,P,Z- 100* P:RETURN
280 PLOT 3,37+ 3* Q,1+ P+ P:Z= G(P,Q):GOTO 310
290 PLOT 31:GOSUB 300:PLOT 15:RETURN
300 P= U:Q= V:GOTO 280
310 GOSUB 250:PLOT 17:PRINT U$(A);:PLOT 19- B:PRINT U$(C):RETURN
320 Z(P,Q)= Z
330 PLOT 3,8+ 3* Q,1+ P+ P:PRINT P$(Z):RETURN
340 Z= 0:GOTO 320
350 Z= 2:P= X:Q= Y:GOTO 320
360 P= P2:Q= Q2:GOTO 320
370 DEF FN R(R)= INT (R* RND (1)+ 1):DEF FN D(I)= SQR ((I(I)- X)^ 2+ (J(I)- Y)^ 2)
380 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
390 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))
400 GOTO 430
410 PLOT 15,6,2,12,27,24
420 PLOT 27,4:PRINT "LOA STTREK.PIC":PLOT 255:GOTO 180
430 REM
440 RESTORE 440:READ F,H:DATA 30,3000
450 FOR I= 1TO 9:READ Y(I),X(I):NEXT
460 DATA 0,1,-1,1,-1,0,-1,-1,0,-1,1,-1,1,0,1,1,0,1
470 U$(0)= " ":FOR I= 1TO 9:U$(I)= CHR$ (48+ I):NEXT
480 L= 20:GOSUB 210:INPUT "STAR DATE ? ";D:D= INT (D):IF D< 1OR D> 9900THEN 480
490 W= RND (- D):F= F+ D
500 FOR I= 1TO 8:FOR J= 1TO 8:R= RND (1):A= - (R> .8)- (R> .95)- (R> .98):E= E+ A
510 B= - (RND (1)> .96):G= G+ B:C= FN R(9):G(I,J)= 100* A+ 10* B+ C:NEXT :NEXT
520 IF G= 0THEN G= 1:P= FN R(8):Q= FN R(8):G(P,Q)= G(P,Q)+ 10
530 U= FN R(8):V= FN R(8):X= FN R(8):Y= FN R(8)
540 DIM P$(6):FOR I= 0TO 6:READ P$(I):NEXT :DATA "  "," *","O[","-<","``","**","**"
550 FOR I= 1TO 8:GOSUB 1490:NEXT
560 O= 10:DIM C$(3):FOR I= 0TO 3:READ C$(I):NEXT :DATA "GRN","YEL","RED","DCK"
570 GOSUB 1540:GOSUB 1190
580 N= 0:IF E= 0THEN 1130
590 GOSUB 260:IF A> 0AND M+ H< 6AND N< 3THEN 1160
600 GOSUB 1320:GOSUB 1540:GOSUB 1280:GOSUB 240:INPUT "COMMAND: ";T:IF T< 0OR T> 3THEN 580
610 ON T+ 1GOSUB 640,870,910,990
620 GOSUB 1800:GOTO 580
630 END
640 GOSUB 210:INPUT "COURSE (1-9): ";S:IF S= 0THEN RETURN
650 IF S< 1OR S> 9THEN 640
660 IF S= 9THEN S= 1
670 GOSUB 210:INPUT "WARP FACTOR (0-8): ";T:IF T< 0OR T> 8THEN 640
680 IF D(1)< 0AND T> .125THEN GOSUB 240:PRINT "MAXIMUM SPEED = WARP .125":GOTO 640
690 GOSUB 260:IF A> 0THEN GOSUB 1610
700 R= INT (8* T+ .5):IF R= 0THEN R= 1
710 RH= INT (5+ 3* R+ .05* R* R):IF RH< = HTHEN 730
720 GOSUB 240:PRINT "MOVE REQUIRES"RH" ENERGY UNITS":RETURN
730 GOSUB 1390:P= X:Q= Y:GOSUB 340
740 K= 1:GOTO 1740
750 GOSUB 1790:X= P:Y= Q:GOSUB 240:PRINT "WARP ENGINES SHUTDOWN"
760 GOSUB 210:PRINT "  AT SECTOR "U$(X)","U$(Y)
770 GOSUB 210:PRINT "  DUE TO BAD NAVIGATION":GOTO 790
780 X= P:Y= Q
790 GOSUB 350
800 H= H- RH:IF T> = 1THEN D= D+ 1
810 GOSUB 290:IF D> = FTHEN 1150
820 RETURN
830 GOSUB 300
840 P2= INT (U* 8+ X+ P1* R+ .5):Q2= INT (V* 8+ Y+ Q1* R+ .5)
850 P= INT ((P2- 1)/ 8):Q= INT ((Q2- 1)/ 8):IF FN O(P)THEN R= R- 1:GOTO 840
860 U= P:V= Q:X= P2- U* 8:Y= Q2- V* 8:GOSUB 1190:GOTO 800
870 IF D(7)< 0THEN RETURN
880 GOSUB 210:INPUT "UNITS TO SHIELDS: ";T:IF T< = 0THEN RETURN
890 IF H+ M< TTHEN 880
900 T= INT (T):H= H+ M- T:M= T:RETURN
910 GOSUB 260:IF D(2)< 0OR D(4)< 0OR A= 0OR N= 3THEN RETURN
920 GOSUB 210:INPUT "UNITS TO FIRE: ";T:IF T< = 0THEN RETURN
930 W= A:IF T> HTHEN GOSUB 210:PRINT "ENERGY NOT AVAILABLE":GOTO 920
940 T= INT (T):H= H- T:GOSUB 1610:IF D(8)< 0THEN GOSUB 210:PRINT "LOSS OF ACCURACY":T= FN R(T)
950 FOR I= 1TO 9:IF K(I)< = 0THEN 980
960 R= FN P(T):K(I)= K(I)- R:GOSUB 240:PRINT ""R" UNIT HIT ON KLINGON"
970 GOSUB 1670:PRINT " ("K(I)" LEFT)":IF K(I)< = 0THEN GOSUB 1690
980 NEXT :RETURN
990 IF D(5)< 0OR O= 0OR N= 3THEN RETURN
1000 GOSUB 210:INPUT "TORPEDO COURSE (1-9): ";S:IF S= 0THEN RETURN
1010 IF S< 1OR S> 9THEN 1000
1020 O= O- 1:IF S= 9THEN S= 1
1030 GOSUB 260:IF A> 0THEN GOSUB 1610
1040 K= 2:R= 99:GOTO 1740
1050 GOSUB 1090:Z= 1:GOSUB 360:GOSUB 240:PRINT "YOU CAN'T DESTROY STARS":GOSUB 1100:Z= 1:GOTO 360
1060 GOSUB 1090:Z= 6:GOSUB 360:G(U,V)= G(U,V)- 10:G= G- 1:GOSUB 290:GOSUB 240
1070 PRINT "YOU DESTROYED YOUR STAR BASE":GOSUB 1100:Z= 0:GOSUB 360:GOTO 340
1080 GOSUB 1790:GOSUB 1090:GOSUB 240:PRINT "TORPEDO MISSED":GOTO 1100
1090 P2= P:Q2= Q:GOSUB 1110:GOTO 350
1100 PLOT 30:GOSUB 1110:PLOT 29:GOTO 350
1110 PLOT 6,7
1120 PLOT 2,253,18+ 6* Y,122- 8* X,242,18+ 6* Q2,122- 8* P2,255:RETURN
1130 GOSUB 240:PRINT "YOU WIN"
1140 GOTO 1180
1150 GOSUB 240:PRINT "OUT OF TIME":GOTO 1170
1160 GOSUB 240:PRINT "DEAD IN SPACE"
1170 GOSUB 240:PRINT "YOU LOSE"
1180 FOR I= 1TO 4000:NEXT :LOAD "MENU":RUN
1190 FOR I= 1TO 8:FOR J= 1TO 8:Z(I,J)= 0:NEXT :NEXT :Z= G(U,V):GOSUB 250
1200 Z(X,Y)= 2:Z= 1:FOR I= 1TO C:GOSUB 1260:NEXT
1210 IF BTHEN Z= 4:GOSUB 1260
1220 FOR I= 1TO 9:I(I)= 0:J(I)= 0:K(I)= 0:NEXT
1230 Z= 3:IF ATHEN FOR I= 1TO A:GOSUB 1260:I(I)= P:J(I)= Q:K(I)= 100+ FN R(200):NEXT
1240 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
1250 PRINT :NEXT :RETURN
1260 P= FN R(8):Q= FN R(8):IF Z(P,Q)THEN 1260
1270 Z(P,Q)= Z:RETURN
1280 IF D(3)< 0THEN RETURN
1290 FOR I= U- 1TO U+ 1:FOR J= V- 1TO V+ 1:P= I:Q= J:IF FN O(X)THEN 1310
1300 ON 1- (I= UAND J= V)GOSUB 280,290
1310 NEXT J:NEXT I:RETURN
1320 FOR P= X- 1TO X+ 1:FOR Q= Y- 1TO Y+ 1:IF FN O(X)THEN 1340
1330 IF Z(P,Q)= 4THEN 1380
1340 NEXT Q:NEXT P
1350 GOSUB 260:IF A> 0OR M< 200THEN N= 2:RETURN
1360 IF H< 300THEN N= 1
1370 RETURN
1380 N= 3:H= 2900:M= 100:O= 10:GOSUB 240:PRINT "  SHIELDS DROPPED":RETURN
1390 W= (D(6)= 0):FOR I= 1TO 8:IF D(I)= 0THEN 1420
1400 D(I)= D(I)+ 1:IF D(I)> 0THEN D(I)= 0
1410 IF WTHEN GOSUB 1490
1420 NEXT I:GOSUB 1470:IF RND (1)> .2THEN RETURN
1430 I= FN R(8):IF RND (1)> .5THEN 1450
1440 D(I)= D(I)- (5* RND (1)+ 1):GOTO 1490
1450 D(I)= D(I)+ (5* RND (1)+ 1):IF D(I)> 0THEN D(I)= 0
1460 IF WTHEN GOSUB 1490
1470 IF WOR D(6)< 0THEN RETURN
1480 FOR I= 1TO 8:GOSUB 1490:NEXT :RETURN
1490 PLOT 3,61,23+ I:IF D(I)> = 0THEN PRINT "UP ":RETURN
1500 IF D(6)< 0THEN PRINT "DN ":RETURN
1510 IF D(I)> = - 1THEN PRINT "DN ":RETURN
1520 PRINT "DN";:DD= ABS (INT (D(I))):IF DD> 9THEN DD= 9
1530 PLOT 48+ DD:RETURN
1540 GOSUB 1560:GOSUB 1580:GOSUB 1600
1550 PLOT 3,3,3,19:PRINT RIGHT$ ("  "+ STR$ (D),4):PLOT 3,60,20:PRINT C$(N):RETURN
1560 PLOT 3,0,9:PRINT ""RIGHT$ ("  "+ STR$ (H),4)"/"RIGHT$ ("  "+ STR$ (M),4)
1570 PLOT 3,3,12,18:PRINT RIGHT$ ("  "+ STR$ (O),4):RETURN
1580 PLOT 3,3,6,19:PRINT RIGHT$ ("  "+ STR$ (F- D),4)
1590 PLOT 3,3,15,17:PRINT RIGHT$ ("  "+ STR$ (E),4):RETURN
1600 PLOT 8,18,14,25,U+ 48,25,V+ 48,25,25,X+ 48,25,Y+ 48,15:RETURN
1610 IF N= 3THEN GOSUB 240:PRINT "STAR BASE SHIELDS ENTERPRISE":RETURN
1620 GOSUB 260:W= A:IF A= 0THEN RETURN
1630 FOR I= 1TO 9:IF K(I)< = 0THEN 1660
1640 R= W* FN P(K(I)):M= M- R:GOSUB 240:PRINT ""R" UNIT HIT ON ENTERPRISE"
1650 GOSUB 1670:PRINT :GOSUB 1560:IF M< 0THEN 1170
1660 NEXT I:RETURN
1670 IF D(2)= 0THEN GOSUB 210:PRINT "  AT SECTOR "U$(I(I))","U$(J(I));
1680 RETURN
1690 R= 0:P2= I(I):Q2= J(I):GOTO 1720
1700 R= 1:GOSUB 1090:FOR I= 1TO 9:IF INT (P2)= I(I)AND INT (Q2)= J(I)THEN 1720
1710 NEXT I
1720 Z= 5:GOSUB 360:GOSUB 240:PRINT "*** KLINGON DESTROYED ***":GOSUB 1670:A= A- 1:E= E- 1
1730 G(U,V)= G(U,V)- 100:ON RGOSUB 1100:K(I)= 0:Z= 0:GOSUB 360:GOSUB 290:GOTO 1580
1740 P1= FN Y(S):Q1= FN X(S):P2= X:Q2= Y
1750 FOR I= 1TO R:P= INT (P2+ P1+ .5):Q= INT (Q2+ Q1+ .5):ON - FN O(P)* KGOTO 830,1080
1760 IF K= 2THEN ON Z(P,Q)+ 1GOTO 1780,1050,1780,1700,1060
1770 IF Z(P,Q)< > 0THEN 750
1780 P2= P2+ P1:Q2= Q2+ Q1:NEXT I:GOTO 780
1790 P= INT (P2+ .5):Q= INT (Q2+ .5):RETURN
1800 GOSUB 260:IF B< > 0THEN RETURN
1810 FOR I= 1TO 8:FOR J= 1TO 8:S= INT (G(I,J)/ 100):IF S= 0THEN 1920
1820 R= ABS (I- U)+ ABS (J- V):IF R= 0OR R> 3THEN 1920
1830 FOR K= 1TO S:IF RND (1)< .5THEN 1910
1840 P= INT ((I+ U+ SGN (U- I))/ 2):Q= INT ((J+ V+ SGN (V- J))/ 2):T= INT (G(P,Q)/ 100)+ 1
1850 IF T= 10THEN 1920
1860 G(I,J)= G(I,J)- 100:G(P,Q)= G(P,Q)+ 100:IF P< > UOR Q< > VTHEN 1910
1870 Z= 3:GOSUB 1260:IF D(2)> = 0THEN GOSUB 320
1880 FOR T= 1TO 9:IF K(T)= 0THEN 1900
1890 NEXT
1900 I(T)= P:J(T)= Q:K(T)= 100+ FN R(200)
1910 NEXT K
1920 NEXT J:NEXT I:RETURN