gfxbrot.c and gfxjulia.c

Using, learning, programming and modding the Gigatron and anything related.
Forum rules
Be nice. No drama.
veekoo
Posts: 121
Joined: 07 Jun 2021, 07:07

Re: gfxbrot.c and gfxjulia.c

Post by veekoo »

I am working with mandelbrot and julia drawing with random dots, but not same dot many times.
Attached files work with 64k and ROM v5a.
Biggest problem of this is still it uses floating point calculation.
Maybe one day I make integer math fractals...
Screenshot from 2022-10-14 16-54-25.png
Screenshot from 2022-10-14 16-54-25.png (171.03 KiB) Viewed 3531 times
Last edited by veekoo on 22 Nov 2023, 14:23, edited 3 times in total.
veekoo
Posts: 121
Joined: 07 Jun 2021, 07:07

Re: gfxbrot.c and gfxjulia.c

Post by veekoo »

Maybe someone who knows integer fractals can adapt my code.
Codes can be found at github:
Last edited by veekoo on 22 Nov 2023, 14:06, edited 1 time in total.
lb3361
Posts: 360
Joined: 17 Feb 2021, 23:07

Re: gfxbrot.c and gfxjulia.c

Post by lb3361 »

veekoo wrote: 31 Jan 2022, 12:23 Maybe one day I make integer math fractals...
I do not have time to do it but the attached code might help you.

This code represents fractional numbers -16<x<16 as the integer 256*x. One can add or subtract such number using the normal integer addition or subtraction. A small vcpu routine, mul48, multiplies two such numbers. It only works when both its arguments and its result are strictly between -16 and +16, otherwise it silently returns erroneous results. This is just enough to implement Mandelbrot at the normal scale.
Attachments
fix48.zip
(2.25 KiB) Downloaded 119 times
veekoo
Posts: 121
Joined: 07 Jun 2021, 07:07

Re: gfxbrot.c and gfxjulia.c

Post by veekoo »

One guy from github had done good job documenting and given sources for integer fractals. I can give the link in privatemsg.
Last edited by veekoo on 22 Nov 2023, 14:03, edited 5 times in total.
veekoo
Posts: 121
Joined: 07 Jun 2021, 07:07

Re: gfxbrot.c and gfxjulia.c

Post by veekoo »

Example picture of this code using long data type. Getting fast calculation might not happen with this code.

"Types short and int are 16 bits long. Type long is 32 bits long. Types float and double are 40 bits long, using the Microsoft Basic floating point format. Both long arithmetic or floating point arithmetic incur a significant speed penalty."
Attachments
longbrot.png
longbrot.png (9.19 KiB) Viewed 3358 times
Last edited by veekoo on 18 Oct 2022, 05:03, edited 1 time in total.
lb3361
Posts: 360
Joined: 17 Feb 2021, 23:07

Re: gfxbrot.c and gfxjulia.c

Post by lb3361 »

I believe this reference on integer fractals was written with a substantially more powerful processor in mind.

As you know, the Gigatron does not have a hardware multiplier. Therefore a 32-bits multiplication must be computed with 32 32-bits additions and shifts. In addition the Gigatron hardware can only perform 8 bit operations. Since it does not provide access to the carry bit, one needs additional logic to determine whether there is a carry and to apply the carry as needed. For 16-bits additions and subtractions, this is implemented quite efficiently in native code. For 32-bits additions and subtractions, this must be done with vCPU instructions.

This means that it pays to make our fractional precision numbers fit inside a 16-bits integer. This is what is achieved by the fractional multiplication from my earlier post. Since it only uses 12 bits of the int variable, one needs only 12 loops in the multiplication routine, another little gain. Anyway this is close to what Marcel did in the original version of the Gigatron Mandelbrot program, and should have a comparable speed.

One can go faster thanks to qwertyface's quarter square multiplication trick. See https://forum.gigatron.io/viewtopic.php?p=2632#p2632 for details. Interestingly this can be achieved with just vCPU code, but only in a manner that is very specific to the Mandelbrot calculation.

PS. My latest version of the GLCC runtime has a 20% speedup on long additions and subtractions. But that only gives 10% on multiplications.
veekoo
Posts: 121
Joined: 07 Jun 2021, 07:07

Re: gfxbrot.c and gfxjulia.c

Post by veekoo »

I think for Gigatron community making another Mandelbrot in integer is not so important. A fast Julia might be intresting. Yes the example was for Amiga or PC. I noticed the update on GLCC and used it in here.

There is now long Mandelbrot and long Julia versions. Its integer math, but not 16-bit int.

These are faster than previous programs. Currently testing at fullscreen.

Gfx mandelbrot uses floating point and takes 2 hours 5 minutes to draw the screen. Long version takes 45 min.

Gfx julia uses floating point and takes 1 hour 50 minutes to draw the screen. Long version takes 35 min.
veekoo
Posts: 121
Joined: 07 Jun 2021, 07:07

Re: gfxbrot.c and gfxjulia.c

Post by veekoo »

In Mandelbrot family there is also Julia, but not many know Burning Ship. Very small modification to Mandelbrot program you get Burning Ship. In some illustrations you can actually see the ship.

Two pictures: 1. Burning Ship zoomed 2. Burning Ship original view
Attachments
burnship_zoomed.png
burnship_zoomed.png (8.25 KiB) Viewed 3324 times
Screenshot from 2022-10-18 02-25-08.png
Screenshot from 2022-10-18 02-25-08.png (8.24 KiB) Viewed 3344 times
lb3361
Posts: 360
Joined: 17 Feb 2021, 23:07

Re: gfxbrot.c and gfxjulia.c

Post by lb3361 »

veekoo wrote: 17 Oct 2022, 06:51 Gfx mandelbrot uses floating point and takes 2 hours 5 minutes to draw the screen. Long version takes 45 min.
Gfx julia uses floating point and takes 1 hour 50 minutes to draw the screen. Long version takes 35 min.
Not bad!
veekoo
Posts: 121
Joined: 07 Jun 2021, 07:07

Re: gfxbrot.c and gfxjulia.c

Post by veekoo »

I have gone to ROMv6 era. So here is all in one fractal programs.

Floating point math with graphics: fpfract2 (all in one)
Long integer math with graphics: longfract (all in one)
Integer math with graphics: intfract (all in one)

With these you can get faster or more accurate pictures. Floating point is most accurate and slowest. Long integer is medium speed and medium accurate. Integer is fastest but loses accuracy and picture size is limited.

Good "screen saver" is random dot fractals.
Floating point math with random dot: rndbrot and rndjulia (64K)
Attachments
intfract.gt1
(6.94 KiB) Downloaded 55 times
longfract.gt1
(8.53 KiB) Downloaded 59 times
fpfract2.gt1
(10.02 KiB) Downloaded 68 times
rndjulia.gt1
(3.79 KiB) Downloaded 59 times
rndbrot.gt1
(3.82 KiB) Downloaded 58 times
Post Reply