diff --git a/README.md b/README.md index 3207d25..5ccba5d 100644 --- a/README.md +++ b/README.md @@ -586,6 +586,12 @@ The C64 has a hires graphics mode with 320x200 pixels. Oscar provides a library Draws and clears lines with various patterns. +#### Draw lines "fractaltree.c" + +Draws a recursive fractal tree. + +![Fractal recursive tree](samples/hires/fractaltree.png) + #### Draw 3D wireframe "cube3d.c" Draws a rotating 3D wireframe cube using draw (OR) and clear (AND) operations. The 3D operations are performed using 12.4 bit fixpoint math. diff --git a/samples/hires/fractaltree.c b/samples/hires/fractaltree.c new file mode 100644 index 0000000..febfaf2 --- /dev/null +++ b/samples/hires/fractaltree.c @@ -0,0 +1,64 @@ +#include +#include +#include +#include +#include +#include + + +char * const Color = (char *)0xd000; +char * const Hires = (char *)0xe000; + +Bitmap Screen; +ClipRect Clip = {0, 0, 320, 200}; + +void init(void) +{ + mmap_trampoline(); + mmap_set(MMAP_RAM); + + memset(Color, 0x01, 1000); + memset(Hires, 0x00, 8000); + + mmap_set(MMAP_NO_ROM); + + vic_setmode(VICM_HIRES, Color, Hires); + + vic.color_border = VCOL_WHITE; + + bm_init(&Screen, Hires, 40, 25); +} + +void done(void) +{ + mmap_set(MMAP_ROM); + + getch(); + + vic_setmode(VICM_TEXT, (char *)0x0400, (char *)0x1000); +} + +void draw(float x, float y, float a, float s) +{ + if (s < 6.0) + return; + + float tx = x + cos(a) * s; + float ty = y + sin(a) * s; + + bm_line(&Screen, &Clip, x, y, tx, ty, 0xff, LINOP_SET); + + draw(tx, ty, a + 0.3, s * 0.9); + draw(tx, ty, a - 0.4, s * 0.8); +} + +int main(void) +{ + init(); + + draw(140, 199, PI * 1.5, 32); + + done(); + + return 0; +} diff --git a/samples/hires/fractaltree.png b/samples/hires/fractaltree.png new file mode 100644 index 0000000..5ce401b Binary files /dev/null and b/samples/hires/fractaltree.png differ diff --git a/samples/hires/func3d.c b/samples/hires/func3d.c index 605c385..7613594 100644 --- a/samples/hires/func3d.c +++ b/samples/hires/func3d.c @@ -8,6 +8,8 @@ #include #include +#pragma stacksize(1024) + #pragma region(main, 0x0a00, 0xc800, , , {code, data, bss, heap, stack} ) diff --git a/samples/hires/make.bat b/samples/hires/make.bat index 2742b41..f41a25a 100644 --- a/samples/hires/make.bat +++ b/samples/hires/make.bat @@ -4,3 +4,4 @@ call ..\..\bin\oscar64 lines.c -n call ..\..\bin\oscar64 polygon.c -n call ..\..\bin\oscar64 bitblit.c -n call ..\..\bin\oscar64 cube3d.c -n +call ..\..\bin\oscar64 fractaltree.c -n diff --git a/samples/memmap/allmem.c b/samples/memmap/allmem.c index 725730a..93e20eb 100644 --- a/samples/memmap/allmem.c +++ b/samples/memmap/allmem.c @@ -4,6 +4,8 @@ // make space until 0x1000 by for the stack +#pragma stacksize(0x0600) + #pragma region( stack, 0x0a00, 0x1000, , , {stack} ) // everything beyond will be code, data, bss and heap to the end