This page is a mirror of Tepples' nesdev forum mirror (URL TBD).
Last updated on Oct-18-2019 Download

Mandelbrot / Fractals in 6502?

Mandelbrot / Fractals in 6502?
by on (#26219)
Hi, folks. I'm a bit interested in making a program that'll calculate the Mandelbrot set, but I don't want to reinvent the wheel. Does anybody have any links to 6502/6510 ASM code for generating this fractal?

I've already done quite the search through Google and 6502.org and while there is plenty of theory and floating-point C code to be found, there are very few usable code examples for an 8-bit 6502.

Help!?
Re: Mandelbrot / Fractals in 6502?
by on (#26332)
ccovell wrote:
Hi, folks. I'm a bit interested in making a program that'll calculate the Mandelbrot set, but I don't want to reinvent the wheel. Does anybody have any links to 6502/6510 ASM code for generating this fractal?

I've already done quite the search through Google and 6502.org and while there is plenty of theory and floating-point C code to be found, there are very few usable code examples for an 8-bit 6502.

Help!?


Your best bet is to do a search for Commodore 64 programs that do this. Virtually everything that could be done with a 6502 processor was done on a C64 at some time or another by someone. The June 1988 issue of COMPUTE!'s Gazette had a type-in program called "Eight Thousand Dragons," which did Mandelbrot graphics. Sadly, source code was not included.

The Sep. 1985 issue of COMPUTE! Magazine has an article on "Apple Fractals," which would have been done on a 6502-based system. Again, there probably isn't source code, though the article may contain some useful information.

by on (#26346)
Thanks for the reply. Since nobody answered in good time, I bit the bullet and did some research, checking out examples in BASIC and C. After a bit of thinking and coding, I made up a nice working Mandelbrot generator in 6502 ASM. But sorry NES fans, my program is for the 7.16 Mhz PC-Engine, because the NES' CPU just isn't fast enough to render some nice fractals without my falling asleep... :-)

I'll update this post when I've finished up the PCE program, since somebody might be interested.

by on (#26497)
OK, an updated post. Double-post, yay!

I finished up my mandelbrot program on the PC-E, and called it Fractal Engine. You can check it out here:
http://www.disgruntleddesigner.com/chri ... ngine.html

Image

Image

by on (#26505)
Wow, that looks like a pretty good program considering what it does. Just a couple of questions:

In the second screenshot of the entire Mandelbrot set, how were the axes oriented? In FRACTINT I believe the X-axis (for real values) points to the right, thus causing the Mandelbrot to "point" to the left towards negative values.

And, do you think you'll ever try implementing Julia sets?

by on (#26507)
It would be nice to see that on the NES, even if you had to wait a whole night to see anything interesting! =)

by on (#26508)
I've used an Applesoft Basic fractal generator, and it took about an hour to run on an Apple ][ C+. I have no doubt an ASM based generator would be much faster on a NES.

by on (#26532)
doppelganger wrote:
Wow, that looks like a pretty good program considering what it does. Just a couple of questions:

In the second screenshot of the entire Mandelbrot set, how were the axes oriented? In FRACTINT I believe the X-axis (for real values) points to the right, thus causing the Mandelbrot to "point" to the left towards negative values.

And, do you think you'll ever try implementing Julia sets?


Yes, read the readme; it admits that the Mandelbrot is flipped horizontally just to make the inside iterations as simple and speedy as possible.

I was thinking about putting in Julias, but I never found an easy-to-understand explanation anywhere that said just HOW rendering a Julia set is different from a Mandelbrot set.

by on (#26533)
Wikipedia states that Julia sets are rendered with repeated applications of square roots.

by on (#26541)
Julia sets and Mandelbrot sets are calculated with the same recurrence relation

z[n+1] = z[n]^2 + c

For the Mandlebrot set, z[0] = 0 and c varies over the entire complex plane.

For Julia sets, a specific complex value c is selected, and z[0] varies over the entire complex plane.

by on (#26542)
The Mandelbrot and Julia sets use the same formula, but they use C differently.

The Mandelbrot set use the current complex number (where the pixel coordinates are) for the value of C on every iteration, thus it changes on every pixel.

Julia sets use one fixed complex number for the value of C on every iteration, thus it remains fixed. The fixed complex number is supposed to be assigned before rendering the Julia set.

Since Julia sets use a fixed point and the Mandelbrot set uses every point, it can be said that the Mandelbrot set is an index to every possible Julia set. I will even go so far as to say the Mandelbrot set *is* every Julia set mashed up together in one fractal universe.

by on (#26546)
doppelganger wrote:
Since Julia sets use a fixed point and the Mandelbrot set uses every point, it can be said that the Mandelbrot set is an index to every possible Julia set. I will even go so far as to say the Mandelbrot set *is* every Julia set mashed up together in one fractal universe.

You'd be correct. The Mandelbrot set was invented as a way to test conjectures about the set of Julia sets. Wikipedia states that "it is the subset of the complex plane consisting of those parameters c for which the Julia set of fc is connected."