10 REM KLINGON CAPTURE
20 REM BASED ON TSC'S 6800 MACHINE LANGUAGE GAME
30 REM WRITTEN IN TSC'S MICRO BASIC PLUS
40 REM BY
50 REM MICKEY E. FERGUSON
60 REM (IN 'KILOBAUD' MAGAZINE, SEPT 1977, PG 110)
62 REM (TWEAKED A TAD & 'Y,X' INPUT, BY DHH, DEC 2023)
65 REM LINE 70 GETS YOU 15 - 20 SHOTS
70 S=RND/5:IF S<15 THEN 70:IF S>20 THEN 70
80 PRINT:INPUT"INSTRUCTIONS (YES=1)",I:IF I<>1 THEN 150 
90 PRINT "YOUR MISSION, COMMANDER, IS TO CAPTURE A KLINGON BATTLE"
100 PRINT "CRUISER. YOU MUST NOT DESTROY THE KLINGON, BUT TAKE IT"
110 PRINT "ALIVE. TO CAPTURE THE KLINGON, YOU MUST DESTROY ALL"
120 PRINT "SECTORS SURROUNDING IT. THE BATTLE COMPUTER WILL KEEP YOU"
130 PRINT "INFORMED OF ITS LAST KNOWN POSITION. GOOD LUCK AND REMEMBER"
140 PRINT "THAT WE ARE COUNTING ON YOU, COMMANDER."
150 PRINT:PRINT "YOU HAVE ";S;" SHOTS. SCANNING...":PRINT
155 REM INITIALIZE QUADRANT
160 DIM Q(9,9)
170 FOR X=0 TO 9:FOR Y=0 TO 9:Q(Y,X)=0
180 Q(0,X)=-1:Q(9,X)=-1:Q(Y,0)=-1:Q(Y,9)=-1:NEXT Y:NEXT X
185 REM LINES 190 - 200 GET KLINGON'S INITIAL POSITION
190 X=RND/10:IF X<1 THEN 190:IF X>8 THEN 190
200 Y=RND/10:IF Y<1 THEN 200:IF Y>8 THEN 200
205 REM PRINT KLINGON'S "PRESENT" POSITION
210 PRINT "KLINGON'S LAST KNOWN POSITION, SECTOR ";X;", ";Y:PRINT
215 REM MOVE KLINGON (MAYBE)
220 IF S<=0 THEN 530:C=X:D=Y
230 A=RND/10:IF A<C THEN X=X-1:IF A>C THEN X=X+1
240 IF X<1 THEN X=1:IF X>8 THEN X=8
250 A=RND/10:IF A<D THEN Y=Y-1:IF A>D THEN Y=Y+1
260 IF Y<1 THEN Y=1 :IF Y>8 THEN Y=8
270 IF Q(Y,X)<>-1 THEN 280:X=C:Y=D:GOTO 230
275 REM PRINT MAP
280 FOR A=1 TO 8:FOR B=1 TO 8
290 IF Q(B,A)=0 THEN PRINT "* ";
300 IF Q(B,A)=-1 THEN PRINT "0 ";
310 NEXT B:PRINT SPC(1);A:NEXT A
320 FOR A=1 TO 8:PRINT A;SPC(1);:NEXT A:PRINT
325 REM CHECK TO SEE IF BEING ATTACKED (5% CHANCE)
330 A=RND:IF A>4 THEN 370
340 PRINT "THE ENTERPRISE HAS BEEN ATTACKED."
350 PRINT "PHASOR ENERGY USED TO REPLENISH SHIELDS.":S=S-1
360 PRINT S;" SHOTS REMAIN.":PRINT
365 REM CHECK FOR SUPERNOVA (5% CHANCE)
370 A=RND:IF A<94 THEN 420
375 REM LOCATE SUPERNOVA
380 A=RND/10:IF A=X THEN 380:IF A<1 THEN 380:IF A>8 THEN 380
390 B=RND/10:IF B=Y THEN 390:IF B<1 THEN 390:IF B>8 THEN 390
400 Q(B,A)=-1
410 PRINT "SUPERNOVA IN SECTOR ";A;" ; ";B:PRINT
420 INPUT "YOUR SHOT (Y,X) ",A,B:S=S-1
425 REM CHECK IF YOU SHOT KLINGON
430 IF A=X THEN IF B=Y THEN 540
435 REM CHECK IF SECTOR HAS ALREADY BEEN SHOT
440 IF Q(B,A)=-1 THEN 580:Q(B,A)=-1
445 REM CHECK TO SEE IF YOU WIN
450 FOR A=X-1 TO X+1:FOR B=Y-1 TO Y+1
460 IF A=X THEN IF B=Y THEN 480
470 IF Q(B,A)<>-1 THEN 210
480 NEXT B:NEXT A
490 PRINT "CONGRATULATIONS! COMMANDER,"
500 PRINT "YOUR MISSION IS A SUCCESS! THE KLINGON HAS BEEN"
510 PRINT "CAPTURED AND YOU HAVE ";S;" SHOTS REMAINING!"
520 END
530 PRINT "PHASORS OUT OF ENERGY. NO SHOTS LEFT.":GOTO 560
540 PRINT "CONGRATULATIONS, DUMMY!"
550 PRINT "YOU JUST FRIED THE KLINGON!"
560 PRINT "YOUR MISSION IS A TOTAL LOSS!"
570 END
580 PRINT "NICE GOING, DUMMY!"
590 PRINT "YOU JUST SHOT A PREVIOUSLY DESTROYED SECTOR!"
600 GOTO 210
