Page 1 of 1

Mandelbrot implementation for the Apple II?

Posted: Sun Jun 27, 2021 8:58 am
by 65f02
I thought I'd try a fractal plotting program as a demo for the 100 MHz 65F02 in my Apple II. A reasonably efficient implementation (fixed point? assembly core routines?) would be great as a starting point.

Bob Bishop's article in Call A.P.P.L.E. seems to have just what I am looking for (https://web.archive.org/web/20120307183 ... index.html). Is anyone aware of a machine-readable version of Bob's code, either as a "modern" text file or maybe as an Apple II disk image? I am ready to type in the code from the article if I have to -- vintage style ;-) -- but would not mind a shortcut.

Thanks!
Juergen

Re: Mandelbrot implementation for the Apple II?

Posted: Sun Jun 27, 2021 12:11 pm
by drogon
Not able to help with the machine code version, sorry, but some time back I did a simple BASIC one that I could use to check different BASICs - EhBASIC, CBM BASIC2 and BBC Basic. I think it might run on an Apple II under Applesoft unchanged, although the output would need an 80 column card to look good.

The output it produces is:

https://unicorn.drogon.net/mandel.txt

and that number; 48.21 is seconds that it took on my Ruby system running BBC Basic at 16Mhz. (A BBC Micro normally runs at 2Mhz). The run for EhBASIC and CBM Basic on the same hardware at 16Mhz is nearly double that at 78 seconds.

The source code is here:

https://unicorn.drogon.net/mandel.bas

So hoping it might run in about 12 seconds or so on your 100Mhz system which would be nice to see. (although IIRC Applesoft uses 5 byte FP while EhBASIC uses 4-byte, so possible a shade slower)

-Gordon

Re: Mandelbrot implementation for the Apple II?

Posted: Mon Jun 28, 2021 12:31 am
by dclxvi
This post discusses an adaptation of Bishop's routines for the 65C816. Everything's in assembly, and there are some optimizations, though it's not a big deal if X0, DX, DY, and YY are calculated once at the beginning in BASIC.

viewtopic.php?f=2&t=2243

Code and documentation can be found here:

http://biged.github.io/6502-website-arc ... mandel.htm

Re: Mandelbrot implementation for the Apple II?

Posted: Mon Jun 28, 2021 6:10 am
by BigEd
Oh, I'm glad I didn't dive in to say I couldn't find a trace of Bishop's code! Thanks Bruce.

(I did feed the posted link into the Wayback Machine to get a free OCR, but as is often the case, the OCR failed pretty miserably on the code sections. There might be a way to pre-process the images to get a better result.)

For a couple of different approaches, search for David Given's Bogomandel. The crux of Mandelbrot is the squaring of a complex value - table-driven multiplication can be very fast, but there are many ways to tackle the problem. Two things worth noting, one is that Mandelbrot, despite appearances, is very much a fixed-point application and not a floating-point one. The other is that squaring is inherently a bit simpler and can be made a bit faster than multiplication. But the linked thread and article go into this.

Re: Mandelbrot implementation for the Apple II?

Posted: Mon Jun 28, 2021 6:32 am
by rudla.kudla
A friend of mine recently programmed nice Mandelbrot fractal generator in assembler for Atari 8bit.
You can download it for testing here:

http://flop.atariportal.cz/frames.htm

The software name is FRACTARI.COM. There is an english manual too.

I may be able to get you source codes for this.

Re: Mandelbrot implementation for the Apple II?

Posted: Mon Jun 28, 2021 6:40 am
by BigEd
(Source code would always be very welcome!)

Re: Mandelbrot implementation for the Apple II?

Posted: Mon Jun 28, 2021 8:51 am
by 65f02
Thank you all! Those are some great leads.

I just realized that I will need to take a slight detour, unfortunately: They keyboard of my old Apple II has began to really act up. This seems to be beyond the level of flaky key contacts (of which it has a few), but rather encoder-related -- various keys stop and restart working over the course of minutes or hours. So some hardware debugging is in order before any meaningful typing can happen...