In my final article about Mandelbrot sets, I’m sharing the hybrid program built from the last two. After finishing the chunky graphics version, I envisioned a merged version. This split graphic version is a nice compromise to showcase the beauty of the fractal.
# Starting with some minor adjustments.
Being a modified version of the two previous programs, it wasn’t hard doing the conversation. Since I needed to again plot each point along the X axis, I reverted the loop counter to the original code from the assembly version. I also reverted the status counter back to what it was for the same reason.
As noted before, to speed things up the program mirrored the top and bottom halves. This made plotting much simpler since I was scaling along the axis. Calculating one value, I could display the pixel in each half of the image. This worked in my favor as I could keep those calculations intact. But I needed to adjust what and when I printed a pixel.
Mandelbrot Split Graphics, ZX81 screenshot, 2022 by Steven Reid
Because of that, I focused on the print routine. In the original program, I plotted the top, did some math, then plotted the bottom. Easy enough. For the chunky version, I had to divide the X value by two to get the correct position on screen. Because of the way I stored variables, I did that calculation twice. Good so far.
For the split version, I would plot the bottom as before by commenting out the divide by 2. I swapped in the old plot routine since I didn’t need the pen color. Now for the top, I didn’t need to print every pixel. To get around that, I used an
rrca (roll right carry A). This rolls the last bit into the carry which I could then test if set with with
Mandelbrot Split Graphics, Zoomed in, ZX81 screenshot, 2022 by Steven Reid
If the carry is set, I skip down to display the bottom pixel. If the bit isn’t set, I use same code as the chunky plot to display the top row and then fall through. Since the top and bottom meet in the middle, the routine works out to only display the bottom point in that row.
# In closing.
To my surprise, it was a pretty straight forward conversion to get the split version. I had lamented on the lack of optimization in the previous versions. But the fact that I hadn’t made writing this version easier.
Mandelbrot Split Graphics, Zoomed in again, ZX81 screenshot, 2022 by Steven Reid
I’m now all caught up on all the programs I worked on over the 2022 Holiday break. On the positive side, I now have a reason to dig back into my ZX81 programs. But I also still need to finish Gem Quest which is becoming a much longer project than I anticipated.