Mandelbrot Set
The World's Crunchiest Trippiest Oldschool 8-Bit Fractal



Programmed by Sean Kelly / Psych Software 2008
BGM arranged by Sean Kelly 2008

Original BGM track "Mandelbrot Set" by Jonathan Coulton
released under CC-NC (http://creativecommons.org/licenses/by-nc/3.0/)
and may be found at http://www.jonathancoulton.com

Please, due to the above, do NOT redistribute the accompanying ROM without this file!!

Controls

A - zoom in by 2x on screen center
B - zoom out by 2x on screen center
d-pad - move view by 1/4 screen
Select - decrease render depth (max 64) - faster, but poorer results
Start - increase render depth (min 1) - slower, but more areas displayed

The math is good in most of the <-1,1>/<-i,i> range, but will lose precision around the edges.  I haven't yet pushed the full limits of the ROM, but for the level of detail needed to see nice stuff by ~8x zoom (increase render depth by at least 16) means you'll probably be setting your emulator to Turbo and even then waiting a bit to get a full screen.  Dive at your own risk!

Based on the nature of the algorithm, the black regions actually take longest to render since they require going down to the full render depth.  You can cut render time at high depth settings by keeping as little black in your viewing window as possible.


About

	I started off thinking "Hey, Coulton's 'Code Monkey' would sound awesomely appropriate as a chiptune!"  Obviously something somewhere went terribly wrong, since within the week I had the NES displaying the Mandelbrot Set with no accompanying music.  By the end of a long weekend, I'd arranged and encoded Coulton's 'Mandelbrot Set' to go along with it.

	This was really a "because I could" sort of project.  The 100% 6502 Assembly source code is included as a gold star for resum purposes, and as a recent homebrew codebase for future NES developers.  I don't use any fancy scanline tricks, undocumented ops, or any crazy hardcore hackery.  Heck, I don't even use sprites, DMC, tinting, or many standard NES perks that I've used in the past.  The core of this demo is the set of 16-bit fixed-point complex math routines I wrote for the 8-bit CPU.  They're all individually wrapped and labeled for resale, which on an architecture like the NES makes them a bit slow, but much friendlier to use and read than inlined register-micromanaging alternatives.

	If you have your own copy of nesasm (and I've written some of the instructions that my copy has trouble with out in raw bytecode), feel free to recompile the ROM, inline the math, and see how much more juice you can squeeze out of it.  Also, just for fun, try replicating the "jsr pow2Cpx" in the mandelbrot subroutine for any power-of-two set in the Mandelbrot family.  The math should hold out at lower magnification long enough to get some result, I think...

Mandelbrot Set ROM/source  Sean Kelly 2008
Distributed under CC-NC (see top link)
