Generating Mandelbrot sets with Atari BASIC
2 min read
views

Scott Williamson created a program to generate Mandelbrot sets on 8-bit Atari computers, with just ten lines of BASIC code!
"Mandelbrot Set Explorer" took second place in the "SCHAU" category (for demos, tools and non-recreational applications with a limit of 256 characters per line) of therecent NOMAM BASIC 10 Liner 2021 contest
This interactive project allows you to visualize twelve classic fractal locations with a multi-resolution renderer, title screens, sound, and nine selectable color cycle patterns, ranging from relaxing to psychedelic.
Given the obvious limitations of the Atari's 1.79MHz 6502 CPU, the program is set to perform 81 iterations - that is, 81 calculations for each pixel; otherwise, more cycles would start to take too long.
The user can zoom in and out to see the twists and turns. The colors in the images represent the number of times the Mandelbrot function repeats before diverging; the black areas are infinite iterations or are beyond the number of iterations the program is capable of performing.
"Instead of slowly filling the screen in a raster fashion (left to right, top to bottom), this program uses a multi-resolution progressive rendering technique. It starts by filling the 80-column screen with three evenly spaced rows, stretched vertically 64x to fill the entire 192-line screen. Then, successive passes fill twice as many rows (after the second pass), at half the height of the previous pass until the last pass fills every other row on the screen," explains Williamson.in the project blog
It is worth noting that Czech composer Adam J. Sporka generously offered to share his chiptunes music for use in the videos, which Williamson made on a real Atari 800.
How to load into the emulator
Configure your preferred emulator to use OS-B. Set the video system to NTSC - it can be PAL, but playback will probably be 1/6 slower. Enable Atari BASIC loading.Place the program image "Mandelbrot Set Explorer - 10 lines Atari BASIC.atr" in disk drive 1.
When the usual READY message appears, type:LOAD"D1:MANDELBR.BAS"
Next, type RUN and press the Enter key. A title screen will appear and the program will begin rendering the Mandelbrot set.
Controls
The program is used with the joystick or arrow keys in the emulator:Above: zoom in (enlarge the image to double its size).
Below: zoom out (reduce the image to half its size).
Right: Advances to the next of the 12 locations and resets the zoom to the default value.
Left: Returns to the previous location of 12 and resets the zoom to the default value.
Fire button: -or the right CTRL key in the emulator- returns from the title screen to the renderer.
Please comment politely. Spam comments will be moderated. Thank you.