I’ve now managed to get a first, very rough version of I.L.Powell’s 1979 Triton Tiny BASIC ‘Star Trek’ game to work in Python on my Raspberry Pi. Most of my effort has been spent in understanding how the original game worked – not easy, even for someone who learned to program in BASIC at about the time the original article was published.
As I wrote in an earlier post, I wanted to try to remain reasonably faithful to the way the original game worked, even to the point of preserving the original data structures and codes. I have however made a few tweaks – the most noticeable being to slow parts of the program down to try to replicate that ‘authentic’ early home computer experience! I think I’ve achieved that part of what I set out to do.
As for my other aim of producing some reasonably elegant Python … well, not yet I haven’t! My code is a hack – and a fairly nasty one too. All this exercise has convinced me of is that 20 years or so after I cut my last piece of production code I absolutely need to go back to basics (if you’ll forgive the pun) if I’m ever going to become reasonably proficient in the language.
So I think I’ll spend a little time over the next few weeks working my way through the MIT OpenCourseWare in Object-Oriented programming in Python – it seems as good a resource to try as any.
Since my Raspberry Pi arrived a few weeks ago, I’ve been tinkering with it rather a lot. For example, I’m currently on my 3rd operating system build. I’ve already been through the Debian squeeze and wheezy beta, and last night I started using a version of the Raspbian port (derived from Debian, but complied to take advantage of the floating point processor on the Pi, meaning better performance for most things).
All this tinkering means that I haven’t got as far as I hoped with my attempt to learn a little more Python by creating a port of a Star Trek Tiny BASIC game, originally published by Computing Today (CT) in October 1979. Its been slow going – and not only because I’m busy with other things!
My first problem was trying to understand how the original software worked. It’s not easy – and an extract of the original listing from the magazine illustrates why.
The limitations of the Tiny BASIC language combined with the limited memory capacity of home computers in 1979 (8 kilobytes would have been a luxury for most people) mean that it’s a rather difficult program to decipher, even with the two pages of description CT published in addition to the listing.
In some ways I’d have been better off redesigning the game from scratch. However, I’m trying to aim for as an authentic reconstruction as I can manage, but one that is better structured and in Python. My quest for authenticity applies even down to using the same data structures for the galaxy and the 64 sectors it was divided into in the original game, making sure that I’m using the same encoding for stars, starbases and Klingons. The porting task would have been far simpler if I’d decided to abandon the original data structures and used something far more powerful in their place, but that would have felt like cheating.
Even so, I think I’m around halfway there. Here’s a screenshot of the Enterprise -O- moving through Klingon >!< infested space to prove it …
… and a small snippet of Python to show how a sector of the galaxy is decoded. (Hint – the value in the galaxy array for sector 17 shown above is 305).
I’ve been playing around with my Raspberry Pi for a couple of weeks now. “Playing” is definitely the right word!
So far, I’ve ‘built’ a case for it from a rather nasty grey plastic box I sourced from a local electrical retailer, figured out how to create SD cards so I can boot it into Linux (the beta of the Debian ‘Wheezy’ release being my current choice), got it working on my home network (and out onto the internet), installed a FORTRAN compiler and most excitingly of all, started to learn Python.
I think I’m going to like Python. It seems to have all the good bits from languages like C, Pascal, LISP, Perl and Java, with none of the bad bits such as pointer arithmetic, garbage collection and the like.
Anyway, here’s a screenshot of my very first working Python program (other than “hello world”, of course). It doesn’t do anything very clever I’m afraid, but it’s enabled me to get the hang of the basics of the language’s syntax and figure out how to use SPE, one of the many development environments that are available.
If the weather stays as lousy as it is at the moment this weekend, I’m going to attempt something a little more ambitious next. I have a Star Trek game from a 1979 issue of Computing Today, written in a dialect of BASIC, that I’m going to try to convert into a working (and hopefully reasonably elegant) Python equivalent.
The lauch of the Raspberry Pi is beginning to look more and more like the early days of home computing – but this time, it’s not about the excitement of programming, it’s all about delays in delivery. Having been promised delivery by April 30th, it will now be with me “around the end of May”. Oh well. It’s not the end of the world I suppose!
However, at least I’ve managed to place an order with Farnell – which is more that RS Components have managed to offer me so far. In the meantime, I might just have to dig my Vic20 out of the attic to have a play with as well as playing with the UK101 sat by me in the study as I type this …
… is what Practical Electronics said about the launch of the Compukit UK101 back in August 1979.
While you’re reading their article, remember that it isn’t about the Raspberry Pi – instead, it’s about an 8MHz 6502, 4Kbyte computer with a UHF output to a black and white TV monitor and a 300 baud (very, very slow) cassette tape interface for backing up your programs and data.
Imagine being able to run a program to help your child (or yourself) revise for exams. Animated diagrams are possible, such as an internal combustion engine shown reciprocating, with mathematical equations to match. Picture an automobile program designed to accept daily input from you on petrol and oil use, along with mileage, etc. The machine could accumulate information, and at any time give you the average m.p.g., plot performance versus time or some other parameter, and remind you when to check the tyres and drive to the Garage for a service.
and rather more presciently:
For the first time, anyone, technical or otherwise, can have an affordable easily programmable home-computer for domestic use – a much neglected area at the moment, but one which is about to take off.
Yes. We have. But not for a long, long time and that’s why I’m looking forward to receiving mine, once production can keep up with demand. At £21.60 + VAT for a “model B”, you can’t really argue about value, even though you have to provide your own keyboard, monitor, SD cards and a case.
Eben [Upton, a Cambridge University lecturer] had noticed a distinct drop in the skills levels of the A Level students applying to read Computer Science in each academic year when he came to interview them. From a situation in the 1990s where most of the kids applying were coming to interview as hobbyist programmers, the landscape in the 2000s was very different; a typical applicant now had experience only with web design, and sometimes not even with that.
A number of problems were identified: the colonisation of the ICT curriculum with lessons on using Word and Excel, or writing webpages; the end of the dot-com boom; and the rise of the home PC and games console to replace the Amigas, BBC Micros, Spectrum ZX and Commodore 64 machines that people of an earlier generation learned to program on.
Single board computers were all the rage amongst hobbyists in the late 1970s / early 1980s. I have my own rare example, purchased from an internet auction site a few years ago when I was feeling nostalgic – a 1979 Compukit UK101.
The UK101 wasn’t the first single board machine (the Science of Cambridge MK14 and the Ohio Superboard II – of which the UK101 was a pretty close clone – predated it) and it wasn’t the last either. How I wish I’d invested a few pounds in a Sinclair ZX80 – good examples sell for hundreds these days!
Comparisons are odious – but that’s what I’m going to do anyway.
1979 Compukit UK101
2012 Raspberry Pi ‘B’
1MHz – stepped down from an 8MHz crystal
No dedicated processor, but 1Kbyte VDU RAM
Videocore 4 GPU
4Kbytes – expandable to 8Kbytes on board using 0.5 Kbyte 2114 RAM packages
256Mbytes – included in package with CPU and GPU. A “system on a chip”. No expansion capability
Machine code monitor and I/O utilities in ROM
Fedora Linux on SD card – other ARM11 compatible distributions should be possible
Microsoft BASIC (8K in ROM)
Python – but presumably any other language capable of running on Fedora Linux (Wikipedia is suggesting that an implementation of BBC BASIC is already available, along with C and Perl – I am sure there are other languages that will run too)
UHF to TV
RCA video and HDMI
240V AC mains transformer – 9V DC
Micro power 5V USB
Cassette interface (CUTS) – 300 baud (often modified to run at 600 baud), RS232 possible as an enhancement, as was an 8” floppy disk controller
USB 2.0 and Ethernet
Via HDMI or 3.5mm jack socket
PCB and kit of parts – assembly required
£219 + VAT from Compshop Ltd.
£21.60 + VAT from RS Components or Premier Farnell.
I really hope that the Raspberry Pi succeeds in its aim of reintroducing the fun of programming to novices. One potential mark of success would be the return of the “listings magazine” – which provided not only source code, but also useful articles on how to program and reviews of new hardware.
I get all misty-eyed when I think of the hours I spent typing in programs from the long gone “Computing Today” and learning how modify code written for a different BASIC dialect to work on either the Sharp MZ80K I had, or the RM 380Z and Commodore PETs the school acquired when I was in sixth form.
It’s unlikely that a listings magazine would work in print form today, but I look forward to seeing some novice-friendly web equivalents appear.
In the meantime, I’ve just rescued my UK101 from the attic. Now, where did I put my computing magazines?