Mandelbrot in BASIC

A bit more nostalgia, this time BBCSDL and a slightly dodgy Mandelbrot generator:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34

MODE 0
ITERATIONS = 50
LIMIT = 50
DEF FN_mag(a,b) = SQR((a * a) + (b * b))
DEF FN_add_a(a,c) = a + c
DEF FN_add_b(b,d) = b +d
DEF FN_mult_a(a,b,c,d) = (a*c) - (b*d)
DEF FN_mult_b(a,b,c,d) = (a * d) + (b * c)

FOR a = -2 TO 2 STEP 0.01
FOR b = -2 TO 2 STEP 0.01
z_a = 0
z_b = 0
FOR iter = 0 TO ITERATIONS
orig_a = z_a
z_a = FN_mult_a(z_a, z_b, z_a, z_b)
z_b = FN_mult_b(orig_a, z_b, orig_a, z_b)
z_a = FN_add_a(z_a, a)
z_b = FN_add_b(z_b, b)
IF FN_mag(z_a, z_b)>LIMIT THEN EXIT FOR
NEXT
point_x = (a * 320) + 640
point_y = (b * 256) + 512
MOVE point_x, point_y
IF FN_mag(z_a,z_b)>LIMIT THEN
GCOL 0
ELSE
GCOL 1
ENDIF
DRAW point_x, point_y
NEXT
NEXT

And the output:

slightly grainy mandelbrot

simple 8-bit fun

Having simple 8-bit fun with the Agon Light

I got the Agon Light 2 from the pi hut.

It’s a little hard to find the right keyboard, you need one that supports PS/2 over a USB connection, after some experiment I found this one from amazon works: JUSTOP Extra Value Wired Desktop PC Computer Keyboard Slim UK Layout USB / PS2 Connectors.

So far I’ve run the classic BASIC program we all used to type in shops back in the 80s:

1
2
3
10 PRINT "HELLO WORLD"
20 GOTO 10
RUN

And flashed the firmware using the instructions at https://github.com/breakintoprogram/agon-docs/wiki/Updating-Firmware.

For me it did work on a m1 mac, but I needed the note here:

If you are using an Apple Mac with an M chipset and are having difficulties uploading to the Agon, try changing the upload speed from 921600 to 115200 - some users have reported that works.

It’s all good simple retro fun.