In Yet Another Side Project, I have been monkeying with Bob Bishop's Mandelbrot routines and have recoded them for the 65C816 with 16-bit accumulator/memory and index register. I also recoded the BASIC program in (16-bit) assembly, so it should be relatively straightforward to port it to the 65org16. MASK (which is $FF to clear high bytes) probably won't be necessary on the 65org16. In fact, the reason I changed the zero page save/restore routines to use a RAM buffer instead of the stack is because JSR pushes one 16-bit quantity on the 65C816, but two 16-bit quantities on on the 65org16 (I encountered this while porting eForth). I have also included the system-specific routines (e.g. I/O, plotting) I used on the Apple IIgs, for anyone who wishes to run it on a IIgs (or an emulator), but those routines can be simply discarded for the 65org16, of course. (Incidentally, there isn't any of Bob's original code left. I've gone into a bit more detail about the differences in the documentation.)
With 16-bit math, it took just under four minutes (on an Apple IIgs in fast (2.8 MHz) mode) to generate Figure 2 (the lo-res picture from Bob's article), as compared to seven and a half minutes for the original program (I measured it at 7 minutes 17 seconds, which matches Bob's seven and a half minutes from the article). (Actually, since measuring the new routines, I've since refactored the code a bit, but it's mostly things like input and parsing, which only happen at the very beginning and aren't inside loops, so it should still be somewhere near four minutes.)
Anyway, as the subject hints at, I have written some fixed-point routines to replace some of the floating point calculations from the original BASIC program. It's not much of a library so far (I only wrote the operations needed to replace BASIC program, so you get arithmetic, but no transcendental (e.g. trig) functions), but the fixed-point are completely independent of the rest of Mandelbrot program (and are grouped together in the source code, for easy cut-and-paste).
And since it's a Mandelbrot program here are a few pictures for your viewing pleasure/annoyance. First up is a recreation of Figure 2 from the article, using the new routines. I used this for testing and comparison since it doesn't take very long to run, compared to the other pictures from the article. An explanation of why this isn't exactly the same as the picture from the magazine is in the documentation, so I won't repeat that here.
Attachment:
figure2.png [ 3.54 KiB | Viewed 1949 times ]
Next up are two higher resolution pictures (each 200 x 150 pixels and more colors), which use the same X and Y coordinates and magnification as the lo-res picture. (The aspect ratio is 1.)
In this picture, the timeout value was 256 (the "distance" returned by MANDEL ranging from 0 to 256 was used as a color), and the 8-bit (per color) RGB values are:
Attachment:
figure2h.png [ 18.21 KiB | Viewed 1949 times ]
color 0: R = 0, G = 0, B = 0
color c+0*51+1: R = 255, G = 5*c, B = 0
color c+1*51+1: R = 255-5*c, G = 255, B = 0
color c+2*51+1: R = 0, G = 255, B = 5*c
color c+3*51+1: R = 0, G = 255-5*c, B = 255
color c+4*51+1: R = 5*c, G = 0, B = 255
color 256: R = 255, G = 0, B = 255
where c = 0 to 50
In this picture, the timeout value was 258 (the color is likewise from 0 to 258), and the 8-bit (per color) RGB values are:
Attachment:
figure2c.png [ 22.84 KiB | Viewed 1949 times ]
color 0: R = 0, G = 0, B = 0
color 3*c+1: R = 255, G = 0, B = 3*c
color 3*c+2: R = 3*c, G = 255, B = 0
color 3*c+3: R = 0, G = 3*c, B = 255
where c = 0 to 85
As usual, available here:
http://www.lowkey.comuf.com/