10 REM	TREK.BAS	27-JUL-73	ARON K. INSINGA	PROJECT DELTA
20 REM	CRTREK.B2S	30-JUL-77	JAMES E. THOMPSON	IPG
30 REM	TREK.BAS	21-DEC-78	BOB SUPNIK	SSE
40 A=TTYSET(255,255)
50 RANDOMIZE
60 DEF FNC$(X,Y)=CHR$(27)&"["&STR$(Y+1)&";"&STR$(X+1)&"H"
70 E$=CHR$(27%) \ REM ESCAPE
80 E1$=E$+"[J" \ D1%=8% \ REM ERASE SCREEN FROM CURSOR DOWNWARD
90 H0$=E$+"[H" \ B$=CHR$(8%) \ REM HOME BACKSPACE
100 H2$=FNC$(0,20)+E1$ \ REM ERASE BOTTOM
110 G0$=E$+"(0"+E$+"[36m" \ N0$=E$+"(B"+E$+"[0m" \ REM VT100 GRAPHICS AND ALPHA MODES
120 S8%=60% \ S9%=9% \ REM DEFINE SECTOR ORIGIN
130 G8%=4% \ G9%=16% \ REM DEFINE GALAXY ORIGIN
140 P8%=46% \ P9%=9% \ REM DEFINE COMPASS ORIGIN
150 D8%=18% \ D9%=20% \ REM DEFINE DAMAGE ORIGIN
160 DIM V%(7%),L$(3%) \ REM HOLDS OFFSETS FOR STATUS VARIABLES
170 DATA 9,11,9,7,7,9,9
180 FOR I%=1% TO 7% \ READ V%(I%) \ NEXT I%
190 DEF FNS$(X%,Y%)=FNC$(S8%+((X%-1%)*2%),S9%-(Y%-1%))
200 DEF FNQ$(X%,Y%)=FNC$(G8%+((X%-1%)*4%),G9%-((Y%-1%)*2%))
210 DEF FNP$(X%,Y%)=FNC$(P8%+X%,P9%+Y%)
220 DEF FNV$(I%)=FNC$(S8%+V%(I%),S9%+1%+I%)
230 DEF FNO$(X%,Y%)=SEG$(".EKB*",Q%(X%,Y%)+1%,Q%(X%,Y%)+1%)
240 DEF FNG$(X%,Y%)=SEG$(STR$(Z%(X%,Y%)+1000%),2%,4%)
250 DEF FND$(X%,Y%)=FNC$(D8%+X%,D9%+(Y%-1%))
260 DEF FNZ$(X%,Y%)=SEG$(".E...",Q%(X%,Y%)+1%,Q%(X%,Y%)+1%)
270 REM
280 REM	OBTAIN TERMINAL CHARACTERISTICS
290 REM
300 PRINT H0$;E1$;"Star Trek V2.0" \ PRINT 
310 PRINT "Terminal baud rate"; \ INPUT B5%
320 F%=B5%/300% \ REM SET NO. OF TIMES TO FLICKER
330 B5$="" \ PRINT "Sound effects"; \ INPUT A$
340 IF SEG$(A$,1,1)="Y" THEN B5$=CHR$(7%)
350 M9%=0% \ REM MASTER GAME SWITCH
360 PRINT "Master game"; \ INPUT A$
370 IF SEG$(A$,1,1)="Y" THEN M9%=-1%
380 X9%=200% \ IF M9%<>0% THEN X9%=1000%
390 DIM R(9%),D$(8%),G%(8%,8%),Q%(8%,8%),K%(9%,3%),D%(8%),Z%(8%,8%)
400 FOR I%=1% TO D1% \ READ D$(I%) \ D%(I%)=0% \ NEXT I%
410 FOR I%=1% TO 9% \ READ R(I%) \ NEXT I%
420 FOR I%=1% TO 3% \ READ L$(I%) \ NEXT I%
430 FOR I%=1% TO 8% \ FOR J%=1% TO 8% \ Z%(I%,J%)=0% \ NEXT J% \ NEXT I%
440 DATA "Warp engines","S.R. sensors","L.R. sensors","Phaser beam"
450 DATA "Torpedo tubes","Damage cntrl","Computer","Battle analyzer"
460 DATA .0001, .01, .03, .08, .23, 1.28, 3.28, 6.28, 13.28
470 DATA "Battle Report:","[Dist/Energy]",""
480 T%=INT(RND*20+20)*100% \ T0%=T% \ E%=3000% \ E0%=E%
490 P%=10% \ P0%=P% \ REM INITIAL CONDITIONS
500 T9%=40% \ IF M9%<>0% THEN T9%=30%+INT(RND*20)
510 REM
520 DEF FNF(X%)=SQR((K%(X%,1%)-S1%)^2%+(K%(X%,2%)-S2%)^2%)
530 DEF FNR%(X%)=INT(RND*8+1)
540 Q1%=FNR%(X%) \ Q2%=FNR%(X%) \ S1%=FNR%(X%) \ S2%=FNR%(X%)
550 REM
560 REM SET UP THE GALAXY
570 REM
580 B9%=0% \ K9%=0%
590 FOR I%=1% TO 8% \ FOR J%=1% TO 8%
600 K3%=0% \ C1=RND*64
610 FOR K0%=1% TO 9% \ IF C1<R(K0%) THEN K3%=K3%+1%
620 NEXT K0%
630 K9%=K9%+K3% \ B3%=0% \ IF RND>.9 THEN B3%=1%
640 B9%=B9%+B3% \ G%(I%,J%)=(K3%*100%)+(B3%*10%)+FNR%(X%)
650 NEXT J%
660 NEXT I%
670 K0%=K9%
680 REM
690 REM	MAKE SURE THERE IS AT LEAST ONE BASE
700 IF B9%=0% THEN I%=FNR%(X%) \ J%=FNR%(X%) \ G%(I%,J%)=G%(I%,J%)+10% \ B9%=1%
710 PRINT H0$;E1$;"Orders:	Stardate =";T% \ PRINT 
720 PRINT "You must destroy the Klingon invasion force of";K9%;"battle"
730 PRINT "cruisers.  You have";T9%;"solar years to complete your mission."
740 PRINT "Ready"; \ INPUT A$
750 PRINT H0$;E1$ \ GOSUB 3140 \ REM BLANK SCREEN & DRAW THE GALAXY
760 REM
770 REM	SET UP QUADRANT
780 REM
790 K3%=0% \ B3%=0% \ S3%=0% \ H8%=0% \ K8%=0%
800 X=G%(Q1%,Q2%) \ REM GET WORD WHICH DESCRIBES OCCUPANTS OF THIS QUAD
810 K3%=INT(X/100) \ B3%=INT(X/10)-(10*K3%) \ S3%=X-(INT(X/10)*10)
820 FOR I%=1% TO 8% \ FOR J%=1% TO 8% \ Q%(I%,J%)=0% \ NEXT J% \ NEXT I%
830 FOR I%=1% TO 9% \ FOR J%=1% TO 3% \ K%(I%,J%)=0% \ NEXT J% \ NEXT I%
840 Q%(S1%,S2%)=1% \ REM INSERT ENTERPRISE
850 FOR I%=1% TO K3%
860 GOSUB 3880 \ REM SELECT RANDOM EMPTY SECTOR
870 Q%(R1%,R2%)=2% \ REM AND PUT A KLINGON IN IT
880 K%(I%,1%)=R1% \ K%(I%,2%)=R2% \ K%(I%,3%)=X9%+INT(RND*(X9%/2%))
890 NEXT I%
900 FOR I%=1% TO B3% \ GOSUB 3880 \ Q%(R1%,R2%)=3% \ NEXT I% \ REM INSERT BASE(S)
910 FOR I%=1% TO S3% \ GOSUB 3880 \ Q%(R1%,R2%)=4% \ NEXT I% \ REM INSERT STAR(S)
920 GOSUB 960 \ GOSUB 1170 \ REM SET STATUS, DISPLAY QUAD
930 GOSUB 2770 \ REM KLINGON ATTACK
940 GO TO 1280 \  TO CMDDECODER
950 REM
960 REM	RED/ORANGE/YELLOW/GREEN STATUS [SUBROUTINE]
970 REM
980 C$="Green " \ IF E%<=E0%/10% THEN C$="Yellow"
990 FOR I%=Q1%-1% TO Q1%+1%
1000 FOR J%=Q2%-1% TO Q2%+1%
1010 IF I%>0% THEN IF I%<9% THEN IF J%>0% THEN IF J%<9% THEN  GO TO 1030
1020 GO TO 1040 \ REM INVALID SECTOR
1030 IF G%(I%,J%)>99% THEN C$="Orange" \ GO TO 1060
1040 NEXT J%
1050 NEXT I%
1060 FOR I%=S1%-1% TO S1%+1%
1070 FOR J%=S2%-1% TO S2%+1%
1080 IF I%>0% THEN IF I%<9% THEN IF J%>0% THEN IF J%<9% THEN IF Q%(I%,J%)=3 THEN  GO TO 1100
1090 GO TO 1120
1100 FOR I1%=1% TO 8% \ D%(I1%)=0% \ NEXT I1% \ C$="Docked"
1110 E%=E0% \ P%=P0% \ PRINT FNV$(5%);E%;FNV$(6%);P%; \ GO TO 1150
1120 NEXT J%
1130 NEXT I%
1140 IF K3%<>0% THEN C$="Red   " \ REM IF NOT DOCKED & KLINGON(S)INQUADRANT
1150 PRINT  \ PRINT FNV$(2%);C$; \ RETURN \ REM PUT NEW CODITION IN STATUS DISPLAY
1160 REM
1170 REM	SCAN QUADRANT SECTOR BY SECTOR [SUBROUTINE]
1180 REM
1190 FOR I%=8% TO 1% STEP -1%
1200 PRINT FNS$(1%,I%);
1210 FOR J%=1% TO 8%
1220 IF D%(2%)=0% THEN PRINT FNO$(I%,J%);" ";
1230 IF D%(2%)<>0% THEN PRINT FNZ$(I%,J%);" ";
1240 NEXT J% \ REM PRINT "|"
1250 NEXT I%
1260 RETURN
1270 REM
1280 REM	COMMAND DECODER
1290 REM
1300 GOSUB 960 \ REM OBTAIN CURRENT CONDITION
1310 A$="" \ PRINT H2$;
1320 Z%(Q1%,Q2%)=G%(Q1%,Q2%) \ REM UPDATE GALAXY (NOTDISPLAYEDYET,THO)
1330 PRINT "Command"; \ INPUT A$ \ A%=POS("WSLPTDCEB",SEG$(A$,1%,1%),1%)
1340 IF A%=0% THEN  GO TO 3710
1350 ON A% GO TO 1370,3820,1930,2070,2300,2650,3760,3060,3930
1360 REM
1370 REM	WARP DRIVE [W COMMAND]
1380 REM
1390 PRINT H2$;
1400 PRINT "Course (1-8.99), Warp factor (0-12)"; \ INPUT C1,W1
1410 IF W1*C1=0 GO TO 1280
1420 IF C1>=1 THEN IF C1<=9 THEN IF W1>=0 THEN IF W1<=12 GO TO 1440
1430 PRINT "Invalid course, please reenter."; \ GOSUB 4120 \ GO TO 1390
1440 Z5%=0% \ REM FLAG FOR QUADRANT DETECTION
1450 IF W1>.25 THEN IF D%(1%)<0% THEN PRINT "Warp engines are damaged, max speed = Warp .25" \ GOSUB 4120 \ GO TO 1390
1460 IF K3%>0% THEN  GOSUB 2770 \ REM ALLOW KLINGON ATTACK IF ANY PRESENT
1470 IF M9%=0% THEN  GO TO 1610 \ NODAMAGEINBASICGAME
1480 FOR I%=1% TO D1% \ IF D%(I%)<0% THEN D%(I%)=D%(I%)+1%
1490 NEXT I% \ REM IMPROVE STATUS
1500 IF RND>.2 GO TO 1600 \ REM ONE CHANCE IN FIVE OF DISASTER
1510 IF RND>.5 GO TO 1550
1520 I%=INT((RND*D1%)+1)
1530 PRINT "*** Space storm: ";D$(I%);" damaged. ***"
1540 D%(I%)=D%(I%)-INT((RND*3)+1) \ GO TO 1600
1550 FOR I%=1% TO D1% \ IF D%(I%)<0% THEN  GO TO 1570
1560 NEXT I% \ GO TO 1600
1570 D%(I%)=D%(I%)-INT((RND*D%(I%))-1)
1580 IF D%(I%)>0% THEN D%(I%)=0%
1590 PRINT "*** ";D$(I%);" state of repair improved. ***"
1600 REM
1610 N%=INT(W1*8%) \ IF E%-N%<=0% THEN 2950
1620 IF T%+1%>T0%+T9% THEN 2950 \ REM LOST
1630 Q%(S1%,S2%)=0% \ REM REMOVE "E" IN SECTOR
1640 X=(Q1%*8%)+(S1%-1%) \ Y=(Q2%*8%)+(S2%-1%) \ GOSUB 2630 \ REM POSITION AND DIRECTION
1650 FOR I%=1% TO N%
1660 PRINT  \ REM RESET LINE COUNTER
1670 X=X+X1 \ Y=Y+X2 \ REM MOVE ONE UNIT IN PROPER DIRECTION
1680 Z3%=(INT(X+.5))/8% \ Z4%=(INT(Y+.5))/8% \ REM CALC NEW QUADRANT
1690 Z1%=INT(X+.5)-(Z3%*8%)+1% \ Z2%=INT(Y+.5)-(Z4%*8%)+1% \ REM NEW SECTOR
1700 IF Z3%=Q1% THEN IF Z4%=Q2% THEN 1780 \ REM SKIP IF SAME QUADRANT
1710 IF Z3%>0% THEN IF Z3%<9% THEN IF Z4%>0% THEN IF Z4%<9% THEN 1730
1720 GO TO 1870 \ REM OUT OF GALAXY
1730 IF Z5%<>0% THEN 1760
1740 Z5%=1% \ FOR I1%=1% TO 8% \ FOR J1%=1% TO 8% \ Q%(I1%,J1%)=0% \ NEXT J1% \ NEXT I1%
1750 FOR J%=1% TO 8% \ PRINT FNS$(1%,J%);"               " \ NEXT J%
1760 PRINT  \ PRINT FNQ$(Q2%,Q1%);FNG$(Q1%,Q2%);FNQ$(Z4%,Z3%);" E "; \ REM UPDATE GALAXY DISPLAY
1770 Q1%=Z3% \ Q2%=Z4% \ PRINT FNV$(3%);Q2%;"-";Q1%;
1780 IF Q%(Z1%,Z2%)<>0% THEN 1860 \ REM CAN BE BLOCKED ONLY IN ORIGINAL QUAD
1790 PRINT FNS$(S2%,S1%); \ IF Z5%=1% THEN PRINT " "; \ GO TO 1810
1800 PRINT "."; \ REM REMOVE "E" FROM OLD SECTOR
1810 S1%=Z1% \ S2%=Z2% \ PRINT  \ PRINT FNS$(S2%,S1%);"E";
1820 FOR J%=1% TO F% \ PRINT B$;" ";B$;"E"; \ NEXT J%
1830 PRINT  \ REM RESET LINE POINTER
1840 NEXT I%
1850 GO TO 1870
1860 PRINT H2$;"ENTERPRISE blocked by object at sector";Z2%;"-";Z1% \ GOSUB 4120
1870 T%=T%+1% \ PRINT FNV$(1%);T% \ REM ADVANCE STARDATE
1880 PRINT FNV$(4%);S2%;"-";S1%; \ REM UPDATE SECTOR
1890 E%=E%-N% \ PRINT FNV$(5%);E%; \ REM ENERGY LOSS = 1 UNIT/UNIT DISTANCE
1900 Q%(S1%,S2%)=1% \ IF Z5%=1% THEN 770
1910 GO TO 1280
1920 REM
1930 REM	LONG RANGE SENSOR SCAN [L COMMAND]
1940 REM
1950 IF D%(3%)<>0% THEN PRINT "Long range sensors are inoperable." \ GOSUB 4120 \ GO TO 1280
1960 FOR I%=Q1%+1% TO Q1%-1% STEP -1%
1970 FOR J%=Q2%-1% TO Q2%+1% STEP 1%
1980 IF I%>0% THEN IF I%<9% THEN IF J%>0% THEN IF J%<9% THEN 2000
1990 GO TO 2030
2000 Z%(I%,J%)=G%(I%,J%)
2010 IF I%=Q1% THEN IF J%=Q2% THEN 2030
2020 PRINT FNQ$(J%,I%);FNG$(I%,J%);
2030 NEXT J%
2040 NEXT I%
2050 GO TO 1280 \ REM GO GET NEXT COMMAND
2060 REM
2070 REM	PHASER CONTROL [P COMMAND]
2080 REM
2090 IF D%(4%)<>0% THEN PRINT "Phaser control is disabled." \ GOSUB 4120 \ GO TO 1280
2100 IF K3%<=0% THEN PRINT "No Klingons in quadrant." \ GOSUB 4120 \ GO TO 1280
2110 PRINT H2$;
2120 IF D%(7%)<>0% THEN PRINT "Computer failure reduces phaser effectiveness."
2130 PRINT "Number of units to fire"; \ INPUT X%
2140 IF X%<=0% GO TO 1280
2150 IF X%>E% THEN PRINT "Only";E%;"energy units available."; \ GOSUB 4120 \ GO TO 2110
2160 E%=E%-X%
2170 PRINT FNV$(5%);E% \ REM SHOW REDUCED ENERGY
2180 IF D%(7%)<>0% THEN X%=X%/INT(RND*5+1)
2190 FOR I%=1% TO 9%
2200 IF K%(I%,3%)<=0% THEN 2270 \ REM DON'T REDUCE IF ALREADY DEAD
2210 H%=INT(X%/FNF(I%)*((2*RND)+1%)) \ REM CALCULATE ENERGY IN HIT
2220 K%(I%,3%)=K%(I%,3%)-H% \ REM REDUCE KLINGON'S ENERGY
2230 GOSUB 3530 \ IF K%(I%,3%)<=0% THEN  GOSUB 3610
2240 PRINT H2$;H%;"unit hit on Klingon at sector";K%(I%,2%);"-";K%(I%,1%)
2250 IF K%(I%,3%)>0% THEN PRINT "    (";K%(I%,3%);"remain)"
2260 GOSUB 4120 \ IF K9%<=0% THEN 3000 \ REM QUIT IF LAST KLINGON DESTROYED
2270 NEXT I%
2280 GOSUB 2770 \ GO TO 1280 \ REM GIVE THE KLINGONS THEIR TURN
2290 REM
2300 REM	PHOTON TORPEDOS [T COMMAND]
2310 REM
2320 IF D%(5%)<>0% THEN PRINT "Photon tubes are not operational." \ GOSUB 4120 \ GO TO 1280
2330 IF P%<=0% THEN PRINT "All photon torpedoes expended." \ GOSUB 4120 \ GO TO 1280
2340 PRINT H2$;
2350 PRINT "Torpedo course (1-8.9999)"; \ INPUT C1
2360 IF C1=0 THEN 1280
2370 IF C1>=1 THEN IF C1<9 THEN  GO TO 2390
2380 PRINT H2$;"Invalid course, please reenter." \ GOSUB 4120 \ GO TO 2340
2390 GOSUB 2630
2400 X=S1% \ Y=S2% \ P%=P%-1% \ PRINT FNV$(6%);P%; \ REM REDUCE TORPEDO COUNT
2410 X=X+X1 \ Y=Y+X2 \ REM MOVE ONE UNIT IN SELECTED DIRECTION
2420 Z1%=INT(X+.5) \ Z2%=INT(Y+.5) \ REM SET INTERMEDIATE LOCATION
2430 IF Z1%>0% THEN IF Z1%<9% THEN IF Z2%>0% THEN IF Z2%<9% THEN 2450
2440 PRINT H2$;"   Missed"; \ GO TO 2610
2450 PRINT  \ PRINT FNS$(Z2%,Z1%);
2460 IF Q%(Z1%,Z2%)<>0% THEN 2500 \ REM JUMP IF HIT SOMETHING
2470 FOR I%=1% TO F%
2480 PRINT "T";B$;" ";B$; \ NEXT I% \ REM FLICKER TORPEDO
2490 PRINT ".";B$; \ GO TO 2410
2500 FOR I%=1% TO 8% \ PRINT "T";B$;FNO$(Z1%,Z2%);B$; \ NEXT I%
2510 IF Q%(Z1%,Z2%)<>2% THEN 2570 \ REM JUMP IF NOT A KLINGON
2520 FOR I%=1% TO 9% \ REM FIND OUT WHICH KLINGON
2530 IF K%(I%,1%)<>Z1% THEN 2560
2540 IF K%(I%,2%)<>Z2% THEN 2560
2550 GOSUB 3610 \ PRINT H2$;"*** Klingon Destroyed! ***" \ GO TO 2610
2560 NEXT I%
2570 PRINT ".";B5$;H2$
2580 IF Q%(Z1%,Z2%)=4% THEN S3%=S3%-1% \ PRINT "   Star destroyed"
2590 IF Q%(Z1%,Z2%)=3% THEN B3%=B3%-1% \ PRINT "*** Starbase destroyed...Congratulations ***"
2600 Q%(Z1%,Z2%)=0% \ G%(Q1%,Q2%)=(K3%*100%)+(B3%*10%)+S3%
2610 GOSUB 4120 \ IF K9%<=0% THEN 3000
2620 GOSUB 2770 \ GO TO 1280
2630 X1=SIN((C1-1)*.785398) \ X2=COS((C1-1)*.785398) \ RETURN
2640 REM
2650 REM	DAMAGE CONTROL REPORT [D COMMAND]
2660 REM
2670 IF D%(6%)<>0% THEN PRINT "Damage control system is non-functional." \ GOSUB 4120 \ GO TO 1280
2680 PRINT H2$;"Damage Report:";
2690 FOR I%=1% TO 3%
2700 FOR J%=1% TO 3% \ I0%=(I%-1%)*3%+J%
2710 IF I0%<=D1% THEN PRINT  \ PRINT FND$((J%-1%)*20%,I%);D$(I0%);"=";D%(I0%);
2720 NEXT J%
2730 NEXT I%
2740 GOSUB 4120
2750 GO TO 1280
2760 REM
2770 REM	KLINGON ATTACK [SUBROUTINE]
2780 REM
2790 IF K3%=0% THEN RETURN \ REM IMMEDIATE RETURN IF NO KLINGONS
2800 IF C$="Docked" THEN PRINT H2$;"Starbase shields protect the ENTERPRISE" \ GOSUB 4120 \ RETURN
2810 H8%=0% \ K8%=0% \ REM TOTAL COUNTERS
2820 FOR I%=1% TO 9%
2830 H1%=K%(I%,3%) \ IF H1%<=0% THEN 2920 \ REM SKIP ATTACK IF HE HAS NO ENERGY
2840 IF M9%<>0% THEN IF RND<=.3 THEN  GO TO 2920
2850 IF M9%<>0% THEN H1%=H1%/INT(RND*4+2) \ K%(I%,3%)=K%(I%,3%)-H1%
2860 H%=INT((H1%/FNF(I%))*((2*RND)+1%)) \ REM HIT INVERSE TO DISTANCE
2870 GOSUB 3530 \ REM FLICKER THE ATTACKER
2880 PRINT H2$;H%;"unit hit from Klingon at sector";K%(I%,2%);"-";K%(I%,1%) \ REM REPORT HIT
2890 H8%=H8%+H% \ K8%=K8%+1% \ REM INCREMENT TOTALS
2900 E%=E%-H% \ PRINT FNV$(5%);E%; \ REM SHOW TOTAL ENERGY REMAINING
2910 GOSUB 4120
2920 NEXT I%
2930 IF K8%>1% THEN PRINT H2$;H8%;"units lost during attack by";K8%;"enemy ships." \ GOSUB 4120
2940 IF E%>0% THEN RETURN \ REM FALL THRU IF NO ENERGY REMAINING
2950 PRINT H0$;E1$;"It is Stardate";T% \ PRINT 
2960 PRINT "The ENTERPRISE has been destroyed."
2970 PRINT "The Federation will be conquered."
2980 PRINT "There are still";K9%;"Klingon battle cruisers in the galaxy."
2990 PRINT "You are dead." \ GO TO 3100
3000 PRINT H0$;E1$;"It is Stardate";T% \ PRINT 
3010 PRINT "The last Klingon battle cruiser in the galaxy has been destroyed."
3020 PRINT "The Federation has been saved."
3030 PRINT "You have been promoted to Admiral."
3040 PRINT K0%;"Klingons in";T%-T0%;"years. ";
3050 PRINT "Rating = ";(K0%*100%)/(T%-T0%)*10% \ GO TO 3100
3060 PRINT H0$;E1$;"It is Stardate";T% \ PRINT 
3070 PRINT "There are still";K9%;"Klingon battle cruisers in the galaxy."
3080 PRINT "The ENTERPRISE has been placed in more capable hands."
3090 PRINT "You have been put on the retired list with an inadequate pension."
3100 PRINT  \ PRINT "Another game"; \ INPUT A$
3110 IF SEG$(A$,1,1)="Y" THEN  GO TO 430
3120 STOP
3130 REM
3140 REM	CHART ENTIRE GALAXY [SUBROUTINE]
3150 REM
3160 PRINT H0$; \ REM CURSOR HOME
3170 PRINT "            >>Galaxy  Map<<"
3180 PRINT G0$;"   lqqqwqqqwqqqwqqqwqqqwqqqwqqqwqqqk";N0$
3190 FOR I%=8% TO 1% STEP -1%
3200 IF I%<>8 THEN PRINT G0$;"   tqqqnqqqnqqqnqqqnqqqnqqqnqqqnqqqu";N0$
3210 PRINT I%;G0$;"x";N0$;
3220 FOR J%=1% TO 8%
3230 IF I%=Q1% THEN IF J%=Q2% THEN A$=" E " \ GO TO 3250
3240 A$=SEG$(STR$(1000%+Z%(I%,J%)),2%,4%)
3250 PRINT A$;G0$;"x";N0$;
3260 NEXT J%
3270 PRINT 
3280 NEXT I%
3290 PRINT G0$;"   mqqqvqqqvqqqvqqqvqqqvqqqvqqqvqqqj";N0$
3300 PRINT "   "; \ FOR I%=1% TO 8% \ PRINT " ";I%; \ NEXT I%
3310 PRINT FNS$(0%,10%);" >>Quadrant  Map<<"
3320 PRINT FNS$(0%,9%);G0$;"lqqqqqqqqqqqqqqqqqk";N0$
3330 FOR I%=8% TO 1% STEP -1% \ PRINT FNS$(0%,I%);G0$;"x                 x";N0$ \ NEXT I%
3340 PRINT FNS$(0%,0%);G0$;"mqqqqqqqqqqqqqqqqqj";N0$ \ REM OTHER SECTOR BOUNDARY
3350 PRINT FNS$(1%,-1%);"Stardate:";T%
3360 PRINT FNS$(1%,-2%);"Condition:"
3370 PRINT FNS$(1%,-3%);"Quadrant:";Q2%;"-";Q1%;
3380 PRINT FNS$(1%,-4%);"Sector:";S2%;"-";S1%
3390 PRINT FNS$(1%,-5%);"Energy:";E%;FNS$(1%,-6%);"Torpedos:";P%
3400 PRINT FNS$(1%,-7%);"Klingons:";K9%
3410 REM
3420 REM	PRINT COMPASS (POINTER)
3430 REM
3440 PRINT FNP$(0%,-3%);"3"
3450 PRINT FNP$(-2%,-2%);"4 ! 2"
3460 PRINT FNP$(-1%,-1%);"\!/"
3470 PRINT FNP$(-3%,0%);"5--E--1"
3480 PRINT FNP$(-1%,1%);"/!\"
3490 PRINT FNP$(-2%,2%);"6 ! 8"
3500 PRINT FNP$(0%,3%);"7"
3510 RETURN
3520 REM
3530 REM	BLINK THE KLINGON WHO IS CURRENTLY ATTACKING (ORBEINGATTACKED)
3540 REM
3550 PRINT  \ PRINT FNS$(K%(I%,2%),K%(I%,1%));
3560 FOR F7%=1% TO F%
3570 PRINT " ";B$;"K";B$;
3580 NEXT F7%
3590 RETURN
3600 REM
3610 REM	REMOVE A KLINGON (HURRAH!)
3620 REM
3630 PRINT ".";B5$ \ REM ASSUME LAST CHARACTER IN FLICKER WAS BACKSPACE
3640 K3%=K3%-1% \ K9%=K9%-1% \ REM REDUCE SECTOR, GALAXY COUNTS
3650 PRINT FNV$(7%);K9% \ REM UPDATE STATUS DISPLAY
3660 Q%(K%(I%,1%),K%(I%,2%))=0% \ REM REMOVE FROM QUADRANT
3670 K%(I%,3%)=0% \ REM MAKE SURE KLINGON STAYS DEAD (DAREYATODELETE3245)
3680 G%(Q1%,Q2%)=G%(Q1%,Q2%)-100% \ REM AND FROM GALAXY
3690 RETURN \ REM PREPARE FOR NEXT MESSAGE
3700 REM
3710 REM	ERROR RECOVERY
3720 REM
3730 PRINT H2$;
3740 PRINT "Valid commands are C, S, L, P, T, W, D, B, and E."
3750 GOSUB 4120 \ GO TO 1280
3760 REM
3770 REM	CHART ENTIRE GALAXY [C COMMAND]
3780 REM
3790 PRINT H0$;E1$; \ REM ERASE SCREEN
3800 GOSUB 3140 \ GOSUB 1170 \ REM CHART GALAXY AND QUADRANT
3810 GO TO 1280
3820 REM
3830 REM	SHORT RANGE SENSOR SCAN [S COMMAND]
3840 REM
3850 IF D%(2%)<>0% THEN PRINT "Short range sensors are inoperable." \ GOSUB 4120 \ GO TO 1280
3860 GOSUB 1170
3870 GO TO 1280
3880 REM
3890 REM	FIND EMPTY SECTOR [SUBROUTINE]
3900 REM
3910 R1%=FNR%(X%) \ R2%=FNR%(X%) \ IF Q%(R1%,R2%)<>0% THEN 3910
3920 RETURN
3930 REM
3940 REM	BATTLE ANALYSIS [B COMMAND]
3950 REM
3960 IF D%(8%)<>0% THEN PRINT "Battle analyzer is out of commission." \ GOSUB 4120 \ GO TO 1280
3970 IF K3%<=0% THEN PRINT "No Klingons in quadrant." \ GOSUB 4120 \ GO TO 1280
3980 PRINT H2$;
3990 FOR I%=1% TO 3%
4000 PRINT FND$(-18%,I%);L$(I%);
4010 FOR J%=1% TO 3% \ I0%=(I%-1%)*3+J%
4020 IF K%(I0%,3%)<=0% THEN  GO TO 4080
4030 PRINT  \ PRINT FND$((J%-1%)*20%,I%);"K@ ";STR$(K%(I0%,2%));"-";STR$(K%(I0%,1%));
4040 PRINT " = ";STR$(INT(FNF(I0%)));"/";STR$(K%(I0%,3%));
4050 REM
4060 REM	INSERT COMPUTER PRINTOUT HERE
4070 REM
4080 NEXT J%
4090 NEXT I%
4100 GOSUB 4120
4110 GO TO 1280
4120 REM
4130 REM	SLEEP FOR TWO SECONDS
4140 REM
4150 FOR Z9%=1% TO 30000% \ NEXT Z9% \ RETURN
4160 END
