2 !!DESCRIPTION!! mandelbrot test program
4 !!LICENCE!! Public Domain
5 !!AUTHOR!! Groepaz/Hitmen
11 static unsigned short SCREEN_X;
12 static unsigned char SCREEN_Y;
16 #define maxiterations 16
20 #define tofp(_x) ((_x)<<fpshift)
21 #define fromfp(_x) ((_x)>>fpshift)
22 #define fpabs(_x) (abs(_x))
24 #define mulfp(_a,_b) ((((signed long)_a)*(_b))>>fpshift)
25 #define divfp(_a,_b) ((((signed long)_a)<<fpshift)/(_b))
27 unsigned char dither[MAXCOL]={" .*o+0%#"};
29 void mandelbrot(signed short x1,signed short y1,signed short x2,signed short y2)
31 register signed short r,r1,i;
32 register unsigned char count;
33 register signed short xs,ys,xx,yy;
34 register signed short x;
35 register unsigned char y;
38 xs=((x2-x1)/(SCREEN_X));
39 ys=((y2-y1)/(SCREEN_Y));
42 for(y = 0; y < (SCREEN_Y); ++y)
45 for(x = 0; x < (SCREEN_X); ++x)
50 for(count=0;(count<maxiterations)&&
55 r1 = (mulfp(r,r)-mulfp(i,i))+xx;
56 /* i = (mulfp(mulfp(r,i),tofp(2)))+yy; */
57 i = (((signed long)r*i)>>(fpshift-1))+yy;
60 if(count==maxiterations)
66 printf("%c",dither[(count%MAXCOL)]);
78 /* calc mandelbrot set */
79 mandelbrot(tofp(-2),tofp(-2),tofp(2),tofp(2));