Retro Games The C64 "Maxi
Blast from the past: programming in BASIC with the C64
As a kid, I used to love programming in BASIC. I decided to try out a C64 knockoff to see if that’s still the case.
The Commodore 64 is a legend from the PC Stone Age – in other words, 40 years old. It still manages to fascinate me to this day. That’s not just because it’s linked to memories of my youth, but also because of the concept of the machine in general. Switching from a modern PC to an old, bulky box feels like driving a go-kart in the Tesla age. Not comfortable at all. But it does boast simple mechanics that you can get to grips with immediately. And a directness in its actions. None of it is at all useful, but it’s oodles of fun.
If you want to relive the C64, you have a number of options. The easiest is to use it directly in your web browser. Or by downloading the VICE emulator, which offers a few more features. I went a step further and bought the C64 Maxi. In theory, it’s also an emulator, but in casing that looks very much like the original. It also comes with a joystick. Purists are sure to prefer a real C64. For me, this replica does the job. And it can easily be connected to a screen via HDMI.
I never had a C64 myself, and it doesn’t occupy important real estate in my memories. Nonetheless, the device still sparks an element of nostalgia, as the C64 uses BASIC. That’s a programming language I learnt between the ages of 11 and 13 on a very peculiar device called a Basictutor.
I want to use the C64 to take me back in time and programme in BASIC again. It makes me wonder what will come of it and if I’ll get that same magic feeling as before. Then there’s the question of whether I’ll be just as over keen as in 1988. Back then, full of childish naivety and youthful delusions of grandeur, I programmed a flight simulator on a device that could only display 15 characters and no graphics.
It’s up and away before it’s even started
In fact, my motivation is almost too much to begin with. I can’t hold out for the C64 Maxi to be delivered. So instead, I start programming on my Mac. And not on a C64 emulator, which would have been smarter, but on the first BASIC interpreter I find on Google, which turns out to be a BBC Basic.
To be fair, programming is a lot easier than on the C64. Because with the BBC Basic, you get a few comforts of the modern programming environment, such as debugging with variable monitoring or automatic new line numbering. Here’s the problem, BASIC isn’t what it says on the tin. There are countless language variants. A programme that works with BBC BASIC won’t automatically be compatible with the C64.
My first idea is to create a programme that asks the user mental maths questions. In BBC BASIC, I get an initial working version surprisingly quickly.
Transferring to the C64 Maxi
A few days later, the C64 Maxi arrives. Now how do I move my programme over to this box? One of the advantages over the original C64 is that the C64 Maxi provides four USB ports. Consequently, I can use a USB stick to download and save data.
But it’s not as simple as it sounds. The reason being that the C64 Maxi can’t directly copy data onto or read it from the stick. That only works within a .d64 disc image file. However, I can’t access the image’s content from my Mac.
So, what’s the solution? I install the VICE emulator. It can enter text from the clipboard into the C64 terminal. And it also uses D64 images. So, I copy the text from BBC BASIC, put it in the emulator and save the programme as a D64 image. This then ends up on the USB stick, which the C64 Maxi reads. It’s a little awkward, but hey, it works.
When I say «it works», I just mean the data transfer. The programme itself doesn’t. My motivation takes a slight hit. But at the same time, even though it’s a hard nut to crack, I’m determined to do it.
Adapting to the C64 and other bits and bobs
First, I need to convert everything to lower case, otherwise the ASCII allocation won’t be right. On the C64, upper case characters become symbols. The other problem is that the C64 doesn’t recognise the ELSE statement. Confusingly, no error message is issued. It does something, just not what it’s supposed to.
The third problem is that it randomises numbers differently. The RND command does generate a random number in both BASIC dialects. But with the C64, the number is between 0 and 1, while in BBC, it’s an integer with an upper limit of the value given in brackets.
Alongside this, I optimise a whole load of other aspects. When I’m finally happy with my first programme, it’s increased to 139 lines. Making it totally confusing. That’s because BASIC hardly features any option to structure programming. Instead, it naturally errs towards spaghetti code.
However, the very fact that the programme is long and elaborate is what makes me proud of the result. Exactly as I was over 30 years ago. Creating your own home-made programme is, quite simply, very satisfying. I’m particularly proud of the way the difficulty level in the arithmetic problems automatically adjusts to how well you answer the questions.
Give it a go
You can download the zipped image here. Then extract it and pull it to the drag-and-drop area in the online emulator.
Here’s how the programme works:
- To start, you say how many arithmetic problems you want to answer.
- Then select the type of calculation.
- If you answer a lot of questions correctly, the problems will get more difficult. Likewise, they’ll get easier if you get it wrong.
- If you keep passing most of the questions with flying colours at the more difficult level, the «game» will finish sooner because you don’t need any more practice. 🥳
And that’s just scratching the surface. I’m sure I’ll think up more programmes. How about a text-based flight simulator?
My interest in IT and writing landed me in tech journalism early on (2000). I want to know how we can use technology without being used. Outside of the office, I’m a keen musician who makes up for lacking talent with excessive enthusiasm.