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...
gfxbrot.c and gfxjulia.c
Forum rules
Be nice. No drama.
Be nice. No drama.
Re: gfxbrot.c and gfxjulia.c
Last edited by veekoo on 22 Nov 2023, 14:23, edited 3 times in total.
Re: gfxbrot.c and gfxjulia.c
Maybe someone who knows integer fractals can adapt my code.
Codes can be found at github:
Codes can be found at github:
Last edited by veekoo on 22 Nov 2023, 14:06, edited 1 time in total.
Re: gfxbrot.c and gfxjulia.c
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 448 times
Re: gfxbrot.c and gfxjulia.c
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.
Re: gfxbrot.c and gfxjulia.c
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."
"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 (9.19 KiB) Viewed 4630 times
Last edited by veekoo on 18 Oct 2022, 05:03, edited 1 time in total.
Re: gfxbrot.c and gfxjulia.c
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 32bits multiplication must be computed with 32 32bits 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 16bits additions and subtractions, this is implemented quite efficiently in native code. For 32bits additions and subtractions, this must be done with vCPU instructions.
This means that it pays to make our fractional precision numbers fit inside a 16bits 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.
As you know, the Gigatron does not have a hardware multiplier. Therefore a 32bits multiplication must be computed with 32 32bits 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 16bits additions and subtractions, this is implemented quite efficiently in native code. For 32bits additions and subtractions, this must be done with vCPU instructions.
This means that it pays to make our fractional precision numbers fit inside a 16bits 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.
Re: gfxbrot.c and gfxjulia.c
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 16bit 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.
There is now long Mandelbrot and long Julia versions. Its integer math, but not 16bit 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.
Re: gfxbrot.c and gfxjulia.c
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
Two pictures: 1. Burning Ship zoomed 2. Burning Ship original view
 Attachments

 burnship_zoomed.png (8.25 KiB) Viewed 4596 times

 Screenshot from 20221018 022508.png (8.24 KiB) Viewed 4616 times
Re: gfxbrot.c and gfxjulia.c
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)
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 383 times

 longfract.gt1
 (8.53 KiB) Downloaded 375 times

 fpfract2.gt1
 (10.02 KiB) Downloaded 396 times

 rndjulia.gt1
 (3.79 KiB) Downloaded 390 times

 rndbrot.gt1
 (3.82 KiB) Downloaded 384 times