home *** CD-ROM | disk | FTP | other *** search
/ Mega A/V / mega_av.zip / mega_av / GRAPHUTL / FRPOR172.ZIP / FRACTALS.C < prev    next >
C/C++ Source or Header  |  1992-02-19  |  81KB  |  2,909 lines

  1. /*
  2. FRACTALS.C, FRACTALP.C and CALCFRAC.C actually calculate the fractal
  3. images (well, SOMEBODY had to do it!).  The modules are set up so that
  4. all logic that is independent of any fractal-specific code is in
  5. CALCFRAC.C, the code that IS fractal-specific is in FRACTALS.C, and the
  6. struscture that ties (we hope!) everything together is in FRACTALP.C.
  7. Original author Tim Wegner, but just about ALL the authors have
  8. contributed SOME code to this routine at one time or another, or
  9. contributed to one of the many massive restructurings.
  10.  
  11. The Fractal-specific routines are divided into three categories:
  12.  
  13. 1. Routines that are called once-per-orbit to calculate the orbit
  14.    value. These have names like "XxxxFractal", and their function
  15.    pointers are stored in fractalspecific[fractype].orbitcalc. EVERY
  16.    new fractal type needs one of these. Return 0 to continue iterations,
  17.    1 if we're done. Results for integer fractals are left in 'lnew.x' and
  18.    'lnew.y', for floating point fractals in 'new.x' and 'new.y'.
  19.  
  20. 2. Routines that are called once per pixel to set various variables
  21.    prior to the orbit calculation. These have names like xxx_per_pixel
  22.    and are fairly generic - chances are one is right for your new type.
  23.    They are stored in fractalspecific[fractype].per_pixel.
  24.  
  25. 3. Routines that are called once per screen to set various variables.
  26.    These have names like XxxxSetup, and are stored in
  27.    fractalspecific[fractype].per_image.
  28.  
  29. 4. The main fractal routine. Usually this will be StandardFractal(),
  30.    but if you have written a stand-alone fractal routine independent
  31.    of the StandardFractal mechanisms, your routine name goes here,
  32.    stored in fractalspecific[fractype].calctype.per_image.
  33.  
  34. Adding a new fractal type should be simply a matter of adding an item
  35. to the 'fractalspecific' structure, writing (or re-using one of the existing)
  36. an appropriate setup, per_image, per_pixel, and orbit routines.
  37.  
  38. --------------------------------------------------------------------   */
  39.  
  40.  
  41. #include <stdio.h>
  42. #include <stdlib.h>
  43. #include <float.h>
  44. #include <limits.h>
  45. #include <string.h>
  46. #ifdef __TURBOC__
  47. #include <alloc.h>
  48. #else
  49. #include <malloc.h>
  50. #endif
  51. #include "fractint.h"
  52. #include "mpmath.h"
  53. #include "helpdefs.h"
  54. #include "fractype.h"
  55.  
  56. #define NEWTONDEGREELIMIT  100
  57.  
  58. extern struct complex  initorbit;
  59. extern struct lcomplex linitorbit;
  60. extern char useinitorbit;
  61. extern double fgLimit;
  62. extern int distest;
  63.  
  64. extern void (*ltrig0)();
  65. extern void (*ltrig1)();
  66. extern void (*ltrig2)();
  67. extern void (*ltrig3)();
  68. extern void (*dtrig0)();
  69. extern void (*dtrig1)();
  70. extern void (*dtrig2)();
  71. extern void (*dtrig3)();
  72.  
  73. /* -------------------------------------------------------------------- */
  74. /*   The following #defines allow the complex transcendental functions    */
  75. /*   in parser.c to be used here thus avoiding duplicated code.     */
  76. /* -------------------------------------------------------------------- */
  77.  
  78. #define CMPLXmod(z)      (sqr((z).x)+sqr((z).y))
  79. #define CMPLXconj(z)    ((z).y =  -((z).y))
  80. #define LCMPLXmod(z)       (lsqr((z).x)+lsqr((z).y))
  81. #define LCMPLXconj(z)    ((z).y =  -((z).y))
  82.  
  83.  
  84. #define LCMPLXtrig0(arg,out) Arg1->l = (arg); ltrig0(); (out)=Arg1->l
  85. #define LCMPLXtrig1(arg,out) Arg1->l = (arg); ltrig1(); (out)=Arg1->l
  86. #define LCMPLXtrig2(arg,out) Arg1->l = (arg); ltrig2(); (out)=Arg1->l
  87. #define LCMPLXtrig3(arg,out) Arg1->l = (arg); ltrig3(); (out)=Arg1->l
  88.  
  89. #define  CMPLXtrig0(arg,out) Arg1->d = (arg); dtrig0(); (out)=Arg1->d
  90. #define  CMPLXtrig1(arg,out) Arg1->d = (arg); dtrig1(); (out)=Arg1->d
  91. #define  CMPLXtrig2(arg,out) Arg1->d = (arg); dtrig2(); (out)=Arg1->d
  92. #define  CMPLXtrig3(arg,out) Arg1->d = (arg); dtrig3(); (out)=Arg1->d
  93.  
  94.  
  95. #define LCMPLXsin(arg,out)   Arg1->l = (arg); lStkSin();  (out) = Arg1->l
  96. #define LCMPLXcos(arg,out)   Arg1->l = (arg); lStkCos();  (out) = Arg1->l
  97. #define LCMPLXsinh(arg,out)  Arg1->l = (arg); lStkSinh(); (out) = Arg1->l
  98. #define LCMPLXcosh(arg,out)  Arg1->l = (arg); lStkCosh(); (out) = Arg1->l
  99. #define LCMPLXlog(arg,out)   Arg1->l = (arg); lStkLog();  (out) = Arg1->l
  100. #define LCMPLXexp(arg,out)   Arg1->l = (arg); lStkExp();  (out) = Arg1->l
  101. /*
  102. #define LCMPLXsqr(arg,out)   Arg1->l = (arg); lStkSqr();  (out) = Arg1->l
  103. */
  104. #define LCMPLXsqr(arg,out)   \
  105.    (out).x = lsqr((arg).x) - lsqr((arg).y);\
  106.    (out).y = multiply((arg).x, (arg).y, bitshiftless1)
  107. #define LCMPLXsqr_old(out)     \
  108.    (out).y = multiply(lold.x, lold.y, bitshiftless1);\
  109.    (out).x = ltempsqrx - ltempsqry\
  110.  
  111. #define LCMPLXpwr(arg1,arg2,out)    Arg2->l = (arg1); Arg1->l = (arg2);\
  112.      lStkPwr(); Arg1++; Arg2++; (out) = Arg2->l
  113. #define LCMPLXmult(arg1,arg2,out)    Arg2->l = (arg1); Arg1->l = (arg2);\
  114.      lStkMul(); Arg1++; Arg2++; (out) = Arg2->l
  115. #define LCMPLXadd(arg1,arg2,out)    \
  116.     (out).x = (arg1).x + (arg2).x; (out).y = (arg1).y + (arg2).y
  117. #define LCMPLXsub(arg1,arg2,out)    \
  118.     (out).x = (arg1).x - (arg2).x; (out).y = (arg1).y - (arg2).y
  119.  
  120. #define LCMPLXtimesreal(arg,real,out)    \
  121.     (out).x = multiply((arg).x,(real),bitshift);\
  122.     (out).y = multiply((arg).y,(real),bitshift)
  123.  
  124. #define LCMPLXrecip(arg,out)    \
  125. { long denom; denom = lsqr((arg).x) + lsqr((arg).y);\
  126. if(denom==0L) overflow=1; else {(out).x = divide((arg).x,denom,bitshift);\
  127. (out).y = -divide((arg).y,denom,bitshift);}}
  128.  
  129. #define CMPLXsin(arg,out)    Arg1->d = (arg); dStkSin();  (out) = Arg1->d
  130. #define CMPLXcos(arg,out)    Arg1->d = (arg); dStkCos();  (out) = Arg1->d
  131. #define CMPLXsinh(arg,out)   Arg1->d = (arg); dStkSinh(); (out) = Arg1->d
  132. #define CMPLXcosh(arg,out)   Arg1->d = (arg); dStkCosh(); (out) = Arg1->d
  133. #define CMPLXlog(arg,out)    Arg1->d = (arg); dStkLog();  (out) = Arg1->d
  134. #define CMPLXexp(arg,out)    FPUcplxexp(&(arg), &(out))
  135. /*
  136. #define CMPLXsqr(arg,out)    Arg1->d = (arg); dStkSqr();  (out) = Arg1->d
  137. */
  138. #define CMPLXsqr(arg,out)    \
  139.    (out).x = sqr((arg).x) - sqr((arg).y);\
  140.    (out).y = ((arg).x+(arg).x) * (arg).y
  141. #define CMPLXsqr_old(out)    \
  142.    (out).y = (old.x+old.x) * old.y;\
  143.    (out).x = tempsqrx - tempsqry
  144.  
  145. #define CMPLXpwr(arg1,arg2,out)   (out)= ComplexPower((arg1), (arg2))
  146. #define CMPLXmult1(arg1,arg2,out)    Arg2->d = (arg1); Arg1->d = (arg2);\
  147.      dStkMul(); Arg1++; Arg2++; (out) = Arg2->d
  148. #define CMPLXmult(arg1,arg2,out)  \
  149.     {\
  150.        CMPLX TmP;\
  151.        TmP.x = (arg1).x*(arg2).x - (arg1).y*(arg2).y;\
  152.        TmP.y = (arg1).x*(arg2).y + (arg1).y*(arg2).x;\
  153.        (out) = TmP;\
  154.      }
  155. #define CMPLXadd(arg1,arg2,out)    \
  156.     (out).x = (arg1).x + (arg2).x; (out).y = (arg1).y + (arg2).y
  157. #define CMPLXsub(arg1,arg2,out)    \
  158.     (out).x = (arg1).x - (arg2).x; (out).y = (arg1).y - (arg2).y
  159. #define CMPLXtimesreal(arg,real,out)   \
  160.     (out).x = (arg).x*(real);\
  161.     (out).y = (arg).y*(real)
  162.  
  163. #define CMPLXrecip(arg,out)    \
  164.    { double denom; denom = sqr((arg).x) + sqr((arg).y);\
  165.      if(denom==0.0) {(out).x = 1.0e10;(out).y = 1.0e10;}else\
  166.     { (out).x =  (arg).x/denom;\
  167.      (out).y = -(arg).y/denom;}}
  168.  
  169. extern int xshift, yshift;
  170. long Exp086(long);
  171. double fmod(double,double);
  172. extern int biomorph;
  173. extern int forcesymmetry;
  174. extern int symmetry;
  175. LCMPLX lcoefficient,lold,lnew,lparm, linit,ltmp,ltmp2,lparm2;
  176. long ltempsqrx,ltempsqry;
  177. extern int decomp[];
  178. extern double param[];
  179. extern int potflag;                   /* potential enabled? */
  180. extern double f_radius,f_xcenter,f_ycenter;    /* inversion radius, center */
  181. extern double xxmin,xxmax,yymin,yymax;           /* corners */
  182. extern int overflow;
  183. extern int integerfractal;    /* TRUE if fractal uses integer math */
  184.  
  185. int maxcolor;
  186. int root, degree,basin;
  187. double floatmin,floatmax;
  188. double roverd, d1overd, threshold;
  189. CMPLX tmp2;
  190. extern CMPLX init,tmp,old,new,saved,ComplexPower();
  191. CMPLX    staticroots[16]; /* roots array for degree 16 or less */
  192. CMPLX    *roots = staticroots;
  193. struct MPC    *MPCroots;
  194. extern int color, row, col;
  195. extern int invert;
  196. extern double far *dx0, far *dy0;
  197. extern double far *dx1, far *dy1;
  198. long FgHalf;
  199.  
  200. CMPLX one;
  201. CMPLX pwr;
  202. CMPLX Coefficient;
  203.  
  204. extern int    colors;             /* maximum colors available */
  205. extern int    inside;             /* "inside" color to use    */
  206. extern int    outside;            /* "outside" color to use   */
  207. extern int    finattract;
  208. extern int    fractype;            /* fractal type */
  209. extern int    debugflag;            /* for debugging purposes */
  210.  
  211. extern double    param[];        /* parameters */
  212. extern long    far *lx0, far *ly0;        /* X, Y points */
  213. extern long    far *lx1, far *ly1;        /* X, Y points */
  214. extern long    delx,dely;            /* X, Y increments */
  215. extern long    delmin;             /* min(max(dx),max(dy) */
  216. extern double    ddelmin;            /* min(max(dx),max(dy) */
  217. extern long    fudge;                /* fudge factor (2**n) */
  218. extern int    bitshift;            /* bit shift for fudge */
  219. int    bitshiftless1;            /* bit shift less 1 */
  220.  
  221. #ifndef sqr
  222. #define sqr(x) ((x)*(x))
  223. #endif
  224.  
  225. #ifndef lsqr
  226. #define lsqr(x) (multiply((x),(x),bitshift))
  227. #endif
  228.  
  229. #define modulus(z)     (sqr((z).x)+sqr((z).y))
  230. #define conjugate(pz)    ((pz)->y = 0.0 - (pz)->y)
  231. #define distance(z1,z2)  (sqr((z1).x-(z2).x)+sqr((z1).y-(z2).y))
  232. #define pMPsqr(z) (*pMPmul((z),(z)))
  233. #define MPdistance(z1,z2)  (*pMPadd(pMPsqr(*pMPsub((z1).x,(z2).x)),pMPsqr(*pMPsub((z1).y,(z2).y))))
  234.  
  235. double twopi = PI*2.0;
  236. static int c_exp;
  237.  
  238.  
  239. /* These are local but I don't want to pass them as parameters */
  240. CMPLX lambda;
  241. extern double magnitude, rqlim, rqlim2;
  242. CMPLX parm,parm2;
  243. CMPLX *floatparm;
  244. LCMPLX *longparm; /* used here and in jb.c */
  245. extern int (*calctype)();
  246. extern unsigned long lm;        /* magnitude limit (CALCMAND) */
  247.  
  248. /* -------------------------------------------------------------------- */
  249. /*        These variables are external for speed's sake only      */
  250. /* -------------------------------------------------------------------- */
  251.  
  252. double sinx,cosx,sinhx,coshx;
  253. double siny,cosy,sinhy,coshy;
  254. double tmpexp;
  255. double tempsqrx,tempsqry;
  256.  
  257. double foldxinitx,foldyinity,foldxinity,foldyinitx;
  258. long oldxinitx,oldyinity,oldxinity,oldyinitx;
  259. long longtmp;
  260. extern long lmagnitud, llimit, llimit2, l16triglim;
  261. extern periodicitycheck;
  262. extern char floatflag;
  263.  
  264. extern int StandardFractal();
  265. extern int NewtonFractal2(); /* Lee Crocker's Newton code */
  266.  
  267. /* these are in mpmath_c.c */
  268. extern int ComplexNewtonSetup(void);
  269. extern int ComplexNewton(void), ComplexBasin(void), MarksCplxMand(void);
  270. extern int MarksCplxMandperp(void);
  271.  
  272. /* these are in (I think) JB.C */
  273. extern int Std4dFractal(), JulibrotSetup(), jb_per_pixel();
  274.  
  275. extern int Lsystem();
  276. extern int lya_setup(void);
  277. extern int lyapunov(void);
  278.  
  279. /* temporary variables for trig use */
  280. long lcosx, lcoshx, lsinx, lsinhx;
  281. long lcosy, lcoshy, lsiny, lsinhy;
  282.  
  283. /*
  284. **  details of finite attractors (required for Magnet Fractals)
  285. **  (can also be used in "coloring in" the lakes of Julia types)
  286. */
  287. extern          int      attractors; /* number of finite attractors   */
  288. extern CMPLX  attr[];       /* finite attractor values (f.p) */
  289. extern LCMPLX lattr[];      /* finite attractor values (int) */
  290.  
  291. /*
  292. **  pre-calculated values for fractal types Magnet2M & Magnet2J
  293. */
  294. CMPLX    T_Cm1;          /* 3 * (floatparm - 1)            */
  295. CMPLX    T_Cm2;          /* 3 * (floatparm - 2)            */
  296. CMPLX    T_Cm1Cm2;     /* (floatparm - 1) * (floatparm - 2) */
  297.  
  298. void FloatPreCalcMagnet2() /* precalculation for Magnet2 (M & J) for speed */
  299.   {
  300.     T_Cm1.x = floatparm->x - 1.0;   T_Cm1.y = floatparm->y;
  301.     T_Cm2.x = floatparm->x - 2.0;   T_Cm2.y = floatparm->y;
  302.     T_Cm1Cm2.x = (T_Cm1.x * T_Cm2.x) - (T_Cm1.y * T_Cm2.y);
  303.     T_Cm1Cm2.y = (T_Cm1.x * T_Cm2.y) + (T_Cm1.y * T_Cm2.x);
  304.     T_Cm1.x += T_Cm1.x + T_Cm1.x;   T_Cm1.y += T_Cm1.y + T_Cm1.y;
  305.     T_Cm2.x += T_Cm2.x + T_Cm2.x;   T_Cm2.y += T_Cm2.y + T_Cm2.y;
  306.   }
  307.  
  308. /* -------------------------------------------------------------------- */
  309. /*        Stand-alone routines                                            */
  310. /* -------------------------------------------------------------------- */
  311.  
  312. extern int orbit2dfloat();
  313. extern int orbit2dlong();
  314. extern int kamtorusfloatorbit();
  315. extern int kamtoruslongorbit();
  316.  
  317. /* functions defined elswhere needed for fractalspecific */
  318. extern int hopalong2dfloatorbit();
  319. extern int martin2dfloatorbit();
  320. extern int orbit3dfloat();
  321. extern int orbit3dlong();
  322. extern int lorenz3dlongorbit();
  323. extern int orbit3dlongsetup();
  324. extern int lorenz3dfloatorbit();
  325. extern int lorenz3d1floatorbit();
  326. extern int lorenz3d3floatorbit();
  327. extern int lorenz3d4floatorbit();
  328. extern int orbit3dfloatsetup();
  329. extern int rosslerfloatorbit();
  330. extern int rosslerlongorbit();
  331. extern int henonfloatorbit();
  332. extern int henonlongorbit();
  333. extern int pickoverfloatorbit();
  334. extern int gingerbreadfloatorbit();
  335. extern int diffusion();
  336. extern int plasma();
  337. extern int test();
  338. extern int ifs();
  339. extern int Bifurcation(void);
  340. extern int BifurcVerhulst(void);
  341. extern int LongBifurcVerhulst(void);
  342. extern int BifurcLambda(void);
  343. extern int LongBifurcLambda(void);
  344. extern int BifurcAddSinPi(void);
  345. extern int LongBifurcAddSinPi(void);
  346. extern int BifurcSetSinPi(void);
  347. extern int LongBifurcSetSinPi(void);
  348. extern int BifurcStewart(void);
  349. extern int LongBifurcStewart(void);
  350. extern int popcorn(void);
  351.  
  352. /* -------------------------------------------------------------------- */
  353. /*        Bailout Routines Macros                                                 */
  354. /* -------------------------------------------------------------------- */
  355.  
  356. static int near floatbailout()
  357. {
  358.    if ( ( magnitude = ( tempsqrx=sqr(new.x) )
  359.             + ( tempsqry=sqr(new.y) ) ) >= rqlim ) return(1);
  360.    old = new;
  361.    return(0);
  362. }
  363.  
  364. /* longbailout() is equivalent to next */
  365. #define LONGBAILOUT()    \
  366.    ltempsqrx = lsqr(lnew.x); ltempsqry = lsqr(lnew.y);\
  367.    lmagnitud = ltempsqrx + ltempsqry;\
  368.    if (lmagnitud >= llimit || lmagnitud < 0 || labs(lnew.x) > llimit2\
  369.      || labs(lnew.y) > llimit2 || overflow) \
  370.            { overflow=0;return(1);}\
  371.    lold = lnew;
  372.  
  373. #define FLOATTRIGBAILOUT()  \
  374.    if (fabs(old.y) >= rqlim2) return(1);
  375.  
  376. #define LONGTRIGBAILOUT()  \
  377.    if(labs(lold.y) >= llimit2 || overflow) { overflow=0;return(1);}
  378.  
  379. #define LONGXYTRIGBAILOUT()  \
  380.    if(labs(lold.x) >= llimit2 || labs(lold.y) >= llimit2 || overflow)\
  381.     { overflow=0;return(1);}
  382.  
  383. #define FLOATXYTRIGBAILOUT()  \
  384.    if (fabs(old.x) >= rqlim2 || fabs(old.y) >= rqlim2) return(1);
  385.  
  386. #define FLOATHTRIGBAILOUT()  \
  387.    if (fabs(old.x) >= rqlim2) return(1);
  388.  
  389. #define LONGHTRIGBAILOUT()  \
  390.    if(labs(lold.x) >= llimit2 || overflow) { overflow=0;return(1);}
  391.  
  392. #define TRIG16CHECK(X)    \
  393.       if(labs((X)) > l16triglim || overflow) { overflow=0;return(1);}
  394.  
  395. #define FLOATEXPBAILOUT()  \
  396.    if (fabs(old.y) >= 1.0e8) return(1);\
  397.    if (fabs(old.x) >= 6.4e2) return(1);
  398.  
  399. #define LONGEXPBAILOUT()  \
  400.    if (labs(lold.y) >= (1000L<<bitshift)) return(1);\
  401.    if (labs(lold.x) >=      (8L<<bitshift)) return(1);
  402.  
  403. #if 0
  404. /* this define uses usual trig instead of fast trig */
  405. #define FPUsincos(px,psinx,pcosx) \
  406.    *(psinx) = sin(*(px));\
  407.    *(pcosx) = cos(*(px));
  408.  
  409. #define FPUsinhcosh(px,psinhx,pcoshx) \
  410.    *(psinhx) = sinh(*(px));\
  411.    *(pcoshx) = cosh(*(px));
  412. #endif
  413.  
  414. #define LTRIGARG(X)    \
  415.    if(labs((X)) > l16triglim)\
  416.    {\
  417.       double tmp;\
  418.       tmp = (X);\
  419.       tmp /= fudge;\
  420.       tmp = fmod(tmp,twopi);\
  421.       tmp *= fudge;\
  422.       (X) = tmp;\
  423.    }\
  424.  
  425. /* -------------------------------------------------------------------- */
  426. /*        Fractal (once per iteration) routines            */
  427. /* -------------------------------------------------------------------- */
  428. static double xt, yt, t2;
  429.  
  430. /* Raise complex number (base) to the (exp) power, storing the result
  431. ** in complex (result).
  432. */
  433. void cpower(CMPLX *base, int exp, CMPLX *result)
  434. {
  435.     xt = base->x;   yt = base->y;
  436.  
  437.     if (exp & 1)
  438.     {
  439.        result->x = xt;
  440.        result->y = yt;
  441.     }
  442.     else
  443.     {
  444.        result->x = 1.0;
  445.        result->y = 0.0;
  446.     }
  447.  
  448.     exp >>= 1;
  449.     while (exp)
  450.     {
  451.     t2 = xt * xt - yt * yt;
  452.     yt = 2 * xt * yt;
  453.     xt = t2;
  454.  
  455.     if (exp & 1)
  456.     {
  457.         t2 = xt * result->x - yt * result->y;
  458.         result->y = result->y * xt + yt * result->x;
  459.         result->x = t2;
  460.     }
  461.     exp >>= 1;
  462.     }
  463. }
  464. /* long version */
  465. static long lxt, lyt, lt2;
  466.  
  467. lcpower(LCMPLX *base, int exp, LCMPLX *result, int bitshift)
  468. {
  469.     static long maxarg;
  470.     maxarg = 64L<<bitshift;
  471.  
  472.     overflow = 0;
  473.     lxt = base->x;   lyt = base->y;
  474.  
  475.     if (exp & 1)
  476.     {
  477.        result->x = lxt;
  478.        result->y = lyt;
  479.     }
  480.     else
  481.     {
  482.        result->x = 1L<<bitshift;
  483.        result->y = 0L;
  484.     }
  485.  
  486.     exp >>= 1;
  487.     while (exp)
  488.     {
  489.     /*
  490.     if(labs(lxt) >= maxarg || labs(lyt) >= maxarg)
  491.        return(-1);
  492.     */
  493.     lt2 = multiply(lxt, lxt, bitshift) - multiply(lyt,lyt,bitshift);
  494.     lyt = multiply(lxt,lyt,bitshiftless1);
  495.     if(overflow)
  496.        return(overflow);
  497.     lxt = lt2;
  498.  
  499.     if (exp & 1)
  500.     {
  501.         lt2 = multiply(lxt,result->x, bitshift) - multiply(lyt,result->y,bitshift);
  502.         result->y = multiply(result->y,lxt,bitshift) + multiply(lyt,result->x,bitshift);
  503.         result->x = lt2;
  504.     }
  505.     exp >>= 1;
  506.     }
  507.     if(result->x == 0 && result->y == 0)
  508.        overflow = 1;
  509.     return(overflow);
  510. }
  511. #if 0
  512. z_to_the_z(CMPLX *z, CMPLX *out)
  513. {
  514.     static CMPLX tmp1,tmp2;
  515.     /* raises complex z to the z power */
  516.     int errno_xxx;
  517.     errno_xxx = 0;
  518.  
  519.     if(fabs(z->x) < DBL_EPSILON) return(-1);
  520.  
  521.     /* log(x + iy) = 1/2(log(x*x + y*y) + i(arc_tan(y/x)) */
  522.     tmp1.x = .5*log(sqr(z->x)+sqr(z->y));
  523.  
  524.     /* the fabs in next line added to prevent discontinuity in image */
  525.     tmp1.y = atan(fabs(z->y/z->x));
  526.  
  527.     /* log(z)*z */
  528.     tmp2.x = tmp1.x * z->x - tmp1.y * z->y;
  529.     tmp2.y = tmp1.x * z->y + tmp1.y * z->x;
  530.  
  531.     /* z*z = e**(log(z)*z) */
  532.     /* e**(x + iy) =  e**x * (cos(y) + isin(y)) */
  533.  
  534.     tmpexp = exp(tmp2.x);
  535.  
  536.     FPUsincos(&tmp2.y,&siny,&cosy);
  537.     out->x = tmpexp*cosy;
  538.     out->y = tmpexp*siny;
  539.     return(errno_xxx);
  540. }
  541. #endif
  542. /* Distance of complex z from unit circle */
  543. #define DIST1(z) (((z).x-1.0)*((z).x-1.0)+((z).y)*((z).y))
  544. #define LDIST1(z) (lsqr((((z).x)-fudge)) + lsqr(((z).y)))
  545.  
  546. #ifdef NEWTON
  547. int complex_mult(CMPLX arg1,CMPLX arg2,CMPLX *pz);
  548. int complex_div(CMPLX arg1,CMPLX arg2,CMPLX *pz);
  549.  
  550. int NewtonFractal()
  551. {
  552.     static char start=1;
  553.     if(start)
  554.     {
  555.        start = 0;
  556.     }
  557.     cpower(&old, degree-1, &tmp);
  558.     complex_mult(tmp, old, &new);
  559.  
  560.     if (DIST1(new) < threshold)
  561.     {
  562.        if(fractype==NEWTBASIN)
  563.        {
  564.       int tmpcolor;
  565.       int i;
  566.       tmpcolor = -1;
  567.       /* this code determines which degree-th root of root the
  568.          Newton formula converges to. The roots of a 1 are
  569.          distributed on a circle of radius 1 about the origin. */
  570.       for(i=0;i<degree;i++)
  571.          /* color in alternating shades with iteration according to
  572.         which root of 1 it converged to */
  573.           if(distance(roots[i],old) < threshold)
  574.           {
  575.            /*    tmpcolor = 1+(i&7)+((color&1)<<3); */
  576.            tmpcolor = 1+i;
  577.            break;
  578.           }
  579.        if(tmpcolor == -1)
  580.           color = maxcolor;
  581.        else
  582.           color = tmpcolor;
  583.        }
  584.        return(1);
  585.     }
  586.     new.x = d1overd * new.x + roverd;
  587.     new.y *= d1overd;
  588.  
  589.     /* Watch for divide underflow */
  590.     if ((t2 = tmp.x * tmp.x + tmp.y * tmp.y) < FLT_MIN)
  591.       return(1);
  592.     else
  593.     {
  594.     t2 = 1.0 / t2;
  595.     old.x = t2 * (new.x * tmp.x + new.y * tmp.y);
  596.     old.y = t2 * (new.y * tmp.x - new.x * tmp.y);
  597.     }
  598.     return(0);
  599. }
  600.  
  601.  
  602. complex_mult(arg1,arg2,pz)
  603. CMPLX arg1,arg2,*pz;
  604. {
  605.    pz->x = arg1.x*arg2.x - arg1.y*arg2.y;
  606.    pz->y = arg1.x*arg2.y+arg1.y*arg2.x;
  607.    return(0);
  608. }
  609.  
  610. complex_div(numerator,denominator,pout)
  611. CMPLX numerator,denominator,*pout;
  612. {
  613.    double mod;
  614.    if((mod = modulus(denominator)) < FLT_MIN)
  615.       return(1);
  616.    conjugate(&denominator);
  617.    complex_mult(numerator,denominator,pout);
  618.    pout->x = pout->x/mod;
  619.    pout->y = pout->y/mod;
  620.    return(0);
  621. }
  622.  
  623.  
  624. lcomplex_mult(arg1,arg2,pz,bitshift)
  625. LCMPLX arg1,arg2,*pz;
  626. int bitshift;
  627. {
  628.    overflow = 0;
  629.    pz->x = multiply(arg1.x,arg2.x,bitshift) - multiply(arg1.y,arg2.y,bitshift);
  630.    pz->y = multiply(arg1.x,arg2.y,bitshift) + multiply(arg1.y,arg2.x,bitshift);
  631.    return(overflow);
  632. }
  633.  
  634. #endif
  635.  
  636. #define MPCmod(m) (*pMPadd(*pMPmul((m).x, (m).x), *pMPmul((m).y, (m).y)))
  637. struct MPC mpcold, mpcnew, mpctmp, mpctmp1;
  638. struct MP mproverd, mpd1overd, mpthreshold,sqrmpthreshold;
  639. struct MP mpt2;
  640. struct MP mpone;
  641. extern struct MPC MPCone;
  642. extern int MPOverflow;
  643. int MPCNewtonFractal()
  644. {
  645.     MPOverflow = 0;
  646.     mpctmp   = MPCpow(mpcold,degree-1);
  647.  
  648. #ifndef XFRACT
  649.     mpcnew.x = *pMPsub(*pMPmul(mpctmp.x,mpcold.x),*pMPmul(mpctmp.y,mpcold.y));
  650.     mpcnew.y = *pMPadd(*pMPmul(mpctmp.x,mpcold.y),*pMPmul(mpctmp.y,mpcold.x));
  651.     mpctmp1.x = *pMPsub(mpcnew.x, MPCone.x);
  652.     mpctmp1.y = *pMPsub(mpcnew.y, MPCone.y);
  653.     if(pMPcmp(MPCmod(mpctmp1),mpthreshold)< 0)
  654. #else
  655.     mpcnew.x.val = mpctmp.x.val*mpcold.x.val-mpctmp.y.val*mpcold.y.val;
  656.     mpcnew.y.val = mpctmp.x.val*mpcold.y.val+mpctmp.y.val*mpcold.x.val;
  657.     mpctmp1.x.val = mpcnew.x.val-1;
  658.     mpctmp1.y.val = mpcnew.y.val;
  659.     if (mpctmp1.x.val*mpctmp1.x.val+mpctmp1.y.val*mpctmp1.y.val<mpthreshold.val)
  660. #endif
  661.     {
  662.       if(fractype==MPNEWTBASIN)
  663.       {
  664.      int tmpcolor;
  665.      int i;
  666.      tmpcolor = -1;
  667.      for(i=0;i<degree;i++)
  668.          if(pMPcmp(MPdistance(MPCroots[i],mpcold),mpthreshold) < 0)
  669.          {
  670.         if(basin==2)
  671.            tmpcolor = 1+(i&7) + ((color&1)<<3);
  672.         else
  673.            tmpcolor = 1+i;
  674.             break;
  675.          }
  676.       if(tmpcolor == -1)
  677.          color = maxcolor;
  678.       else
  679.          color = tmpcolor;
  680.       }
  681.        return(1);
  682.     }
  683.  
  684. #ifndef XFRACT
  685.     mpcnew.x = *pMPadd(*pMPmul(mpd1overd,mpcnew.x),mproverd);
  686.     mpcnew.y = *pMPmul(mpcnew.y,mpd1overd);
  687.     mpt2 = MPCmod(mpctmp);
  688.     mpt2 = *pMPdiv(mpone,mpt2);
  689.     mpcold.x = *pMPmul(mpt2,(*pMPadd(*pMPmul(mpcnew.x,mpctmp.x),*pMPmul(mpcnew.y,mpctmp.y))));
  690.     mpcold.y = *pMPmul(mpt2,(*pMPsub(*pMPmul(mpcnew.y,mpctmp.x),*pMPmul(mpcnew.x,mpctmp.y))));
  691. #else
  692.     mpcnew.x.val = mpd1overd.val*mpcnew.x.val+mproverd.val;
  693.     mpcnew.y.val= mpcnew.y.val*mpd1overd.val;
  694.     mpt2.val = mpctmp.x.val*mpctmp.x.val+mpctmp.y.val*mpctmp.y.val;
  695.     mpt2.val = 1./mpt2.val;
  696.     mpcold.x.val = mpt2.val*(mpcnew.x.val*mpctmp.x.val+mpcnew.y.val*mpctmp.y.val);
  697.     mpcold.y.val = mpt2.val*(mpcnew.y.val*mpctmp.x.val-mpcnew.x.val*mpctmp.y.val);
  698. #endif
  699.  
  700.     new.x = *pMP2d(mpcold.x);
  701.     new.y = *pMP2d(mpcold.y);
  702.     return(MPOverflow);
  703. }
  704.  
  705.  
  706. Barnsley1Fractal()
  707. {
  708.    /* Barnsley's Mandelbrot type M1 from "Fractals
  709.    Everywhere" by Michael Barnsley, p. 322 */
  710.  
  711.    /* calculate intermediate products */
  712.    oldxinitx   = multiply(lold.x, longparm->x, bitshift);
  713.    oldyinity   = multiply(lold.y, longparm->y, bitshift);
  714.    oldxinity   = multiply(lold.x, longparm->y, bitshift);
  715.    oldyinitx   = multiply(lold.y, longparm->x, bitshift);
  716.    /* orbit calculation */
  717.    if(lold.x >= 0)
  718.    {
  719.       lnew.x = (oldxinitx - longparm->x - oldyinity);
  720.       lnew.y = (oldyinitx - longparm->y + oldxinity);
  721.    }
  722.    else
  723.    {
  724.       lnew.x = (oldxinitx + longparm->x - oldyinity);
  725.       lnew.y = (oldyinitx + longparm->y + oldxinity);
  726.    }
  727.    return(longbailout());
  728. }
  729.  
  730. Barnsley1FPFractal()
  731. {
  732.    /* Barnsley's Mandelbrot type M1 from "Fractals
  733.    Everywhere" by Michael Barnsley, p. 322 */
  734.    /* note that fast >= 287 equiv in fracsuba.asm must be kept in step */
  735.  
  736.    /* calculate intermediate products */
  737.    foldxinitx = old.x * floatparm->x;
  738.    foldyinity = old.y * floatparm->y;
  739.    foldxinity = old.x * floatparm->y;
  740.    foldyinitx = old.y * floatparm->x;
  741.    /* orbit calculation */
  742.    if(old.x >= 0)
  743.    {
  744.       new.x = (foldxinitx - floatparm->x - foldyinity);
  745.       new.y = (foldyinitx - floatparm->y + foldxinity);
  746.    }
  747.    else
  748.    {
  749.       new.x = (foldxinitx + floatparm->x - foldyinity);
  750.       new.y = (foldyinitx + floatparm->y + foldxinity);
  751.    }
  752.    return(floatbailout());
  753. }
  754.  
  755. Barnsley2Fractal()
  756. {
  757.    /* An unnamed Mandelbrot/Julia function from "Fractals
  758.    Everywhere" by Michael Barnsley, p. 331, example 4.2 */
  759.    /* note that fast >= 287 equiv in fracsuba.asm must be kept in step */
  760.  
  761.    /* calculate intermediate products */
  762.    oldxinitx   = multiply(lold.x, longparm->x, bitshift);
  763.    oldyinity   = multiply(lold.y, longparm->y, bitshift);
  764.    oldxinity   = multiply(lold.x, longparm->y, bitshift);
  765.    oldyinitx   = multiply(lold.y, longparm->x, bitshift);
  766.  
  767.    /* orbit calculation */
  768.    if(oldxinity + oldyinitx >= 0)
  769.    {
  770.       lnew.x = oldxinitx - longparm->x - oldyinity;
  771.       lnew.y = oldyinitx - longparm->y + oldxinity;
  772.    }
  773.    else
  774.    {
  775.       lnew.x = oldxinitx + longparm->x - oldyinity;
  776.       lnew.y = oldyinitx + longparm->y + oldxinity;
  777.    }
  778.    return(longbailout());
  779. }
  780.  
  781. Barnsley2FPFractal()
  782. {
  783.    /* An unnamed Mandelbrot/Julia function from "Fractals
  784.    Everywhere" by Michael Barnsley, p. 331, example 4.2 */
  785.  
  786.    /* calculate intermediate products */
  787.    foldxinitx = old.x * floatparm->x;
  788.    foldyinity = old.y * floatparm->y;
  789.    foldxinity = old.x * floatparm->y;
  790.    foldyinitx = old.y * floatparm->x;
  791.  
  792.    /* orbit calculation */
  793.    if(foldxinity + foldyinitx >= 0)
  794.    {
  795.       new.x = foldxinitx - floatparm->x - foldyinity;
  796.       new.y = foldyinitx - floatparm->y + foldxinity;
  797.    }
  798.    else
  799.    {
  800.       new.x = foldxinitx + floatparm->x - foldyinity;
  801.       new.y = foldyinitx + floatparm->y + foldxinity;
  802.    }
  803.    return(floatbailout());
  804. }
  805.  
  806. JuliaFractal()
  807. {
  808.    /* used for C prototype of fast integer math routines for classic
  809.       Mandelbrot and Julia */
  810.    lnew.x  = ltempsqrx - ltempsqry + longparm->x;
  811.    lnew.y = multiply(lold.x, lold.y, bitshiftless1) + longparm->y;
  812.    return(longbailout());
  813. }
  814.  
  815. JuliafpFractal()
  816. {
  817.    /* floating point version of classical Mandelbrot/Julia */
  818.    /* note that fast >= 287 equiv in fracsuba.asm must be kept in step */
  819.    new.x = tempsqrx - tempsqry + floatparm->x;
  820.    new.y = 2.0 * old.x * old.y + floatparm->y;
  821.    return(floatbailout());
  822. }
  823.  
  824. static double f(double x, double y)
  825. {
  826.    return(x - x*y);
  827. }
  828.  
  829. static double g(double x, double y)
  830. {
  831.    return(-y + x*y);
  832. }
  833.  
  834. LambdaFPFractal()
  835. {
  836.    /* variation of classical Mandelbrot/Julia */
  837.    /* note that fast >= 287 equiv in fracsuba.asm must be kept in step */
  838.  
  839.    tempsqrx = old.x - tempsqrx + tempsqry;
  840.    tempsqry = -(old.y * old.x);
  841.    tempsqry += tempsqry + old.y;
  842.  
  843.    new.x = floatparm->x * tempsqrx - floatparm->y * tempsqry;
  844.    new.y = floatparm->x * tempsqry + floatparm->y * tempsqrx;
  845.    return(floatbailout());
  846. }
  847.  
  848. LambdaFractal()
  849. {
  850.    /* variation of classical Mandelbrot/Julia */
  851.  
  852.    /* in complex math) temp = Z * (1-Z) */
  853.    ltempsqrx = lold.x - ltempsqrx + ltempsqry;
  854.    ltempsqry = lold.y
  855.          - multiply(lold.y, lold.x, bitshiftless1);
  856.    /* (in complex math) Z = Lambda * Z */
  857.    lnew.x = multiply(longparm->x, ltempsqrx, bitshift)
  858.     - multiply(longparm->y, ltempsqry, bitshift);
  859.    lnew.y = multiply(longparm->x, ltempsqry, bitshift)
  860.     + multiply(longparm->y, ltempsqrx, bitshift);
  861.    return(longbailout());
  862. }
  863.  
  864. SierpinskiFractal()
  865. {
  866.    /* following code translated from basic - see "Fractals
  867.    Everywhere" by Michael Barnsley, p. 251, Program 7.1.1 */
  868.    lnew.x = (lold.x << 1);        /* new.x = 2 * old.x  */
  869.    lnew.y = (lold.y << 1);        /* new.y = 2 * old.y  */
  870.    if(lold.y > ltmp.y)    /* if old.y > .5 */
  871.       lnew.y = lnew.y - ltmp.x; /* new.y = 2 * old.y - 1 */
  872.    else if(lold.x > ltmp.y)    /* if old.x > .5 */
  873.       lnew.x = lnew.x - ltmp.x; /* new.x = 2 * old.x - 1 */
  874.    /* end barnsley code */
  875.    return(longbailout());
  876. }
  877.  
  878. SierpinskiFPFractal()
  879. {
  880.    /* following code translated from basic - see "Fractals
  881.    Everywhere" by Michael Barnsley, p. 251, Program 7.1.1 */
  882.  
  883.    new.x = old.x + old.x;
  884.    new.y = old.y + old.y;
  885.    if(old.y > .5)
  886.       new.y = new.y - 1;
  887.    else if (old.x > .5)
  888.       new.x = new.x - 1;
  889.  
  890.    /* end barnsley code */
  891.    return(floatbailout());
  892. }
  893.  
  894. LambdaexponentFractal()
  895. {
  896.    /* found this in  "Science of Fractal Images" */
  897.    FLOATEXPBAILOUT();
  898.    FPUsincos  (&old.y,&siny,&cosy);
  899.  
  900.    if (old.x >= rqlim && cosy >= 0.0) return(1);
  901.    tmpexp = exp(old.x);
  902.    tmp.x = tmpexp*cosy;
  903.    tmp.y = tmpexp*siny;
  904.  
  905.    /*multiply by lamda */
  906.    new.x = floatparm->x*tmp.x - floatparm->y*tmp.y;
  907.    new.y = floatparm->y*tmp.x + floatparm->x*tmp.y;
  908.    old = new;
  909.    return(0);
  910. }
  911.  
  912. LongLambdaexponentFractal()
  913. {
  914.    /* found this in  "Science of Fractal Images" */
  915.    LONGEXPBAILOUT();
  916.  
  917.    SinCos086  (lold.y, &lsiny,    &lcosy);
  918.  
  919.    if (lold.x >= llimit && lcosy >= 0L) return(1);
  920.    longtmp = Exp086(lold.x);
  921.  
  922.    ltmp.x = multiply(longtmp,       lcosy,   bitshift);
  923.    ltmp.y = multiply(longtmp,       lsiny,   bitshift);
  924.  
  925.    lnew.x  = multiply(longparm->x, ltmp.x, bitshift)
  926.        - multiply(longparm->y, ltmp.y, bitshift);
  927.    lnew.y  = multiply(longparm->x, ltmp.y, bitshift)
  928.        + multiply(longparm->y, ltmp.x, bitshift);
  929.    lold = lnew;
  930.    return(0);
  931. }
  932.  
  933. FloatTrigPlusExponentFractal()
  934. {
  935.    /* another Scientific American biomorph type */
  936.    /* z(n+1) = e**z(n) + trig(z(n)) + C */
  937.  
  938.    if (fabs(old.x) >= 6.4e2) return(1); /* DOMAIN errors */
  939.    tmpexp = exp(old.x);
  940.    FPUsincos  (&old.y,&siny,&cosy);
  941.    CMPLXtrig0(old,new);
  942.  
  943.    /*new =   trig(old) + e**old + C  */
  944.    new.x += tmpexp*cosy + floatparm->x;
  945.    new.y += tmpexp*siny + floatparm->y;
  946.    return(floatbailout());
  947. }
  948.  
  949.  
  950. LongTrigPlusExponentFractal()
  951. {
  952.    /* calculate exp(z) */
  953.  
  954.    /* domain check for fast transcendental functions */
  955.    TRIG16CHECK(lold.x);
  956.    TRIG16CHECK(lold.y);
  957.  
  958.    longtmp = Exp086(lold.x);
  959.    SinCos086  (lold.y, &lsiny,    &lcosy);
  960.    LCMPLXtrig0(lold,lnew);
  961.    lnew.x += multiply(longtmp,      lcosy,   bitshift) + longparm->x;
  962.    lnew.y += multiply(longtmp,      lsiny,   bitshift) + longparm->y;
  963.    return(longbailout());
  964. }
  965.  
  966. MarksLambdaFractal()
  967. {
  968.    /* Mark Peterson's variation of "lambda" function */
  969.  
  970.    /* Z1 = (C^(exp-1) * Z**2) + C */
  971.    ltmp.x = ltempsqrx - ltempsqry;
  972.    ltmp.y = multiply(lold.x ,lold.y ,bitshiftless1);
  973.  
  974.    lnew.x = multiply(lcoefficient.x, ltmp.x, bitshift)
  975.     - multiply(lcoefficient.y, ltmp.y, bitshift) + longparm->x;
  976.    lnew.y = multiply(lcoefficient.x, ltmp.y, bitshift)
  977.     + multiply(lcoefficient.y, ltmp.x, bitshift) + longparm->y;
  978.  
  979.    return(longbailout());
  980. }
  981.  
  982.  
  983. long XXOne, FgOne, FgTwo;
  984.  
  985. UnityFractal()
  986. {
  987.    /* brought to you by Mark Peterson - you won't find this in any fractal
  988.       books unless they saw it here first - Mark invented it! */
  989.    XXOne = multiply(lold.x, lold.x, bitshift) + multiply(lold.y, lold.y, bitshift);
  990.    if((XXOne > FgTwo) || (labs(XXOne - FgOne) < delmin))
  991.       return(1);
  992.    lold.y = multiply(FgTwo - XXOne, lold.x, bitshift);
  993.    lold.x = multiply(FgTwo - XXOne, lold.y, bitshift);
  994.    lnew=lold;  /* TW added this line */
  995.    return(0);
  996. }
  997.  
  998. #define XXOne new.x
  999.  
  1000. UnityfpFractal()
  1001. {
  1002.    /* brought to you by Mark Peterson - you won't find this in any fractal
  1003.       books unless they saw it here first - Mark invented it! */
  1004.  
  1005.    XXOne = sqr(old.x) + sqr(old.y);
  1006.    if((XXOne > 2.0) || (fabs(XXOne - 1.0) < ddelmin))
  1007.       return(1);
  1008.    old.y = (2.0 - XXOne)* old.x;
  1009.    old.x = (2.0 - XXOne)* old.y;
  1010.    new=old;  /* TW added this line */
  1011.    return(0);
  1012. }
  1013.  
  1014. #undef XXOne
  1015.  
  1016. Mandel4Fractal()
  1017. {
  1018.    /* By writing this code, Bert has left behind the excuse "don't
  1019.       know what a fractal is, just know how to make'em go fast".
  1020.       Bert is hereby declared a bonafide fractal expert! Supposedly
  1021.       this routine calculates the Mandelbrot/Julia set based on the
  1022.       polynomial z**4 + lambda, but I wouldn't know -- can't follow
  1023.       all that integer math speedup stuff - Tim */
  1024.  
  1025.    /* first, compute (x + iy)**2 */
  1026.    lnew.x  = ltempsqrx - ltempsqry;
  1027.    lnew.y = multiply(lold.x, lold.y, bitshiftless1);
  1028.    if (longbailout()) return(1);
  1029.  
  1030.    /* then, compute ((x + iy)**2)**2 + lambda */
  1031.    lnew.x  = ltempsqrx - ltempsqry + longparm->x;
  1032.    lnew.y = multiply(lold.x, lold.y, bitshiftless1) + longparm->y;
  1033.    return(longbailout());
  1034. }
  1035.  
  1036. floatZtozPluszpwrFractal()
  1037. {
  1038.    cpower(&old,(int)param[2],&new);
  1039.    old = ComplexPower(old,old);
  1040.    new.x = new.x + old.x +floatparm->x;
  1041.    new.y = new.y + old.y +floatparm->y;
  1042.    return(floatbailout());
  1043. }
  1044.  
  1045. longZpowerFractal()
  1046. {
  1047.    if(lcpower(&lold,c_exp,&lnew,bitshift))
  1048.       lnew.x = lnew.y = 8L<<bitshift;
  1049.    lnew.x += longparm->x;
  1050.    lnew.y += longparm->y;
  1051.    return(longbailout());
  1052. }
  1053.  
  1054. longCmplxZpowerFractal()
  1055. {
  1056.    struct complex x, y;
  1057.  
  1058.    x.x = (double)lold.x / fudge;
  1059.    x.y = (double)lold.y / fudge;
  1060.    y.x = (double)lparm2.x / fudge;
  1061.    y.y = (double)lparm2.y / fudge;
  1062.    x = ComplexPower(x, y);
  1063.    if(fabs(x.x) < fgLimit && fabs(x.y) < fgLimit) {
  1064.       lnew.x = (long)(x.x * fudge);
  1065.       lnew.y = (long)(x.y * fudge);
  1066.    }
  1067.    else
  1068.       overflow = 1;
  1069.    lnew.x += longparm->x;
  1070.    lnew.y += longparm->y;
  1071.    return(longbailout());
  1072. }
  1073.  
  1074. floatZpowerFractal()
  1075. {
  1076.    cpower(&old,c_exp,&new);
  1077.    new.x += floatparm->x;
  1078.    new.y += floatparm->y;
  1079.    return(floatbailout());
  1080. }
  1081.  
  1082. floatCmplxZpowerFractal()
  1083. {
  1084.    new = ComplexPower(old, parm2);
  1085.    new.x += floatparm->x;
  1086.    new.y += floatparm->y;
  1087.    return(floatbailout());
  1088. }
  1089.  
  1090. Barnsley3Fractal()
  1091. {
  1092.    /* An unnamed Mandelbrot/Julia function from "Fractals
  1093.    Everywhere" by Michael Barnsley, p. 292, example 4.1 */
  1094.  
  1095.    /* calculate intermediate products */
  1096.    oldxinitx   = multiply(lold.x, lold.x, bitshift);
  1097.    oldyinity   = multiply(lold.y, lold.y, bitshift);
  1098.    oldxinity   = multiply(lold.x, lold.y, bitshift);
  1099.  
  1100.    /* orbit calculation */
  1101.    if(lold.x > 0)
  1102.    {
  1103.       lnew.x = oldxinitx   - oldyinity - fudge;
  1104.       lnew.y = oldxinity << 1;
  1105.    }
  1106.    else
  1107.    {
  1108.       lnew.x = oldxinitx - oldyinity - fudge
  1109.        + multiply(longparm->x,lold.x,bitshift);
  1110.       lnew.y = oldxinity <<1;
  1111.  
  1112.       /* This term added by Tim Wegner to make dependent on the
  1113.      imaginary part of the parameter. (Otherwise Mandelbrot
  1114.      is uninteresting. */
  1115.       lnew.y += multiply(longparm->y,lold.x,bitshift);
  1116.    }
  1117.    return(longbailout());
  1118. }
  1119.  
  1120. Barnsley3FPFractal()
  1121. {
  1122.    /* An unnamed Mandelbrot/Julia function from "Fractals
  1123.    Everywhere" by Michael Barnsley, p. 292, example 4.1 */
  1124.  
  1125.  
  1126.    /* calculate intermediate products */
  1127.    foldxinitx  = old.x * old.x;
  1128.    foldyinity  = old.y * old.y;
  1129.    foldxinity  = old.x * old.y;
  1130.  
  1131.    /* orbit calculation */
  1132.    if(old.x > 0)
  1133.    {
  1134.       new.x = foldxinitx - foldyinity - 1.0;
  1135.       new.y = foldxinity * 2;
  1136.    }
  1137.    else
  1138.    {
  1139.       new.x = foldxinitx - foldyinity -1.0 + floatparm->x * old.x;
  1140.       new.y = foldxinity * 2;
  1141.  
  1142.       /* This term added by Tim Wegner to make dependent on the
  1143.      imaginary part of the parameter. (Otherwise Mandelbrot
  1144.      is uninteresting. */
  1145.       new.y += floatparm->y * old.x;
  1146.    }
  1147.    return(floatbailout());
  1148. }
  1149.  
  1150. TrigPlusZsquaredFractal()
  1151. {
  1152.    /* From Scientific American, July 1989 */
  1153.    /* A Biomorph              */
  1154.    /* z(n+1) = trig(z(n))+z(n)**2+C      */
  1155.    LCMPLXtrig0(lold,lnew);
  1156.    lnew.x += ltempsqrx - ltempsqry + longparm->x;
  1157.    lnew.y += multiply(lold.x, lold.y, bitshiftless1) + longparm->y;
  1158.    return(longbailout());
  1159. }
  1160.  
  1161. TrigPlusZsquaredfpFractal()
  1162. {
  1163.    /* From Scientific American, July 1989 */
  1164.    /* A Biomorph              */
  1165.    /* z(n+1) = trig(z(n))+z(n)**2+C      */
  1166.  
  1167.    CMPLXtrig0(old,new);
  1168.    new.x += tempsqrx - tempsqry + floatparm->x;
  1169.    new.y += 2.0 * old.x * old.y + floatparm->y;
  1170.    return(floatbailout());
  1171. }
  1172.  
  1173. Richard8fpFractal()
  1174. {
  1175.    /*  Richard8 {c = z = pixel: z=sin(z)+sin(pixel),|z|<=50} */
  1176.    CMPLXtrig0(old,new);
  1177. /*   CMPLXtrig1(*floatparm,tmp); */
  1178.    new.x += tmp.x;
  1179.    new.y += tmp.y;
  1180.    return(floatbailout());
  1181. }
  1182.  
  1183. Richard8Fractal()
  1184. {
  1185.    /*  Richard8 {c = z = pixel: z=sin(z)+sin(pixel),|z|<=50} */
  1186.    LCMPLXtrig0(lold,lnew);
  1187. /*   LCMPLXtrig1(*longparm,ltmp); */
  1188.    lnew.x += ltmp.x;
  1189.    lnew.y += ltmp.y;
  1190.    return(longbailout());
  1191. }
  1192.  
  1193. PopcornFractal()
  1194. {
  1195.    extern int row;
  1196.    tmp = old;
  1197.    tmp.x *= 3.0;
  1198.    tmp.y *= 3.0;
  1199.    FPUsincos(&tmp.x,&sinx,&cosx);
  1200.    FPUsincos(&tmp.y,&siny,&cosy);
  1201.    tmp.x = sinx/cosx + old.x;
  1202.    tmp.y = siny/cosy + old.y;
  1203.    FPUsincos(&tmp.x,&sinx,&cosx);
  1204.    FPUsincos(&tmp.y,&siny,&cosy);
  1205.    new.x = old.x - parm.x*siny;
  1206.    new.y = old.y - parm.x*sinx;
  1207.    /*
  1208.    new.x = old.x - parm.x*sin(old.y+tan(3*old.y));
  1209.    new.y = old.y - parm.x*sin(old.x+tan(3*old.x));
  1210.    */
  1211.    if(plot == noplot)
  1212.    {
  1213.       plot_orbit(new.x,new.y,1+row%colors);
  1214.       old = new;
  1215.    }
  1216.    else
  1217.    /* FLOATBAILOUT(); */
  1218.    /* PB The above line was weird, not what it seems to be!  But, bracketing
  1219.      it or always doing it (either of which seem more likely to be what
  1220.      was intended) changes the image for the worse, so I'm not touching it.
  1221.      Same applies to int form in next routine. */
  1222.    /* PB later: recoded inline, still leaving it weird */
  1223.       tempsqrx = sqr(new.x);
  1224.    tempsqry = sqr(new.y);
  1225.    if((magnitude = tempsqrx + tempsqry) >= rqlim) return(1);
  1226.    old = new;
  1227.    return(0);
  1228. }
  1229.  
  1230. LPopcornFractal()
  1231. {
  1232.    extern int row;
  1233.    ltmp = lold;
  1234.    ltmp.x *= 3L;
  1235.    ltmp.y *= 3L;
  1236.    LTRIGARG(ltmp.x);
  1237.    LTRIGARG(ltmp.y);
  1238.    SinCos086(ltmp.x,&lsinx,&lcosx);
  1239.    SinCos086(ltmp.y,&lsiny,&lcosy);
  1240.    ltmp.x = divide(lsinx,lcosx,bitshift) + lold.x;
  1241.    ltmp.y = divide(lsiny,lcosy,bitshift) + lold.y;
  1242.    LTRIGARG(ltmp.x);
  1243.    LTRIGARG(ltmp.y);
  1244.    SinCos086(ltmp.x,&lsinx,&lcosx);
  1245.    SinCos086(ltmp.y,&lsiny,&lcosy);
  1246.    lnew.x = lold.x - multiply(lparm.x,lsiny,bitshift);
  1247.    lnew.y = lold.y - multiply(lparm.x,lsinx,bitshift);
  1248.    if(plot == noplot)
  1249.    {
  1250.       iplot_orbit(lnew.x,lnew.y,1+row%colors);
  1251.       lold = lnew;
  1252.    }
  1253.    else
  1254.       LONGBAILOUT();
  1255.    /* PB above still the old way, is weird, see notes in FP popcorn case */
  1256.    return(0);
  1257. }
  1258.  
  1259. int MarksCplxMand(void)
  1260. {
  1261.    tmp.x = tempsqrx - tempsqry;
  1262.    tmp.y = 2*old.x*old.y;
  1263.    FPUcplxmul(&tmp, &Coefficient, &new);
  1264.    new.x += floatparm->x;
  1265.    new.y += floatparm->y;
  1266.    return(floatbailout());
  1267. }
  1268.  
  1269. int SpiderfpFractal(void)
  1270. {
  1271.    /* Spider(XAXIS) { c=z=pixel: z=z*z+c; c=c/2+z, |z|<=4 } */
  1272.    new.x = tempsqrx - tempsqry + tmp.x;
  1273.    new.y = 2 * old.x * old.y + tmp.y;
  1274.    tmp.x = tmp.x/2 + new.x;
  1275.    tmp.y = tmp.y/2 + new.y;
  1276.    return(floatbailout());
  1277. }
  1278.  
  1279. SpiderFractal(void)
  1280. {
  1281.    /* Spider(XAXIS) { c=z=pixel: z=z*z+c; c=c/2+z, |z|<=4 } */
  1282.    lnew.x  = ltempsqrx - ltempsqry + ltmp.x;
  1283.    lnew.y = multiply(lold.x, lold.y, bitshiftless1) + ltmp.y;
  1284.    ltmp.x = (ltmp.x >> 1) + lnew.x;
  1285.    ltmp.y = (ltmp.y >> 1) + lnew.y;
  1286.    return(longbailout());
  1287. }
  1288.  
  1289. TetratefpFractal()
  1290. {
  1291.    /* Tetrate(XAXIS) { c=z=pixel: z=c^z, |z|<=(P1+3) } */
  1292.    new = ComplexPower(*floatparm,old);
  1293.    return(floatbailout());
  1294. }
  1295.  
  1296. ZXTrigPlusZFractal()
  1297. {
  1298.    /* z = (p1*z*trig(z))+p2*z */
  1299.    LCMPLXtrig0(lold,ltmp);        /* ltmp  = trig(old)         */
  1300.    LCMPLXmult(lparm,ltmp,ltmp);      /* ltmp  = p1*trig(old)          */
  1301.    LCMPLXmult(lold,ltmp,ltmp2);      /* ltmp2 = p1*old*trig(old)      */
  1302.    LCMPLXmult(lparm2,lold,ltmp);     /* ltmp  = p2*old              */
  1303.    LCMPLXadd(ltmp2,ltmp,lnew);         /* lnew  = p1*trig(old) + p2*old */
  1304.    return(longbailout());
  1305. }
  1306.  
  1307. ScottZXTrigPlusZFractal()
  1308. {
  1309.    /* z = (z*trig(z))+z */
  1310.    LCMPLXtrig0(lold,ltmp);        /* ltmp  = trig(old)       */
  1311.    LCMPLXmult(lold,ltmp,lnew);         /* lnew  = old*trig(old)    */
  1312.    LCMPLXadd(lnew,lold,lnew);         /* lnew  = trig(old) + old */
  1313.    return(longbailout());
  1314. }
  1315.  
  1316. SkinnerZXTrigSubZFractal()
  1317. {
  1318.    /* z = (z*trig(z))-z */
  1319.    LCMPLXtrig0(lold,ltmp);        /* ltmp  = trig(old)       */
  1320.    LCMPLXmult(lold,ltmp,lnew);         /* lnew  = old*trig(old)    */
  1321.    LCMPLXsub(lnew,lold,lnew);         /* lnew  = trig(old) - old */
  1322.    return(longbailout());
  1323. }
  1324.  
  1325. ZXTrigPlusZfpFractal()
  1326. {
  1327.    /* z = (p1*z*trig(z))+p2*z */
  1328.    CMPLXtrig0(old,tmp);      /* tmp  = trig(old)         */
  1329.    CMPLXmult(parm,tmp,tmp);     /* tmp  = p1*trig(old)      */
  1330.    CMPLXmult(old,tmp,tmp2);     /* tmp2 = p1*old*trig(old)     */
  1331.    CMPLXmult(parm2,old,tmp);     /* tmp  = p2*old         */
  1332.    CMPLXadd(tmp2,tmp,new);     /* new  = p1*trig(old) + p2*old */
  1333.    return(floatbailout());
  1334. }
  1335.  
  1336. ScottZXTrigPlusZfpFractal()
  1337. {
  1338.    /* z = (z*trig(z))+z */
  1339.    CMPLXtrig0(old,tmp);     /* tmp    = trig(old)      */
  1340.    CMPLXmult(old,tmp,new);     /* new  = old*trig(old)   */
  1341.    CMPLXadd(new,old,new);     /* new  = trig(old) + old */
  1342.    return(floatbailout());
  1343. }
  1344.  
  1345. SkinnerZXTrigSubZfpFractal()
  1346. {
  1347.    /* z = (z*trig(z))-z */
  1348.    CMPLXtrig0(old,tmp);     /* tmp    = trig(old)      */
  1349.    CMPLXmult(old,tmp,new);     /* new  = old*trig(old)   */
  1350.    CMPLXsub(new,old,new);     /* new  = trig(old) - old */
  1351.    return(floatbailout());
  1352. }
  1353.  
  1354. Sqr1overTrigFractal()
  1355. {
  1356.    /* z = sqr(1/trig(z)) */
  1357.    LCMPLXtrig0(lold,lold);
  1358.    LCMPLXrecip(lold,lold);
  1359.    LCMPLXsqr(lold,lnew);
  1360.    return(longbailout());
  1361. }
  1362.  
  1363. Sqr1overTrigfpFractal()
  1364. {
  1365.    /* z = sqr(1/trig(z)) */
  1366.    CMPLXtrig0(old,old);
  1367.    CMPLXrecip(old,old);
  1368.    CMPLXsqr(old,new);
  1369.    return(floatbailout());
  1370. }
  1371.  
  1372. TrigPlusTrigFractal()
  1373. {
  1374.    /* z = trig(0,z)*p1+trig1(z)*p2 */
  1375.    LCMPLXtrig0(lold,ltmp);
  1376.    LCMPLXmult(lparm,ltmp,ltmp);
  1377.    LCMPLXtrig1(lold,ltmp2);
  1378.    LCMPLXmult(lparm2,ltmp2,lold);
  1379.    LCMPLXadd(ltmp,lold,lnew);
  1380.    return(longbailout());
  1381. }
  1382.  
  1383. TrigPlusTrigfpFractal()
  1384. {
  1385.    /* z = trig0(z)*p1+trig1(z)*p2 */
  1386.    CMPLXtrig0(old,tmp);
  1387.    CMPLXmult(parm,tmp,tmp);
  1388.    CMPLXtrig1(old,old);
  1389.    CMPLXmult(parm2,old,old);
  1390.    CMPLXadd(tmp,old,new);
  1391.    return(floatbailout());
  1392. }
  1393.  
  1394.  
  1395. ScottTrigPlusTrigFractal()
  1396. {
  1397.    /* z = trig0(z)+trig1(z) */
  1398.    LCMPLXtrig0(lold,ltmp);
  1399.    LCMPLXtrig1(lold,lold);
  1400.    LCMPLXadd(ltmp,lold,lnew);
  1401.    return(longbailout());
  1402. }
  1403.  
  1404. ScottTrigPlusTrigfpFractal()
  1405. {
  1406.    /* z = trig0(z)+trig1(z) */
  1407.    CMPLXtrig0(old,tmp);
  1408.    CMPLXtrig1(old,tmp2);
  1409.    CMPLXadd(tmp,tmp2,new);
  1410.    return(floatbailout());
  1411. }
  1412.  
  1413. SkinnerTrigSubTrigFractal()
  1414. {
  1415.    /* z = trig(0,z)-trig1(z) */
  1416.    LCMPLXtrig0(lold,ltmp);
  1417.    LCMPLXtrig1(lold,ltmp2);
  1418.    LCMPLXsub(ltmp,ltmp2,lnew);
  1419.    return(longbailout());
  1420. }
  1421.  
  1422. SkinnerTrigSubTrigfpFractal()
  1423. {
  1424.    /* z = trig0(z)-trig1(z) */
  1425.    CMPLXtrig0(old,tmp);
  1426.    CMPLXtrig1(old,tmp2);
  1427.    CMPLXsub(tmp,tmp2,new);
  1428.    return(floatbailout());
  1429. }
  1430.  
  1431.  
  1432. TrigXTrigfpFractal()
  1433. {
  1434.    /* z = trig0(z)*trig1(z) */
  1435.    CMPLXtrig0(old,tmp);
  1436.    CMPLXtrig1(old,old);
  1437.    CMPLXmult(tmp,old,new);
  1438.    return(floatbailout());
  1439. }
  1440.  
  1441. TrigXTrigFractal()
  1442. {
  1443.    LCMPLX ltmp2;
  1444.    /* z = trig0(z)*trig1(z) */
  1445.    LCMPLXtrig0(lold,ltmp);
  1446.    LCMPLXtrig1(lold,ltmp2);
  1447.    LCMPLXmult(ltmp,ltmp2,lnew);
  1448.    if(overflow)
  1449.       TryFloatFractal(TrigXTrigfpFractal);
  1450.    return(longbailout());
  1451. }
  1452.  
  1453.  /* call float version of fractal if integer math overflow */
  1454. TryFloatFractal(int (*fpFractal)())
  1455. {
  1456.    overflow=0;
  1457.    /* lold had better not be changed! */
  1458.    old.x = lold.x; old.x /= fudge;
  1459.    old.y = lold.y; old.y /= fudge;
  1460.    tempsqrx = sqr(old.x);
  1461.    tempsqry = sqr(old.y);
  1462.    fpFractal();
  1463.    lnew.x = new.x/fudge;
  1464.    lnew.y = new.y/fudge;
  1465.    return(0);
  1466. }
  1467.  
  1468. /********************************************************************/
  1469. /*  Next six orbit functions are one type - extra functions are     */
  1470. /*    special cases written for speed.                    */
  1471. /********************************************************************/
  1472.  
  1473. TrigPlusSqrFractal() /* generalization of Scott and Skinner types */
  1474. {
  1475.    /* { z=pixel: z=(p1,p2)*trig(z)+(p3,p4)*sqr(z), |z|<BAILOUT } */
  1476.    LCMPLXtrig0(lold,ltmp);     /* ltmp = trig(lold)               */
  1477.    LCMPLXmult(lparm,ltmp,lnew); /* lnew = lparm*trig(lold)            */
  1478.    LCMPLXsqr_old(ltmp);     /* ltmp = sqr(lold)                */
  1479.    LCMPLXmult(lparm2,ltmp,ltmp);/* ltmp = lparm2*sqr(lold)            */
  1480.    LCMPLXadd(lnew,ltmp,lnew);    /* lnew = lparm*trig(lold)+lparm2*sqr(lold) */
  1481.    return(longbailout());
  1482. }
  1483.  
  1484. TrigPlusSqrfpFractal() /* generalization of Scott and Skinner types */
  1485. {
  1486.    /* { z=pixel: z=(p1,p2)*trig(z)+(p3,p4)*sqr(z), |z|<BAILOUT } */
  1487.    CMPLXtrig0(old,tmp);     /* tmp = trig(old)               */
  1488.    CMPLXmult(parm,tmp,new); /* new = parm*trig(old)           */
  1489.    CMPLXsqr_old(tmp);         /* tmp = sqr(old)                */
  1490.    CMPLXmult(parm2,tmp,tmp2); /* tmp = parm2*sqr(old)             */
  1491.    CMPLXadd(new,tmp2,new);    /* new = parm*trig(old)+parm2*sqr(old) */
  1492.    return(floatbailout());
  1493. }
  1494.  
  1495. ScottTrigPlusSqrFractal()
  1496. {
  1497.    /*  { z=pixel: z=trig(z)+sqr(z), |z|<BAILOUT } */
  1498.    LCMPLXtrig0(lold,lnew);    /* lnew = trig(lold)         */
  1499.    LCMPLXsqr_old(ltmp);        /* lold = sqr(lold)          */
  1500.    LCMPLXadd(ltmp,lnew,lnew);  /* lnew = trig(lold)+sqr(lold) */
  1501.    return(longbailout());
  1502. }
  1503.  
  1504. ScottTrigPlusSqrfpFractal() /* float version */
  1505. {
  1506.    /* { z=pixel: z=sin(z)+sqr(z), |z|<BAILOUT } */
  1507.    CMPLXtrig0(old,new);       /* new = trig(old)      */
  1508.    CMPLXsqr_old(tmp);           /* tmp = sqr(old)       */
  1509.    CMPLXadd(new,tmp,new);      /* new = trig(old)+sqr(old) */
  1510.    return(floatbailout());
  1511. }
  1512.  
  1513. SkinnerTrigSubSqrFractal()
  1514. {
  1515.    /* { z=pixel: z=sin(z)-sqr(z), |z|<BAILOUT }           */
  1516.    LCMPLXtrig0(lold,lnew);    /* lnew = trig(lold)         */
  1517.    LCMPLXsqr_old(ltmp);        /* lold = sqr(lold)          */
  1518.    LCMPLXsub(lnew,ltmp,lnew);  /* lnew = trig(lold)-sqr(lold) */
  1519.    return(longbailout());
  1520. }
  1521.  
  1522. SkinnerTrigSubSqrfpFractal()
  1523. {
  1524.    /* { z=pixel: z=sin(z)-sqr(z), |z|<BAILOUT } */
  1525.    CMPLXtrig0(old,new);       /* new = trig(old) */
  1526.    CMPLXsqr_old(tmp);           /* old = sqr(old)  */
  1527.    CMPLXsub(new,tmp,new);      /* new = trig(old)-sqr(old) */
  1528.    return(floatbailout());
  1529. }
  1530.  
  1531. TrigZsqrdfpFractal()
  1532. {
  1533.    /* { z=pixel: z=trig(z*z), |z|<TEST } */
  1534.    CMPLXsqr_old(tmp);
  1535.    CMPLXtrig0(tmp,new);
  1536.    return(floatbailout());
  1537. }
  1538.  
  1539. TrigZsqrdFractal() /* this doesn't work very well */
  1540. {
  1541.    /* { z=pixel: z=trig(z*z), |z|<TEST } */
  1542.    LCMPLXsqr_old(ltmp);
  1543.    LCMPLXtrig0(ltmp,lnew);
  1544.    if(overflow)
  1545.       TryFloatFractal(TrigZsqrdfpFractal);
  1546.    return(longbailout());
  1547. }
  1548.  
  1549. SqrTrigFractal()
  1550. {
  1551.    /* { z=pixel: z=sqr(trig(z)), |z|<TEST} */
  1552.    LCMPLXtrig0(lold,ltmp);
  1553.    LCMPLXsqr(ltmp,lnew);
  1554.    return(longbailout());
  1555. }
  1556.  
  1557. SqrTrigfpFractal()
  1558. {
  1559.    /* SZSB(XYAXIS) { z=pixel, TEST=(p1+3): z=sin(z)*sin(z), |z|<TEST} */
  1560.    CMPLXtrig0(old,tmp);
  1561.    CMPLXsqr(tmp,new);
  1562.    return(floatbailout());
  1563. }
  1564.  
  1565.  
  1566. Magnet1Fractal()    /*      Z = ((Z**2 + C - 1)/(2Z + C - 2))**2      */
  1567.   {              /*  In "Beauty of Fractals", code by Kev Allen. */
  1568.     CMPLX top, bot, tmp;
  1569.     double div;
  1570.  
  1571.     top.x = tempsqrx - tempsqry + floatparm->x - 1; /* top = Z**2+C-1 */
  1572.     top.y = old.x * old.y;
  1573.     top.y = top.y + top.y + floatparm->y;
  1574.  
  1575.     bot.x = old.x + old.x + floatparm->x - 2;        /* bot = 2*Z+C-2  */
  1576.     bot.y = old.y + old.y + floatparm->y;
  1577.  
  1578.     div = bot.x*bot.x + bot.y*bot.y;            /* tmp = top/bot  */
  1579.     if (div < FLT_MIN) return(1);
  1580.     tmp.x = (top.x*bot.x + top.y*bot.y)/div;
  1581.     tmp.y = (top.y*bot.x - top.x*bot.y)/div;
  1582.  
  1583.     new.x = (tmp.x + tmp.y) * (tmp.x - tmp.y);        /* Z = tmp**2     */
  1584.     new.y = tmp.x * tmp.y;
  1585.     new.y += new.y;
  1586.  
  1587.     return(floatbailout());
  1588.   }
  1589.  
  1590. Magnet2Fractal()  /* Z = ((Z**3 + 3(C-1)Z + (C-1)(C-2)    ) /     */
  1591.             /*         (3Z**2 + 3(C-2)Z + (C-1)(C-2)+1) )**2  */
  1592.   {            /*     In "Beauty of Fractals", code by Kev Allen.  */
  1593.     CMPLX top, bot, tmp;
  1594.     double div;
  1595.  
  1596.     top.x = old.x * (tempsqrx-tempsqry-tempsqry-tempsqry + T_Cm1.x)
  1597.       - old.y * T_Cm1.y + T_Cm1Cm2.x;
  1598.     top.y = old.y * (tempsqrx+tempsqrx+tempsqrx-tempsqry + T_Cm1.x)
  1599.       + old.x * T_Cm1.y + T_Cm1Cm2.y;
  1600.  
  1601.     bot.x = tempsqrx - tempsqry;
  1602.     bot.x = bot.x + bot.x + bot.x
  1603.       + old.x * T_Cm2.x - old.y * T_Cm2.y
  1604.       + T_Cm1Cm2.x + 1.0;
  1605.     bot.y = old.x * old.y;
  1606.     bot.y += bot.y;
  1607.     bot.y = bot.y + bot.y + bot.y
  1608.       + old.x * T_Cm2.y + old.y * T_Cm2.x
  1609.       + T_Cm1Cm2.y;
  1610.  
  1611.     div = bot.x*bot.x + bot.y*bot.y;            /* tmp = top/bot  */
  1612.     if (div < FLT_MIN) return(1);
  1613.     tmp.x = (top.x*bot.x + top.y*bot.y)/div;
  1614.     tmp.y = (top.y*bot.x - top.x*bot.y)/div;
  1615.  
  1616.     new.x = (tmp.x + tmp.y) * (tmp.x - tmp.y);        /* Z = tmp**2     */
  1617.     new.y = tmp.x * tmp.y;
  1618.     new.y += new.y;
  1619.  
  1620.     return(floatbailout());
  1621.   }
  1622.  
  1623. LambdaTrigFractal()
  1624. {
  1625.    LONGXYTRIGBAILOUT();
  1626.    LCMPLXtrig0(lold,ltmp);         /* ltmp = trig(lold)        */
  1627.    LCMPLXmult(*longparm,ltmp,lnew);   /* lnew = longparm*trig(lold)  */
  1628.    lold = lnew;
  1629.    return(0);
  1630. }
  1631.  
  1632. LambdaTrigfpFractal()
  1633. {
  1634.    FLOATXYTRIGBAILOUT();
  1635.    CMPLXtrig0(old,tmp);          /* tmp = trig(old)       */
  1636.    CMPLXmult(*floatparm,tmp,new);   /* new = longparm*trig(old)  */
  1637.    old = new;
  1638.    return(0);
  1639. }
  1640.  
  1641. /* bailouts are different for different trig functions */
  1642. LambdaTrigFractal1()
  1643. {
  1644.    LONGTRIGBAILOUT(); /* sin,cos */
  1645.    LCMPLXtrig0(lold,ltmp);         /* ltmp = trig(lold)        */
  1646.    LCMPLXmult(*longparm,ltmp,lnew);   /* lnew = longparm*trig(lold)  */
  1647.    lold = lnew;
  1648.    return(0);
  1649. }
  1650.  
  1651. LambdaTrigfpFractal1()
  1652. {
  1653.    FLOATTRIGBAILOUT(); /* sin,cos */
  1654.    CMPLXtrig0(old,tmp);          /* tmp = trig(old)       */
  1655.    CMPLXmult(*floatparm,tmp,new);   /* new = longparm*trig(old)  */
  1656.    old = new;
  1657.    return(0);
  1658. }
  1659.  
  1660. LambdaTrigFractal2()
  1661. {
  1662.    LONGHTRIGBAILOUT(); /* sinh,cosh */
  1663.    LCMPLXtrig0(lold,ltmp);         /* ltmp = trig(lold)        */
  1664.    LCMPLXmult(*longparm,ltmp,lnew);   /* lnew = longparm*trig(lold)  */
  1665.    lold = lnew;
  1666.    return(0);
  1667. }
  1668.  
  1669. LambdaTrigfpFractal2()
  1670. {
  1671.    FLOATHTRIGBAILOUT(); /* sinh,cosh */
  1672.    CMPLXtrig0(old,tmp);          /* tmp = trig(old)       */
  1673.    CMPLXmult(*floatparm,tmp,new);   /* new = longparm*trig(old)  */
  1674.    old = new;
  1675.    return(0);
  1676. }
  1677.  
  1678. ManOWarFractal()
  1679. {
  1680.    /* From Art Matrix via Lee Skinner */
  1681.    lnew.x  = ltempsqrx - ltempsqry + ltmp.x + longparm->x;
  1682.    lnew.y = multiply(lold.x, lold.y, bitshiftless1) + ltmp.y + longparm->y;
  1683.    ltmp = lold;
  1684.    return(longbailout());
  1685. }
  1686.  
  1687. ManOWarfpFractal()
  1688. {
  1689.    /* From Art Matrix via Lee Skinner */
  1690.    /* note that fast >= 287 equiv in fracsuba.asm must be kept in step */
  1691.    new.x = tempsqrx - tempsqry + tmp.x + floatparm->x;
  1692.    new.y = 2.0 * old.x * old.y + tmp.y + floatparm->y;
  1693.    tmp = old;
  1694.    return(floatbailout());
  1695. }
  1696.  
  1697. /*
  1698.    MarksMandelPwr (XAXIS) {
  1699.       z = pixel, c = z ^ (z - 1):
  1700.      z = c * sqr(z) + pixel,
  1701.       |z| <= 4
  1702.    }
  1703. */
  1704.  
  1705. MarksMandelPwrfpFractal()
  1706. {
  1707.    CMPLXtrig0(old,new);
  1708.    CMPLXmult(tmp,new,new);
  1709.    new.x += floatparm->x;
  1710.    new.y += floatparm->y;
  1711.    return(floatbailout());
  1712. }
  1713.  
  1714. MarksMandelPwrFractal()
  1715. {
  1716.    LCMPLXtrig0(lold,lnew);
  1717.    LCMPLXmult(ltmp,lnew,lnew);
  1718.    lnew.x += longparm->x;
  1719.    lnew.y += longparm->y;
  1720.    return(longbailout());
  1721. }
  1722.  
  1723. /* I was coding Marksmandelpower and failed to use some temporary
  1724.    variables. The result was nice, and since my name is not on any fractal,
  1725.    I thought I would immortalize myself with this error!
  1726.         Tim Wegner */
  1727.  
  1728.  
  1729. TimsErrorfpFractal()
  1730. {
  1731.    CMPLXtrig0(old,new);
  1732.    new.x = new.x * tmp.x - new.y * tmp.y;
  1733.    new.y = new.x * tmp.y - new.y * tmp.x;
  1734.    new.x += floatparm->x;
  1735.    new.y += floatparm->y;
  1736.    return(floatbailout());
  1737. }
  1738. TimsErrorFractal()
  1739. {
  1740.    LCMPLXtrig0(lold,lnew);
  1741.    lnew.x = multiply(lnew.x,ltmp.x,bitshift)-multiply(lnew.y,ltmp.y,bitshift);
  1742.    lnew.y = multiply(lnew.x,ltmp.y,bitshift)-multiply(lnew.y,ltmp.x,bitshift);
  1743.    lnew.x += longparm->x;
  1744.    lnew.y += longparm->y;
  1745.    return(longbailout());
  1746. }
  1747.  
  1748. CirclefpFractal()
  1749. {
  1750.    extern int colors;
  1751.    extern int color;
  1752.    int i;
  1753.    i = param[0]*(tempsqrx+tempsqry);
  1754.    color = i&(colors-1);
  1755.    return(1);
  1756. }
  1757. /*
  1758. CirclelongFractal()
  1759. {
  1760.    extern int colors;
  1761.    extern int color;
  1762.    long i;
  1763.    i = multiply(lparm.x,(ltempsqrx+ltempsqry),bitshift);
  1764.    i = i >> bitshift;
  1765.    color = i&(colors-1);
  1766.    return(1);
  1767. }
  1768. */
  1769.  
  1770. /* -------------------------------------------------------------------- */
  1771. /*        Initialization (once per pixel) routines                        */
  1772. /* -------------------------------------------------------------------- */
  1773.  
  1774. #ifdef XFRACT
  1775. /* this code translated to asm - lives in newton.asm */
  1776. /* transform points with reciprocal function */
  1777. void invertz2(CMPLX *z)
  1778. {
  1779.    z->x = dx0[col]+dx1[row];
  1780.    z->y = dy0[row]+dy1[col];
  1781.    z->x -= f_xcenter; z->y -= f_ycenter;  /* Normalize values to center of circle */
  1782.  
  1783.    tempsqrx = sqr(z->x) + sqr(z->y);  /* Get old radius */
  1784.    if(fabs(tempsqrx) > FLT_MIN)
  1785.       tempsqrx = f_radius / tempsqrx;
  1786.    else
  1787.       tempsqrx = FLT_MAX;   /* a big number, but not TOO big */
  1788.    z->x *= tempsqrx;      z->y *= tempsqrx;     /* Perform inversion */
  1789.    z->x += f_xcenter; z->y += f_ycenter; /* Renormalize */
  1790. }
  1791. #endif
  1792.  
  1793. int long_julia_per_pixel()
  1794. {
  1795.    /* integer julia types */
  1796.    /* lambda */
  1797.    /* barnsleyj1 */
  1798.    /* barnsleyj2 */
  1799.    /* sierpinski */
  1800.    if(invert)
  1801.    {
  1802.       /* invert */
  1803.       invertz2(&old);
  1804.  
  1805.       /* watch out for overflow */
  1806.       if(sqr(old.x)+sqr(old.y) >= 127)
  1807.       {
  1808.      old.x = 8;  /* value to bail out in one iteration */
  1809.      old.y = 8;
  1810.       }
  1811.  
  1812.       /* convert to fudged longs */
  1813.       lold.x = old.x*fudge;
  1814.       lold.y = old.y*fudge;
  1815.    }
  1816.    else
  1817.    {
  1818.       lold.x = lx0[col]+lx1[row];
  1819.       lold.y = ly0[row]+ly1[col];
  1820.    }
  1821.    return(0);
  1822. }
  1823.  
  1824. int long_richard8_per_pixel()
  1825. {
  1826.     long_mandel_per_pixel();
  1827.     LCMPLXtrig1(*longparm,ltmp);
  1828.     LCMPLXmult(ltmp,lparm2,ltmp);
  1829.     return(1);
  1830. }
  1831.  
  1832. int long_mandel_per_pixel()
  1833. {
  1834.    /* integer mandel types */
  1835.    /* barnsleym1 */
  1836.    /* barnsleym2 */
  1837.    linit.x = lx0[col]+lx1[row];
  1838.  
  1839.    if(invert)
  1840.    {
  1841.       /* invert */
  1842.       invertz2(&init);
  1843.  
  1844.       /* watch out for overflow */
  1845.       if(sqr(init.x)+sqr(init.y) >= 127)
  1846.       {
  1847.      init.x = 8;  /* value to bail out in one iteration */
  1848.      init.y = 8;
  1849.       }
  1850.  
  1851.       /* convert to fudged longs */
  1852.       linit.x = init.x*fudge;
  1853.       linit.y = init.y*fudge;
  1854.    }
  1855.  
  1856.    if(useinitorbit == 1)
  1857.       lold = linitorbit;
  1858.    else
  1859.       lold = linit;
  1860.  
  1861.    lold.x += lparm.x;     /* initial pertubation of parameters set */
  1862.    lold.y += lparm.y;
  1863.    return(1); /* 1st iteration has been done */
  1864. }
  1865.  
  1866. int julia_per_pixel()
  1867. {
  1868.    /* julia */
  1869.  
  1870.    if(invert)
  1871.    {
  1872.       /* invert */
  1873.       invertz2(&old);
  1874.  
  1875.       /* watch out for overflow */
  1876.       if(bitshift <= 24)
  1877.      if (sqr(old.x)+sqr(old.y) >= 127)
  1878.      {
  1879.         old.x = 8;    /* value to bail out in one iteration */
  1880.         old.y = 8;
  1881.      }
  1882.       if(bitshift >  24)
  1883.      if (sqr(old.x)+sqr(old.y) >= 4.0)
  1884.      {
  1885.         old.x = 2;    /* value to bail out in one iteration */
  1886.         old.y = 2;
  1887.      }
  1888.  
  1889.       /* convert to fudged longs */
  1890.       lold.x = old.x*fudge;
  1891.       lold.y = old.y*fudge;
  1892.    }
  1893.    else
  1894.    {
  1895.       lold.x = lx0[col]+lx1[row];
  1896.       lold.y = ly0[row]+ly1[col];
  1897.    }
  1898.  
  1899.    ltempsqrx = multiply(lold.x, lold.x, bitshift);
  1900.    ltempsqry = multiply(lold.y, lold.y, bitshift);
  1901.    ltmp = lold;
  1902.    return(0);
  1903. }
  1904.  
  1905. marks_mandelpwr_per_pixel()
  1906. {
  1907.    mandel_per_pixel();
  1908.    ltmp = lold;
  1909.    ltmp.x -= fudge;
  1910.    LCMPLXpwr(lold,ltmp,ltmp);
  1911.    return(1);
  1912. }
  1913.  
  1914. int mandel_per_pixel()
  1915. {
  1916.    /* mandel */
  1917.  
  1918.    if(invert)
  1919.    {
  1920.       invertz2(&init);
  1921.  
  1922.       /* watch out for overflow */
  1923.       if(bitshift <= 24)
  1924.      if (sqr(init.x)+sqr(init.y) >= 127)
  1925.      {
  1926.         init.x = 8;  /* value to bail out in one iteration */
  1927.         init.y = 8;
  1928.      }
  1929.       if(bitshift >  24)
  1930.      if (sqr(init.x)+sqr(init.y) >= 4)
  1931.      {
  1932.         init.x = 2;  /* value to bail out in one iteration */
  1933.         init.y = 2;
  1934.      }
  1935.  
  1936.       /* convert to fudged longs */
  1937.       linit.x = init.x*fudge;
  1938.       linit.y = init.y*fudge;
  1939.    }
  1940.    else
  1941.       linit.x = lx0[col]+lx1[row];
  1942.    switch (fractype)
  1943.      {
  1944.     case MANDELLAMBDA:        /* Critical Value 0.5 + 0.0i  */
  1945.         lold.x = FgHalf;
  1946.         lold.y = 0;
  1947.         break;
  1948.     default:
  1949.         lold = linit;
  1950.         break;
  1951.       }
  1952.  
  1953.    /* alter init value */
  1954.    if(useinitorbit == 1)
  1955.       lold = linitorbit;
  1956.    else if(useinitorbit == 2)
  1957.       lold = linit;
  1958.  
  1959.    if(inside == -60 || inside == -61)
  1960.    {
  1961.       /* kludge to match "Beauty of Fractals" picture since we start
  1962.      Mandelbrot iteration with init rather than 0 */
  1963.       lold.x = lparm.x; /* initial pertubation of parameters set */
  1964.       lold.y = lparm.y;
  1965.       color = -1;
  1966.    }
  1967.    else
  1968.    {
  1969.       lold.x += lparm.x; /* initial pertubation of parameters set */
  1970.       lold.y += lparm.y;
  1971.    }
  1972.    ltmp = linit; /* for spider */
  1973.    ltempsqrx = multiply(lold.x, lold.x, bitshift);
  1974.    ltempsqry = multiply(lold.y, lold.y, bitshift);
  1975.    return(1); /* 1st iteration has been done */
  1976. }
  1977.  
  1978.  
  1979. int marksmandel_per_pixel()
  1980. {
  1981.    /* marksmandel */
  1982.  
  1983.    if(invert)
  1984.    {
  1985.       invertz2(&init);
  1986.  
  1987.       /* watch out for overflow */
  1988.       if(sqr(init.x)+sqr(init.y) >= 127)
  1989.       {
  1990.      init.x = 8;  /* value to bail out in one iteration */
  1991.      init.y = 8;
  1992.       }
  1993.  
  1994.       /* convert to fudged longs */
  1995.       linit.x = init.x*fudge;
  1996.       linit.y = init.y*fudge;
  1997.    }
  1998.    else
  1999.       linit.x = lx0[col]+lx1[row];
  2000.  
  2001.    if(useinitorbit == 1)
  2002.       lold = linitorbit;
  2003.    else
  2004.       lold = linit;
  2005.  
  2006.    lold.x += lparm.x;     /* initial pertubation of parameters set */
  2007.    lold.y += lparm.y;
  2008.  
  2009.    if(c_exp > 3)
  2010.       lcpower(&lold,c_exp-1,&lcoefficient,bitshift);
  2011.    else if(c_exp == 3) {
  2012.       lcoefficient.x = multiply(lold.x, lold.x, bitshift)
  2013.      - multiply(lold.y, lold.y, bitshift);
  2014.       lcoefficient.y = multiply(lold.x, lold.y, bitshiftless1);
  2015.    }
  2016.    else if(c_exp == 2)
  2017.       lcoefficient = lold;
  2018.    else if(c_exp < 2) {
  2019.       lcoefficient.x = 1L << bitshift;
  2020.       lcoefficient.y = 0L;
  2021.    }
  2022.  
  2023.    ltempsqrx = multiply(lold.x, lold.x, bitshift);
  2024.    ltempsqry = multiply(lold.y, lold.y, bitshift);
  2025.    return(1); /* 1st iteration has been done */
  2026. }
  2027.  
  2028. marks_mandelpwrfp_per_pixel()
  2029. {
  2030.    mandelfp_per_pixel();
  2031.    tmp = old;
  2032.    tmp.x -= 1;
  2033.    CMPLXpwr(old,tmp,tmp);
  2034.    return(1);
  2035. }
  2036.  
  2037. int mandelfp_per_pixel()
  2038. {
  2039.    /* floating point mandelbrot */
  2040.    /* mandelfp */
  2041.  
  2042.    if(invert)
  2043.       invertz2(&init);
  2044.    else
  2045.       init.x = dx0[col]+dx1[row];
  2046.     switch (fractype)
  2047.       {
  2048.     case MAGNET2M:
  2049.         FloatPreCalcMagnet2();
  2050.     case MAGNET1M:         /* Crit Val Zero both, but neither   */
  2051.         old.x = old.y = 0.0; /* is of the form f(Z,C) = Z*g(Z)+C  */
  2052.         break;
  2053.     case MANDELLAMBDAFP:        /* Critical Value 0.5 + 0.0i  */
  2054.         old.x = 0.5;
  2055.         old.y = 0.0;
  2056.         break;
  2057.     default:
  2058.         old = init;
  2059.         break;
  2060.       }
  2061.  
  2062.    /* alter init value */
  2063.    if(useinitorbit == 1)
  2064.       old = initorbit;
  2065.    else if(useinitorbit == 2)
  2066.       old = init;
  2067.  
  2068.    if(inside == -60 || inside == -61)
  2069.    {
  2070.       /* kludge to match "Beauty of Fractals" picture since we start
  2071.      Mandelbrot iteration with init rather than 0 */
  2072.       old.x = parm.x; /* initial pertubation of parameters set */
  2073.       old.y = parm.y;
  2074.       color = -1;
  2075.    }
  2076.    else
  2077.    {
  2078.      old.x += parm.x;
  2079.      old.y += parm.y;
  2080.    }
  2081.    tmp = init; /* for spider */
  2082.    tempsqrx = sqr(old.x);  /* precalculated value for regular Mandelbrot */
  2083.    tempsqry = sqr(old.y);
  2084.    return(1); /* 1st iteration has been done */
  2085. }
  2086.  
  2087. int juliafp_per_pixel()
  2088. {
  2089.    /* floating point julia */
  2090.    /* juliafp */
  2091.    if(invert)
  2092.       invertz2(&old);
  2093.    else
  2094.    {
  2095.      old.x = dx0[col]+dx1[row];
  2096.      old.y = dy0[row]+dy1[col];
  2097.    }
  2098.    tempsqrx = sqr(old.x);  /* precalculated value for regular Julia */
  2099.    tempsqry = sqr(old.y);
  2100.    tmp = old;
  2101.    return(0);
  2102. }
  2103.  
  2104. int MPCjulia_per_pixel()
  2105. {
  2106.    /* floating point julia */
  2107.    /* juliafp */
  2108.    if(invert)
  2109.       invertz2(&old);
  2110.    else
  2111.    {
  2112.      old.x = dx0[col]+dx1[row];
  2113.      old.y = dy0[row]+dy1[col];
  2114.    }
  2115.    mpcold.x = *pd2MP(old.x);
  2116.    mpcold.y = *pd2MP(old.y);
  2117.    return(0);
  2118. }
  2119.  
  2120. otherrichard8fp_per_pixel()
  2121. {
  2122.     othermandelfp_per_pixel();
  2123.     CMPLXtrig1(*floatparm,tmp);
  2124.     CMPLXmult(tmp,parm2,tmp);
  2125.     return(1);
  2126. }
  2127.  
  2128. int othermandelfp_per_pixel()
  2129. {
  2130.    if(invert)
  2131.       invertz2(&init);
  2132.    else
  2133.       init.x = dx0[col]+dx1[row];
  2134.  
  2135.    if(useinitorbit == 1)
  2136.       old = initorbit;
  2137.    else
  2138.       old = init;
  2139.  
  2140.    old.x += parm.x;     /* initial pertubation of parameters set */
  2141.    old.y += parm.y;
  2142.  
  2143.    return(1); /* 1st iteration has been done */
  2144. }
  2145.  
  2146. int otherjuliafp_per_pixel()
  2147. {
  2148.    if(invert)
  2149.       invertz2(&old);
  2150.    else
  2151.    {
  2152.       old.x = dx0[col]+dx1[row];
  2153.       old.y = dy0[row]+dy1[col];
  2154.    }
  2155.    return(0);
  2156. }
  2157.  
  2158. int trigmandelfp_per_pixel()
  2159. {
  2160.    if(invert)
  2161.       invertz2(&init);
  2162.    else
  2163.       init.x = dx0[col]+dx1[row];
  2164.  
  2165.    if(useinitorbit == 1)
  2166.       old = initorbit;
  2167.    else
  2168.       old = init;
  2169.  
  2170.    old.x += parm.x;     /* initial pertubation of parameters set */
  2171.    old.y += parm.y;
  2172.    CMPLXtrig0(old,old);
  2173.    return(1); /* 1st iteration has been done */
  2174. }
  2175.  
  2176. int trigjuliafp_per_pixel()
  2177. {
  2178.    /* for tetrated types */
  2179.    if(invert)
  2180.       invertz2(&old);
  2181.    else
  2182.    {
  2183.       old.x = dx0[col]+dx1[row];
  2184.       old.y = dy0[row]+dy1[col];
  2185.    }
  2186.    CMPLXtrig0(old,old);
  2187.    return(0);
  2188. }
  2189.  
  2190. int trigXtrigmandelfp_per_pixel()
  2191. {
  2192.    if(invert)
  2193.       invertz2(&init);
  2194.    else
  2195.       init.x = dx0[col]+dx1[row];
  2196.  
  2197.    if(useinitorbit == 1)
  2198.       old = initorbit;
  2199.    else
  2200.       old = init;
  2201.  
  2202.    old.x += parm.x;     /* initial pertubation of parameters set */
  2203.    old.y += parm.y;
  2204.    CMPLXtrig0(old,tmp);
  2205.    CMPLXtrig1(old,tmp2);
  2206.    CMPLXmult(tmp,tmp2,old);
  2207.    return(1); /* 1st iteration has been done */
  2208. }
  2209.  
  2210. int trigXtrigjuliafp_per_pixel()
  2211. {
  2212.    if(invert)
  2213.       invertz2(&old);
  2214.    else
  2215.    {
  2216.       old.x = dx0[col]+dx1[row];
  2217.       old.y = dy0[row]+dy1[col];
  2218.    }
  2219.    CMPLXtrig0(old,tmp);
  2220.    CMPLXtrig1(old,tmp2);
  2221.    CMPLXmult(tmp,tmp2,old);
  2222.    return(0);
  2223. }
  2224.  
  2225. int MarksCplxMandperp(void)
  2226. {
  2227.    if(invert)
  2228.       invertz2(&init);
  2229.    else
  2230.       init.x = dx0[col]+dx1[row];
  2231.    old.x = init.x + parm.x; /* initial pertubation of parameters set */
  2232.    old.y = init.y + parm.y;
  2233.    tempsqrx = sqr(old.x);  /* precalculated value */
  2234.    tempsqry = sqr(old.y);
  2235.    Coefficient = ComplexPower(init, pwr);
  2236.    return(1);
  2237. }
  2238.  
  2239. /* -------------------------------------------------------------------- */
  2240. /*        Setup (once per fractal image) routines         */
  2241. /* -------------------------------------------------------------------- */
  2242.  
  2243. MandelSetup()        /* Mandelbrot Routine */
  2244. {
  2245. #ifndef XFRACT
  2246.    if (debugflag != 90 && ! invert && decomp[0] == 0 && rqlim <= 4.0
  2247.        && bitshift == 29 && potflag == 0
  2248.        && biomorph == -1 && inside > -59 && outside == -1
  2249.        && useinitorbit != 1)
  2250.       calctype = calcmand; /* the normal case - use CALCMAND */
  2251.    else
  2252. #endif
  2253.    {
  2254.       /* special case: use the main processing loop */
  2255.       calctype = StandardFractal;
  2256.       longparm = &linit;
  2257.    }
  2258.    return(1);
  2259. }
  2260.  
  2261. JuliaSetup()        /* Julia Routine */
  2262. {
  2263.    if (debugflag != 90 && ! invert && decomp[0] == 0 && rqlim <= 4.0
  2264.        && bitshift == 29 && potflag == 0
  2265.        && biomorph == -1 && inside > -59 && outside == -1
  2266.        && !finattract)
  2267.       calctype = calcmand; /* the normal case - use CALCMAND */
  2268.    else
  2269.    {
  2270.       /* special case: use the main processing loop */
  2271.       calctype = StandardFractal;
  2272.       longparm = &lparm;
  2273.       get_julia_attractor (0.0, 0.0);    /* another attractor? */
  2274.    }
  2275.    return(1);
  2276. }
  2277.  
  2278. NewtonSetup()        /* Newton/NewtBasin Routines */
  2279. {
  2280.    int i;
  2281.    extern int basin;
  2282.    extern int fpu;
  2283.    if (debugflag != 1010)
  2284.    {
  2285.       if(fpu != 0)
  2286.       {
  2287.      if(fractype == MPNEWTON)
  2288.         fractype = NEWTON;
  2289.      else if(fractype == MPNEWTBASIN)
  2290.         fractype = NEWTBASIN;
  2291.       }
  2292.       else
  2293.       {
  2294.      if(fractype == NEWTON)
  2295.            fractype = MPNEWTON;
  2296.      else if(fractype == NEWTBASIN)
  2297.            fractype = MPNEWTBASIN;
  2298.       }
  2299.       curfractalspecific = &fractalspecific[fractype];
  2300.    }
  2301.  
  2302.    /* set up table of roots of 1 along unit circle */
  2303.    degree = (int)parm.x;
  2304.    if(degree < 2)
  2305.       degree = 3;   /* defaults to 3, but 2 is possible */
  2306.    root = 1;
  2307.  
  2308.    /* precalculated values */
  2309.    roverd    = (double)root / (double)degree;
  2310.    d1overd    = (double)(degree - 1) / (double)degree;
  2311.    maxcolor    = 0;
  2312.    threshold    = .3*PI/degree; /* less than half distance between roots */
  2313.    if (fractype == MPNEWTON || fractype == MPNEWTBASIN) {
  2314.       mproverd       = *pd2MP(roverd);
  2315.       mpd1overd    = *pd2MP(d1overd);
  2316.       mpthreshold  = *pd2MP(threshold);
  2317.       mpone       = *pd2MP(1.0);
  2318.    }
  2319.  
  2320.    floatmin = FLT_MIN;
  2321.    floatmax = FLT_MAX;
  2322.  
  2323.    basin = 0;
  2324.    if(roots != staticroots) {
  2325.       free(roots);
  2326.       roots = staticroots;
  2327.    }
  2328.  
  2329.    if (fractype==NEWTBASIN)
  2330.    {
  2331.       if(parm.y)
  2332.      basin = 2; /*stripes */
  2333.       else
  2334.      basin = 1;
  2335.       if(degree > 16)
  2336.       {
  2337.      if((roots=(CMPLX *)malloc(degree*sizeof(CMPLX)))==NULL)
  2338.      {
  2339.         roots = staticroots;
  2340.         degree = 16;
  2341.      }
  2342.       }
  2343.       else
  2344.      roots = staticroots;
  2345.  
  2346.       /* list of roots to discover where we converged for newtbasin */
  2347.       for(i=0;i<degree;i++)
  2348.       {
  2349.      roots[i].x = cos(i*PI*2.0/(double)degree);
  2350.      roots[i].y = sin(i*PI*2.0/(double)degree);
  2351.       }
  2352.    }
  2353.    else if (fractype==MPNEWTBASIN)
  2354.    {
  2355.      if(parm.y)
  2356.      basin = 2; /*stripes */
  2357.       else
  2358.      basin = 1;
  2359.  
  2360.       if(degree > 16)
  2361.       {
  2362.      if((MPCroots=(struct MPC *)malloc(degree*sizeof(struct MPC)))==NULL)
  2363.      {
  2364.         MPCroots = (struct MPC *)staticroots;
  2365.         degree = 16;
  2366.      }
  2367.       }
  2368.       else
  2369.      MPCroots = (struct MPC *)staticroots;
  2370.  
  2371.       /* list of roots to discover where we converged for newtbasin */
  2372.       for(i=0;i<degree;i++)
  2373.       {
  2374.      MPCroots[i].x = *pd2MP(cos(i*PI*2.0/(double)degree));
  2375.      MPCroots[i].y = *pd2MP(sin(i*PI*2.0/(double)degree));
  2376.       }
  2377.    }
  2378.  
  2379.    if (degree%4 == 0)
  2380.       symmetry = XYAXIS;
  2381.    else
  2382.       symmetry = XAXIS;
  2383.  
  2384.    calctype=StandardFractal;
  2385.    if (fractype == MPNEWTON || fractype == MPNEWTBASIN)
  2386.       setMPfunctions();
  2387.    return(1);
  2388. }
  2389.  
  2390.  
  2391. StandaloneSetup()
  2392. {
  2393.    timer(0,curfractalspecific->calctype);
  2394.    return(0);        /* effectively disable solid-guessing */
  2395. }
  2396.  
  2397. UnitySetup()
  2398. {
  2399.    periodicitycheck = 0;
  2400.    FgOne = (1L << bitshift);
  2401.    FgTwo = FgOne + FgOne;
  2402.    return(1);
  2403. }
  2404.  
  2405. MandelfpSetup()
  2406. {
  2407.    c_exp = param[2];
  2408.    pwr.x = param[2] - 1.0;
  2409.    pwr.y = param[3];
  2410.    floatparm = &init;
  2411.    switch (fractype)
  2412.    {
  2413.    case MANDELFP:
  2414.     /*
  2415.        floating point code could probably be altered to handle many of
  2416.        the situations that otherwise are using StandardFractal().
  2417.        calcmandfp() can currently handle invert, any rqlim, potflag
  2418.        zmag, epsilon cross, and all the current outside options
  2419.                              Wes Loewer 11/03/91
  2420.     */
  2421.     if (debugflag != 90
  2422.         && !distest
  2423.         && decomp[0] == 0
  2424.         && biomorph == -1
  2425.         && (inside >= -1 || inside == -59 || inside == -100)
  2426.         /* uncomment this next line if more outside options are added */
  2427.         /* && outside >= -5 */
  2428.         && useinitorbit != 1)
  2429.     {
  2430.        calctype = calcmandfp; /* the normal case - use calcmandfp */
  2431.        calcmandfpasmstart();
  2432.     }
  2433.     else
  2434.     {
  2435.        /* special case: use the main processing loop */
  2436.        calctype = StandardFractal;
  2437.     }
  2438.     break;
  2439.    case FPMANDELZPOWER:
  2440.       if(c_exp < 1)
  2441.          c_exp = 1;
  2442.       if(c_exp & 1) /* odd exponents */
  2443.          symmetry = XYAXIS_NOPARM;
  2444.       if(param[3] != 0 || (double)c_exp != param[2])
  2445.          symmetry = NOSYM;
  2446.       if(param[4] == 0.0 && debugflag != 6000 && (double)c_exp == param[2])
  2447.           fractalspecific[fractype].orbitcalc = floatZpowerFractal;
  2448.       else
  2449.           fractalspecific[fractype].orbitcalc = floatCmplxZpowerFractal;
  2450.       break;
  2451.    case MAGNET1M:
  2452.    case MAGNET2M:
  2453.       attr[0].x = 1.0;        /* 1.0 + 0.0i always attracts */
  2454.       attr[0].y = 0.0;        /* - both MAGNET1 and MAGNET2 */
  2455.       attractors = 1;
  2456.       break;
  2457.    case SPIDERFP:
  2458.       if(periodicitycheck==1) /* if not user set */
  2459.      periodicitycheck=4;
  2460.       break;
  2461.    case MANDELEXP:
  2462.       symmetry = XAXIS_NOPARM;
  2463.       break;
  2464.    default:
  2465.       break;
  2466.    }
  2467.    return(1);
  2468. }
  2469.  
  2470. JuliafpSetup()
  2471. {
  2472.    c_exp = param[2];
  2473.    floatparm = &parm;
  2474.    if(fractype==COMPLEXMARKSJUL)
  2475.    {
  2476.       pwr.x = param[2] - 1.0;
  2477.       pwr.y = param[3];
  2478.       Coefficient = ComplexPower(*floatparm, pwr);
  2479.    }
  2480.    switch (fractype)
  2481.    {
  2482.    case JULIAFP:
  2483.     /*
  2484.        floating point code could probably be altered to handle many of
  2485.        the situations that otherwise are using StandardFractal().
  2486.        calcmandfp() can currently handle invert, any rqlim, potflag
  2487.        zmag, epsilon cross, and all the current outside options
  2488.                              Wes Loewer 11/03/91
  2489.     */
  2490.     if (debugflag != 90
  2491.         && !distest
  2492.         && decomp[0] == 0
  2493.         && biomorph == -1
  2494.         && (inside >= -1 || inside == -59 || inside == -100)
  2495.         /* uncomment this next line if more outside options are added */
  2496.         /* && outside >= -5 */
  2497.         && useinitorbit != 1
  2498.         && !finattract)
  2499.     {
  2500.        calctype = calcmandfp; /* the normal case - use calcmandfp */
  2501.        calcmandfpasmstart();
  2502.     }
  2503.     else
  2504.     {
  2505.        /* special case: use the main processing loop */
  2506.        calctype = StandardFractal;
  2507.        get_julia_attractor (0.0, 0.0);   /* another attractor? */
  2508.     }
  2509.     break;
  2510.    case FPJULIAZPOWER:
  2511.       if((c_exp & 1) || param[3] != 0.0 || (double)c_exp != param[2] )
  2512.          symmetry = NOSYM;
  2513.       else if(c_exp < 1)
  2514.          c_exp = 1;
  2515.       if(param[4] == 0.0 && debugflag != 6000 && (double)c_exp == param[2])
  2516.           fractalspecific[fractype].orbitcalc = floatZpowerFractal;
  2517.       else
  2518.           fractalspecific[fractype].orbitcalc = floatCmplxZpowerFractal;
  2519.       break;
  2520.    case MAGNET2J:
  2521.       FloatPreCalcMagnet2();
  2522.    case MAGNET1J:
  2523.       attr[0].x = 1.0;        /* 1.0 + 0.0i always attracts */
  2524.       attr[0].y = 0.0;        /* - both MAGNET1 and MAGNET2 */
  2525.       attractors = 1;
  2526.       get_julia_attractor (0.0, 0.0);    /* another attractor? */
  2527.       break;
  2528.    case LAMBDAFP:
  2529.       get_julia_attractor (0.0, 0.0);    /* another attractor? */
  2530.       get_julia_attractor (0.5, 0.0);    /* another attractor? */
  2531.       break;
  2532.    case LAMBDAEXP:
  2533.       if(parm.y == 0.0)
  2534.      symmetry=XAXIS;
  2535.       get_julia_attractor (0.0, 0.0);    /* another attractor? */
  2536.       break;
  2537.    default:
  2538.       get_julia_attractor (0.0, 0.0);    /* another attractor? */
  2539.       break;
  2540.    }
  2541.    return(1);
  2542. }
  2543.  
  2544. MandellongSetup()
  2545. {
  2546.    FgHalf = fudge >> 1;
  2547.    c_exp = param[2];
  2548.    if(fractype==MARKSMANDEL && c_exp < 1)
  2549.       c_exp = 1;
  2550.    if(fractype==LMANDELZPOWER && c_exp < 1)
  2551.       c_exp = 1;
  2552.    if((fractype==MARKSMANDEL   && !(c_exp & 1)) ||
  2553.        (fractype==LMANDELZPOWER && c_exp & 1))
  2554.       symmetry = XYAXIS_NOPARM;    /* odd exponents */
  2555.    if((fractype==MARKSMANDEL && (c_exp & 1)) || fractype==LMANDELEXP)
  2556.       symmetry = XAXIS_NOPARM;
  2557.    if(fractype==SPIDER && periodicitycheck==1)
  2558.       periodicitycheck=4;
  2559.    longparm = &linit;
  2560.    if(fractype==LMANDELZPOWER)
  2561.    {
  2562.       if(param[4] == 0.0 && debugflag != 6000  && (double)c_exp == param[2])
  2563.           fractalspecific[fractype].orbitcalc = longZpowerFractal;
  2564.       else
  2565.           fractalspecific[fractype].orbitcalc = longCmplxZpowerFractal;
  2566.       if(param[3] != 0 || (double)c_exp != param[2] )
  2567.          symmetry = NOSYM;
  2568.     }
  2569.  
  2570.    return(1);
  2571. }
  2572.  
  2573. JulialongSetup()
  2574. {
  2575.    c_exp = param[2];
  2576.    longparm = &lparm;
  2577.    switch (fractype)
  2578.    {
  2579.    case LJULIAZPOWER:
  2580.       if((c_exp & 1) || param[3] != 0.0 || (double)c_exp != param[2])
  2581.          symmetry = NOSYM;
  2582.       else if(c_exp < 1)
  2583.          c_exp = 1;
  2584.       if(param[4] == 0.0 && debugflag != 6000 && (double)c_exp == param[2])
  2585.           fractalspecific[fractype].orbitcalc = longZpowerFractal;
  2586.       else
  2587.           fractalspecific[fractype].orbitcalc = longCmplxZpowerFractal;
  2588.       break;
  2589.    case LAMBDA:
  2590.       get_julia_attractor (0.0, 0.0);    /* another attractor? */
  2591.       get_julia_attractor (0.5, 0.0);    /* another attractor? */
  2592.       break;
  2593.    case LLAMBDAEXP:
  2594.       if(lparm.y == 0)
  2595.      symmetry = XAXIS;
  2596.       break;
  2597.    default:
  2598.       get_julia_attractor (0.0, 0.0);    /* another attractor? */
  2599.       break;
  2600.    }
  2601.    return(1);
  2602. }
  2603.  
  2604. TrigPlusSqrlongSetup()
  2605. {
  2606.    curfractalspecific->per_pixel =  julia_per_pixel;
  2607.    curfractalspecific->orbitcalc =  TrigPlusSqrFractal;
  2608.    if(lparm.x == fudge && lparm.y == 0L && lparm2.y == 0L && debugflag != 90)
  2609.    {
  2610.       if(lparm2.x == fudge)       /* Scott variant */
  2611.      curfractalspecific->orbitcalc =  ScottTrigPlusSqrFractal;
  2612.       else if(lparm2.x == -fudge)  /* Skinner variant */
  2613.      curfractalspecific->orbitcalc =  SkinnerTrigSubSqrFractal;
  2614.    }
  2615.    return(JulialongSetup());
  2616. }
  2617.  
  2618. TrigPlusSqrfpSetup()
  2619. {
  2620.    curfractalspecific->per_pixel =  juliafp_per_pixel;
  2621.    curfractalspecific->orbitcalc =  TrigPlusSqrfpFractal;
  2622.    if(parm.x == 1.0 && parm.y == 0.0 && parm2.y == 0.0 && debugflag != 90)
  2623.    {
  2624.       if(parm2.x == 1.0)    /* Scott variant */
  2625.      curfractalspecific->orbitcalc =  ScottTrigPlusSqrfpFractal;
  2626.       else if(parm2.x == -1.0)    /* Skinner variant */
  2627.      curfractalspecific->orbitcalc =  SkinnerTrigSubSqrfpFractal;
  2628.    }
  2629.    return(JuliafpSetup());
  2630. }
  2631.  
  2632. TrigPlusTriglongSetup()
  2633. {
  2634.    FnPlusFnSym();
  2635.    if(trigndx[1] == SQR)
  2636.       return(TrigPlusSqrlongSetup());
  2637.    curfractalspecific->per_pixel =  long_julia_per_pixel;
  2638.    curfractalspecific->orbitcalc =  TrigPlusTrigFractal;
  2639.    if(lparm.x == fudge && lparm.y == 0L && lparm2.y == 0L && debugflag != 90)
  2640.    {
  2641.       if(lparm2.x == fudge)       /* Scott variant */
  2642.      curfractalspecific->orbitcalc =  ScottTrigPlusTrigFractal;
  2643.       else if(lparm2.x == -fudge)  /* Skinner variant */
  2644.      curfractalspecific->orbitcalc =  SkinnerTrigSubTrigFractal;
  2645.    }
  2646.    return(JulialongSetup());
  2647. }
  2648.  
  2649. TrigPlusTrigfpSetup()
  2650. {
  2651.    FnPlusFnSym();
  2652.    if(trigndx[1] == SQR)
  2653.       return(TrigPlusSqrfpSetup());
  2654.    curfractalspecific->per_pixel =  otherjuliafp_per_pixel;
  2655.    curfractalspecific->orbitcalc =  TrigPlusTrigfpFractal;
  2656.    if(parm.x == 1.0 && parm.y == 0.0 && parm2.y == 0.0 && debugflag != 90)
  2657.    {
  2658.       if(parm2.x == 1.0)    /* Scott variant */
  2659.      curfractalspecific->orbitcalc =  ScottTrigPlusTrigfpFractal;
  2660.       else if(parm2.x == -1.0)    /* Skinner variant */
  2661.      curfractalspecific->orbitcalc =  SkinnerTrigSubTrigfpFractal;
  2662.    }
  2663.    return(JuliafpSetup());
  2664. }
  2665.  
  2666. FnPlusFnSym() /* set symmetry matrix for fn+fn type */
  2667. {
  2668.    static char far fnplusfn[7][7] =
  2669.    {/* fn2 ->sin     cos    sinh    cosh   sqr      exp     log  */
  2670.    /* fn1 */
  2671.    /* sin */ {PI_SYM,XAXIS, XYAXIS, XAXIS, XAXIS, XAXIS, XAXIS},
  2672.    /* cos */ {XAXIS, PI_SYM,XAXIS,  XYAXIS,XAXIS, XAXIS, XAXIS},
  2673.    /* sinh*/ {XYAXIS,XAXIS, XYAXIS, XAXIS, XAXIS, XAXIS, XAXIS},
  2674.    /* cosh*/ {XAXIS, XYAXIS,XAXIS,  XYAXIS,XAXIS, XAXIS, XAXIS},
  2675.    /* sqr */ {XAXIS, XYAXIS,XAXIS,  XAXIS, XYAXIS,XAXIS, XAXIS},
  2676.    /* exp */ {XAXIS, XAXIS, XAXIS,  XAXIS, XAXIS, XAXIS, XAXIS},
  2677.    /* log */ {XAXIS, XAXIS, XAXIS,  XAXIS, XAXIS, XAXIS, XYAXIS}
  2678.    };
  2679.    if(parm.y == 0.0 && parm2.y == 0.0)
  2680.       symmetry = fnplusfn[trigndx[0]][trigndx[1]];
  2681.    else
  2682.       symmetry = NOSYM;
  2683.    return(0);
  2684. }
  2685.  
  2686. ZXTrigPlusZSetup()
  2687. {
  2688.    static char far ZXTrigPlusZSym1[] =
  2689.    /* fn1 ->  sin   cos    sinh  cosh    sqr    exp   log  */
  2690.          {XAXIS,XYAXIS,XAXIS,XYAXIS,XYAXIS,XAXIS,XAXIS};
  2691.    static char far ZXTrigPlusZSym2[] =
  2692.    /* fn1 ->  sin   cos    sinh  cosh    sqr    exp   log  */
  2693.          {NOSYM,ORIGIN,NOSYM,ORIGIN,XYAXIS,NOSYM,NOSYM};
  2694.    if(param[1] == 0.0 && param[3] == 0.0)
  2695.       symmetry = ZXTrigPlusZSym1[trigndx[0]];
  2696.    else
  2697.       symmetry = ZXTrigPlusZSym2[trigndx[0]];
  2698.  
  2699.    if(curfractalspecific->isinteger)
  2700.    {
  2701.       curfractalspecific->orbitcalc =  ZXTrigPlusZFractal;
  2702.       if(lparm.x == fudge && lparm.y == 0L && lparm2.y == 0L && debugflag != 90)
  2703.       {
  2704.      if(lparm2.x == fudge)       /* Scott variant */
  2705.          curfractalspecific->orbitcalc =  ScottZXTrigPlusZFractal;
  2706.      else if(lparm2.x == -fudge)  /* Skinner variant */
  2707.          curfractalspecific->orbitcalc =  SkinnerZXTrigSubZFractal;
  2708.       }
  2709.       return(JulialongSetup());
  2710.    }
  2711.    else
  2712.    {
  2713.       curfractalspecific->orbitcalc =  ZXTrigPlusZfpFractal;
  2714.       if(parm.x == 1.0 && parm.y == 0.0 && parm2.y == 0.0 && debugflag != 90)
  2715.       {
  2716.      if(parm2.x == 1.0)    /* Scott variant */
  2717.          curfractalspecific->orbitcalc =  ScottZXTrigPlusZfpFractal;
  2718.      else if(parm2.x == -1.0)    /* Skinner variant */
  2719.          curfractalspecific->orbitcalc =  SkinnerZXTrigSubZfpFractal;
  2720.       }
  2721.    }
  2722.    return(JuliafpSetup());
  2723. }
  2724.  
  2725. LambdaTrigSetup()
  2726. {
  2727.    int isinteger;
  2728.    if((isinteger = curfractalspecific->isinteger))
  2729.       curfractalspecific->orbitcalc =  LambdaTrigFractal;
  2730.    else
  2731.       curfractalspecific->orbitcalc =  LambdaTrigfpFractal;
  2732.    switch(trigndx[0])
  2733.    {
  2734.    case SIN:
  2735.    case COS:
  2736.       symmetry = PI_SYM;
  2737.       if(isinteger)
  2738.      curfractalspecific->orbitcalc =  LambdaTrigFractal1;
  2739.       else
  2740.      curfractalspecific->orbitcalc =  LambdaTrigfpFractal1;
  2741.       break;
  2742.    case SINH:
  2743.    case COSH:
  2744.       symmetry = ORIGIN;
  2745.       if(isinteger)
  2746.      curfractalspecific->orbitcalc =  LambdaTrigFractal2;
  2747.       else
  2748.      curfractalspecific->orbitcalc =  LambdaTrigfpFractal2;
  2749.       break;
  2750.    case SQR:
  2751.       symmetry = ORIGIN;
  2752.       break;
  2753.    case EXP:
  2754.       if(isinteger)
  2755.      curfractalspecific->orbitcalc =  LongLambdaexponentFractal;
  2756.       else
  2757.      curfractalspecific->orbitcalc =  LambdaexponentFractal;
  2758.       symmetry = XAXIS;
  2759.       break;
  2760.    case LOG:
  2761.       symmetry = NOSYM;
  2762.       break;
  2763.    }
  2764.    if(isinteger)
  2765.       return(JulialongSetup());
  2766.    else
  2767.       return(JuliafpSetup());
  2768. }
  2769.  
  2770. JuliafnPlusZsqrdSetup()
  2771. {
  2772.    static char far fnpluszsqrd[] =
  2773.    /* fn1 ->  sin   cos    sinh  cosh    sqr    exp   log  */
  2774.    /* sin */ {NOSYM,ORIGIN,NOSYM,ORIGIN,ORIGIN,NOSYM,NOSYM};
  2775.  
  2776.    symmetry = fnpluszsqrd[trigndx[0]];
  2777.    if(curfractalspecific->isinteger)
  2778.       return(JulialongSetup());
  2779.    else
  2780.       return(JuliafpSetup());
  2781. }
  2782.  
  2783. SqrTrigSetup()
  2784. {
  2785.    static char far SqrTrigSym[] =
  2786.    /* fn1 ->  sin    cos    sinh   cosh   sqr     exp   log  */
  2787.          {PI_SYM,PI_SYM,XYAXIS,XYAXIS,XYAXIS,XAXIS,XAXIS};
  2788.    symmetry = SqrTrigSym[trigndx[0]];
  2789.    if(curfractalspecific->isinteger)
  2790.       return(JulialongSetup());
  2791.    else
  2792.       return(JuliafpSetup());
  2793. }
  2794.  
  2795. FnXFnSetup()
  2796. {
  2797.    static char far fnxfn[7][7] =
  2798.    {/* fn2 ->sin     cos    sinh    cosh   sqr      exp     log  */
  2799.    /* fn1 */
  2800.    /* sin */ {PI_SYM,YAXIS, XYAXIS,XYAXIS,XYAXIS,XAXIS, XAXIS},
  2801.    /* cos */ {YAXIS, PI_SYM,XYAXIS,XYAXIS,XYAXIS,XAXIS, XAXIS},
  2802.    /* sinh*/ {XYAXIS,XYAXIS,XYAXIS,XYAXIS,XYAXIS,XAXIS, XAXIS},
  2803.    /* cosh*/ {XYAXIS,XYAXIS,XYAXIS,XYAXIS,XYAXIS,XAXIS, XAXIS},
  2804.    /* sqr */ {XYAXIS,XYAXIS,XYAXIS,XYAXIS,XYAXIS,XAXIS, XAXIS},
  2805.    /* exp */ {XAXIS, XAXIS, XAXIS, XAXIS, XAXIS, XAXIS, XAXIS},
  2806.    /* log */ {XAXIS, XAXIS, XAXIS, XAXIS, XAXIS, XAXIS, XAXIS},
  2807.    };
  2808.    /*
  2809.    if(trigndx[0]==EXP || trigndx[0]==LOG || trigndx[1]==EXP || trigndx[1]==LOG)
  2810.       symmetry = XAXIS;
  2811.    else if((trigndx[0]==SIN && trigndx[1]==SIN)||(trigndx[0]==COS && trigndx[1]==COS))
  2812.       symmetry = PI_SYM;
  2813.    else if((trigndx[0]==SIN && trigndx[1]==COS)||(trigndx[0]==COS && trigndx[1]==SIN))
  2814.       symmetry = YAXIS;
  2815.    else
  2816.       symmetry = XYAXIS;
  2817.    */
  2818.    symmetry = fnxfn[trigndx[0]][trigndx[1]];
  2819.    if(curfractalspecific->isinteger)
  2820.       return(JulialongSetup());
  2821.    else
  2822.       return(JuliafpSetup());
  2823. }
  2824.  
  2825. MandelTrigSetup()
  2826. {
  2827.    int isinteger;
  2828.    if((isinteger = curfractalspecific->isinteger))
  2829.       curfractalspecific->orbitcalc =  LambdaTrigFractal;
  2830.    else
  2831.       curfractalspecific->orbitcalc =  LambdaTrigfpFractal;
  2832.    symmetry = XYAXIS_NOPARM;
  2833.    switch(trigndx[0])
  2834.    {
  2835.    case SIN:
  2836.    case COS:
  2837.       if(isinteger)
  2838.      curfractalspecific->orbitcalc =  LambdaTrigFractal1;
  2839.       else
  2840.      curfractalspecific->orbitcalc =  LambdaTrigfpFractal1;
  2841.       break;
  2842.    case SINH:
  2843.    case COSH:
  2844.       if(isinteger)
  2845.      curfractalspecific->orbitcalc =  LambdaTrigFractal2;
  2846.       else
  2847.      curfractalspecific->orbitcalc =  LambdaTrigfpFractal2;
  2848.       break;
  2849.    case EXP:
  2850.       symmetry = XAXIS_NOPARM;
  2851.       if(isinteger)
  2852.      curfractalspecific->orbitcalc =  LongLambdaexponentFractal;
  2853.       else
  2854.      curfractalspecific->orbitcalc =  LambdaexponentFractal;
  2855.       break;
  2856.    case LOG:
  2857.       symmetry = XAXIS_NOPARM;
  2858.       break;
  2859.    }
  2860.    if(isinteger)
  2861.       return(MandellongSetup());
  2862.    else
  2863.       return(MandelfpSetup());
  2864. }
  2865.  
  2866. MarksJuliaSetup()
  2867. {
  2868.    c_exp = param[2];
  2869.    longparm = &lparm;
  2870.    lold = *longparm;
  2871.    if(c_exp > 2)
  2872.       lcpower(&lold,c_exp,&lcoefficient,bitshift);
  2873.    else if(c_exp == 2)
  2874.    {
  2875.       lcoefficient.x = multiply(lold.x,lold.x,bitshift) - multiply(lold.y,lold.y,bitshift);
  2876.       lcoefficient.y = multiply(lold.x,lold.y,bitshiftless1);
  2877.    }
  2878.    else if(c_exp < 2)
  2879.       lcoefficient = lold;
  2880.    return(1);
  2881. }
  2882.  
  2883. SierpinskiSetup()
  2884. {
  2885.    /* sierpinski */
  2886.    periodicitycheck = 0;        /* disable periodicity checks */
  2887.    ltmp.x = 1;
  2888.    ltmp.x = ltmp.x << bitshift; /* ltmp.x = 1 */
  2889.    ltmp.y = ltmp.x >> 1;            /* ltmp.y = .5 */
  2890.    return(1);
  2891. }
  2892.  
  2893. SierpinskiFPSetup()
  2894. {
  2895.    /* sierpinski */
  2896.    periodicitycheck = 0;        /* disable periodicity checks */
  2897.    tmp.x = 1;
  2898.    tmp.y = 0.5;
  2899.    return(1);
  2900. }
  2901.  
  2902.  
  2903. StandardSetup()
  2904. {
  2905.    if(fractype==UNITYFP)
  2906.       periodicitycheck=0;
  2907.    return(1);
  2908. }
  2909.