gfxbrot.c and gfxjulia.c

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

gfxbrot.c and gfxjulia.c

Post by veekoo »

The idea of drawing fractals grew. First I wanted to do simple julia. Ended up doing it with ascii. Julia can't be done without mandelbrot, so it did ascbrot.c and then ascjulia.c. Now I was suggested to use graphics.
lb3361 wrote: 12 Sep 2021, 03:03 Now with graphics?

Code: Select all

#include <gigatron/console.h>

void drawPixel(int x, int y, int color)
{
    screenMemory[y][x] = color;
}
Note: the code above assumes the screen has not been scrolled -- default videoTable.
Otherwise you can include <gigatron/console.h> and call console_clear_screen(void) to reset it.
All I needed to do minor changes to asc-version to get gfx-version.
Last edited by veekoo on 22 Nov 2023, 14:05, edited 6 times in total.
lb3361
Posts: 376
Joined: 17 Feb 2021, 23:07

Re: gfxbrot.c and gfxjulia.c

Post by lb3361 »

Cool.

I am afraid floating point on the Gigatron is not very fast. This is why official 'Mandelbrot' program uses fixed point. But that makes it very hard to follow. Anyway, thanks for giving such a good test to my floating point runtime.
veekoo
Posts: 126
Joined: 07 Jun 2021, 07:07

Re: gfxbrot.c and gfxjulia.c

Post by veekoo »

Indeed slow stuff - gfxbrot - took 4,5 hours to calculate
Attachments
IMG_0921.jpg
IMG_0921.jpg (3.02 MiB) Viewed 10832 times
at67
Site Admin
Posts: 652
Joined: 14 May 2018, 08:29

Re: gfxbrot.c and gfxjulia.c

Post by at67 »

veekoo wrote: 12 Sep 2021, 14:15 Indeed slow stuff - gfxbrot - took 4,5 hours to calculate
Looks good, try changing modes, (use Mode 3), to get about a 250% speedup compared to mode 0.

P.S. Mandlebrot in gtBASIC ROMvX0 in mode 3 using fixed point and symmetry to cut calculations in half takes just over 60seconds.
FastMandlebrot.JPG
FastMandlebrot.JPG (326.87 KiB) Viewed 10829 times
veekoo
Posts: 126
Joined: 07 Jun 2021, 07:07

Re: gfxbrot.c and gfxjulia.c

Post by veekoo »

gfxjulia - took 3 hours to calculate

I always with these apps use fast mode during calculations and afterwards when viewing the screen I switch to slow mode.
I think using less colors and iterations this could be made faster plus in code there might be something to optimize. Maybe a grey scale version? What color numbers those might be?
Attachments
IMG_0923.JPG
IMG_0923.JPG (2.74 MiB) Viewed 10817 times
lb3361
Posts: 376
Joined: 17 Feb 2021, 23:07

Re: gfxbrot.c and gfxjulia.c

Post by lb3361 »

The graphics version has a much smaller gt1 because it doesn't need to link stdio or console support.
at67
Site Admin
Posts: 652
Joined: 14 May 2018, 08:29

Re: gfxbrot.c and gfxjulia.c

Post by at67 »

veekoo wrote: 12 Sep 2021, 17:16 I think using less colors and iterations this could be made faster plus in code there might be something to optimize. Maybe a grey scale version? What color numbers those might be?
Iterations will help with speed but will lose fidelity on the boundaries, (the interesting bits), I use 16 iterations and map those to a LUT filled with 16 interesting colours.

The Gigatron only has 2bits per colour component, (i.e. RGB), so that is a maximum of 4 grey scales, (including black and white). You could use dithering to sacrifice spatial resolution for colour/grey scale resolution and simulate more grey scales, but it would probably look much worse given how big the Gigatron's pixels already are, (only one way to find out though).
veekoo
Posts: 126
Joined: 07 Jun 2021, 07:07

Re: gfxbrot.c and gfxjulia.c

Post by veekoo »

This is current state of coding. Pictures added.
Attachments
gfxjulia.jpg
gfxjulia.jpg (35.54 KiB) Viewed 10692 times
gfxbrot.jpg
gfxbrot.jpg (39.55 KiB) Viewed 10692 times
veekoo
Posts: 126
Joined: 07 Jun 2021, 07:07

Re: gfxbrot.c and gfxjulia.c

Post by veekoo »

Latest sources and executables can be found at github:
Last edited by veekoo on 22 Nov 2023, 14:06, edited 1 time in total.
veekoo
Posts: 126
Joined: 07 Jun 2021, 07:07

Re: gfxbrot.c and gfxjulia.c

Post by veekoo »

Graphics fractal development has gone to solid version (ROMV4). Goal of code is to give full support for standard Gigatron TTL machine with stable rom. I hope many other coders publish some version of their programs for standard machine too. -x (extended) version has more iterations and colors thus longer cakculation time.
Attachments
gfxjuliax.jpg
gfxjuliax.jpg (64.3 KiB) Viewed 8123 times
gfxjulia.jpg
gfxjulia.jpg (44.7 KiB) Viewed 8123 times
gfxbrotx.jpg
gfxbrotx.jpg (49.92 KiB) Viewed 8123 times
gfxbrot.jpg
gfxbrot.jpg (48.19 KiB) Viewed 8123 times
gfxjuliax.gt1
(3.92 KiB) Downloaded 491 times
gfxjulia.gt1
(4.16 KiB) Downloaded 491 times
gfxbrotx.gt1
(3.97 KiB) Downloaded 509 times
gfxbrot.gt1
(4.15 KiB) Downloaded 488 times
Post Reply