-
Notifications
You must be signed in to change notification settings - Fork 1
/
mandelfp.noc
executable file
·73 lines (67 loc) · 1.79 KB
/
mandelfp.noc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
//==============================================================================
// code below by Martin Wendt, all else part of gd32vf103inator
// except for minor additions to display.c/.h -> dp_imagefill565()
#include "mandelfp.h"
#include "snip1.h"
#include "myasm.h"
#define FIXSIZE 14
#define mul(a,b) ((((int)a)*(b))>>FIXSIZE)
#define fixpt(a) ((int)(((a)*(1<<FIXSIZE))))
#define SCREEN_WIDTH 160
#define SCREEN_HEIGHT 80
__attribute__((noinline))
void mandelfp()
{
//float xmin,ymin,xmax,ymax,xs,ys;
int x0,y0,p,q,xn;
int i,x,y,z;
const int maxiter = 300;
int xs,ys;
//all of this below could already
//perform in fixpt space!
int xmin=-20666;//-1.26136183;
int xmax=-20441;//-1.24763480;
int ymin= 6168;//0.37648215;
int ymax= 6337;//0.38676353;
int s=-1;
struct linebuf linebuf;
while (1)
{
s=s*-1;
for (z=0;z<200;z++)
{
xmin-=z*s;
xmax+=z*s;
ymin-=z*s;
ymax+=z*s;
int xs=(xmax-xmin)*16/SCREEN_WIDTH;
int ys=(ymax-ymin)*16/SCREEN_HEIGHT;
for (y=0;y<SCREEN_HEIGHT;y++) {
q= ymin+(y*ys)/16;
for (x=0;x<SCREEN_WIDTH;x++) {
p = xmin+(x*xs)/16;
xn=0;
x0=0;
y0=0;
i=0;
while ((mul(xn,xn)+mul(y0,y0))<(65536) && ++i<maxiter)
{
xn=mul((x0+y0),(x0-y0)) +p;
//xn=mul(myasm(x0,y0),(x0-y0)) +p;
//xn=myasm(x0,y0,p);
//xn+=+p;
y0=mul(32768,mul(x0,y0)) +q;
x0=xn;
}
if (i==maxiter) i=1;
{
//linebuf.buf[y*160+x]=i*111;
linebuf.buf[y*160*2+x*2]=i;
linebuf.buf[y*160*2+x*2+1]=i*2;
}
}
}
dp_imagefill565(linebuf.buf);
}
}
}