C64 adventures | download | source
I started with installing the ACME assembler and the VICE emulator for the Commodore 64. Spent some time getting familiar with the assembly language. It wasn't totally new, but not because of my childhood, I only used BASIC then. I learned a lot about the 65xx processors when I wrote a NES emulator a few years ago. That family was quite common in the 1980s, many Commodore machines and also the Apple ][ used that.
The biggest obstacle on the C64 is the lack of multiplication. It can add and subtract numbers, but not multiply (or divise). One has two options: either using the floating point routines that come with the C64 BASIC interpreter or implement them by hand. There are various sources with assembly snippets around, and after I realised that the floating point arithmetic is unbearably slow for my purposes I decided to switch to 16 bit fixed point arithmetic (with 8 bit for the fraction part) and pulled in some routines from https://codebase64.org/.
It didn't work of course... The output resembled the Mandelbrot set but was kind of well...
Now how do I debug this thing? I wrote a few assembly routines and tried the arithmetic on a few examples, but it looked all good. There are so many places to screw it up....
I could just call the regular
I found a few places where the multiplication returned bad results. Went through the code a couple of times, but it took me an hour until I found that my Mandelbrot drawer is using the same memory locations for its local variables as the multiplication routine for the helper tables...
I essentially overwrote things like 100 * 100 = 10000 with some garbage... (The reality is a bit more tricky as it's not directly storing 100* 1 00, but you get the idea.)
Anyway, once it was fixed, it really started to look like a Mandelbrot set.
Using my proven tactic, I went to reddit and asked around for help. A few hours later fellow reddit user u/pskipw created a few pictures for me. Here is one:
I have never heard about it, but the C64 had a portable version as well, called the SX-64. u/eventhorizonrocket shot this. It takes about 5 minutes to render:
A close up from u/conventionalmemories:
The colors are different because the SX-64 has different color settings after startup than the C64 and I didn't count with that.