Old Code

I recently purchased one of those ‘C64 mini‘ devices. It’s quite amazing and very slick in how I can use USB and HDMI with such an ancient piece of technology. As you can imagine, it’s running Linux and an emulator, and not real C64 hardware, although there is a group making an FPGA version of the 64 as well.

The little computer can also handle any floppy disk (converted to D64 format) that you can throw at it. In fact, I downloaded every copy of the old Compute’s Gazette disk and stuck them all on a tiny USB key. (I’d happily pay for them if they were for sale anywhere, but they have long been abandoned.) At first I had forgotten my own contribution to Compute’s Gazette. It’s been a long time, but I was sure they had published at least one program of mine. Well, after a little digging, it all came flooding back: February 1994 and January 1995 were the issues that had my submissions.

In February 1994 they published a program I wrote called ‘Statistics’. It was a BASIC program that calculated mean, median, range, minimum, maximum, variance and standard deviation of a set of numbers that the user entered. I wrote an accompanying article. By the time that Compute’s Gazette published my article and program they were no longer in print, but a disk-only magazine.

Doesn’t matter – I still got paid!

In January 1995 they published my second submission. The contract specified the name ‘Annuity Schedule’ which is why I took so long to find this one. They renamed it to ‘The Value of Money’ when they published. This program calculated the amortization of a loan or the future value of an investment at a fixed interest rate. This program was in the second last edition that they ever published. Just under the wire!

I earned a total of $400 USD for these two programs. Good cash in the early 90s to someone who was still in university.

So. What did this code look like? It’s something I wrote in 1993/94. It had to be awful, right? It’s 26 years old!

Surprisingly, for the time, and considering most everyone wrote spaghetti code BASIC on the 64, it wasn’t half bad. And the article was quite well written. Here’s a sample of the Statistics code:

700 rem sample variance
710 for g=1tod
720 tt=tt+(r(g)-av)^2
730 next g
740 var=(tt)/(d-1)
750 sd=var^.5
760 pv=tt/d
770 print"the sample variance is:";var
780 print"sample standard deviation is:";sd

Yep. Line numbers.

There are some things that could have been done better. Variable names is not one – they are by definition in BASIC on the 64 just two (meaningful) characters long. It would probably have been better to make a labeled routine instead of writing the code inline. And there’s not much protection against divide by zero errors or anything. But it does the job. Just don’t stress it too much!

Meanwhile, there’s talk of a full-size 64 with Linux and an emulator and USB and HDMI with a working original-style keyboard. I always feel a bit uneasy looking back instead of forward. But damn if it’s not going to be a cool little machine.

Leave a Reply

Your email address will not be published. Required fields are marked *