UK101
Return to index

Sample Programs and Tapes

The following sample programs and tapes are provided:

Note: Where indicated (using a cassette image) some of these sample programs and tapes are recovered from original software. I do not own the copyrights for these recovered programs and so I sincerely hope no one will mind them being included in this package. If any of the original copyright owners object, please contact me at the email address at the bottom of the page and I will gladly remove anything that should not be here.

In addition this page provides some notes about the tape formats used by the simulator and details of how to recover programs from cassette tapes.

Loading and Running BASIC programs

To load and run a program written in BASIC:

  1. Reset the machine and do a cold start to enter the BASIC interpreter.
  2. Type the LOAD and press Enter. The cursor will stop flashing to indicate input has been switched to the cassette player.
  3. Use the Cassette Recorder to open the program source code file and press the Play button. You should see the program being loaded.
  4. When the loading has finished press the SPACE bar to switch control back to the keyboard (the cursor should start flashing again).
  5. Type RUN and press Enter to run the program.

Loading and Running Machine Code Tapes

Machine code program tapes need to be loaded using the Monitor:

  1. Reset the machine and enter the Monitor by pressing M.
  2. Start the Monitor load routine by pressing L. There's no visible cue that anything has happened but the system should now be waiting for input from the cassette player.
  3. Use the Cassette Recorder to open the program tape file and press the Play button. You should see the program being loaded.
  4. Machine code tapes normally have trigger commands embedded at the end to automatically run the program that was loaded.

Often machine code is loaded in two or more phases, where the first phase loads a more sophisticated checksum loader that then loads the remaining code.


Hello World

Source Code samples/basic/hello1.basic
Load asBASIC

This is a very simple "hello world" BASIC program. This program is used in the quick start guide.


Character Set

Source Code samples/basic/charset.basic
Load asBASIC

This is the program from page 38 of the manual which can be used to display most of the character set of the machine. It is not quite the same as the listing in the manual, as that listing actually contains a couple of bugs and also needed some changes to work correctly with the New Monitor.


New York Taxi

Sample Tape
Source Code samples/basic/nytaxi.basic
Load asBASIC

This is a game that was provided on a sample tape that came with the original machine. You should set the keyboard to game mode to play the game.

Hectic

Sample Tape
Source Code samples/basic/hectic.basic
Load asBASIC

This is a game that was provided on a sample tape that came with the original machine. You should set the keyboard to game mode to play the game.

Black Box

Source Code samples/basic/blackbox.basic
Load asBASIC

This is game kindly sent to me by Chic McGregor. It was first published in the July 1980 issue of Personal Computer World and is provided here exactly as originally published. When you run the game it can provide some instructions on how to use it.

Black Box

There's an interesting history to this particular program as it was almost certainly the first user written BASIC program for the UK101. How can we know this? Chic tells me that the very first shipment of UK101 machines were sent out without any BASIC ROMs because the ROMs were not ready due to some issues in the factory in Scotland that was producing them. As it happened Chic (who bought one of those very first machines) was also a young engineer working in that very factory - so not surprisingly managed to get hold of a set of ROMs ahead of anyone else.


Le Passe-Temps

Passe-Temp Tape
Source Code samples/basic/passetemp.basic
Load asBASIC

This game was published in Practical Electronics in July 1980, athough the copy here is a slightly later version that I bought on cassette. It is a version of the Connect Four game.

The program should give some instructions on how to use it. You should set the keyboard to game mode to play the game.


Labyrinth

Source Code samples/basic/labyrinth.basic
Load asBASIC

This is a version of the ubiquitous "first-person 3D maze" type of game, popular in the early 1980's - this one was written by me in about 1982, I think.

Labyrinth

It was written for my modified UK101 and requires a 32-line display and the CEGMON monitor installed; it also works better with a faster CPU. So ensure the following configuration options are specified when starting the simulator:

-p rom.monitor=CEGMON,video.rows=32,cpu.speed=4

When the program starts it will display some instructions on how to play the game. In addition to the keys listed in the instructions you can also press the G key to display the current maze and your position and trail within it.


Real-Time Star Trek

Source Code samples/basic/startrek.basic
Load asBASIC

This game was written by Martin Ward and is an impressive achievement squeezing just about everything it can into the 8K BASIC memory space!

This game must be run on a 32-line display and requires a patched version of the standard monitor ROM that fully supports 32 lines. A suitable monitor called NEWMON32.ROM can be found in the samples/roms directory. Ensure the following configuration options are specified when starting the simulator:

-p rom.monitor=samples/roms/NEWMON32.ROM,video.rows=32

It's probably best to run the game with a standard 1MHz CPU speed to start with until you get the hang of the controls. Then maybe switch to 2MHz (or more) for a greater challenge!

Real-Time Star Trek Instructions

Real Time Star Trek is, in the modern jargon, a procedurally generated, open world, RTS (real time strategy) game with destructable environments.

The object of the game is to destroy all the Klingons before the time runs out: when they will perfect their secret weapon and take over the galaxy.

Star Trek

To execute a function: hold down the function key (a letter) plus an optional direction key (a digit). For example, to move down, firing your phasers and recharging shields all at the same time, hold down: "I", "5", "P", and "S".

Hold down the key(s) and wait for the function to take effect. Press the function before pressing the direction.

The numbers around the E show the directions: 1 for straight up etc.

You can operate several functions at the same time, by holding down more than one key at a time.

Functions are:

I + dir Impulse Drive: move around within the current sector
W + dir Warp drive: move to an adjacent sector
T + dir Fire a photon torpedo in the given direction. If a torpedo hits a star, it will create a large explosion which may destroy nearby Klingons (or you!)
S Recharge shield energy: hold down to charge your shields up to the maximum of 500 energy units. Energy is taken from your main energy store, which recharge (by the power plant) up to its maximum of 3000 units.
R Repair. You can repair damage at the cost of energy.
P Fire phasers. Phasers automatically lock on target and keep firing as long as you hold down the P key. Phaser effectiveness decreases with distance. The Klingons only have phasers, so their weapons do more damage the closer you are to them.
G Galaxy Scan: displays the map of the galaxy for as long as you hold down the G key.

The area on the left is the short range scan, showing the current sector:

EThe Enterprise (you!)
KKlingon
BStarbase
*Star

The bottom right is the long range scan, showing your sector and the eight surrounding sectors:

Tens digitnumber of Klingons in that sector
Units digitnumber of starbases in that sector
9edge of galaxy

To dock with a starbase, move next to it (using the impulse drive I+direction) and press Y. This will repair all damage, give you full energy, and 8 torpedoes, and reduce shields to zero. So hold down S afterwards to charge up your shields again.


Extended Monitor

Sample Tape
Program Tape samples/tapes/exmon.tape
Load asMachine code

This is the Extended Monitor that was provided on a sample tape that came with the original machine. The extended monitor provided some extra function to help with writing and debugging simple machine code programs.

Details of the extended monitor can be found on its instruction sheet.

When the program loads it will first load a short checksum loader program then automatically load the rest of the code in checksum format.


Space Invaders

Invaders Tape
Program Tape samples/tapes/invaders.tape
Load asMachine code

This is a copy of Premier Publication's excellent Invaders space invaders game.

Invaders

The game was intended to be played on a standard 1Mhz processor, if you have over-clocked the processor (see system configuration) it may run too fast. Some old notes I have suggest that location $0F69 defines the game speed with the default value being 20 - on a 2MHz machine this might be best changed to 40, it says.

To move the laser the CTRL is used to go left and the left-SHIFT key is used to go right. On a real UK101 the CTRL-key is above the SHIFT-key so CTRL-for-left and SHIFT-for-right makes sense. Unfortunately these keys are the other way up on a PC keyboard so this is not ideal! I once knew some locations to patch to change these keys, but I can no longer find those notes - sorry! You should set the keyboard to game mode to play the game. Once the game is loaded you can reset the machine and perform a warm start to restart it at any time.


8K Super Invaders

Super Invaders Tape
Program Tape samples/tapes/superinvaders.tape
Load asBASIC

This is a copy of Craig Clapp's excellent 8K Super Invaders space invaders game, which shows just how much could be done with the limited character set graphics.

Super Invaders

This games is a mix of machine code and BASIC, but it is loaded as if it were a BASIC program and automatically handles loading both the machine code and BASIC parts. If you do a warm start you can restart it just by typing RUN.

This game rather cleverly hooked into the ACIA timing signals to ensure it always ran at the correct speed, even if the CPU was over-clocked to 2MHz - my thanks to Craig for explaining to me how this worked so I could ensure the emulator handled it correctly! It would also produce some simple sound effects if you hooked up a speaker or earphone to the ACIA output - this is not implemented in the simulation yet but I hope to add it soon.

To move the laser the left-SHIFT key is used to go left and the Z key is used to go right. The right-SHIFT key is used to fire, but note there are some problems when trying to use both shift keys independently on Windows (something to do with the way Java reports the key events), so you should use an alternative to the right-SHIFT if you can. When the keyboard is set to game mode either the right-CTRL or the Windows-Menu key (both normally directly beneath the right-SHIFT) can be used as alternatives for the right-SHIFT key.


Asteroids

Asteroids Tape
Program Tape samples/tapes/asteroids.tape
Load asBASIC

This is a copy of Arcadia's Asteroids game, another really well done game given the limitations of the UK101's simple character set graphics.

Asteroids

Asteroids is actually a BASIC program with a large section of additional machine code which it loads automatically. Once that has loaded the game will start. If you do a warm start you can restart it just by typing RUN.

To rotate the laser press the left-SHIFT to rotate anti-clockwise or press the right-SHIFT to rotate clockwise. Press the SPACE bar to fire. The laser does seem to rotate rather fast - I'm not sure if it always did this or if it is related to the simulation! You should set the keyboard to game mode to play the game.


Binary, ASCII and Audio Tape Formats

When the UK101 wrote data to a cassette tape it was written as a series of bytes. Although most of the bytes that were written were standard ASCII characters, the tapes would include some control characters, some padding NUL (0x00) characters and possibly some bytes whose values were outside the range of the standard character set. If these tapes are saved as PC files, the resulting file is not guaranteed to be viewable on the PC and can probably not be successfully edited using standard PC editors without some data corruption.

To help overcome these problems the simulator allows tapes to be stored in one of three formats:

Binary
This the raw bytes format as would have been stored on a real cassette tape. If you recover a program or data from an old cassette tape it will be in binary format.

All the sample machine code programs are in binary format and have a file extension of .tape.

ASCII
This is a converted format that can be viewed and edited on the PC using any standard PC editor (for example Notepad on Windows) without any data loss or data corruption.

The conversion leaves any standard ASCII character unchanged, it detects line ends and stores them as standard PC style line ends and any other unrecognised byte is converted to an escaped form \nn where nn is a pair of hexadecimal digits.

All the sample BASIC programs are in ASCII format and have a file extension of .basic.

Audio
This is the original Kansas City Standard encoded audio format which is stored in the form of a WAV file. The audio encoding parameters can be controlled by properties in the system configuraton.

The simulator will correctly recognise and load tapes any of the three formats and can save in any selected format. If you are saving a BASIC program it would make sense to save in ASCII format (which is the default) as the resulting program can then be easily viewed and edited on the PC. If you are saving a tape to potentially load back onto a real UK101 you will need to ensure it is in binary or maybe audio format. The utility programs Tape Reader and Tape Writer can be used to quickly convert between the various formats.

When an audio file is produced the waveform created can either be an approximation to the output generated by the real hardware (which is the default) or pure sine waves (which is probably what the Kansas City standard specified).

System Waveform Sine Waveform
System WaveformSine Waveform

Recovering Programs from Old Cassette Tapes

If you have original UK101 programs on old cassette tapes it is usually possible to recover them on a PC so they can be loaded and used with the simulator, provided the tapes are still playable and provided you still have something to play them with. The first steps are to record the cassette as an audio WAV file on the PC:

  1. Attach a cassette tape player to the sound card in your PC. I used an old (but good quality) Sony Walkman and plugged the headphone output into the line-input on the PC (it's best not to use the microphone input) and set the volume to about 7.
  2. Play the tape and record the sound to a WAV file, setting to Mono (rather than Stereo) if you can and sampling at a high rate such as 44.1kHz or 48kHz. I used Audacity to do the recording and exporting as a WAV, remembering to trim off any unwanted blanks and noise at the beginning and end of the recording. Make sure you save as an uncompressed WAV file, not an MP3.

If the recording is good quality and the original tape was in reasonably good condtion it should be possible to load the resulting WAV file directly into the simulator by playing it with the cassette player.

If the recording is poor quality or the original tape was in poor condition (which is quite likely) further processing might be needed to recover the data. This is done using an excellent piece of software written by Martin Ward that can examine and process the WAV file in great detail to recover the original data bytes. The process is something like this:

  1. Download and install Martin Ward's kansas city tape decoder. This is a perl script, so might require a few pre-requisites to be gathered from elsewhere if you are a Windows user (like me).
  2. Run the perl script to process the WAV file and create the decoded tape. This might take a little while if the original tape was fairly long. Hopefully the data will be analysed, processed and extracted correctly - Martin's program did a fine job for all the tapes I have found and tried.
  3. The resulting file will be what I called binary format (even though it may have a .txt extension). This can be loaded directly into the simulator as either a BASIC program or as machine code in the monitor or you can use the Tape Reader utility to convert the binary form to ASCII for easy viewing or editing on the PC.

Tim Baldwin
May 2015
tjb101@tinymail.co.uk
Return to index

© Tim Baldwin 2010,2015