Star Trek 3.5

This file is part of and Timex Sinclair Public Domain Library Tape 1005. Download the collection to get this file.
Developer(s): Tony Willing
Date: 198x
Type: Program
Platform(s): TS 1000
Tags: Game

This program is a text-based Star Trek strategy game (version 3.5) for the Sinclair/Timex platform, in which the player commands the USS Enterprise to destroy a fleet of Klingon battle cruisers within a time limit. The galaxy is represented as an 8×8 grid of quadrants, each subdivided into an 8×8 sector grid, with object positions encoded compactly in a single integer per quadrant cell (hundreds digit = stars, tens digit = starbases, units digit = Klingons). The game features six commands: navigation with warp factor and course (in degrees converted to radians via division by 57.3), short- and long-range sensor scans, phaser fire with inverse-square-law damage falloff, multi-torpedo spread firing with a randomised angular deviation, and a damage/tracking system report. Notably, damaged Klingons with fewer than 50 shield units may warp out of the quadrant (subroutine 6000), relocating to an adjacent quadrant, and the tracking system computes bearing angles using ATN with a small epsilon offset (1E-8) to avoid division by zero.


Program Analysis

Program Structure

The program is divided into clearly demarcated functional regions, though all in a single flat BASIC file:

Line RangeFunction
0–37Array declarations and variable initialisation
65–225Galaxy generation (Klingons, starbases, stars, starting position)
230–467Main game loop: command dispatch
500–630Introductory text and command list subroutines
2005–2435Navigation (course and warp factor movement)
2445–2740Short-range sensor scan and status display
2750–2870Long-range sensor scan
2880–3045Phaser fire
3055–3255Photon torpedo fire
3265–3400Damage control report and separator line subroutines
3500–3565Torpedo spread firing sequence
4005–4530Klingon attack, docking check, condition update, random events, quadrant entry
5000–5100Win/lose end screens
6000–6110Klingon warp-out subroutine
6500–6700Tracking system report
6750–7035Save stub and credits REMs

Galaxy Data Encoding

The galaxy map array M(8,8) encodes all three object types in a single integer per quadrant: hundreds digit = star count, tens digit = starbase count, units digit = Klingon count. This compact scheme allows the long-range scan to display a three-digit code per quadrant directly. The decode subroutine at line 4500 unpacks these values into S1 (stars), B1 (starbases), and K1 (Klingons in current quadrant) using integer arithmetic.

Navigation Engine

Navigation uses trigonometric dead-reckoning. The player supplies a course in degrees; line 2015 converts it to radians via A=A/57.3. Each warp unit causes 10 loop iterations (line 2065: FOR I=1 TO 10*B+.1), stepping position by SIN(A) and COS(A) each iteration. Quadrant boundaries are detected by comparing floating-point sector coordinates against 0.5 and 8.5 thresholds, with wrap-around into adjacent quadrants handled at lines 2105–2185. The +.1 in the loop limit is a guard against floating-point truncation dropping the last iteration.

Sector Object Grid

The sector array D(8,8) stores object codes: 0 = empty, 1 = Enterprise, 2 = Klingon, 3 = starbase, 4 = star. Klingon shield strengths are stored in the flat array K(88), indexed by I*10+J (sector coordinates), giving a maximum index of 88 for sector (8,8).

Combat Mechanics

Phaser damage follows an inverse-square law: the energy allocated to a Klingon is B/((I-X1)²+(J-Y1)²) where B is total energy fired and (I,J) are the Klingon’s sector coordinates (line 2960). Klingon return fire at line 4030 uses a similar formula scaled by a random multiplier. Torpedoes travel in half-sector steps (lines 3115–3120), printing their position each step with a PAUSE 25 delay for visual effect.

Multi-Torpedo Spread

The spread system (lines 3085–3565) is a notable enhancement. The player specifies torpedo count (up to 5), a spread angle in degrees, and a centre bearing. A random angular error Z is added to the centre angle (lines 3094–3100), scaled by the number of Klingons in the quadrant — more Klingons yield wider random deviation. Subroutine 3500 fires each torpedo in sequence, offsetting successive angles by ±D radians around the (already randomised) centre.

Klingon Warp-Out

When a Klingon’s shields drop below 50 but remain above 5 (lines 3017–3017), subroutine 6000 is called. The Klingon is removed from the current quadrant and relocated to a randomly chosen adjacent quadrant by generating random signs ZX and ZY (±1), adding them to the current quadrant coordinates, and validating boundary conditions. This mechanic meaningfully complicates the endgame.

Tracking System

The tracking system subroutine at line 6500 computes bearing to each Klingon in the current sector using 57.29*ATN((I-X1)/(J-Y1)+1E-8). The 1E-8 epsilon prevents division-by-zero when the Klingon is directly above or below the Enterprise. Lines 6540–6560 apply quadrant corrections (+180° or +360°) to map the ATN result from its principal value into a full 0–360° compass bearing.

Condition and Docking

Ship condition (GREEN/YELLOW/RED/DOCKED) is computed by subroutine 4095–4215. Docking is detected by checking if any starbase in the sector array has a Euclidean distance less than 1.5 sectors from the Enterprise position (line 4115). When docked, torpedoes are replenished to 20, energy to 5000, and all damage cleared.

Scoring

The efficiency rating at line 5020 is computed as 1000*(K3/(D1-D4))/B9 — kills per stardate elapsed, normalised by number of starbases. This rewards fast play and penalises games played in galaxies with more supporting bases. K3 holds the original Klingon count, D4 the starting stardate, and D1 the current stardate.

Bugs and Anomalies

  • Line 370 jumps to GOTO 300, but line 300 does not exist; execution falls through to line 305 (the command prompt). This is a valid idiom in BASIC where GO TO a missing line number continues at the next line — functioning correctly here by accident of convention.
  • Line 3280 is referenced by line 3265 (GOTO 3280) but does not exist; execution falls to line 3285, which begins the damage report loop — the intended behaviour.
  • Lines 6060–6062 implement a sign assignment for ZX with a logic error: the condition IF ZX<.5 is checked twice. After the first check sets ZX=-1, the second IF ZX<.5 THEN GOTO 6070 will always branch (since -1 < 0.5), meaning ZX is never set to +1. The warp-out destination is therefore always in the direction of decreasing X coordinate (or same quadrant if boundary is hit).
  • Line 3190 uses K(X*10+Y) with floating-point X and Y rather than XX and YY; this may produce an incorrect array index, leaving a ghost entry in the Klingon strength array.
  • The GOTO 1 in line 6780 references a non-existent line, so the program halts after saving — a deliberate save-and-restart pattern.

Content

Appears On

Assembled by Tim Ward from many sources. Contains programs 10211 – 10251.

Related Products

Related Articles

Related Content

Image Gallery

Star Trek 3.5

Source Code

   0 REM   TO START, GOTO 1                STAR TREK 3.5  VIA              SEATTLE TIMEX U/G               MODIFICATIONS TO                LONG RANGE SCAN,                CLEAN UP OF DISPLAY             AND SCORING SYSTEM              BY ANTHONY WILLING
   3 CLS 
   5 FAST 
  10 DIM S(8)
  12 DIM M(8,8)
  14 DIM D(8,8)
  16 DIM K(88)
  35 LET L9=0
  36 LET C9=0
  37 LET ZZZ=0
  65 LET D1=INT ((INT (RND*1999)+2001)/10)*10
  67 LET D4=D1
  75 LET D3=INT (RND*20)+31
  80 LET D2=D3+D1
  85 LET K9=INT (RND*D3/3)+1+INT (D3/3)
  87 LET K3=K9
  90 FOR I=1 TO K9
  95 LET X=INT (RND*8)+1
 100 LET Y=INT (RND*8)+1
 105 IF M(X,Y)>4 THEN GOTO 95
 110 LET M(X,Y)=M(X,Y)+1
 115 NEXT I
 120 LET B9=INT (RND*10)+1
 125 FOR I=1 TO B9
 130 LET X=INT (RND*8)+1
 135 LET Y=INT (RND*8)+1
 140 IF M(X,Y)>15 THEN GOTO 130
 145 LET M(X,Y)=M(X,Y)+10
 150 NEXT I
 155 LET S9=INT (RND*250)+1
 160 FOR I=1 TO S9
 165 LET X=INT (RND*8)+1
 170 LET Y=INT (RND*8)+1
 175 IF M(X,Y)>800 THEN GOTO 165
 180 LET M(X,Y)=M(X,Y)+100
 185 NEXT I
 190 LET U1=INT (RND*8)+1
 195 LET V1=INT (RND*8)+1
 200 LET X1=INT (RND*8)+1
 205 LET Y1=INT (RND*8)+1
 210 LET P9=3000
 220 LET T9=20
 225 GOSUB 4350
 230 GOSUB 550
 232 GOSUB 510
 233 INPUT K$
 234 CLS 
 235 GOSUB 4095
 240 GOSUB 2445
 305 PRINT "     COMMAND?"
 310 INPUT I
 315 IF I=0 THEN GOTO 375
 320 IF I=1 THEN GOTO 390
 325 IF I=2 THEN GOTO 405
 330 IF I=3 THEN GOTO 415
 335 IF I=4 THEN GOTO 435
 340 IF I=5 THEN GOTO 455
 342 IF I=6 THEN GOTO 465
 360 PRINT "YOU ARE NOT CLEARED    FOR THAT COMMAND"
 370 GOTO 300
 375 GOSUB 2005
 380 GOSUB 4005
 385 GOSUB 4225
 388 GOTO 391
 390 CLS 
 391 GOSUB 4095
 395 GOSUB 2445
 400 GOTO 305
 405 CLS 
 406 GOSUB 2750
 410 GOTO 305
 415 GOSUB 2880
 420 GOSUB 4005
 425 GOSUB 4225
 430 GOTO 305
 435 GOSUB 3055
 440 GOSUB 4005
 445 GOSUB 4225
 450 GOTO 305
 455 CLS 
 456 GOSUB 3265
 460 GOTO 305
 465 GOSUB 6500
 467 GOTO 305
 500 STOP 
 510 CLS 
 511 PRINT "   YOUR CHOICES OF COMMAND ARE:"
 515 PRINT "   0 = SET COURSE"
 520 PRINT "   1 = SHORT RANGE SENSOR SCAN"
 525 PRINT "   2 = LONG RANGE SENSOR SCAN"
 530 PRINT "   3 = FIRE PHASERS"
 535 PRINT "   4 = FIRE PHOTON TORPEDOES"
 537 PRINT "   5 = DAMAGE CONTROL REPORT"
 540 PRINT "   6 = TRACKING SYSTEM REPORT"
 541 PRINT 
 542 PRINT "SPOCK HERE; WE ARE  READY SIR"
 543 PRINT "THE SHIP IS EQUIPPED WITH A TEK SENSOR SCREEN ACTIVATE IT NOW"
 544 PRINT "PRESS RETURN."
 545 RETURN 
 550 PRINT "ORDERS; STARDATE = ";D1
 552 PRINT 
 555 PRINT "AS COMMANDER OF THE UNITED STAR-SHIP ENTERPRISE, YOUR MISSION   IS TO RID THE GALAXY OF THE     DEADLY KLINGON MENACE.  TO DO   THIS YOU MUST DESTROY THE       KLINGON INVASION FORCE OF ";K9,"BATTLE CRUISERS."
 575 PRINT "YOU HAVE ";D3;" SOLAR DAYS TO COMP- LETE YOUR MISSION, (UNTIL","STARDATE ";D2;")"
 585 PRINT "YOU HAVE ";B9;" SUPPORTING STARBASES WHEN THE ENTERPRISE DOCKS AT ONE(IS POSITIONED NEXT TO ONE) IT"
 590 PRINT "IS RESUPPLIED WITH ENERGY AND   PHOTON TORPEDOES."
 615 PRINT "WE ARE CURRENTLY IN","QUADRANT ";U1;"-";V1,,"SECTOR ";X1;"-";Y1
 617 PRINT 
 620 PRINT "PRESS RETURN TO START-CAPTAIN"
 625 INPUT I$
 627 CLS 
 630 RETURN 
 2005 PRINT "SULU HERE; WHAT COURSE CAPTAIN?"
 2010 INPUT A
 2015 LET A=A/57.3
 2020 PRINT "WARP FACTOR (0-8)"
 2025 INPUT B
 2030 IF B<0 OR B>8 THEN GOTO 2005
 2035 IF S(1)=0 OR B<=.5 THEN GOTO 2050
 2040 PRINT "WARP DRIVE DAMAGED MAXIMUM      IMPULSE .5"
 2045 GOTO 2005
 2050 LET P9=P9-100*B
 2051 CLS 
 2052 IF P9<0 THEN GOTO 5050
 2055 LET X0=X1
 2060 LET Y0=Y1
 2062 PRINT "SHIPS COURSE: QUADRANT, SECTOR"
 2065 FOR I=1 TO 10*B+.1
 2070 LET M=U1
 2075 LET N=V1
 2080 LET X=X0+SIN (A)
 2085 LET Y=Y0+COS (A)
 2090 IF X<=.5 THEN GOTO 2105
 2095 IF X>8.5 THEN GOTO 2125
 2100 GOTO 2140
 2105 IF M<=1 THEN GOTO 2300
 2110 LET M=M-1
 2115 LET X=X+8
 2120 GOTO 2140
 2125 IF M>=8 THEN GOTO 2300
 2130 LET M=M+1
 2135 LET X=X-8
 2140 IF Y<=.5 THEN GOTO 2155
 2145 IF Y>8.5 THEN GOTO 2175
 2150 GOTO 2190
 2155 IF N<=1 THEN GOTO 2300
 2160 LET N=N-1
 2165 LET Y=Y+8
 2170 GOTO 2190
 2175 IF N>=8 THEN GOTO 2300
 2180 LET N=N+1
 2185 LET Y=Y-8
 2190 LET U1=M
 2195 LET V1=N
 2200 LET M=INT (X+.5)
 2205 LET N=INT (Y+.5)
 2210 LET X0=X
 2215 LET Y0=Y
 2220 IF L9=10*U1+V1 THEN GOTO 2260
 2225 LET X1=M
 2230 LET Y1=N
 2235 LET D1=D1+1
 2240 IF D2-D1<1 THEN GOTO 5050
 2245 GOSUB 4350
 2250 LET P9=P9-100
 2252 IF P9<0 THEN GOTO 5050
 2255 GOTO 2285
 2260 IF D(M,N)>1 THEN GOTO 2330
 2265 LET D(X1,Y1)=0
 2270 LET X1=M
 2275 LET Y1=N
 2280 LET D(X1,Y1)=1
 2285 PRINT U1;" ";V1;" , ";X;" ";Y
 2290 NEXT I
 2292 INPUT I$
 2293 CLS 
 2295 RETURN 
 2300 PRINT "ENTERPRISE HALTED AT ROMULON     SPACE"
 2305 RETURN 
 2310 LET D(I,J)=0
 2315 LET M(U1,V1)=M(U1,V1)-1
 2320 LET K(10*I+J)=0
 2325 GOTO 3030
 2330 IF D(M,N)=4 THEN GOTO 2350
 2335 IF D(M,N)=3 THEN GOTO 2360
 2340 IF D(M,N)=2 THEN GOTO 2370
 2345 STOP 
 2350 CLS 
 2351 PRINT "ENTERPRISE IN STANDARD ORBIT    OVER STAR."
 2355 RETURN 
 2360 CLS 
 2361 PRINT "ENTERPRISE DOCKED AT STARBASE"
 2365 RETURN 
 2370 CLS 
 2371 PRINT "***KLINGON RAMMED***"
 2375 PRINT "WARP DRIVE DAMAGED IN COLLISION"
 2380 LET K1=K1-1
 2385 LET K9=K9-1
 2390 IF K9<1 THEN GOTO 5000
 2395 LET D(M,N)=0
 2400 LET K(10*M+N)=0
 2405 LET M(U1,V1)=M(U1,V1)-1
 2410 LET S(1)=S(1)+4*RND
 2415 LET D(X1,Y1)=0
 2420 LET X1=M
 2425 LET Y1=N
 2430 LET D(M,N)=1
 2435 RETURN 
 2445 IF S(2)=0 THEN GOTO 2470
 2450 PRINT "*** S.R. SENSORS ARE OUT ***"
 2455 GOTO 2475
 2470 GOSUB 3365
 2475 FOR J=8 TO 1 STEP -1
 2477 PRINT TAB 6;
 2480 IF S(2)>0 THEN GOTO 2555
 2490 FOR I=1 TO 8
 2495 IF D(I,J)=4 THEN PRINT " *";
 2500 IF D(I,J)=0 THEN PRINT " :";
 2505 IF D(I,J)=1 THEN PRINT " >";
 2510 IF D(I,J)=2 THEN PRINT " £";
 2515 IF D(I,J)=3 THEN PRINT " B";
 2545 NEXT I
 2547 PRINT " "
 2550 NEXT J
 2555 PRINT "STARDATE ";D1
 2560 PRINT "QUADRANT ";U1;"-";V1,"SECTOR ";X1;"-";Y1
 2565 PRINT "ENERGY ";P9,"TORPEDOES ";T9
 2570 PRINT "KLINGONS ";K9
 2575 PRINT "CONDITION ";
 2580 IF C9=0 THEN PRINT "GREEN"
 2585 IF C9=1 THEN PRINT "YELLOW"
 2590 IF C9=2 THEN PRINT "RED"
 2595 IF C9=3 THEN PRINT "DOCKED"
 2600 PRINT "DAYS LEFT ";D2-D1
 2725 LET A=4
 2730 LET B=25
 2735 GOSUB 3365
 2740 RETURN 
 2750 IF S(3)=0 THEN GOTO 2765
 2755 PRINT "*** L.R. SENSORS OUT ***"
 2760 RETURN 
 2765 PRINT "L.R. SCAN OF QUADRANT ";U1;"-";V1
 2785 GOSUB 3365
 2790 FOR I=V1+1 TO V1-1 STEP -1
 2795 PRINT TAB 8;"";
 2800 FOR J=U1-1 TO U1+1
 2805 IF I<1 OR I>8 THEN GOTO 2825
 2815 IF J<1 OR J>8 THEN GOTO 2835
 2820 GOTO 2845
 2825 PRINT ":";"######";":";"######";":";"######"
 2830 GOTO 2860
 2835 PRINT ":";"######";
 2840 GOTO 2858
 2845 IF M(J,I)>=100 THEN GOTO 2847
 2846 GOTO 2849
 2847 PRINT ":";M(J,I);
 2848 GOTO 2858
 2849 IF M(J,I)>=10 THEN GOTO 2851
 2850 GOTO 2853
 2851 PRINT ":0";M(J,I);
 2852 GOTO 2858
 2853 IF M(J,I)<10 AND M(J,I)>0 THEN PRINT ":00";M(J,I);
 2854 IF M(J,I)=0 THEN PRINT ":000";
 2858 NEXT J
 2859 PRINT 
 2860 GOSUB 3365
 2865 NEXT I
 2870 RETURN 
 2880 IF S(4)=0 THEN GOTO 2895
 2885 PRINT "PHASOR CONTROL DAMAGED"
 2890 RETURN 
 2895 IF K1>0 THEN GOTO 2910
 2900 PRINT "?TARGET?"
 2905 RETURN 
 2910 PRINT "PHASORS LOCKED ON TARGET"
 2915 PRINT "ENERGY= ";P9
 2920 PRINT "SULU; NUMBER OF FIRE CAPTAIN?"
 2925 INPUT B
 2926 CLS 
 2930 IF B<0 THEN GOTO 2920
 2935 IF B>P9 THEN GOTO 2915
 2940 LET P9=P9-B
 2945 FOR I=1 TO 8
 2950 FOR J=1 TO 8
 2955 IF D(I,J)<>2 THEN GOTO 3030
 2960 LET A=B/((I-X1)*(I-X1)+(J-Y1)*(J-Y1))
 2965 LET K(I*10+J)=K(I*10+J)-A
 2970 PRINT "KLINGON AT ";I;"-";J;" HIT ";A;", ";
 2975 IF K(I*10+J)>0 THEN GOTO 3015
 2980 PRINT "DESTROYED"
 2985 LET K1=K1-1
 2990 LET K9=K9-1
 2995 IF K9<1 THEN GOTO 5000
 3000 LET D(I,J)=0
 3005 LET M(U1,V1)=M(U1,V1)-1
 3010 GOTO 3030
 3015 PRINT K(I*10+J);" UNITS LEFT"
 3016 IF K(I*10+J)<5 THEN PRINT "SPOCK, THE KLINGON VESSEL AT";I;"-";J;"  IS DRIFTING AND DISABLED"
 3017 IF K(I*10+J)>5 AND K(I*10+J)<50 THEN GOSUB 6000
 3019 IF K1<1 THEN RETURN 
 3020 IF S(7)<>0 THEN GOTO 3030
 3024 LET ZZZ=1
 3025 GOSUB 6530
 3026 LET ZZZ=0
 3030 NEXT J
 3035 NEXT I
 3040 IF P9<1 THEN GOTO 5050
 3045 RETURN 
 3055 IF S(5)=0 THEN GOTO 3070
 3060 PRINT "PHOTON TUBES OUT"
 3065 RETURN 
 3070 IF T9>0 THEN GOTO 3085
 3075 PRINT "TORPEDOE SUPPLY EXHAUSTED"
 3080 RETURN 
 3085 PRINT "NUMBER OF TORPEDOES-MAX 5"
 3087 INPUT NN
 3088 IF K1=0 THEN LET Z=0
 3089 PRINT "SPREAD FACTOR"
 3090 INPUT D
 3091 LET D=D/57.29
 3092 PRINT "CENTER OF SPREAD"
 3093 INPUT A
 3094 LET ZZ=RND
 3095 CLS 
 3096 IF K1>=3 THEN LET Z=RND
 3097 IF K1=1 THEN LET Z=RND**10
 3098 IF K1=2 THEN LET Z=RND**2
 3099 IF ZZ<.5 THEN LET Z=-Z
 3100 LET A=A/57.29+Z
 3101 GOTO 3500
 3102 LET T9=T9-1
 3104 IF T9<.5 THEN GOTO 3075
 3105 LET X=X1
 3110 LET Y=Y1
 3115 LET X=X+SIN (A)/2
 3116 LET XX=X
 3120 LET Y=Y+COS (A)/2
 3121 LET YY=Y
 3130 PRINT INT (X*10+.5)/10;"-";INT (Y*10+.5)/10
 3132 PAUSE 25
 3135 IF XX<1 OR XX>8 OR YY<1 OR YY>8 THEN GOTO 3250
 3140 IF D(XX,YY)=2 THEN GOTO 3160
 3145 IF D(XX,YY)=3 THEN GOTO 3200
 3150 IF D(XX,YY)=4 THEN GOTO 3225
 3155 GOTO 3115
 3160 PRINT "***KLINGON DESTROYED***"
 3162 INPUT A$
 3163 CLS 
 3165 LET K1=K1-1
 3170 LET K9=K9-1
 3175 IF K9<1 THEN GOTO 5000
 3180 LET D(XX,YY)=0
 3185 LET M(U1,V1)=M(U1,V1)-1
 3190 LET K(X*10+Y)=0
 3195 RETURN 
 3200 PRINT "?STARBASE DESTROYED?"
 3202 INPUT A$
 3203 CLS 
 3205 LET B1=B1-1
 3210 LET D(XX,YY)=0
 3215 LET M(U1,V1)=M(U1,V1)-10
 3220 RETURN 
 3225 PRINT "STAR DESTROYED"
 3227 INPUT A$
 3228 CLS 
 3230 LET S1=S1-1
 3235 LET D(XX,YY)=0
 3240 LET M(U1,V1)=M(U1,V1)-100
 3245 RETURN 
 3250 PRINT "TORPEDO MISSED"
 3252 INPUT A$
 3253 CLS 
 3255 RETURN 
 3265 IF S(6)=0 THEN GOTO 3280
 3270 PRINT "DAMAGE CONTROL NOT AVAILABLE"
 3275 RETURN 
 3285 FOR A=1 TO 7
 3290 GOSUB 3320
 3295 PRINT "   ";S(A)
 3300 NEXT A
 3305 RETURN 
 3315 LET A=INT (RND*7)+1
 3320 IF A=1 THEN PRINT "WARP ENGINES     ";
 3325 IF A=2 THEN PRINT "S. R. SENSORS    ";
 3330 IF A=3 THEN PRINT "L. R. SENSORS    ";
 3335 IF A=4 THEN PRINT "PHASOR CONTROL   ";
 3340 IF A=5 THEN PRINT "PHOTON TORPEDOES ";
 3345 IF A=6 THEN PRINT "DAMAGE CONTROL   ";
 3350 IF A=7 THEN PRINT "TRACKING SYSTEM  ";
 3355 RETURN 
 3365 PRINT "    ----------------------"
 3400 RETURN 
 3500 GOSUB 3102
 3505 IF NN<=1 THEN RETURN 
 3510 LET A=A+D
 3515 GOSUB 3102
 3520 IF NN<=2 THEN RETURN 
 3525 LET A=A-2*D
 3530 GOSUB 3102
 3535 IF NN<=3 THEN RETURN 
 3540 LET A=A+D/2
 3545 GOSUB 3102
 3550 IF NN<=4 THEN RETURN 
 3555 LET A=A+D
 3560 GOSUB 3102
 3565 RETURN 
 4005 IF K1<1 THEN RETURN 
 4010 PRINT K1;" KLINGONS ATTACKING  RED ALERT"
 4015 FOR I=1 TO 8
 4020 FOR J=1 TO 8
 4022 IF D(I,J)<>2 THEN GOTO 4075
 4025 LET B=INT (RND*K(I*10+J))+1
 4030 LET A=B*10/((I-X1)*(I-X1)+(J-Y1)*(J-Y1))
 4040 IF A<15 THEN GOTO 4075
 4045 LET K(I*10+J)=K(I*10+J)-A
 4050 LET P9=P9-A
 4060 PRINT "ENTERPRISE HIT (";A;" UNITS) KLINGONS AT SECTOR ";I;"-";J
 4070 IF P9<1 THEN GOTO 5050
 4075 NEXT J
 4080 NEXT I
 4085 RETURN 
 4095 IF B1=0 THEN GOTO 4180
 4100 FOR I=1 TO 8
 4105 FOR J=1 TO 8
 4110 IF D(I,J)<>3 THEN GOTO 4120
 4115 IF SQR ((X1-I)*(X1-I)+(Y1-J)*(Y1-J))<1.5 THEN GOTO 4135
 4120 NEXT J
 4125 NEXT I
 4130 GOTO 4180
 4135 LET C9=3
 4140 IF T9>20 THEN GOTO 4150
 4145 LET T9=20
 4150 IF P9>5000 THEN GOTO 4160
 4155 LET P9=5000
 4160 FOR I=1 TO 7
 4165 LET S(I)=0
 4170 NEXT I
 4175 RETURN 
 4180 IF K1<1 THEN GOTO 4195
 4185 LET C9=2
 4190 RETURN 
 4195 IF P9>1000 THEN GOTO 4210
 4200 LET C9=1
 4205 RETURN 
 4210 LET C9=0
 4215 RETURN 
 4225 LET A=RND
 4230 IF A<.4 THEN RETURN 
 4235 IF A<.5 THEN GOTO 4290
 4240 IF A<.9 AND K1<>0 THEN GOTO 4265
 4242 IF A<.95 THEN RETURN 
 4245 PRINT "*** SOLAR STORM ***"
 4250 IF C9<>3 THEN GOTO 4270
 4255 PRINT "STARBASE SHIELDS PROTECT SHIP**"
 4260 RETURN 
 4265 PRINT "BATTLE DAMAGE"
 4266 IF K1<1 THEN RETURN 
 4270 GOSUB 3315
 4275 PRINT " DAMAGED"
 4280 LET S(A)=S(A)+4*RND
 4285 RETURN 
 4290 FOR A=1 TO 7
 4295 IF S(A)<>0 THEN GOTO 4310
 4300 NEXT A
 4305 RETURN 
 4310 PRINT "CAPTAIN, SCOTTY HERE",
 4315 GOSUB 3320
 4320 PRINT "STATE OF REPAIR IMPROVED"
 4325 LET S(A)=S(A)-5*RND
 4330 IF S(A)>0 THEN GOTO 4340
 4335 LET S(A)=0
 4340 RETURN 
 4350 IF L9<>U1*10+V1 THEN GOTO 4360
 4352 RETURN 
 4360 LET L9=U1*10+V1
 4365 GOSUB 4500
 4370 FOR K=1 TO 8
 4375 FOR L=1 TO 8
 4380 LET D(K,L)=0
 4385 NEXT L
 4390 NEXT K
 4395 LET D(X1,Y1)=1
 4400 LET J=S1
 4405 LET B=4
 4410 GOSUB 4455
 4415 LET J=B1
 4420 LET B=3
 4425 GOSUB 4455
 4430 LET B=2
 4435 FOR K=1 TO K1
 4437 GOSUB 4470
 4440 LET K(U*10+V)=INT (RND*300)+151
 4445 NEXT K
 4450 RETURN 
 4455 FOR K=1 TO J
 4460 GOSUB 4470
 4465 NEXT K
 4466 RETURN 
 4470 LET U=INT (RND*8)+1
 4475 LET V=INT (RND*8)+1
 4480 IF D(U,V)<>0 THEN GOTO 4470
 4485 LET D(U,V)=B
 4490 RETURN 
 4500 LET K1=M(U1,V1)
 4505 LET S1=INT (K1/100)
 4510 LET K1=K1-S1*100
 4515 LET B1=INT (K1/10)
 4520 LET K1=K1-B1*10
 4525 RETURN 
 4530 PRINT "BATTLE ALARM"
 4535 RETURN 
 5000 CLS 
 5001 PRINT "IT IS STARDATE ";D1
 5005 PRINT "THE KLINGONS HAVE BEEN DESTROYED"
 5010 PRINT "THE FEDERATION IS SAVED"
 5015 PRINT "YOU ARE A HERO, CAPTAIN"
 5020 PRINT "YOUR EFFICIENCY RATING IS ",,, 1000*(K3/(D1-D4))/B9
 5021 PRINT 
 5022 PRINT "KILLS=";K3,"DAYS=";D1-D4
 5035 STOP 
 5050 CLS 
 5051 PRINT "IT IS STARDATE ";D1
 5055 IF D2-D1<1 THEN GOTO 5070
 5060 PRINT "THE ENTERPRISE ENERGY BANKS ARE DEAD"
 5065 GOTO 5080
 5070 PRINT "TIME HAS RUN OUT FOR YOU"
 5080 PRINT "THE ENTERPRISE IS DESTROYED"
 5085 PRINT "THERE ARE STILL ";K9;" KLINGON BATTLE CRUISERS LEFT"
 5090 PRINT "ITS COOKIES CAPTAIN"
 5100 STOP 
 6000 PRINT "A KLINGON SHIP IS WARPING OUT   OF THIS QUADRANT"
 6010 LET K(I*10+J)=0
 6020 LET D(I,J)=0
 6030 LET K1=K1-1
 6040 LET M(U1,V1)=M(U1,V1)-1
 6050 LET ZX=RND
 6060 IF ZX<.5 THEN LET ZX=-1
 6061 IF ZX<.5 THEN GOTO 6070
 6062 LET ZX=1
 6070 LET ZY=RND
 6080 IF ZY<.5 THEN LET ZY=-1
 6081 IF ZY<.5 THEN GOTO 6086
 6082 LET ZY=1
 6086 LET XX=INT (ZX+U1)
 6087 LET YY=INT (ZY+V1)
 6090 IF XX>8.5 OR YY>8.5 OR XX<.5 OR YY<.5 THEN GOTO 6050
 6100 LET M(XX,YY)=M(XX,YY)+1
 6110 RETURN 
 6500 IF S(7)=0 THEN GOTO 6504
 6502 PRINT "TRACKING SYSTEM NOT FUNCTIONAL"
 6503 RETURN 
 6504 IF K1>=1 THEN GOTO 6509
 6505 PRINT "?TARGET?"
 6506 RETURN 
 6509 FOR I=1 TO 8
 6510 FOR J=1 TO 8
 6520 IF D(I,J)<>2 THEN GOTO 6590
 6530 LET DD=57.29*ATN ((I-X1)/(J-Y1)+1E-8)
 6540 IF (I-X1)>=0 AND (J-Y1)<=0 OR (I-X1)<=0 AND (J-Y1)<=0 THEN LET DD=DD+180
 6560 IF (I-X1)<=0 AND (J-Y1)>=0 THEN LET DD=DD+360
 6570 PRINT " TRACKING KLINGON AT ";DD
 6580 IF ZZZ=1 THEN GOTO 6700
 6590 NEXT J
 6595 NEXT I
 6700 RETURN 
 6750 STOP 
 6760 REM RAND USR 14336
 6770 REM SAVE "TREK35.B1"
 6775 SAVE "1021%7"
 6780 GOTO 1
 7000 REM ORIGINAL PROGRAM FROM
 7005 REM  SEATTLE TIMEX USER 
 7010 REM  GROUP (SEATUG).
 7015 REM  MODIFICATIONS WERE
 7020 REM  IMPROVING LONG RANGE
 7025 REM  SCAN, NUMERICAL SCORE
 7030 REM  SYSTEM, AND CLEANING
 7035 REM  UP SCREEN DISPLAY.

Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.

Scroll to Top