Add fractal tree sample
This commit is contained in:
parent
8c19b1f148
commit
76f463daff
|
@ -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.
|
||||
|
||||

|
||||
|
||||
#### 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.
|
||||
|
|
|
@ -0,0 +1,64 @@
|
|||
#include <c64/memmap.h>
|
||||
#include <c64/vic.h>
|
||||
#include <gfx/bitmap.h>
|
||||
#include <math.h>
|
||||
#include <string.h>
|
||||
#include <conio.h>
|
||||
|
||||
|
||||
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;
|
||||
}
|
Binary file not shown.
After Width: | Height: | Size: 6.7 KiB |
|
@ -8,6 +8,8 @@
|
|||
#include <gfx/bitmap.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#pragma stacksize(1024)
|
||||
|
||||
#pragma region(main, 0x0a00, 0xc800, , , {code, data, bss, heap, stack} )
|
||||
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue