Saturday, February 23, 2019

Game 48: Star Trek

Download or view my fixed codebase of Star Trek here:

Download a compatible BASIC interpreter here:

The next whale is Atari’s Star Raiders, which was apparently an action-oriented remake of the popular mainframe computer game Star Trek from 1971.

Star Trek's original code was written by Mike Mayfield on his high school’s Sigma 7 mainframe, and was played on a teletype. That original codebase has likely been lost to time, and I wouldn’t know how to get BASIC files onto a SIMH-compatible disk image or how to use them. Fortunately, his subsequent rewrite to HP BASIC in 1972 does survive, and there is an HP BASIC interpreter that runs natively on Windows.

Unfortunately, I found multiple versions floating around, none quite as suitable as I would like. The first, which I will refer to as “Decode Systems,” has bugs in it which entirely prevent the Enterprise’s warp drives and torpedoes from functioning correctly. Another version has extensive differences and appears to be a relatively recent port to a different platform.

A third, which I will call “Pete Turnbull,” is more similar to the Decode Systems version but has several differences. It does not have the bugs that would prevent the warp drive and torpedoes from working, but does have a bug that prevents the game from even starting, and some misspellings.

My best guess is that the Pete Turnbull version is the original or closest to it, and the Decode Systems version’s differences are from manual transcription errors or deliberate correction. Perhaps the bug that prevents the former from starting is due to a lenient behavior in the original BASIC interpreter that isn’t allowed in more modern ones, and this bug was fixed in the Decode Systems version, while new ones were introduced by transcription error. The bug is easily fixed by copying the relevant line from the Decode Systems version into the Pete Turnbull version, and this is what I have done.

260  DIM G[8,8],C[9,2],K[3,3],N[3],Z[8,8],   D[10] Line 260 from Decode Systems
260  DIM G[8,8],C[9,2],K[3,3],N[3],Z[8,8] Line 260 from Pete Turnbull
Was the D[10] tacked on by a transcriber who discovered the code wouldn’t run without it?

1950  A$="  " Line 1950 from Decode Systems
1950  A$="   " Line 1950 from Pete Turnbull
That omission of a single space in the former line prevents the Enterprise from warping anywhere. A manual retyping error, perhaps?

Star Trek is about exploring strange new worlds, seeking out new life, new civilizations, and boldly going where no man has gone before.

Just kidding. It's a strategy game about blowing up Klingons. And it sort of plays like a cross between Battleship and Minesweeper.

The warning mattered back when this was played on a Teletype.

There are a whole bunch of things that aren’t adequately explained here. The entire game is played by entering series of commands to the Enterprise. The galaxy is a two-dimensional 8x8 grid of quadrants, and each quadrant is a two dimensional 8x8 grid of sectors. Each sector is either empty space or contains one object; the Enterprise, an enemy ship, starbase, or star. Starbases can be docked at to refuel and rearm the ship, and stars are obstacles that block the Enterprise and its torpedoes.

The warp engines are your sole means of navigating space, and require you to enter an angular heading and distance. For instance, course 1 means due east, course 2 means northeast, and so on. Warp factor determines distance moved, and warp 1 moves the distance of a single quadrant. To move within a quadrant, you must enter a warp factor less than one. E.g. – warp 0.125 takes you the distance of a one sector (as there are eight sectors spanning the width of a quadrant), warp 0.25 takes you the distance of two sectors, etc. If the Enterprise collides into an object while warping, it simply stops in its tracks right next to the object.

Courses may also be entered as decimals to move in directions finer than 45 degrees, but I found it better not to. I tried to navigate by using trig for precise headings, but it rarely took me where I wanted to go. Either my trig is wrong, or this game’s approximation of it is wrong. And I doubt it’s using special relativistic velocity calculations.

The short range sector scan shows you the map of your current quadrant. It’s automatically activated when you start the game and whenever you warp anywhere.

The long range sensor scan shows you a 3x3 grid of the nine quadrants in your immediate vicinity, and tells you what you can expect to find in it.

Phaser control fires energy at all Klingon battlecruisers in the current quadrant. It always hits (provided the battle computer is operational), but you are responsible for deciding how much energy to fire. Damage to each battlecruiser is equal to the amount of energy used, divided by the distance in sectors to that battlecruiser, divided by the number of battlecruisers in the area, and multiplied by a random decimal number between 0 and 2. It takes 200 points of damage to destroy one.

Photon torpedo control requires you to enter a course for your torpedoes, which is a bit pointless because the battle computer can compute it for you. Stars will block them, and they will blow up friendly starbases if they hit one. Torpedoes are limited in supply but kill in one hit and do not drain energy.

Shield control lets you transfer energy to (or from) the shields. If your shields are not charged, then a single hit from the Klingons’ disruptors will destroy the Enterprise.

Damage control lets you see the status of the Enterprise’s systems, which function badly or not at all when damaged. Taking hits causes subsystem damage, but the parts also spontaneously fail as you cruise around the galaxy. Fortunately, Mr. Scott repairs damage over time.

The computer’s function 0 shows you an 8x8 grid map of the known galaxy, and is automatically updated whenever you perform a long range scan. Could this be the first automap in a computer game?

Function 1 and 2 are explained adequately. The photon torpedo calculations are a free action, there’s no advantage to doing the calculations yourself.

So, onto the game:

Just started, and I’m already dumped into a quadrant with a Klingon! Red alert, shields up, diverting 1000 energy, and activate the battle computer.

Battle computer indicates a direction of 3.25. Mr. Chekov, fire.

Scratch one Klingon. With this quadrant now quiet, I performed a long range scan, which is a good thing to do whenever killing a Klingon or entering a new quadrant.

Nothing in this vicinity but stars. I checked the computer map.

I’m in row 2, column 3. The quadrants surrounding me were scanned, but everything else was blank. So I decided to warp west one quadrant so that I could view the top three rows of column 1.

Nothing there. I checked the map again, which gets filled out more with every long range scan you perform.

Quadrant 5,2 is right in the middle of a totally unexplored 3x3 grid. Mr. Sulu, plot course 7, warp 3.

Nothing here either! I warped further south to complete my search of the left side of the galaxy.

Again, nothing. On to quadrant 7,5. Course 1, warp 3.

Three Klingons are nearby! Let’s head east first.

Another easy kill. Another map-updating scan:

Two nearby quadrants contain Klingons, which I warped to and killed with my torpedoes.

I continued this search and destroy technique, and soon found a quadrant with two Klingons!

No problem. The closer Klingon was directly course 3.

I don’t even need the battle computer here.

The battle computer and another torpedo take care of the second.

Eventually, I started to run low on torpedoes.

Two torpedoes left, six Klingons nearby. Time to check the map.

There’s a friendly starbase in quadrant 8,7 directly to the south. Lucky me. Course 7, warp 3.

To dock, just move the ship to an adjacent sector. Each sector length is 1/8th of a quadrant, so course 1, warp factor 0.375 will take me three sectors to the east.

Don’t forget to reactivate the shields after undocking.

After impulse driving around the stars and warping north, I found a quadrant with three Klingons! I was surrounded.

And the poor bastards didn’t have a chance. No need for the battle computer here!

Warping again, another set of three.

Two of these are behind stars. I torpedo the first.

Then I decided to try phasers on the remaining two. It takes 200 damage to kill a Klingons. The closest one is 3 sectors away, and there are two of them. The random factor should have an average distribution of 1. 200 * 3 * 2 = 1200, so I tried 1200 energy.

The RNG worked in my favor, and both were destroyed.

I warped one more time and found two more Klingons, who I torpedoed.

And that’s the game. I have no idea how the mission time is calculated, but the method probably just doesn’t work right on a modern BASIC interpreter.

Figuring out the game was kind of fun, but there just isn’t enough depth or complexity for it to have lasting power. The hardest parts were remembering what directions the course numbers correspond to, and occasionally navigating around stars in particularly dense sectors. The battle computer makes bagging Klingons a turkey shoot, and I’m sure the aiming algorithm is simple enough for a human to figure out and perform manually. I just didn’t care enough to try.


  1. You didn't mention having it on your master list, but if you're playing Star Trek as a lead-up to Star Raiders, I'd strongly recommend playing Atari's 2600 game Stellar Track from 1980 between the two. This was Atari's first attempt at remaking/porting Star Trek to their system, and missing out on it would leave it as this sort of missing link between the two.

    1. Star Raiders was 1979, but thanks for sharing that! It's a dead ringer for Star Trek, alright, and I'm impressed that they made any amount of that game work on a VCS and its one-button controller. I may cover this when I do Star Raiders.

    2. Wow, so it was. Sorry about that, I was convinced it was a 1981 release for some reason.

    3. Oh, it was the Atari 2600 version of Star Raiders that was 1982 (yeah, still not '81, not sure where I got that year from... I think it's just that Activision's Starmaster was '82, and I knew that was based on Star Raiders). Didn't even know there WAS an Atari 8-bit version.


Most popular posts