Month: January 2016

(This is part six of the chronicle of my Retrochallenge 2016/01 submission, which is to port some classic Star Trek text games to the Mattel Aquarius. To jump to the beginning, go here.)

STTR2

For the final week of this year’s Retrochallenge, I worked on creating STTR2. This is an embellished port of STTR1 taking some advantage of the modest capabilities of the Mattel/Radofin Aquarius.

To get to this point, I took the code for my “straight” port of STTR1 and completely re-factored the BASIC code to make it more structured. Next was to change any code that PRINTED to use relocatable, colored text and use the Aquarius’ graphic text characters to make grids, etc.

Sadly the project is incomplete for the purposes of challenge. There is no sound. It exceeds my target 16K RAM, and is slower than an ASR-33 teletype terminal. (The video above is running in an emulator with max speed enabled). But it was very fun to get this far.

Retrochallenge 2016/01 Epilogue

Well, I fell a little short for my challenge. I did not port Super Star Trek like I had originally planned and therefore ported STTR1 to the Aquarius instead of Super Star Trek. In retrospect I’m fine with it. I find STTR1 to be simple and enjoyable. The Trek games that followed added perhaps needless complexity.

What I was successful with was learning a ton about a game that I initially knew very little about. I have heard revering stories of the game from programmers who got an earlier start in computers than I did. I was also successful in learning more about the Aquarius and the great efforts of its enthusiasts.

(This is part four of the chronicle of my Retrochallenge 2016/01 submission, which is to port some classic Star Trek text games to the Mattel Aquarius. To jump to the beginning, go here.)

STTR1’s Gone Gold

STTR1 cassette case

The straight port of STTR1 for the Aquarius is nearing completion. These were the tasks on my TODO list:

Finalize the code

Create a Git repository for the files that will be publicly shared

Record STTR1 to a cassette tape

(Finally) run STTR1 on a real Aquarius

Create & print artwork for the cassette case

Finalize the Code

I’m trying to keep the target platform an Aquarius with a 16K RAM extension, even in emulation. One of the files I’ll be including in the distribution is a ROM (.bin file) image. This will allow easier loading on emulators or perhaps one day the file can be included with a multi-cart. To accomplish this, I used the modern hack Bootloader BASIC v2.1 (or BLBasic) found on the Atariage forums. This is an enhanced version of Aquarius Extended BASIC that, among other things, will create a ready-to-run binary version of a BASIC program. The clever trick exploits the fact that Virtual Aquarius emulator redirects printer output to a text file on the host computer. BLBasic re-purposes the LDUMP command to instead export a binary version of a BASIC program to the host computer via the emulated Aquarius printer port.

However I was seeing some strange behavior emanating from the .bin version of STTR1 while using MESS. It could be that MESS is not correctly emulating the Aquarius, or perhaps the STTR1 code along with whatever runtime is needed by BLBasic was hitting the upper bounds of the available memory.

So I’ve trimmed the memory footprint of the STTR1 code on the Aquarius by:

Consolidating multiple lines of HP Time-Shared BASIC to a single line using the “:” command separator. HP must’ve allowed strictly one command per line number in its Time-Shared BASIC because the original code never strays from that.

Trimming REM statements when HP added the program to their Contributed Program Library.

Consolidating commands introduced many new bugs because I inevitably removed a line number that was referenced somewhere else by a GOTO. I became very familiar with the “UL” error.

UL UNDEFINED LINE. Attemp-
ted branch to a line that is not in
memory, or deletion of a non-
existent line.

Create a Git Repository

Nothing too interesting . I’ve been using bitbucket.org for no particular reason. I know all the cool kids are hanging out at github, but I’m too lazy to migrate. So far, I’ve uploaded:

Record STTR1 to a Cassette Tape

In the Virtual Aquarius emulator, you can run the CSAVE command and it will export a .CAQ data file to your PC. Included in the tools sub-directory of the emulator is a program called CAQ2WAV.EXE. This Windows application will convert a .CAQ to a .WAV audio file.

I used Audacity to play the .WAV file to this gorgeous c.1986 General Electric 3-5015C tape recorder connected to the laptop’s audio output. Moved the tape over to the Aquarius’s Data Record and CLOAD’ed the muther in.

For all the stink eye that cassettes get, let me say that this all worked on the first try. Sure it takes 4m30s but that’s time to meditate – or run a very good mile.

Red DATA Light means life is good

(Finally) Play STTR1 on a Real Aquarius

STTR1 Instructions being printed to screen

The game plays well on the Aquarius. I even love the keyboard. The program includes an option to either print the instructions to screen or to the Aquarius’ thermal printer. I almost got weepy seeing that work on the first run.

Create & print artwork for the cassette case

I wanted a nice looking cassette case for STTR1. I looked at some examples of the third-party games sold in the eighties, for example “Chuckman“. And skimmed through episodes of Star Trek: The Only Series on Netflix to find some screen shots of space scenes to grab. After a long night of cutting, pasting, rotating, blurring, and undoing, I came up with something I like. Even has liner notes.

Up Next

My original plan was to also port Super Star Trek. Alas that one may have to wait for a future Retrochallenge. Instead I want to add color, sound, and maybe even extremely crude graphics to STTR1, making it what? STTR2?

(This is part three of the chronicle of my Retrochallenge 2016/01 submission, which is to port some classic Star Trek text games to the Mattel Aquarius. To jump to the beginning, go here.)

Mind Melding

In porting the 1972 version of STTR1 from HP Time-Shared BASIC to the Mattel Aquarius, I had to learn more about the code than I originally thought would be required. I imagined merely dealing with syntax differences which I could search and replace with ignorant bliss. However, the implementation of string variables differ so much between the two systems, I inevitably had to time-travel, get into the head of the high school student who authored STTR1, understand the program’s logic to a sufficient degree, and re-code some critical sections.

Is it spaghetti code? Of course it is. This is early BASIC and therefore a design requirement. Even so, some very clever algorithms exist throughout. (I’m especially impressed by the code that calculates course and torpedo trajectory.) However, the 1 or 2 character limit for variable names makes for a dizzying experience.

So before I move on and allow the weeds to germinate, I’d like to at least catalog the more interesting variables found in the original STTR1 listing along with my understanding of each one’s purpose.

Noteworthy Variables Found in Original STTR1

In case you’re inclined to follow along, here is the original BASIC listing for STTR1.

Up Next

(This is part two of the chronicle of my Retrochallenge 2016/01 submission, which is to port some classic Star Trek text games to the Mattel Aquarius. To jump to the beginning, go here.)

Work-in-Progress Port of STTR1 on the Aquarius

As with most of my Retrochallenge experiences, what I imagine I can accomplish in the first weekend requires the remainder of the month. So it has been with the no-frills port of the 1972 version of STTR1 to the Aquarius. My real goal is to extend a classic Star Trek text game to use Aquarius features such as color, sound, and hand controllers. But here we are halfway through January and I’m still just trying to get the original STTR1 game to run on the target platform.

As of the last several work sessions I have a foothold into the game and am able to play for a bit before encountering a mysterious syntax error at line number 1910. And torpedoes targeted towards Klingons instead say that I shouldn’t attack stars.

In this post I will enumerate the types of code changes I’ve had to make so far and provide some brief examples. At a high level there’s the trivial changes and, well, the non-trivial.

Trivial Changes

Printing Concatenated Strings

HP doesn’t require semicolons as concatenation operators.

HP Time-Shared BASIC

1580 PRINT "YOU HAVE"E" UNITS OF ENERGY"

Aquarius BASIC

1580 PRINT "YOU HAVE";E;" UNITS OF ENERGY"

Array Indexes

HP uses square brackets. Aquarius uses parentheses.

HP Time-Shared BASIC

1630 D[I]=D[I]+1

Aquarius BASIC

1630 D(I)=D(I)+1

Chained Variable Assignments

HP allows chained assignments, the Aquarius does not.

HP Time-Shared BASIC

320 E0=E=3000
330 P0=P=10

Aquarius BASIC

320 E0=3000:E=E0
330 P0=10:P=P0

Shortening Command Lines to 72 Characters

Aquarius BASIC has a maximum line length of 72 characters. The original STTR1 source for the HP contains many, many lines that exceed that limit. These are simple but somewhat tedious changes.

Aquarius Guide to Home Computing pp. 1-10

Reformatting Output for a 40 Character Display

The teletype terminals that would be connected to an HP2000C had generous line widths for displaying the program output. The 40 character display on a television set requires inserting line breaks into the original STTR1 text.

Formatted Output

HP Time-Shared BASIC provides formatted printing akin to C’s printf() function. IMAGE statements define a mix of literal strings and placeholders with format codes. The PRINT USING statement points to the line containing the desired IMAGE statement and a list of variables to be substituted for the placeholders.

1270 PRINT "COMMAND:";
1280 INPUT A
1290 IF A=0 THEN 1410
1292 IF A=1 THEN 1260
1293 IF A=2 THEN 2330
1294 IF A=3 THEN 2530
1295 IF A=4 THEN 2800
1296 IF A=5 THEN 3460
1297 IF A=6 THEN 3560
1298 IF A=7 THEN 4630

Non-Trivial Changes

Fundamental Differences in String Variables

Throughout the original STTR1 code, much of the game’s “graphical” representation is accomplished by injecting the symbols for the Enterprise (‘<*>’), stars (‘ * ‘), and Klingons (‘+++’) into large strings, exploiting HP’s treatment of Strings as special cases of matrices.

However, HP BASIC strings are limited to 72 characters. For this reason, the young Mr. Mayfield had to split the 192 (8 x 8 x 3) characters needed to represent the Short Range Scan view across 3 string variables Q$, R$, and S$. And then add code to cascade across the variables when trying to inspect a particular spot in a quadrant.

Strings do not need to be declared before use. The command DIM Q$ (64) creates an array of 64 (maybe 65) strings. For the Aquarius version of STTR1, strings will need to be used in a totally different way. Since the game’s “graphics” are stored as 3-character strings, I’ve opted to create an array of strings. In a 8×8 quadrant, Q$ will provide (64) 3-character strings.

Memory

No-Frills STTR1 Consumes Most of the 16K on an Aquarius

The target platform is an Aquarius with 16K RAM. If I drop the STTR1 code into an Aquarius emulator, FRE(0) shows that 1K of RAM is remaining. If I want to add new features, then the existing program will need to be put on a diet. Otherwise OM (Out of Memory) errors will begin to appear.

Solutions include: moving the embedded instructions to a separate, stand-alone program, combining multiple BASIC commands onto a single line, and creating an array of resource strings to use in place of repeated literals, like “KLINGON”, “TORPEDO”, and “ENTERPRISE”.

Up Next

(This is part one of the chronicle of my Retrochallenge 2016/01 submission, which is to port some classic Star Trek text games to the Mattel Aquarius. To jump to the beginning, go here.)

Let’s Play the HP Time Shared BASIC Version of STTR1

I recorded a “Let’s Play” video of an abbreviated session of STTR1, enough to exercise all of the commands at least once. This was very, very late night recording – my mental acuteness was the opposite of acute.

How/Where to Run the Original STTR1

In preparation for my Retrochallenge, I spent some time in December trying to learn about STTR1 and how to play the original game. Well, I assume the “original” original game, which ran on an SDS Sigma 7 computer is lost to us and now resides in bit heaven. But the HP Time Shared BASIC port survived because of its inclusion in HP’s User-Contributed Library and the success of the HP2000 Family. In the end, I found at least three options for playing the HP version of STTR1:

Locate and restore (2) HP2000 Series computers. One unit is needed for multiplexing terminals and one to run Access/Time Shared BASIC. And don’t forget tape drives or paper tape readers. And the media (magnetic and/or paper tapes). So – this option is impossible.

Download, compile, configure, and run the SimH simulator. If you haven’t heard of SimH, it is to minicomputers what MESS is to microcomputers – only difficult. I did, in fact, have success with this route after several weeks of trying and would like to document my setup and perhaps share some configuration files. But that is a lower priority at the moment. If I fail to document this, I did find everything I needed, (though not in any single, tidy package) at the HP2000 Yahoo Group but you’ll need to join the group to gain access to the necessary files.

Telnet to an already-running instance of a simh simulator. There are two such machines available at the time of this writing due to the generosity of the HP2000 Yahoo Group members :

mickey.publicvm.com
hp2000.brighton.ac.uk

The “Too Long, Didn’t Watch” Version

So, assuming these machines are still listening when you read this, the telnet option is the most straight-forward way to try out STTR1.

To Launch STTR1:

Launch a terminal, such as the classic ‘xterm‘, that won’t be confused by the HP’s strange End-of-Line characters.

For your convenience, the instructions for STTR1 have been pulled from the original source and reformatted in my previous post.

To Quit STTR1:

Use Command 7,2

Enter a long string at prompt for using the calculator. This causes a string overflow and breaks out of the program.

BYE

These machines have many other early text games including 1975 version of Oregon Trail. When looking at the list of programs in the output of GROUPS, the programs with a “C” attribute are semi-compiled and may need to be started using the command EXE-*progname, otherwise you should be able to use EXE-progname.

Up Next

Due to incompatibilities between HP’s BASIC and the version of MS BASIC found on the Aquarius, I’m forced to climb into the head of a teenage programmer from 1972.

Command 0 = Warp Engine Control

‘Course’ is a circular numerical vector arrangement as shown. Integer and real values may be used. Therefore course 1.5 is half way between 1 and 2.

4 3 2\ ^ / \ ^ /5 ------------- 1/ ^ \/ ^ \6 7 8
C O U R S E

A vector of 9 is undefined, but values may approach 9.

One ‘warp factor’ is the size of one quadrant. Therefore to get from quadrant 6,5 to 5,5 you would use course 3, warp factor 1.

Command 1 = Short Range Sensor Scan

Prints the quadrant you are currently in, including stars, Klingons, starbases, and the Enterprise; along with other pertinate information.

Command 2 = Long Range Sensor Scan

Shows conditions in space for one quadrant on each side of the Enterprise in the middle of the scan. The scan is coded in the form XXX, where the units digit is the number of stars, the tens digit is the number of starbases, and the hundreds digit is the number of Klingons.

Command 3 = Phaser Control

Allows you to destroy the Klingons by hitting him with suitably large numbers of energy units to deplete his shield power. Keep in mind that when you shoot at him, he gonna do it to you too.

Command 4 = Photon Torpedo Control

Course is the same as used in Warp Engine Control. If you hit the Klingon, he is destroyed and cannot fire back at you. If you miss, he will shoot his phasers at you.

Note: The Library Computer (Command 7) has an option to compute torpedo trajectory for you (Option 2).

Command 5 = Shield Control

Defines number of energy units to be assigned to shields. Energy is taken from the total ship’s energy.

Command 6 = Damage Control Report

Gives state of repairs of all devices. A state of repair less than zero shows that the device is temporarily damaged.

Command 7 = Library Computer

The library computer contains the three options:

Option 0 = Cumulative Galactic Record

Shows computer memory of the results of all previous long range sensor scans.

Option 1 = Status Report

Shows number of Klingons, stardates, and starbases left.

Option 2 = Photon Torpedo Data

Gives trajectory and distance between the Enterprise and all Klingons in your quadrant.