diff --git a/fractint/common/3d.c b/fractint/common/3d.c deleted file mode 100644 index 3b8b4233e..000000000 --- a/fractint/common/3d.c +++ /dev/null @@ -1,396 +0,0 @@ -/* -A word about the 3D library. Even though this library supports -three dimensions, the matrices are 4x4 for the following reason. -With normal 3 dimensional vectors, translation is an ADDITION, -and rotation is a MULTIPLICATION. A vector {x,y,z} is represented -as a 4-tuple {x,y,z,1}. It is then possible to define a 4x4 -matrix such that multiplying the vector by the matrix translates -the vector. This allows combinations of translation and rotation -to be obtained in a single matrix by multiplying a translation -matrix and a rotation matrix together. Note that in the code, -vectors have three components; since the fourth component is -always 1, that value is not included in the vector variable to -save space, but the routines make use of the fourth component -(see vec_mult()). Similarly, the fourth column of EVERY matrix is -always - 0 - 0 - 0 - 1 -but currently the C version of a matrix includes this even though -it could be left out of the data structure and assumed in the -routines. Vectors are ROW vectors, and are always multiplied with -matrices FROM THE LEFT (e.g. vector*matrix). Also note the order -of indices of a matrix is matrix[row][column], and in usual C -fashion, numbering starts with 0. - -TRANSLATION MATRIX = 1 0 0 0 - 0 1 0 0 - 0 0 1 0 - Tx Ty Tz 1 - -SCALE MATRIX = Sx 0 0 0 - 0 Sy 0 0 - 0 0 Sz 0 - 0 0 0 1 - -Rotation about x axis i degrees: -ROTX(i) = 1 0 0 0 - 0 cosi sini 0 - 0 -sini cosi 0 - 0 0 0 1 - -Rotation about y axis i degrees: -ROTY(i) = cosi 0 -sini 0 - 0 1 0 0 - sini 0 cosi 0 - 0 0 0 1 - -Rotation about z axis i degrees: -ROTZ(i) = cosi sini 0 0 - -sini cosi 0 0 - 0 0 1 0 - 0 0 0 1 - - -- Tim Wegner April 22, 1989 -*/ - - -#include - /* see Fractint.c for a description of the "include" hierarchy */ -#include "port.h" -#include "prototyp.h" - -/* initialize a matrix and set to identity matrix - (all 0's, 1's on diagonal) */ -void identity(MATRIX m) -{ - int i,j; - for (i=0; i FLT_MAX) - return -1; - vlength = sqrt(vlength); - if (vlength < FLT_MIN) - return -1; - - v[0] /= vlength; - v[1] /= vlength; - v[2] /= vlength; - return 0; -} - -/* multiply source vector s by matrix m, result in target t */ -/* used to apply transformations to a vector */ -int vmult(VECTOR s, MATRIX m, VECTOR t) -{ - VECTOR tmp; - int i,j; - for (j=0; j= 0.0) - { - v[0] = bad_value; /* clipping will catch these values */ - v[1] = bad_value; /* so they won't plot values BEHIND viewer */ - v[2] = bad_value; - return -1; - } - v[0] = (v[0]*view[2] - view[0]*v[2])/denom; - v[1] = (v[1]*view[2] - view[1]*v[2])/denom; - - /* calculation of z if needed later */ - /* v[2] = v[2]/denom;*/ - return 0; -} - -/* long version of vmult and perspective combined for speed */ -int -longvmultpersp(LVECTOR s, LMATRIX m, LVECTOR t0, LVECTOR t, LVECTOR lview, - int bitshift) -{ -/* s: source vector */ -/* m: transformation matrix */ -/* t0: after transformation, before persp */ -/* t: target vector */ -/* lview: perspective viewer coordinates */ -/* bitshift: fixed point conversion bitshift */ - LVECTOR tmp; - int i,j, k; - overflow = 0; - k = CMAX-1; /* shorten the math if non-perspective and non-illum */ - if (lview[2] == 0 && t0[0] == 0) k--; - - for (j=0; j= 0) /* bail out if point is "behind" us */ - { - t[0] = bad_value; - t[0] = t[0]<= 0) /* bail out if point is "behind" us */ - { - lv[0] = bad_value; - lv[0] = lv[0]< fractint.c -.SUFFIXES: -.SUFFIXES: .o .c .s .h .asm - -all: $(OBJS) - -tidy: - rm -f $(OBJS) - -clean: - rm -f $(OBJS) - -fractint.o: fractint.c - $(CC) $(CFLAGS) -DSRCDIR=\"$(SRCDIR)\" -c fractint.c - -help.o: help.c - $(CC) $(CFLAGS) -DSRCDIR=\"$(SRCDIR)\" -c help.c - -copy: $(FILES) - mv $(FILES) backup - -# DO NOT DELETE THIS LINE -- make depend depends on it. - -3d.o: 3d.c ${HFD}/fractint.h ${HFD}/port.h ${HFD}/prototyp.h ${HFD}/mpmath.h ${HFD}/helpcom.h - -ant.o: ant.c ${HFD}/fractint.h ${HFD}/port.h ${HFD}/prototyp.h ${HFD}/mpmath.h ${HFD}/helpcom.h ${HFD}/helpdefs.h - -bigflt.o: bigflt.c ${HFD}/big.h ${HFD}/biginit.h - -biginit.o: biginit.c ${HFD}/fractint.h ${HFD}/port.h ${HFD}/prototyp.h ${HFD}/mpmath.h ${HFD}/helpcom.h \ -${HFD}/big.h - -bignum.o: bignum.c ${HFD}/fractint.h ${HFD}/port.h ${HFD}/prototyp.h ${HFD}/mpmath.h ${HFD}/helpcom.h - -bignumc.o: bignumc.c ${HFD}/fractint.h ${HFD}/port.h ${HFD}/prototyp.h ${HFD}/mpmath.h ${HFD}/helpcom.h - -calcfrac.o: calcfrac.c ${HFD}/fractint.h ${HFD}/port.h ${HFD}/fractype.h ${HFD}/mpmath.h ${HFD}/targa_lc.h \ - ${HFD}/prototyp.h ${HFD}/helpcom.h - -cmdfiles.o: cmdfiles.c ${HFD}/fractint.h ${HFD}/port.h ${HFD}/fractype.h ${HFD}/prototyp.h ${HFD}/mpmath.h \ - ${HFD}/helpcom.h - -decoder.o: decoder.c ${HFD}/prototyp.h ${HFD}/mpmath.h ${HFD}/port.h ${HFD}/fractint.h ${HFD}/helpcom.h - -editpal.o: editpal.c ${HFD}/fractint.h ${HFD}/port.h ${HFD}/prototyp.h ${HFD}/mpmath.h ${HFD}/helpcom.h - -encoder.o: encoder.c ${HFD}/fractint.h ${HFD}/port.h ${HFD}/fractype.h ${HFD}/prototyp.h ${HFD}/mpmath.h ${HFD}/helpcom.h - -f16.o: f16.c ${HFD}/targa_lc.h ${HFD}/prototyp.h ${HFD}/mpmath.h ${HFD}/port.h ${HFD}/fractint.h ${HFD}/helpcom.h - -fracsubr.o: fracsubr.c ${HFD}/fractint.h ${HFD}/port.h ${HFD}/fractype.h ${HFD}/mpmath.h ${HFD}/prototyp.h \ - ${HFD}/helpcom.h - -fractalb.o: fractalb.c ${HFD}/fractint.h ${HFD}/port.h ${HFD}/prototyp.h ${HFD}/mpmath.h ${HFD}/helpcom.h \ -${HFD}/helpdefs.h ${HFD}/fractype.h - -fractalp.o: fractalp.c ${HFD}/fractint.h ${HFD}/port.h ${HFD}/mpmath.h ${HFD}/helpdefs.h ${HFD}/fractype.h \ - ${HFD}/prototyp.h ${HFD}/helpcom.h - -fractals.o: fractals.c ${HFD}/fractint.h ${HFD}/port.h ${HFD}/mpmath.h ${HFD}/helpdefs.h ${HFD}/fractype.h \ - ${HFD}/prototyp.h ${HFD}/helpcom.h - -fractint.o: fractint.c ${HFD}/prototyp.h ${HFD}/mpmath.h ${HFD}/port.h ${HFD}/fractint.h ${HFD}/helpcom.h \ - ${HFD}/fractype.h ${HFD}/helpdefs.h - -framain2.o: framain2.c ${HFD}/fractint.h ${HFD}/port.h ${HFD}/prototyp.h ${HFD}/mpmath.h ${HFD}/helpcom.h \ -${HFD}/fractype.h ${HFD}/helpdefs.h - -frasetup.o: frasetup.c ${HFD}/fractint.h ${HFD}/port.h ${HFD}/prototyp.h ${HFD}/mpmath.h ${HFD}/helpcom.h \ -${HFD}/mpmath.h ${HFD}/helpdefs.h ${HFD}/fractype.h - -gifview.o: gifview.c ${HFD}/fractint.h ${HFD}/port.h ${HFD}/prototyp.h ${HFD}/mpmath.h ${HFD}/helpcom.h - -hcmplx.o: hcmplx.c ${HFD}/fractint.h ${HFD}/port.h ${HFD}/prototyp.h ${HFD}/mpmath.h ${HFD}/helpcom.h ${HFD}/mpmath.h - -help.o: help.c ${HFD}/fractint.h ${HFD}/port.h ${HFD}/helpcom.h ${HFD}/helpdefs.h ${HFD}/prototyp.h ${HFD}/mpmath.h - -intro.o: intro.c ${HFD}/fractint.h ${HFD}/port.h ${HFD}/helpdefs.h ${HFD}/prototyp.h ${HFD}/mpmath.h ${HFD}/helpcom.h - -jb.o: jb.c ${HFD}/fractint.h ${HFD}/port.h ${HFD}/mpmath.h ${HFD}/helpdefs.h ${HFD}/prototyp.h ${HFD}/helpcom.h - -jiim.o: jiim.c ${HFD}/helpdefs.h ${HFD}/fractint.h ${HFD}/port.h ${HFD}/fractype.h ${HFD}/prototyp.h ${HFD}/mpmath.h \ - ${HFD}/helpcom.h - -line3d.o: line3d.c ${HFD}/fractint.h ${HFD}/port.h ${HFD}/prototyp.h ${HFD}/mpmath.h ${HFD}/helpcom.h - -loadfdos.o: loadfdos.c ${HFD}/fractint.h ${HFD}/port.h ${HFD}/helpdefs.h ${HFD}/prototyp.h ${HFD}/mpmath.h \ - ${HFD}/helpcom.h - -loadfile.o: loadfile.c ${HFD}/fractint.h ${HFD}/port.h ${HFD}/fractype.h ${HFD}/targa_lc.h ${HFD}/prototyp.h \ - ${HFD}/mpmath.h ${HFD}/helpcom.h - -loadmap.o: loadmap.c ${HFD}/fractint.h ${HFD}/port.h ${HFD}/prototyp.h ${HFD}/mpmath.h ${HFD}/helpcom.h - -lorenz.o: lorenz.c ${HFD}/mpmath.h ${HFD}/fractint.h ${HFD}/port.h ${HFD}/fractype.h ${HFD}/prototyp.h ${HFD}/helpcom.h - -lsys.o: lsys.c ${HFD}/fractint.h ${HFD}/port.h ${HFD}/prototyp.h ${HFD}/mpmath.h ${HFD}/helpcom.h - -lsysf.o: lsysf.c ${HFD}/fractint.h ${HFD}/port.h ${HFD}/prototyp.h ${HFD}/mpmath.h ${HFD}/helpcom.h ${HFD}/lsys.h - -miscfrac.o: miscfrac.c ${HFD}/fractint.h ${HFD}/port.h ${HFD}/prototyp.h ${HFD}/mpmath.h ${HFD}/helpcom.h \ -${HFD}/fractype.h ${HFD}/targa_lc.h - -miscovl.o: miscovl.c ${HFD}/fractint.h ${HFD}/port.h ${HFD}/fractype.h ${HFD}/helpdefs.h ${HFD}/prototyp.h \ - ${HFD}/mpmath.h ${HFD}/helpcom.h - -miscres.o: miscres.c ${HFD}/fractint.h ${HFD}/port.h ${HFD}/fractype.h ${HFD}/helpdefs.h ${HFD}/prototyp.h \ - ${HFD}/mpmath.h ${HFD}/helpcom.h - -mpmath_c.o: mpmath_c.c ${HFD}/mpmath.h ${HFD}/prototyp.h ${HFD}/port.h ${HFD}/fractint.h ${HFD}/helpcom.h - -parser.o: parser.c ${HFD}/mpmath.h ${HFD}/prototyp.h ${HFD}/port.h ${HFD}/fractint.h ${HFD}/helpcom.h - -parserfp.o: parserfp.c ${HFD}/fractint.h ${HFD}/port.h ${HFD}/prototyp.h ${HFD}/mpmath.h ${HFD}/helpcom.h - -plot3d.o: plot3d.c ${HFD}/fractint.h ${HFD}/port.h ${HFD}/fractype.h ${HFD}/prototyp.h ${HFD}/mpmath.h ${HFD}/helpcom.h - -prompts1.o: prompts1.c ${HFD}/fractint.h ${HFD}/port.h ${HFD}/fractype.h ${HFD}/helpdefs.h ${HFD}/prototyp.h \ - ${HFD}/mpmath.h ${HFD}/helpcom.h - -prompts2.o: prompts2.c ${HFD}/fractint.h ${HFD}/port.h ${HFD}/fractype.h ${HFD}/helpdefs.h ${HFD}/prototyp.h \ - ${HFD}/mpmath.h ${HFD}/helpcom.h - -realdos.o: realdos.c ${HFD}/fractint.h ${HFD}/port.h ${HFD}/fractype.h ${HFD}/helpdefs.h ${HFD}/prototyp.h \ - ${HFD}/mpmath.h ${HFD}/helpcom.h - -rotate.o: rotate.c ${HFD}/fractint.h ${HFD}/port.h ${HFD}/helpdefs.h ${HFD}/prototyp.h ${HFD}/mpmath.h ${HFD}/helpcom.h - -slideshw.o: slideshw.c ${HFD}/fractint.h ${HFD}/port.h ${HFD}/prototyp.h ${HFD}/mpmath.h ${HFD}/helpcom.h - -stereo.o: stereo.c ${HFD}/fractint.h ${HFD}/port.h ${HFD}/prototyp.h ${HFD}/mpmath.h ${HFD}/helpcom.h ${HFD}/helpdefs.h - -targa.o: targa.c ${HFD}/targa.h ${HFD}/fractint.h ${HFD}/port.h ${HFD}/prototyp.h ${HFD}/mpmath.h ${HFD}/helpcom.h - -testpt.o: testpt.c - -tgaview.o: tgaview.c ${HFD}/fractint.h ${HFD}/port.h ${HFD}/targa_lc.h ${HFD}/prototyp.h ${HFD}/mpmath.h ${HFD}/helpcom.h - -tp3d.o: tp3d.c ${HFD}/mpmath.h ${HFD}/fractint.h ${HFD}/port.h ${HFD}/prototyp.h ${HFD}/helpcom.h - -zoom.o: zoom.c ${HFD}/fractint.h ${HFD}/port.h ${HFD}/prototyp.h ${HFD}/mpmath.h ${HFD}/helpcom.h diff --git a/fractint/common/ant.c b/fractint/common/ant.c deleted file mode 100644 index b06fe93df..000000000 --- a/fractint/common/ant.c +++ /dev/null @@ -1,476 +0,0 @@ -/* The Ant Automaton is based on an article in Scientific American, July 1994. - * The original Fractint implementation was by Tim Wegner in Fractint 19.0. - * This routine is a major rewrite by Luciano Genero & Fulvio Cappelli using - * tables for speed, and adds a second ant type, multiple ants, and random - * rules. - * - * Revision history: - * 20 Mar 95 LG/FC First release of table driven version - * 31 Mar 95 LG/FC Fixed a bug that writes one pixel off the screen - * 31 Mar 95 LG/FC Changed ant type 1 to produce the same pattern as the - * original implementation (they were mirrored on the - * x axis) - * 04 Apr 95 TW Added wrap option and further modified the code to match - * the original algorithm. It now matches exactly. - * 10 Apr 95 TW Suffix array does not contain enough memory. Crashes at - * over 1024x768. Changed to extraseg. - * 12 Apr 95 TW Added maxants range check. - */ -#include - /* see Fractint.c for a description of the "include" hierarchy */ -#include "port.h" -#include "prototyp.h" -#include "helpdefs.h" -#include "drivers.h" - -#define RANDOM(n) ((int)((long)((long)rand() * (long)(n)) >> 15)) /* Generate Random - * Number 0 <= r < n */ -#define MAX_ANTS 256 -#define XO (xdots/2) -#define YO (ydots/2) -#define DIRS 4 -#define INNER_LOOP 100 - -/* possible value of idir e relative movement in the 4 directions - * for x 0, 1, 0, -1 - * for y 1, 0, -1, 0 - */ -static int *s_incx[DIRS]; /* tab for 4 directions */ -static int *s_incy[DIRS]; -static int s_last_xdots = 0; -static int s_last_ydots = 0; - -void -setwait(long *wait) -{ - char msg[30]; - int kbdchar; - - for (;;) - { - sprintf(msg, "Delay %4ld", *wait); - while ((int)strlen(msg) < 15) - strcat(msg, " "); - msg[15] = '\0'; - showtempmsg((char *) msg); - kbdchar = driver_get_key(); - switch (kbdchar) - { - case FIK_CTL_RIGHT_ARROW: - case FIK_CTL_UP_ARROW: - (*wait) += 100; - break; - case FIK_RIGHT_ARROW: - case FIK_UP_ARROW: - (*wait) += 10; - break; - case FIK_CTL_DOWN_ARROW: - case FIK_CTL_LEFT_ARROW: - (*wait) -= 100; - break; - case FIK_LEFT_ARROW: - case FIK_DOWN_ARROW: - (*wait) -= 10; - break; - default: - cleartempmsg(); - return; - } - if (*wait < 0) - *wait = 0; - } -} - -/* turkmite from scientific american july 1994 pag 91 - * Tweaked by Luciano Genero & Fulvio Cappelli - */ -void -TurkMite1(int maxtur, int rule_len, char *ru, long maxpts, long wait) -{ - int color, ix, iy, idir, pixel, i; - int kbdchar, step, antwrap; - int x[MAX_ANTS + 1], y[MAX_ANTS + 1]; - int next_col[MAX_ANTS + 1], rule[MAX_ANTS + 1], dir[MAX_ANTS + 1]; - long count; - antwrap = ((param[4] == 0) ? 0 : 1); - step = (int) wait; - if (step == 1) - wait = 0; - else - step = 0; - if (rule_len == 0) - { /* random rule */ - for (color = 0; color < MAX_ANTS; color++) - { /* init the rules and colors for the - * turkmites: 1 turn left, -1 turn right */ - rule[color] = 1 - (RANDOM(2) * 2); - next_col[color] = color + 1; - } - /* close the cycle */ - next_col[color] = 0; - } - else - { /* user defined rule */ - for (color = 0; color < rule_len; color++) - { /* init the rules and colors for the - * turkmites: 1 turn left, -1 turn right */ - rule[color] = (ru[color] * 2) - 1; - next_col[color] = color + 1; - } - /* repeats to last color */ - for (color = rule_len; color < MAX_ANTS; color++) - { /* init the rules and colors for the - * turkmites: 1 turn left, -1 turn right */ - rule[color] = rule[color % rule_len]; - next_col[color] = color + 1; - } - /* close the cycle */ - next_col[color] = 0; - } - for (color = maxtur; color; color--) - { /* init the various turmites N.B. non usa - * x[0], y[0], dir[0] */ - if (rule_len) - { - dir[color] = 1; - x[color] = XO; - y[color] = YO; - } - else - { - dir[color] = RANDOM(DIRS); - x[color] = RANDOM(xdots); - y[color] = RANDOM(ydots); - } - } - maxpts = maxpts / (long) INNER_LOOP; - for (count = 0; count < maxpts; count++) - { - /* check for a key only every inner_loop times */ - kbdchar = driver_key_pressed(); - if (kbdchar || step) - { - int done = 0; - if (kbdchar == 0) - kbdchar = driver_get_key(); - switch (kbdchar) - { - case FIK_SPACE: - step = 1 - step; - break; - case FIK_ESC: - done = 1; - break; - case FIK_RIGHT_ARROW: - case FIK_UP_ARROW: - case FIK_DOWN_ARROW: - case FIK_LEFT_ARROW: - case FIK_CTL_RIGHT_ARROW: - case FIK_CTL_UP_ARROW: - case FIK_CTL_DOWN_ARROW: - case FIK_CTL_LEFT_ARROW: - setwait(&wait); - break; - default: - done = 1; - break; - } - if (done) - goto exit_ant; - if (driver_key_pressed()) - driver_get_key(); - } - for (i = INNER_LOOP; i; i--) - { - if (wait > 0 && step == 0) - { - for (color = maxtur; color; color--) - { /* move the various turmites */ - ix = x[color]; /* temp vars */ - iy = y[color]; - idir = dir[color]; - - pixel = getcolor(ix, iy); - putcolor(ix, iy, 15); - sleepms(wait); - putcolor(ix, iy, next_col[pixel]); - idir += rule[pixel]; - idir &= 3; - if (antwrap == 0) - if ((idir == 0 && iy == ydots - 1) || - (idir == 1 && ix == xdots - 1) || - (idir == 2 && iy == 0) || - (idir == 3 && ix == 0)) - goto exit_ant; - x[color] = s_incx[idir][ix]; - y[color] = s_incy[idir][iy]; - dir[color] = idir; - } - } - else - { - for (color = maxtur; color; color--) - { /* move the various turmites without delay */ - ix = x[color]; /* temp vars */ - iy = y[color]; - idir = dir[color]; - pixel = getcolor(ix, iy); - putcolor(ix, iy, next_col[pixel]); - idir += rule[pixel]; - idir &= 3; - if (antwrap == 0) - if ((idir == 0 && iy == ydots - 1) || - (idir == 1 && ix == xdots - 1) || - (idir == 2 && iy == 0) || - (idir == 3 && ix == 0)) - goto exit_ant; - x[color] = s_incx[idir][ix]; - y[color] = s_incy[idir][iy]; - dir[color] = idir; - } - } - } - } -exit_ant: - return; -} - -/* this one ignore the color of the current cell is more like a white ant */ -void -TurkMite2(int maxtur, int rule_len, char *ru, long maxpts, long wait) -{ - int color, ix, iy, idir, pixel, dir[MAX_ANTS + 1], i; - int kbdchar, step, antwrap; - int x[MAX_ANTS + 1], y[MAX_ANTS + 1]; - int rule[MAX_ANTS + 1], rule_mask; - long count; - - antwrap = ((param[4] == 0) ? 0 : 1); - - step = (int) wait; - if (step == 1) - wait = 0; - else - step = 0; - if (rule_len == 0) - { /* random rule */ - for (color = MAX_ANTS - 1; color; color--) - { /* init the various turmites N.B. don't use - * x[0], y[0], dir[0] */ - dir[color] = RANDOM(DIRS); - rule[color] = (rand() << RANDOM(2)) | RANDOM(2); - x[color] = RANDOM(xdots); - y[color] = RANDOM(ydots); - } - } - else - { /* the same rule the user wants for every - * turkmite (max rule_len = 16 bit) */ - rule_len = min(rule_len, 8 * sizeof(int)); - for (i = 0, rule[0] = 0; i < rule_len; i++) - rule[0] = (rule[0] << 1) | ru[i]; - for (color = MAX_ANTS - 1; color; color--) - { /* init the various turmites N.B. non usa - * x[0], y[0], dir[0] */ - dir[color] = 0; - rule[color] = rule[0]; - x[color] = XO; - y[color] = YO; - } - } -/* use this rule when a black pixel is found */ - rule[0] = 0; - rule_mask = 1; - maxpts = maxpts / (long) INNER_LOOP; - for (count = 0; count < maxpts; count++) - { - /* check for a key only every inner_loop times */ - kbdchar = driver_key_pressed(); - if (kbdchar || step) - { - int done = 0; - if (kbdchar == 0) - kbdchar = driver_get_key(); - switch (kbdchar) - { - case FIK_SPACE: - step = 1 - step; - break; - case FIK_ESC: - done = 1; - break; - case FIK_RIGHT_ARROW: - case FIK_UP_ARROW: - case FIK_DOWN_ARROW: - case FIK_LEFT_ARROW: - case FIK_CTL_RIGHT_ARROW: - case FIK_CTL_UP_ARROW: - case FIK_CTL_DOWN_ARROW: - case FIK_CTL_LEFT_ARROW: - setwait(&wait); - break; - default: - done = 1; - break; - } - if (done) - goto exit_ant; - if (driver_key_pressed()) - driver_get_key(); - } - for (i = INNER_LOOP; i; i--) - { - for (color = maxtur; color; color--) - { /* move the various turmites */ - ix = x[color]; /* temp vars */ - iy = y[color]; - idir = dir[color]; - pixel = getcolor(ix, iy); - putcolor(ix, iy, 15); - - if (wait > 0 && step == 0) - sleepms(wait); - - if (rule[pixel] & rule_mask) - { /* turn right */ - idir--; - putcolor(ix, iy, 0); - } - else - { /* turn left */ - idir++; - putcolor(ix, iy, color); - } - idir &= 3; - if (antwrap == 0) - if ((idir == 0 && iy == ydots - 1) || - (idir == 1 && ix == xdots - 1) || - (idir == 2 && iy == 0) || - (idir == 3 && ix == 0)) - goto exit_ant; - x[color] = s_incx[idir][ix]; - y[color] = s_incy[idir][iy]; - dir[color] = idir; - } - rule_mask = _rotl(rule_mask, 1); - } - } -exit_ant: - return; -} - -void free_ant_storage(void) -{ - if (s_incx[0]) - { - free(s_incx[0]); - s_incx[0] = NULL; - } -} - -/* N.B. use the common memory in extraseg - suffix not large enough*/ -int -ant(void) -{ - int maxants, type, i; - int oldhelpmode, rule_len; - long maxpts, wait; - char rule[MAX_ANTS]; - - if (xdots != s_last_xdots || ydots != s_last_ydots) - { - int *storage = (int *) malloc((xdots + 2)*sizeof(int)*DIRS + (ydots + 2)*sizeof(int)*DIRS); - int *y_storage = storage + (xdots + 2)*DIRS; - - s_last_xdots = xdots; - s_last_ydots = ydots; - - free_ant_storage(); /* free old memory */ - for (i = 0; i < DIRS; i++) - { - s_incx[i] = storage; - storage += xdots + 2; - s_incy[i] = y_storage; - y_storage += ydots + 2; - } - } - -/* In this vectors put all the possible point that the ants can visit. - * Wrap them from a side to the other insted of simply end calculation - */ - for (i = 0; i < xdots; i++) - { - s_incx[0][i] = i; - s_incx[2][i] = i; - } - - for (i = 0; i < xdots; i++) - s_incx[3][i] = i + 1; - s_incx[3][xdots-1] = 0; /* wrap from right of the screen to left */ - - for (i = 1; i < xdots; i++) - s_incx[1][i] = i - 1; - s_incx[1][0] = xdots-1; /* wrap from left of the screen to right */ - - for (i = 0; i < ydots; i++) - { - s_incy[1][i] = i; - s_incy[3][i] = i; - } - for (i = 0; i < ydots; i++) - s_incy[0][i] = i + 1; - s_incy[0][ydots - 1] = 0; /* wrap from the top of the screen to the - * bottom */ - for (i = 1; i < ydots; i++) - s_incy[2][i] = i - 1; - s_incy[2][0] = ydots - 1; /* wrap from the bottom of the screen to the - * top */ - oldhelpmode = helpmode; - helpmode = ANTCOMMANDS; - maxpts = (long) param[1]; - maxpts = labs(maxpts); - wait = abs(orbit_delay); - sprintf(rule, "%.17g", param[0]); - rule_len = (int) strlen(rule); - if (rule_len > 1) - { /* if rule_len == 0 random rule */ - for (i = 0; i < rule_len; i++) - { - if (rule[i] != '1') - rule[i] = (char) 0; - else - rule[i] = (char) 1; - } - } - else - rule_len = 0; - - /* set random seed for reproducibility */ - if ((!rflag) && param[5] == 1) - --rseed; - if (param[5] != 0 && param[5] != 1) - rseed = (int)param[5]; - - srand(rseed); - if (!rflag) ++rseed; - - maxants = (int) param[2]; - if (maxants < 1) /* if maxants == 0 maxants random */ - maxants = 2 + RANDOM(MAX_ANTS - 2); - else if (maxants > MAX_ANTS) - param[2] = maxants = MAX_ANTS; - type = (int) param[3] - 1; - if (type < 0 || type > 1) - type = RANDOM(2); /* if type == 0 choose a random type */ - switch (type) - { - case 0: - TurkMite1(maxants, rule_len, rule, maxpts, wait); - break; - case 1: - TurkMite2(maxants, rule_len, rule, maxpts, wait); - break; - } - helpmode = oldhelpmode; - return 0; -} diff --git a/fractint/common/bigflt.c b/fractint/common/bigflt.c deleted file mode 100644 index 7ef605c7e..000000000 --- a/fractint/common/bigflt.c +++ /dev/null @@ -1,2373 +0,0 @@ -/* bigflt.c - C routines for big floating point numbers */ - -/* -Wesley Loewer's Big Numbers. (C) 1994-95, Wesley B. Loewer -*/ - -#include - /* see Fractint.c for a description of the "include" hierarchy */ -#include "port.h" -#include "big.h" -#ifndef BIG_ANSI_C -#include -#endif - -#define LOG10_256 2.4082399653118 -#define LOG_256 5.5451774444795 - -/********************************************************************/ -/* bf_hexdump() - for debugging, dumps to stdout */ - -void bf_hexdump(bf_t r) - { - int i; - - for (i=0; i= '0' && *l <= '9') /* while a digit */ - { - onesbyte = (BYTE)(*(l--) - '0'); - inttobf(bftmp1,onesbyte); - unsafe_add_a_bf(r, bftmp1); - div_a_bf_int(r, 10); - } - - if (*(l--) == '.') /* the digit was found */ - { - keeplooping = *l >= '0' && *l <= '9' && l>=s; - while (keeplooping) /* while a digit */ - { - onesbyte = (BYTE)(*(l--) - '0'); - inttobf(bftmp1,onesbyte); - unsafe_add_a_bf(r, bftmp1); - keeplooping = *l >= '0' && *l <= '9' && l>=s; - if (keeplooping) - { - div_a_bf_int(r, 10); - powerten++; /* increase the power of ten */ - } - } - } - } - else - { - keeplooping = *l >= '0' && *l <= '9' && l>=s; - while (keeplooping) /* while a digit */ - { - onesbyte = (BYTE)(*(l--) - '0'); - inttobf(bftmp1,onesbyte); - unsafe_add_a_bf(r, bftmp1); - keeplooping = *l >= '0' && *l <= '9' && l>=s; - if (keeplooping) - { - div_a_bf_int(r, 10); - powerten++; /* increase the power of ten */ - } - } - } - - if (powerten > 0) - { - for (; powerten>0; powerten--) - { - mult_a_bf_int(r, 10); - } - } - else if (powerten < 0) - { - for (; powerten<0; powerten++) - { - div_a_bf_int(r, 10); - } - } - if (signflag) - neg_a_bf(r); - - return r; - } - -/********************************************************************/ -/* strlen_needed() - returns string length needed to hold bigfloat */ - -int strlen_needed_bf() - { - int length; - - /* first space for integer part */ - length = 1; - length += decimals; /* decimal part */ - length += 2; /* decimal point and sign */ - length += 2; /* e and sign */ - length += 4; /* exponent */ - length += 4; /* null and a little extra for safety */ - return(length); - } - -/********************************************************************/ -/* bftostr() - converts a bigfloat into a scientific notation string */ -/* s - string, must be large enough to hold the number. */ -/* dec - decimal places, 0 for max */ -/* r - bigfloat */ -/* will convert to a floating point notation */ -/* SIDE-EFFECT: the bigfloat, r, is destroyed. */ -/* Copy it first if necessary. */ -/* USES: bftmp1 - bftmp2 */ -/********************************************************************/ - -char *unsafe_bftostr(char *s, int dec, bf_t r) - { - LDBL value; - int power; - - value = bftofloat(r); - if (value == 0.0) - { - strcpy(s, "0.0"); - return s; - } - - copy_bf(bftmp1, r); - unsafe_bftobf10(bf10tmp, dec, bftmp1); - power = (S16)big_access16(bf10tmp+dec+2); /* where the exponent is stored */ - if (power > -4 && power < 6) /* tinker with this */ - bf10tostr_f(s, dec, bf10tmp); - else - bf10tostr_e(s, dec, bf10tmp); - return s; - } - - -/********************************************************************/ -/* the e version puts it in scientific notation, (like printf's %e) */ -char *unsafe_bftostr_e(char *s, int dec, bf_t r) - { - LDBL value; - - value = bftofloat(r); - if (value == 0.0) - { - strcpy(s, "0.0"); - return s; - } - - copy_bf(bftmp1, r); - unsafe_bftobf10(bf10tmp, dec, bftmp1); - bf10tostr_e(s, dec, bf10tmp); - return s; - } - -/********************************************************************/ -/* the f version puts it in decimal notation, (like printf's %f) */ -char *unsafe_bftostr_f(char *s, int dec, bf_t r) - { - LDBL value; - - value = bftofloat(r); - if (value == 0.0) - { - strcpy(s, "0.0"); - return s; - } - - copy_bf(bftmp1, r); - unsafe_bftobf10(bf10tmp, dec, bftmp1); - bf10tostr_f(s, dec, bf10tmp); - return s; - } - -/*********************************************************************/ -/* bn = floor(bf) */ -/* Converts a bigfloat to a bignumber (integer) */ -/* bflength must be at least bnlength+2 */ -bn_t bftobn(bn_t n, bf_t f) - { - int fexp; - int movebytes; - BYTE hibyte; - - fexp = (S16)big_access16(f+bflength); - if (fexp >= intlength) - { /* if it's too big, use max value */ - max_bn(n); - if (is_bf_neg(f)) - neg_a_bn(n); - return n; - } - - if (-fexp > bnlength - intlength) /* too small, return zero */ - { - clear_bn(n); - return n; - } - - /* already checked for over/underflow, this should be ok */ - movebytes = bnlength - intlength + fexp + 1; - memcpy(n, f+bflength-movebytes-1, movebytes); - hibyte = *(f+bflength-1); - memset(n+movebytes, hibyte, bnlength-movebytes); /* sign extends */ - return n; - } - -/*********************************************************************/ -/* bf = bn */ -/* Converts a bignumber (integer) to a bigfloat */ -/* bflength must be at least bnlength+2 */ -bf_t bntobf(bf_t f, bn_t n) - { - memcpy(f+bflength-bnlength-1, n, bnlength); - memset(f, 0, bflength - bnlength - 1); - *(f+bflength-1) = (BYTE)(is_bn_neg(n) ? 0xFF : 0x00); /* sign extend */ - big_set16(f+bflength, (S16)(intlength - 1)); /* exp */ - norm_bf(f); - return f; - } - -/*********************************************************************/ -/* b = l */ -/* Converts a long to a bigfloat */ -bf_t inttobf(bf_t r, long longval) - { - clear_bf(r); - big_set32(r+bflength-4, (S32)longval); - big_set16(r+bflength, (S16)2); - norm_bf(r); - return r; - } - -/*********************************************************************/ -/* l = floor(b), floor rounds down */ -/* Converts a bigfloat to a long */ -/* note: a bf value of 2.999... will be return a value of 2, not 3 */ -long bftoint(bf_t f) - { - int fexp; - long longval; - - fexp = (S16)big_access16(f+bflength); - if (fexp > 3) - { - longval = 0x7FFFFFFFL; - if (is_bf_neg(f)) - longval = -longval; - return longval; - } - longval = big_access32(f+bflength-5); - longval >>= 8*(3-fexp); - return longval; - } - -/********************************************************************/ -/* sign(r) */ -int sign_bf(bf_t n) - { - return is_bf_neg(n) ? -1 : is_bf_not_zero(n) ? 1 : 0; - } - -/********************************************************************/ -/* r = |n| */ -bf_t abs_bf(bf_t r, bf_t n) - { - copy_bf(r,n); - if (is_bf_neg(r)) - { - neg_a_bf(r); - } - return r; - } - -/********************************************************************/ -/* r = |r| */ -bf_t abs_a_bf(bf_t r) - { - if (is_bf_neg(r)) - neg_a_bf(r); - return r; - } - -/********************************************************************/ -/* r = 1/n */ -/* uses bftmp1 - bftmp2 - global temp bigfloats */ -/* SIDE-EFFECTS: */ -/* n ends up as |n|/256^exp Make copy first if necessary. */ -bf_t unsafe_inv_bf(bf_t r, bf_t n) - { - int signflag=0, i; - int fexp, rexp; - LDBL f; - bf_t orig_r, orig_n; /* orig_bftmp1 not needed here */ - int orig_bflength, - orig_bnlength, - orig_padding, - orig_rlength, - orig_shiftfactor, - orig_rbflength; - - /* use Newton's recursive method for zeroing in on 1/n : r=r(2-rn) */ - - if (is_bf_neg(n)) - { /* will be a lot easier to deal with just positives */ - signflag = 1; - neg_a_bf(n); - } - - fexp = (S16)big_access16(n+bflength); - big_set16(n+bflength, (S16)0); /* put within LDBL range */ - - f = bftofloat(n); - if (f == 0) /* division by zero */ - { - max_bf(r); - return r; - } - f = 1/f; /* approximate inverse */ - - /* With Newton's Method, there is no need to calculate all the digits */ - /* every time. The precision approximately doubles each iteration. */ - /* Save original values. */ - orig_bflength = bflength; - orig_bnlength = bnlength; - orig_padding = padding; - orig_rlength = rlength; - orig_shiftfactor = shiftfactor; - orig_rbflength = rbflength; - orig_r = r; - orig_n = n; - /* orig_bftmp1 = bftmp1; */ - - /* calculate new starting values */ - bnlength = intlength + (int)(LDBL_DIG/LOG10_256) + 1; /* round up */ - if (bnlength > orig_bnlength) - bnlength = orig_bnlength; - calc_lengths(); - - /* adjust pointers */ - r = orig_r + orig_bflength - bflength; - n = orig_n + orig_bflength - bflength; - /* bftmp1 = orig_bftmp1 + orig_bflength - bflength; */ - - floattobf(r, f); /* start with approximate inverse */ - - for (i=0; i<25; i++) /* safety net, this shouldn't ever be needed */ - { - /* adjust lengths */ - bnlength <<= 1; /* double precision */ - if (bnlength > orig_bnlength) - bnlength = orig_bnlength; - calc_lengths(); - r = orig_r + orig_bflength - bflength; - n = orig_n + orig_bflength - bflength; - /* bftmp1 = orig_bftmp1 + orig_bflength - bflength; */ - - unsafe_mult_bf(bftmp1, r, n); /* bftmp1=rn */ - inttobf(bftmp2, 1); /* will be used as 1.0 */ - - /* There seems to very little difficulty getting bftmp1 to be EXACTLY 1 */ - if (bflength == orig_bflength && cmp_bf(bftmp1, bftmp2) == 0) - break; - - inttobf(bftmp2, 2); /* will be used as 2.0 */ - unsafe_sub_a_bf(bftmp2, bftmp1); /* bftmp2=2-rn */ - unsafe_mult_bf(bftmp1, r, bftmp2); /* bftmp1=r(2-rn) */ - copy_bf(r, bftmp1); /* r = bftmp1 */ - } - - /* restore original values */ - bflength = orig_bflength; - bnlength = orig_bnlength; - padding = orig_padding; - rlength = orig_rlength; - shiftfactor = orig_shiftfactor; - rbflength = orig_rbflength; - r = orig_r; - n = orig_n; - /* bftmp1 = orig_bftmp1; */ - - if (signflag) - { - neg_a_bf(r); - } - rexp = (S16)big_access16(r+bflength); - rexp -= fexp; - big_set16(r+bflength, (S16)rexp); /* adjust result exponent */ - return r; - } - -/********************************************************************/ -/* r = n1/n2 */ -/* r - result of length bflength */ -/* uses bftmp1 - bftmp2 - global temp bigfloats */ -/* SIDE-EFFECTS: */ -/* n1, n2 end up as |n1|/256^x, |n2|/256^x */ -/* Make copies first if necessary. */ -bf_t unsafe_div_bf(bf_t r, bf_t n1, bf_t n2) - { - int aexp, bexp, rexp; - LDBL a, b; - - /* first, check for valid data */ - - aexp = (S16)big_access16(n1+bflength); - big_set16(n1+bflength, (S16)0); /* put within LDBL range */ - - a = bftofloat(n1); - if (a == 0) /* division into zero */ - { - clear_bf(r); /* return 0 */ - return r; - } - - bexp = (S16)big_access16(n2+bflength); - big_set16(n2+bflength, (S16)0); /* put within LDBL range */ - - b = bftofloat(n2); - if (b == 0) /* division by zero */ - { - max_bf(r); - return r; - } - - unsafe_inv_bf(r, n2); - unsafe_mult_bf(bftmp1, n1, r); - copy_bf(r, bftmp1); /* r = bftmp1 */ - - rexp = (S16)big_access16(r+bflength); - rexp += aexp - bexp; - big_set16(r+bflength, (S16)rexp); /* adjust result exponent */ - - return r; - } - -/********************************************************************/ -/* sqrt(r) */ -/* uses bftmp1 - bftmp3 - global temp bigfloats */ -/* SIDE-EFFECTS: */ -/* n ends up as |n| */ -bf_t unsafe_sqrt_bf(bf_t r, bf_t n) - { - int i, comp, almost_match=0; - LDBL f; - bf_t orig_r, orig_n; - int orig_bflength, - orig_bnlength, - orig_padding, - orig_rlength, - orig_shiftfactor, - orig_rbflength; - -/* use Newton's recursive method for zeroing in on sqrt(n): r=.5(r+n/r) */ - - if (is_bf_neg(n)) - { /* sqrt of a neg, return 0 */ - clear_bf(r); - return r; - } - - f = bftofloat(n); - if (f == 0) /* division by zero will occur */ - { - clear_bf(r); /* sqrt(0) = 0 */ - return r; - } - f = sqrtl(f); /* approximate square root */ - /* no need to check overflow */ - - /* With Newton's Method, there is no need to calculate all the digits */ - /* every time. The precision approximately doubles each iteration. */ - /* Save original values. */ - orig_bflength = bflength; - orig_bnlength = bnlength; - orig_padding = padding; - orig_rlength = rlength; - orig_shiftfactor = shiftfactor; - orig_rbflength = rbflength; - orig_r = r; - orig_n = n; - - /* calculate new starting values */ - bnlength = intlength + (int)(LDBL_DIG/LOG10_256) + 1; /* round up */ - if (bnlength > orig_bnlength) - bnlength = orig_bnlength; - calc_lengths(); - - /* adjust pointers */ - r = orig_r + orig_bflength - bflength; - n = orig_n + orig_bflength - bflength; - - floattobf(r, f); /* start with approximate sqrt */ - - for (i=0; i<25; i++) /* safety net, this shouldn't ever be needed */ - { - /* adjust lengths */ - bnlength <<= 1; /* double precision */ - if (bnlength > orig_bnlength) - bnlength = orig_bnlength; - calc_lengths(); - r = orig_r + orig_bflength - bflength; - n = orig_n + orig_bflength - bflength; - - unsafe_div_bf(bftmp3, n, r); - unsafe_add_a_bf(r, bftmp3); - half_a_bf(r); - if (bflength == orig_bflength && (comp=abs(cmp_bf(r, bftmp3))) < 8 ) /* if match or almost match */ - { - if (comp < 4 /* perfect or near perfect match */ - || almost_match == 1) /* close enough for 2nd time */ - break; - else /* this is the first time they almost matched */ - almost_match++; - } - } - - /* restore original values */ - bflength = orig_bflength; - bnlength = orig_bnlength; - padding = orig_padding; - rlength = orig_rlength; - shiftfactor = orig_shiftfactor; - rbflength = orig_rbflength; - r = orig_r; - n = orig_n; - - return r; - } - -/********************************************************************/ -/* exp(r) */ -/* uses bftmp1, bftmp2, bftmp3 - global temp bigfloats */ -bf_t exp_bf(bf_t r, bf_t n) - { - U16 fact=1; - S16 BIGDIST * testexp, BIGDIST * rexp; - - testexp = (S16 BIGDIST *)(bftmp2+bflength); - rexp = (S16 BIGDIST *)(r+bflength); - - if (is_bf_zero(n)) - { - inttobf(r, 1); - return r; - } - -/* use Taylor Series (very slow convergence) */ - inttobf(r, 1); /* start with r=1.0 */ - copy_bf(bftmp2, r); - for (;;) - { - copy_bf(bftmp1, n); - unsafe_mult_bf(bftmp3, bftmp2, bftmp1); - unsafe_div_bf_int(bftmp2, bftmp3, fact); - if (big_accessS16(testexp) < big_accessS16(rexp)-(bflength-2)) - break; /* too small to register */ - unsafe_add_a_bf(r, bftmp2); - fact++; - } - - return r; - } - -/********************************************************************/ -/* ln(r) */ -/* uses bftmp1 - bftmp6 - global temp bigfloats */ -/* SIDE-EFFECTS: */ -/* n ends up as |n| */ -bf_t unsafe_ln_bf(bf_t r, bf_t n) - { - int i, comp, almost_match=0; - LDBL f; - bf_t orig_r, orig_n, orig_bftmp5; - int orig_bflength, - orig_bnlength, - orig_padding, - orig_rlength, - orig_shiftfactor, - orig_rbflength; - -/* use Newton's recursive method for zeroing in on ln(n): r=r+n*exp(-r)-1 */ - - if (is_bf_neg(n) || is_bf_zero(n)) - { /* error, return largest neg value */ - max_bf(r); - neg_a_bf(r); - return r; - } - - f = bftofloat(n); - f = logl(f); /* approximate ln(x) */ - /* no need to check overflow */ - /* appears to be ok, do ln */ - - /* With Newton's Method, there is no need to calculate all the digits */ - /* every time. The precision approximately doubles each iteration. */ - /* Save original values. */ - orig_bflength = bflength; - orig_bnlength = bnlength; - orig_padding = padding; - orig_rlength = rlength; - orig_shiftfactor = shiftfactor; - orig_rbflength = rbflength; - orig_r = r; - orig_n = n; - orig_bftmp5 = bftmp5; - - /* calculate new starting values */ - bnlength = intlength + (int)(LDBL_DIG/LOG10_256) + 1; /* round up */ - if (bnlength > orig_bnlength) - bnlength = orig_bnlength; - calc_lengths(); - - /* adjust pointers */ - r = orig_r + orig_bflength - bflength; - n = orig_n + orig_bflength - bflength; - bftmp5 = orig_bftmp5 + orig_bflength - bflength; - - floattobf(r, f); /* start with approximate ln */ - neg_a_bf(r); /* -r */ - copy_bf(bftmp5, r); /* -r */ - - for (i=0; i<25; i++) /* safety net, this shouldn't ever be needed */ - { - /* adjust lengths */ - bnlength <<= 1; /* double precision */ - if (bnlength > orig_bnlength) - bnlength = orig_bnlength; - calc_lengths(); - r = orig_r + orig_bflength - bflength; - n = orig_n + orig_bflength - bflength; - bftmp5 = orig_bftmp5 + orig_bflength - bflength; - - exp_bf(bftmp6, r); /* exp(-r) */ - unsafe_mult_bf(bftmp2, bftmp6, n); /* n*exp(-r) */ - inttobf(bftmp4, 1); - unsafe_sub_a_bf(bftmp2, bftmp4); /* n*exp(-r) - 1 */ - unsafe_sub_a_bf(r, bftmp2); /* -r - (n*exp(-r) - 1) */ - if (bflength == orig_bflength && (comp=abs(cmp_bf(r, bftmp5))) < 8 ) /* if match or almost match */ - { - if (comp < 4 /* perfect or near perfect match */ - || almost_match == 1) /* close enough for 2nd time */ - break; - else /* this is the first time they almost matched */ - almost_match++; - } - copy_bf(bftmp5, r); /* -r */ - } - - /* restore original values */ - bflength = orig_bflength; - bnlength = orig_bnlength; - padding = orig_padding; - rlength = orig_rlength; - shiftfactor = orig_shiftfactor; - rbflength = orig_rbflength; - r = orig_r; - n = orig_n; - bftmp5 = orig_bftmp5; - - neg_a_bf(r); /* -(-r) */ - return r; - } - -/********************************************************************/ -/* sincos_bf(r) */ -/* uses bftmp1 - bftmp2 - global temp bigfloats */ -/* SIDE-EFFECTS: */ -/* n ends up as |n| mod (pi/4) */ -bf_t unsafe_sincos_bf(bf_t s, bf_t c, bf_t n) - { - U16 fact=2; - int k=0, i, halves; - int signcos=0, signsin=0, switch_sincos=0; - int sin_done=0, cos_done=0; - S16 BIGDIST * testexp, BIGDIST * cexp, BIGDIST * sexp; - - testexp = (S16 BIGDIST *)(bftmp1+bflength); - cexp = (S16 BIGDIST *)(c+bflength); - sexp = (S16 BIGDIST *)(s+bflength); - -#ifndef CALCULATING_BIG_PI - /* assure range 0 <= x < pi/4 */ - - if (is_bf_zero(n)) - { - clear_bf(s); /* sin(0) = 0 */ - inttobf(c, 1); /* cos(0) = 1 */ - return s; - } - - if (is_bf_neg(n)) - { - signsin = !signsin; /* sin(-x) = -sin(x), odd; cos(-x) = cos(x), even */ - neg_a_bf(n); - } - /* n >= 0 */ - - double_bf(bftmp1, bf_pi); /* 2*pi */ - /* this could be done with remainders, but it would probably be slower */ - while (cmp_bf(n, bftmp1) >= 0) /* while n >= 2*pi */ - { - copy_bf(bftmp2, bftmp1); - unsafe_sub_a_bf(n, bftmp2); - } - /* 0 <= n < 2*pi */ - - copy_bf(bftmp1, bf_pi); /* pi */ - if (cmp_bf(n, bftmp1) >= 0) /* if n >= pi */ - { - unsafe_sub_a_bf(n, bftmp1); - signsin = !signsin; - signcos = !signcos; - } - /* 0 <= n < pi */ - - half_bf(bftmp1, bf_pi); /* pi/2 */ - if (cmp_bf(n, bftmp1) > 0) /* if n > pi/2 */ - { - copy_bf(bftmp2, bf_pi); - unsafe_sub_bf(n, bftmp2, n); - signcos = !signcos; - } - /* 0 <= n < pi/2 */ - - half_bf(bftmp1, bf_pi); /* pi/2 */ - half_a_bf(bftmp1); /* pi/4 */ - if (cmp_bf(n, bftmp1) > 0) /* if n > pi/4 */ - { - copy_bf(bftmp2, n); - half_bf(bftmp1, bf_pi); /* pi/2 */ - unsafe_sub_bf(n, bftmp1, bftmp2); /* pi/2 - n */ - switch_sincos = !switch_sincos; - } - /* 0 <= n < pi/4 */ - - /* this looks redundant, but n could now be zero when it wasn't before */ - if (is_bf_zero(n)) - { - clear_bf(s); /* sin(0) = 0 */ - inttobf(c, 1); /* cos(0) = 1 */ - return s; - } - - -/* at this point, the double angle trig identities could be used as many */ -/* times as desired to reduce the range to pi/8, pi/16, etc... Each time */ -/* the range is cut in half, the number of iterations required is reduced */ -/* by "quite a bit." It's just a matter of testing to see what gives the */ -/* optimal results. */ - /* halves = bflength / 10; */ /* this is experimental */ - halves = 1; - for (i = 0; i < halves; i++) - half_a_bf(n); -#endif - -/* use Taylor Series (very slow convergence) */ - copy_bf(s, n); /* start with s=n */ - inttobf(c, 1); /* start with c=1 */ - copy_bf(bftmp1, n); /* the current x^n/n! */ - do - { - /* even terms for cosine */ - copy_bf(bftmp2, bftmp1); - unsafe_mult_bf(bftmp1, bftmp2, n); - div_a_bf_int(bftmp1, fact++); - if (!cos_done) - { - cos_done = (big_accessS16(testexp) < big_accessS16(cexp)-(bflength-2)); /* too small to register */ - if (!cos_done) - { - if (k) /* alternate between adding and subtracting */ - unsafe_add_a_bf(c, bftmp1); - else - unsafe_sub_a_bf(c, bftmp1); - } - } - - /* odd terms for sine */ - copy_bf(bftmp2, bftmp1); - unsafe_mult_bf(bftmp1, bftmp2, n); - div_a_bf_int(bftmp1, fact++); - if (!sin_done) - { - sin_done = (big_accessS16(testexp) < big_accessS16(sexp)-(bflength-2)); /* too small to register */ - if (!sin_done) - { - if (k) /* alternate between adding and subtracting */ - unsafe_add_a_bf(s, bftmp1); - else - unsafe_sub_a_bf(s, bftmp1); - } - } - k = !k; /* toggle */ -#if defined(CALCULATING_BIG_PI) && !defined(_WIN32) - printf("."); /* lets you know it's doing something */ -#endif - } while (!cos_done || !sin_done); - -#ifndef CALCULATING_BIG_PI - /* now need to undo what was done by cutting angles in half */ - for (i = 0; i < halves; i++) - { - unsafe_mult_bf(bftmp2, s, c); /* no need for safe mult */ - double_bf(s, bftmp2); /* sin(2x) = 2*sin(x)*cos(x) */ - unsafe_square_bf(bftmp2,c); - double_a_bf(bftmp2); - inttobf(bftmp1, 1); - unsafe_sub_bf(c, bftmp2, bftmp1); /* cos(2x) = 2*cos(x)*cos(x) - 1 */ - } - - if (switch_sincos) - { - copy_bf(bftmp1, s); - copy_bf(s, c); - copy_bf(c, bftmp1); - } - if (signsin) - neg_a_bf(s); - if (signcos) - neg_a_bf(c); -#endif - - return s; /* return sine I guess */ - } - -/********************************************************************/ -/* atan(r) */ -/* uses bftmp1 - bftmp5 - global temp bigfloats */ -/* SIDE-EFFECTS: */ -/* n ends up as |n| or 1/|n| */ -bf_t unsafe_atan_bf(bf_t r, bf_t n) - { - int i, comp, almost_match=0, signflag=0; - LDBL f; - bf_t orig_r, orig_n, orig_bf_pi, orig_bftmp3; - int orig_bflength, - orig_bnlength, - orig_padding, - orig_rlength, - orig_shiftfactor, - orig_rbflength; - int large_arg; - - -/* use Newton's recursive method for zeroing in on atan(n): r=r-cos(r)(sin(r)-n*cos(r)) */ - - if (is_bf_neg(n)) - { - signflag = 1; - neg_a_bf(n); - } - -/* If n is very large, atanl() won't give enough decimal places to be a */ -/* good enough initial guess for Newton's Method. If it is larger than */ -/* say, 1, atan(n) = pi/2 - acot(n) = pi/2 - atan(1/n). */ - - f = bftofloat(n); - large_arg = f > 1.0; - if (large_arg) - { - unsafe_inv_bf(bftmp3, n); - copy_bf(n, bftmp3); - f = bftofloat(n); - } - - clear_bf(bftmp3); /* not really necessary, but makes things more consistent */ - - /* With Newton's Method, there is no need to calculate all the digits */ - /* every time. The precision approximately doubles each iteration. */ - /* Save original values. */ - orig_bflength = bflength; - orig_bnlength = bnlength; - orig_padding = padding; - orig_rlength = rlength; - orig_shiftfactor = shiftfactor; - orig_rbflength = rbflength; - orig_bf_pi = bf_pi; - orig_r = r; - orig_n = n; - orig_bftmp3 = bftmp3; - - /* calculate new starting values */ - bnlength = intlength + (int)(LDBL_DIG/LOG10_256) + 1; /* round up */ - if (bnlength > orig_bnlength) - bnlength = orig_bnlength; - calc_lengths(); - - /* adjust pointers */ - r = orig_r + orig_bflength - bflength; - n = orig_n + orig_bflength - bflength; - bf_pi = orig_bf_pi + orig_bflength - bflength; - bftmp3 = orig_bftmp3 + orig_bflength - bflength; - - f = atanl(f); /* approximate arctangent */ - /* no need to check overflow */ - - floattobf(r, f); /* start with approximate atan */ - copy_bf(bftmp3, r); - - for (i=0; i<25; i++) /* safety net, this shouldn't ever be needed */ - { - /* adjust lengths */ - bnlength <<= 1; /* double precision */ - if (bnlength > orig_bnlength) - bnlength = orig_bnlength; - calc_lengths(); - r = orig_r + orig_bflength - bflength; - n = orig_n + orig_bflength - bflength; - bf_pi = orig_bf_pi + orig_bflength - bflength; - bftmp3 = orig_bftmp3 + orig_bflength - bflength; - -#if defined(CALCULATING_BIG_PI) && !defined(_WIN32) - printf("\natan() loop #%i, bflength=%i\nsincos() loops\n", i, bflength); -#endif - unsafe_sincos_bf(bftmp4, bftmp5, bftmp3); /* sin(r), cos(r) */ - copy_bf(bftmp3, r); /* restore bftmp3 from sincos_bf() */ - copy_bf(bftmp1, bftmp5); - unsafe_mult_bf(bftmp2, n, bftmp1); /* n*cos(r) */ - unsafe_sub_a_bf(bftmp4, bftmp2); /* sin(r) - n*cos(r) */ - unsafe_mult_bf(bftmp1, bftmp5, bftmp4); /* cos(r) * (sin(r) - n*cos(r)) */ - copy_bf(bftmp3, r); - unsafe_sub_a_bf(r, bftmp1); /* r - cos(r) * (sin(r) - n*cos(r)) */ -#if defined(CALCULATING_BIG_PI) && !defined(_WIN32) - putchar('\n'); - bf_hexdump(r); -#endif - if (bflength == orig_bflength && (comp=abs(cmp_bf(r, bftmp3))) < 8 ) /* if match or almost match */ - { -#if defined(CALCULATING_BIG_PI) && !defined(_WIN32) - printf("atan() loop comp=%i\n", comp); -#endif - if (comp < 4 /* perfect or near perfect match */ - || almost_match == 1) /* close enough for 2nd time */ - break; - else /* this is the first time they almost matched */ - almost_match++; - } - -#if defined(CALCULATING_BIG_PI) && !defined(_WIN32) - if (bflength == orig_bflength && comp >= 8) - printf("atan() loop comp=%i\n", comp); -#endif - - copy_bf(bftmp3, r); /* make a copy for later comparison */ - } - - /* restore original values */ - bflength = orig_bflength; - bnlength = orig_bnlength; - padding = orig_padding; - rlength = orig_rlength; - shiftfactor = orig_shiftfactor; - rbflength = orig_rbflength; - bf_pi = orig_bf_pi; - r = orig_r; - n = orig_n; - bftmp3 = orig_bftmp3; - - if (large_arg) - { - half_bf(bftmp3, bf_pi); /* pi/2 */ - sub_a_bf(bftmp3, r); /* pi/2 - atan(1/n) */ - copy_bf(r, bftmp3); - } - - if (signflag) - neg_a_bf(r); - return r; - } - -/********************************************************************/ -/* atan2(r,ny,nx) */ -/* uses bftmp1 - bftmp6 - global temp bigfloats */ -bf_t unsafe_atan2_bf(bf_t r, bf_t ny, bf_t nx) - { - int signx, signy; - - signx = sign_bf(nx); - signy = sign_bf(ny); - - if (signy == 0) - { - if (signx < 0) - copy_bf(r, bf_pi); /* negative x axis, 180 deg */ - else /* signx >= 0 positive x axis, 0 */ - clear_bf(r); - return(r); - } - if (signx == 0) - { - copy_bf(r, bf_pi); /* y axis */ - half_a_bf(r); /* +90 deg */ - if (signy < 0) - neg_a_bf(r); /* -90 deg */ - return(r); - } - - if (signy < 0) - neg_a_bf(ny); - if (signx < 0) - neg_a_bf(nx); - unsafe_div_bf(bftmp6,ny,nx); - unsafe_atan_bf(r, bftmp6); - if (signx < 0) - sub_bf(r,bf_pi,r); - if (signy < 0) - neg_a_bf(r); - return(r); - } - -/**********************************************************************/ -/* The rest of the functions are "safe" versions of the routines that */ -/* have side effects which alter the parameters. */ -/* Most bf routines change values of parameters, not just the sign. */ -/**********************************************************************/ - -/**********************************************************************/ -bf_t add_bf(bf_t r, bf_t n1, bf_t n2) - { - copy_bf(bftmpcpy1, n1); - copy_bf(bftmpcpy2, n2); - unsafe_add_bf(r, bftmpcpy1, bftmpcpy2); - return r; - } - -/**********************************************************************/ -bf_t add_a_bf(bf_t r, bf_t n) - { - copy_bf(bftmpcpy1, n); - unsafe_add_a_bf(r, bftmpcpy1); - return r; - } - -/**********************************************************************/ -bf_t sub_bf(bf_t r, bf_t n1, bf_t n2) - { - copy_bf(bftmpcpy1, n1); - copy_bf(bftmpcpy2, n2); - unsafe_sub_bf(r, bftmpcpy1, bftmpcpy2); - return r; - } - -/**********************************************************************/ -bf_t sub_a_bf(bf_t r, bf_t n) - { - copy_bf(bftmpcpy1, n); - unsafe_sub_a_bf(r, bftmpcpy1); - return r; - } - -/**********************************************************************/ -/* mult and div only change sign */ -bf_t full_mult_bf(bf_t r, bf_t n1, bf_t n2) - { - copy_bf(bftmpcpy1, n1); - copy_bf(bftmpcpy2, n2); - unsafe_full_mult_bf(r, bftmpcpy1, bftmpcpy2); - return r; - } - -/**********************************************************************/ -bf_t mult_bf(bf_t r, bf_t n1, bf_t n2) - { - copy_bf(bftmpcpy1, n1); - copy_bf(bftmpcpy2, n2); - unsafe_mult_bf(r, bftmpcpy1, bftmpcpy2); - return r; - } - -/**********************************************************************/ -bf_t full_square_bf(bf_t r, bf_t n) - { - copy_bf(bftmpcpy1, n); - unsafe_full_square_bf(r, bftmpcpy1); - return r; - } - -/**********************************************************************/ -bf_t square_bf(bf_t r, bf_t n) - { - copy_bf(bftmpcpy1, n); - unsafe_square_bf(r, bftmpcpy1); - return r; - } - -/**********************************************************************/ -bf_t mult_bf_int(bf_t r, bf_t n, U16 u) - { - copy_bf(bftmpcpy1, n); - unsafe_mult_bf_int(r, bftmpcpy1, u); - return r; - } - -/**********************************************************************/ -bf_t div_bf_int(bf_t r, bf_t n, U16 u) - { - copy_bf(bftmpcpy1, n); - unsafe_div_bf_int(r, bftmpcpy1, u); - return r; - } - -/**********************************************************************/ -char *bftostr(char *s, int dec, bf_t r) - { - copy_bf(bftmpcpy1, r); - unsafe_bftostr(s, dec, bftmpcpy1); - return s; - } - -/**********************************************************************/ -char *bftostr_e(char *s, int dec, bf_t r) - { - copy_bf(bftmpcpy1, r); - unsafe_bftostr_e(s, dec, bftmpcpy1); - return s; - } - -/**********************************************************************/ -char *bftostr_f(char *s, int dec, bf_t r) - { - copy_bf(bftmpcpy1, r); - unsafe_bftostr_f(s, dec, bftmpcpy1); - return s; - } - -/**********************************************************************/ -bf_t inv_bf(bf_t r, bf_t n) - { - copy_bf(bftmpcpy1, n); - unsafe_inv_bf(r, bftmpcpy1); - return r; - } - -/**********************************************************************/ -bf_t div_bf(bf_t r, bf_t n1, bf_t n2) - { - copy_bf(bftmpcpy1, n1); - copy_bf(bftmpcpy2, n2); - unsafe_div_bf(r, bftmpcpy1, bftmpcpy2); - return r; - } - -/**********************************************************************/ -bf_t sqrt_bf(bf_t r, bf_t n) - { - copy_bf(bftmpcpy1, n); - unsafe_sqrt_bf(r, bftmpcpy1); - return r; - } - -/**********************************************************************/ -bf_t ln_bf(bf_t r, bf_t n) - { - copy_bf(bftmpcpy1, n); - unsafe_ln_bf(r, bftmpcpy1); - return r; - } - -/**********************************************************************/ -bf_t sincos_bf(bf_t s, bf_t c, bf_t n) - { - copy_bf(bftmpcpy1, n); - return unsafe_sincos_bf(s, c, bftmpcpy1); - } - -/**********************************************************************/ -bf_t atan_bf(bf_t r, bf_t n) - { - copy_bf(bftmpcpy1, n); - unsafe_atan_bf(r, bftmpcpy1); - return r; - } - -/**********************************************************************/ -bf_t atan2_bf(bf_t r, bf_t ny, bf_t nx) - { - copy_bf(bftmpcpy1, ny); - copy_bf(bftmpcpy2, nx); - unsafe_atan2_bf(r, bftmpcpy1, bftmpcpy2); - return r; - } - -/**********************************************************************/ -int is_bf_zero(bf_t n) - { - return !is_bf_not_zero(n); - } - -/************************************************************************/ -/* convert_bf -- convert bigfloat numbers from old to new lengths */ -int convert_bf(bf_t newnum, bf_t old, int newbflength, int oldbflength) - { - int savebflength; - - /* save lengths so not dependent on external environment */ - savebflength = bflength; - bflength = newbflength; - clear_bf(newnum); - bflength = savebflength; - - if (newbflength > oldbflength) - memcpy(newnum+newbflength-oldbflength,old,oldbflength+2); - else - memcpy(newnum,old+oldbflength-newbflength,newbflength+2); - return(0); - } - -/* The following used to be in bigfltc.c */ -/********************************************************************/ -/* normalize big float */ -bf_t norm_bf(bf_t r) - { - int scale; - BYTE hi_byte; - S16 BIGDIST *rexp; - - rexp = (S16 BIGDIST *)(r+bflength); - - /* check for overflow */ - hi_byte = r[bflength-1]; - if (hi_byte != 0x00 && hi_byte != 0xFF) - { - memmove(r, r+1, bflength-1); - r[bflength-1] = (BYTE)(hi_byte & 0x80 ? 0xFF : 0x00); - big_setS16(rexp,big_accessS16(rexp)+(S16)1); /* exp */ - } - - /* check for underflow */ - else - { - for (scale = 2; scale < bflength && r[bflength-scale] == hi_byte; scale++) - ; /* do nothing */ - if (scale == bflength && hi_byte == 0) /* zero */ - big_setS16(rexp,0); - else - { - scale -= 2; - if (scale > 0) /* it did underflow */ - { - memmove(r+scale, r, bflength-scale-1); - memset(r, 0, scale); - big_setS16(rexp,big_accessS16(rexp)-(S16)scale); /* exp */ - } - } - } - - return r; - } - -/********************************************************************/ -/* normalize big float with forced sign */ -/* positive = 1, force to be positive */ -/* = 0, force to be negative */ -void norm_sign_bf(bf_t r, int positive) - { - norm_bf(r); - r[bflength-1] = (BYTE)(positive ? 0x00 : 0xFF); - } -/******************************************************/ -/* adjust n1, n2 for before addition or subtraction */ -/* by forcing exp's to match. */ -/* returns the value of the adjusted exponents */ -S16 adjust_bf_add(bf_t n1, bf_t n2) - { - int scale, fill_byte; - S16 rexp; - S16 BIGDIST *n1exp, BIGDIST *n2exp; - - /* scale n1 or n2 */ - /* compare exp's */ - n1exp = (S16 BIGDIST *)(n1+bflength); - n2exp = (S16 BIGDIST *)(n2+bflength); - if (big_accessS16(n1exp) > big_accessS16(n2exp)) - { /* scale n2 */ - scale = big_accessS16(n1exp) - big_accessS16(n2exp); /* n1exp - n2exp */ - if (scale < bflength) - { - fill_byte = is_bf_neg(n2) ? 0xFF : 0x00; - memmove(n2, n2+scale, bflength-scale); - memset(n2+bflength-scale, fill_byte, scale); - } - else - clear_bf(n2); - big_setS16(n2exp,big_accessS16(n1exp)); /* *n2exp = *n1exp; set exp's = */ - rexp = big_accessS16(n2exp); - } - else if (big_accessS16(n1exp) < big_accessS16(n2exp)) - { /* scale n1 */ - scale = big_accessS16(n2exp) - big_accessS16(n1exp); /* n2exp - n1exp */ - if (scale < bflength) - { - fill_byte = is_bf_neg(n1) ? 0xFF : 0x00; - memmove(n1, n1+scale, bflength-scale); - memset(n1+bflength-scale, fill_byte, scale); - } - else - clear_bf(n1); - big_setS16(n1exp,big_accessS16(n2exp)); /* *n1exp = *n2exp; set exp's = */ - rexp = big_accessS16(n2exp); - } - else - rexp = big_accessS16(n1exp); - return rexp; - } - -/********************************************************************/ -/* r = max positive value */ -bf_t max_bf(bf_t r) - { - inttobf(r, 1); - big_set16(r+bflength, (S16)(LDBL_MAX_EXP/8)); - return r; - } - -/****************************************************************************/ -/* n1 != n2 ? */ -/* RETURNS: */ -/* if n1 == n2 returns 0 */ -/* if n1 > n2 returns a positive (bytes left to go when mismatch occurred) */ -/* if n1 < n2 returns a negative (bytes left to go when mismatch occurred) */ - -int cmp_bf(bf_t n1, bf_t n2) - { - int i; - int sign1, sign2; - S16 BIGDIST *n1exp, BIGDIST *n2exp; - U16 value1, value2; - - - /* compare signs */ - sign1 = sign_bf(n1); - sign2 = sign_bf(n2); - if (sign1 > sign2) - return bflength; - else if (sign1 < sign2) - return -bflength; - /* signs are the same */ - - /* compare exponents, using signed comparisons */ - n1exp = (S16 BIGDIST *)(n1+bflength); - n2exp = (S16 BIGDIST *)(n2+bflength); - if (big_accessS16(n1exp) > big_accessS16(n2exp)) - return sign1*(bflength); - else if (big_accessS16(n1exp) < big_accessS16(n2exp)) - return -sign1*(bflength); - - /* To get to this point, the signs must match */ - /* so unsigned comparison is ok. */ - /* two bytes at a time */ - for (i=bflength-2; i>=0; i-=2) - { - if ( (value1=big_access16(n1+i)) > (value2=big_access16(n2+i)) ) - { /* now determine which of the two bytes was different */ - if ( (value1&0xFF00) > (value2&0xFF00) ) /* compare just high bytes */ - return (i+2); /* high byte was different */ - else - return (i+1); /* low byte was different */ - } - else if (value1 < value2) - { /* now determine which of the two bytes was different */ - if ( (value1&0xFF00) < (value2&0xFF00) ) /* compare just high bytes */ - return -(i+2); /* high byte was different */ - else - return -(i+1); /* low byte was different */ - } - } - return 0; - } - -/********************************************************************/ -/* r < 0 ? */ -/* returns 1 if negative, 0 if positive or zero */ -int is_bf_neg(bf_t n) - { - return (S8)n[bflength-1] < 0; - } - -/********************************************************************/ -/* n != 0 ? */ -/* RETURNS: if n != 0 returns 1 */ -/* else returns 0 */ -int is_bf_not_zero(bf_t n) - { - int bnl; - int retval; - - bnl = bnlength; - bnlength = bflength; - retval = is_bn_not_zero(n); - bnlength = bnl; - - return retval; - } - -/********************************************************************/ -/* r = n1 + n2 */ -/* SIDE-EFFECTS: n1 and n2 can be "de-normalized" and lose precision */ -bf_t unsafe_add_bf(bf_t r, bf_t n1, bf_t n2) - { - int bnl; - S16 BIGDIST *rexp; - - if (is_bf_zero(n1)) - { - copy_bf(r, n2); - return r; - } - if (is_bf_zero(n2)) - { - copy_bf(r, n1); - return r; - } - - rexp = (S16 BIGDIST *)(r+bflength); - big_setS16(rexp,adjust_bf_add(n1, n2)); - - bnl = bnlength; - bnlength = bflength; - add_bn(r, n1, n2); - bnlength = bnl; - - norm_bf(r); - return r; - } - -/********************************************************************/ -/* r += n */ -bf_t unsafe_add_a_bf(bf_t r, bf_t n) - { - int bnl; - - if (is_bf_zero(r)) - { - copy_bf(r, n); - return r; - } - if (is_bf_zero(n)) - { - return r; - } - - adjust_bf_add(r, n); - - bnl = bnlength; - bnlength = bflength; - add_a_bn(r, n); - bnlength = bnl; - - norm_bf(r); - - return r; - } - -/********************************************************************/ -/* r = n1 - n2 */ -/* SIDE-EFFECTS: n1 and n2 can be "de-normalized" and lose precision */ -bf_t unsafe_sub_bf(bf_t r, bf_t n1, bf_t n2) - { - int bnl; - S16 BIGDIST *rexp; - - if (is_bf_zero(n1)) - { - neg_bf(r, n2); - return r; - } - if (is_bf_zero(n2)) - { - copy_bf(r, n1); - return r; - } - - rexp = (S16 BIGDIST *)(r+bflength); - big_setS16(rexp,adjust_bf_add(n1, n2)); - - bnl = bnlength; - bnlength = bflength; - sub_bn(r, n1, n2); - bnlength = bnl; - - norm_bf(r); - return r; - } - -/********************************************************************/ -/* r -= n */ -bf_t unsafe_sub_a_bf(bf_t r, bf_t n) - { - int bnl; - - if (is_bf_zero(r)) - { - neg_bf(r,n); - return r; - } - if (is_bf_zero(n)) - { - return r; - } - - adjust_bf_add(r, n); - - bnl = bnlength; - bnlength = bflength; - sub_a_bn(r, n); - bnlength = bnl; - - norm_bf(r); - return r; - } - -/********************************************************************/ -/* r = -n */ -bf_t neg_bf(bf_t r, bf_t n) - { - int bnl; - S16 BIGDIST *rexp, BIGDIST *nexp; - - rexp = (S16 BIGDIST *)(r+bflength); - nexp = (S16 BIGDIST *)(n+bflength); - big_setS16(rexp, big_accessS16(nexp)); /* *rexp = *nexp; */ - - bnl = bnlength; - bnlength = bflength; - neg_bn(r, n); - bnlength = bnl; - - norm_bf(r); - return r; - } - -/********************************************************************/ -/* r *= -1 */ -bf_t neg_a_bf(bf_t r) - { - int bnl; - - bnl = bnlength; - bnlength = bflength; - neg_a_bn(r); - bnlength = bnl; - - norm_bf(r); - return r; - } - -/********************************************************************/ -/* r = 2*n */ -bf_t double_bf(bf_t r, bf_t n) - { - int bnl; - S16 BIGDIST *rexp, BIGDIST *nexp; - - rexp = (S16 BIGDIST *)(r+bflength); - nexp = (S16 BIGDIST *)(n+bflength); - big_setS16(rexp, big_accessS16(nexp)); /* *rexp = *nexp; */ - - bnl = bnlength; - bnlength = bflength; - double_bn(r, n); - bnlength = bnl; - - norm_bf(r); - return r; - } - -/********************************************************************/ -/* r *= 2 */ -bf_t double_a_bf(bf_t r) - { - int bnl; - - bnl = bnlength; - bnlength = bflength; - double_a_bn(r); - bnlength = bnl; - - norm_bf(r); - return r; - } - -/********************************************************************/ -/* r = n/2 */ -bf_t half_bf(bf_t r, bf_t n) - { - int bnl; - S16 BIGDIST *rexp, BIGDIST *nexp; - - rexp = (S16 BIGDIST *)(r+bflength); - nexp = (S16 BIGDIST *)(n+bflength); - big_setS16(rexp, big_accessS16(nexp)); /* *rexp = *nexp; */ - - bnl = bnlength; - bnlength = bflength; - half_bn(r, n); - bnlength = bnl; - - norm_bf(r); - return r; - } - -/********************************************************************/ -/* r /= 2 */ -bf_t half_a_bf(bf_t r) - { - int bnl; - - bnl = bnlength; - bnlength = bflength; - half_a_bn(r); - bnlength = bnl; - - norm_bf(r); - return r; - } - -/************************************************************************/ -/* r = n1 * n2 */ -/* Note: r will be a double wide result, 2*bflength */ -/* n1 and n2 can be the same pointer */ -/* SIDE-EFFECTS: n1 and n2 are changed to their absolute values */ -bf_t unsafe_full_mult_bf(bf_t r, bf_t n1, bf_t n2) - { - int bnl, dbfl; - S16 BIGDIST *rexp, BIGDIST *n1exp, BIGDIST *n2exp; - - if (is_bf_zero(n1) || is_bf_zero(n2) ) - { - bflength <<= 1; - clear_bf(r); - bflength >>= 1; - return r; - } - - dbfl = 2*bflength; /* double width bflength */ - rexp = (S16 BIGDIST *)(r+dbfl); /* note: 2*bflength */ - n1exp = (S16 BIGDIST *)(n1+bflength); - n2exp = (S16 BIGDIST *)(n2+bflength); - /* add exp's */ - big_setS16(rexp, (S16)(big_accessS16(n1exp) + big_accessS16(n2exp)) ); - - bnl = bnlength; - bnlength = bflength; - unsafe_full_mult_bn(r, n1, n2); - bnlength = bnl; - - /* handle normalizing full mult on individual basis */ - - return r; - } - -/************************************************************************/ -/* r = n1 * n2 calculating only the top rlength bytes */ -/* Note: r will be of length rlength */ -/* 2*bflength <= rlength < bflength */ -/* n1 and n2 can be the same pointer */ -/* SIDE-EFFECTS: n1 and n2 are changed to their absolute values */ -bf_t unsafe_mult_bf(bf_t r, bf_t n1, bf_t n2) - { - int positive; - int bnl, bfl, rl; - int rexp; - S16 BIGDIST *n1exp, BIGDIST *n2exp; - - if (is_bf_zero(n1) || is_bf_zero(n2) ) - { - clear_bf(r); - return r; - } - - n1exp = (S16 BIGDIST *)(n1+bflength); - n2exp = (S16 BIGDIST *)(n2+bflength); - /* add exp's */ - rexp = big_accessS16(n1exp) + big_accessS16(n2exp); - - positive = (is_bf_neg(n1) == is_bf_neg(n2)); /* are they the same sign? */ - - bnl = bnlength; - bnlength = bflength; - rl = rlength; - rlength = rbflength; - unsafe_mult_bn(r, n1, n2); - bnlength = bnl; - rlength = rl; - - bfl = bflength; - bflength = rbflength; - big_set16(r+bflength, (S16)(rexp+2)); /* adjust after mult */ - norm_sign_bf(r, positive); - bflength = bfl; - memmove(r, r+padding, bflength+2); /* shift back */ - - return r; - } - -/************************************************************************/ -/* r = n^2 */ -/* because of the symmetry involved, n^2 is much faster than n*n */ -/* for a bignumber of length l */ -/* n*n takes l^2 multiplications */ -/* n^2 takes (l^2+l)/2 multiplications */ -/* which is about 1/2 n*n as l gets large */ -/* uses the fact that (a+b+c+...)^2 = (a^2+b^2+c^2+...)+2(ab+ac+bc+...)*/ -/* */ -/* SIDE-EFFECTS: n is changed to its absolute value */ -bf_t unsafe_full_square_bf(bf_t r, bf_t n) - { - int bnl, dbfl; - S16 BIGDIST *rexp, BIGDIST *nexp; - - if (is_bf_zero(n)) - { - bflength <<= 1; - clear_bf(r); - bflength >>= 1; - return r; - } - - dbfl = 2*bflength; /* double width bflength */ - rexp = (S16 BIGDIST *)(r+dbfl); /* note: 2*bflength */ - nexp = (S16 BIGDIST *)(n+bflength); - big_setS16(rexp, 2 * big_accessS16(nexp)); - - bnl = bnlength; - bnlength = bflength; - unsafe_full_square_bn(r, n); - bnlength = bnl; - - /* handle normalizing full mult on individual basis */ - - return r; - } - - -/************************************************************************/ -/* r = n^2 */ -/* because of the symmetry involved, n^2 is much faster than n*n */ -/* for a bignumber of length l */ -/* n*n takes l^2 multiplications */ -/* n^2 takes (l^2+l)/2 multiplications */ -/* which is about 1/2 n*n as l gets large */ -/* uses the fact that (a+b+c+...)^2 = (a^2+b^2+c^2+...)+2(ab+ac+bc+...)*/ -/* */ -/* Note: r will be of length rlength */ -/* 2*bflength >= rlength > bflength */ -/* SIDE-EFFECTS: n is changed to its absolute value */ -bf_t unsafe_square_bf(bf_t r, bf_t n) - { - int bnl, bfl, rl; - int rexp; - S16 BIGDIST *nexp; - - if (is_bf_zero(n)) - { - clear_bf(r); - return r; - } - - nexp = (S16 BIGDIST *)(n+bflength); - rexp = (S16)(2 * big_accessS16(nexp)); - - bnl = bnlength; - bnlength = bflength; - rl = rlength; - rlength = rbflength; - unsafe_square_bn(r, n); - bnlength = bnl; - rlength = rl; - - bfl = bflength; - bflength = rbflength; - big_set16(r+bflength, (S16)(rexp+2)); /* adjust after mult */ - - norm_sign_bf(r, 1); - bflength = bfl; - memmove(r, r+padding, bflength+2); /* shift back */ - - return r; - } - -/********************************************************************/ -/* r = n * u where u is an unsigned integer */ -/* SIDE-EFFECTS: n can be "de-normalized" and lose precision */ -bf_t unsafe_mult_bf_int(bf_t r, bf_t n, U16 u) - { - int positive; - int bnl; - S16 BIGDIST *rexp, BIGDIST *nexp; - - rexp = (S16 BIGDIST *)(r+bflength); - nexp = (S16 BIGDIST *)(n+bflength); - big_setS16(rexp, big_accessS16(nexp)); /* *rexp = *nexp; */ - - positive = !is_bf_neg(n); - -/* -if u > 0x00FF, then the integer part of the mantissa will overflow the -2 byte (16 bit) integer size. Therefore, make adjustment before -multiplication is performed. -*/ - if (u > 0x00FF) - { /* un-normalize n */ - memmove(n, n+1, bflength-1); /* this sign extends as well */ - big_setS16(rexp,big_accessS16(rexp)+(S16)1); - } - - bnl = bnlength; - bnlength = bflength; - mult_bn_int(r, n, u); - bnlength = bnl; - - norm_sign_bf(r, positive); - return r; - } - -/********************************************************************/ -/* r *= u where u is an unsigned integer */ -bf_t mult_a_bf_int(bf_t r, U16 u) - { - int positive; - int bnl; - S16 BIGDIST *rexp; - - rexp = (S16 BIGDIST *)(r+bflength); - positive = !is_bf_neg(r); - -/* -if u > 0x00FF, then the integer part of the mantissa will overflow the -2 byte (16 bit) integer size. Therefore, make adjustment before -multiplication is performed. -*/ - if (u > 0x00FF) - { /* un-normalize n */ - memmove(r, r+1, bflength-1); /* this sign extends as well */ - big_setS16(rexp,big_accessS16(rexp)+(S16)1); - } - - bnl = bnlength; - bnlength = bflength; - mult_a_bn_int(r, u); - bnlength = bnl; - - norm_sign_bf(r, positive); - return r; - } - -/********************************************************************/ -/* r = n / u where u is an unsigned integer */ -bf_t unsafe_div_bf_int(bf_t r, bf_t n, U16 u) - { - int bnl; - S16 BIGDIST *rexp, BIGDIST *nexp; - - if (u == 0) /* division by zero */ - { - max_bf(r); - if (is_bf_neg(n)) - neg_a_bf(r); - return r; - } - - rexp = (S16 BIGDIST *)(r+bflength); - nexp = (S16 BIGDIST *)(n+bflength); - big_setS16(rexp, big_accessS16(nexp)); /* *rexp = *nexp; */ - - bnl = bnlength; - bnlength = bflength; - unsafe_div_bn_int(r, n, u); - bnlength = bnl; - - norm_bf(r); - return r; - } - -/********************************************************************/ -/* r /= u where u is an unsigned integer */ -bf_t div_a_bf_int(bf_t r, U16 u) - { - int bnl; - - if (u == 0) /* division by zero */ - { - if (is_bf_neg(r)) - { - max_bf(r); - neg_a_bf(r); - } - else - { - max_bf(r); - } - return r; - } - - bnl = bnlength; - bnlength = bflength; - div_a_bn_int(r, u); - bnlength = bnl; - - norm_bf(r); - return r; - } - -/********************************************************************/ -/* extracts the mantissa and exponent of f */ -/* finds m and n such that 1<=|m|= 0 ? f: -f; /* abs value */ - ff = af > 1 ? af : 1/af; - n = 0; - powertwo = 1; - while (b < ff) - { - value[n] = b; - n++; - powertwo <<= 1; - b *= b; - } - - *exp_ptr = 0; - for (; n > 0; n--) - { - powertwo >>= 1; - if (value[n-1] < ff) - { - ff /= value[n-1]; - *exp_ptr += powertwo; - } - } - if (f < 0) - ff = -ff; - if (af < 1) - { - ff = orig_b/ff; - *exp_ptr = -*exp_ptr - 1; - } - - return ff; - } - -/********************************************************************/ -/* calculates and returns the value of f*b^n */ -/* sort of like ldexp() */ -LDBL scale_value( LDBL f, LDBL b , int n ) - { - LDBL total=1; - int an; - - if (b == 0 || f == 0) - return 0; - - if (n == 0) - return f; - - an = abs(n); - - while (an != 0) - { - if (an & 0x0001) - total *= b; - b *= b; - an >>= 1; - } - - if (n > 0) - f *= total; - else /* n < 0 */ - f /= total; - return f; - } - -/********************************************************************/ -/* extracts the mantissa and exponent of f */ -/* finds m and n such that 1<=|m|<10 and f = m*10^n */ -/* n is stored in *exp_ptr and m is returned, sort of like frexp() */ -LDBL extract_10(LDBL f, int *exp_ptr) - { - return extract_value(f, 10, exp_ptr); - } - -/********************************************************************/ -/* calculates and returns the value of f*10^n */ -/* sort of like ldexp() */ -LDBL scale_10( LDBL f, int n ) - { - return scale_value( f, 10, n ); - } - - - -/* big10flt.c - C routines for base 10 big floating point numbers */ - -/********************************************************** -(Just when you thought it was safe to go back in the water.) -Just when you thought you seen every type of format possible, -16 bit integer, 32 bit integer, double, long double, mpmath, -bn_t, bf_t, I now give you bf10_t (big float base 10)! - -Why, because this is the only way (I can think of) to properly do a -bftostr() without rounding errors. With out this, then - -1.9999999999( > LDBL_DIG of 9's)9999999123456789... -will round to -2.0. The good news is that we only need to do two -mathematical operations: multiplication and division by integers - -bf10_t format: (notice the position of the MSB and LSB) - -MSB LSB - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ -n <><------------- dec --------------><> <-> - 1 byte pad 1 byte rounding 2 byte exponent. - - total length = dec + 4 - -***********************************************************/ - -/**********************************************************************/ -/* unsafe_bftobf10() - converts a bigfloat into a bigfloat10 */ -/* n - pointer to a bigfloat */ -/* r - result array of BYTE big enough to hold the bf10_t number */ -/* dec - number of decimals, not including the one extra for rounding */ -/* SIDE-EFFECTS: n is changed to |n|. Make copy of n if necessary. */ - -bf10_t unsafe_bftobf10(bf10_t r, int dec, bf_t n) - { - int d; - int power256; - int p; - int bnl; - bf_t onesbyte; - bf10_t power10; - - if (is_bf_zero(n)) - { /* in scientific notation, the leading digit can't be zero */ - r[1] = (BYTE)0; /* unless the number is zero */ - return r; - } - - onesbyte = n + bflength - 1; /* really it's n+bflength-2 */ - power256 = (S16)big_access16(n + bflength) + 1; /* so adjust power256 by 1 */ - - if (dec == 0) - dec = decimals; - dec++; /* one extra byte for rounding */ - power10 = r + dec + 1; - - if (is_bf_neg(n)) - { - neg_a_bf(n); - r[0] = 1; /* sign flag */ - } - else - r[0] = 0; - - p = -1; /* multiply by 10 right away */ - bnl = bnlength; - bnlength = bflength; - for (d=1; d<=dec; d++) - { - /* pretend it's a bn_t instead of a bf_t */ - /* this leaves n un-normalized, which is what we want here */ - mult_a_bn_int(n, 10); - - r[d] = *onesbyte; - if (d == 1 && r[d] == 0) - { - d = 0; /* back up a digit */ - p--; /* and decrease by a factor of 10 */ - } - *onesbyte = 0; - } - bnlength = bnl; - big_set16(power10, (U16)p); /* save power of ten */ - - /* the digits are all read in, now scale it by 256^power256 */ - if (power256 > 0) - for (d=0; dpower256; d--) - div_a_bf10_int(r, dec, 256); - - /* else power256 is zero, don't do anything */ - - /* round the last digit */ - if (r[dec] >= 5) - { - d = dec-1; - while (d > 0) /* stop before you get to the sign flag */ - { - r[d]++; /* round up */ - if (r[d] < 10) - { - d = -1; /* flag for below */ - break; /* finished rounding */ - } - r[d] = 0; - d--; - } - if (d == 0) /* rounding went back to the first digit and it overflowed */ - { - r[1] = 0; - memmove(r+2, r+1, dec-1); - r[1] = 1; - p = (S16)big_access16(power10); - big_set16(power10, (U16)(p+1)); - } - } - r[dec] = 0; /* truncate the rounded digit */ - - return r; - } - - -/**********************************************************************/ -/* mult_a_bf10_int() */ -/* r *= n */ -/* dec - number of decimals, including the one extra for rounding */ - -bf10_t mult_a_bf10_int(bf10_t r, int dec, U16 n) - { - int signflag; - int d, p; - unsigned value, overflow; - bf10_t power10; - - if (r[1] == 0 || n == 0) - { - r[1] = 0; - return r; - } - - power10 = r + dec + 1; - p = (S16)big_access16(power10); - - signflag = r[0]; /* r[0] to be used as a padding */ - overflow = 0; - for (d = dec; d>0; d--) - { - value = r[d] * n + overflow; - r[d] = (BYTE)(value % 10); - overflow = value / 10; - } - while (overflow) - { - p++; - memmove(r+2, r+1, dec-1); - r[1] = (BYTE)(overflow % 10); - overflow = overflow / 10; - } - big_set16(power10, (U16)p); /* save power of ten */ - r[0] = (BYTE)signflag; /* restore sign flag */ - return r; - } - -/**********************************************************************/ -/* div_a_bf10_int() */ -/* r /= n */ -/* dec - number of decimals, including the one extra for rounding */ - -bf10_t div_a_bf10_int (bf10_t r, int dec, U16 n) - { - int src, dest, p; - unsigned value, remainder; - bf10_t power10; - - if (r[1] == 0 || n == 0) - { - r[1] = 0; - return r; - } - - power10 = r + dec + 1; - p = (S16)big_access16(power10); - - remainder = 0; - for (src=dest=1; src<=dec; dest++, src++) - { - value = 10*remainder + r[src]; - r[dest] = (BYTE)(value / n); - remainder = value % n; - if (dest == 1 && r[dest] == 0) - { - dest = 0; /* back up a digit */ - p--; /* and decrease by a factor of 10 */ - } - } - for (; dest<=dec; dest++) - { - value = 10*remainder; - r[dest] = (BYTE)(value / n); - remainder = value % n; - if (dest == 1 && r[dest] == 0) - { - dest = 0; /* back up a digit */ - p--; /* and decrease by a factor of 10 */ - } - } - - big_set16(power10, (U16)p); /* save power of ten */ - return r; - } - - -/*************************************************************************/ -/* bf10tostr_e() */ -/* Takes a bf10 number and converts it to an ascii string, sci. notation */ -/* dec - number of decimals, not including the one extra for rounding */ - -char *bf10tostr_e(char *s, int dec, bf10_t n) - { - int d, p; - bf10_t power10; - - if (n[1] == 0) - { - strcpy(s, "0.0"); - return s; - } - - if (dec == 0) - dec = decimals; - dec++; /* one extra byte for rounding */ - power10 = n + dec + 1; - p = (S16)big_access16(power10); - - /* if p is negative, it is not necessary to show all the decimal places */ - if (p < 0 && dec > 8) /* 8 sounds like a reasonable value */ - { - dec = dec + p; - if (dec < 8) /* let's keep at least a few */ - dec = 8; - } - - if (n[0] == 1) /* sign flag */ - *(s++) = '-'; - *(s++) = (char)(n[1] + '0'); - *(s++) = '.'; - for (d=2; d<=dec; d++) - { - *(s++) = (char)(n[d] + '0'); - } - /* clean up trailing 0's */ - while (*(s-1) == '0') - s--; - if (*(s-1) == '.') /* put at least one 0 after the decimal */ - *(s++) = '0'; - sprintf(s, "e%d", p); - return s; - } - -/****************************************************************************/ -/* bf10tostr_f() */ -/* Takes a bf10 number and converts it to an ascii string, decimal notation */ - -char *bf10tostr_f(char *s, int dec, bf10_t n) - { - int d, p; - bf10_t power10; - - if (n[1] == 0) - { - strcpy(s, "0.0"); - return s; - } - - if (dec == 0) - dec = decimals; - dec++; /* one extra byte for rounding */ - power10 = n + dec + 1; - p = (S16)big_access16(power10); - - /* if p is negative, it is not necessary to show all the decimal places */ - if (p < 0 && dec > 8) /* 8 sounds like a reasonable value */ - { - dec = dec + p; - if (dec < 8) /* let's keep at least a few */ - dec = 8; - } - - if (n[0] == 1) /* sign flag */ - *(s++) = '-'; - if (p >= 0) - { - for (d=1; d<=p+1; d++) - *(s++) = (char)(n[d] + '0'); - *(s++) = '.'; - for (; d<=dec; d++) - *(s++) = (char)(n[d] + '0'); - } - else - { - *(s++) = '0'; - *(s++) = '.'; - for (d=0; d>p+1; d--) - *(s++) = '0'; - for (d=1; d<=dec; d++) - *(s++) = (char)(n[d] + '0'); - } - - /* clean up trailing 0's */ - while (*(s-1) == '0') - s--; - if (*(s-1) == '.') /* put at least one 0 after the decimal */ - *(s++) = '0'; - *s = '\0'; /* terminating nul */ - return s; - } diff --git a/fractint/common/biginit.c b/fractint/common/biginit.c deleted file mode 100644 index 9cedddf15..000000000 --- a/fractint/common/biginit.c +++ /dev/null @@ -1,520 +0,0 @@ -/* biginit.c - C routines for bignumbers */ - -/* -Note: This is NOT the biginit.c file that come the standard BigNum library, -but is a customized version specific to Fractint. The biggest difference -is in the allocations of memory for the big numbers. -*/ - -#include -#if !defined(_WIN32) -#include -#endif - /* see Fractint.c for a description of the "include" hierarchy */ -#include "port.h" -#include "prototyp.h" -#include "fractype.h" - -/* appears to me that avoiding the start of extraseg is unnecessary. If - correct, later we can eliminate ENDVID here. */ -#ifdef ENDVID -#undef ENDVID -#endif -#define ENDVID 0 - -/* globals */ -#ifdef BIG_BASED -_segment bignum_seg; -#endif -int bnstep = 0, bnlength = 0, intlength = 0, rlength = 0, padding = 0, shiftfactor = 0, decimals = 0; -int bflength = 0, rbflength = 0, bfdecimals = 0; - -/* used internally by bignum.c routines */ -static char s_storage[4096]; -static bn_t bnroot = BIG_NULL; -static bn_t stack_ptr = BIG_NULL; /* memory allocator base after global variables */ -bn_t bntmp1 = BIG_NULL, bntmp2 = BIG_NULL, bntmp3 = BIG_NULL, bntmp4 = BIG_NULL, bntmp5 = BIG_NULL, bntmp6 = BIG_NULL; /* rlength */ -bn_t bntmpcpy1 = BIG_NULL, bntmpcpy2 = BIG_NULL; /* bnlength */ - -/* used by other routines */ -bn_t bnxmin = BIG_NULL, bnxmax = BIG_NULL, bnymin = BIG_NULL, bnymax = BIG_NULL, bnx3rd = BIG_NULL, bny3rd = BIG_NULL; /* bnlength */ -bn_t bnxdel = BIG_NULL, bnydel = BIG_NULL, bnxdel2 = BIG_NULL, bnydel2 = BIG_NULL, bnclosenuff = BIG_NULL; /* bnlength */ -bn_t bntmpsqrx = BIG_NULL, bntmpsqry = BIG_NULL, bntmp = BIG_NULL; /* rlength */ -_BNCMPLX bnold = { BIG_NULL, BIG_NULL }, /* bnnew, */ bnparm = { BIG_NULL, BIG_NULL }, bnsaved = { BIG_NULL, BIG_NULL }; /* bnlength */ -_BNCMPLX bnnew = { BIG_NULL, BIG_NULL }; /* rlength */ -bn_t bn_pi = BIG_NULL; /* TAKES NO SPACE */ - -bf_t bftmp1 = BIG_NULL, bftmp2 = BIG_NULL, bftmp3 = BIG_NULL, bftmp4 = BIG_NULL, bftmp5 = BIG_NULL, bftmp6 = BIG_NULL; /* rbflength+2 */ -bf_t bftmpcpy1 = BIG_NULL, bftmpcpy2 = BIG_NULL; /* rbflength+2 */ -bf_t bfxdel = BIG_NULL, bfydel = BIG_NULL, bfxdel2 = BIG_NULL, bfydel2 = BIG_NULL, bfclosenuff = BIG_NULL; /* rbflength+2 */ -bf_t bftmpsqrx = BIG_NULL, bftmpsqry = BIG_NULL; /* rbflength+2 */ -_BFCMPLX /* bfold, bfnew, */ bfparm = { BIG_NULL, BIG_NULL }, bfsaved = { BIG_NULL, BIG_NULL }; /* bflength+2 */ -_BFCMPLX bfold = { BIG_NULL, BIG_NULL }, bfnew = { BIG_NULL, BIG_NULL }; /* rbflength+2 */ -bf_t bf_pi = BIG_NULL; /* TAKES NO SPACE */ -bf_t big_pi = BIG_NULL; /* bflength+2 */ - -/* for testing only */ - -/* used by other routines */ -bf_t bfxmin = BIG_NULL, bfxmax = BIG_NULL, bfymin = BIG_NULL, bfymax = BIG_NULL, bfx3rd = BIG_NULL, bfy3rd = BIG_NULL; /* bflength+2 */ -bf_t bfsxmin = BIG_NULL, bfsxmax = BIG_NULL, bfsymin = BIG_NULL, bfsymax = BIG_NULL, bfsx3rd = BIG_NULL, bfsy3rd = BIG_NULL;/* bflength+2 */ -bf_t bfparms[10]; /* (bflength+2)*10 */ -bf_t bftmp = BIG_NULL; - -bf_t bf10tmp = BIG_NULL; /* dec+4 */ - -#define LOG10_256 2.4082399653118 -#define LOG_256 5.5451774444795 - -static int save_bf_vars(void); -static int restore_bf_vars(void); - -/*********************************************************************/ -/* given bnlength, calc_lengths will calculate all the other lengths */ -void calc_lengths(void) - { -#if 0 -#ifdef USE_BIGNUM_C_CODE - bnstep = 2; -#else /* use 80x86 asm code */ - if (cpu >= 386) - bnstep = 4; - else /* cpu <= 286 */ - bnstep = 2; -#endif -#else - bnstep = 4; /* use 4 in all cases */ -#endif - - if (bnlength % bnstep != 0) - bnlength = (bnlength / bnstep + 1) * bnstep; - if (bnlength == bnstep) - padding = bnlength; - else - padding = 2*bnstep; - rlength = bnlength + padding; - - /* This shiftfactor assumes non-full multiplications will be performed.*/ - /* Change to bnlength-intlength for full multiplications. */ - shiftfactor = padding - intlength; - - bflength = bnlength+bnstep; /* one extra step for added precision */ - rbflength = bflength + padding; - bfdecimals = (int)((bflength-2)*LOG10_256); - } - -/************************************************************************/ -/* intended only to be called from init_bf_dec() or init_bf_length(). */ -/* initialize bignumber global variables */ - -long maxptr = 0; -long startstack = 0; -long maxstack = 0; -int bf_save_len = 0; - -static void init_bf_2(void) - { - int i; - long ptr; - save_bf_vars(); /* copy corners values for conversion */ - - calc_lengths(); - - bnroot = (bf_t) &s_storage[0]; - - /* at present time one call would suffice, but this logic allows - multiple kinds of alternate math eg long double */ - if ((i = find_alternate_math(fractype, BIGNUM)) > -1) - bf_math = alternatemath[i].math; - else if ((i = find_alternate_math(fractype, BIGFLT)) > -1) - bf_math = alternatemath[i].math; - else - bf_math = 1; /* maybe called from cmdfiles.c and fractype not set */ - - floatflag=1; - - /* Now split up the memory among the pointers */ - /* internal pointers */ - ptr = 0; - bntmp1 = bnroot+ptr; ptr += rlength; - bntmp2 = bnroot+ptr; ptr += rlength; - bntmp3 = bnroot+ptr; ptr += rlength; - bntmp4 = bnroot+ptr; ptr += rlength; - bntmp5 = bnroot+ptr; ptr += rlength; - bntmp6 = bnroot+ptr; ptr += rlength; - - bftmp1 = bnroot+ptr; ptr += rbflength+2; - bftmp2 = bnroot+ptr; ptr += rbflength+2; - bftmp3 = bnroot+ptr; ptr += rbflength+2; - bftmp4 = bnroot+ptr; ptr += rbflength+2; - bftmp5 = bnroot+ptr; ptr += rbflength+2; - bftmp6 = bnroot+ptr; ptr += rbflength+2; - - bftmpcpy1 = bnroot+ptr; ptr += (rbflength+2)*2; - bftmpcpy2 = bnroot+ptr; ptr += (rbflength+2)*2; - - bntmpcpy1 = bnroot+ptr; ptr += (rlength*2); - bntmpcpy2 = bnroot+ptr; ptr += (rlength*2); - - if (bf_math == BIGNUM) - { - bnxmin = bnroot+ptr; ptr += bnlength; - bnxmax = bnroot+ptr; ptr += bnlength; - bnymin = bnroot+ptr; ptr += bnlength; - bnymax = bnroot+ptr; ptr += bnlength; - bnx3rd = bnroot+ptr; ptr += bnlength; - bny3rd = bnroot+ptr; ptr += bnlength; - bnxdel = bnroot+ptr; ptr += bnlength; - bnydel = bnroot+ptr; ptr += bnlength; - bnxdel2 = bnroot+ptr; ptr += bnlength; - bnydel2 = bnroot+ptr; ptr += bnlength; - bnold.x = bnroot+ptr; ptr += rlength; - bnold.y = bnroot+ptr; ptr += rlength; - bnnew.x = bnroot+ptr; ptr += rlength; - bnnew.y = bnroot+ptr; ptr += rlength; - bnsaved.x = bnroot+ptr; ptr += bnlength; - bnsaved.y = bnroot+ptr; ptr += bnlength; - bnclosenuff= bnroot+ptr; ptr += bnlength; - bnparm.x = bnroot+ptr; ptr += bnlength; - bnparm.y = bnroot+ptr; ptr += bnlength; - bntmpsqrx = bnroot+ptr; ptr += rlength; - bntmpsqry = bnroot+ptr; ptr += rlength; - bntmp = bnroot+ptr; ptr += rlength; - } - if (bf_math == BIGFLT) - { - bfxdel = bnroot+ptr; ptr += bflength+2; - bfydel = bnroot+ptr; ptr += bflength+2; - bfxdel2 = bnroot+ptr; ptr += bflength+2; - bfydel2 = bnroot+ptr; ptr += bflength+2; - bfold.x = bnroot+ptr; ptr += rbflength+2; - bfold.y = bnroot+ptr; ptr += rbflength+2; - bfnew.x = bnroot+ptr; ptr += rbflength+2; - bfnew.y = bnroot+ptr; ptr += rbflength+2; - bfsaved.x = bnroot+ptr; ptr += bflength+2; - bfsaved.y = bnroot+ptr; ptr += bflength+2; - bfclosenuff= bnroot+ptr; ptr += bflength+2; - bfparm.x = bnroot+ptr; ptr += bflength+2; - bfparm.y = bnroot+ptr; ptr += bflength+2; - bftmpsqrx = bnroot+ptr; ptr += rbflength+2; - bftmpsqry = bnroot+ptr; ptr += rbflength+2; - big_pi = bnroot+ptr; ptr += bflength+2; - bftmp = bnroot+ptr; ptr += rbflength+2; - } - bf10tmp = bnroot+ptr; ptr += bfdecimals+4; - - /* ptr needs to be 16-bit aligned on some systems */ - ptr = (ptr+1)&~1; - - stack_ptr = bnroot + ptr; - startstack = ptr; - - /* max stack offset from bnroot */ - maxstack = (long)0x10000l-(bflength+2)*22-ENDVID; - - /* sanity check */ - /* leave room for NUMVARS variables allocated from stack */ - /* also leave room for the safe area at top of segment */ - if (ptr + NUMVARS*(bflength+2) > maxstack) - { - char msg[80]; - sprintf(msg,"Requested precision of %d too high, aborting",decimals); - stopmsg(0,msg); - goodbye(); - } - - /* room for 6 corners + 6 save corners + 10 params at top of extraseg */ - /* this area is safe - use for variables that are used outside fractal*/ - /* generation - e.g. zoom box variables */ - ptr = maxstack; - bfxmin = bnroot+ptr; ptr += bflength+2; - bfxmax = bnroot+ptr; ptr += bflength+2; - bfymin = bnroot+ptr; ptr += bflength+2; - bfymax = bnroot+ptr; ptr += bflength+2; - bfx3rd = bnroot+ptr; ptr += bflength+2; - bfy3rd = bnroot+ptr; ptr += bflength+2; - for (i=0; i<10; i++) - { - bfparms[i] = bnroot+ptr; ptr += bflength+2; - } - bfsxmin = bnroot+ptr; ptr += bflength+2; - bfsxmax = bnroot+ptr; ptr += bflength+2; - bfsymin = bnroot+ptr; ptr += bflength+2; - bfsymax = bnroot+ptr; ptr += bflength+2; - bfsx3rd = bnroot+ptr; ptr += bflength+2; - bfsy3rd = bnroot+ptr; ptr += bflength+2; - /* end safe vars */ - - /* good citizens initialize variables */ - if (bf_save_len) /* leave save area */ - memset(bnroot+(bf_save_len+2)*22,0,(unsigned)(startstack-(bf_save_len+2)*22)); - else /* first time through - nothing saved */ - { - /* high variables */ - memset(bnroot+maxstack,0,(bflength+2)*22); - /* low variables */ - memset(bnroot,0,(unsigned)startstack); - } - - restore_bf_vars(); - - /* Initialize the value of pi. Needed for trig functions. */ - /* init_big_pi(); */ -/* call to init_big_pi() has been moved to fractal setup routine */ -/* so as to use only when necessary. */ - - } - - -/**********************************************************/ -/* save current corners and parameters to start of bnroot */ -/* to preserve values across calls to init_bf() */ -static int save_bf_vars(void) - { - int ret; - unsigned int mem; - if (bnroot != BIG_NULL) - { - mem = (bflength+2)*22; /* 6 corners + 6 save corners + 10 params */ - bf_save_len = bflength; - memcpy(bnroot,bfxmin,mem); - /* scrub old high area */ - memset(bfxmin,0,mem); - ret = 0; - } - else - { - bf_save_len = 0; - ret = -1; - } - return(ret); - } - -/************************************************************************/ -/* copy current corners and parameters from save location */ -static int restore_bf_vars(void) - { - bf_t ptr; - int i; - if (bf_save_len == 0) - return(-1); - ptr = bnroot; - convert_bf(bfxmin,ptr,bflength,bf_save_len); ptr += bf_save_len+2; - convert_bf(bfxmax,ptr,bflength,bf_save_len); ptr += bf_save_len+2; - convert_bf(bfymin,ptr,bflength,bf_save_len); ptr += bf_save_len+2; - convert_bf(bfymax,ptr,bflength,bf_save_len); ptr += bf_save_len+2; - convert_bf(bfx3rd,ptr,bflength,bf_save_len); ptr += bf_save_len+2; - convert_bf(bfy3rd,ptr,bflength,bf_save_len); ptr += bf_save_len+2; - for (i=0; i<10; i++) - { - convert_bf(bfparms[i],ptr,bflength,bf_save_len); - ptr += bf_save_len+2; - } - convert_bf(bfsxmin,ptr,bflength,bf_save_len); ptr += bf_save_len+2; - convert_bf(bfsxmax,ptr,bflength,bf_save_len); ptr += bf_save_len+2; - convert_bf(bfsymin,ptr,bflength,bf_save_len); ptr += bf_save_len+2; - convert_bf(bfsymax,ptr,bflength,bf_save_len); ptr += bf_save_len+2; - convert_bf(bfsx3rd,ptr,bflength,bf_save_len); ptr += bf_save_len+2; - convert_bf(bfsy3rd,ptr,bflength,bf_save_len); ptr += bf_save_len+2; - - /* scrub save area */ - memset(bnroot,0,(bf_save_len+2)*22); - return(0); - } - -/*******************************************/ -/* free corners and parameters save memory */ -void free_bf_vars() - { - bf_save_len = bf_math = 0; - bnstep=bnlength=intlength=rlength=padding=shiftfactor=decimals=0; - bflength=rbflength=bfdecimals=0; - } - -/************************************************************************/ -/* Memory allocator routines start here. */ -/************************************************************************/ -/* Allocates a bn_t variable on stack */ -bn_t alloc_stack(size_t size) - { - long stack_addr; - if (bf_math == 0) - { - stopmsg(0,"alloc_stack called with bf_math==0"); - return(0); - } - stack_addr = (long)((stack_ptr-bnroot)+size); /* +ENDVID, part of bnroot */ - - if (stack_addr > maxstack) - { - stopmsg(0,"Aborting, Out of Bignum Stack Space"); - goodbye(); - } - /* keep track of max ptr */ - if (stack_addr > maxptr) - maxptr = stack_addr; - stack_ptr += size; /* increment stack pointer */ - return(stack_ptr - size); - } - -/************************************************************************/ -/* Returns stack pointer offset so it can be saved. */ -int save_stack(void) - { - return (int) (stack_ptr - bnroot); - } - -/************************************************************************/ -/* Restores stack pointer, effectively freeing local variables */ -/* allocated since save_stack() */ -void restore_stack(int old_offset) - { - stack_ptr = bnroot+old_offset; - } - -/************************************************************************/ -/* Memory allocator routines end here. */ -/************************************************************************/ - -/************************************************************************/ -/* initialize bignumber global variables */ -/* dec = decimal places after decimal point */ -/* intl = bytes for integer part (1, 2, or 4) */ - -void init_bf_dec(int dec) - { - if (bfdigits) - decimals=bfdigits; /* blindly force */ - else - decimals = dec; - if (bailout > 10) /* arbitrary value */ - /* using 2 doesn't gain much and requires another test */ - intlength = 4; - else if (fractype == FPMANDELZPOWER || fractype == FPJULIAZPOWER) - intlength = 2; - /* the bailout tests need greater dynamic range */ - else if (bailoutest == Real || bailoutest == Imag || bailoutest == And || - bailoutest == Manr) - intlength = 2; - else - intlength = 1; - /* conservative estimate */ - bnlength = intlength + (int)(decimals/LOG10_256) + 1; /* round up */ - init_bf_2(); - } - -/************************************************************************/ -/* initialize bignumber global variables */ -/* bnl = bignumber length */ -/* intl = bytes for integer part (1, 2, or 4) */ -void init_bf_length(int bnl) - { - bnlength = bnl; - - if (bailout > 10) /* arbitrary value */ - /* using 2 doesn't gain much and requires another test */ - intlength = 4; - else if (fractype == FPMANDELZPOWER || fractype == FPJULIAZPOWER) - intlength = 2; - /* the bailout tests need greater dynamic range */ - else if (bailoutest == Real || bailoutest == Imag || bailoutest == And || - bailoutest == Manr) - intlength = 2; - else - intlength = 1; - /* conservative estimate */ - decimals = (int)((bnlength-intlength)*LOG10_256); - init_bf_2(); - } - - -void init_big_pi(void) - { - /* What, don't you recognize the first 700 digits of pi, */ - /* in base 256, in reverse order? */ - int length, pi_offset; - static BYTE pi_table[] = { - 0x44, 0xD5, 0xDB, 0x69, 0x17, 0xDF, 0x2E, 0x56, 0x87, 0x1A, - 0xA0, 0x8C, 0x6F, 0xCA, 0xBB, 0x57, 0x5C, 0x9E, 0x82, 0xDF, - 0x00, 0x3E, 0x48, 0x7B, 0x31, 0x53, 0x60, 0x87, 0x23, 0xFD, - 0xFA, 0xB5, 0x3D, 0x32, 0xAB, 0x52, 0x05, 0xAD, 0xC8, 0x1E, - 0x50, 0x2F, 0x15, 0x6B, 0x61, 0xFD, 0xDF, 0x16, 0x75, 0x3C, - 0xF8, 0x22, 0x32, 0xDB, 0xF8, 0xE9, 0xA5, 0x8E, 0xCC, 0xA3, - 0x1F, 0xFB, 0xFE, 0x25, 0x9F, 0x67, 0x79, 0x72, 0x2C, 0x40, - 0xC6, 0x00, 0xA1, 0xD6, 0x0A, 0x32, 0x60, 0x1A, 0xBD, 0xC0, - 0x79, 0x55, 0xDB, 0xFB, 0xD3, 0xB9, 0x39, 0x5F, 0x0B, 0xD2, - 0x0F, 0x74, 0xC8, 0x45, 0x57, 0xA8, 0xCB, 0xC0, 0xB3, 0x4B, - 0x2E, 0x19, 0x07, 0x28, 0x0F, 0x66, 0xFD, 0x4A, 0x33, 0xDE, - 0x04, 0xD0, 0xE3, 0xBE, 0x09, 0xBD, 0x5E, 0xAF, 0x44, 0x45, - 0x81, 0xCC, 0x2C, 0x95, 0x30, 0x9B, 0x1F, 0x51, 0xFC, 0x6D, - 0x6F, 0xEC, 0x52, 0x3B, 0xEB, 0xB2, 0x39, 0x13, 0xB5, 0x53, - 0x6C, 0x3E, 0xAF, 0x6F, 0xFB, 0x68, 0x63, 0x24, 0x6A, 0x19, - 0xC2, 0x9E, 0x5C, 0x5E, 0xC4, 0x60, 0x9F, 0x40, 0xB6, 0x4F, - 0xA9, 0xC1, 0xBA, 0x06, 0xC0, 0x04, 0xBD, 0xE0, 0x6C, 0x97, - 0x3B, 0x4C, 0x79, 0xB6, 0x1A, 0x50, 0xFE, 0xE3, 0xF7, 0xDE, - 0xE8, 0xF6, 0xD8, 0x79, 0xD4, 0x25, 0x7B, 0x1B, 0x99, 0x80, - 0xC9, 0x72, 0x53, 0x07, 0x9B, 0xC0, 0xF1, 0x49, 0xD3, 0xEA, - 0x0F, 0xDB, 0x48, 0x12, 0x0A, 0xD0, 0x24, 0xD7, 0xD0, 0x37, - 0x3D, 0x02, 0x9B, 0x42, 0x72, 0xDF, 0xFE, 0x1B, 0x06, 0x77, - 0x3F, 0x36, 0x62, 0xAA, 0xD3, 0x4E, 0xA6, 0x6A, 0xC1, 0x56, - 0x9F, 0x44, 0x1A, 0x40, 0x73, 0x20, 0xC1, 0x85, 0xD8, 0x75, - 0x6F, 0xE0, 0xBE, 0x5E, 0x8B, 0x3B, 0xC3, 0xA5, 0x84, 0x7D, - 0xB4, 0x9F, 0x6F, 0x45, 0x19, 0x86, 0xEE, 0x8C, 0x88, 0x0E, - 0x43, 0x82, 0x3E, 0x59, 0xCA, 0x66, 0x76, 0x01, 0xAF, 0x39, - 0x1D, 0x65, 0xF1, 0xA1, 0x98, 0x2A, 0xFB, 0x7E, 0x50, 0xF0, - 0x3B, 0xBA, 0xE4, 0x3B, 0x7A, 0x13, 0x6C, 0x0B, 0xEF, 0x6E, - 0xA3, 0x33, 0x51, 0xAB, 0x28, 0xA7, 0x0F, 0x96, 0x68, 0x2F, - 0x54, 0xD8, 0xD2, 0xA0, 0x51, 0x6A, 0xF0, 0x88, 0xD3, 0xAB, - 0x61, 0x9C, 0x0C, 0x67, 0x9A, 0x6C, 0xE9, 0xF6, 0x42, 0x68, - 0xC6, 0x21, 0x5E, 0x9B, 0x1F, 0x9E, 0x4A, 0xF0, 0xC8, 0x69, - 0x04, 0x20, 0x84, 0xA4, 0x82, 0x44, 0x0B, 0x2E, 0x39, 0x42, - 0xF4, 0x83, 0xF3, 0x6F, 0x6D, 0x0F, 0xC5, 0xAC, 0x96, 0xD3, - 0x81, 0x3E, 0x89, 0x23, 0x88, 0x1B, 0x65, 0xEB, 0x02, 0x23, - 0x26, 0xDC, 0xB1, 0x75, 0x85, 0xE9, 0x5D, 0x5D, 0x84, 0xEF, - 0x32, 0x80, 0xEC, 0x5D, 0x60, 0xAC, 0x7C, 0x48, 0x91, 0xA9, - 0x21, 0xFB, 0xCC, 0x09, 0xD8, 0x61, 0x93, 0x21, 0x28, 0x66, - 0x1B, 0xE8, 0xBF, 0xC4, 0xAF, 0xB9, 0x4B, 0x6B, 0x98, 0x48, - 0x8F, 0x3B, 0x77, 0x86, 0x95, 0x28, 0x81, 0x53, 0x32, 0x7A, - 0x5C, 0xCF, 0x24, 0x6C, 0x33, 0xBA, 0xD6, 0xAF, 0x1E, 0x93, - 0x87, 0x9B, 0x16, 0x3E, 0x5C, 0xCE, 0xF6, 0x31, 0x18, 0x74, - 0x5D, 0xC5, 0xA9, 0x2B, 0x2A, 0xBC, 0x6F, 0x63, 0x11, 0x14, - 0xEE, 0xB3, 0x93, 0xE9, 0x72, 0x7C, 0xAF, 0x86, 0x54, 0xA1, - 0xCE, 0xE8, 0x41, 0x11, 0x34, 0x5C, 0xCC, 0xB4, 0xB6, 0x10, - 0xAB, 0x2A, 0x6A, 0x39, 0xCA, 0x55, 0x40, 0x14, 0xE8, 0x63, - 0x62, 0x98, 0x48, 0x57, 0x94, 0xAB, 0x55, 0xAA, 0xF3, 0x25, - 0x55, 0xE6, 0x60, 0x5C, 0x60, 0x55, 0xDA, 0x2F, 0xAF, 0x78, - 0x27, 0x4B, 0x31, 0xBD, 0xC1, 0x77, 0x15, 0xD7, 0x3E, 0x8A, - 0x1E, 0xB0, 0x8B, 0x0E, 0x9E, 0x6C, 0x0E, 0x18, 0x3A, 0x60, - 0xB0, 0xDC, 0x79, 0x8E, 0xEF, 0x38, 0xDB, 0xB8, 0x18, 0x79, - 0x41, 0xCA, 0xF0, 0x85, 0x60, 0x28, 0x23, 0xB0, 0xD1, 0xC5, - 0x13, 0x60, 0xF2, 0x2A, 0x39, 0xD5, 0x30, 0x9C, 0xB5, 0x59, - 0x5A, 0xC2, 0x1D, 0xA4, 0x54, 0x7B, 0xEE, 0x4A, 0x15, 0x82, - 0x58, 0xCD, 0x8B, 0x71, 0x58, 0xB6, 0x8E, 0x72, 0x8F, 0x74, - 0x95, 0x0D, 0x7E, 0x3D, 0x93, 0xF4, 0xA3, 0xFE, 0x58, 0xA4, - 0x69, 0x4E, 0x57, 0x71, 0xD8, 0x20, 0x69, 0x63, 0x16, 0xFC, - 0x8E, 0x85, 0xE2, 0xF2, 0x01, 0x08, 0xF7, 0x6C, 0x91, 0xB3, - 0x47, 0x99, 0xA1, 0x24, 0x99, 0x7F, 0x2C, 0xF1, 0x45, 0x90, - 0x7C, 0xBA, 0x96, 0x7E, 0x26, 0x6A, 0xED, 0xAF, 0xE1, 0xB8, - 0xB7, 0xDF, 0x1A, 0xD0, 0xDB, 0x72, 0xFD, 0x2F, 0xAC, 0xB5, - 0xDF, 0x98, 0xA6, 0x0B, 0x31, 0xD1, 0x1B, 0xFB, 0x79, 0x89, - 0xD9, 0xD5, 0x16, 0x92, 0x17, 0x09, 0x47, 0xB5, 0xB5, 0xD5, - 0x84, 0x3F, 0xDD, 0x50, 0x7C, 0xC9, 0xB7, 0x29, 0xAC, 0xC0, - 0x6C, 0x0C, 0xE9, 0x34, 0xCF, 0x66, 0x54, 0xBE, 0x77, 0x13, - 0xD0, 0x38, 0xE6, 0x21, 0x28, 0x45, 0x89, 0x6C, 0x4E, 0xEC, - 0x98, 0xFA, 0x2E, 0x08, 0xD0, 0x31, 0x9F, 0x29, 0x22, 0x38, - 0x09, 0xA4, 0x44, 0x73, 0x70, 0x03, 0x2E, 0x8A, 0x19, 0x13, - 0xD3, 0x08, 0xA3, 0x85, 0x88, 0x6A, 0x3F, 0x24, - /* . */ 0x03, 0x00, 0x00, 0x00 - /* <- up to intlength 4 -> */ - /* or bf_t int length of 2 + 2 byte exp */ - }; - - length = bflength+2; /* 2 byte exp */ - pi_offset = sizeof pi_table - length; - memcpy(big_pi, pi_table + pi_offset, length); - - /* notice that bf_pi and bn_pi can share the same memory space */ - bf_pi = big_pi; - bn_pi = big_pi + (bflength-2) - (bnlength-intlength); - return; - } diff --git a/fractint/common/bignum.c b/fractint/common/bignum.c deleted file mode 100644 index ec246cc19..000000000 --- a/fractint/common/bignum.c +++ /dev/null @@ -1,1431 +0,0 @@ -/* bignum.c - C routines for bignumbers */ - -/* -Wesley Loewer's Big Numbers. (C) 1994-95, Wesley B. Loewer - -The bignumber format is simply a signed integer of variable length. The -bytes are stored in reverse order (least significant byte first, most -significant byte last). The sign bit is the highest bit of the most -significant byte. Negatives are stored in 2's complement form. The byte -length of the bignumbers must be a multiple of 4 for 386+ operations, and -a multiple of 2 for 8086/286 and non 80x86 machines. - -Some of the arithmetic operations coded here may alter some of the -operands used. Therefore, take note of the SIDE-EFFECTS listed with each -procedure. If the value of an operand needs to be retained, just use -copy_bn() first. This was done for speed sake to avoid unnecessary -copying. If space is at such a premium that copying it would be -difficult, some of the operations only change the sign of the value. In -this case, the original could be optained by calling neg_a_bn(). - -Most of the bignumber routines operate on true integers. Some of the -procedures, however, are designed specifically for fixed decimal point -operations. The results and how the results are interpreted depend on -where the implied decimal point is located. The routines that depend on -where the decimal is located are: strtobn(), bntostr(), bntoint(), inttobn(), -bntofloat(), floattobn(), inv_bn(), div_bn(). The number of bytes -designated for the integer part may be 1, 2, or 4. - - -BIGNUMBER FORMAT: -The following is a discription of the bignumber format and associated -variables. The number is stored in reverse order (Least Significant Byte, -LSB, stored first in memory, Most Significant Byte, MSB, stored last). -Each '_' below represents a block of memory used for arithmetic (1 block = -4 bytes on 386+, 2 bytes on 286-). All lengths are given in bytes. - -LSB MSB - _ _ _ _ _ _ _ _ _ _ _ _ -n <----------- bnlength -----------> - intlength ---> <--- - - bnlength = the length in bytes of the bignumber - intlength = the number of bytes used to represent the integer part of - the bignumber. Possible values are 1, 2, or 4. This - determines the largest number that can be represented by - the bignumber. - intlength = 1, max value = 127.99... - intlength = 2, max value = 32,767.99... - intlength = 4, max value = 2,147,483,647.99... - - -FULL DOUBLE PRECISION MULTIPLICATION: -( full_mult_bn(), full_square_bn() ) - -The product of two bignumbers, n1 and n2, will be a result, r, which is -a double wide bignumber. The integer part will also be twice as wide, -thereby eliminating the possiblity of overflowing the number. - -LSB MSB - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ -r <--------------------------- 2*bnlength -----------------------------> - 2*intlength ---> <--- - -If this double wide bignumber, r, needs to be converted to a normal, -single width bignumber, this is easily done with pointer arithmetic. The -converted value starts at r+shiftfactor (where shiftfactor = -bnlength-intlength) and continues for bnlength bytes. The lower order -bytes and the upper integer part of the double wide number can then be -ignored. - -LSB MSB - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ -r <--------------------------- 2*bnlength -----------------------------> - 2*intlength ---> <--- - LSB MSB - r+shiftfactor <---------- bnlength ------------> - intlength ---> <--- - - -PARTIAL PRECISION MULTIPLICATION: -( mult_bn(), square_bn() ) - -In most cases, full double precision multiplication is not necessary. The -lower order bytes are usually thrown away anyway. The non-"full" -multiplication routines only calculate rlength bytes in the result. The -value of rlength must be in the range: 2*bnlength <= rlength < bnlength. -The amount by which rlength exceeds bnlength accounts for the extra bytes -that must be multiplied so that the first bnlength bytes are correct. -These extra bytes are refered to in the code as the "padding," that is: -rlength=bnlength+padding. - -All three of the values, bnlength, rlength, and therefore padding, must be -multiples of the size of memory blocks being used for arithmetic (2 on -8086/286 and 4 on 386+). Typically, the padding is 2*blocksize. In the -case where bnlength=blocksize, padding can only be blocksize to keep -rlength from being too big. - -The product of two bignumbers, n1 and n2, will then be a result, r, which -is of length rlength. The integer part will be twice as wide, thereby -eliminating the possiblity of overflowing the number. - - LSB MSB - _ _ _ _ _ _ _ _ _ _ _ _ _ _ - r <---- rlength = bnlength+padding ------> - 2*intlength ---> <--- - -If r needs to be converted to a normal, single width bignumber, this is -easily done with pointer arithmetic. The converted value starts at -r+shiftfactor (where shiftfactor = padding-intlength) and continues for -bnlength bytes. The lower order bytes and the upper integer part of the -double wide number can then be ignored. - - LSB MSB - _ _ _ _ _ _ _ _ _ _ _ _ _ _ - r <---- rlength = bnlength+padding ------> - 2*intlength ---> <--- - LSB MSB - r+shiftfactor <---------- bnlength ---------> - intlength ---> <--- -*/ - -/************************************************************************/ -/* There are three parts to the bignum library: */ -/* */ -/* 1) bignum.c - initialization, general routines, routines that would */ -/* not be speeded up much with assembler. */ -/* */ -/* 2) bignuma.asm - hand coded assembler routines. */ -/* */ -/* 3) bignumc.c - portable C versions of routines in bignuma.asm */ -/* */ -/************************************************************************/ - -#include - /* see Fractint.c for a description of the "include" hierarchy */ -#include "port.h" -#include "prototyp.h" -#include "big.h" -#ifndef BIG_ANSI_C -#include -#endif - -/************************************************************************* -* The original bignumber code was written specifically for a Little Endian -* system (80x86). The following is not particularly efficient, but was -* simple to incorporate. If speed with a Big Endian machine is critical, -* the bignumber format could be reversed. -**************************************************************************/ -#ifdef ACCESS_BY_BYTE -U32 big_access32(BYTE BIGDIST *addr) - { - return addr[0] | ((U32)addr[1]<<8) | ((U32)addr[2]<<16) | ((U32)addr[3]<<24); - } - -U16 big_access16(BYTE BIGDIST *addr) - { - return (U16)addr[0] | ((U16)addr[1]<<8); - } - -S16 big_accessS16(S16 BIGDIST *addr) - { - return (S16)((BYTE *)addr)[0] | ((S16)((BYTE *)addr)[1]<<8); - } - -U32 big_set32(BYTE BIGDIST *addr, U32 val) - { - addr[0] = (BYTE)(val&0xff); - addr[1] = (BYTE)((val>>8)&0xff); - addr[2] = (BYTE)((val>>16)&0xff); - addr[3] = (BYTE)((val>>24)&0xff); - return val; - } - -U16 big_set16(BYTE BIGDIST *addr, U16 val) - { - addr[0] = (BYTE)(val&0xff); - addr[1] = (BYTE)((val>>8)&0xff); - return val; - } - -S16 big_setS16(S16 BIGDIST *addr, S16 val) - { - ((BYTE *)addr)[0] = (BYTE)(val&0xff); - ((BYTE *)addr)[1] = (BYTE)((val>>8)&0xff); - return val; - } - -#endif - -/************************************************************************/ -/* convert_bn -- convert bignum numbers from old to new lengths */ -int convert_bn(bn_t newnum, bn_t old, int newbnlength, int newintlength, - int oldbnlength, int oldintlength) - { - int savebnlength, saveintlength; - - /* save lengths so not dependent on external environment */ - saveintlength = intlength; - savebnlength = bnlength; - - intlength = newintlength; - bnlength = newbnlength; - clear_bn(newnum); - - if (newbnlength - newintlength > oldbnlength - oldintlength) - { - - /* This will keep the integer part from overflowing past the array. */ - bnlength = oldbnlength - oldintlength + min(oldintlength, newintlength); - - memcpy(newnum+newbnlength-newintlength-oldbnlength+oldintlength, - old,bnlength); - } - else - { - bnlength = newbnlength - newintlength + min(oldintlength, newintlength); - memcpy(newnum,old+oldbnlength-oldintlength-newbnlength+newintlength, - bnlength); - } - intlength = saveintlength; - bnlength = savebnlength; - return(0); - } - -/********************************************************************/ -/* bn_hexdump() - for debugging, dumps to stdout */ - -void bn_hexdump(bn_t r) - { - int i; - - for (i=0; i= '0' && s[l] <= '9') /* while a digit */ - { - *onesbyte = (BYTE)(s[l--] - '0'); - div_a_bn_int(r, 10); - } - - if (s[l] == '.') - { - longval = atol(s); - switch (intlength) - { /* only 1, 2, or 4 are allowed */ - case 1: - *onesbyte = (BYTE)longval; - break; - case 2: - big_set16(onesbyte, (U16)longval); - break; - case 4: - big_set32(onesbyte, longval); - break; - } - } - } - else - { - longval = atol(s); - switch (intlength) - { /* only 1, 2, or 4 are allowed */ - case 1: - *onesbyte = (BYTE)longval; - break; - case 2: - big_set16(onesbyte, (U16)longval); - break; - case 4: - big_set32(onesbyte, longval); - break; - } - } - - - if (signflag) - neg_a_bn(r); - - return r; - } - -/********************************************************************/ -/* strlen_needed() - returns string length needed to hold bignumber */ - -int strlen_needed() - { - int length = 3; - - /* first space for integer part */ - switch (intlength) - { - case 1: - length = 3; /* max 127 */ - break; - case 2: - length = 5; /* max 32767 */ - break; - case 4: - length = 10; /* max 2147483647 */ - break; - } - length += decimals; /* decimal part */ - length += 2; /* decimal point and sign */ - length += 4; /* null and a little extra for safety */ - return(length); - } - -/********************************************************************/ -/* bntostr() - converts a bignumber into a string */ -/* s - string, must be large enough to hold the number. */ -/* r - bignumber */ -/* will covert to a floating point notation */ -/* SIDE-EFFECT: the bignumber, r, is destroyed. */ -/* Copy it first if necessary. */ - -char *unsafe_bntostr(char *s, int dec, bn_t r) - { - int l=0, d; - bn_t onesbyte; - long longval = 0; - - if (dec == 0) - dec = decimals; - onesbyte = r + bnlength - intlength; - - if (is_bn_neg(r)) - { - neg_a_bn(r); - *(s++) = '-'; - } - switch (intlength) - { /* only 1, 2, or 4 are allowed */ - case 1: - longval = *onesbyte; - break; - case 2: - longval = big_access16(onesbyte); - break; - case 4: - longval = big_access32(onesbyte); - break; - } - ltoa(longval, s, 10); - l = (int) strlen(s); - s[l++] = '.'; - for (d=0; d < dec; d++) - { - *onesbyte = 0; /* clear out highest byte */ - mult_a_bn_int(r, 10); - if (is_bn_zero(r)) - break; - s[l++] = (BYTE)(*onesbyte + '0'); - } - s[l] = '\0'; /* don't forget nul char */ - - return s; - } - -/*********************************************************************/ -/* b = l */ -/* Converts a long to a bignumber */ -bn_t inttobn(bn_t r, long longval) - { - bn_t onesbyte; - - clear_bn(r); - onesbyte = r + bnlength - intlength; - switch (intlength) - { /* only 1, 2, or 4 are allowed */ - case 1: - *onesbyte = (BYTE)longval; - break; - case 2: - big_set16(onesbyte, (U16)longval); - break; - case 4: - big_set32(onesbyte, longval); - break; - } - return r; - } - -/*********************************************************************/ -/* l = floor(b), floor rounds down */ -/* Converts the integer part a bignumber to a long */ -long bntoint(bn_t n) - { - bn_t onesbyte; - long longval = 0; - - onesbyte = n + bnlength - intlength; - switch (intlength) - { /* only 1, 2, or 4 are allowed */ - case 1: - longval = *onesbyte; - break; - case 2: - longval = big_access16(onesbyte); - break; - case 4: - longval = big_access32(onesbyte); - break; - } - return longval; - } - -/*********************************************************************/ -/* b = f */ -/* Converts a double to a bignumber */ -bn_t floattobn(bn_t r, LDBL f) - { -#ifndef USE_BIGNUM_C_CODE - /* Only use this when using the ASM code as the C version of */ - /* floattobf() calls floattobn(), an infinite recursive loop. */ - floattobf(bftmp1, f); - return bftobn(r, bftmp1); - -#else - bn_t onesbyte; - int i; - int signflag=0; - - clear_bn(r); - onesbyte = r + bnlength - intlength; - - if (f < 0) - { - signflag = 1; - f = -f; - } - - switch (intlength) - { /* only 1, 2, or 4 are allowed */ - case 1: - *onesbyte = (BYTE)f; - break; - case 2: - big_set16(onesbyte, (U16)f); - break; - case 4: - big_set32(onesbyte, (U32)f); - break; - } - - f -= (long)f; /* keep only the decimal part */ - for (i = bnlength - intlength - 1; i >= 0 && f != 0.0; i--) - { - f *= 256; - r[i] = (BYTE)f; /* keep use the integer part */ - f -= (BYTE)f; /* now throw away the integer part */ - } - - if (signflag) - neg_a_bn(r); - - return r; -#endif /* USE_BIGNUM_C_CODE */ - } - -/********************************************************************/ -/* sign(r) */ -int sign_bn(bn_t n) - { - return is_bn_neg(n) ? -1 : is_bn_not_zero(n) ? 1 : 0; - } - -/********************************************************************/ -/* r = |n| */ -bn_t abs_bn(bn_t r, bn_t n) - { - copy_bn(r,n); - if (is_bn_neg(r)) - neg_a_bn(r); - return r; - } - -/********************************************************************/ -/* r = |r| */ -bn_t abs_a_bn(bn_t r) - { - if (is_bn_neg(r)) - neg_a_bn(r); - return r; - } - -/********************************************************************/ -/* r = 1/n */ -/* uses bntmp1 - bntmp3 - global temp bignumbers */ -/* SIDE-EFFECTS: */ -/* n ends up as |n| Make copy first if necessary. */ -bn_t unsafe_inv_bn(bn_t r, bn_t n) - { - int signflag=0, i; - long maxval; - LDBL f; - bn_t orig_r, orig_n; /* orig_bntmp1 not needed here */ - int orig_bnlength, - orig_padding, - orig_rlength, - orig_shiftfactor; - - /* use Newton's recursive method for zeroing in on 1/n : r=r(2-rn) */ - - if (is_bn_neg(n)) - { /* will be a lot easier to deal with just positives */ - signflag = 1; - neg_a_bn(n); - } - - f = bntofloat(n); - if (f == 0) /* division by zero */ - { - max_bn(r); - return r; - } - f = 1/f; /* approximate inverse */ - maxval = (1L << ((intlength<<3)-1)) - 1; - if (f > maxval) /* check for overflow */ - { - max_bn(r); - return r; - } - else if (f <= -maxval) - { - max_bn(r); - neg_a_bn(r); - return r; - } - - /* With Newton's Method, there is no need to calculate all the digits */ - /* every time. The precision approximately doubles each iteration. */ - /* Save original values. */ - orig_bnlength = bnlength; - orig_padding = padding; - orig_rlength = rlength; - orig_shiftfactor = shiftfactor; - orig_r = r; - orig_n = n; - /* orig_bntmp1 = bntmp1; */ - - /* calculate new starting values */ - bnlength = intlength + (int)(LDBL_DIG/LOG10_256) + 1; /* round up */ - if (bnlength > orig_bnlength) - bnlength = orig_bnlength; - calc_lengths(); - - /* adjust pointers */ - r = orig_r + orig_bnlength - bnlength; - n = orig_n + orig_bnlength - bnlength; - /* bntmp1 = orig_bntmp1 + orig_bnlength - bnlength; */ - - floattobn(r, f); /* start with approximate inverse */ - clear_bn(bntmp2); /* will be used as 1.0 and 2.0 */ - - for (i=0; i<25; i++) /* safety net, this shouldn't ever be needed */ - { - /* adjust lengths */ - bnlength <<= 1; /* double precision */ - if (bnlength > orig_bnlength) - bnlength = orig_bnlength; - calc_lengths(); - r = orig_r + orig_bnlength - bnlength; - n = orig_n + orig_bnlength - bnlength; - /* bntmp1 = orig_bntmp1 + orig_bnlength - bnlength; */ - - unsafe_mult_bn(bntmp1, r, n); /* bntmp1=rn */ - inttobn(bntmp2, 1); /* bntmp2 = 1.0 */ - if (bnlength == orig_bnlength && cmp_bn(bntmp2, bntmp1+shiftfactor) == 0 ) /* if not different */ - break; /* they must be the same */ - inttobn(bntmp2, 2); /* bntmp2 = 2.0 */ - sub_bn(bntmp3, bntmp2, bntmp1+shiftfactor); /* bntmp3=2-rn */ - unsafe_mult_bn(bntmp1, r, bntmp3); /* bntmp1=r(2-rn) */ - copy_bn(r, bntmp1+shiftfactor); /* r = bntmp1 */ - } - - /* restore original values */ - bnlength = orig_bnlength; - padding = orig_padding; - rlength = orig_rlength; - shiftfactor = orig_shiftfactor; - r = orig_r; - n = orig_n; - /* bntmp1 = orig_bntmp1; */ - - if (signflag) - { - neg_a_bn(r); - } - return r; - } - -/********************************************************************/ -/* r = n1/n2 */ -/* r - result of length bnlength */ -/* uses bntmp1 - bntmp3 - global temp bignumbers */ -/* SIDE-EFFECTS: */ -/* n1, n2 can end up as GARBAGE */ -/* Make copies first if necessary. */ -bn_t unsafe_div_bn(bn_t r, bn_t n1, bn_t n2) - { - int scale1, scale2, scale, sign=0, i; - long maxval; - LDBL a, b, f; - - /* first, check for valid data */ - a = bntofloat(n1); - if (a == 0) /* division into zero */ - { - clear_bn(r); /* return 0 */ - return r; - } - b = bntofloat(n2); - if (b == 0) /* division by zero */ - { - max_bn(r); - return r; - } - f = a/b; /* approximate quotient */ - maxval = (1L << ((intlength<<3)-1)) - 1; - if (f > maxval) /* check for overflow */ - { - max_bn(r); - return r; - } - else if (f <= -maxval) - { - max_bn(r); - neg_a_bn(r); - return r; - } - /* appears to be ok, do division */ - - if (is_bn_neg(n1)) - { - neg_a_bn(n1); - sign = !sign; - } - if (is_bn_neg(n2)) - { - neg_a_bn(n2); - sign = !sign; - } - - /* scale n1 and n2 so: |n| >= 1/256 */ - /* scale = (int)(log(1/fabs(a))/LOG_256) = LOG_256(1/|a|) */ - i = bnlength-1; - while (i >= 0 && n1[i] == 0) - i--; - scale1 = bnlength - i - 2; - if (scale1 < 0) - scale1 = 0; - i = bnlength-1; - while (i >= 0 && n2[i] == 0) - i--; - scale2 = bnlength - i - 2; - if (scale2 < 0) - scale2 = 0; - - /* shift n1, n2 */ - /* important!, use memmove(), not memcpy() */ - memmove(n1+scale1, n1, bnlength-scale1); /* shift bytes over */ - memset(n1, 0, scale1); /* zero out the rest */ - memmove(n2+scale2, n2, bnlength-scale2); /* shift bytes over */ - memset(n2, 0, scale2); /* zero out the rest */ - - unsafe_inv_bn(r, n2); - unsafe_mult_bn(bntmp1, n1, r); - copy_bn(r, bntmp1+shiftfactor); /* r = bntmp1 */ - - if (scale1 != scale2) - { - /* Rescale r back to what it should be. Overflow has already been checked */ - if (scale1 > scale2) /* answer is too big, adjust it */ - { - scale = scale1-scale2; - memmove(r, r+scale, bnlength-scale); /* shift bytes over */ - memset(r+bnlength-scale, 0, scale); /* zero out the rest */ - } - else if (scale1 < scale2) /* answer is too small, adjust it */ - { - scale = scale2-scale1; - memmove(r+scale, r, bnlength-scale); /* shift bytes over */ - memset(r, 0, scale); /* zero out the rest */ - } - /* else scale1 == scale2 */ - - } - - if (sign) - neg_a_bn(r); - - return r; - } - -/********************************************************************/ -/* sqrt(r) */ -/* uses bntmp1 - bntmp6 - global temp bignumbers */ -/* SIDE-EFFECTS: */ -/* n ends up as |n| */ -bn_t sqrt_bn(bn_t r, bn_t n) - { - int i, comp, almost_match=0; - LDBL f; - bn_t orig_r, orig_n; - int orig_bnlength, - orig_padding, - orig_rlength, - orig_shiftfactor; - -/* use Newton's recursive method for zeroing in on sqrt(n): r=.5(r+n/r) */ - - if (is_bn_neg(n)) - { /* sqrt of a neg, return 0 */ - clear_bn(r); - return r; - } - - f = bntofloat(n); - if (f == 0) /* division by zero will occur */ - { - clear_bn(r); /* sqrt(0) = 0 */ - return r; - } - f = sqrtl(f); /* approximate square root */ - /* no need to check overflow */ - - /* With Newton's Method, there is no need to calculate all the digits */ - /* every time. The precision approximately doubles each iteration. */ - /* Save original values. */ - orig_bnlength = bnlength; - orig_padding = padding; - orig_rlength = rlength; - orig_shiftfactor = shiftfactor; - orig_r = r; - orig_n = n; - - /* calculate new starting values */ - bnlength = intlength + (int)(LDBL_DIG/LOG10_256) + 1; /* round up */ - if (bnlength > orig_bnlength) - bnlength = orig_bnlength; - calc_lengths(); - - /* adjust pointers */ - r = orig_r + orig_bnlength - bnlength; - n = orig_n + orig_bnlength - bnlength; - - floattobn(r, f); /* start with approximate sqrt */ - copy_bn(bntmp4, r); - - for (i=0; i<25; i++) /* safety net, this shouldn't ever be needed */ - { - /* adjust lengths */ - bnlength <<= 1; /* double precision */ - if (bnlength > orig_bnlength) - bnlength = orig_bnlength; - calc_lengths(); - r = orig_r + orig_bnlength - bnlength; - n = orig_n + orig_bnlength - bnlength; - - copy_bn(bntmp6, r); - copy_bn(bntmp5, n); - unsafe_div_bn(bntmp4, bntmp5, bntmp6); - add_a_bn(r, bntmp4); - half_a_bn(r); - if (bnlength == orig_bnlength && (comp=abs(cmp_bn(r, bntmp4))) < 8 ) /* if match or almost match */ - { - if (comp < 4 /* perfect or near perfect match */ - || almost_match == 1) /* close enough for 2nd time */ - break; - else /* this is the first time they almost matched */ - almost_match++; - } - } - - /* restore original values */ - bnlength = orig_bnlength; - padding = orig_padding; - rlength = orig_rlength; - shiftfactor = orig_shiftfactor; - r = orig_r; - n = orig_n; - - return r; - } - -/********************************************************************/ -/* exp(r) */ -/* uses bntmp1, bntmp2, bntmp3 - global temp bignumbers */ -bn_t exp_bn(bn_t r, bn_t n) - { - U16 fact=1; - - if (is_bn_zero(n)) - { - inttobn(r, 1); - return r; - } - -/* use Taylor Series (very slow convergence) */ - inttobn(r, 1); /* start with r=1.0 */ - copy_bn(bntmp2, r); - for (;;) - { - /* copy n, if n is negative, mult_bn() alters n */ - unsafe_mult_bn(bntmp3, bntmp2, copy_bn(bntmp1, n)); - copy_bn(bntmp2, bntmp3+shiftfactor); - div_a_bn_int(bntmp2, fact); - if (!is_bn_not_zero(bntmp2)) - break; /* too small to register */ - add_a_bn(r, bntmp2); - fact++; - } - return r; - } - -/********************************************************************/ -/* ln(r) */ -/* uses bntmp1 - bntmp6 - global temp bignumbers */ -/* SIDE-EFFECTS: */ -/* n ends up as |n| */ -bn_t unsafe_ln_bn(bn_t r, bn_t n) - { - int i, comp, almost_match=0; - long maxval; - LDBL f; - bn_t orig_r, orig_n, orig_bntmp5, orig_bntmp4; - int orig_bnlength, - orig_padding, - orig_rlength, - orig_shiftfactor; - -/* use Newton's recursive method for zeroing in on ln(n): r=r+n*exp(-r)-1 */ - - if (is_bn_neg(n) || is_bn_zero(n)) - { /* error, return largest neg value */ - max_bn(r); - neg_a_bn(r); - return r; - } - - f = bntofloat(n); - f = logl(f); /* approximate ln(x) */ - maxval = (1L << ((intlength<<3)-1)) - 1; - if (f > maxval) /* check for overflow */ - { - max_bn(r); - return r; - } - else if (f <= -maxval) - { - max_bn(r); - neg_a_bn(r); - return r; - } - /* appears to be ok, do ln */ - - /* With Newton's Method, there is no need to calculate all the digits */ - /* every time. The precision approximately doubles each iteration. */ - /* Save original values. */ - orig_bnlength = bnlength; - orig_padding = padding; - orig_rlength = rlength; - orig_shiftfactor = shiftfactor; - orig_r = r; - orig_n = n; - orig_bntmp5 = bntmp5; - orig_bntmp4 = bntmp4; - - inttobn(bntmp4, 1); /* set before setting new values */ - - /* calculate new starting values */ - bnlength = intlength + (int)(LDBL_DIG/LOG10_256) + 1; /* round up */ - if (bnlength > orig_bnlength) - bnlength = orig_bnlength; - calc_lengths(); - - /* adjust pointers */ - r = orig_r + orig_bnlength - bnlength; - n = orig_n + orig_bnlength - bnlength; - bntmp5 = orig_bntmp5 + orig_bnlength - bnlength; - bntmp4 = orig_bntmp4 + orig_bnlength - bnlength; - - floattobn(r, f); /* start with approximate ln */ - neg_a_bn(r); /* -r */ - copy_bn(bntmp5, r); /* -r */ - - for (i=0; i<25; i++) /* safety net, this shouldn't ever be needed */ - { - /* adjust lengths */ - bnlength <<= 1; /* double precision */ - if (bnlength > orig_bnlength) - bnlength = orig_bnlength; - calc_lengths(); - r = orig_r + orig_bnlength - bnlength; - n = orig_n + orig_bnlength - bnlength; - bntmp5 = orig_bntmp5 + orig_bnlength - bnlength; - bntmp4 = orig_bntmp4 + orig_bnlength - bnlength; - exp_bn(bntmp6, r); /* exp(-r) */ - unsafe_mult_bn(bntmp2, bntmp6, n); /* n*exp(-r) */ - sub_a_bn(bntmp2+shiftfactor, bntmp4); /* n*exp(-r) - 1 */ - sub_a_bn(r, bntmp2+shiftfactor); /* -r - (n*exp(-r) - 1) */ - - if (bnlength == orig_bnlength && (comp=abs(cmp_bn(r, bntmp5))) < 8 ) /* if match or almost match */ - { - if (comp < 4 /* perfect or near perfect match */ - || almost_match == 1) /* close enough for 2nd time */ - break; - else /* this is the first time they almost matched */ - almost_match++; - } - copy_bn(bntmp5, r); /* -r */ - } - - /* restore original values */ - bnlength = orig_bnlength; - padding = orig_padding; - rlength = orig_rlength; - shiftfactor = orig_shiftfactor; - r = orig_r; - n = orig_n; - bntmp5 = orig_bntmp5; - bntmp4 = orig_bntmp4; - - neg_a_bn(r); /* -(-r) */ - return r; - } - -/********************************************************************/ -/* sincos_bn(r) */ -/* uses bntmp1 - bntmp2 - global temp bignumbers */ -/* SIDE-EFFECTS: */ -/* n ends up as |n| mod (pi/4) */ -bn_t unsafe_sincos_bn(bn_t s, bn_t c, bn_t n) - { - U16 fact=2; - int k=0, i, halves; - int signcos=0, signsin=0, switch_sincos=0; - -#ifndef CALCULATING_BIG_PI - /* assure range 0 <= x < pi/4 */ - - if (is_bn_zero(n)) - { - clear_bn(s); /* sin(0) = 0 */ - inttobn(c, 1); /* cos(0) = 1 */ - return s; - } - - if (is_bn_neg(n)) - { - signsin = !signsin; /* sin(-x) = -sin(x), odd; cos(-x) = cos(x), even */ - neg_a_bn(n); - } - /* n >= 0 */ - - double_bn(bntmp1, bn_pi); /* 2*pi */ - /* this could be done with remainders, but it would probably be slower */ - while (cmp_bn(n, bntmp1) >= 0) /* while n >= 2*pi */ - sub_a_bn(n, bntmp1); - /* 0 <= n < 2*pi */ - - copy_bn(bntmp1, bn_pi); /* pi */ - if (cmp_bn(n, bntmp1) >= 0) /* if n >= pi */ - { - sub_a_bn(n, bntmp1); - signsin = !signsin; - signcos = !signcos; - } - /* 0 <= n < pi */ - - half_bn(bntmp1, bn_pi); /* pi/2 */ - if (cmp_bn(n, bntmp1) > 0) /* if n > pi/2 */ - { - sub_bn(n, bn_pi, n); /* pi - n */ - signcos = !signcos; - } - /* 0 <= n < pi/2 */ - - half_bn(bntmp1, bn_pi); /* pi/2 */ - half_a_bn(bntmp1); /* pi/4 */ - if (cmp_bn(n, bntmp1) > 0) /* if n > pi/4 */ - { - half_bn(bntmp1, bn_pi); /* pi/2 */ - sub_bn(n, bntmp1, n); /* pi/2 - n */ - switch_sincos = !switch_sincos; - } - /* 0 <= n < pi/4 */ - - /* this looks redundant, but n could now be zero when it wasn't before */ - if (is_bn_zero(n)) - { - clear_bn(s); /* sin(0) = 0 */ - inttobn(c, 1); /* cos(0) = 1 */ - return s; - } - - -/* at this point, the double angle trig identities could be used as many */ -/* times as desired to reduce the range to pi/8, pi/16, etc... Each time */ -/* the range is cut in half, the number of iterations required is reduced */ -/* by "quite a bit." It's just a matter of testing to see what gives the */ -/* optimal results. */ - /* halves = bnlength / 10; */ /* this is experimental */ - halves = 1; - for (i = 0; i < halves; i++) - half_a_bn(n); -#endif - -/* use Taylor Series (very slow convergence) */ - copy_bn(s, n); /* start with s=n */ - inttobn(c, 1); /* start with c=1 */ - copy_bn(bntmp1, n); /* the current x^n/n! */ - - for (;;) - { - /* even terms for cosine */ - unsafe_mult_bn(bntmp2, bntmp1, n); - copy_bn(bntmp1, bntmp2+shiftfactor); - div_a_bn_int(bntmp1, fact++); - if (!is_bn_not_zero(bntmp1)) - break; /* too small to register */ - if (k) /* alternate between adding and subtracting */ - add_a_bn(c, bntmp1); - else - sub_a_bn(c, bntmp1); - - /* odd terms for sine */ - unsafe_mult_bn(bntmp2, bntmp1, n); - copy_bn(bntmp1, bntmp2+shiftfactor); - div_a_bn_int(bntmp1, fact++); - if (!is_bn_not_zero(bntmp1)) - break; /* too small to register */ - if (k) /* alternate between adding and subtracting */ - add_a_bn(s, bntmp1); - else - sub_a_bn(s, bntmp1); - k = !k; /* toggle */ -#ifdef CALCULATING_BIG_PI - printf("."); /* lets you know it's doing something */ -#endif - } - -#ifndef CALCULATING_BIG_PI - /* now need to undo what was done by cutting angles in half */ - inttobn(bntmp1, 1); - for (i = 0; i < halves; i++) - { - unsafe_mult_bn(bntmp2, s, c); /* no need for safe mult */ - double_bn(s, bntmp2+shiftfactor); /* sin(2x) = 2*sin(x)*cos(x) */ - unsafe_square_bn(bntmp2,c); - double_a_bn(bntmp2+shiftfactor); - sub_bn(c, bntmp2+shiftfactor, bntmp1); /* cos(2x) = 2*cos(x)*cos(x) - 1 */ - } - - if (switch_sincos) - { - copy_bn(bntmp1, s); - copy_bn(s, c); - copy_bn(c, bntmp1); - } - if (signsin) - neg_a_bn(s); - if (signcos) - neg_a_bn(c); -#endif - - return s; /* return sine I guess */ - } - -/********************************************************************/ -/* atan(r) */ -/* uses bntmp1 - bntmp5 - global temp bignumbers */ -/* SIDE-EFFECTS: */ -/* n ends up as |n| or 1/|n| */ -bn_t unsafe_atan_bn(bn_t r, bn_t n) - { - int i, comp, almost_match=0, signflag=0; - LDBL f; - bn_t orig_r, orig_n, orig_bn_pi, orig_bntmp3; - int orig_bnlength, - orig_padding, - orig_rlength, - orig_shiftfactor; - int large_arg; - -/* use Newton's recursive method for zeroing in on atan(n): r=r-cos(r)(sin(r)-n*cos(r)) */ - - if (is_bn_neg(n)) - { - signflag = 1; - neg_a_bn(n); - } - -/* If n is very large, atanl() won't give enough decimal places to be a */ -/* good enough initial guess for Newton's Method. If it is larger than */ -/* say, 1, atan(n) = pi/2 - acot(n) = pi/2 - atan(1/n). */ - - f = bntofloat(n); - large_arg = f > 1.0; - if (large_arg) - { - unsafe_inv_bn(bntmp3, n); - copy_bn(n, bntmp3); - f = bntofloat(n); - } - - clear_bn(bntmp3); /* not really necessary, but makes things more consistent */ - - /* With Newton's Method, there is no need to calculate all the digits */ - /* every time. The precision approximately doubles each iteration. */ - /* Save original values. */ - orig_bnlength = bnlength; - orig_padding = padding; - orig_rlength = rlength; - orig_shiftfactor = shiftfactor; - orig_bn_pi = bn_pi; - orig_r = r; - orig_n = n; - orig_bntmp3 = bntmp3; - - /* calculate new starting values */ - bnlength = intlength + (int)(LDBL_DIG/LOG10_256) + 1; /* round up */ - if (bnlength > orig_bnlength) - bnlength = orig_bnlength; - calc_lengths(); - - /* adjust pointers */ - r = orig_r + orig_bnlength - bnlength; - n = orig_n + orig_bnlength - bnlength; - bn_pi = orig_bn_pi + orig_bnlength - bnlength; - bntmp3 = orig_bntmp3 + orig_bnlength - bnlength; - - f = atanl(f); /* approximate arctangent */ - /* no need to check overflow */ - - floattobn(r, f); /* start with approximate atan */ - copy_bn(bntmp3, r); - - for (i=0; i<25; i++) /* safety net, this shouldn't ever be needed */ - { - /* adjust lengths */ - bnlength <<= 1; /* double precision */ - if (bnlength > orig_bnlength) - bnlength = orig_bnlength; - calc_lengths(); - r = orig_r + orig_bnlength - bnlength; - n = orig_n + orig_bnlength - bnlength; - bn_pi = orig_bn_pi + orig_bnlength - bnlength; - bntmp3 = orig_bntmp3 + orig_bnlength - bnlength; - -#ifdef CALCULATING_BIG_PI - printf("\natan() loop #%i, bnlength=%i\nsincos() loops\n", i, bnlength); -#endif - unsafe_sincos_bn(bntmp4, bntmp5, bntmp3); /* sin(r), cos(r) */ - copy_bn(bntmp3, r); /* restore bntmp3 from sincos_bn() */ - copy_bn(bntmp1, bntmp5); - unsafe_mult_bn(bntmp2, n, bntmp1); /* n*cos(r) */ - sub_a_bn(bntmp4, bntmp2+shiftfactor); /* sin(r) - n*cos(r) */ - unsafe_mult_bn(bntmp1, bntmp5, bntmp4); /* cos(r) * (sin(r) - n*cos(r)) */ - sub_a_bn(r, bntmp1+shiftfactor); /* r - cos(r) * (sin(r) - n*cos(r)) */ - -#ifdef CALCULATING_BIG_PI - putchar('\n'); - bn_hexdump(r); -#endif - if (bnlength == orig_bnlength && (comp=abs(cmp_bn(r, bntmp3))) < 8 ) /* if match or almost match */ - { -#ifdef CALCULATING_BIG_PI - printf("atan() loop comp=%i\n", comp); -#endif - if (comp < 4 /* perfect or near perfect match */ - || almost_match == 1) /* close enough for 2nd time */ - break; - else /* this is the first time they almost matched */ - almost_match++; - } - -#ifdef CALCULATING_BIG_PI - if (bnlength == orig_bnlength && comp >= 8) - printf("atan() loop comp=%i\n", comp); -#endif - - copy_bn(bntmp3, r); /* make a copy for later comparison */ - } - - /* restore original values */ - bnlength = orig_bnlength; - padding = orig_padding; - rlength = orig_rlength; - shiftfactor = orig_shiftfactor; - bn_pi = orig_bn_pi; - r = orig_r; - n = orig_n; - bntmp3 = orig_bntmp3; - - if (large_arg) - { - half_bn(bntmp3, bn_pi); /* pi/2 */ - sub_a_bn(bntmp3, r); /* pi/2 - atan(1/n) */ - copy_bn(r, bntmp3); - } - - if (signflag) - neg_a_bn(r); - return r; - } - -/********************************************************************/ -/* atan2(r,ny,nx) */ -/* uses bntmp1 - bntmp6 - global temp bigfloats */ -bn_t unsafe_atan2_bn(bn_t r, bn_t ny, bn_t nx) - { - int signx, signy; - - signx = sign_bn(nx); - signy = sign_bn(ny); - - if (signy == 0) - { - if (signx < 0) - copy_bn(r, bn_pi); /* negative x axis, 180 deg */ - else /* signx >= 0 positive x axis, 0 */ - clear_bn(r); - return(r); - } - if (signx == 0) - { - copy_bn(r, bn_pi); /* y axis */ - half_a_bn(r); /* +90 deg */ - if (signy < 0) - neg_a_bn(r); /* -90 deg */ - return(r); - } - - if (signy < 0) - neg_a_bn(ny); - if (signx < 0) - neg_a_bn(nx); - unsafe_div_bn(bntmp6,ny,nx); - unsafe_atan_bn(r, bntmp6); - if (signx < 0) - sub_bn(r,bn_pi,r); - if (signy < 0) - neg_a_bn(r); - return(r); - } - - -/**********************************************************************/ -/* The rest of the functions are "safe" versions of the routines that */ -/* have side effects which alter the parameters */ -/**********************************************************************/ - -/**********************************************************************/ -bn_t full_mult_bn(bn_t r, bn_t n1, bn_t n2) - { - int sign1, sign2; - - sign1 = is_bn_neg(n1); - sign2 = is_bn_neg(n2); - unsafe_full_mult_bn(r, n1, n2); - if (sign1) - neg_a_bn(n1); - if (sign2) - neg_a_bn(n2); - return r; - } - -/**********************************************************************/ -bn_t mult_bn(bn_t r, bn_t n1, bn_t n2) - { - int sign1, sign2; - - /* TW ENDFIX */ - sign1 = is_bn_neg(n1); - sign2 = is_bn_neg(n2); - unsafe_mult_bn(r, n1, n2); - if (sign1) - neg_a_bn(n1); - if (sign2) - neg_a_bn(n2); - return r; - } - -/**********************************************************************/ -bn_t full_square_bn(bn_t r, bn_t n) - { - int sign; - - sign = is_bn_neg(n); - unsafe_full_square_bn(r, n); - if (sign) - neg_a_bn(n); - return r; - } - -/**********************************************************************/ -bn_t square_bn(bn_t r, bn_t n) - { - int sign; - - sign = is_bn_neg(n); - unsafe_square_bn(r, n); - if (sign) - neg_a_bn(n); - return r; - } - -/**********************************************************************/ -bn_t div_bn_int(bn_t r, bn_t n, U16 u) - { - int sign; - - sign = is_bn_neg(n); - unsafe_div_bn_int(r, n, u); - if (sign) - neg_a_bn(n); - return r; - } - -/**********************************************************************/ -char *bntostr(char *s, int dec, bn_t r) - { - return unsafe_bntostr(s, dec, copy_bn(bntmpcpy2, r)); - } - -/**********************************************************************/ -bn_t inv_bn(bn_t r, bn_t n) - { - int sign; - - sign = is_bn_neg(n); - unsafe_inv_bn(r, n); - if (sign) - neg_a_bn(n); - return r; - } - -/**********************************************************************/ -bn_t div_bn(bn_t r, bn_t n1, bn_t n2) - { - copy_bn(bntmpcpy1, n1); - copy_bn(bntmpcpy2, n2); - return unsafe_div_bn(r, bntmpcpy1, bntmpcpy2); - } - -/**********************************************************************/ -bn_t ln_bn(bn_t r, bn_t n) - { -#if 0 - int sign; - - sign = is_bn_neg(n); - unsafe_ln_bn(r, n); - if (sign) - neg_a_bn(n); -#endif - copy_bn(bntmpcpy1, n); /* allows r and n to overlap memory */ - unsafe_ln_bn(r, bntmpcpy1); - return r; - } - -/**********************************************************************/ -bn_t sincos_bn(bn_t s, bn_t c, bn_t n) - { - return unsafe_sincos_bn(s, c, copy_bn(bntmpcpy1, n)); - } - -/**********************************************************************/ -bn_t atan_bn(bn_t r, bn_t n) - { - int sign; - - sign = is_bn_neg(n); - unsafe_atan_bn(r, n); - if (sign) - neg_a_bn(n); - return r; - } - -/**********************************************************************/ -bn_t atan2_bn(bn_t r, bn_t ny, bn_t nx) - { - copy_bn(bntmpcpy1, ny); - copy_bn(bntmpcpy2, nx); - unsafe_atan2_bn(r, bntmpcpy1, bntmpcpy2); - return r; - } - - -/**********************************************************************/ -/* Tim's miscellaneous stuff follows */ - -/**********************************************************************/ -int is_bn_zero(bn_t n) - { - return !is_bn_not_zero(n); - } diff --git a/fractint/common/bignumc.c b/fractint/common/bignumc.c deleted file mode 100644 index 3d4795a3d..000000000 --- a/fractint/common/bignumc.c +++ /dev/null @@ -1,1000 +0,0 @@ -/* bignumc.c - C routines equivalent to ASM routines in bignuma.asm */ - -/* -Wesley Loewer's Big Numbers. (C) 1994-95, Wesley B. Loewer -*/ - -#include - /* see Fractint.c for a description of the "include" hierarchy */ -#include "port.h" -#include "big.h" - -/******************************************************************** - The following code contains the C versions of the routines from the - file BIGNUMA.ASM. It is provided here for portibility and for clarity. -*********************************************************************/ - -/******************************************************************** - Note: The C code must be able to detect over/underflow. Therefore - 32 bit integers must be used when doing 16 bit math. All we really - need is one more bit, such as is provided in asm with the carry bit. - Functions that don't need the test for over/underflow, such as cmp_bn() - and is_bn_not_zero(), can use 32 bit integers as as long as bnstep - is set to 4. - - The 16/32 bit compination of integer sizes could be increased to - 32/64 bit to improve efficiency, but since many compilers don't offer - 64 bit integers, this option was not included. - -*********************************************************************/ - -/********************************************************************/ -/* r = 0 */ -bn_t clear_bn(bn_t r) - { -#ifdef BIG_BASED - _fmemset( r, 0, bnlength); /* set array to zero */ -#else -#ifdef BIG_FAR - _fmemset( r, 0, bnlength); /* set array to zero */ -#else - memset( r, 0, bnlength); /* set array to zero */ -#endif -#endif - return r; - } - -/********************************************************************/ -/* r = max positive value */ -bn_t max_bn(bn_t r) - { -#ifdef BIG_BASED - _fmemset( r, 0xFF, bnlength-1); /* set to max values */ -#else -#ifdef BIG_FAR - _fmemset( r, 0xFF, bnlength-1); /* set to max values */ -#else - memset( r, 0xFF, bnlength-1); /* set to max values */ -#endif -#endif - r[bnlength-1] = 0x7F; /* turn off the sign bit */ - return r; - } - -/********************************************************************/ -/* r = n */ -bn_t copy_bn(bn_t r, bn_t n) - { -#ifdef BIG_BASED - _fmemcpy( r, n, bnlength); -#else -#ifdef BIG_FAR - _fmemcpy( r, n, bnlength); -#else - memcpy( r, n, bnlength); -#endif -#endif - return r; - } - -/***************************************************************************/ -/* n1 != n2 ? */ -/* RETURNS: */ -/* if n1 == n2 returns 0 */ -/* if n1 > n2 returns a positive (bytes left to go when mismatch occured) */ -/* if n1 < n2 returns a negative (bytes left to go when mismatch occured) */ -int cmp_bn(bn_t n1, bn_t n2) - { - int i; - S16 Svalue1, Svalue2; - U16 value1, value2; - - /* two bytes at a time */ - /* signed comparison for msb */ - if ( (Svalue1=big_accessS16((S16 BIGDIST *)(n1+bnlength-2))) > - (Svalue2=big_accessS16((S16 BIGDIST *)(n2+bnlength-2))) ) - { /* now determine which of the two bytes was different */ - if ( (S16)(Svalue1&0xFF00) > (S16)(Svalue2&0xFF00) ) /* compare just high bytes */ - return (bnlength); /* high byte was different */ - else - return (bnlength-1); /* low byte was different */ - } - else if (Svalue1 < Svalue2) - { /* now determine which of the two bytes was different */ - if ( (S16)(Svalue1&0xFF00) < (S16)(Svalue2&0xFF00) ) /* compare just high bytes */ - return -(bnlength); /* high byte was different */ - else - return -(bnlength-1); /* low byte was different */ - } - - /* unsigned comparison for the rest */ - for (i=bnlength-4; i>=0; i-=2) - { - if ( (value1=big_access16(n1+i)) > (value2=big_access16(n2+i)) ) - { /* now determine which of the two bytes was different */ - if ( (value1&0xFF00) > (value2&0xFF00) ) /* compare just high bytes */ - return (i+2); /* high byte was different */ - else - return (i+1); /* low byte was different */ - } - else if (value1 < value2) - { /* now determine which of the two bytes was different */ - if ( (value1&0xFF00) < (value2&0xFF00) ) /* compare just high bytes */ - return -(i+2); /* high byte was different */ - else - return -(i+1); /* low byte was different */ - } - } - return 0; - } - -/********************************************************************/ -/* r < 0 ? */ -/* returns 1 if negative, 0 if positive or zero */ -int is_bn_neg(bn_t n) - { - return (S8)n[bnlength-1] < 0; - } - -/********************************************************************/ -/* n != 0 ? */ -/* RETURNS: if n != 0 returns 1 */ -/* else returns 0 */ -int is_bn_not_zero(bn_t n) - { - int i; - - /* two bytes at a time */ - for (i=0; i>= 16; /* shift the overflow for next time */ - } - return r; - } - -/********************************************************************/ -/* r += n */ -bn_t add_a_bn(bn_t r, bn_t n) - { - int i; - U32 sum=0; - - /* two bytes at a time */ - for (i=0; i>= 16; /* shift the overflow for next time */ - } - return r; - } - -/********************************************************************/ -/* r = n1 - n2 */ -bn_t sub_bn(bn_t r, bn_t n1, bn_t n2) - { - int i; - U32 diff=0; - - /* two bytes at a time */ - for (i=0; i>= 16; /* shift the underflow for next time */ - } - return r; - } - -/********************************************************************/ -/* r -= n */ -bn_t sub_a_bn(bn_t r, bn_t n) - { - int i; - U32 diff=0; - - /* two bytes at a time */ - for (i=0; i>= 16; /* shift the underflow for next time */ - } - return r; - } - -/********************************************************************/ -/* r = -n */ -bn_t neg_bn(bn_t r, bn_t n) - { - int i; - U16 t_short; - U32 neg=1; /* to get the 2's complement started */ - - /* two bytes at a time */ - for (i=0; neg != 0 && i>= 16; /* shift the sign bit for next time */ - } - /* if neg was 0, then just "not" the rest */ - for (; i>= 16; /* shift the sign bit for next time */ - } - /* if neg was 0, then just "not" the rest */ - for (; i>= 16; /* shift the overflow for next time */ - } - return r; - } - -/********************************************************************/ -/* r *= 2 */ -bn_t double_a_bn(bn_t r) - { - int i; - U32 prod=0; - - /* two bytes at a time */ - for (i=0; i>= 16; /* shift the overflow for next time */ - } - return r; - } - -/********************************************************************/ -/* r = n/2 */ -bn_t half_bn(bn_t r, bn_t n) - { - int i; - U32 quot=0; - - /* two bytes at a time */ - - /* start with an arithmetic shift */ - i=bnlength-2; - quot += (U32)(((S32)(S16)big_access16(n+i)<<16)>>1) ; /* shift to upper 2 bytes and half it */ - big_set16(r+i, (U16)(quot>>16)); /* store the upper 2 bytes */ - quot <<= 16; /* shift the underflow for next time */ - - for (i=bnlength-4; i>=0; i-=2) - { - /* looks wierd, but properly sign extends argument */ - quot += (U32)(((U32)big_access16(n+i)<<16)>>1) ; /* shift to upper 2 bytes and half it */ - big_set16(r+i, (U16)(quot>>16)); /* store the upper 2 bytes */ - quot <<= 16; /* shift the underflow for next time */ - } - - return r; - } - -/********************************************************************/ -/* r /= 2 */ -bn_t half_a_bn(bn_t r) - { - int i; - U32 quot=0; - - /* two bytes at a time */ - - /* start with an arithmetic shift */ - i=bnlength-2; - quot += (U32)(((S32)(S16)big_access16(r+i)<<16)>>1) ; /* shift to upper 2 bytes and half it */ - big_set16(r+i, (U16)(quot>>16)); /* store the upper 2 bytes */ - quot <<= 16; /* shift the underflow for next time */ - - for (i=bnlength-4; i>=0; i-=2) - { - /* looks wierd, but properly sign extends argument */ - quot += (U32)(((U32)(U16)big_access16(r+i)<<16)>>1) ; /* shift to upper 2 bytes and half it */ - big_set16(r+i, (U16)(quot>>16)); /* store the upper 2 bytes */ - quot <<= 16; /* shift the underflow for next time */ - } - return r; - } - -/************************************************************************/ -/* r = n1 * n2 */ -/* Note: r will be a double wide result, 2*bnlength */ -/* n1 and n2 can be the same pointer */ -/* SIDE-EFFECTS: n1 and n2 are changed to their absolute values */ -bn_t unsafe_full_mult_bn(bn_t r, bn_t n1, bn_t n2) - { - int sign1, sign2 = 0, samevar; - int i, j, k, steps, doublesteps, carry_steps; - bn_t n1p, n2p; /* pointers for n1, n2 */ - bn_t rp1, rp2, rp3; /* pointers for r */ - U32 prod, sum; - - sign1 = is_bn_neg(n1); - if (sign1 != 0) /* =, not == */ - { - neg_a_bn(n1); - } - samevar = (n1 == n2); - if (!samevar) /* check to see if they're the same pointer */ - { - sign2 = is_bn_neg(n2); - if (sign2 != 0) /* =, not == */ - { - neg_a_bn(n2); - } - } - - n1p = n1; - steps = bnlength>>1; /* two bytes at a time */ - carry_steps = doublesteps = (steps<<1) - 2; - bnlength <<= 1; - clear_bn(r); /* double width */ - bnlength >>= 1; - rp1 = rp2 = r; - for (i = 0; i < steps; i++) - { - n2p = n2; - for (j = 0; j < steps; j++) - { - prod = (U32)big_access16(n1p) * (U32)big_access16(n2p); /* U16*U16=U32 */ - sum = (U32)big_access16(rp2) + prod; /* add to previous, including overflow */ - big_set16(rp2, (U16)sum); /* save the lower 2 bytes */ - sum >>= 16; /* keep just the upper 2 bytes */ - rp3 = rp2 + 2; /* move over 2 bytes */ - sum += big_access16(rp3); /* add what was the upper two bytes */ - big_set16(rp3 ,(U16)sum); /* save what was the upper two bytes */ - sum >>= 16; /* keep just the overflow */ - for (k=0; sum != 0 && k>= 16; /* keep just the new overflow */ - } - n2p += 2; /* to next word */ - rp2 += 2; - carry_steps--; /* use one less step */ - } - n1p += 2; /* to next word */ - rp2 = rp1 += 2; - carry_steps = --doublesteps; /* decrease doubles steps and reset carry_steps */ - } - - /* if they were the same or same sign, the product must be positive */ - if (!samevar && sign1 != sign2) - { - bnlength <<= 1; /* for a double wide number */ - neg_a_bn(r); - bnlength >>= 1; /* restore bnlength */ - } - return r; - } - -/************************************************************************/ -/* r = n1 * n2 calculating only the top rlength bytes */ -/* Note: r will be of length rlength */ -/* 2*bnlength <= rlength < bnlength */ -/* n1 and n2 can be the same pointer */ -/* SIDE-EFFECTS: n1 and n2 are changed to their absolute values */ -bn_t unsafe_mult_bn(bn_t r, bn_t n1, bn_t n2) - { - int sign1, sign2 = 0, samevar; - int i, j, k, steps, doublesteps, carry_steps, skips; - bn_t n1p, n2p; /* pointers for n1, n2 */ - bn_t rp1, rp2, rp3; /* pointers for r */ - U32 prod, sum; - int bnl; /* temp bnlength holder */ - - bnl = bnlength; - sign1 = is_bn_neg(n1); - if (sign1 != 0) /* =, not == */ - neg_a_bn(n1); - samevar = (n1 == n2); - if (!samevar) /* check to see if they're the same pointer */ - { - sign2 = is_bn_neg(n2); - if (sign2 != 0) /* =, not == */ - neg_a_bn(n2); - } - n1p = n1; - n2 += (bnlength<<1) - rlength; /* shift n2 over to where it is needed */ - - bnlength = rlength; - clear_bn(r); /* zero out r, rlength width */ - bnlength = bnl; - - steps = (rlength-bnlength)>>1; - skips = (bnlength>>1) - steps; - carry_steps = doublesteps = (rlength>>1)-2; - rp2 = rp1 = r; - for (i=bnlength>>1; i>0; i--) - { - n2p = n2; - for (j=0; j>= 16; /* keep just the upper 2 bytes */ - rp3 = rp2 + 2; /* move over 2 bytes */ - sum += big_access16(rp3); /* add what was the upper two bytes */ - big_set16(rp3, (U16)sum); /* save what was the upper two bytes */ - sum >>= 16; /* keep just the overflow */ - for (k=0; sum != 0 && k>= 16; /* keep just the new overflow */ - } - n2p += 2; /* increase by two bytes */ - rp2 += 2; - carry_steps--; - } - n1p += 2; /* increase by two bytes */ - - if (skips != 0) - { - n2 -= 2; /* shift n2 back a word */ - steps++; /* one more step this time */ - skips--; /* keep track of how many times we've done this */ - } - else - { - rp1 += 2; /* shift forward a word */ - doublesteps--; /* reduce the carry steps needed next time */ - } - rp2 = rp1; - carry_steps = doublesteps; - } - - /* if they were the same or same sign, the product must be positive */ - if (!samevar && sign1 != sign2) - { - bnlength = rlength; - neg_a_bn(r); /* wider bignumber */ - bnlength = bnl; - } - return r; - } - -/************************************************************************/ -/* r = n^2 */ -/* because of the symetry involved, n^2 is much faster than n*n */ -/* for a bignumber of length l */ -/* n*n takes l^2 multiplications */ -/* n^2 takes (l^2+l)/2 multiplications */ -/* which is about 1/2 n*n as l gets large */ -/* uses the fact that (a+b+c+...)^2 = (a^2+b^2+c^2+...)+2(ab+ac+bc+...)*/ -/* */ -/* SIDE-EFFECTS: n is changed to its absolute value */ -bn_t unsafe_full_square_bn(bn_t r, bn_t n) - { - int i, j, k, steps, doublesteps, carry_steps; - bn_t n1p, n2p; - bn_t rp1, rp2, rp3; - U32 prod, sum; - - if (is_bn_neg(n)) /* don't need to keep track of sign since the */ - neg_a_bn(n); /* answer must be positive. */ - - bnlength <<= 1; - clear_bn(r); /* zero out r, double width */ - bnlength >>= 1; - - steps = (bnlength>>1)-1; - carry_steps = doublesteps = (steps<<1) - 1; - rp2 = rp1 = r + 2; /* start with second two-byte word */ - n1p = n; - if (steps != 0) /* if zero, then skip all the middle term calculations */ - { - for (i=steps; i>0; i--) /* steps gets altered, count backwards */ - { - n2p = n1p + 2; /* set n2p pointer to 1 step beyond n1p */ - for (j=0; j>= 16; /* keep just the upper 2 bytes */ - rp3 = rp2 + 2; /* move over 2 bytes */ - sum += big_access16(rp3); /* add what was the upper two bytes */ - big_set16(rp3, (U16)sum); /* save what was the upper two bytes */ - sum >>= 16; /* keep just the overflow */ - for (k=0; sum != 0 && k>= 16; /* keep just the new overflow */ - } - n2p += 2; /* increase by two bytes */ - rp2 += 2; - carry_steps--; - } - n1p += 2; /* increase by two bytes */ - rp2 = rp1 += 4; /* increase by 2 * two bytes */ - carry_steps = doublesteps -= 2; /* reduce the carry steps needed */ - steps--; - } - /* All the middle terms have been multiplied. Now double it. */ - bnlength <<= 1; /* double wide bignumber */ - double_a_bn(r); - bnlength >>= 1; - /* finished with middle terms */ - } - - /* Now go back and add in the squared terms. */ - n1p = n; - steps = (bnlength>>1); - carry_steps = doublesteps = (steps<<1) - 2; - rp1 = r; - for (i=0; i>= 16; /* keep just the upper 2 bytes */ - rp3 = rp1 + 2; /* move over 2 bytes */ - sum += big_access16(rp3); /* add what was the upper two bytes */ - big_set16(rp3, (U16)sum); /* save what was the upper two bytes */ - sum >>= 16; /* keep just the overflow */ - for (k=0; sum != 0 && k>= 16; /* keep just the new overflow */ - } - n1p += 2; /* increase by 2 bytes */ - rp1 += 4; /* increase by 4 bytes */ - carry_steps = doublesteps -= 2; - } - return r; - } - - -/************************************************************************/ -/* r = n^2 */ -/* because of the symetry involved, n^2 is much faster than n*n */ -/* for a bignumber of length l */ -/* n*n takes l^2 multiplications */ -/* n^2 takes (l^2+l)/2 multiplications */ -/* which is about 1/2 n*n as l gets large */ -/* uses the fact that (a+b+c+...)^2 = (a^2+b^2+c^2+...)+2(ab+ac+bc+...)*/ -/* */ -/* Note: r will be of length rlength */ -/* 2*bnlength >= rlength > bnlength */ -/* SIDE-EFFECTS: n is changed to its absolute value */ -bn_t unsafe_square_bn(bn_t r, bn_t n) - { - int i, j, k, steps, doublesteps, carry_steps; - int skips, rodd; - bn_t n1p, n2p, n3p; - bn_t rp1, rp2, rp3; - U32 prod, sum; - int bnl; - -/* This whole procedure would be a great deal simpler if we could assume that */ -/* rlength < 2*bnlength (that is, not =). Therefore, we will take the */ -/* easy way out and call full_square_bn() if it is. */ - if (rlength == (bnlength<<1)) /* rlength == 2*bnlength */ - return unsafe_full_square_bn(r, n); /* call full_square_bn() and quit */ - - if (is_bn_neg(n)) /* don't need to keep track of sign since the */ - neg_a_bn(n); /* answer must be positive. */ - - bnl = bnlength; - bnlength = rlength; - clear_bn(r); /* zero out r, of width rlength */ - bnlength = bnl; - - /* determine whether r is on an odd or even two-byte word in the number */ - rodd = (U16)(((bnlength<<1)-rlength)>>1) & 0x0001; - i = (bnlength>>1)-1; - steps = (rlength-bnlength)>>1; - carry_steps = doublesteps = (bnlength>>1)+steps-2; - skips = (i - steps)>>1; /* how long to skip over pointer shifts */ - rp2 = rp1 = r; - n1p = n; - n3p = n2p = n1p + (((bnlength>>1)-steps)<<1); /* n2p = n1p + 2*(bnlength/2 - steps) */ - if (i != 0) /* if zero, skip middle term calculations */ - { - /* i is already set */ - for (; i>0; i--) - { - for (j=0; j>= 16; /* keep just the upper 2 bytes */ - rp3 = rp2 + 2; /* move over 2 bytes */ - sum += big_access16(rp3); /* add what was the upper two bytes */ - big_set16(rp3, (U16)sum); /* save what was the upper two bytes */ - sum >>= 16; /* keep just the overflow */ - for (k=0; sum != 0 && k>= 16; /* keep just the new overflow */ - } - n2p += 2; /* increase by 2-byte word size */ - rp2 += 2; - carry_steps--; - } - n1p += 2; /* increase by 2-byte word size */ - if (skips > 0) - { - n2p = n3p -= 2; - steps++; - skips--; - } - else if (skips == 0) /* only gets executed once */ - { - steps -= rodd; /* rodd is 1 or 0 */ - doublesteps -= rodd+1; - rp1 += (rodd+1)<<1; - n2p = n1p+2; - skips--; - } - else /* skips < 0 */ - { - steps--; - doublesteps -= 2; - rp1 += 4; /* add two 2-byte words */ - n2p = n1p + 2; - } - rp2 = rp1; - carry_steps = doublesteps; - } - /* All the middle terms have been multiplied. Now double it. */ - bnlength = rlength; - double_a_bn(r); - bnlength = bnl; - } - /* Now go back and add in the squared terms. */ - - /* be careful, the next dozen or so lines are confusing! */ - /* determine whether r is on an odd or even word in the number */ - /* using i as a temporary variable here */ - i = (bnlength<<1)-rlength; - rp1 = r + ((U16)i & (U16)0x0002); - i = (U16)((i>>1)+1) & (U16)0xFFFE; - n1p = n + i; - /* i here is no longer a temp var., but will be used as a loop counter */ - i = (bnlength - i)>>1; - carry_steps = doublesteps = (i<<1)-2; - /* i is already set */ - for (; i>0; i--) - { - /* square it */ - prod = (U32)big_access16(n1p) * (U32)big_access16(n1p); /* U16*U16=U32 */ - sum = (U32)big_access16(rp1) + prod; /* add to previous, including overflow */ - big_set16(rp1, (U16)sum); /* save the lower 2 bytes */ - sum >>= 16; /* keep just the upper 2 bytes */ - rp3 = rp1 + 2; /* move over 2 bytes */ - sum += big_access16(rp3); /* add what was the upper two bytes */ - big_set16(rp3, (U16)sum); /* save what was the upper two bytes */ - sum >>= 16; /* keep just the overflow */ - for (k=0; sum != 0 && k>= 16; /* keep just the new overflow */ - } - n1p += 2; - rp1 += 4; - carry_steps = doublesteps -= 2; - } - return r; - } - -/********************************************************************/ -/* r = n * u where u is an unsigned integer */ -bn_t mult_bn_int(bn_t r, bn_t n, U16 u) - { - int i; - U32 prod=0; - - /* two bytes at a time */ - for (i=0; i>= 16; /* shift the overflow for next time */ - } - return r; - } - -/********************************************************************/ -/* r *= u where u is an unsigned integer */ -bn_t mult_a_bn_int(bn_t r, U16 u) - { - int i; - U32 prod=0; - - /* two bytes at a time */ - for (i=0; i>= 16; /* shift the overflow for next time */ - } - return r; - } - -/********************************************************************/ -/* r = n / u where u is an unsigned integer */ -bn_t unsafe_div_bn_int(bn_t r, bn_t n, U16 u) - { - int i, sign; - U32 full_number; - U16 quot, rem=0; - - sign = is_bn_neg(n); - if (sign) - neg_a_bn(n); - - if (u == 0) /* division by zero */ - { - max_bn(r); - if (sign) - neg_a_bn(r); - return r; - } - - /* two bytes at a time */ - for (i=bnlength-2; i>=0; i-=2) - { - full_number = ((U32)rem<<16) + (U32)big_access16(n+i); - quot = (U16)(full_number / u); - rem = (U16)(full_number % u); - big_set16(r+i, quot); - } - - if (sign) - neg_a_bn(r); - return r; - } - -/********************************************************************/ -/* r /= u where u is an unsigned integer */ -bn_t div_a_bn_int(bn_t r, U16 u) - { - int i, sign; - U32 full_number; - U16 quot, rem=0; - - sign = is_bn_neg(r); - if (sign) - neg_a_bn(r); - - if (u == 0) /* division by zero */ - { - max_bn(r); - if (sign) - neg_a_bn(r); - return r; - } - - /* two bytes at a time */ - for (i=bnlength-2; i>=0; i-=2) - { - full_number = ((U32)rem<<16) + (U32)big_access16(r+i); - quot = (U16)(full_number / u); - rem = (U16)(full_number % u); - big_set16(r+i, quot); - } - - if (sign) - neg_a_bn(r); - return r; - } - -/*********************************************************************/ -/* f = b */ -/* Converts a bignumber to a double */ -LDBL bntofloat(bn_t n) - { - int i; - int signflag=0; - int expon; - bn_t getbyte; - LDBL f=0; - - if (is_bn_neg(n)) - { - signflag = 1; - neg_a_bn(n); - } - - expon = intlength - 1; - getbyte = n + bnlength - 1; - while (*getbyte == 0 && getbyte >= n) - { - getbyte--; - expon--; - } - - /* There is no need to use all bnlength bytes. To get the full */ - /* precision of LDBL, all you need is LDBL_MANT_DIG/8+1. */ - for (i = 0; i < (LDBL_MANT_DIG/8+1) && getbyte >= n; i++, getbyte--) - { - f += scale_256(*getbyte,-i); - } - - f = scale_256(f,expon); - - if (signflag) - { - f = -f; - neg_a_bn(n); - } - return f; - } - -/*****************************************/ -/* the following used to be in bigfltc.c */ - -/********************************************************************/ -/* r = 0 */ -bf_t clear_bf(bf_t r) - { - memset( r, 0, bflength+2); /* set array to zero */ - return r; - } - -/********************************************************************/ -/* r = n */ -bf_t copy_bf(bf_t r, bf_t n) - { - memcpy( r, n, bflength+2); - return r; - } - -/*********************************************************************/ -/* b = f */ -/* Converts a double to a bigfloat */ -bf_t floattobf(bf_t r, LDBL f) - { - int power; - int bnl, il; - if (f == 0) - { - clear_bf(r); - return r; - } - - /* remove the exp part */ - f = extract_256(f, &power); - - bnl = bnlength; - bnlength = bflength; - il = intlength; - intlength = 2; - floattobn(r, f); - bnlength = bnl; - intlength = il; - - big_set16(r + bflength, (S16)power); /* exp */ - - return r; - } - -/*********************************************************************/ -/* b = f */ -/* Converts a double to a bigfloat */ -bf_t floattobf1(bf_t r, LDBL f) - { - char msg[80]; -#ifdef USE_LONG_DOUBLE - sprintf(msg,"%-.22Le",f); -#else - sprintf(msg,"%-.22le",f); -#endif - strtobf(r,msg); - return r; - } - -/*********************************************************************/ -/* f = b */ -/* Converts a bigfloat to a double */ -LDBL bftofloat(bf_t n) - { - int power; - int bnl, il; - LDBL f; - - bnl = bnlength; - bnlength = bflength; - il = intlength; - intlength = 2; - f = bntofloat(n); - bnlength = bnl; - intlength = il; - - power = (S16)big_access16(n + bflength); - f = scale_256(f,power); - - return f; - } - -/********************************************************************/ -/* extracts the mantissa and exponent of f */ -/* finds m and n such that 1<=|m|<256 and f = m*256^n */ -/* n is stored in *exp_ptr and m is returned, sort of like frexp() */ -LDBL extract_256(LDBL f, int *exp_ptr) - { - return extract_value(f, 256, exp_ptr); - } - -/********************************************************************/ -/* calculates and returns the value of f*256^n */ -/* sort of like ldexp() */ -/* */ -/* n must be in the range -2^12 <= n < 2^12 (2^12=4096), */ -/* which should not be a problem */ -LDBL scale_256( LDBL f, int n ) - { - return scale_value( f, 256, n ); - } diff --git a/fractint/common/calcfrac.c b/fractint/common/calcfrac.c deleted file mode 100644 index ba867c495..000000000 --- a/fractint/common/calcfrac.c +++ /dev/null @@ -1,4335 +0,0 @@ -/* -CALCFRAC.C contains the high level ("engine") code for calculating the -fractal images (well, SOMEBODY had to do it!). -Original author Tim Wegner, but just about ALL the authors have contributed -SOME code to this routine at one time or another, or contributed to one of -the many massive restructurings. -The following modules work very closely with CALCFRAC.C: - FRACTALS.C the fractal-specific code for escape-time fractals. - FRACSUBR.C assorted subroutines belonging mainly to calcfrac. - CALCMAND.ASM fast Mandelbrot/Julia integer implementation -Additional fractal-specific modules are also invoked from CALCFRAC: - LORENZ.C engine level and fractal specific code for attractors. - JB.C julibrot logic - PARSER.C formula fractals - and more - -------------------------------------------------------------------- */ - -#include -#include -#include - /* see Fractint.c for a description of the "include" hierarchy */ -#include "port.h" -#include "prototyp.h" -#include "fractype.h" -#include "targa_lc.h" -#include "drivers.h" - -/* routines in this module */ -static void perform_worklist(void); -static int OneOrTwoPass(void); -static int _fastcall StandardCalc(int); -static int _fastcall potential(double,long); -static void decomposition(void); -static int bound_trace_main(void); -static void step_col_row(void); -static int solidguess(void); -static int _fastcall guessrow(int,int,int); -static void _fastcall plotblock(int,int,int,int); -static void _fastcall setsymmetry(int,int); -static int _fastcall xsym_split(int,int); -static int _fastcall ysym_split(int,int); -static void _fastcall puttruecolor_disk(int,int,int); -static int diffusion_engine (void); -static int sticky_orbits(void); - -/**CJLT new function prototypes: */ -static int tesseral(void); -static int _fastcall tesschkcol(int,int,int); -static int _fastcall tesschkrow(int,int,int); -static int _fastcall tesscol(int,int,int); -static int _fastcall tessrow(int,int,int); - -/* new drawing method by HB */ -static int diffusion_scan(void); - -/* lookup tables to avoid too much bit fiddling : */ -static char dif_la[] = { -0, 8, 0, 8,4,12,4,12,0, 8, 0, 8,4,12,4,12, 2,10, 2,10,6,14,6,14,2,10, -2,10, 6,14,6,14,0, 8,0, 8, 4,12,4,12,0, 8, 0, 8, 4,12,4,12,2,10,2,10, -6,14, 6,14,2,10,2,10,6,14, 6,14,1, 9,1, 9, 5,13, 5,13,1, 9,1, 9,5,13, -5,13, 3,11,3,11,7,15,7,15, 3,11,3,11,7,15, 7,15, 1, 9,1, 9,5,13,5,13, -1, 9, 1, 9,5,13,5,13,3,11, 3,11,7,15,7,15, 3,11, 3,11,7,15,7,15,0, 8, -0, 8, 4,12,4,12,0, 8,0, 8, 4,12,4,12,2,10, 2,10, 6,14,6,14,2,10,2,10, -6,14, 6,14,0, 8,0, 8,4,12, 4,12,0, 8,0, 8, 4,12, 4,12,2,10,2,10,6,14, -6,14, 2,10,2,10,6,14,6,14, 1, 9,1, 9,5,13, 5,13, 1, 9,1, 9,5,13,5,13, -3,11, 3,11,7,15,7,15,3,11, 3,11,7,15,7,15, 1, 9, 1, 9,5,13,5,13,1, 9, -1, 9, 5,13,5,13,3,11,3,11, 7,15,7,15,3,11, 3,11, 7,15,7,15 -}; - -static char dif_lb[] = { - 0, 8, 8, 0, 4,12,12, 4, 4,12,12, 4, 8, 0, 0, 8, 2,10,10, 2, 6,14,14, - 6, 6,14,14, 6,10, 2, 2,10, 2,10,10, 2, 6,14,14, 6, 6,14,14, 6,10, 2, - 2,10, 4,12,12, 4, 8, 0, 0, 8, 8, 0, 0, 8,12, 4, 4,12, 1, 9, 9, 1, 5, -13,13, 5, 5,13,13, 5, 9, 1, 1, 9, 3,11,11, 3, 7,15,15, 7, 7,15,15, 7, -11, 3, 3,11, 3,11,11, 3, 7,15,15, 7, 7,15,15, 7,11, 3, 3,11, 5,13,13, - 5, 9, 1, 1, 9, 9, 1, 1, 9,13, 5, 5,13, 1, 9, 9, 1, 5,13,13, 5, 5,13, -13, 5, 9, 1, 1, 9, 3,11,11, 3, 7,15,15, 7, 7,15,15, 7,11, 3, 3,11, 3, -11,11, 3, 7,15,15, 7, 7,15,15, 7,11, 3, 3,11, 5,13,13, 5, 9, 1, 1, 9, - 9, 1, 1, 9,13, 5, 5,13, 2,10,10, 2, 6,14,14, 6, 6,14,14, 6,10, 2, 2, -10, 4,12,12, 4, 8, 0, 0, 8, 8, 0, 0, 8,12, 4, 4,12, 4,12,12, 4, 8, 0, - 0, 8, 8, 0, 0, 8,12, 4, 4,12, 6,14,14, 6,10, 2, 2,10,10, 2, 2,10,14, - 6, 6,14 -}; - -/* added for testing autologmap() */ -static long autologmap(void); - -/* variables exported from this file */ -_LCMPLX linitorbit; -long lmagnitud, llimit, llimit2, lclosenuff, l16triglim; -_CMPLX init, tmp, old, g_new, saved; -int color; -long coloriter, oldcoloriter, realcoloriter; -int row, col, passes; -int invert; -double f_radius,f_xcenter, f_ycenter; /* for inversion */ -void (_fastcall *putcolor)(int,int,int) = putcolor_a; -void (_fastcall *plot)(int,int,int) = putcolor_a; - -double magnitude, rqlim, rqlim2, rqlim_save; -int no_mag_calc = 0; -int use_old_period = 0; -int use_old_distest = 0; -int old_demm_colors = 0; -int (*calctype)(void); -int (*calctypetmp)(void); -int quick_calc = 0; -double closeprox = 0.01; - -double closenuff; -int pixelpi; /* value of pi in pixels */ -unsigned long lm; /* magnitude limit (CALCMAND) */ - -/* ORBIT variables */ -int show_orbit; /* flag to turn on and off */ -int orbit_ptr; /* pointer into save_orbit array */ -int save_orbit[1500]; /* array to save orbit values */ -int orbit_color=15; /* XOR color */ - -int ixstart, ixstop, iystart, iystop; /* start, stop here */ -int symmetry; /* symmetry flag */ -int reset_periodicity; /* nonzero if escape time pixel rtn to reset */ -int kbdcount, max_kbdcount; /* avoids checking keyboard too often */ - -U16 resume_info = 0; /* handle to resume info if allocated */ -int resuming; /* nonzero if resuming after interrupt */ -int num_worklist; /* resume worklist for standard engine */ -WORKLIST worklist[MAXCALCWORK]; -int xxstart,xxstop,xxbegin; /* these are same as worklist, */ -int yystart,yystop,yybegin; /* declared as separate items */ -int workpass,worksym; /* for the sake of calcmand */ - -VOIDPTR typespecific_workarea = NULL; - -static double dem_delta, dem_width; /* distance estimator variables */ -static double dem_toobig; -static int dem_mandel; -#define DEM_BAILOUT 535.5 /* (pb: not sure if this is special or arbitrary) */ - -/* variables which must be visible for tab_display */ -int got_status; /* -1 if not, 0 for 1or2pass, 1 for ssg, */ - /* 2 for btm, 3 for 3d, 4 for tesseral, 5 for diffusion_scan */ - /* 6 for orbits */ -int curpass,totpasses; -int currow,curcol; - -/* static vars for diffusion scan */ -unsigned bits=0; /* number of bits in the counter */ -unsigned long dif_counter; /* the diffusion counter */ -unsigned long dif_limit; /* the diffusion counter */ - -/* static vars for solidguess & its subroutines */ -char three_pass; -static int maxblock,halfblock; -static int guessplot; /* paint 1st pass row at a time? */ -static int right_guess,bottom_guess; -#define maxyblk 7 /* maxxblk*maxyblk*2 <= 4096, the size of "prefix" */ -#define maxxblk 202 /* each maxnblk is oversize by 2 for a "border" */ - /* maxxblk defn must match fracsubr.c */ -/* next has a skip bit for each maxblock unit; - 1st pass sets bit [1]... off only if block's contents guessed; - at end of 1st pass [0]... bits are set if any surrounding block not guessed; - bits are numbered [..][y/16+1][x+1]&(1<<(y&15)) */ - -/* Original array */ -/* extern unsigned int prefix[2][maxyblk][maxxblk]; */ - -typedef int (*TPREFIX)[2][maxyblk][maxxblk]; - -/* size of next puts a limit of MAXPIXELS pixels across on solid guessing logic */ -#if defined(XFRACT) || defined(_WIN32) -BYTE dstack[4096]; /* common temp, two put_line calls */ -unsigned int tprefix[2][maxyblk][maxxblk]; /* common temp */ -#else -#define tprefix (*((TPREFIX)prefix)) -#endif - -int nxtscreenflag; /* for cellular next screen generation */ -int attractors; /* number of finite attractors */ -_CMPLX attr[N_ATTR]; /* finite attractor vals (f.p) */ -_LCMPLX lattr[N_ATTR]; /* finite attractor vals (int) */ -int attrperiod[N_ATTR]; /* period of the finite attractor */ - -/***** vars for new btm *****/ -enum direction {North,East,South,West}; -enum direction going_to; -int trail_row, trail_col; - -#ifndef sqr -#define sqr(x) ((x)*(x)) -#endif - -#ifndef lsqr -#define lsqr(x) (multiply((x),(x),bitshift)) -#endif - -/* -------------------------------------------------------------------- */ -/* These variables are external for speed's sake only */ -/* -------------------------------------------------------------------- */ - -int periodicitycheck; - -/* For periodicity testing, only in StandardFractal() */ -int nextsavedincr; -long firstsavedand; - -static BYTE *savedots = NULL; -static BYTE *fillbuff; -static int savedotslen; -static int showdotcolor; -int atan_colors = 180; - -static int showdot_width = 0; -#define SAVE 1 -#define RESTORE 2 - -#define JUST_A_POINT 0 -#define LOWER_RIGHT 1 -#define UPPER_RIGHT 2 -#define LOWER_LEFT 3 -#define UPPER_LEFT 4 - -/* FMODTEST routine. */ -/* Makes the test condition for the FMOD coloring type - that of the current bailout method. 'or' and 'and' - methods are not used - in these cases a normal - modulus test is used */ - -double fmodtest(void) -{ - double result; - if (inside==FMODI && save_release <= 2000) /* for backwards compatibility */ - { - if (magnitude == 0.0 || no_mag_calc == 0 || integerfractal) - result=sqr(g_new.x)+sqr(g_new.y); - else - result=magnitude; /* don't recalculate */ - return result; - } - - switch (bailoutest) - { - case Mod: - { - if (magnitude == 0.0 || no_mag_calc == 0 || integerfractal) - result=sqr(g_new.x)+sqr(g_new.y); - else - result=magnitude; /* don't recalculate */ - }break; - case Real: - { - result=sqr(g_new.x); - }break; - case Imag: - { - result=sqr(g_new.y); - }break; - case Or: - { - double tmpx, tmpy; - if ((tmpx = sqr(g_new.x)) > (tmpy = sqr(g_new.y))) - result=tmpx; - else - result=tmpy; - }break; - case Manh: - { - result=sqr(fabs(g_new.x)+fabs(g_new.y)); - }break; - case Manr: - { - result=sqr(g_new.x+g_new.y); - }break; - default: - { - result=sqr(g_new.x)+sqr(g_new.y); - }break; - } - return result; -} - -/* - The sym_fill_line() routine was pulled out of the boundary tracing - code for re-use with showdot. It's purpose is to fill a line with a - solid color. This assumes that BYTE *str is already filled - with the color. The routine does write the line using symmetry - in all cases, however the symmetry logic assumes that the line - is one color; it is not general enough to handle a row of - pixels of different colors. -*/ -static void sym_fill_line(int row, int left, int right, BYTE *str) -{ - int i,j,k, length; - length = right-left+1; - put_line(row,left,right,str); - /* here's where all the symmetry goes */ - if (plot == putcolor) - kbdcount -= length >> 4; /* seems like a reasonable value */ - else if (plot == symplot2) /* X-axis symmetry */ - { - i = yystop-(row-yystart); - if (i > iystop && i < ydots) - { - put_line(i,left,right,str); - kbdcount -= length >> 3; - } - } - else if (plot == symplot2Y) /* Y-axis symmetry */ - { - put_line(row,xxstop-(right-xxstart),xxstop-(left-xxstart),str); - kbdcount -= length >> 3; - } - else if (plot == symplot2J) /* Origin symmetry */ - { - i = yystop-(row-yystart); - j = min(xxstop-(right-xxstart),xdots-1); - k = min(xxstop-(left -xxstart),xdots-1); - if (i > iystop && i < ydots && j <= k) - put_line(i,j,k,str); - kbdcount -= length >> 3; - } - else if (plot == symplot4) /* X-axis and Y-axis symmetry */ - { - i = yystop-(row-yystart); - j = min(xxstop-(right-xxstart),xdots-1); - k = min(xxstop-(left -xxstart),xdots-1); - if (i > iystop && i < ydots) - { - put_line(i,left,right,str); - if (j <= k) - put_line(i,j,k,str); - } - if (j <= k) - put_line(row,j,k,str); - kbdcount -= length >> 2; - } - else /* cheap and easy way out */ - { - for (i = left; i <= right; i++) /* DG */ - (*plot)(i,row,str[i-left]); - kbdcount -= length >> 1; - } -} - -/* - The sym_put_line() routine is the symmetry-aware version of put_line(). - It only works efficiently in the no symmetry or XAXIS symmetry case, - otherwise it just writes the pixels one-by-one. -*/ -static void sym_put_line(int row, int left, int right, BYTE *str) -{ - int length,i; - length = right-left+1; - put_line(row,left,right,str); - if (plot == putcolor) - kbdcount -= length >> 4; /* seems like a reasonable value */ - else if (plot == symplot2) /* X-axis symmetry */ - { - i = yystop-(row-yystart); - if (i > iystop && i < ydots) - put_line(i,left,right,str); - kbdcount -= length >> 3; - } - else - { - for (i = left; i <= right; i++) /* DG */ - (*plot)(i,row,str[i-left]); - kbdcount -= length >> 1; - } -} - -void showdotsaverestore(int startx, int stopx, int starty, int stopy, int direction, int action) -{ - int j,ct; - ct = 0; - if (direction != JUST_A_POINT) - { - if (savedots == NULL) - { - stopmsg(0,"savedots NULL"); - exit(0); - } - if (fillbuff == NULL) - { - stopmsg(0,"fillbuff NULL"); - exit(0); - } - } - switch (direction) - { - case LOWER_RIGHT: - for (j=starty; j<=stopy; startx++,j++) - { - if (action==SAVE) - { - get_line(j,startx,stopx,savedots+ct); - sym_fill_line(j,startx,stopx,fillbuff); - } - else - sym_put_line(j,startx,stopx,savedots+ct); - ct += stopx-startx+1; - } - break; - case UPPER_RIGHT: - for (j=starty; j>=stopy; startx++,j--) - { - if (action==SAVE) - { - get_line(j,startx,stopx,savedots+ct); - sym_fill_line(j,startx,stopx,fillbuff); - } - else - sym_put_line(j,startx,stopx,savedots+ct); - ct += stopx-startx+1; - } - break; - case LOWER_LEFT: - for (j=starty; j<=stopy; stopx--,j++) - { - if (action==SAVE) - { - get_line(j,startx,stopx,savedots+ct); - sym_fill_line(j,startx,stopx,fillbuff); - } - else - sym_put_line(j,startx,stopx,savedots+ct); - ct += stopx-startx+1; - } - break; - case UPPER_LEFT: - for (j=starty; j>=stopy; stopx--,j--) - { - if (action==SAVE) - { - get_line(j,startx,stopx,savedots+ct); - sym_fill_line(j,startx,stopx,fillbuff); - } - else - sym_put_line(j,startx,stopx,savedots+ct); - ct += stopx-startx+1; - } - break; - } - if (action == SAVE) - (*plot) (col,row, showdotcolor); -} - -int calctypeshowdot(void) -{ - int out, startx, starty, stopx, stopy, direction, width; - direction = JUST_A_POINT; - startx = stopx = col; - starty = stopy = row; - width = showdot_width+1; - if (width > 0) { - if (col+width <= ixstop && row+width <= iystop) - { - /* preferred showdot shape */ - direction = UPPER_LEFT; - startx = col; - stopx = col+width; - starty = row+width; - stopy = row+1; - } - else if (col-width >= ixstart && row+width <= iystop) - { - /* second choice */ - direction = UPPER_RIGHT; - startx = col-width; - stopx = col; - starty = row+width; - stopy = row+1; - } - else if (col-width >= ixstart && row-width >= iystart) - { - direction = LOWER_RIGHT; - startx = col-width; - stopx = col; - starty = row-width; - stopy = row-1; - } - else if (col+width <= ixstop && row-width >= iystart) - { - direction = LOWER_LEFT; - startx = col; - stopx = col+width; - starty = row-width; - stopy = row-1; - } - } - showdotsaverestore(startx, stopx, starty, stopy, direction, SAVE); - if (orbit_delay > 0) sleepms(orbit_delay); - out = (*calctypetmp)(); - showdotsaverestore(startx, stopx, starty, stopy, direction, RESTORE); - return out; -} - -/******* calcfract - the top level routine for generating an image *******/ - -int calcfract(void) -{ - matherr_ct = 0; - attractors = 0; /* default to no known finite attractors */ - display3d = 0; - basin = 0; - /* added yet another level of indirection to putcolor!!! TW */ - putcolor = putcolor_a; - if (g_is_true_color && truemode) - /* Have to force passes=1 */ - usr_stdcalcmode = stdcalcmode = '1'; - if (truecolor) - { - check_writefile(light_name, ".tga"); - if (startdisk1(light_name,NULL,0)==0) - { - /* Have to force passes=1 */ - usr_stdcalcmode = stdcalcmode = '1'; - putcolor = puttruecolor_disk; - } - else - truecolor = 0; - } - if (!use_grid) - { - if (usr_stdcalcmode != 'o') - usr_stdcalcmode = stdcalcmode = '1'; - } - - init_misc(); /* set up some variables in parser.c */ - reset_clock(); - - /* following delta values useful only for types with rotation disabled */ - /* currently used only by bifurcation */ - if (integerfractal) - distest = 0; - parm.x = param[0]; - parm.y = param[1]; - parm2.x = param[2]; - parm2.y = param[3]; - - if (LogFlag && colors < 16) { - stopmsg(0, "Need at least 16 colors to use logmap"); - LogFlag = 0; - } - - if (use_old_period == 1) { - nextsavedincr = 1; - firstsavedand = 1; - } - else { - nextsavedincr = (int)log10(maxit); /* works better than log() */ - if (nextsavedincr < 4) nextsavedincr = 4; /* maintains image with low iterations */ - firstsavedand = (long)((nextsavedincr*2) + 1); - } - - LogTable = NULL; - MaxLTSize = maxit; - Log_Calc = 0; -/* below, INT_MAX=32767 only when an integer is two bytes. Which is not true for Xfractint. */ -/* Since 32767 is what was meant, replaced the instances of INT_MAX with 32767. */ - if (LogFlag && (((maxit > 32767) && (save_release > 1920)) - || Log_Fly_Calc == 1)) { - Log_Calc = 1; /* calculate on the fly */ - SetupLogTable(); - } - else if (LogFlag && (((maxit > 32767) && (save_release <= 1920)) - || Log_Fly_Calc == 2)) { - MaxLTSize = 32767; - Log_Calc = 0; /* use logtable */ - } - else if (rangeslen && (maxit >= 32767)) { - MaxLTSize = 32766; - } - - if ((LogFlag || rangeslen) && !Log_Calc) - { - LogTable = (BYTE *)malloc((long)MaxLTSize + 1); - - if (LogTable == NULL) - { - if (rangeslen || Log_Fly_Calc == 2) { - stopmsg(0, "Insufficient memory for logmap/ranges with this maxiter"); - } - else { - stopmsg(0, "Insufficient memory for logTable, using on-the-fly routine"); - Log_Fly_Calc = 1; - Log_Calc = 1; /* calculate on the fly */ - SetupLogTable(); - } - } - else if (rangeslen) { /* Can't do ranges if MaxLTSize > 32767 */ - int i,k,l,m,numval,flip,altern; - i = k = l = 0; - LogFlag = 0; /* ranges overrides logmap */ - while (i < rangeslen) { - m = flip = 0; - altern = 32767; - if ((numval = ranges[i++]) < 0) { - altern = ranges[i++]; /* sub-range iterations */ - numval = ranges[i++]; - } - if (numval > (int)MaxLTSize || i >= rangeslen) - numval = (int)MaxLTSize; - while (l <= numval) { - LogTable[l++] = (BYTE)(k + flip); - if (++m >= altern) { - flip ^= 1; /* Alternate colors */ - m = 0; - } - } - ++k; - if (altern != 32767) ++k; - } - } - else - SetupLogTable(); - } - lm = 4L << bitshift; /* CALCMAND magnitude limit */ - - if (save_release > 2002) - atan_colors = colors; - else - atan_colors = 180; - - /* ORBIT stuff */ - show_orbit = start_showorbit; - orbit_ptr = 0; - orbit_color = 15; - if (colors < 16) - orbit_color = 1; - - if (inversion[0] != 0.0) - { - f_radius = inversion[0]; - f_xcenter = inversion[1]; - f_ycenter = inversion[2]; - - if (inversion[0] == AUTOINVERT) /* auto calc radius 1/6 screen */ - { - inversion[0] = min(fabs(xxmax - xxmin), - fabs(yymax - yymin)) / 6.0; - fix_inversion(&inversion[0]); - f_radius = inversion[0]; - } - - if (invert < 2 || inversion[1] == AUTOINVERT) /* xcenter not already set */ - { - inversion[1] = (xxmin + xxmax) / 2.0; - fix_inversion(&inversion[1]); - f_xcenter = inversion[1]; - if (fabs(f_xcenter) < fabs(xxmax-xxmin) / 100) - inversion[1] = f_xcenter = 0.0; - } - - if (invert < 3 || inversion[2] == AUTOINVERT) /* ycenter not already set */ - { - inversion[2] = (yymin + yymax) / 2.0; - fix_inversion(&inversion[2]); - f_ycenter = inversion[2]; - if (fabs(f_ycenter) < fabs(yymax-yymin) / 100) - inversion[2] = f_ycenter = 0.0; - } - - invert = 3; /* so values will not be changed if we come back */ - } - - closenuff = ddelmin*pow(2.0,-(double)(abs(periodicitycheck))); - rqlim_save = rqlim; - rqlim2 = sqrt(rqlim); - if (integerfractal) /* for integer routines (lambda) */ - { - lparm.x = (long)(parm.x * fudge); /* real portion of Lambda */ - lparm.y = (long)(parm.y * fudge); /* imaginary portion of Lambda */ - lparm2.x = (long)(parm2.x * fudge); /* real portion of Lambda2 */ - lparm2.y = (long)(parm2.y * fudge); /* imaginary portion of Lambda2 */ - llimit = (long)(rqlim * fudge); /* stop if magnitude exceeds this */ - if (llimit <= 0) llimit = 0x7fffffffL; /* klooge for integer math */ - llimit2 = (long)(rqlim2 * fudge); /* stop if magnitude exceeds this */ - lclosenuff = (long)(closenuff * fudge); /* "close enough" value */ - l16triglim = 8L<<16; /* domain limit of fast trig functions */ - linitorbit.x = (long)(initorbit.x * fudge); - linitorbit.y = (long)(initorbit.y * fudge); - } - resuming = (calc_status == CALCSTAT_RESUMABLE); - if (!resuming) /* free resume_info memory if any is hanging around */ - { - end_resume(); - if (resave_flag) { - updatesavename(savename); /* do the pending increment */ - resave_flag = started_resaves = 0; - } - calctime = 0; - } - - if (curfractalspecific->calctype != StandardFractal - && curfractalspecific->calctype != calcmand - && curfractalspecific->calctype != calcmandfp - && curfractalspecific->calctype != lyapunov - && curfractalspecific->calctype != calcfroth) - { - calctype = curfractalspecific->calctype; /* per_image can override */ - symmetry = curfractalspecific->symmetry; /* calctype & symmetry */ - plot = putcolor; /* defaults when setsymmetry not called or does nothing */ - iystart = ixstart = yystart = xxstart = yybegin = xxbegin = 0; - iystop = yystop = ydots -1; - ixstop = xxstop = xdots -1; - calc_status = CALCSTAT_IN_PROGRESS; /* mark as in-progress */ - distest = 0; /* only standard escape time engine supports distest */ - /* per_image routine is run here */ - if (curfractalspecific->per_image()) - { /* not a stand-alone */ - /* next two lines in case periodicity changed */ - closenuff = ddelmin*pow(2.0,-(double)(abs(periodicitycheck))); - lclosenuff = (long)(closenuff * fudge); /* "close enough" value */ - setsymmetry(symmetry,0); - timer(0,calctype); /* non-standard fractal engine */ - } - if (check_key()) - { - if (calc_status == CALCSTAT_IN_PROGRESS) /* calctype didn't set this itself, */ - calc_status = CALCSTAT_NON_RESUMABLE; /* so mark it interrupted, non-resumable */ - } - else - calc_status = CALCSTAT_COMPLETED; /* no key, so assume it completed */ - } - else /* standard escape-time engine */ - { - if (stdcalcmode == '3') /* convoluted 'g' + '2' hybrid */ - { - int oldcalcmode; - oldcalcmode = stdcalcmode; - if (!resuming || three_pass) - { - stdcalcmode = 'g'; - three_pass = 1; - timer(0,(int(*)())perform_worklist); - if (calc_status == CALCSTAT_COMPLETED) - { - if (xdots >= 640) /* '2' is silly after 'g' for low rez */ - stdcalcmode = '2'; - else - stdcalcmode = '1'; - - timer(0,(int(*)())perform_worklist); - three_pass = 0; - } - } - else /* resuming '2' pass */ - { - if (xdots >= 640) - stdcalcmode = '2'; - else - stdcalcmode = '1'; - timer(0,(int(*)())perform_worklist); - } - stdcalcmode = (char)oldcalcmode; - } - else /* main case, much nicer! */ - { - three_pass = 0; - timer(0,(int(*)())perform_worklist); - } - } - calctime += timer_interval; - - if (LogTable && !Log_Calc) - { - free(LogTable); /* free if not using extraseg */ - LogTable = NULL; - } - if (typespecific_workarea) - { - free_workarea(); - } - - if (curfractalspecific->calctype == calcfroth) - froth_cleanup(); - if ((soundflag & SOUNDFLAG_ORBITMASK) > SOUNDFLAG_BEEP) /* close sound write file */ - close_snd(); - if (truecolor) - enddisk(); - return (calc_status == CALCSTAT_COMPLETED) ? 0 : -1; -} - -/* locate alternate math record */ -int find_alternate_math(int type, int math) -{ - int i,ret,curtype /* ,curmath=0 */; - /* unsigned umath; */ - ret = -1; - if (math==0) - return ret; - i= -1; -#if 0 /* for now at least, the only alternatemath is bignum and bigflt math */ - umath = math; - umath <<= 14; /* BF_MATH or DL_MATH */ - - /* this depends on last two bits of flags */ - if (fractalspecific[type].flags & umath) - { - while (((curtype=alternatemath[++i].type ) != type - || (curmath=alternatemath[i].math) != math) && curtype != -1); - if (curtype == type && curmath == math) - ret = i; - } -#else - while ((curtype=alternatemath[++i].type) != type && curtype != -1) - ; - if (curtype == type && alternatemath[i].math) - ret = i; -#endif - return ret; -} - - -/**************** general escape-time engine routines *********************/ - -static void perform_worklist() -{ - int (*sv_orbitcalc)(void) = NULL; /* function that calculates one orbit */ - int (*sv_per_pixel)(void) = NULL; /* once-per-pixel init */ - int (*sv_per_image)(void) = NULL; /* once-per-image setup */ - int i, alt; - - if ((alt=find_alternate_math(fractype,bf_math)) > -1) - { - sv_orbitcalc = curfractalspecific->orbitcalc; - sv_per_pixel = curfractalspecific->per_pixel; - sv_per_image = curfractalspecific->per_image; - curfractalspecific->orbitcalc = alternatemath[alt].orbitcalc; - curfractalspecific->per_pixel = alternatemath[alt].per_pixel; - curfractalspecific->per_image = alternatemath[alt].per_image; - } - else - bf_math = 0; - - if (potflag && pot16bit) - { - int tmpcalcmode = stdcalcmode; - - stdcalcmode = '1'; /* force 1 pass */ - if (resuming == 0) - if (pot_startdisk() < 0) - { - pot16bit = 0; /* startdisk failed or cancelled */ - stdcalcmode = (char)tmpcalcmode; /* maybe we can carry on??? */ - } - } - if (stdcalcmode == 'b' && (curfractalspecific->flags & NOTRACE)) - stdcalcmode = '1'; - if (stdcalcmode == 'g' && (curfractalspecific->flags & NOGUESS)) - stdcalcmode = '1'; - if (stdcalcmode == 'o' && (curfractalspecific->calctype != StandardFractal)) - stdcalcmode = '1'; - - /* default setup a new worklist */ - num_worklist = 1; - worklist[0].xxstart = worklist[0].xxbegin = 0; - worklist[0].yystart = worklist[0].yybegin = 0; - worklist[0].xxstop = xdots - 1; - worklist[0].yystop = ydots - 1; - worklist[0].pass = worklist[0].sym = 0; - if (resuming) /* restore worklist, if we can't the above will stay in place */ - { - int vsn; - vsn = start_resume(); - get_resume(sizeof(num_worklist),&num_worklist,sizeof(worklist),worklist,0); - end_resume(); - if (vsn < 2) - xxbegin = 0; - } - - if (distest) /* setup stuff for distance estimator */ - { - double ftemp,ftemp2,delxx,delyy2,delyy,delxx2,dxsize,dysize; - double aspect; - if (pseudox && pseudoy) - { - aspect = (double)pseudoy/(double)pseudox; - dxsize = pseudox-1; - dysize = pseudoy-1; - } - else - { - aspect = (double)ydots/(double)xdots; - dxsize = xdots-1; - dysize = ydots-1; - } - - delxx = (xxmax - xx3rd) / dxsize; /* calculate stepsizes */ - delyy = (yymax - yy3rd) / dysize; - delxx2 = (xx3rd - xxmin) / dysize; - delyy2 = (yy3rd - yymin) / dxsize; - - if (save_release < 1827) /* in case it's changed with */ - use_old_distest = 1; - else - use_old_distest = 0; - rqlim = rqlim_save; /* just in case changed to DEM_BAILOUT earlier */ - if (distest != 1 || colors == 2) /* not doing regular outside colors */ - if (rqlim < DEM_BAILOUT) /* so go straight for dem bailout */ - rqlim = DEM_BAILOUT; - if (curfractalspecific->tojulia != NOFRACTAL || use_old_distest - || fractype == FORMULA || fractype == FFORMULA) - dem_mandel = 1; /* must be mandel type, formula, or old PAR/GIF */ - else - dem_mandel = 0; - dem_delta = sqr(delxx) + sqr(delyy2); - if ((ftemp = sqr(delyy) + sqr(delxx2)) > dem_delta) - dem_delta = ftemp; - if (distestwidth == 0) - distestwidth = 1; - ftemp = distestwidth; - if (distestwidth > 0) - dem_delta *= sqr(ftemp)/10000; /* multiply by thickness desired */ - else - dem_delta *= 1/(sqr(ftemp)*10000); /* multiply by thickness desired */ - dem_width = ( sqrt( sqr(xxmax-xxmin) + sqr(xx3rd-xxmin) ) * aspect - + sqrt( sqr(yymax-yymin) + sqr(yy3rd-yymin) ) ) / distest; - ftemp = (rqlim < DEM_BAILOUT) ? DEM_BAILOUT : rqlim; - ftemp += 3; /* bailout plus just a bit */ - ftemp2 = log(ftemp); - if (use_old_distest) - dem_toobig = sqr(ftemp) * sqr(ftemp2) * 4 / dem_delta; - else - dem_toobig = fabs(ftemp) * fabs(ftemp2) * 2 / sqrt(dem_delta); - } - - while (num_worklist > 0) - { - /* per_image can override */ - calctype = curfractalspecific->calctype; - symmetry = curfractalspecific->symmetry; /* calctype & symmetry */ - plot = putcolor; /* defaults when setsymmetry not called or does nothing */ - - /* pull top entry off worklist */ - ixstart = xxstart = worklist[0].xxstart; - ixstop = xxstop = worklist[0].xxstop; - xxbegin = worklist[0].xxbegin; - iystart = yystart = worklist[0].yystart; - iystop = yystop = worklist[0].yystop; - yybegin = worklist[0].yybegin; - workpass = worklist[0].pass; - worksym = worklist[0].sym; - --num_worklist; - for (i=0; iper_image(); - if (showdot >= 0) - { - find_special_colors(); - switch (autoshowdot) - { - case 'd': - showdotcolor = g_color_dark%colors; - break; - case 'm': - showdotcolor = g_color_medium%colors; - break; - case 'b': - case 'a': - showdotcolor = g_color_bright%colors; - break; - default: - showdotcolor = showdot%colors; - break; - } - if (sizedot <= 0) - showdot_width = -1; - else - { - double dshowdot_width; - dshowdot_width = (double)sizedot*xdots/1024.0; - /* - Arbitrary sanity limit, however showdot_width will - overflow if dshowdot width gets near 256. - */ - if (dshowdot_width > 150.0) - showdot_width = 150; - else if (dshowdot_width > 0.0) - showdot_width = (int)dshowdot_width; - else - showdot_width = -1; - } -#ifdef SAVEDOTS_USES_MALLOC - while (showdot_width >= 0) - { - /* - We're using near memory, so get the amount down - to something reasonable. The polynomial used to - calculate savedotslen is exactly right for the - triangular-shaped shotdot cursor. The that cursor - is changed, this formula must match. - */ - while ((savedotslen=sqr(showdot_width)+5*showdot_width+4) > 1000) - showdot_width--; - if ((savedots = (BYTE *)malloc(savedotslen)) != NULL) - { - savedotslen /= 2; - fillbuff = savedots + savedotslen; - memset(fillbuff,showdotcolor,savedotslen); - break; - } - /* - There's even less free memory than we thought, so reduce - showdot_width still more - */ - showdot_width--; - } - if (savedots == NULL) - showdot_width = -1; -#else - while ((savedotslen=sqr(showdot_width)+5*showdot_width+4) > 2048) - showdot_width--; - savedots = (BYTE *)decoderline; - savedotslen /= 2; - fillbuff = savedots + savedotslen; - memset(fillbuff,showdotcolor,savedotslen); -#endif - calctypetmp = calctype; - calctype = calctypeshowdot; - } - - /* some common initialization for escape-time pixel level routines */ - closenuff = ddelmin*pow(2.0,-(double)(abs(periodicitycheck))); - lclosenuff = (long)(closenuff * fudge); /* "close enough" value */ - kbdcount=max_kbdcount; - - setsymmetry(symmetry,1); - - if (!(resuming)&&(labs(LogFlag) ==2 || (LogFlag && Log_Auto_Calc))) - { /* calculate round screen edges to work out best start for logmap */ - LogFlag = ( autologmap() * (LogFlag / labs(LogFlag))); - SetupLogTable(); - } - - /* call the appropriate escape-time engine */ - switch (stdcalcmode) - { - case 's': - if (debugflag==3444) - soi_ldbl(); - else - soi(); - break; - case 't': - tesseral(); - break; - case 'b': - bound_trace_main(); - break; - case 'g': - solidguess(); - break; - case 'd': - diffusion_scan(); - break; - case 'o': - sticky_orbits(); - break; - default: - OneOrTwoPass(); - } -#ifdef SAVEDOTS_USES_MALLOC - if (savedots != NULL) - { - free(savedots); - savedots = NULL; - fillbuff = NULL; - } -#endif - if (check_key()) /* interrupted? */ - break; - } - - if (num_worklist > 0) - { /* interrupted, resumable */ - alloc_resume(sizeof(worklist)+20,2); - put_resume(sizeof(num_worklist),&num_worklist,sizeof(worklist),worklist,0); - } - else - calc_status = CALCSTAT_COMPLETED; /* completed */ - if (sv_orbitcalc != NULL) - { - curfractalspecific->orbitcalc = sv_orbitcalc; - curfractalspecific->per_pixel = sv_per_pixel; - curfractalspecific->per_image = sv_per_image; - } -} - -static int diffusion_scan(void) -{ - double log2; - - log2 = (double) log (2.0); - - got_status = 5; - - /* note: the max size of 2048x2048 gives us a 22 bit counter that will */ - /* fit any 32 bit architecture, the maxinum limit for this case would */ - /* be 65536x65536 (HB) */ - - bits = (unsigned) (min ( log (iystop-iystart+1), log(ixstop-ixstart+1) )/log2 ); - bits <<= 1; /* double for two axes */ - dif_limit = 1l << bits; - - if (diffusion_engine() == -1) - { - add_worklist(xxstart,xxstop,xxstart,yystart,yystop, - (int)(dif_counter >> 16), /* high, */ - (int)(dif_counter & 0xffff), /* low order words */ - worksym); - return -1; - } - - return 0; -} - -/* little macro that plots a filled square of color c, size s with - top left cornet at (x,y) with optimization from sym_fill_line */ -#define plot_block(x,y,s,c) \ - memset(dstack,(c),(s)); \ - for (ty=(y); ty<(y)+(s); ty++) \ - sym_fill_line(ty, (x), (x)+(s)-1, dstack) - -/* macro that does the same as above, but checks the limits in x and y */ -#define plot_block_lim(x,y,s,c) \ - memset(dstack,(c),(s)); \ - for (ty=(y); ty>=8; \ - x <<=4; x+=dif_la[tC&0xFF]; y <<=4; y+=dif_lb[tC&0xFF]; tC>>=8; \ - x <<=4; x+=dif_la[tC&0xFF]; y <<=4; y+=dif_lb[tC&0xFF]; tC>>=8; \ - x >>= dif_offset; y >>= dif_offset -/* end of inlined function */ - -/* REMOVED: counter byte 3 */ \ -/* (x) <<=4; (x)+=dif_la[tC&0(x)FF]; (y) <<=4; (y)+=dif_lb[tC&0(x)FF]; tC>>=8; - --> eliminated this and made (*) because fractint user coordinates up to - 2048(x)2048 what means a counter of 24 bits or 3 bytes */ - -/* Calculate the point */ -#define calculate \ - reset_periodicity = 1; \ - if ((*calctype)() == -1) \ - return -1; \ - reset_periodicity = 0 - -static int diffusion_engine (void) { - - double log2 = (double) log (2.0); - - int i,j; - - int nx,ny; /* number of tyles to build in x and y dirs */ - /* made this to complete the area that is not */ - /* a square with sides like 2 ** n */ - int rem_x,rem_y; /* what is left on the last tile to draw */ - - int ty; /* temp for y */ - - long unsigned tC; /* temp for dif_counter */ - - int dif_offset; /* offset for adjusting looked-up values */ - - int sqsz; /* size of the block being filled */ - - int colo, rowo; /* original col and row */ - - int s = 1 << (bits/2); /* size of the square */ - - nx = (int) floor( (ixstop-ixstart+1)/s ); - ny = (int) floor( (iystop-iystart+1)/s ); - - rem_x = (ixstop-ixstart+1) - nx * s; - rem_y = (iystop-iystart+1) - ny * s; - - if (yybegin == iystart && workpass == 0) { /* if restarting on pan: */ - dif_counter =0l; - } else { - /* yybegin and passes contain data for resuming the type: */ - dif_counter = (((long) ((unsigned)yybegin))<<16) | ((unsigned)workpass); - } - - dif_offset = 12-(bits/2); /* offset to adjust coordinates */ - /* (*) for 4 bytes use 16 for 3 use 12 etc. */ - - /*************************************/ - /* only the points (dithering only) :*/ - if ( fillcolor==0 ){ - while (dif_counter < (dif_limit>>1)) { - count_to_int(dif_counter, colo, rowo); - - i=0; - col = ixstart + colo; /* get the right tiles */ - do { - j=0; - row = iystart + rowo ; - do { - calculate; - (*plot)(col,row,color); - j++; - row += s; /* next tile */ - } while (j < ny); - /* in the last y tile we may not need to plot the point - */ - if (rowo < rem_y) { - calculate; - (*plot)(col,row,color); - } - i++; - col += s; - } while (i < nx); - /* in the last x tiles we may not need to plot the point */ if - (colo < rem_x) { - row = iystart + rowo; - j=0; - do { - calculate; - (*plot)(col,row,color); - j++; - row += s; /* next tile */ - } while (j < ny); - if (rowo < rem_y) { - calculate; - (*plot)(col,row,color); - } - } - dif_counter++; - } - } else { - /*********************************/ - /* with progressive filling : */ - while (dif_counter < (dif_limit>>1)) - { - sqsz=1<<( (int)(bits-(int)( log(dif_counter+0.5)/log2 )-1)/2 ); - - count_to_int(dif_counter, colo, rowo); - - i=0; - do { - j=0; - do { - col = ixstart + colo + i * s; /* get the right tiles */ - row = iystart + rowo + j * s; - - calculate; - plot_block(col,row,sqsz,color); - j++; - } while (j < ny); - /* in the last tile we may not need to plot the point */ - if (rowo < rem_y) { - row = iystart + rowo + ny * s; - - calculate; - plot_block_lim(col,row,sqsz,color); - } - i++; - } while (i < nx); - /* in the last tile we may not need to plot the point */ - if (colo < rem_x) { - col = ixstart + colo + nx * s; - j=0; - do { - row = iystart + rowo + j * s; /* get the right tiles */ - - calculate; - plot_block_lim(col,row,sqsz,color); - j++; - } while (j < ny); - if (rowo < rem_y) { - row = iystart + rowo + ny * s; - - calculate; - plot_block_lim(col,row,sqsz,color); - } - } - - dif_counter++; - } - } - /* from half dif_limit on we only plot 1x1 points :-) */ - while (dif_counter < dif_limit) - { - count_to_int(dif_counter, colo, rowo); - - i=0; - do { - j=0; - do { - col = ixstart + colo + i * s; /* get the right tiles */ - row = iystart + rowo + j * s; - - calculate; - (*plot)(col,row,color); - j++; - } while (j < ny); - /* in the last tile we may not need to plot the point */ - if (rowo < rem_y) { - row = iystart + rowo + ny * s; - - calculate; - (*plot)(col,row,color); - } - i++; - } while (i < nx); - /* in the last tile we may nnt need to plot the point */ - if (colo < rem_x) { - col = ixstart + colo + nx * s; - j=0; - do { - row = iystart + rowo + j * s; /* get the right tiles */ - - calculate; - (*plot)(col,row,color); - j++; - } while (j < ny); - if (rowo < rem_y) { - row = iystart + rowo + ny * s; - - calculate; - (*plot)(col,row,color); - } - } - dif_counter++; - } - return 0; -} - -/* OLD function (less eficient than the lookup code above: -static void count_to_int (long unsigned C, int *r, int *l) { - - int i; - - *r = *l = 0; - - for (i = bits; i>0; i -= 2){ - *r <<=1; *r += C % 2; C >>= 1; - *l <<=1; *l += C % 2; C >>= 1; - } - *l = (*l+*r)%(1<<(bits/2)); * a+b mod 2^k * - -} -*/ - -char drawmode = 'r'; - -static int sticky_orbits(void) -{ - got_status = 6; /* for screen */ - totpasses = 1; - - if (plotorbits2dsetup() == -1) { - stdcalcmode = 'g'; - return -1; - } - - switch (drawmode) - { - case 'r': - default: - /* draw a rectangle */ - row = yybegin; - col = xxbegin; - - while (row <= iystop) - { - currow = row; - while (col <= ixstop) - { - if (plotorbits2dfloat() == -1) - { - add_worklist(xxstart,xxstop,col,yystart,yystop,row,0,worksym); - return -1; /* interrupted */ - } - ++col; - } - col = ixstart; - ++row; - } - break; - case 'l': - { - int dX, dY; /* vector components */ - int final, /* final row or column number */ - G, /* used to test for new row or column */ - inc1, /* G increment when row or column doesn't change */ - inc2; /* G increment when row or column changes */ - char pos_slope; - - dX = ixstop - ixstart; /* find vector components */ - dY = iystop - iystart; - pos_slope = (char)(dX > 0); /* is slope positive? */ - if (dY < 0) - pos_slope = (char)!pos_slope; - if (abs (dX) > abs (dY)) /* shallow line case */ - { - if (dX > 0) /* determine start point and last column */ - { - col = xxbegin; - row = yybegin; - final = ixstop; - } - else - { - col = ixstop; - row = iystop; - final = xxbegin; - } - inc1 = 2 * abs (dY); /* determine increments and initial G */ - G = inc1 - abs (dX); - inc2 = 2 * (abs (dY) - abs (dX)); - if (pos_slope) - while (col <= final) /* step through columns checking for new row */ - { - if (plotorbits2dfloat() == -1) - { - add_worklist(xxstart,xxstop,col,yystart,yystop,row,0,worksym); - return -1; /* interrupted */ - } - col++; - if (G >= 0) /* it's time to change rows */ - { - row++; /* positive slope so increment through the rows */ - G += inc2; - } - else /* stay at the same row */ - G += inc1; - } - else - while (col <= final) /* step through columns checking for new row */ - { - if (plotorbits2dfloat() == -1) - { - add_worklist(xxstart,xxstop,col,yystart,yystop,row,0,worksym); - return -1; /* interrupted */ - } - col++; - if (G > 0) /* it's time to change rows */ - { - row--; /* negative slope so decrement through the rows */ - G += inc2; - } - else /* stay at the same row */ - G += inc1; - } - } /* if |dX| > |dY| */ - else /* steep line case */ - { - if (dY > 0) /* determine start point and last row */ - { - col = xxbegin; - row = yybegin; - final = iystop; - } - else - { - col = ixstop; - row = iystop; - final = yybegin; - } - inc1 = 2 * abs (dX); /* determine increments and initial G */ - G = inc1 - abs (dY); - inc2 = 2 * (abs (dX) - abs (dY)); - if (pos_slope) - while (row <= final) /* step through rows checking for new column */ - { - if (plotorbits2dfloat() == -1) - { - add_worklist(xxstart,xxstop,col,yystart,yystop,row,0,worksym); - return -1; /* interrupted */ - } - row++; - if (G >= 0) /* it's time to change columns */ - { - col++; /* positive slope so increment through the columns */ - G += inc2; - } - else /* stay at the same column */ - G += inc1; - } - else - while (row <= final) /* step through rows checking for new column */ - { - if (plotorbits2dfloat() == -1) - { - add_worklist(xxstart,xxstop,col,yystart,yystop,row,0,worksym); - return -1; /* interrupted */ - } - row++; - if (G > 0) /* it's time to change columns */ - { - col--; /* negative slope so decrement through the columns */ - G += inc2; - } - else /* stay at the same column */ - G += inc1; - } - } - } /* end case 'l' */ - break; - case 'f': /* this code does not yet work??? */ - { - double Xctr,Yctr; - LDBL Magnification; /* LDBL not really needed here, but used to match function parameters */ - double Xmagfactor,Rotation,Skew; - int angle; - double factor = PI / 180.0; - double theta; - double xfactor = xdots / 2.0; - double yfactor = ydots / 2.0; - - angle = xxbegin; /* save angle in x parameter */ - - cvtcentermag(&Xctr, &Yctr, &Magnification, &Xmagfactor, &Rotation, &Skew); - if (Rotation <= 0) - Rotation += 360; - - while (angle < Rotation) - { - theta = (double)angle * factor; - col = (int)(xfactor + (Xctr + Xmagfactor * cos(theta))); - row = (int)(yfactor + (Yctr + Xmagfactor * sin(theta))); - if (plotorbits2dfloat() == -1) - { - add_worklist(angle,0,0,0,0,0,0,worksym); - return -1; /* interrupted */ - } - angle++; - } - - - } /* end case 'f' */ - break; - } /* end switch */ - - return 0; -} - -static int OneOrTwoPass(void) -{ - int i; - - totpasses = 1; - if (stdcalcmode == '2') totpasses = 2; - if (stdcalcmode == '2' && workpass == 0) /* do 1st pass of two */ - { - if (StandardCalc(1) == -1) - { - add_worklist(xxstart,xxstop,col,yystart,yystop,row,0,worksym); - return -1; - } - if (num_worklist > 0) /* worklist not empty, defer 2nd pass */ - { - add_worklist(xxstart,xxstop,xxstart,yystart,yystop,yystart,1,worksym); - return 0; - } - workpass = 1; - xxbegin = xxstart; - yybegin = yystart; - } - /* second or only pass */ - if (StandardCalc(2) == -1) - { - i = yystop; - if (iystop != yystop) /* must be due to symmetry */ - i -= row - iystart; - add_worklist(xxstart,xxstop,col,row,i,row,workpass,worksym); - return -1; - } - - return 0; -} - -static int _fastcall StandardCalc(int passnum) -{ - got_status = 0; - curpass = passnum; - row = yybegin; - col = xxbegin; - - while (row <= iystop) - { - currow = row; - reset_periodicity = 1; - while (col <= ixstop) - { - /* on 2nd pass of two, skip even pts */ - if (quick_calc && !resuming) - if ((color = getcolor(col,row)) != inside) { - ++col; - continue; - } - if (passnum == 1 || stdcalcmode == '1' || (row&1) != 0 || (col&1) != 0) - { - if ((*calctype)() == -1) /* StandardFractal(), calcmand() or calcmandfp() */ - return -1; /* interrupted */ - resuming = 0; /* reset so quick_calc works */ - reset_periodicity = 0; - if (passnum == 1) /* first pass, copy pixel and bump col */ - { - if ((row&1) == 0 && row < iystop) - { - (*plot)(col,row+1,color); - if ((col&1) == 0 && col < ixstop) - (*plot)(col+1,row+1,color); - } - if ((col&1) == 0 && col < ixstop) - (*plot)(++col,row,color); - } - } - ++col; - } - col = ixstart; - if (passnum == 1 && (row&1) == 0) - ++row; - ++row; - } - return 0; -} - - -int calcmand(void) /* fast per pixel 1/2/b/g, called with row & col set */ -{ - /* setup values from array to avoid using es reg in calcmand.asm */ - linitx = lxpixel(); - linity = lypixel(); - if (calcmandasm() >= 0) - { - if ((LogTable || Log_Calc) /* map color, but not if maxit & adjusted for inside,etc */ - && (realcoloriter < maxit || (inside < 0 && coloriter == maxit))) - coloriter = logtablecalc(coloriter); - color = abs((int)coloriter); - if (coloriter >= colors) { /* don't use color 0 unless from inside/outside */ - if (save_release <= 1950) { - if (colors < 16) - color &= g_and_color; - else - color = ((color - 1) % g_and_color) + 1; /* skip color zero */ - } - else { - if (colors < 16) - color = (int)(coloriter & g_and_color); - else - color = (int)(((coloriter - 1) % g_and_color) + 1); - } - } - if (debugflag != 470) - if (color <= 0 && stdcalcmode == 'b' ) /* fix BTM bug */ - color = 1; - (*plot) (col, row, color); - } - else - color = (int)coloriter; - return color; -} - -long (*calcmandfpasm)(void); - -/************************************************************************/ -/* added by Wes Loewer - sort of a floating point version of calcmand() */ -/* can also handle invert, any rqlim, potflag, zmag, epsilon cross, */ -/* and all the current outside options -Wes Loewer 11/03/91 */ -/************************************************************************/ -int calcmandfp(void) -{ - if (invert) - invertz2(&init); - else - { - init.x = dxpixel(); - init.y = dypixel(); - } - if (calcmandfpasm() >= 0) - { - if (potflag) - coloriter = potential(magnitude, realcoloriter); - if ((LogTable || Log_Calc) /* map color, but not if maxit & adjusted for inside,etc */ - && (realcoloriter < maxit || (inside < 0 && coloriter == maxit))) - coloriter = logtablecalc(coloriter); - color = abs((int)coloriter); - if (coloriter >= colors) { /* don't use color 0 unless from inside/outside */ - if (save_release <= 1950) { - if (colors < 16) - color &= g_and_color; - else - color = ((color - 1) % g_and_color) + 1; /* skip color zero */ - } - else { - if (colors < 16) - color = (int)(coloriter & g_and_color); - else - color = (int)(((coloriter - 1) % g_and_color) + 1); - } - } - if (debugflag != 470) - if (color == 0 && stdcalcmode == 'b' ) /* fix BTM bug */ - color = 1; - (*plot) (col, row, color); - } - else - color = (int)coloriter; - return color; -} -#define STARTRAILMAX FLT_MAX /* just a convenient large number */ -#define green 2 -#define yellow 6 -#if 0 -#define NUMSAVED 40 /* define this to save periodicity analysis to file */ -#endif -#if 0 -#define MINSAVEDAND 3 /* if not defined, old method used */ -#endif -int StandardFractal(void) /* per pixel 1/2/b/g, called with row & col set */ -{ -#ifdef NUMSAVED - _CMPLX savedz[NUMSAVED]; - long caught[NUMSAVED]; - long changed[NUMSAVED]; - int zctr = 0; -#endif - long savemaxit; - double tantable[16]; - int hooper = 0; - long lcloseprox; - double memvalue = 0.0; - double min_orbit = 100000.0; /* orbit value closest to origin */ - long min_index = 0; /* iteration of min_orbit */ - long cyclelen = -1; - long savedcoloriter = 0; - int caught_a_cycle; - long savedand; - int savedincr; /* for periodicity checking */ - _LCMPLX lsaved; - int i, attracted; - _LCMPLX lat; - _CMPLX at; - _CMPLX deriv; - long dem_color = -1; - _CMPLX dem_new; - int check_freq; - double totaldist = 0.0; - _CMPLX lastz; - - lcloseprox = (long)(closeprox*fudge); - savemaxit = maxit; -#ifdef NUMSAVED - for (i=0; i 1824) maxit = 16; - } - if (periodicitycheck == 0 || inside == ZMAG || inside == STARTRAIL) - oldcoloriter = 2147483647L; /* don't check periodicity at all */ - else if (inside == PERIOD) /* for display-periodicity */ - oldcoloriter = (maxit/5)*4; /* don't check until nearly done */ - else if (reset_periodicity) - oldcoloriter = 255; /* don't check periodicity 1st 250 iterations */ - - /* Jonathan - how about this idea ? skips first saved value which never works */ -#ifdef MINSAVEDAND - if (oldcoloriter < MINSAVEDAND) - oldcoloriter = MINSAVEDAND; -#else - if (oldcoloriter < firstsavedand) /* I like it! */ - oldcoloriter = firstsavedand; -#endif - /* really fractal specific, but we'll leave it here */ - if (!integerfractal) - { - if (useinitorbit == 1) - saved = initorbit; - else { - saved.x = 0; - saved.y = 0; - } -#ifdef NUMSAVED - savedz[zctr++] = saved; -#endif - if (bf_math) - { - if (decimals > 200) - kbdcount = -1; - if (bf_math == BIGNUM) - { - clear_bn(bnsaved.x); - clear_bn(bnsaved.y); - } - else if (bf_math == BIGFLT) - { - clear_bf(bfsaved.x); - clear_bf(bfsaved.y); - } - } - init.y = dypixel(); - if (distest) - { - if (use_old_distest) { - rqlim = rqlim_save; - if (distest != 1 || colors == 2) /* not doing regular outside colors */ - if (rqlim < DEM_BAILOUT) /* so go straight for dem bailout */ - rqlim = DEM_BAILOUT; - dem_color = -1; - } - deriv.x = 1; - deriv.y = 0; - magnitude = 0; - } - } - else - { - if (useinitorbit == 1) - lsaved = linitorbit; - else { - lsaved.x = 0; - lsaved.y = 0; - } - linit.y = lypixel(); - } - orbit_ptr = 0; - coloriter = 0; - if (fractype==JULIAFP || fractype==JULIA) - coloriter = -1; - caught_a_cycle = 0; - if (inside == PERIOD) { - savedand = 16; /* begin checking every 16th cycle */ - } else { - /* Jonathan - don't understand such a low savedand -- how about this? */ -#ifdef MINSAVEDAND - savedand = MINSAVEDAND; -#else - savedand = firstsavedand; /* begin checking every other cycle */ -#endif - } - savedincr = 1; /* start checking the very first time */ - - if (inside <= BOF60 && inside >= BOF61) - { - magnitude = lmagnitud = 0; - min_orbit = 100000.0; - } - overflow = 0; /* reset integer math overflow flag */ - - curfractalspecific->per_pixel(); /* initialize the calculations */ - - attracted = FALSE; - - if (outside == TDIS) { - if (integerfractal) - { - old.x = ((double)lold.x) / fudge; - old.y = ((double)lold.y) / fudge; - } - else if (bf_math == BIGNUM) - old = cmplxbntofloat(&bnold); - else if (bf_math==BIGFLT) - old = cmplxbftofloat(&bfold); - lastz.x = old.x; - lastz.y = old.y; - } - - if (((soundflag & SOUNDFLAG_ORBITMASK) > SOUNDFLAG_X || showdot >= 0) && orbit_delay > 0) - check_freq = 16; - else - check_freq = 2048; - - if (show_orbit) - snd_time_write(); - while (++coloriter < maxit) - { - /* calculation of one orbit goes here */ - /* input in "old" -- output in "new" */ - if (coloriter % check_freq == 0) { - if (check_key()) - return -1; - } - - if (distest) - { - double ftemp; - /* Distance estimator for points near Mandelbrot set */ - /* Original code by Phil Wilson, hacked around by PB */ - /* Algorithms from Peitgen & Saupe, Science of Fractal Images, p.198 */ - if (dem_mandel) - ftemp = 2 * (old.x * deriv.x - old.y * deriv.y) + 1; - else - ftemp = 2 * (old.x * deriv.x - old.y * deriv.y); - deriv.y = 2 * (old.y * deriv.x + old.x * deriv.y); - deriv.x = ftemp; - if (use_old_distest) { - if (sqr(deriv.x)+sqr(deriv.y) > dem_toobig) - break; - } - else if (save_release > 1950) - if (max(fabs(deriv.x),fabs(deriv.y)) > dem_toobig) - break; - /* if above exit taken, the later test vs dem_delta will place this - point on the boundary, because mag(old)orbitcalc() || (overflow && save_release > 1826)) - { - if (use_old_distest) { - if (dem_color < 0) { - dem_color = coloriter; - dem_new = g_new; - } - if (rqlim >= DEM_BAILOUT - || magnitude >= (rqlim = DEM_BAILOUT) - || magnitude == 0) - break; - } - else - break; - } - old = g_new; - } - - /* the usual case */ - else if ((curfractalspecific->orbitcalc() && inside != STARTRAIL) - || overflow) - break; - if (show_orbit) { - if (!integerfractal) - { - if (bf_math == BIGNUM) - g_new = cmplxbntofloat(&bnnew); - else if (bf_math==BIGFLT) - g_new = cmplxbftofloat(&bfnew); - plot_orbit(g_new.x, g_new.y, -1); - } - else - iplot_orbit(lnew.x, lnew.y, -1); - } - if ( inside < -1) - { - if (bf_math == BIGNUM) - g_new = cmplxbntofloat(&bnnew); - else if (bf_math == BIGFLT) - g_new = cmplxbftofloat(&bfnew); - if (inside == STARTRAIL) - { - if (0 < coloriter && coloriter < 16) - { - if (integerfractal) - { - g_new.x = lnew.x; - g_new.x /= fudge; - g_new.y = lnew.y; - g_new.y /= fudge; - } - - if (save_release > 1824) { - if (g_new.x > STARTRAILMAX) - g_new.x = STARTRAILMAX; - if (g_new.x < -STARTRAILMAX) - g_new.x = -STARTRAILMAX; - if (g_new.y > STARTRAILMAX) - g_new.y = STARTRAILMAX; - if (g_new.y < -STARTRAILMAX) - g_new.y = -STARTRAILMAX; - tempsqrx = g_new.x * g_new.x; - tempsqry = g_new.y * g_new.y; - magnitude = tempsqrx + tempsqry; - old = g_new; - } - { - int tmpcolor; - tmpcolor = (int)(((coloriter - 1) % g_and_color) + 1); - tantable[tmpcolor-1] = g_new.y/(g_new.x+.000001); - } - } - } - else if (inside == EPSCROSS) - { - hooper = 0; - if (integerfractal) - { - if (labs(lnew.x) < labs(lcloseprox)) - { - hooper = (lcloseprox>0? 1 : -1); /* close to y axis */ - goto plot_inside; - } - else if (labs(lnew.y) < labs(lcloseprox)) - { - hooper = (lcloseprox>0 ? 2: -2); /* close to x axis */ - goto plot_inside; - } - } - else - { - if (fabs(g_new.x) < fabs(closeprox)) - { - hooper = (closeprox>0? 1 : -1); /* close to y axis */ - goto plot_inside; - } - else if (fabs(g_new.y) < fabs(closeprox)) - { - hooper = (closeprox>0? 2 : -2); /* close to x axis */ - goto plot_inside; - } - } - } - else if (inside == FMODI) - { - double mag; - if (integerfractal) - { - g_new.x = ((double)lnew.x) / fudge; - g_new.y = ((double)lnew.y) / fudge; - } - mag = fmodtest(); - if (mag < closeprox) - memvalue = mag; - } - else if (inside <= BOF60 && inside >= BOF61) - { - if (integerfractal) - { - if (lmagnitud == 0 || no_mag_calc == 0) - lmagnitud = lsqr(lnew.x) + lsqr(lnew.y); - magnitude = lmagnitud; - magnitude = magnitude / fudge; - } - else - if (magnitude == 0.0 || no_mag_calc == 0) - magnitude = sqr(g_new.x) + sqr(g_new.y); - if (magnitude < min_orbit) - { - min_orbit = magnitude; - min_index = coloriter + 1; - } - } - } - - if (outside == TDIS || outside == FMOD) - { - if (bf_math == BIGNUM) - g_new = cmplxbntofloat(&bnnew); - else if (bf_math == BIGFLT) - g_new = cmplxbftofloat(&bfnew); - if (outside == TDIS) - { - if (integerfractal) - { - g_new.x = ((double)lnew.x) / fudge; - g_new.y = ((double)lnew.y) / fudge; - } - totaldist += sqrt(sqr(lastz.x-g_new.x)+sqr(lastz.y-g_new.y)); - lastz.x = g_new.x; - lastz.y = g_new.y; - } - else if (outside == FMOD) - { - double mag; - if (integerfractal) - { - g_new.x = ((double)lnew.x) / fudge; - g_new.y = ((double)lnew.y) / fudge; - } - mag = fmodtest(); - if (mag < closeprox) - memvalue = mag; - } - } - - if (attractors > 0) /* finite attractor in the list */ - { /* NOTE: Integer code is UNTESTED */ - if (integerfractal) - { - for (i = 0; i < attractors; i++) - { - lat.x = lnew.x - lattr[i].x; - lat.x = lsqr(lat.x); - if (lat.x < l_at_rad) - { - lat.y = lnew.y - lattr[i].y; - lat.y = lsqr(lat.y); - if (lat.y < l_at_rad) - { - if ((lat.x + lat.y) < l_at_rad) - { - attracted = TRUE; - if (finattract<0) coloriter = (coloriter%attrperiod[i])+1; - break; - } - } - } - } - } - else - { - for (i = 0; i < attractors; i++) - { - at.x = g_new.x - attr[i].x; - at.x = sqr(at.x); - if (at.x < f_at_rad) - { - at.y = g_new.y - attr[i].y; - at.y = sqr(at.y); - if ( at.y < f_at_rad) - { - if ((at.x + at.y) < f_at_rad) - { - attracted = TRUE; - if (finattract<0) coloriter = (coloriter%attrperiod[i])+1; - break; - } - } - } - } - } - if (attracted) - break; /* AHA! Eaten by an attractor */ - } - - if (coloriter > oldcoloriter) /* check periodicity */ - { - if ((coloriter & savedand) == 0) /* time to save a new value */ - { - savedcoloriter = coloriter; - if (integerfractal) - lsaved = lnew;/* integer fractals */ - else if (bf_math == BIGNUM) - { - copy_bn(bnsaved.x,bnnew.x); - copy_bn(bnsaved.y,bnnew.y); - } - else if (bf_math == BIGFLT) - { - copy_bf(bfsaved.x,bfnew.x); - copy_bf(bfsaved.y,bfnew.y); - } - else - { - saved = g_new; /* floating pt fractals */ -#ifdef NUMSAVED - if (zctr < NUMSAVED) - { - changed[zctr] = coloriter; - savedz[zctr++] = saved; - } -#endif - } - if (--savedincr == 0) /* time to lengthen the periodicity? */ - { - savedand = (savedand << 1) + 1; /* longer periodicity */ - savedincr = nextsavedincr;/* restart counter */ - } - } - else /* check against an old save */ - { - if (integerfractal) /* floating-pt periodicity chk */ - { - if (labs(lsaved.x - lnew.x) < lclosenuff) - if (labs(lsaved.y - lnew.y) < lclosenuff) - caught_a_cycle = 1; - } - else if (bf_math == BIGNUM) - { - if (cmp_bn(abs_a_bn(sub_bn(bntmp,bnsaved.x,bnnew.x)), bnclosenuff) < 0) - if (cmp_bn(abs_a_bn(sub_bn(bntmp,bnsaved.y,bnnew.y)), bnclosenuff) < 0) - caught_a_cycle = 1; - } - else if (bf_math == BIGFLT) - { - if (cmp_bf(abs_a_bf(sub_bf(bftmp,bfsaved.x,bfnew.x)), bfclosenuff) < 0) - if (cmp_bf(abs_a_bf(sub_bf(bftmp,bfsaved.y,bfnew.y)), bfclosenuff) < 0) - caught_a_cycle = 1; - } - else - { - if (fabs(saved.x - g_new.x) < closenuff) - if (fabs(saved.y - g_new.y) < closenuff) - caught_a_cycle = 1; -#ifdef NUMSAVED - int i; - for (i=0; i<=zctr; i++) - { - if (caught[i] == 0) - { - if (fabs(savedz[i].x - g_new.x) < closenuff) - if (fabs(savedz[i].y - g_new.y) < closenuff) - caught[i] = coloriter; - } - } -#endif - } - if (caught_a_cycle) - { -#ifdef NUMSAVED - char msg[MSGLEN]; - static FILE *fp = NULL; - static char c; - if (fp==NULL) - fp = dir_fopen(workdir,"cycles.txt","w"); -#endif - cyclelen = coloriter-savedcoloriter; -#ifdef NUMSAVED - fprintf(fp,"row %3d col %3d len %6ld iter %6ld savedand %6ld\n", - row,col,cyclelen,coloriter,savedand); - if (zctr > 1 && zctr < NUMSAVED) - { - int i; - for (i=0; i= maxit) - oldcoloriter = 0; /* check periodicity immediately next time */ - else - { - oldcoloriter = coloriter + 10; /* check when past this + 10 next time */ - if (coloriter == 0) - coloriter = 1; /* needed to make same as calcmand */ - } - - if (potflag) - { - if (integerfractal) /* adjust integer fractals */ - { - g_new.x = ((double)lnew.x) / fudge; - g_new.y = ((double)lnew.y) / fudge; - } - else if (bf_math==BIGNUM) - { - g_new.x = (double)bntofloat(bnnew.x); - g_new.y = (double)bntofloat(bnnew.y); - } - else if (bf_math==BIGFLT) - { - g_new.x = (double)bftofloat(bfnew.x); - g_new.y = (double)bftofloat(bfnew.y); - } - magnitude = sqr(g_new.x) + sqr(g_new.y); - coloriter = potential(magnitude, coloriter); - if (LogTable || Log_Calc) - coloriter = logtablecalc(coloriter); - goto plot_pixel; /* skip any other adjustments */ - } - - if (coloriter >= maxit) /* an "inside" point */ - goto plot_inside; /* distest, decomp, biomorph don't apply */ - - - if (outside < -1) /* these options by Richard Hughes modified by TW */ - { - if (integerfractal) - { - g_new.x = ((double)lnew.x) / fudge; - g_new.y = ((double)lnew.y) / fudge; - } - else if (bf_math==1) - { - g_new.x = (double)bntofloat(bnnew.x); - g_new.y = (double)bntofloat(bnnew.y); - } - /* Add 7 to overcome negative values on the MANDEL */ - if (outside == REAL) /* "real" */ - coloriter += (long)g_new.x + 7; - else if (outside == IMAG) /* "imag" */ - coloriter += (long)g_new.y + 7; - else if (outside == MULT && g_new.y) /* "mult" */ - coloriter = (long)((double)coloriter * (g_new.x/g_new.y)); - else if (outside == SUM) /* "sum" */ - coloriter += (long)(g_new.x + g_new.y); - else if (outside == ATAN) /* "atan" */ - coloriter = (long)fabs(atan2(g_new.y,g_new.x)*atan_colors/PI); - else if (outside == FMOD) - coloriter = (long)(memvalue * colors / closeprox); - else if (outside == TDIS) { - coloriter = (long)(totaldist); -} - - - /* eliminate negative colors & wrap arounds */ - if ((coloriter <= 0 || coloriter > maxit) && outside!=FMOD) { - if (save_release < 1961) - coloriter = 0; - else - coloriter = 1; - } - } - - if (distest) - { - double dist,temp; - dist = sqr(g_new.x) + sqr(g_new.y); - if (dist == 0 || overflow) - dist = 0; - else { - temp = log(dist); - dist = dist * sqr(temp) / ( sqr(deriv.x) + sqr(deriv.y) ); - } - if (dist < dem_delta) /* point is on the edge */ - { - if (distest > 0) - goto plot_inside; /* show it as an inside point */ - coloriter = 0 - distest; /* show boundary as specified color */ - goto plot_pixel; /* no further adjustments apply */ - } - if (colors == 2) - { - coloriter = !inside; /* the only useful distest 2 color use */ - goto plot_pixel; /* no further adjustments apply */ - } - if (distest > 1) /* pick color based on distance */ - { - if (old_demm_colors) /* this one is needed for old color scheme */ - coloriter = (long)sqrt(sqrt(dist) / dem_width + 1); - else if (use_old_distest) - coloriter = (long)sqrt(dist / dem_width + 1); - else - coloriter = (long)(dist / dem_width + 1); - coloriter &= LONG_MAX; /* oops - color can be negative */ - goto plot_pixel; /* no further adjustments apply */ - } - if (use_old_distest) { - coloriter = dem_color; - g_new = dem_new; - } - /* use pixel's "regular" color */ - } - - if (decomp[0] > 0) - decomposition(); - else if (biomorph != -1) - { - if (integerfractal) - { - if (labs(lnew.x) < llimit2 || labs(lnew.y) < llimit2) - coloriter = biomorph; - } - else - if (fabs(g_new.x) < rqlim2 || fabs(g_new.y) < rqlim2) - coloriter = biomorph; - } - - if (outside >= 0 && attracted == FALSE) /* merge escape-time stripes */ - coloriter = outside; - else if (LogTable || Log_Calc) - coloriter = logtablecalc(coloriter); - goto plot_pixel; - - plot_inside: /* we're "inside" */ - if (periodicitycheck < 0 && caught_a_cycle) - coloriter = 7; /* show periodicity */ - else if (inside >= 0) - coloriter = inside; /* set to specified color, ignore logpal */ - else - { - if (inside == STARTRAIL) - { - int i; - double diff; - coloriter = 0; - for (i=1; i<16; i++) - { - diff = tantable[0] - tantable[i]; - if (fabs(diff) < .05) - { - coloriter = i; - break; - } - } - } - else if (inside== PERIOD) { - if (cyclelen>0) { - coloriter = cyclelen; - } else { - coloriter = maxit; - } - } - else if (inside == EPSCROSS) - { - if (hooper==1) - coloriter = green; - else if (hooper==2) - coloriter = yellow; - else if ( hooper==0) - coloriter = maxit; - if (show_orbit) - scrub_orbit(); - } - else if (inside == FMODI) - { - coloriter = (long)(memvalue * colors / closeprox); - } - else if (inside == ATANI) /* "atan" */ - if (integerfractal) { - g_new.x = ((double)lnew.x) / fudge; - g_new.y = ((double)lnew.y) / fudge; - coloriter = (long)fabs(atan2(g_new.y,g_new.x)*atan_colors/PI); - } - else - coloriter = (long)fabs(atan2(g_new.y,g_new.x)*atan_colors/PI); - else if (inside == BOF60) - coloriter = (long)(sqrt(min_orbit) * 75); - else if (inside == BOF61) - coloriter = min_index; - else if (inside == ZMAG) - { - if (integerfractal) - { - /* - g_new.x = ((double)lnew.x) / fudge; - g_new.y = ((double)lnew.y) / fudge; - coloriter = (long)((((double)lsqr(lnew.x))/fudge + ((double)lsqr(lnew.y))/fudge) * (maxit>>1) + 1); - */ - coloriter = (long)(((double)lmagnitud/fudge) * (maxit>>1) + 1); - } - else - coloriter = (long)((sqr(g_new.x) + sqr(g_new.y)) * (maxit>>1) + 1); - } - else /* inside == -1 */ - coloriter = maxit; - if (LogTable || Log_Calc) - coloriter = logtablecalc(coloriter); - } - - plot_pixel: - - color = abs((int)coloriter); - if (coloriter >= colors) { /* don't use color 0 unless from inside/outside */ - if (save_release <= 1950) { - if (colors < 16) - color &= g_and_color; - else - color = ((color - 1) % g_and_color) + 1; /* skip color zero */ - } - else { - if (colors < 16) - color = (int)(coloriter & g_and_color); - else - color = (int)(((coloriter - 1) % g_and_color) + 1); - } - } - if (debugflag != 470) - if (color <= 0 && stdcalcmode == 'b' ) /* fix BTM bug */ - color = 1; - (*plot) (col, row, color); - - maxit = savemaxit; - if ((kbdcount -= abs((int)realcoloriter)) <= 0) - { - if (check_key()) - return -1; - kbdcount = max_kbdcount; - } - return color; -} -#undef green -#undef yellow - -#define cos45 sin45 -#define lcos45 lsin45 - -/**************** standardfractal doodad subroutines *********************/ -static void decomposition(void) -{ -/* static double cos45 = 0.70710678118654750; */ /* cos 45 degrees */ - static double sin45 = 0.70710678118654750; /* sin 45 degrees */ - static double cos22_5 = 0.92387953251128670; /* cos 22.5 degrees */ - static double sin22_5 = 0.38268343236508980; /* sin 22.5 degrees */ - static double cos11_25 = 0.98078528040323040; /* cos 11.25 degrees */ - static double sin11_25 = 0.19509032201612820; /* sin 11.25 degrees */ - static double cos5_625 = 0.99518472667219690; /* cos 5.625 degrees */ - static double sin5_625 = 0.09801714032956060; /* sin 5.625 degrees */ - static double tan22_5 = 0.41421356237309500; /* tan 22.5 degrees */ - static double tan11_25 = 0.19891236737965800; /* tan 11.25 degrees */ - static double tan5_625 = 0.09849140335716425; /* tan 5.625 degrees */ - static double tan2_8125 = 0.04912684976946725; /* tan 2.8125 degrees */ - static double tan1_4063 = 0.02454862210892544; /* tan 1.4063 degrees */ -/* static long lcos45 ;*/ /* cos 45 degrees */ - static long lsin45 ; /* sin 45 degrees */ - static long lcos22_5 ; /* cos 22.5 degrees */ - static long lsin22_5 ; /* sin 22.5 degrees */ - static long lcos11_25 ; /* cos 11.25 degrees */ - static long lsin11_25 ; /* sin 11.25 degrees */ - static long lcos5_625 ; /* cos 5.625 degrees */ - static long lsin5_625 ; /* sin 5.625 degrees */ - static long ltan22_5 ; /* tan 22.5 degrees */ - static long ltan11_25 ; /* tan 11.25 degrees */ - static long ltan5_625 ; /* tan 5.625 degrees */ - static long ltan2_8125 ; /* tan 2.8125 degrees */ - static long ltan1_4063 ; /* tan 1.4063 degrees */ - static long reset_fudge = -1; - int temp = 0; - int save_temp = 0; - int i; - _LCMPLX lalt; - _CMPLX alt; - coloriter = 0; - if (integerfractal) /* the only case */ - { - if (reset_fudge != fudge) - { - reset_fudge = fudge; - /* lcos45 = (long)(cos45 * fudge); */ - lsin45 = (long)(sin45 * fudge); - lcos22_5 = (long)(cos22_5 * fudge); - lsin22_5 = (long)(sin22_5 * fudge); - lcos11_25 = (long)(cos11_25 * fudge); - lsin11_25 = (long)(sin11_25 * fudge); - lcos5_625 = (long)(cos5_625 * fudge); - lsin5_625 = (long)(sin5_625 * fudge); - ltan22_5 = (long)(tan22_5 * fudge); - ltan11_25 = (long)(tan11_25 * fudge); - ltan5_625 = (long)(tan5_625 * fudge); - ltan2_8125 = (long)(tan2_8125 * fudge); - ltan1_4063 = (long)(tan1_4063 * fudge); - } - if (lnew.y < 0) - { - temp = 2; - lnew.y = -lnew.y; - } - - if (lnew.x < 0) - { - ++temp; - lnew.x = -lnew.x; - } - if (decomp[0] == 2 && save_release >= 1827) - { - save_temp = temp; - if (temp==2) save_temp = 3; - if (temp==3) save_temp = 2; - } - - if (decomp[0] >= 8) - { - temp <<= 1; - if (lnew.x < lnew.y) - { - ++temp; - lalt.x = lnew.x; /* just */ - lnew.x = lnew.y; /* swap */ - lnew.y = lalt.x; /* them */ - } - - if (decomp[0] >= 16) - { - temp <<= 1; - if (multiply(lnew.x,ltan22_5,bitshift) < lnew.y) - { - ++temp; - lalt = lnew; - lnew.x = multiply(lalt.x,lcos45,bitshift) + - multiply(lalt.y,lsin45,bitshift); - lnew.y = multiply(lalt.x,lsin45,bitshift) - - multiply(lalt.y,lcos45,bitshift); - } - - if (decomp[0] >= 32) - { - temp <<= 1; - if (multiply(lnew.x,ltan11_25,bitshift) < lnew.y) - { - ++temp; - lalt = lnew; - lnew.x = multiply(lalt.x,lcos22_5,bitshift) + - multiply(lalt.y,lsin22_5,bitshift); - lnew.y = multiply(lalt.x,lsin22_5,bitshift) - - multiply(lalt.y,lcos22_5,bitshift); - } - - if (decomp[0] >= 64) - { - temp <<= 1; - if (multiply(lnew.x,ltan5_625,bitshift) < lnew.y) - { - ++temp; - lalt = lnew; - lnew.x = multiply(lalt.x,lcos11_25,bitshift) + - multiply(lalt.y,lsin11_25,bitshift); - lnew.y = multiply(lalt.x,lsin11_25,bitshift) - - multiply(lalt.y,lcos11_25,bitshift); - } - - if (decomp[0] >= 128) - { - temp <<= 1; - if (multiply(lnew.x,ltan2_8125,bitshift) < lnew.y) - { - ++temp; - lalt = lnew; - lnew.x = multiply(lalt.x,lcos5_625,bitshift) + - multiply(lalt.y,lsin5_625,bitshift); - lnew.y = multiply(lalt.x,lsin5_625,bitshift) - - multiply(lalt.y,lcos5_625,bitshift); - } - - if (decomp[0] == 256) - { - temp <<= 1; - if (multiply(lnew.x,ltan1_4063,bitshift) < lnew.y) - if ((lnew.x*ltan1_4063 < lnew.y)) - ++temp; - } - } - } - } - } - } - } - else /* double case */ - { - if (g_new.y < 0) - { - temp = 2; - g_new.y = -g_new.y; - } - if (g_new.x < 0) - { - ++temp; - g_new.x = -g_new.x; - } - if (decomp[0] == 2 && save_release >= 1827) - { - save_temp = temp; - if (temp==2) save_temp = 3; - if (temp==3) save_temp = 2; - } - if (decomp[0] >= 8) - { - temp <<= 1; - if (g_new.x < g_new.y) - { - ++temp; - alt.x = g_new.x; /* just */ - g_new.x = g_new.y; /* swap */ - g_new.y = alt.x; /* them */ - } - if (decomp[0] >= 16) - { - temp <<= 1; - if (g_new.x*tan22_5 < g_new.y) - { - ++temp; - alt = g_new; - g_new.x = alt.x*cos45 + alt.y*sin45; - g_new.y = alt.x*sin45 - alt.y*cos45; - } - - if (decomp[0] >= 32) - { - temp <<= 1; - if (g_new.x*tan11_25 < g_new.y) - { - ++temp; - alt = g_new; - g_new.x = alt.x*cos22_5 + alt.y*sin22_5; - g_new.y = alt.x*sin22_5 - alt.y*cos22_5; - } - - if (decomp[0] >= 64) - { - temp <<= 1; - if (g_new.x*tan5_625 < g_new.y) - { - ++temp; - alt = g_new; - g_new.x = alt.x*cos11_25 + alt.y*sin11_25; - g_new.y = alt.x*sin11_25 - alt.y*cos11_25; - } - - if (decomp[0] >= 128) - { - temp <<= 1; - if (g_new.x*tan2_8125 < g_new.y) - { - ++temp; - alt = g_new; - g_new.x = alt.x*cos5_625 + alt.y*sin5_625; - g_new.y = alt.x*sin5_625 - alt.y*cos5_625; - } - - if (decomp[0] == 256) - { - temp <<= 1; - if ((g_new.x*tan1_4063 < g_new.y)) - ++temp; - } - } - } - } - } - } - } - for (i = 1; temp > 0; ++i) - { - if (temp & 1) - coloriter = (1 << i) - 1 - coloriter; - temp >>= 1; - } - if (decomp[0] == 2 && save_release >= 1827) { - if (save_temp & 2) coloriter = 1; - else coloriter = 0; - if (colors == 2) - coloriter++; - } - else if (decomp[0] == 2 && save_release < 1827) - coloriter &= 1; - if (colors > decomp[0]) - coloriter++; -} - -/******************************************************************/ -/* Continuous potential calculation for Mandelbrot and Julia */ -/* Reference: Science of Fractal Images p. 190. */ -/* Special thanks to Mark Peterson for his "MtMand" program that */ -/* beautifully approximates plate 25 (same reference) and spurred */ -/* on the inclusion of similar capabilities in FRACTINT. */ -/* */ -/* The purpose of this function is to calculate a color value */ -/* for a fractal that varies continuously with the screen pixels */ -/* locations for better rendering in 3D. */ -/* */ -/* Here "magnitude" is the modulus of the orbit value at */ -/* "iterations". The potparms[] are user-entered paramters */ -/* controlling the level and slope of the continuous potential */ -/* surface. Returns color. - Tim Wegner 6/25/89 */ -/* */ -/* -- Change history -- */ -/* */ -/* 09/12/89 - added floatflag support and fixed float underflow */ -/* */ -/******************************************************************/ - -static int _fastcall potential(double mag, long iterations) -{ - float f_mag,f_tmp,pot; - double d_tmp; - int i_pot; - long l_pot; - - if (iterations < maxit) - { - pot = (float)(l_pot = iterations+2); - if (l_pot <= 0 || mag <= 1.0) - pot = (float)0.0; - else /* pot = log(mag) / pow(2.0, (double)pot); */ - { - if (l_pot < 120 && !floatflag) /* empirically determined limit of fShift */ - { - f_mag = (float)mag; - fLog14(f_mag,f_tmp); /* this SHOULD be non-negative */ - fShift(f_tmp,(char)-l_pot,pot); - } - else - { - d_tmp = log(mag)/(double)pow(2.0,(double)pot); - if (d_tmp > FLT_MIN) /* prevent float type underflow */ - pot = (float)d_tmp; - else - pot = (float)0.0; - } - } - /* following transformation strictly for aesthetic reasons */ - /* meaning of parameters: - potparam[0] -- zero potential level - highest color - - potparam[1] -- slope multiplier -- higher is steeper - potparam[2] -- rqlim value if changeable (bailout for modulus) */ - - if (pot > 0.0) - { - if (floatflag) - pot = (float)sqrt((double)pot); - else - { - fSqrt14(pot,f_tmp); - pot = f_tmp; - } - pot = (float)(potparam[0] - pot*potparam[1] - 1.0); - } - else - pot = (float)(potparam[0] - 1.0); - if (pot < 1.0) - pot = (float)1.0; /* avoid color 0 */ - } - else if (inside >= 0) - pot = (float) inside; - else /* inside < 0 implies inside=maxit, so use 1st pot param instead */ - pot = (float)potparam[0]; - - i_pot = (int)((l_pot = (long)(pot * 256)) >> 8); - if (i_pot >= colors) - { - i_pot = colors - 1; - l_pot = 255; - } - - if (pot16bit) - { - if (!driver_diskp()) /* if putcolor won't be doing it for us */ - writedisk(col+sxoffs,row+syoffs,i_pot); - writedisk(col+sxoffs,row+sydots+syoffs,(int)l_pot); - } - - return i_pot; -} - - -/******************* boundary trace method *************************** -Fractint's original btm was written by David Guenther. There were a few -rare circumstances in which the original btm would not trace or fill -correctly, even on Mandelbrot Sets. The code below was adapted from -"Mandelbrot Sets by Wesley Loewer" (see calmanfp.asm) which was written -before I was introduced to Fractint. It should be noted that without -David Guenther's implimentation of a btm, I doubt that I would have been -able to impliment my own code into Fractint. There are several things in -the following code that are not original with me but came from David -Guenther's code. I've noted these places with the initials DG. - - Wesley Loewer 3/8/92 -*********************************************************************/ -#define bkcolor 0 /* I have some ideas for the future with this. -Wes */ -#define advance_match() coming_from = ((going_to = (going_to - 1) & 0x03) - 1) & 0x03 -#define advance_no_match() going_to = (going_to + 1) & 0x03 - -static -int bound_trace_main(void) - { - enum direction coming_from; - unsigned int match_found, continue_loop; - int trail_color, fillcolor_used, last_fillcolor_used = -1; - int max_putline_length; - int right, left, length; - if (inside == 0 || outside == 0) - { - stopmsg(0, "Boundary tracing cannot be used with inside=0 or outside=0"); - return -1; - } - if (colors < 16) - { - stopmsg(0, "Boundary tracing cannot be used with < 16 colors"); - return -1; - } - - got_status = 2; - max_putline_length = 0; /* reset max_putline_length */ - for (currow = iystart; currow <= iystop; currow++) - { - reset_periodicity = 1; /* reset for a new row */ - color = bkcolor; - for (curcol = ixstart; curcol <= ixstop; curcol++) - { - if (getcolor(curcol, currow) != bkcolor) - continue; - - trail_color = color; - row = currow; - col = curcol; - if ((*calctype)()== -1) /* color, row, col are global */ - { - if (showdot != bkcolor) /* remove showdot pixel */ - (*plot)(col,row,bkcolor); - if (iystop != yystop) /* DG */ - iystop = yystop - (currow - yystart); /* allow for sym */ - add_worklist(xxstart,xxstop,curcol,currow,iystop,currow,0,worksym); - return -1; - } - reset_periodicity = 0; /* normal periodicity checking */ - - /* - This next line may cause a few more pixels to be calculated, - but at the savings of quite a bit of overhead - */ - if (color != trail_color) /* DG */ - continue; - - /* sweep clockwise to trace outline */ - trail_row = currow; - trail_col = curcol; - trail_color = color; - fillcolor_used = fillcolor > 0 ? fillcolor : trail_color; - coming_from = West; - going_to = East; - match_found = 0; - continue_loop = TRUE; - do - { - step_col_row(); - if (row >= currow - && col >= ixstart - && col <= ixstop - && row <= iystop) - { - /* the order of operations in this next line is critical */ - color = getcolor(col, row); - if (color == bkcolor && (*calctype)()== -1) - /* color, row, col are global for (*calctype)() */ - { - if (showdot != bkcolor) /* remove showdot pixel */ - (*plot)(col,row,bkcolor); - if (iystop != yystop) /* DG */ - iystop = yystop - (currow - yystart); /* allow for sym */ - add_worklist(xxstart,xxstop,curcol,currow,iystop,currow,0,worksym); - return -1; - } - else if (color == trail_color) - { - if (match_found < 4) /* to keep it from overflowing */ - match_found++; - trail_row = row; - trail_col = col; - advance_match(); - } - else - { - advance_no_match(); - continue_loop = going_to != coming_from || match_found; - } - } - else - { - advance_no_match(); - continue_loop = going_to != coming_from || match_found; - } - } while (continue_loop && (col != curcol || row != currow)); - - if (match_found <= 3) /* DG */ - { /* no hole */ - color = bkcolor; - reset_periodicity = 1; - continue; - } - -/* -Fill in region by looping around again, filling lines to the left -whenever going_to is South or West -*/ - trail_row = currow; - trail_col = curcol; - coming_from = West; - going_to = East; - do - { - match_found = FALSE; - do - { - step_col_row(); - if (row >= currow - && col >= ixstart - && col <= ixstop - && row <= iystop - && getcolor(col,row) == trail_color) - /* getcolor() must be last */ - { - if (going_to == South - || (going_to == West && coming_from != East)) - { /* fill a row, but only once */ - right = col; - while (--right >= ixstart) - { - color = getcolor(right,row); - if (color == trail_color) - { - break; - } - } - if (color == bkcolor) /* check last color */ - { - left = right; - while (getcolor(--left,row) == bkcolor) - /* Should NOT be possible for left < ixstart */ - ; /* do nothing */ - left++; /* one pixel too far */ - if (right == left) /* only one hole */ - (*plot)(left,row,fillcolor_used); - else - { /* fill the line to the left */ - length=right-left+1; - if (fillcolor_used != last_fillcolor_used || length > max_putline_length) - { /* only reset dstack if necessary */ - memset(dstack,fillcolor_used,length); - last_fillcolor_used = fillcolor_used; - max_putline_length = length; - } - sym_fill_line(row, left, right, dstack); - } - } /* end of fill line */ - -#if 0 /* don't interupt with a check_key() during fill */ - if (--kbdcount<=0) - { - if (check_key()) - { - if (iystop != yystop) - iystop = yystop - (currow - yystart); /* allow for sym */ - add_worklist(xxstart,xxstop,curcol,currow,iystop,currow,0,worksym); - return -1; - } - kbdcount=max_kbdcount; - } -#endif - } - trail_row = row; - trail_col = col; - advance_match(); - match_found = TRUE; - } - else - advance_no_match(); - } while (!match_found && going_to != coming_from); - - if (!match_found) - { /* next one has to be a match */ - step_col_row(); - trail_row = row; - trail_col = col; - advance_match(); - } - } while (trail_col != curcol || trail_row != currow); - reset_periodicity = 1; /* reset after a trace/fill */ - color = bkcolor; - } - } - return 0; - } - -/*******************************************************************/ -/* take one step in the direction of going_to */ -static void step_col_row() - { - switch (going_to) - { - case North: - col = trail_col; - row = trail_row - 1; - break; - case East: - col = trail_col + 1; - row = trail_row; - break; - case South: - col = trail_col; - row = trail_row + 1; - break; - case West: - col = trail_col - 1; - row = trail_row; - break; - } - } - -/******************* end of boundary trace method *******************/ - - -/************************ super solid guessing *****************************/ - -/* - I, Timothy Wegner, invented this solidguessing idea and implemented it in - more or less the overall framework you see here. I am adding this note - now in a possibly vain attempt to secure my place in history, because - Pieter Branderhorst has totally rewritten this routine, incorporating - a *MUCH* more sophisticated algorithm. His revised code is not only - faster, but is also more accurate. Harrumph! -*/ - -static int solidguess(void) -{ - int i,x,y,xlim,ylim,blocksize; - unsigned int *pfxp0,*pfxp1; - unsigned int u; - - guessplot=(plot!=putcolor && plot!=symplot2 && plot!=symplot2J); - /* check if guessing at bottom & right edges is ok */ - bottom_guess = (plot == symplot2 || (plot == putcolor && iystop+1 == ydots)); - right_guess = (plot == symplot2J - || ((plot == putcolor || plot == symplot2) && ixstop+1 == xdots)); - - /* there seems to be a bug in solid guessing at bottom and side */ - if (debugflag != 472) - bottom_guess = right_guess = 0; /* TIW march 1995 */ - - i = maxblock = blocksize = ssg_blocksize(); - totpasses = 1; - while ((i >>= 1) > 1) ++totpasses; - - /* ensure window top and left are on required boundary, treat window - as larger than it really is if necessary (this is the reason symplot - routines must check for > xdots/ydots before plotting sym points) */ - ixstart &= -1 - (maxblock-1); - iystart = yybegin; - iystart &= -1 - (maxblock-1); - - got_status = 1; - - if (workpass == 0) /* otherwise first pass already done */ - { - /* first pass, calc every blocksize**2 pixel, quarter result & paint it */ - curpass = 1; - if (iystart <= yystart) /* first time for this window, init it */ - { - currow = 0; - memset(&tprefix[1][0][0],0,maxxblk*maxyblk*2); /* noskip flags off */ - reset_periodicity = 1; - row=iystart; - for (col=ixstart; col<=ixstop; col+=maxblock) - { /* calc top row */ - if ((*calctype)()== -1) - { - add_worklist(xxstart,xxstop,xxbegin,yystart,yystop,yybegin,0,worksym); - goto exit_solidguess; - } - reset_periodicity = 0; - } - } - else - memset(&tprefix[1][0][0],-1,maxxblk*maxyblk*2); /* noskip flags on */ - for (y=iystart; y<=iystop; y+=blocksize) - { - currow = y; - i = 0; - if (y+blocksize<=iystop) - { /* calc the row below */ - row=y+blocksize; - reset_periodicity = 1; - for (col=ixstart; col<=ixstop; col+=maxblock) - { - i=(*calctype)(); - if (i == -1) - break; - reset_periodicity = 0; - } - } - reset_periodicity = 0; - if (i == -1 || guessrow(1,y,blocksize) != 0) /* interrupted? */ - { - if (y < yystart) - y = yystart; - add_worklist(xxstart,xxstop,xxstart,yystart,yystop,y,0,worksym); - goto exit_solidguess; - } - } - - if (num_worklist) /* work list not empty, just do 1st pass */ - { - add_worklist(xxstart,xxstop,xxstart,yystart,yystop,yystart,1,worksym); - goto exit_solidguess; - } - ++workpass; - iystart = yystart & (-1 - (maxblock-1)); - - /* calculate skip flags for skippable blocks */ - xlim=(ixstop+maxblock)/maxblock+1; - ylim=((iystop+maxblock)/maxblock+15)/16+1; - if (right_guess==0) /* no right edge guessing, zap border */ - for (y=0; y<=ylim; ++y) - tprefix[1][y][xlim]= 0xffff; - if (bottom_guess==0) /* no bottom edge guessing, zap border */ - { - i=(iystop+maxblock)/maxblock+1; - y=i/16+1; - i=1<<(i&15); - for (x=0; x<=xlim; ++x) - tprefix[1][y][x]|=i; - } - /* set each bit in tprefix[0] to OR of it & surrounding 8 in tprefix[1] */ - for (y=0; ++y>1)|(u<<1) - |((*(pfxp1-(maxxblk+1))|*(pfxp1-maxxblk)|*(pfxp1-(maxxblk-1)))>>15) - |((*(pfxp1+(maxxblk-1))|*(pfxp1+maxxblk)|*(pfxp1+(maxxblk+1)))<<15); - } - } - } - else /* first pass already done */ - memset(&tprefix[0][0][0],-1,maxxblk*maxyblk*2); /* noskip flags on */ - if (three_pass) - goto exit_solidguess; - - /* remaining pass(es), halve blocksize & quarter each blocksize**2 */ - i = workpass; - while (--i > 0) /* allow for already done passes */ - blocksize = blocksize>>1; - reset_periodicity = 0; - while ((blocksize=blocksize>>1)>=2) - { - if (stoppass > 0) - if (workpass >= stoppass) - goto exit_solidguess; - curpass = workpass + 1; - for (y=iystart; y<=iystop; y+=blocksize) - { - currow = y; - if (guessrow(0,y,blocksize) != 0) - { - if (y < yystart) - y = yystart; - add_worklist(xxstart,xxstop,xxstart,yystart,yystop,y,workpass,worksym); - goto exit_solidguess; - } - } - ++workpass; - if (num_worklist /* work list not empty, do one pass at a time */ - && blocksize>2) /* if 2, we just did last pass */ - { - add_worklist(xxstart,xxstop,xxstart,yystart,yystop,yystart,workpass,worksym); - goto exit_solidguess; - } - iystart = yystart & (-1 - (maxblock-1)); - } - - exit_solidguess: - return 0; -} - -#define calcadot(c,x,y) { col=x; row=y; c=(*calctype)(); if (c == -1) return -1; } - -static int _fastcall guessrow(int firstpass,int y,int blocksize) -{ - int x,i,j,color; - int xplushalf,xplusblock; - int ylessblock,ylesshalf,yplushalf,yplusblock; - int c21,c31,c41; /* cxy is the color of pixel at (x,y) */ - int c12,c22,c32,c42; /* where c22 is the topleft corner of */ - int c13,c23,c33; /* the block being handled in current */ - int c24, c44; /* iteration */ - int guessed23,guessed32,guessed33,guessed12,guessed13; - int prev11,fix21,fix31; - unsigned int *pfxptr,pfxmask; - - c44 = c41 = c42 = 0; /* just for warning */ - - halfblock=blocksize>>1; - i=y/maxblock; - pfxptr= (unsigned int *)&tprefix[firstpass][(i>>4)+1][ixstart/maxblock]; - pfxmask=1<<(i&15); - ylesshalf=y-halfblock; - ylessblock=y-blocksize; /* constants, for speed */ - yplushalf=y+halfblock; - yplusblock=y+blocksize; - prev11= -1; - c24=c12=c13=c22=getcolor(ixstart,y); - c31=c21=getcolor(ixstart,(y>0)?ylesshalf:0); - if (yplusblock<=iystop) - c24=getcolor(ixstart,yplusblock); - else if (bottom_guess==0) - c24= -1; - guessed12=guessed13=0; - - for (x=ixstart; x<=ixstop; ) /* increment at end, or when doing continue */ - { - if ((x&(maxblock-1))==0) /* time for skip flag stuff */ - { - ++pfxptr; - if (firstpass==0 && (*pfxptr&pfxmask)==0) /* check for fast skip */ - { - /* next useful in testing to make skips visible */ - /* - if (halfblock==1) - { - (*plot)(x+1,y,0); (*plot)(x,y+1,0); (*plot)(x+1,y+1,0); - } - */ - x+=maxblock; - prev11=c31=c21=c24=c12=c13=c22; - guessed12=guessed13=0; - continue; - } - } - - if (firstpass) /* 1st pass, paint topleft corner */ - plotblock(0,x,y,c22); - /* setup variables */ - xplusblock=(xplushalf=x+halfblock)+halfblock; - if (xplushalf>ixstop) - { - if (right_guess==0) - c31= -1; - } - else if (y>0) - c31=getcolor(xplushalf,ylesshalf); - if (xplusblock<=ixstop) - { - if (yplusblock<=iystop) - c44=getcolor(xplusblock,yplusblock); - c41=getcolor(xplusblock,(y>0)?ylesshalf:0); - c42=getcolor(xplusblock,y); - } - else if (right_guess==0) - c41=c42=c44= -1; - if (yplusblock>iystop) - c44=(bottom_guess)?c42:-1; - - /* guess or calc the remaining 3 quarters of current block */ - guessed23=guessed32=guessed33=1; - c23=c32=c33=c22; - if (yplushalf>iystop) - { - if (bottom_guess==0) - c23=c33= -1; - guessed23=guessed33= -1; - guessed13=0; /* fix for ydots not divisible by four bug TW 2/16/97 */ - } - if (xplushalf>ixstop) - { - if (right_guess==0) - c32=c33= -1; - guessed32=guessed33= -1; - } - while (1) /* go around till none of 23,32,33 change anymore */ - { - if (guessed33>0 - && (c33!=c44 || c33!=c42 || c33!=c24 || c33!=c32 || c33!=c23)) - { - calcadot(c33,xplushalf,yplushalf); - guessed33=0; - } - if (guessed32>0 - && (c32!=c33 || c32!=c42 || c32!=c31 || c32!=c21 - || c32!=c41 || c32!=c23)) - { - calcadot(c32,xplushalf,y); - guessed32=0; - continue; - } - if (guessed23>0 - && (c23!=c33 || c23!=c24 || c23!=c13 || c23!=c12 || c23!=c32)) - { - calcadot(c23,x,yplushalf); - guessed23=0; - continue; - } - break; - } - - if (firstpass) /* note whether any of block's contents were calculated */ - if (guessed23==0 || guessed32==0 || guessed33==0) - *pfxptr|=pfxmask; - - if (halfblock>1) { /* not last pass, check if something to display */ - if (firstpass) /* display guessed corners, fill in block */ - { - if (guessplot) - { - if (guessed23>0) - (*plot)(x,yplushalf,c23); - if (guessed32>0) - (*plot)(xplushalf,y,c32); - if (guessed33>0) - (*plot)(xplushalf,yplushalf,c33); - } - plotblock(1,x,yplushalf,c23); - plotblock(0,xplushalf,y,c32); - plotblock(1,xplushalf,yplushalf,c33); - } - else /* repaint changed blocks */ - { - if (c23!=c22) - plotblock(-1,x,yplushalf,c23); - if (c32!=c22) - plotblock(-1,xplushalf,y,c32); - if (c33!=c22) - plotblock(-1,xplushalf,yplushalf,c33); - } - } - - /* check if some calcs in this block mean earlier guesses need fixing */ - fix21=((c22!=c12 || c22!=c32) - && c21==c22 && c21==c31 && c21==prev11 - && y>0 - && (x==ixstart || c21==getcolor(x-halfblock,ylessblock)) - && (xplushalf>ixstop || c21==getcolor(xplushalf,ylessblock)) - && c21==getcolor(x,ylessblock)); - fix31=(c22!=c32 - && c31==c22 && c31==c42 && c31==c21 && c31==c41 - && y>0 && xplushalf<=ixstop - && c31==getcolor(xplushalf,ylessblock) - && (xplusblock>ixstop || c31==getcolor(xplusblock,ylessblock)) - && c31==getcolor(x,ylessblock)); - prev11=c31; /* for next time around */ - if (fix21) - { - calcadot(c21,x,ylesshalf); - if (halfblock>1 && c21!=c22) - plotblock(-1,x,ylesshalf,c21); - } - if (fix31) - { - calcadot(c31,xplushalf,ylesshalf); - if (halfblock>1 && c31!=c22) - plotblock(-1,xplushalf,ylesshalf,c31); - } - if (c23!=c22) - { - if (guessed12) - { - calcadot(c12,x-halfblock,y); - if (halfblock>1 && c12!=c22) - plotblock(-1,x-halfblock,y,c12); - } - if (guessed13) - { - calcadot(c13,x-halfblock,yplushalf); - if (halfblock>1 && c13!=c22) - plotblock(-1,x-halfblock,yplushalf,c13); - } - } - c22=c42; - c24=c44; - c13=c33; - c31=c21=c41; - c12=c32; - guessed12=guessed32; - guessed13=guessed33; - x+=blocksize; - } /* end x loop */ - - if (firstpass==0 || guessplot) return 0; - - /* paint rows the fast way */ - for (i=0; i=xxstart; ) - { - color=dstack[i]; - dstack[i]=dstack[j=ixstop-(i-xxstart)]; - dstack[j]=(BYTE)color; - j+=OLDMAXPIXELS; - color=dstack[i+OLDMAXPIXELS]; - dstack[i+OLDMAXPIXELS]=dstack[j]; - dstack[j]=(BYTE)color; - } - for (i=0; iiystop && jiystop && jixstop) - xlim=ixstop+1; - if (buildrow>=0 && guessplot==0) /* save it for later put_line */ - { - if (buildrow==0) - for (i=x; i=xxstart) /* when x reduced for alignment, paint those dots too */ - return; /* the usual case */ - } - /* paint it */ - if ((ylim=y+halfblock)>iystop) - { - if (y>iystop) - return; - ylim=iystop+1; - } - for (i=x; ++i= yystop) - return 1; /* axis not in window */ - i = xaxis_row + (xaxis_row - yystart); - if (xaxis_between) - ++i; - if (i > yystop) /* split into 2 pieces, bottom has the symmetry */ - { - if (num_worklist >= MAXCALCWORK-1) /* no room to split */ - return 1; - iystop = xaxis_row - (yystop - xaxis_row); - if (!xaxis_between) - --iystop; - add_worklist(xxstart,xxstop,xxstart,iystop+1,yystop,iystop+1,workpass,0); - yystop = iystop; - return 1; /* tell set_symmetry no sym for current window */ - } - if (i < yystop) /* split into 2 pieces, top has the symmetry */ - { - if (num_worklist >= MAXCALCWORK-1) /* no room to split */ - return 1; - add_worklist(xxstart,xxstop,xxstart,i+1,yystop,i+1,workpass,0); - yystop = i; - } - iystop = xaxis_row; - worksym |= 1; - } - symmetry = 0; - return 0; /* tell set_symmetry its a go */ -} - -static int _fastcall ysym_split(int yaxis_col,int yaxis_between) -{ - int i; - if ((worksym&0x22) == 0x20) /* already decided not sym */ - return 1; - if ((worksym&2) != 0) /* already decided on sym */ - ixstop = (xxstart+xxstop)/2; - else /* new window, decide */ - { - worksym |= 0x20; - if (yaxis_col <= xxstart || yaxis_col >= xxstop) - return 1; /* axis not in window */ - i = yaxis_col + (yaxis_col - xxstart); - if (yaxis_between) - ++i; - if (i > xxstop) /* split into 2 pieces, right has the symmetry */ - { - if (num_worklist >= MAXCALCWORK-1) /* no room to split */ - return 1; - ixstop = yaxis_col - (xxstop - yaxis_col); - if (!yaxis_between) - --ixstop; - add_worklist(ixstop+1,xxstop,ixstop+1,yystart,yystop,yystart,workpass,0); - xxstop = ixstop; - return 1; /* tell set_symmetry no sym for current window */ - } - if (i < xxstop) /* split into 2 pieces, left has the symmetry */ - { - if (num_worklist >= MAXCALCWORK-1) /* no room to split */ - return 1; - add_worklist(i+1,xxstop,i+1,yystart,yystop,yystart,workpass,0); - xxstop = i; - } - ixstop = yaxis_col; - worksym |= 2; - } - symmetry = 0; - return 0; /* tell set_symmetry its a go */ -} - -#ifdef _MSC_VER -#pragma optimize ("ea", off) -#endif - -static void _fastcall setsymmetry(int sym, int uselist) /* set up proper symmetrical plot functions */ -{ - int i; - int parmszero, parmsnoreal, parmsnoimag; - int xaxis_row, yaxis_col; /* pixel number for origin */ - int xaxis_between=0, yaxis_between=0; /* if axis between 2 pixels, not on one */ - int xaxis_on_screen=0, yaxis_on_screen=0; - double ftemp; - bf_t bft1; - int saved=0; - symmetry = 1; - if (stdcalcmode == 's' || stdcalcmode == 'o') - return; - if (sym == NOPLOT && forcesymmetry == 999) - { - plot = noplot; - return; - } - /* NOTE: 16-bit potential disables symmetry */ - /* also any decomp= option and any inversion not about the origin */ - /* also any rotation other than 180deg and any off-axis stretch */ - if (bf_math) - if (cmp_bf(bfxmin,bfx3rd) || cmp_bf(bfymin,bfy3rd)) - return; - if ((potflag && pot16bit) || (invert && inversion[2] != 0.0) - || decomp[0] != 0 - || xxmin!=xx3rd || yymin!=yy3rd) - return; - if (sym != XAXIS && sym != XAXIS_NOPARM && inversion[1] != 0.0 && forcesymmetry == 999) - return; - if (forcesymmetry < 999) - sym = forcesymmetry; - else if (forcesymmetry == 1000) - forcesymmetry = sym; /* for backwards compatibility */ - else if (outside==REAL || outside==IMAG || outside==MULT || outside==SUM - || outside==ATAN || bailoutest==Manr || outside==FMOD) - return; - else if (inside==FMODI || outside==TDIS) - return; - parmszero = (parm.x == 0.0 && parm.y == 0.0 && useinitorbit != 1); - parmsnoreal = (parm.x == 0.0 && useinitorbit != 1); - parmsnoimag = (parm.y == 0.0 && useinitorbit != 1); - switch (fractype) - { case LMANLAMFNFN: /* These need only P1 checked. */ - case FPMANLAMFNFN: /* P2 is used for a switch value */ - case LMANFNFN: /* These have NOPARM set in fractalp.c, */ - case FPMANFNFN: /* but it only applies to P1. */ - case FPMANDELZPOWER: /* or P2 is an exponent */ - case LMANDELZPOWER: - case FPMANZTOZPLUSZPWR: - case MARKSMANDEL: - case MARKSMANDELFP: - case MARKSJULIA: - case MARKSJULIAFP: - break; - case FORMULA: /* Check P2, P3, P4 and P5 */ - case FFORMULA: - parmszero = (parmszero && param[2] == 0.0 && param[3] == 0.0 - && param[4] == 0.0 && param[5] == 0.0 - && param[6] == 0.0 && param[7] == 0.0 - && param[8] == 0.0 && param[9] == 0.0); - parmsnoreal = (parmsnoreal && param[2] == 0.0 && param[4] == 0.0 - && param[6] == 0.0 && param[8] == 0.0); - parmsnoimag = (parmsnoimag && param[3] == 0.0 && param[5] == 0.0 - && param[7] == 0.0 && param[9] == 0.0); - break; - default: /* Check P2 for the rest */ - parmszero = (parmszero && parm2.x == 0.0 && parm2.y == 0.0); - } - xaxis_row = yaxis_col = -1; - if (bf_math) - { - saved = save_stack(); - bft1 = alloc_stack(rbflength+2); - xaxis_on_screen = (sign_bf(bfymin) != sign_bf(bfymax)); - yaxis_on_screen = (sign_bf(bfxmin) != sign_bf(bfxmax)); - } - else - { - xaxis_on_screen = (sign(yymin) != sign(yymax)); - yaxis_on_screen = (sign(xxmin) != sign(xxmax)); - } - if (xaxis_on_screen) /* axis is on screen */ - { - if (bf_math) - { - /* ftemp = (0.0-yymax) / (yymin-yymax); */ - sub_bf(bft1,bfymin,bfymax); - div_bf(bft1,bfymax,bft1); - neg_a_bf(bft1); - ftemp = (double)bftofloat(bft1); - } - else - ftemp = (0.0-yymax) / (yymin-yymax); - ftemp *= (ydots-1); - ftemp += 0.25; - xaxis_row = (int)ftemp; - xaxis_between = (ftemp - xaxis_row >= 0.5); - if (uselist == 0 && (!xaxis_between || (xaxis_row+1)*2 != ydots)) - xaxis_row = -1; /* can't split screen, so dead center or not at all */ - } - if (yaxis_on_screen) /* axis is on screen */ - { - if (bf_math) - { - /* ftemp = (0.0-xxmin) / (xxmax-xxmin); */ - sub_bf(bft1,bfxmax,bfxmin); - div_bf(bft1,bfxmin,bft1); - neg_a_bf(bft1); - ftemp = (double)bftofloat(bft1); - } - else - ftemp = (0.0-xxmin) / (xxmax-xxmin); - ftemp *= (xdots-1); - ftemp += 0.25; - yaxis_col = (int)ftemp; - yaxis_between = (ftemp - yaxis_col >= 0.5); - if (uselist == 0 && (!yaxis_between || (yaxis_col+1)*2 != xdots)) - yaxis_col = -1; /* can't split screen, so dead center or not at all */ - } - switch (sym) /* symmetry switch */ - { - case XAXIS_NOREAL: /* X-axis Symmetry (no real param) */ - if (!parmsnoreal) break; - goto xsym; - case XAXIS_NOIMAG: /* X-axis Symmetry (no imag param) */ - if (!parmsnoimag) break; - goto xsym; - case XAXIS_NOPARM: /* X-axis Symmetry (no params)*/ - if (!parmszero) - break; - xsym: - case XAXIS: /* X-axis Symmetry */ - if (xsym_split(xaxis_row,xaxis_between) == 0) { - if (basin) - plot = symplot2basin; - else - plot = symplot2; - } - break; - case YAXIS_NOPARM: /* Y-axis Symmetry (No Parms)*/ - if (!parmszero) - break; - case YAXIS: /* Y-axis Symmetry */ - if (ysym_split(yaxis_col,yaxis_between) == 0) - plot = symplot2Y; - break; - case XYAXIS_NOPARM: /* X-axis AND Y-axis Symmetry (no parms)*/ - if (!parmszero) - break; - case XYAXIS: /* X-axis AND Y-axis Symmetry */ - xsym_split(xaxis_row,xaxis_between); - ysym_split(yaxis_col,yaxis_between); - switch (worksym & 3) - { - case 1: /* just xaxis symmetry */ - if (basin) - plot = symplot2basin; - else - plot = symplot2 ; - break; - case 2: /* just yaxis symmetry */ - if (basin) /* got no routine for this case */ - { - ixstop = xxstop; /* fix what split should not have done */ - symmetry = 1; - } - else - plot = symplot2Y; - break; - case 3: /* both axes */ - if (basin) - plot = symplot4basin; - else - plot = symplot4 ; - } - break; - case ORIGIN_NOPARM: /* Origin Symmetry (no parms)*/ - if (!parmszero) - break; - case ORIGIN: /* Origin Symmetry */ - originsym: - if ( xsym_split(xaxis_row,xaxis_between) == 0 - && ysym_split(yaxis_col,yaxis_between) == 0) - { - plot = symplot2J; - ixstop = xxstop; /* didn't want this changed */ - } - else - { - iystop = yystop; /* in case first split worked */ - symmetry = 1; - worksym = 0x30; /* let it recombine with others like it */ - } - break; - case PI_SYM_NOPARM: - if (!parmszero) - break; - case PI_SYM: /* PI symmetry */ - if (bf_math) - { - if ((double)bftofloat(abs_a_bf(sub_bf(bft1,bfxmax,bfxmin))) < PI/4) - break; /* no point in pi symmetry if values too close */ - } - else - { - if (fabs(xxmax - xxmin) < PI/4) - break; /* no point in pi symmetry if values too close */ - } - if (invert && forcesymmetry == 999) - goto originsym; - plot = symPIplot ; - symmetry = 0; - if ( xsym_split(xaxis_row,xaxis_between) == 0 - && ysym_split(yaxis_col,yaxis_between) == 0) - if (parm.y == 0.0) - plot = symPIplot4J; /* both axes */ - else - plot = symPIplot2J; /* origin */ - else - { - iystop = yystop; /* in case first split worked */ - worksym = 0x30; /* don't mark pisym as ysym, just do it unmarked */ - } - if (bf_math) - { - sub_bf(bft1,bfxmax,bfxmin); - abs_a_bf(bft1); - pixelpi = (int)((PI/(double)bftofloat(bft1)*xdots)); /* PI in pixels */ - } - else - pixelpi = (int)((PI/fabs(xxmax-xxmin))*xdots); /* PI in pixels */ - - if ( (ixstop = xxstart+pixelpi-1 ) > xxstop) - ixstop = xxstop; - if (plot == symPIplot4J && ixstop > (i = (xxstart+xxstop)/2)) - ixstop = i; - break; - default: /* no symmetry */ - break; - } - if (bf_math) - restore_stack(saved); -} - -#ifdef _MSC_VER -#pragma optimize ("ea", on) -#endif - -/**************** tesseral method by CJLT begins here*********************/ -/* reworked by PB for speed and resumeability */ - -struct tess { /* one of these per box to be done gets stacked */ - int x1,x2,y1,y2; /* left/right top/bottom x/y coords */ - int top,bot,lft,rgt; /* edge colors, -1 mixed, -2 unknown */ -}; - -static int tesseral(void) -{ - struct tess *tp; - - guessplot = (plot != putcolor && plot != symplot2); - tp = (struct tess *)&dstack[0]; - tp->x1 = ixstart; /* set up initial box */ - tp->x2 = ixstop; - tp->y1 = iystart; - tp->y2 = iystop; - - if (workpass == 0) { /* not resuming */ - tp->top = tessrow(ixstart,ixstop,iystart); /* Do top row */ - tp->bot = tessrow(ixstart,ixstop,iystop); /* Do bottom row */ - tp->lft = tesscol(ixstart,iystart+1,iystop-1); /* Do left column */ - tp->rgt = tesscol(ixstop,iystart+1,iystop-1); /* Do right column */ - if (check_key()) { /* interrupt before we got properly rolling */ - add_worklist(xxstart,xxstop,xxstart,yystart,yystop,yystart,0,worksym); - return -1; - } - } - - else { /* resuming, rebuild work stack */ - int i,mid,curx,cury,xsize,ysize; - struct tess *tp2; - tp->top = tp->bot = tp->lft = tp->rgt = -2; - cury = yybegin & 0xfff; - ysize = 1; - i = (unsigned)yybegin >> 12; - while (--i >= 0) ysize <<= 1; - curx = workpass & 0xfff; - xsize = 1; - i = (unsigned)workpass >> 12; - while (--i >= 0) xsize <<= 1; - while (1) { - tp2 = tp; - if (tp->x2 - tp->x1 > tp->y2 - tp->y1) { /* next divide down middle */ - if (tp->x1 == curx && (tp->x2 - tp->x1 - 2) < xsize) - break; - mid = (tp->x1 + tp->x2) >> 1; /* Find mid point */ - if (mid > curx) { /* stack right part */ - memcpy(++tp,tp2,sizeof(*tp)); - tp->x2 = mid; - } - tp2->x1 = mid; - } - else { /* next divide across */ - if (tp->y1 == cury && (tp->y2 - tp->y1 - 2) < ysize) break; - mid = (tp->y1 + tp->y2) >> 1; /* Find mid point */ - if (mid > cury) { /* stack bottom part */ - memcpy(++tp,tp2,sizeof(*tp)); - tp->y2 = mid; - } - tp2->y1 = mid; - } - } - } - - got_status = 4; /* for tab_display */ - - while (tp >= (struct tess *)&dstack[0]) { /* do next box */ - curcol = tp->x1; /* for tab_display */ - currow = tp->y1; - - if (tp->top == -1 || tp->bot == -1 || tp->lft == -1 || tp->rgt == -1) - goto tess_split; - /* for any edge whose color is unknown, set it */ - if (tp->top == -2) - tp->top = tesschkrow(tp->x1,tp->x2,tp->y1); - if (tp->top == -1) - goto tess_split; - if (tp->bot == -2) - tp->bot = tesschkrow(tp->x1,tp->x2,tp->y2); - if (tp->bot != tp->top) - goto tess_split; - if (tp->lft == -2) - tp->lft = tesschkcol(tp->x1,tp->y1,tp->y2); - if (tp->lft != tp->top) - goto tess_split; - if (tp->rgt == -2) - tp->rgt = tesschkcol(tp->x2,tp->y1,tp->y2); - if (tp->rgt != tp->top) - goto tess_split; - - { - int mid,midcolor; - if (tp->x2 - tp->x1 > tp->y2 - tp->y1) { /* divide down the middle */ - mid = (tp->x1 + tp->x2) >> 1; /* Find mid point */ - midcolor = tesscol(mid, tp->y1+1, tp->y2-1); /* Do mid column */ - if (midcolor != tp->top) goto tess_split; - } - else { /* divide across the middle */ - mid = (tp->y1 + tp->y2) >> 1; /* Find mid point */ - midcolor = tessrow(tp->x1+1, tp->x2-1, mid); /* Do mid row */ - if (midcolor != tp->top) goto tess_split; - } - } - - { /* all 4 edges are the same color, fill in */ - int i,j; - i = 0; - if (fillcolor != 0) - { - if (fillcolor > 0) - tp->top = fillcolor %colors; - if (guessplot || (j = tp->x2 - tp->x1 - 1) < 2) { /* paint dots */ - for (col = tp->x1 + 1; col < tp->x2; col++) - for (row = tp->y1 + 1; row < tp->y2; row++) { - (*plot)(col,row,tp->top); - if (++i > 500) { - if (check_key()) goto tess_end; - i = 0; - } - } - } - else { /* use put_line for speed */ - memset(&dstack[OLDMAXPIXELS],tp->top,j); - for (row = tp->y1 + 1; row < tp->y2; row++) { - put_line(row,tp->x1+1,tp->x2-1,&dstack[OLDMAXPIXELS]); - if (plot != putcolor) /* symmetry */ - if ((j = yystop-(row-yystart)) > iystop && j < ydots) - put_line(j,tp->x1+1,tp->x2-1,&dstack[OLDMAXPIXELS]); - if (++i > 25) { - if (check_key()) goto tess_end; - i = 0; - } - } - } - } - --tp; - } - continue; - - tess_split: - { /* box not surrounded by same color, sub-divide */ - int mid,midcolor; - struct tess *tp2; - if (tp->x2 - tp->x1 > tp->y2 - tp->y1) { /* divide down the middle */ - mid = (tp->x1 + tp->x2) >> 1; /* Find mid point */ - midcolor = tesscol(mid, tp->y1+1, tp->y2-1); /* Do mid column */ - if (midcolor == -3) goto tess_end; - if (tp->x2 - mid > 1) { /* right part >= 1 column */ - if (tp->top == -1) tp->top = -2; - if (tp->bot == -1) tp->bot = -2; - tp2 = tp; - if (mid - tp->x1 > 1) { /* left part >= 1 col, stack right */ - memcpy(++tp,tp2,sizeof(*tp)); - tp->x2 = mid; - tp->rgt = midcolor; - } - tp2->x1 = mid; - tp2->lft = midcolor; - } - else - --tp; - } - else { /* divide across the middle */ - mid = (tp->y1 + tp->y2) >> 1; /* Find mid point */ - midcolor = tessrow(tp->x1+1, tp->x2-1, mid); /* Do mid row */ - if (midcolor == -3) goto tess_end; - if (tp->y2 - mid > 1) { /* bottom part >= 1 column */ - if (tp->lft == -1) tp->lft = -2; - if (tp->rgt == -1) tp->rgt = -2; - tp2 = tp; - if (mid - tp->y1 > 1) { /* top also >= 1 col, stack bottom */ - memcpy(++tp,tp2,sizeof(*tp)); - tp->y2 = mid; - tp->bot = midcolor; - } - tp2->y1 = mid; - tp2->top = midcolor; - } - else - --tp; - } - } - - } - - tess_end: - if (tp >= (struct tess *)&dstack[0]) { /* didn't complete */ - int i,xsize,ysize; - xsize = ysize = 1; - i = 2; - while (tp->x2 - tp->x1 - 2 >= i) { - i <<= 1; - ++xsize; - } - i = 2; - while (tp->y2 - tp->y1 - 2 >= i) { - i <<= 1; - ++ysize; - } - add_worklist(xxstart,xxstop,xxstart,yystart,yystop, - (ysize<<12)+tp->y1,(xsize<<12)+tp->x1,worksym); - return -1; - } - return 0; - -} /* tesseral */ - -static int _fastcall tesschkcol(int x,int y1,int y2) -{ - int i; - i = getcolor(x,++y1); - while (--y2 > y1) - if (getcolor(x,y2) != i) return -1; - return i; -} - -static int _fastcall tesschkrow(int x1,int x2,int y) -{ - int i; - i = getcolor(x1,y); - while (x2 > x1) { - if (getcolor(x2,y) != i) return -1; - --x2; - } - return i; -} - -static int _fastcall tesscol(int x,int y1,int y2) -{ - int colcolor,i; - col = x; - row = y1; - reset_periodicity = 1; - colcolor = (*calctype)(); - reset_periodicity = 0; - while (++row <= y2) { /* generate the column */ - if ((i = (*calctype)()) < 0) return -3; - if (i != colcolor) colcolor = -1; - } - return colcolor; -} - -static int _fastcall tessrow(int x1,int x2,int y) -{ - int rowcolor,i; - row = y; - col = x1; - reset_periodicity = 1; - rowcolor = (*calctype)(); - reset_periodicity = 0; - while (++col <= x2) { /* generate the row */ - if ((i = (*calctype)()) < 0) return -3; - if (i != rowcolor) rowcolor = -1; - } - return rowcolor; -} - -/* added for testing autologmap() */ /* CAE 9211 fixed missing comment */ -/* insert at end of CALCFRAC.C */ - -static long autologmap(void) /*RB*/ -{ /* calculate round screen edges to avoid wasted colours in logmap */ - long mincolour; - int lag; - int xstop = xdots - 1; /* don't use symetry */ - int ystop = ydots - 1; /* don't use symetry */ - long old_maxit; - mincolour=LONG_MAX; - row=0; - reset_periodicity = 0; - old_maxit = maxit; - for (col=0;col=32 ) (*plot)(col-32,row,0); - } /* these lines tidy up for BTM etc */ - for (lag=32;lag>0;lag--) (*plot)(col-lag,row,0); - - col=xstop; - for (row=0;row=32 ) (*plot)(col,row-32,0); - } - for (lag=32;lag>0;lag--) (*plot)(col,row-lag,0); - - col=0; - for (row=0;row=32 ) (*plot)(col,row-32,0); - } - for (lag=32;lag>0;lag--) (*plot)(col,row-lag,0); - - row=ystop ; - for (col=0;col=32 ) (*plot)(col-32,row,0); - } - for (lag=32;lag>0;lag--) (*plot)(col-lag,row,0); - - ack: /* bailout here if key is pressed */ - if (mincolour==2) resuming=1; /* insure autologmap not called again */ - maxit = old_maxit; - - return mincolour ; -} - -/* Symmetry plot for period PI */ -void _fastcall symPIplot(int x, int y, int color) -{ - while (x <= xxstop) - { - putcolor(x, y, color) ; - x += pixelpi; - } -} -/* Symmetry plot for period PI plus Origin Symmetry */ -void _fastcall symPIplot2J(int x, int y, int color) -{ - int i,j; - while (x <= xxstop) - { - putcolor(x, y, color) ; - if ((i=yystop-(y-yystart)) > iystop && i < ydots - && (j=xxstop-(x-xxstart)) < xdots) - putcolor(j, i, color) ; - x += pixelpi; - } -} -/* Symmetry plot for period PI plus Both Axis Symmetry */ -void _fastcall symPIplot4J(int x, int y, int color) -{ - int i,j; - while (x <= (xxstart+xxstop)/2) - { - j = xxstop-(x-xxstart); - putcolor( x , y , color) ; - if (j < xdots) - putcolor(j , y , color) ; - if ((i=yystop-(y-yystart)) > iystop && i < ydots) - { - putcolor(x , i , color) ; - if (j < xdots) - putcolor(j , i , color) ; - } - x += pixelpi; - } -} - -/* Symmetry plot for X Axis Symmetry */ -void _fastcall symplot2(int x, int y, int color) -{ - int i; - putcolor(x, y, color) ; - if ((i=yystop-(y-yystart)) > iystop && i < ydots) - putcolor(x, i, color) ; -} - -/* Symmetry plot for Y Axis Symmetry */ -void _fastcall symplot2Y(int x, int y, int color) -{ - int i; - putcolor(x, y, color) ; - if ((i=xxstop-(x-xxstart)) < xdots) - putcolor(i, y, color) ; -} - -/* Symmetry plot for Origin Symmetry */ -void _fastcall symplot2J(int x, int y, int color) -{ - int i,j; - putcolor(x, y, color) ; - if ((i=yystop-(y-yystart)) > iystop && i < ydots - && (j=xxstop-(x-xxstart)) < xdots) - putcolor(j, i, color) ; -} - -/* Symmetry plot for Both Axis Symmetry */ -void _fastcall symplot4(int x, int y, int color) -{ - int i,j; - j = xxstop-(x-xxstart); - putcolor( x , y, color) ; - if (j < xdots) - putcolor( j , y, color) ; - if ((i=yystop-(y-yystart)) > iystop && i < ydots) - { - putcolor( x , i, color) ; - if (j < xdots) - putcolor(j , i, color) ; - } -} - -/* Symmetry plot for X Axis Symmetry - Striped Newtbasin version */ -void _fastcall symplot2basin(int x, int y, int color) -{ - int i,stripe; - putcolor(x, y, color) ; - if (basin==2 && color > 8) - stripe=8; - else - stripe = 0; - if ((i=yystop-(y-yystart)) > iystop && i < ydots) - { - color -= stripe; /* reconstruct unstriped color */ - color = (degree+1-color)%degree+1; /* symmetrical color */ - color += stripe; /* add stripe */ - putcolor(x, i,color) ; - } -} - -/* Symmetry plot for Both Axis Symmetry - Newtbasin version */ -void _fastcall symplot4basin(int x, int y, int color) -{ - int i,j,color1,stripe; - if (color == 0) /* assumed to be "inside" color */ - { - symplot4(x, y, color); - return; - } - if (basin==2 && color > 8) - stripe = 8; - else - stripe = 0; - color -= stripe; /* reconstruct unstriped color */ - color1 = degree/2+degree+2 - color; - if (color < degree/2+2) - color1 = degree/2+2 - color; - else - color1 = degree/2+degree+2 - color; - j = xxstop-(x-xxstart); - putcolor( x, y, color+stripe) ; - if (j < xdots) - putcolor( j, y, color1+stripe) ; - if ((i=yystop-(y-yystart)) > iystop && i < ydots) - { - putcolor( x, i, stripe + (degree+1 - color)%degree+1) ; - if (j < xdots) - putcolor(j, i, stripe + (degree+1 - color1)%degree+1) ; - } -} - -static void _fastcall puttruecolor_disk(int x, int y, int color) -{ - putcolor_a(x,y,color); - - targa_color(x, y, color); -/* writedisk(x*=3,y,(BYTE)((realcoloriter ) & 0xff)); */ /* blue */ -/* writedisk(++x, y,(BYTE)((realcoloriter >> 8 ) & 0xff)); */ /* green */ -/* writedisk(x+1, y,(BYTE)((realcoloriter >> 16) & 0xff)); */ /* red */ - -} - -/* Do nothing plot!!! */ -#ifdef __CLINT__ -#pragma argsused -#endif - -void _fastcall noplot(int x,int y,int color) -{ - x = y = color = 0; /* just for warning */ -} diff --git a/fractint/common/cmdfiles.c b/fractint/common/cmdfiles.c deleted file mode 100644 index c2e8bbf8c..000000000 --- a/fractint/common/cmdfiles.c +++ /dev/null @@ -1,3259 +0,0 @@ -/* - Command-line / Command-File Parser Routines -*/ - -#include -#include -#include -#include -#if !defined(XFRACT) && !defined(_WIN32) -#include -#endif - /* see Fractint.c for a description of the "include" hierarchy */ -#include "port.h" -#include "prototyp.h" -#include "fractype.h" -#include "drivers.h" - -#ifdef XFRACT -#define DEFAULT_PRINTER 5 /* Assume a Postscript printer */ -#define PRT_RESOLUTION 100 /* Assume medium resolution */ -#define INIT_GIF87 0 /* Turn on GIF 89a processing */ -#else -#define DEFAULT_PRINTER 2 /* Assume an IBM/Epson printer */ -#define PRT_RESOLUTION 60 /* Assume low resolution */ -#define INIT_GIF87 0 /* Turn on GIF 89a processing */ -#endif - -static int cmdfile(FILE *,int); -static int next_command(char *,int,FILE *,char *,int *,int); -static int next_line(FILE *,char *,int); -int cmdarg(char *,int); -static void argerror(const char *); -static void initvars_run(void); -static void initvars_restart(void); -static void initvars_fractal(void); -static void initvars_3d(void); -static void reset_ifs_defn(void); -static void parse_textcolors(char *value); -static int parse_colors(char *value); -//static int parse_printer(char *value); -static int get_bf(bf_t, char *); -static int isabigfloat(char *str); - -/* variables defined by the command line/files processor */ -int stoppass=0; /* stop at this guessing pass early */ -int pseudox=0; /* xdots to use for video independence */ -int pseudoy=0; /* ydots to use for video independence */ -int bfdigits=0; /* digits to use (force) for bf_math */ -int showdot=-1; /* color to show crawling graphics cursor */ -int sizedot; /* size of dot crawling cursor */ -char recordcolors; /* default PAR color-writing method */ -char autoshowdot=0; /* dark, medium, bright */ -char start_showorbit=0; /* show orbits on at start of fractal */ -char temp1[256]; /* temporary strings */ -char readname[FILE_MAX_PATH];/* name of fractal input file */ -char tempdir[FILE_MAX_DIR] = {""}; /* name of temporary directory */ -char workdir[FILE_MAX_DIR] = {""}; /* name of directory for misc files */ -char orgfrmdir[FILE_MAX_DIR] = {""};/*name of directory for orgfrm files*/ -char gifmask[13] = {""}; -char PrintName[FILE_MAX_PATH]={"fract001.prn"}; /* Name for print-to-file */ -char savename[FILE_MAX_PATH]={"fract001"}; /* save files using this name */ -char autoname[FILE_MAX_PATH]={"auto.key"}; /* record auto keystrokes here */ -int potflag=0; /* continuous potential enabled? */ -int pot16bit; /* store 16 bit continuous potential values */ -int gif87a_flag; /* 1 if GIF87a format, 0 otherwise */ -int dither_flag; /* 1 if want to dither GIFs */ -int askvideo; /* flag for video prompting */ -char floatflag; -int biomorph; /* flag for biomorph */ -int usr_biomorph; -int forcesymmetry; /* force symmetry */ -int showfile; /* zero if file display pending */ -int rflag, rseed; /* Random number seeding flag and value */ -int decomp[2]; /* Decomposition coloring */ -long distest; -int distestwidth; -char fract_overwrite = 0; /* 0 if file overwrite not allowed */ -int soundflag; /* sound control bitfield... see sound.c for useage*/ -int basehertz; /* sound=x/y/x hertz value */ -int debugflag; /* internal use only - you didn't see this */ -int timerflag; /* you didn't see this, either */ -int cyclelimit; /* color-rotator upper limit */ -int inside; /* inside color: 1=blue */ -int fillcolor; /* fillcolor: -1=normal */ -int outside; /* outside color */ -int finattract; /* finite attractor logic */ -int display3d; /* 3D display flag: 0 = OFF */ -int overlay3d; /* 3D overlay flag: 0 = OFF */ -int init3d[20]; /* '3d=nn/nn/nn/...' values */ -int checkcurdir; /* flag to check current dir for files */ -int initbatch; /* 1 if batch run (no kbd) */ -int initsavetime; /* autosave minutes */ -_CMPLX initorbit; /* initial orbitvalue */ -char useinitorbit; /* flag for initorbit */ -int g_init_mode; /* initial video mode */ -int initcyclelimit; /* initial cycle limit */ -BYTE usemag; /* use center-mag corners */ -long bailout; /* user input bailout value */ -enum bailouts bailoutest; /* test used for determining bailout */ -double inversion[3]; /* radius, xcenter, ycenter */ -int rotate_lo,rotate_hi; /* cycling color range */ -int *ranges; /* iter->color ranges mapping */ -int rangeslen = 0; /* size of ranges array */ -BYTE *mapdacbox = NULL; /* map= (default colors) */ -int colorstate; /* 0, g_dac_box matches default (bios or map=) */ - /* 1, g_dac_box matches no known defined map */ - /* 2, g_dac_box matches the colorfile map */ -int colorpreloaded; /* if g_dac_box preloaded for next mode select */ -int save_release; /* release creating PAR file*/ -char dontreadcolor=0; /* flag for reading color from GIF */ -double math_tol[2]={.05,.05}; /* For math transition */ -int Targa_Out = 0; /* 3D fullcolor flag */ -int truecolor = 0; /* escape time truecolor flag */ -int truemode = 0; /* truecolor coloring scheme */ -char colorfile[FILE_MAX_PATH];/* from last or colors=@filename */ -int functionpreloaded; /* if function loaded for new bifs, JCO 7/5/92 */ -float screenaspect = DEFAULTASPECT; /* aspect ratio of the screen */ -float aspectdrift = DEFAULTASPECTDRIFT; /* how much drift is allowed and */ - /* still forced to screenaspect */ -int fastrestore = 0; /* 1 - reset viewwindows prior to a restore - and do not display warnings when video - mode changes during restore */ - -int orgfrmsearch = 0; /* 1 - user has specified a directory for - Orgform formula compilation files */ - -int orbitsave = 0; /* for IFS and LORENZ to output acrospin file */ -int orbit_delay; /* clock ticks delating orbit release */ -int transparent[2]; /* transparency min/max values */ -long LogFlag; /* Logarithmic palette flag: 0 = no */ - -BYTE exitmode = 3; /* video mode on exit */ - -int Log_Fly_Calc = 0; /* calculate logmap on-the-fly */ -int Log_Auto_Calc = 0; /* auto calculate logmap */ -int nobof = 0; /* Flag to make inside=bof options not duplicate bof images */ - -int escape_exit; /* set to 1 to avoid the "are you sure?" screen */ -int first_init=1; /* first time into cmdfiles? */ -static int init_rseed; -static char initcorners,initparams; -struct fractalspecificstuff *curfractalspecific = NULL; - -char FormFileName[FILE_MAX_PATH];/* file to find (type=)formulas in */ -char FormName[ITEMNAMELEN+1]; /* Name of the Formula (if not null) */ -char LFileName[FILE_MAX_PATH]; /* file to find (type=)L-System's in */ -char LName[ITEMNAMELEN+1]; /* Name of L-System */ -char CommandFile[FILE_MAX_PATH]; /* file to find command sets in */ -char CommandName[ITEMNAMELEN+1]; /* Name of Command set */ -char CommandComment[4][MAXCMT]; /* comments for command set */ -char IFSFileName[FILE_MAX_PATH];/* file to find (type=)IFS in */ -char IFSName[ITEMNAMELEN+1]; /* Name of the IFS def'n (if not null) */ -struct SearchPath searchfor; -float *ifs_defn = NULL; /* ifs parameters */ -int ifs_type; /* 0=2d, 1=3d */ -int g_slides = SLIDES_OFF; /* 1 autokey=play, 2 autokey=record */ - -BYTE txtcolor[]={ - BLUE*16+L_WHITE, /* C_TITLE title background */ - BLUE*16+L_GREEN, /* C_TITLE_DEV development vsn foreground */ - GREEN*16+YELLOW, /* C_HELP_HDG help page title line */ - WHITE*16+BLACK, /* C_HELP_BODY help page body */ - GREEN*16+GRAY, /* C_HELP_INSTR help page instr at bottom */ - WHITE*16+BLUE, /* C_HELP_LINK help page links */ - CYAN*16+BLUE, /* C_HELP_CURLINK help page current link */ - WHITE*16+GRAY, /* C_PROMPT_BKGRD prompt/choice background */ - WHITE*16+BLACK, /* C_PROMPT_TEXT prompt/choice extra info */ - BLUE*16+WHITE, /* C_PROMPT_LO prompt/choice text */ - BLUE*16+L_WHITE, /* C_PROMPT_MED prompt/choice hdg2/... */ - BLUE*16+YELLOW, /* C_PROMPT_HI prompt/choice hdg/cur/... */ - GREEN*16+L_WHITE, /* C_PROMPT_INPUT fullscreen_prompt input */ - CYAN*16+L_WHITE, /* C_PROMPT_CHOOSE fullscreen_prompt choice */ - MAGENTA*16+L_WHITE, /* C_CHOICE_CURRENT fullscreen_choice input */ - BLACK*16+WHITE, /* C_CHOICE_SP_INSTR speed key bar & instr */ - BLACK*16+L_MAGENTA, /* C_CHOICE_SP_KEYIN speed key value */ - WHITE*16+BLUE, /* C_GENERAL_HI tab, thinking, IFS */ - WHITE*16+BLACK, /* C_GENERAL_MED */ - WHITE*16+GRAY, /* C_GENERAL_LO */ - BLACK*16+L_WHITE, /* C_GENERAL_INPUT */ - WHITE*16+BLACK, /* C_DVID_BKGRD disk video */ - BLACK*16+YELLOW, /* C_DVID_HI */ - BLACK*16+L_WHITE, /* C_DVID_LO */ - RED*16+L_WHITE, /* C_STOP_ERR stop message, error */ - GREEN*16+BLACK, /* C_STOP_INFO stop message, info */ - BLUE*16+WHITE, /* C_TITLE_LOW bottom lines of title screen */ - GREEN*16+BLACK, /* C_AUTHDIV1 title screen dividers */ - GREEN*16+GRAY, /* C_AUTHDIV2 title screen dividers */ - BLACK*16+L_WHITE, /* C_PRIMARY primary authors */ - BLACK*16+WHITE /* C_CONTRIB contributing authors */ - }; - -char s_makepar[] = "makepar"; - -int lzw[2]; - -/* - cmdfiles(argc,argv) process the command-line arguments - it also processes the 'sstools.ini' file and any - indirect files ('fractint @myfile') -*/ - -/* This probably ought to go somewhere else, but it's used here. */ -/* getpower10(x) returns the magnitude of x. This rounds */ -/* a little so 9.95 rounds to 10, but we're using a binary base anyway, */ -/* so there's nothing magic about changing to the next power of 10. */ -int getpower10(LDBL x) -{ - char string[11]; /* space for "+x.xe-xxxx" */ - int p; - -#ifdef USE_LONG_DOUBLE - sprintf(string,"%+.1Le", x); -#else - sprintf(string,"%+.1le", x); -#endif - p = atoi(string+5); - return p; -} - - - -int cmdfiles(int argc,char **argv) -{ - int i; - char curarg[141]; - char tempstring[101]; - char *sptr; - FILE *initfile; - - if (first_init) initvars_run(); /* once per run initialization */ - initvars_restart(); /* key initialization */ - initvars_fractal(); /* image initialization */ - - strcpy(curarg, "sstools.ini"); - findpath(curarg, tempstring); /* look for SSTOOLS.INI */ - if (tempstring[0] != 0) /* found it! */ - if ((initfile = fopen(tempstring,"r")) != NULL) - cmdfile(initfile, CMDFILE_SSTOOLS_INI); /* process it */ - - for (i = 1; i < argc; i++) { /* cycle through args */ -#ifdef XFRACT - /* Let the xfract code take a look at the argument */ - if (unixarg(argc,argv,&i)) continue; -#endif - strcpy(curarg,argv[i]); - if (curarg[0] == ';') /* start of comments? */ - break; - if (curarg[0] != '@') { /* simple command? */ - if (strchr(curarg,'=') == NULL) { /* not xxx=yyy, so check for gif */ - strcpy(tempstring,curarg); - if (has_ext(curarg) == NULL) - strcat(tempstring,".gif"); - if ((initfile = fopen(tempstring,"rb")) != NULL) { - fread(tempstring,6,1,initfile); - if ( tempstring[0] == 'G' - && tempstring[1] == 'I' - && tempstring[2] == 'F' - && tempstring[3] >= '8' && tempstring[3] <= '9' - && tempstring[4] >= '0' && tempstring[4] <= '9') { - strcpy(readname,curarg); - extract_filename(browsename,readname); - curarg[0] = (char)(showfile = 0); - } - fclose(initfile); - } - } - if (curarg[0]) - cmdarg(curarg, CMDFILE_AT_CMDLINE); /* process simple command */ - } - else if ((sptr = strchr(curarg,'/')) != NULL) { /* @filename/setname? */ - *sptr = 0; - if (merge_pathnames(CommandFile, &curarg[1], 0) < 0) - init_msg("",CommandFile,0); - strcpy(CommandName,sptr+1); - if (find_file_item(CommandFile,CommandName,&initfile, 0)<0 || initfile==NULL) - argerror(curarg); - cmdfile(initfile, CMDFILE_AT_CMDLINE_SETNAME); - } - else { /* @filename */ - initfile = fopen(&curarg[1],"r"); - if (initfile == NULL) - argerror(curarg); - cmdfile(initfile, CMDFILE_AT_CMDLINE); - } - } - - if (first_init == 0) { - g_init_mode = -1; /* don't set video when key used */ - showfile = 1; /* nor startup image file */ - } - - init_msg("",NULL,0); /* this causes driver_get_key if init_msg called on runup */ - - if (debugflag != 110) - first_init = 0; -/* { - char msg[MSGLEN]; - sprintf(msg,"cmdfiles colorpreloaded %d showfile %d savedac %d", - colorpreloaded, showfile, savedac); - stopmsg(0,msg); - } -*/ - if (colorpreloaded && showfile==0) /* PAR reads a file and sets color */ - dontreadcolor = 1; /* don't read colors from GIF */ - else - dontreadcolor = 0; /* read colors from GIF */ - - /*set structure of search directories*/ - strcpy(searchfor.par, CommandFile); - strcpy(searchfor.frm, FormFileName); - strcpy(searchfor.lsys, LFileName); - strcpy(searchfor.ifs, IFSFileName); - return 0; -} - - -int load_commands(FILE *infile) -{ - /* when called, file is open in binary mode, positioned at the */ - /* '(' or '{' following the desired parameter set's name */ - int ret; - initcorners = initparams = 0; /* reset flags for type= */ - ret = cmdfile(infile, CMDFILE_AT_AFTER_STARTUP); -/* - { - char msg[MSGLEN]; - sprintf(msg,"load commands colorpreloaded %d showfile %d savedac %d", - colorpreloaded, showfile, savedac); - stopmsg(0,msg); - } -*/ - - if (colorpreloaded && showfile==0) /* PAR reads a file and sets color */ - dontreadcolor = 1; /* don't read colors from GIF */ - else - dontreadcolor = 0; /* read colors from GIF */ - return ret; -} - - -static void initvars_run() /* once per run init */ -{ - char *p; - init_rseed = (int)time(NULL); - init_comments(); - p = getenv("TMP"); - if (p == NULL) - p = getenv("TEMP"); - if (p != NULL) - { - if (isadirectory(p) != 0) - { - strcpy(tempdir,p); - fix_dirname(tempdir); - } - } - else - *tempdir = 0; -} - -static void initvars_restart() /* key init */ -{ - int i; - recordcolors = 'a'; /* don't use mapfiles in PARs */ - save_release = g_release; /* this release number */ - gif87a_flag = INIT_GIF87; /* turn on GIF89a processing */ - dither_flag = 0; /* no dithering */ - askvideo = 1; /* turn on video-prompt flag */ - fract_overwrite = 0; /* don't overwrite */ - soundflag = SOUNDFLAG_SPEAKER | SOUNDFLAG_BEEP; /* sound is on to PC speaker */ - initbatch = 0; /* not in batch mode */ - checkcurdir = 0; /* flag to check current dire for files */ - initsavetime = 0; /* no auto-save */ - g_init_mode = -1; /* no initial video mode */ - viewwindow = 0; /* no view window */ - viewreduction = (float)4.2; - viewcrop = 1; - g_virtual_screens = 1; /* virtual screen modes on */ - finalaspectratio = screenaspect; - viewxdots = viewydots = 0; - video_cutboth = 1; /* keep virtual aspect */ - zscroll = 1; /* relaxed screen scrolling */ - orbit_delay = 0; /* full speed orbits */ - orbit_interval = 1; /* plot all orbits */ - debugflag = 0; /* debugging flag(s) are off */ - timerflag = 0; /* timer flags are off */ - strcpy(FormFileName, "fractint.frm"); /* default formula file */ - FormName[0] = 0; - strcpy(LFileName, "fractint.l"); - LName[0] = 0; - strcpy(CommandFile, "fractint.par"); - CommandName[0] = 0; - for (i=0; i<4; i++) - CommandComment[i][0] = 0; - strcpy(IFSFileName, "fractint.ifs"); - IFSName[0] = 0; - reset_ifs_defn(); - rflag = 0; /* not a fixed srand() seed */ - rseed = init_rseed; - strcpy(readname,DOTSLASH); /* initially current directory */ - showfile = 1; - /* next should perhaps be fractal re-init, not just ? */ - initcyclelimit=55; /* spin-DAC default speed limit */ - mapset = 0; /* no map= name active */ - if (mapdacbox) { - free(mapdacbox); - mapdacbox = NULL; - } - - major_method = breadth_first; /* default inverse julia methods */ - minor_method = left_first; /* default inverse julia methods */ - truecolor = 0; /* truecolor output flag */ - truemode = 0; /* set to default color scheme */ -} - -static void initvars_fractal() /* init vars affecting calculation */ -{ - int i; - escape_exit = 0; /* don't disable the "are you sure?" screen */ - usr_periodicitycheck = 1; /* turn on periodicity */ - inside = 1; /* inside color = blue */ - fillcolor = -1; /* no special fill color */ - usr_biomorph = -1; /* turn off biomorph flag */ - outside = -1; /* outside color = -1 (not used) */ - maxit = 150; /* initial maxiter */ - usr_stdcalcmode = 'g'; /* initial solid-guessing */ - stoppass = 0; /* initial guessing stoppass */ - quick_calc = 0; - closeprox = 0.01; - ismand = 1; /* default formula mand/jul toggle */ -#ifndef XFRACT - usr_floatflag = 0; /* turn off the float flag */ -#else - usr_floatflag = 1; /* turn on the float flag */ -#endif - finattract = 0; /* disable finite attractor logic */ - fractype = 0; /* initial type Set flag */ - curfractalspecific = &fractalspecific[0]; - initcorners = initparams = 0; - bailout = 0; /* no user-entered bailout */ - nobof = 0; /* use normal bof initialization to make bof images */ - useinitorbit = 0; - for (i = 0; i < MAXPARAMS; i++) param[i] = 0.0; /* initial parameter values */ - for (i = 0; i < 3; i++) potparam[i] = 0.0; /* initial potential values */ - for (i = 0; i < 3; i++) inversion[i] = 0.0; /* initial invert values */ - initorbit.x = initorbit.y = 0.0; /* initial orbit values */ - invert = 0; - decomp[0] = decomp[1] = 0; - usr_distest = 0; - pseudox = 0; - pseudoy = 0; - distestwidth = 71; - forcesymmetry = 999; /* symmetry not forced */ - xx3rd = xxmin = -2.5; xxmax = 1.5; /* initial corner values */ - yy3rd = yymin = -1.5; yymax = 1.5; /* initial corner values */ - bf_math = 0; - pot16bit = potflag = 0; - LogFlag = 0; /* no logarithmic palette */ - set_trig_array(0, "sin"); /* trigfn defaults */ - set_trig_array(1, "sqr"); - set_trig_array(2, "sinh"); - set_trig_array(3, "cosh"); - if (rangeslen) { - free((char *)ranges); - rangeslen = 0; - } - usemag = 1; /* use center-mag, not corners */ - - colorstate = colorpreloaded = 0; - rotate_lo = 1; rotate_hi = 255; /* color cycling default range */ - orbit_delay = 0; /* full speed orbits */ - orbit_interval = 1; /* plot all orbits */ - keep_scrn_coords = 0; - drawmode = 'r'; /* passes=orbits draw mode */ - set_orbit_corners = 0; - oxmin = curfractalspecific->xmin; - oxmax = curfractalspecific->xmax; - ox3rd = curfractalspecific->xmin; - oymin = curfractalspecific->ymin; - oymax = curfractalspecific->ymax; - oy3rd = curfractalspecific->ymin; - - math_tol[0] = 0.05; - math_tol[1] = 0.05; - - display3d = 0; /* 3D display is off */ - overlay3d = 0; /* 3D overlay is off */ - - old_demm_colors = 0; - bailoutest = Mod; - floatbailout = (int ( *)(void))fpMODbailout; - longbailout = (int ( *)(void))asmlMODbailout; - bignumbailout = (int ( *)(void))bnMODbailout; - bigfltbailout = (int ( *)(void))bfMODbailout; - - functionpreloaded = 0; /* for old bifs JCO 7/5/92 */ - mxminfp = -.83; - myminfp = -.25; - mxmaxfp = -.83; - mymaxfp = .25; - originfp = 8; - heightfp = 7; - widthfp = 10; - distfp = 24; - eyesfp = (float)2.5; - depthfp = 8; - neworbittype = JULIA; - zdots = 128; - initvars_3d(); - basehertz = 440; /* basic hertz rate */ -#ifndef XFRACT - fm_vol = 63; /* full volume on soundcard o/p */ - hi_atten = 0; /* no attenuation of hi notes */ - fm_attack = 5; /* fast attack */ - fm_decay = 10; /* long decay */ - fm_sustain = 13; /* fairly high sustain level */ - fm_release = 5; /* short release */ - fm_wavetype = 0; /* sin wave */ - polyphony = 0; /* no polyphony */ - for (i=0; i<=11; i++) scale_map[i]=i+1; /* straight mapping of notes in octave */ -#endif -} - -static void initvars_3d() /* init vars affecting 3d */ -{ - RAY = 0; - BRIEF = 0; - SPHERE = FALSE; - preview = 0; - showbox = 0; - xadjust = 0; - yadjust = 0; - g_eye_separation = 0; - g_glasses_type = 0; - previewfactor = 20; - red_crop_left = 4; - red_crop_right = 0; - blue_crop_left = 0; - blue_crop_right = 4; - red_bright = 80; - blue_bright = 100; - transparent[0] = transparent[1] = 0; /* no min/max transparency */ - set_3d_defaults(); -} - -static void reset_ifs_defn() -{ - if (ifs_defn) { - free((char *)ifs_defn); - ifs_defn = NULL; - } -} - - -static int cmdfile(FILE *handle,int mode) - /* mode = 0 command line @filename */ - /* 1 sstools.ini */ - /* 2 <@> command after startup */ - /* 3 command line @filename/setname */ -{ - /* note that cmdfile could be open as text OR as binary */ - /* binary is used in @ command processing for reasonable speed note/point */ - int i; - int lineoffset = 0; - int changeflag = 0; /* &1 fractal stuff chgd, &2 3d stuff chgd */ - char linebuf[513]; - char cmdbuf[10000] = { 0 }; - - if (mode == CMDFILE_AT_AFTER_STARTUP || mode == CMDFILE_AT_CMDLINE_SETNAME) { - while ((i = getc(handle)) != '{' && i != EOF) { } - for (i=0; i<4; i++) - CommandComment[i][0] = 0; - } - linebuf[0] = 0; - while (next_command(cmdbuf,10000,handle,linebuf,&lineoffset,mode) > 0) { - if ((mode == CMDFILE_AT_AFTER_STARTUP || mode == CMDFILE_AT_CMDLINE_SETNAME) && strcmp(cmdbuf,"}") == 0) break; - if ((i = cmdarg(cmdbuf,mode)) < 0) break; - changeflag |= i; - } - fclose(handle); -#ifdef XFRACT - g_init_mode = 0; /* Skip credits if @file is used. */ -#endif - if (changeflag & CMDARG_FRACTAL_PARAM) - { - backwards_v18(); - backwards_v19(); - backwards_v20(); - } - return changeflag; -} - -static int next_command(char *cmdbuf,int maxlen, - FILE *handle,char *linebuf,int *lineoffset,int mode) -{ - int i; - int cmdlen = 0; - char *lineptr; - lineptr = linebuf + *lineoffset; - while (1) { - while (*lineptr <= ' ' || *lineptr == ';') { - if (cmdlen) { /* space or ; marks end of command */ - cmdbuf[cmdlen] = 0; - *lineoffset = (int) (lineptr - linebuf); - return cmdlen; - } - while (*lineptr && *lineptr <= ' ') - ++lineptr; /* skip spaces and tabs */ - if (*lineptr == ';' || *lineptr == 0) { - if (*lineptr == ';' - && (mode == CMDFILE_AT_AFTER_STARTUP || mode == CMDFILE_AT_CMDLINE_SETNAME) - && (CommandComment[0][0] == 0 || CommandComment[1][0] == 0 || - CommandComment[2][0] == 0 || CommandComment[3][0] == 0)) { - /* save comment */ - while (*(++lineptr) - && (*lineptr == ' ' || *lineptr == '\t')) { } - if (*lineptr) { - if ((int)strlen(lineptr) >= MAXCMT) - *(lineptr+MAXCMT-1) = 0; - for (i=0; i<4; i++) - if (CommandComment[i][0] == 0) - { - strcpy(CommandComment[i],lineptr); - break; - } - } - } - if (next_line(handle,linebuf,mode) != 0) - return -1; /* eof */ - lineptr = linebuf; /* start new line */ - } - } - if (*lineptr == '\\' /* continuation onto next line? */ - && *(lineptr+1) == 0) { - if (next_line(handle,linebuf,mode) != 0) { - argerror(cmdbuf); /* missing continuation */ - return -1; - } - lineptr = linebuf; - while (*lineptr && *lineptr <= ' ') - ++lineptr; /* skip white space @ start next line */ - continue; /* loop to check end of line again */ - } - cmdbuf[cmdlen] = *(lineptr++); /* copy character to command buffer */ - if (++cmdlen >= maxlen) { /* command too long? */ - argerror(cmdbuf); - return -1; - } - } -} - -static int next_line(FILE *handle,char *linebuf,int mode) -{ - int toolssection; - char tmpbuf[11]; - toolssection = 0; - while (file_gets(linebuf,512,handle) >= 0) { - if (mode == CMDFILE_SSTOOLS_INI && linebuf[0] == '[') { /* check for [fractint] */ -#ifndef XFRACT - strncpy(tmpbuf,&linebuf[1],9); - tmpbuf[9] = 0; - strlwr(tmpbuf); - toolssection = strncmp(tmpbuf,"fractint]",9); -#else - strncpy(tmpbuf,&linebuf[1],10); - tmpbuf[10] = 0; - strlwr(tmpbuf); - toolssection = strncmp(tmpbuf,"xfractint]",10); -#endif - continue; /* skip tools section heading */ - } - if (toolssection == 0) return 0; - } - return -1; -} - -/* - cmdarg(string,mode) processes a single command-line/command-file argument - return: - -1 error, >= 0 ok - if ok, return value: - | 1 means fractal parm has been set - | 2 means 3d parm has been set - | 4 means 3d=yes specified - | 8 means reset specified -*/ - -#define NONNUMERIC -32767 - -int cmdarg(char *curarg, int mode) /* process a single argument */ -{ - char variable[21]; /* variable name goes here */ - char *value; /* pointer to variable value */ - int valuelen; /* length of value */ - int numval; /* numeric value of arg */ - char charval[16]; /* first character of arg */ - int yesnoval[16]; /* 0 if 'n', 1 if 'y', -1 if not */ - double ftemp; - int i, j, k; - char *argptr,*argptr2; - int totparms; /* # of / delimited parms */ - int intparms; /* # of / delimited ints */ - int floatparms; /* # of / delimited floats */ - int intval[64]; /* pre-parsed integer parms */ - double floatval[16]; /* pre-parsed floating parms */ - char *floatvalstr[16]; /* pointers to float vals */ - char tmpc; - int lastarg; - double Xctr, Yctr, Xmagfactor, Rotation, Skew; - LDBL Magnification; - bf_t bXctr, bYctr; - - - argptr = curarg; - while (*argptr) - { /* convert to lower case */ - if (*argptr >= 'A' && *argptr <= 'Z') - { - *argptr += 'a' - 'A'; - } - else if (*argptr == '=') - { - /* don't convert colors=value or comment=value */ - if ((strncmp(curarg, "colors=", 7) == 0) || (strncmp(curarg, "comment", 7) == 0)) - { - break; - } - } - ++argptr; - } - - value = strchr(&curarg[1], '='); - if (value != NULL) - { - j = (int) ((value++) - curarg); - if (j > 1 && curarg[j-1] == ':') - { - --j; /* treat := same as = */ - } - } - else - { - j = (int) strlen(curarg); - value = curarg + j; - } - if (j > 20) - { - goto badarg; /* keyword too long */ - } - strncpy(variable, curarg, j); /* get the variable name */ - variable[j] = 0; /* truncate variable name */ - valuelen = (int) strlen(value); /* note value's length */ - charval[0] = value[0]; /* first letter of value */ - yesnoval[0] = -1; /* note yes|no value */ - if (charval[0] == 'n') - { - yesnoval[0] = 0; - } - if (charval[0] == 'y') - { - yesnoval[0] = 1; - } - - argptr = value; - numval = totparms = intparms = floatparms = 0; - while (*argptr) /* count and pre-parse parms */ - { - long ll; - lastarg = 0; - argptr2 = strchr(argptr,'/'); - if (argptr2 == NULL) /* find next '/' */ - { - argptr2 = argptr + strlen(argptr); - *argptr2 = '/'; - lastarg = 1; - } - if (totparms == 0) - { - numval = NONNUMERIC; - } - i = -1; - if ( totparms < 16) - { - charval[totparms] = *argptr; /* first letter of value */ - if (charval[totparms] == 'n') - { - yesnoval[totparms] = 0; - } - if (charval[totparms] == 'y') - { - yesnoval[totparms] = 1; - } - } - j = 0; - if (sscanf(argptr, "%c%c", (char *) &j, &tmpc) > 0 /* NULL entry */ - && ((char) j == '/' || (char) j == '=') && tmpc == '/') - { - j = 0; - ++floatparms; - ++intparms; - if (totparms < 16) - { - floatval[totparms] = j; - floatvalstr[totparms] = "0"; - } - if (totparms < 64) - { - intval[totparms] = j; - } - if (totparms == 0) - { - numval = j; - } - } - else if (sscanf(argptr, "%ld%c", &ll, &tmpc) > 0 /* got an integer */ - && tmpc == '/') /* needs a long int, ll, here for lyapunov */ - { - ++floatparms; - ++intparms; - if (totparms < 16) - { - floatval[totparms] = ll; - floatvalstr[totparms] = argptr; - } - if (totparms < 64) - { - intval[totparms] = (int) ll; - } - if (totparms == 0) - { - numval = (int) ll; - } - } -#ifndef XFRACT - else if (sscanf(argptr, "%lg%c", &ftemp, &tmpc) > 0 /* got a float */ -#else - else if (sscanf(argptr, "%lf%c", &ftemp, &tmpc) > 0 /* got a float */ -#endif - && tmpc == '/') - { - ++floatparms; - if (totparms < 16) - { - floatval[totparms] = ftemp; - floatvalstr[totparms] = argptr; - } - } - /* using arbitrary precision and above failed */ - else if (((int) strlen(argptr) > 513) /* very long command */ - || (totparms > 0 && floatval[totparms-1] == FLT_MAX - && totparms < 6) - || isabigfloat(argptr)) - { - ++floatparms; - floatval[totparms] = FLT_MAX; - floatvalstr[totparms] = argptr; - } - ++totparms; - argptr = argptr2; /* on to the next */ - if (lastarg) - { - *argptr = 0; - } - else - { - ++argptr; - } - } - - if (mode != CMDFILE_AT_AFTER_STARTUP || debugflag == 110) - { - /* these commands are allowed only at startup */ - if (strcmp(variable, "batch") == 0) /* batch=? */ - { - if (yesnoval[0] < 0) - { - goto badarg; - } -#ifdef XFRACT - g_init_mode = yesnoval[0] ? 0 : -1; /* skip credits for batch mode */ -#endif - initbatch = yesnoval[0]; - return 3; - } - if (strcmp(variable, "maxhistory") == 0) /* maxhistory=? */ - { - if (numval == NONNUMERIC) - { - goto badarg; - } - else if (numval < 0 /* || numval > 1000 */) - { - goto badarg; - } - else - { - maxhistory = numval; - } - return 3; - } - - /* adapter= no longer used */ - if (strcmp(variable, "adapter") == 0) /* adapter==? */ - { - /* adapter parameter no longer used; check for bad argument anyway */ - if ((strcmp(value, "egamono") != 0) && (strcmp(value, "hgc") != 0) && - (strcmp(value, "ega") != 0) && (strcmp(value, "cga") != 0) && - (strcmp(value, "mcga") != 0) && (strcmp(value, "vga") != 0)) - { - goto badarg; - } - return 3; - } - - /* 8514 API no longer used; silently gobble any argument */ - if (strcmp(variable, "afi") == 0) - { - return 3; - } - - if (strcmp(variable,"textsafe") == 0 ) /* textsafe==? */ - { - /* textsafe no longer used, do validity checking, but gobble argument */ - if (first_init) - { - if (!((charval[0] == 'n') /* no */ - || (charval[0] == 'y') /* yes */ - || (charval[0] == 'b') /* bios */ - || (charval[0] == 's'))) /* save */ - { - goto badarg; - } - } - return 3; - } - - if (strcmp(variable, "vesadetect") == 0) - { - /* vesadetect no longer used, do validity checks, but gobble argument */ - if (yesnoval[0] < 0) - { - goto badarg; - } - return 3; - } - - /* biospalette no longer used, do validity checks, but gobble argument */ - if (strcmp(variable, "biospalette") == 0) - { - if (yesnoval[0] < 0) - { - goto badarg; - } - return 3; - } - - if (strcmp(variable, "fpu") == 0) - { - if (strcmp(value, "387") == 0) - { -#ifndef XFRACT - fpu = 387; -#else - fpu = -1; -#endif - return 0; - } - goto badarg; - } - - if (strcmp(variable, "exitnoask") == 0) - { - if (yesnoval[0] < 0) - { - goto badarg; - } - escape_exit = yesnoval[0]; - return 3; - } - - if (strcmp(variable, "makedoc") == 0) - { - print_document(*value ? value : "fractint.doc", makedoc_msg_func, 0); -#ifndef WINFRACT - goodbye(); -#endif - } - - if (strcmp(variable,s_makepar) == 0) - { - char *slash, *next = NULL; - if (totparms < 1 || totparms > 2) - { - goto badarg; - } - slash = strchr(value, '/'); - if (slash != NULL) - { - *slash = 0; - next = slash+1; - } - - strcpy(CommandFile, value); - if (strchr(CommandFile, '.') == NULL) - { - strcat(CommandFile, ".par"); - } - if (strcmp(readname, DOTSLASH)==0) - { - *readname = 0; - } - if (next == NULL) - { - if (*readname != 0) - { - extract_filename(CommandName, readname); - } - else if (*MAP_name != 0) - { - extract_filename(CommandName, MAP_name); - } - else - { - goto badarg; - } - } - else - { - strncpy(CommandName, next, ITEMNAMELEN); - CommandName[ITEMNAMELEN] = 0; - } - *s_makepar = 0; /* used as a flag for makepar case */ - if (*readname != 0) - { - if (read_overlay() != 0) - { - goodbye(); - } - } - else if (*MAP_name != 0) - { - s_makepar[1] = 0; /* second char is flag for map */ - } - xdots = filexdots; - ydots = fileydots; - dxsize = xdots - 1; - dysize = ydots - 1; - calcfracinit(); - make_batch_file(); -#ifndef WINFRACT -#if !defined(XFRACT) -#if defined(_WIN32) - ABORT(0, "Don't call standard I/O without a console on Windows"); - _ASSERTE(0 && "Don't call standard I/O without a console on Windows"); -#else - if (*readname != 0) - { - printf("copying fractal info in GIF %s to PAR %s/%s\n", - readname, CommandFile, CommandName); - } - else if (*MAP_name != 0) - { - printf("copying color info in map %s to PAR %s/%s\n", - MAP_name, CommandFile, CommandName); - } -#endif -#endif - goodbye(); -#endif - } - } /* end of commands allowed only at startup */ - - if (strcmp(variable, "reset") == 0) - { - initvars_fractal(); - - /* PAR release unknown unless specified */ - if (numval >= 0) - { - save_release = numval; - } - else - { - goto badarg; - } - if (save_release == 0) - { - save_release = 1730; /* before start of lyapunov wierdness */ - } - return 9; - } - - if (strcmp(variable, "filename") == 0) /* filename=? */ - { - int existdir; - if (charval[0] == '.' && value[1] != SLASHC) - { - if (valuelen > 4) - { - goto badarg; - } - gifmask[0] = '*'; - gifmask[1] = 0; - strcat(gifmask, value); - return 0; - } - if (valuelen > (FILE_MAX_PATH-1)) - { - goto badarg; - } - if (mode == CMDFILE_AT_AFTER_STARTUP && display3d == 0) /* can't do this in @ command */ - { - goto badarg; - } - - existdir = merge_pathnames(readname, value, mode); - if (existdir == 0) - { - showfile = 0; - } - else if (existdir < 0) - { - init_msg(variable, value, mode); - } - else - { - extract_filename(browsename, readname); - } - return 3; - } - - if (strcmp(variable, "video") == 0) /* video=? */ - { - k = check_vidmode_keyname(value); - if (k == 0) - { - goto badarg; - } - g_init_mode = -1; - for (i = 0; i < MAXVIDEOMODES; ++i) - { - if (g_video_table[i].keynum == k) - { - g_init_mode = i; - break; - } - } - if (g_init_mode == -1) - { - goto badarg; - } - return 3; - } - - if (strcmp(variable, "map") == 0) /* map=, set default colors */ - { - int existdir; - if (valuelen > (FILE_MAX_PATH-1)) - { - goto badarg; - } - existdir = merge_pathnames(MAP_name, value, mode); - if (existdir > 0) - { - return 0; /* got a directory */ - } - else if (existdir < 0) - { - init_msg(variable, value, mode); - return 0; - } - SetColorPaletteName(MAP_name); - return 0; - } - - if (strcmp(variable, "colors") == 0) /* colors=, set current colors */ - { - if (parse_colors(value) < 0) - { - goto badarg; - } - return 0; - } - - if (strcmp(variable, "recordcolors") == 0) /* recordcolors= */ - { - if (*value != 'y' && *value != 'c' && *value != 'a') - { - goto badarg; - } - recordcolors = *value; - return 0; - } - - if (strcmp(variable, "maxlinelength") == 0) /* maxlinelength= */ - { - if (numval < MINMAXLINELENGTH || numval > MAXMAXLINELENGTH) - { - goto badarg; - } - maxlinelength = numval; - return 0; - } - - if (strcmp(variable, "comment") == 0) /* comment= */ - { - parse_comments(value); - return 0; - } - - /* tplus no longer used, validate value and gobble argument */ - if (strcmp(variable, "tplus") == 0) - { - if (yesnoval[0] < 0) - { - goto badarg; - } - return 0; - } - - /* noninterlaced no longer used, validate value and gobble argument */ - if (strcmp(variable, "noninterlaced") == 0) - { - if (yesnoval[0] < 0) - { - goto badarg; - } - return 0; - } - - /* maxcolorres no longer used, validate value and gobble argument */ - if (strcmp(variable, "maxcolorres") == 0) /* Change default color resolution */ - { - if (numval == 1 || numval == 4 || numval == 8 || - numval == 16 || numval == 24) - { - return 0; - } - goto badarg; - } - - /* pixelzoom no longer used, validate value and gobble argument */ - if (strcmp(variable, "pixelzoom") == 0) - { - if (numval >= 5) - { - goto badarg; - } - return 0; - } - - /* keep this for backward compatibility */ - if (strcmp(variable, "warn") == 0) /* warn=? */ - { - if (yesnoval[0] < 0) - { - goto badarg; - } - fract_overwrite = (char) (yesnoval[0] ^ 1); - return 0; - } - if (strcmp(variable, "overwrite") == 0) /* overwrite=? */ - { - if (yesnoval[0] < 0) - { - goto badarg; - } - fract_overwrite = (char) yesnoval[0]; - return 0; - } - - if (strcmp(variable, "gif87a") == 0) /* gif87a=? */ - { - if (yesnoval[0] < 0) - { - goto badarg; - } - gif87a_flag = yesnoval[0]; - return 0; - } - - if (strcmp(variable, "dither") == 0) /* dither=? */ - { - if (yesnoval[0] < 0) - { - goto badarg; - } - dither_flag = yesnoval[0]; - return 0; - } - - if (strcmp(variable, "savetime") == 0) /* savetime=? */ - { - initsavetime = numval; - return 0; - } - - if (strcmp(variable, "autokey") == 0) /* autokey=? */ - { - if (strcmp(value, "record") == 0) - { - g_slides = SLIDES_RECORD; - } - else if (strcmp(value, "play") == 0) - { - g_slides = SLIDES_PLAY; - } - else - { - goto badarg; - } - return 0; - } - - if (strcmp(variable, "autokeyname") == 0) /* autokeyname=? */ - { - if (merge_pathnames(autoname, value, mode) < 0) - { - init_msg(variable, value, mode); - } - return 0; - } - - if (strcmp(variable, "type") == 0) /* type=? */ - { - if (value[valuelen-1] == '*') - { - value[--valuelen] = 0; - } - /* kludge because type ifs3d has an asterisk in front */ - if (strcmp(value, "ifs3d") == 0) - { - value[3] = 0; - } - for (k = 0; fractalspecific[k].name != NULL; k++) - { - if (strcmp(value, fractalspecific[k].name) == 0) - { - break; - } - } - if (fractalspecific[k].name == NULL) - { - goto badarg; - } - fractype = k; - curfractalspecific = &fractalspecific[fractype]; - if (initcorners == 0) - { - xx3rd = xxmin = curfractalspecific->xmin; - xxmax = curfractalspecific->xmax; - yy3rd = yymin = curfractalspecific->ymin; - yymax = curfractalspecific->ymax; - } - if (initparams == 0) - { - load_params(fractype); - } - return 1; - } - - if (strcmp(variable, "inside") == 0) /* inside=? */ - { - struct - { - const char *arg; - int inside; - } args[] = - { - { "zmag", ZMAG }, - { "bof60", BOF60 }, - { "bof61", BOF61 }, - { "epsiloncross", EPSCROSS }, - { "startrail", STARTRAIL }, - { "period", PERIOD }, - { "fmod", FMODI }, - { "atan", ATANI }, - { "maxiter", -1 } - }; - int ii; - for (ii = 0; ii < NUM_OF(args); ii++) - { - if (strcmp(value, args[ii].arg) == 0) - { - inside = args[ii].inside; - return 1; - } - } - if (numval == NONNUMERIC) - { - goto badarg; - } - else - { - inside = numval; - } - return 1; - } - - if (strcmp(variable, "proximity") == 0) /* proximity=? */ - { - closeprox = floatval[0]; - return 1; - } - - if (strcmp(variable, "fillcolor") == 0) /* fillcolor */ - { - if (strcmp(value, "normal")==0) - { - fillcolor = -1; - } - else if (numval == NONNUMERIC) - { - goto badarg; - } - else - { - fillcolor = numval; - } - return 1; - } - - if (strcmp(variable, "finattract") == 0) /* finattract=? */ - { - if (yesnoval[0] < 0) - { - goto badarg; - } - finattract = yesnoval[0]; - return 1; - } - - if (strcmp(variable, "nobof") == 0) /* nobof=? */ - { - if (yesnoval[0] < 0) - { - goto badarg; - } - nobof = yesnoval[0]; - return 1; - } - - if (strcmp(variable, "function") == 0) /* function=?,? */ - { - k = 0; - while (*value && k < 4) - { - if (set_trig_array(k++, value)) - { - goto badarg; - } - value = strchr(value, '/'); - if (value == NULL) - { - break; - } - ++value; - } - functionpreloaded = 1; /* for old bifs JCO 7/5/92 */ - return 1; - } - - if (strcmp(variable, "outside") == 0) /* outside=? */ - { - int ii; - struct - { - const char *arg; - int outside; - } - args[] = - { - { "iter", ITER }, - { "real", REAL }, - { "imag", IMAG }, - { "mult", MULT }, - { "summ", SUM }, - { "atan", ATAN }, - { "fmod", FMOD }, - { "tdis", TDIS } - }; - for (ii = 0; ii < NUM_OF(args); ii++) - { - if (strcmp(value, args[ii].arg) == 0) - { - outside = args[ii].outside; - return 1; - } - } - if ((numval == NONNUMERIC) || (numval < TDIS || numval > 255)) - { - goto badarg; - } - outside = numval; - return 1; - } - - if (strcmp(variable, "bfdigits") == 0) /* bfdigits=? */ - { - if ((numval == NONNUMERIC) || (numval < 0 || numval > 2000)) - { - goto badarg; - } - bfdigits = numval; - return 1; - } - - if (strcmp(variable, "maxiter") == 0) /* maxiter=? */ - { - if (floatval[0] < 2) - { - goto badarg; - } - maxit = (long) floatval[0]; - return 1; - } - - if (strcmp(variable, "iterincr") == 0) /* iterincr=? */ - { - return 0; - } - - if (strcmp(variable, "passes") == 0) /* passes=? */ - { - if (charval[0] != '1' && charval[0] != '2' && charval[0] != '3' - && charval[0] != 'g' && charval[0] != 'b' - && charval[0] != 't' && charval[0] != 's' - && charval[0] != 'd' && charval[0] != 'o') - { - goto badarg; - } - usr_stdcalcmode = charval[0]; - if (charval[0] == 'g') - { - stoppass = ((int)value[1] - (int)'0'); - if (stoppass < 0 || stoppass > 6) - { - stoppass = 0; - } - } - return 1; - } - - if (strcmp(variable, "ismand") == 0) /* ismand=? */ - { - if (yesnoval[0] < 0) - { - goto badarg; - } - ismand = (short int)yesnoval[0]; - return 1; - } - - if (strcmp(variable, "cyclelimit") == 0) /* cyclelimit=? */ - { - if (numval <= 1 || numval > 256) - { - goto badarg; - } - initcyclelimit = numval; - return 0; - } - - if (strcmp(variable, "makemig") == 0) - { - int xmult, ymult; - if (totparms < 2) - { - goto badarg; - } - xmult = intval[0]; - ymult = intval[1]; - make_mig(xmult, ymult); -#ifndef WINFRACT - exit(0); -#endif - } - - if (strcmp(variable, "cyclerange") == 0) - { - if (totparms < 2) - { - intval[1] = 255; - } - if (totparms < 1) - { - intval[0] = 1; - } - if (totparms != intparms - || intval[0] < 0 || intval[1] > 255 || intval[0] > intval[1]) - { - goto badarg; - } - rotate_lo = intval[0]; - rotate_hi = intval[1]; - return 0; - } - - if (strcmp(variable, "ranges") == 0) - { - int i, j, entries, prev; - int tmpranges[128]; - - if (totparms != intparms) - { - goto badarg; - } - entries = prev = i = 0; - LogFlag = 0; /* ranges overrides logmap */ - while (i < totparms) - { - if ((j = intval[i++]) < 0) /* striping */ - { - if ((j = 0-j) < 1 || j >= 16384 || i >= totparms) - { - goto badarg; - } - tmpranges[entries++] = -1; /* {-1,width,limit} for striping */ - tmpranges[entries++] = j; - j = intval[i++]; - } - if (j < prev) - { - goto badarg; - } - tmpranges[entries++] = prev = j; - } - if (prev == 0) - { - goto badarg; - } - ranges = (int *)malloc(sizeof(int)*entries); - if (ranges == NULL) - { - stopmsg(STOPMSG_NO_STACK, "Insufficient memory for ranges="); - return -1; - } - rangeslen = entries; - for (i = 0; i < rangeslen; ++i) - { - ranges[i] = tmpranges[i]; - } - return 1; - } - - if (strcmp(variable, "savename") == 0) /* savename=? */ - { - if (valuelen > (FILE_MAX_PATH-1)) - { - goto badarg; - } - if (first_init || mode == CMDFILE_AT_AFTER_STARTUP) - { - if (merge_pathnames(savename, value, mode) < 0) - { - init_msg(variable, value, mode); - } - } - return 0; - } - - if (strcmp(variable, "tweaklzw") == 0) /* tweaklzw=? */ - { - if (totparms >= 1) - { - lzw[0] = intval[0]; - } - if (totparms >= 2) - { - lzw[1] = intval[1]; - } - return 0; - } - - if (strcmp(variable, "minstack") == 0) /* minstack=? */ - { - if (totparms != 1) - { - goto badarg; - } - minstack = intval[0]; - return 0; - } - - if (strcmp(variable, "mathtolerance") == 0) /* mathtolerance=? */ - { - if (charval[0] == '/') - { - ; /* leave math_tol[0] at the default value */ - } - else if (totparms >= 1) - { - math_tol[0] = floatval[0]; - } - if (totparms >= 2) - { - math_tol[1] = floatval[1]; - } - return 0; - } - - if (strcmp(variable, "tempdir") == 0) /* tempdir=? */ - { - if (valuelen > (FILE_MAX_DIR-1)) - { - goto badarg; - } - if (isadirectory(value) == 0) - { - goto badarg; - } - strcpy(tempdir, value); - fix_dirname(tempdir); - return 0; - } - - if (strcmp(variable, "workdir") == 0) /* workdir=? */ - { - if (valuelen > (FILE_MAX_DIR-1)) - { - goto badarg; - } - if (isadirectory(value) == 0) - { - goto badarg; - } - strcpy(workdir, value); - fix_dirname(workdir); - return 0; - } - - if (strcmp(variable, "exitmode") == 0) /* exitmode=? */ - { - sscanf(value, "%x", &numval); - exitmode = (BYTE)numval; - return 0; - } - - if (strcmp(variable, "textcolors") == 0) - { - parse_textcolors(value); - return 0; - } - - if (strcmp(variable, "potential") == 0) /* potential=? */ - { - k = 0; - while (k < 3 && *value) - { - if (k==1) - { - potparam[k] = atof(value); - } - else - { - potparam[k] = atoi(value); - } - k++; - value = strchr(value, '/'); - if (value == NULL) - { - k = 99; - } - ++value; - } - pot16bit = 0; - if (k < 99) - { - if (strcmp(value, "16bit")) - { - goto badarg; - } - pot16bit = 1; - } - return 1; - } - - if (strcmp(variable, "params") == 0) /* params=?,? */ - { - if (totparms != floatparms || totparms > MAXPARAMS) - { - goto badarg; - } - initparams = 1; - for (k = 0; k < MAXPARAMS; ++k) - { - param[k] = (k < totparms) ? floatval[k] : 0.0; - } - if (bf_math) - { - for (k = 0; k < MAXPARAMS; k++) - { - floattobf(bfparms[k], param[k]); - } - } - return 1; - } - - if (strcmp(variable, "miim") == 0) /* miim=?[/?[/?[/?]]] */ - { - if (totparms > 6) - { - goto badarg; - } - if (charval[0] == 'b') - { - major_method = breadth_first; - } - else if (charval[0] == 'd') - { - major_method = depth_first; - } - else if (charval[0] == 'w') - { - major_method = random_walk; - } -#ifdef RANDOM_RUN - else if (charval[0] == 'r') - { - major_method = random_run; - } -#endif - else - { - goto badarg; - } - - if (charval[1] == 'l') - { - minor_method = left_first; - } - else if (charval[1] == 'r') - { - minor_method = right_first; - } - else - { - goto badarg; - } - - /* keep this next part in for backwards compatibility with old PARs ??? */ - - if (totparms > 2) - { - for (k = 2; k < 6; ++k) - { - param[k-2] = (k < totparms) ? floatval[k] : 0.0; - } - } - - return 1; - } - - if (strcmp(variable, "initorbit") == 0) /* initorbit=?,? */ - { - if (strcmp(value, "pixel")==0) - { - useinitorbit = 2; - } - else - { - if (totparms != 2 || floatparms != 2) - { - goto badarg; - } - initorbit.x = floatval[0]; - initorbit.y = floatval[1]; - useinitorbit = 1; - } - return 1; - } - - if (strcmp(variable, "orbitname") == 0) /* orbitname=? */ - { - if (check_orbit_name(value)) - { - goto badarg; - } - return 1; - } - - if (strcmp(variable, "3dmode") == 0) /* orbitname=? */ - { - int i, j; - j = -1; - for (i = 0; i < 4; i++) - { - if (strcmp(value, juli3Doptions[i]) == 0) - { - j = i; - } - } - if (j < 0) - { - goto badarg; - } - else - { - juli3Dmode = j; - } - return 1; - } - - if (strcmp(variable, "julibrot3d") == 0) /* julibrot3d=?,?,?,? */ - { - if (floatparms != totparms) - { - goto badarg; - } - if (totparms > 0) - { - zdots = (int)floatval[0]; - } - if (totparms > 1) - { - originfp = (float)floatval[1]; - } - if (totparms > 2) - { - depthfp = (float)floatval[2]; - } - if (totparms > 3) - { - heightfp = (float)floatval[3]; - } - if (totparms > 4) - { - widthfp = (float)floatval[4]; - } - if (totparms > 5) - { - distfp = (float)floatval[5]; - } - return 1; - } - - if (strcmp(variable, "julibroteyes") == 0) /* julibroteyes=?,?,?,? */ - { - if (floatparms != totparms || totparms != 1) - { - goto badarg; - } - eyesfp = (float)floatval[0]; - return 1; - } - - if (strcmp(variable, "julibrotfromto") == 0) /* julibrotfromto=?,?,?,? */ - { - if (floatparms != totparms || totparms != 4) - { - goto badarg; - } - mxmaxfp = floatval[0]; - mxminfp = floatval[1]; - mymaxfp = floatval[2]; - myminfp = floatval[3]; - return 1; - } - - if (strcmp(variable, "corners") == 0) /* corners=?,?,?,? */ - { - int dec; - if (fractype == CELLULAR) - { - return 1; /* skip setting the corners */ - } -#if 0 - /* use a debugger and OutputDebugString instead of standard I/O on Windows */ - printf("totparms %d floatparms %d\n", totparms, floatparms); - getch(); -#endif - if (floatparms != totparms - || (totparms != 0 && totparms != 4 && totparms != 6)) - { - goto badarg; - } - usemag = 0; - if (totparms == 0) - { - return 0; /* turns corners mode on */ - } - initcorners = 1; - /* good first approx, but dec could be too big */ - dec = get_max_curarg_len(floatvalstr, totparms) + 1; - if ((dec > DBL_DIG+1 || debugflag == 3200) && debugflag != 3400) - { - int old_bf_math; - - old_bf_math = bf_math; - if (!bf_math || dec > decimals) - { - init_bf_dec(dec); - } - if (old_bf_math == 0) - { - int k; - for (k = 0; k < MAXPARAMS; k++) - { - floattobf(bfparms[k], param[k]); - } - } - - /* xx3rd = xxmin = floatval[0]; */ - get_bf(bfxmin, floatvalstr[0]); - get_bf(bfx3rd, floatvalstr[0]); - - /* xxmax = floatval[1]; */ - get_bf(bfxmax, floatvalstr[1]); - - /* yy3rd = yymin = floatval[2]; */ - get_bf(bfymin, floatvalstr[2]); - get_bf(bfy3rd, floatvalstr[2]); - - /* yymax = floatval[3]; */ - get_bf(bfymax, floatvalstr[3]); - - if (totparms == 6) - { - /* xx3rd = floatval[4]; */ - get_bf(bfx3rd, floatvalstr[4]); - - /* yy3rd = floatval[5]; */ - get_bf(bfy3rd, floatvalstr[5]); - } - - /* now that all the corners have been read in, get a more */ - /* accurate value for dec and do it all again */ - - dec = getprecbf_mag(); - if (dec < 0) - { - goto badarg; /* ie: Magnification is +-1.#INF */ - } - - if (dec > decimals) /* get corners again if need more precision */ - { - init_bf_dec(dec); - - /* now get parameters and corners all over again at new - decimal setting */ - for (k = 0; k < MAXPARAMS; k++) - { - floattobf(bfparms[k], param[k]); - } - - /* xx3rd = xxmin = floatval[0]; */ - get_bf(bfxmin, floatvalstr[0]); - get_bf(bfx3rd, floatvalstr[0]); - - /* xxmax = floatval[1]; */ - get_bf(bfxmax, floatvalstr[1]); - - /* yy3rd = yymin = floatval[2]; */ - get_bf(bfymin, floatvalstr[2]); - get_bf(bfy3rd, floatvalstr[2]); - - /* yymax = floatval[3]; */ - get_bf(bfymax, floatvalstr[3]); - - if (totparms == 6) - { - /* xx3rd = floatval[4]; */ - get_bf(bfx3rd, floatvalstr[4]); - - /* yy3rd = floatval[5]; */ - get_bf(bfy3rd, floatvalstr[5]); - } - } - } - xx3rd = xxmin = floatval[0]; - xxmax = floatval[1]; - yy3rd = yymin = floatval[2]; - yymax = floatval[3]; - - if (totparms == 6) - { - xx3rd = floatval[4]; - yy3rd = floatval[5]; - } - return 1; - } - - if (strcmp(variable, "orbitcorners") == 0) /* orbit corners=?,?,?,? */ - { - set_orbit_corners = 0; - if (floatparms != totparms - || (totparms != 0 && totparms != 4 && totparms != 6)) - { - goto badarg; - } - ox3rd = oxmin = floatval[0]; - oxmax = floatval[1]; - oy3rd = oymin = floatval[2]; - oymax = floatval[3]; - - if (totparms == 6) - { - ox3rd = floatval[4]; - oy3rd = floatval[5]; - } - set_orbit_corners = 1; - keep_scrn_coords = 1; - return 1; - } - - if (strcmp(variable, "screencoords") == 0) /* screencoords=? */ - { - if (yesnoval[0] < 0) - { - goto badarg; - } - keep_scrn_coords = yesnoval[0]; - return 1; - } - - if (strcmp(variable, "orbitdrawmode") == 0) /* orbitdrawmode=? */ - { - if (charval[0] != 'l' && charval[0] != 'r' && charval[0] != 'f') - { - goto badarg; - } - drawmode = charval[0]; - return 1; - } - - if (strcmp(variable, "viewwindows") == 0) { /* viewwindows=?,?,?,?,? */ - if (totparms > 5 || floatparms-intparms > 2 || intparms > 4) - goto badarg; - viewwindow = 1; - viewreduction = 4.2f; /* reset default values */ - finalaspectratio = screenaspect; - viewcrop = 1; /* yes */ - viewxdots = viewydots = 0; - - if ((totparms > 0) && (floatval[0] > 0.001)) - viewreduction = (float)floatval[0]; - if ((totparms > 1) && (floatval[1] > 0.001)) - finalaspectratio = (float)floatval[1]; - if ((totparms > 2) && (yesnoval[2] == 0)) - viewcrop = yesnoval[2]; - if ((totparms > 3) && (intval[3] > 0)) - viewxdots = intval[3]; - if ((totparms == 5) && (intval[4] > 0)) - viewydots = intval[4]; - return 1; - } - - if (strcmp(variable, "center-mag") == 0) { /* center-mag=?,?,?[,?,?,?] */ - int dec; - - if ( (totparms != floatparms) - || (totparms != 0 && totparms < 3) - || (totparms >= 3 && floatval[2] == 0.0)) - goto badarg; - if (fractype == CELLULAR) - return 1; /* skip setting the corners */ - usemag = 1; - if (totparms == 0) return 0; /* turns center-mag mode on */ - initcorners = 1; - /* dec = get_max_curarg_len(floatvalstr, totparms); */ -#ifdef USE_LONG_DOUBLE - sscanf(floatvalstr[2], "%Lf", &Magnification); -#else - sscanf(floatvalstr[2], "%lf", &Magnification); -#endif - - /* I don't know if this is portable, but something needs to */ - /* be used in case compiler's LDBL_MAX is not big enough */ - if (Magnification > LDBL_MAX || Magnification < -LDBL_MAX) - goto badarg; /* ie: Magnification is +-1.#INF */ - - dec = getpower10(Magnification) + 4; /* 4 digits of padding sounds good */ - - if ((dec <= DBL_DIG+1 && debugflag != 3200) || debugflag == 3400) { /* rough estimate that double is OK */ - Xctr = floatval[0]; - Yctr = floatval[1]; - /* Magnification = floatval[2]; */ /* already done above */ - Xmagfactor = 1; - Rotation = 0; - Skew = 0; - if (floatparms > 3) - Xmagfactor = floatval[3]; - if (Xmagfactor == 0) - Xmagfactor = 1; - if (floatparms > 4) - Rotation = floatval[4]; - if (floatparms > 5) - Skew = floatval[5]; - /* calculate bounds */ - cvtcorners(Xctr, Yctr, Magnification, Xmagfactor, Rotation, Skew); - return 1; - } - else { /* use arbitrary precision */ - int old_bf_math; - int saved; - initcorners = 1; - old_bf_math = bf_math; - if (!bf_math || dec > decimals) - init_bf_dec(dec); - if (old_bf_math == 0) { - int k; - for (k = 0; k < MAXPARAMS; k++) - floattobf(bfparms[k], param[k]); - } - usemag = 1; - saved = save_stack(); - bXctr = alloc_stack(bflength+2); - bYctr = alloc_stack(bflength+2); - /* Xctr = floatval[0]; */ - get_bf(bXctr, floatvalstr[0]); - /* Yctr = floatval[1]; */ - get_bf(bYctr, floatvalstr[1]); - /* Magnification = floatval[2]; */ /* already done above */ - Xmagfactor = 1; - Rotation = 0; - Skew = 0; - if (floatparms > 3) - Xmagfactor = floatval[3]; - if (Xmagfactor == 0) - Xmagfactor = 1; - if (floatparms > 4) - Rotation = floatval[4]; - if (floatparms > 5) - Skew = floatval[5]; - /* calculate bounds */ - cvtcornersbf(bXctr, bYctr, Magnification, Xmagfactor, Rotation, Skew); - bfcornerstofloat(); - restore_stack(saved); - return 1; - } - } - - if (strcmp(variable, "aspectdrift") == 0 ) { /* aspectdrift=? */ - if (floatparms != 1 || floatval[0] < 0) - goto badarg; - aspectdrift = (float)floatval[0]; - return 1; - } - - if (strcmp(variable, "invert") == 0) { /* invert=?,?,? */ - if (totparms != floatparms || (totparms != 1 && totparms != 3)) - goto badarg; - invert = ((inversion[0] = floatval[0]) != 0.0) ? totparms : 0; - if (totparms == 3) { - inversion[1] = floatval[1]; - inversion[2] = floatval[2]; - } - return 1; - } - - if (strcmp(variable, "olddemmcolors") == 0 ) { /* olddemmcolors=? */ - if (yesnoval[0] < 0) goto badarg; - old_demm_colors = yesnoval[0]; - return 0; - } - - if (strcmp(variable, "askvideo") == 0 ) { /* askvideo=? */ - if (yesnoval[0] < 0) goto badarg; - askvideo = yesnoval[0]; - return 0; - } - - if (strcmp(variable, "ramvideo") == 0 ) /* ramvideo=? */ - return 0; /* just ignore and return, for old time's sake */ - - if (strcmp(variable, "float") == 0 ) { /* float=? */ - if (yesnoval[0] < 0) goto badarg; -#ifndef XFRACT - usr_floatflag = (char)yesnoval[0]; -#else - usr_floatflag = 1; /* must use floating point */ -#endif - return 3; - } - - if (strcmp(variable, "fastrestore") == 0 ) { /* fastrestore=? */ - if (yesnoval[0] < 0) goto badarg; - fastrestore = (char)yesnoval[0]; - return 0; - } - - if (strcmp(variable, "orgfrmdir") == 0 ) { /* orgfrmdir=? */ - if (valuelen > (FILE_MAX_DIR-1)) goto badarg; - if (isadirectory(value) == 0) goto badarg; - orgfrmsearch = 1; - strcpy(orgfrmdir, value); - fix_dirname(orgfrmdir); - return 0; - } - - if (strcmp(variable, "biomorph") == 0 ) { /* biomorph=? */ - usr_biomorph = numval; - return 1; - } - - if (strcmp(variable, "orbitsave") == 0 ) { /* orbitsave=? */ - if (charval[0] == 's') - orbitsave |= 2; - else if (yesnoval[0] < 0) goto badarg; - orbitsave |= yesnoval[0]; - return 1; - } - - if (strcmp(variable, "bailout") == 0 ) { /* bailout=? */ - if (floatval[0] < 1 || floatval[0] > 2100000000L) goto badarg; - bailout = (long)floatval[0]; - return 1; - } - - if (strcmp(variable, "bailoutest") == 0 ) { /* bailoutest=? */ - if (strcmp(value, "mod" )==0) bailoutest = Mod; - else if (strcmp(value, "real")==0) bailoutest = Real; - else if (strcmp(value, "imag")==0) bailoutest = Imag; - else if (strcmp(value, "or" )==0) bailoutest = Or; - else if (strcmp(value, "and" )==0) bailoutest = And; - else if (strcmp(value, "manh")==0) bailoutest = Manh; - else if (strcmp(value, "manr")==0) bailoutest = Manr; - else goto badarg; - setbailoutformula(bailoutest); - return 1; - } - - if (strcmp(variable, "symmetry") == 0 ) { /* symmetry=? */ - if (strcmp(value, "xaxis" )==0) forcesymmetry = XAXIS; - else if (strcmp(value, "yaxis" )==0) forcesymmetry = YAXIS; - else if (strcmp(value, "xyaxis")==0) forcesymmetry = XYAXIS; - else if (strcmp(value, "origin")==0) forcesymmetry = ORIGIN; - else if (strcmp(value, "pi" )==0) forcesymmetry = PI_SYM; - else if (strcmp(value, "none" )==0) forcesymmetry = NOSYM; - else goto badarg; - return 1; - } - - /* deprecated print parameters */ - if ((strcmp(variable, "printer") == 0) - || (strcmp(variable, "printfile") == 0) - || (strcmp(variable, "rleps") == 0) - || (strcmp(variable, "colorps") == 0) - || (strcmp(variable, "epsf") == 0) - || (strcmp(variable, "title") == 0) - || (strcmp(variable, "translate") == 0) - || (strcmp(variable, "plotstyle") == 0) - || (strcmp(variable, "halftone") == 0) - || (strcmp(variable, "linefeed") == 0) - || (strcmp(variable, "comport") == 0)) - { - return 0; - } - - if (strcmp(variable, "sound") == 0 ) { /* sound=?,?,? */ - if (totparms > 5) - goto badarg; - soundflag = SOUNDFLAG_OFF; /* start with a clean slate, add bits as we go */ - if (totparms == 1) - soundflag = SOUNDFLAG_SPEAKER; /* old command, default to PC speaker */ - - /* soundflag is used as a bitfield... bit 0,1,2 used for whether sound - is modified by an orbits x,y,or z component. and also to turn it on - or off (0==off, 1==beep (or yes), 2==x, 3==y, 4==z), - Bit 3 is used for flagging the PC speaker sound, - Bit 4 for OPL3 FM soundcard output, - Bit 5 will be for midi output (not yet), - Bit 6 for whether the tone is quantised to the nearest 'proper' note - (according to the western, even tempered system anyway) */ - - if (charval[0] == 'n' || charval[0] == 'o') - soundflag &= ~SOUNDFLAG_ORBITMASK; - else if ((strncmp(value, "ye", 2) == 0) || (charval[0] == 'b')) - soundflag |= SOUNDFLAG_BEEP; - else if (charval[0] == 'x') - soundflag |= SOUNDFLAG_X; - else if (charval[0] == 'y' && strncmp(value, "ye", 2) != 0) - soundflag |= SOUNDFLAG_Y; - else if (charval[0] == 'z') - soundflag |= SOUNDFLAG_Z; - else - goto badarg; -#if !defined(XFRACT) - if (totparms > 1) { - int i; - soundflag &= SOUNDFLAG_ORBITMASK; /* reset options */ - for (i = 1; i < totparms; i++) { - /* this is for 2 or more options at the same time */ - if (charval[i] == 'f') { /* (try to)switch on opl3 fm synth */ - if (driver_init_fm()) - soundflag |= SOUNDFLAG_OPL3_FM; - else - soundflag &= ~SOUNDFLAG_OPL3_FM; - } - else if (charval[i] == 'p') - soundflag |= SOUNDFLAG_SPEAKER; - else if (charval[i] == 'm') - soundflag |= SOUNDFLAG_MIDI; - else if (charval[i] == 'q') - soundflag |= SOUNDFLAG_QUANTIZED; - else - goto badarg; - } /* end for */ - } /* end totparms > 1 */ - return 0; - } - - if (strcmp(variable, "hertz") == 0) { /* Hertz=? */ - basehertz = numval; - return 0; - } - - if (strcmp(variable, "volume") == 0) { /* Volume =? */ - fm_vol = numval & 0x3F; /* 63 */ - return 0; - } - - if (strcmp(variable, "attenuate") == 0) { - if (charval[0] == 'n') - hi_atten = 0; - else if (charval[0] == 'l') - hi_atten = 1; - else if (charval[0] == 'm') - hi_atten = 2; - else if (charval[0] == 'h') - hi_atten = 3; - else - goto badarg; - return 0; - } - - if (strcmp(variable, "polyphony") == 0) { - if (numval > 9) - goto badarg; - polyphony = abs(numval-1); - return 0; - } - - if (strcmp(variable, "wavetype") == 0) { /* wavetype = ? */ - fm_wavetype = numval & 0x0F; - return 0; - } - - if (strcmp(variable, "attack") == 0) { /* attack = ? */ - fm_attack = numval & 0x0F; - return 0; - } - - if (strcmp(variable, "decay") == 0) { /* decay = ? */ - fm_decay = numval & 0x0F; - return 0; - } - - if (strcmp(variable, "sustain") == 0) { /* sustain = ? */ - fm_sustain = numval & 0x0F; - return 0; - } - - if (strcmp(variable, "srelease") == 0) { /* release = ? */ - fm_release = numval & 0x0F; - return 0; - } - - if (strcmp(variable, "scalemap") == 0) { /* Scalemap=?,?,?,?,?,?,?,?,?,?,? */ - int counter; - if (totparms != intparms) goto badarg; - for (counter=0; counter <=11; counter++) - if ((totparms > counter) && (intval[counter] > 0) - && (intval[counter] < 13)) - scale_map[counter] = intval[counter]; -#endif - return 0; - } - - if (strcmp(variable, "periodicity") == 0 ) { /* periodicity=? */ - usr_periodicitycheck=1; - if ((charval[0] == 'n') || (numval == 0)) - usr_periodicitycheck=0; - else if (charval[0] == 'y') - usr_periodicitycheck=1; - else if (charval[0] == 's') /* 's' for 'show' */ - usr_periodicitycheck= -1; - else if (numval == NONNUMERIC) - goto badarg; - else if (numval != 0) - usr_periodicitycheck=numval; - if (usr_periodicitycheck > 255) usr_periodicitycheck = 255; - if (usr_periodicitycheck < -255) usr_periodicitycheck = -255; - return 1; - } - - if (strcmp(variable, "logmap") == 0 ) { /* logmap=? */ - Log_Auto_Calc = 0; /* turn this off if loading a PAR */ - if (charval[0] == 'y') - LogFlag = 1; /* palette is logarithmic */ - else if (charval[0] == 'n') - LogFlag = 0; - else if (charval[0] == 'o') - LogFlag = -1; /* old log palette */ - else - LogFlag = (long)floatval[0]; - return 1; - } - - if (strcmp(variable, "logmode") == 0 ) { /* logmode=? */ - Log_Fly_Calc = 0; /* turn off if error */ - Log_Auto_Calc = 0; - if (charval[0] == 'f') - Log_Fly_Calc = 1; /* calculate on the fly */ - else if (charval[0] == 't') - Log_Fly_Calc = 2; /* force use of LogTable */ - else if (charval[0] == 'a') { - Log_Auto_Calc = 1; /* force auto calc of logmap */ - } - else goto badarg; - return 1; - } - - if (strcmp(variable, "debugflag") == 0 - || strcmp(variable, "debug") == 0) { /* internal use only */ - debugflag = numval; - timerflag = debugflag & 1; /* separate timer flag */ - debugflag -= timerflag; - return 0; - } - - if (strcmp(variable, "rseed") == 0) { - rseed = numval; - rflag = 1; - return 1; - } - - if (strcmp(variable, "orbitdelay") == 0) { - orbit_delay = numval; - return 0; - } - - if (strcmp(variable, "orbitinterval") == 0) { - orbit_interval = numval; - if (orbit_interval < 1) - orbit_interval = 1; - if (orbit_interval > 255) - orbit_interval = 255; - return 0; - } - - if (strcmp(variable, "showdot") == 0) { - showdot = 15; - if (totparms > 0) - { - autoshowdot = (char)0; - if (isalpha(charval[0])) - { - if (strchr("abdm", (int)charval[0]) != NULL) - autoshowdot = charval[0]; - else - goto badarg; - } - else - { - showdot=numval; - if (showdot<0) - showdot=-1; - } - if (totparms > 1 && intparms > 0) - sizedot = intval[1]; - if (sizedot < 0) - sizedot = 0; - } - return 0; - } - - if (strcmp(variable, "showorbit") == 0) { /* showorbit=yes|no */ - start_showorbit=(char)yesnoval[0]; - return 0; - } - - if (strcmp(variable, "decomp") == 0) { - if (totparms != intparms || totparms < 1) goto badarg; - decomp[0] = intval[0]; - decomp[1] = 0; - if (totparms > 1) /* backward compatibility */ - bailout = decomp[1] = intval[1]; - return 1; - } - - if (strcmp(variable, "distest") == 0) { - if (totparms != intparms || totparms < 1) goto badarg; - usr_distest = (long)floatval[0]; - distestwidth = 71; - if (totparms > 1) - distestwidth = intval[1]; - if (totparms > 3 && intval[2] > 0 && intval[3] > 0) { - pseudox = intval[2]; - pseudoy = intval[3]; - } - else - pseudox = pseudoy = 0; - return 1; - } - - if (strcmp(variable, "formulafile") == 0) { /* formulafile=? */ - if (valuelen > (FILE_MAX_PATH-1)) goto badarg; - if (merge_pathnames(FormFileName, value, mode)<0) - init_msg(variable, value, mode); - return 1; - } - - if (strcmp(variable, "formulaname") == 0) { /* formulaname=? */ - if (valuelen > ITEMNAMELEN) goto badarg; - strcpy(FormName, value); - return 1; - } - - if (strcmp(variable, "lfile") == 0) { /* lfile=? */ - if (valuelen > (FILE_MAX_PATH-1)) goto badarg; - if (merge_pathnames(LFileName, value, mode)<0) - init_msg(variable, value, mode); - return 1; - } - - if (strcmp(variable, "lname") == 0) { - if (valuelen > ITEMNAMELEN) goto badarg; - strcpy(LName, value); - return 1; - } - - if (strcmp(variable, "ifsfile") == 0) { /* ifsfile=?? */ - int existdir; - if (valuelen > (FILE_MAX_PATH-1)) goto badarg; - existdir=merge_pathnames(IFSFileName, value, mode); - if (existdir==0) - reset_ifs_defn(); - else if (existdir < 0) - init_msg(variable, value, mode); - return 1; - } - - - if (strcmp(variable, "ifs") == 0 - || strcmp(variable, "ifs3d") == 0) { /* ifs3d for old time's sake */ - if (valuelen > ITEMNAMELEN) goto badarg; - strcpy(IFSName, value); - reset_ifs_defn(); - return 1; - } - - if (strcmp(variable, "parmfile") == 0) { /* parmfile=? */ - if (valuelen > (FILE_MAX_PATH-1)) goto badarg; - if (merge_pathnames(CommandFile, value, mode)<0) - init_msg(variable, value, mode); - return 1; - } - - if (strcmp(variable, "stereo") == 0) { /* stereo=? */ - if ((numval<0) || (numval>4)) goto badarg; - g_glasses_type = numval; - return 3; - } - - if (strcmp(variable, "rotation") == 0) { /* rotation=?/?/? */ - if (totparms != 3 || intparms != 3) goto badarg; - XROT = intval[0]; - YROT = intval[1]; - ZROT = intval[2]; - return 3; - } - - if (strcmp(variable, "perspective") == 0) { /* perspective=? */ - if (numval == NONNUMERIC) goto badarg; - ZVIEWER = numval; - return 3; - } - - if (strcmp(variable, "xyshift") == 0) { /* xyshift=?/? */ - if (totparms != 2 || intparms != 2) goto badarg; - XSHIFT = intval[0]; - YSHIFT = intval[1]; - return 3; - } - - if (strcmp(variable, "interocular") == 0) { /* interocular=? */ - g_eye_separation = numval; - return 3; - } - - if (strcmp(variable, "converge") == 0) { /* converg=? */ - xadjust = numval; - return 3; - } - - if (strcmp(variable, "crop") == 0) { /* crop=? */ - if (totparms != 4 || intparms != 4 - || intval[0] < 0 || intval[0] > 100 - || intval[1] < 0 || intval[1] > 100 - || intval[2] < 0 || intval[2] > 100 - || intval[3] < 0 || intval[3] > 100) - goto badarg; - red_crop_left = intval[0]; - red_crop_right = intval[1]; - blue_crop_left = intval[2]; - blue_crop_right = intval[3]; - return 3; - } - - if (strcmp(variable, "bright") == 0) { /* bright=? */ - if (totparms != 2 || intparms != 2) goto badarg; - red_bright = intval[0]; - blue_bright = intval[1]; - return 3; - } - - if (strcmp(variable, "xyadjust") == 0) { /* trans=? */ - if (totparms != 2 || intparms != 2) goto badarg; - xtrans = intval[0]; - ytrans = intval[1]; - return 3; - } - - if (strcmp(variable, "3d") == 0) { /* 3d=?/?/.. */ - if (strcmp(value, "overlay")==0) { - yesnoval[0]=1; - if (calc_status > CALCSTAT_NO_FRACTAL) /* if no image, treat same as 3D=yes */ - overlay3d=1; - } - else if (yesnoval[0] < 0) goto badarg; - display3d = yesnoval[0]; - initvars_3d(); - return (display3d) ? 6 : 2; - } - - if (strcmp(variable, "sphere") == 0 ) { /* sphere=? */ - if (yesnoval[0] < 0) goto badarg; - SPHERE = yesnoval[0]; - return 2; - } - - if (strcmp(variable, "scalexyz") == 0) { /* scalexyz=?/?/? */ - if (totparms < 2 || intparms != totparms) goto badarg; - XSCALE = intval[0]; - YSCALE = intval[1]; - if (totparms > 2) ROUGH = intval[2]; - return 2; - } - - /* "rough" is really scale z, but we add it here for convenience */ - if (strcmp(variable, "roughness") == 0) { /* roughness=? */ - ROUGH = numval; - return 2; - } - - if (strcmp(variable, "waterline") == 0) { /* waterline=? */ - if (numval<0) goto badarg; - WATERLINE = numval; - return 2; - } - - if (strcmp(variable, "filltype") == 0) { /* filltype=? */ - if (numval < -1 || numval > 6) goto badarg; - FILLTYPE = numval; - return 2; - } - - if (strcmp(variable, "lightsource") == 0) { /* lightsource=?/?/? */ - if (totparms != 3 || intparms != 3) goto badarg; - XLIGHT = intval[0]; - YLIGHT = intval[1]; - ZLIGHT = intval[2]; - return 2; - } - - if (strcmp(variable, "smoothing") == 0) { /* smoothing=? */ - if (numval<0) goto badarg; - LIGHTAVG = numval; - return 2; - } - - if (strcmp(variable, "latitude") == 0) { /* latitude=?/? */ - if (totparms != 2 || intparms != 2) goto badarg; - THETA1 = intval[0]; - THETA2 = intval[1]; - return 2; - } - - if (strcmp(variable, "longitude") == 0) { /* longitude=?/? */ - if (totparms != 2 || intparms != 2) goto badarg; - PHI1 = intval[0]; - PHI2 = intval[1]; - return 2; - } - - if (strcmp(variable, "radius") == 0) { /* radius=? */ - if (numval < 0) goto badarg; - RADIUS = numval; - return 2; - } - - if (strcmp(variable, "transparent") == 0) { /* transparent? */ - if (totparms != intparms || totparms < 1) goto badarg; - transparent[1] = transparent[0] = intval[0]; - if (totparms > 1) transparent[1] = intval[1]; - return 2; - } - - if (strcmp(variable, "preview") == 0) { /* preview? */ - if (yesnoval[0] < 0) goto badarg; - preview = (char)yesnoval[0]; - return 2; - } - - if (strcmp(variable, "showbox") == 0) { /* showbox? */ - if (yesnoval[0] < 0) goto badarg; - showbox = (char)yesnoval[0]; - return 2; - } - - if (strcmp(variable, "coarse") == 0) { /* coarse=? */ - if (numval < 3 || numval > 2000) goto badarg; - previewfactor = numval; - return 2; - } - - if (strcmp(variable, "randomize") == 0) { /* RANDOMIZE=? */ - if (numval<0 || numval>7) goto badarg; - RANDOMIZE = numval; - return 2; - } - - if (strcmp(variable, "ambient") == 0) { /* ambient=? */ - if (numval<0||numval>100) goto badarg; - Ambient = numval; - return 2; - } - - if (strcmp(variable, "haze") == 0) { /* haze=? */ - if (numval<0||numval>100) goto badarg; - haze = numval; - return 2; - } - - if (strcmp(variable, "fullcolor") == 0) { /* fullcolor=? */ - if (yesnoval[0] < 0) goto badarg; - Targa_Out = yesnoval[0]; - return 2; - } - - if (strcmp(variable, "truecolor") == 0) { /* truecolor=? */ - if (yesnoval[0] < 0) goto badarg; - truecolor = yesnoval[0]; - return 3; - } - - if (strcmp(variable, "truemode") == 0) { /* truemode=? */ - truemode = 0; /* use default if error */ - if (charval[0] == 'd') - truemode = 0; /* use default color output */ - if (charval[0] == 'i' || intval[0] == 1) - truemode = 1; /* use iterates output */ - if (intval[0] == 2) - truemode = 2; - if (intval[0] == 3) - truemode = 3; - return 3; - } - - if (strcmp(variable, "usegrayscale") == 0) { /* usegrayscale? */ - if (yesnoval[0] < 0) goto badarg; - grayflag = (char)yesnoval[0]; - return 2; - } - - if (strcmp(variable, "monitorwidth") == 0) { /* monitorwidth=? */ - if (totparms != 1 || floatparms != 1) goto badarg; - AutoStereo_width = floatval[0]; - return 2; - } - - if (strcmp(variable, "targa_overlay") == 0) { /* Targa Overlay? */ - if (yesnoval[0] < 0) goto badarg; - Targa_Overlay = yesnoval[0]; - return 2; - } - - if (strcmp(variable, "background") == 0) { /* background=?/? */ - if (totparms != 3 || intparms != 3) goto badarg; - for (i=0;i<3;i++) - if (intval[i] & ~0xff) - goto badarg; - back_color[0] = (BYTE)intval[0]; - back_color[1] = (BYTE)intval[1]; - back_color[2] = (BYTE)intval[2]; - return 2; - } - - if (strcmp(variable, "lightname") == 0) { /* lightname=? */ - if (valuelen > (FILE_MAX_PATH-1)) goto badarg; - if (first_init || mode == CMDFILE_AT_AFTER_STARTUP) - strcpy(light_name, value); - return 0; - } - - if (strcmp(variable, "ray") == 0) { /* RAY=? */ - if (numval < 0 || numval > 6) goto badarg; - RAY = numval; - return 2; - } - - if (strcmp(variable, "brief") == 0) { /* BRIEF? */ - if (yesnoval[0] < 0) goto badarg; - BRIEF = yesnoval[0]; - return 2; - } - - if (strcmp(variable, "release") == 0) { /* release */ - if (numval < 0) goto badarg; - - save_release = numval; - return 2; - } - - if (strcmp(variable, "curdir") == 0) { /* curdir= */ - if (yesnoval[0] < 0) goto badarg; - checkcurdir = yesnoval[0]; - return 0; - } - - if (strcmp(variable, "virtual") == 0) /* virtual= */ - { - if (yesnoval[0] < 0) - { - goto badarg; - } - g_virtual_screens = yesnoval[0]; - return 1; - } - -badarg: - argerror(curarg); - return -1; -} - -#ifdef _MSC_VER -#if (_MSC_VER >= 600) -#pragma optimize( "el", on ) -#endif -#endif - -/* Some routines broken out of above so compiler doesn't run out of heap: */ - -static void parse_textcolors(char *value) -{ - int i,j,k,hexval; - if (strcmp(value, "mono") == 0) { - for (k = 0; k < sizeof(txtcolor); ++k) - txtcolor[k] = BLACK*16+WHITE; - /* C_HELP_CURLINK = C_PROMPT_INPUT = C_CHOICE_CURRENT = C_GENERAL_INPUT - = C_AUTHDIV1 = C_AUTHDIV2 = WHITE*16+BLACK; */ - txtcolor[6] = txtcolor[12] = txtcolor[13] = txtcolor[14] = txtcolor[20] - = txtcolor[27] = txtcolor[28] = WHITE*16+BLACK; - /* C_TITLE = C_HELP_HDG = C_HELP_LINK = C_PROMPT_HI = C_CHOICE_SP_KEYIN - = C_GENERAL_HI = C_DVID_HI = C_STOP_ERR - = C_STOP_INFO = BLACK*16+L_WHITE; */ - txtcolor[0] = txtcolor[2] = txtcolor[5] = txtcolor[11] = txtcolor[16] - = txtcolor[17] = txtcolor[22] = txtcolor[24] - = txtcolor[25] = BLACK*16+L_WHITE; - } - else { - k = 0; - while ( k < sizeof(txtcolor)) { - if (*value == 0) break; - if (*value != '/') { - sscanf(value,"%x",&hexval); - i = (hexval / 16) & 7; - j = hexval & 15; - if (i == j || (i == 0 && j == 8)) /* force contrast */ - j = 15; - txtcolor[k] = (BYTE)(i * 16 + j); - value = strchr(value,'/'); - if (value == NULL) break; - } - ++value; - ++k; - } - } -} - -static int parse_colors(char *value) -{ - int i,j,k; - if (*value == '@') { - if (merge_pathnames(MAP_name,&value[1],3)<0) - init_msg("",&value[1],3); - if ((int)strlen(value) > FILE_MAX_PATH || ValidateLuts(MAP_name) != 0) - goto badcolor; - if (display3d) { - mapset = 1; - } - else { - if (merge_pathnames(colorfile,&value[1],3)<0) - init_msg("",&value[1],3); - colorstate = 2; - } - } - else { - int smooth; - i = smooth = 0; - while (*value) { - if (i >= 256) goto badcolor; - if (*value == '<') { - if (i == 0 || smooth - || (smooth = atoi(value+1)) < 2 - || (value = strchr(value,'>')) == NULL) - goto badcolor; - i += smooth; - ++value; - } - else { - for (j = 0; j < 3; ++j) { - if ((k = *(value++)) < '0') goto badcolor; - else if (k <= '9') k -= '0'; - else if (k < 'A') goto badcolor; - else if (k <= 'Z') k -= ('A'-10); - else if (k < '_' || k > 'z') goto badcolor; - else k -= ('_'-36); - g_dac_box[i][j] = (BYTE)k; - if (smooth) { - int start,spread,cnum; - start = i - (spread = smooth + 1); - cnum = 0; - if ((k - (int)g_dac_box[start][j]) == 0) { - while (++cnum < spread) - g_dac_box[start+cnum][j] = (BYTE)k; - } - else { - while (++cnum < spread) - g_dac_box[start+cnum][j] = - (BYTE)(( cnum *g_dac_box[i][j] - + (i-(start+cnum))*g_dac_box[start][j] - + spread/2 ) - / (BYTE) spread); - } - } - } - smooth = 0; - ++i; - } - } - if (smooth) goto badcolor; - while (i < 256) { /* zap unset entries */ - g_dac_box[i][0] = g_dac_box[i][1] = g_dac_box[i][2] = 40; - ++i; - } - colorstate = 1; - } - colorpreloaded = 1; - memcpy(olddacbox,g_dac_box,256*3); - return 0; -badcolor: - return -1; -} - -static void argerror(const char *badarg) /* oops. couldn't decode this */ -{ - char msg[300]; - char spillover[71]; - if ((int) strlen(badarg) > 70) - { - strncpy(spillover, badarg, 70); - spillover[70] = 0; - badarg = spillover; - } - sprintf(msg, "Oops. I couldn't understand the argument:\n %s", badarg); - - if (first_init) /* this is 1st call to cmdfiles */ - { - strcat(msg, "\n" - "\n" - "(see the Startup Help screens or documentation for a complete\n" - " argument list with descriptions)"); - } - stopmsg(0, msg); - if (initbatch) - { - initbatch = 4; - goodbye(); - } -} - -void set_3d_defaults() -{ - ROUGH = 30; - WATERLINE = 0; - ZVIEWER = 0; - XSHIFT = 0; - YSHIFT = 0; - xtrans = 0; - ytrans = 0; - LIGHTAVG = 0; - Ambient = 20; - RANDOMIZE = 0; - haze = 0; - back_color[0] = 51; back_color[1] = 153; back_color[2] = 200; - if (SPHERE) { - PHI1 = 180; - PHI2 = 0; - THETA1 = -90; - THETA2 = 90; - RADIUS = 100; - FILLTYPE = 2; - XLIGHT = 1; - YLIGHT = 1; - ZLIGHT = 1; - } - else { - XROT = 60; - YROT = 30; - ZROT = 0; - XSCALE = 90; - YSCALE = 90; - FILLTYPE = 0; - XLIGHT = 1; - YLIGHT = -1; - ZLIGHT = 1; - } -} - -/* copy a big number from a string, up to slash */ -static int get_bf(bf_t bf, char *curarg) -{ - char *s; - s=strchr(curarg,'/'); - if (s) - *s = 0; - strtobf(bf,curarg); - if (s) - *s = '/'; - return 0; -} - -/* Get length of current args */ -int get_curarg_len(char *curarg) -{ - int len; - char *s; - s=strchr(curarg,'/'); - if (s) - *s = 0; - len = (int) strlen(curarg); - if (s) - *s = '/'; - return len; -} - -/* Get max length of current args */ -int get_max_curarg_len(char *floatvalstr[], int totparms) -{ - int i,tmp,max_str; - max_str = 0; - for (i=0; i max_str) - max_str = tmp; - return max_str; -} - -/* mode = 0 command line @filename */ -/* 1 sstools.ini */ -/* 2 <@> command after startup */ -/* 3 command line @filename/setname */ -/* this is like stopmsg() but can be used in cmdfiles() */ -/* call with NULL for badfilename to get pause for driver_get_key() */ -int init_msg(char *cmdstr,char *badfilename,int mode) -{ - char *modestr[4] = - {"command line", "sstools.ini", "PAR file", "PAR file"}; - char msg[256]; - char cmd[80]; - static int row = 1; - - if (initbatch == 1) { /* in batch mode */ - if (badfilename) - /* uncomment next if wish to cause abort in batch mode for - errors in CMDFILES.C such as parsing SSTOOLS.INI */ - /* initbatch = 4; */ /* used to set errorlevel */ - return -1; - } - strncpy(cmd,cmdstr,30); - cmd[29] = 0; - - if (*cmd) - strcat(cmd,"="); - if (badfilename) - sprintf(msg,"Can't find %s%s, please check %s",cmd,badfilename,modestr[mode]); - if (first_init) { /* & cmdfiles hasn't finished 1st try */ - if (row == 1 && badfilename) { - driver_set_for_text(); - driver_put_string(0,0,15, "Fractint found the following problems when parsing commands: "); - } - if (badfilename) - driver_put_string(row++,0,7,msg); - else if (row > 1){ - driver_put_string(++row,0,15, "Press Escape to abort, any other key to continue"); - driver_move_cursor(row+1,0); - /* - if (getakeynohelp()==27) - goodbye(); - */ - dopause(2); /* defer getakeynohelp until after parseing */ - } - } - else if (badfilename) - stopmsg(0,msg); - return 0; -} - -/* defer pause until after parsing so we know if in batch mode */ -void dopause(int action) -{ - static unsigned char needpause = 0; - switch (action) - { - case 0: - if (initbatch == 0) - { - if (needpause == 1) - driver_get_key(); - else if (needpause == 2) - if (getakeynohelp() == FIK_ESC) - goodbye(); - } - needpause = 0; - break; - case 1: - case 2: - needpause = (char)action; - break; - default: - break; - } -} - -/* - Crude function to detect a floating point number. Intended for - use with arbitrary precision. -*/ -static int isabigfloat(char *str) -{ - /* [+|-]numbers][.]numbers[+|-][e|g]numbers */ - int result=1; - char *s = str; - int numdot=0; - int nume=0; - int numsign=0; - while (*s != 0 && *s != '/' && *s != ' ') - { - if (*s == '-' || *s == '+') numsign++; - else if (*s == '.') numdot++; - else if (*s == 'e' || *s == 'E' || *s == 'g' || *s == 'G') nume++; - else if (!isdigit(*s)) {result=0; break;} - s++; - } - if (numdot > 1 || numsign > 2 || nume > 1) result=0; - return result; -} - diff --git a/fractint/common/decoder.c b/fractint/common/decoder.c deleted file mode 100644 index 432486020..000000000 --- a/fractint/common/decoder.c +++ /dev/null @@ -1,462 +0,0 @@ -/* DECODE.C - An LZW decoder for GIF - * Copyright (C) 1987, by Steven A. Bennett - * - * Permission is given by the author to freely redistribute and include - * this code in any program as long as this credit is given where due. - * - * In accordance with the above, I want to credit Steve Wilhite who wrote - * the code which this is heavily inspired by... - * - * GIF and 'Graphics Interchange Format' are trademarks (tm) of - * Compuserve, Incorporated, an H&R Block Company. - * - * Release Notes: This file contains a decoder routine for GIF images - * which is similar, structurally, to the original routine by Steve Wilhite. - * It is, however, somewhat noticably faster in most cases. - * - == This routine was modified for use in FRACTINT in two ways. - == - == 1) The original #includes were folded into the routine strictly to hold - == down the number of files we were dealing with. - == - == 2) The 'stack', 'suffix', 'prefix', and 'decoderline' arrays were - == changed from static and 'malloc()'ed to external only so that - == the assembler program could use the same array space for several - == independent chunks of code. Also, 'stack' was renamed to 'dstack' - == for TASM compatibility. - == - == 3) The 'out_line()' external function has been changed to reference - == '*outln()' for flexibility (in particular, 3D transformations) - == - == 4) A call to 'driver_key_pressed()' has been added after the 'outln()' calls - == to check for the presenc of a key-press as a bail-out signal - == - == (Bert Tyler and Timothy Wegner) - */ - -/* Rev 01/02/91 - Revised by Mike Gelvin - * altered logic to allow newcode to input a line at a time - * altered logic to allow decoder to place characters - * directly into the output buffer if they fit - */ - - -/***** Application Includes *********************************************/ - /* see Fractint.c for a description of the "include" hierarchy */ -#include "port.h" -#include "prototyp.h" -#include "drivers.h" - -/***** Application Function Prototypes **********************************/ -static short get_next_code(void); - -/* extern short out_line(pixels, linelen) - * UBYTE pixels[]; - * short linelen; - * - * - This function takes a full line of pixels (one byte per pixel) and - * displays them (or does whatever your program wants with them...). It - * should return zero, or negative if an error or some other event occurs - * which would require aborting the decode process... Note that the length - * passed will almost always be equal to the line length passed to the - * decoder function, with the sole exception occurring when an ending code - * occurs in an odd place in the GIF file... In any case, linelen will be - * equal to the number of pixels passed... - */ -int (*outln) (BYTE *, int) = out_line; - -/***** Local Static Variables *******************************************/ -/* Various error codes used by decoder - * and my own routines... It's okay - * for you to define whatever you want, - * as long as it's negative... It will be - * returned intact up the various subroutine - * levels... - */ -#define OUT_OF_MEMORY -10 -#define BAD_CODE_SIZE -20 -#define READ_ERROR -1 -#define WRITE_ERROR -2 -#define OPEN_ERROR -3 -#define CREATE_ERROR -4 - -#define MAX_CODES 4095 - -#define NOPE 0 -#define YUP -1 - -static short curr_size; /* The current code size */ - -/* The following static variables are used - * for seperating out codes - */ -static short navail_bytes; /* # bytes left in block */ -static short nbits_left; /* # bits left in current byte */ -static BYTE *byte_buff; /* Current block, reuse shared mem */ -static BYTE *pbytes; /* Pointer to next byte in block */ - -static short code_mask[13] = -{ - 0, - 0x0001, 0x0003, - 0x0007, 0x000F, - 0x001F, 0x003F, - 0x007F, 0x00FF, - 0x01FF, 0x03FF, - 0x07FF, 0x0FFF -}; - -/***** External Variables ***********************************************/ -/* extern short bad_code_count; - * - * This value is the only other global required by the using program, and - * is incremented each time an out of range code is read by the decoder. - * When this value is non-zero after a decode, your GIF file is probably - * corrupt in some way... - * - * whups, here are more globals, added by PB: - * extern short skipxdots; 0 to get every dot, 1 for every 2nd, 2 every 3rd, ... - * extern short skipydots; - * - * All external declarations now in PROTOTYPE.H - */ - - -/* -I removed the LOCAL identifiers in the arrays below and replaced them -with 'extern's so as to declare (and re-use) the space elsewhere. -The arrays are actually declared in the assembler source. - Bert Tyler -*/ - -#if 0 -/* declarations moved to PROTOTYPE.H - these left for documentation */ -BYTE dstack[MAX_CODES + 1]; /* Stack for storing pixels */ -BYTE suffix[MAX_CODES + 1]; /* Suffix table */ -unsigned short prefix[MAX_CODES + 1]; /* Prefix linked list */ -BYTE decoderline[2]; /* decoded line goes here */ -#endif - -/* avoid using fixed near arrays by enabling next */ -#if 0 -BYTE dstack1[MAX_CODES + 1]; /* Stack for storing pixels */ -#define dstack dstack1 -#endif - -#if 0 /* remove this when suffix no longer used in diskvid.c */ -BYTE suffix1[MAX_CODES + 1]; /* Suffix table */ -#define suffix suffix1 -#endif - -#if 0 -unsigned short prefix1[MAX_CODES + 1]; /* Prefix linked list */ -#define prefix prefix1 -#endif - -/* for the time being, use a pointer to a buffer in the gifview stack */ -extern BYTE *decoderline1; -#define decoderline decoderline1 - -/* The reason we have these separated like this instead of using - * a structure like the original Wilhite code did, is because this - * stuff generally produces significantly faster code when compiled... - * This code is full of similar speedups... (For a good book on writing - * C for speed or for space optimization, see Efficient C by Tom Plum, - * published by Plum-Hall Associates...) - */ - - -/***** Program **********************************************************/ -/* short decoder(linewidth) - * short linewidth; * Pixels per line of image * - * - * - This function decodes an LZW image, according to the method used - * in the GIF spec. Every *linewidth* "characters" (ie. pixels) decoded - * will generate a call to out_line(), which is a user specific function - * to display a line of pixels. The function gets its codes from - * get_next_code() which is responsible for reading blocks of data and - * seperating them into the proper size codes. Finally, get_byte() is - * the global routine to read the next byte from the GIF file. - * - * It is generally a good idea to have linewidth correspond to the actual - * width of a line (as specified in the Image header) to make your own - * code a bit simpler, but it isn't absolutely necessary. - * - * Returns: 0 if successful, else negative. (See ERRS.H) - * - */ - -/* moved sizeofstring here for possible re-use elsewhere */ -short sizeofstring[MAX_CODES + 1]; /* size of string list */ - -short decoder(short linewidth) -{ -#if defined(XFRACT) || defined(_WIN32) - U16 prefix[MAX_CODES+1]; /* Prefix linked list */ -#endif - BYTE *sp; - short code; - short old_code; - short ret; - short c; - short size; - short i; - short j; - short fastloop; - short bufcnt; /* how many empty spaces left in buffer */ - short xskip; - short slot; /* Last read code */ - short newcodes; /* First available code */ - BYTE *bufptr; - short yskip; - short top_slot; /* Highest code for current size */ - short clear; /* Value for a clear code */ - short ending; /* Value for a ending code */ - BYTE out_value; - - /* Initialize for decoding a new image... */ - - if ((size = (short) get_byte()) < 0) - return (size); - if (size < 2 || 9 < size) - return (BAD_CODE_SIZE); - - curr_size = (short) (size + 1); - top_slot = (short) (1 << curr_size); - clear = (short) (1 << size); - ending = (short) (clear + 1); - slot = newcodes = (short) (ending + 1); - navail_bytes = nbits_left = sizeofstring[slot] = xskip = yskip - = old_code = 0; - out_value = 0; - for (i = 0; i < slot; i++) - { - sizeofstring[i] = 0; - } - - /* Initialize in case they forgot to put in a clear code. (This shouldn't - * happen, but we'll try and decode it anyway...) */ - - /* Set up the stack pointer and decode buffer pointer */ - sp = dstack; - bufptr = decoderline; - bufcnt = linewidth; - - /* This is the main loop. For each code we get we pass through the linked - * list of prefix codes, pushing the corresponding "character" for each - * code onto the stack. When the list reaches a single "character" we - * push that on the stack too, and then start unstacking each character - * for output in the correct order. Special handling is included for the - * clear code, and the whole thing ends when we get an ending code. */ - while ((c = get_next_code()) != ending) - { - - /* If we had a file error, return without completing the decode */ - if (c < 0) - return (0); - - /* If the code is a clear code, reinitialize all necessary items. */ - if (c == clear) - { - curr_size = (short) (size + 1); - slot = newcodes; - sizeofstring[slot] = 0; - top_slot = (short) (1 << curr_size); - - /* Continue reading codes until we get a non-clear code (Another - * unlikely, but possible case...) */ - do - { - c = get_next_code(); - } while (c == clear); - - /* If we get an ending code immediately after a clear code (Yet - * another unlikely case), then break out of the loop. */ - if (c == ending) - break; - - /* Finally, if the code is beyond the range of already set codes, - * (This one had better NOT happen... I have no idea what will - * result from this, but I doubt it will look good...) then set it - * to color zero. */ - if (c >= slot) - c = 0; - - out_value = (BYTE) (old_code = c); - - /* And let us not forget to put the char into the buffer... */ - *sp++ = (BYTE) c; - } - else - { - /* In this case, it's not a clear code or an ending code, so it must - * be a code code... So we can now decode the code into a stack of - * character codes. (Clear as mud, right?) */ - code = c; - - /* Here we go again with one of those off chances... If, on the off - * chance, the code we got is beyond the range of those already set - * up (Another thing which had better NOT happen...) we trick the - * decoder into thinking it actually got the next slot avail. */ - - if (code >= slot) - { - if (code > slot) - { - ++bad_code_count; - c = slot; - } - code = old_code; - *sp++ = out_value; - } - - /* Here we scan back along the linked list of prefixes. If they can - * fit into the output buffer then transfer them direct. ELSE push - * them into the stack until we are down to enough characters that - * they do fit. Output the line then fall through to unstack the - * ones that would not fit. */ - fastloop = NOPE; - while (code >= newcodes) - { - j = i = sizeofstring[code]; - if (i > 0 && bufcnt - i > 0 && skipxdots == 0) - { - fastloop = YUP; - - do - { - *(bufptr + j) = suffix[code]; - code = prefix[code]; - } while (--j > 0); - *bufptr = (BYTE) code; - bufptr += ++i; - bufcnt -= i; - if (bufcnt == 0) /* finished an input row? */ - { - if (--yskip < 0) - { - if ((ret = (short) ((*outln) (decoderline, (int) (bufptr - decoderline)))) < 0) - return (ret); - yskip = skipydots; - } - if (driver_key_pressed()) - return (-1); - bufptr = decoderline; - bufcnt = linewidth; - xskip = 0; - } - } - else - { - *sp++ = suffix[code]; - code = prefix[code]; - } - } - - /* Push the last character on the stack, and set up the new prefix - * and suffix, and if the required slot number is greater than that - * allowed by the current bit size, increase the bit size. (NOTE - - * If we are all full, we *don't* save the new suffix and prefix... - * I'm not certain if this is correct... it might be more proper to - * overwrite the last code... */ - if (fastloop == NOPE) - *sp++ = (BYTE) code; - - if (slot < top_slot) - { - sizeofstring[slot] = (short) (sizeofstring[old_code] + 1); - suffix[slot] = out_value = (BYTE) code; - prefix[slot++] = old_code; - old_code = c; - } - if (slot >= top_slot) - if (curr_size < 12) - { - top_slot <<= 1; - ++curr_size; - } - } - while (sp > dstack) - { - --sp; - if (--xskip < 0) - { - xskip = skipxdots; - *bufptr++ = *sp; - } - if (--bufcnt == 0) /* finished an input row? */ - { - if (--yskip < 0) - { - if ((ret = (short) ((*outln) (decoderline, (int) (bufptr - decoderline)))) < 0) - return (ret); - yskip = skipydots; - } - if (driver_key_pressed()) - return (-1); - bufptr = decoderline; - bufcnt = linewidth; - xskip = 0; - } - } - } - /* PB note that if last line is incomplete, we're not going to try to emit - * it; original code did, but did so via out_line and therefore couldn't - * have worked well in all cases... */ - return (0); -} - -/***** Program **********************************************************/ -/* get_next_code() - * - gets the next code from the GIF file. Returns the code, or else - * a negative number in case of file errors... - */ -static short get_next_code() -{ - static BYTE b1; /* Current byte */ - static unsigned short ret_code; - - if (nbits_left == 0) - { - if (navail_bytes <= 0) - { - - /* Out of bytes in current block, so read next block */ - pbytes = byte_buff; - if ((navail_bytes = (short) get_byte()) < 0) - return (navail_bytes); - else if (navail_bytes) - get_bytes(byte_buff, navail_bytes); - } - b1 = *pbytes++; - nbits_left = 8; - --navail_bytes; - } - - ret_code = (short) (b1 >> (8 - nbits_left)); - while (curr_size > nbits_left) - { - if (navail_bytes <= 0) - { - - /* Out of bytes in current block, so read next block */ - pbytes = byte_buff; - if ((navail_bytes = (short) get_byte()) < 0) - return (navail_bytes); - else if (navail_bytes) - get_bytes(byte_buff, navail_bytes); - } - b1 = *pbytes++; - ret_code |= b1 << nbits_left; - nbits_left += 8; - --navail_bytes; - } - nbits_left -= curr_size; - return ((short) (ret_code & code_mask[curr_size])); -} - -/* called in parent reoutine to set byte_buff */ -void set_byte_buff(BYTE * ptr) -{ - byte_buff = ptr; -} diff --git a/fractint/common/diskvid.c b/fractint/common/diskvid.c deleted file mode 100644 index 98f09e414..000000000 --- a/fractint/common/diskvid.c +++ /dev/null @@ -1,750 +0,0 @@ -/* - "Disk-Video" (and RAM-Video and Expanded-Memory Video) routines - - Reworked with fast caching July '90 by Pieter Branderhorst. - (I'm proud of this cache handler, had to get my name on it!) - Caution when modifying any code in here: bugs are possible which - slow the cache substantially but don't cause incorrect results. - Do timing tests for a variety of situations after any change. - -*/ - -#include - -/* see Fractint.c for a description of the "include" hierarchy */ -#include "port.h" -#include "prototyp.h" -#include "drivers.h" - -#define BOXROW 6 -#define BOXCOL 11 -#define BOXWIDTH 57 -#define BOXDEPTH 12 - -int disk16bit = 0; /* storing 16 bit values for continuous potential */ - -static int timetodisplay; -static FILE *fp = NULL; -static int disktarga; - -#define BLOCKLEN 2048 /* must be a power of 2, must match next */ -#define BLOCKSHIFT 11 /* must match above */ -#define CACHEMIN 4 /* minimum cache size in Kbytes */ -#define CACHEMAX 64 /* maximum cache size in Kbytes */ -#define FREEMEM 33 /* try to leave this much memory unallocated */ -#define HASHSIZE 1024 /* power of 2, near CACHEMAX/(BLOCKLEN+8) */ - -static struct cache /* structure of each cache entry */ -{ - long offset; /* pixel offset in image */ - BYTE pixel[BLOCKLEN]; /* one pixel per byte (this *is* faster) */ - unsigned int hashlink; /* ptr to next cache entry with same hash */ - unsigned int dirty : 1; /* changed since read? */ - unsigned int lru : 1; /* recently used? */ -} *cache_end, *cache_lru, *cur_cache; - -static struct cache *cache_start = NULL; -static long high_offset; /* highwater mark of writes */ -static long seek_offset; /* what we'll get next if we don't seek */ -static long cur_offset; /* offset of last block referenced */ -static int cur_row; -static long cur_row_base; -static unsigned int hash_ptr[HASHSIZE] = { 0 }; -static int pixelshift; -static int headerlength; -static int rowsize = 0; /* doubles as a disk video not ok flag */ -static int colsize; /* sydots, *2 when pot16bit */ - -static BYTE *membuf; -static U16 dv_handle = 0; -static long memoffset = 0; -static long oldmemoffset = 0; -static BYTE *membufptr; - -static void _fastcall findload_cache(long); -static struct cache * _fastcall find_cache(long); -static void write_cache_lru(void); -static void _fastcall mem_putc(BYTE); -static BYTE mem_getc(void); -static void _fastcall mem_seek(long); - -int startdisk() -{ - headerlength = disktarga = 0; - return common_startdisk(sxdots, sydots, colors); -} - -int pot_startdisk() -{ - int i; - if (driver_diskp()) /* ditch the original disk file */ - { - enddisk(); - } - else - { - showtempmsg("clearing 16bit pot work area"); - } - headerlength = disktarga = 0; - i = common_startdisk(sxdots, sydots << 1, colors); - cleartempmsg(); - if (i == 0) - { - disk16bit = 1; - } - - return i; -} - -int targa_startdisk(FILE *targafp, int overhead) -{ - int i; - if (driver_diskp()) /* ditch the original file, make just the targa */ - { - enddisk(); /* close the 'screen' */ - setnullvideo(); /* set readdot and writedot routines to do nothing */ - } - headerlength = overhead; - fp = targafp; - disktarga = 1; - i = common_startdisk(xdots*3, ydots, colors); - high_offset = 100000000L; /* targa not necessarily init'd to zeros */ - - return i; -} - -int _fastcall common_startdisk(long newrowsize, long newcolsize, int colors) -{ - int i, freemem; - long memorysize, offset; - unsigned int *fwd_link = NULL; - struct cache *ptr1 = NULL; - long longtmp; - unsigned int cache_size; - BYTE *tempfar = NULL; - if (g_disk_flag) - { - enddisk(); - } - if (driver_diskp()) /* otherwise, real screen also in use, don't hit it */ - { - char buf[128]; - helptitle(); - driver_set_attr(1, 0, C_DVID_BKGRD, 24*80); /* init rest to background */ - for (i = 0; i < BOXDEPTH; ++i) - { - driver_set_attr(BOXROW+i, BOXCOL, C_DVID_LO, BOXWIDTH); /* init box */ - } - driver_put_string(BOXROW+2, BOXCOL+4, C_DVID_HI, "'Disk-Video' mode"); - sprintf(buf, "Screen resolution: %d x %d", sxdots, sydots); - driver_put_string(BOXROW+4, BOXCOL+4, C_DVID_LO, buf); - if (disktarga) - { - driver_put_string(-1, -1, C_DVID_LO, " 24 bit Targa"); - } - else - { - driver_put_string(-1, -1, C_DVID_LO, " Colors: "); - sprintf(buf, "%d", colors); - driver_put_string(-1, -1, C_DVID_LO, buf); - } - sprintf(buf, "Save name: %s", savename); - driver_put_string(BOXROW+8, BOXCOL+4, C_DVID_LO, buf); - driver_put_string(BOXROW+10, BOXCOL+4, C_DVID_LO, "Status:"); - dvid_status(0, "clearing the 'screen'"); - } - cur_offset = seek_offset = high_offset = -1; - cur_row = -1; - if (disktarga) - { - pixelshift = 0; - } - else - { - pixelshift = 3; - i = 2; - while (i < colors) - { - i *= i; - --pixelshift; - } - } - timetodisplay = bf_math ? 10 : 1000; /* time-to-g_driver-status counter */ - - /* allocate cache: try for the max; leave FREEMEMk free if we can get - that much or more; if we can't get that much leave 1/2 of whatever - there is free; demand a certain minimum or nogo at all */ - freemem = FREEMEM; - - for (cache_size = CACHEMAX; cache_size >= CACHEMIN; --cache_size) - { - longtmp = ((int)cache_size < freemem) ? - (long)cache_size << 11 : (long)(cache_size+freemem) << 10; - if ((tempfar = malloc(longtmp)) != NULL) - { - free(tempfar); - break; - } - } - if (debugflag == 4200) - { - cache_size = CACHEMIN; - } - longtmp = (long)cache_size << 10; - cache_start = (struct cache *)malloc(longtmp); - if (cache_size == 64) - { - --longtmp; /* safety for next line */ - } - cache_end = (cache_lru = cache_start) + longtmp / sizeof(*cache_start); - membuf = (BYTE *)malloc((long)BLOCKLEN); - if (cache_start == NULL || membuf == NULL) - { - stopmsg(0, "*** insufficient free memory for cache buffers ***"); - return -1; - } - if (driver_diskp()) - { - char buf[50]; - sprintf(buf, "Cache size: %dK", cache_size); - driver_put_string(BOXROW+6, BOXCOL+4, C_DVID_LO, buf); - } - - /* preset cache to all invalid entries so we don't need free list logic */ - for (i = 0; i < HASHSIZE; ++i) - { - hash_ptr[i] = 0xffff; /* 0xffff marks the end of a hash chain */ - } - longtmp = 100000000L; - for (ptr1 = cache_start; ptr1 < cache_end; ++ptr1) - { - ptr1->dirty = ptr1->lru = 0; - longtmp += BLOCKLEN; - fwd_link = &hash_ptr[(((unsigned short)longtmp >> BLOCKSHIFT) & (HASHSIZE-1))]; - ptr1->offset = longtmp; - ptr1->hashlink = *fwd_link; - *fwd_link = (int) ((char *)ptr1 - (char *)cache_start); - } - - memorysize = (long)(newcolsize) * newrowsize + headerlength; - if ((i = (short)memorysize & (BLOCKLEN-1)) != 0) - { - memorysize += BLOCKLEN - i; - } - memorysize >>= pixelshift; - memorysize >>= BLOCKSHIFT; - g_disk_flag = 1; - rowsize = (unsigned int) newrowsize; - colsize = (unsigned int) newcolsize; - - if (disktarga) - { - /* Retrieve the header information first */ - BYTE *tmpptr; - tmpptr = membuf; - fseek(fp, 0L, SEEK_SET); - for (i = 0; i < headerlength; i++) - { - *tmpptr++ = (BYTE)fgetc(fp); - } - fclose(fp); - dv_handle = MemoryAlloc((U16)BLOCKLEN, memorysize, DISK); - } - else - { - dv_handle = MemoryAlloc((U16)BLOCKLEN, memorysize, MEMORY); - } - if (dv_handle == 0) - { - stopmsg(0, "*** insufficient free memory/disk space ***"); - g_good_mode = 0; - rowsize = 0; - return -1; - } - - if (driver_diskp()) - { - driver_put_string(BOXROW+2, BOXCOL+23, C_DVID_LO, - (MemoryType(dv_handle) == DISK) ? "Using your Disk Drive" : "Using your memory"); - } - - membufptr = membuf; - - if (disktarga) - { - /* Put header information in the file */ - MoveToMemory(membuf, (U16)headerlength, 1L, 0, dv_handle); - } - else - { - for (offset = 0; offset < memorysize; offset++) - { - SetMemory(0, (U16)BLOCKLEN, 1L, offset, dv_handle); - if (driver_key_pressed()) /* user interrupt */ - { - /* esc to cancel, else continue */ - if (stopmsg(STOPMSG_CANCEL, "Disk Video initialization interrupted:\n")) - { - enddisk(); - g_good_mode = 0; - return -2; /* -1 == failed, -2 == cancel */ - } - } - } - } - - if (driver_diskp()) - { - dvid_status(0, ""); - } - return 0; -} - -void enddisk() -{ - if (fp != NULL) - { - if (disktarga) /* flush the cache */ - { - for (cache_lru = cache_start; cache_lru < cache_end; ++cache_lru) - { - if (cache_lru->dirty) - { - write_cache_lru(); - } - } - } - fclose(fp); - fp = NULL; - } - - if (dv_handle != 0) - { - MemoryRelease(dv_handle); - dv_handle = 0; - } - if (cache_start != NULL) - { - free((void *)cache_start); - cache_start = NULL; - } - if (membuf != NULL) - { - free((void *)membuf); - membuf = NULL; - } - g_disk_flag = rowsize = disk16bit = 0; -} - -int readdisk(int col, int row) -{ - int col_subscr; - long offset; - char buf[41]; - if (--timetodisplay < 0) /* time to g_driver status? */ - { - if (driver_diskp()) - { - sprintf(buf, " reading line %4d", - (row >= sydots) ? row-sydots : row); /* adjust when potfile */ - dvid_status(0, buf); - } - if (bf_math) - { - timetodisplay = 10; /* time-to-g_driver-status counter */ - } - else - { - timetodisplay = 1000; /* time-to-g_driver-status counter */ - } - } - if (row != cur_row) /* try to avoid ghastly code generated for multiply */ - { - if (row >= colsize) /* while we're at it avoid this test if not needed */ - { - return 0; - } - cur_row = row; - cur_row_base = (long) cur_row * rowsize; - } - if (col >= rowsize) - { - return 0; - } - offset = cur_row_base + col; - col_subscr = (short) offset & (BLOCKLEN-1); /* offset within cache entry */ - if (cur_offset != (offset & (0L-BLOCKLEN))) /* same entry as last ref? */ - { - findload_cache(offset & (0L-BLOCKLEN)); - } - return cur_cache->pixel[col_subscr]; -} - -int FromMemDisk(long offset, int size, void *dest) -{ - int col_subscr = (int) (offset & (BLOCKLEN - 1)); - if (col_subscr + size > BLOCKLEN) /* access violates a */ - { - return 0; /* cache boundary */ - } - if (cur_offset != (offset & (0L-BLOCKLEN))) /* same entry as last ref? */ - { - findload_cache(offset & (0L-BLOCKLEN)); - } - memcpy(dest, (void *) &cur_cache->pixel[col_subscr], size); - cur_cache->dirty = 0; - return 1; -} - - -void targa_readdisk(unsigned int col, unsigned int row, - BYTE *red, BYTE *green, BYTE *blue) -{ - col *= 3; - *blue = (BYTE)readdisk(col, row); - *green = (BYTE)readdisk(++col, row); - *red = (BYTE)readdisk(col+1, row); -} - -void writedisk(int col, int row, int color) -{ - int col_subscr; - long offset; - char buf[41]; - if (--timetodisplay < 0) /* time to display status? */ - { - if (driver_diskp()) - { - sprintf(buf, " writing line %4d", - (row >= sydots) ? row-sydots : row); /* adjust when potfile */ - dvid_status(0, buf); - } - timetodisplay = 1000; - } - if (row != (unsigned int) cur_row) /* try to avoid ghastly code generated for multiply */ - { - if (row >= colsize) /* while we're at it avoid this test if not needed */ - { - return; - } - cur_row_base = (long) (cur_row = row) * rowsize; - } - if (col >= rowsize) - { - return; - } - offset = cur_row_base + col; - col_subscr = (short) offset & (BLOCKLEN-1); - if (cur_offset != (offset & (0L-BLOCKLEN))) /* same entry as last ref? */ - { - findload_cache(offset & (0L-BLOCKLEN)); - } - if (cur_cache->pixel[col_subscr] != (color & 0xff)) - { - cur_cache->pixel[col_subscr] = (BYTE) color; - cur_cache->dirty = 1; - } -} - -int ToMemDisk(long offset, int size, void *src) -{ - int col_subscr = (int)(offset & (BLOCKLEN - 1)); - - if (col_subscr + size > BLOCKLEN) /* access violates a */ - { - return 0; /* cache boundary */ - } - - if (cur_offset != (offset & (0L-BLOCKLEN))) /* same entry as last ref? */ - { - findload_cache (offset & (0L-BLOCKLEN)); - } - - memcpy((void *) &cur_cache->pixel[col_subscr], src, size); - cur_cache->dirty = 1; - return 1; -} - -void targa_writedisk(unsigned int col, unsigned int row, - BYTE red, BYTE green, BYTE blue) -{ - writedisk(col *= 3, row, blue); - writedisk(++col, row, green); - writedisk(col+1, row, red); -} - -static void _fastcall findload_cache(long offset) /* used by read/write */ -{ -#ifndef XFRACT - unsigned int tbloffset; - int i, j; - unsigned int *fwd_link; - BYTE *pixelptr; - BYTE tmpchar; - cur_offset = offset; /* note this for next reference */ - /* check if required entry is in cache - lookup by hash */ - tbloffset = hash_ptr[ ((unsigned short)offset >> BLOCKSHIFT) & (HASHSIZE-1) ]; - while (tbloffset != 0xffff) /* follow the hash chain */ - { - cur_cache = (struct cache *)((char *)cache_start + tbloffset); - if (cur_cache->offset == offset) /* great, it is in the cache */ - { - cur_cache->lru = 1; - return; - } - tbloffset = cur_cache->hashlink; - } - /* must load the cache entry from backing store */ - for (;;) /* look around for something not recently used */ - { - if (++cache_lru >= cache_end) - { - cache_lru = cache_start; - } - if (cache_lru->lru == 0) - { - break; - } - cache_lru->lru = 0; - } - if (cache_lru->dirty) /* must write this block before reusing it */ - { - write_cache_lru(); - } - /* remove block at cache_lru from its hash chain */ - fwd_link = &hash_ptr[(((unsigned short)cache_lru->offset >> BLOCKSHIFT) & (HASHSIZE-1))]; - tbloffset = (int) ((char *)cache_lru - (char *)cache_start); - while (*fwd_link != tbloffset) - { - fwd_link = &((struct cache *)((char *)cache_start+*fwd_link))->hashlink; - } - *fwd_link = cache_lru->hashlink; - /* load block */ - cache_lru->dirty = 0; - cache_lru->lru = 1; - cache_lru->offset = offset; - pixelptr = &cache_lru->pixel[0]; - if (offset > high_offset) /* never been this high before, just clear it */ - { - high_offset = offset; - memset(pixelptr, 0, BLOCKLEN); - pixelptr += BLOCKLEN; - } - else - { - if (offset != seek_offset) - { - mem_seek(offset >> pixelshift); - } - seek_offset = offset + BLOCKLEN; - switch (pixelshift) - { - case 0: - for (i = 0; i < BLOCKLEN; ++i) - { - *(pixelptr++) = mem_getc(); - } - break; - - case 1: - for (i = 0; i < BLOCKLEN/2; ++i) { - tmpchar = mem_getc(); - *(pixelptr++) = (BYTE)(tmpchar >> 4); - *(pixelptr++) = (BYTE)(tmpchar & 15); - } - break; - case 2: - for (i = 0; i < BLOCKLEN/4; ++i) { - tmpchar = mem_getc(); - for (j = 6; j >= 0; j -= 2) - *(pixelptr++) = (BYTE)((tmpchar >> j) & 3); - } - break; - case 3: - for (i = 0; i < BLOCKLEN/8; ++i) { - tmpchar = mem_getc(); - for (j = 7; j >= 0; --j) - *(pixelptr++) = (BYTE)((tmpchar >> j) & 1); - } - break; - } - } - /* add new block to its hash chain */ - fwd_link = &hash_ptr[(((unsigned short)offset >> BLOCKSHIFT) & (HASHSIZE-1))]; - cache_lru->hashlink = *fwd_link; - *fwd_link = (int) ((char *)cache_lru - (char *)cache_start); - cur_cache = cache_lru; -#endif -} - -/* lookup for write_cache_lru */ -static struct cache * _fastcall find_cache(long offset) -{ -#ifndef XFRACT - unsigned int tbloffset; - struct cache *ptr1; - tbloffset = hash_ptr[((unsigned short)offset >> BLOCKSHIFT) & (HASHSIZE-1)]; - while (tbloffset != 0xffff) - { - ptr1 = (struct cache *)((char *)cache_start + tbloffset); - if (ptr1->offset == offset) - { - return (ptr1); - } - tbloffset = ptr1->hashlink; - } - return NULL; -#endif -} - -static void write_cache_lru() -{ - int i, j; - BYTE *pixelptr; - long offset; - BYTE tmpchar = 0; - struct cache *ptr1, *ptr2; -#define WRITEGAP 4 /* 1 for no gaps */ - /* scan back to also write any preceding dirty blocks, skipping small gaps */ - ptr1 = cache_lru; - offset = ptr1->offset; - i = 0; - while (++i <= WRITEGAP) - { - if ((ptr2 = find_cache(offset -= BLOCKLEN)) != NULL && ptr2->dirty) - { - ptr1 = ptr2; - i = 0; - } - } - /* write all consecutive dirty blocks (often whole cache in 1pass modes) */ - /* keep going past small gaps */ - -write_seek: - mem_seek(ptr1->offset >> pixelshift); - -write_stuff: - pixelptr = &ptr1->pixel[0]; - switch (pixelshift) - { - case 0: - for (i = 0; i < BLOCKLEN; ++i) - mem_putc(*(pixelptr++)); - break; - case 1: - for (i = 0; i < BLOCKLEN/2; ++i) - { - tmpchar = (BYTE)(*(pixelptr++) << 4); - tmpchar = (BYTE)(tmpchar + *(pixelptr++)); - mem_putc(tmpchar); - } - break; - case 2: - for (i = 0; i < BLOCKLEN/4; ++i) - { - for (j = 6; j >= 0; j -= 2) - tmpchar = (BYTE)((tmpchar << 2) + *(pixelptr++)); - mem_putc(tmpchar); - } - break; - case 3: - for (i = 0; i < BLOCKLEN/8; ++i) - { - mem_putc((BYTE) - ((((((((((((((*pixelptr - << 1) - | *(pixelptr+1) ) - << 1) - | *(pixelptr+2) ) - << 1) - | *(pixelptr+3) ) - << 1) - | *(pixelptr+4) ) - << 1) - | *(pixelptr+5) ) - << 1) - | *(pixelptr+6) ) - << 1) - | *(pixelptr+7))); - pixelptr += 8; - } - break; - } - ptr1->dirty = 0; - offset = ptr1->offset + BLOCKLEN; - if ((ptr1 = find_cache(offset)) != NULL && ptr1->dirty != 0) - { - goto write_stuff; - } - i = 1; - while (++i <= WRITEGAP) - { - if ((ptr1 = find_cache(offset += BLOCKLEN)) != NULL && ptr1->dirty != 0) - { - goto write_seek; - } - } - seek_offset = -1; /* force a seek before next read */ -} - -/* Seek, mem_getc, mem_putc routines follow. - Note that the calling logic always separates mem_getc and mem_putc - sequences with a seek between them. A mem_getc is never followed by - a mem_putc nor v.v. without a seek between them. - */ -static void _fastcall mem_seek(long offset) /* mem seek */ -{ - offset += headerlength; - memoffset = offset >> BLOCKSHIFT; - if (memoffset != oldmemoffset) - { - MoveToMemory(membuf, (U16)BLOCKLEN, 1L, oldmemoffset, dv_handle); - MoveFromMemory(membuf, (U16)BLOCKLEN, 1L, memoffset, dv_handle); - } - oldmemoffset = memoffset; - membufptr = membuf + (offset & (BLOCKLEN - 1)); -} - -static BYTE mem_getc() /* memory get_char */ -{ - if (membufptr - membuf >= BLOCKLEN) - { - MoveToMemory(membuf, (U16)BLOCKLEN, 1L, memoffset, dv_handle); - memoffset++; - MoveFromMemory(membuf, (U16)BLOCKLEN, 1L, memoffset, dv_handle); - membufptr = membuf; - oldmemoffset = memoffset; - } - return (*(membufptr++)); -} - -static void _fastcall mem_putc(BYTE c) /* memory get_char */ -{ - if (membufptr - membuf >= BLOCKLEN) - { - MoveToMemory(membuf, (U16)BLOCKLEN, 1L, memoffset, dv_handle); - memoffset++; - MoveFromMemory(membuf, (U16)BLOCKLEN, 1L, memoffset, dv_handle); - membufptr = membuf; - oldmemoffset = memoffset; - } - *(membufptr++) = c; -} - - -void dvid_status(int line, char *msg) -{ - char buf[41]; - int attrib; - memset(buf, ' ', 40); - memcpy(buf, msg, (int) strlen(msg)); - buf[40] = 0; - attrib = C_DVID_HI; - if (line >= 100) - { - line -= 100; - attrib = C_STOP_ERR; - } - driver_put_string(BOXROW+10+line, BOXCOL+12, attrib, buf); - driver_hide_text_cursor(); -} diff --git a/fractint/common/drivers.c b/fractint/common/drivers.c deleted file mode 100644 index 25ad4b204..000000000 --- a/fractint/common/drivers.c +++ /dev/null @@ -1,342 +0,0 @@ -#include "port.h" -#include "prototyp.h" -#include "externs.h" -#include "cmplx.h" -#include "drivers.h" - -#include - -extern Driver *x11_driver; -extern Driver *gdi_driver; -extern Driver *disk_driver; - -/* list of drivers that are supported by source code in fractint */ -/* default driver is first one in the list that initializes. */ -#define MAX_DRIVERS 10 -static int num_drivers = 0; -static Driver *s_available[MAX_DRIVERS]; - -Driver *g_driver = NULL; - -static int -load_driver(Driver *drv, int *argc, char **argv) -{ - if (drv && drv->init) - { - const int num = (*drv->init)(drv, argc, argv); - if (num > 0) - { - if (! g_driver) - { - g_driver = drv; - } - s_available[num_drivers++] = drv; - return 1; - } - } - - return 0; -} - -/*------------------------------------------------------------ - * init_drivers - * - * Go through the static list of drivers defined and try to initialize - * them one at a time. Returns the number of drivers initialized. - */ -int -init_drivers(int *argc, char **argv) -{ -#if HAVE_X11_DRIVER - load_driver(x11_driver, argc, argv); -#endif - -#if HAVE_WIN32_DISK_DRIVER - load_driver(disk_driver, argc, argv); -#endif - -#if HAVE_GDI_DRIVER - load_driver(gdi_driver, argc, argv); -#endif - - return num_drivers; /* number of drivers supported at runtime */ -} - -/* add_video_mode - * - * a driver uses this to inform the system of an available video mode - */ -void -add_video_mode(Driver *drv, VIDEOINFO *mode) -{ -#if defined(_WIN32) - _ASSERTE(g_video_table_len < MAXVIDEOMODES); -#endif - /* stash away driver pointer so we can init driver for selected mode */ - mode->driver = drv; - memcpy(&g_video_table[g_video_table_len], mode, sizeof(g_video_table[0])); - g_video_table_len++; -} - -void -close_drivers(void) -{ - int i; - - for (i = 0; i < num_drivers; i++) - { - if (s_available[i]) - { - (*s_available[i]->terminate)(s_available[i]); - s_available[i] = NULL; - } - } - - g_driver = NULL; -} - -Driver * -driver_find_by_name(const char *name) -{ - int i; - - for (i = 0; i < num_drivers; i++) - { - if (strcmp(name, s_available[i]->name) == 0) - { - return s_available[i]; - } - } - return NULL; -} - -void -driver_set_video_mode(VIDEOINFO *mode) -{ - if (g_driver != mode->driver) - { - g_driver->pause(g_driver); - g_driver = mode->driver; - g_driver->resume(g_driver); - } - (*g_driver->set_video_mode)(g_driver, mode); -} - -#if defined(USE_DRIVER_FUNCTIONS) -void -driver_terminate(void) -{ - (*g_driver->terminate)(g_driver); -} - -#define METHOD_VOID(name_) \ -void driver_##name_(void) { (*g_driver->name_)(g_driver); } -#define METHOD(type_,name_) \ -type_ driver_##name_(void) { return (*g_driver->name_)(g_driver); } -#define METHOD_INT(name_) METHOD(int,name_) - -void -driver_schedule_alarm(int soon) -{ - (*g_driver->schedule_alarm)(g_driver, soon); -} - -METHOD_VOID(window) -METHOD_INT(resize) -METHOD_VOID(redraw) -METHOD_INT(read_palette) -METHOD_INT(write_palette) - -int -driver_read_pixel(int x, int y) -{ - return (*g_driver->read_pixel)(g_driver, x, y); -} - -void -driver_write_pixel(int x, int y, int color) -{ - (*g_driver->write_pixel)(g_driver, x, y, color); -} - -void -driver_read_span(int y, int x, int lastx, BYTE *pixels) -{ - (*g_driver->read_span)(g_driver, y, x, lastx, pixels); -} - -void -driver_write_span(int y, int x, int lastx, BYTE *pixels) -{ - (*g_driver->write_span)(g_driver, y, x, lastx, pixels); -} - -void -driver_set_line_mode(int mode) -{ - (*g_driver->set_line_mode)(g_driver, mode); -} - -void -driver_draw_line(int x1, int y1, int x2, int y2, int color) -{ - (*g_driver->draw_line)(g_driver, x1, y1, x2, y2, color); -} - -int -driver_get_key(void) -{ - return (*g_driver->get_key)(g_driver); -} - -int -driver_key_cursor(int row, int col) -{ - return (*g_driver->key_cursor)(g_driver, row, col); -} - -int -driver_key_pressed(void) -{ - return (*g_driver->key_pressed)(g_driver); -} - -int -driver_wait_key_pressed(int timeout) -{ - return (*g_driver->wait_key_pressed)(g_driver, timeout); -} - -METHOD_VOID(shell) - -void -driver_put_string(int row, int col, int attr, const char *msg) -{ - (*g_driver->put_string)(g_driver, row, col, attr, msg); -} - -METHOD_VOID(set_for_text) -METHOD_VOID(set_for_graphics) -METHOD_VOID(set_clear) - -void -driver_move_cursor(int row, int col) -{ - (*g_driver->move_cursor)(g_driver, row, col); -} - -METHOD_VOID(hide_text_cursor) - -void -driver_set_attr(int row, int col, int attr, int count) -{ - (*g_driver->set_attr)(g_driver, row, col, attr, count); -} - -void -driver_scroll_up(int top, int bot) -{ - (*g_driver->scroll_up)(g_driver, top, bot); -} - -METHOD_VOID(stack_screen) -METHOD_VOID(unstack_screen) -METHOD_VOID(discard_screen) - -METHOD_INT(init_fm) - -void -driver_buzzer(int kind) -{ - (*g_driver->buzzer)(g_driver, kind); -} - -int -driver_sound_on(int freq) -{ - return (*g_driver->sound_on)(g_driver, freq); -} - -METHOD_VOID(sound_off) -METHOD_VOID(mute) -METHOD_INT(diskp) - -int -driver_get_char_attr(void) -{ - return (*g_driver->get_char_attr)(g_driver); -} - -void -driver_put_char_attr(int char_attr) -{ - (*g_driver->put_char_attr)(g_driver, char_attr); -} - -int -driver_validate_mode(VIDEOINFO *mode) -{ - return (*g_driver->validate_mode)(g_driver, mode); -} - -void -driver_unget_key(int key) -{ - (*g_driver->unget_key)(g_driver, key); -} - -void -driver_delay(int ms) -{ - (*g_driver->delay)(g_driver, ms); -} - -void -driver_get_truecolor(int x, int y, int *r, int *g, int *b, int *a) -{ - (*g_driver->get_truecolor)(g_driver, x, y, r, g, b, a); -} - -void -driver_put_truecolor(int x, int y, int r, int g, int b, int a) -{ - (*g_driver->put_truecolor)(g_driver, x, y, r, g, b, a); -} - -void -driver_display_string(int x, int y, int fg, int bg, const char *text) -{ - (*g_driver->display_string)(g_driver, x, y, fg, bg, text); -} - -void -driver_save_graphics(void) -{ - (*g_driver->save_graphics)(g_driver); -} - -void -driver_restore_graphics(void) -{ - (*g_driver->restore_graphics)(g_driver); -} - -void -driver_get_max_screen(int *xmax, int *ymax) -{ - (*g_driver->get_max_screen)(g_driver, xmax, ymax); -} - -void -driver_set_keyboard_timeout(int ms) -{ - (*g_driver->set_keyboard_timeout)(g_driver, ms); -} - -void -driver_flush(void) -{ - (*g_driver->flush)(g_driver); -} - -#endif diff --git a/fractint/common/editpal.c b/fractint/common/editpal.c deleted file mode 100644 index bf8423750..000000000 --- a/fractint/common/editpal.c +++ /dev/null @@ -1,3459 +0,0 @@ -/* - * editpal.c - * - * Edits VGA 256-color palettes. - * - * Key to initials: - * - * EAN - Ethan Nagel [70022,2552] - * - * JJB - Juan J. Buhler [jbuhler@gidef.edu.ar] - * - * TIW - Tim Wegner - * - * AMC - Andrew McCarthy [andrewmc@netsoc.ucd.ie] - * - * Revision History: - * - * 10-22-90 EAN Initial release. - * - * 10-23-90 EAN "Discovered" get_line/put_line functions, integrated - * them in (instead of only getcolor/putcolor). Much - * faster! - * Redesigned color editors (now at top of palette) and - * re-assigned some keys. - * Added (A)uto option. - * Fixed memory allocation problem. Now uses shared - * FRACTINT data area (strlocn). Uses 6 bytes DS. - * - * 10-27-90 EAN Added save to memory option - will save screen image to - * memory, if enough mem avail. (disk otherwise). - * Added s(T)ripe mode - works like (S)hade except only - * changes every n'th entry. - * Added temporary palette save/restore. (Can work like - * an undo feature.) Thanks to Pieter Branderhorst for - * idea. - * - * 10-28-90 EAN The (H)ide function now makes the palette invisible, - * while allowing any other operations (except '\\' - - * move/resize) to continue. - * - * 10-29-90 PB (in EAN's absence, ) - * Change 'c' to 'd' and 's' to '=' for below. - * Add 'l' to load palette from .map, 's' to store .map. - * Add 'c' to invoke color cycling. - * Change cursor to use whatever colors it can from - * the palette (not fixed 0 and 255). - * Restore colors 0 and 255 to real values whenever - * palette is not on display. - * Rotate 255 colors instead of 254. - * Reduce cursor blink rate. - * - * 11-15-90 EAN Minor "bug" fixes. Continuous rotation now at a fixed - * rate - once every timer tick (18.2 sec); Blanks out - * color samples when rotating; Editors no longer rotate - * with the colors in color rotation mode; Eliminated - * (Z)oom mode; other minor fixes. - * - * 01-05-91 PB Add 'w' function to convert to greyscale. - * - * 01-16-91 PB Change rotate function to use new cyclerange stuff. - * - * 01-29-91 EAN Made all colors editable. The two reserved colors are - * X'ed out. They can be edited but the color is not - * visible. (There is an X over the sample instead.) - * Changed default reserved colors to 254 & 255. - * Added 'v' command to set the reserved colors to those - * under the editors. - * Added 'o' command to set the rotate range to between - * the two editors. - * Modified 'w' function: - * uses internal function to do conversion (not BIOS) - * will convert only current color if in 'x' mode or - * range between editors in 'y' mode or entire palette - * if in "normal" mode. - * - * 02-08-91 EAN Improved 16 color support. In 16 color mode, colors - * 16-255 have a dot over them and are editable but not - * visible (like the two reserved colors). - * - * 09-08-91 SWT Added 'n' command to make a negative color palette: - * will convert only current color if in 'x' mode or - * range between editors in 'y' mode or entire palette - * if in "normal" mode. - * - * 03-03-92 JJB Added '!', '@' and '#' commands to swap RG, GB and - * RB columns (sorry, I didn't find better keys) - * - * 10-03-92 TIW Minor changes for Jiim support, primarily changing - * variables from static to global. - * - * 2-11-93 EAN Added full Undo ('U' key) and Redo ('E' key) - * capability. Works pretty much as you'd expect - * it to. - * - * 3-6-93 EAN Modified "freestyle" mode, written by RB, to integrate - * into palette editor more completely and work with - * undo logic. - * Added status area under the "fractint" message to - * display current state of editor. A = Auto mode, - * X, Y = exclusion modes, F = freesyle mode, T = stripe - * mode is waiting for #. - * - * 03-21-97 AMC Made '"' work the same as '@' and made 'œ' work like - * '#' for those of us on this side of the Atlantic! - * The original palette is now stored in the other slots - * on startup, so you can 'undo all' if you haven't - * overwritten them already. Undo could do this, but - * this is handy. - * 05-22-97 TIW Replaced movedata with far_memcopy() - */ - -#ifdef DEBUG_UNDO -#include "mdisp.h" /* EAN 930211 *** Debug Only *** */ -#endif - -#include - -#ifndef USE_VARARGS -#include -#else -#include -#endif - - /* see Fractint.c for a description of the "include" hierarchy */ -#include "port.h" -#include "prototyp.h" -#include "drivers.h" - -/* - * misc. #defines - */ - -#define FONT_DEPTH 8 /* font size */ - -#define CSIZE_MIN 8 /* csize cannot be smaller than this */ - -#define CURSOR_SIZE 5 /* length of one side of the x-hair cursor */ - -#ifndef XFRACT -#define CURSOR_BLINK_RATE 3 /* timer ticks between cursor blinks */ -#else -#define CURSOR_BLINK_RATE 300 /* timer ticks between cursor blinks */ -#endif - -#define FAR_RESERVE 8192L /* amount of mem we will leave avail. */ - -#define MAX_WIDTH 1024 /* palette editor cannot be wider than this */ - -char scrnfile[] = "FRACTINT.$$1"; /* file where screen portion is */ - /* stored */ -char undofile[] = "FRACTINT.$$2"; /* file where undo list is stored */ -#define TITLE "FRACTINT" - -#define TITLE_LEN (8) - - -#define newx(size) mem_alloc(size) -#define new(class) (class *)(mem_alloc(sizeof(class))) -#define delete(block) block=NULL /* just for warning */ - -#ifdef XFRACT -int editpal_cursor = 0; -#endif - - -/* - * Stuff from fractint - */ - -#if 0 - /* declarations moved to PRORTOTYPE.H - this left for docs */ - BYTE dacbox[256][3]; /* DAC spindac() will use */ - int sxdots; /* width of physical screen */ - int sydots; /* depth of physical screen */ - int sxoffs; /* start of logical screen */ - int syoffs; /* start of logical screen */ - int lookatmouse; /* mouse mode for driver_get_key(), etc */ - int strlocn[]; /* 10K buffer to store classes in */ - int colors; /* # colors avail. */ - int g_color_bright; /* brightest color in palette */ - int g_color_dark; /* darkest color in palette */ - int g_color_medium; /* nearest to medbright gray color */ - int rotate_lo, rotate_hi; - int debugflag; -#endif -int using_jiim = 0; - -/* - * basic data types - */ - - -typedef struct - { - BYTE red, - green, - blue; - } PALENTRY; - - - -/* - * static data - */ - - -BYTE *line_buff; /* must be alloced!!! */ -static BYTE fg_color, - bg_color; -static BOOLEAN reserve_colors; -static BOOLEAN inverse; - -static float gamma_val = 1; - - -/* - * Interface to FRACTINT's graphics stuff - */ - - -static void setpal(int pal, int r, int g, int b) - { - g_dac_box[pal][0] = (BYTE)r; - g_dac_box[pal][1] = (BYTE)g; - g_dac_box[pal][2] = (BYTE)b; - spindac(0,1); - } - - -static void setpalrange(int first, int how_many, PALENTRY *pal) - { - memmove(g_dac_box+first, pal, how_many*3); - spindac(0,1); - } - - -static void getpalrange(int first, int how_many, PALENTRY *pal) - { - memmove(pal, g_dac_box+first, how_many*3); - } - - -static void rotatepal(PALENTRY *pal, int dir, int lo, int hi) - { /* rotate in either direction */ - PALENTRY hold; - int size; - - size = 1 + (hi-lo); - - if ( dir > 0 ) - { - while ( dir-- > 0 ) - { - memmove(&hold, &pal[hi], 3); - memmove(&pal[lo+1], &pal[lo], 3*(size-1)); - memmove(&pal[lo], &hold, 3); - } - } - - else if ( dir < 0 ) - { - while ( dir++ < 0 ) - { - memmove(&hold, &pal[lo], 3); - memmove(&pal[lo], &pal[lo+1], 3*(size-1)); - memmove(&pal[hi], &hold, 3); - } - } - } - - -static void clip_put_line(int row, int start, int stop, BYTE *pixels) - { - if ( row < 0 || row >= sydots || start > sxdots || stop < 0 ) - return ; - - if ( start < 0 ) - { - pixels += -start; - start = 0; - } - - if ( stop >= sxdots ) - stop = sxdots - 1; - - if ( start > stop ) - return ; - - put_line(row, start, stop, pixels); - } - - -static void clip_get_line(int row, int start, int stop, BYTE *pixels) - { - if ( row < 0 || row >= sydots || start > sxdots || stop < 0 ) - return ; - - if ( start < 0 ) - { - pixels += -start; - start = 0; - } - - if ( stop >= sxdots ) - stop = sxdots - 1; - - if ( start > stop ) - return ; - - get_line(row, start, stop, pixels); - } - - -void clip_putcolor(int x, int y, int color) - { - if ( x < 0 || y < 0 || x >= sxdots || y >= sydots ) - return ; - - putcolor(x, y, color); - } - - -int clip_getcolor(int x, int y) - { - if ( x < 0 || y < 0 || x >= sxdots || y >= sydots ) - return 0; - - return getcolor(x, y); - } - - -static void hline(int x, int y, int width, int color) - { - memset(line_buff, color, width); - clip_put_line(y, x, x+width-1, line_buff); - } - - -static void vline(int x, int y, int depth, int color) - { - while (depth-- > 0) - clip_putcolor(x, y++, color); - } - - -void getrow(int x, int y, int width, char *buff) - { - clip_get_line(y, x, x+width-1, (BYTE *)buff); - } - - -void putrow(int x, int y, int width, char *buff) - { - clip_put_line(y, x, x+width-1, (BYTE *)buff); - } - - -static void vgetrow(int x, int y, int depth, char *buff) - { - while (depth-- > 0) - *buff++ = (char)clip_getcolor(x, y++); - } - - -static void vputrow(int x, int y, int depth, char *buff) - { - while (depth-- > 0) - clip_putcolor(x, y++, (BYTE)(*buff++)); - } - - -static void fillrect(int x, int y, int width, int depth, int color) - { - while (depth-- > 0) - hline(x, y++, width, color); - } - - -static void rect(int x, int y, int width, int depth, int color) - { - hline(x, y, width, color); - hline(x, y+depth-1, width, color); - - vline(x, y, depth, color); - vline(x+width-1, y, depth, color); - } - - -#ifndef USE_VARARGS -static void displayf(int x, int y, int fg, int bg, char *format, ...) -#else -static void displayf(va_alist) -va_dcl -#endif - { - char buff[81]; - - va_list arg_list; - -#ifndef USE_VARARGS - va_start(arg_list, format); -#else - int x,y,fg,bg; - char *format; - - va_start(arg_list); - x = va_arg(arg_list,int); - y = va_arg(arg_list,int); - fg = va_arg(arg_list,int); - bg = va_arg(arg_list,int); - format = va_arg(arg_list,char *); -#endif - vsprintf(buff, format, arg_list); - va_end(arg_list); - - driver_display_string(x, y, fg, bg, buff); -} - - -/* - * create smooth shades between two colors - */ - - -static void mkpalrange(PALENTRY *p1, PALENTRY *p2, PALENTRY pal[], int num, int skip) - { - int curr; - double rm = (double)((int) p2->red - (int) p1->red ) / num, - gm = (double)((int) p2->green - (int) p1->green) / num, - bm = (double)((int) p2->blue - (int) p1->blue ) / num; - - for (curr=0; currred == p2->red ) ? p1->red : - (int) p1->red + (int) ( rm * curr )); - pal[curr].green = (BYTE)((p1->green == p2->green) ? p1->green : - (int) p1->green + (int) ( gm * curr )); - pal[curr].blue = (BYTE)((p1->blue == p2->blue ) ? p1->blue : - (int) p1->blue + (int) ( bm * curr )); - } - else - { - pal[curr].red = (BYTE)((p1->red == p2->red ) ? p1->red : - (int) (p1->red + pow(curr/(double)(num-1),gamma_val)*num*rm)); - pal[curr].green = (BYTE)((p1->green == p2->green) ? p1->green : - (int) (p1->green + pow(curr/(double)(num-1),gamma_val)*num*gm)); - pal[curr].blue = (BYTE)((p1->blue == p2->blue ) ? p1->blue : - (int) (p1->blue + pow(curr/(double)(num-1),gamma_val)*num*bm)); - } - } - } - - - -/* Swap RG GB & RB columns */ - -static void rotcolrg(PALENTRY pal[], int num) - { - int curr; - int dummy; - - for (curr=0; curr<=num; curr++) - { - dummy = pal[curr].red; - pal[curr].red = pal[curr].green; - pal[curr].green = (BYTE)dummy; - } - } - - -static void rotcolgb(PALENTRY pal[], int num) - { - int curr; - int dummy; - - for (curr=0; curr<=num; curr++) - { - dummy = pal[curr].green; - pal[curr].green = pal[curr].blue; - pal[curr].blue = (BYTE)dummy; - } - } - -static void rotcolbr(PALENTRY pal[], int num) - { - int curr; - int dummy; - - for (curr=0; curr<=num; curr++) - { - dummy = pal[curr].red; - pal[curr].red = pal[curr].blue; - pal[curr].blue = (BYTE)dummy; - } - } - - -/* - * convert a range of colors to grey scale - */ - - -static void palrangetogrey(PALENTRY pal[], int first, int how_many) - { - PALENTRY *curr; - BYTE val; - - - for (curr = &pal[first]; how_many>0; how_many--, curr++) - { - val = (BYTE) ( ((int)curr->red*30 + (int)curr->green*59 + (int)curr->blue*11) / 100 ); - curr->red = curr->green = curr->blue = (BYTE)val; - } - } - -/* - * convert a range of colors to their inverse - */ - - -static void palrangetonegative(PALENTRY pal[], int first, int how_many) - { - PALENTRY *curr; - - for (curr = &pal[first]; how_many>0; how_many--, curr++) - { - curr->red = (BYTE)(63 - curr->red); - curr->green = (BYTE)(63 - curr->green); - curr->blue = (BYTE)(63 - curr->blue); - } - } - - -/* - * draw and horizontal/vertical dotted lines - */ - - -static void hdline(int x, int y, int width) - { - int ctr; - BYTE *ptr; - - for (ctr=0, ptr=line_buff; ctr= bx) && (y >= by) && (x < bx+bw) && (y < by+bd)); - } - - - -static void draw_diamond(int x, int y, int color) - { - putcolor (x+2, y+0, color); - hline (x+1, y+1, 3, color); - hline (x+0, y+2, 5, color); - hline (x+1, y+3, 3, color); - putcolor (x+2, y+4, color); - } - - - -/* - * Class: Cursor - * - * Purpose: Draw the blinking cross-hair cursor. - * - * Note: Only one Cursor can exist (referenced through the_cursor). - * IMPORTANT: Call Cursor_Construct before you use any other - * Cursor_ function! Call Cursor_Destroy before exiting to - * deallocate memory. - */ - -struct _Cursor - { - - int x, y; - int hidden; /* >0 if mouse hidden */ - long last_blink; - BOOLEAN blink; -#if 0 - char t[CURSOR_SIZE], /* save line segments here */ - b[CURSOR_SIZE], - l[CURSOR_SIZE], - r[CURSOR_SIZE]; -#endif - char t[CURSOR_SIZE]; /* save line segments here */ - char b[CURSOR_SIZE]; - char l[CURSOR_SIZE]; - char r[CURSOR_SIZE]; - } ; - -#define Cursor struct _Cursor - -/* private: */ - - static void Cursor__Draw (void); - static void Cursor__Save (void); - static void Cursor__Restore (void); - -/* public: */ -#ifdef NOT_USED - static BOOLEAN Cursor_IsHidden (void); -#endif - - - -static Cursor *the_cursor = NULL; - - -BOOLEAN Cursor_Construct(void) - { - if (the_cursor != NULL) - return FALSE; - - the_cursor = new(Cursor); - - the_cursor->x = sxdots/2; - the_cursor->y = sydots/2; - the_cursor->hidden = 1; - the_cursor->blink = FALSE; - the_cursor->last_blink = 0; - - return TRUE; - } - - -void Cursor_Destroy(void) - { - if (the_cursor != NULL) - delete(the_cursor); - - the_cursor = NULL; - } - - - -static void Cursor__Draw(void) - { - int color; - - find_special_colors(); - color = (the_cursor->blink) ? g_color_medium : g_color_dark; - - vline(the_cursor->x, the_cursor->y-CURSOR_SIZE-1, CURSOR_SIZE, color); - vline(the_cursor->x, the_cursor->y+2, CURSOR_SIZE, color); - - hline(the_cursor->x-CURSOR_SIZE-1, the_cursor->y, CURSOR_SIZE, color); - hline(the_cursor->x+2, the_cursor->y, CURSOR_SIZE, color); - } - - -static void Cursor__Save(void) - { - vgetrow(the_cursor->x, the_cursor->y-CURSOR_SIZE-1, CURSOR_SIZE, the_cursor->t); - vgetrow(the_cursor->x, the_cursor->y+2, CURSOR_SIZE, the_cursor->b); - - getrow(the_cursor->x-CURSOR_SIZE-1, the_cursor->y, CURSOR_SIZE, the_cursor->l); - getrow(the_cursor->x+2, the_cursor->y, CURSOR_SIZE, the_cursor->r); - } - - -static void Cursor__Restore(void) - { - vputrow(the_cursor->x, the_cursor->y-CURSOR_SIZE-1, CURSOR_SIZE, the_cursor->t); - vputrow(the_cursor->x, the_cursor->y+2, CURSOR_SIZE, the_cursor->b); - - putrow(the_cursor->x-CURSOR_SIZE-1, the_cursor->y, CURSOR_SIZE, the_cursor->l); - putrow(the_cursor->x+2, the_cursor->y, CURSOR_SIZE, the_cursor->r); - } - - - -void Cursor_SetPos(int x, int y) - { - if (!the_cursor->hidden) - Cursor__Restore(); - - the_cursor->x = x; - the_cursor->y = y; - - if (!the_cursor->hidden) - { - Cursor__Save(); - Cursor__Draw(); - } - } - -#ifdef NOT_USED - -static int Cursor_IsHidden(void) - { - return the_cursor->hidden; - } - - -#endif - - -void Cursor_Move(int xoff, int yoff) - { - if ( !the_cursor->hidden ) - Cursor__Restore(); - - the_cursor->x += xoff; - the_cursor->y += yoff; - - if (the_cursor->x < 0) the_cursor->x = 0; - if (the_cursor->y < 0) the_cursor->y = 0; - if (the_cursor->x >= sxdots) the_cursor->x = sxdots-1; - if (the_cursor->y >= sydots) the_cursor->y = sydots-1; - - if ( !the_cursor->hidden ) - { - Cursor__Save(); - Cursor__Draw(); - } - } - - -int Cursor_GetX(void) { return the_cursor->x; } - -int Cursor_GetY(void) { return the_cursor->y; } - - -void Cursor_Hide(void) - { - if ( the_cursor->hidden++ == 0 ) - Cursor__Restore(); - } - - -void Cursor_Show(void) - { - if ( --the_cursor->hidden == 0) - { - Cursor__Save(); - Cursor__Draw(); - } - } - -#ifdef XFRACT -void Cursor_StartMouseTracking() -{ - editpal_cursor = 1; -} - -void Cursor_EndMouseTracking() -{ - editpal_cursor = 0; -} -#endif - -/* See if the cursor should blink yet, and blink it if so */ -void Cursor_CheckBlink(void) -{ - long tick; - tick = readticker(); - - if ( (tick - the_cursor->last_blink) > CURSOR_BLINK_RATE ) - { - the_cursor->blink = (BOOLEAN)((the_cursor->blink) ? FALSE : TRUE); - the_cursor->last_blink = tick; - if ( !the_cursor->hidden ) - Cursor__Draw(); - } - else if ( tick < the_cursor->last_blink ) - the_cursor->last_blink = tick; -} - -int Cursor_WaitKey(void) /* blink cursor while waiting for a key */ - { - - while ( !driver_wait_key_pressed(1) ) { - Cursor_CheckBlink(); - } - - return driver_key_pressed(); - } - - - -/* - * Class: MoveBox - * - * Purpose: Handles the rectangular move/resize box. - */ - -struct _MoveBox - { - int x, y; - int base_width, - base_depth; - int csize; - BOOLEAN moved; - BOOLEAN should_hide; - char *t, *b, - *l, *r; - } ; - -#define MoveBox struct _MoveBox - -/* private: */ - - static void MoveBox__Draw (MoveBox *me); - static void MoveBox__Erase (MoveBox *me); - static void MoveBox__Move (MoveBox *me, int key); - -/* public: */ - - static MoveBox *MoveBox_Construct (int x, int y, int csize, int base_width, - int base_depth); - static void MoveBox_Destroy (MoveBox *me); - static BOOLEAN MoveBox_Process (MoveBox *me); /* returns FALSE if ESCAPED */ - static BOOLEAN MoveBox_Moved (MoveBox *me); - static BOOLEAN MoveBox_ShouldHide (MoveBox *me); - static int MoveBox_X (MoveBox *me); - static int MoveBox_Y (MoveBox *me); - static int MoveBox_CSize (MoveBox *me); - - static void MoveBox_SetPos (MoveBox *me, int x, int y); - static void MoveBox_SetCSize (MoveBox *me, int csize); - - - -static MoveBox *MoveBox_Construct(int x, int y, int csize, int base_width, int base_depth) - { - MoveBox *me = new(MoveBox); - - me->x = x; - me->y = y; - me->csize = csize; - me->base_width = base_width; - me->base_depth = base_depth; - me->moved = FALSE; - me->should_hide = FALSE; - me->t = newx(sxdots); - me->b = newx(sxdots); - me->l = newx(sydots); - me->r = newx(sydots); - - return me; - } - - -static void MoveBox_Destroy(MoveBox *me) - { - delete(me->t); - delete(me->b); - delete(me->l); - delete(me->r); - delete(me); - } - - -static BOOLEAN MoveBox_Moved(MoveBox *me) { return me->moved; } - -static BOOLEAN MoveBox_ShouldHide(MoveBox *me) { return me->should_hide; } - -static int MoveBox_X(MoveBox *me) { return me->x; } - -static int MoveBox_Y(MoveBox *me) { return me->y; } - -static int MoveBox_CSize(MoveBox *me) { return me->csize; } - - -static void MoveBox_SetPos(MoveBox *me, int x, int y) - { - me->x = x; - me->y = y; - } - - -static void MoveBox_SetCSize(MoveBox *me, int csize) - { - me->csize = csize; - } - - -static void MoveBox__Draw(MoveBox *me) /* private */ - { - int width = me->base_width + me->csize*16+1, - depth = me->base_depth + me->csize*16+1; - int x = me->x, - y = me->y; - - - getrow (x, y, width, me->t); - getrow (x, y+depth-1, width, me->b); - - vgetrow(x, y, depth, me->l); - vgetrow(x+width-1, y, depth, me->r); - - hdline(x, y, width); - hdline(x, y+depth-1, width); - - vdline(x, y, depth); - vdline(x+width-1, y, depth); - } - - -static void MoveBox__Erase(MoveBox *me) /* private */ - { - int width = me->base_width + me->csize*16+1, - depth = me->base_depth + me->csize*16+1; - - vputrow(me->x, me->y, depth, me->l); - vputrow(me->x+width-1, me->y, depth, me->r); - - putrow(me->x, me->y, width, me->t); - putrow(me->x, me->y+depth-1, width, me->b); - } - - -#define BOX_INC 1 -#define CSIZE_INC 2 - -static void MoveBox__Move(MoveBox *me, int key) - { - BOOLEAN done = FALSE; - BOOLEAN first = TRUE; - int xoff = 0, - yoff = 0; - - while ( !done ) - { - switch (key) - { - case FIK_CTL_RIGHT_ARROW: xoff += BOX_INC*4; break; - case FIK_RIGHT_ARROW: xoff += BOX_INC; break; - case FIK_CTL_LEFT_ARROW: xoff -= BOX_INC*4; break; - case FIK_LEFT_ARROW: xoff -= BOX_INC; break; - case FIK_CTL_DOWN_ARROW: yoff += BOX_INC*4; break; - case FIK_DOWN_ARROW: yoff += BOX_INC; break; - case FIK_CTL_UP_ARROW: yoff -= BOX_INC*4; break; - case FIK_UP_ARROW: yoff -= BOX_INC; break; - - default: - done = TRUE; - } - - if (!done) - { - if (!first) - driver_get_key(); /* delete key from buffer */ - else - first = FALSE; - key = driver_key_pressed(); /* peek at the next one... */ - } - } - - xoff += me->x; - yoff += me->y; /* (xoff,yoff) = new position */ - - if (xoff < 0) xoff = 0; - if (yoff < 0) yoff = 0; - - if (xoff+me->base_width+me->csize*16+1 > sxdots) - xoff = sxdots - (me->base_width+me->csize*16+1); - - if (yoff+me->base_depth+me->csize*16+1 > sydots) - yoff = sydots - (me->base_depth+me->csize*16+1); - - if ( xoff!=me->x || yoff!=me->y ) - { - MoveBox__Erase(me); - me->y = yoff; - me->x = xoff; - MoveBox__Draw(me); - } - } - - -static BOOLEAN MoveBox_Process(MoveBox *me) - { - int key; - int orig_x = me->x, - orig_y = me->y, - orig_csize = me->csize; - - MoveBox__Draw(me); - -#ifdef XFRACT - Cursor_StartMouseTracking(); -#endif - while (1) - { - Cursor_WaitKey(); - key = driver_get_key(); - - if (key==FIK_ENTER || key==FIK_ENTER_2 || key==FIK_ESC || key=='H' || key=='h') - { - if (me->x != orig_x || me->y != orig_y || me->csize != orig_csize) - me->moved = TRUE; - else - me->moved = FALSE; - break; - } - - switch (key) - { - case FIK_UP_ARROW: - case FIK_DOWN_ARROW: - case FIK_LEFT_ARROW: - case FIK_RIGHT_ARROW: - case FIK_CTL_UP_ARROW: - case FIK_CTL_DOWN_ARROW: - case FIK_CTL_LEFT_ARROW: - case FIK_CTL_RIGHT_ARROW: - MoveBox__Move(me, key); - break; - - case FIK_PAGE_UP: /* shrink */ - if (me->csize > CSIZE_MIN) - { - int t = me->csize - CSIZE_INC; - int change; - - if (t < CSIZE_MIN) - t = CSIZE_MIN; - - MoveBox__Erase(me); - - change = me->csize - t; - me->csize = t; - me->x += (change*16) / 2; - me->y += (change*16) / 2; - MoveBox__Draw(me); - } - break; - - case FIK_PAGE_DOWN: /* grow */ - { - int max_width = min(sxdots, MAX_WIDTH); - - if (me->base_depth+(me->csize+CSIZE_INC)*16+1 < sydots && - me->base_width+(me->csize+CSIZE_INC)*16+1 < max_width ) - { - MoveBox__Erase(me); - me->x -= (CSIZE_INC*16) / 2; - me->y -= (CSIZE_INC*16) / 2; - me->csize += CSIZE_INC; - if (me->y+me->base_depth+me->csize*16+1 > sydots) - me->y = sydots - (me->base_depth+me->csize*16+1); - if (me->x+me->base_width+me->csize*16+1 > max_width) - me->x = max_width - (me->base_width+me->csize*16+1); - if (me->y < 0) - me->y = 0; - if (me->x < 0) - me->x = 0; - MoveBox__Draw(me); - } - } - break; - } - } - -#ifdef XFRACT - Cursor_EndMouseTracking(); -#endif - - MoveBox__Erase(me); - - me->should_hide = (BOOLEAN)((key == 'H' || key == 'h') ? TRUE : FALSE); - - return (BOOLEAN)((key==FIK_ESC) ? FALSE : TRUE); - } - - - -/* - * Class: CEditor - * - * Purpose: Edits a single color component (R, G or B) - * - * Note: Calls the "other_key" function to process keys it doesn't use. - * The "change" function is called whenever the value is changed - * by the CEditor. - */ - -struct _CEditor - { - int x, y; - char letter; - int val; - BOOLEAN done; - BOOLEAN hidden; -#ifndef XFRACT - void (*other_key)(int key, struct _CEditor *ce, VOIDPTR info); - void (*change)(struct _CEditor *ce, VOIDPTR info); -#else - void (*other_key)(); - void (*change)(); -#endif - void *info; - - } ; - -#define CEditor struct _CEditor - -/* public: */ - -#ifndef XFRACT - static CEditor *CEditor_Construct( int x, int y, char letter, - void (*other_key)(int,CEditor*,void*), - void (*change)(CEditor*,void*), VOIDPTR info); - static void CEditor_Destroy (CEditor *me); - static void CEditor_Draw (CEditor *me); - static void CEditor_SetPos (CEditor *me, int x, int y); - static void CEditor_SetVal (CEditor *me, int val); - static int CEditor_GetVal (CEditor *me); - static void CEditor_SetDone (CEditor *me, BOOLEAN done); - static void CEditor_SetHidden (CEditor *me, BOOLEAN hidden); - static int CEditor_Edit (CEditor *me); -#else - static CEditor *CEditor_Construct( int , int , char , - void (*other_key)(), - void (*change)(), VOIDPTR ); - static void CEditor_Destroy (CEditor *); - static void CEditor_Draw (CEditor *); - static void CEditor_SetPos (CEditor *, int , int ); - static void CEditor_SetVal (CEditor *, int ); - static int CEditor_GetVal (CEditor *); - static void CEditor_SetDone (CEditor *, BOOLEAN ); - static void CEditor_SetHidden (CEditor *, BOOLEAN ); - static int CEditor_Edit (CEditor *); -#endif - -#define CEditor_WIDTH (8*3+4) -#define CEditor_DEPTH (8+4) - - - -#ifndef XFRACT -static CEditor *CEditor_Construct( int x, int y, char letter, - void (*other_key)(int,CEditor*,VOIDPTR), - void (*change)(CEditor*, VOIDPTR), VOIDPTR info) -#else -static CEditor *CEditor_Construct( int x, int y, char letter, - void (*other_key)(), - void (*change)(), VOIDPTR info) -#endif - { - CEditor *me = new(CEditor); - - me->x = x; - me->y = y; - me->letter = letter; - me->val = 0; - me->other_key = other_key; - me->hidden = FALSE; - me->change = change; - me->info = info; - - return me; - } - -#ifdef __CLINT__ -# pragma argsused /* kills "arg not used" warning */ -#endif - -static void CEditor_Destroy(CEditor *me) - { - delete(me); - } - - -static void CEditor_Draw(CEditor *me) - { - if (me->hidden) - return; - - Cursor_Hide(); - displayf(me->x+2, me->y+2, fg_color, bg_color, "%c%02d", me->letter, me->val); - Cursor_Show(); - } - - -static void CEditor_SetPos(CEditor *me, int x, int y) - { - me->x = x; - me->y = y; - } - - -static void CEditor_SetVal(CEditor *me, int val) - { - me->val = val; - } - - -static int CEditor_GetVal(CEditor *me) - { - return me->val; - } - - -static void CEditor_SetDone(CEditor *me, BOOLEAN done) - { - me->done = done; - } - - -static void CEditor_SetHidden(CEditor *me, BOOLEAN hidden) - { - me->hidden = hidden; - } - - -static int CEditor_Edit(CEditor *me) - { - int key = 0; - int diff; - - me->done = FALSE; - - if (!me->hidden) - { - Cursor_Hide(); - rect(me->x, me->y, CEditor_WIDTH, CEditor_DEPTH, fg_color); - Cursor_Show(); - } - -#ifdef XFRACT - Cursor_StartMouseTracking(); -#endif - while ( !me->done ) - { - Cursor_WaitKey(); - key = driver_get_key(); - - switch ( key ) - { - case FIK_PAGE_UP: - if (me->val < 63) - { - me->val += 5; - if (me->val > 63) - me->val = 63; - CEditor_Draw(me); - me->change(me, me->info); - } - break; - - case '+': - case FIK_CTL_PLUS: /*RB*/ - diff = 1; - while (driver_key_pressed() == key) - { - driver_get_key(); - ++diff; - } - if (me->val < 63) - { - me->val += diff; - if (me->val > 63) - me->val = 63; - CEditor_Draw(me); - me->change(me, me->info); - } - break; - - case FIK_PAGE_DOWN: - if (me->val > 0) - { - me->val -= 5; - if (me->val < 0) - me->val = 0; - CEditor_Draw(me); - me->change(me, me->info); - } break; - - case '-': - case FIK_CTL_MINUS: /*RB*/ - diff = 1; - while (driver_key_pressed() == key) - { - driver_get_key(); - ++diff; - } - if (me->val > 0) - { - me->val -= diff; - if (me->val < 0) - me->val = 0; - CEditor_Draw(me); - me->change(me, me->info); - } - break; - - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - me->val = (key - '0') * 10; - if (me->val > 63) - me->val = 63; - CEditor_Draw(me); - me->change(me, me->info); - break; - - default: - me->other_key(key, me, me->info); - break; - } /* switch */ - } /* while */ -#ifdef XFRACT - Cursor_EndMouseTracking(); -#endif - - if (!me->hidden) - { - Cursor_Hide(); - rect(me->x, me->y, CEditor_WIDTH, CEditor_DEPTH, bg_color); - Cursor_Show(); - } - - return key; - } - - - -/* - * Class: RGBEditor - * - * Purpose: Edits a complete color using three CEditors for R, G and B - */ - -struct _RGBEditor - { - int x, y; /* position */ - int curr; /* 0=r, 1=g, 2=b */ - int pal; /* palette number */ - BOOLEAN done; - BOOLEAN hidden; - CEditor *color[3]; /* color editors 0=r, 1=g, 2=b */ -#ifndef XFRACT - void (*other_key)(int key, struct _RGBEditor *e, VOIDPTR info); - void (*change)(struct _RGBEditor *e, VOIDPTR info); -#else - void (*other_key)(); - void (*change)(); -#endif - void *info; - } ; - -#define RGBEditor struct _RGBEditor - -/* private: */ - - static void RGBEditor__other_key (int key, CEditor *ceditor, VOIDPTR info); - static void RGBEditor__change (CEditor *ceditor, VOIDPTR info); - -/* public: */ - -#ifndef XFRACT - static RGBEditor *RGBEditor_Construct(int x, int y, - void (*other_key)(int,RGBEditor*,void*), - void (*change)(RGBEditor*,void*), VOIDPTR info); -#else - static RGBEditor *RGBEditor_Construct(int x, int y, - void (*other_key)(), - void (*change)(), VOIDPTR info); -#endif - - static void RGBEditor_Destroy (RGBEditor *me); - static void RGBEditor_SetPos (RGBEditor *me, int x, int y); - static void RGBEditor_SetDone (RGBEditor *me, BOOLEAN done); - static void RGBEditor_SetHidden(RGBEditor *me, BOOLEAN hidden); - static void RGBEditor_BlankSampleBox(RGBEditor *me); - static void RGBEditor_Update (RGBEditor *me); - static void RGBEditor_Draw (RGBEditor *me); - static int RGBEditor_Edit (RGBEditor *me); - static void RGBEditor_SetRGB (RGBEditor *me, int pal, PALENTRY *rgb); - static PALENTRY RGBEditor_GetRGB (RGBEditor *me); - -#define RGBEditor_WIDTH 62 -#define RGBEditor_DEPTH (1+1+CEditor_DEPTH*3-2+2) - -#define RGBEditor_BWIDTH ( RGBEditor_WIDTH - (2+CEditor_WIDTH+1 + 2) ) -#define RGBEditor_BDEPTH ( RGBEditor_DEPTH - 4 ) - - - -#ifndef XFRACT -static RGBEditor *RGBEditor_Construct(int x, int y, void (*other_key)(int,RGBEditor*,void*), - void (*change)(RGBEditor*,void*), VOIDPTR info) -#else -static RGBEditor *RGBEditor_Construct(int x, int y, void (*other_key)(), - void (*change)(), VOIDPTR info) -#endif - { - RGBEditor *me = new(RGBEditor); - static char letter[] = "RGB"; - int ctr; - - for (ctr=0; ctr<3; ctr++) - me->color[ctr] = CEditor_Construct(0, 0, letter[ctr], RGBEditor__other_key, - RGBEditor__change, me); - - RGBEditor_SetPos(me, x, y); - me->curr = 0; - me->pal = 1; - me->hidden = FALSE; - me->other_key = other_key; - me->change = change; - me->info = info; - - return me; - } - - -static void RGBEditor_Destroy(RGBEditor *me) - { - CEditor_Destroy(me->color[0]); - CEditor_Destroy(me->color[1]); - CEditor_Destroy(me->color[2]); - delete(me); - } - - -static void RGBEditor_SetDone(RGBEditor *me, BOOLEAN done) - { - me->done = done; - } - - -static void RGBEditor_SetHidden(RGBEditor *me, BOOLEAN hidden) - { - me->hidden = hidden; - CEditor_SetHidden(me->color[0], hidden); - CEditor_SetHidden(me->color[1], hidden); - CEditor_SetHidden(me->color[2], hidden); - } - - -static void RGBEditor__other_key(int key, CEditor *ceditor, VOIDPTR info) /* private */ - { - RGBEditor *me = (RGBEditor *)info; - - switch ( key ) - { - case 'R': - case 'r': - if (me->curr != 0) - { - me->curr = 0; - CEditor_SetDone(ceditor, TRUE); - } - break; - - case 'G': - case 'g': - if (me->curr != 1) - { - me->curr = 1; - CEditor_SetDone(ceditor, TRUE); - } - break; - - case 'B': - case 'b': - if (me->curr != 2) - { - me->curr = 2; - CEditor_SetDone(ceditor, TRUE); - } - break; - - case FIK_DELETE: /* move to next CEditor */ - case FIK_CTL_ENTER_2: /*double click rt mouse also! */ - if ( ++me->curr > 2) - me->curr = 0; - CEditor_SetDone(ceditor, TRUE); - break; - - case FIK_INSERT: /* move to prev CEditor */ - if ( --me->curr < 0) - me->curr = 2; - CEditor_SetDone(ceditor, TRUE); - break; - - default: - me->other_key(key, me, me->info); - if (me->done) - CEditor_SetDone(ceditor, TRUE); - break; - } - } - -#ifdef __CLINT__ -# pragma argsused /* kills "arg not used" warning */ -#endif - -static void RGBEditor__change(CEditor *ceditor, VOIDPTR info) /* private */ - { - RGBEditor *me = (RGBEditor *)info; - - ceditor = NULL; /* just for warning */ - if ( me->pal < colors && !is_reserved(me->pal) ) - setpal(me->pal, CEditor_GetVal(me->color[0]), - CEditor_GetVal(me->color[1]), CEditor_GetVal(me->color[2])); - - me->change(me, me->info); - } - - -static void RGBEditor_SetPos(RGBEditor *me, int x, int y) - { - me->x = x; - me->y = y; - - CEditor_SetPos(me->color[0], x+2, y+2); - CEditor_SetPos(me->color[1], x+2, y+2+CEditor_DEPTH-1); - CEditor_SetPos(me->color[2], x+2, y+2+CEditor_DEPTH-1+CEditor_DEPTH-1); - } - - -static void RGBEditor_BlankSampleBox(RGBEditor *me) - { - if (me->hidden) - return ; - - Cursor_Hide(); - fillrect(me->x+2+CEditor_WIDTH+1+1, me->y+2+1, RGBEditor_BWIDTH-2, RGBEditor_BDEPTH-2, bg_color); - Cursor_Show(); - } - - -static void RGBEditor_Update(RGBEditor *me) - { - int x1 = me->x+2+CEditor_WIDTH+1+1, - y1 = me->y+2+1; - - if (me->hidden) - return ; - - Cursor_Hide(); - - if ( me->pal >= colors ) - { - fillrect(x1, y1, RGBEditor_BWIDTH-2, RGBEditor_BDEPTH-2, bg_color); - draw_diamond(x1+(RGBEditor_BWIDTH-5)/2, y1+(RGBEditor_BDEPTH-5)/2, fg_color); - } - - else if ( is_reserved(me->pal) ) - { - int x2 = x1+RGBEditor_BWIDTH-3, - y2 = y1+RGBEditor_BDEPTH-3; - - fillrect(x1, y1, RGBEditor_BWIDTH-2, RGBEditor_BDEPTH-2, bg_color); - driver_draw_line(x1, y1, x2, y2, fg_color); - driver_draw_line(x1, y2, x2, y1, fg_color); - } - else - fillrect(x1, y1, RGBEditor_BWIDTH-2, RGBEditor_BDEPTH-2, me->pal); - - CEditor_Draw(me->color[0]); - CEditor_Draw(me->color[1]); - CEditor_Draw(me->color[2]); - Cursor_Show(); - } - - -static void RGBEditor_Draw(RGBEditor *me) - { - if (me->hidden) - return ; - - Cursor_Hide(); - drect(me->x, me->y, RGBEditor_WIDTH, RGBEditor_DEPTH); - fillrect(me->x+1, me->y+1, RGBEditor_WIDTH-2, RGBEditor_DEPTH-2, bg_color); - rect(me->x+1+CEditor_WIDTH+2, me->y+2, RGBEditor_BWIDTH, RGBEditor_BDEPTH, fg_color); - RGBEditor_Update(me); - Cursor_Show(); - } - - -static int RGBEditor_Edit(RGBEditor *me) - { - int key = 0; - - me->done = FALSE; - - if (!me->hidden) - { - Cursor_Hide(); - rect(me->x, me->y, RGBEditor_WIDTH, RGBEditor_DEPTH, fg_color); - Cursor_Show(); - } - - while ( !me->done ) - key = CEditor_Edit( me->color[me->curr] ); - - if (!me->hidden) - { - Cursor_Hide(); - drect(me->x, me->y, RGBEditor_WIDTH, RGBEditor_DEPTH); - Cursor_Show(); - } - - return key; - } - - -static void RGBEditor_SetRGB(RGBEditor *me, int pal, PALENTRY *rgb) - { - me->pal = pal; - CEditor_SetVal(me->color[0], rgb->red); - CEditor_SetVal(me->color[1], rgb->green); - CEditor_SetVal(me->color[2], rgb->blue); - } - - -static PALENTRY RGBEditor_GetRGB(RGBEditor *me) - { - PALENTRY pal; - - pal.red = (BYTE)CEditor_GetVal(me->color[0]); - pal.green = (BYTE)CEditor_GetVal(me->color[1]); - pal.blue = (BYTE)CEditor_GetVal(me->color[2]); - - return pal; - } - - - -/* - * Class: PalTable - * - * Purpose: This is where it all comes together. Creates the two RGBEditors - * and the palette. Moves the cursor, hides/restores the screen, - * handles (S)hading, (C)opying, e(X)clude mode, the "Y" exclusion - * mode, (Z)oom option, (H)ide palette, rotation, etc. - * - */ - -/* -enum stored_at_values - { - NOWHERE, - DISK, - MEMORY - } ; -*/ - -/* - -Modes: - Auto: "A", " " - Exclusion: "X", "Y", " " - Freestyle: "F", " " - S(t)ripe mode: "T", " " - -*/ - - - -struct _PalTable - { - int x, y; - int csize; - int active; /* which RGBEditor is active (0,1) */ - int curr[2]; - RGBEditor *rgb[2]; - MoveBox *movebox; - BOOLEAN done; - BOOLEAN exclude; - BOOLEAN auto_select; - PALENTRY pal[256]; - FILE *undo_file; - BOOLEAN curr_changed; - int num_redo; - int hidden; - int stored_at; - FILE *file; - char *memory; - - PALENTRY *save_pal[8]; - - - PALENTRY fs_color; - int top,bottom; /* top and bottom colours of freestyle band */ - int bandwidth; /*size of freestyle colour band */ - BOOLEAN freestyle; - } ; - -#define PalTable struct _PalTable - -/* private: */ - - static void PalTable__DrawStatus (PalTable *me, BOOLEAN stripe_mode); - static void PalTable__HlPal (PalTable *me, int pnum, int color); - static void PalTable__Draw (PalTable *me); - static BOOLEAN PalTable__SetCurr (PalTable *me, int which, int curr); - static BOOLEAN PalTable__MemoryAlloc (PalTable *me, long size); - static void PalTable__SaveRect (PalTable *me); - static void PalTable__RestoreRect (PalTable *me); - static void PalTable__SetPos (PalTable *me, int x, int y); - static void PalTable__SetCSize (PalTable *me, int csize); - static int PalTable__GetCursorColor(PalTable *me); - static void PalTable__DoCurs (PalTable *me, int key); - static void PalTable__Rotate (PalTable *me, int dir, int lo, int hi); - static void PalTable__UpdateDAC (PalTable *me); - static void PalTable__other_key (int key, RGBEditor *rgb, VOIDPTR info); - static void PalTable__SaveUndoData(PalTable *me, int first, int last); - static void PalTable__SaveUndoRotate(PalTable *me, int dir, int first, int last); - static void PalTable__UndoProcess (PalTable *me, int delta); - static void PalTable__Undo (PalTable *me); - static void PalTable__Redo (PalTable *me); - static void PalTable__change (RGBEditor *rgb, VOIDPTR info); - -/* public: */ - - static PalTable *PalTable_Construct (void); - static void PalTable_Destroy (PalTable *me); - static void PalTable_Process (PalTable *me); - static void PalTable_SetHidden (PalTable *me, BOOLEAN hidden); - static void PalTable_Hide (PalTable *me, RGBEditor *rgb, BOOLEAN hidden); - - -#define PalTable_PALX (1) -#define PalTable_PALY (2+RGBEditor_DEPTH+2) - -#define UNDO_DATA (1) -#define UNDO_DATA_SINGLE (2) -#define UNDO_ROTATE (3) - -/* - Freestyle code - */ - -static void PalTable__CalcTopBottom(PalTable *me) - { - if (me->curr[me->active] < me->bandwidth ) - me->bottom = 0; - else - me->bottom = (me->curr[me->active]) - me->bandwidth; - - if (me->curr[me->active] > (255-me->bandwidth) ) - me->top = 255; - else - me->top = (me->curr[me->active]) + me->bandwidth; - } - -static void PalTable__PutBand(PalTable *me, PALENTRY *pal) - { - int r,b,a; - - /* clip top and bottom values to stop them running off the end of the DAC */ - - PalTable__CalcTopBottom(me); - - /* put bands either side of current colour */ - - a = me->curr[me->active]; - b = me->bottom; - r = me->top; - - pal[a] = me->fs_color; - - if (r != a && a != b) - { - mkpalrange(&pal[a], &pal[r], &pal[a], r-a, 1); - mkpalrange(&pal[b], &pal[a], &pal[b], a-b, 1); - } - - } - - -/* - Undo.Redo code - */ - - -static void PalTable__SaveUndoData(PalTable *me, int first, int last) - { - int num; - - if ( me->undo_file == NULL ) - return ; - - num = (last - first) + 1; - -#ifdef DEBUG_UNDO - mprintf("%6ld Writing Undo DATA from %d to %d (%d)", ftell(me->undo_file), first, last, num); -#endif - - fseek(me->undo_file, 0, SEEK_CUR); - if ( num == 1 ) - { - putc(UNDO_DATA_SINGLE, me->undo_file); - putc(first, me->undo_file); - fwrite(me->pal+first, 3, 1, me->undo_file); - putw( 1 + 1 + 3 + sizeof(int), me->undo_file); - } - else - { - putc(UNDO_DATA, me->undo_file); - putc(first, me->undo_file); - putc(last, me->undo_file); - fwrite(me->pal+first, 3, num, me->undo_file); - putw(1 + 2 + (num*3) + sizeof(int), me->undo_file); - } - - me->num_redo = 0; - } - - -static void PalTable__SaveUndoRotate(PalTable *me, int dir, int first, int last) - { - if ( me->undo_file == NULL ) - return ; - -#ifdef DEBUG_UNDO - mprintf("%6ld Writing Undo ROTATE of %d from %d to %d", ftell(me->undo_file), dir, first, last); -#endif - - fseek(me->undo_file, 0, SEEK_CUR); - putc(UNDO_ROTATE, me->undo_file); - putc(first, me->undo_file); - putc(last, me->undo_file); - putw(dir, me->undo_file); - putw(1 + 2 + sizeof(int), me->undo_file); - - me->num_redo = 0; - } - - -static void PalTable__UndoProcess(PalTable *me, int delta) /* undo/redo common code */ - { /* delta = -1 for undo, +1 for redo */ - int cmd = getc(me->undo_file); - - switch ( cmd ) - { - case UNDO_DATA: - case UNDO_DATA_SINGLE: - { - int first, last, num; - PALENTRY temp[256]; - - if ( cmd == UNDO_DATA ) - { - first = (unsigned char)getc(me->undo_file); - last = (unsigned char)getc(me->undo_file); - } - else /* UNDO_DATA_SINGLE */ - first = last = (unsigned char)getc(me->undo_file); - - num = (last - first) + 1; - -#ifdef DEBUG_UNDO - mprintf(" Reading DATA from %d to %d", first, last); -#endif - - fread(temp, 3, num, me->undo_file); - - fseek(me->undo_file, -(num*3), SEEK_CUR); /* go to start of undo/redo data */ - fwrite(me->pal+first, 3, num, me->undo_file); /* write redo/undo data */ - - memmove(me->pal+first, temp, num*3); - - PalTable__UpdateDAC(me); - - RGBEditor_SetRGB(me->rgb[0], me->curr[0], &(me->pal[me->curr[0]])); - RGBEditor_SetRGB(me->rgb[1], me->curr[1], &(me->pal[me->curr[1]])); - RGBEditor_Update(me->rgb[0]); - RGBEditor_Update(me->rgb[1]); - break; - } - - case UNDO_ROTATE: - { - int first = (unsigned char)getc(me->undo_file); - int last = (unsigned char)getc(me->undo_file); - int dir = getw(me->undo_file); - -#ifdef DEBUG_UNDO - mprintf(" Reading ROTATE of %d from %d to %d", dir, first, last); -#endif - PalTable__Rotate(me, delta*dir, first, last); - break; - } - - default: -#ifdef DEBUG_UNDO - mprintf(" Unknown command: %d", cmd); -#endif - break; - } - - fseek(me->undo_file, 0, SEEK_CUR); /* to put us in read mode */ - getw(me->undo_file); /* read size */ - } - - -static void PalTable__Undo(PalTable *me) - { - int size; - long pos; - - if ( ftell(me->undo_file) <= 0 ) /* at beginning of file? */ - { /* nothing to undo -- exit */ - return ; - } - - fseek(me->undo_file, -(int)sizeof(int), SEEK_CUR); /* go back to get size */ - - size = getw(me->undo_file); - fseek(me->undo_file, -size, SEEK_CUR); /* go to start of undo */ - -#ifdef DEBUG_UNDO - mprintf("%6ld Undo:", ftell(me->undo_file)); -#endif - - pos = ftell(me->undo_file); - - PalTable__UndoProcess(me, -1); - - fseek(me->undo_file, pos, SEEK_SET); /* go to start of me block */ - - ++me->num_redo; - } - - -static void PalTable__Redo(PalTable *me) - { - if ( me->num_redo <= 0 ) - return ; - -#ifdef DEBUG_UNDO - mprintf("%6ld Redo:", ftell(me->undo_file)); -#endif - - fseek(me->undo_file, 0, SEEK_CUR); /* to make sure we are in "read" mode */ - PalTable__UndoProcess(me, 1); - - --me->num_redo; - } - - -/* - everything else - */ - - -#define STATUS_LEN (4) - -static void PalTable__DrawStatus(PalTable *me, BOOLEAN stripe_mode) - { - int color; - int width = 1+(me->csize*16)+1+1; - - if ( !me->hidden && ( width - (RGBEditor_WIDTH*2+4) >= STATUS_LEN*8 ) ) - { - int x = me->x + 2 + RGBEditor_WIDTH, - y = me->y + PalTable_PALY - 10; - color = PalTable__GetCursorColor(me); - if (color < 0 || color >= colors) /* hmm, the border returns -1 */ - color = 0; - Cursor_Hide(); - - { - char buff[80]; - sprintf(buff, "%c%c%c%c", - me->auto_select ? 'A' : ' ', - (me->exclude == 1) ? 'X' : (me->exclude == 2) ? 'Y' : ' ', - me->freestyle ? 'F' : ' ', - stripe_mode ? 'T' : ' '); - driver_display_string(x, y, fg_color, bg_color, buff); - - y = y - 10; - sprintf(buff, "%d", color); - driver_display_string(x, y, fg_color, bg_color, buff); - } - Cursor_Show(); - } - } - - -static void PalTable__HlPal(PalTable *me, int pnum, int color) - { - int x = me->x + PalTable_PALX + (pnum%16)*me->csize, - y = me->y + PalTable_PALY + (pnum/16)*me->csize, - size = me->csize; - - if (me->hidden) - return ; - - Cursor_Hide(); - - if (color < 0) - drect(x, y, size+1, size+1); - else - rect(x, y, size+1, size+1, color); - - Cursor_Show(); - } - - -static void PalTable__Draw(PalTable *me) - { - int pal; - int xoff, yoff; - int width; - - if (me->hidden) - return ; - - Cursor_Hide(); - - width = 1+(me->csize*16)+1+1; - - rect(me->x, me->y, width, 2+RGBEditor_DEPTH+2+(me->csize*16)+1+1, fg_color); - - fillrect(me->x+1, me->y+1, width-2, 2+RGBEditor_DEPTH+2+(me->csize*16)+1+1-2, bg_color); - - hline(me->x, me->y+PalTable_PALY-1, width, fg_color); - - if ( width - (RGBEditor_WIDTH*2+4) >= TITLE_LEN*8 ) - { - int center = (width - TITLE_LEN*8) / 2; - - displayf(me->x+center, me->y+RGBEditor_DEPTH/2-6, fg_color, bg_color, TITLE); - } - - RGBEditor_Draw(me->rgb[0]); - RGBEditor_Draw(me->rgb[1]); - - for (pal=0; pal<256; pal++) - { - xoff = PalTable_PALX + (pal%16) * me->csize; - yoff = PalTable_PALY + (pal/16) * me->csize; - - if ( pal >= colors ) - { - fillrect(me->x + xoff + 1, me->y + yoff + 1, me->csize-1, me->csize-1, bg_color); - draw_diamond(me->x + xoff + me->csize/2 - 1, me->y + yoff + me->csize/2 - 1, fg_color); - } - - else if ( is_reserved(pal) ) - { - int x1 = me->x + xoff + 1, - y1 = me->y + yoff + 1, - x2 = x1 + me->csize - 2, - y2 = y1 + me->csize - 2; - fillrect(me->x + xoff + 1, me->y + yoff + 1, me->csize-1, me->csize-1, bg_color); - driver_draw_line(x1, y1, x2, y2, fg_color); - driver_draw_line(x1, y2, x2, y1, fg_color); - } - else - fillrect(me->x + xoff + 1, me->y + yoff + 1, me->csize-1, me->csize-1, pal); - - } - - if (me->active == 0) - { - PalTable__HlPal(me, me->curr[1], -1); - PalTable__HlPal(me, me->curr[0], fg_color); - } - else - { - PalTable__HlPal(me, me->curr[0], -1); - PalTable__HlPal(me, me->curr[1], fg_color); - } - - PalTable__DrawStatus(me, FALSE); - - Cursor_Show(); - } - - - -static BOOLEAN PalTable__SetCurr(PalTable *me, int which, int curr) - { - BOOLEAN redraw = (BOOLEAN)((which < 0) ? TRUE : FALSE); - - if ( redraw ) - { - which = me->active; - curr = me->curr[which]; - } - else - if ( curr == me->curr[which] || curr < 0 ) - return FALSE; - - Cursor_Hide(); - - PalTable__HlPal(me, me->curr[0], bg_color); - PalTable__HlPal(me, me->curr[1], bg_color); - PalTable__HlPal(me, me->top, bg_color); - PalTable__HlPal(me, me->bottom, bg_color); - - if ( me->freestyle ) - { - me->curr[which] = curr; - - PalTable__CalcTopBottom(me); - - PalTable__HlPal(me, me->top, -1); - PalTable__HlPal(me, me->bottom, -1); - PalTable__HlPal(me, me->curr[me->active], fg_color); - - RGBEditor_SetRGB(me->rgb[which], me->curr[which], &me->fs_color); - RGBEditor_Update(me->rgb[which]); - - PalTable__UpdateDAC(me); - - Cursor_Show(); - - return TRUE; - } - - me->curr[which] = curr; - - if (me->curr[0] != me->curr[1]) - PalTable__HlPal(me, me->curr[me->active==0?1:0], -1); - PalTable__HlPal(me, me->curr[me->active], fg_color); - - RGBEditor_SetRGB(me->rgb[which], me->curr[which], &(me->pal[me->curr[which]])); - - if (redraw) - { - int other = (which==0) ? 1 : 0; - RGBEditor_SetRGB(me->rgb[other], me->curr[other], &(me->pal[me->curr[other]])); - RGBEditor_Update(me->rgb[0]); - RGBEditor_Update(me->rgb[1]); - } - else - RGBEditor_Update(me->rgb[which]); - - if (me->exclude) - PalTable__UpdateDAC(me); - - Cursor_Show(); - - me->curr_changed = FALSE; - - return TRUE; - } - - -static BOOLEAN PalTable__MemoryAlloc(PalTable *me, long size) - { - char *temp; - - if (debugflag == 420) - { - me->stored_at = NOWHERE; - return FALSE; /* can't do it */ - } - temp = (char *)malloc(FAR_RESERVE); /* minimum free space */ - - if (temp == NULL) - { - me->stored_at = NOWHERE; - return FALSE; /* can't do it */ - } - - me->memory = (char *)malloc( size ); - - free(temp); - - if ( me->memory == NULL ) - { - me->stored_at = NOWHERE; - return FALSE; - } - else - { - me->stored_at = MEMORY; - return TRUE; - } - } - - -static void PalTable__SaveRect(PalTable *me) - { - char buff[MAX_WIDTH]; - int width = PalTable_PALX + me->csize*16 + 1 + 1, - depth = PalTable_PALY + me->csize*16 + 1 + 1; - int yoff; - - - /* first, do any de-allocationg */ - - switch ( me->stored_at ) - { - case NOWHERE: - break; - - case DISK: - break; - - case MEMORY: - if (me->memory != NULL) - free(me->memory); - me->memory = NULL; - break; - } ; - - /* allocate space and store the rect */ - - if ( PalTable__MemoryAlloc(me, (long)width*depth) ) - { - char *ptr = me->memory; - char *bufptr = buff; /* MSC needs me indirection to get it right */ - - Cursor_Hide(); - for (yoff=0; yoffx, me->y+yoff, width, buff); - hline (me->x, me->y+yoff, width, bg_color); - memcpy(ptr,bufptr, width); - ptr += width; - } - Cursor_Show(); - } - - else /* to disk */ - { - me->stored_at = DISK; - - if ( me->file == NULL ) - { - me->file = dir_fopen(tempdir,scrnfile, "w+b"); - if (me->file == NULL) - { - me->stored_at = NOWHERE; - driver_buzzer(BUZZER_ERROR); - return ; - } - } - - rewind(me->file); - Cursor_Hide(); - for (yoff=0; yoffx, me->y+yoff, width, buff); - hline (me->x, me->y+yoff, width, bg_color); - if ( fwrite(buff, width, 1, me->file) != 1 ) - { - driver_buzzer(BUZZER_ERROR); - break; - } - } - Cursor_Show(); - } - - } - - -static void PalTable__RestoreRect(PalTable *me) - { - char buff[MAX_WIDTH]; - int width = PalTable_PALX + me->csize*16 + 1 + 1, - depth = PalTable_PALY + me->csize*16 + 1 + 1; - int yoff; - - if (me->hidden) - return; - - switch ( me->stored_at ) - { - case DISK: - rewind(me->file); - Cursor_Hide(); - for (yoff=0; yofffile) != 1 ) - { - driver_buzzer(BUZZER_ERROR); - break; - } - putrow(me->x, me->y+yoff, width, buff); - } - Cursor_Show(); - break; - - case MEMORY: - { - char *ptr = me->memory; - char *bufptr = buff; /* MSC needs me indirection to get it right */ - - Cursor_Hide(); - for (yoff=0; yoffx, me->y+yoff, width, buff); - ptr += width; - } - Cursor_Show(); - break; - } - - case NOWHERE: - break; - } /* switch */ - } - - -static void PalTable__SetPos(PalTable *me, int x, int y) - { - int width = PalTable_PALX + me->csize*16 + 1 + 1; - - me->x = x; - me->y = y; - - RGBEditor_SetPos(me->rgb[0], x+2, y+2); - RGBEditor_SetPos(me->rgb[1], x+width-2-RGBEditor_WIDTH, y+2); - } - - -static void PalTable__SetCSize(PalTable *me, int csize) - { - me->csize = csize; - PalTable__SetPos(me, me->x, me->y); - } - - -static int PalTable__GetCursorColor(PalTable *me) - { - int x = Cursor_GetX(), - y = Cursor_GetY(), - size; - int color = getcolor(x, y); - - if ( is_reserved(color) ) - { - if ( is_in_box(x, y, me->x, me->y, 1+(me->csize*16)+1+1, 2+RGBEditor_DEPTH+2+(me->csize*16)+1+1) ) - { /* is the cursor over the editor? */ - x -= me->x + PalTable_PALX; - y -= me->y + PalTable_PALY; - size = me->csize; - - if (x < 0 || y < 0 || x > size*16 || y > size*16) - return -1; - - if ( x == size*16 ) - --x; - if ( y == size*16 ) - --y; - - return (y/size)*16 + x/size; - } - else - return color; - } - - return color; - } - - - -#define CURS_INC 1 - -static void PalTable__DoCurs(PalTable *me, int key) - { - BOOLEAN done = FALSE; - BOOLEAN first = TRUE; - int xoff = 0, - yoff = 0; - - while ( !done ) - { - switch (key) - { - case FIK_CTL_RIGHT_ARROW: xoff += CURS_INC*4; break; - case FIK_RIGHT_ARROW: xoff += CURS_INC; break; - case FIK_CTL_LEFT_ARROW: xoff -= CURS_INC*4; break; - case FIK_LEFT_ARROW: xoff -= CURS_INC; break; - case FIK_CTL_DOWN_ARROW: yoff += CURS_INC*4; break; - case FIK_DOWN_ARROW: yoff += CURS_INC; break; - case FIK_CTL_UP_ARROW: yoff -= CURS_INC*4; break; - case FIK_UP_ARROW: yoff -= CURS_INC; break; - - default: - done = TRUE; - } - - if (!done) - { - if (!first) - driver_get_key(); /* delete key from buffer */ - else - first = FALSE; - key = driver_key_pressed(); /* peek at the next one... */ - } - } - - Cursor_Move(xoff, yoff); - - if (me->auto_select) - PalTable__SetCurr(me, me->active, PalTable__GetCursorColor(me)); - } - - -#ifdef __CLINT__ -# pragma argsused -#endif - -static void PalTable__change(RGBEditor *rgb, VOIDPTR info) - { - PalTable *me = (PalTable *)info; - int pnum = me->curr[me->active]; - - if ( me->freestyle ) - { - me->fs_color = RGBEditor_GetRGB(rgb); - PalTable__UpdateDAC(me); - return ; - } - - if ( !me->curr_changed ) - { - PalTable__SaveUndoData(me, pnum, pnum); - me->curr_changed = TRUE; - } - - me->pal[pnum] = RGBEditor_GetRGB(rgb); - - if (me->curr[0] == me->curr[1]) - { - int other = me->active==0 ? 1 : 0; - PALENTRY color; - - color = RGBEditor_GetRGB(me->rgb[me->active]); - RGBEditor_SetRGB(me->rgb[other], me->curr[other], &color); - - Cursor_Hide(); - RGBEditor_Update(me->rgb[other]); - Cursor_Show(); - } - - } - - -static void PalTable__UpdateDAC(PalTable *me) - { - if ( me->exclude ) - { - memset(g_dac_box, 0, 256*3); - if (me->exclude == 1) - { - int a = me->curr[me->active]; - memmove(g_dac_box[a], &me->pal[a], 3); - } - else - { - int a = me->curr[0], - b = me->curr[1]; - - if (a>b) - { - int t=a; - a=b; - b=t; - } - - memmove(g_dac_box[a], &me->pal[a], 3*(1+(b-a))); - } - } - else - { - memmove(g_dac_box[0], me->pal, 3*colors); - - if ( me->freestyle ) - PalTable__PutBand(me, (PALENTRY *)g_dac_box); /* apply band to g_dac_box */ - } - - if ( !me->hidden ) - { - if (inverse) - { - memset(g_dac_box[fg_color], 0, 3); /* g_dac_box[fg] = (0,0,0) */ - memset(g_dac_box[bg_color], 48, 3); /* g_dac_box[bg] = (48,48,48) */ - } - else - { - memset(g_dac_box[bg_color], 0, 3); /* g_dac_box[bg] = (0,0,0) */ - memset(g_dac_box[fg_color], 48, 3); /* g_dac_box[fg] = (48,48,48) */ - } - } - - spindac(0,1); - } - - -static void PalTable__Rotate(PalTable *me, int dir, int lo, int hi) - { - - rotatepal(me->pal, dir, lo, hi); - - Cursor_Hide(); - - /* update the DAC. */ - - PalTable__UpdateDAC(me); - - /* update the editors. */ - - RGBEditor_SetRGB(me->rgb[0], me->curr[0], &(me->pal[me->curr[0]])); - RGBEditor_SetRGB(me->rgb[1], me->curr[1], &(me->pal[me->curr[1]])); - RGBEditor_Update(me->rgb[0]); - RGBEditor_Update(me->rgb[1]); - - Cursor_Show(); - } - - -static void PalTable__other_key(int key, RGBEditor *rgb, VOIDPTR info) - { - PalTable *me = (PalTable *)info; - - switch (key) - { - case '\\': /* move/resize */ - { - if (me->hidden) - break; /* cannot move a hidden pal */ - Cursor_Hide(); - PalTable__RestoreRect(me); - MoveBox_SetPos(me->movebox, me->x, me->y); - MoveBox_SetCSize(me->movebox, me->csize); - if ( MoveBox_Process(me->movebox) ) - { - if ( MoveBox_ShouldHide(me->movebox) ) - PalTable_SetHidden(me, TRUE); - else if ( MoveBox_Moved(me->movebox) ) - { - PalTable__SetPos(me, MoveBox_X(me->movebox), MoveBox_Y(me->movebox)); - PalTable__SetCSize(me, MoveBox_CSize(me->movebox)); - PalTable__SaveRect(me); - } - } - PalTable__Draw(me); - Cursor_Show(); - - RGBEditor_SetDone(me->rgb[me->active], TRUE); - - if (me->auto_select) - PalTable__SetCurr(me, me->active, PalTable__GetCursorColor(me)); - break; - } - - case 'Y': /* exclude range */ - case 'y': - if ( me->exclude==2 ) - me->exclude = 0; - else - me->exclude = 2; - PalTable__UpdateDAC(me); - break; - - case 'X': - case 'x': /* exclude current entry */ - if ( me->exclude==1 ) - me->exclude = 0; - else - me->exclude = 1; - PalTable__UpdateDAC(me); - break; - - case FIK_RIGHT_ARROW: - case FIK_LEFT_ARROW: - case FIK_UP_ARROW: - case FIK_DOWN_ARROW: - case FIK_CTL_RIGHT_ARROW: - case FIK_CTL_LEFT_ARROW: - case FIK_CTL_UP_ARROW: - case FIK_CTL_DOWN_ARROW: - PalTable__DoCurs(me, key); - break; - - case FIK_ESC: - me->done = TRUE; - RGBEditor_SetDone(rgb, TRUE); - break; - - case ' ': /* select the other palette register */ - me->active = (me->active==0) ? 1 : 0; - if (me->auto_select) - PalTable__SetCurr(me, me->active, PalTable__GetCursorColor(me)); - else - PalTable__SetCurr(me, -1, 0); - - if (me->exclude || me->freestyle) - PalTable__UpdateDAC(me); - - RGBEditor_SetDone(rgb, TRUE); - break; - - case FIK_ENTER: /* set register to color under cursor. useful when not */ - case FIK_ENTER_2: /* in auto_select mode */ - - if ( me->freestyle ) - { - PalTable__SaveUndoData(me, me->bottom, me->top); - PalTable__PutBand(me, me->pal); - } - - PalTable__SetCurr(me, me->active, PalTable__GetCursorColor(me)); - - if (me->exclude || me->freestyle ) - PalTable__UpdateDAC(me); - - RGBEditor_SetDone(rgb, TRUE); - break; - - case 'D': /* copy (Duplicate?) color in inactive to color in active */ - case 'd': - { - int a = me->active, - b = (a==0) ? 1 : 0; - PALENTRY t; - - t = RGBEditor_GetRGB(me->rgb[b]); - Cursor_Hide(); - - RGBEditor_SetRGB(me->rgb[a], me->curr[a], &t); - RGBEditor_Update(me->rgb[a]); - PalTable__change(me->rgb[a], me); - PalTable__UpdateDAC(me); - - Cursor_Show(); - break; - } - - case '=': /* create a shade range between the two entries */ - { - int a = me->curr[0], - b = me->curr[1]; - - if (a > b) - { - int t = a; - a = b; - b = t; - } - - PalTable__SaveUndoData(me, a, b); - - if (a != b) - { - mkpalrange(&me->pal[a], &me->pal[b], &me->pal[a], b-a, 1); - PalTable__UpdateDAC(me); - } - - break; - } - - case '!': /* swap r<->g */ - { - int a = me->curr[0], - b = me->curr[1]; - - if (a > b) - { - int t = a; - a = b; - b = t; - } - - PalTable__SaveUndoData(me, a, b); - - if (a != b) - { - rotcolrg(&me->pal[a], b-a); - PalTable__UpdateDAC(me); - } - - - break; - } - - case '@': /* swap g<->b */ - case '"': /* UK keyboards */ - case 151: /* French keyboards */ - { - int a = me->curr[0], - b = me->curr[1]; - - if (a > b) - { - int t = a; - a = b; - b = t; - } - - PalTable__SaveUndoData(me, a, b); - - if (a != b) - { - rotcolgb(&me->pal[a], b-a); - PalTable__UpdateDAC(me); - } - - break; - } - - case '#': /* swap r<->b */ - case 156: /* UK keyboards (pound sign) */ - case '$': /* For French keyboards */ - { - int a = me->curr[0], - b = me->curr[1]; - - if (a > b) - { - int t = a; - a = b; - b = t; - } - - PalTable__SaveUndoData(me, a, b); - - if (a != b) - { - rotcolbr(&me->pal[a], b-a); - PalTable__UpdateDAC(me); - } - - break; - } - - - case 'T': - case 't': /* s(T)ripe mode */ - { - int key; - - Cursor_Hide(); - PalTable__DrawStatus(me, TRUE); - key = getakeynohelp(); - Cursor_Show(); - - if (key >= '1' && key <= '9') - { - int a = me->curr[0], - b = me->curr[1]; - - if (a > b) - { - int t = a; - a = b; - b = t; - } - - PalTable__SaveUndoData(me, a, b); - - if (a != b) - { - mkpalrange(&me->pal[a], &me->pal[b], &me->pal[a], b-a, key-'0'); - PalTable__UpdateDAC(me); - } - } - - break; - } - - case 'M': /* set gamma */ - case 'm': - { - int i; - char buf[20]; - sprintf(buf,"%.3f",1./gamma_val); - driver_stack_screen(); - i = field_prompt("Enter gamma value",NULL,buf,20,NULL); - driver_unstack_screen(); - if (i != -1) { - sscanf(buf,"%f",&gamma_val); - if (gamma_val==0) { - gamma_val = (float)0.0000000001; - } - gamma_val = (float)(1./gamma_val); - } - } - break; - case 'A': /* toggle auto-select mode */ - case 'a': - me->auto_select = (BOOLEAN)((me->auto_select) ? FALSE : TRUE); - if (me->auto_select) - { - PalTable__SetCurr(me, me->active, PalTable__GetCursorColor(me)); - if (me->exclude) - PalTable__UpdateDAC(me); - } - break; - - case 'H': - case 'h': /* toggle hide/display of palette editor */ - Cursor_Hide(); - PalTable_Hide(me, rgb, (BOOLEAN)((me->hidden) ? FALSE : TRUE)); - Cursor_Show(); - break; - - case '.': /* rotate once */ - case ',': - { - int dir = (key=='.') ? 1 : -1; - - PalTable__SaveUndoRotate(me, dir, rotate_lo, rotate_hi); - PalTable__Rotate(me, dir, rotate_lo, rotate_hi); - break; - } - - case '>': /* continuous rotation (until a key is pressed) */ - case '<': - { - int dir; - long tick; - int diff = 0; - - Cursor_Hide(); - - if ( !me->hidden ) - { - RGBEditor_BlankSampleBox(me->rgb[0]); - RGBEditor_BlankSampleBox(me->rgb[1]); - RGBEditor_SetHidden(me->rgb[0], TRUE); - RGBEditor_SetHidden(me->rgb[1], TRUE); - } - - do - { - dir = (key=='>') ? 1 : -1; - - while (!driver_key_pressed()) - { - tick = readticker(); - PalTable__Rotate(me, dir, rotate_lo, rotate_hi); - diff += dir; - while (readticker() == tick) ; /* wait until a tick passes */ - } - - key = driver_get_key(); - } - while (key=='<' || key=='>'); - - if ( !me->hidden ) - { - RGBEditor_SetHidden(me->rgb[0], FALSE); - RGBEditor_SetHidden(me->rgb[1], FALSE); - RGBEditor_Update(me->rgb[0]); - RGBEditor_Update(me->rgb[1]); - } - - if ( diff != 0 ) - PalTable__SaveUndoRotate(me, diff, rotate_lo, rotate_hi); - - Cursor_Show(); - break; - } - - case 'I': /* invert the fg & bg colors */ - case 'i': - inverse = (BOOLEAN)!inverse; - PalTable__UpdateDAC(me); - break; - - case 'V': - case 'v': /* set the reserved colors to the editor colors */ - if ( me->curr[0] >= colors || me->curr[1] >= colors || - me->curr[0] == me->curr[1] ) - { - driver_buzzer(BUZZER_ERROR); - break; - } - - fg_color = (BYTE)me->curr[0]; - bg_color = (BYTE)me->curr[1]; - - if ( !me->hidden ) - { - Cursor_Hide(); - PalTable__UpdateDAC(me); - PalTable__Draw(me); - Cursor_Show(); - } - - RGBEditor_SetDone(me->rgb[me->active], TRUE); - break; - - case 'O': /* set rotate_lo and rotate_hi to editors */ - case 'o': - if (me->curr[0] > me->curr[1]) - { - rotate_lo = me->curr[1]; - rotate_hi = me->curr[0]; - } - else - { - rotate_lo = me->curr[0]; - rotate_hi = me->curr[1]; - } - break; - - case FIK_F2: /* restore a palette */ - case FIK_F3: - case FIK_F4: - case FIK_F5: - case FIK_F6: - case FIK_F7: - case FIK_F8: - case FIK_F9: - { - int which = key - FIK_F2; - - if ( me->save_pal[which] != NULL ) - { - Cursor_Hide(); - - PalTable__SaveUndoData(me, 0, 255); - memcpy(me->pal,me->save_pal[which],256*3); - PalTable__UpdateDAC(me); - - PalTable__SetCurr(me, -1, 0); - Cursor_Show(); - RGBEditor_SetDone(me->rgb[me->active], TRUE); - } - else - driver_buzzer(BUZZER_ERROR); /* error buzz */ - break; - } - - case FIK_SF2: /* save a palette */ - case FIK_SF3: - case FIK_SF4: - case FIK_SF5: - case FIK_SF6: - case FIK_SF7: - case FIK_SF8: - case FIK_SF9: - { - int which = key - FIK_SF2; - - if ( me->save_pal[which] != NULL ) - { - memcpy(me->save_pal[which],me->pal,256*3); - } - else - driver_buzzer(BUZZER_ERROR); /* oops! short on memory! */ - break; - } - - case 'L': /* load a .map palette */ - case 'l': - { - PalTable__SaveUndoData(me, 0, 255); - - load_palette(); -#ifndef XFRACT - getpalrange(0, colors, me->pal); -#else - getpalrange(0, 256, me->pal); -#endif - PalTable__UpdateDAC(me); - RGBEditor_SetRGB(me->rgb[0], me->curr[0], &(me->pal[me->curr[0]])); - RGBEditor_Update(me->rgb[0]); - RGBEditor_SetRGB(me->rgb[1], me->curr[1], &(me->pal[me->curr[1]])); - RGBEditor_Update(me->rgb[1]); - break; - } - - case 'S': /* save a .map palette */ - case 's': - { -#ifndef XFRACT - setpalrange(0, colors, me->pal); -#else - setpalrange(0, 256, me->pal); -#endif - save_palette(); - PalTable__UpdateDAC(me); - break; - } - - case 'C': /* color cycling sub-mode */ - case 'c': - { - BOOLEAN oldhidden = (BOOLEAN)me->hidden; - - PalTable__SaveUndoData(me, 0, 255); - - Cursor_Hide(); - if ( !oldhidden ) - PalTable_Hide(me, rgb, TRUE); - setpalrange(0, colors, me->pal); - rotate(0); - getpalrange(0, colors, me->pal); - PalTable__UpdateDAC(me); - if ( !oldhidden ) - { - RGBEditor_SetRGB(me->rgb[0], me->curr[0], &(me->pal[me->curr[0]])); - RGBEditor_SetRGB(me->rgb[1], me->curr[1], &(me->pal[me->curr[1]])); - PalTable_Hide(me, rgb, FALSE); - } - Cursor_Show(); - break; - } - - case 'F': - case 'f': /* toggle freestyle palette edit mode */ - me->freestyle= (BOOLEAN)((me->freestyle) ? FALSE :TRUE); - - PalTable__SetCurr(me, -1, 0); - - if ( !me->freestyle ) /* if turning off... */ - PalTable__UpdateDAC(me); - - break; - - case FIK_CTL_DEL: /* rt plus down */ - if (me->bandwidth >0 ) - me->bandwidth --; - else - me->bandwidth=0; - PalTable__SetCurr(me, -1, 0); - break; - - case FIK_CTL_INSERT: /* rt plus up */ - if (me->bandwidth <255 ) - me->bandwidth ++; - else - me->bandwidth = 255; - PalTable__SetCurr(me, -1, 0); - break; - - case 'W': /* convert to greyscale */ - case 'w': - { - switch ( me->exclude ) - { - case 0: /* normal mode. convert all colors to grey scale */ - PalTable__SaveUndoData(me, 0, 255); - palrangetogrey(me->pal, 0, 256); - break; - - case 1: /* 'x' mode. convert current color to grey scale. */ - PalTable__SaveUndoData(me, me->curr[me->active], me->curr[me->active]); - palrangetogrey(me->pal, me->curr[me->active], 1); - break; - - case 2: /* 'y' mode. convert range between editors to grey. */ - { - int a = me->curr[0], - b = me->curr[1]; - - if (a > b) - { - int t = a; - a = b; - b = t; - } - - PalTable__SaveUndoData(me, a, b); - palrangetogrey(me->pal, a, 1+(b-a)); - break; - } - } - - PalTable__UpdateDAC(me); - RGBEditor_SetRGB(me->rgb[0], me->curr[0], &(me->pal[me->curr[0]])); - RGBEditor_Update(me->rgb[0]); - RGBEditor_SetRGB(me->rgb[1], me->curr[1], &(me->pal[me->curr[1]])); - RGBEditor_Update(me->rgb[1]); - break; - } - - case 'N': /* convert to negative color */ - case 'n': - { - switch ( me->exclude ) - { - case 0: /* normal mode. convert all colors to grey scale */ - PalTable__SaveUndoData(me, 0, 255); - palrangetonegative(me->pal, 0, 256); - break; - - case 1: /* 'x' mode. convert current color to grey scale. */ - PalTable__SaveUndoData(me, me->curr[me->active], me->curr[me->active]); - palrangetonegative(me->pal, me->curr[me->active], 1); - break; - - case 2: /* 'y' mode. convert range between editors to grey. */ - { - int a = me->curr[0], - b = me->curr[1]; - - if (a > b) - { - int t = a; - a = b; - b = t; - } - - PalTable__SaveUndoData(me, a, b); - palrangetonegative(me->pal, a, 1+(b-a)); - break; - } - } - - PalTable__UpdateDAC(me); - RGBEditor_SetRGB(me->rgb[0], me->curr[0], &(me->pal[me->curr[0]])); - RGBEditor_Update(me->rgb[0]); - RGBEditor_SetRGB(me->rgb[1], me->curr[1], &(me->pal[me->curr[1]])); - RGBEditor_Update(me->rgb[1]); - break; - } - - case 'U': /* Undo */ - case 'u': - PalTable__Undo(me); - break; - - case 'e': /* Redo */ - case 'E': - PalTable__Redo(me); - break; - - } /* switch */ - PalTable__DrawStatus(me, FALSE); - } - -static void PalTable__MkDefaultPalettes(PalTable *me) /* creates default Fkey palettes */ -{ - int i; - for (i=0; i<8; i++) /* copy original palette to save areas */ - { - if (me->save_pal[i] != NULL) - { - memcpy(me->save_pal[i], me->pal, 256*3); - } - } -} - - - -static PalTable *PalTable_Construct(void) - { - PalTable *me = new(PalTable); - int csize; - int ctr; - PALENTRY *mem_block; - void *temp; - - temp = (void *)malloc(FAR_RESERVE); - - if ( temp != NULL ) - { - mem_block = (PALENTRY *)malloc(256L*3 * 8); - - if ( mem_block == NULL ) - { - for (ctr=0; ctr<8; ctr++) - me->save_pal[ctr] = NULL; - } - else - { - for (ctr=0; ctr<8; ctr++) - me->save_pal[ctr] = mem_block + (256*ctr); - } - free(temp); - } - - me->rgb[0] = RGBEditor_Construct(0, 0, PalTable__other_key, - PalTable__change, me); - me->rgb[1] = RGBEditor_Construct(0, 0, PalTable__other_key, - PalTable__change, me); - - me->movebox = MoveBox_Construct(0,0,0, PalTable_PALX+1, PalTable_PALY+1); - - me->active = 0; - me->curr[0] = 1; - me->curr[1] = 1; - me->auto_select = TRUE; - me->exclude = FALSE; - me->hidden = FALSE; - me->stored_at = NOWHERE; - me->file = NULL; - me->memory = NULL; - - me->fs_color.red = 42; - me->fs_color.green = 42; - me->fs_color.blue = 42; - me->freestyle = FALSE; - me->bandwidth = 15; - me->top = 255; - me->bottom = 0 ; - - me->undo_file = dir_fopen(tempdir,undofile, "w+b"); - me->curr_changed = FALSE; - me->num_redo = 0; - - RGBEditor_SetRGB(me->rgb[0], me->curr[0], &me->pal[me->curr[0]]); - RGBEditor_SetRGB(me->rgb[1], me->curr[1], &me->pal[me->curr[0]]); - - if (g_video_scroll) { - PalTable__SetPos(me, g_video_start_x, g_video_start_y); - csize = ( (g_vesa_y_res-(PalTable_PALY+1+1)) / 2 ) / 16; - } else { - PalTable__SetPos(me, 0, 0); - csize = ( (sydots-(PalTable_PALY+1+1)) / 2 ) / 16; - } - - if (csizehidden = hidden; - RGBEditor_SetHidden(me->rgb[0], hidden); - RGBEditor_SetHidden(me->rgb[1], hidden); - PalTable__UpdateDAC(me); - } - - - -static void PalTable_Hide(PalTable *me, RGBEditor *rgb, BOOLEAN hidden) - { - if (hidden) - { - PalTable__RestoreRect(me); - PalTable_SetHidden(me, TRUE); - reserve_colors = FALSE; - if (me->auto_select) - PalTable__SetCurr(me, me->active, PalTable__GetCursorColor(me)); - } - else - { - PalTable_SetHidden(me, FALSE); - reserve_colors = TRUE; - if (me->stored_at == NOWHERE) /* do we need to save screen? */ - PalTable__SaveRect(me); - PalTable__Draw(me); - if (me->auto_select) - PalTable__SetCurr(me, me->active, PalTable__GetCursorColor(me)); - RGBEditor_SetDone(rgb, TRUE); - } - } - - -static void PalTable_Destroy(PalTable *me) - { - - if (me->file != NULL) - { - fclose(me->file); - dir_remove(tempdir,scrnfile); - } - - if (me->undo_file != NULL) - { - fclose(me->undo_file); - dir_remove(tempdir,undofile); - } - - if (me->memory != NULL) - free(me->memory); - - if (me->save_pal[0] != NULL) - free((BYTE *)me->save_pal[0]); - - RGBEditor_Destroy(me->rgb[0]); - RGBEditor_Destroy(me->rgb[1]); - MoveBox_Destroy(me->movebox); - delete(me); - } - - -static void PalTable_Process(PalTable *me) - { - int ctr; - - getpalrange(0, colors, me->pal); - - /* Make sure all palette entries are 0-63 */ - - for (ctr=0; ctr<768; ctr++) - ((char *)me->pal)[ctr] &= 63; - - PalTable__UpdateDAC(me); - - RGBEditor_SetRGB(me->rgb[0], me->curr[0], &me->pal[me->curr[0]]); - RGBEditor_SetRGB(me->rgb[1], me->curr[1], &me->pal[me->curr[0]]); - - if (!me->hidden) - { - MoveBox_SetPos(me->movebox, me->x, me->y); - MoveBox_SetCSize(me->movebox, me->csize); - if ( !MoveBox_Process(me->movebox) ) - { - setpalrange(0, colors, me->pal); - return ; - } - - PalTable__SetPos(me, MoveBox_X(me->movebox), MoveBox_Y(me->movebox)); - PalTable__SetCSize(me, MoveBox_CSize(me->movebox)); - - if ( MoveBox_ShouldHide(me->movebox) ) - { - PalTable_SetHidden(me, TRUE); - reserve_colors = FALSE; /* */ - } - else - { - reserve_colors = TRUE; /* */ - PalTable__SaveRect(me); - PalTable__Draw(me); - } - } - - PalTable__SetCurr(me, me->active, PalTable__GetCursorColor(me)); - PalTable__SetCurr(me, (me->active==1)?0:1, PalTable__GetCursorColor(me)); - Cursor_Show(); - PalTable__MkDefaultPalettes(me); - me->done = FALSE; - - while ( !me->done ) - RGBEditor_Edit(me->rgb[me->active]); - - Cursor_Hide(); - PalTable__RestoreRect(me); - setpalrange(0, colors, me->pal); - } - - -/* - * interface to FRACTINT - */ - - - -void EditPalette(void) /* called by fractint */ - { - int oldlookatmouse = lookatmouse; - int oldsxoffs = sxoffs; - int oldsyoffs = syoffs; - PalTable *pt; - - mem_init(strlocn, 10*1024); - - if (sxdots < 133 || sydots < 174) - return; /* prevents crash when physical screen is too small */ - - plot = putcolor; - - line_buff = newx(max(sxdots,sydots)); - - lookatmouse = 3; - sxoffs = syoffs = 0; - - reserve_colors = TRUE; - inverse = FALSE; - fg_color = (BYTE)(255%colors); - bg_color = (BYTE)(fg_color-1); - - Cursor_Construct(); - pt = PalTable_Construct(); - PalTable_Process(pt); - PalTable_Destroy(pt); - Cursor_Destroy(); - - lookatmouse = oldlookatmouse; - sxoffs = oldsxoffs; - syoffs = oldsyoffs; - delete(line_buff); - } diff --git a/fractint/common/encoder.c b/fractint/common/encoder.c deleted file mode 100644 index 313798a8e..000000000 --- a/fractint/common/encoder.c +++ /dev/null @@ -1,1173 +0,0 @@ -/* - encoder.c - GIF Encoder and associated routines -*/ - -#include -#include -#ifndef XFRACT -#include -#endif - /* see Fractint.c for a description of the "include" hierarchy */ -#include "port.h" -#include "prototyp.h" -#include "fractype.h" -#include "drivers.h" - -static int compress(int rowlimit); -static int _fastcall shftwrite(BYTE * color, int numcolors); -static int _fastcall extend_blk_len(int datalen); -static int _fastcall put_extend_blk(int block_id, int block_len, char * block_data); -static int _fastcall store_item_name(char *); -static void _fastcall setup_save_info(struct fractal_info * save_info); - -/* - Save-To-Disk Routines (GIF) - -The following routines perform the GIF encoding when the 's' key is pressed. - -The compression logic in this file has been replaced by the classic -UNIX compress code. We have extensively modified the sources to fit -Fractint's needs, but have left the original credits where they -appear. Thanks to the original authors for making available these -classic and reliable sources. Of course, they are not responsible for -all the changes we have made to integrate their sources into Fractint. - -MEMORY ALLOCATION - -There are two large arrays: - - long htab[HSIZE] (5003*4 = 20012 bytes) - unsigned short codetab[HSIZE] (5003*2 = 10006 bytes) - -At the moment these arrays reuse extraseg and strlocn, respectively. - -*/ - -static int numsaves = 0; /* For adjusting 'save-to-disk' filenames */ -static FILE *g_outfile; -static int last_colorbar; -static int save16bit; -static int outcolor1s, outcolor2s; -static int startbits; - -static BYTE paletteBW[] = -{ /* B&W palette */ - 0, 0, 0, 63, 63, 63, -}; - -#ifndef XFRACT -static BYTE paletteCGA[] = -{ /* 4-color (CGA) palette */ - 0, 0, 0, 21, 63, 63, 63, 21, 63, 63, 63, 63, -}; -#endif - -static BYTE paletteEGA[] = -{ /* 16-color (EGA/CGA) pal */ - 0, 0, 0, 0, 0, 42, 0, 42, 0, 0, 42, 42, - 42, 0, 0, 42, 0, 42, 42, 21, 0, 42, 42, 42, - 21, 21, 21, 21, 21, 63, 21, 63, 21, 21, 63, 63, - 63, 21, 21, 63, 21, 63, 63, 63, 21, 63, 63, 63, -}; - -static int gif_savetodisk(char *filename) /* save-to-disk routine */ -{ - char tmpmsg[41]; /* before openfile in case of overrun */ - char openfile[FILE_MAX_PATH], openfiletype[10]; - char tmpfile[FILE_MAX_PATH]; - char *period; - int newfile; - int i, j, interrupted, outcolor1, outcolor2; -restart: - - save16bit = disk16bit; - if (gif87a_flag) /* not storing non-standard fractal info */ - save16bit = 0; - - strcpy(openfile, filename); /* decode and open the filename */ - strcpy(openfiletype, DEFAULTFRACTALTYPE); /* determine the file - * extension */ - if (save16bit) - strcpy(openfiletype, ".pot"); - - if ((period = has_ext(openfile)) != NULL) - { - strcpy(openfiletype, period); - *period = 0; - } - if (resave_flag != 1) - updatesavename(filename); /* for next time */ - - strcat(openfile, openfiletype); - - strcpy(tmpfile, openfile); - if (access(openfile, 0) != 0)/* file doesn't exist */ - newfile = 1; - else - { /* file already exists */ - if (fract_overwrite == 0) - { - if (resave_flag == 0) - goto restart; - if (started_resaves == 0) - { /* first save of a savetime set */ - updatesavename(filename); - goto restart; - } - } - if (access(openfile, 2) != 0) - { - sprintf(tmpmsg, "Can't write %s", openfile); - stopmsg(0, tmpmsg); - return -1; - } - newfile = 0; - i = (int) strlen(tmpfile); - while (--i >= 0 && tmpfile[i] != SLASHC) - tmpfile[i] = 0; - strcat(tmpfile, "fractint.tmp"); - } - - started_resaves = (resave_flag == 1) ? 1 : 0; - if (resave_flag == 2) /* final save of savetime set? */ - resave_flag = 0; - - g_outfile = fopen(tmpfile, "wb"); - if (g_outfile == NULL) - { - sprintf(tmpmsg, "Can't create %s", tmpfile); - stopmsg(0, tmpmsg); - return -1; - } - - if (driver_diskp()) - { /* disk-video */ - char buf[61]; - extract_filename(tmpmsg, openfile); - - sprintf(buf, "Saving %s", tmpmsg); - dvid_status(1, buf); - } -#ifdef XFRACT - else - { - driver_put_string(3, 0, 0, "Saving to:"); - driver_put_string(4, 0, 0, openfile); - driver_put_string(5, 0, 0, " "); - } -#endif - - busy = 1; - - if (debugflag != 200) - interrupted = encoder(); - else - interrupted = timer(2, NULL); /* invoke encoder() via timer */ - - busy = 0; - - fclose(g_outfile); - - if (interrupted) - { - char buf[200]; - sprintf(buf, "Save of %s interrupted.\nCancel to ", openfile); - if (newfile) - strcat(buf,"delete the file,\ncontinue to keep the partial image."); - else - strcat(buf,"retain the original file,\ncontinue to replace original with new partial image."); - interrupted = 1; - if (stopmsg(STOPMSG_CANCEL, buf) < 0) - { - interrupted = -1; - unlink(tmpfile); - } - } - - if (newfile == 0 && interrupted >= 0) - { /* replace the real file */ - unlink(openfile); /* success assumed since we checked */ - rename(tmpfile, openfile);/* earlier with access */ - } - - if (!driver_diskp()) - { /* supress this on disk-video */ - outcolor1 = outcolor1s; - outcolor2 = outcolor2s; - for (j = 0; j <= last_colorbar; j++) - { - if ((j & 4) == 0) - { - if (++outcolor1 >= colors) - outcolor1 = 0; - if (++outcolor2 >= colors) - outcolor2 = 0; - } - for (i = 0; 250 * i < xdots; i++) - { /* clear vert status bars */ - putcolor(i, j, getcolor(i, j) ^ outcolor1); - putcolor(xdots - 1 - i, j, - getcolor(xdots - 1 - i, j) ^ outcolor2); - } - } - } - else /* disk-video */ - dvid_status(1, ""); - - if (interrupted) - { - texttempmsg(" *interrupted* save "); - if (initbatch >= 1) - initbatch = 3; /* if batch mode, set error level */ - return -1; - } - if (timedsave == 0) - { - driver_buzzer(BUZZER_COMPLETE); - if (initbatch == 0) - { - extract_filename(tmpfile, openfile); - sprintf(tmpmsg, " File saved as %s ", tmpfile); - texttempmsg(tmpmsg); - } - } - if (initsavetime < 0) - goodbye(); - return 0; -} - -enum tag_save_format -{ - SAVEFORMAT_GIF = 0, - SAVEFORMAT_PNG, - SAVEFORMAT_JPEG -}; -typedef enum tag_save_format e_save_format; - -int savetodisk(char *filename) -{ - e_save_format format = SAVEFORMAT_GIF; - - switch (format) - { - case SAVEFORMAT_GIF: - return gif_savetodisk(filename); - - default: - return -1; - } -} - -int encoder() -{ - int i, width, rowlimit, interrupted; - BYTE bitsperpixel, x; - struct fractal_info save_info; - - if (initbatch) /* flush any impending keystrokes */ - while (driver_key_pressed()) - driver_get_key(); - - setup_save_info(&save_info); - -#ifndef XFRACT - bitsperpixel = 0; /* calculate bits / pixel */ - for (i = colors; i >= 2; i /= 2) - bitsperpixel++; - - startbits = bitsperpixel + 1;/* start coding with this many bits */ - if (colors == 2) - startbits++; /* B&W Klooge */ -#else - if (colors == 2) - { - bitsperpixel = 1; - startbits = 3; - } - else - { - bitsperpixel = 8; - startbits = 9; - } -#endif - - if (gif87a_flag == 1) - { - if (fwrite("GIF87a", 6, 1, g_outfile) != 1) - goto oops; /* old GIF Signature */ - } - else - { - if (fwrite("GIF89a", 6, 1, g_outfile) != 1) - goto oops; /* new GIF Signature */ - } - - width = xdots; - rowlimit = ydots; - if (save16bit) - { - /* pot16bit info is stored as: file: double width rows, right side - * of row is low 8 bits diskvid: ydots rows of colors followed by ydots - * rows of low 8 bits decoder: returns (row of color info then row of - * low 8 bits) * ydots */ - rowlimit <<= 1; - width <<= 1; - } - if (write2(&width, 2, 1, g_outfile) != 1) - goto oops; /* screen descriptor */ - if (write2(&ydots, 2, 1, g_outfile) != 1) - goto oops; - x = (BYTE) (128 + ((6 - 1) << 4) + (bitsperpixel - 1)); /* color resolution == 6 - * bits worth */ - if (write1(&x, 1, 1, g_outfile) != 1) - goto oops; - if (fputc(0, g_outfile) != 0) - goto oops; /* background color */ - i = 0; - - /* TODO: pixel aspect ratio should be 1:1? */ - if (viewwindow /* less than full screen? */ - && (viewxdots == 0 || viewydots == 0)) /* and we picked the dots? */ - i = (int) (((double) sydots / (double) sxdots) * 64.0 / screenaspect - 14.5); - else /* must risk loss of precision if numbers low */ - i = (int) ((((double) ydots / (double) xdots) / finalaspectratio) * 64 - 14.5); - if (i < 1) - i = 1; - if (i > 255) - i = 255; - if (gif87a_flag) - i = 0; /* for some decoders which can't handle - * aspect */ - if (fputc(i, g_outfile) != i) - goto oops; /* pixel aspect ratio */ - -#ifndef XFRACT - if (colors == 256) - { /* write out the 256-color palette */ - if (g_got_real_dac) - { /* got a DAC - must be a VGA */ - if (!shftwrite((BYTE *) g_dac_box, colors)) - goto oops; -#else - if (colors > 2) - { - if (g_got_real_dac || fake_lut) - { /* got a DAC - must be a VGA */ - if (!shftwrite((BYTE *) g_dac_box, 256)) - goto oops; -#endif - } - else - { /* uh oh - better fake it */ - for (i = 0; i < 256; i += 16) - if (!shftwrite((BYTE *)paletteEGA, 16)) - goto oops; - } - } - if (colors == 2) - { /* write out the B&W palette */ - if (!shftwrite((BYTE *)paletteBW, colors)) - goto oops; - } -#ifndef XFRACT - if (colors == 4) - { /* write out the CGA palette */ - if (!shftwrite((BYTE *)paletteCGA, colors)) - goto oops; - } - if (colors == 16) - { /* Either EGA or VGA */ - if (g_got_real_dac) - { - if (!shftwrite((BYTE *) g_dac_box, colors)) - goto oops; - } - else - { /* no DAC - must be an EGA */ - if (!shftwrite((BYTE *)paletteEGA, colors)) - goto oops; - } - } -#endif - - if (fwrite(",", 1, 1, g_outfile) != 1) - goto oops; /* Image Descriptor */ - i = 0; - if (write2(&i, 2, 1, g_outfile) != 1) - goto oops; - if (write2(&i, 2, 1, g_outfile) != 1) - goto oops; - if (write2(&width, 2, 1, g_outfile) != 1) - goto oops; - if (write2(&ydots, 2, 1, g_outfile) != 1) - goto oops; - if (write1(&i, 1, 1, g_outfile) != 1) - goto oops; - - bitsperpixel = (BYTE) (startbits - 1); - - if (write1(&bitsperpixel, 1, 1, g_outfile) != 1) - goto oops; - - interrupted = compress(rowlimit); - - if (ferror(g_outfile)) - goto oops; - - if (fputc(0, g_outfile) != 0) - goto oops; - - if (gif87a_flag == 0) - { /* store non-standard fractal info */ - /* loadfile.c has notes about extension block structure */ - if (interrupted) - save_info.calc_status = CALCSTAT_PARAMS_CHANGED; /* partial save is not resumable */ - save_info.tot_extend_len = 0; - if (resume_info != 0 && save_info.calc_status == CALCSTAT_RESUMABLE) - { - /* resume info block, 002 */ - save_info.tot_extend_len += extend_blk_len(resume_len); - MoveFromMemory((BYTE *)block,(U16)1,(long)resume_len,0,resume_info); - if (!put_extend_blk(2, resume_len, (char *)block)) - goto oops; - } -/* save_info.fractal_type gets modified in setup_save_info() in float only - version, so we need to use fractype. JCO 06JAN01 */ -/* if (save_info.fractal_type == FORMULA || save_info.fractal_type == FFORMULA) */ - if (fractype == FORMULA || fractype == FFORMULA) - save_info.tot_extend_len += store_item_name(FormName); -/* if (save_info.fractal_type == LSYSTEM) */ - if (fractype == LSYSTEM) - save_info.tot_extend_len += store_item_name(LName); -/* if (save_info.fractal_type == IFS || save_info.fractal_type == IFS3D) */ - if (fractype == IFS || fractype == IFS3D) - save_info.tot_extend_len += store_item_name(IFSName); - if (display3d <= 0 && rangeslen) - { - /* ranges block, 004 */ - save_info.tot_extend_len += extend_blk_len(rangeslen * 2); -#ifdef XFRACT - fix_ranges(ranges, rangeslen, 0); -#endif - if (!put_extend_blk(4, rangeslen * 2, (char *) ranges)) - goto oops; - - } - /* Extended parameters block 005 */ - if (bf_math) - { - save_info.tot_extend_len += extend_blk_len(22 * (bflength + 2)); - /* note: this assumes variables allocated in order starting with - * bfxmin in init_bf2() in BIGNUM.C */ - if (!put_extend_blk(5, 22 * (bflength + 2), (char *) bfxmin)) - goto oops; - } - - /* Extended parameters block 006 */ - if (evolving&1) - { - struct evolution_info esave_info; - int i; - struct evolution_info resume_e_info; - GENEBASE gene[NUMGENES]; - MoveFromMemory((BYTE *)&gene, (U16)sizeof(gene), 1L, 0L, gene_handle); - if (evolve_handle == 0 || calc_status == CALCSTAT_COMPLETED) { - esave_info.paramrangex = paramrangex; - esave_info.paramrangey = paramrangey; - esave_info.opx = opx; - esave_info.opy = opy; - esave_info.odpx = (short)odpx; - esave_info.odpy = (short)odpy; - esave_info.px = (short)px; - esave_info.py = (short)py; - esave_info.sxoffs = (short)sxoffs; - esave_info.syoffs = (short)syoffs; - esave_info.xdots = (short)xdots; - esave_info.ydots = (short)ydots; - esave_info.gridsz = (short)gridsz; - esave_info.evolving = (short)evolving; - esave_info.this_gen_rseed = (unsigned short)this_gen_rseed; - esave_info.fiddlefactor = fiddlefactor; - esave_info.ecount = (short) (gridsz * gridsz); /* flag for done */ - } - else { /* we will need the resuming information */ - MoveFromMemory((BYTE *)&resume_e_info,(U16)sizeof(resume_e_info),1L,0L,evolve_handle); - esave_info.paramrangex = resume_e_info.paramrangex; - esave_info.paramrangey = resume_e_info.paramrangey; - esave_info.opx = resume_e_info.opx; - esave_info.opy = resume_e_info.opy; - esave_info.odpx = (short)resume_e_info.odpx; - esave_info.odpy = (short)resume_e_info.odpy; - esave_info.px = (short)resume_e_info.px; - esave_info.py = (short)resume_e_info.py; - esave_info.sxoffs = (short)resume_e_info.sxoffs; - esave_info.syoffs = (short)resume_e_info.syoffs; - esave_info.xdots = (short)resume_e_info.xdots; - esave_info.ydots = (short)resume_e_info.ydots; - esave_info.gridsz = (short)resume_e_info.gridsz; - esave_info.evolving = (short)resume_e_info.evolving; - esave_info.this_gen_rseed = (unsigned short)resume_e_info.this_gen_rseed; - esave_info.fiddlefactor = resume_e_info.fiddlefactor; - esave_info.ecount = resume_e_info.ecount; - } - for (i = 0; i < NUMGENES; i++) - esave_info.mutate[i] = (short)gene[i].mutate; - - for (i = 0; i < sizeof(esave_info.future) / sizeof(short); i++) - esave_info.future[i] = 0; - - /* some XFRACT logic for the doubles needed here */ -#ifdef XFRACT - decode_evolver_info(&esave_info, 0); -#endif - /* evolution info block, 006 */ - save_info.tot_extend_len += extend_blk_len(sizeof(esave_info)); - if (!put_extend_blk(6, sizeof(esave_info), (char *) &esave_info)) - goto oops; - } - - /* Extended parameters block 007 */ - if (stdcalcmode == 'o') - { - struct orbits_info osave_info; - int i; - osave_info.oxmin = oxmin; - osave_info.oxmax = oxmax; - osave_info.oymin = oymin; - osave_info.oymax = oymax; - osave_info.ox3rd = ox3rd; - osave_info.oy3rd = oy3rd; - osave_info.keep_scrn_coords= (short)keep_scrn_coords; - osave_info.drawmode = drawmode; - for (i = 0; i < sizeof(osave_info.future) / sizeof(short); i++) - osave_info.future[i] = 0; - - /* some XFRACT logic for the doubles needed here */ -#ifdef XFRACT - decode_orbits_info(&osave_info, 0); -#endif - /* orbits info block, 007 */ - save_info.tot_extend_len += extend_blk_len(sizeof(osave_info)); - if (!put_extend_blk(7, sizeof(osave_info), (char *) &osave_info)) - goto oops; - } - - /* main and last block, 001 */ - save_info.tot_extend_len += extend_blk_len(FRACTAL_INFO_SIZE); -#ifdef XFRACT - decode_fractal_info(&save_info, 0); -#endif - if (!put_extend_blk(1, FRACTAL_INFO_SIZE, (char *) &save_info)) - { - goto oops; - } - } - - if (fwrite(";", 1, 1, g_outfile) != 1) - goto oops; /* GIF Terminator */ - - return (interrupted); - -oops: - { - fflush(g_outfile); - stopmsg(0,"Error Writing to disk (Disk full?)"); - return 1; - } -} - -/* TODO: should we be doing this? We need to store full colors, not the VGA truncated business. */ -/* shift IBM colors to GIF */ -static int _fastcall shftwrite(BYTE * color, int numcolors) -{ - BYTE thiscolor; - int i, j; - for (i = 0; i < numcolors; i++) - for (j = 0; j < 3; j++) - { - thiscolor = color[3 * i + j]; - thiscolor = (BYTE) (thiscolor << 2); - thiscolor = (BYTE) (thiscolor + (BYTE) (thiscolor >> 6)); - if (fputc(thiscolor, g_outfile) != (int) thiscolor) - return (0); - } - return (1); -} - -static int _fastcall extend_blk_len(int datalen) -{ - return (datalen + (datalen + 254) / 255 + 15); - /* data + 1.per.block + 14 for id + 1 for null at end */ -} - -static int _fastcall put_extend_blk(int block_id, int block_len, char * block_data) -{ - int i, j; - char header[15]; - strcpy(header, "!\377\013fractint"); - sprintf(&header[11], "%03u", block_id); - if (fwrite(header, 14, 1, g_outfile) != 1) - return (0); - i = (block_len + 254) / 255; - while (--i >= 0) - { - block_len -= (j = min(block_len, 255)); - if (fputc(j, g_outfile) != j) - return (0); - while (--j >= 0) - fputc(*(block_data++), g_outfile); - } - if (fputc(0, g_outfile) != 0) - return (0); - return (1); -} - -static int _fastcall store_item_name(char *nameptr) -{ - struct formula_info fsave_info; - int i; - for (i = 0; i < 40; i++) - fsave_info.form_name[i] = 0; /* initialize string */ - strcpy(fsave_info.form_name, nameptr); - if (fractype == FORMULA || fractype == FFORMULA) - { - fsave_info.uses_p1 = (short) uses_p1; - fsave_info.uses_p2 = (short) uses_p2; - fsave_info.uses_p3 = (short) uses_p3; - fsave_info.uses_ismand = (short) uses_ismand; - fsave_info.ismand = (short) ismand; - fsave_info.uses_p4 = (short) uses_p4; - fsave_info.uses_p5 = (short) uses_p5; - } - else - { - fsave_info.uses_p1 = 0; - fsave_info.uses_p2 = 0; - fsave_info.uses_p3 = 0; - fsave_info.uses_ismand = 0; - fsave_info.ismand = 0; - fsave_info.uses_p4 = 0; - fsave_info.uses_p5 = 0; - } - for (i = 0; i < sizeof(fsave_info.future) / sizeof(short); i++) - fsave_info.future[i] = 0; - /* formula/lsys/ifs info block, 003 */ - put_extend_blk(3, sizeof(fsave_info), (char *) &fsave_info); - return (extend_blk_len(sizeof(fsave_info))); -} - -static void _fastcall setup_save_info(struct fractal_info * save_info) -{ - int i; - if (fractype != FORMULA && fractype != FFORMULA) - maxfn = 0; - /* set save parameters in save structure */ - strcpy(save_info->info_id, INFO_ID); - save_info->version = FRACTAL_INFO_VERSION; - - if (maxit <= SHRT_MAX) - save_info->iterationsold = (short) maxit; - else - save_info->iterationsold = (short) SHRT_MAX; - - save_info->fractal_type = (short) fractype; - save_info->xmin = xxmin; - save_info->xmax = xxmax; - save_info->ymin = yymin; - save_info->ymax = yymax; - save_info->creal = param[0]; - save_info->cimag = param[1]; - save_info->videomodeax = (short) g_video_entry.videomodeax; - save_info->videomodebx = (short) g_video_entry.videomodebx; - save_info->videomodecx = (short) g_video_entry.videomodecx; - save_info->videomodedx = (short) g_video_entry.videomodedx; - save_info->dotmode = (short) (g_video_entry.dotmode % 100); - save_info->xdots = (short) g_video_entry.xdots; - save_info->ydots = (short) g_video_entry.ydots; - save_info->colors = (short) g_video_entry.colors; - save_info->parm3 = 0; /* pre version==7 fields */ - save_info->parm4 = 0; - save_info->dparm3 = param[2]; - save_info->dparm4 = param[3]; - save_info->dparm5 = param[4]; - save_info->dparm6 = param[5]; - save_info->dparm7 = param[6]; - save_info->dparm8 = param[7]; - save_info->dparm9 = param[8]; - save_info->dparm10 = param[9]; - save_info->fillcolor = (short) fillcolor; - save_info->potential[0] = (float) potparam[0]; - save_info->potential[1] = (float) potparam[1]; - save_info->potential[2] = (float) potparam[2]; - save_info->rflag = (short) rflag; - save_info->rseed = (short) rseed; - save_info->inside = (short) inside; - if (LogFlag <= SHRT_MAX) - save_info->logmapold = (short) LogFlag; - else - save_info->logmapold = (short) SHRT_MAX; - save_info->invert[0] = (float) inversion[0]; - save_info->invert[1] = (float) inversion[1]; - save_info->invert[2] = (float) inversion[2]; - save_info->decomp[0] = (short) decomp[0]; - save_info->biomorph = (short) usr_biomorph; - save_info->symmetry = (short) forcesymmetry; - for (i = 0; i < 16; i++) - save_info->init3d[i] = (short) init3d[i]; - save_info->previewfactor = (short) previewfactor; - save_info->xtrans = (short) xtrans; - save_info->ytrans = (short) ytrans; - save_info->red_crop_left = (short) red_crop_left; - save_info->red_crop_right = (short) red_crop_right; - save_info->blue_crop_left = (short) blue_crop_left; - save_info->blue_crop_right = (short) blue_crop_right; - save_info->red_bright = (short) red_bright; - save_info->blue_bright = (short) blue_bright; - save_info->xadjust = (short) xadjust; - save_info->yadjust = (short) yadjust; - save_info->eyeseparation = (short) g_eye_separation; - save_info->glassestype = (short) g_glasses_type; - save_info->outside = (short) outside; - save_info->x3rd = xx3rd; - save_info->y3rd = yy3rd; - save_info->calc_status = (short) calc_status; - save_info->stdcalcmode = (char) ((three_pass && stdcalcmode == '3') ? 127 : stdcalcmode); - if (distest <= 32000) - save_info->distestold = (short) distest; - else - save_info->distestold = 32000; - save_info->floatflag = floatflag; - if (bailout >= 4 && bailout <= 32000) - save_info->bailoutold = (short) bailout; - else - save_info->bailoutold = 0; - - save_info->calctime = calctime; - save_info->trigndx[0] = trigndx[0]; - save_info->trigndx[1] = trigndx[1]; - save_info->trigndx[2] = trigndx[2]; - save_info->trigndx[3] = trigndx[3]; - save_info->finattract = (short) finattract; - save_info->initorbit[0] = initorbit.x; - save_info->initorbit[1] = initorbit.y; - save_info->useinitorbit = useinitorbit; - save_info->periodicity = (short) periodicitycheck; - save_info->pot16bit = (short) disk16bit; - save_info->faspectratio = finalaspectratio; - save_info->system = (short) save_system; - - if (check_back()) - save_info->release = (short) min(save_release, g_release); - else - save_info->release = (short) g_release; - - save_info->flag3d = (short) display3d; - save_info->ambient = (short) Ambient; - save_info->randomize = (short) RANDOMIZE; - save_info->haze = (short) haze; - save_info->transparent[0] = (short) transparent[0]; - save_info->transparent[1] = (short) transparent[1]; - save_info->rotate_lo = (short) rotate_lo; - save_info->rotate_hi = (short) rotate_hi; - save_info->distestwidth = (short) distestwidth; - save_info->mxmaxfp = mxmaxfp; - save_info->mxminfp = mxminfp; - save_info->mymaxfp = mymaxfp; - save_info->myminfp = myminfp; - save_info->zdots = (short) zdots; - save_info->originfp = originfp; - save_info->depthfp = depthfp; - save_info->heightfp = heightfp; - save_info->widthfp = widthfp; - save_info->distfp = distfp; - save_info->eyesfp = eyesfp; - save_info->orbittype = (short) neworbittype; - save_info->juli3Dmode = (short) juli3Dmode; - save_info->maxfn = maxfn; - save_info->inversejulia = (short) ((major_method << 8) + minor_method); /* MVS */ - save_info->bailout = bailout; - save_info->bailoutest = (short) bailoutest; - save_info->iterations = maxit; - save_info->bflength = (short) bnlength; - save_info->bf_math = (short) bf_math; - save_info->old_demm_colors = (short) old_demm_colors; - save_info->logmap = LogFlag; - save_info->distest = distest; - save_info->dinvert[0] = inversion[0]; - save_info->dinvert[1] = inversion[1]; - save_info->dinvert[2] = inversion[2]; - save_info->logcalc = (short) Log_Fly_Calc; - save_info->stoppass = (short) stoppass; - save_info->quick_calc = (short) quick_calc; - save_info->closeprox = closeprox; - save_info->nobof = (short) nobof; - save_info->orbit_interval = orbit_interval; - save_info->orbit_delay = (short) orbit_delay; - save_info->math_tol[0] = math_tol[0]; - save_info->math_tol[1] = math_tol[1]; - for (i = 0; i < sizeof(save_info->future) / sizeof(short); i++) - save_info->future[i] = 0; - -} - -/*************************************************************************** - * - * GIFENCOD.C - GIF Image compression routines - * - * Lempel-Ziv compression based on 'compress'. GIF modifications by - * David Rowley (mgardi@watdcsu.waterloo.edu). - * Thoroughly massaged by the Stone Soup team for Fractint's purposes. - * - ***************************************************************************/ - -#define BITSF 12 -#define HSIZE 5003 /* 80% occupancy */ - -/* - * - * GIF Image compression - modified 'compress' - * - * Based on: compress.c - File compression ala IEEE Computer, June 1984. - * - * By Authors: Spencer W. Thomas (decvax!harpo!utah-cs!utah-gr!thomas) - * Jim McKie (decvax!mcvax!jim) - * Steve Davies (decvax!vax135!petsd!peora!srd) - * Ken Turkowski (decvax!decwrl!turtlevax!ken) - * James A. Woods (decvax!ihnp4!ames!jaw) - * Joe Orost (decvax!vax135!petsd!joe) - * - */ - -/* prototypes */ - -static void _fastcall output(int code); -static void _fastcall char_out(int c); -static void _fastcall flush_char(void); -static void _fastcall cl_block(void); - -static int n_bits; /* number of bits/code */ -static int maxbits = BITSF; /* user settable max # bits/code */ -static int maxcode; /* maximum code, given n_bits */ -static int maxmaxcode = (int)1 << BITSF; /* should NEVER generate this code */ -# define MAXCODE(n_bits) (((int) 1 << (n_bits)) - 1) - -#ifdef XFRACT -unsigned int strlocn[10240]; -BYTE block[4096]; -#endif - -static long htab[HSIZE]; -static unsigned short *codetab = (unsigned short *)strlocn; - -/* - * To save much memory, we overlay the table used by compress() with those - * used by decompress(). The tab_prefix table is the same size and type - * as the codetab. The tab_suffix table needs 2**BITSF characters. We - * get this from the beginning of htab. The output stack uses the rest - * of htab, and contains characters. There is plenty of room for any - * possible stack (stack used to be 8000 characters). - */ - -#define tab_prefixof(i) codetab[i] -#define tab_suffixof(i) ((char_type *)(htab))[i] -#define de_stack ((char_type *)&tab_suffixof((int)1< 2) - { - outcolor1 = 2; - outcolor2 = 3; - } - if (((++numsaves) & 1) == 0) - { /* reverse the colors on alt saves */ - i = outcolor1; - outcolor1 = outcolor2; - outcolor2 = i; - } - outcolor1s = outcolor1; - outcolor2s = outcolor2; - - /* - * Set up the necessary values - */ - cur_accum = 0; - cur_bits = 0; - clear_flg = 0; - ydot = 0; - ent = 0; - maxcode = MAXCODE(n_bits = startbits); - - ClearCode = (1 << (startbits - 1)); - EOFCode = ClearCode + 1; - free_ent = ClearCode + 2; - - a_count = 0; - hshift = 0; - for (fcode = (long) HSIZE; fcode < 65536L; fcode *= 2L) - hshift++; - hshift = 8 - hshift; /* set hash code range bound */ - - memset(htab,0xff,(unsigned)HSIZE*sizeof(long)); - hsize_reg = HSIZE; - - output((int)ClearCode); - - for (rownum = 0; rownum < ydots; rownum++) - { /* scan through the dots */ - for (ydot = rownum; ydot < rowlimit; ydot += ydots) - { - for (xdot = 0; xdot < xdots; xdot++) - { - if (save16bit == 0 || ydot < ydots) - color = getcolor(xdot, ydot); - else - color = readdisk(xdot + sxoffs, ydot + syoffs); - if (in_count == 0) - { - in_count = 1; - ent = color; - continue; - } - fcode = (long) (((long) color << maxbits) + ent); - i = (((int)color << hshift) ^ ent); /* xor hashing */ - - if (htab[i] == fcode) - { - ent = codetab[i]; - continue; - } else if ((long)htab[i] < 0) /* empty slot */ - goto nomatch; - disp = hsize_reg - i; /* secondary hash (after G. Knott) */ - if (i == 0) - disp = 1; -probe: - if ((i -= disp) < 0) - i += hsize_reg; - - if (htab[i] == fcode) - { - ent = codetab[i]; - continue; - } - if ((long)htab[i] > 0) - goto probe; -nomatch: - output ((int) ent); - ent = color; - if (free_ent < maxmaxcode) - { - /* code -> hashtable */ - codetab[i] = (unsigned short)free_ent++; - htab[i] = fcode; - } - else - cl_block(); - } /* end for xdot */ - if (! driver_diskp() /* supress this on disk-video */ - && ydot == rownum) - { - if ((ydot & 4) == 0) - { - if (++outcolor1 >= colors) - outcolor1 = 0; - if (++outcolor2 >= colors) - outcolor2 = 0; - } - for (i = 0; 250 * i < xdots; i++) - { /* display vert status bars */ - /* (this is NOT GIF-related) */ - putcolor(i, ydot, getcolor(i, ydot) ^ outcolor1); - putcolor(xdots - 1 - i, ydot, - getcolor(xdots - 1 - i, ydot) ^ outcolor2); - } - last_colorbar = ydot; - } /* end if !driver_diskp() */ - tempkey = driver_key_pressed(); - if (tempkey && (tempkey != (int)'s')) /* keyboard hit - bail out */ - { - interrupted = 1; - rownum = ydots; - break; - } - if (tempkey == (int)'s') - driver_get_key(); /* eat the keystroke */ - } /* end for ydot */ - } /* end for rownum */ - - /* - * Put out the final code. - */ - output((int)ent); - output((int) EOFCode); - return (interrupted); -} - -/***************************************************************** - * TAG(output) - * - * Output the given code. - * Inputs: - * code: A n_bits-bit integer. If == -1, then EOF. This assumes - * that n_bits =< (long)wordsize - 1. - * Outputs: - * Outputs code to the file. - * Assumptions: - * Chars are 8 bits long. - * Algorithm: - * Maintain a BITSF character long buffer (so that 8 codes will - * fit in it exactly). Use the VAX insv instruction to insert each - * code in turn. When the buffer fills up empty it and start over. - */ - - -static void _fastcall output(int code) -{ - static unsigned long masks[] = - { 0x0000, 0x0001, 0x0003, 0x0007, 0x000F, - 0x001F, 0x003F, 0x007F, 0x00FF, - 0x01FF, 0x03FF, 0x07FF, 0x0FFF, - 0x1FFF, 0x3FFF, 0x7FFF, 0xFFFF }; - - cur_accum &= masks[ cur_bits ]; - - if (cur_bits > 0) - cur_accum |= ((long)code << cur_bits); - else - cur_accum = code; - - cur_bits += n_bits; - - while (cur_bits >= 8) - { - char_out((unsigned int)(cur_accum & 0xff)); - cur_accum >>= 8; - cur_bits -= 8; - } - - /* - * If the next entry is going to be too big for the code size, - * then increase it, if possible. - */ - if (free_ent > maxcode || clear_flg) - { - if (clear_flg) - { - maxcode = MAXCODE (n_bits = startbits); - clear_flg = 0; - - } - else - { - n_bits++; - if (n_bits == maxbits) - maxcode = maxmaxcode; - else - maxcode = MAXCODE(n_bits); - } - } - - if (code == EOFCode) - { - /* - * At EOF, write the rest of the buffer. - */ - while (cur_bits > 0) - { - char_out((unsigned int)(cur_accum & 0xff)); - cur_accum >>= 8; - cur_bits -= 8; - } - - flush_char(); - - fflush(g_outfile); - } -} - -/* - * Clear out the hash table - */ -static void _fastcall cl_block(void) /* table clear for block compress */ -{ - memset(htab,0xff,(unsigned)HSIZE*sizeof(long)); - free_ent = ClearCode + 2; - clear_flg = 1; - output((int)ClearCode); -} - -/* - * Add a character to the end of the current packet, and if it is 254 - * characters, flush the packet to disk. - */ -static void _fastcall char_out(int c) -{ - accum[ a_count++ ] = (char)c; - if (a_count >= 254) - flush_char(); -} - -/* - * Flush the packet to disk, and reset the accumulator - */ -static void _fastcall flush_char(void) -{ - if (a_count > 0) { - fputc(a_count, g_outfile); - fwrite(accum, 1, a_count, g_outfile); - a_count = 0; - } -} diff --git a/fractint/common/evolve.c b/fractint/common/evolve.c deleted file mode 100644 index 7f1a4970e..000000000 --- a/fractint/common/evolve.c +++ /dev/null @@ -1,1022 +0,0 @@ -#include -#include "port.h" -#include "prototyp.h" -#include "fractype.h" -#include "helpdefs.h" -#define PARMBOX 128 -U16 gene_handle = 0; - -/* px and py are coordinates in the parameter grid (small images on screen) */ -/* evolving = flag, gridsz = dimensions of image grid (gridsz x gridsz) */ -int px,py,evolving,gridsz; -#define MAXGRIDSZ 51 /* This is arbitrary, = 1024/20 */ -static int ecountbox[MAXGRIDSZ][MAXGRIDSZ]; - -unsigned int this_gen_rseed; -/* used to replay random sequences to obtain correct values when selecting a - seed image for next generation */ - -double opx,opy,newopx,newopy,paramrangex,paramrangey,dpx,dpy,fiddlefactor; -double fiddle_reduction; -double parmzoom; -char odpx,odpy,newodpx,newodpy; -/* offset for discrete parameters x and y..*/ -/* used for things like inside or outside types, bailout tests, trig fn etc */ -/* variation factors, opx,opy, paramrangex/y dpx, dpy.. used in field mapping - for smooth variation across screen. opx =offset param x, dpx = delta param - per image, paramrangex = variation across grid of param ...likewise for py */ -/* fiddlefactor is amount of random mutation used in random modes , - fiddle_reduction is used to decrease fiddlefactor from one generation to the - next to eventually produce a stable population */ - -U16 prmboxhandle = 0; -U16 imgboxhandle = 0; -int prmboxcount,imgboxcount; -U16 oldhistory_handle = 0; - -struct phistory_info /* for saving evolution data of center image */ -{ - double param0; - double param1; - double param2; - double param3; - double param4; - double param5; - double param6; - double param7; - double param8; - double param9; - int inside; - int outside; - int decomp0; - double invert0; - double invert1; - double invert2; - BYTE trigndx0; - BYTE trigndx1; - BYTE trigndx2; - BYTE trigndx3; - int bailoutest; -}; - -typedef struct phistory_info PARAMHIST; - -void param_history(int mode); -void varydbl(GENEBASE gene[],int randval,int i); -int varyint( int randvalue, int limit, int mode); -int wrapped_positive_varyint( int randvalue, int limit, int mode ); -void varyinside(GENEBASE gene[], int randval, int i); -void varyoutside(GENEBASE gene[], int randval, int i); -void varypwr2(GENEBASE gene[], int randval, int i); -void varytrig(GENEBASE gene[], int randval, int i); -void varybotest(GENEBASE gene[], int randval, int i); -void varyinv(GENEBASE gene[], int randval, int i); -int explore_check(void); -void spiralmap(int); -static void set_random(int); -void set_mutation_level(int); -void SetupParamBox(void); -void ReleaseParamBox(void); - -void initgene(void) /* set up pointers and mutation params for all usable image - control variables in fractint... revise as necessary when - new vars come along... dont forget to increment NUMGENES - (in fractint.h ) as well */ -{ - int i = 0; - /* 0 = dont vary, 1= with x axis, 2 = with y */ - /* 3 = with x+y, 4 = with x-y, 5 = random, 6 = weighted random */ - /* Use only 15 letters below: 123456789012345 */ - GENEBASE gene[NUMGENES] = { - { ¶m[0], varydbl, 5, "Param 1 real",1 }, - { ¶m[1], varydbl, 5, "Param 1 imag",1 }, - { ¶m[2], varydbl, 0, "Param 2 real",1 }, - { ¶m[3], varydbl, 0, "Param 2 imag",1 }, - { ¶m[4], varydbl, 0, "Param 3 real",1 }, - { ¶m[5], varydbl, 0, "Param 3 imag",1 }, - { ¶m[6], varydbl, 0, "Param 4 real",1 }, - { ¶m[7], varydbl, 0, "Param 4 imag",1 }, - { ¶m[8], varydbl, 0, "Param 5 real",1 }, - { ¶m[9], varydbl, 0, "Param 5 imag",1 }, - { &inside, varyinside, 0, "inside color",2 }, - { &outside, varyoutside, 0, "outside color",3 }, - { &decomp[0], varypwr2, 0, "decomposition",4 }, - { &inversion[0],varyinv, 0, "invert radius",7 }, - { &inversion[1],varyinv, 0, "invert center x",7 }, - { &inversion[2],varyinv, 0, "invert center y",7 }, - { &trigndx[0], varytrig, 0, "trig function 1",5 }, - { &trigndx[1], varytrig, 0, "trig fn 2",5 }, - { &trigndx[2], varytrig, 0, "trig fn 3",5 }, - { &trigndx[3], varytrig, 0, "trig fn 4",5 }, - { &bailoutest, varybotest, 0, "bailout test",6 } - }; - - /* TODO: MemoryAlloc, MoveToMemory */ - if (gene_handle == 0) - gene_handle = MemoryAlloc((U16)sizeof(gene),1L,MEMORY); - MoveToMemory((BYTE *)&gene, (U16)sizeof(gene), 1L, 0L, gene_handle); -} - -void param_history(int mode) -{ /* mode = 0 for save old history, - mode = 1 for restore old history */ - - PARAMHIST oldhistory; - - /* TODO: MemoryAlloc */ - if (oldhistory_handle == 0) - oldhistory_handle = MemoryAlloc((U16)sizeof(oldhistory),1L,MEMORY); - - if (mode == 0) { /* save the old parameter history */ - oldhistory.param0 = param[0]; - oldhistory.param1 = param[1]; - oldhistory.param2 = param[2]; - oldhistory.param3 = param[3]; - oldhistory.param4 = param[4]; - oldhistory.param5 = param[5]; - oldhistory.param6 = param[6]; - oldhistory.param7 = param[7]; - oldhistory.param8 = param[8]; - oldhistory.param9 = param[9]; - oldhistory.inside = inside; - oldhistory.outside = outside; - oldhistory.decomp0 = decomp[0]; - oldhistory.invert0 = inversion[0]; - oldhistory.invert1 = inversion[1]; - oldhistory.invert2 = inversion[2]; - oldhistory.trigndx0 = trigndx[0]; - oldhistory.trigndx1 = trigndx[1]; - oldhistory.trigndx2 = trigndx[2]; - oldhistory.trigndx3 = trigndx[3]; - oldhistory.bailoutest = bailoutest; - MoveToMemory((BYTE *)&oldhistory, (U16)sizeof(oldhistory), 1L, 0L, oldhistory_handle); - } - - if (mode == 1) { /* restore the old parameter history */ - MoveFromMemory((BYTE *)&oldhistory, (U16)sizeof(oldhistory), 1L, 0L, oldhistory_handle); - param[0] = oldhistory.param0; - param[1] = oldhistory.param1; - param[2] = oldhistory.param2; - param[3] = oldhistory.param3; - param[4] = oldhistory.param4; - param[5] = oldhistory.param5; - param[6] = oldhistory.param6; - param[7] = oldhistory.param7; - param[8] = oldhistory.param8; - param[9] = oldhistory.param9; - inside = oldhistory.inside; - outside = oldhistory.outside; - decomp[0] = oldhistory.decomp0; - inversion[0] = oldhistory.invert0; - inversion[1] = oldhistory.invert1; - inversion[2] = oldhistory.invert2; - invert = (inversion[0] == 0.0) ? 0 : 3 ; - trigndx[0] = oldhistory.trigndx0; - trigndx[1] = oldhistory.trigndx1; - trigndx[2] = oldhistory.trigndx2; - trigndx[3] = oldhistory.trigndx3; - bailoutest = oldhistory.bailoutest; - } -} - -void varydbl(GENEBASE gene[],int randval,int i) /* routine to vary doubles */ -{ -int lclpy = gridsz - py - 1; - switch (gene[i].mutate) { - default: - case 0: - break; - case 1: - *(double *)gene[i].addr = px * dpx + opx; /*paramspace x coord * per view delta px + offset */ - break; - case 2: - *(double *)gene[i].addr = lclpy * dpy + opy; /*same for y */ - break; - case 3: - *(double *)gene[i].addr = px*dpx+opx +(lclpy*dpy)+opy; /*and x+y */ - break; - case 4: - *(double *)gene[i].addr = (px*dpx+opx)-(lclpy*dpy+opy); /*and x-y*/ - break; - case 5: - *(double *)gene[i].addr += (((double)randval / RAND_MAX) * 2 * fiddlefactor) - fiddlefactor; - break; - case 6: /* weighted random mutation, further out = further change */ - { - int mid = gridsz /2; - double radius = sqrt( sqr(px - mid) + sqr(lclpy - mid) ); - *(double *)gene[i].addr += ((((double)randval / RAND_MAX) * 2 * fiddlefactor) - fiddlefactor) * radius; - } - break; - } -return; -} - -int varyint( int randvalue, int limit, int mode) -{ -int ret = 0; -int lclpy = gridsz - py - 1; - switch (mode) { - default: - case 0: - break; - case 1: /* vary with x */ - ret = (odpx+px)%limit; - break; - case 2: /* vary with y */ - ret = (odpy+lclpy)%limit; - break; - case 3: /* vary with x+y */ - ret = (odpx+px+odpy+lclpy)%limit; - break; - case 4: /* vary with x-y */ - ret = (odpx+px)-(odpy+lclpy)%limit; - break; - case 5: /* random mutation */ - ret = randvalue % limit; - break; - case 6: /* weighted random mutation, further out = further change */ - { - int mid = gridsz /2; - double radius = sqrt( sqr(px - mid) + sqr(lclpy - mid) ); - ret = (int)((((randvalue / RAND_MAX) * 2 * fiddlefactor) - fiddlefactor) * radius); - ret %= limit; - } - break; - } - return(ret); -} - -int wrapped_positive_varyint( int randvalue, int limit, int mode ) -{ - int i; - i = varyint(randvalue,limit,mode); - if (i < 0) - return(limit + i); - else - return(i); -} - -void varyinside(GENEBASE gene[], int randval, int i) - { - int choices[9]={-59,-60,-61,-100,-101,-102,-103,-104,-1}; - if (gene[i].mutate) - *(int*)gene[i].addr=choices[wrapped_positive_varyint(randval,9,gene[i].mutate)]; - return; - } - -void varyoutside(GENEBASE gene[], int randval, int i) - { - int choices[8]={-1,-2,-3,-4,-5,-6,-7,-8}; - if (gene[i].mutate) - *(int*)gene[i].addr=choices[wrapped_positive_varyint(randval,8,gene[i].mutate)]; - return; - } - -void varybotest(GENEBASE gene[], int randval, int i) - { - int choices[7]={Mod, Real, Imag, Or, And, Manh, Manr}; - if (gene[i].mutate) { - *(int*)gene[i].addr=choices[wrapped_positive_varyint(randval,7,gene[i].mutate)]; - /* move this next bit to varybot where it belongs */ - setbailoutformula(bailoutest); - } - return; - } - -void varypwr2(GENEBASE gene[], int randval, int i) - { - int choices[9]={0,2,4,8,16,32,64,128,256}; - if (gene[i].mutate) - *(int*)gene[i].addr=choices[wrapped_positive_varyint(randval,9,gene[i].mutate)]; - return; -} - -void varytrig(GENEBASE gene[], int randval, int i) - { - if (gene[i].mutate) - /* Changed following to BYTE since trigfn is an array of BYTEs and if one */ - /* of the functions isn't varied, it's value was being zeroed by the high */ - /* BYTE of the preceeding function. JCO 2 MAY 2001 */ - *(BYTE*)gene[i].addr=(BYTE)wrapped_positive_varyint(randval,numtrigfn,gene[i].mutate); - /* replaced '30' with numtrigfn, set in prompts1.c */ - set_trig_pointers(5); /*set all trig ptrs up*/ - return; - } - -void varyinv(GENEBASE gene[], int randval, int i) - { - if (gene[i].mutate) - varydbl(gene,randval,i); - invert = (inversion[0] == 0.0) ? 0 : 3 ; - } - -/* --------------------------------------------------------------------- */ -/* - get_evolve_params() is called from FRACTINT.C whenever the 'ctrl_e' key - is pressed. Return codes are: - -1 routine was ESCAPEd - no need to re-generate the images - 0 minor variable changed. No need to re-generate the image. - 1 major parms changed. Re-generate the images. -*/ -int get_the_rest(void) -{ - char *evolvmodes[]={"no","x","y","x+y","x-y","random","spread"}; - int i,k,num, numtrig; - char *choices[20]; - struct fullscreenvalues uvalues[20]; - GENEBASE gene[NUMGENES]; - - /* TODO: allocate real memory, not reuse shared segment */ -// ptr = (char *) extraseg; - - MoveFromMemory((BYTE *)&gene, (U16)sizeof(gene), 1L, 0L, gene_handle); - - numtrig = (curfractalspecific->flags >> 6) & 7; - if (fractype==FORMULA || fractype==FFORMULA ) { - numtrig = maxfn; - } - -choose_vars_restart: - - k = -1; - for (num = MAXPARAMS; num < (NUMGENES - 5); num++) { - choices[++k]=gene[num].name; - uvalues[k].type = 'l'; - uvalues[k].uval.ch.vlen = 7; - uvalues[k].uval.ch.llen = 7; - uvalues[k].uval.ch.list = evolvmodes; - uvalues[k].uval.ch.val = gene[num].mutate; - } - - for (num = (NUMGENES - 5); num < (NUMGENES - 5 + numtrig); num++) { - choices[++k]=gene[num].name; - uvalues[k].type = 'l'; - uvalues[k].uval.ch.vlen = 7; - uvalues[k].uval.ch.llen = 7; - uvalues[k].uval.ch.list = evolvmodes; - uvalues[k].uval.ch.val = gene[num].mutate; - } - - if (curfractalspecific->calctype == StandardFractal && - (curfractalspecific->flags & BAILTEST) ) { - choices[++k]=gene[NUMGENES - 1].name; - uvalues[k].type = 'l'; - uvalues[k].uval.ch.vlen = 7; - uvalues[k].uval.ch.llen = 7; - uvalues[k].uval.ch.list = evolvmodes; - uvalues[k].uval.ch.val = gene[NUMGENES - 1].mutate; - } - - choices[++k]= ""; - uvalues[k].type = '*'; - choices[++k]= "Press F2 to set all to off"; - uvalues[k].type ='*'; - choices[++k]= "Press F3 to set all on"; - uvalues[k].type = '*'; - choices[++k]= "Press F4 to randomize all"; - uvalues[k].type = '*'; - - i = fullscreen_prompt("Variable tweak central 2 of 2",k+1,choices,uvalues,28,NULL); - - switch (i) { - case FIK_F2: /* set all off */ - for (num = MAXPARAMS; num < NUMGENES; num++) - gene[num].mutate = 0; - goto choose_vars_restart; - case FIK_F3: /* set all on..alternate x and y for field map */ - for (num = MAXPARAMS; num < NUMGENES; num ++ ) - gene[num].mutate = (char)((num % 2) + 1); - goto choose_vars_restart; - case FIK_F4: /* Randomize all */ - for (num =MAXPARAMS; num < NUMGENES; num ++ ) - gene[num].mutate = (char)(rand() % 6); - goto choose_vars_restart; - case -1: - return(-1); - default: - break; - } - - /* read out values */ - k = -1; - for ( num = MAXPARAMS; num < (NUMGENES - 5); num++) - gene[num].mutate = (char)(uvalues[++k].uval.ch.val); - - for (num = (NUMGENES - 5); num < (NUMGENES - 5 + numtrig); num++) - gene[num].mutate = (char)(uvalues[++k].uval.ch.val); - - if (curfractalspecific->calctype == StandardFractal && - (curfractalspecific->flags & BAILTEST) ) - gene[NUMGENES - 1].mutate = (char)(uvalues[++k].uval.ch.val); - - MoveToMemory((BYTE *)&gene, (U16)sizeof(gene), 1L, 0L, gene_handle); - return(1); /* if you were here, you want to regenerate */ -} - -int get_variations(void) -{ - char *evolvmodes[]={"no","x","y","x+y","x-y","random","spread"}; - int i,k,num, numparams; - char *choices[20]; - struct fullscreenvalues uvalues[20]; - GENEBASE gene[NUMGENES]; - int firstparm = 0; - int lastparm = MAXPARAMS; - int chngd = -1; - - /* TODO: allocate real memory, not reuse shared segment */ -// ptr = (char *) extraseg; - - MoveFromMemory((BYTE *)&gene, (U16)sizeof(gene), 1L, 0L, gene_handle); - - if (fractype == FORMULA || fractype == FFORMULA) { - if (uses_p1) /* set first parameter */ - firstparm = 0; - else if (uses_p2) - firstparm = 2; - else if (uses_p3) - firstparm = 4; - else if (uses_p4) - firstparm = 6; - else - firstparm = 8; /* uses_p5 or no parameter */ - - if (uses_p5) /* set last parameter */ - lastparm = 10; - else if (uses_p4) - lastparm = 8; - else if (uses_p3) - lastparm = 6; - else if (uses_p2) - lastparm = 4; - else - lastparm = 2; /* uses_p1 or no parameter */ - } - - numparams = 0; - for (i = firstparm; i < lastparm; i++) - { - if (typehasparm(julibrot?neworbittype:fractype,i,NULL)==0) { - if (fractype == FORMULA || fractype == FFORMULA) - if (paramnotused(i)) - continue; - break; - } - numparams++; - } - - if (fractype != FORMULA && fractype != FFORMULA) - lastparm = numparams; - -choose_vars_restart: - - k = -1; - for (num = firstparm; num < lastparm; num++) { - if (fractype == FORMULA || fractype == FFORMULA) - if (paramnotused(num)) - continue; - choices[++k]=gene[num].name; - uvalues[k].type = 'l'; - uvalues[k].uval.ch.vlen = 7; - uvalues[k].uval.ch.llen = 7; - uvalues[k].uval.ch.list = evolvmodes; - uvalues[k].uval.ch.val = gene[num].mutate; - } - - choices[++k]= ""; - uvalues[k].type = '*'; - choices[++k]= "Press F2 to set all to off"; - uvalues[k].type ='*'; - choices[++k]= "Press F3 to set all on"; - uvalues[k].type = '*'; - choices[++k]= "Press F4 to randomize all"; - uvalues[k].type = '*'; - choices[++k]= "Press F6 for second page"; /* F5 gets eaten */ - uvalues[k].type = '*'; - - i = fullscreen_prompt("Variable tweak central 1 of 2",k+1,choices,uvalues,92,NULL); - - switch (i) { - case FIK_F2: /* set all off */ - for (num = 0; num < MAXPARAMS; num++) - gene[num].mutate = 0; - goto choose_vars_restart; - case FIK_F3: /* set all on..alternate x and y for field map */ - for (num = 0; num < MAXPARAMS; num ++ ) - gene[num].mutate = (char)((num % 2) + 1); - goto choose_vars_restart; - case FIK_F4: /* Randomize all */ - for (num =0; num < MAXPARAMS; num ++ ) - gene[num].mutate = (char)(rand() % 6); - goto choose_vars_restart; - case FIK_F6: /* go to second screen, put array away first */ - MoveToMemory((BYTE *)&gene, (U16)sizeof(gene), 1L, 0L, gene_handle); - chngd = get_the_rest(); - MoveFromMemory((BYTE *)&gene, (U16)sizeof(gene), 1L, 0L, gene_handle); - goto choose_vars_restart; - case -1: - return(chngd); - default: - break; - } - - /* read out values */ - k = -1; - for (num = firstparm; num < lastparm; num++) { - if (fractype == FORMULA || fractype == FFORMULA) - if (paramnotused(num)) - continue; - gene[num].mutate = (char)(uvalues[++k].uval.ch.val); - } - - MoveToMemory((BYTE *)&gene, (U16)sizeof(gene), 1L, 0L, gene_handle); - return(1); /* if you were here, you want to regenerate */ -} - -void set_mutation_level(int strength) -{ -/* scan through the gene array turning on random variation for all parms that */ -/* are suitable for this level of mutation */ - int i; - GENEBASE gene[NUMGENES]; - /* get the gene array from memory */ - MoveFromMemory((BYTE *)&gene, (U16)sizeof(gene), 1L, 0L, gene_handle); - - for (i=0;i) */ - - k = -1; - - viewwindow = evolving = uvalues[++k].uval.ch.val; - - if (!evolving && i != FIK_F6) /* don't need any of the other parameters JCO 12JUL2002 */ - return(1); /* the following code can set evolving even if it's off */ - - gridsz = uvalues[++k].uval.ival; - tmp = sxdots / (MINPIXELS<<1); - /* (sxdots / 20), max # of subimages @ 20 pixels per subimage */ - /* MAXGRIDSZ == 1024 / 20 == 51 */ - if (gridsz > MAXGRIDSZ) - gridsz = MAXGRIDSZ; - if (gridsz > tmp) - gridsz = tmp; - if (gridsz < 3) - gridsz = 3; - gridsz |= 1; /* make sure gridsz is odd */ - if (explore_check()) { - tmp = (PARMBOX * uvalues[++k].uval.ch.val); - if (evolving) - evolving += tmp; - paramrangex = uvalues[++k].uval.dval; - newopx = opx = uvalues[++k].uval.dval; - paramrangey = uvalues[++k].uval.dval; - newopy = opy = uvalues[++k].uval.dval; - } - - fiddlefactor = uvalues[++k].uval.dval; - - fiddle_reduction = uvalues[++k].uval.dval; - - if (!(uvalues[++k].uval.ch.val)) evolving = evolving + NOGROUT; - - viewxdots = (sxdots / gridsz)-2; - viewydots = (sydots / gridsz)-2; - if (!viewwindow) viewxdots=viewydots=0; - - i = 0; - - if ( evolving != old_evolving - || (gridsz != old_gridsz) ||(paramrangex!= old_paramrangex) - || (opx != old_opx ) || (paramrangey != old_paramrangey) - || (opy != old_opy) || (fiddlefactor != old_fiddlefactor) - || (old_variations > 0) ) - i = 1; - - if (evolving && !old_evolving) - param_history(0); /* save old history */ - - if (!evolving && (evolving == old_evolving)) i = 0; - -if (j==FIK_F6) { - old_variations = get_variations(); - set_current_params(); - if (old_variations > 0) - { - viewwindow = 1; - evolving |= 1; /* leave other settings alone */ - } - fiddlefactor = 1; - fiddle_reduction = 1.0; - goto get_evol_restart; - } - return(i); -} - -void SetupParamBox(void) -{ - int vidsize; - prmboxcount = 0; - parmzoom=((double)gridsz-1.0)/2.0; -/* need to allocate 2 int arrays for boxx and boxy plus 1 byte array for values */ - vidsize = (xdots+ydots) * 4 * sizeof(int) ; - vidsize = vidsize + xdots + ydots + 2 ; - /* TODO: MemoryAlloc */ - if (prmboxhandle == 0) - prmboxhandle = MemoryAlloc((U16)(vidsize),1L,MEMORY); - if (prmboxhandle == 0 ) { - texttempmsg("Sorry...can't allocate mem for parmbox"); - evolving=0; - } - prmboxcount=0; - -/* vidsize = (vidsize / gridsz)+3 ; */ /* allocate less mem for smaller box */ -/* taken out above as *all* pixels get plotted in small boxes */ - /* TODO: MemoryAlloc */ - if (imgboxhandle == 0) - imgboxhandle = MemoryAlloc((U16)(vidsize),1L,MEMORY); - if (!imgboxhandle) { - texttempmsg("Sorry...can't allocate mem for imagebox"); - } -} - -void ReleaseParamBox(void) -{ - MemoryRelease(prmboxhandle); - MemoryRelease(imgboxhandle); - prmboxhandle = 0; - imgboxhandle = 0; -} - -void set_current_params(void) -{ - paramrangex = curfractalspecific->xmax - curfractalspecific->xmin; - opx = newopx = - (paramrangex / 2); - paramrangey = curfractalspecific->ymax - curfractalspecific->ymin; - opy = newopy = - (paramrangey / 2); - return; -} - -void fiddleparms(GENEBASE gene[], int ecount) -{ -/* call with px,py ... parameter set co-ords*/ -/* set random seed then call rnd enough times to get to px,py */ -/* 5/2/96 adding in indirection */ -/* 26/2/96 adding in multiple methods and field map */ -/* 29/4/96 going for proper handling of the whole gene array */ -/* bung in a pile of switches to allow for expansion to any - future variable types */ -/* 11/6/96 scrapped most of switches above and used function pointers - instead */ -/* 4/1/97 picking it up again after the last step broke it all horribly! */ - - int i; - -/* when writing routines to vary param types make sure that rand() gets called -the same number of times whether gene[].mutate is set or not to allow -user to change it between generations without screwing up the duplicability -of the sequence and starting from the wrong point */ - -/* this function has got simpler and simpler throughout the construction of the - evolver feature and now consists of just these few lines to loop through all - the variables referenced in the gene array and call the functions required - to vary them, aren't pointers marvellous! */ - - if ((px == gridsz / 2) && (py == gridsz / 2)) /* return if middle image */ - return; - - set_random(ecount); /* generate the right number of pseudo randoms */ - - for (i=0;i 0) && (gene[i].mutate < 5)) nonrandom = TRUE; - return(nonrandom); -} - -void drawparmbox(int mode) -{ -/* draws parameter zoom box in evolver mode */ -/* clears boxes off screen if mode=1, otherwise, redraws boxes */ -struct coords tl,tr,bl,br; -int grout; - if (!(evolving & PARMBOX)) return; /* don't draw if not asked to! */ - grout = !((evolving & NOGROUT)/NOGROUT) ; - imgboxcount = boxcount; - if (boxcount) { - /* stash normal zoombox pixels */ - MoveToMemory((BYTE *)boxx,(U16)(boxcount*2),1L,0L,imgboxhandle); - MoveToMemory((BYTE *)boxy,(U16)(boxcount*2),1L,1L,imgboxhandle); - MoveToMemory((BYTE *)boxvalues,(U16)boxcount,1L,4L,imgboxhandle); - clearbox(); /* to avoid probs when one box overlaps the other */ - } - if (prmboxcount!=0) { /* clear last parmbox */ - boxcount=prmboxcount; - MoveFromMemory((BYTE *)boxx,(U16)(boxcount*2),1L,0L,prmboxhandle); - MoveFromMemory((BYTE *)boxy,(U16)(boxcount*2),1L,1L,prmboxhandle); - MoveFromMemory((BYTE *)boxvalues,(U16)boxcount,1L,4L,prmboxhandle); - clearbox(); - } - - if (mode == 1) { - boxcount = imgboxcount; - prmboxcount = 0; - return; - } - - boxcount =0; - /*draw larger box to show parm zooming range */ - tl.x = bl.x = ((px -(int)parmzoom) * (int)(dxsize+1+grout))-sxoffs-1; - tl.y = tr.y = ((py -(int)parmzoom) * (int)(dysize+1+grout))-syoffs-1; - br.x = tr.x = ((px +1+(int)parmzoom) * (int)(dxsize+1+grout))-sxoffs; - br.y = bl.y = ((py +1+(int)parmzoom) * (int)(dysize+1+grout))-syoffs; -#ifndef XFRACT - addbox(br);addbox(tr);addbox(bl);addbox(tl); - drawlines(tl,tr,bl.x-tl.x,bl.y-tl.y); - drawlines(tl,bl,tr.x-tl.x,tr.y-tl.y); -#else - boxx[0] = tl.x + sxoffs; - boxy[0] = tl.y + syoffs; - boxx[1] = tr.x + sxoffs; - boxy[1] = tr.y + syoffs; - boxx[2] = br.x + sxoffs; - boxy[2] = br.y + syoffs; - boxx[3] = bl.x + sxoffs; - boxy[3] = bl.y + syoffs; - boxcount = 8; -#endif - if (boxcount) { - dispbox(); - /* stash pixel values for later */ - MoveToMemory((BYTE *)boxx,(U16)(boxcount*2),1L,0L,prmboxhandle); - MoveToMemory((BYTE *)boxy,(U16)(boxcount*2),1L,1L,prmboxhandle); - MoveToMemory((BYTE *)boxvalues,(U16)boxcount,1L,4L,prmboxhandle); - } - prmboxcount = boxcount; - boxcount = imgboxcount; - if (imgboxcount) { - /* and move back old values so that everything can proceed as normal */ - MoveFromMemory((BYTE *)boxx,(U16)(boxcount*2),1L,0L,imgboxhandle); - MoveFromMemory((BYTE *)boxy,(U16)(boxcount*2),1L,1L,imgboxhandle); - MoveFromMemory((BYTE *)boxvalues,(U16)boxcount,1L,4L,imgboxhandle); - dispbox(); - } - return; -} - -void set_evolve_ranges(void) -{ -int lclpy = gridsz - py - 1; - /* set up ranges and offsets for parameter explorer/evolver */ - paramrangex=dpx*(parmzoom*2.0); - paramrangey=dpy*(parmzoom*2.0); - newopx=opx+(((double)px-parmzoom)*dpx); - newopy=opy+(((double)lclpy-parmzoom)*dpy); - - newodpx=(char)(odpx+(px-gridsz/2)); - newodpy=(char)(odpy+(lclpy-gridsz/2)); - return; -} - -void spiralmap(int count) -{ - /* maps out a clockwise spiral for a prettier and possibly */ - /* more intuitively useful order of drawing the sub images. */ - /* All the malarky with count is to allow resuming */ - - int i,mid,offset; - i = 0; - mid = gridsz / 2; - if (count == 0) { /* start in the middle */ - px = py = mid; - return; - } - for (offset = 1; offset <= mid; offset ++) { - /* first do the top row */ - py = (mid - offset); - for (px = (mid - offset)+1; px mid - offset;px--) { - i++; - if (i == count) return; - } - /* then up the left to finish */ - for (; py >= mid - offset; py-- ) { - i++; - if (i== count ) return; - } - } -} - -int unspiralmap(void) -{ - /* unmaps the clockwise spiral */ - /* All this malarky is to allow selecting different subimages */ - /* Returns the count from the center subimage to the current px & py */ - int mid; - static int oldgridsz = 0; - - mid = gridsz / 2; - if ((px == mid && py == mid) || (oldgridsz != gridsz)) { - int i, gridsqr; - /* set up array and return */ - gridsqr = gridsz * gridsz; - ecountbox[px][py] = 0; /* we know the first one, do the rest */ - for (i = 1; i < gridsqr; i++) { - spiralmap(i); - ecountbox[px][py] = i; - } - oldgridsz = gridsz; - px = py = mid; - return(0); - } - return(ecountbox[px][py]); -} - - /* points to ponder..... - watch out for near mem..... (TW) It's better now. - try and keep gene array in overlay? (TW) No, but try dynamic alloc. - how to preserve 'what to mutate ' choices through overlay swaps in - prompts... (TW) Needs checking, seems OK. LOADCHOICES copies, so is - safe. - */ - diff --git a/fractint/common/f16.c b/fractint/common/f16.c deleted file mode 100644 index e311017d2..000000000 --- a/fractint/common/f16.c +++ /dev/null @@ -1,92 +0,0 @@ -/************************************** -** -** F16.C : Code to read 16-bit fractal data sets. Uses -** strictly Targa16 type 10 files (run-length encoded 16-bit RGB). -*/ - -/* Lee Daniel Crocker CompuServe: 73407,2030 <== Preferred -** 1380 Jewett Ave. BIX: lcrocker -** Pittsburg, CA 94565 Usenet: ...!ames!pacbell!sactoh0!siva!lee -** -** This code is hereby placed in the public domain. You are free to -** use, modify, usurp, laugh at, destroy, or otherwise abuse it in any -** way you see fit. -** -** "If you steal from one author it's plagiarism; if you steal from -** many it's research." --Wilson Mizner -*/ - -/* 16 bit .tga files were generated for continuous potential "potfile"s - from version 9.? thru version 14. Replaced by double row gif type - file (.pot) in version 15. Delete this code after a few more revs. - The part which wrote 16 bit .tga files has already been deleted. -*/ - -#include -#include - /* see Fractint.c for a description of the "include" hierarchy */ -#include "port.h" -#include "prototyp.h" -#include "targa_lc.h" - -#ifdef XFRACT -char rlebuf[258]; /* RLE-state variables */ -#endif -static int state, count, bufp; - -/************************************** -** -** Open previously saved Targa16 type 10 file filling in hs, vs, and -** csize with values in the header. If *csize is not zero, the block -** pointed to by cp is filled with the comment block. The caller -** _must_ allocate 256 bytes for this purpose before calling. -*/ - -FILE *t16_open(char *fname, int *hs, int *vs, int *csize, U8 *cp) -{ - char filename[64]; - U8 header[HEADERSIZE]; - FILE *fp; - - strcpy(filename, fname); - if (has_ext(filename) == NULL) strcat(filename, ".TGA"); - fp = fopen(filename, READMODE); - if (fp == NULL) return NULL; - - fread(header, HEADERSIZE, 1, fp); - if ((header[O_FILETYPE] != T_RLERGB) || (header[O_ESIZE] != 16)) { - fclose(fp); - return NULL; - } - GET16(header[O_HSIZE], *hs); - GET16(header[O_VSIZE], *vs); - if ((*csize = header[O_COMMENTLEN]) != 0) fread(cp, *csize, 1, fp); - - state = count = bufp = 0; - return fp; -} - -int t16_getline(FILE *fp, int hs, U16 *data) -{ - int i; - - for (i=0; i 127) { - state = 1; - count -= 127; - fread(rlebuf, 2, 1, fp); - } else { - state = 2; - ++count; - fread(rlebuf, 2, count, fp); - } - } - GET16(rlebuf[bufp], data[i]); - if (--count == 0) state = 0; - if (state == 2) bufp += 2; - } - return 0; -} - diff --git a/fractint/common/fracsubr.c b/fractint/common/fracsubr.c deleted file mode 100644 index 142222419..000000000 --- a/fractint/common/fracsubr.c +++ /dev/null @@ -1,1664 +0,0 @@ -/* -FRACSUBR.C contains subroutines which belong primarily to CALCFRAC.C and -FRACTALS.C, i.e. which are non-fractal-specific fractal engine subroutines. -*/ -#include - -#ifndef USE_VARARGS -#include -#else -#include -#endif - -#ifndef XFRACT -#include -#endif -#include -#include - /* see Fractint.c for a description of the "include" hierarchy */ -#include "port.h" -#include "prototyp.h" -#include "fractype.h" -#include "drivers.h" - -#if defined(_WIN32) -#define ftimex ftime -#define timebx timeb -#endif - -/* routines in this module */ - -static long _fastcall fudgetolong(double d); -static double _fastcall fudgetodouble(long l); -static void _fastcall adjust_to_limits(double); -static void _fastcall smallest_add(double *); -static int _fastcall ratio_bad(double,double); -static void _fastcall plotdorbit(double,double,int); -static int _fastcall combine_worklist(void); - -static void _fastcall adjust_to_limitsbf(double); -static void _fastcall smallest_add_bf(bf_t); - int resume_len; /* length of resume info */ -static int resume_offset; /* offset in resume info gets */ - int taborhelp; /* kludge for sound and tab or help key press */ - -#define FUDGEFACTOR 29 /* fudge all values up by 2**this */ -#define FUDGEFACTOR2 24 /* (or maybe this) */ - -void free_grid_pointers() -{ - if (dx0) - { - free(dx0); - dx0 = NULL; - } - if (lx0) - { - free(lx0); - lx0 = NULL; - } -} - -void set_grid_pointers() -{ - free_grid_pointers(); - dx0 = (double *) malloc(sizeof(double)*(2*xdots + 2*ydots)); - dy1 = dx0 + xdots; - dy0 = dy1 + xdots; - dx1 = dy0 + ydots; - lx0 = (long *) malloc(sizeof(long)*(2*xdots + 2*ydots)); - ly1 = lx0 + xdots; - ly0 = ly1 + xdots; - lx1 = ly0 + ydots; - set_pixel_calc_functions(); -} - -void fill_dx_array(void) -{ - int i; - if (use_grid) - { - dx0[0] = xxmin; /* fill up the x, y grids */ - dy0[0] = yymax; - dx1[0] = dy1[0] = 0; - for (i = 1; i < xdots; i++ ) { - dx0[i] = (double)(dx0[0] + i*delxx); - dy1[i] = (double)(dy1[0] - i*delyy2); - } - for (i = 1; i < ydots; i++ ) { - dy0[i] = (double)(dy0[0] - i*delyy); - dx1[i] = (double)(dx1[0] + i*delxx2); - } - } -} -void fill_lx_array(void) -{ - int i; - /* note that lx1 & ly1 values can overflow into sign bit; since */ - /* they're used only to add to lx0/ly0, 2s comp straightens it out */ - if (use_grid) - { - lx0[0] = xmin; /* fill up the x, y grids */ - ly0[0] = ymax; - lx1[0] = ly1[0] = 0; - for (i = 1; i < xdots; i++ ) { - lx0[i] = lx0[i-1] + delx; - ly1[i] = ly1[i-1] - dely2; - } - for (i = 1; i < ydots; i++ ) { - ly0[i] = ly0[i-1] - dely; - lx1[i] = lx1[i-1] + delx2; - } - } -} - -void fractal_floattobf(void) -{ - int i; - init_bf_dec(getprecdbl(CURRENTREZ)); - floattobf(bfxmin,xxmin); - floattobf(bfxmax,xxmax); - floattobf(bfymin,yymin); - floattobf(bfymax,yymax); - floattobf(bfx3rd,xx3rd); - floattobf(bfy3rd,yy3rd); - - for (i = 0; i < MAXPARAMS; i++) - if (typehasparm(fractype,i,NULL)) - floattobf(bfparms[i],param[i]); - calc_status = CALCSTAT_PARAMS_CHANGED; -} - - -#ifdef _MSC_VER -#if _MSC_VER == 800 -/* MSC8 doesn't correctly calculate the address of certain arrays here */ -#pragma optimize( "", off ) -#endif -#endif - -int use_grid; - -void calcfracinit(void) /* initialize a *pile* of stuff for fractal calculation */ -{ - int tries = 0; - int i, gotprec; - long xytemp; - double ftemp; - coloriter=oldcoloriter = 0L; - for (i=0; i<10; i++) - rhombus_stack[i] = 0; - - /* set up grid array compactly leaving space at end */ - /* space req for grid is 2(xdots+ydots)*sizeof(long or double) */ - /* space available in extraseg is 65536 Bytes */ - xytemp = xdots + ydots; - if ( ((usr_floatflag == 0) && (xytemp * sizeof(long) > 32768)) || - ((usr_floatflag == 1) && (xytemp * sizeof(double) > 32768)) || - debugflag == 3800) - { - use_grid=0; - floatflag = usr_floatflag = 1; - } - else - use_grid=1; - - set_grid_pointers(); - - if (!(curfractalspecific->flags & BF_MATH)) - { - int tofloat = curfractalspecific->tofloat; - if (tofloat == NOFRACTAL) - bf_math = 0; - else if (!(fractalspecific[tofloat].flags & BF_MATH)) - bf_math = 0; - else if (bf_math) - { - curfractalspecific = &fractalspecific[tofloat]; - fractype = tofloat; - } - } - - /* switch back to double when zooming out if using arbitrary precision */ - if (bf_math) - { - gotprec=getprecbf(CURRENTREZ); - if ((gotprec <= DBL_DIG+1 && debugflag != 3200) || math_tol[1] >= 1.0) - { - bfcornerstofloat(); - bf_math = 0; - } - else - init_bf_dec(gotprec); - } - else if ((fractype==MANDEL || fractype==MANDELFP) && debugflag==3200) - { - fractype=MANDELFP; - curfractalspecific = &fractalspecific[MANDELFP]; - fractal_floattobf(); - usr_floatflag = 1; - } - else if ((fractype==JULIA || fractype==JULIAFP) && debugflag==3200) - { - fractype=JULIAFP; - curfractalspecific = &fractalspecific[JULIAFP]; - fractal_floattobf(); - usr_floatflag = 1; - } - else if ((fractype==LMANDELZPOWER || fractype==FPMANDELZPOWER) && debugflag==3200) - { - fractype=FPMANDELZPOWER; - curfractalspecific = &fractalspecific[FPMANDELZPOWER]; - fractal_floattobf(); - usr_floatflag = 1; - } - else if ((fractype==LJULIAZPOWER || fractype==FPJULIAZPOWER) && debugflag==3200) - { - fractype=FPJULIAZPOWER; - curfractalspecific = &fractalspecific[FPJULIAZPOWER]; - fractal_floattobf(); - usr_floatflag = 1; - } - else - free_bf_vars(); - if (bf_math) - floatflag=1; - else - floatflag = usr_floatflag; - if (calc_status == CALCSTAT_RESUMABLE) { /* on resume, ensure floatflag correct */ - if (curfractalspecific->isinteger) - floatflag = 0; - else - floatflag = 1; - } - /* if floating pt only, set floatflag for TAB screen */ - if (!curfractalspecific->isinteger && curfractalspecific->tofloat == NOFRACTAL) - floatflag = 1; - if (usr_stdcalcmode == 's') { - if (fractype == MANDEL || fractype == MANDELFP) - floatflag = 1; - else - usr_stdcalcmode = '1'; - } - -init_restart: -#if defined(_WIN32) - _ASSERTE(_CrtCheckMemory()); -#endif - - /* the following variables may be forced to a different setting due to - calc routine constraints; usr_xxx is what the user last said is wanted, - xxx is what we actually do in the current situation */ - stdcalcmode = usr_stdcalcmode; - periodicitycheck = usr_periodicitycheck; - distest = usr_distest; - biomorph = usr_biomorph; - - potflag = 0; - if (potparam[0] != 0.0 - && colors >= 64 - && (curfractalspecific->calctype == StandardFractal - || curfractalspecific->calctype == calcmand - || curfractalspecific->calctype == calcmandfp)) { - potflag = 1; - distest = usr_distest = 0; /* can't do distest too */ - } - - if (distest) - floatflag = 1; /* force floating point for dist est */ - - if (floatflag) { /* ensure type matches floatflag */ - if (curfractalspecific->isinteger != 0 - && curfractalspecific->tofloat != NOFRACTAL) - fractype = curfractalspecific->tofloat; - } - else { - if (curfractalspecific->isinteger == 0 - && curfractalspecific->tofloat != NOFRACTAL) - fractype = curfractalspecific->tofloat; - } - /* match Julibrot with integer mode of orbit */ - if (fractype == JULIBROTFP && fractalspecific[neworbittype].isinteger) - { - int i; - if ((i=fractalspecific[neworbittype].tofloat) != NOFRACTAL) - neworbittype = i; - else - fractype = JULIBROT; - } - else if (fractype == JULIBROT && fractalspecific[neworbittype].isinteger==0) - { - int i; - if ((i=fractalspecific[neworbittype].tofloat) != NOFRACTAL) - neworbittype = i; - else - fractype = JULIBROTFP; - } - - curfractalspecific = &fractalspecific[fractype]; - - integerfractal = curfractalspecific->isinteger; - -/* if (fractype == JULIBROT) - rqlim = 4; - else */ if (potflag && potparam[2] != 0.0) - rqlim = potparam[2]; -/* else if (decomp[0] > 0 && decomp[1] > 0) - rqlim = (double)decomp[1]; */ - else if (bailout) /* user input bailout */ - rqlim = bailout; - else if (biomorph != -1) /* biomorph benefits from larger bailout */ - rqlim = 100; - else - rqlim = curfractalspecific->orbit_bailout; - if (integerfractal) /* the bailout limit mustn't be too high here */ - if (rqlim > 127.0) rqlim = 127.0; - - if ((curfractalspecific->flags&NOROTATE) != 0) { - /* ensure min xxmax) { ftemp = xxmax; xxmax = xxmin; xxmin = ftemp; } - if (yymin > yymax) { ftemp = yymax; yymax = yymin; yymin = ftemp; } - xx3rd = xxmin; yy3rd = yymin; - } - - /* set up bitshift for integer math */ - bitshift = FUDGEFACTOR2; /* by default, the smaller shift */ - if (integerfractal > 1) /* use specific override from table */ - bitshift = integerfractal; - if (integerfractal == 0) { /* float? */ - if ((i = curfractalspecific->tofloat) != NOFRACTAL) /* -> int? */ - { - if (fractalspecific[i].isinteger > 1) /* specific shift? */ - bitshift = fractalspecific[i].isinteger; - } - else - bitshift = 16; /* to allow larger corners */ - } -/* We want this code if we're using the assembler calcmand */ - if (fractype == MANDEL || fractype == JULIA) { /* adust shift bits if.. */ - if (potflag == 0 /* not using potential */ - && (param[0] > -2.0 && param[0] < 2.0) /* parameters not too large */ - && (param[1] > -2.0 && param[1] < 2.0) - && !invert /* and not inverting */ - && biomorph == -1 /* and not biomorphing */ - && rqlim <= 4.0 /* and bailout not too high */ - && (outside > -2 || outside < -6) /* and no funny outside stuff */ - && debugflag != 1234 /* and not debugging */ - && closeprox <= 2.0 /* and closeprox not too large */ - && bailoutest == Mod) /* and bailout test = mod */ - bitshift = FUDGEFACTOR; /* use the larger bitshift */ - } - - fudge = 1L << bitshift; - - l_at_rad = fudge/32768L; - f_at_rad = 1.0/32768L; - - /* now setup arrays of real coordinates corresponding to each pixel */ - if (bf_math) - adjust_to_limitsbf(1.0); /* make sure all corners in valid range */ - else - { - adjust_to_limits(1.0); /* make sure all corners in valid range */ - delxx = (LDBL)(xxmax - xx3rd) / (LDBL)dxsize; /* calculate stepsizes */ - delyy = (LDBL)(yymax - yy3rd) / (LDBL)dysize; - delxx2 = (LDBL)(xx3rd - xxmin) / (LDBL)dysize; - delyy2 = (LDBL)(yy3rd - yymin) / (LDBL)dxsize; - fill_dx_array(); - } - - if (fractype != CELLULAR && fractype != ANT) /* fudgetolong fails w >10 digits in double */ - { - creal = fudgetolong(param[0]); /* integer equivs for it all */ - cimag = fudgetolong(param[1]); - xmin = fudgetolong(xxmin); - xmax = fudgetolong(xxmax); - x3rd = fudgetolong(xx3rd); - ymin = fudgetolong(yymin); - ymax = fudgetolong(yymax); - y3rd = fudgetolong(yy3rd); - delx = fudgetolong((double)delxx); - dely = fudgetolong((double)delyy); - delx2 = fudgetolong((double)delxx2); - dely2 = fudgetolong((double)delyy2); - } - - /* skip this if plasma to avoid 3d problems */ - /* skip if bf_math to avoid extraseg conflict with dx0 arrays */ - /* skip if ifs, ifs3d, or lsystem to avoid crash when mathtolerance */ - /* is set. These types don't auto switch between float and integer math */ - if (fractype != PLASMA && bf_math == 0 - && fractype != IFS && fractype != IFS3D && fractype != LSYSTEM) - { - if (integerfractal && !invert && use_grid) - { - if ( (delx == 0 && delxx != 0.0) - || (delx2 == 0 && delxx2 != 0.0) - || (dely == 0 && delyy != 0.0) - || (dely2 == 0 && delyy2 != 0.0) ) - goto expand_retry; - - fill_lx_array(); /* fill up the x,y grids */ - /* past max res? check corners within 10% of expected */ - if ( ratio_bad((double)lx0[xdots-1]-xmin,(double)xmax-x3rd) - || ratio_bad((double)ly0[ydots-1]-ymax,(double)y3rd-ymax) - || ratio_bad((double)lx1[(ydots>>1)-1],((double)x3rd-xmin)/2) - || ratio_bad((double)ly1[(xdots>>1)-1],((double)ymin-y3rd)/2) ) - { -expand_retry: - if (integerfractal /* integer fractal type? */ - && curfractalspecific->tofloat != NOFRACTAL) - floatflag = 1; /* switch to floating pt */ - else - adjust_to_limits(2.0); /* double the size */ - if (calc_status == CALCSTAT_RESUMABLE) /* due to restore of an old file? */ - calc_status = CALCSTAT_PARAMS_CHANGED; /* whatever, it isn't resumable */ - goto init_restart; - } /* end if ratio bad */ - - /* re-set corners to match reality */ - xmax = lx0[xdots-1] + lx1[ydots-1]; - ymin = ly0[ydots-1] + ly1[xdots-1]; - x3rd = xmin + lx1[ydots-1]; - y3rd = ly0[ydots-1]; - xxmin = fudgetodouble(xmin); - xxmax = fudgetodouble(xmax); - xx3rd = fudgetodouble(x3rd); - yymin = fudgetodouble(ymin); - yymax = fudgetodouble(ymax); - yy3rd = fudgetodouble(y3rd); - } /* end if (integerfractal && !invert && use_grid) */ - else - { - double dx0,dy0,dx1,dy1; - /* set up dx0 and dy0 analogs of lx0 and ly0 */ - /* put fractal parameters in doubles */ - dx0 = xxmin; /* fill up the x, y grids */ - dy0 = yymax; - dx1 = dy1 = 0; - /* this way of defining the dx and dy arrays is not the most - accurate, but it is kept because it is used to determine - the limit of resolution */ - for (i = 1; i < xdots; i++ ) { - dx0 = (double)(dx0 + (double)delxx); - dy1 = (double)(dy1 - (double)delyy2); - } - for (i = 1; i < ydots; i++ ) { - dy0 = (double)(dy0 - (double)delyy); - dx1 = (double)(dx1 + (double)delxx2); - } - if (bf_math == 0) /* redundant test, leave for now */ - { - double testx_try, testx_exact; - double testy_try, testy_exact; - /* Following is the old logic for detecting failure of double - precision. It has two advantages: it is independent of the - representation of numbers, and it is sensitive to resolution - (allows depper zooms at lower resolution. However it fails - for rotations of exactly 90 degrees, so we added a safety net - by using the magnification. */ - if (++tries < 2) /* for safety */ - { - if (tries > 1) stopmsg(0, "precision-detection error"); - /* Previously there were four tests of distortions in the - zoom box used to detect precision limitations. In some - cases of rotated/skewed zoom boxs, this causes the algorithm - to bail out to arbitrary precision too soon. The logic - now only tests the larger of the two deltas in an attempt - to repair this bug. This should never make the transition - to arbitrary precision sooner, but always later.*/ - if (fabs(xxmax-xx3rd) > fabs(xx3rd-xxmin)) - { - testx_exact = xxmax-xx3rd; - testx_try = dx0-xxmin; - } - else - { - testx_exact = xx3rd-xxmin; - testx_try = dx1; - } - if (fabs(yy3rd-yymax) > fabs(yymin-yy3rd)) - { - testy_exact = yy3rd-yymax; - testy_try = dy0-yymax; - } - else - { - testy_exact = yymin-yy3rd; - testy_try = dy1; - } - if (ratio_bad(testx_try,testx_exact) || - ratio_bad(testy_try,testy_exact)) - { - if (curfractalspecific->flags & BF_MATH) - { - fractal_floattobf(); - goto init_restart; - } - goto expand_retry; - } /* end if ratio_bad etc. */ - } /* end if tries < 2 */ - } /* end if bf_math == 0 */ - - /* if long double available, this is more accurate */ - fill_dx_array(); /* fill up the x, y grids */ - - /* re-set corners to match reality */ - xxmax = (double)(xxmin + (xdots-1)*delxx + (ydots-1)*delxx2); - yymin = (double)(yymax - (ydots-1)*delyy - (xdots-1)*delyy2); - xx3rd = (double)(xxmin + (ydots-1)*delxx2); - yy3rd = (double)(yymax - (ydots-1)*delyy); - - } /* end else */ - } /* end if not plasma */ - - /* for periodicity close-enough, and for unity: */ - /* min(max(delx,delx2),max(dely,dely2) */ - ddelmin = fabs((double)delxx); - if (fabs((double)delxx2) > ddelmin) - ddelmin = fabs((double)delxx2); - if (fabs((double)delyy) > fabs((double)delyy2)) - { - if (fabs((double)delyy) < ddelmin) - ddelmin = fabs((double)delyy); - } - else if (fabs((double)delyy2) < ddelmin) - ddelmin = fabs((double)delyy2); - delmin = fudgetolong(ddelmin); - - /* calculate factors which plot real values to screen co-ords */ - /* calcfrac.c plot_orbit routines have comments about this */ - ftemp = (double)((0.0-delyy2) * delxx2 * dxsize * dysize - - (xxmax-xx3rd) * (yy3rd-yymax)); - if (ftemp != 0) - { - plotmx1 = (double)(delxx2 * dxsize * dysize / ftemp); - plotmx2 = (yy3rd-yymax) * dxsize / ftemp; - plotmy1 = (double)((0.0-delyy2) * dxsize * dysize / ftemp); - plotmy2 = (xxmax-xx3rd) * dysize / ftemp; - } - if (bf_math == 0) - free_bf_vars(); -} - -#ifdef _MSC_VER -#if _MSC_VER == 800 -#pragma optimize( "", on ) /* restore optimization options */ -#endif -#endif - -static long _fastcall fudgetolong(double d) -{ - if ((d *= fudge) > 0) d += 0.5; - else d -= 0.5; - return (long)d; -} - -static double _fastcall fudgetodouble(long l) -{ - char buf[30]; - double d; - sprintf(buf,"%.9g",(double)l / fudge); -#ifndef XFRACT - sscanf(buf,"%lg",&d); -#else - sscanf(buf,"%lf",&d); -#endif - return d; -} - -void adjust_cornerbf(void) -{ - /* make edges very near vert/horiz exact, to ditch rounding errs and */ - /* to avoid problems when delta per axis makes too large a ratio */ - double ftemp; - double Xmagfactor, Rotation, Skew; - LDBL Magnification; - - bf_t bftemp, bftemp2; - bf_t btmp1; - int saved; saved = save_stack(); - bftemp = alloc_stack(rbflength+2); - bftemp2 = alloc_stack(rbflength+2); - btmp1 = alloc_stack(rbflength+2); - - /* While we're at it, let's adjust the Xmagfactor as well */ - /* use bftemp, bftemp2 as bfXctr, bfYctr */ - cvtcentermagbf(bftemp, bftemp2, &Magnification, &Xmagfactor, &Rotation, &Skew); - ftemp = fabs(Xmagfactor); - if (ftemp != 1 && ftemp >= (1-aspectdrift) && ftemp <= (1+aspectdrift)) - { - Xmagfactor = sign(Xmagfactor); - cvtcornersbf(bftemp, bftemp2, Magnification, Xmagfactor, Rotation, Skew); - } - - /* ftemp=fabs(xx3rd-xxmin); */ - abs_a_bf(sub_bf(bftemp,bfx3rd,bfxmin)); - - /* ftemp2=fabs(xxmax-xx3rd);*/ - abs_a_bf(sub_bf(bftemp2,bfxmax,bfx3rd)); - - /* if ( (ftemp=fabs(xx3rd-xxmin)) < (ftemp2=fabs(xxmax-xx3rd)) ) */ - if (cmp_bf(bftemp,bftemp2) < 0) - { - /* if (ftemp*10000 < ftemp2 && yy3rd != yymax) */ - if (cmp_bf(mult_bf_int(btmp1,bftemp,10000),bftemp2) < 0 - && cmp_bf(bfy3rd,bfymax) != 0 ) - /* xx3rd = xxmin; */ - copy_bf(bfx3rd, bfxmin); - } - - /* else if (ftemp2*10000 < ftemp && yy3rd != yymin) */ - if (cmp_bf(mult_bf_int(btmp1,bftemp2,10000),bftemp) < 0 - && cmp_bf(bfy3rd,bfymin) != 0 ) - /* xx3rd = xxmax; */ - copy_bf(bfx3rd, bfxmax); - - /* ftemp=fabs(yy3rd-yymin); */ - abs_a_bf(sub_bf(bftemp,bfy3rd,bfymin)); - - /* ftemp2=fabs(yymax-yy3rd); */ - abs_a_bf(sub_bf(bftemp2,bfymax,bfy3rd)); - - /* if ( (ftemp=fabs(yy3rd-yymin)) < (ftemp2=fabs(yymax-yy3rd)) ) */ - if (cmp_bf(bftemp,bftemp2) < 0) - { - /* if (ftemp*10000 < ftemp2 && xx3rd != xxmax) */ - if (cmp_bf(mult_bf_int(btmp1,bftemp,10000),bftemp2) < 0 - && cmp_bf(bfx3rd,bfxmax) != 0 ) - /* yy3rd = yymin; */ - copy_bf(bfy3rd, bfymin); - } - - /* else if (ftemp2*10000 < ftemp && xx3rd != xxmin) */ - if (cmp_bf(mult_bf_int(btmp1,bftemp2,10000),bftemp) < 0 - && cmp_bf(bfx3rd,bfxmin) != 0 ) - /* yy3rd = yymax; */ - copy_bf(bfy3rd, bfymax); - - - restore_stack(saved); -} - -void adjust_corner(void) -{ - /* make edges very near vert/horiz exact, to ditch rounding errs and */ - /* to avoid problems when delta per axis makes too large a ratio */ - double ftemp,ftemp2; - double Xctr, Yctr, Xmagfactor, Rotation, Skew; - LDBL Magnification; - - if (!integerfractal) - { - /* While we're at it, let's adjust the Xmagfactor as well */ - cvtcentermag(&Xctr, &Yctr, &Magnification, &Xmagfactor, &Rotation, &Skew); - ftemp = fabs(Xmagfactor); - if (ftemp != 1 && ftemp >= (1-aspectdrift) && ftemp <= (1+aspectdrift)) - { - Xmagfactor = sign(Xmagfactor); - cvtcorners(Xctr, Yctr, Magnification, Xmagfactor, Rotation, Skew); - } - } - - if ( (ftemp=fabs(xx3rd-xxmin)) < (ftemp2=fabs(xxmax-xx3rd)) ) { - if (ftemp*10000 < ftemp2 && yy3rd != yymax) - xx3rd = xxmin; - } - - if (ftemp2*10000 < ftemp && yy3rd != yymin) - xx3rd = xxmax; - - if ( (ftemp=fabs(yy3rd-yymin)) < (ftemp2=fabs(yymax-yy3rd)) ) { - if (ftemp*10000 < ftemp2 && xx3rd != xxmax) - yy3rd = yymin; - } - - if (ftemp2*10000 < ftemp && xx3rd != xxmin) - yy3rd = yymax; - -} - -static void _fastcall adjust_to_limitsbf(double expand) -{ - LDBL limit; - bf_t bcornerx[4],bcornery[4]; - bf_t blowx,bhighx,blowy,bhighy,blimit,bftemp; - bf_t bcenterx,bcentery,badjx,badjy,btmp1,btmp2; - bf_t bexpand; - int i; - int saved; saved = save_stack(); - bcornerx[0] = alloc_stack(rbflength+2); - bcornerx[1] = alloc_stack(rbflength+2); - bcornerx[2] = alloc_stack(rbflength+2); - bcornerx[3] = alloc_stack(rbflength+2); - bcornery[0] = alloc_stack(rbflength+2); - bcornery[1] = alloc_stack(rbflength+2); - bcornery[2] = alloc_stack(rbflength+2); - bcornery[3] = alloc_stack(rbflength+2); - blowx = alloc_stack(rbflength+2); - bhighx = alloc_stack(rbflength+2); - blowy = alloc_stack(rbflength+2); - bhighy = alloc_stack(rbflength+2); - blimit = alloc_stack(rbflength+2); - bftemp = alloc_stack(rbflength+2); - bcenterx = alloc_stack(rbflength+2); - bcentery = alloc_stack(rbflength+2); - badjx = alloc_stack(rbflength+2); - badjy = alloc_stack(rbflength+2); - btmp1 = alloc_stack(rbflength+2); - btmp2 = alloc_stack(rbflength+2); - bexpand = alloc_stack(rbflength+2); - - limit = 32767.99; - -/* if (bitshift >= 24) limit = 31.99; - if (bitshift >= 29) limit = 3.99; */ - floattobf(blimit,limit); - floattobf(bexpand,expand); - - add_bf(bcenterx,bfxmin,bfxmax); - half_a_bf(bcenterx); - - /* centery = (yymin+yymax)/2; */ - add_bf(bcentery,bfymin,bfymax); - half_a_bf(bcentery); - - /* if (xxmin == centerx) { */ - if (cmp_bf(bfxmin,bcenterx)==0) { /* ohoh, infinitely thin, fix it */ - smallest_add_bf(bfxmax); - /* bfxmin -= bfxmax-centerx; */ - sub_a_bf(bfxmin,sub_bf(btmp1,bfxmax,bcenterx)); - } - - /* if (bfymin == centery) */ - if (cmp_bf(bfymin,bcentery)==0) { - smallest_add_bf(bfymax); - /* bfymin -= bfymax-centery; */ - sub_a_bf(bfymin,sub_bf(btmp1,bfymax,bcentery)); - } - - /* if (bfx3rd == centerx) */ - if (cmp_bf(bfx3rd,bcenterx)==0) - smallest_add_bf(bfx3rd); - - /* if (bfy3rd == centery) */ - if (cmp_bf(bfy3rd,bcentery)==0) - smallest_add_bf(bfy3rd); - - /* setup array for easier manipulation */ - /* cornerx[0] = xxmin; */ - copy_bf(bcornerx[0],bfxmin); - - /* cornerx[1] = xxmax; */ - copy_bf(bcornerx[1],bfxmax); - - /* cornerx[2] = xx3rd; */ - copy_bf(bcornerx[2],bfx3rd); - - /* cornerx[3] = xxmin+(xxmax-xx3rd); */ - sub_bf(bcornerx[3],bfxmax,bfx3rd); - add_a_bf(bcornerx[3],bfxmin); - - /* cornery[0] = yymax; */ - copy_bf(bcornery[0],bfymax); - - /* cornery[1] = yymin; */ - copy_bf(bcornery[1],bfymin); - - /* cornery[2] = yy3rd; */ - copy_bf(bcornery[2],bfy3rd); - - /* cornery[3] = yymin+(yymax-yy3rd); */ - sub_bf(bcornery[3],bfymax,bfy3rd); - add_a_bf(bcornery[3],bfymin); - - /* if caller wants image size adjusted, do that first */ - if (expand != 1.0) - { - for (i=0; i<4; ++i) { - /* cornerx[i] = centerx + (cornerx[i]-centerx)*expand; */ - sub_bf(btmp1,bcornerx[i],bcenterx); - mult_bf(bcornerx[i],btmp1,bexpand); - add_a_bf(bcornerx[i],bcenterx); - - /* cornery[i] = centery + (cornery[i]-centery)*expand; */ - sub_bf(btmp1,bcornery[i],bcentery); - mult_bf(bcornery[i],btmp1,bexpand); - add_a_bf(bcornery[i],bcentery); - } - } - - /* get min/max x/y values */ - /* lowx = highx = cornerx[0]; */ - copy_bf(blowx,bcornerx[0]); copy_bf(bhighx,bcornerx[0]); - - /* lowy = highy = cornery[0]; */ - copy_bf(blowy,bcornery[0]); copy_bf(bhighy,bcornery[0]); - - for (i=1; i<4; ++i) { - /* if (cornerx[i] < lowx) lowx = cornerx[i]; */ - if (cmp_bf(bcornerx[i],blowx) < 0) copy_bf(blowx,bcornerx[i]); - - /* if (cornerx[i] > highx) highx = cornerx[i]; */ - if (cmp_bf(bcornerx[i],bhighx) > 0) copy_bf(bhighx,bcornerx[i]); - - /* if (cornery[i] < lowy) lowy = cornery[i]; */ - if (cmp_bf(bcornery[i],blowy) < 0) copy_bf(blowy,bcornery[i]); - - /* if (cornery[i] > highy) highy = cornery[i]; */ - if (cmp_bf(bcornery[i],bhighy) > 0) copy_bf(bhighy,bcornery[i]); - } - - /* if image is too large, downsize it maintaining center */ - /* ftemp = highx-lowx; */ - sub_bf(bftemp,bhighx,blowx); - - /* if (highy-lowy > ftemp) ftemp = highy-lowy; */ - if (cmp_bf(sub_bf(btmp1,bhighy,blowy),bftemp) > 0) copy_bf(bftemp,btmp1); - - /* if image is too large, downsize it maintaining center */ - - floattobf(btmp1,limit*2.0); - copy_bf(btmp2,bftemp); - div_bf(bftemp,btmp1,btmp2); - floattobf(btmp1,1.0); - if (cmp_bf(bftemp,btmp1) < 0) - for (i=0; i<4; ++i) { - /* cornerx[i] = centerx + (cornerx[i]-centerx)*ftemp; */ - sub_bf(btmp1,bcornerx[i],bcenterx); - mult_bf(bcornerx[i],btmp1,bftemp); - add_a_bf(bcornerx[i],bcenterx); - - /* cornery[i] = centery + (cornery[i]-centery)*ftemp; */ - sub_bf(btmp1,bcornery[i],bcentery); - mult_bf(bcornery[i],btmp1,bftemp); - add_a_bf(bcornery[i],bcentery); - } - - /* if any corner has x or y past limit, move the image */ - /* adjx = adjy = 0; */ - clear_bf(badjx); clear_bf(badjy); - - for (i=0; i<4; ++i) { - /* if (cornerx[i] > limit && (ftemp = cornerx[i] - limit) > adjx) - adjx = ftemp; */ - if (cmp_bf(bcornerx[i],blimit) > 0 && - cmp_bf(sub_bf(bftemp,bcornerx[i],blimit),badjx) > 0) - copy_bf(badjx,bftemp); - - /* if (cornerx[i] < 0.0-limit && (ftemp = cornerx[i] + limit) < adjx) - adjx = ftemp; */ - if (cmp_bf(bcornerx[i],neg_bf(btmp1,blimit)) < 0 && - cmp_bf(add_bf(bftemp,bcornerx[i],blimit),badjx) < 0) - copy_bf(badjx,bftemp); - - /* if (cornery[i] > limit && (ftemp = cornery[i] - limit) > adjy) - adjy = ftemp; */ - if (cmp_bf(bcornery[i],blimit) > 0 && - cmp_bf(sub_bf(bftemp,bcornery[i],blimit),badjy) > 0) - copy_bf(badjy,bftemp); - - /* if (cornery[i] < 0.0-limit && (ftemp = cornery[i] + limit) < adjy) - adjy = ftemp; */ - if (cmp_bf(bcornery[i],neg_bf(btmp1,blimit)) < 0 && - cmp_bf(add_bf(bftemp,bcornery[i],blimit),badjy) < 0) - copy_bf(badjy,bftemp); - } - - /* if (calc_status == CALCSTAT_RESUMABLE && (adjx != 0 || adjy != 0) && (zwidth == 1.0)) - calc_status = CALCSTAT_PARAMS_CHANGED; */ - if (calc_status == CALCSTAT_RESUMABLE && (is_bf_not_zero(badjx)|| is_bf_not_zero(badjy)) && (zwidth == 1.0)) - calc_status = CALCSTAT_PARAMS_CHANGED; - - /* xxmin = cornerx[0] - adjx; */ - sub_bf(bfxmin,bcornerx[0],badjx); - /* xxmax = cornerx[1] - adjx; */ - sub_bf(bfxmax,bcornerx[1],badjx); - /* xx3rd = cornerx[2] - adjx; */ - sub_bf(bfx3rd,bcornerx[2],badjx); - /* yymax = cornery[0] - adjy; */ - sub_bf(bfymax,bcornery[0],badjy); - /* yymin = cornery[1] - adjy; */ - sub_bf(bfymin,bcornery[1],badjy); - /* yy3rd = cornery[2] - adjy; */ - sub_bf(bfy3rd,bcornery[2],badjy); - - adjust_cornerbf(); /* make 3rd corner exact if very near other co-ords */ - restore_stack(saved); -} - -static void _fastcall adjust_to_limits(double expand) -{ - double cornerx[4],cornery[4]; - double lowx,highx,lowy,highy,limit,ftemp; - double centerx,centery,adjx,adjy; - int i; - - limit = 32767.99; - - if (integerfractal) { - if (save_release > 1940) /* let user reproduce old GIF's and PAR's */ - limit = 1023.99; - if (bitshift >= 24) limit = 31.99; - if (bitshift >= 29) limit = 3.99; - } - - centerx = (xxmin+xxmax)/2; - centery = (yymin+yymax)/2; - - if (xxmin == centerx) { /* ohoh, infinitely thin, fix it */ - smallest_add(&xxmax); - xxmin -= xxmax-centerx; - } - - if (yymin == centery) { - smallest_add(&yymax); - yymin -= yymax-centery; - } - - if (xx3rd == centerx) - smallest_add(&xx3rd); - - if (yy3rd == centery) - smallest_add(&yy3rd); - - /* setup array for easier manipulation */ - cornerx[0] = xxmin; - cornerx[1] = xxmax; - cornerx[2] = xx3rd; - cornerx[3] = xxmin+(xxmax-xx3rd); - - cornery[0] = yymax; - cornery[1] = yymin; - cornery[2] = yy3rd; - cornery[3] = yymin+(yymax-yy3rd); - - /* if caller wants image size adjusted, do that first */ - if (expand != 1.0) - { - for (i=0; i<4; ++i) { - cornerx[i] = centerx + (cornerx[i]-centerx)*expand; - cornery[i] = centery + (cornery[i]-centery)*expand; - } - } - /* get min/max x/y values */ - lowx = highx = cornerx[0]; - lowy = highy = cornery[0]; - - for (i=1; i<4; ++i) { - if (cornerx[i] < lowx) lowx = cornerx[i]; - if (cornerx[i] > highx) highx = cornerx[i]; - if (cornery[i] < lowy) lowy = cornery[i]; - if (cornery[i] > highy) highy = cornery[i]; - } - - /* if image is too large, downsize it maintaining center */ - ftemp = highx-lowx; - - if (highy-lowy > ftemp) ftemp = highy-lowy; - - /* if image is too large, downsize it maintaining center */ - if ((ftemp = limit*2/ftemp) < 1.0) { - for (i=0; i<4; ++i) { - cornerx[i] = centerx + (cornerx[i]-centerx)*ftemp; - cornery[i] = centery + (cornery[i]-centery)*ftemp; - } - } - - /* if any corner has x or y past limit, move the image */ - adjx = adjy = 0; - - for (i=0; i<4; ++i) { - if (cornerx[i] > limit && (ftemp = cornerx[i] - limit) > adjx) - adjx = ftemp; - if (cornerx[i] < 0.0-limit && (ftemp = cornerx[i] + limit) < adjx) - adjx = ftemp; - if (cornery[i] > limit && (ftemp = cornery[i] - limit) > adjy) - adjy = ftemp; - if (cornery[i] < 0.0-limit && (ftemp = cornery[i] + limit) < adjy) - adjy = ftemp; - } - if (calc_status == CALCSTAT_RESUMABLE && (adjx != 0 || adjy != 0) && (zwidth == 1.0)) - calc_status = CALCSTAT_PARAMS_CHANGED; - xxmin = cornerx[0] - adjx; - xxmax = cornerx[1] - adjx; - xx3rd = cornerx[2] - adjx; - yymax = cornery[0] - adjy; - yymin = cornery[1] - adjy; - yy3rd = cornery[2] - adjy; - - adjust_corner(); /* make 3rd corner exact if very near other co-ords */ -} - -static void _fastcall smallest_add(double *num) -{ - *num += *num * 5.0e-16; -} - -static void _fastcall smallest_add_bf(bf_t num) -{ - bf_t btmp1; - int saved; saved = save_stack(); - btmp1 = alloc_stack(bflength+2); - mult_bf(btmp1,floattobf(btmp1, 5.0e-16),num); - add_a_bf(num,btmp1); - restore_stack(saved); -} - -static int _fastcall ratio_bad(double actual, double desired) -{ - double ftemp, tol; - if (integerfractal) - tol = math_tol[0]; - else - tol = math_tol[1]; - if (tol <= 0.0) - return(1); - else if (tol >= 1.0) - return(0); - ftemp = 0; - if (desired != 0 && debugflag != 3400) - ftemp = actual / desired; - if (desired != 0 && debugflag != 3400) - if ((ftemp = actual / desired) < (1.0-tol) || ftemp > (1.0+tol)) - return(1); - return(0); -} - - -/* Save/resume stuff: - - Engines which aren't resumable can simply ignore all this. - - Before calling the (per_image,calctype) routines (engine), calcfract sets: - "resuming" to 0 if new image, nonzero if resuming a partially done image - "calc_status" to CALCSTAT_IN_PROGRESS - If an engine is interrupted and wants to be able to resume it must: - store whatever status info it needs to be able to resume later - set calc_status to CALCSTAT_RESUMABLE and return - If subsequently called with resuming!=0, the engine must restore status - info and continue from where it left off. - - Since the info required for resume can get rather large for some types, - it is not stored directly in save_info. Instead, memory is dynamically - allocated as required, and stored in .fra files as a separate block. - To save info for later resume, an engine routine can use: - alloc_resume(maxsize,version) - Maxsize must be >= max bytes subsequently saved + 2; over-allocation - is harmless except for possibility of insufficient mem available; - undersize is not checked and probably causes serious misbehaviour. - Version is an arbitrary number so that subsequent revisions of the - engine can be made backward compatible. - Alloc_resume sets calc_status to CALCSTAT_RESUMABLE if it succeeds; - to CALCSTAT_NON_RESUMABLE if it cannot allocate memory - (and issues warning to user). - put_resume({bytes,&argument,} ... 0) - Can be called as often as required to store the info. - Arguments must not be far addresses. - Is not protected against calls which use more space than allocated. - To reload info when resuming, use: - start_resume() - initializes and returns version number - get_resume({bytes,&argument,} ... 0) - inverse of store_resume - end_resume() - optional, frees the memory area sooner than would happen otherwise - - Example, save info: - alloc_resume(sizeof(parmarray)+100,2); - put_resume(sizeof(row),&row, sizeof(col),&col, - sizeof(parmarray),parmarray, 0); - restore info: - vsn = start_resume(); - get_resume(sizeof(row),&row, sizeof(col),&col, 0); - if (vsn >= 2) - get_resume(sizeof(parmarray),parmarray,0); - end_resume(); - - Engines which allocate a large memory chunk of their own might - directly set resume_info, resume_len, calc_status to avoid doubling - transient memory needs by using these routines. - - StandardFractal, calcmand, solidguess, and bound_trace_main are a related - set of engines for escape-time fractals. They use a common worklist - structure for save/resume. Fractals using these must specify calcmand - or StandardFractal as the engine in fractalspecificinfo. - Other engines don't get btm nor ssg, don't get off-axis symmetry nor - panning (the worklist stuff), and are on their own for save/resume. - - */ - -#ifndef USE_VARARGS -int put_resume(int len, ...) -#else -int put_resume(va_alist) -va_dcl -#endif -{ - va_list arg_marker; /* variable arg list */ - BYTE *source_ptr; -#ifdef USE_VARARGS - int len; -#endif - - if (resume_info == 0) - return(-1); -#ifndef USE_VARARGS - va_start(arg_marker,len); -#else - va_start(arg_marker); - len = va_arg(arg_marker,int); -#endif - while (len) - { - source_ptr = (BYTE *)va_arg(arg_marker,char *); -/* memcpy(resume_info+resume_len,source_ptr,len); */ - MoveToMemory(source_ptr,(U16)1,(long)len,resume_len,resume_info); - resume_len += len; - len = va_arg(arg_marker,int); - } - va_end(arg_marker); - return(0); -} - -int alloc_resume(int alloclen, int version) -{ /* WARNING! if alloclen > 4096B, problems may occur with GIF save/restore */ - if (resume_info != 0) /* free the prior area if there is one */ - MemoryRelease(resume_info); - /* TODO: MemoryAlloc */ - resume_info = MemoryAlloc((U16)sizeof(alloclen), (long)alloclen, MEMORY); - if (resume_info == 0) - { - stopmsg(0,"Warning - insufficient free memory to save status.\n" - "You will not be able to resume calculating this image."); - calc_status = CALCSTAT_NON_RESUMABLE; - return(-1); - } - resume_len = 0; - put_resume(sizeof(version),&version,0); - calc_status = CALCSTAT_RESUMABLE; - return(0); -} - -#ifndef USE_VARARGS -int get_resume(int len, ...) -#else -int get_resume(va_alist) -va_dcl -#endif -{ - va_list arg_marker; /* variable arg list */ - BYTE *dest_ptr; -#ifdef USE_VARARGS - int len; -#endif - - if (resume_info == 0) - return(-1); -#ifndef USE_VARARGS - va_start(arg_marker,len); -#else - va_start(arg_marker); - len = va_arg(arg_marker,int); -#endif - while (len) - { - dest_ptr = (BYTE *)va_arg(arg_marker,char *); -/* memcpy(dest_ptr,resume_info+resume_offset,len); */ - MoveFromMemory(dest_ptr,(U16)1,(long)len,resume_offset,resume_info); - resume_offset += len; - len = va_arg(arg_marker,int); - } - va_end(arg_marker); - return(0); -} - -int start_resume(void) -{ - int version; - if (resume_info == 0) - return(-1); - resume_offset = 0; - get_resume(sizeof(version),&version,0); - return(version); -} - -void end_resume(void) -{ - if (resume_info != 0) /* free the prior area if there is one */ - { - MemoryRelease(resume_info); - resume_info = 0; - } -} - - -/* Showing orbit requires converting real co-ords to screen co-ords. - Define: - Xs == xxmax-xx3rd Ys == yy3rd-yymax - W == xdots-1 D == ydots-1 - We know that: - realx == lx0[col] + lx1[row] - realy == ly0[row] + ly1[col] - lx0[col] == (col/width) * Xs + xxmin - lx1[row] == row * delxx - ly0[row] == (row/D) * Ys + yymax - ly1[col] == col * (0-delyy) - so: - realx == (col/W) * Xs + xxmin + row * delxx - realy == (row/D) * Ys + yymax + col * (0-delyy) - and therefore: - row == (realx-xxmin - (col/W)*Xs) / Xv (1) - col == (realy-yymax - (row/D)*Ys) / Yv (2) - substitute (2) into (1) and solve for row: - row == ((realx-xxmin)*(0-delyy2)*W*D - (realy-yymax)*Xs*D) - / ((0-delyy2)*W*delxx2*D-Ys*Xs) - */ - -/* sleep N * a tenth of a millisecond */ - -void sleepms_old(long ms) -{ - static long scalems = 0L; - int savehelpmode,savetabmode; - struct timebx t1,t2; -#define SLEEPINIT 250 /* milliseconds for calibration */ - savetabmode = tabmode; - savehelpmode = helpmode; - tabmode = 0; - helpmode = -1; - if (scalems==0L) /* calibrate */ - { - /* selects a value of scalems that makes the units - 10000 per sec independent of CPU speed */ - int i,elapsed; - scalems = 1L; - if (driver_key_pressed()) /* check at start, hope to get start of timeslice */ - goto sleepexit; - /* calibrate, assume slow computer first */ - showtempmsg("Calibrating timer"); - do - { - scalems *= 2; - ftimex(&t2); - do { /* wait for the start of a new tick */ - ftimex(&t1); - } - while (t2.time == t1.time && t2.millitm == t1.millitm); - sleepms_old(10L * SLEEPINIT); /* about 1/4 sec */ - ftimex(&t2); - if (driver_key_pressed()) { - scalems = 0L; - cleartempmsg(); - goto sleepexit; - } - } - while ((elapsed = (int)(t2.time-t1.time)*1000 + t2.millitm-t1.millitm) - < SLEEPINIT); - /* once more to see if faster (eg multi-tasking) */ - do { /* wait for the start of a new tick */ - ftimex(&t1); - } - while (t2.time == t1.time && t2.millitm == t1.millitm); - sleepms_old(10L * SLEEPINIT); - ftimex(&t2); - if ((i = (int)(t2.time-t1.time)*1000 + t2.millitm-t1.millitm) < elapsed) - elapsed = (i == 0) ? 1 : i; - scalems = (long)((float)SLEEPINIT/(float)(elapsed) * scalems); - cleartempmsg(); - } - if (ms > 10L * SLEEPINIT) { /* using ftime is probably more accurate */ - ms /= 10; - ftimex(&t1); - while (1) { - if (driver_key_pressed()) break; - ftimex(&t2); - if ((long)((t2.time-t1.time)*1000 + t2.millitm-t1.millitm) >= ms) break; - } - } - else - if (!driver_key_pressed()) { - ms *= scalems; - while (ms-- >= 0); - } -sleepexit: - tabmode = savetabmode; - helpmode = savehelpmode; -} - -static void sleepms_new(long ms) -{ - uclock_t next_time; - uclock_t now = usec_clock(); - next_time = now + ms*100; - while ((now = usec_clock()) < next_time) - if (driver_key_pressed()) break; -} - -void sleepms(long ms) -{ - if (debugflag == 4020) - sleepms_old(ms); - else - sleepms_new(ms); -} - -/* - * wait until wait_time microseconds from the - * last call has elapsed. - */ -#define MAX_INDEX 2 -static uclock_t next_time[MAX_INDEX]; -void wait_until(int index, uclock_t wait_time) -{ - if (debugflag == 4020) - sleepms_old(wait_time); - else - { - uclock_t now; - while ( (now = usec_clock()) < next_time[index]) - if (driver_key_pressed()) break; - next_time[index] = now + wait_time*100; /* wait until this time next call */ - } -} - -void reset_clock(void) -{ - int i; - restart_uclock(); - for (i=0; i= 1500-3) return; - i = (int)(dy * plotmx1 - dx * plotmx2); i += sxoffs; - if (i < 0 || i >= sxdots) return; - j = (int)(dx * plotmy1 - dy * plotmy2); j += syoffs; - if (j < 0 || j >= sydots) return; - save_sxoffs = sxoffs; - save_syoffs = syoffs; - sxoffs = syoffs = 0; - /* save orbit value */ - if (color == -1) - { - *(save_orbit + orbit_ptr++) = i; - *(save_orbit + orbit_ptr++) = j; - *(save_orbit + orbit_ptr++) = c = getcolor(i,j); - putcolor(i,j,c^orbit_color); - } - else - putcolor(i,j,color); - sxoffs = save_sxoffs; - syoffs = save_syoffs; - if (debugflag == 4030) { - if ((soundflag & SOUNDFLAG_ORBITMASK) == SOUNDFLAG_X) /* sound = x */ - w_snd((int)(i*1000/xdots+basehertz)); - else if ((soundflag & SOUNDFLAG_ORBITMASK) > SOUNDFLAG_X) /* sound = y or z */ - w_snd((int)(j*1000/ydots+basehertz)); - else if (orbit_delay > 0) - { - wait_until(0,orbit_delay); - } - } - else { - if ((soundflag & SOUNDFLAG_ORBITMASK) == SOUNDFLAG_X) /* sound = x */ - w_snd((int)(i+basehertz)); - else if ((soundflag & SOUNDFLAG_ORBITMASK) == SOUNDFLAG_Y) /* sound = y */ - w_snd((int)(j+basehertz)); - else if ((soundflag & SOUNDFLAG_ORBITMASK) == SOUNDFLAG_Z) /* sound = z */ - w_snd((int)(i+j+basehertz)); - else if (orbit_delay > 0) - { - wait_until(0,orbit_delay); - } - } - - /* placing sleepms here delays each dot */ -} - -void iplot_orbit(long ix, long iy, int color) -{ - plotdorbit((double)ix/fudge-xxmin,(double)iy/fudge-yymax,color); -} - -void plot_orbit(double real,double imag,int color) -{ - plotdorbit(real-xxmin,imag-yymax,color); -} - -void scrub_orbit(void) -{ - int i,j,c; - int save_sxoffs,save_syoffs; - driver_mute(); - save_sxoffs = sxoffs; - save_syoffs = syoffs; - sxoffs = syoffs = 0; - while (orbit_ptr >= 3) - { - c = *(save_orbit + --orbit_ptr); - j = *(save_orbit + --orbit_ptr); - i = *(save_orbit + --orbit_ptr); - putcolor(i,j,c); - } - sxoffs = save_sxoffs; - syoffs = save_syoffs; -} - - -int add_worklist(int xfrom, int xto, int xbegin, -int yfrom, int yto, int ybegin, -int pass, int sym) -{ - if (num_worklist >= MAXCALCWORK) - return(-1); - worklist[num_worklist].xxstart = xfrom; - worklist[num_worklist].xxstop = xto; - worklist[num_worklist].xxbegin = xbegin; - worklist[num_worklist].yystart = yfrom; - worklist[num_worklist].yystop = yto; - worklist[num_worklist].yybegin = ybegin; - worklist[num_worklist].pass = pass; - worklist[num_worklist].sym = sym; - ++num_worklist; - tidy_worklist(); - return(0); -} - -static int _fastcall combine_worklist(void) /* look for 2 entries which can freely merge */ -{ - int i,j; - for (i=0; i= N_ATTR) /* space for more attractors ? */ - return; /* Bad luck - no room left ! */ - - savper = periodicitycheck; - savmaxit = maxit; - periodicitycheck = 0; - old.x = real; /* prepare for f.p orbit calc */ - old.y = imag; - tempsqrx = sqr(old.x); - tempsqry = sqr(old.y); - - lold.x = (long)real; /* prepare for int orbit calc */ - lold.y = (long)imag; - ltempsqrx = (long)tempsqrx; - ltempsqry = (long)tempsqry; - - lold.x = lold.x << bitshift; - lold.y = lold.y << bitshift; - ltempsqrx = ltempsqrx << bitshift; - ltempsqry = ltempsqry << bitshift; - - if (maxit < 500) /* we're going to try at least this hard */ - maxit = 500; - coloriter = 0; - overflow = 0; - while (++coloriter < maxit) - if (curfractalspecific->orbitcalc() || overflow) - break; - if (coloriter >= maxit) /* if orbit stays in the lake */ - { - if (integerfractal) /* remember where it went to */ - lresult = lnew; - else - result = g_new; - for (i=0;i<10;i++) { - overflow = 0; - if (!curfractalspecific->orbitcalc() && !overflow) /* if it stays in the lake */ - { /* and doesn't move far, probably */ - if (integerfractal) /* found a finite attractor */ - { - if (labs(lresult.x-lnew.x) < lclosenuff - && labs(lresult.y-lnew.y) < lclosenuff) - { - lattr[attractors] = lnew; - attrperiod[attractors] = i+1; - attractors++; /* another attractor - coloured lakes ! */ - break; - } - } - else - { - if (fabs(result.x-g_new.x) < closenuff - && fabs(result.y-g_new.y) < closenuff) - { - attr[attractors] = g_new; - attrperiod[attractors] = i+1; - attractors++; /* another attractor - coloured lakes ! */ - break; - } - } - } else { - break; - } - } - } - if (attractors==0) - periodicitycheck = savper; - maxit = savmaxit; -} - - -#define maxyblk 7 /* must match calcfrac.c */ -#define maxxblk 202 /* must match calcfrac.c */ -int ssg_blocksize(void) /* used by solidguessing and by zoom panning */ -{ - int blocksize,i; - /* blocksize 4 if <300 rows, 8 if 300-599, 16 if 600-1199, 32 if >=1200 */ - blocksize=4; - i=300; - while (i<=ydots) - { - blocksize+=blocksize; - i+=i; - } - /* increase blocksize if prefix array not big enough */ - while (blocksize*(maxxblk-2) -#include -#if !defined(__386BSD__) -#if !defined(_WIN32) -#include -#endif -#endif - /* see Fractint.c for a description of the "include" hierarchy */ -#include "port.h" -#include "prototyp.h" -#include "helpdefs.h" -#include "fractype.h" - - -int bf_math = 0; - -#ifdef DEBUG - -/**********************************************************************/ -void show_var_bn(char *s, bn_t n) - { - char msg[200]; - strcpy(msg,s); - strcat(msg," "); - bntostr(msg+strlen(s),40,n); - msg[79] = 0; - stopmsg(0,(char *)msg); - } - -void showcornersdbl(char *s) -{ - char msg[400]; - sprintf(msg,"%s\n" - "xxmin= %.20f xxmax= %.20f\n" - "yymin= %.20f yymax= %.20f\n" - "xx3rd= %.20f yy3rd= %.20f\n" - "delxx= %.20Lf delyy= %.20Lf\n" - "delx2= %.20Lf dely2= %.20Lf", - s,xxmin,xxmax,yymin,yymax,xx3rd,yy3rd, - delxx, delyy,delxx2, delyy2); - if (stopmsg(0,msg)==-1) - goodbye(); -} - -/* show floating point and bignumber corners */ -void showcorners(char *s) -{ - int dec=20; - char msg[100],msg1[100],msg3[100]; - bntostr(msg,dec,bnxmin); - sprintf(msg1,"bnxmin=%s\nxxmin= %.20f\n\n",msg,xxmin); - strcpy(msg3,s); - strcat(msg3,"\n"); - strcat(msg3,msg1); - bntostr(msg,dec,bnxmax); - sprintf(msg1,"bnxmax=%s\nxxmax= %.20f\n\n",msg,xxmax); - strcat(msg3,msg1); - bntostr(msg,dec,bnymin); - sprintf(msg1,"bnymin=%s\nyymin= %.20f\n\n",msg,yymin); - strcat(msg3,msg1); - bntostr(msg,dec,bnymax); - sprintf(msg1,"bnymax=%s\nyymax= %.20f\n\n",msg,yymax); - strcat(msg3,msg1); - bntostr(msg,dec,bnx3rd); - sprintf(msg1,"bnx3rd=%s\nxx3rd= %.20f\n\n",msg,xx3rd); - strcat(msg3,msg1); - bntostr(msg,dec,bny3rd); - sprintf(msg1,"bny3rd=%s\nyy3rd= %.20f\n\n",msg,yy3rd); - strcat(msg3,msg1); - if (stopmsg(0,msg3)==-1) - goodbye(); -} - -/* show globals */ -void showbfglobals(char *s) -{ - char msg[300]; - sprintf(msg, "%s\n\ -bnstep=%d bnlength=%d intlength=%d rlength=%d padding=%d\n\ -shiftfactor=%d decimals=%d bflength=%d rbflength=%d \n\ -bfdecimals=%d ", - s, bnstep, bnlength, intlength, rlength, padding, - shiftfactor, decimals, bflength, rbflength, - bfdecimals); - if (stopmsg(0,msg)==-1) - goodbye(); -} - -void showcornersbf(char *s) -{ - int dec=decimals; - char msg[100],msg1[100],msg3[600]; - if (dec > 20) dec = 20; - bftostr(msg,dec,bfxmin); - sprintf(msg1,"bfxmin=%s\nxxmin= %.20f decimals %d bflength %d\n\n", - msg,xxmin,decimals,bflength); - strcpy(msg3,s); - strcat(msg3,"\n"); - strcat(msg3,msg1); - bftostr(msg,dec,bfxmax); - sprintf(msg1,"bfxmax=%s\nxxmax= %.20f\n\n",msg,xxmax); - strcat(msg3,msg1); - bftostr(msg,dec,bfymin); - sprintf(msg1,"bfymin=%s\nyymin= %.20f\n\n",msg,yymin); - strcat(msg3,msg1); - bftostr(msg,dec,bfymax); - sprintf(msg1,"bfymax=%s\nyymax= %.20f\n\n",msg,yymax); - strcat(msg3,msg1); - bftostr(msg,dec,bfx3rd); - sprintf(msg1,"bfx3rd=%s\nxx3rd= %.20f\n\n",msg,xx3rd); - strcat(msg3,msg1); - bftostr(msg,dec,bfy3rd); - sprintf(msg1,"bfy3rd=%s\nyy3rd= %.20f\n\n",msg,yy3rd); - strcat(msg3,msg1); - if (stopmsg(0,msg3)==-1) - goodbye(); -} - -void showcornersbfs(char *s) -{ - int dec=20; - char msg[100],msg1[100],msg3[500]; - bftostr(msg,dec,bfsxmin); - sprintf(msg1,"bfsxmin=%s\nxxmin= %.20f\n\n",msg,xxmin); - strcpy(msg3,s); - strcat(msg3,"\n"); - strcat(msg3,msg1); - bftostr(msg,dec,bfsxmax); - sprintf(msg1,"bfsxmax=%s\nxxmax= %.20f\n\n",msg,xxmax); - strcat(msg3,msg1); - bftostr(msg,dec,bfsymin); - sprintf(msg1,"bfsymin=%s\nyymin= %.20f\n\n",msg,yymin); - strcat(msg3,msg1); - bftostr(msg,dec,bfsymax); - sprintf(msg1,"bfsymax=%s\nyymax= %.20f\n\n",msg,yymax); - strcat(msg3,msg1); - bftostr(msg,dec,bfsx3rd); - sprintf(msg1,"bfsx3rd=%s\nxx3rd= %.20f\n\n",msg,xx3rd); - strcat(msg3,msg1); - bftostr(msg,dec,bfsy3rd); - sprintf(msg1,"bfsy3rd=%s\nyy3rd= %.20f\n\n",msg,yy3rd); - strcat(msg3,msg1); - if (stopmsg(0,msg3)==-1) - goodbye(); -} - -void show_two_bf(char *s1,bf_t t1,char *s2, bf_t t2, int digits) -{ - char msg1[200],msg2[200], msg3[400]; - bftostr_e(msg1,digits,t1); - bftostr_e(msg2,digits,t2); - sprintf(msg3,"\n%s->%s\n%s->%s",s1,msg1,s2,msg2); - if (stopmsg(0,msg3)==-1) - goodbye(); -} - -void show_three_bf(char *s1,bf_t t1,char *s2, bf_t t2, char *s3, bf_t t3, int digits) -{ - char msg1[200],msg2[200], msg3[200], msg4[600]; - bftostr_e(msg1,digits,t1); - bftostr_e(msg2,digits,t2); - bftostr_e(msg3,digits,t3); - sprintf(msg4,"\n%s->%s\n%s->%s\n%s->%s",s1,msg1,s2,msg2,s3,msg3); - if (stopmsg(0,msg4)==-1) - goodbye(); -} - -/* for aspect ratio debugging */ -void showaspect(char *s) -{ - bf_t bt1,bt2,aspect; - char msg[100],str[100]; - int saved; saved = save_stack(); - bt1 = alloc_stack(rbflength+2); - bt2 = alloc_stack(rbflength+2); - aspect = alloc_stack(rbflength+2); - sub_bf(bt1,bfxmax,bfxmin); - sub_bf(bt2,bfymax,bfymin); - div_bf(aspect,bt2,bt1); - bftostr(str,10,aspect); - sprintf(msg,"aspect %s\nfloat %13.10f\nbf %s\n\n", - s, - (yymax-yymin)/(xxmax-xxmin), - str); - if (stopmsg(0,msg)==-1) - goodbye(); - restore_stack(saved); -} - -/* compare a double and bignumber */ -void comparevalues(char *s, LDBL x, bn_t bnx) -{ - int dec=40; - char msg[100],msg1[100]; - bntostr(msg,dec,bnx); - sprintf(msg1,"%s\nbignum=%s\ndouble=%.20Lf\n\n",s,msg,x); - if (stopmsg(0,msg1)==-1) - goodbye(); -} -/* compare a double and bignumber */ -void comparevaluesbf(char *s, LDBL x, bf_t bfx) -{ - int dec=40; - char msg[300],msg1[300]; - bftostr_e(msg,dec,bfx); - sprintf(msg1,"%s\nbignum=%s\ndouble=%.20Lf\n\n",s,msg,x); - if (stopmsg(0,msg1)==-1) - goodbye(); -} - -/**********************************************************************/ -void show_var_bf(char *s, bf_t n) - { - char msg[200]; - strcpy(msg,s); - strcat(msg," "); - bftostr_e(msg+strlen(s),40,n); - msg[79] = 0; - if (stopmsg(0,msg)==-1) - goodbye(); - } - -#endif - -void bfcornerstofloat(void) -{ - int i; - if (bf_math) - { - xxmin = (double)bftofloat(bfxmin); - yymin = (double)bftofloat(bfymin); - xxmax = (double)bftofloat(bfxmax); - yymax = (double)bftofloat(bfymax); - xx3rd = (double)bftofloat(bfx3rd); - yy3rd = (double)bftofloat(bfy3rd); - } - for (i=0; i= (long)rqlim) - return 1; - copy_bn(bnold.x, bnnew.x); - copy_bn(bnold.y, bnnew.y); - return 0; -} - -int bnREALbailout() -{ - long longtempsqrx; - - square_bn(bntmpsqrx, bnnew.x); - square_bn(bntmpsqry, bnnew.y); - longtempsqrx = bntoint(bntmpsqrx+shiftfactor); - if (longtempsqrx >= (long)rqlim) - return 1; - copy_bn(bnold.x, bnnew.x); - copy_bn(bnold.y, bnnew.y); - return 0; -} - - -int bnIMAGbailout() -{ - long longtempsqry; - - square_bn(bntmpsqrx, bnnew.x); - square_bn(bntmpsqry, bnnew.y); - longtempsqry = bntoint(bntmpsqry+shiftfactor); - if (longtempsqry >= (long)rqlim) - return 1; - copy_bn(bnold.x, bnnew.x); - copy_bn(bnold.y, bnnew.y); - return(0); -} - -int bnORbailout() -{ - long longtempsqrx, longtempsqry; - - square_bn(bntmpsqrx, bnnew.x); - square_bn(bntmpsqry, bnnew.y); - longtempsqrx = bntoint(bntmpsqrx+shiftfactor); - longtempsqry = bntoint(bntmpsqry+shiftfactor); - if (longtempsqrx >= (long)rqlim || longtempsqry >= (long)rqlim) - return 1; - copy_bn(bnold.x, bnnew.x); - copy_bn(bnold.y, bnnew.y); - return(0); -} - -int bnANDbailout() -{ - long longtempsqrx, longtempsqry; - - square_bn(bntmpsqrx, bnnew.x); - square_bn(bntmpsqry, bnnew.y); - longtempsqrx = bntoint(bntmpsqrx+shiftfactor); - longtempsqry = bntoint(bntmpsqry+shiftfactor); - if (longtempsqrx >= (long)rqlim && longtempsqry >= (long)rqlim) - return 1; - copy_bn(bnold.x, bnnew.x); - copy_bn(bnold.y, bnnew.y); - return(0); -} - -int bnMANHbailout() -{ - long longtempmag; - - square_bn(bntmpsqrx, bnnew.x); - square_bn(bntmpsqry, bnnew.y); - /* note: in next five lines, bnold is just used as a temporary variable */ - abs_bn(bnold.x,bnnew.x); - abs_bn(bnold.y,bnnew.y); - add_bn(bntmp, bnold.x, bnold.y); - square_bn(bnold.x, bntmp); - longtempmag = bntoint(bnold.x+shiftfactor); - if (longtempmag >= (long)rqlim) - return 1; - copy_bn(bnold.x, bnnew.x); - copy_bn(bnold.y, bnnew.y); - return(0); -} - -int bnMANRbailout() -{ - long longtempmag; - - square_bn(bntmpsqrx, bnnew.x); - square_bn(bntmpsqry, bnnew.y); - add_bn(bntmp, bnnew.x, bnnew.y); /* don't need abs since we square it next */ - /* note: in next two lines, bnold is just used as a temporary variable */ - square_bn(bnold.x, bntmp); - longtempmag = bntoint(bnold.x+shiftfactor); - if (longtempmag >= (long)rqlim) - return 1; - copy_bn(bnold.x, bnnew.x); - copy_bn(bnold.y, bnnew.y); - return(0); -} - -int bfMODbailout() -{ - long longmagnitude; - - square_bf(bftmpsqrx, bfnew.x); - square_bf(bftmpsqry, bfnew.y); - add_bf(bftmp, bftmpsqrx, bftmpsqry); - - longmagnitude = bftoint(bftmp); - if (longmagnitude >= (long)rqlim) - return 1; - copy_bf(bfold.x, bfnew.x); - copy_bf(bfold.y, bfnew.y); - return 0; -} - -int bfREALbailout() -{ - long longtempsqrx; - - square_bf(bftmpsqrx, bfnew.x); - square_bf(bftmpsqry, bfnew.y); - longtempsqrx = bftoint(bftmpsqrx); - if (longtempsqrx >= (long)rqlim) - return 1; - copy_bf(bfold.x, bfnew.x); - copy_bf(bfold.y, bfnew.y); - return 0; -} - - -int bfIMAGbailout() -{ - long longtempsqry; - - square_bf(bftmpsqrx, bfnew.x); - square_bf(bftmpsqry, bfnew.y); - longtempsqry = bftoint(bftmpsqry); - if (longtempsqry >= (long)rqlim) - return 1; - copy_bf(bfold.x, bfnew.x); - copy_bf(bfold.y, bfnew.y); - return(0); -} - -int bfORbailout() -{ - long longtempsqrx, longtempsqry; - - square_bf(bftmpsqrx, bfnew.x); - square_bf(bftmpsqry, bfnew.y); - longtempsqrx = bftoint(bftmpsqrx); - longtempsqry = bftoint(bftmpsqry); - if (longtempsqrx >= (long)rqlim || longtempsqry >= (long)rqlim) - return 1; - copy_bf(bfold.x, bfnew.x); - copy_bf(bfold.y, bfnew.y); - return(0); -} - -int bfANDbailout() -{ - long longtempsqrx, longtempsqry; - - square_bf(bftmpsqrx, bfnew.x); - square_bf(bftmpsqry, bfnew.y); - longtempsqrx = bftoint(bftmpsqrx); - longtempsqry = bftoint(bftmpsqry); - if (longtempsqrx >= (long)rqlim && longtempsqry >= (long)rqlim) - return 1; - copy_bf(bfold.x, bfnew.x); - copy_bf(bfold.y, bfnew.y); - return(0); -} - -int bfMANHbailout() -{ - long longtempmag; - - square_bf(bftmpsqrx, bfnew.x); - square_bf(bftmpsqry, bfnew.y); - /* note: in next five lines, bfold is just used as a temporary variable */ - abs_bf(bfold.x,bfnew.x); - abs_bf(bfold.y,bfnew.y); - add_bf(bftmp, bfold.x, bfold.y); - square_bf(bfold.x, bftmp); - longtempmag = bftoint(bfold.x); - if (longtempmag >= (long)rqlim) - return 1; - copy_bf(bfold.x, bfnew.x); - copy_bf(bfold.y, bfnew.y); - return(0); -} - -int bfMANRbailout() -{ - long longtempmag; - - square_bf(bftmpsqrx, bfnew.x); - square_bf(bftmpsqry, bfnew.y); - add_bf(bftmp, bfnew.x, bfnew.y); /* don't need abs since we square it next */ - /* note: in next two lines, bfold is just used as a temporary variable */ - square_bf(bfold.x, bftmp); - longtempmag = bftoint(bfold.x); - if (longtempmag >= (long)rqlim) - return 1; - copy_bf(bfold.x, bfnew.x); - copy_bf(bfold.y, bfnew.y); - return(0); -} - -int MandelbnSetup() -{ - /* this should be set up dynamically based on corners */ - bn_t bntemp1, bntemp2; - int saved; saved = save_stack(); - bntemp1 = alloc_stack(bnlength); - bntemp2 = alloc_stack(bnlength); - - bftobn(bnxmin,bfxmin); - bftobn(bnxmax,bfxmax); - bftobn(bnymin,bfymin); - bftobn(bnymax,bfymax); - bftobn(bnx3rd,bfx3rd); - bftobn(bny3rd,bfy3rd); - - bf_math = BIGNUM; - - /* bnxdel = (bnxmax - bnx3rd)/(xdots-1) */ - sub_bn(bnxdel, bnxmax, bnx3rd); - div_a_bn_int(bnxdel, (U16)(xdots - 1)); - - /* bnydel = (bnymax - bny3rd)/(ydots-1) */ - sub_bn(bnydel, bnymax, bny3rd); - div_a_bn_int(bnydel, (U16)(ydots - 1)); - - /* bnxdel2 = (bnx3rd - bnxmin)/(ydots-1) */ - sub_bn(bnxdel2, bnx3rd, bnxmin); - div_a_bn_int(bnxdel2, (U16)(ydots - 1)); - - /* bnydel2 = (bny3rd - bnymin)/(xdots-1) */ - sub_bn(bnydel2, bny3rd, bnymin); - div_a_bn_int(bnydel2, (U16)(xdots - 1)); - - abs_bn(bnclosenuff,bnxdel); - if (cmp_bn(abs_bn(bntemp1,bnxdel2),bnclosenuff) > 0) - copy_bn(bnclosenuff,bntemp1); - if (cmp_bn(abs_bn(bntemp1,bnydel),abs_bn(bntemp2,bnydel2)) > 0) - { - if (cmp_bn(bntemp1,bnclosenuff) > 0) - copy_bn(bnclosenuff,bntemp1); - } - else if (cmp_bn(bntemp2,bnclosenuff) > 0) - copy_bn(bnclosenuff,bntemp2); - { - int t; - t = abs(periodicitycheck); - while (t--) - half_a_bn(bnclosenuff); - } - - c_exp = (int)param[2]; - switch (fractype) - { - case JULIAFP: - bftobn(bnparm.x, bfparms[0]); - bftobn(bnparm.y, bfparms[1]); - break; - case FPMANDELZPOWER: - init_big_pi(); - if ((double)c_exp == param[2] && (c_exp & 1)) /* odd exponents */ - symmetry = XYAXIS_NOPARM; - if (param[3] != 0) - symmetry = NOSYM; - break; - case FPJULIAZPOWER: - init_big_pi(); - bftobn(bnparm.x, bfparms[0]); - bftobn(bnparm.y, bfparms[1]); - if ((c_exp & 1) || param[3] != 0.0 || (double)c_exp != param[2] ) - symmetry = NOSYM; - break; - } - -/* at the present time, parameters are kept in float, but want to keep - the arbitrary precision logic intact. The next two lines, if used, - would disguise and breaking of the arbitrary precision logic */ - /* - floattobn(bnparm.x,param[0]); - floattobn(bnparm.y,param[1]); - */ - restore_stack(saved); - return (1); -} - -int MandelbfSetup() -{ - /* this should be set up dynamically based on corners */ - bf_t bftemp1, bftemp2; - int saved; saved = save_stack(); - bftemp1 = alloc_stack(bflength+2); - bftemp2 = alloc_stack(bflength+2); - - bf_math = BIGFLT; - - /* bfxdel = (bfxmax - bfx3rd)/(xdots-1) */ - sub_bf(bfxdel, bfxmax, bfx3rd); - div_a_bf_int(bfxdel, (U16)(xdots - 1)); - - /* bfydel = (bfymax - bfy3rd)/(ydots-1) */ - sub_bf(bfydel, bfymax, bfy3rd); - div_a_bf_int(bfydel, (U16)(ydots - 1)); - - /* bfxdel2 = (bfx3rd - bfxmin)/(ydots-1) */ - sub_bf(bfxdel2, bfx3rd, bfxmin); - div_a_bf_int(bfxdel2, (U16)(ydots - 1)); - - /* bfydel2 = (bfy3rd - bfymin)/(xdots-1) */ - sub_bf(bfydel2, bfy3rd, bfymin); - div_a_bf_int(bfydel2, (U16)(xdots - 1)); - - abs_bf(bfclosenuff,bfxdel); - if (cmp_bf(abs_bf(bftemp1,bfxdel2),bfclosenuff) > 0) - copy_bf(bfclosenuff,bftemp1); - if (cmp_bf(abs_bf(bftemp1,bfydel),abs_bf(bftemp2,bfydel2)) > 0) - { - if (cmp_bf(bftemp1,bfclosenuff) > 0) - copy_bf(bfclosenuff,bftemp1); - } - else if (cmp_bf(bftemp2,bfclosenuff) > 0) - copy_bf(bfclosenuff,bftemp2); - { - int t; - t = abs(periodicitycheck); - while (t--) - half_a_bf(bfclosenuff); - } - - c_exp = (int)param[2]; - switch (fractype) - { - case JULIAFP: - copy_bf(bfparm.x, bfparms[0]); - copy_bf(bfparm.y, bfparms[1]); - break; - case FPMANDELZPOWER: - init_big_pi(); - if ((double)c_exp == param[2] && (c_exp & 1)) /* odd exponents */ - symmetry = XYAXIS_NOPARM; - if (param[3] != 0) - symmetry = NOSYM; - break; - case FPJULIAZPOWER: - init_big_pi(); - copy_bf(bfparm.x, bfparms[0]); - copy_bf(bfparm.y, bfparms[1]); - if ((c_exp & 1) || param[3] != 0.0 || (double)c_exp != param[2] ) - symmetry = NOSYM; - break; - } - - restore_stack(saved); - return (1); -} - -int mandelbn_per_pixel() -{ - /* parm.x = xxmin + col*delx + row*delx2 */ - mult_bn_int(bnparm.x, bnxdel, (U16)col); - mult_bn_int(bntmp, bnxdel2, (U16)row); - - add_a_bn(bnparm.x, bntmp); - add_a_bn(bnparm.x, bnxmin); - - /* parm.y = yymax - row*dely - col*dely2; */ - /* note: in next four lines, bnold is just used as a temporary variable */ - mult_bn_int(bnold.x, bnydel, (U16)row); - mult_bn_int(bnold.y, bnydel2, (U16)col); - add_a_bn(bnold.x, bnold.y); - sub_bn(bnparm.y, bnymax, bnold.x); - - copy_bn(bnold.x, bnparm.x); - copy_bn(bnold.y, bnparm.y); - - if ((inside == BOF60 || inside == BOF61) && !nobof) - { - /* kludge to match "Beauty of Fractals" picture since we start - Mandelbrot iteration with init rather than 0 */ - floattobn(bnold.x,param[0]); /* initial pertubation of parameters set */ - floattobn(bnold.y,param[1]); - coloriter = -1; - } - else - { - floattobn(bnnew.x,param[0]); - floattobn(bnnew.y,param[1]); - add_a_bn(bnold.x,bnnew.x); - add_a_bn(bnold.y,bnnew.y); - } - - /* square has side effect - must copy first */ - copy_bn(bnnew.x, bnold.x); - copy_bn(bnnew.y, bnold.y); - - /* Square these to rlength bytes of precision */ - square_bn(bntmpsqrx, bnnew.x); - square_bn(bntmpsqry, bnnew.y); - - return (1); /* 1st iteration has been done */ -} - -int mandelbf_per_pixel() -{ - /* parm.x = xxmin + col*delx + row*delx2 */ - mult_bf_int(bfparm.x, bfxdel, (U16)col); - mult_bf_int(bftmp, bfxdel2, (U16)row); - - add_a_bf(bfparm.x, bftmp); - add_a_bf(bfparm.x, bfxmin); - - /* parm.y = yymax - row*dely - col*dely2; */ - /* note: in next four lines, bfold is just used as a temporary variable */ - mult_bf_int(bfold.x, bfydel, (U16)row); - mult_bf_int(bfold.y, bfydel2, (U16)col); - add_a_bf(bfold.x, bfold.y); - sub_bf(bfparm.y, bfymax, bfold.x); - - copy_bf(bfold.x, bfparm.x); - copy_bf(bfold.y, bfparm.y); - - if ((inside == BOF60 || inside == BOF61) && !nobof) - { - /* kludge to match "Beauty of Fractals" picture since we start - Mandelbrot iteration with init rather than 0 */ - floattobf(bfold.x,param[0]); /* initial pertubation of parameters set */ - floattobf(bfold.y,param[1]); - coloriter = -1; - } - else - { - floattobf(bfnew.x,param[0]); - floattobf(bfnew.y,param[1]); - add_a_bf(bfold.x,bfnew.x); - add_a_bf(bfold.y,bfnew.y); - } - - /* square has side effect - must copy first */ - copy_bf(bfnew.x, bfold.x); - copy_bf(bfnew.y, bfold.y); - - /* Square these to rbflength bytes of precision */ - square_bf(bftmpsqrx, bfnew.x); - square_bf(bftmpsqry, bfnew.y); - - return (1); /* 1st iteration has been done */ -} - -int -juliabn_per_pixel() -{ - /* old.x = xxmin + col*delx + row*delx2 */ - mult_bn_int(bnold.x, bnxdel, (U16)col); - mult_bn_int(bntmp, bnxdel2, (U16)row); - - add_a_bn(bnold.x, bntmp); - add_a_bn(bnold.x, bnxmin); - - /* old.y = yymax - row*dely - col*dely2; */ - /* note: in next four lines, bnnew is just used as a temporary variable */ - mult_bn_int(bnnew.x, bnydel, (U16)row); - mult_bn_int(bnnew.y, bnydel2, (U16)col); - add_a_bn(bnnew.x, bnnew.y); - sub_bn(bnold.y, bnymax, bnnew.x); - - /* square has side effect - must copy first */ - copy_bn(bnnew.x, bnold.x); - copy_bn(bnnew.y, bnold.y); - - /* Square these to rlength bytes of precision */ - square_bn(bntmpsqrx, bnnew.x); - square_bn(bntmpsqry, bnnew.y); - - return (1); /* 1st iteration has been done */ -} - -int -juliabf_per_pixel() -{ - /* old.x = xxmin + col*delx + row*delx2 */ - mult_bf_int(bfold.x, bfxdel, (U16)col); - mult_bf_int(bftmp, bfxdel2, (U16)row); - - add_a_bf(bfold.x, bftmp); - add_a_bf(bfold.x, bfxmin); - - /* old.y = yymax - row*dely - col*dely2; */ - /* note: in next four lines, bfnew is just used as a temporary variable */ - mult_bf_int(bfnew.x, bfydel, (U16)row); - mult_bf_int(bfnew.y, bfydel2, (U16)col); - add_a_bf(bfnew.x, bfnew.y); - sub_bf(bfold.y, bfymax, bfnew.x); - - /* square has side effect - must copy first */ - copy_bf(bfnew.x, bfold.x); - copy_bf(bfnew.y, bfold.y); - - /* Square these to rbflength bytes of precision */ - square_bf(bftmpsqrx, bfnew.x); - square_bf(bftmpsqry, bfnew.y); - - return (1); /* 1st iteration has been done */ -} - -int -JuliabnFractal() -{ - /* Don't forget, with bn_t numbers, after multiplying or squaring */ - /* you must shift over by shiftfactor to get the bn number. */ - - /* bntmpsqrx and bntmpsqry were previously squared before getting to */ - /* this function, so they must be shifted. */ - - /* new.x = tmpsqrx - tmpsqry + parm.x; */ - sub_a_bn(bntmpsqrx+shiftfactor, bntmpsqry+shiftfactor); - add_bn(bnnew.x, bntmpsqrx+shiftfactor, bnparm.x); - - /* new.y = 2 * bnold.x * bnold.y + parm.y; */ - mult_bn(bntmp, bnold.x, bnold.y); /* ok to use unsafe here */ - double_a_bn(bntmp+shiftfactor); - add_bn(bnnew.y, bntmp+shiftfactor, bnparm.y); - - return bignumbailout(); -} - -int -JuliabfFractal() -{ - /* new.x = tmpsqrx - tmpsqry + parm.x; */ - sub_a_bf(bftmpsqrx, bftmpsqry); - add_bf(bfnew.x, bftmpsqrx, bfparm.x); - - /* new.y = 2 * bfold.x * bfold.y + parm.y; */ - mult_bf(bftmp, bfold.x, bfold.y); /* ok to use unsafe here */ - double_a_bf(bftmp); - add_bf(bfnew.y, bftmp, bfparm.y); - return bigfltbailout(); -} - -int -JuliaZpowerbnFractal() -{ - _BNCMPLX parm2; - int saved; saved = save_stack(); - - parm2.x = alloc_stack(bnlength); - parm2.y = alloc_stack(bnlength); - - floattobn(parm2.x,param[2]); - floattobn(parm2.y,param[3]); - ComplexPower_bn(&bnnew,&bnold,&parm2); - add_bn(bnnew.x,bnparm.x,bnnew.x+shiftfactor); - add_bn(bnnew.y,bnparm.y,bnnew.y+shiftfactor); - restore_stack(saved); - return bignumbailout(); -} - -int -JuliaZpowerbfFractal() -{ - _BFCMPLX parm2; - int saved; saved = save_stack(); - - parm2.x = alloc_stack(bflength+2); - parm2.y = alloc_stack(bflength+2); - - floattobf(parm2.x,param[2]); - floattobf(parm2.y,param[3]); - ComplexPower_bf(&bfnew,&bfold,&parm2); - add_bf(bfnew.x,bfparm.x,bfnew.x); - add_bf(bfnew.y,bfparm.y,bfnew.y); - restore_stack(saved); - return bigfltbailout(); -} - - -#if 0 -/* -the following is an example of how you can take advantage of the bn_t -format to squeeze a little more precision out of the calculations. -*/ -int -JuliabnFractal() -{ - int oldbnlength; - bn_t mod; - /* using partial precision multiplications */ - - /* bnnew.x = bntmpsqrx - bntmpsqry + bnparm.x; */ - /* - * Since tmpsqrx and tmpsqry where just calculated to rlength bytes of - * precision, we might as well keep that extra precision in this next - * subtraction. Therefore, use rlength as the length. - */ - - oldbnlength = bnlength; - bnlength = rlength; sub_a_bn(bntmpsqrx, bntmpsqry); bnlength = oldbnlength; - - /* - * Now that bntmpsqry has been sutracted from bntmpsqrx, we need to treat - * tmpsqrx as a single width bignumber, so shift to bntmpsqrx+shiftfactor. - */ - add_bn(bnnew.x, bntmpsqrx + shiftfactor, bnparm.x); - - /* new.y = 2 * bnold.x * bnold.y + old.y; */ - /* Multiply bnold.x*bnold.y to rlength precision. */ - mult_bn(bntmp, bnold.x, bnold.y); - - /* - * Double bnold.x*bnold.y by shifting bits, including one of those bits - * calculated in the previous mult_bn(). Therefore, use rlength. - */ - bnlength = rlength; double_a_bn(bntmp); bnlength = oldbnlength; - - /* Convert back to a single width bignumber and add bnparm.y */ - add_bn(bnnew.y, bntmp + shiftfactor, bnparm.y); - - copy_bn(bnold.x, bnnew.x); - copy_bn(bnold.y, bnnew.y); - - /* Square these to rlength bytes of precision */ - square_bn(bntmpsqrx, bnold.x); - square_bn(bntmpsqry, bnold.y); - - /* And add the full rlength precision to get those extra bytes */ - bnlength = rlength; - add_bn(bntmp, bntmpsqrx, bntmpsqry); - bnlength = oldbnlength; - - mod = bntmp + (rlength) - (intlength << 1); /* where int part starts - * after mult */ - /* - * equivalent to, but faster than, mod = bn_int(tmp+shiftfactor); - */ - - if ((magnitude = *mod) >= rqlim) - return (1); - return (0); -} -#endif - -_CMPLX cmplxbntofloat(_BNCMPLX *s) -{ - _CMPLX t; - t.x = (double)bntofloat(s->x); - t.y = (double)bntofloat(s->y); - return(t); -} - -_CMPLX cmplxbftofloat(_BFCMPLX *s) -{ - _CMPLX t; - t.x = (double)bftofloat(s->x); - t.y = (double)bftofloat(s->y); - return(t); -} - -_BFCMPLX *cmplxlog_bf(_BFCMPLX *t, _BFCMPLX *s) -{ - square_bf(t->x,s->x); - square_bf(t->y,s->y); - add_a_bf(t->x,t->y); - ln_bf(t->x,t->x); - half_a_bf(t->x); - atan2_bf(t->y,s->y,s->x); - return(t); -} - -_BFCMPLX *cplxmul_bf( _BFCMPLX *t, _BFCMPLX *x, _BFCMPLX *y) -{ - bf_t tmp1; - int saved; saved = save_stack(); - tmp1 = alloc_stack(rbflength+2); - mult_bf(t->x, x->x, y->x); - mult_bf(t->y, x->y, y->y); - sub_bf(t->x,t->x,t->y); - - mult_bf(tmp1, x->x, y->y); - mult_bf(t->y, x->y, y->x); - add_bf(t->y,tmp1,t->y); - restore_stack(saved); - return(t); -} - -_BFCMPLX *ComplexPower_bf(_BFCMPLX *t, _BFCMPLX *xx, _BFCMPLX *yy) -{ - _BFCMPLX tmp; - bf_t e2x, siny, cosy; - int saved; saved = save_stack(); - e2x = alloc_stack(rbflength+2); - siny = alloc_stack(rbflength+2); - cosy = alloc_stack(rbflength+2); - tmp.x = alloc_stack(rbflength+2); - tmp.y = alloc_stack(rbflength+2); - - /* 0 raised to anything is 0 */ - if (is_bf_zero(xx->x) && is_bf_zero(xx->y)) - { - clear_bf(t->x); - clear_bf(t->y); - return(t); - } - - cmplxlog_bf(t, xx); - cplxmul_bf(&tmp, t, yy); - exp_bf(e2x,tmp.x); - sincos_bf(siny,cosy,tmp.y); - mult_bf(t->x, e2x, cosy); - mult_bf(t->y, e2x, siny); - restore_stack(saved); - return(t); -} - -_BNCMPLX *cmplxlog_bn(_BNCMPLX *t, _BNCMPLX *s) -{ - square_bn(t->x,s->x); - square_bn(t->y,s->y); - add_a_bn(t->x+shiftfactor,t->y+shiftfactor); - ln_bn(t->x,t->x+shiftfactor); - half_a_bn(t->x); - atan2_bn(t->y,s->y,s->x); - return(t); -} - -_BNCMPLX *cplxmul_bn( _BNCMPLX *t, _BNCMPLX *x, _BNCMPLX *y) -{ - bn_t tmp1; - int saved; saved = save_stack(); - tmp1 = alloc_stack(rlength); - mult_bn(t->x, x->x, y->x); - mult_bn(t->y, x->y, y->y); - sub_bn(t->x,t->x+shiftfactor,t->y+shiftfactor); - - mult_bn(tmp1, x->x, y->y); - mult_bn(t->y, x->y, y->x); - add_bn(t->y,tmp1+shiftfactor,t->y+shiftfactor); - restore_stack(saved); - return(t); -} - -/* note: ComplexPower_bn() returns need to be +shiftfactor'ed */ -_BNCMPLX *ComplexPower_bn(_BNCMPLX *t, _BNCMPLX *xx, _BNCMPLX *yy) -{ - _BNCMPLX tmp; - bn_t e2x, siny, cosy; - int saved; saved = save_stack(); - e2x = alloc_stack(bnlength); - siny = alloc_stack(bnlength); - cosy = alloc_stack(bnlength); - tmp.x = alloc_stack(rlength); - tmp.y = alloc_stack(rlength); - - /* 0 raised to anything is 0 */ - if (is_bn_zero(xx->x) && is_bn_zero(xx->y)) - { - clear_bn(t->x); - clear_bn(t->y); - return(t); - } - - cmplxlog_bn(t, xx); - cplxmul_bn(&tmp, t, yy); - exp_bn(e2x,tmp.x); - sincos_bn(siny,cosy,tmp.y); - mult_bn(t->x, e2x, cosy); - mult_bn(t->y, e2x, siny); - restore_stack(saved); - return(t); -} diff --git a/fractint/common/fractalp.c b/fractint/common/fractalp.c deleted file mode 100644 index 706343623..000000000 --- a/fractint/common/fractalp.c +++ /dev/null @@ -1,2338 +0,0 @@ -/* - This module consists only of the fractalspecific structure - and a *slew* of defines needed to get it to compile -*/ -#include - -/* includes needed for fractalspecific */ - - /* see Fractint.c for a description of the "include" hierarchy */ -#include "port.h" -#include "prototyp.h" -#include "helpdefs.h" -#include "fractype.h" - -/* functions defined elswhere needed for fractalspecific */ -/* moved to prototyp.h */ - -/* parameter descriptions */ -/* Note: parameters preceded by + are integer parameters */ -/* parameters preceded by # are U32 parameters */ - -/* for Mandelbrots */ -static char realz0[] = "Real Perturbation of Z(0)"; -static char imagz0[] = "Imaginary Perturbation of Z(0)"; - -/* for Julias */ -static char realparm[] = "Real Part of Parameter"; -static char imagparm[] = "Imaginary Part of Parameter"; - -/* for Newtons */ -static char newtdegree[] = "+Polynomial Degree (>= 2)"; - -/* for MarksMandel/Julia */ -static char exponent[] = "Real part of Exponent"; -static char imexponent[] = "Imag part of Exponent"; - -/* for Lorenz */ -static char timestep[] = "Time Step"; - -/* for formula */ -static char p1real[] = "Real portion of p1"; -static char p2real[] = "Real portion of p2"; -static char p3real[] = "Real portion of p3"; -static char p4real[] = "Real portion of p4"; -static char p5real[] = "Real portion of p5"; -static char p1imag[] = "Imaginary portion of p1"; -static char p2imag[] = "Imaginary portion of p2"; -static char p3imag[] = "Imaginary portion of p3"; -static char p4imag[] = "Imaginary portion of p4"; -static char p5imag[] = "Imaginary portion of p5"; - -/* trig functions */ -static char recoeftrg1[] = "Real Coefficient First Function"; -static char imcoeftrg1[] = "Imag Coefficient First Function"; -static char recoeftrg2[] = "Real Coefficient Second Function"; -static char imcoeftrg2[] = "Imag Coefficient Second Function"; - -/* KAM Torus */ -static char kamangle[] = "Angle (radians)"; -static char kamstep[] = "Step size"; -static char kamstop[] = "Stop value"; -static char pointsperorbit[] = "+Points per orbit"; - -/* popcorn and julia popcorn generalized */ -static char step_x[] = "Step size (real)"; -static char step_y[] = "Step size (imaginary)"; -static char constant_x[] = "Constant C (real)"; -static char constant_y[] = "Constant C (imaginary)"; - -/* bifurcations */ -static char filt[] = "+Filter Cycles"; -static char seed[] = "Seed Population"; - -/* frothy basins */ -static char frothmapping[] = "+Apply mapping once (1) or twice (2)"; -static char frothshade[] = "+Enter non-zero value for alternate color shading"; -static char frothavalue[] = "A (imaginary part of C)"; - -/* plasma and ant */ - -static char s_randomseed[] = "+Random Seed Value (0 = Random, 1 = Reuse Last)"; - -/* ifs */ -static char color_method[] = "+Coloring method (0,1)"; - -/* phoenix fractals */ -static char degreeZ[] = "Degree = 0 | >= 2 | <= -3"; - -/* julia inverse */ -static char s_maxhits[] = "Max Hits per Pixel"; - -/* halley */ -static char order[] = {"+Order (integer > 1)"}; -static char real_relax[] = {"Real Relaxation coefficient"}; -static char epsilon[] = {"Epsilon"}; -static char imag_relax[] = {"Imag Relaxation coefficient"}; -/* cellular */ -static char cell_init[] = {"#Initial String | 0 = Random | -1 = Reuse Last Random"}; -static char cell_rule[] = {"#Rule = # of digits (see below) | 0 = Random"}; -static char cell_type[] = {"+Type (see below)"}; -static char cell_strt[] = {"#Starting Row Number"}; - -/* bailout defines */ -#define FTRIGBAILOUT 2500 -#define LTRIGBAILOUT 64 -#define FROTHBAILOUT 7 -#define STDBAILOUT 4 -#define NOBAILOUT 0 - -MOREPARAMS moreparams[] = -{ - {ICON ,{ "Omega", "+Degree of symmetry", "","","",""},{0,3,0,0,0,0}}, - {ICON3D ,{ "Omega", "+Degree of symmetry", "","","",""},{0,3,0,0,0,0}}, - {HYPERCMPLXJFP ,{ "zj", "zk", "","","",""},{0,0,0,0,0,0}}, - {QUATJULFP ,{ "zj", "zk", "","","",""},{0,0,0,0,0,0}}, - {PHOENIXCPLX ,{ degreeZ, "", "","","",""},{0,0,0,0,0,0}}, - {PHOENIXFPCPLX ,{ degreeZ, "", "","","",""},{0,0,0,0,0,0}}, - {MANDPHOENIXCPLX ,{ degreeZ, "", "","","",""},{0,0,0,0,0,0}}, - {MANDPHOENIXFPCPLX,{ degreeZ, "", "","","",""},{0,0,0,0,0,0}}, - {FORMULA ,{ p3real,p3imag,p4real,p4imag,p5real,p5imag},{0,0,0,0,0,0}}, - {FFORMULA ,{ p3real,p3imag,p4real,p4imag,p5real,p5imag},{0,0,0,0,0,0}}, - {ANT ,{ "+Wrap?",s_randomseed,"","","",""},{1,0,0,0,0,0}}, - {MANDELBROTMIX4 ,{ p3real,p3imag, "","","",""},{0,0,0,0,0,0}}, - {-1 ,{ NULL,NULL,NULL,NULL,NULL,NULL },{0,0,0,0,0,0}} -}; - -/* - type math orbitcalc fnct per_pixel fnct per_image fnct - |-----|----|--------------|--------------|--------------| */ -struct alternatemathstuff alternatemath[] = -{ -#define USEBN -#ifdef USEBN - {JULIAFP, 1,JuliabnFractal,juliabn_per_pixel, MandelbnSetup}, - {MANDELFP,1,JuliabnFractal,mandelbn_per_pixel, MandelbnSetup}, -#else - {JULIAFP, 2,JuliabfFractal,juliabf_per_pixel, MandelbfSetup}, - {MANDELFP,2,JuliabfFractal,mandelbf_per_pixel, MandelbfSetup}, -#endif -/* -NOTE: The default precision for bf_math=BIGNUM is not high enough - for JuliaZpowerbnFractal. If you want to test BIGNUM (1) instead - of the usual BIGFLT (2), then set bfdigits on the command to - increase the precision. -*/ - {FPJULIAZPOWER,2,JuliaZpowerbfFractal,juliabf_per_pixel, MandelbfSetup }, - {FPMANDELZPOWER,2,JuliaZpowerbfFractal,mandelbf_per_pixel, MandelbfSetup}, - {-1, 0,NULL, NULL, NULL } -}; - -/* These are only needed for types with both integer and float variations */ -char t_barnsleyj1[]= "*barnsleyj1"; -char t_barnsleyj2[]= "*barnsleyj2"; -char t_barnsleyj3[]= "*barnsleyj3"; -char t_barnsleym1[]= "*barnsleym1"; -char t_barnsleym2[]= "*barnsleym2"; -char t_barnsleym3[]= "*barnsleym3"; -char t_bifplussinpi[]= "*bif+sinpi"; -char t_bifeqsinpi[]= "*bif=sinpi"; -char t_biflambda[]= "*biflambda"; -char t_bifmay[]= "*bifmay"; -char t_bifstewart[]= "*bifstewart"; -char t_bifurcation[]= "*bifurcation"; -char t_fn_z_plusfn_pix_[]= "*fn(z)+fn(pix)"; -char t_fn_zz_[]= "*fn(z*z)"; -char t_fnfn[]= "*fn*fn"; -char t_fnzplusz[]= "*fn*z+z"; -char t_fnplusfn[]= "*fn+fn"; -char t_formula[]= "*formula"; -char t_henon[]= "*henon"; -char t_ifs3d[]= "*ifs3d"; -char t_julfnplusexp[]= "*julfn+exp"; -char t_julfnpluszsqrd[]= "*julfn+zsqrd"; -char t_julia[]= "*julia"; -char t_julia_fnorfn_[]= "*julia(fn||fn)"; -char t_julia4[]= "*julia4"; -char t_julia_inverse[]= "*julia_inverse"; -char t_julibrot[]= "*julibrot"; -char t_julzpower[]= "*julzpower"; -char t_kamtorus[]= "*kamtorus"; -char t_kamtorus3d[]= "*kamtorus3d"; -char t_lambda[]= "*lambda"; -char t_lambda_fnorfn_[]= "*lambda(fn||fn)"; -char t_lambdafn[]= "*lambdafn"; -char t_lorenz[]= "*lorenz"; -char t_lorenz3d[]= "*lorenz3d"; -char t_mandel[]= "*mandel"; -char t_mandel_fnorfn_[]= "*mandel(fn||fn)"; -char t_mandel4[]= "*mandel4"; -char t_mandelfn[]= "*mandelfn"; -char t_mandellambda[]= "*mandellambda"; -char t_mandphoenix[]= "*mandphoenix"; -char t_mandphoenixcplx[]= "*mandphoenixclx"; -char t_manfnplusexp[]= "*manfn+exp"; -char t_manfnpluszsqrd[]= "*manfn+zsqrd"; -char t_manlam_fnorfn_[]= "*manlam(fn||fn)"; -char t_manowar[]= "*manowar"; -char t_manowarj[]= "*manowarj"; -char t_manzpower[]= "*manzpower"; -char t_marksjulia[]= "*marksjulia"; -char t_marksmandel[]= "*marksmandel"; -char t_marksmandelpwr[]= "*marksmandelpwr"; -char t_newtbasin[]= "*newtbasin"; -char t_newton[]= "*newton"; -char t_phoenix[]= "*phoenix"; -char t_phoenixcplx[]= "*phoenixcplx"; -char t_popcorn[]= "*popcorn"; -char t_popcornjul[]= "*popcornjul"; -char t_rossler3d[]= "*rossler3d"; -char t_sierpinski[]= "*sierpinski"; -char t_spider[]= "*spider"; -char t_sqr_1divfn_[]= "*sqr(1/fn)"; -char t_sqr_fn_[]= "*sqr(fn)"; -char t_tims_error[]= "*tim's_error"; -char t_unity[]= "*unity"; -char t_frothybasin[]= "*frothybasin"; -char t_halley[]= "*halley"; - -/* use next to cast orbitcalcs() that have arguments */ -#define VF int(*)(void) - -struct fractalspecificstuff fractalspecific[]= -{ - /* - { - fractal name, - {parameter text strings}, - {parameter values}, - helptext, helpformula, flags, - xmin, xmax, ymin, ymax, - int, tojulia, tomandel, tofloat, symmetry, - orbit fnct, per_pixel fnct, per_image fnct, calctype fcnt, - bailout - } - */ - - { - t_mandel+1, - {realz0, imagz0, "", ""}, - {0, 0, 0, 0}, - HT_MANDEL, HF_MANDEL, WINFRAC+BAILTEST, - (float)-2.5, (float)1.5, (float)-1.5, (float)1.5, - 1, JULIA, NOFRACTAL, MANDELFP, XAXIS_NOPARM, - JuliaFractal, mandel_per_pixel,MandelSetup, StandardFractal, - STDBAILOUT - }, - - { - t_julia+1, - {realparm, imagparm, "", ""}, - {0.3, 0.6, 0, 0}, - HT_JULIA, HF_JULIA, WINFRAC+OKJB+BAILTEST, - (float)-2.0, (float)2.0, (float)-1.5, (float)1.5, - 1, NOFRACTAL, MANDEL, JULIAFP, ORIGIN, - JuliaFractal, julia_per_pixel, JuliaSetup, StandardFractal, - STDBAILOUT - }, - - { - t_newtbasin, - {newtdegree, "Enter non-zero value for stripes", "", ""}, - {3, 0, 0, 0}, - HT_NEWTBAS, HF_NEWTBAS, WINFRAC, - (float)-2.0, (float)2.0, (float)-1.5, (float)1.5, - 0, NOFRACTAL, NOFRACTAL, MPNEWTBASIN, NOSYM, - NewtonFractal2, otherjuliafp_per_pixel, NewtonSetup, StandardFractal, - NOBAILOUT - }, - - { - t_lambda+1, - {realparm, imagparm, "", ""}, - {0.85, 0.6, 0, 0}, - HT_LAMBDA, HF_LAMBDA, WINFRAC+OKJB+BAILTEST, - (float)-1.5, (float)2.5, (float)-1.5, (float)1.5, - 1, NOFRACTAL, MANDELLAMBDA, LAMBDAFP, NOSYM, - LambdaFractal, julia_per_pixel, JulialongSetup, StandardFractal, - STDBAILOUT - }, - - { - t_mandel, - {realz0, imagz0, "", ""}, - {0, 0, 0, 0}, - HT_MANDEL, HF_MANDEL, WINFRAC+BAILTEST+BF_MATH, - (float)-2.5, (float)1.5, (float)-1.5, (float)1.5, - 0, JULIAFP, NOFRACTAL, MANDEL, XAXIS_NOPARM, - JuliafpFractal, mandelfp_per_pixel, MandelfpSetup, StandardFractal, - STDBAILOUT - }, - - { - t_newton, - {newtdegree, "", "", ""}, - {3, 0, 0, 0}, - HT_NEWT, HF_NEWT, WINFRAC, - (float)-2.0, (float)2.0, (float)-1.5, (float)1.5, - 0, NOFRACTAL, NOFRACTAL, MPNEWTON, XAXIS, - NewtonFractal2, otherjuliafp_per_pixel, NewtonSetup, StandardFractal, - NOBAILOUT - }, - - { - t_julia, - {realparm, imagparm, "", ""}, - {0.3, 0.6, 0, 0}, - HT_JULIA, HF_JULIA, WINFRAC+OKJB+BAILTEST+BF_MATH, - (float)-2.0, (float)2.0, (float)-1.5, (float)1.5, - 0, NOFRACTAL, MANDELFP, JULIA, ORIGIN, - JuliafpFractal, juliafp_per_pixel, JuliafpSetup, StandardFractal, - STDBAILOUT - }, - - { - "plasma", - {"Graininess Factor (0 or 0.125 to 100, default is 2)", - "+Algorithm (0 = original, 1 = new)", - "+Random Seed Value (0 = Random, 1 = Reuse Last)", - "+Save as Pot File? (0 = No, 1 = Yes)" - }, - {2, 0, 0, 0}, - HT_PLASMA, HF_PLASMA, NOZOOM+NOGUESS+NOTRACE+NORESUME+WINFRAC, - (float)-2.0, (float)2.0, (float)-1.5, (float)1.5, - 1, NOFRACTAL, NOFRACTAL, NOFRACTAL, NOSYM, - NULL, NULL, StandaloneSetup, plasma, - NOBAILOUT - }, - - { - t_mandelfn, - {realz0, imagz0, "", ""}, - {0, 0, 0, 0}, - HT_MANDFN, HF_MANDFN, TRIG1+WINFRAC, - (float)-8.0, (float)8.0, (float)-6.0, (float)6.0, - 0, LAMBDATRIGFP, NOFRACTAL, MANDELTRIG, XYAXIS_NOPARM, - LambdaTrigfpFractal,othermandelfp_per_pixel,MandelTrigSetup, - StandardFractal, - LTRIGBAILOUT - }, - - { - t_manowar, - {realz0, imagz0, "", ""}, - {0, 0, 0, 0}, - HT_SCOTSKIN, HF_MANOWAR, WINFRAC+BAILTEST, - (float)-2.5, (float)1.5, (float)-1.5, (float)1.5, - 0, MANOWARJFP, NOFRACTAL, MANOWAR, XAXIS_NOPARM, - ManOWarfpFractal, mandelfp_per_pixel, MandelfpSetup, StandardFractal, - STDBAILOUT - }, - - { - t_manowar+1, - {realz0, imagz0, "", ""}, - {0, 0, 0, 0}, - HT_SCOTSKIN, HF_MANOWAR, WINFRAC+BAILTEST, - (float)-2.5, (float)1.5, (float)-1.5, (float)1.5, - 1, MANOWARJ, NOFRACTAL, MANOWARFP, XAXIS_NOPARM, - ManOWarFractal, mandel_per_pixel, MandellongSetup, StandardFractal, - STDBAILOUT - }, - - { - "test", - {"(testpt Param #1)", - "(testpt param #2)", - "(testpt param #3)", - "(testpt param #4)" - }, - {0, 0, 0, 0}, - HT_TEST, HF_TEST, 0, - (float)-2.0, (float)2.0, (float)-1.5, (float)1.5, - 0, NOFRACTAL, NOFRACTAL, NOFRACTAL, NOSYM, - NULL, NULL, StandaloneSetup, test, - STDBAILOUT - }, - - { - t_sierpinski+1, - {"", "", "", ""}, - {0, 0, 0, 0}, - HT_SIER, HF_SIER, WINFRAC, - (float)-4/3, (float)96/45, (float)-0.9, (float)1.7, - 1, NOFRACTAL, NOFRACTAL, SIERPINSKIFP, NOSYM, - SierpinskiFractal, long_julia_per_pixel, SierpinskiSetup, - StandardFractal, - 127 - }, - - { - t_barnsleym1+1, - {realz0, imagz0, "", ""}, - {0, 0, 0, 0}, - HT_BARNS, HF_BARNSM1, WINFRAC+BAILTEST, - (float)-2.0, (float)2.0, (float)-1.5, (float)1.5, - 1, BARNSLEYJ1,NOFRACTAL, BARNSLEYM1FP, XYAXIS_NOPARM, - Barnsley1Fractal, long_mandel_per_pixel, MandellongSetup, - StandardFractal, - STDBAILOUT - }, - - { - t_barnsleyj1+1, - {realparm, imagparm, "", ""}, - {0.6, 1.1, 0, 0}, - HT_BARNS, HF_BARNSJ1, WINFRAC+OKJB+BAILTEST, - (float)-2.0, (float)2.0, (float)-1.5, (float)1.5, - 1, NOFRACTAL, BARNSLEYM1, BARNSLEYJ1FP, ORIGIN, - Barnsley1Fractal, long_julia_per_pixel, JulialongSetup, StandardFractal, - STDBAILOUT - }, - - { - t_barnsleym2+1, - {realz0, imagz0, "", ""}, - {0, 0, 0, 0}, - HT_BARNS, HF_BARNSM2, WINFRAC+BAILTEST, - (float)-2.0, (float)2.0, (float)-1.5, (float)1.5, - 1, BARNSLEYJ2, NOFRACTAL, BARNSLEYM2FP, YAXIS_NOPARM, - Barnsley2Fractal, long_mandel_per_pixel, MandellongSetup, - StandardFractal, - STDBAILOUT - }, - - { - t_barnsleyj2+1, - {realparm, imagparm, "", ""}, - {0.6, 1.1, 0, 0}, - HT_BARNS, HF_BARNSJ2, WINFRAC+OKJB+BAILTEST, - (float)-2.0, (float)2.0, (float)-1.5, (float)1.5, - 1, NOFRACTAL, BARNSLEYM2, BARNSLEYJ2FP, ORIGIN, - Barnsley2Fractal, long_julia_per_pixel, JulialongSetup, StandardFractal, - STDBAILOUT - }, - - { - t_sqr_fn_+1, - {"", "", "", ""}, - {0, 0, 0, 0}, - HT_SCOTSKIN, HF_SQRFN, TRIG1+WINFRAC+BAILTEST, - (float)-4.0, (float)4.0, (float)-3.0, (float)3.0, - 16, NOFRACTAL, NOFRACTAL, SQRTRIGFP, XAXIS, - SqrTrigFractal, long_julia_per_pixel, SqrTrigSetup, StandardFractal, - LTRIGBAILOUT - }, - - { - t_sqr_fn_, - {"", "", "", ""}, - {0, 0, 0, 0}, - HT_SCOTSKIN, HF_SQRFN, TRIG1+WINFRAC+BAILTEST, - (float)-4.0, (float)4.0, (float)-3.0, (float)3.0, - 0, NOFRACTAL, NOFRACTAL, SQRTRIG, XAXIS, - SqrTrigfpFractal, otherjuliafp_per_pixel, SqrTrigSetup, StandardFractal, - LTRIGBAILOUT - }, - - { - t_fnplusfn+1, - {recoeftrg1, imcoeftrg1, recoeftrg2, imcoeftrg2}, - {1, 0, 1, 0}, - HT_SCOTSKIN, HF_FNPLUSFN, TRIG2+WINFRAC+BAILTEST, - (float)-4.0, (float)4.0, (float)-3.0, (float)3.0, - 16, NOFRACTAL, NOFRACTAL, TRIGPLUSTRIGFP, XAXIS, - TrigPlusTrigFractal, long_julia_per_pixel, TrigPlusTriglongSetup, - StandardFractal, - LTRIGBAILOUT - }, - - { - t_mandellambda+1, - {realz0, imagz0, "", ""}, - {0, 0, 0, 0}, - HT_MLAMBDA, HF_MLAMBDA, WINFRAC+BAILTEST, - (float)-3.0, (float)5.0, (float)-3.0, (float)3.0, - 1, LAMBDA, NOFRACTAL, MANDELLAMBDAFP, XAXIS_NOPARM, - LambdaFractal, mandel_per_pixel,MandellongSetup, StandardFractal, - STDBAILOUT - }, - - { - t_marksmandel+1, - {realz0, imagz0, exponent, ""}, - {0, 0, 1, 0}, - HT_MARKS, HF_MARKSMAND, WINFRAC+BAILTEST, - (float)-2.0, (float)2.0, (float)-1.5, (float)1.5, - 1, MARKSJULIA, NOFRACTAL, MARKSMANDELFP, NOSYM, - MarksLambdaFractal, marksmandel_per_pixel, MandellongSetup, - StandardFractal, - STDBAILOUT - }, - - { - t_marksjulia+1, - {realparm, imagparm, exponent, ""}, - {0.1, 0.9, 1, 0}, - HT_MARKS, HF_MARKSJULIA, WINFRAC+BAILTEST, - (float)-2.0, (float)2.0, (float)-1.5, (float)1.5, - 1, NOFRACTAL, MARKSMANDEL, MARKSJULIAFP, ORIGIN, - MarksLambdaFractal, julia_per_pixel, MarksJuliaSetup, StandardFractal, - STDBAILOUT - }, - - { - t_unity+1, - {"", "", "", ""}, - {0, 0, 0, 0}, - HT_UNITY, HF_UNITY, WINFRAC, - (float)-2.0, (float)2.0, (float)-1.5, (float)1.5, - 1, NOFRACTAL, NOFRACTAL, UNITYFP, XYAXIS, - UnityFractal, long_julia_per_pixel, UnitySetup, StandardFractal, - NOBAILOUT - }, - - { - t_mandel4+1, - {realz0, imagz0, "", ""}, - {0, 0, 0, 0}, - HT_MANDJUL4, HF_MANDEL4, WINFRAC+BAILTEST, - (float)-2.0, (float)2.0, (float)-1.5, (float)1.5, - 1, JULIA4, NOFRACTAL, MANDEL4FP, XAXIS_NOPARM, - Mandel4Fractal, mandel_per_pixel, MandellongSetup, StandardFractal, - STDBAILOUT - }, - - { - t_julia4+1, - {realparm, imagparm, "", ""}, - {0.6, 0.55, 0, 0}, - HT_MANDJUL4, HF_JULIA4, WINFRAC+OKJB+BAILTEST, - (float)-2.0, (float)2.0, (float)-1.5, (float)1.5, - 1, NOFRACTAL, MANDEL4, JULIA4FP, ORIGIN, - Mandel4Fractal, julia_per_pixel, JulialongSetup, StandardFractal, - STDBAILOUT - }, - - { - "ifs", - {color_method, "", "", ""}, - {0, 0, 0, 0}, - HT_IFS, -4, NOGUESS+NOTRACE+NORESUME+WINFRAC+INFCALC, - (float)-8.0, (float)8.0, (float)-1.0, (float)11.0, - 16, NOFRACTAL, NOFRACTAL, NOFRACTAL, NOSYM, - NULL, NULL, StandaloneSetup, ifs, - NOBAILOUT - }, - - { - t_ifs3d, - {color_method, "", "", ""}, - {0, 0, 0, 0}, - HT_IFS, -4, NOGUESS+NOTRACE+NORESUME+WINFRAC+PARMS3D+INFCALC, - (float)-11.0, (float)11.0, (float)-11.0, (float)11.0, - 16, NOFRACTAL, NOFRACTAL, NOFRACTAL, NOSYM, - NULL, NULL, StandaloneSetup, ifs, - NOBAILOUT - }, - - { - t_barnsleym3+1, - {realz0, imagz0, "", ""}, - {0, 0, 0, 0}, - HT_BARNS, HF_BARNSM3, WINFRAC+BAILTEST, - (float)-2.0, (float)2.0, (float)-1.5, (float)1.5, - 1, BARNSLEYJ3,NOFRACTAL, BARNSLEYM3FP, XAXIS_NOPARM, - Barnsley3Fractal, long_mandel_per_pixel, MandellongSetup, - StandardFractal, - STDBAILOUT - }, - - { - t_barnsleyj3+1, - {realparm, imagparm, "", ""}, - {0.1, 0.36, 0, 0}, - HT_BARNS, HF_BARNSJ3, WINFRAC+OKJB+BAILTEST, - (float)-2.0, (float)2.0, (float)-1.5, (float)1.5, - 1, NOFRACTAL, BARNSLEYM3, BARNSLEYJ3FP, NOSYM, - Barnsley3Fractal, long_julia_per_pixel, JulialongSetup, StandardFractal, - STDBAILOUT - }, - - { - t_fn_zz_+1, - {"", "", "", ""}, - {0, 0, 0, 0}, - HT_SCOTSKIN, HF_FNZTIMESZ, TRIG1+WINFRAC+BAILTEST, - (float)-4.0, (float)4.0, (float)-3.0, (float)3.0, - 16, NOFRACTAL, NOFRACTAL, TRIGSQRFP, XYAXIS, - TrigZsqrdFractal, julia_per_pixel, JulialongSetup, StandardFractal, - STDBAILOUT - }, - - { - t_fn_zz_, - {"", "", "", ""}, - {0, 0, 0, 0}, - HT_SCOTSKIN, HF_FNZTIMESZ, TRIG1+WINFRAC+BAILTEST, - (float)-4.0, (float)4.0, (float)-3.0, (float)3.0, - 0, NOFRACTAL, NOFRACTAL, TRIGSQR, XYAXIS, - TrigZsqrdfpFractal, juliafp_per_pixel, JuliafpSetup, StandardFractal, - STDBAILOUT - }, - - { - t_bifurcation, - {filt, seed, "", ""}, - {1000.0, 0.66, 0, 0}, - HT_BIF, HF_BIFURCATION, TRIG1+NOGUESS+NOTRACE+NOROTATE+WINFRAC, - (float)1.9, (float)3.0, (float)0.0, (float)1.34, - 0, NOFRACTAL, NOFRACTAL, LBIFURCATION, NOSYM, - BifurcVerhulstTrig, NULL, StandaloneSetup, Bifurcation, - NOBAILOUT - }, - - { - t_fnplusfn, - {recoeftrg1, imcoeftrg1, recoeftrg2, imcoeftrg2}, - {1, 0, 1, 0}, - HT_SCOTSKIN, HF_FNPLUSFN, TRIG2+WINFRAC+BAILTEST, - (float)-4.0, (float)4.0, (float)-3.0, (float)3.0, - 0, NOFRACTAL, NOFRACTAL, TRIGPLUSTRIG, XAXIS, - TrigPlusTrigfpFractal, otherjuliafp_per_pixel, TrigPlusTrigfpSetup, - StandardFractal, - LTRIGBAILOUT - }, - - { - t_fnfn+1, - {"", "", "", ""}, - {0, 0, 0, 0}, - HT_SCOTSKIN, HF_FNTIMESFN, TRIG2+WINFRAC+BAILTEST, - (float)-4.0, (float)4.0, (float)-3.0, (float)3.0, - 16, NOFRACTAL, NOFRACTAL, TRIGXTRIGFP, XAXIS, - TrigXTrigFractal, long_julia_per_pixel, FnXFnSetup, StandardFractal, - LTRIGBAILOUT - }, - - { - t_fnfn, - {"", "", "", ""}, - {0, 0, 0, 0}, - HT_SCOTSKIN, HF_FNTIMESFN, TRIG2+WINFRAC+BAILTEST, - (float)-4.0, (float)4.0, (float)-3.0, (float)3.0, - 0, NOFRACTAL, NOFRACTAL, TRIGXTRIG, XAXIS, - TrigXTrigfpFractal, otherjuliafp_per_pixel, FnXFnSetup, StandardFractal, - LTRIGBAILOUT - }, - - { - t_sqr_1divfn_+1, - {"", "", "", ""}, - {0, 0, 0, 0}, - HT_SCOTSKIN, HF_SQROVFN, TRIG1+WINFRAC+BAILTEST, - (float)-4.0, (float)4.0, (float)-3.0, (float)3.0, - 16, NOFRACTAL, NOFRACTAL, SQR1OVERTRIGFP, NOSYM, - Sqr1overTrigFractal, long_julia_per_pixel, SqrTrigSetup, - StandardFractal, - LTRIGBAILOUT - }, - - { - t_sqr_1divfn_, - {"", "", "", ""}, - {0, 0, 0, 0}, - HT_SCOTSKIN, HF_SQROVFN, TRIG1+WINFRAC+BAILTEST, - (float)-4.0, (float)4.0, (float)-3.0, (float)3.0, - 0, NOFRACTAL, NOFRACTAL, SQR1OVERTRIG, NOSYM, - Sqr1overTrigfpFractal, otherjuliafp_per_pixel, SqrTrigSetup, - StandardFractal, - LTRIGBAILOUT - }, - - { - t_fnzplusz+1, - {recoeftrg1, imcoeftrg1, "Real Coefficient Second Term", "Imag Coefficient Second Term"}, - {1, 0, 1, 0}, - HT_SCOTSKIN, HF_FNXZPLUSZ, TRIG1+WINFRAC+BAILTEST, - (float)-4.0, (float)4.0, (float)-3.0, (float)3.0, - 1, NOFRACTAL, NOFRACTAL, ZXTRIGPLUSZFP, XAXIS, - ZXTrigPlusZFractal, julia_per_pixel, ZXTrigPlusZSetup, StandardFractal, - LTRIGBAILOUT - }, - - { - t_fnzplusz, - {recoeftrg1, imcoeftrg1, "Real Coefficient Second Term", "Imag Coefficient Second Term"}, - {1, 0, 1, 0}, - HT_SCOTSKIN, HF_FNXZPLUSZ, TRIG1+WINFRAC+BAILTEST, - (float)-4.0, (float)4.0, (float)-3.0, (float)3.0, - 0, NOFRACTAL, NOFRACTAL, ZXTRIGPLUSZ, XAXIS, - ZXTrigPlusZfpFractal, juliafp_per_pixel, ZXTrigPlusZSetup, - StandardFractal, - LTRIGBAILOUT - }, - - { - t_kamtorus, - {kamangle, kamstep, kamstop, pointsperorbit}, - {1.3, .05, 1.5, 150}, - HT_KAM, HF_KAM, NOGUESS+NOTRACE+WINFRAC, - (float)-1.0, (float)1.0, (float)-.75, (float).75, - 0, NOFRACTAL, NOFRACTAL, KAM, NOSYM, - (VF)kamtorusfloatorbit, NULL, orbit3dfloatsetup, orbit2dfloat, - NOBAILOUT - }, - - { - t_kamtorus+1, - {kamangle, kamstep, kamstop, pointsperorbit}, - {1.3, .05, 1.5, 150}, - HT_KAM, HF_KAM, NOGUESS+NOTRACE+WINFRAC, - (float)-1.0, (float)1.0, (float)-.75, (float).75, - 16, NOFRACTAL, NOFRACTAL, KAMFP, NOSYM, - (VF)kamtoruslongorbit, NULL, orbit3dlongsetup, orbit2dlong, - NOBAILOUT - }, - - { - t_kamtorus3d, - {kamangle, kamstep, kamstop, pointsperorbit}, - {1.3, .05, 1.5, 150}, - HT_KAM, HF_KAM, NOGUESS+NOTRACE+NORESUME+WINFRAC+PARMS3D, - (float)-3.0, (float)3.0, (float)-1.0, (float)3.5, - 0, NOFRACTAL, NOFRACTAL, KAM3D, NOSYM, - (VF)kamtorusfloatorbit, NULL, orbit3dfloatsetup, orbit3dfloat, - NOBAILOUT - }, - - { - t_kamtorus3d+1, - {kamangle, kamstep, kamstop, pointsperorbit}, - {1.3, .05, 1.5, 150}, - HT_KAM, HF_KAM, NOGUESS+NOTRACE+NORESUME+WINFRAC+PARMS3D, - (float)-3.0, (float)3.0, (float)-1.0, (float)3.5, - 16, NOFRACTAL, NOFRACTAL, KAM3DFP, NOSYM, - (VF)kamtoruslongorbit, NULL, orbit3dlongsetup, orbit3dlong, - NOBAILOUT - }, - - { - t_lambdafn+1, - {realparm, imagparm, "", ""}, - {1.0, 0.4, 0, 0}, - HT_LAMBDAFN, HF_LAMBDAFN, TRIG1+WINFRAC+OKJB, - (float)-4.0, (float)4.0, (float)-3.0, (float)3.0, - 16, NOFRACTAL, MANDELTRIG, LAMBDATRIGFP, PI_SYM, - (VF)LambdaTrigFractal, long_julia_per_pixel, LambdaTrigSetup, - StandardFractal, - LTRIGBAILOUT - }, - - { - t_manfnpluszsqrd+1, - {realz0, imagz0, "", ""}, - {0, 0, 0, 0}, - HT_PICKMJ, HF_MANDFNPLUSZSQRD, TRIG1+WINFRAC+BAILTEST, - (float)-2.5, (float)1.5, (float)-1.5, (float)1.5, - 16, LJULTRIGPLUSZSQRD, NOFRACTAL, FPMANTRIGPLUSZSQRD, XAXIS_NOPARM, - TrigPlusZsquaredFractal, mandel_per_pixel, MandellongSetup, - StandardFractal, - STDBAILOUT - }, - - { - t_julfnpluszsqrd+1, - {realparm, imagparm, "", ""}, - {-0.5, 0.5, 0, 0}, - HT_PICKMJ, HF_JULFNPLUSZSQRD, TRIG1+WINFRAC+OKJB+BAILTEST, - (float)-2.0, (float)2.0, (float)-1.5, (float)1.5, - 16, NOFRACTAL, LMANTRIGPLUSZSQRD, FPJULTRIGPLUSZSQRD, NOSYM, - TrigPlusZsquaredFractal, julia_per_pixel, JuliafnPlusZsqrdSetup, - StandardFractal, - STDBAILOUT - }, - - { - t_manfnpluszsqrd, - {realz0, imagz0, "", ""}, - {0, 0, 0, 0}, - HT_PICKMJ, HF_MANDFNPLUSZSQRD, TRIG1+WINFRAC+BAILTEST, - (float)-2.5, (float)1.5, (float)-1.5, (float)1.5, - 0, FPJULTRIGPLUSZSQRD, NOFRACTAL, LMANTRIGPLUSZSQRD, XAXIS_NOPARM, - TrigPlusZsquaredfpFractal, mandelfp_per_pixel, MandelfpSetup, - StandardFractal, - STDBAILOUT - }, - - { - t_julfnpluszsqrd, - {realparm, imagparm, "", ""}, - {-0.5, 0.5, 0, 0}, - HT_PICKMJ, HF_JULFNPLUSZSQRD, TRIG1+WINFRAC+OKJB+BAILTEST, - (float)-2.0, (float)2.0, (float)-1.5, (float)1.5, - 0, NOFRACTAL, FPMANTRIGPLUSZSQRD, LJULTRIGPLUSZSQRD, NOSYM, - TrigPlusZsquaredfpFractal, juliafp_per_pixel, JuliafnPlusZsqrdSetup, - StandardFractal, - STDBAILOUT - }, - - { - t_lambdafn, - {realparm, imagparm, "", ""}, - {1.0, 0.4, 0, 0}, - HT_LAMBDAFN, HF_LAMBDAFN, TRIG1+WINFRAC+OKJB, - (float)-2.0, (float)2.0, (float)-1.5, (float)1.5, - 0, NOFRACTAL, MANDELTRIGFP, LAMBDATRIG, PI_SYM, - LambdaTrigfpFractal, otherjuliafp_per_pixel, LambdaTrigSetup, - StandardFractal, - LTRIGBAILOUT - }, - - { - t_mandelfn+1, - {realz0, imagz0, "", ""}, - {0, 0, 0, 0}, - HT_MANDFN, HF_MANDFN, TRIG1+WINFRAC, - (float)-8.0, (float)8.0, (float)-6.0, (float)6.0, - 16, LAMBDATRIG, NOFRACTAL, MANDELTRIGFP, XYAXIS_NOPARM, - LambdaTrigFractal, long_mandel_per_pixel, MandelTrigSetup, - StandardFractal, - LTRIGBAILOUT - }, - - { - t_manzpower+1, - {realz0, imagz0, exponent, imexponent}, - {0, 0, 2, 0}, - HT_PICKMJ, HF_MANZPOWER, WINFRAC+BAILTEST, - (float)-2.0, (float)2.0, (float)-1.5, (float)1.5, - 1, LJULIAZPOWER, NOFRACTAL, FPMANDELZPOWER, XAXIS_NOIMAG, - longZpowerFractal, long_mandel_per_pixel, MandellongSetup, - StandardFractal, - STDBAILOUT - }, - - { - t_julzpower+1, - {realparm, imagparm, exponent, imexponent}, - {0.3, 0.6, 2, 0}, - HT_PICKMJ, HF_JULZPOWER, WINFRAC+OKJB+BAILTEST, - (float)-2.0, (float)2.0, (float)-1.5, (float)1.5, - 1, NOFRACTAL, LMANDELZPOWER, FPJULIAZPOWER, ORIGIN, - longZpowerFractal, long_julia_per_pixel, JulialongSetup, - StandardFractal, - STDBAILOUT - }, - - { - t_manzpower, - {realz0, imagz0, exponent, imexponent}, - {0, 0, 2, 0}, - HT_PICKMJ, HF_MANZPOWER, WINFRAC+BAILTEST+BF_MATH, - (float)-2.5, (float)1.5, (float)-1.5, (float)1.5, - 0, FPJULIAZPOWER, NOFRACTAL, LMANDELZPOWER, XAXIS_NOIMAG, - floatZpowerFractal, othermandelfp_per_pixel, MandelfpSetup, - StandardFractal, - STDBAILOUT - }, - - { - t_julzpower, - {realparm, imagparm, exponent, imexponent}, - {0.3, 0.6, 2, 0}, - HT_PICKMJ, HF_JULZPOWER, WINFRAC+OKJB+BAILTEST+BF_MATH, - (float)-2.0, (float)2.0, (float)-1.5, (float)1.5, - 0, NOFRACTAL, FPMANDELZPOWER, LJULIAZPOWER, ORIGIN, - floatZpowerFractal, otherjuliafp_per_pixel, JuliafpSetup, - StandardFractal, - STDBAILOUT - }, - - { - "manzzpwr", - {realz0, imagz0, exponent, ""}, - {0, 0, 2, 0}, - HT_PICKMJ, HF_MANZZPWR, WINFRAC+BAILTEST, - (float)-2.5, (float)1.5, (float)-1.5, (float)1.5, - 0, FPJULZTOZPLUSZPWR, NOFRACTAL, NOFRACTAL, XAXIS_NOPARM, - floatZtozPluszpwrFractal, othermandelfp_per_pixel, MandelfpSetup, - StandardFractal, - STDBAILOUT - }, - - { - "julzzpwr", - {realparm, imagparm, exponent, ""}, - {-0.3, 0.3, 2, 0}, - HT_PICKMJ, HF_JULZZPWR, WINFRAC+OKJB+BAILTEST, - (float)-2.0, (float)2.0, (float)-1.5, (float)1.5, - 0, NOFRACTAL, FPMANZTOZPLUSZPWR, NOFRACTAL, NOSYM, - floatZtozPluszpwrFractal, otherjuliafp_per_pixel, JuliafpSetup, - StandardFractal, - STDBAILOUT - }, - - { - t_manfnplusexp+1, - {realz0, imagz0, "", ""}, - {0, 0, 0, 0}, - HT_PICKMJ, HF_MANDFNPLUSEXP, TRIG1+WINFRAC+BAILTEST, - (float)-8.0, (float)8.0, (float)-6.0, (float)6.0, - 16, LJULTRIGPLUSEXP, NOFRACTAL, FPMANTRIGPLUSEXP, XAXIS_NOPARM, - LongTrigPlusExponentFractal, long_mandel_per_pixel, MandellongSetup, - StandardFractal, - STDBAILOUT - }, - - { - t_julfnplusexp+1, - {realparm, imagparm, "", ""}, - {0, 0, 0, 0}, - HT_PICKMJ, HF_JULFNPLUSEXP, TRIG1+WINFRAC+OKJB+BAILTEST, - (float)-4.0, (float)4.0, (float)-3.0, (float)3.0, - 16, NOFRACTAL, LMANTRIGPLUSEXP,FPJULTRIGPLUSEXP, NOSYM, - LongTrigPlusExponentFractal, long_julia_per_pixel, JulialongSetup, - StandardFractal, - STDBAILOUT - }, - - { - t_manfnplusexp, - {realz0, imagz0, "", ""}, - {0, 0, 0, 0}, - HT_PICKMJ, HF_MANDFNPLUSEXP, TRIG1+WINFRAC+BAILTEST, - (float)-8.0, (float)8.0, (float)-6.0, (float)6.0, - 0, FPJULTRIGPLUSEXP, NOFRACTAL, LMANTRIGPLUSEXP, XAXIS_NOPARM, - FloatTrigPlusExponentFractal, othermandelfp_per_pixel, MandelfpSetup, - StandardFractal, - STDBAILOUT - }, - - { - t_julfnplusexp, - {realparm, imagparm, "", ""}, - {0, 0, 0, 0}, - HT_PICKMJ, HF_JULFNPLUSEXP, TRIG1+WINFRAC+OKJB+BAILTEST, - (float)-4.0, (float)4.0, (float)-3.0, (float)3.0, - 0, NOFRACTAL, FPMANTRIGPLUSEXP, LJULTRIGPLUSEXP, NOSYM, - FloatTrigPlusExponentFractal, otherjuliafp_per_pixel, JuliafpSetup, - StandardFractal, - STDBAILOUT - }, - - { - t_popcorn, - {step_x, step_y, constant_x, constant_y}, - {0.05, 0, 3.00, 0}, - HT_POPCORN, HF_POPCORN, NOGUESS+NOTRACE+WINFRAC+TRIG4, - (float)-3.0, (float)3.0, (float)-2.25, (float)2.25, - 0, NOFRACTAL, NOFRACTAL, LPOPCORN, NOPLOT, - PopcornFractalFn, otherjuliafp_per_pixel, JuliafpSetup, popcorn, - STDBAILOUT - }, - - { - t_popcorn+1, - {step_x, step_y, constant_x, constant_y}, - {0.05, 0, 3.00, 0}, - HT_POPCORN, HF_POPCORN, NOGUESS+NOTRACE+WINFRAC+TRIG4, - (float)-3.0, (float)3.0, (float)-2.25, (float)2.25, - 16, NOFRACTAL, NOFRACTAL, FPPOPCORN, NOPLOT, - LPopcornFractalFn, long_julia_per_pixel, JulialongSetup, popcorn, - STDBAILOUT - }, - - { - t_lorenz, - {timestep, "a", "b", "c"}, - {.02, 5, 15, 1}, - HT_LORENZ, HF_LORENZ, NOGUESS+NOTRACE+INFCALC+WINFRAC, - (float)-15.0, (float)15.0, (float)0.0, (float)30.0, - 0, NOFRACTAL, NOFRACTAL, LLORENZ, NOSYM, - (VF)lorenz3dfloatorbit, NULL, orbit3dfloatsetup, orbit2dfloat, - NOBAILOUT - }, - - { - t_lorenz+1, - {timestep, "a", "b", "c"}, - {.02, 5, 15, 1}, - HT_LORENZ, HF_LORENZ, NOGUESS+NOTRACE+INFCALC+WINFRAC, - (float)-15.0, (float)15.0, (float)0.0, (float)30.0, - 16, NOFRACTAL, NOFRACTAL, FPLORENZ, NOSYM, - (VF)lorenz3dlongorbit, NULL, orbit3dlongsetup, orbit2dlong, - NOBAILOUT - }, - - { - t_lorenz3d+1, - {timestep, "a", "b", "c"}, - {.02, 5, 15, 1}, - HT_LORENZ, HF_LORENZ, NOGUESS+NOTRACE+NORESUME+WINFRAC+PARMS3D+INFCALC, - (float)-30.0, (float)30.0, (float)-30.0, (float)30.0, - 16, NOFRACTAL, NOFRACTAL, FPLORENZ3D, NOSYM, - (VF)lorenz3dlongorbit, NULL, orbit3dlongsetup, orbit3dlong, - NOBAILOUT - }, - - { - t_newton+1, - {newtdegree, "", "", ""}, - {3, 0, 0, 0}, - HT_NEWT, HF_NEWT, WINFRAC, - (float)-2.0, (float)2.0, (float)-1.5, (float)1.5, - 0, NOFRACTAL, NOFRACTAL, NEWTON, XAXIS, - MPCNewtonFractal, MPCjulia_per_pixel, NewtonSetup, StandardFractal, - NOBAILOUT - }, - - { - t_newtbasin+1, - {newtdegree, "Enter non-zero value for stripes", "", ""}, - {3, 0, 0, 0}, - HT_NEWTBAS, HF_NEWTBAS, WINFRAC, - (float)-2.0, (float)2.0, (float)-1.5, (float)1.5, - 0, NOFRACTAL, NOFRACTAL, NEWTBASIN, NOSYM, - MPCNewtonFractal, MPCjulia_per_pixel, NewtonSetup, StandardFractal, - NOBAILOUT - }, - - { - "complexnewton", - {"Real part of Degree", "Imag part of Degree", "Real part of Root", "Imag part of Root"}, - {3, 0, 1, 0}, - HT_NEWTCMPLX, HF_COMPLEXNEWT, WINFRAC, - (float)-2.0, (float)2.0, (float)-1.5, (float)1.5, - 0, NOFRACTAL, NOFRACTAL, NOFRACTAL, NOSYM, - ComplexNewton, otherjuliafp_per_pixel, ComplexNewtonSetup, - StandardFractal, - NOBAILOUT - }, - - { - "complexbasin", - {"Real part of Degree", "Imag part of Degree", "Real part of Root", "Imag part of Root"}, - {3, 0, 1, 0}, - HT_NEWTCMPLX, HF_COMPLEXNEWT, WINFRAC, - (float)-2.0, (float)2.0, (float)-1.5, (float)1.5, - 0, NOFRACTAL, NOFRACTAL, NOFRACTAL, NOSYM, - ComplexBasin, otherjuliafp_per_pixel, ComplexNewtonSetup, - StandardFractal, - NOBAILOUT - }, - - { - "cmplxmarksmand", - {realz0, imagz0, exponent, imexponent}, - {0, 0, 1, 0}, - HT_MARKS, HF_CMPLXMARKSMAND, WINFRAC+BAILTEST, - (float)-2.0, (float)2.0, (float)-1.5, (float)1.5, - 0, COMPLEXMARKSJUL, NOFRACTAL, NOFRACTAL, NOSYM, - MarksCplxMand, MarksCplxMandperp, MandelfpSetup, StandardFractal, - STDBAILOUT - }, - - { - "cmplxmarksjul", - {realparm, imagparm, exponent, imexponent}, - {0.3, 0.6, 1, 0}, - HT_MARKS, HF_CMPLXMARKSJUL, WINFRAC+BAILTEST, - (float)-2.0, (float)2.0, (float)-1.5, (float)1.5, - 0, NOFRACTAL, COMPLEXMARKSMAND, NOFRACTAL, NOSYM, - MarksCplxMand, juliafp_per_pixel, JuliafpSetup, StandardFractal, - STDBAILOUT - }, - - { - t_formula+1, - {p1real, p1imag, p2real, p2imag}, - {0, 0, 0, 0}, - HT_FORMULA, -2, WINFRAC+MORE, - (float)-2.0, (float)2.0, (float)-1.5, (float)1.5, - 1, NOFRACTAL, NOFRACTAL, FFORMULA, SETUP_SYM, - Formula, form_per_pixel, intFormulaSetup, StandardFractal, - 0 - }, - - { - t_formula, - {p1real, p1imag, p2real, p2imag}, - {0, 0, 0, 0}, - HT_FORMULA, -2, WINFRAC+MORE, - (float)-2.0, (float)2.0, (float)-1.5, (float)1.5, - 0, NOFRACTAL, NOFRACTAL, FORMULA, SETUP_SYM, - Formula, form_per_pixel, fpFormulaSetup, StandardFractal, - 0 - }, - - { - t_sierpinski, - {"", "", "", ""}, - {0, 0, 0, 0}, - HT_SIER, HF_SIER, WINFRAC, - (float)-4/3, (float)96/45, (float)-0.9, (float)1.7, - 0, NOFRACTAL, NOFRACTAL, SIERPINSKI, NOSYM, - SierpinskiFPFractal, otherjuliafp_per_pixel, SierpinskiFPSetup, - StandardFractal, - 127 - }, - - { - t_lambda, - {realparm, imagparm, "", ""}, - {0.85, 0.6, 0, 0}, - HT_LAMBDA, HF_LAMBDA, WINFRAC+OKJB+BAILTEST, - (float)-2.0, (float)2.0, (float)-1.5, (float)1.5, - 0, NOFRACTAL, MANDELLAMBDAFP, LAMBDA, NOSYM, - LambdaFPFractal, juliafp_per_pixel, JuliafpSetup, StandardFractal, - STDBAILOUT - }, - - { - t_barnsleym1, - {realz0, imagz0, "", ""}, - {0, 0, 0, 0}, - HT_BARNS, HF_BARNSM1, WINFRAC+BAILTEST, - (float)-2.0, (float)2.0, (float)-1.5, (float)1.5, - 0, BARNSLEYJ1FP,NOFRACTAL, BARNSLEYM1, XYAXIS_NOPARM, - Barnsley1FPFractal, othermandelfp_per_pixel, MandelfpSetup, - StandardFractal, - STDBAILOUT - }, - - { - t_barnsleyj1, - {realparm, imagparm, "", ""}, - {0.6, 1.1, 0, 0}, - HT_BARNS, HF_BARNSJ1, WINFRAC+OKJB+BAILTEST, - (float)-2.0, (float)2.0, (float)-1.5, (float)1.5, - 0, NOFRACTAL, BARNSLEYM1FP, BARNSLEYJ1, ORIGIN, - Barnsley1FPFractal, otherjuliafp_per_pixel, JuliafpSetup, - StandardFractal, - STDBAILOUT - }, - - { - t_barnsleym2, - {realz0, imagz0, "", ""}, - {0, 0, 0, 0}, - HT_BARNS, HF_BARNSM2, WINFRAC+BAILTEST, - (float)-2.0, (float)2.0, (float)-1.5, (float)1.5, - 0, BARNSLEYJ2FP,NOFRACTAL, BARNSLEYM2, YAXIS_NOPARM, - Barnsley2FPFractal, othermandelfp_per_pixel, MandelfpSetup, - StandardFractal, - STDBAILOUT - }, - - { - t_barnsleyj2, - {realparm, imagparm, "", ""}, - {0.6, 1.1, 0, 0}, - HT_BARNS, HF_BARNSJ2, WINFRAC+OKJB+BAILTEST, - (float)-2.0, (float)2.0, (float)-1.5, (float)1.5, - 0, NOFRACTAL, BARNSLEYM2FP, BARNSLEYJ2, ORIGIN, - Barnsley2FPFractal, otherjuliafp_per_pixel, JuliafpSetup, - StandardFractal, - STDBAILOUT - }, - - { - t_barnsleym3, - {realz0, imagz0, "", ""}, - {0, 0, 0, 0}, - HT_BARNS, HF_BARNSM3, WINFRAC+BAILTEST, - (float)-2.0, (float)2.0, (float)-1.5, (float)1.5, - 0, BARNSLEYJ3FP, NOFRACTAL, BARNSLEYM3, XAXIS_NOPARM, - Barnsley3FPFractal, othermandelfp_per_pixel, MandelfpSetup, - StandardFractal, - STDBAILOUT - }, - - { - t_barnsleyj3, - {realparm, imagparm, "", ""}, - {0.6, 1.1, 0, 0}, - HT_BARNS, HF_BARNSJ3, WINFRAC+OKJB+BAILTEST, - (float)-2.0, (float)2.0, (float)-1.5, (float)1.5, - 0, NOFRACTAL, BARNSLEYM3FP, BARNSLEYJ3, NOSYM, - Barnsley3FPFractal, otherjuliafp_per_pixel, JuliafpSetup, - StandardFractal, - STDBAILOUT - }, - - { - t_mandellambda, - {realz0, imagz0, "", ""}, - {0, 0, 0, 0}, - HT_MLAMBDA, HF_MLAMBDA, WINFRAC+BAILTEST, - (float)-3.0, (float)5.0, (float)-3.0, (float)3.0, - 0, LAMBDAFP, NOFRACTAL, MANDELLAMBDA, XAXIS_NOPARM, - LambdaFPFractal, mandelfp_per_pixel, MandelfpSetup, StandardFractal, - STDBAILOUT - }, - - { - t_julibrot+1, - {"", "", "", ""}, - {0, 0, 0, 0}, - HT_JULIBROT, -1, NOGUESS+NOTRACE+NOROTATE+NORESUME+WINFRAC, - (float)-2.0, (float)2.0, (float)-1.5, (float)1.5, - 1, NOFRACTAL, NOFRACTAL, JULIBROTFP, NOSYM, - JuliaFractal, jb_per_pixel, JulibrotSetup, Std4dFractal, - STDBAILOUT - }, - - { - t_lorenz3d, - {timestep, "a", "b", "c"}, - {.02, 5, 15, 1}, - HT_LORENZ, HF_LORENZ, NOGUESS+NOTRACE+NORESUME+WINFRAC+PARMS3D+INFCALC, - (float)-30.0, (float)30.0, (float)-30.0, (float)30.0, - 0, NOFRACTAL, NOFRACTAL, LLORENZ3D, NOSYM, - (VF)lorenz3dfloatorbit, NULL, orbit3dfloatsetup, orbit3dfloat, - NOBAILOUT - }, - - { - t_rossler3d+1, - {timestep, "a", "b", "c"}, - {.04, .2, .2, 5.7}, - HT_ROSS, HF_ROSS, NOGUESS+NOTRACE+NORESUME+WINFRAC+PARMS3D+INFCALC, - (float)-30.0, (float)30.0, (float)-20.0, (float)40.0, - 16, NOFRACTAL, NOFRACTAL, FPROSSLER, NOSYM, - (VF)rosslerlongorbit, NULL, orbit3dlongsetup, orbit3dlong, - NOBAILOUT - }, - - { - t_rossler3d, - {timestep, "a", "b", "c"}, - {.04, .2, .2, 5.7}, - HT_ROSS, HF_ROSS, NOGUESS+NOTRACE+NORESUME+WINFRAC+PARMS3D+INFCALC, - (float)-30.0, (float)30.0, (float)-20.0, (float)40.0, - 0, NOFRACTAL, NOFRACTAL, LROSSLER, NOSYM, - (VF)rosslerfloatorbit, NULL, orbit3dfloatsetup, orbit3dfloat, - NOBAILOUT - }, - - { - t_henon+1, - {"a", "b", "", ""}, - {1.4, .3, 0, 0}, - HT_HENON, HF_HENON, NOGUESS+NOTRACE+INFCALC+WINFRAC, - (float)-1.4, (float)1.4, (float)-.5, (float).5, - 16, NOFRACTAL, NOFRACTAL, FPHENON, NOSYM, - (VF)henonlongorbit, NULL, orbit3dlongsetup, orbit2dlong, - NOBAILOUT - }, - - { - t_henon, - {"a", "b", "", ""}, - {1.4, .3, 0, 0}, - HT_HENON, HF_HENON, NOGUESS+NOTRACE+INFCALC+WINFRAC, - (float)-1.4, (float)1.4, (float)-.5, (float).5, - 0, NOFRACTAL, NOFRACTAL, LHENON, NOSYM, - (VF)henonfloatorbit, NULL, orbit3dfloatsetup, orbit2dfloat, - NOBAILOUT - }, - - { - "pickover", - {"a", "b", "c", "d"}, - {2.24, .43, -.65, -2.43}, - HT_PICK, HF_PICKOVER, NOGUESS+NOTRACE+NORESUME+WINFRAC+PARMS3D, - (float)-8/3, (float)8/3, (float)-2, (float)2, - 0, NOFRACTAL, NOFRACTAL, NOFRACTAL, NOSYM, - (VF)pickoverfloatorbit, NULL, orbit3dfloatsetup, orbit3dfloat, - NOBAILOUT - }, - - { - "gingerbreadman", - {"Initial x", "Initial y", "", ""}, - {-.1, 0, 0, 0}, - HT_GINGER, HF_GINGER, NOGUESS+NOTRACE+INFCALC+WINFRAC, - (float)-4.5, (float)8.5, (float)-4.5, (float)8.5, - 0, NOFRACTAL, NOFRACTAL, NOFRACTAL, NOSYM, - (VF)gingerbreadfloatorbit, NULL, orbit3dfloatsetup, orbit2dfloat, - NOBAILOUT - }, - - { - "diffusion", - {"+Border size", - "+Type (0=Central,1=Falling,2=Square Cavity)", - "+Color change rate (0=Random)", - "" - }, - {10, 0, 0, 0}, - HT_DIFFUS, HF_DIFFUS, NOZOOM+NOGUESS+NOTRACE+WINFRAC, - (float)-2.0, (float)2.0, (float)-1.5, (float)1.5, - 0, NOFRACTAL, NOFRACTAL, NOFRACTAL, NOSYM, - NULL, NULL, StandaloneSetup, diffusion, - NOBAILOUT - }, - - { - t_unity, - {"", "", "", ""}, - {0, 0, 0, 0}, - HT_UNITY, HF_UNITY, WINFRAC, - (float)-2.0, (float)2.0, (float)-1.5, (float)1.5, - 0, NOFRACTAL, NOFRACTAL, UNITY, XYAXIS, - UnityfpFractal, otherjuliafp_per_pixel, StandardSetup, StandardFractal, - NOBAILOUT - }, - - { - t_spider, - {realz0, imagz0, "", ""}, - {0, 0, 0, 0}, - HT_SCOTSKIN, HF_SPIDER, WINFRAC+BAILTEST, - (float)-2.5, (float)1.5, (float)-1.5, (float)1.5, - 0, NOFRACTAL, NOFRACTAL, SPIDER, XAXIS_NOPARM, - SpiderfpFractal, mandelfp_per_pixel, MandelfpSetup, StandardFractal, - STDBAILOUT - }, - - { - t_spider+1, - {realz0, imagz0, "", ""}, - {0, 0, 0, 0}, - HT_SCOTSKIN, HF_SPIDER, WINFRAC+BAILTEST, - (float)-2.5, (float)1.5, (float)-1.5, (float)1.5, - 1, NOFRACTAL, NOFRACTAL, SPIDERFP, XAXIS_NOPARM, - SpiderFractal, mandel_per_pixel, MandellongSetup,StandardFractal, - STDBAILOUT - }, - - { - "tetrate", - {realz0, imagz0, "", ""}, - {0, 0, 0, 0}, - HT_SCOTSKIN, HF_TETRATE, WINFRAC+BAILTEST, - (float)-2.0, (float)2.0, (float)-1.5, (float)1.5, - 0, NOFRACTAL, NOFRACTAL, NOFRACTAL, XAXIS_NOIMAG, - TetratefpFractal, othermandelfp_per_pixel, MandelfpSetup, - StandardFractal, - STDBAILOUT - }, - - { - "magnet1m", - {realz0, imagz0, "", ""}, - {0, 0, 0, 0}, - HT_MAGNET, HF_MAGM1, WINFRAC, - (float)-4.0, (float)4.0, (float)-3.0, (float)3.0, - 0, MAGNET1J,NOFRACTAL,NOFRACTAL, XAXIS_NOPARM, - Magnet1Fractal, mandelfp_per_pixel, MandelfpSetup, StandardFractal, - 100 - }, - - { - "magnet1j", - {realparm, imagparm, "", ""}, - {0, 0, 0, 0}, - HT_MAGNET, HF_MAGJ1, WINFRAC, - (float)-8.0, (float)8.0, (float)-6.0, (float)6.0, - 0, NOFRACTAL,MAGNET1M,NOFRACTAL, XAXIS_NOIMAG, - Magnet1Fractal, juliafp_per_pixel, JuliafpSetup, StandardFractal, - 100 - }, - - { - "magnet2m", - {realz0, imagz0, "", ""}, - {0, 0, 0, 0}, - HT_MAGNET, HF_MAGM2, WINFRAC, - (float)-1.5, (float)3.7, (float)-1.95, (float)1.95, - 0, MAGNET2J, NOFRACTAL, NOFRACTAL, XAXIS_NOPARM, - Magnet2Fractal, mandelfp_per_pixel, MandelfpSetup, StandardFractal, - 100 - }, - - { - "magnet2j", - {realparm, imagparm, "", ""}, - {0, 0, 0, 0}, - HT_MAGNET, HF_MAGJ2, WINFRAC, - (float)-8.0, (float)8.0, (float)-6.0, (float)6.0, - 0, NOFRACTAL, MAGNET2M, NOFRACTAL, XAXIS_NOIMAG, - Magnet2Fractal, juliafp_per_pixel, JuliafpSetup, StandardFractal, - 100 - }, - - { - t_bifurcation+1, - {filt, seed, "", ""}, - {1000.0, 0.66, 0, 0}, - HT_BIF, HF_BIFURCATION, TRIG1+NOGUESS+NOTRACE+NOROTATE+WINFRAC, - (float)1.9, (float)3.0, (float)0.0, (float)1.34, - 1, NOFRACTAL, NOFRACTAL, BIFURCATION, NOSYM, - LongBifurcVerhulstTrig, NULL, StandaloneSetup, Bifurcation, - NOBAILOUT - }, - - { - t_biflambda+1, - {filt, seed, "", ""}, - {1000.0, 0.66, 0, 0}, - HT_BIF, HF_BIFLAMBDA, TRIG1+NOGUESS+NOTRACE+NOROTATE+WINFRAC, - (float)-2.0, (float)4.0, (float)-1.0, (float)2.0, - 1, NOFRACTAL, NOFRACTAL, BIFLAMBDA, NOSYM, - LongBifurcLambdaTrig, NULL, StandaloneSetup, Bifurcation, - NOBAILOUT - }, - - { - t_biflambda, - {filt, seed, "", ""}, - {1000.0, 0.66, 0, 0}, - HT_BIF, HF_BIFLAMBDA, TRIG1+NOGUESS+NOTRACE+NOROTATE+WINFRAC, - (float)-2.0, (float)4.0, (float)-1.0, (float)2.0, - 0, NOFRACTAL, NOFRACTAL, LBIFLAMBDA, NOSYM, - BifurcLambdaTrig, NULL, StandaloneSetup, Bifurcation, - NOBAILOUT - }, - - { - t_bifplussinpi, - {filt, seed, "", ""}, - {1000.0, 0.66, 0, 0}, - HT_BIF, HF_BIFPLUSSINPI, TRIG1+NOGUESS+NOTRACE+NOROTATE+WINFRAC, - (float)0.275, (float)1.45, (float)0.0, (float)2.0, - 0, NOFRACTAL, NOFRACTAL, LBIFADSINPI, NOSYM, - BifurcAddTrigPi, NULL, StandaloneSetup, Bifurcation, - NOBAILOUT - }, - - { - t_bifeqsinpi, - {filt, seed, "", ""}, - {1000.0, 0.66, 0, 0}, - HT_BIF, HF_BIFEQSINPI, TRIG1+NOGUESS+NOTRACE+NOROTATE+WINFRAC, - (float)-2.5, (float)2.5, (float)-3.5, (float)3.5, - 0, NOFRACTAL, NOFRACTAL, LBIFEQSINPI, NOSYM, - BifurcSetTrigPi, NULL, StandaloneSetup, Bifurcation, - NOBAILOUT - }, - - { - t_popcornjul, - {step_x, step_y, constant_x, constant_y}, - {0.05, 0, 3.00, 0}, - HT_POPCORN, HF_POPCJUL, WINFRAC+TRIG4, - (float)-3.0, (float)3.0, (float)-2.25, (float)2.25, - 0, NOFRACTAL, NOFRACTAL, LPOPCORNJUL, NOSYM, - PopcornFractalFn, otherjuliafp_per_pixel, JuliafpSetup,StandardFractal, - STDBAILOUT - }, - - { - t_popcornjul+1, - {step_x, step_y, constant_x, constant_y}, - {0.05, 0, 3.0, 0}, - HT_POPCORN, HF_POPCJUL, WINFRAC+TRIG4, - (float)-3.0, (float)3.0, (float)-2.25, (float)2.25, - 16, NOFRACTAL, NOFRACTAL, FPPOPCORNJUL, NOSYM, - LPopcornFractalFn, long_julia_per_pixel, JulialongSetup, StandardFractal, - STDBAILOUT - }, - - { - "lsystem", - {"+Order", "", "", ""}, - {2, 0, 0, 0}, - HT_LSYS, -3, NOZOOM+NORESUME+NOGUESS+NOTRACE+WINFRAC, - (float)-1.0, (float)1.0, (float)-1.0, (float)1.0, - 1, NOFRACTAL, NOFRACTAL, NOFRACTAL, NOSYM, - NULL, NULL, StandaloneSetup, Lsystem, - NOBAILOUT - }, - - { - t_manowarj, - {realparm, imagparm, "", ""}, - {0, 0, 0, 0}, - HT_SCOTSKIN, HF_MANOWARJ, WINFRAC+OKJB+BAILTEST, - (float)-2.5, (float)1.5, (float)-1.5, (float)1.5, - 0, NOFRACTAL, MANOWARFP, MANOWARJ, NOSYM, - ManOWarfpFractal, juliafp_per_pixel, JuliafpSetup, StandardFractal, - STDBAILOUT - }, - - { - t_manowarj+1, - {realparm, imagparm, "", ""}, - {0, 0, 0, 0}, - HT_SCOTSKIN, HF_MANOWARJ, WINFRAC+OKJB+BAILTEST, - (float)-2.5, (float)1.5, (float)-1.5, (float)1.5, - 1, NOFRACTAL, MANOWAR, MANOWARJFP, NOSYM, - ManOWarFractal, julia_per_pixel, JulialongSetup, StandardFractal, - STDBAILOUT - }, - - { - t_fn_z_plusfn_pix_, - {realz0, imagz0, recoeftrg2, imcoeftrg2}, - {0, 0, 1, 0}, - HT_SCOTSKIN, HF_FNPLUSFNPIX, TRIG2+WINFRAC+BAILTEST, - (float)-3.6, (float)3.6, (float)-2.7, (float)2.7, - 0, NOFRACTAL, NOFRACTAL, FNPLUSFNPIXLONG, NOSYM, - Richard8fpFractal, otherrichard8fp_per_pixel, MandelfpSetup, - StandardFractal, - LTRIGBAILOUT - }, - - { - t_fn_z_plusfn_pix_+1, - {realz0, imagz0, recoeftrg2, imcoeftrg2}, - {0, 0, 1, 0}, - HT_SCOTSKIN, HF_FNPLUSFNPIX, TRIG2+WINFRAC+BAILTEST, - (float)-3.6, (float)3.6, (float)-2.7, (float)2.7, - 1, NOFRACTAL, NOFRACTAL, FNPLUSFNPIXFP, NOSYM, - Richard8Fractal, long_richard8_per_pixel, MandellongSetup, - StandardFractal, - LTRIGBAILOUT - }, - - { - t_marksmandelpwr, - {realz0, imagz0, "", ""}, - {0, 0, 0, 0}, - HT_MARKS, HF_MARKSMANDPWR, TRIG1+WINFRAC+BAILTEST, - (float)-2.5, (float)1.5, (float)-1.5, (float)1.5, - 0, NOFRACTAL, NOFRACTAL, MARKSMANDELPWR, XAXIS_NOPARM, - MarksMandelPwrfpFractal, marks_mandelpwrfp_per_pixel, MandelfpSetup, - StandardFractal, - STDBAILOUT - }, - - { - t_marksmandelpwr+1, - {realz0, imagz0, "", ""}, - {0, 0, 0, 0}, - HT_MARKS, HF_MARKSMANDPWR, TRIG1+WINFRAC+BAILTEST, - (float)-2.5, (float)1.5, (float)-1.5, (float)1.5, - 1, NOFRACTAL, NOFRACTAL, MARKSMANDELPWRFP, XAXIS_NOPARM, - MarksMandelPwrFractal, marks_mandelpwr_per_pixel, MandellongSetup, - StandardFractal, - STDBAILOUT - }, - - { - t_tims_error, - {realz0, imagz0, "", ""}, - {0, 0, 0, 0}, - HT_MARKS, HF_TIMSERR, WINFRAC+TRIG1+BAILTEST, - (float)-2.9, (float)4.3, (float)-2.7, (float)2.7, - 0, NOFRACTAL, NOFRACTAL, TIMSERROR, XAXIS_NOPARM, - TimsErrorfpFractal, marks_mandelpwrfp_per_pixel, MandelfpSetup, - StandardFractal, - STDBAILOUT - }, - - { - t_tims_error+1, - {realz0, imagz0, "", ""}, - {0, 0, 0, 0}, - HT_MARKS, HF_TIMSERR, WINFRAC+TRIG1+BAILTEST, - (float)-2.9, (float)4.3, (float)-2.7, (float)2.7, - 1, NOFRACTAL, NOFRACTAL, TIMSERRORFP, XAXIS_NOPARM, - TimsErrorFractal, marks_mandelpwr_per_pixel, MandellongSetup, - StandardFractal, - STDBAILOUT - }, - - { - t_bifeqsinpi+1, - {filt, seed, "", ""}, - {1000.0, 0.66, 0, 0}, - HT_BIF, HF_BIFEQSINPI, TRIG1+NOGUESS+NOTRACE+NOROTATE+WINFRAC, - (float)-2.5, (float)2.5, (float)-3.5, (float)3.5, - 1, NOFRACTAL, NOFRACTAL, BIFEQSINPI, NOSYM, - LongBifurcSetTrigPi, NULL, StandaloneSetup, Bifurcation, - NOBAILOUT - }, - - { - t_bifplussinpi+1, - {filt, seed, "", ""}, - {1000.0, 0.66, 0, 0}, - HT_BIF, HF_BIFPLUSSINPI, TRIG1+NOGUESS+NOTRACE+NOROTATE+WINFRAC, - (float)0.275, (float)1.45, (float)0.0, (float)2.0, - 1, NOFRACTAL, NOFRACTAL, BIFADSINPI, NOSYM, - LongBifurcAddTrigPi, NULL, StandaloneSetup, Bifurcation, - NOBAILOUT - }, - - { - t_bifstewart, - {filt, seed, "", ""}, - {1000.0, 0.66, 0, 0}, - HT_BIF, HF_BIFSTEWART, TRIG1+NOGUESS+NOTRACE+NOROTATE+WINFRAC, - (float)0.7, (float)2.0, (float)-1.1, (float)1.1, - 0, NOFRACTAL, NOFRACTAL, LBIFSTEWART, NOSYM, - BifurcStewartTrig, NULL, StandaloneSetup, Bifurcation, - NOBAILOUT - }, - - { - t_bifstewart+1, - {filt, seed, "", ""}, - {1000.0, 0.66, 0, 0}, - HT_BIF, HF_BIFSTEWART, TRIG1+NOGUESS+NOTRACE+NOROTATE+WINFRAC, - (float)0.7, (float)2.0, (float)-1.1, (float)1.1, - 1, NOFRACTAL, NOFRACTAL, BIFSTEWART, NOSYM, - LongBifurcStewartTrig, NULL, StandaloneSetup, Bifurcation, - NOBAILOUT - }, - - { - "hopalong", - {"a", "b", "c", ""}, - {.4, 1, 0, 0}, - HT_MARTIN, HF_HOPALONG, NOGUESS+NOTRACE+INFCALC+WINFRAC, - (float)-2.0, (float)3.0, (float)-1.625, (float)2.625, - 0, NOFRACTAL, NOFRACTAL, NOFRACTAL, NOSYM, - (VF)hopalong2dfloatorbit, NULL, orbit3dfloatsetup, orbit2dfloat, - NOBAILOUT - }, - - { - "circle", - {"magnification", "", "", ""}, - {200000L, 0, 0, 0}, - HT_CIRCLE, HF_CIRCLE, WINFRAC, - (float)-2.0, (float)2.0, (float)-1.5, (float)1.5, - 0, NOFRACTAL, NOFRACTAL, NOFRACTAL, XYAXIS, - CirclefpFractal, juliafp_per_pixel, JuliafpSetup, StandardFractal, - NOBAILOUT - }, - - { - "martin", - {"a", "", "", ""}, - {3.14, 0, 0, 0}, - HT_MARTIN, HF_MARTIN, NOGUESS+NOTRACE+INFCALC+WINFRAC, - (float)-32, (float)32, (float)-24, (float)24, - 0, NOFRACTAL, NOFRACTAL, NOFRACTAL, NOSYM, - (VF)martin2dfloatorbit, NULL, orbit3dfloatsetup, orbit2dfloat, - NOBAILOUT - }, - - { - "lyapunov", - {"+Order (integer)", "Population Seed", "+Filter Cycles", ""}, - {0, 0.5, 0, 0}, - HT_LYAPUNOV, HT_LYAPUNOV, WINFRAC, - (float)-8.0, (float)8.0, (float)-6.0, (float)6.0, - 0, NOFRACTAL, NOFRACTAL, NOFRACTAL, NOSYM, - BifurcLambda, NULL, lya_setup, lyapunov, - NOBAILOUT - }, - - { - "lorenz3d1", - {timestep, "a", "b", "c"}, - {.02, 5, 15, 1}, - HT_LORENZ, HF_LORENZ3D1, - NOGUESS+NOTRACE+NORESUME+WINFRAC+PARMS3D+INFCALC, - (float)-30.0, (float)30.0, (float)-30.0, (float)30.0, - 0, NOFRACTAL, NOFRACTAL, NOFRACTAL, NOSYM, - (VF)lorenz3d1floatorbit, NULL, orbit3dfloatsetup, orbit3dfloat, - NOBAILOUT - }, - - { - "lorenz3d3", - {timestep, "a", "b", "c"}, - {.02, 10, 28, 2.66}, - HT_LORENZ, HF_LORENZ3D3, - NOGUESS+NOTRACE+NORESUME+WINFRAC+PARMS3D+INFCALC, - (float)-30.0, (float)30.0, (float)-30.0, (float)30.0, - 0, NOFRACTAL, NOFRACTAL, NOFRACTAL, NOSYM, - (VF)lorenz3d3floatorbit, NULL, orbit3dfloatsetup, orbit3dfloat, - NOBAILOUT - }, - - { - "lorenz3d4", - {timestep, "a", "b", "c"}, - {.02, 10, 28, 2.66}, - HT_LORENZ, HF_LORENZ3D4, - NOGUESS+NOTRACE+NORESUME+WINFRAC+PARMS3D+INFCALC, - (float)-30.0, (float)30.0, (float)-30.0, (float)30.0, - 0, NOFRACTAL, NOFRACTAL, NOFRACTAL, NOSYM, - (VF)lorenz3d4floatorbit, NULL, orbit3dfloatsetup, orbit3dfloat, - NOBAILOUT - }, - - { - t_lambda_fnorfn_+1, - {realparm, imagparm, "Function Shift Value", ""}, - {1, 0.1, 1, 0}, - HT_FNORFN, HF_LAMBDAFNFN, TRIG2+WINFRAC+BAILTEST, - (float)-4.0, (float)4.0, (float)-3.0, (float)3.0, - 16, NOFRACTAL, LMANLAMFNFN, FPLAMBDAFNFN, ORIGIN, - LambdaTrigOrTrigFractal, long_julia_per_pixel, LambdaTrigOrTrigSetup, - StandardFractal, - LTRIGBAILOUT - }, - - { - t_lambda_fnorfn_, - {realparm, imagparm, "Function Shift Value", ""}, - {1, 0.1, 1, 0}, - HT_FNORFN, HF_LAMBDAFNFN, TRIG2+WINFRAC+BAILTEST, - (float)-4.0, (float)4.0, (float)-3.0, (float)3.0, - 0, NOFRACTAL, FPMANLAMFNFN, LLAMBDAFNFN, ORIGIN, - LambdaTrigOrTrigfpFractal, otherjuliafp_per_pixel, - LambdaTrigOrTrigSetup, StandardFractal, - LTRIGBAILOUT - }, - - { - t_julia_fnorfn_+1, - {realparm, imagparm, "Function Shift Value", ""}, - {0, 0, 8, 0}, - HT_FNORFN, HF_JULIAFNFN, TRIG2+WINFRAC+BAILTEST, - (float)-4.0, (float)4.0, (float)-3.0, (float)3.0, - 16, NOFRACTAL, LMANFNFN, FPJULFNFN, XAXIS, - JuliaTrigOrTrigFractal, long_julia_per_pixel, JuliaTrigOrTrigSetup, - StandardFractal, - LTRIGBAILOUT - }, - - { - t_julia_fnorfn_, - {realparm, imagparm, "Function Shift Value", ""}, - {0, 0, 8, 0}, - HT_FNORFN, HF_JULIAFNFN, TRIG2+WINFRAC+BAILTEST, - (float)-4.0, (float)4.0, (float)-3.0, (float)3.0, - 0, NOFRACTAL, FPMANFNFN, LJULFNFN, XAXIS, - JuliaTrigOrTrigfpFractal, otherjuliafp_per_pixel, - JuliaTrigOrTrigSetup, StandardFractal, - LTRIGBAILOUT - }, - - { - t_manlam_fnorfn_+1, - {realz0, imagz0, "Function Shift Value", ""}, - {0, 0, 10, 0}, - HT_FNORFN, HF_MANLAMFNFN, TRIG2+WINFRAC+BAILTEST, - (float)-4.0, (float)4.0, (float)-3.0, (float)3.0, - 16, LLAMBDAFNFN, NOFRACTAL, FPMANLAMFNFN, XAXIS_NOPARM, - LambdaTrigOrTrigFractal, long_mandel_per_pixel, - ManlamTrigOrTrigSetup, StandardFractal, - LTRIGBAILOUT - }, - - { - t_manlam_fnorfn_, - {realz0, imagz0, "Function Shift Value", ""}, - {0, 0, 10, 0}, - HT_FNORFN, HF_MANLAMFNFN, TRIG2+WINFRAC+BAILTEST, - (float)-4.0, (float)4.0, (float)-3.0, (float)3.0, - 0, FPLAMBDAFNFN, NOFRACTAL, LMANLAMFNFN, XAXIS_NOPARM, - LambdaTrigOrTrigfpFractal, othermandelfp_per_pixel, - ManlamTrigOrTrigSetup, StandardFractal, - LTRIGBAILOUT - }, - - { - t_mandel_fnorfn_+1, - {realz0, imagz0, "Function Shift Value", ""}, - {0, 0, 0.5, 0}, - HT_FNORFN, HF_MANDELFNFN, TRIG2+WINFRAC+BAILTEST, - (float)-4.0, (float)4.0, (float)-3.0, (float)3.0, - 16, LJULFNFN, NOFRACTAL, FPMANFNFN,XAXIS_NOPARM, - JuliaTrigOrTrigFractal, long_mandel_per_pixel, - MandelTrigOrTrigSetup, StandardFractal, - LTRIGBAILOUT - }, - - { - t_mandel_fnorfn_, - {realz0, imagz0, "Function Shift Value", ""}, - {0, 0, 0.5, 0}, - HT_FNORFN, HF_MANDELFNFN, TRIG2+WINFRAC+BAILTEST, - (float)-4.0, (float)4.0, (float)-3.0, (float)3.0, - 0, FPJULFNFN, NOFRACTAL, LMANFNFN,XAXIS_NOPARM, - JuliaTrigOrTrigfpFractal, othermandelfp_per_pixel, - MandelTrigOrTrigSetup, StandardFractal, - LTRIGBAILOUT - }, - - { - t_bifmay+1, - {filt, seed, "Beta >= 2", ""}, - {300.0, 0.9, 5, 0}, - HT_BIF, HF_BIFMAY, NOGUESS+NOTRACE+NOROTATE+WINFRAC, - (float)-3.5, (float)-0.9, (float)-0.5, (float)3.2, - 16, NOFRACTAL, NOFRACTAL, BIFMAY, NOSYM, - LongBifurcMay, NULL, BifurcMaySetup, Bifurcation, - NOBAILOUT - }, - - { - t_bifmay, - {filt, seed, "Beta >= 2", ""}, - {300.0, 0.9, 5, 0}, - HT_BIF, HF_BIFMAY, NOGUESS+NOTRACE+NOROTATE+WINFRAC, - (float)-3.5, (float)-0.9, (float)-0.5, (float)3.2, - 0, NOFRACTAL, NOFRACTAL, LBIFMAY, NOSYM, - BifurcMay, NULL, BifurcMaySetup, Bifurcation, - NOBAILOUT - }, - - { - t_halley+1, - {order, real_relax, epsilon, imag_relax}, - {6, 1.0, 0.0001, 0}, - HT_HALLEY, HF_HALLEY, WINFRAC, - (float)-2.0, (float)2.0, (float)-1.5, (float)1.5, - 0, NOFRACTAL, NOFRACTAL, HALLEY, XYAXIS, - MPCHalleyFractal, MPCHalley_per_pixel, HalleySetup, StandardFractal, - NOBAILOUT - }, - - { - t_halley, - {order, real_relax, epsilon, imag_relax}, - {6, 1.0, 0.0001, 0}, - HT_HALLEY, HF_HALLEY, WINFRAC, - (float)-2.0, (float)2.0, (float)-1.5, (float)1.5, - 0, NOFRACTAL, NOFRACTAL, MPHALLEY, XYAXIS, - HalleyFractal, Halley_per_pixel, HalleySetup, StandardFractal, - NOBAILOUT - }, - - { - "dynamic", - {"+# of intervals (<0 = connect)", "time step (<0 = Euler)", "a", "b"}, - {50, .1, 1, 3}, - HT_DYNAM, HF_DYNAM, NOGUESS+NOTRACE+WINFRAC+TRIG1, - (float)-20.0, (float)20.0, (float)-20.0, (float)20.0, - 0, NOFRACTAL, NOFRACTAL, NOFRACTAL, NOSYM, - (VF)dynamfloat, NULL, dynam2dfloatsetup, dynam2dfloat, - NOBAILOUT - }, - - { - "quat", - {"notused", "notused", "cj", "ck"}, - {0, 0, 0, 0}, - HT_QUAT, HF_QUAT, WINFRAC+OKJB, - (float)-2.0, (float)2.0, (float)-1.5, (float)1.5, - 0, QUATJULFP, NOFRACTAL, NOFRACTAL, XAXIS, - QuaternionFPFractal, quaternionfp_per_pixel, MandelfpSetup, - StandardFractal, - LTRIGBAILOUT - }, - - { - "quatjul", - {"c1", "ci", "cj", "ck"}, - {-.745, 0, .113, .05}, - HT_QUAT, HF_QUATJ, WINFRAC+OKJB+MORE, - (float)-2.0, (float)2.0, (float)-1.5, (float)1.5, - 0, NOFRACTAL, QUATFP, NOFRACTAL, ORIGIN, - QuaternionFPFractal, quaternionjulfp_per_pixel, JuliafpSetup, - StandardFractal, - LTRIGBAILOUT - }, - - { - "cellular", - {cell_init, cell_rule, cell_type, cell_strt}, - {11.0, 3311100320.0, 41.0, 0}, - HT_CELLULAR, HF_CELLULAR, NOGUESS+NOTRACE+NOZOOM+WINFRAC, - (float)-1.0, (float)1.0, (float)-1.0, (float)1.0, - 0, NOFRACTAL, NOFRACTAL, NOFRACTAL, NOSYM, - NULL, NULL, CellularSetup, cellular, - NOBAILOUT - }, - - { - t_julibrot, - {"", "", "", ""}, - {0, 0, 0, 0}, - HT_JULIBROT, -1, NOGUESS+NOTRACE+NOROTATE+NORESUME+WINFRAC, - (float)-2.0, (float)2.0, (float)-1.5, (float)1.5, - 0, NOFRACTAL, NOFRACTAL, JULIBROT, NOSYM, - JuliafpFractal, jbfp_per_pixel, JulibrotSetup, Std4dfpFractal, - STDBAILOUT - }, - -#ifdef RANDOM_RUN - { - t_julia_inverse+1, - {realparm, imagparm, s_maxhits, "Random Run Interval"}, - {-0.11, 0.6557, 4, 1024}, - HT_INVERSE, HF_INVERSE, NOGUESS+NOTRACE+INFCALC+NORESUME, - (float)-2.0, (float)2.0, (float)-1.5, (float)1.5, - 24, NOFRACTAL, MANDEL, INVERSEJULIAFP, NOSYM, - Linverse_julia_orbit, NULL, orbit3dlongsetup, inverse_julia_per_image, - NOBAILOUT - }, - - { - t_julia_inverse, - {realparm, imagparm, s_maxhits, "Random Run Interval"}, - {-0.11, 0.6557, 4, 1024}, - HT_INVERSE, HF_INVERSE, NOGUESS+NOTRACE+INFCALC+NORESUME, - (float)-2.0, (float)2.0, (float)-1.5, (float)1.5, - 0, NOFRACTAL, MANDEL, INVERSEJULIA, NOSYM, - Minverse_julia_orbit, NULL, orbit3dfloatsetup, inverse_julia_per_image, - NOBAILOUT - }, -#else - { - t_julia_inverse+1, - {realparm, imagparm, s_maxhits, ""}, - {-0.11, 0.6557, 4, 1024}, - HT_INVERSE, HF_INVERSE, NOGUESS+NOTRACE+INFCALC+NORESUME, - (float)-2.0, (float)2.0, (float)-1.5, (float)1.5, - 24, NOFRACTAL, MANDEL, INVERSEJULIAFP, NOSYM, - Linverse_julia_orbit, NULL, orbit3dlongsetup, inverse_julia_per_image, - NOBAILOUT - }, - - { - t_julia_inverse, - {realparm, imagparm, s_maxhits, ""}, - {-0.11, 0.6557, 4, 1024}, - HT_INVERSE, HF_INVERSE, NOGUESS+NOTRACE+INFCALC+NORESUME, - (float)-2.0, (float)2.0, (float)-1.5, (float)1.5, - 0, NOFRACTAL, MANDEL, INVERSEJULIA, NOSYM, - Minverse_julia_orbit, NULL, orbit3dfloatsetup, inverse_julia_per_image, - NOBAILOUT - }, - -#endif - - { - "mandelcloud", - {"+# of intervals (<0 = connect)", "", "", ""}, - {50, 0, 0, 0}, - HT_MANDELCLOUD, HF_MANDELCLOUD, NOGUESS+NOTRACE+WINFRAC, - (float)-2.5, (float)1.5, (float)-1.5, (float)1.5, - 0, NOFRACTAL, NOFRACTAL, NOFRACTAL, NOSYM, - (VF)mandelcloudfloat, NULL, dynam2dfloatsetup, dynam2dfloat, - NOBAILOUT - }, - - { - t_phoenix+1, - {p1real, p2real, degreeZ, ""}, - {0.56667, -0.5, 0, 0}, - HT_PHOENIX, HF_PHOENIX, WINFRAC+BAILTEST, - (float)-2.0, (float)2.0, (float)-1.5, (float)1.5, - 1, NOFRACTAL, MANDPHOENIX, PHOENIXFP, XAXIS, - LongPhoenixFractal, long_phoenix_per_pixel, PhoenixSetup, - StandardFractal, - STDBAILOUT - }, - - { - t_phoenix, - {p1real, p2real, degreeZ, ""}, - {0.56667, -0.5, 0, 0}, - HT_PHOENIX, HF_PHOENIX, WINFRAC+BAILTEST, - (float)-2.0, (float)2.0, (float)-1.5, (float)1.5, - 0, NOFRACTAL, MANDPHOENIXFP, PHOENIX, XAXIS, - PhoenixFractal, phoenix_per_pixel, PhoenixSetup, StandardFractal, - STDBAILOUT - }, - - { - t_mandphoenix+1, - {realz0, imagz0, degreeZ, ""}, - {0.0, 0.0, 0, 0}, - HT_PHOENIX, HF_MANDPHOENIX, WINFRAC+BAILTEST, - (float)-2.5, (float)1.5, (float)-1.5, (float)1.5, - 1, PHOENIX, NOFRACTAL, MANDPHOENIXFP, NOSYM, - LongPhoenixFractal, long_mandphoenix_per_pixel, MandPhoenixSetup, - StandardFractal, - STDBAILOUT - }, - - { - t_mandphoenix, - {realz0, imagz0, degreeZ, ""}, - {0.0, 0.0, 0, 0}, - HT_PHOENIX, HF_MANDPHOENIX, WINFRAC+BAILTEST, - (float)-2.5, (float)1.5, (float)-1.5, (float)1.5, - 0, PHOENIXFP, NOFRACTAL, MANDPHOENIX, NOSYM, - PhoenixFractal, mandphoenix_per_pixel, MandPhoenixSetup, - StandardFractal, - STDBAILOUT - }, - - { - "hypercomplex", - {"notused", "notused", "cj", "ck"}, - {0, 0, 0, 0}, - HT_HYPERC, HF_HYPERC, WINFRAC+OKJB+TRIG1, - (float)-2.0, (float)2.0, (float)-1.5, (float)1.5, - 0, HYPERCMPLXJFP, NOFRACTAL, NOFRACTAL, XAXIS, - HyperComplexFPFractal, quaternionfp_per_pixel, MandelfpSetup, - StandardFractal, - LTRIGBAILOUT - }, - - { - "hypercomplexj", - {"c1", "ci", "cj", "ck"}, - {-.745, 0, .113, .05}, - HT_HYPERC, HF_HYPERCJ, WINFRAC+OKJB+TRIG1+MORE, - (float)-2.0, (float)2.0, (float)-1.5, (float)1.5, - 0, NOFRACTAL, HYPERCMPLXFP, NOFRACTAL, ORIGIN, - HyperComplexFPFractal, quaternionjulfp_per_pixel, JuliafpSetup, - StandardFractal, - LTRIGBAILOUT - }, - - { - t_frothybasin+1, - {frothmapping, frothshade, frothavalue, ""}, - {1, 0, 1.028713768218725, 0}, - HT_FROTH, HF_FROTH, NOTRACE+WINFRAC, - (float)-2.8, (float)2.8, (float)-2.355, (float)1.845, - 28, NOFRACTAL, NOFRACTAL, FROTHFP, NOSYM, - froth_per_orbit, froth_per_pixel, froth_setup, calcfroth, - FROTHBAILOUT - }, - - { - t_frothybasin, - {frothmapping, frothshade, frothavalue, ""}, - {1, 0, 1.028713768218725, 0}, - HT_FROTH, HF_FROTH, NOTRACE+WINFRAC, - (float)-2.8, (float)2.8, (float)-2.355, (float)1.845, - 0, NOFRACTAL, NOFRACTAL, FROTH, NOSYM, - froth_per_orbit, froth_per_pixel, froth_setup, calcfroth, - FROTHBAILOUT - }, - - { - t_mandel4, - {realz0, imagz0, "", ""}, - {0, 0, 0, 0}, - HT_MANDJUL4, HF_MANDEL4, WINFRAC+BAILTEST, - (float)-2.0, (float)2.0, (float)-1.5, (float)1.5, - 0, JULIA4FP, NOFRACTAL, MANDEL4, XAXIS_NOPARM, - Mandel4fpFractal, mandelfp_per_pixel, MandelfpSetup, StandardFractal, - STDBAILOUT - }, - - { - t_julia4, - {realparm, imagparm, "", ""}, - {0.6, 0.55, 0, 0}, - HT_MANDJUL4, HF_JULIA4, WINFRAC+OKJB+BAILTEST, - (float)-2.0, (float)2.0, (float)-1.5, (float)1.5, - 0, NOFRACTAL, MANDEL4FP, JULIA4, ORIGIN, - Mandel4fpFractal, juliafp_per_pixel, JuliafpSetup,StandardFractal, - STDBAILOUT - }, - - { - t_marksmandel, - {realz0, imagz0, exponent, ""}, - {0, 0, 1, 0}, - HT_MARKS, HF_MARKSMAND, WINFRAC+BAILTEST, - (float)-2.0, (float)2.0, (float)-1.5, (float)1.5, - 0, MARKSJULIAFP, NOFRACTAL, MARKSMANDEL, NOSYM, - MarksLambdafpFractal, marksmandelfp_per_pixel, MandelfpSetup, - StandardFractal, - STDBAILOUT - }, - - { - t_marksjulia, - {realparm, imagparm, exponent, ""}, - {0.1, 0.9, 1, 0}, - HT_MARKS, HF_MARKSJULIA, WINFRAC+BAILTEST, - (float)-2.0, (float)2.0, (float)-1.5, (float)1.5, - 0, NOFRACTAL, MARKSMANDELFP, MARKSJULIA, ORIGIN, - MarksLambdafpFractal, juliafp_per_pixel, MarksJuliafpSetup, - StandardFractal, - STDBAILOUT - }, - - /* dmf */ - { - "icons", - {"Lambda", "Alpha", "Beta", "Gamma"}, - {-2.34, 2.0, 0.2, 0.1}, - HT_ICON, HF_ICON, NOGUESS+NOTRACE+WINFRAC+INFCALC+MORE, - (float)-2.0, (float)2.0, (float)-1.5, (float)1.5, - 0, NOFRACTAL, NOFRACTAL, NOFRACTAL, NOSYM, - (VF)iconfloatorbit, NULL, orbit3dfloatsetup, orbit2dfloat, - NOBAILOUT - }, - - /* dmf */ - { - "icons3d", - {"Lambda", "Alpha", "Beta", "Gamma"}, - {-2.34, 2.0, 0.2, 0.1}, - HT_ICON, HF_ICON, NOGUESS+NOTRACE+WINFRAC+INFCALC+PARMS3D+MORE, - (float)-2.0, (float)2.0, (float)-1.5, (float)1.5, - 0, NOFRACTAL, NOFRACTAL, NOFRACTAL, NOSYM, - (VF)iconfloatorbit, NULL, orbit3dfloatsetup, orbit3dfloat, - NOBAILOUT - }, - - { - t_phoenixcplx+1, - {p1real, p1imag, p2real, p2imag}, - {0.2, 0, 0.3, 0}, - HT_PHOENIX, HF_PHOENIXCPLX, WINFRAC+MORE+BAILTEST, - (float)-2.0, (float)2.0, (float)-1.5, (float)1.5, - 1, NOFRACTAL, MANDPHOENIXCPLX,PHOENIXFPCPLX, ORIGIN, - LongPhoenixFractalcplx, long_phoenix_per_pixel, PhoenixCplxSetup, - StandardFractal, - STDBAILOUT - }, - - { - t_phoenixcplx, - {p1real, p1imag, p2real, p2imag}, - {0.2, 0, 0.3, 0}, - HT_PHOENIX, HF_PHOENIXCPLX, WINFRAC+MORE+BAILTEST, - (float)-2.0, (float)2.0, (float)-1.5, (float)1.5, - 0, NOFRACTAL, MANDPHOENIXFPCPLX, PHOENIXCPLX, ORIGIN, - PhoenixFractalcplx, phoenix_per_pixel, PhoenixCplxSetup, - StandardFractal, - STDBAILOUT - }, - - { - t_mandphoenixcplx+1, - {realz0, imagz0, p2real, p2imag}, - {0, 0, 0.5, 0}, - HT_PHOENIX, HF_MANDPHOENIXCPLX, WINFRAC+MORE+BAILTEST, - (float)-2.5, (float)1.5, (float)-1.5, (float)1.5, - 1, PHOENIXCPLX, NOFRACTAL, MANDPHOENIXFPCPLX, XAXIS, - LongPhoenixFractalcplx, long_mandphoenix_per_pixel, - MandPhoenixCplxSetup, StandardFractal, - STDBAILOUT - }, - - { - t_mandphoenixcplx, - {realz0, imagz0, p2real, p2imag}, - {0, 0, 0.5, 0}, - HT_PHOENIX, HF_MANDPHOENIXCPLX, WINFRAC+MORE+BAILTEST, - (float)-2.5, (float)1.5, (float)-1.5, (float)1.5, - 0, PHOENIXFPCPLX, NOFRACTAL, MANDPHOENIXCPLX, XAXIS, - PhoenixFractalcplx, mandphoenix_per_pixel, MandPhoenixCplxSetup, - StandardFractal, - STDBAILOUT - }, - - { - "ant", - {"#Rule String (1's and non-1's, 0 rand)", - "#Maxpts", - "+Numants (max 256)", - "+Ant type (1 or 2)" - }, - {1100, 1.0E9, 1, 1}, - HT_ANT, HF_ANT, WINFRAC+NOZOOM+NOGUESS+NOTRACE+NORESUME+MORE, - (float)-1.0, (float)1.0, (float)-1.0, (float)1.0, - 0, NOFRACTAL, NOFRACTAL, NOFRACTAL, NOSYM, - NULL, NULL, StandaloneSetup, ant, - NOBAILOUT - }, - - { - "chip", - {"a", "b", "c", ""}, - {-15,-19,1,0}, - HT_MARTIN, HF_CHIP, NOGUESS+NOTRACE+INFCALC+WINFRAC, - (float)-760.0, (float)760.0, (float)-570.0, (float)570.0, - 0, NOFRACTAL, NOFRACTAL, NOFRACTAL, NOSYM, - (VF)chip2dfloatorbit, NULL, orbit3dfloatsetup, orbit2dfloat, - NOBAILOUT - }, - - { - "quadruptwo", - {"a", "b", "c", ""}, - {34, 1, 5, 0}, - HT_MARTIN, HF_QUADRUPTWO, NOGUESS+NOTRACE+INFCALC+WINFRAC, - (float)-82.93367, (float)112.2749, (float)-55.76383, (float)90.64257, - 0, NOFRACTAL, NOFRACTAL, NOFRACTAL, NOSYM, - (VF)quadruptwo2dfloatorbit, NULL, orbit3dfloatsetup, orbit2dfloat, - NOBAILOUT - }, - - { - "threeply", - {"a", "b", "c", ""}, - {-55, -1, -42, 0}, - HT_MARTIN, HF_THREEPLY, NOGUESS+NOTRACE+INFCALC+WINFRAC, - (float)-8000.0, (float)8000.0, (float)-6000.0, (float)6000.0, - 0, NOFRACTAL, NOFRACTAL, NOFRACTAL, NOSYM, - (VF)threeply2dfloatorbit, NULL, orbit3dfloatsetup, orbit2dfloat, - NOBAILOUT - }, - - { - "volterra-lotka", - {"h", "p", "", ""}, - {0.739, 0.739, 0, 0}, - HT_VL, HF_VL, WINFRAC, - (float)0.0, (float)6.0, (float)0.0, (float)4.5, - 0, NOFRACTAL, NOFRACTAL, NOFRACTAL, NOSYM, - VLfpFractal, otherjuliafp_per_pixel, VLSetup, StandardFractal, - 256 - }, - - { - "escher_julia", - {realparm, imagparm, "", ""}, - {0.32, 0.043, 0, 0}, - HT_ESCHER, HF_ESCHER, WINFRAC, - (float)-1.6, (float)1.6, (float)-1.2, (float)1.2, - 0, NOFRACTAL, NOFRACTAL, NOFRACTAL, ORIGIN, - EscherfpFractal, juliafp_per_pixel, StandardSetup, - StandardFractal, - STDBAILOUT - }, - -/* From Pickovers' "Chaos in Wonderland" */ -/* included by Humberto R. Baptista */ -/* code adapted from king.cpp bt James Rankin */ - - { - "latoocarfian", - {"a", "b", "c", "d"}, - {-0.966918, 2.879879, 0.765145, 0.744728}, - HT_LATOO, HF_LATOO, NOGUESS+NOTRACE+WINFRAC+INFCALC+MORE+TRIG4, - (float)-2.0, (float)2.0, (float)-1.5, (float)1.5, - 0, NOFRACTAL, NOFRACTAL, NOFRACTAL, NOSYM, - (VF)latoofloatorbit, NULL, orbit3dfloatsetup, orbit2dfloat, - NOBAILOUT - }, -#if 0 - { - "mandelbrotmix4", - {p1real, p1imag, p2real, p2imag}, - {0.05, 3, -1.5, -2}, - HT_MANDELBROTMIX4, HF_MANDELBROTMIX4, WINFRAC+BAILTEST+TRIG1+MORE, - (float)-2.5, (float)1.5, (float)-1.5, (float)1.5, - 0, NOFRACTAL, NOFRACTAL, NOFRACTAL, NOSYM, - MandelbrotMix4fpFractal, MandelbrotMix4fp_per_pixel, MandelbrotMix4Setup, StandardFractal, - STDBAILOUT - }, -#endif - { - NULL, /* marks the END of the list */ - {NULL, NULL, NULL, NULL}, - {0, 0, 0, 0}, - -1, -1, 0, - (float)0.0, (float)0.0, (float)0.0, (float)0.0, - 0, NOFRACTAL, NOFRACTAL, NOFRACTAL, NOSYM, - NULL, NULL, NULL, NULL, - 0 - } -}; - -int num_fractal_types = (sizeof(fractalspecific)/ - sizeof(struct fractalspecificstuff)) -1; - -/* - * Returns 1 if the formula parameter is not used in the current - * formula. If the parameter is used, or not a formula fractal, - * a 0 is returned. Note: this routine only works for formula types. - */ -int paramnotused(int parm) -{ - int ret = 0; - - /* sanity check */ - if (fractype != FORMULA && fractype != FFORMULA) - return (0); - - switch (parm/2) { - case 0: - if (!uses_p1) - ret = 1; - break; - case 1: - if (!uses_p2) - ret = 1; - break; - case 2: - if (!uses_p3) - ret = 1; - break; - case 3: - if (!uses_p4) - ret = 1; - break; - case 4: - if (!uses_p5) - ret = 1; - break; - default: - ret = 0; - break; - } - return (ret); -} - -/* - * Returns 1 if parameter number parm exists for type. If the - * parameter exists, the parameter prompt string is copied to buf. - * Pass in NULL for buf if only the existence of the parameter is - * needed, and not the prompt string. - */ -int typehasparm(int type,int parm,char *buf) -{ - int extra; - char *ret = NULL; - if (0 <= parm && parm < 4) - ret=fractalspecific[type].param[parm]; - else if (parm >= 4 && parm < MAXPARAMS) - if ((extra=find_extra_param(type)) > -1) - ret=moreparams[extra].param[parm-4]; - if (ret) - if (*ret == 0) - ret = NULL; - - if (type == FORMULA || type == FFORMULA) - if (paramnotused(parm)) - ret = NULL; - - if (ret && buf != NULL) - strcpy(buf,ret); - return(ret?1:0); -} diff --git a/fractint/common/fractals.c b/fractint/common/fractals.c deleted file mode 100644 index 615f5470c..000000000 --- a/fractint/common/fractals.c +++ /dev/null @@ -1,3494 +0,0 @@ -/* -FRACTALS.C, FRACTALP.C and CALCFRAC.C actually calculate the fractal -images (well, SOMEBODY had to do it!). The modules are set up so that -all logic that is independent of any fractal-specific code is in -CALCFRAC.C, the code that IS fractal-specific is in FRACTALS.C, and the -structure that ties (we hope!) everything together is in FRACTALP.C. -Original author Tim Wegner, but just about ALL the authors have -contributed SOME code to this routine at one time or another, or -contributed to one of the many massive restructurings. - -The Fractal-specific routines are divided into three categories: - -1. Routines that are called once-per-orbit to calculate the orbit - value. These have names like "XxxxFractal", and their function - pointers are stored in fractalspecific[fractype].orbitcalc. EVERY - new fractal type needs one of these. Return 0 to continue iterations, - 1 if we're done. Results for integer fractals are left in 'lnew.x' and - 'lnew.y', for floating point fractals in 'new.x' and 'new.y'. - -2. Routines that are called once per pixel to set various variables - prior to the orbit calculation. These have names like xxx_per_pixel - and are fairly generic - chances are one is right for your new type. - They are stored in fractalspecific[fractype].per_pixel. - -3. Routines that are called once per screen to set various variables. - These have names like XxxxSetup, and are stored in - fractalspecific[fractype].per_image. - -4. The main fractal routine. Usually this will be StandardFractal(), - but if you have written a stand-alone fractal routine independent - of the StandardFractal mechanisms, your routine name goes here, - stored in fractalspecific[fractype].calctype.per_image. - -Adding a new fractal type should be simply a matter of adding an item -to the 'fractalspecific' structure, writing (or re-using one of the existing) -an appropriate setup, per_image, per_pixel, and orbit routines. - --------------------------------------------------------------------- */ - -#include -#include -#if !defined(__386BSD__) -#if !defined(_WIN32) -#include -#endif -#endif - /* see Fractint.c for a description of the "include" hierarchy */ -#include "port.h" -#include "prototyp.h" -#include "helpdefs.h" -#include "fractype.h" -#include "externs.h" - - -#define NEWTONDEGREELIMIT 100 - -_LCMPLX lcoefficient,lold,lnew,lparm, linit,ltmp,ltmp2,lparm2; -long ltempsqrx,ltempsqry; -int maxcolor; -int root, degree,basin; -double floatmin,floatmax; -double roverd, d1overd, threshold; -_CMPLX tmp2; -_CMPLX coefficient; -_CMPLX staticroots[16]; /* roots array for degree 16 or less */ -_CMPLX *roots = staticroots; -struct MPC *MPCroots; -long FgHalf; -_CMPLX pwr; -int bitshiftless1; /* bit shift less 1 */ - -#ifndef sqr -#define sqr(x) ((x)*(x)) -#endif - -#ifndef lsqr -#define lsqr(x) (multiply((x),(x),bitshift)) -#endif - -#define modulus(z) (sqr((z).x)+sqr((z).y)) -#define conjugate(pz) ((pz)->y = 0.0 - (pz)->y) -#define distance(z1,z2) (sqr((z1).x-(z2).x)+sqr((z1).y-(z2).y)) -#define pMPsqr(z) (*pMPmul((z),(z))) -#define MPdistance(z1,z2) (*pMPadd(pMPsqr(*pMPsub((z1).x,(z2).x)),pMPsqr(*pMPsub((z1).y,(z2).y)))) - -double twopi = PI*2.0; -int c_exp; - - -/* These are local but I don't want to pass them as parameters */ -_CMPLX parm,parm2; -_CMPLX *floatparm; -_LCMPLX *longparm; /* used here and in jb.c */ - -/* -------------------------------------------------------------------- */ -/* These variables are external for speed's sake only */ -/* -------------------------------------------------------------------- */ - -double sinx,cosx; -double siny,cosy; -double tmpexp; -double tempsqrx,tempsqry; - -double foldxinitx,foldyinity,foldxinity,foldyinitx; -long oldxinitx,oldyinity,oldxinity,oldyinitx; -long longtmp; - -/* These are for quaternions */ -double qc,qci,qcj,qck; - -/* temporary variables for trig use */ -long lcosx, lsinx; -long lcosy, lsiny; - -/* -** details of finite attractors (required for Magnet Fractals) -** (can also be used in "coloring in" the lakes of Julia types) -*/ - -/* -** pre-calculated values for fractal types Magnet2M & Magnet2J -*/ -_CMPLX T_Cm1; /* 3 * (floatparm - 1) */ -_CMPLX T_Cm2; /* 3 * (floatparm - 2) */ -_CMPLX T_Cm1Cm2; /* (floatparm - 1) * (floatparm - 2) */ - -void FloatPreCalcMagnet2(void) /* precalculation for Magnet2 (M & J) for speed */ - { - T_Cm1.x = floatparm->x - 1.0; T_Cm1.y = floatparm->y; - T_Cm2.x = floatparm->x - 2.0; T_Cm2.y = floatparm->y; - T_Cm1Cm2.x = (T_Cm1.x * T_Cm2.x) - (T_Cm1.y * T_Cm2.y); - T_Cm1Cm2.y = (T_Cm1.x * T_Cm2.y) + (T_Cm1.y * T_Cm2.x); - T_Cm1.x += T_Cm1.x + T_Cm1.x; T_Cm1.y += T_Cm1.y + T_Cm1.y; - T_Cm2.x += T_Cm2.x + T_Cm2.x; T_Cm2.y += T_Cm2.y + T_Cm2.y; - } - -/* -------------------------------------------------------------------- */ -/* Bailout Routines Macros */ -/* -------------------------------------------------------------------- */ - -int ( *floatbailout)(void); -int ( *longbailout)(void); -int ( *bignumbailout)(void); -int ( *bigfltbailout)(void); - -#if 0 -int fpMODbailout(void) -{ - if ( ( magnitude = ( tempsqrx=sqr(g_new.x) ) - + ( tempsqry=sqr(g_new.y) ) ) >= rqlim ) return 1; - old = g_new; - return 0; -} -#endif -int fpMODbailout(void) -{ - tempsqrx=sqr(g_new.x); - tempsqry=sqr(g_new.y); - magnitude = tempsqrx + tempsqry; - if (magnitude >= rqlim) return 1; - old = g_new; - return 0; -} - -int fpREALbailout(void) -{ - tempsqrx=sqr(g_new.x); - tempsqry=sqr(g_new.y); - magnitude = tempsqrx + tempsqry; - if (tempsqrx >= rqlim) return 1; - old = g_new; - return 0; -} - -int fpIMAGbailout(void) -{ - tempsqrx=sqr(g_new.x); - tempsqry=sqr(g_new.y); - magnitude = tempsqrx + tempsqry; - if (tempsqry >= rqlim) return 1; - old = g_new; - return 0; -} - -int fpORbailout(void) -{ - tempsqrx=sqr(g_new.x); - tempsqry=sqr(g_new.y); - magnitude = tempsqrx + tempsqry; - if (tempsqrx >= rqlim || tempsqry >= rqlim) return 1; - old = g_new; - return 0; -} - -int fpANDbailout(void) -{ - tempsqrx=sqr(g_new.x); - tempsqry=sqr(g_new.y); - magnitude = tempsqrx + tempsqry; - if (tempsqrx >= rqlim && tempsqry >= rqlim) return 1; - old = g_new; - return 0; -} - -int fpMANHbailout(void) -{ - double manhmag; - tempsqrx=sqr(g_new.x); - tempsqry=sqr(g_new.y); - magnitude = tempsqrx + tempsqry; - manhmag = fabs(g_new.x) + fabs(g_new.y); - if ((manhmag * manhmag) >= rqlim) return 1; - old = g_new; - return 0; -} - -int fpMANRbailout(void) -{ - double manrmag; - tempsqrx=sqr(g_new.x); - tempsqry=sqr(g_new.y); - magnitude = tempsqrx + tempsqry; - manrmag = g_new.x + g_new.y; /* don't need abs() since we square it next */ - if ((manrmag * manrmag) >= rqlim) return 1; - old = g_new; - return 0; -} - -#define FLOATTRIGBAILOUT() \ - if (fabs(old.y) >= rqlim2) return 1; - -#define LONGTRIGBAILOUT() \ - if (labs(lold.y) >= llimit2) { return 1;} - -#define LONGXYTRIGBAILOUT() \ - if (labs(lold.x) >= llimit2 || labs(lold.y) >= llimit2)\ - { return 1;} - -#define FLOATXYTRIGBAILOUT() \ - if (fabs(old.x) >= rqlim2 || fabs(old.y) >= rqlim2) return 1; - -#define FLOATHTRIGBAILOUT() \ - if (fabs(old.x) >= rqlim2) return 1; - -#define LONGHTRIGBAILOUT() \ - if (labs(lold.x) >= llimit2) { return 1;} - -#define TRIG16CHECK(X) \ - if (labs((X)) > l16triglim) { return 1;} - -#define OLD_FLOATEXPBAILOUT() \ - if (fabs(old.y) >= 1.0e8) return 1;\ - if (fabs(old.x) >= 6.4e2) return 1; - -#define FLOATEXPBAILOUT() \ - if (fabs(old.y) >= 1.0e3) return 1;\ - if (fabs(old.x) >= 8) return 1; - -#define LONGEXPBAILOUT() \ - if (labs(lold.y) >= (1000L<= (8L< l16triglim)\ - {\ - double tmp;\ - tmp = (X);\ - tmp /= fudge;\ - tmp = fmod(tmp,twopi);\ - tmp *= fudge;\ - (X) = (long)tmp;\ - }\ - -static int Halleybailout(void) -{ - if ( fabs(modulus(g_new)-modulus(old)) < parm2.x) - return 1; - old = g_new; - return 0; -} - -#if !defined(XFRACT) -#define MPCmod(m) (*pMPadd(*pMPmul((m).x, (m).x), *pMPmul((m).y, (m).y))) -struct MPC mpcold, mpcnew, mpctmp, mpctmp1; -struct MP mptmpparm2x; - -static int MPCHalleybailout(void) -{ - static struct MP mptmpbailout; - mptmpbailout = *MPabs(*pMPsub(MPCmod(mpcnew), MPCmod(mpcold))); - if (pMPcmp(mptmpbailout, mptmpparm2x) < 0) - return 1; - mpcold = mpcnew; - return 0; -} -#endif - -#if defined(XFRACT) -int asmlMODbailout(void) { return 0;} -int asmlREALbailout(void) { return 0;} -int asmlIMAGbailout(void) { return 0;} -int asmlORbailout(void) { return 0;} -int asmlANDbailout(void) { return 0;} -int asmlMANHbailout(void) { return 0;} -int asmlMANRbailout(void) { return 0;} -int asm386lMODbailout(void) { return 0;} -int asm386lREALbailout(void) { return 0;} -int asm386lIMAGbailout(void) { return 0;} -int asm386lORbailout(void) { return 0;} -int asm386lANDbailout(void) { return 0;} -int asm386lMANHbailout(void) { return 0;} -int asm386lMANRbailout(void) { return 0;} -int asmfpMODbailout(void) { return 0;} -int asmfpREALbailout(void) { return 0;} -int asmfpIMAGbailout(void) { return 0;} -int asmfpORbailout(void) { return 0;} -int asmfpANDbailout(void) { return 0;} -int asmfpMANHbailout(void) { return 0;} -int asmfpMANRbailout(void) { return 0;} -#endif - -/* -------------------------------------------------------------------- */ -/* Fractal (once per iteration) routines */ -/* -------------------------------------------------------------------- */ -static double xt, yt, t2; - -/* Raise complex number (base) to the (exp) power, storing the result -** in complex (result). -*/ -void cpower(_CMPLX *base, int exp, _CMPLX *result) -{ - if (exp<0) { - cpower(base,-exp,result); - CMPLXrecip(*result,*result); - return; - } - - xt = base->x; yt = base->y; - - if (exp & 1) - { - result->x = xt; - result->y = yt; - } - else - { - result->x = 1.0; - result->y = 0.0; - } - - exp >>= 1; - while (exp) - { - t2 = xt * xt - yt * yt; - yt = 2 * xt * yt; - xt = t2; - - if (exp & 1) - { - t2 = xt * result->x - yt * result->y; - result->y = result->y * xt + yt * result->x; - result->x = t2; - } - exp >>= 1; - } -} - -#if !defined(XFRACT) -/* long version */ -static long lxt, lyt, lt2; -int -lcpower(_LCMPLX *base, int exp, _LCMPLX *result, int bitshift) -{ - static long maxarg; - maxarg = 64L<x; lyt = base->y; - - if (exp & 1) - { - result->x = lxt; - result->y = lyt; - } - else - { - result->x = 1L<y = 0L; - } - - exp >>= 1; - while (exp) - { - /* - if (labs(lxt) >= maxarg || labs(lyt) >= maxarg) - return -1; - */ - lt2 = multiply(lxt, lxt, bitshift) - multiply(lyt,lyt,bitshift); - lyt = multiply(lxt,lyt,bitshiftless1); - if (overflow) - return overflow; - lxt = lt2; - - if (exp & 1) - { - lt2 = multiply(lxt,result->x, bitshift) - multiply(lyt,result->y,bitshift); - result->y = multiply(result->y,lxt,bitshift) + multiply(lyt,result->x,bitshift); - result->x = lt2; - } - exp >>= 1; - } - if (result->x == 0 && result->y == 0) - overflow = 1; - return overflow; -} -#if 0 -int -z_to_the_z(_CMPLX *z, _CMPLX *out) -{ - static _CMPLX tmp1,tmp2; - /* raises complex z to the z power */ - int errno_xxx; - errno_xxx = 0; - - if (fabs(z->x) < DBL_EPSILON) return -1; - - /* log(x + iy) = 1/2(log(x*x + y*y) + i(arc_tan(y/x)) */ - tmp1.x = .5*log(sqr(z->x)+sqr(z->y)); - - /* the fabs in next line added to prevent discontinuity in image */ - tmp1.y = atan(fabs(z->y/z->x)); - - /* log(z)*z */ - tmp2.x = tmp1.x * z->x - tmp1.y * z->y; - tmp2.y = tmp1.x * z->y + tmp1.y * z->x; - - /* z*z = e**(log(z)*z) */ - /* e**(x + iy) = e**x * (cos(y) + isin(y)) */ - - tmpexp = exp(tmp2.x); - - FPUsincos(&tmp2.y,&siny,&cosy); - out->x = tmpexp*cosy; - out->y = tmpexp*siny; - return errno_xxx; -} -#endif -#endif - -#if defined(XFRACT) || defined(_WIN32) /* fractint uses the NewtonFractal2 code in newton.asm */ - -int complex_div(_CMPLX arg1,_CMPLX arg2,_CMPLX *pz); -int complex_mult(_CMPLX arg1,_CMPLX arg2,_CMPLX *pz); - -/* Distance of complex z from unit circle */ -#define DIST1(z) (((z).x-1.0)*((z).x-1.0)+((z).y)*((z).y)) -#define LDIST1(z) (lsqr((((z).x)-fudge)) + lsqr(((z).y))) - - -int NewtonFractal2(void) -{ - static char start=1; - if (start) - { - start = 0; - } - cpower(&old, degree-1, &tmp); - complex_mult(tmp, old, &g_new); - - if (DIST1(g_new) < threshold) - { - if (fractype==NEWTBASIN || fractype==MPNEWTBASIN) - { - long tmpcolor; - int i; - tmpcolor = -1; - /* this code determines which degree-th root of root the - Newton formula converges to. The roots of a 1 are - distributed on a circle of radius 1 about the origin. */ - for (i=0; ix = arg1.x*arg2.x - arg1.y*arg2.y; - pz->y = arg1.x*arg2.y+arg1.y*arg2.x; - return 0; -} - -int -complex_div(_CMPLX numerator,_CMPLX denominator,_CMPLX *pout) -{ - double mod; - if ((mod = modulus(denominator)) < FLT_MIN) - return 1; - conjugate(&denominator); - complex_mult(numerator,denominator,pout); - pout->x = pout->x/mod; - pout->y = pout->y/mod; - return 0; -} -#endif /* newton code only used by xfractint */ - -#if !defined(XFRACT) -struct MP mproverd, mpd1overd, mpthreshold; -struct MP mpt2; -struct MP mpone; -#endif - -int MPCNewtonFractal(void) -{ -#if !defined(XFRACT) - MPOverflow = 0; - mpctmp = MPCpow(mpcold,degree-1); - - mpcnew.x = *pMPsub(*pMPmul(mpctmp.x,mpcold.x),*pMPmul(mpctmp.y,mpcold.y)); - mpcnew.y = *pMPadd(*pMPmul(mpctmp.x,mpcold.y),*pMPmul(mpctmp.y,mpcold.x)); - mpctmp1.x = *pMPsub(mpcnew.x, MPCone.x); - mpctmp1.y = *pMPsub(mpcnew.y, MPCone.y); - if (pMPcmp(MPCmod(mpctmp1),mpthreshold)< 0) - { - if (fractype==MPNEWTBASIN) - { - long tmpcolor; - int i; - tmpcolor = -1; - for (i=0; ix, bitshift); - oldyinity = multiply(lold.y, longparm->y, bitshift); - oldxinity = multiply(lold.x, longparm->y, bitshift); - oldyinitx = multiply(lold.y, longparm->x, bitshift); - /* orbit calculation */ - if (lold.x >= 0) - { - lnew.x = (oldxinitx - longparm->x - oldyinity); - lnew.y = (oldyinitx - longparm->y + oldxinity); - } - else - { - lnew.x = (oldxinitx + longparm->x - oldyinity); - lnew.y = (oldyinitx + longparm->y + oldxinity); - } - return longbailout(); -#else - return 0; -#endif -} - -int -Barnsley1FPFractal(void) -{ - /* Barnsley's Mandelbrot type M1 from "Fractals - Everywhere" by Michael Barnsley, p. 322 */ - /* note that fast >= 287 equiv in fracsuba.asm must be kept in step */ - - /* calculate intermediate products */ - foldxinitx = old.x * floatparm->x; - foldyinity = old.y * floatparm->y; - foldxinity = old.x * floatparm->y; - foldyinitx = old.y * floatparm->x; - /* orbit calculation */ - if (old.x >= 0) - { - g_new.x = (foldxinitx - floatparm->x - foldyinity); - g_new.y = (foldyinitx - floatparm->y + foldxinity); - } - else - { - g_new.x = (foldxinitx + floatparm->x - foldyinity); - g_new.y = (foldyinitx + floatparm->y + foldxinity); - } - return floatbailout(); -} - -int -Barnsley2Fractal(void) -{ -#if !defined(XFRACT) - /* An unnamed Mandelbrot/Julia function from "Fractals - Everywhere" by Michael Barnsley, p. 331, example 4.2 */ - /* note that fast >= 287 equiv in fracsuba.asm must be kept in step */ - - /* calculate intermediate products */ - oldxinitx = multiply(lold.x, longparm->x, bitshift); - oldyinity = multiply(lold.y, longparm->y, bitshift); - oldxinity = multiply(lold.x, longparm->y, bitshift); - oldyinitx = multiply(lold.y, longparm->x, bitshift); - - /* orbit calculation */ - if (oldxinity + oldyinitx >= 0) - { - lnew.x = oldxinitx - longparm->x - oldyinity; - lnew.y = oldyinitx - longparm->y + oldxinity; - } - else - { - lnew.x = oldxinitx + longparm->x - oldyinity; - lnew.y = oldyinitx + longparm->y + oldxinity; - } - return longbailout(); -#else - return 0; -#endif -} - -int -Barnsley2FPFractal(void) -{ - /* An unnamed Mandelbrot/Julia function from "Fractals - Everywhere" by Michael Barnsley, p. 331, example 4.2 */ - - /* calculate intermediate products */ - foldxinitx = old.x * floatparm->x; - foldyinity = old.y * floatparm->y; - foldxinity = old.x * floatparm->y; - foldyinitx = old.y * floatparm->x; - - /* orbit calculation */ - if (foldxinity + foldyinitx >= 0) - { - g_new.x = foldxinitx - floatparm->x - foldyinity; - g_new.y = foldyinitx - floatparm->y + foldxinity; - } - else - { - g_new.x = foldxinitx + floatparm->x - foldyinity; - g_new.y = foldyinitx + floatparm->y + foldxinity; - } - return floatbailout(); -} - -int -JuliaFractal(void) -{ -#if !defined(XFRACT) - /* used for C prototype of fast integer math routines for classic - Mandelbrot and Julia */ - lnew.x = ltempsqrx - ltempsqry + longparm->x; - lnew.y = multiply(lold.x, lold.y, bitshiftless1) + longparm->y; - return longbailout(); -#elif !defined(__386BSD__) - { - static int been_here = 0; - if (!been_here) - { - stopmsg(0, "This integer fractal type is unimplemented;\n" - "Use float=yes to get a real image."); - been_here = 1; - } - return 0; - } -#endif -} - -int -JuliafpFractal(void) -{ - /* floating point version of classical Mandelbrot/Julia */ - /* note that fast >= 287 equiv in fracsuba.asm must be kept in step */ - g_new.x = tempsqrx - tempsqry + floatparm->x; - g_new.y = 2.0 * old.x * old.y + floatparm->y; - return floatbailout(); -} - -int -LambdaFPFractal(void) -{ - /* variation of classical Mandelbrot/Julia */ - /* note that fast >= 287 equiv in fracsuba.asm must be kept in step */ - - tempsqrx = old.x - tempsqrx + tempsqry; - tempsqry = -(old.y * old.x); - tempsqry += tempsqry + old.y; - - g_new.x = floatparm->x * tempsqrx - floatparm->y * tempsqry; - g_new.y = floatparm->x * tempsqry + floatparm->y * tempsqrx; - return floatbailout(); -} - -int -LambdaFractal(void) -{ -#if !defined(XFRACT) - /* variation of classical Mandelbrot/Julia */ - - /* in complex math) temp = Z * (1-Z) */ - ltempsqrx = lold.x - ltempsqrx + ltempsqry; - ltempsqry = lold.y - - multiply(lold.y, lold.x, bitshiftless1); - /* (in complex math) Z = Lambda * Z */ - lnew.x = multiply(longparm->x, ltempsqrx, bitshift) - - multiply(longparm->y, ltempsqry, bitshift); - lnew.y = multiply(longparm->x, ltempsqry, bitshift) - + multiply(longparm->y, ltempsqrx, bitshift); - return longbailout(); -#else - return 0; -#endif -} - -int -SierpinskiFractal(void) -{ -#if !defined(XFRACT) - /* following code translated from basic - see "Fractals - Everywhere" by Michael Barnsley, p. 251, Program 7.1.1 */ - lnew.x = (lold.x << 1); /* new.x = 2 * old.x */ - lnew.y = (lold.y << 1); /* new.y = 2 * old.y */ - if (lold.y > ltmp.y) /* if old.y > .5 */ - lnew.y = lnew.y - ltmp.x; /* new.y = 2 * old.y - 1 */ - else if (lold.x > ltmp.y) /* if old.x > .5 */ - lnew.x = lnew.x - ltmp.x; /* new.x = 2 * old.x - 1 */ - /* end barnsley code */ - return longbailout(); -#else - return 0; -#endif -} - -int -SierpinskiFPFractal(void) -{ - /* following code translated from basic - see "Fractals - Everywhere" by Michael Barnsley, p. 251, Program 7.1.1 */ - - g_new.x = old.x + old.x; - g_new.y = old.y + old.y; - if (old.y > .5) - g_new.y = g_new.y - 1; - else if (old.x > .5) - g_new.x = g_new.x - 1; - - /* end barnsley code */ - return floatbailout(); -} - -int -LambdaexponentFractal(void) -{ - /* found this in "Science of Fractal Images" */ - if (save_release > 2002) { /* need braces since these are macros */ - FLOATEXPBAILOUT(); - } - else { - OLD_FLOATEXPBAILOUT(); - } - FPUsincos (&old.y,&siny,&cosy); - - if (old.x >= rqlim && cosy >= 0.0) return 1; - tmpexp = exp(old.x); - tmp.x = tmpexp*cosy; - tmp.y = tmpexp*siny; - - /*multiply by lamda */ - g_new.x = floatparm->x*tmp.x - floatparm->y*tmp.y; - g_new.y = floatparm->y*tmp.x + floatparm->x*tmp.y; - old = g_new; - return 0; -} - -int -LongLambdaexponentFractal(void) -{ -#if !defined(XFRACT) - /* found this in "Science of Fractal Images" */ - LONGEXPBAILOUT(); - - SinCos086 (lold.y, &lsiny, &lcosy); - - if (lold.x >= llimit && lcosy >= 0L) return 1; - longtmp = Exp086(lold.x); - - ltmp.x = multiply(longtmp, lcosy, bitshift); - ltmp.y = multiply(longtmp, lsiny, bitshift); - - lnew.x = multiply(longparm->x, ltmp.x, bitshift) - - multiply(longparm->y, ltmp.y, bitshift); - lnew.y = multiply(longparm->x, ltmp.y, bitshift) - + multiply(longparm->y, ltmp.x, bitshift); - lold = lnew; - return 0; -#else - return 0; -#endif -} - -int -FloatTrigPlusExponentFractal(void) -{ - /* another Scientific American biomorph type */ - /* z(n+1) = e**z(n) + trig(z(n)) + C */ - - if (fabs(old.x) >= 6.4e2) return 1; /* DOMAIN errors */ - tmpexp = exp(old.x); - FPUsincos (&old.y,&siny,&cosy); - CMPLXtrig0(old,g_new); - - /*new = trig(old) + e**old + C */ - g_new.x += tmpexp*cosy + floatparm->x; - g_new.y += tmpexp*siny + floatparm->y; - return floatbailout(); -} - -int -LongTrigPlusExponentFractal(void) -{ -#if !defined(XFRACT) - /* calculate exp(z) */ - - /* domain check for fast transcendental functions */ - TRIG16CHECK(lold.x); - TRIG16CHECK(lold.y); - - longtmp = Exp086(lold.x); - SinCos086 (lold.y, &lsiny, &lcosy); - LCMPLXtrig0(lold,lnew); - lnew.x += multiply(longtmp, lcosy, bitshift) + longparm->x; - lnew.y += multiply(longtmp, lsiny, bitshift) + longparm->y; - return longbailout(); -#else - return 0; -#endif -} - -int -MarksLambdaFractal(void) -{ - /* Mark Peterson's variation of "lambda" function */ - - /* Z1 = (C^(exp-1) * Z**2) + C */ -#if !defined(XFRACT) - ltmp.x = ltempsqrx - ltempsqry; - ltmp.y = multiply(lold.x ,lold.y ,bitshiftless1); - - lnew.x = multiply(lcoefficient.x, ltmp.x, bitshift) - - multiply(lcoefficient.y, ltmp.y, bitshift) + longparm->x; - lnew.y = multiply(lcoefficient.x, ltmp.y, bitshift) - + multiply(lcoefficient.y, ltmp.x, bitshift) + longparm->y; - - return longbailout(); -#else - return 0; -#endif -} - -int -MarksLambdafpFractal(void) -{ - /* Mark Peterson's variation of "lambda" function */ - - /* Z1 = (C^(exp-1) * Z**2) + C */ - tmp.x = tempsqrx - tempsqry; - tmp.y = old.x * old.y *2; - - g_new.x = coefficient.x * tmp.x - coefficient.y * tmp.y + floatparm->x; - g_new.y = coefficient.x * tmp.y + coefficient.y * tmp.x + floatparm->y; - - return floatbailout(); -} - - -long XXOne, FgOne, FgTwo; - -int -UnityFractal(void) -{ -#if !defined(XFRACT) - /* brought to you by Mark Peterson - you won't find this in any fractal - books unless they saw it here first - Mark invented it! */ - XXOne = multiply(lold.x, lold.x, bitshift) + multiply(lold.y, lold.y, bitshift); - if ((XXOne > FgTwo) || (labs(XXOne - FgOne) < delmin)) - return 1; - lold.y = multiply(FgTwo - XXOne, lold.x, bitshift); - lold.x = multiply(FgTwo - XXOne, lold.y, bitshift); - lnew=lold; /* TW added this line */ - return 0; -#else - return 0; -#endif -} - -int -UnityfpFractal(void) -{ -double XXOne; - /* brought to you by Mark Peterson - you won't find this in any fractal - books unless they saw it here first - Mark invented it! */ - - XXOne = sqr(old.x) + sqr(old.y); - if ((XXOne > 2.0) || (fabs(XXOne - 1.0) < ddelmin)) - return 1; - old.y = (2.0 - XXOne)* old.x; - old.x = (2.0 - XXOne)* old.y; - g_new=old; /* TW added this line */ - return 0; -} - -int -Mandel4Fractal(void) -{ - /* By writing this code, Bert has left behind the excuse "don't - know what a fractal is, just know how to make'em go fast". - Bert is hereby declared a bonafide fractal expert! Supposedly - this routine calculates the Mandelbrot/Julia set based on the - polynomial z**4 + lambda, but I wouldn't know -- can't follow - all that integer math speedup stuff - Tim */ - - /* first, compute (x + iy)**2 */ -#if !defined(XFRACT) - lnew.x = ltempsqrx - ltempsqry; - lnew.y = multiply(lold.x, lold.y, bitshiftless1); - if (longbailout()) return 1; - - /* then, compute ((x + iy)**2)**2 + lambda */ - lnew.x = ltempsqrx - ltempsqry + longparm->x; - lnew.y = multiply(lold.x, lold.y, bitshiftless1) + longparm->y; - return longbailout(); -#else - return 0; -#endif -} - -int -Mandel4fpFractal(void) -{ - /* first, compute (x + iy)**2 */ - g_new.x = tempsqrx - tempsqry; - g_new.y = old.x*old.y*2; - if (floatbailout()) return 1; - - /* then, compute ((x + iy)**2)**2 + lambda */ - g_new.x = tempsqrx - tempsqry + floatparm->x; - g_new.y = old.x*old.y*2 + floatparm->y; - return floatbailout(); -} - -int -floatZtozPluszpwrFractal(void) -{ - cpower(&old,(int)param[2],&g_new); - old = ComplexPower(old,old); - g_new.x = g_new.x + old.x +floatparm->x; - g_new.y = g_new.y + old.y +floatparm->y; - return floatbailout(); -} - -int -longZpowerFractal(void) -{ -#if !defined(XFRACT) - if (lcpower(&lold,c_exp,&lnew,bitshift)) - lnew.x = lnew.y = 8L<x; - lnew.y += longparm->y; - return longbailout(); -#else - return 0; -#endif -} - -int -longCmplxZpowerFractal(void) -{ -#if !defined(XFRACT) - _CMPLX x, y; - - x.x = (double)lold.x / fudge; - x.y = (double)lold.y / fudge; - y.x = (double)lparm2.x / fudge; - y.y = (double)lparm2.y / fudge; - x = ComplexPower(x, y); - if (fabs(x.x) < fgLimit && fabs(x.y) < fgLimit) { - lnew.x = (long)(x.x * fudge); - lnew.y = (long)(x.y * fudge); - } - else - overflow = 1; - lnew.x += longparm->x; - lnew.y += longparm->y; - return longbailout(); -#else - return 0; -#endif -} - -int -floatZpowerFractal(void) -{ - cpower(&old,c_exp,&g_new); - g_new.x += floatparm->x; - g_new.y += floatparm->y; - return floatbailout(); -} - -int -floatCmplxZpowerFractal(void) -{ - g_new = ComplexPower(old, parm2); - g_new.x += floatparm->x; - g_new.y += floatparm->y; - return floatbailout(); -} - -int -Barnsley3Fractal(void) -{ - /* An unnamed Mandelbrot/Julia function from "Fractals - Everywhere" by Michael Barnsley, p. 292, example 4.1 */ - - /* calculate intermediate products */ -#if !defined(XFRACT) - oldxinitx = multiply(lold.x, lold.x, bitshift); - oldyinity = multiply(lold.y, lold.y, bitshift); - oldxinity = multiply(lold.x, lold.y, bitshift); - - /* orbit calculation */ - if (lold.x > 0) - { - lnew.x = oldxinitx - oldyinity - fudge; - lnew.y = oldxinity << 1; - } - else - { - lnew.x = oldxinitx - oldyinity - fudge - + multiply(longparm->x,lold.x,bitshift); - lnew.y = oldxinity <<1; - - /* This term added by Tim Wegner to make dependent on the - imaginary part of the parameter. (Otherwise Mandelbrot - is uninteresting. */ - lnew.y += multiply(longparm->y,lold.x,bitshift); - } - return longbailout(); -#else - return 0; -#endif -} - -int -Barnsley3FPFractal(void) -{ - /* An unnamed Mandelbrot/Julia function from "Fractals - Everywhere" by Michael Barnsley, p. 292, example 4.1 */ - - - /* calculate intermediate products */ - foldxinitx = old.x * old.x; - foldyinity = old.y * old.y; - foldxinity = old.x * old.y; - - /* orbit calculation */ - if (old.x > 0) - { - g_new.x = foldxinitx - foldyinity - 1.0; - g_new.y = foldxinity * 2; - } - else - { - g_new.x = foldxinitx - foldyinity -1.0 + floatparm->x * old.x; - g_new.y = foldxinity * 2; - - /* This term added by Tim Wegner to make dependent on the - imaginary part of the parameter. (Otherwise Mandelbrot - is uninteresting. */ - g_new.y += floatparm->y * old.x; - } - return floatbailout(); -} - -int -TrigPlusZsquaredFractal(void) -{ -#if !defined(XFRACT) - /* From Scientific American, July 1989 */ - /* A Biomorph */ - /* z(n+1) = trig(z(n))+z(n)**2+C */ - LCMPLXtrig0(lold,lnew); - lnew.x += ltempsqrx - ltempsqry + longparm->x; - lnew.y += multiply(lold.x, lold.y, bitshiftless1) + longparm->y; - return longbailout(); -#else - return 0; -#endif -} - -int -TrigPlusZsquaredfpFractal(void) -{ - /* From Scientific American, July 1989 */ - /* A Biomorph */ - /* z(n+1) = trig(z(n))+z(n)**2+C */ - - CMPLXtrig0(old,g_new); - g_new.x += tempsqrx - tempsqry + floatparm->x; - g_new.y += 2.0 * old.x * old.y + floatparm->y; - return floatbailout(); -} - -int -Richard8fpFractal(void) -{ - /* Richard8 {c = z = pixel: z=sin(z)+sin(pixel),|z|<=50} */ - CMPLXtrig0(old,g_new); -/* CMPLXtrig1(*floatparm,tmp); */ - g_new.x += tmp.x; - g_new.y += tmp.y; - return floatbailout(); -} - -int -Richard8Fractal(void) -{ -#if !defined(XFRACT) - /* Richard8 {c = z = pixel: z=sin(z)+sin(pixel),|z|<=50} */ - LCMPLXtrig0(lold,lnew); -/* LCMPLXtrig1(*longparm,ltmp); */ - lnew.x += ltmp.x; - lnew.y += ltmp.y; - return longbailout(); -#else - return 0; -#endif -} - -int -PopcornFractal_Old(void) -{ - tmp = old; - tmp.x *= 3.0; - tmp.y *= 3.0; - FPUsincos(&tmp.x,&sinx,&cosx); - FPUsincos(&tmp.y,&siny,&cosy); - tmp.x = sinx/cosx + old.x; - tmp.y = siny/cosy + old.y; - FPUsincos(&tmp.x,&sinx,&cosx); - FPUsincos(&tmp.y,&siny,&cosy); - g_new.x = old.x - parm.x*siny; - g_new.y = old.y - parm.x*sinx; - /* - g_new.x = old.x - parm.x*sin(old.y+tan(3*old.y)); - g_new.y = old.y - parm.x*sin(old.x+tan(3*old.x)); - */ - if (plot == noplot) - { - plot_orbit(g_new.x,g_new.y,1+row%colors); - old = g_new; - } - else - /* FLOATBAILOUT(); */ - /* PB The above line was weird, not what it seems to be! But, bracketing - it or always doing it (either of which seem more likely to be what - was intended) changes the image for the worse, so I'm not touching it. - Same applies to int form in next routine. */ - /* PB later: recoded inline, still leaving it weird */ - tempsqrx = sqr(g_new.x); - tempsqry = sqr(g_new.y); - if ((magnitude = tempsqrx + tempsqry) >= rqlim) return 1; - old = g_new; - return 0; -} - -int -PopcornFractal(void) -{ - tmp = old; - tmp.x *= 3.0; - tmp.y *= 3.0; - FPUsincos(&tmp.x,&sinx,&cosx); - FPUsincos(&tmp.y,&siny,&cosy); - tmp.x = sinx/cosx + old.x; - tmp.y = siny/cosy + old.y; - FPUsincos(&tmp.x,&sinx,&cosx); - FPUsincos(&tmp.y,&siny,&cosy); - g_new.x = old.x - parm.x*siny; - g_new.y = old.y - parm.x*sinx; - /* - g_new.x = old.x - parm.x*sin(old.y+tan(3*old.y)); - g_new.y = old.y - parm.x*sin(old.x+tan(3*old.x)); - */ - if (plot == noplot) - { - plot_orbit(g_new.x,g_new.y,1+row%colors); - old = g_new; - } - /* else */ - /* FLOATBAILOUT(); */ - /* PB The above line was weird, not what it seems to be! But, bracketing - it or always doing it (either of which seem more likely to be what - was intended) changes the image for the worse, so I'm not touching it. - Same applies to int form in next routine. */ - /* PB later: recoded inline, still leaving it weird */ - /* JCO: sqr's should always be done, else magnitude could be wrong */ - tempsqrx = sqr(g_new.x); - tempsqry = sqr(g_new.y); - if ((magnitude = tempsqrx + tempsqry) >= rqlim - || fabs(g_new.x) > rqlim2 || fabs(g_new.y) > rqlim2 ) - return 1; - old = g_new; - return 0; -} - -int -LPopcornFractal_Old(void) -{ -#if !defined(XFRACT) - ltmp = lold; - ltmp.x *= 3L; - ltmp.y *= 3L; - LTRIGARG(ltmp.x); - LTRIGARG(ltmp.y); - SinCos086(ltmp.x,&lsinx,&lcosx); - SinCos086(ltmp.y,&lsiny,&lcosy); - ltmp.x = divide(lsinx,lcosx,bitshift) + lold.x; - ltmp.y = divide(lsiny,lcosy,bitshift) + lold.y; - LTRIGARG(ltmp.x); - LTRIGARG(ltmp.y); - SinCos086(ltmp.x,&lsinx,&lcosx); - SinCos086(ltmp.y,&lsiny,&lcosy); - lnew.x = lold.x - multiply(lparm.x,lsiny,bitshift); - lnew.y = lold.y - multiply(lparm.x,lsinx,bitshift); - if (plot == noplot) - { - iplot_orbit(lnew.x,lnew.y,1+row%colors); - lold = lnew; - } - else - /* LONGBAILOUT(); */ - /* PB above still the old way, is weird, see notes in FP popcorn case */ - { - ltempsqrx = lsqr(lnew.x); - ltempsqry = lsqr(lnew.y); - } - lmagnitud = ltempsqrx + ltempsqry; - if (lmagnitud >= llimit || lmagnitud < 0 || labs(lnew.x) > llimit2 - || labs(lnew.y) > llimit2) - return 1; - lold = lnew; - return 0; -#else - return 0; -#endif -} - -int -LPopcornFractal(void) -{ -#if !defined(XFRACT) - ltmp = lold; - ltmp.x *= 3L; - ltmp.y *= 3L; - LTRIGARG(ltmp.x); - LTRIGARG(ltmp.y); - SinCos086(ltmp.x,&lsinx,&lcosx); - SinCos086(ltmp.y,&lsiny,&lcosy); - ltmp.x = divide(lsinx,lcosx,bitshift) + lold.x; - ltmp.y = divide(lsiny,lcosy,bitshift) + lold.y; - LTRIGARG(ltmp.x); - LTRIGARG(ltmp.y); - SinCos086(ltmp.x,&lsinx,&lcosx); - SinCos086(ltmp.y,&lsiny,&lcosy); - lnew.x = lold.x - multiply(lparm.x,lsiny,bitshift); - lnew.y = lold.y - multiply(lparm.x,lsinx,bitshift); - if (plot == noplot) - { - iplot_orbit(lnew.x,lnew.y,1+row%colors); - lold = lnew; - } - /* else */ - /* JCO: sqr's should always be done, else magnitude could be wrong */ - ltempsqrx = lsqr(lnew.x); - ltempsqry = lsqr(lnew.y); - lmagnitud = ltempsqrx + ltempsqry; - if (lmagnitud >= llimit || lmagnitud < 0 - || labs(lnew.x) > llimit2 - || labs(lnew.y) > llimit2) - return 1; - lold = lnew; - return 0; -#else - return 0; -#endif -} - -/* Popcorn generalization proposed by HB */ - -int -PopcornFractalFn(void) -{ - _CMPLX tmpx; - _CMPLX tmpy; - - /* tmpx contains the generalized value of the old real "x" equation */ - CMPLXtimesreal(parm2,old.y,tmp); /* tmp = (C * old.y) */ - CMPLXtrig1(tmp,tmpx); /* tmpx = trig1(tmp) */ - tmpx.x += old.y; /* tmpx = old.y + trig1(tmp) */ - CMPLXtrig0(tmpx,tmp); /* tmp = trig0(tmpx) */ - CMPLXmult(tmp,parm,tmpx); /* tmpx = tmp * h */ - - /* tmpy contains the generalized value of the old real "y" equation */ - CMPLXtimesreal(parm2,old.x,tmp); /* tmp = (C * old.x) */ - CMPLXtrig3(tmp,tmpy); /* tmpy = trig3(tmp) */ - tmpy.x += old.x; /* tmpy = old.x + trig1(tmp) */ - CMPLXtrig2(tmpy,tmp); /* tmp = trig2(tmpy) */ - - CMPLXmult(tmp,parm,tmpy); /* tmpy = tmp * h */ - - g_new.x = old.x - tmpx.x - tmpy.y; - g_new.y = old.y - tmpy.x - tmpx.y; - - if (plot == noplot) - { - plot_orbit(g_new.x,g_new.y,1+row%colors); - old = g_new; - } - - tempsqrx = sqr(g_new.x); - tempsqry = sqr(g_new.y); - if ((magnitude = tempsqrx + tempsqry) >= rqlim - || fabs(g_new.x) > rqlim2 || fabs(g_new.y) > rqlim2 ) - return 1; - old = g_new; - return 0; -} - -#define FIX_OVERFLOW(arg) if (overflow) \ - { \ - (arg).x = fudge;\ - (arg).y = 0;\ - overflow = 0;\ - } - -int -LPopcornFractalFn(void) -{ -#if !defined(XFRACT) - _LCMPLX ltmpx, ltmpy; - - overflow = 0; - - /* ltmpx contains the generalized value of the old real "x" equation */ - LCMPLXtimesreal(lparm2,lold.y,ltmp); /* tmp = (C * old.y) */ - LCMPLXtrig1(ltmp,ltmpx); /* tmpx = trig1(tmp) */ - FIX_OVERFLOW(ltmpx); - ltmpx.x += lold.y; /* tmpx = old.y + trig1(tmp) */ - LCMPLXtrig0(ltmpx,ltmp); /* tmp = trig0(tmpx) */ - FIX_OVERFLOW(ltmp); - LCMPLXmult(ltmp,lparm,ltmpx); /* tmpx = tmp * h */ - - /* ltmpy contains the generalized value of the old real "y" equation */ - LCMPLXtimesreal(lparm2,lold.x,ltmp); /* tmp = (C * old.x) */ - LCMPLXtrig3(ltmp,ltmpy); /* tmpy = trig3(tmp) */ - FIX_OVERFLOW(ltmpy); - ltmpy.x += lold.x; /* tmpy = old.x + trig1(tmp) */ - LCMPLXtrig2(ltmpy,ltmp); /* tmp = trig2(tmpy) */ - FIX_OVERFLOW(ltmp); - LCMPLXmult(ltmp,lparm,ltmpy); /* tmpy = tmp * h */ - - lnew.x = lold.x - ltmpx.x - ltmpy.y; - lnew.y = lold.y - ltmpy.x - ltmpx.y; - - if (plot == noplot) - { - iplot_orbit(lnew.x,lnew.y,1+row%colors); - lold = lnew; - } - ltempsqrx = lsqr(lnew.x); - ltempsqry = lsqr(lnew.y); - lmagnitud = ltempsqrx + ltempsqry; - if (lmagnitud >= llimit || lmagnitud < 0 - || labs(lnew.x) > llimit2 - || labs(lnew.y) > llimit2) - return 1; - lold = lnew; - return 0; -#else - return 0; -#endif -} - -int MarksCplxMand(void) -{ - tmp.x = tempsqrx - tempsqry; - tmp.y = 2*old.x*old.y; - FPUcplxmul(&tmp, &coefficient, &g_new); - g_new.x += floatparm->x; - g_new.y += floatparm->y; - return floatbailout(); -} - -int SpiderfpFractal(void) -{ - /* Spider(XAXIS) { c=z=pixel: z=z*z+c; c=c/2+z, |z|<=4 } */ - g_new.x = tempsqrx - tempsqry + tmp.x; - g_new.y = 2 * old.x * old.y + tmp.y; - tmp.x = tmp.x/2 + g_new.x; - tmp.y = tmp.y/2 + g_new.y; - return floatbailout(); -} - -int -SpiderFractal(void) -{ -#if !defined(XFRACT) - /* Spider(XAXIS) { c=z=pixel: z=z*z+c; c=c/2+z, |z|<=4 } */ - lnew.x = ltempsqrx - ltempsqry + ltmp.x; - lnew.y = multiply(lold.x, lold.y, bitshiftless1) + ltmp.y; - ltmp.x = (ltmp.x >> 1) + lnew.x; - ltmp.y = (ltmp.y >> 1) + lnew.y; - return longbailout(); -#else - return 0; -#endif -} - -int -TetratefpFractal(void) -{ - /* Tetrate(XAXIS) { c=z=pixel: z=c^z, |z|<=(P1+3) } */ - g_new = ComplexPower(*floatparm,old); - return floatbailout(); -} - -int -ZXTrigPlusZFractal(void) -{ -#if !defined(XFRACT) - /* z = (p1*z*trig(z))+p2*z */ - LCMPLXtrig0(lold,ltmp); /* ltmp = trig(old) */ - LCMPLXmult(lparm,ltmp,ltmp); /* ltmp = p1*trig(old) */ - LCMPLXmult(lold,ltmp,ltmp2); /* ltmp2 = p1*old*trig(old) */ - LCMPLXmult(lparm2,lold,ltmp); /* ltmp = p2*old */ - LCMPLXadd(ltmp2,ltmp,lnew); /* lnew = p1*trig(old) + p2*old */ - return longbailout(); -#else - return 0; -#endif -} - -int -ScottZXTrigPlusZFractal(void) -{ -#if !defined(XFRACT) - /* z = (z*trig(z))+z */ - LCMPLXtrig0(lold,ltmp); /* ltmp = trig(old) */ - LCMPLXmult(lold,ltmp,lnew); /* lnew = old*trig(old) */ - LCMPLXadd(lnew,lold,lnew); /* lnew = trig(old) + old */ - return longbailout(); -#else - return 0; -#endif -} - -int -SkinnerZXTrigSubZFractal(void) -{ -#if !defined(XFRACT) - /* z = (z*trig(z))-z */ - LCMPLXtrig0(lold,ltmp); /* ltmp = trig(old) */ - LCMPLXmult(lold,ltmp,lnew); /* lnew = old*trig(old) */ - LCMPLXsub(lnew,lold,lnew); /* lnew = trig(old) - old */ - return longbailout(); -#else - return 0; -#endif -} - -int -ZXTrigPlusZfpFractal(void) -{ - /* z = (p1*z*trig(z))+p2*z */ - CMPLXtrig0(old,tmp); /* tmp = trig(old) */ - CMPLXmult(parm,tmp,tmp); /* tmp = p1*trig(old) */ - CMPLXmult(old,tmp,tmp2); /* tmp2 = p1*old*trig(old) */ - CMPLXmult(parm2,old,tmp); /* tmp = p2*old */ - CMPLXadd(tmp2,tmp,g_new); /* new = p1*trig(old) + p2*old */ - return floatbailout(); -} - -int -ScottZXTrigPlusZfpFractal(void) -{ - /* z = (z*trig(z))+z */ - CMPLXtrig0(old,tmp); /* tmp = trig(old) */ - CMPLXmult(old,tmp,g_new); /* new = old*trig(old) */ - CMPLXadd(g_new,old,g_new); /* new = trig(old) + old */ - return floatbailout(); -} - -int -SkinnerZXTrigSubZfpFractal(void) -{ - /* z = (z*trig(z))-z */ - CMPLXtrig0(old,tmp); /* tmp = trig(old) */ - CMPLXmult(old,tmp,g_new); /* new = old*trig(old) */ - CMPLXsub(g_new,old,g_new); /* new = trig(old) - old */ - return floatbailout(); -} - -int -Sqr1overTrigFractal(void) -{ -#if !defined(XFRACT) - /* z = sqr(1/trig(z)) */ - LCMPLXtrig0(lold,lold); - LCMPLXrecip(lold,lold); - LCMPLXsqr(lold,lnew); - return longbailout(); -#else - return 0; -#endif -} - -int -Sqr1overTrigfpFractal(void) -{ - /* z = sqr(1/trig(z)) */ - CMPLXtrig0(old,old); - CMPLXrecip(old,old); - CMPLXsqr(old,g_new); - return floatbailout(); -} - -int -TrigPlusTrigFractal(void) -{ -#if !defined(XFRACT) - /* z = trig(0,z)*p1+trig1(z)*p2 */ - LCMPLXtrig0(lold,ltmp); - LCMPLXmult(lparm,ltmp,ltmp); - LCMPLXtrig1(lold,ltmp2); - LCMPLXmult(lparm2,ltmp2,lold); - LCMPLXadd(ltmp,lold,lnew); - return longbailout(); -#else - return 0; -#endif -} - -int -TrigPlusTrigfpFractal(void) -{ - /* z = trig0(z)*p1+trig1(z)*p2 */ - CMPLXtrig0(old,tmp); - CMPLXmult(parm,tmp,tmp); - CMPLXtrig1(old,old); - CMPLXmult(parm2,old,old); - CMPLXadd(tmp,old,g_new); - return floatbailout(); -} - -/* The following four fractals are based on the idea of parallel - or alternate calculations. The shift is made when the mod - reaches a given value. JCO 5/6/92 */ - -int -LambdaTrigOrTrigFractal(void) -{ -#if !defined(XFRACT) - /* z = trig0(z)*p1 if mod(old) < p2.x and - trig1(z)*p1 if mod(old) >= p2.x */ - if ((LCMPLXmod(lold)) < lparm2.x){ - LCMPLXtrig0(lold,ltmp); - LCMPLXmult(*longparm,ltmp,lnew);} - else{ - LCMPLXtrig1(lold,ltmp); - LCMPLXmult(*longparm,ltmp,lnew);} - return longbailout(); -#else - return 0; -#endif -} - -int -LambdaTrigOrTrigfpFractal(void) -{ - /* z = trig0(z)*p1 if mod(old) < p2.x and - trig1(z)*p1 if mod(old) >= p2.x */ - if (CMPLXmod(old) < parm2.x){ - CMPLXtrig0(old,old); - FPUcplxmul(floatparm,&old,&g_new);} - else{ - CMPLXtrig1(old,old); - FPUcplxmul(floatparm,&old,&g_new);} - return floatbailout(); -} - -int -JuliaTrigOrTrigFractal(void) -{ -#if !defined(XFRACT) - /* z = trig0(z)+p1 if mod(old) < p2.x and - trig1(z)+p1 if mod(old) >= p2.x */ - if (LCMPLXmod(lold) < lparm2.x){ - LCMPLXtrig0(lold,ltmp); - LCMPLXadd(*longparm,ltmp,lnew);} - else{ - LCMPLXtrig1(lold,ltmp); - LCMPLXadd(*longparm,ltmp,lnew);} - return longbailout(); -#else - return 0; -#endif -} - -int -JuliaTrigOrTrigfpFractal(void) -{ - /* z = trig0(z)+p1 if mod(old) < p2.x and - trig1(z)+p1 if mod(old) >= p2.x */ - if (CMPLXmod(old) < parm2.x){ - CMPLXtrig0(old,old); - CMPLXadd(*floatparm,old,g_new);} - else{ - CMPLXtrig1(old,old); - CMPLXadd(*floatparm,old,g_new);} - return floatbailout(); -} - -int AplusOne, Ap1deg; -struct MP mpAplusOne, mpAp1deg; -struct MPC mpctmpparm; - -int MPCHalleyFractal(void) -{ -#if !defined(XFRACT) - /* X(X^a - 1) = 0, Halley Map */ - /* a = parm.x, relaxation coeff. = parm.y, epsilon = parm2.x */ - -int ihal; -struct MPC mpcXtoAlessOne, mpcXtoA; -struct MPC mpcXtoAplusOne; /* a-1, a, a+1 */ -struct MPC mpcFX, mpcF1prime, mpcF2prime, mpcHalnumer1; -struct MPC mpcHalnumer2, mpcHaldenom, mpctmp; - - MPOverflow = 0; - mpcXtoAlessOne.x = mpcold.x; - mpcXtoAlessOne.y = mpcold.y; - for (ihal=2; ihalx+multiply(longparm->y,ltmp2.x,bitshift); - lnew.y = (ltmp.x + ltmp.x) + multiply(longparm->y,ltmp2.y,bitshift); - ltmp2 = lold; /* set ltmp2 to Y value */ - return longbailout(); -#else - return 0; -#endif -} - -int -PhoenixFractal(void) -{ -/* z(n+1) = z(n)^2 + p + qy(n), y(n+1) = z(n) */ - tmp.x = old.x * old.y; - g_new.x = tempsqrx - tempsqry + floatparm->x + (floatparm->y * tmp2.x); - g_new.y = (tmp.x + tmp.x) + (floatparm->y * tmp2.y); - tmp2 = old; /* set tmp2 to Y value */ - return floatbailout(); -} - -int -LongPhoenixFractalcplx(void) -{ -#if !defined(XFRACT) -/* z(n+1) = z(n)^2 + p + qy(n), y(n+1) = z(n) */ - ltmp.x = multiply(lold.x, lold.y, bitshift); - lnew.x = ltempsqrx-ltempsqry+longparm->x+multiply(lparm2.x,ltmp2.x,bitshift)-multiply(lparm2.y,ltmp2.y,bitshift); - lnew.y = (ltmp.x + ltmp.x)+longparm->y+multiply(lparm2.x,ltmp2.y,bitshift)+multiply(lparm2.y,ltmp2.x,bitshift); - ltmp2 = lold; /* set ltmp2 to Y value */ - return longbailout(); -#else - return 0; -#endif -} - -int -PhoenixFractalcplx(void) -{ -/* z(n+1) = z(n)^2 + p1 + p2*y(n), y(n+1) = z(n) */ - tmp.x = old.x * old.y; - g_new.x = tempsqrx - tempsqry + floatparm->x + (parm2.x * tmp2.x) - (parm2.y * tmp2.y); - g_new.y = (tmp.x + tmp.x) + floatparm->y + (parm2.x * tmp2.y) + (parm2.y * tmp2.x); - tmp2 = old; /* set tmp2 to Y value */ - return floatbailout(); -} - -int -LongPhoenixPlusFractal(void) -{ -#if !defined(XFRACT) -/* z(n+1) = z(n)^(degree-1) * (z(n) + p) + qy(n), y(n+1) = z(n) */ -int i; -_LCMPLX loldplus, lnewminus; - loldplus = lold; - ltmp = lold; - for (i=1; i= 2, degree=degree-1 in setup */ - LCMPLXmult(lold,ltmp,ltmp); /* = old^(degree-1) */ - } - loldplus.x += longparm->x; - LCMPLXmult(ltmp, loldplus, lnewminus); - lnew.x = lnewminus.x + multiply(longparm->y,ltmp2.x,bitshift); - lnew.y = lnewminus.y + multiply(longparm->y,ltmp2.y,bitshift); - ltmp2 = lold; /* set ltmp2 to Y value */ - return longbailout(); -#else - return 0; -#endif -} - -int -PhoenixPlusFractal(void) -{ -/* z(n+1) = z(n)^(degree-1) * (z(n) + p) + qy(n), y(n+1) = z(n) */ -int i; -_CMPLX oldplus, newminus; - oldplus = old; - tmp = old; - for (i=1; i= 2, degree=degree-1 in setup */ - FPUcplxmul(&old, &tmp, &tmp); /* = old^(degree-1) */ - } - oldplus.x += floatparm->x; - FPUcplxmul(&tmp, &oldplus, &newminus); - g_new.x = newminus.x + (floatparm->y * tmp2.x); - g_new.y = newminus.y + (floatparm->y * tmp2.y); - tmp2 = old; /* set tmp2 to Y value */ - return floatbailout(); -} - -int -LongPhoenixMinusFractal(void) -{ -#if !defined(XFRACT) -/* z(n+1) = z(n)^(degree-2) * (z(n)^2 + p) + qy(n), y(n+1) = z(n) */ -int i; -_LCMPLX loldsqr, lnewminus; - LCMPLXmult(lold,lold,loldsqr); - ltmp = lold; - for (i=1; i= 3, degree=degree-2 in setup */ - LCMPLXmult(lold,ltmp,ltmp); /* = old^(degree-2) */ - } - loldsqr.x += longparm->x; - LCMPLXmult(ltmp, loldsqr, lnewminus); - lnew.x = lnewminus.x + multiply(longparm->y,ltmp2.x,bitshift); - lnew.y = lnewminus.y + multiply(longparm->y,ltmp2.y,bitshift); - ltmp2 = lold; /* set ltmp2 to Y value */ - return longbailout(); -#else - return 0; -#endif -} - -int -PhoenixMinusFractal(void) -{ -/* z(n+1) = z(n)^(degree-2) * (z(n)^2 + p) + qy(n), y(n+1) = z(n) */ -int i; -_CMPLX oldsqr, newminus; - FPUcplxmul(&old, &old, &oldsqr); - tmp = old; - for (i=1; i= 3, degree=degree-2 in setup */ - FPUcplxmul(&old, &tmp, &tmp); /* = old^(degree-2) */ - } - oldsqr.x += floatparm->x; - FPUcplxmul(&tmp, &oldsqr, &newminus); - g_new.x = newminus.x + (floatparm->y * tmp2.x); - g_new.y = newminus.y + (floatparm->y * tmp2.y); - tmp2 = old; /* set tmp2 to Y value */ - return floatbailout(); -} - -int -LongPhoenixCplxPlusFractal(void) -{ -#if !defined(XFRACT) -/* z(n+1) = z(n)^(degree-1) * (z(n) + p) + qy(n), y(n+1) = z(n) */ -int i; -_LCMPLX loldplus, lnewminus; - loldplus = lold; - ltmp = lold; - for (i=1; i= 2, degree=degree-1 in setup */ - LCMPLXmult(lold,ltmp,ltmp); /* = old^(degree-1) */ - } - loldplus.x += longparm->x; - loldplus.y += longparm->y; - LCMPLXmult(ltmp, loldplus, lnewminus); - LCMPLXmult(lparm2, ltmp2, ltmp); - lnew.x = lnewminus.x + ltmp.x; - lnew.y = lnewminus.y + ltmp.y; - ltmp2 = lold; /* set ltmp2 to Y value */ - return longbailout(); -#else - return 0; -#endif -} - -int -PhoenixCplxPlusFractal(void) -{ -/* z(n+1) = z(n)^(degree-1) * (z(n) + p) + qy(n), y(n+1) = z(n) */ -int i; -_CMPLX oldplus, newminus; - oldplus = old; - tmp = old; - for (i=1; i= 2, degree=degree-1 in setup */ - FPUcplxmul(&old, &tmp, &tmp); /* = old^(degree-1) */ - } - oldplus.x += floatparm->x; - oldplus.y += floatparm->y; - FPUcplxmul(&tmp, &oldplus, &newminus); - FPUcplxmul(&parm2, &tmp2, &tmp); - g_new.x = newminus.x + tmp.x; - g_new.y = newminus.y + tmp.y; - tmp2 = old; /* set tmp2 to Y value */ - return floatbailout(); -} - -int -LongPhoenixCplxMinusFractal(void) -{ -#if !defined(XFRACT) -/* z(n+1) = z(n)^(degree-2) * (z(n)^2 + p) + qy(n), y(n+1) = z(n) */ -int i; -_LCMPLX loldsqr, lnewminus; - LCMPLXmult(lold,lold,loldsqr); - ltmp = lold; - for (i=1; i= 3, degree=degree-2 in setup */ - LCMPLXmult(lold,ltmp,ltmp); /* = old^(degree-2) */ - } - loldsqr.x += longparm->x; - loldsqr.y += longparm->y; - LCMPLXmult(ltmp, loldsqr, lnewminus); - LCMPLXmult(lparm2, ltmp2, ltmp); - lnew.x = lnewminus.x + ltmp.x; - lnew.y = lnewminus.y + ltmp.y; - ltmp2 = lold; /* set ltmp2 to Y value */ - return longbailout(); -#else - return 0; -#endif -} - -int -PhoenixCplxMinusFractal(void) -{ -/* z(n+1) = z(n)^(degree-2) * (z(n)^2 + p) + qy(n), y(n+1) = z(n) */ -int i; -_CMPLX oldsqr, newminus; - FPUcplxmul(&old, &old, &oldsqr); - tmp = old; - for (i=1; i= 3, degree=degree-2 in setup */ - FPUcplxmul(&old, &tmp, &tmp); /* = old^(degree-2) */ - } - oldsqr.x += floatparm->x; - oldsqr.y += floatparm->y; - FPUcplxmul(&tmp, &oldsqr, &newminus); - FPUcplxmul(&parm2, &tmp2, &tmp); - g_new.x = newminus.x + tmp.x; - g_new.y = newminus.y + tmp.y; - tmp2 = old; /* set tmp2 to Y value */ - return floatbailout(); -} - -int -ScottTrigPlusTrigFractal(void) -{ -#if !defined(XFRACT) - /* z = trig0(z)+trig1(z) */ - LCMPLXtrig0(lold,ltmp); - LCMPLXtrig1(lold,lold); - LCMPLXadd(ltmp,lold,lnew); - return longbailout(); -#else - return 0; -#endif -} - -int -ScottTrigPlusTrigfpFractal(void) -{ - /* z = trig0(z)+trig1(z) */ - CMPLXtrig0(old,tmp); - CMPLXtrig1(old,tmp2); - CMPLXadd(tmp,tmp2,g_new); - return floatbailout(); -} - -int -SkinnerTrigSubTrigFractal(void) -{ -#if !defined(XFRACT) - /* z = trig(0,z)-trig1(z) */ - LCMPLXtrig0(lold,ltmp); - LCMPLXtrig1(lold,ltmp2); - LCMPLXsub(ltmp,ltmp2,lnew); - return longbailout(); -#else - return 0; -#endif -} - -int -SkinnerTrigSubTrigfpFractal(void) -{ - /* z = trig0(z)-trig1(z) */ - CMPLXtrig0(old,tmp); - CMPLXtrig1(old,tmp2); - CMPLXsub(tmp,tmp2,g_new); - return floatbailout(); -} - -int -TrigXTrigfpFractal(void) -{ - /* z = trig0(z)*trig1(z) */ - CMPLXtrig0(old,tmp); - CMPLXtrig1(old,old); - CMPLXmult(tmp,old,g_new); - return floatbailout(); -} - -#if !defined(XFRACT) - /* call float version of fractal if integer math overflow */ -static int TryFloatFractal(int (*fpFractal)(void)) -{ - overflow=0; - /* lold had better not be changed! */ - old.x = lold.x; old.x /= fudge; - old.y = lold.y; old.y /= fudge; - tempsqrx = sqr(old.x); - tempsqry = sqr(old.y); - fpFractal(); - if (save_release < 1900) { /* for backwards compatibility */ - lnew.x = (long)(g_new.x/fudge); /* this error has been here a long time */ - lnew.y = (long)(g_new.y/fudge); - } else { - lnew.x = (long)(g_new.x*fudge); - lnew.y = (long)(g_new.y*fudge); - } - return 0; -} -#endif - -int -TrigXTrigFractal(void) -{ -#if !defined(XFRACT) - _LCMPLX ltmp2; - /* z = trig0(z)*trig1(z) */ - LCMPLXtrig0(lold,ltmp); - LCMPLXtrig1(lold,ltmp2); - LCMPLXmult(ltmp,ltmp2,lnew); - if (overflow) - TryFloatFractal(TrigXTrigfpFractal); - return longbailout(); -#else - return 0; -#endif -} - -/********************************************************************/ -/* Next six orbit functions are one type - extra functions are */ -/* special cases written for speed. */ -/********************************************************************/ - -int -TrigPlusSqrFractal(void) /* generalization of Scott and Skinner types */ -{ -#if !defined(XFRACT) - /* { z=pixel: z=(p1,p2)*trig(z)+(p3,p4)*sqr(z), |z| l16triglim_2 || labs(ltmp.y) > l16triglim_2) && - save_release > 1900) - overflow = 1; - else - { - LCMPLXtrig0(ltmp,lnew); - } - if (overflow) - TryFloatFractal(TrigZsqrdfpFractal); - return longbailout(); -#else - return 0; -#endif -} - -int -SqrTrigFractal(void) -{ -#if !defined(XFRACT) - /* { z=pixel: z=sqr(trig(z)), |z|x - 1; /* top = Z**2+C-1 */ - top.y = old.x * old.y; - top.y = top.y + top.y + floatparm->y; - - bot.x = old.x + old.x + floatparm->x - 2; /* bot = 2*Z+C-2 */ - bot.y = old.y + old.y + floatparm->y; - - div = bot.x*bot.x + bot.y*bot.y; /* tmp = top/bot */ - if (div < FLT_MIN) return 1; - tmp.x = (top.x*bot.x + top.y*bot.y)/div; - tmp.y = (top.y*bot.x - top.x*bot.y)/div; - - g_new.x = (tmp.x + tmp.y) * (tmp.x - tmp.y); /* Z = tmp**2 */ - g_new.y = tmp.x * tmp.y; - g_new.y += g_new.y; - - return floatbailout(); - } - -int -Magnet2Fractal(void) /* Z = ((Z**3 + 3(C-1)Z + (C-1)(C-2) ) / */ - /* (3Z**2 + 3(C-2)Z + (C-1)(C-2)+1) )**2 */ - { /* In "Beauty of Fractals", code by Kev Allen. */ - _CMPLX top, bot, tmp; - double div; - - top.x = old.x * (tempsqrx-tempsqry-tempsqry-tempsqry + T_Cm1.x) - - old.y * T_Cm1.y + T_Cm1Cm2.x; - top.y = old.y * (tempsqrx+tempsqrx+tempsqrx-tempsqry + T_Cm1.x) - + old.x * T_Cm1.y + T_Cm1Cm2.y; - - bot.x = tempsqrx - tempsqry; - bot.x = bot.x + bot.x + bot.x - + old.x * T_Cm2.x - old.y * T_Cm2.y - + T_Cm1Cm2.x + 1.0; - bot.y = old.x * old.y; - bot.y += bot.y; - bot.y = bot.y + bot.y + bot.y - + old.x * T_Cm2.y + old.y * T_Cm2.x - + T_Cm1Cm2.y; - - div = bot.x*bot.x + bot.y*bot.y; /* tmp = top/bot */ - if (div < FLT_MIN) return 1; - tmp.x = (top.x*bot.x + top.y*bot.y)/div; - tmp.y = (top.y*bot.x - top.x*bot.y)/div; - - g_new.x = (tmp.x + tmp.y) * (tmp.x - tmp.y); /* Z = tmp**2 */ - g_new.y = tmp.x * tmp.y; - g_new.y += g_new.y; - - return floatbailout(); - } - -int -LambdaTrigFractal(void) -{ -#if !defined(XFRACT) - LONGXYTRIGBAILOUT(); - LCMPLXtrig0(lold,ltmp); /* ltmp = trig(lold) */ - LCMPLXmult(*longparm,ltmp,lnew); /* lnew = longparm*trig(lold) */ - lold = lnew; - return 0; -#else - return 0; -#endif -} - -int -LambdaTrigfpFractal(void) -{ - FLOATXYTRIGBAILOUT(); - CMPLXtrig0(old,tmp); /* tmp = trig(old) */ - CMPLXmult(*floatparm,tmp,g_new); /* new = longparm*trig(old) */ - old = g_new; - return 0; -} - -/* bailouts are different for different trig functions */ -int -LambdaTrigFractal1(void) -{ -#if !defined(XFRACT) - LONGTRIGBAILOUT(); /* sin,cos */ - LCMPLXtrig0(lold,ltmp); /* ltmp = trig(lold) */ - LCMPLXmult(*longparm,ltmp,lnew); /* lnew = longparm*trig(lold) */ - lold = lnew; - return 0; -#else - return 0; -#endif -} - -int -LambdaTrigfpFractal1(void) -{ - FLOATTRIGBAILOUT(); /* sin,cos */ - CMPLXtrig0(old,tmp); /* tmp = trig(old) */ - CMPLXmult(*floatparm,tmp,g_new); /* new = longparm*trig(old) */ - old = g_new; - return 0; -} - -int -LambdaTrigFractal2(void) -{ -#if !defined(XFRACT) - LONGHTRIGBAILOUT(); /* sinh,cosh */ - LCMPLXtrig0(lold,ltmp); /* ltmp = trig(lold) */ - LCMPLXmult(*longparm,ltmp,lnew); /* lnew = longparm*trig(lold) */ - lold = lnew; - return 0; -#else - return 0; -#endif -} - -int -LambdaTrigfpFractal2(void) -{ -#if !defined(XFRACT) - FLOATHTRIGBAILOUT(); /* sinh,cosh */ - CMPLXtrig0(old,tmp); /* tmp = trig(old) */ - CMPLXmult(*floatparm,tmp,g_new); /* new = longparm*trig(old) */ - old = g_new; - return 0; -#else - return 0; -#endif -} - -int -ManOWarFractal(void) -{ -#if !defined(XFRACT) - /* From Art Matrix via Lee Skinner */ - lnew.x = ltempsqrx - ltempsqry + ltmp.x + longparm->x; - lnew.y = multiply(lold.x, lold.y, bitshiftless1) + ltmp.y + longparm->y; - ltmp = lold; - return longbailout(); -#else - return 0; -#endif -} - -int -ManOWarfpFractal(void) -{ - /* From Art Matrix via Lee Skinner */ - /* note that fast >= 287 equiv in fracsuba.asm must be kept in step */ - g_new.x = tempsqrx - tempsqry + tmp.x + floatparm->x; - g_new.y = 2.0 * old.x * old.y + tmp.y + floatparm->y; - tmp = old; - return floatbailout(); -} - -/* - MarksMandelPwr (XAXIS) { - z = pixel, c = z ^ (z - 1): - z = c * sqr(z) + pixel, - |z| <= 4 - } -*/ - -int -MarksMandelPwrfpFractal(void) -{ - CMPLXtrig0(old,g_new); - CMPLXmult(tmp,g_new,g_new); - g_new.x += floatparm->x; - g_new.y += floatparm->y; - return floatbailout(); -} - -int -MarksMandelPwrFractal(void) -{ -#if !defined(XFRACT) - LCMPLXtrig0(lold,lnew); - LCMPLXmult(ltmp,lnew,lnew); - lnew.x += longparm->x; - lnew.y += longparm->y; - return longbailout(); -#else - return 0; -#endif -} - -/* I was coding Marksmandelpower and failed to use some temporary - variables. The result was nice, and since my name is not on any fractal, - I thought I would immortalize myself with this error! - Tim Wegner */ - -int -TimsErrorfpFractal(void) -{ - CMPLXtrig0(old,g_new); - g_new.x = g_new.x * tmp.x - g_new.y * tmp.y; - g_new.y = g_new.x * tmp.y - g_new.y * tmp.x; - g_new.x += floatparm->x; - g_new.y += floatparm->y; - return floatbailout(); -} - -int -TimsErrorFractal(void) -{ -#if !defined(XFRACT) - LCMPLXtrig0(lold,lnew); - lnew.x = multiply(lnew.x,ltmp.x,bitshift)-multiply(lnew.y,ltmp.y,bitshift); - lnew.y = multiply(lnew.x,ltmp.y,bitshift)-multiply(lnew.y,ltmp.x,bitshift); - lnew.x += longparm->x; - lnew.y += longparm->y; - return longbailout(); -#else - return 0; -#endif -} - -int -CirclefpFractal(void) -{ - long i; - i = (long)(param[0]*(tempsqrx+tempsqry)); - coloriter = i%colors; - return 1; -} -/* -CirclelongFractal() -{ - long i; - i = multiply(lparm.x,(ltempsqrx+ltempsqry),bitshift); - i = i >> bitshift; - coloriter = i%colors); - return 1; -} -*/ - -/* -------------------------------------------------------------------- */ -/* Initialization (once per pixel) routines */ -/* -------------------------------------------------------------------- */ - -#if defined(XFRACT) || defined(_WIN32) -/* this code translated to asm - lives in newton.asm */ -/* transform points with reciprocal function */ -void invertz2(_CMPLX *z) -{ - z->x = dxpixel(); - z->y = dypixel(); - z->x -= f_xcenter; z->y -= f_ycenter; /* Normalize values to center of circle */ - - tempsqrx = sqr(z->x) + sqr(z->y); /* Get old radius */ - if (fabs(tempsqrx) > FLT_MIN) - tempsqrx = f_radius / tempsqrx; - else - tempsqrx = FLT_MAX; /* a big number, but not TOO big */ - z->x *= tempsqrx; z->y *= tempsqrx; /* Perform inversion */ - z->x += f_xcenter; z->y += f_ycenter; /* Renormalize */ -} -#endif - -int long_julia_per_pixel(void) -{ -#if !defined(XFRACT) - /* integer julia types */ - /* lambda */ - /* barnsleyj1 */ - /* barnsleyj2 */ - /* sierpinski */ - if (invert) - { - /* invert */ - invertz2(&old); - - /* watch out for overflow */ - if (sqr(old.x)+sqr(old.y) >= 127) - { - old.x = 8; /* value to bail out in one iteration */ - old.y = 8; - } - - /* convert to fudged longs */ - lold.x = (long)(old.x*fudge); - lold.y = (long)(old.y*fudge); - } - else - { - lold.x = lxpixel(); - lold.y = lypixel(); - } - return 0; -#else - return 0; -#endif -} - -int long_richard8_per_pixel(void) -{ -#if !defined(XFRACT) - long_mandel_per_pixel(); - LCMPLXtrig1(*longparm,ltmp); - LCMPLXmult(ltmp,lparm2,ltmp); - return 1; -#else - return 0; -#endif -} - -int long_mandel_per_pixel(void) -{ -#if !defined(XFRACT) - /* integer mandel types */ - /* barnsleym1 */ - /* barnsleym2 */ - linit.x = lxpixel(); - if (save_release >= 2004) - linit.y = lypixel(); - - if (invert) - { - /* invert */ - invertz2(&init); - - /* watch out for overflow */ - if (sqr(init.x)+sqr(init.y) >= 127) - { - init.x = 8; /* value to bail out in one iteration */ - init.y = 8; - } - - /* convert to fudged longs */ - linit.x = (long)(init.x*fudge); - linit.y = (long)(init.y*fudge); - } - - if (useinitorbit == 1) - lold = linitorbit; - else - lold = linit; - - lold.x += lparm.x; /* initial pertubation of parameters set */ - lold.y += lparm.y; - return 1; /* 1st iteration has been done */ -#else - return 0; -#endif -} - -int julia_per_pixel(void) -{ - /* julia */ - - if (invert) - { - /* invert */ - invertz2(&old); - - /* watch out for overflow */ - if (bitshift <= 24) - if (sqr(old.x)+sqr(old.y) >= 127) - { - old.x = 8; /* value to bail out in one iteration */ - old.y = 8; - } - if (bitshift > 24) - if (sqr(old.x)+sqr(old.y) >= 4.0) - { - old.x = 2; /* value to bail out in one iteration */ - old.y = 2; - } - - /* convert to fudged longs */ - lold.x = (long)(old.x*fudge); - lold.y = (long)(old.y*fudge); - } - else - { - lold.x = lxpixel(); - lold.y = lypixel(); - } - - ltempsqrx = multiply(lold.x, lold.x, bitshift); - ltempsqry = multiply(lold.y, lold.y, bitshift); - ltmp = lold; - return 0; -} - -int -marks_mandelpwr_per_pixel(void) -{ -#if !defined(XFRACT) - mandel_per_pixel(); - ltmp = lold; - ltmp.x -= fudge; - LCMPLXpwr(lold,ltmp,ltmp); - return 1; -#else - return 0; -#endif -} - -int mandel_per_pixel(void) -{ - /* mandel */ - - if (invert) - { - invertz2(&init); - - /* watch out for overflow */ - if (bitshift <= 24) - if (sqr(init.x)+sqr(init.y) >= 127) - { - init.x = 8; /* value to bail out in one iteration */ - init.y = 8; - } - if (bitshift > 24) - if (sqr(init.x)+sqr(init.y) >= 4) - { - init.x = 2; /* value to bail out in one iteration */ - init.y = 2; - } - - /* convert to fudged longs */ - linit.x = (long)(init.x*fudge); - linit.y = (long)(init.y*fudge); - } - else { - linit.x = lxpixel(); - if (save_release >= 2004) - linit.y = lypixel(); - } - switch (fractype) - { - case MANDELLAMBDA: /* Critical Value 0.5 + 0.0i */ - lold.x = FgHalf; - lold.y = 0; - break; - default: - lold = linit; - break; - } - - /* alter init value */ - if (useinitorbit == 1) - lold = linitorbit; - else if (useinitorbit == 2) - lold = linit; - - if ((inside == BOF60 || inside == BOF61) && !nobof) - { - /* kludge to match "Beauty of Fractals" picture since we start - Mandelbrot iteration with init rather than 0 */ - lold.x = lparm.x; /* initial pertubation of parameters set */ - lold.y = lparm.y; - coloriter = -1; - } - else - { - lold.x += lparm.x; /* initial pertubation of parameters set */ - lold.y += lparm.y; - } - ltmp = linit; /* for spider */ - ltempsqrx = multiply(lold.x, lold.x, bitshift); - ltempsqry = multiply(lold.y, lold.y, bitshift); - return 1; /* 1st iteration has been done */ -} - -int marksmandel_per_pixel() -{ -#if !defined(XFRACT) - /* marksmandel */ - if (invert) - { - invertz2(&init); - - /* watch out for overflow */ - if (sqr(init.x)+sqr(init.y) >= 127) - { - init.x = 8; /* value to bail out in one iteration */ - init.y = 8; - } - - /* convert to fudged longs */ - linit.x = (long)(init.x*fudge); - linit.y = (long)(init.y*fudge); - } - else { - linit.x = lxpixel(); - if (save_release >= 2004) - linit.y = lypixel(); - } - - if (useinitorbit == 1) - lold = linitorbit; - else - lold = linit; - - lold.x += lparm.x; /* initial pertubation of parameters set */ - lold.y += lparm.y; - - if (c_exp > 3) - lcpower(&lold,c_exp-1,&lcoefficient,bitshift); - else if (c_exp == 3) { - lcoefficient.x = multiply(lold.x, lold.x, bitshift) - - multiply(lold.y, lold.y, bitshift); - lcoefficient.y = multiply(lold.x, lold.y, bitshiftless1); - } - else if (c_exp == 2) - lcoefficient = lold; - else if (c_exp < 2) { - lcoefficient.x = 1L << bitshift; - lcoefficient.y = 0L; - } - - ltempsqrx = multiply(lold.x, lold.x, bitshift); - ltempsqry = multiply(lold.y, lold.y, bitshift); -#endif - return 1; /* 1st iteration has been done */ -} - -int marksmandelfp_per_pixel() -{ - /* marksmandel */ - - if (invert) - invertz2(&init); - else { - init.x = dxpixel(); - if (save_release >= 2004) - init.y = dypixel(); - } - - if (useinitorbit == 1) - old = initorbit; - else - old = init; - - old.x += parm.x; /* initial pertubation of parameters set */ - old.y += parm.y; - - tempsqrx = sqr(old.x); - tempsqry = sqr(old.y); - - if (c_exp > 3) - cpower(&old,c_exp-1,&coefficient); - else if (c_exp == 3) { - coefficient.x = tempsqrx - tempsqry; - coefficient.y = old.x * old.y * 2; - } - else if (c_exp == 2) - coefficient = old; - else if (c_exp < 2) { - coefficient.x = 1.0; - coefficient.y = 0.0; - } - - return 1; /* 1st iteration has been done */ -} - -int -marks_mandelpwrfp_per_pixel(void) -{ - mandelfp_per_pixel(); - tmp = old; - tmp.x -= 1; - CMPLXpwr(old,tmp,tmp); - return 1; -} - -int mandelfp_per_pixel(void) -{ - /* floating point mandelbrot */ - /* mandelfp */ - - if (invert) - invertz2(&init); - else { - init.x = dxpixel(); - if (save_release >= 2004) - init.y = dypixel(); - } - switch (fractype) - { - case MAGNET2M: - FloatPreCalcMagnet2(); - case MAGNET1M: /* Crit Val Zero both, but neither */ - old.x = old.y = 0.0; /* is of the form f(Z,C) = Z*g(Z)+C */ - break; - case MANDELLAMBDAFP: /* Critical Value 0.5 + 0.0i */ - old.x = 0.5; - old.y = 0.0; - break; - default: - old = init; - break; - } - - /* alter init value */ - if (useinitorbit == 1) - old = initorbit; - else if (useinitorbit == 2) - old = init; - - if ((inside == BOF60 || inside == BOF61) && !nobof) - { - /* kludge to match "Beauty of Fractals" picture since we start - Mandelbrot iteration with init rather than 0 */ - old.x = parm.x; /* initial pertubation of parameters set */ - old.y = parm.y; - coloriter = -1; - } - else - { - old.x += parm.x; - old.y += parm.y; - } - tmp = init; /* for spider */ - tempsqrx = sqr(old.x); /* precalculated value for regular Mandelbrot */ - tempsqry = sqr(old.y); - return 1; /* 1st iteration has been done */ -} - -int juliafp_per_pixel(void) -{ - /* floating point julia */ - /* juliafp */ - if (invert) - invertz2(&old); - else - { - old.x = dxpixel(); - old.y = dypixel(); - } - tempsqrx = sqr(old.x); /* precalculated value for regular Julia */ - tempsqry = sqr(old.y); - tmp = old; - return 0; -} - -int MPCjulia_per_pixel(void) -{ -#if !defined(XFRACT) - /* floating point julia */ - /* juliafp */ - if (invert) - invertz2(&old); - else - { - old.x = dxpixel(); - old.y = dypixel(); - } - mpcold.x = *pd2MP(old.x); - mpcold.y = *pd2MP(old.y); - return 0; -#else - return 0; -#endif -} - -int -otherrichard8fp_per_pixel(void) -{ - othermandelfp_per_pixel(); - CMPLXtrig1(*floatparm,tmp); - CMPLXmult(tmp,parm2,tmp); - return 1; -} - -int othermandelfp_per_pixel(void) -{ - if (invert) - invertz2(&init); - else { - init.x = dxpixel(); - if (save_release >= 2004) - init.y = dypixel(); - } - - if (useinitorbit == 1) - old = initorbit; - else - old = init; - - old.x += parm.x; /* initial pertubation of parameters set */ - old.y += parm.y; - - return 1; /* 1st iteration has been done */ -} - -int MPCHalley_per_pixel(void) -{ -#if !defined(XFRACT) - /* MPC halley */ - if (invert) - invertz2(&init); - else { - init.x = dxpixel(); - if (save_release >= 2004) - init.y = dypixel(); - } - - mpcold.x = *pd2MP(init.x); - mpcold.y = *pd2MP(init.y); - - return 0; -#else - return 0; -#endif -} - -int Halley_per_pixel(void) -{ - if (invert) - invertz2(&init); - else { - init.x = dxpixel(); - if (save_release >= 2004) - init.y = dypixel(); - } - - old = init; - - return 0; /* 1st iteration is not done */ -} - -int otherjuliafp_per_pixel(void) -{ - if (invert) - invertz2(&old); - else - { - old.x = dxpixel(); - old.y = dypixel(); - } - return 0; -} - -#if 0 -#define Q0 .113 -#define Q1 .01 -#else -#define Q0 0 -#define Q1 0 -#endif - -int quaternionjulfp_per_pixel(void) -{ - old.x = dxpixel(); - old.y = dypixel(); - floatparm->x = param[4]; - floatparm->y = param[5]; - qc = param[0]; - qci = param[1]; - qcj = param[2]; - qck = param[3]; - return 0; -} - -int quaternionfp_per_pixel(void) -{ - old.x = 0; - old.y = 0; - floatparm->x = 0; - floatparm->y = 0; - qc = dxpixel(); - qci = dypixel(); - qcj = param[2]; - qck = param[3]; - return 0; -} - -int MarksCplxMandperp(void) -{ - if (invert) - invertz2(&init); - else { - init.x = dxpixel(); - if (save_release >= 2004) - init.y = dypixel(); - } - old.x = init.x + parm.x; /* initial pertubation of parameters set */ - old.y = init.y + parm.y; - tempsqrx = sqr(old.x); /* precalculated value */ - tempsqry = sqr(old.y); - coefficient = ComplexPower(init, pwr); - return 1; -} - -int long_phoenix_per_pixel(void) -{ -#if !defined(XFRACT) - if (invert) - { - /* invert */ - invertz2(&old); - - /* watch out for overflow */ - if (sqr(old.x)+sqr(old.y) >= 127) - { - old.x = 8; /* value to bail out in one iteration */ - old.y = 8; - } - - /* convert to fudged longs */ - lold.x = (long)(old.x*fudge); - lold.y = (long)(old.y*fudge); - } - else - { - lold.x = lxpixel(); - lold.y = lypixel(); - } - ltempsqrx = multiply(lold.x, lold.x, bitshift); - ltempsqry = multiply(lold.y, lold.y, bitshift); - ltmp2.x = 0; /* use ltmp2 as the complex Y value */ - ltmp2.y = 0; - return 0; -#else - return 0; -#endif -} - -int phoenix_per_pixel(void) -{ - if (invert) - invertz2(&old); - else - { - old.x = dxpixel(); - old.y = dypixel(); - } - tempsqrx = sqr(old.x); /* precalculated value */ - tempsqry = sqr(old.y); - tmp2.x = 0; /* use tmp2 as the complex Y value */ - tmp2.y = 0; - return 0; -} -int long_mandphoenix_per_pixel(void) -{ -#if !defined(XFRACT) - linit.x = lxpixel(); - if (save_release >= 2004) - linit.y = lypixel(); - - if (invert) - { - /* invert */ - invertz2(&init); - - /* watch out for overflow */ - if (sqr(init.x)+sqr(init.y) >= 127) - { - init.x = 8; /* value to bail out in one iteration */ - init.y = 8; - } - - /* convert to fudged longs */ - linit.x = (long)(init.x*fudge); - linit.y = (long)(init.y*fudge); - } - - if (useinitorbit == 1) - lold = linitorbit; - else - lold = linit; - - lold.x += lparm.x; /* initial pertubation of parameters set */ - lold.y += lparm.y; - ltempsqrx = multiply(lold.x, lold.x, bitshift); - ltempsqry = multiply(lold.y, lold.y, bitshift); - ltmp2.x = 0; - ltmp2.y = 0; - return 1; /* 1st iteration has been done */ -#else - return 0; -#endif -} -int mandphoenix_per_pixel(void) -{ - if (invert) - invertz2(&init); - else { - init.x = dxpixel(); - if (save_release >= 2004) - init.y = dypixel(); - } - - if (useinitorbit == 1) - old = initorbit; - else - old = init; - - old.x += parm.x; /* initial pertubation of parameters set */ - old.y += parm.y; - tempsqrx = sqr(old.x); /* precalculated value */ - tempsqry = sqr(old.y); - tmp2.x = 0; - tmp2.y = 0; - return 1; /* 1st iteration has been done */ -} - -int -QuaternionFPFractal(void) -{ - double a0,a1,a2,a3,n0,n1,n2,n3; - a0 = old.x; - a1 = old.y; - a2 = floatparm->x; - a3 = floatparm->y; - - n0 = a0*a0-a1*a1-a2*a2-a3*a3 + qc; - n1 = 2*a0*a1 + qci; - n2 = 2*a0*a2 + qcj; - n3 = 2*a0*a3 + qck; - /* Check bailout */ - magnitude = a0*a0+a1*a1+a2*a2+a3*a3; - if (magnitude>rqlim) { - return 1; - } - old.x = g_new.x = n0; - old.y = g_new.y = n1; - floatparm->x = n2; - floatparm->y = n3; - return 0; -} - -int -HyperComplexFPFractal(void) -{ - _HCMPLX hold, hnew; - hold.x = old.x; - hold.y = old.y; - hold.z = floatparm->x; - hold.t = floatparm->y; - -/* HComplexSqr(&hold,&hnew); */ - HComplexTrig0(&hold,&hnew); - - hnew.x += qc; - hnew.y += qci; - hnew.z += qcj; - hnew.t += qck; - - old.x = g_new.x = hnew.x; - old.y = g_new.y = hnew.y; - floatparm->x = hnew.z; - floatparm->y = hnew.t; - - /* Check bailout */ - magnitude = sqr(old.x)+sqr(old.y)+sqr(floatparm->x)+sqr(floatparm->y); - if (magnitude>rqlim) { - return 1; - } - return 0; -} - -int -VLfpFractal(void) /* Beauty of Fractals pp. 125 - 127 */ -{ - double a, b, ab, half, u, w, xy; - - half = param[0] / 2.0; - xy = old.x * old.y; - u = old.x - xy; - w = -old.y + xy; - a = old.x + param[1] * u; - b = old.y + param[1] * w; - ab = a * b; - g_new.x = old.x + half * (u + (a - ab)); - g_new.y = old.y + half * (w + (-b + ab)); - return floatbailout(); -} - -int -EscherfpFractal(void) /* Science of Fractal Images pp. 185, 187 */ -{ - _CMPLX oldtest, newtest, testsqr; - double testsize = 0.0; - long testiter = 0; - - g_new.x = tempsqrx - tempsqry; /* standard Julia with C == (0.0, 0.0i) */ - g_new.y = 2.0 * old.x * old.y; - oldtest.x = g_new.x * 15.0; /* scale it */ - oldtest.y = g_new.y * 15.0; - testsqr.x = sqr(oldtest.x); /* set up to test with user-specified ... */ - testsqr.y = sqr(oldtest.y); /* ... Julia as the target set */ - while (testsize <= rqlim && testiter < maxit) /* nested Julia loop */ - { - newtest.x = testsqr.x - testsqr.y + param[0]; - newtest.y = 2.0 * oldtest.x * oldtest.y + param[1]; - testsize = (testsqr.x = sqr(newtest.x)) + (testsqr.y = sqr(newtest.y)); - oldtest = newtest; - testiter++; - } - if (testsize > rqlim) return floatbailout(); /* point not in target set */ - else /* make distinct level sets if point stayed in target set */ - { - coloriter = ((3L * coloriter) % 255L) + 1L; - return 1; - } -} - -/* re-use static roots variable - memory for mandelmix4 */ - -#define A staticroots[ 0] -#define B staticroots[ 1] -#define C staticroots[ 2] -#define D staticroots[ 3] -#define F staticroots[ 4] -#define G staticroots[ 5] -#define H staticroots[ 6] -#define J staticroots[ 7] -#define K staticroots[ 8] -#define L staticroots[ 9] -#define Z staticroots[10] - -int MandelbrotMix4Setup(void) -{ - int sign_array = 0; - A.x=param[0]; A.y=0.0; /* a=real(p1), */ - B.x=param[1]; B.y=0.0; /* b=imag(p1), */ - D.x=param[2]; D.y=0.0; /* d=real(p2), */ - F.x=param[3]; F.y=0.0; /* f=imag(p2), */ - K.x=param[4]+1.0; K.y=0.0; /* k=real(p3)+1, */ - L.x=param[5]+100.0; L.y=0.0; /* l=imag(p3)+100, */ - CMPLXrecip(F,G); /* g=1/f, */ - CMPLXrecip(D,H); /* h=1/d, */ - CMPLXsub(F,B,tmp); /* tmp = f-b */ - CMPLXrecip(tmp,J); /* j = 1/(f-b) */ - CMPLXneg(A,tmp); - CMPLXmult(tmp,B,tmp); /* z=(-a*b*g*h)^j, */ - CMPLXmult(tmp,G,tmp); - CMPLXmult(tmp,H,tmp); - - /* - This code kludge attempts to duplicate the behavior - of the parser in determining the sign of zero of the - imaginary part of the argument of the power function. The - reason this is important is that the complex arctangent - returns PI in one case and -PI in the other, depending - on the sign bit of zero, and we wish the results to be - compatible with Jim Muth's mix4 formula using the parser. - - First create a number encoding the signs of a, b, g , h. Our - kludge assumes that those signs determine the behavior. - */ - if (A.x < 0.0) sign_array += 8; - if (B.x < 0.0) sign_array += 4; - if (G.x < 0.0) sign_array += 2; - if (H.x < 0.0) sign_array += 1; - if (tmp.y == 0.0) /* we know tmp.y IS zero but ... */ - { - switch (sign_array) - { - /* - Add to this list the magic numbers of any cases - in which the fractal does not match the formula version - */ - case 15: /* 1111 */ - case 10: /* 1010 */ - case 6: /* 0110 */ - case 5: /* 0101 */ - case 3: /* 0011 */ - case 0: /* 0000 */ - tmp.y = -tmp.y; /* swap sign bit */ - default: /* do nothing - remaining cases already OK */ - ; - } - /* in case our kludge failed, let the user fix it */ - if (debugflag == 1012) tmp.y = -tmp.y; - } - - CMPLXpwr(tmp,J,tmp); /* note: z is old */ - /* in case our kludge failed, let the user fix it */ - if (param[6] < 0.0) tmp.y = -tmp.y; - - if (bailout == 0) - { - rqlim = L.x; - rqlim2 = rqlim*rqlim; - } - return 1; -} - -int MandelbrotMix4fp_per_pixel(void) -{ - if (invert) - invertz2(&init); - else { - init.x = dxpixel(); - init.y = dypixel(); - } - old = tmp; - CMPLXtrig0(init,C); /* c=fn1(pixel): */ - return 0; /* 1st iteration has been NOT been done */ -} - -int -MandelbrotMix4fpFractal(void) /* from formula by Jim Muth */ -{ - /* z=k*((a*(z^b))+(d*(z^f)))+c, */ - _CMPLX z_b, z_f; - CMPLXpwr(old,B,z_b); /* (z^b) */ - CMPLXpwr(old,F,z_f); /* (z^f) */ - g_new.x = K.x*A.x*z_b.x + K.x*D.x*z_f.x + C.x; - g_new.y = K.x*A.x*z_b.y + K.x*D.x*z_f.y + C.y; - return floatbailout(); -} -#undef A -#undef B -#undef C -#undef D -#undef F -#undef G -#undef H -#undef J -#undef K -#undef L - -/* - * The following functions calculate the real and imaginary complex - * coordinates of the point in the complex plane corresponding to - * the screen coordinates (col,row) at the current zoom corners - * settings. The functions come in two flavors. One looks up the pixel - * values using the precalculated grid arrays dx0, dx1, dy0, and dy1, - * which has a speed advantage but is limited to MAXPIXELS image - * dimensions. The other calculates the complex coordinates at a - * cost of two additions and two multiplications for each component, - * but works at any resolution. - * - * With Microsoft C's _fastcall keyword, the function call overhead - * appears to be negligible. It also appears that the speed advantage - * of the lookup vs the calculation is negligible on machines with - * coprocessors. Bert Tyler's original implementation was designed for - * machines with no coprocessor; on those machines the saving was - * significant. For the time being, the table lookup capability will - * be maintained. - */ - -/* Real component, grid lookup version - requires dx0/dx1 arrays */ -static double _fastcall dxpixel_grid(void) -{ - return dx0[col]+dx1[row]; -} - -/* Real component, calculation version - does not require arrays */ -static double _fastcall dxpixel_calc(void) -{ - return (double) (xxmin + col*delxx + row*delxx2); -} - -/* Imaginary component, grid lookup version - requires dy0/dy1 arrays */ -static double _fastcall dypixel_grid(void) -{ - return dy0[row]+dy1[col]; -} - -/* Imaginary component, calculation version - does not require arrays */ -static double _fastcall dypixel_calc(void) -{ - return (double)(yymax - row*delyy - col*delyy2); -} - -/* Real component, grid lookup version - requires lx0/lx1 arrays */ -static long _fastcall lxpixel_grid(void) -{ - return lx0[col]+lx1[row]; -} - -/* Real component, calculation version - does not require arrays */ -static long _fastcall lxpixel_calc(void) -{ - return xmin + col*delx + row*delx2; -} - -/* Imaginary component, grid lookup version - requires ly0/ly1 arrays */ -static long _fastcall lypixel_grid(void) -{ - return ly0[row]+ly1[col]; -} - -/* Imaginary component, calculation version - does not require arrays */ -static long _fastcall lypixel_calc(void) -{ - return ymax - row*dely - col*dely2; -} - -double (_fastcall *dxpixel)(void) = dxpixel_calc; -double (_fastcall *dypixel)(void) = dypixel_calc; -long (_fastcall *lxpixel)(void) = lxpixel_calc; -long (_fastcall *lypixel)(void) = lypixel_calc; - -void set_pixel_calc_functions(void) -{ - if (use_grid) - { - dxpixel = dxpixel_grid; - dypixel = dypixel_grid; - lxpixel = lxpixel_grid; - lypixel = lypixel_grid; - } - else - { - dxpixel = dxpixel_calc; - dypixel = dypixel_calc; - lxpixel = lxpixel_calc; - lypixel = lypixel_calc; - } -} diff --git a/fractint/common/fractint.c b/fractint/common/fractint.c deleted file mode 100644 index 611894ecf..000000000 --- a/fractint/common/fractint.c +++ /dev/null @@ -1,675 +0,0 @@ -/* - FRACTINT - The Ultimate Fractal Generator - Main Routine -*/ - -#include -#include -#include - -#ifndef XFRACT -#include -#endif - -#ifndef USE_VARARGS -#include -#else -#include -#endif - -#include - - /* #include hierarchy for fractint is a follows: - Each module should include port.h as the first fractint specific - include. port.h includes , , , - ; and, ifndef XFRACT, . - Most modules should include prototyp.h, which incorporates by - direct or indirect reference the following header files: - mpmath.h - cmplx.h - fractint.h - big.h - biginit.h - helpcom.h - externs.h - Other modules may need the following, which must be included - separately: - fractype.h - helpdefs.h - lsys.y - targa.h - targa_lc.h - tplus.h - If included separately from prototyp.h, big.h includes cmplx.h - and biginit.h; and mpmath.h includes cmplx.h - */ - -#include "port.h" -#include "prototyp.h" -#include "fractype.h" -#include "helpdefs.h" -#include "drivers.h" - -struct videoinfo g_video_entry; -int helpmode; - -long timer_start,timer_interval; /* timer(...) start & total */ -int g_adapter; /* Video Adapter chosen from list in ...h */ -char *fract_dir1="", *fract_dir2=""; - -/* - the following variables are out here only so - that the calcfract() and assembler routines can get at them easily -*/ - int dotmode; /* video access method */ - int textsafe2; /* textsafe override from g_video_table */ - int g_ok_to_print; /* 0 if printf() won't work */ - int sxdots,sydots; /* # of dots on the physical screen */ - int sxoffs,syoffs; /* physical top left of logical screen */ - int xdots, ydots; /* # of dots on the logical screen */ - double dxsize, dysize; /* xdots-1, ydots-1 */ - int colors = 256; /* maximum colors available */ - long maxit; /* try this many iterations */ - int boxcount; /* 0 if no zoom-box yet */ - int zrotate; /* zoombox rotation */ - double zbx,zby; /* topleft of zoombox */ - double zwidth,zdepth,zskew; /* zoombox size & shape */ - - int fractype; /* if == 0, use Mandelbrot */ - char stdcalcmode; /* '1', '2', 'g', 'b' */ - long creal, cimag; /* real, imag'ry parts of C */ - long delx, dely; /* screen pixel increments */ - long delx2, dely2; /* screen pixel increments */ - LDBL delxx, delyy; /* screen pixel increments */ - LDBL delxx2, delyy2; /* screen pixel increments */ - long delmin; /* for calcfrac/calcmand */ - double ddelmin; /* same as a double */ - double param[MAXPARAMS]; /* parameters */ - double potparam[3]; /* three potential parameters*/ - long fudge; /* 2**fudgefactor */ - long l_at_rad; /* finite attractor radius */ - double f_at_rad; /* finite attractor radius */ - int bitshift; /* fudgefactor */ - - int g_bad_config = 0; /* 'fractint.cfg' ok? */ - int hasinverse = 0; - /* note that integer grid is set when integerfractal && !invert; */ - /* otherwise the floating point grid is set; never both at once */ - long *lx0, *ly0; /* x, y grid */ - long *lx1, *ly1; /* adjustment for rotate */ - /* note that lx1 & ly1 values can overflow into sign bit; since */ - /* they're used only to add to lx0/ly0, 2s comp straightens it out */ - double *dx0, *dy0; /* floating pt equivs */ - double *dx1, *dy1; - int integerfractal; /* TRUE if fractal uses integer math */ - - /* usr_xxx is what the user wants, vs what we may be forced to do */ - char usr_stdcalcmode; - int usr_periodicitycheck; - long usr_distest; - char usr_floatflag; - - int viewwindow; /* 0 for full screen, 1 for window */ - float viewreduction; /* window auto-sizing */ - int viewcrop; /* nonzero to crop default coords */ - float finalaspectratio; /* for view shape and rotation */ - int viewxdots,viewydots; /* explicit view sizing */ - int video_cutboth; /* nonzero to keep virtual aspect */ - int zscroll; /* screen/zoombox 0 fixed, 1 relaxed */ - -/* HISTORY *history = NULL; */ - U16 history = 0; - int maxhistory = 10; - -/* variables defined by the command line/files processor */ -int comparegif=0; /* compare two gif files flag */ -int timedsave=0; /* when doing a timed save */ -int resave_flag=0; /* tells encoder not to incr filename */ -int started_resaves=0; /* but incr on first resave */ -int save_system; /* from and for save files */ -int tabmode = 1; /* tab display enabled */ - -/* for historical reasons (before rotation): */ -/* top left corner of screen is (xxmin,yymax) */ -/* bottom left corner of screen is (xx3rd,yy3rd) */ -/* bottom right corner of screen is (xxmax,yymin) */ -double xxmin,xxmax,yymin,yymax,xx3rd,yy3rd; /* selected screen corners */ -long xmin, xmax, ymin, ymax, x3rd, y3rd; /* integer equivs */ -double sxmin,sxmax,symin,symax,sx3rd,sy3rd; /* displayed screen corners */ -double plotmx1,plotmx2,plotmy1,plotmy2; /* real->screen multipliers */ - -int calc_status = CALCSTAT_NO_FRACTAL; - /* -1 no fractal */ - /* 0 parms changed, recalc reqd */ - /* 1 actively calculating */ - /* 2 interrupted, resumable */ - /* 3 interrupted, not resumable */ - /* 4 completed */ -long calctime; - -int max_colors; /* maximum palette size */ -int zoomoff; /* = 0 when zoom is disabled */ -int savedac; /* save-the-Video DAC flag */ -int browsing; /* browse mode flag */ -char file_name_stack[16][13]; /* array of file names used while browsing */ -int name_stack_ptr ; -double toosmall; -int minbox; -int no_sub_images; -int autobrowse,doublecaution; -char brwscheckparms,brwschecktype; -char browsemask[13]; -int scale_map[12] = {1,2,3,4,5,6,7,8,9,10,11,12}; /*RB, array for mapping notes to a (user defined) scale */ - - -#define RESTART 1 -#define IMAGESTART 2 -#define RESTORESTART 3 -#define CONTINUE 4 - -void check_samename(void) - { - char drive[FILE_MAX_DRIVE]; - char dir[FILE_MAX_DIR]; - char fname[FILE_MAX_FNAME]; - char ext[FILE_MAX_EXT]; - char path[FILE_MAX_PATH]; - splitpath(savename,drive,dir,fname,ext); - if (strcmp(fname,"fract001")) - { - makepath(path,drive,dir,fname,"gif"); - if (access(path,0)==0) - exit(0); - } - } - -/* Do nothing if math error */ -static void my_floating_point_err(int sig) -{ - if (sig != 0) - overflow = 1; -} - -int main(int argc, char **argv) -{ - int resumeflag; - int kbdchar; /* keyboard key-hit value */ - int kbdmore; /* continuation variable */ - char stacked=0; /* flag to indicate screen stacked */ - - /* this traps non-math library floating point errors */ - signal( SIGFPE, my_floating_point_err ); - - initasmvars(); /* initialize ASM stuff */ - InitMemory(); - - /* let drivers add their video modes */ - if (! init_drivers(&argc, argv)) - { - init_failure("Sorry, I couldn't find any working video drivers for your system\n"); - exit(-1); - } - /* load fractint.cfg, match against driver supplied modes */ - load_fractint_config(); - init_help(); - - -restart: /* insert key re-starts here */ -#if defined(_WIN32) - _ASSERTE(_CrtCheckMemory()); -#endif - autobrowse = FALSE; - brwschecktype = TRUE; - brwscheckparms = TRUE; - doublecaution = TRUE; - no_sub_images = FALSE; - toosmall = 6; - minbox = 3; - strcpy(browsemask,"*.gif"); - strcpy(browsename," "); - name_stack_ptr= -1; /* init loaded files stack */ - - evolving = FALSE; - paramrangex = 4; - opx = newopx = -2.0; - paramrangey = 3; - opy = newopy = -1.5; - odpx = odpy = 0; - gridsz = 9; - fiddlefactor = 1; - fiddle_reduction = 1.0; - this_gen_rseed = (unsigned int)clock_ticks(); - srand(this_gen_rseed); - initgene(); /*initialise pointers to lots of fractint variables for the evolution engine*/ - start_showorbit = 0; - showdot = -1; /* turn off showdot if entered with command */ - calc_status = CALCSTAT_NO_FRACTAL; /* no active fractal image */ - - fract_dir1 = getenv("FRACTDIR"); - if (fract_dir1==NULL) - { - fract_dir1 = "."; - } -#ifdef SRCDIR - fract_dir2 = SRCDIR; -#else - fract_dir2 = "."; -#endif - - cmdfiles(argc,argv); /* process the command-line */ - dopause(0); /* pause for error msg if not batch */ - init_msg("",NULL,0); /* this causes driver_get_key if init_msg called on runup */ - - while (maxhistory > 0) /* decrease history if necessary */ - { - history = MemoryAlloc((U16) sizeof(HISTORY),(long) maxhistory, MEMORY); - if (history) - { - break; - } - maxhistory--; - } - - if (debugflag==450 && initbatch==1) /* abort if savename already exists */ - { - check_samename(); - } - driver_window(); - memcpy(olddacbox,g_dac_box,256*3); /* save in case colors= present */ - - if (debugflag == 8088) - { - cpu = 86; /* for testing purposes */ - } - if (debugflag == 2870 && fpu >= 287 ) - { - fpu = 287; /* for testing purposes */ - cpu = 286; - } - if (debugflag == 870 && fpu >= 87 ) - { - fpu = 87; /* for testing purposes */ - cpu = 86; - } - if (debugflag == 70) - { - fpu = 0; /* for testing purposes */ - } - if (getenv("NO87")) - { - fpu = 0; - } - - if (fpu >= 287 && debugflag != 72) /* Fast 287 math */ - { - setup287code(); - } - adapter_detect(); /* check what video is really present */ - - driver_set_for_text(); /* switch to text mode */ - savedac = 0; /* don't save the VGA DAC */ - -#ifndef XFRACT - if (g_bad_config < 0) /* fractint.cfg bad, no msg yet */ - { - bad_fractint_cfg_msg(); - } -#endif - - max_colors = 256; /* the Windows version is lower */ - max_kbdcount = (cpu >= 386) ? 80 : 30; /* check the keyboard this often */ - - if (showfile && g_init_mode < 0) - { - intro(); /* display the credits screen */ - if (driver_key_pressed() == FIK_ESC) - { - driver_get_key(); - goodbye(); - } - } - - browsing = FALSE; - - if (!functionpreloaded) - { - set_if_old_bif(); - } - stacked = 0; - -restorestart: -#if defined(_WIN32) - _ASSERTE(_CrtCheckMemory()); -#endif - - if (colorpreloaded) - { - memcpy(g_dac_box,olddacbox,256*3); /* restore in case colors= present */ - } - - lookatmouse = 0; /* ignore mouse */ - - while (showfile <= 0) /* image is to be loaded */ - { - char *hdg; - tabmode = 0; - if (!browsing ) /*RB*/ - { - if (overlay3d) - { - hdg = "Select File for 3D Overlay"; - helpmode = HELP3DOVLY; - } - else if (display3d) - { - hdg = "Select File for 3D Transform"; - helpmode = HELP3D; - } - else - { - hdg = "Select File to Restore"; - helpmode = HELPSAVEREST; - } - if (showfile < 0 && getafilename(hdg,gifmask,readname) < 0) - { - showfile = 1; /* cancelled */ - g_init_mode = -1; - break; - } - - name_stack_ptr = 0; /* 'r' reads first filename for browsing */ - strcpy(file_name_stack[name_stack_ptr],browsename); - } - - evolving = viewwindow = 0; - showfile = 0; - helpmode = -1; - tabmode = 1; - if (stacked) - { - driver_discard_screen(); - driver_set_for_text(); - stacked = 0; - } - if (read_overlay() == 0) /* read hdr, get video mode */ - { - break; /* got it, exit */ - } - if (browsing) /* break out of infinite loop, but lose your mind */ - { - showfile = 1; - } - else - { - showfile = -1; /* retry */ - } - } - - helpmode = HELPMENU; /* now use this help mode */ - tabmode = 1; - lookatmouse = 0; /* ignore mouse */ - - if (((overlay3d && !initbatch) || stacked) && g_init_mode < 0) /* overlay command failed */ - { - driver_unstack_screen(); /* restore the graphics screen */ - stacked = 0; - overlay3d = 0; /* forget overlays */ - display3d = 0; /* forget 3D */ - if (calc_status ==CALCSTAT_NON_RESUMABLE) - calc_status = CALCSTAT_PARAMS_CHANGED; - resumeflag = 1; - goto resumeloop; /* ooh, this is ugly */ - } - - savedac = 0; /* don't save the VGA DAC */ - -imagestart: /* calc/display a new image */ -#if defined(_WIN32) - _ASSERTE(_CrtCheckMemory()); -#endif - - if (stacked) - { - driver_discard_screen(); - stacked = 0; - } -#ifdef XFRACT - usr_floatflag = 1; -#endif - got_status = -1; /* for tab_display */ - - if (showfile) - if (calc_status > CALCSTAT_PARAMS_CHANGED) /* goto imagestart implies re-calc */ - calc_status = CALCSTAT_PARAMS_CHANGED; - - if (initbatch == 0) - lookatmouse = -FIK_PAGE_UP; /* just mouse left button, == pgup */ - - cyclelimit = initcyclelimit; /* default cycle limit */ - g_adapter = g_init_mode; /* set the video adapter up */ - g_init_mode = -1; /* (once) */ - - while (g_adapter < 0) /* cycle through instructions */ - { - if (initbatch) /* batch, nothing to do */ - { - initbatch = 4; /* exit with error condition set */ - goodbye(); - } - kbdchar = main_menu(0); - if (kbdchar == FIK_INSERT) goto restart; /* restart pgm on Insert Key */ - if (kbdchar == FIK_DELETE) /* select video mode list */ - kbdchar = select_video_mode(-1); - if ((g_adapter = check_vidmode_key(0,kbdchar)) >= 0) - break; /* got a video mode now */ -#ifndef XFRACT - if ('A' <= kbdchar && kbdchar <= 'Z') - kbdchar = tolower(kbdchar); -#endif - if (kbdchar == 'd') { /* shell to DOS */ - driver_set_clear(); -#if !defined(_WIN32) - /* don't use stdio without a console on Windows */ -#ifndef XFRACT - printf("\n\nShelling to DOS - type 'exit' to return\n\n"); -#else - printf("\n\nShelling to Linux/Unix - type 'exit' to return\n\n"); -#endif -#endif - driver_shell(); - goto imagestart; - } - -#ifndef XFRACT - if (kbdchar == '@' || kbdchar == '2') { /* execute commands */ -#else - if (kbdchar == FIK_F2 || kbdchar == '@') { /* We mapped @ to F2 */ -#endif - if ((get_commands() & CMDARG_3D_YES) == 0) - goto imagestart; - kbdchar = '3'; /* 3d=y so fall thru '3' code */ - } -#ifndef XFRACT - if (kbdchar == 'r' || kbdchar == '3' || kbdchar == '#') { -#else - if (kbdchar == 'r' || kbdchar == '3' || kbdchar == FIK_F3) { -#endif - display3d = 0; - if (kbdchar == '3' || kbdchar == '#' || kbdchar == FIK_F3) - display3d = 1; - if (colorpreloaded) - memcpy(olddacbox,g_dac_box,256*3); /* save in case colors= present */ - driver_set_for_text(); /* switch to text mode */ - showfile = -1; - goto restorestart; - } - if (kbdchar == 't') { /* set fractal type */ - julibrot = 0; - get_fracttype(); - goto imagestart; - } - if (kbdchar == 'x') { /* generic toggle switch */ - get_toggles(); - goto imagestart; - } - if (kbdchar == 'y') { /* generic toggle switch */ - get_toggles2(); - goto imagestart; - } - if (kbdchar == 'z') { /* type specific parms */ - get_fract_params(1); - goto imagestart; - } - if (kbdchar == 'v') { /* view parameters */ - get_view_params(); - goto imagestart; - } - if (kbdchar == 2) { /* ctrl B = browse parms*/ - get_browse_params(); - goto imagestart; - } - if (kbdchar == 6) { /* ctrl f = sound parms*/ - get_sound_params(); - goto imagestart; - } - if (kbdchar == 'f') { /* floating pt toggle */ - if (usr_floatflag == 0) - usr_floatflag = 1; - else - usr_floatflag = 0; - goto imagestart; - } - if (kbdchar == 'i') { /* set 3d fractal parms */ - get_fract3d_params(); /* get the parameters */ - goto imagestart; - } - if (kbdchar == 'g') { - get_cmd_string(); /* get command string */ - goto imagestart; - } - /* buzzer(2); */ /* unrecognized key */ - } - - zoomoff = 1; /* zooming is enabled */ - helpmode = HELPMAIN; /* now use this help mode */ - resumeflag = 0; /* allows taking goto inside big_while_loop() */ - -resumeloop: -#if defined(_WIN32) - _ASSERTE(_CrtCheckMemory()); -#endif - - param_history(0); /* save old history */ - /* this switch processes gotos that are now inside function */ - switch (big_while_loop(&kbdmore,&stacked,resumeflag)) - { - case RESTART: - goto restart; - case IMAGESTART: - goto imagestart; - case RESTORESTART: - goto restorestart; - default: - break; - } - - return 0; -} - -int check_key() -{ - int key = driver_key_pressed(); - if (key != 0) - { - if (show_orbit) - { - scrub_orbit(); - } - if (key != 'o' && key != 'O') - { - return -1; - } - driver_get_key(); - if (!driver_diskp()) - { - show_orbit = 1 - show_orbit; - } - } - return 0; -} - -/* timer function: - timer(0,(*fractal)()) fractal engine - timer(1,NULL,int width) decoder - timer(2) encoder - */ -#ifndef USE_VARARGS -int timer(int timertype,int(*subrtn)(),...) -#else -int timer(va_alist) -va_dcl -#endif -{ - va_list arg_marker; /* variable arg list */ - char *timestring; - time_t ltime; - FILE *fp = NULL; - int out=0; - int i; - int do_bench; - -#ifndef USE_VARARGS - va_start(arg_marker,subrtn); -#else - int timertype; - int (*subrtn)(); - va_start(arg_marker); - timertype = va_arg(arg_marker, int); - subrtn = (int (*)())va_arg(arg_marker, int *); -#endif - - do_bench = timerflag; /* record time? */ - if (timertype == 2) /* encoder, record time only if debug=200 */ - do_bench = (debugflag == 200); - if (do_bench) - fp=dir_fopen(workdir,"bench","a"); - timer_start = clock_ticks(); - switch (timertype) { - case 0: - out = (*(int(*)(void))subrtn)(); - break; - case 1: - i = va_arg(arg_marker,int); - out = (int)decoder((short)i); /* not indirect, safer with overlays */ - break; - case 2: - out = encoder(); /* not indirect, safer with overlays */ - break; - } - /* next assumes CLK_TCK is 10^n, n>=2 */ - timer_interval = (clock_ticks() - timer_start) / (CLK_TCK/100); - - if (do_bench) { - time(<ime); - timestring = ctime(<ime); - timestring[24] = 0; /*clobber newline in time string */ - switch (timertype) { - case 1: - fprintf(fp,"decode "); - break; - case 2: - fprintf(fp,"encode "); - break; - } - fprintf(fp,"%s type=%s resolution = %dx%d maxiter=%ld", - timestring, - curfractalspecific->name, - xdots, - ydots, - maxit); - fprintf(fp," time= %ld.%02ld secs\n",timer_interval/100,timer_interval%100); - if (fp != NULL) - fclose(fp); - } - return out; -} diff --git a/fractint/common/framain2.c b/fractint/common/framain2.c deleted file mode 100644 index 951e50158..000000000 --- a/fractint/common/framain2.c +++ /dev/null @@ -1,2513 +0,0 @@ -#include -#include - -#ifndef XFRACT -#include -#endif - -#ifndef USE_VARARGS -#include -#else -#include -#endif - -#include - /* see Fractint.c for a description of the "include" hierarchy */ -#include "port.h" -#include "prototyp.h" -#include "fractype.h" -#include "helpdefs.h" -#include "drivers.h" - -#if 0 -/* makes a handly list of jul-man pairs, not for release */ -static void julman() -{ - FILE *fp; - int i; - fp = dir_fopen(workdir,"toggle.txt","w"); - i = -1; - while (fractalspecific[++i].name) - { - if (fractalspecific[i].tojulia != NOFRACTAL && fractalspecific[i].name[0] != '*') - fprintf(fp,"%s %s\n",fractalspecific[i].name, - fractalspecific[fractalspecific[i].tojulia].name); - } - fclose(fp); -} -#endif - -/* routines in this module */ - -int main_menu_switch(int*,int*,int*,char*,int); -int evolver_menu_switch(int*,int*,int*,char*); -int big_while_loop(int *kbdmore, char *stacked, int resumeflag); -static void move_zoombox(int); -char fromtext_flag = 0; /* = 1 if we're in graphics mode */ -static int call_line3d(BYTE *pixels, int linelen); -static void note_zoom(void); -static void restore_zoom(void); -static void move_zoombox(int keynum); -static void cmp_line_cleanup(void); -static void _fastcall restore_history_info(int); -static void _fastcall save_history_info(void); - -U16 evolve_handle = 0; -char old_stdcalcmode; -static char *savezoom; -static int historyptr = -1; /* user pointer into history tbl */ -static int saveptr = 0; /* save ptr into history tbl */ -static int historyflag; /* are we backing off in history? */ -void (*outln_cleanup) (void); - -int big_while_loop(int *kbdmore, char *stacked, int resumeflag) -{ - int frommandel; /* if julia entered from mandel */ - int axmode = 0; /* video mode (BIOS ##) */ - double ftemp; /* fp temp */ - int i = 0; /* temporary loop counters */ - int kbdchar; - int mms_value; - -#if defined(_WIN32) - _ASSERTE(_CrtCheckMemory()); -#endif - frommandel = 0; - if (resumeflag) - goto resumeloop; - - while (1) /* eternal loop */ - { -#if defined(_WIN32) - _ASSERTE(_CrtCheckMemory()); -#endif - - if (calc_status != CALCSTAT_RESUMABLE || showfile == 0) - { - memcpy((char *)&g_video_entry, (char *)&g_video_table[g_adapter], - sizeof(g_video_entry)); - axmode = g_video_entry.videomodeax; /* video mode (BIOS call) */ - dotmode = g_video_entry.dotmode; /* assembler dot read/write */ - xdots = g_video_entry.xdots; /* # dots across the screen */ - ydots = g_video_entry.ydots; /* # dots down the screen */ - colors = g_video_entry.colors; /* # colors available */ - dotmode %= 100; - sxdots = xdots; - sydots = ydots; - sxoffs = syoffs = 0; - rotate_hi = (rotate_hi < colors) ? rotate_hi : colors - 1; - - memcpy(olddacbox, g_dac_box, 256*3); /* save the DAC */ - - if (overlay3d && !initbatch) - { - driver_unstack_screen(); /* restore old graphics image */ - overlay3d = 0; - } - else - { - driver_set_video_mode(&g_video_entry); /* switch video modes */ - /* switching video modes may have changed drivers or disk flag... */ - if (g_good_mode == 0) - { - if (driver_diskp()) - { - askvideo = TRUE; - } - else - { - stopmsg(0, "That video mode is not available with your adapter."); - askvideo = TRUE; - } - g_init_mode = -1; - driver_set_for_text(); /* switch to text mode */ - /* goto restorestart; */ - return RESTORESTART; - } - - if (g_virtual_screens && (xdots > sxdots || ydots > sydots)) - { - char buf[120]; - static char msgxy1[] = {"Can't set virtual line that long, width cut down."}; - static char msgxy2[] = {"Not enough video memory for that many lines, height cut down."}; - if (xdots > sxdots && ydots > sydots) - { - sprintf(buf, "%s\n%s", (char *) msgxy1, (char *) msgxy2); - stopmsg(0, buf); - } - else if (ydots > sydots) - { - stopmsg(0, msgxy2); - } - else - { - stopmsg(0, msgxy1); - } - } - xdots = sxdots; - ydots = sydots; - g_video_entry.xdots = xdots; - g_video_entry.ydots = ydots; - } - - if (savedac || colorpreloaded) - { - memcpy(g_dac_box, olddacbox, 256*3); /* restore the DAC */ - spindac(0, 1); - colorpreloaded = 0; - } - else - { /* reset DAC to defaults, which setvideomode has done for us */ - if (mapdacbox) - { /* but there's a map=, so load that */ - memcpy((char *)g_dac_box, mapdacbox, 768); - spindac(0, 1); - } - else if ((driver_diskp() && colors == 256) || !colors) - { - /* disk video, setvideomode via bios didn't get it right, so: */ -#if !defined(XFRACT) && !defined(_WIN32) - ValidateLuts("default"); /* read the default palette file */ -#endif - } - colorstate = 0; - } - if (viewwindow) - { - /* bypass for VESA virtual screen */ - ftemp = finalaspectratio*(((double) sydots)/((double) sxdots)/screenaspect); - if ((xdots = viewxdots) != 0) - { /* xdots specified */ - ydots = viewydots; - if (ydots == 0) /* calc ydots? */ - { - ydots = (int)((double)xdots * ftemp + 0.5); - } - } - else if (finalaspectratio <= screenaspect) - { - xdots = (int)((double)sxdots / viewreduction + 0.5); - ydots = (int)((double)xdots * ftemp + 0.5); - } - else - { - ydots = (int)((double)sydots / viewreduction + 0.5); - xdots = (int)((double)ydots / ftemp + 0.5); - } - if (xdots > sxdots || ydots > sydots) - { - stopmsg(0, "View window too large; using full screen."); - viewwindow = 0; - xdots = viewxdots = sxdots; - ydots = viewydots = sydots; - } - else if (((xdots <= 1) /* changed test to 1, so a 2x2 window will */ - || (ydots <= 1)) /* work with the sound feature */ - && !(evolving&1)) - { /* so ssg works */ - /* but no check if in evolve mode to allow lots of small views*/ - stopmsg(0, "View window too small; using full screen."); - viewwindow = 0; - xdots = sxdots; - ydots = sydots; - } - if ((evolving & 1) && (curfractalspecific->flags & INFCALC)) - { - stopmsg(0, "Fractal doesn't terminate! switching off evolution."); - evolving = evolving -1; - viewwindow = FALSE; - xdots = sxdots; - ydots = sydots; - } - if (evolving & 1) - { - xdots = (sxdots / gridsz)-!((evolving & NOGROUT)/NOGROUT); - xdots = xdots - (xdots % 4); /* trim to multiple of 4 for SSG */ - ydots = (sydots / gridsz)-!((evolving & NOGROUT)/NOGROUT); - ydots = ydots - (ydots % 4); - } - else - { - sxoffs = (sxdots - xdots) / 2; - syoffs = (sydots - ydots) / 3; - } - } - dxsize = xdots - 1; /* convert just once now */ - dysize = ydots - 1; - } - /* assume we save next time (except jb) */ - savedac = (savedac == 0) ? 2 : 1; - if (initbatch == 0) - { - lookatmouse = -FIK_PAGE_UP; /* mouse left button == pgup */ - } - - if (showfile == 0) - { /* loading an image */ - outln_cleanup = NULL; /* outln routine can set this */ - if (display3d) /* set up 3D decoding */ - { - outln = call_line3d; - } - else if (filetype >= 1) /* old .tga format input file */ - { - outln = outlin16; - } - else if (comparegif) /* debug 50 */ - { - outln = cmp_line; - } - else if (pot16bit) - { /* .pot format input file */ - if (pot_startdisk() < 0) - { /* pot file failed? */ - showfile = 1; - potflag = 0; - pot16bit = 0; - g_init_mode = -1; - calc_status = CALCSTAT_RESUMABLE; /* "resume" without 16-bit */ - driver_set_for_text(); - get_fracttype(); - /* goto imagestart; */ - return IMAGESTART; - } - outln = pot_line; - } - else if ((soundflag & SOUNDFLAG_ORBITMASK) > SOUNDFLAG_BEEP && !evolving) /* regular gif/fra input file */ - { - outln = sound_line; /* sound decoding */ - } - else - { - outln = out_line; /* regular decoding */ - } - if (filetype == 0) - { - if (debugflag == 2224) - { - char msg[MSGLEN]; - sprintf(msg, "floatflag=%d", usr_floatflag); - stopmsg(STOPMSG_NO_BUZZER, (char *)msg); - } - i = funny_glasses_call(gifview); - } - else - { - i = funny_glasses_call(tgaview); - } - if (outln_cleanup) /* cleanup routine defined? */ - { - (*outln_cleanup)(); - } - if (i == 0) - { - driver_buzzer(BUZZER_COMPLETE); - } - else - { - calc_status = CALCSTAT_NO_FRACTAL; - if (driver_key_pressed()) - { - driver_buzzer(BUZZER_INTERRUPT); - while (driver_key_pressed()) driver_get_key(); - texttempmsg("*** load incomplete ***"); - } - } - } - - zoomoff = 1; /* zooming is enabled */ - if (driver_diskp() || (curfractalspecific->flags&NOZOOM) != 0) - { - zoomoff = 0; /* for these cases disable zooming */ - } - if (!evolving) - { - calcfracinit(); - } - driver_schedule_alarm(1); - - sxmin = xxmin; /* save 3 corners for zoom.c ref points */ - sxmax = xxmax; - sx3rd = xx3rd; - symin = yymin; - symax = yymax; - sy3rd = yy3rd; - - if (bf_math) - { - copy_bf(bfsxmin, bfxmin); - copy_bf(bfsxmax, bfxmax); - copy_bf(bfsymin, bfymin); - copy_bf(bfsymax, bfymax); - copy_bf(bfsx3rd, bfx3rd); - copy_bf(bfsy3rd, bfy3rd); - } - save_history_info(); - - if (showfile == 0) - { /* image has been loaded */ - showfile = 1; - if (initbatch == 1 && calc_status == CALCSTAT_RESUMABLE) - { - initbatch = -1; /* flag to finish calc before save */ - } - if (loaded3d) /* 'r' of image created with '3' */ - { - display3d = 1; /* so set flag for 'b' command */ - } - } - else - { /* draw an image */ - if (initsavetime != 0 /* autosave and resumable? */ - && (curfractalspecific->flags&NORESUME) == 0) - { - savebase = readticker(); /* calc's start time */ - saveticks = abs(initsavetime); - saveticks *= 1092; /* bios ticks/minute */ - if ((saveticks & 65535L) == 0) - { - ++saveticks; /* make low word nonzero */ - } - finishrow = -1; - } - browsing = FALSE; /* regenerate image, turn off browsing */ - /*rb*/ - name_stack_ptr = -1; /* reset pointer */ - browsename[0] = '\0'; /* null */ - if (viewwindow && (evolving&1) && (calc_status != CALCSTAT_COMPLETED)) - { - /* generate a set of images with varied parameters on each one */ - int grout, ecount, tmpxdots, tmpydots, gridsqr; - struct evolution_info resume_e_info; - GENEBASE gene[NUMGENES]; - /* get the gene array from memory */ - MoveFromMemory((BYTE *)&gene, (U16)sizeof(gene), 1L, 0L, gene_handle); - if ((evolve_handle != 0) && (calc_status == CALCSTAT_RESUMABLE)) - { - MoveFromMemory((BYTE *)&resume_e_info, (U16)sizeof(resume_e_info), 1L, 0L, evolve_handle); - paramrangex = resume_e_info.paramrangex; - paramrangey = resume_e_info.paramrangey; - opx = newopx = resume_e_info.opx; - opy = newopy = resume_e_info.opy; - odpx = newodpx = (char)resume_e_info.odpx; - odpy = newodpy = (char)resume_e_info.odpy; - px = resume_e_info.px; - py = resume_e_info.py; - sxoffs = resume_e_info.sxoffs; - syoffs = resume_e_info.syoffs; - xdots = resume_e_info.xdots; - ydots = resume_e_info.ydots; - gridsz = resume_e_info.gridsz; - this_gen_rseed = resume_e_info.this_gen_rseed; - fiddlefactor = resume_e_info.fiddlefactor; - evolving = viewwindow = resume_e_info.evolving; - ecount = resume_e_info.ecount; - MemoryRelease(evolve_handle); /* We're done with it, release it. */ - evolve_handle = 0; - } - else - { /* not resuming, start from the beginning */ - int mid = gridsz / 2; - if ((px != mid) || (py != mid)) - { - this_gen_rseed = (unsigned int)clock_ticks(); /* time for new set */ - } - param_history(0); /* save old history */ - ecount = 0; - fiddlefactor = fiddlefactor * fiddle_reduction; - opx = newopx; opy = newopy; - odpx = newodpx; odpy = newodpy; /*odpx used for discrete parms like - inside, outside, trigfn etc */ - } - prmboxcount = 0; - dpx = paramrangex/(gridsz-1); - dpy = paramrangey/(gridsz-1); - grout = !((evolving & NOGROUT)/NOGROUT); - tmpxdots = xdots+grout; - tmpydots = ydots+grout; - gridsqr = gridsz * gridsz; - while (ecount < gridsqr) - { - spiralmap(ecount); /* sets px & py */ - sxoffs = tmpxdots * px; - syoffs = tmpydots * py; - param_history(1); /* restore old history */ - fiddleparms(gene, ecount); - calcfracinit(); - if (calcfract() == -1) - { - goto done; - } - ecount ++; - } -done: -#if defined(_WIN32) - _ASSERTE(_CrtCheckMemory()); -#endif - - if (ecount == gridsqr) - { - i = 0; - driver_buzzer(BUZZER_COMPLETE); /* finished!! */ - } - else - { /* interrupted screen generation, save info */ - /* TODO: MemoryAlloc */ - if (evolve_handle == 0) - { - evolve_handle = MemoryAlloc((U16)sizeof(resume_e_info), 1L, MEMORY); - } - resume_e_info.paramrangex = paramrangex; - resume_e_info.paramrangey = paramrangey; - resume_e_info.opx = opx; - resume_e_info.opy = opy; - resume_e_info.odpx = (short)odpx; - resume_e_info.odpy = (short)odpy; - resume_e_info.px = (short)px; - resume_e_info.py = (short)py; - resume_e_info.sxoffs = (short)sxoffs; - resume_e_info.syoffs = (short)syoffs; - resume_e_info.xdots = (short)xdots; - resume_e_info.ydots = (short)ydots; - resume_e_info.gridsz = (short)gridsz; - resume_e_info.this_gen_rseed = (short)this_gen_rseed; - resume_e_info.fiddlefactor = fiddlefactor; - resume_e_info.evolving = (short)evolving; - resume_e_info.ecount = (short) ecount; - MoveToMemory((BYTE *)&resume_e_info, (U16)sizeof(resume_e_info), 1L, 0L, evolve_handle); - } - sxoffs = syoffs = 0; - xdots = sxdots; - ydots = sydots; /* otherwise save only saves a sub image and boxes get clipped */ - - /* set up for 1st selected image, this reuses px and py */ - px = py = gridsz/2; - unspiralmap(); /* first time called, w/above line sets up array */ - param_history(1); /* restore old history */ - fiddleparms(gene, 0); - /* now put the gene array back in memory */ - MoveToMemory((BYTE *)&gene, (U16)sizeof(gene), 1L, 0L, gene_handle); - } - /* end of evolution loop */ - else - { - i = calcfract(); /* draw the fractal using "C" */ - if (i == 0) - { - driver_buzzer(BUZZER_COMPLETE); /* finished!! */ - } - } - - saveticks = 0; /* turn off autosave timer */ - if (driver_diskp() && i == 0) /* disk-video */ - { - dvid_status(0, "Image has been completed"); - } - } -#ifndef XFRACT - boxcount = 0; /* no zoom box yet */ - zwidth = 0; -#else - if (!XZoomWaiting) - { - boxcount = 0; /* no zoom box yet */ - zwidth = 0; - } -#endif - - if (fractype == PLASMA && cpu > 88) - { - cyclelimit = 256; /* plasma clouds need quick spins */ - g_dac_count = 256; - g_dac_learn = 1; - } - -resumeloop: /* return here on failed overlays */ -#if defined(_WIN32) - _ASSERTE(_CrtCheckMemory()); -#endif - - *kbdmore = 1; - while (*kbdmore == 1) - { /* loop through command keys */ - if (timedsave != 0) - { - if (timedsave == 1) - { /* woke up for timed save */ - driver_get_key(); /* eat the dummy char */ - kbdchar = 's'; /* do the save */ - resave_flag = 1; - timedsave = 2; - } - else - { /* save done, resume */ - timedsave = 0; - resave_flag = 2; - kbdchar = FIK_ENTER; - } - } - else if (initbatch == 0) /* not batch mode */ - { -#ifndef XFRACT - lookatmouse = (zwidth == 0 && !g_video_scroll) ? -FIK_PAGE_UP : 3; -#else - lookatmouse = (zwidth == 0) ? -FIK_PAGE_UP : 3; -#endif - if (calc_status == CALCSTAT_RESUMABLE && zwidth == 0 && !driver_key_pressed()) - { - kbdchar = FIK_ENTER ; /* no visible reason to stop, continue */ - } - else /* wait for a real keystroke */ - { - if (autobrowse && !no_sub_images) - { - kbdchar = 'l'; - } - else - { - driver_wait_key_pressed(0); - kbdchar = driver_get_key(); - } - if (kbdchar == FIK_ESC || kbdchar == 'm' || kbdchar == 'M') - { - if (kbdchar == FIK_ESC && escape_exit != 0) - { - /* don't ask, just get out */ - goodbye(); - } - driver_stack_screen(); -#ifndef XFRACT - kbdchar = main_menu(1); -#else - if (XZoomWaiting) - { - kbdchar = FIK_ENTER; - } - else - { - kbdchar = main_menu(1); - if (XZoomWaiting) - { - kbdchar = FIK_ENTER; - } - } -#endif - if (kbdchar == '\\' || kbdchar == FIK_CTL_BACKSLASH || - kbdchar == 'h' || kbdchar == 8 || - check_vidmode_key(0, kbdchar) >= 0) - { - driver_discard_screen(); - } - else if (kbdchar == 'x' || kbdchar == 'y' || - kbdchar == 'z' || kbdchar == 'g' || - kbdchar == 'v' || kbdchar == 2 || - kbdchar == 5 || kbdchar == 6) - { - fromtext_flag = 1; - } - else - { - driver_unstack_screen(); - } - } - } - } - else /* batch mode, fake next keystroke */ - { - /* initbatch == -1 flag to finish calc before save */ - /* initbatch == 0 not in batch mode */ - /* initbatch == 1 normal batch mode */ - /* initbatch == 2 was 1, now do a save */ - /* initbatch == 3 bailout with errorlevel == 2, error occurred, no save */ - /* initbatch == 4 bailout with errorlevel == 1, interrupted, try to save */ - /* initbatch == 5 was 4, now do a save */ - - if (initbatch == -1) /* finish calc */ - { - kbdchar = FIK_ENTER; - initbatch = 1; - } - else if (initbatch == 1 || initbatch == 4 ) /* save-to-disk */ - { -/* - while (driver_key_pressed()) - driver_get_key(); -*/ - kbdchar = (debugflag == 50) ? 'r' : 's'; - if (initbatch == 1) - { - initbatch = 2; - } - if (initbatch == 4) - { - initbatch = 5; - } - } - else - { - if (calc_status != CALCSTAT_COMPLETED) - { - initbatch = 3; /* bailout with error */ - } - goodbye(); /* done, exit */ - } - } - -#ifndef XFRACT - if ('A' <= kbdchar && kbdchar <= 'Z') - { - kbdchar = tolower(kbdchar); - } -#endif - if (evolving) - { - mms_value = evolver_menu_switch(&kbdchar, &frommandel, kbdmore, stacked); - } - else - { - mms_value = main_menu_switch(&kbdchar, &frommandel, kbdmore, stacked, axmode); - } - if (quick_calc && (mms_value == IMAGESTART || - mms_value == RESTORESTART || - mms_value == RESTART)) - { - quick_calc = 0; - usr_stdcalcmode = old_stdcalcmode; - } - if (quick_calc && calc_status != CALCSTAT_COMPLETED) - { - usr_stdcalcmode = '1'; - } - switch (mms_value) - { - case IMAGESTART: return IMAGESTART; - case RESTORESTART: return RESTORESTART; - case RESTART: return RESTART; - case CONTINUE: continue; - default: break; - } - if (zoomoff == 1 && *kbdmore == 1) /* draw/clear a zoom box? */ - { - drawbox(1); - } - if (driver_resize()) - { - calc_status = CALCSTAT_NO_FRACTAL; - } - } - } -} - -static int look(char *stacked) -{ - int oldhelpmode; - oldhelpmode = helpmode; - helpmode = HELPBROWSE; - switch (fgetwindow()) - { - case FIK_ENTER: - case FIK_ENTER_2: - showfile = 0; /* trigger load */ - browsing = TRUE; /* but don't ask for the file name as it's - * just been selected */ - if (name_stack_ptr == 15) - { /* about to run off the end of the file - * history stack so shift it all back one to - * make room, lose the 1st one */ - int tmp; - for (tmp = 1; tmp < 16; tmp++) - { - strcpy(file_name_stack[tmp - 1], file_name_stack[tmp]); - } - name_stack_ptr = 14; - } - name_stack_ptr++; - strcpy(file_name_stack[name_stack_ptr], browsename); - /* - splitpath(browsename, NULL, NULL, fname, ext); - splitpath(readname, drive, dir, NULL, NULL); - makepath(readname, drive, dir, fname, ext); - */ - merge_pathnames(readname, browsename, 2); - if (askvideo) - { - driver_stack_screen(); /* save graphics image */ - *stacked = 1; - } - return 1; /* hop off and do it!! */ - - case '\\': - if (name_stack_ptr >= 1) - { - /* go back one file if somewhere to go (ie. browsing) */ - name_stack_ptr--; - while (file_name_stack[name_stack_ptr][0] == '\0' - && name_stack_ptr >= 0) - { - name_stack_ptr--; - } - if (name_stack_ptr < 0) /* oops, must have deleted first one */ - { - break; - } - strcpy(browsename, file_name_stack[name_stack_ptr]); - merge_pathnames(readname,browsename,2); - browsing = TRUE; - showfile = 0; - if (askvideo) - { - driver_stack_screen();/* save graphics image */ - *stacked = 1; - } - return 1; - } /* otherwise fall through and turn off - * browsing */ - case FIK_ESC: - case 'l': /* turn it off */ - case 'L': - browsing = FALSE; - helpmode = oldhelpmode; - break; - - case 's': - browsing = FALSE; - helpmode = oldhelpmode; - savetodisk(savename); - break; - - default: /* or no files found, leave the state of browsing alone */ - break; - } - - return 0; -} - -int main_menu_switch(int *kbdchar, int *frommandel, int *kbdmore, char *stacked, int axmode) -{ - int i,k; - static double jxxmin, jxxmax, jyymin, jyymax; /* "Julia mode" entry point */ - static double jxx3rd, jyy3rd; - long old_maxit; - /* - char drive[FILE_MAX_DRIVE]; - char dir[FILE_MAX_DIR]; - char fname[FILE_MAX_FNAME]; - char ext[FILE_MAX_EXT]; - */ - if (quick_calc && calc_status == CALCSTAT_COMPLETED) { - quick_calc = 0; - usr_stdcalcmode = old_stdcalcmode; - } - if (quick_calc && calc_status != CALCSTAT_COMPLETED) - usr_stdcalcmode = old_stdcalcmode; - switch (*kbdchar) - { - case 't': /* new fractal type */ - julibrot = 0; - clear_zoombox(); - driver_stack_screen(); - if ((i = get_fracttype()) >= 0) - { - driver_discard_screen(); - savedac = 0; - save_release = g_release; - no_mag_calc = 0; - use_old_period = 0; - bad_outside = 0; - ldcheck = 0; - set_current_params(); - odpx=odpy=newodpx=newodpy=0; - fiddlefactor = 1; /* reset param evolution stuff */ - set_orbit_corners = 0; - param_history(0); /* save history */ - if (i == 0) - { - g_init_mode = g_adapter; - *frommandel = 0; - } - else if (g_init_mode < 0) /* it is supposed to be... */ - driver_set_for_text(); /* reset to text mode */ - return IMAGESTART; - } - driver_unstack_screen(); - break; - case FIK_CTL_X: /* Ctl-X, Ctl-Y, CTL-Z do flipping */ - case FIK_CTL_Y: - case FIK_CTL_Z: - flip_image(*kbdchar); - break; - case 'x': /* invoke options screen */ - case 'y': - case 'p': /* passes options */ - case 'z': /* type specific parms */ - case 'g': - case 'v': - case FIK_CTL_B: - case FIK_CTL_E: - case FIK_CTL_F: - old_maxit = maxit; - clear_zoombox(); - if (fromtext_flag == 1) - fromtext_flag = 0; - else - driver_stack_screen(); - if (*kbdchar == 'x') - i = get_toggles(); - else if (*kbdchar == 'y') - i = get_toggles2(); - else if (*kbdchar == 'p') - i = passes_options(); - else if (*kbdchar == 'z') - i = get_fract_params(1); - else if (*kbdchar == 'v') - i = get_view_params(); /* get the parameters */ - else if (*kbdchar == FIK_CTL_B) - i = get_browse_params(); - else if (*kbdchar == FIK_CTL_E) { - i = get_evolve_Parms(); - if (i > 0) { - start_showorbit = 0; - soundflag &= ~(SOUNDFLAG_X | SOUNDFLAG_Y | SOUNDFLAG_Z); /* turn off only x,y,z */ - Log_Auto_Calc = 0; /* turn it off */ - } - } - else if (*kbdchar == FIK_CTL_F) - i = get_sound_params(); - else - i = get_cmd_string(); - driver_unstack_screen(); - if (evolving && truecolor) - truecolor = 0; /* truecolor doesn't play well with the evolver */ - if (maxit > old_maxit && inside >= 0 && calc_status == CALCSTAT_COMPLETED && - curfractalspecific->calctype == StandardFractal && !LogFlag && - !truecolor && /* recalc not yet implemented with truecolor */ - !(usr_stdcalcmode == 't' && fillcolor > -1) && - /* tesseral with fill doesn't work */ - !(usr_stdcalcmode == 'o') && - i == 1 && /* nothing else changed */ - outside != ATAN ) { - quick_calc = 1; - old_stdcalcmode = usr_stdcalcmode; - usr_stdcalcmode = '1'; - *kbdmore = 0; - calc_status = CALCSTAT_RESUMABLE; - i = 0; - } - else if (i > 0) { /* time to redraw? */ - quick_calc = 0; - param_history(0); /* save history */ - *kbdmore = 0; - calc_status = CALCSTAT_PARAMS_CHANGED; - } - break; -#ifndef XFRACT - case '@': /* execute commands */ - case '2': /* execute commands */ -#else - case FIK_F2: /* execute commands */ -#endif - driver_stack_screen(); - i = get_commands(); - if (g_init_mode != -1) - { /* video= was specified */ - g_adapter = g_init_mode; - g_init_mode = -1; - i |= CMDARG_FRACTAL_PARAM; - savedac = 0; - } - else if (colorpreloaded) - { /* colors= was specified */ - spindac(0, 1); - colorpreloaded = 0; - } - else if (i & CMDARG_RESET) /* reset was specified */ - savedac = 0; - if (i & CMDARG_3D_YES) - { /* 3d = was specified */ - *kbdchar = '3'; - driver_unstack_screen(); - goto do_3d_transform; /* pretend '3' was keyed */ - } - if (i & CMDARG_FRACTAL_PARAM) - { /* fractal parameter changed */ - driver_discard_screen(); - /* backwards_v18();*/ /* moved this to cmdfiles.c */ - /* backwards_v19();*/ - *kbdmore = 0; - calc_status = CALCSTAT_PARAMS_CHANGED; - } - else - driver_unstack_screen(); - break; - case 'f': /* floating pt toggle */ - if (usr_floatflag == 0) - usr_floatflag = 1; - else if (stdcalcmode != 'o') /* don't go there */ - usr_floatflag = 0; - g_init_mode = g_adapter; - return IMAGESTART; - case 'i': /* 3d fractal parms */ - if (get_fract3d_params() >= 0) /* get the parameters */ - { - calc_status = CALCSTAT_PARAMS_CHANGED; - *kbdmore = 0; /* time to redraw */ - } - break; -#if 0 - case 'w': - /*chk_keys();*/ - /*julman();*/ - break; -#endif - case FIK_CTL_A: /* ^a Ant */ - clear_zoombox(); - { - int oldtype, err, i; - double oldparm[MAXPARAMS]; - oldtype = fractype; - for (i=0; i= 0) - { - driver_unstack_screen(); - if (ant() >= 0) - calc_status = CALCSTAT_PARAMS_CHANGED; - } - else - driver_unstack_screen(); - fractype = oldtype; - for (i=0; i= 0) - return CONTINUE; - } - break; - case 'k': /* ^s is irritating, give user a single key */ - case FIK_CTL_S: /* ^s RDS */ - clear_zoombox(); - if (get_rds_params() >= 0) - { - if (do_AutoStereo() >= 0) - calc_status = CALCSTAT_PARAMS_CHANGED; - return CONTINUE; - } - break; - case 'a': /* starfield parms */ - clear_zoombox(); - if (get_starfield_params() >= 0) - { - if (starfield() >= 0) - calc_status = CALCSTAT_PARAMS_CHANGED; - return CONTINUE; - } - break; - case FIK_CTL_O: /* ctrl-o */ - case 'o': - /* must use standard fractal and have a float variant */ - if ((fractalspecific[fractype].calctype == StandardFractal - || fractalspecific[fractype].calctype == calcfroth) && - (fractalspecific[fractype].isinteger == 0 || - fractalspecific[fractype].tofloat != NOFRACTAL) && - !bf_math && /* for now no arbitrary precision support */ - !(g_is_true_color && truemode) ) - { - clear_zoombox(); - Jiim(ORBIT); - } - break; - case FIK_SPACE: /* spacebar, toggle mand/julia */ - if (bf_math || evolving) - break; - if (fractype == CELLULAR) - { - if (nxtscreenflag) - nxtscreenflag = 0; /* toggle flag to stop generation */ - else - nxtscreenflag = 1; /* toggle flag to generate next screen */ - calc_status = CALCSTAT_RESUMABLE; - *kbdmore = 0; - } - else - { - if (fractype == FORMULA || fractype == FFORMULA) - { - if (ismand) - { - fractalspecific[fractype].tojulia = fractype; - fractalspecific[fractype].tomandel = NOFRACTAL; - ismand = 0; - } - else - { - fractalspecific[fractype].tojulia = NOFRACTAL; - fractalspecific[fractype].tomandel = fractype; - ismand = 1; - } - } - if (curfractalspecific->tojulia != NOFRACTAL - && param[0] == 0.0 && param[1] == 0.0) - { - /* switch to corresponding Julia set */ - int key; - if ((fractype == MANDEL || fractype == MANDELFP) && bf_math == 0) - hasinverse = 1; - else - hasinverse = 0; - clear_zoombox(); - Jiim(JIIM); - key = driver_get_key(); /* flush keyboard buffer */ - if (key != FIK_SPACE) - { - driver_unget_key(key); - break; - } - fractype = curfractalspecific->tojulia; - curfractalspecific = &fractalspecific[fractype]; - if (xcjul == BIG || ycjul == BIG) - { - param[0] = (xxmax + xxmin) / 2; - param[1] = (yymax + yymin) / 2; - } - else - { - param[0] = xcjul; - param[1] = ycjul; - xcjul = ycjul = BIG; - } - jxxmin = sxmin; - jxxmax = sxmax; - jyymax = symax; - jyymin = symin; - jxx3rd = sx3rd; - jyy3rd = sy3rd; - *frommandel = 1; - xxmin = curfractalspecific->xmin; - xxmax = curfractalspecific->xmax; - yymin = curfractalspecific->ymin; - yymax = curfractalspecific->ymax; - xx3rd = xxmin; - yy3rd = yymin; - if (usr_distest == 0 && usr_biomorph != -1 && bitshift != 29) - { - xxmin *= 3.0; - xxmax *= 3.0; - yymin *= 3.0; - yymax *= 3.0; - xx3rd *= 3.0; - yy3rd *= 3.0; - } - zoomoff = 1; - calc_status = CALCSTAT_PARAMS_CHANGED; - *kbdmore = 0; - } - else if (curfractalspecific->tomandel != NOFRACTAL) - { - /* switch to corresponding Mandel set */ - fractype = curfractalspecific->tomandel; - curfractalspecific = &fractalspecific[fractype]; - if (*frommandel) - { - xxmin = jxxmin; - xxmax = jxxmax; - yymin = jyymin; - yymax = jyymax; - xx3rd = jxx3rd; - yy3rd = jyy3rd; - } - else - { - xxmin = xx3rd = curfractalspecific->xmin; - xxmax = curfractalspecific->xmax; - yymin = yy3rd = curfractalspecific->ymin; - yymax = curfractalspecific->ymax; - } - SaveC.x = param[0]; - SaveC.y = param[1]; - param[0] = 0; - param[1] = 0; - zoomoff = 1; - calc_status = CALCSTAT_PARAMS_CHANGED; - *kbdmore = 0; - } - else - driver_buzzer(BUZZER_ERROR); /* can't switch */ - } /* end of else for if == cellular */ - break; - case 'j': /* inverse julia toggle */ - /* if the inverse types proliferate, something more elegant will be - * needed */ - if (fractype == JULIA || fractype == JULIAFP || fractype == INVERSEJULIA) - { - static int oldtype = -1; - if (fractype == JULIA || fractype == JULIAFP) - { - oldtype = fractype; - fractype = INVERSEJULIA; - } - else if (fractype == INVERSEJULIA) - { - if (oldtype != -1) - fractype = oldtype; - else - fractype = JULIA; - } - curfractalspecific = &fractalspecific[fractype]; - zoomoff = 1; - calc_status = CALCSTAT_PARAMS_CHANGED; - *kbdmore = 0; - } -#if 0 - else if (fractype == MANDEL || fractype == MANDELFP) - { - clear_zoombox(); - Jiim(JIIM); - } -#endif - else - driver_buzzer(BUZZER_ERROR); - break; - case '\\': /* return to prev image */ - case FIK_CTL_BACKSLASH: - case 'h': - case FIK_BACKSPACE: - if (name_stack_ptr >= 1) - { - /* go back one file if somewhere to go (ie. browsing) */ - name_stack_ptr--; - while (file_name_stack[name_stack_ptr][0] == '\0' - && name_stack_ptr >= 0) - name_stack_ptr--; - if (name_stack_ptr < 0) /* oops, must have deleted first one */ - break; - strcpy(browsename, file_name_stack[name_stack_ptr]); - /* - splitpath(browsename, NULL, NULL, fname, ext); - splitpath(readname, drive, dir, NULL, NULL); - makepath(readname, drive, dir, fname, ext); - */ - merge_pathnames(readname,browsename,2); - browsing = TRUE; - no_sub_images = FALSE; - showfile = 0; - if (askvideo) - { - driver_stack_screen(); /* save graphics image */ - *stacked = 1; - } - return RESTORESTART; - } - else if (maxhistory > 0 && bf_math == 0) - { - if (*kbdchar == '\\' || *kbdchar == 'h') - if (--historyptr < 0) - historyptr = maxhistory - 1; - if (*kbdchar == FIK_CTL_BACKSLASH || *kbdchar == FIK_BACKSPACE) - if (++historyptr >= maxhistory) - historyptr = 0; - restore_history_info(historyptr); - zoomoff = 1; - g_init_mode = g_adapter; - if (curfractalspecific->isinteger != 0 && - curfractalspecific->tofloat != NOFRACTAL) - usr_floatflag = 0; - if (curfractalspecific->isinteger == 0 && - curfractalspecific->tofloat != NOFRACTAL) - usr_floatflag = 1; - historyflag = 1; /* avoid re-store parms due to rounding errs */ - return IMAGESTART; - } - break; - case 'd': /* shell to MS-DOS */ - driver_stack_screen(); - driver_shell(); - driver_unstack_screen(); - break; - - case 'c': /* switch to color cycling */ - case '+': /* rotate palette */ - case '-': /* rotate palette */ - clear_zoombox(); - memcpy(olddacbox, g_dac_box, 256 * 3); - rotate((*kbdchar == 'c') ? 0 : ((*kbdchar == '+') ? 1 : -1)); - if (memcmp(olddacbox, g_dac_box, 256 * 3)) - { - colorstate = 1; - save_history_info(); - } - return CONTINUE; - case 'e': /* switch to color editing */ - if (g_is_true_color && !initbatch) { /* don't enter palette editor */ - if (load_palette() >= 0) { - *kbdmore = 0; - calc_status = CALCSTAT_PARAMS_CHANGED; - break; - } else - return CONTINUE; - } - clear_zoombox(); - if (g_dac_box[0][0] != 255 && !g_really_ega && colors >= 16 - && !driver_diskp()) - { - int oldhelpmode; - oldhelpmode = helpmode; - memcpy(olddacbox, g_dac_box, 256 * 3); - helpmode = HELPXHAIR; - EditPalette(); - helpmode = oldhelpmode; - if (memcmp(olddacbox, g_dac_box, 256 * 3)) - { - colorstate = 1; - save_history_info(); - } - } - return CONTINUE; - case 's': /* save-to-disk */ - if (driver_diskp() && disktarga == 1) - return CONTINUE; /* disk video and targa, nothing to save */ - note_zoom(); - savetodisk(savename); - restore_zoom(); - return CONTINUE; - case '#': /* 3D overlay */ -#ifdef XFRACT - case FIK_F3: /* 3D overlay */ -#endif - clear_zoombox(); - overlay3d = 1; - case '3': /* restore-from (3d) */ - do_3d_transform: - if (overlay3d) - display3d = 2; /* for command */ - else - display3d = 1; - case 'r': /* restore-from */ - comparegif = 0; - *frommandel = 0; - if (browsing) - { - browsing = FALSE; - } - if (*kbdchar == 'r') - { - if (debugflag == 50) - { - comparegif = overlay3d = 1; - if (initbatch == 2) - { - driver_stack_screen(); /* save graphics image */ - strcpy(readname, savename); - showfile = 0; - return RESTORESTART; - } - } - else - comparegif = overlay3d = 0; - display3d = 0; - } - driver_stack_screen(); /* save graphics image */ - if (overlay3d) - *stacked = 0; - else - *stacked = 1; - if (resave_flag) - { - updatesavename(savename); /* do the pending increment */ - resave_flag = started_resaves = 0; - } - showfile = -1; - return RESTORESTART; - case 'l': - case 'L': /* Look for other files within this view */ - if ((zwidth != 0) || driver_diskp()) - { - browsing = FALSE; - driver_buzzer(BUZZER_ERROR); /* can't browse if zooming or disk video */ - } - else if (look(stacked)) - { - return RESTORESTART; - } - break; - case 'b': /* make batch file */ - make_batch_file(); - break; - case FIK_CTL_P: /* print current image */ - driver_buzzer(BUZZER_INTERRUPT); - return CONTINUE; - case FIK_ENTER: /* Enter */ - case FIK_ENTER_2: /* Numeric-Keypad Enter */ -#ifdef XFRACT - XZoomWaiting = 0; -#endif - if (zwidth != 0.0) - { /* do a zoom */ - init_pan_or_recalc(0); - *kbdmore = 0; - } - if (calc_status != CALCSTAT_COMPLETED) /* don't restart if image complete */ - *kbdmore = 0; - break; - case FIK_CTL_ENTER: /* control-Enter */ - case FIK_CTL_ENTER_2: /* Control-Keypad Enter */ - init_pan_or_recalc(1); - *kbdmore = 0; - zoomout(); /* calc corners for zooming out */ - break; - case FIK_INSERT: /* insert */ - driver_set_for_text(); /* force text mode */ - return RESTART; - case FIK_LEFT_ARROW: /* cursor left */ - case FIK_RIGHT_ARROW: /* cursor right */ - case FIK_UP_ARROW: /* cursor up */ - case FIK_DOWN_ARROW: /* cursor down */ - move_zoombox(*kbdchar); - break; - case FIK_CTL_LEFT_ARROW: /* Ctrl-cursor left */ - case FIK_CTL_RIGHT_ARROW: /* Ctrl-cursor right */ - case FIK_CTL_UP_ARROW: /* Ctrl-cursor up */ - case FIK_CTL_DOWN_ARROW: /* Ctrl-cursor down */ - move_zoombox(*kbdchar); - break; - case FIK_CTL_HOME: /* Ctrl-home */ - if (boxcount && (curfractalspecific->flags & NOROTATE) == 0) - { - i = key_count(FIK_CTL_HOME); - if ((zskew -= 0.02 * i) < -0.48) - zskew = -0.48; - } - break; - case FIK_CTL_END: /* Ctrl-end */ - if (boxcount && (curfractalspecific->flags & NOROTATE) == 0) - { - i = key_count(FIK_CTL_END); - if ((zskew += 0.02 * i) > 0.48) - zskew = 0.48; - } - break; - case FIK_CTL_PAGE_UP: /* Ctrl-pgup */ - if (boxcount) - chgboxi(0, -2 * key_count(FIK_CTL_PAGE_UP)); - break; - case FIK_CTL_PAGE_DOWN: /* Ctrl-pgdn */ - if (boxcount) - chgboxi(0, 2 * key_count(FIK_CTL_PAGE_DOWN)); - break; - - case FIK_PAGE_UP: /* page up */ - if (zoomoff == 1) - { - if (zwidth == 0) - { /* start zoombox */ - zwidth = zdepth = 1; - zskew = zrotate = 0; - zbx = zby = 0; - find_special_colors(); - boxcolor = g_color_bright; - px = py = gridsz/2; - moveboxf(0.0,0.0); /* force scrolling */ - } - else - resizebox(0 - key_count(FIK_PAGE_UP)); - } - break; - case FIK_PAGE_DOWN: /* page down */ - if (boxcount) - { - if (zwidth >= .999 && zdepth >= 0.999) /* end zoombox */ - zwidth = 0; - else - resizebox(key_count(FIK_PAGE_DOWN)); - } - break; - case FIK_CTL_MINUS: /* Ctrl-kpad- */ - if (boxcount && (curfractalspecific->flags & NOROTATE) == 0) - zrotate += key_count(FIK_CTL_MINUS); - break; - case FIK_CTL_PLUS: /* Ctrl-kpad+ */ - if (boxcount && (curfractalspecific->flags & NOROTATE) == 0) - zrotate -= key_count(FIK_CTL_PLUS); - break; - case FIK_CTL_INSERT: /* Ctrl-ins */ - boxcolor += key_count(FIK_CTL_INSERT); - break; - case FIK_CTL_DEL: /* Ctrl-del */ - boxcolor -= key_count(FIK_CTL_DEL); - break; - - case 1120: /* alt + number keys set mutation level and start evolution engine */ - case 1121: - case 1122: - case 1123: - case 1124: - case 1125: - case 1126: -/* - case 1127: - case 1128: -*/ - viewwindow = evolving = 1; - set_mutation_level(*kbdchar-1119); - param_history(0); /* save parameter history */ - *kbdmore = 0; - calc_status = CALCSTAT_PARAMS_CHANGED; - break; - - case FIK_DELETE: /* select video mode from list */ - { - driver_stack_screen(); - *kbdchar = select_video_mode(g_adapter); - if (check_vidmode_key(0, *kbdchar) >= 0) /* picked a new mode? */ - driver_discard_screen(); - else - driver_unstack_screen(); - /* fall through */ - } - default: /* other (maybe a valid Fn key) */ - if ((k = check_vidmode_key(0, *kbdchar)) >= 0) - { - g_adapter = k; - if (g_video_table[g_adapter].colors != colors) - savedac = 0; - calc_status = CALCSTAT_PARAMS_CHANGED; - *kbdmore = 0; - return CONTINUE; - } - break; - } /* end of the big switch */ - return 0; -} - -int evolver_menu_switch(int *kbdchar, int *frommandel, int *kbdmore, char *stacked) -{ - int i,k; - - switch (*kbdchar) - { - case 't': /* new fractal type */ - julibrot = 0; - clear_zoombox(); - driver_stack_screen(); - if ((i = get_fracttype()) >= 0) - { - driver_discard_screen(); - savedac = 0; - save_release = g_release; - no_mag_calc = 0; - use_old_period = 0; - bad_outside = 0; - ldcheck = 0; - set_current_params(); - odpx=odpy=newodpx=newodpy=0; - fiddlefactor = 1; /* reset param evolution stuff */ - set_orbit_corners = 0; - param_history(0); /* save history */ - if (i == 0) - { - g_init_mode = g_adapter; - *frommandel = 0; - } - else if (g_init_mode < 0) /* it is supposed to be... */ - driver_set_for_text(); /* reset to text mode */ - return IMAGESTART; - } - driver_unstack_screen(); - break; - case 'x': /* invoke options screen */ - case 'y': - case 'p': /* passes options */ - case 'z': /* type specific parms */ - case 'g': - case FIK_CTL_E: - case FIK_SPACE: - clear_zoombox(); - if (fromtext_flag == 1) - fromtext_flag = 0; - else - driver_stack_screen(); - if (*kbdchar == 'x') - i = get_toggles(); - else if (*kbdchar == 'y') - i = get_toggles2(); - else if (*kbdchar == 'p') - i = passes_options(); - else if (*kbdchar == 'z') - i = get_fract_params(1); - else if (*kbdchar == 5 || *kbdchar == FIK_SPACE) - i = get_evolve_Parms(); - else - i = get_cmd_string(); - driver_unstack_screen(); - if (evolving && truecolor) - truecolor = 0; /* truecolor doesn't play well with the evolver */ - if (i > 0) { /* time to redraw? */ - param_history(0); /* save history */ - *kbdmore = 0; - calc_status = CALCSTAT_PARAMS_CHANGED; - } - break; - case 'b': /* quick exit from evolve mode */ - evolving = viewwindow = 0; - param_history(0); /* save history */ - *kbdmore = 0; - calc_status = CALCSTAT_PARAMS_CHANGED; - break; - - case 'f': /* floating pt toggle */ - if (usr_floatflag == 0) - usr_floatflag = 1; - else if (stdcalcmode != 'o') /* don't go there */ - usr_floatflag = 0; - g_init_mode = g_adapter; - return IMAGESTART; - case '\\': /* return to prev image */ - case FIK_CTL_BACKSLASH: - case 'h': - case FIK_BACKSPACE: - if (maxhistory > 0 && bf_math == 0) - { - if (*kbdchar == '\\' || *kbdchar == 'h') - if (--historyptr < 0) - historyptr = maxhistory - 1; - if (*kbdchar == FIK_CTL_BACKSLASH || *kbdchar == 8) - if (++historyptr >= maxhistory) - historyptr = 0; - restore_history_info(historyptr); - zoomoff = 1; - g_init_mode = g_adapter; - if (curfractalspecific->isinteger != 0 && - curfractalspecific->tofloat != NOFRACTAL) - usr_floatflag = 0; - if (curfractalspecific->isinteger == 0 && - curfractalspecific->tofloat != NOFRACTAL) - usr_floatflag = 1; - historyflag = 1; /* avoid re-store parms due to rounding errs */ - return IMAGESTART; - } - break; - case 'c': /* switch to color cycling */ - case '+': /* rotate palette */ - case '-': /* rotate palette */ - clear_zoombox(); - memcpy(olddacbox, g_dac_box, 256 * 3); - rotate((*kbdchar == 'c') ? 0 : ((*kbdchar == '+') ? 1 : -1)); - if (memcmp(olddacbox, g_dac_box, 256 * 3)) - { - colorstate = 1; - save_history_info(); - } - return CONTINUE; - case 'e': /* switch to color editing */ - if (g_is_true_color && !initbatch) { /* don't enter palette editor */ - if (load_palette() >= 0) { - *kbdmore = 0; - calc_status = CALCSTAT_PARAMS_CHANGED; - break; - } else - return CONTINUE; - } - clear_zoombox(); - if (g_dac_box[0][0] != 255 && !g_really_ega && colors >= 16 - && !driver_diskp()) - { - int oldhelpmode; - oldhelpmode = helpmode; - memcpy(olddacbox, g_dac_box, 256 * 3); - helpmode = HELPXHAIR; - EditPalette(); - helpmode = oldhelpmode; - if (memcmp(olddacbox, g_dac_box, 256 * 3)) - { - colorstate = 1; - save_history_info(); - } - } - return CONTINUE; - case 's': /* save-to-disk */ -{ int oldsxoffs, oldsyoffs, oldxdots, oldydots, oldpx, oldpy; - GENEBASE gene[NUMGENES]; - - if (driver_diskp() && disktarga == 1) - return CONTINUE; /* disk video and targa, nothing to save */ - /* get the gene array from memory */ - MoveFromMemory((BYTE *)&gene, (U16)sizeof(gene), 1L, 0L, gene_handle); - oldsxoffs = sxoffs; - oldsyoffs = syoffs; - oldxdots = xdots; - oldydots = ydots; - oldpx = px; - oldpy = py; - sxoffs = syoffs = 0; - xdots = sxdots; - ydots = sydots; /* for full screen save and pointer move stuff */ - px = py = gridsz / 2; - param_history(1); /* restore old history */ - fiddleparms(gene, 0); - drawparmbox(1); - savetodisk(savename); - px = oldpx; - py = oldpy; - param_history(1); /* restore old history */ - fiddleparms(gene, unspiralmap()); - sxoffs = oldsxoffs; - syoffs = oldsyoffs; - xdots = oldxdots; - ydots = oldydots; - MoveToMemory((BYTE *)&gene, (U16)sizeof(gene), 1L, 0L, gene_handle); -} - return CONTINUE; - case 'r': /* restore-from */ - comparegif = 0; - *frommandel = 0; - if (browsing) - { - browsing = FALSE; - } - if (*kbdchar == 'r') - { - if (debugflag == 50) - { - comparegif = overlay3d = 1; - if (initbatch == 2) - { - driver_stack_screen(); /* save graphics image */ - strcpy(readname, savename); - showfile = 0; - return RESTORESTART; - } - } - else - comparegif = overlay3d = 0; - display3d = 0; - } - driver_stack_screen(); /* save graphics image */ - if (overlay3d) - *stacked = 0; - else - *stacked = 1; - if (resave_flag) - { - updatesavename(savename); /* do the pending increment */ - resave_flag = started_resaves = 0; - } - showfile = -1; - return RESTORESTART; - case FIK_ENTER: /* Enter */ - case FIK_ENTER_2: /* Numeric-Keypad Enter */ -#ifdef XFRACT - XZoomWaiting = 0; -#endif - if (zwidth != 0.0) - { /* do a zoom */ - init_pan_or_recalc(0); - *kbdmore = 0; - } - if (calc_status != CALCSTAT_COMPLETED) /* don't restart if image complete */ - *kbdmore = 0; - break; - case FIK_CTL_ENTER: /* control-Enter */ - case FIK_CTL_ENTER_2: /* Control-Keypad Enter */ - init_pan_or_recalc(1); - *kbdmore = 0; - zoomout(); /* calc corners for zooming out */ - break; - case FIK_INSERT: /* insert */ - driver_set_for_text(); /* force text mode */ - return RESTART; - case FIK_LEFT_ARROW: /* cursor left */ - case FIK_RIGHT_ARROW: /* cursor right */ - case FIK_UP_ARROW: /* cursor up */ - case FIK_DOWN_ARROW: /* cursor down */ - move_zoombox(*kbdchar); - break; - case FIK_CTL_LEFT_ARROW: /* Ctrl-cursor left */ - case FIK_CTL_RIGHT_ARROW: /* Ctrl-cursor right */ - case FIK_CTL_UP_ARROW: /* Ctrl-cursor up */ - case FIK_CTL_DOWN_ARROW: /* Ctrl-cursor down */ - /* borrow ctrl cursor keys for moving selection box */ - /* in evolver mode */ - if (boxcount) { - int grout; - GENEBASE gene[NUMGENES]; - /* get the gene array from memory */ - MoveFromMemory((BYTE *)&gene, (U16)sizeof(gene), 1L, 0L, gene_handle); - if (evolving&1) { - if (*kbdchar == FIK_CTL_LEFT_ARROW) { - px--; - } - if (*kbdchar == FIK_CTL_RIGHT_ARROW) { - px++; - } - if (*kbdchar == FIK_CTL_UP_ARROW) { - py--; - } - if (*kbdchar == FIK_CTL_DOWN_ARROW) { - py++; - } - if (px <0 ) px = gridsz-1; - if (px >(gridsz-1)) px = 0; - if (py <0) py = gridsz-1; - if (py > (gridsz-1)) py = 0; - grout = !((evolving & NOGROUT)/NOGROUT) ; - sxoffs = px * (int)(dxsize+1+grout); - syoffs = py * (int)(dysize+1+grout); - - param_history(1); /* restore old history */ - fiddleparms(gene, unspiralmap()); /* change all parameters */ - /* to values appropriate to the image selected */ - set_evolve_ranges(); - chgboxi(0,0); - drawparmbox(0); - } - /* now put the gene array back in memory */ - MoveToMemory((BYTE *)&gene, (U16)sizeof(gene), 1L, 0L, gene_handle); - } - else /* if no zoombox, scroll by arrows */ - move_zoombox(*kbdchar); - break; - case FIK_CTL_HOME: /* Ctrl-home */ - if (boxcount && (curfractalspecific->flags & NOROTATE) == 0) - { - i = key_count(FIK_CTL_HOME); - if ((zskew -= 0.02 * i) < -0.48) - zskew = -0.48; - } - break; - case FIK_CTL_END: /* Ctrl-end */ - if (boxcount && (curfractalspecific->flags & NOROTATE) == 0) - { - i = key_count(FIK_CTL_END); - if ((zskew += 0.02 * i) > 0.48) - zskew = 0.48; - } - break; - case FIK_CTL_PAGE_UP: - if (prmboxcount) { - parmzoom -= 1.0; - if (parmzoom<1.0) parmzoom=1.0; - drawparmbox(0); - set_evolve_ranges(); - } - break; - case FIK_CTL_PAGE_DOWN: - if (prmboxcount) { - parmzoom += 1.0; - if (parmzoom>(double)gridsz/2.0) parmzoom=(double)gridsz/2.0; - drawparmbox(0); - set_evolve_ranges(); - } - break; - - case FIK_PAGE_UP: /* page up */ - if (zoomoff == 1) - { - if (zwidth == 0) - { /* start zoombox */ - zwidth = zdepth = 1; - zskew = zrotate = 0; - zbx = zby = 0; - find_special_colors(); - boxcolor = g_color_bright; - /*rb*/ if (evolving&1) { - /* set screen view params back (previously changed to allow - full screen saves in viewwindow mode) */ - int grout = !((evolving & NOGROUT) / NOGROUT); - sxoffs = px * (int)(dxsize+1+grout); - syoffs = py * (int)(dysize+1+grout); - SetupParamBox(); - drawparmbox(0); - } - moveboxf(0.0,0.0); /* force scrolling */ - } - else - resizebox(0 - key_count(FIK_PAGE_UP)); - } - break; - case FIK_PAGE_DOWN: /* page down */ - if (boxcount) - { - if (zwidth >= .999 && zdepth >= 0.999) { /* end zoombox */ - zwidth = 0; - if (evolving&1) { - drawparmbox(1); /* clear boxes off screen */ - ReleaseParamBox(); - } - } - else - resizebox(key_count(FIK_PAGE_DOWN)); - } - break; - case FIK_CTL_MINUS: /* Ctrl-kpad- */ - if (boxcount && (curfractalspecific->flags & NOROTATE) == 0) - zrotate += key_count(FIK_CTL_MINUS); - break; - case FIK_CTL_PLUS: /* Ctrl-kpad+ */ - if (boxcount && (curfractalspecific->flags & NOROTATE) == 0) - zrotate -= key_count(FIK_CTL_PLUS); - break; - case FIK_CTL_INSERT: /* Ctrl-ins */ - boxcolor += key_count(FIK_CTL_INSERT); - break; - case FIK_CTL_DEL: /* Ctrl-del */ - boxcolor -= key_count(FIK_CTL_DEL); - break; - - /* grabbed a couple of video mode keys, user can change to these using - delete and the menu if necessary */ - - case FIK_F2: /* halve mutation params and regen */ - fiddlefactor = fiddlefactor / 2; - paramrangex = paramrangex / 2; - newopx = opx + paramrangex / 2; - paramrangey = paramrangey / 2; - newopy = opy + paramrangey / 2; - *kbdmore = 0; - calc_status = CALCSTAT_PARAMS_CHANGED; - break; - - case FIK_F3: /*double mutation parameters and regenerate */ - { - double centerx, centery; - fiddlefactor = fiddlefactor * 2; - centerx = opx + paramrangex / 2; - paramrangex = paramrangex * 2; - newopx = centerx - paramrangex / 2; - centery = opy + paramrangey / 2; - paramrangey = paramrangey * 2; - newopy = centery - paramrangey / 2; - *kbdmore = 0; - calc_status = CALCSTAT_PARAMS_CHANGED; - break; - } - - case FIK_F4: /*decrement gridsize and regen */ - if (gridsz > 3) { - gridsz = gridsz - 2; /* gridsz must have odd value only */ - *kbdmore = 0; - calc_status = CALCSTAT_PARAMS_CHANGED; - } - break; - - case FIK_F5: /* increment gridsize and regen */ - if (gridsz < (sxdots / (MINPIXELS<<1))) { - gridsz = gridsz + 2; - *kbdmore = 0; - calc_status = CALCSTAT_PARAMS_CHANGED; - } - break; - - case FIK_F6: /* toggle all variables selected for random variation to - center weighted variation and vice versa */ - { - int i; - GENEBASE gene[NUMGENES]; - /* get the gene array from memory */ - MoveFromMemory((BYTE *)&gene, (U16)sizeof(gene), 1L, 0L, gene_handle); - for (i =0;i < NUMGENES; i++) { - if (gene[i].mutate == 5) { - gene[i].mutate = 6; - continue; - } - if (gene[i].mutate == 6) gene[i].mutate = 5; - } - /* now put the gene array back in memory */ - MoveToMemory((BYTE *)&gene, (U16)sizeof(gene), 1L, 0L, gene_handle); - } - *kbdmore = 0; - calc_status = CALCSTAT_PARAMS_CHANGED; - break; - - case 1120: /* alt + number keys set mutation level */ - case 1121: - case 1122: - case 1123: - case 1124: - case 1125: - case 1126: -/* - case 1127: - case 1128: -*/ - set_mutation_level(*kbdchar-1119); - param_history(1); /* restore old history */ - *kbdmore = 0; - calc_status = CALCSTAT_PARAMS_CHANGED; - break; - - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': -/* add these in when more parameters can be varied - case '8': - case '9': -*/ - set_mutation_level(*kbdchar-(int)'0'); - param_history(1); /* restore old history */ - *kbdmore = 0; - calc_status = CALCSTAT_PARAMS_CHANGED; - break; - case '0': /* mutation level 0 == turn off evolving */ - evolving = viewwindow = 0; - *kbdmore = 0; - calc_status = CALCSTAT_PARAMS_CHANGED; - break; - - case FIK_DELETE: /* select video mode from list */ - driver_stack_screen(); - *kbdchar = select_video_mode(g_adapter); - if (check_vidmode_key(0, *kbdchar) >= 0) /* picked a new mode? */ - driver_discard_screen(); - else - driver_unstack_screen(); - /* fall through */ - default: /* other (maybe valid Fn key */ - if ((k = check_vidmode_key(0, *kbdchar)) >= 0) - { - g_adapter = k; - if (g_video_table[g_adapter].colors != colors) - savedac = 0; - calc_status = CALCSTAT_PARAMS_CHANGED; - *kbdmore = 0; - return CONTINUE; - } - break; - } /* end of the big evolver switch */ - return 0; -} - -static int call_line3d(BYTE *pixels, int linelen) -{ - /* this routine exists because line3d might be in an overlay */ - return line3d(pixels,linelen); -} - -static void note_zoom() -{ - if (boxcount) { /* save zoombox stuff in mem before encode (mem reused) */ - savezoom = (char *)malloc((long)(5*boxcount)); - if (savezoom == NULL) - clear_zoombox(); /* not enuf mem so clear the box */ - else { - reset_zoom_corners(); /* reset these to overall image, not box */ - memcpy(savezoom,boxx,boxcount*2); - memcpy(savezoom+boxcount*2,boxy,boxcount*2); - memcpy(savezoom+boxcount*4,boxvalues,boxcount); - } - } -} - -static void restore_zoom() -{ - if (boxcount) { /* restore zoombox arrays */ - memcpy(boxx,savezoom,boxcount*2); - memcpy(boxy,savezoom+boxcount*2,boxcount*2); - memcpy(boxvalues,savezoom+boxcount*4,boxcount); - free(savezoom); - drawbox(1); /* get the xxmin etc variables recalc'd by redisplaying */ - } -} - -/* do all pending movement at once for smooth mouse diagonal moves */ -static void move_zoombox(int keynum) -{ int vertical, horizontal, getmore; - vertical = horizontal = 0; - getmore = 1; - while (getmore) { - switch (keynum) { - case FIK_LEFT_ARROW: /* cursor left */ - --horizontal; - break; - case FIK_RIGHT_ARROW: /* cursor right */ - ++horizontal; - break; - case FIK_UP_ARROW: /* cursor up */ - --vertical; - break; - case FIK_DOWN_ARROW: /* cursor down */ - ++vertical; - break; - case FIK_CTL_LEFT_ARROW: /* Ctrl-cursor left */ - horizontal -= 8; - break; - case FIK_CTL_RIGHT_ARROW: /* Ctrl-cursor right */ - horizontal += 8; - break; - case FIK_CTL_UP_ARROW: /* Ctrl-cursor up */ - vertical -= 8; - break; - case FIK_CTL_DOWN_ARROW: /* Ctrl-cursor down */ - vertical += 8; - break; /* += 8 needed by VESA scrolling */ - default: - getmore = 0; - } - if (getmore) { - if (getmore == 2) /* eat last key used */ - driver_get_key(); - getmore = 2; - keynum = driver_key_pressed(); /* next pending key */ - } - } - if (boxcount) { -/* - if (horizontal != 0) - moveboxf((double)horizontal/dxsize,0.0); - if (vertical != 0) - moveboxf(0.0,(double)vertical/dysize); -*/ - moveboxf((double)horizontal/dxsize,(double)vertical/dysize); - } -#ifndef XFRACT - else /* if no zoombox, scroll by arrows */ - scroll_relative(horizontal,vertical); -#endif -} - -/* displays differences between current image file and new image */ -static FILE *cmp_fp; -static int errcount; -int cmp_line(BYTE *pixels, int linelen) -{ - int row,col; - int oldcolor; - row = g_row_count++; - if (row == 0) { - errcount = 0; - cmp_fp = dir_fopen(workdir,"cmperr",(initbatch)?"a":"w"); - outln_cleanup = cmp_line_cleanup; - } - if (pot16bit) { /* 16 bit info, ignore odd numbered rows */ - if ((row & 1) != 0) return 0; - row >>= 1; - } - for (col=0; col= maxhistory) /* back to beginning of circular buffer */ - saveptr = 0; - if (++historyptr >= maxhistory) /* move user pointer in parallel */ - historyptr = 0; - MoveToMemory((BYTE *)¤t,(U16)sizeof(HISTORY),1L,(long)saveptr,history); - } -} - -static void _fastcall restore_history_info(int i) -{ - HISTORY last; - if (maxhistory <= 0 || bf_math || history == 0) - return; - MoveFromMemory((BYTE *)&last,(U16)sizeof(HISTORY),1L,(long)i,history); - invert = 0; - calc_status = CALCSTAT_PARAMS_CHANGED; - resuming = 0; - fractype = last.fractal_type ; - xxmin = last.xmin ; - xxmax = last.xmax ; - yymin = last.ymin ; - yymax = last.ymax ; - param[0] = last.creal ; - param[1] = last.cimag ; - param[2] = last.dparm3 ; - param[3] = last.dparm4 ; - param[4] = last.dparm5 ; - param[5] = last.dparm6 ; - param[6] = last.dparm7 ; - param[7] = last.dparm8 ; - param[8] = last.dparm9 ; - param[9] = last.dparm10 ; - fillcolor = last.fillcolor ; - potparam[0] = last.potential[0] ; - potparam[1] = last.potential[1] ; - potparam[2] = last.potential[2] ; - rflag = last.rflag ; - rseed = last.rseed ; - inside = last.inside ; - LogFlag = last.logmap ; - inversion[0] = last.invert[0] ; - inversion[1] = last.invert[1] ; - inversion[2] = last.invert[2] ; - decomp[0] = last.decomp ; - usr_biomorph = last.biomorph ; - biomorph = last.biomorph ; - forcesymmetry = last.symmetry ; - init3d[0] = last.init3d[0] ; - init3d[1] = last.init3d[1] ; - init3d[2] = last.init3d[2] ; - init3d[3] = last.init3d[3] ; - init3d[4] = last.init3d[4] ; - init3d[5] = last.init3d[5] ; - init3d[6] = last.init3d[6] ; - init3d[7] = last.init3d[7] ; - init3d[8] = last.init3d[8] ; - init3d[9] = last.init3d[9] ; - init3d[10] = last.init3d[10] ; - init3d[12] = last.init3d[11] ; - init3d[13] = last.init3d[12] ; - init3d[14] = last.init3d[13] ; - init3d[15] = last.init3d[14] ; - init3d[16] = last.init3d[15] ; - previewfactor = last.previewfactor ; - xtrans = last.xtrans ; - ytrans = last.ytrans ; - red_crop_left = last.red_crop_left ; - red_crop_right = last.red_crop_right ; - blue_crop_left = last.blue_crop_left ; - blue_crop_right = last.blue_crop_right; - red_bright = last.red_bright ; - blue_bright = last.blue_bright ; - xadjust = last.xadjust ; - yadjust = last.yadjust ; - g_eye_separation = last.eyeseparation ; - g_glasses_type = last.glassestype ; - outside = last.outside ; - xx3rd = last.x3rd ; - yy3rd = last.y3rd ; - usr_stdcalcmode = last.stdcalcmode ; - stdcalcmode = last.stdcalcmode ; - three_pass = last.three_pass ; - stoppass = last.stoppass ; - distest = last.distest ; - usr_distest = last.distest ; - trigndx[0] = last.trigndx[0] ; - trigndx[1] = last.trigndx[1] ; - trigndx[2] = last.trigndx[2] ; - trigndx[3] = last.trigndx[3] ; - finattract = last.finattract ; - initorbit.x = last.initorbit[0] ; - initorbit.y = last.initorbit[1] ; - useinitorbit = last.useinitorbit ; - periodicitycheck = last.periodicity ; - usr_periodicitycheck = last.periodicity ; - disk16bit = last.pot16bit ; - g_release = last.release ; - save_release = last.save_release ; - display3d = last.flag3d ; - Ambient = last.ambient ; - RANDOMIZE = last.randomize ; - haze = last.haze ; - transparent[0] = last.transparent[0] ; - transparent[1] = last.transparent[1] ; - rotate_lo = last.rotate_lo ; - rotate_hi = last.rotate_hi ; - distestwidth = last.distestwidth ; - mxmaxfp = last.mxmaxfp ; - mxminfp = last.mxminfp ; - mymaxfp = last.mymaxfp ; - myminfp = last.myminfp ; - zdots = last.zdots ; - originfp = last.originfp ; - depthfp = last.depthfp ; - heightfp = last.heightfp ; - widthfp = last.widthfp ; - distfp = last.distfp ; - eyesfp = last.eyesfp ; - neworbittype = last.orbittype ; - juli3Dmode = last.juli3Dmode ; - maxfn = last.maxfn ; - major_method = (enum Major)last.major_method ; - minor_method = (enum Minor)last.minor_method ; - bailout = last.bailout ; - bailoutest = (enum bailouts)last.bailoutest ; - maxit = last.iterations ; - old_demm_colors = last.old_demm_colors; - curfractalspecific = &fractalspecific[fractype]; - potflag = (potparam[0] != 0.0); - if (inversion[0] != 0.0) - invert = 3; - Log_Fly_Calc = last.logcalc; - ismand = last.ismand; - closeprox = last.closeprox; - nobof = last.nobof; - orbit_delay = last.orbit_delay; - orbit_interval = last.orbit_interval; - oxmin = last.oxmin; - oxmax = last.oxmax; - oymin = last.oymin; - oymax = last.oymax; - ox3rd = last.ox3rd; - oy3rd = last.oy3rd; - keep_scrn_coords = last.keep_scrn_coords; - if (keep_scrn_coords) set_orbit_corners = 1; - drawmode = last.drawmode; - usr_floatflag = (char)((curfractalspecific->isinteger) ? 0 : 1); - memcpy(g_dac_box,last.dac,256*3); - memcpy(olddacbox,last.dac,256*3); - if (mapdacbox) - memcpy(mapdacbox,last.dac,256*3); - spindac(0,1); - if (fractype == JULIBROT || fractype == JULIBROTFP) - savedac = 0; - else - savedac = 1; - switch (fractype) - { - case FORMULA: - case FFORMULA: - strncpy(FormFileName,last.filename,FILE_MAX_PATH); - strncpy(FormName, last.itemname,ITEMNAMELEN+1); - break; - case IFS: - case IFS3D: - strncpy(IFSFileName,last.filename,FILE_MAX_PATH); - strncpy(IFSName ,last.itemname,ITEMNAMELEN+1); - break; - case LSYSTEM: - strncpy(LFileName,last.filename,FILE_MAX_PATH); - strncpy(LName ,last.itemname,ITEMNAMELEN+1); - break; - default: - break; - } -} diff --git a/fractint/common/frasetup.c b/fractint/common/frasetup.c deleted file mode 100644 index 1c2b411b2..000000000 --- a/fractint/common/frasetup.c +++ /dev/null @@ -1,1310 +0,0 @@ -#include -#include -#if !defined(__386BSD__) -#if !defined(_WIN32) -#include -#endif -#endif - /* see Fractint.c for a description of the "include" hierarchy */ -#include "port.h" -#include "prototyp.h" -#include "helpdefs.h" -#include "fractype.h" - -#if !defined(XFRACT) -#define MPCmod(m) (*pMPadd(*pMPmul((m).x, (m).x), *pMPmul((m).y, (m).y))) -#endif - -#if defined(XFRACT) || defined(_WIN32) -extern long calcmandfpasm_c(void); -#endif - -/* -------------------------------------------------------------------- */ -/* Setup (once per fractal image) routines */ -/* -------------------------------------------------------------------- */ - -int -MandelSetup(void) /* Mandelbrot Routine */ -{ - if (debugflag != 90 - && !invert && decomp[0] == 0 && rqlim == 4.0 - && bitshift == 29 && potflag == 0 - && biomorph == -1 && inside > -59 && outside >= -1 - && useinitorbit != 1 && using_jiim == 0 && bailoutest == Mod - && (orbitsave&2) == 0) - calctype = calcmand; /* the normal case - use CALCMAND */ - else - { - /* special case: use the main processing loop */ - calctype = StandardFractal; - longparm = &linit; - } - return(1); -} - -int -JuliaSetup(void) /* Julia Routine */ -{ - if (debugflag != 90 - && !invert && decomp[0] == 0 && rqlim == 4.0 - && bitshift == 29 && potflag == 0 - && biomorph == -1 && inside > -59 && outside >= -1 - && !finattract && using_jiim == 0 && bailoutest == Mod - && (orbitsave&2) == 0) - calctype = calcmand; /* the normal case - use CALCMAND */ - else - { - /* special case: use the main processing loop */ - calctype = StandardFractal; - longparm = &lparm; - get_julia_attractor (0.0, 0.0); /* another attractor? */ - } - return(1); -} - -int -NewtonSetup(void) /* Newton/NewtBasin Routines */ -{ - int i; -#if !defined(XFRACT) - if (debugflag != 1010) - { - if (fpu != 0) - { - if (fractype == MPNEWTON) - fractype = NEWTON; - else if (fractype == MPNEWTBASIN) - fractype = NEWTBASIN; - } - else - { - if (fractype == NEWTON) - fractype = MPNEWTON; - else if (fractype == NEWTBASIN) - fractype = MPNEWTBASIN; - } - curfractalspecific = &fractalspecific[fractype]; - } -#else - if (fractype == MPNEWTON) - fractype = NEWTON; - else if (fractype == MPNEWTBASIN) - fractype = NEWTBASIN; - - curfractalspecific = &fractalspecific[fractype]; -#endif - /* set up table of roots of 1 along unit circle */ - degree = (int)parm.x; - if (degree < 2) - degree = 3; /* defaults to 3, but 2 is possible */ - root = 1; - - /* precalculated values */ - roverd = (double)root / (double)degree; - d1overd = (double)(degree - 1) / (double)degree; - maxcolor = 0; - threshold = .3*PI/degree; /* less than half distance between roots */ -#if !defined(XFRACT) - if (fractype == MPNEWTON || fractype == MPNEWTBASIN) { - mproverd = *pd2MP(roverd); - mpd1overd = *pd2MP(d1overd); - mpthreshold = *pd2MP(threshold); - mpone = *pd2MP(1.0); - } -#endif - - floatmin = FLT_MIN; - floatmax = FLT_MAX; - - basin = 0; - if (roots != staticroots) { - free(roots); - roots = staticroots; - } - - if (fractype==NEWTBASIN) - { - if (parm.y) - basin = 2; /*stripes */ - else - basin = 1; - if (degree > 16) - { - roots = (_CMPLX *) malloc(degree*sizeof(_CMPLX)); - if (roots == NULL) - { - roots = staticroots; - degree = 16; - } - } - else - roots = staticroots; - - /* list of roots to discover where we converged for newtbasin */ - for (i=0; i 16) - { - MPCroots = (struct MPC *) malloc(degree*sizeof(struct MPC)); - if (MPCroots == NULL) - { - MPCroots = (struct MPC *)staticroots; - degree = 16; - } - } - else - MPCroots = (struct MPC *)staticroots; - - /* list of roots to discover where we converged for newtbasin */ - for (i=0; icalctype); - return(0); /* effectively disable solid-guessing */ -} - -int -UnitySetup(void) -{ - periodicitycheck = 0; - FgOne = (1L << bitshift); - FgTwo = FgOne + FgOne; - return(1); -} - -int -MandelfpSetup(void) -{ - bf_math = 0; - c_exp = (int)param[2]; - pwr.x = param[2] - 1.0; - pwr.y = param[3]; - floatparm = &init; - switch (fractype) - { - case MARKSMANDELFP: - if (c_exp < 1){ - c_exp = 1; - param[2] = 1; - } - if (!(c_exp & 1)) - symmetry = XYAXIS_NOPARM; /* odd exponents */ - if (c_exp & 1) - symmetry = XAXIS_NOPARM; - break; - case MANDELFP: - /* - floating point code could probably be altered to handle many of - the situations that otherwise are using StandardFractal(). - calcmandfp() can currently handle invert, any rqlim, potflag - zmag, epsilon cross, and all the current outside options - Wes Loewer 11/03/91 - Took out support for inside= options, for speed. 7/13/97 - */ - if (debugflag != 90 - && !distest - && decomp[0] == 0 - && biomorph == -1 - && (inside >= -1) - /* uncomment this next line if more outside options are added */ - && outside >= -6 - && useinitorbit != 1 - && (soundflag & SOUNDFLAG_ORBITMASK) < SOUNDFLAG_X - && using_jiim == 0 && bailoutest == Mod - && (orbitsave&2) == 0) - { - calctype = calcmandfp; /* the normal case - use calcmandfp */ -#if !defined(XFRACT) - if (cpu >= 386 && fpu >= 387) - { - calcmandfpasmstart_p5(); - calcmandfpasm = (long (*)(void))calcmandfpasm_p5; - } - else if (cpu == 286 && fpu >= 287) - { - calcmandfpasmstart(); - calcmandfpasm = (long (*)(void))calcmandfpasm_287; - } - else - - { - calcmandfpasmstart(); - calcmandfpasm = (long (*)(void))calcmandfpasm_87; - } -#else - { -#ifdef NASM - if (fpu == -1) - { - calcmandfpasmstart_p5(); - calcmandfpasm = (long (*)(void))calcmandfpasm_p5; - } - else -#endif - { - calcmandfpasmstart(); - calcmandfpasm = (long (*)(void))calcmandfpasm_c; - } - } -#endif - } - else - { - /* special case: use the main processing loop */ - calctype = StandardFractal; - } - break; - case FPMANDELZPOWER: - if ((double)c_exp == param[2] && (c_exp & 1)) /* odd exponents */ - symmetry = XYAXIS_NOPARM; - if (param[3] != 0) - symmetry = NOSYM; - if (param[3] == 0.0 && debugflag != 6000 && (double)c_exp == param[2]) - fractalspecific[fractype].orbitcalc = floatZpowerFractal; - else - fractalspecific[fractype].orbitcalc = floatCmplxZpowerFractal; - break; - case MAGNET1M: - case MAGNET2M: - attr[0].x = 1.0; /* 1.0 + 0.0i always attracts */ - attr[0].y = 0.0; /* - both MAGNET1 and MAGNET2 */ - attrperiod[0] = 1; - attractors = 1; - break; - case SPIDERFP: - if (periodicitycheck==1) /* if not user set */ - periodicitycheck=4; - break; - case MANDELEXP: - symmetry = XAXIS_NOPARM; - break; -/* Added to account for symmetry in manfn+exp and manfn+zsqrd */ -/* JCO 2/29/92 */ - case FPMANTRIGPLUSEXP: - case FPMANTRIGPLUSZSQRD: - if (parm.y == 0.0) - symmetry = XAXIS; - else - symmetry = NOSYM; - if ((trigndx[0] == LOG) || (trigndx[0] == 14)) /* LOG or FLIP */ - symmetry = NOSYM; - break; - case QUATFP: - floatparm = &tmp; - attractors = 0; - periodicitycheck = 0; - break; - case HYPERCMPLXFP: - floatparm = &tmp; - attractors = 0; - periodicitycheck = 0; - if (param[2] != 0) - symmetry = NOSYM; - if (trigndx[0] == 14) /* FLIP */ - symmetry = NOSYM; - break; - case TIMSERRORFP: - if (trigndx[0] == 14) /* FLIP */ - symmetry = NOSYM; - break; - case MARKSMANDELPWRFP: - if (trigndx[0] == 14) /* FLIP */ - symmetry = NOSYM; - break; - default: - break; - } - return(1); -} - -int -JuliafpSetup(void) -{ - c_exp = (int)param[2]; - floatparm = &parm; - if (fractype==COMPLEXMARKSJUL) - { - pwr.x = param[2] - 1.0; - pwr.y = param[3]; - coefficient = ComplexPower(*floatparm, pwr); - } - switch (fractype) - { - case JULIAFP: - /* - floating point code could probably be altered to handle many of - the situations that otherwise are using StandardFractal(). - calcmandfp() can currently handle invert, any rqlim, potflag - zmag, epsilon cross, and all the current outside options - Wes Loewer 11/03/91 - Took out support for inside= options, for speed. 7/13/97 - */ - if (debugflag != 90 - && !distest - && decomp[0] == 0 - && biomorph == -1 - && (inside >= -1) - /* uncomment this next line if more outside options are added */ - && outside >= -6 - && useinitorbit != 1 - && (soundflag & SOUNDFLAG_ORBITMASK) < SOUNDFLAG_X - && !finattract - && using_jiim == 0 && bailoutest == Mod - && (orbitsave&2) == 0) - { - calctype = calcmandfp; /* the normal case - use calcmandfp */ -#if !defined(XFRACT) - if (cpu >= 386 && fpu >= 387) - { - calcmandfpasmstart_p5(); - calcmandfpasm = (long (*)(void))calcmandfpasm_p5; - } - else if (cpu == 286 && fpu >= 287) - { - calcmandfpasmstart(); - calcmandfpasm = (long (*)(void))calcmandfpasm_287; - } - else - { - calcmandfpasmstart(); - calcmandfpasm = (long (*)(void))calcmandfpasm_87; - } -#else - { -#ifdef NASM - if (fpu == -1) - { - calcmandfpasmstart_p5(); - calcmandfpasm = (long (*)(void))calcmandfpasm_p5; - } - else -#endif - { - calcmandfpasmstart(); - calcmandfpasm = (long (*)(void))calcmandfpasm_c; - } - } -#endif - } - else - { - /* special case: use the main processing loop */ - calctype = StandardFractal; - get_julia_attractor (0.0, 0.0); /* another attractor? */ - } - break; - case FPJULIAZPOWER: - if ((c_exp & 1) || param[3] != 0.0 || (double)c_exp != param[2] ) - symmetry = NOSYM; - if (param[3] == 0.0 && debugflag != 6000 && (double)c_exp == param[2]) - fractalspecific[fractype].orbitcalc = floatZpowerFractal; - else - fractalspecific[fractype].orbitcalc = floatCmplxZpowerFractal; - get_julia_attractor (param[0], param[1]); /* another attractor? */ - break; - case MAGNET2J: - FloatPreCalcMagnet2(); - case MAGNET1J: - attr[0].x = 1.0; /* 1.0 + 0.0i always attracts */ - attr[0].y = 0.0; /* - both MAGNET1 and MAGNET2 */ - attrperiod[0] = 1; - attractors = 1; - get_julia_attractor (0.0, 0.0); /* another attractor? */ - break; - case LAMBDAFP: - get_julia_attractor (0.0, 0.0); /* another attractor? */ - get_julia_attractor (0.5, 0.0); /* another attractor? */ - break; - case LAMBDAEXP: - if (parm.y == 0.0) - symmetry=XAXIS; - get_julia_attractor (0.0, 0.0); /* another attractor? */ - break; -/* Added to account for symmetry in julfn+exp and julfn+zsqrd */ -/* JCO 2/29/92 */ - case FPJULTRIGPLUSEXP: - case FPJULTRIGPLUSZSQRD: - if (parm.y == 0.0) - symmetry = XAXIS; - else - symmetry = NOSYM; - if ((trigndx[0] == LOG) || (trigndx[0] == 14)) /* LOG or FLIP */ - symmetry = NOSYM; - get_julia_attractor (0.0, 0.0); /* another attractor? */ - break; - case HYPERCMPLXJFP: - if (param[2] != 0) - symmetry = NOSYM; - if (trigndx[0] != SQR) - symmetry=NOSYM; - case QUATJULFP: - attractors = 0; /* attractors broken since code checks r,i not j,k */ - periodicitycheck = 0; - if (param[4] != 0.0 || param[5] != 0) - symmetry = NOSYM; - break; - case FPPOPCORN: - case FPPOPCORNJUL: - { - int default_functions = 0; - if (trigndx[0] == SIN && - trigndx[1] == TAN && - trigndx[2] == SIN && - trigndx[3] == TAN && - fabs(parm2.x - 3.0) < .0001 && - parm2.y == 0 && - parm.y == 0) - { - default_functions = 1; - if (fractype == FPPOPCORNJUL) - symmetry = ORIGIN; - } - if (save_release <=1960) - curfractalspecific->orbitcalc = PopcornFractal_Old; - else if (default_functions && debugflag == 96) - curfractalspecific->orbitcalc = PopcornFractal; - else - curfractalspecific->orbitcalc = PopcornFractalFn; - get_julia_attractor (0.0, 0.0); /* another attractor? */ - } - break; - case FPCIRCLE: - if (inside == STARTRAIL) /* FPCIRCLE locks up when used with STARTRAIL */ - inside = 0; /* arbitrarily set inside = NUMB */ - get_julia_attractor (0.0, 0.0); /* another attractor? */ - break; - default: - get_julia_attractor (0.0, 0.0); /* another attractor? */ - break; - } - return(1); -} - -int -MandellongSetup(void) -{ - FgHalf = fudge >> 1; - c_exp = (int)param[2]; - if (fractype==MARKSMANDEL && c_exp < 1){ - c_exp = 1; - param[2] = 1; - } - if ((fractype==MARKSMANDEL && !(c_exp & 1)) || - (fractype==LMANDELZPOWER && (c_exp & 1))) - symmetry = XYAXIS_NOPARM; /* odd exponents */ - if ((fractype==MARKSMANDEL && (c_exp & 1)) || fractype==LMANDELEXP) - symmetry = XAXIS_NOPARM; - if (fractype==SPIDER && periodicitycheck==1) - periodicitycheck=4; - longparm = &linit; - if (fractype==LMANDELZPOWER) - { - if (param[3] == 0.0 && debugflag != 6000 && (double)c_exp == param[2]) - fractalspecific[fractype].orbitcalc = longZpowerFractal; - else - fractalspecific[fractype].orbitcalc = longCmplxZpowerFractal; - if (param[3] != 0 || (double)c_exp != param[2] ) - symmetry = NOSYM; - } -/* Added to account for symmetry in manfn+exp and manfn+zsqrd */ -/* JCO 2/29/92 */ - if ((fractype==LMANTRIGPLUSEXP)||(fractype==LMANTRIGPLUSZSQRD)) - { - if (parm.y == 0.0) - symmetry = XAXIS; - else - symmetry = NOSYM; - if ((trigndx[0] == LOG) || (trigndx[0] == 14)) /* LOG or FLIP */ - symmetry = NOSYM; - } - if (fractype == TIMSERROR) - { - if (trigndx[0] == 14) /* FLIP */ - symmetry = NOSYM; - } - if (fractype == MARKSMANDELPWR) - { - if (trigndx[0] == 14) /* FLIP */ - symmetry = NOSYM; - } - return(1); -} - -int -JulialongSetup(void) -{ - c_exp = (int)param[2]; - longparm = &lparm; - switch (fractype) - { - case LJULIAZPOWER: - if ((c_exp & 1) || param[3] != 0.0 || (double)c_exp != param[2]) - symmetry = NOSYM; - if (param[3] == 0.0 && debugflag != 6000 && (double)c_exp == param[2]) - fractalspecific[fractype].orbitcalc = longZpowerFractal; - else - fractalspecific[fractype].orbitcalc = longCmplxZpowerFractal; - break; - case LAMBDA: - get_julia_attractor (0.0, 0.0); /* another attractor? */ - get_julia_attractor (0.5, 0.0); /* another attractor? */ - break; - case LLAMBDAEXP: - if (lparm.y == 0) - symmetry = XAXIS; - break; -/* Added to account for symmetry in julfn+exp and julfn+zsqrd */ -/* JCO 2/29/92 */ - case LJULTRIGPLUSEXP: - case LJULTRIGPLUSZSQRD: - if (parm.y == 0.0) - symmetry = XAXIS; - else - symmetry = NOSYM; - if ((trigndx[0] == LOG) || (trigndx[0] == 14)) /* LOG or FLIP */ - symmetry = NOSYM; - get_julia_attractor (0.0, 0.0); /* another attractor? */ - break; - case LPOPCORN: - case LPOPCORNJUL: - { - int default_functions = 0; - if (trigndx[0] == SIN && - trigndx[1] == TAN && - trigndx[2] == SIN && - trigndx[3] == TAN && - fabs(parm2.x - 3.0) < .0001 && - parm2.y == 0 && - parm.y == 0) - { - default_functions = 1; - if (fractype == LPOPCORNJUL) - symmetry = ORIGIN; - } - if (save_release <=1960) - curfractalspecific->orbitcalc = LPopcornFractal_Old; - else if (default_functions && debugflag == 96) - curfractalspecific->orbitcalc = LPopcornFractal; - else - curfractalspecific->orbitcalc = LPopcornFractalFn; - get_julia_attractor (0.0, 0.0); /* another attractor? */ - } - break; - default: - get_julia_attractor (0.0, 0.0); /* another attractor? */ - break; - } - return(1); -} - -int -TrigPlusSqrlongSetup(void) -{ - curfractalspecific->per_pixel = julia_per_pixel; - curfractalspecific->orbitcalc = TrigPlusSqrFractal; - if (lparm.x == fudge && lparm.y == 0L && lparm2.y == 0L && debugflag != 90) - { - if (lparm2.x == fudge) /* Scott variant */ - curfractalspecific->orbitcalc = ScottTrigPlusSqrFractal; - else if (lparm2.x == -fudge) /* Skinner variant */ - curfractalspecific->orbitcalc = SkinnerTrigSubSqrFractal; - } - return(JulialongSetup()); -} - -int -TrigPlusSqrfpSetup(void) -{ - curfractalspecific->per_pixel = juliafp_per_pixel; - curfractalspecific->orbitcalc = TrigPlusSqrfpFractal; - if (parm.x == 1.0 && parm.y == 0.0 && parm2.y == 0.0 && debugflag != 90) - { - if (parm2.x == 1.0) /* Scott variant */ - curfractalspecific->orbitcalc = ScottTrigPlusSqrfpFractal; - else if (parm2.x == -1.0) /* Skinner variant */ - curfractalspecific->orbitcalc = SkinnerTrigSubSqrfpFractal; - } - return(JuliafpSetup()); -} - -int -TrigPlusTriglongSetup(void) -{ - FnPlusFnSym(); - if (trigndx[1] == SQR) - return(TrigPlusSqrlongSetup()); - curfractalspecific->per_pixel = long_julia_per_pixel; - curfractalspecific->orbitcalc = TrigPlusTrigFractal; - if (lparm.x == fudge && lparm.y == 0L && lparm2.y == 0L && debugflag != 90) - { - if (lparm2.x == fudge) /* Scott variant */ - curfractalspecific->orbitcalc = ScottTrigPlusTrigFractal; - else if (lparm2.x == -fudge) /* Skinner variant */ - curfractalspecific->orbitcalc = SkinnerTrigSubTrigFractal; - } - return(JulialongSetup()); -} - -int -TrigPlusTrigfpSetup(void) -{ - FnPlusFnSym(); - if (trigndx[1] == SQR) - return(TrigPlusSqrfpSetup()); - curfractalspecific->per_pixel = otherjuliafp_per_pixel; - curfractalspecific->orbitcalc = TrigPlusTrigfpFractal; - if (parm.x == 1.0 && parm.y == 0.0 && parm2.y == 0.0 && debugflag != 90) - { - if (parm2.x == 1.0) /* Scott variant */ - curfractalspecific->orbitcalc = ScottTrigPlusTrigfpFractal; - else if (parm2.x == -1.0) /* Skinner variant */ - curfractalspecific->orbitcalc = SkinnerTrigSubTrigfpFractal; - } - return(JuliafpSetup()); -} - -int -FnPlusFnSym(void) /* set symmetry matrix for fn+fn type */ -{ - static char fnplusfn[7][7] = - {/* fn2 ->sin cos sinh cosh exp log sqr */ - /* fn1 */ - /* sin */ {PI_SYM,XAXIS, XYAXIS, XAXIS, XAXIS, XAXIS, XAXIS}, - /* cos */ {XAXIS, PI_SYM,XAXIS, XYAXIS,XAXIS, XAXIS, XAXIS}, - /* sinh*/ {XYAXIS,XAXIS, XYAXIS, XAXIS, XAXIS, XAXIS, XAXIS}, - /* cosh*/ {XAXIS, XYAXIS,XAXIS, XYAXIS,XAXIS, XAXIS, XAXIS}, - /* exp */ {XAXIS, XYAXIS,XAXIS, XAXIS, XYAXIS,XAXIS, XAXIS}, - /* log */ {XAXIS, XAXIS, XAXIS, XAXIS, XAXIS, XAXIS, XAXIS}, - /* sqr */ {XAXIS, XAXIS, XAXIS, XAXIS, XAXIS, XAXIS, XYAXIS} - }; - if (parm.y == 0.0 && parm2.y == 0.0) - { if (trigndx[0] < 7 && trigndx[1] < 7) /* bounds of array JCO 5/6/92*/ - symmetry = fnplusfn[trigndx[0]][trigndx[1]]; /* JCO 5/6/92 */ - if (trigndx[0] == 14 || trigndx[1] == 14) /* FLIP */ - symmetry = NOSYM; - } /* defaults to XAXIS symmetry JCO 5/6/92 */ - else - symmetry = NOSYM; - return(0); -} - -int -LambdaTrigOrTrigSetup(void) -{ -/* default symmetry is ORIGIN JCO 2/29/92 (changed from PI_SYM) */ - longparm = &lparm; /* added to consolidate code 10/1/92 JCO */ - floatparm = &parm; - if ((trigndx[0] == EXP) || (trigndx[1] == EXP)) - symmetry = NOSYM; /* JCO 1/9/93 */ - if ((trigndx[0] == LOG) || (trigndx[1] == LOG)) - symmetry = XAXIS; - get_julia_attractor (0.0, 0.0); /* an attractor? */ - return(1); -} - -int -JuliaTrigOrTrigSetup(void) -{ -/* default symmetry is XAXIS */ - longparm = &lparm; /* added to consolidate code 10/1/92 JCO */ - floatparm = &parm; - if (parm.y != 0.0) - symmetry = NOSYM; - if (trigndx[0] == 14 || trigndx[1] == 14) /* FLIP */ - symmetry = NOSYM; - get_julia_attractor (0.0, 0.0); /* an attractor? */ - return(1); -} - -int -ManlamTrigOrTrigSetup(void) -{ /* psuedo */ -/* default symmetry is XAXIS */ - longparm = &linit; /* added to consolidate code 10/1/92 JCO */ - floatparm = &init; - if (trigndx[0] == SQR) - symmetry = NOSYM; - if ((trigndx[0] == LOG) || (trigndx[1] == LOG)) - symmetry = NOSYM; - return(1); -} - -int -MandelTrigOrTrigSetup(void) -{ -/* default symmetry is XAXIS_NOPARM */ - longparm = &linit; /* added to consolidate code 10/1/92 JCO */ - floatparm = &init; - if ((trigndx[0] == 14) || (trigndx[1] == 14)) /* FLIP JCO 5/28/92 */ - symmetry = NOSYM; - return(1); -} - - -int -ZXTrigPlusZSetup(void) -{ -/* static char ZXTrigPlusZSym1[] = */ - /* fn1 -> sin cos sinh cosh exp log sqr */ -/* {XAXIS,XYAXIS,XAXIS,XYAXIS,XAXIS,NOSYM,XYAXIS}; */ -/* static char ZXTrigPlusZSym2[] = */ - /* fn1 -> sin cos sinh cosh exp log sqr */ -/* {NOSYM,ORIGIN,NOSYM,ORIGIN,NOSYM,NOSYM,ORIGIN}; */ - - if (param[1] == 0.0 && param[3] == 0.0) -/* symmetry = ZXTrigPlusZSym1[trigndx[0]]; */ - switch (trigndx[0]) - { - case COS: /* changed to two case statments and made any added */ - case COSH: /* functions default to XAXIS symmetry. JCO 5/25/92 */ - case SQR: - case 9: /* 'real' cos */ - symmetry = XYAXIS; - break; - case 14: /* FLIP JCO 2/29/92 */ - symmetry = YAXIS; - break; - case LOG: - symmetry = NOSYM; - break; - default: - symmetry = XAXIS; - break; - } - else -/* symmetry = ZXTrigPlusZSym2[trigndx[0]]; */ - switch (trigndx[0]) - { - case COS: - case COSH: - case SQR: - case 9: /* 'real' cos */ - symmetry = ORIGIN; - break; - case 14: /* FLIP JCO 2/29/92 */ - symmetry = NOSYM; - break; - default: - symmetry = NOSYM; - break; - } - if (curfractalspecific->isinteger) - { - curfractalspecific->orbitcalc = ZXTrigPlusZFractal; - if (lparm.x == fudge && lparm.y == 0L && lparm2.y == 0L && debugflag != 90) - { - if (lparm2.x == fudge) /* Scott variant */ - curfractalspecific->orbitcalc = ScottZXTrigPlusZFractal; - else if (lparm2.x == -fudge) /* Skinner variant */ - curfractalspecific->orbitcalc = SkinnerZXTrigSubZFractal; - } - return(JulialongSetup()); - } - else - { - curfractalspecific->orbitcalc = ZXTrigPlusZfpFractal; - if (parm.x == 1.0 && parm.y == 0.0 && parm2.y == 0.0 && debugflag != 90) - { - if (parm2.x == 1.0) /* Scott variant */ - curfractalspecific->orbitcalc = ScottZXTrigPlusZfpFractal; - else if (parm2.x == -1.0) /* Skinner variant */ - curfractalspecific->orbitcalc = SkinnerZXTrigSubZfpFractal; - } - } - return(JuliafpSetup()); -} - -int -LambdaTrigSetup(void) -{ - int isinteger; - if ((isinteger = curfractalspecific->isinteger) != 0) - curfractalspecific->orbitcalc = LambdaTrigFractal; - else - curfractalspecific->orbitcalc = LambdaTrigfpFractal; - switch (trigndx[0]) - { - case SIN: - case COS: - case 9: /* 'real' cos, added this and default for additional functions */ - symmetry = PI_SYM; - if (isinteger) - curfractalspecific->orbitcalc = LambdaTrigFractal1; - else - curfractalspecific->orbitcalc = LambdaTrigfpFractal1; - break; - case SINH: - case COSH: - symmetry = ORIGIN; - if (isinteger) - curfractalspecific->orbitcalc = LambdaTrigFractal2; - else - curfractalspecific->orbitcalc = LambdaTrigfpFractal2; - break; - case SQR: - symmetry = ORIGIN; - break; - case EXP: - if (isinteger) - curfractalspecific->orbitcalc = LongLambdaexponentFractal; - else - curfractalspecific->orbitcalc = LambdaexponentFractal; - symmetry = NOSYM; /* JCO 1/9/93 */ - break; - case LOG: - symmetry = NOSYM; - break; - default: /* default for additional functions */ - symmetry = ORIGIN; /* JCO 5/8/92 */ - break; - } - get_julia_attractor (0.0, 0.0); /* an attractor? */ - if (isinteger) - return(JulialongSetup()); - else - return(JuliafpSetup()); -} - -int -JuliafnPlusZsqrdSetup(void) -{ -/* static char fnpluszsqrd[] = */ - /* fn1 -> sin cos sinh cosh sqr exp log */ - /* sin {NOSYM,ORIGIN,NOSYM,ORIGIN,ORIGIN,NOSYM,NOSYM}; */ - -/* symmetry = fnpluszsqrd[trigndx[0]]; JCO 5/8/92 */ - switch (trigndx[0]) /* fix sqr symmetry & add additional functions */ - { - case COS: /* cosxx */ - case COSH: - case SQR: - case 9: /* 'real' cos */ - case 10: /* tan */ - case 11: /* tanh */ - symmetry = ORIGIN; - /* default is for NOSYM symmetry */ - } - if (curfractalspecific->isinteger) - return(JulialongSetup()); - else - return(JuliafpSetup()); -} - -int -SqrTrigSetup(void) -{ -/* static char SqrTrigSym[] = */ - /* fn1 -> sin cos sinh cosh sqr exp log */ -/* {PI_SYM,PI_SYM,XYAXIS,XYAXIS,XYAXIS,XAXIS,XAXIS}; */ -/* symmetry = SqrTrigSym[trigndx[0]]; JCO 5/9/92 */ - switch (trigndx[0]) /* fix sqr symmetry & add additional functions */ - { - case SIN: - case COS: /* cosxx */ - case 9: /* 'real' cos */ - symmetry = PI_SYM; - /* default is for XAXIS symmetry */ - } - if (curfractalspecific->isinteger) - return(JulialongSetup()); - else - return(JuliafpSetup()); -} - -int -FnXFnSetup(void) -{ - static char fnxfn[7][7] = - {/* fn2 ->sin cos sinh cosh exp log sqr */ - /* fn1 */ - /* sin */ {PI_SYM,YAXIS, XYAXIS,XYAXIS,XAXIS, NOSYM, XYAXIS}, - /* cos */ {YAXIS, PI_SYM,XYAXIS,XYAXIS,XAXIS, NOSYM, XYAXIS}, - /* sinh*/ {XYAXIS,XYAXIS,XYAXIS,XYAXIS,XAXIS, NOSYM, XYAXIS}, - /* cosh*/ {XYAXIS,XYAXIS,XYAXIS,XYAXIS,XAXIS, NOSYM, XYAXIS}, - /* exp */ {XAXIS, XAXIS, XAXIS, XAXIS, XAXIS, NOSYM, XYAXIS}, - /* log */ {NOSYM, NOSYM, NOSYM, NOSYM, NOSYM, XAXIS, NOSYM}, - /* sqr */ {XYAXIS,XYAXIS,XYAXIS,XYAXIS,XYAXIS,NOSYM, XYAXIS}, - }; - /* - if (trigndx[0]==EXP || trigndx[0]==LOG || trigndx[1]==EXP || trigndx[1]==LOG) - symmetry = XAXIS; - else if ((trigndx[0]==SIN && trigndx[1]==SIN)||(trigndx[0]==COS && trigndx[1]==COS)) - symmetry = PI_SYM; - else if ((trigndx[0]==SIN && trigndx[1]==COS)||(trigndx[0]==COS && trigndx[1]==SIN)) - symmetry = YAXIS; - else - symmetry = XYAXIS; - */ - if (trigndx[0] < 7 && trigndx[1] < 7) /* bounds of array JCO 5/22/92*/ - symmetry = fnxfn[trigndx[0]][trigndx[1]]; /* JCO 5/22/92 */ - /* defaults to XAXIS symmetry JCO 5/22/92 */ - else { /* added to complete the symmetry JCO 5/22/92 */ - if (trigndx[0]==LOG || trigndx[1] ==LOG) symmetry = NOSYM; - if (trigndx[0]==9 || trigndx[1] ==9) { /* 'real' cos */ - if (trigndx[0]==SIN || trigndx[1] ==SIN) symmetry = PI_SYM; - if (trigndx[0]==COS || trigndx[1] ==COS) symmetry = PI_SYM; - } - if (trigndx[0]==9 && trigndx[1] ==9) symmetry = PI_SYM; - } - if (curfractalspecific->isinteger) - return(JulialongSetup()); - else - return(JuliafpSetup()); -} - -int -MandelTrigSetup(void) -{ - int isinteger; - if ((isinteger = curfractalspecific->isinteger) != 0) - curfractalspecific->orbitcalc = LambdaTrigFractal; - else - curfractalspecific->orbitcalc = LambdaTrigfpFractal; - symmetry = XYAXIS_NOPARM; - switch (trigndx[0]) - { - case SIN: - case COS: - if (isinteger) - curfractalspecific->orbitcalc = LambdaTrigFractal1; - else - curfractalspecific->orbitcalc = LambdaTrigfpFractal1; - break; - case SINH: - case COSH: - if (isinteger) - curfractalspecific->orbitcalc = LambdaTrigFractal2; - else - curfractalspecific->orbitcalc = LambdaTrigfpFractal2; - break; - case EXP: - symmetry = XAXIS_NOPARM; - if (isinteger) - curfractalspecific->orbitcalc = LongLambdaexponentFractal; - else - curfractalspecific->orbitcalc = LambdaexponentFractal; - break; - case LOG: - symmetry = XAXIS_NOPARM; - break; - default: /* added for additional functions, JCO 5/25/92 */ - symmetry = XYAXIS_NOPARM; - break; - } - if (isinteger) - return(MandellongSetup()); - else - return(MandelfpSetup()); -} - -int -MarksJuliaSetup(void) -{ -#if !defined(XFRACT) - if (param[2] < 1) - param[2] = 1; - c_exp = (int)param[2]; - longparm = &lparm; - lold = *longparm; - if (c_exp > 3) - lcpower(&lold,c_exp-1,&lcoefficient,bitshift); - else if (c_exp == 3) - { - lcoefficient.x = multiply(lold.x,lold.x,bitshift) - multiply(lold.y,lold.y,bitshift); - lcoefficient.y = multiply(lold.x,lold.y,bitshiftless1); - } - else if (c_exp == 2) - lcoefficient = lold; - else if (c_exp < 2) { - lcoefficient.x = 1L << bitshift; - lcoefficient.y = 0L; - } - get_julia_attractor (0.0, 0.0); /* an attractor? */ -#endif - return(1); -} - -int -MarksJuliafpSetup(void) -{ - if (param[2] < 1) - param[2] = 1; - c_exp = (int)param[2]; - floatparm = &parm; - old = *floatparm; - if (c_exp > 3) - cpower(&old,c_exp-1,&coefficient); - else if (c_exp == 3) - { - coefficient.x = sqr(old.x) - sqr(old.y); - coefficient.y = old.x * old.y * 2; - } - else if (c_exp == 2) - coefficient = old; - else if (c_exp < 2) { - coefficient.x = 1.0; - coefficient.y = 0.0; - } - get_julia_attractor (0.0, 0.0); /* an attractor? */ - return(1); -} - -int -SierpinskiSetup(void) -{ - /* sierpinski */ - periodicitycheck = 0; /* disable periodicity checks */ - ltmp.x = 1; - ltmp.x = ltmp.x << bitshift; /* ltmp.x = 1 */ - ltmp.y = ltmp.x >> 1; /* ltmp.y = .5 */ - return(1); -} - -int -SierpinskiFPSetup(void) -{ - /* sierpinski */ - periodicitycheck = 0; /* disable periodicity checks */ - tmp.x = 1; - tmp.y = 0.5; - return(1); -} - -int -HalleySetup(void) -{ - /* Halley */ - periodicitycheck=0; - - if (usr_floatflag) - fractype = HALLEY; /* float on */ - else - fractype = MPHALLEY; - - curfractalspecific = &fractalspecific[fractype]; - - degree = (int)parm.x; - if (degree < 2) - degree = 2; - param[0] = (double)degree; - -/* precalculated values */ - AplusOne = degree + 1; /* a+1 */ - Ap1deg = AplusOne * degree; - -#if !defined(XFRACT) - if (fractype == MPHALLEY) { - setMPfunctions(); - mpAplusOne = *pd2MP((double)AplusOne); - mpAp1deg = *pd2MP((double)Ap1deg); - mpctmpparm.x = *pd2MP(parm.y); - mpctmpparm.y = *pd2MP(parm2.y); - mptmpparm2x = *pd2MP(parm2.x); - mpone = *pd2MP(1.0); - } -#endif - - if (degree % 2) - symmetry = XAXIS; /* odd */ - else - symmetry = XYAXIS; /* even */ - return(1); -} - -int -PhoenixSetup(void) -{ - longparm = &lparm; /* added to consolidate code 10/1/92 JCO */ - floatparm = &parm; - degree = (int)parm2.x; - if (degree < 2 && degree > -3) degree = 0; - param[2] = (double)degree; - if (degree == 0){ - if (usr_floatflag) - curfractalspecific->orbitcalc = PhoenixFractal; - else - curfractalspecific->orbitcalc = LongPhoenixFractal; - } - if (degree >= 2){ - degree = degree - 1; - if (usr_floatflag) - curfractalspecific->orbitcalc = PhoenixPlusFractal; - else - curfractalspecific->orbitcalc = LongPhoenixPlusFractal; - } - if (degree <= -3){ - degree = abs(degree) - 2; - if (usr_floatflag) - curfractalspecific->orbitcalc = PhoenixMinusFractal; - else - curfractalspecific->orbitcalc = LongPhoenixMinusFractal; - } - - return(1); -} - -int -PhoenixCplxSetup(void) -{ - longparm = &lparm; - floatparm = &parm; - degree = (int)param[4]; - if (degree < 2 && degree > -3) degree = 0; - param[4] = (double)degree; - if (degree == 0){ - if (parm2.x != 0 || parm2.y != 0) - symmetry = NOSYM; - else - symmetry = ORIGIN; - if (parm.y == 0 && parm2.y == 0) - symmetry = XAXIS; - if (usr_floatflag) - curfractalspecific->orbitcalc = PhoenixFractalcplx; - else - curfractalspecific->orbitcalc = LongPhoenixFractalcplx; - } - if (degree >= 2){ - degree = degree - 1; - if (parm.y == 0 && parm2.y == 0) - symmetry = XAXIS; - else - symmetry = NOSYM; - if (usr_floatflag) - curfractalspecific->orbitcalc = PhoenixCplxPlusFractal; - else - curfractalspecific->orbitcalc = LongPhoenixCplxPlusFractal; - } - if (degree <= -3){ - degree = abs(degree) - 2; - if (parm.y == 0 && parm2.y == 0) - symmetry = XAXIS; - else - symmetry = NOSYM; - if (usr_floatflag) - curfractalspecific->orbitcalc = PhoenixCplxMinusFractal; - else - curfractalspecific->orbitcalc = LongPhoenixCplxMinusFractal; - } - - return(1); -} - -int -MandPhoenixSetup(void) -{ - longparm = &linit; /* added to consolidate code 10/1/92 JCO */ - floatparm = &init; - degree = (int)parm2.x; - if (degree < 2 && degree > -3) degree = 0; - param[2] = (double)degree; - if (degree == 0){ - if (usr_floatflag) - curfractalspecific->orbitcalc = PhoenixFractal; - else - curfractalspecific->orbitcalc = LongPhoenixFractal; - } - if (degree >= 2){ - degree = degree - 1; - if (usr_floatflag) - curfractalspecific->orbitcalc = PhoenixPlusFractal; - else - curfractalspecific->orbitcalc = LongPhoenixPlusFractal; - } - if (degree <= -3){ - degree = abs(degree) - 2; - if (usr_floatflag) - curfractalspecific->orbitcalc = PhoenixMinusFractal; - else - curfractalspecific->orbitcalc = LongPhoenixMinusFractal; - } - - return(1); -} - -int -MandPhoenixCplxSetup(void) -{ - longparm = &linit; /* added to consolidate code 10/1/92 JCO */ - floatparm = &init; - degree = (int)param[4]; - if (degree < 2 && degree > -3) degree = 0; - param[4] = (double)degree; - if (parm.y != 0 || parm2.y != 0) - symmetry = NOSYM; - if (degree == 0){ - if (usr_floatflag) - curfractalspecific->orbitcalc = PhoenixFractalcplx; - else - curfractalspecific->orbitcalc = LongPhoenixFractalcplx; - } - if (degree >= 2){ - degree = degree - 1; - if (usr_floatflag) - curfractalspecific->orbitcalc = PhoenixCplxPlusFractal; - else - curfractalspecific->orbitcalc = LongPhoenixCplxPlusFractal; - } - if (degree <= -3){ - degree = abs(degree) - 2; - if (usr_floatflag) - curfractalspecific->orbitcalc = PhoenixCplxMinusFractal; - else - curfractalspecific->orbitcalc = LongPhoenixCplxMinusFractal; - } - - return(1); -} - -int -StandardSetup(void) -{ - if (fractype==UNITYFP) - periodicitycheck=0; - return(1); -} - -int -VLSetup(void) -{ - if (param[0] < 0.0) param[0] = 0.0; - if (param[1] < 0.0) param[1] = 0.0; - if (param[0] > 1.0) param[0] = 1.0; - if (param[1] > 1.0) param[1] = 1.0; - floatparm = &parm; - return 1; -} diff --git a/fractint/common/gifview.c b/fractint/common/gifview.c deleted file mode 100644 index 828b60495..000000000 --- a/fractint/common/gifview.c +++ /dev/null @@ -1,482 +0,0 @@ -/* - * - * This GIF decoder is designed for use with the FRACTINT program. - * This decoder code lacks full generality in the following respects: - * supports non-interlaced GIF files only, and calmly ignores any - * local color maps and non-Fractint-specific extension blocks. - * - * GIF and 'Graphics Interchange Format' are trademarks (tm) of - * Compuserve, Incorporated, an H&R Block Company. - * - * Tim Wegner - */ - -#include - /* see Fractint.c for a description of the "include" hierarchy */ -#include "port.h" -#include "prototyp.h" -#include "drivers.h" - -static void close_file(void); - -#define MAXCOLORS 256 - -static FILE *fpin = NULL; /* FILE pointer */ -unsigned int height; -unsigned numcolors; -int bad_code_count = 0; /* needed by decoder module */ - -static int out_line_dither(BYTE *, int); -static int out_line_migs(BYTE *, int); -static int out_line_too_wide(BYTE *, int); -static int colcount; /* keeps track of current column for wide images */ - -static unsigned int gifview_image_top; /* (for migs) */ -static unsigned int gifview_image_left; /* (for migs) */ -static unsigned int gifview_image_twidth; /* (for migs) */ - -int get_byte() -{ - return (getc(fpin)); /* EOF is -1, as desired */ -} - -int get_bytes(BYTE *where,int how_many) -{ - return (int) fread((char *)where,1,how_many,fpin); /* EOF is -1, as desired */ -} - -/* - * DECODERLINEWIDTH is the width of the pixel buffer used by the decoder. A - * larger buffer gives better performance. However, this buffer does not - * have to be a whole line width, although historically in Fractint it has - * been: images were decoded line by line and a whole line written to the - * screen at once. The requirement to have a whole line buffered at once - * has now been relaxed in order to support larger images. The one exception - * to this is in the case where the image is being decoded to a smaller size. - * The skipxdots and skipydots logic assumes that the buffer holds one line. - */ - -#if defined(XFRACT) || defined(_WIN32) -BYTE decoderline[MAXPIXELS+1]; /* write-line routines use this */ -#define DECODERLINE_WIDTH MAXPIXELS -#else -#define DECODERLINE_WIDTH 2048 /* width of decoderline, can be smaller */ -#endif - -BYTE *decoderline1; -static char *ditherbuf = NULL; - -/* Main entry decoder */ - -int gifview() -{ - BYTE buffer[16]; - unsigned top, left, width, finished; - char temp1[FILE_MAX_DIR]; - BYTE byte_buf[257]; /* for decoder */ - int status; - int i, j, k, planes; - BYTE linebuf[DECODERLINE_WIDTH]; - decoderline1 = linebuf; - -#if 0 - { - char msg[100]; - sprintf(msg,"Stack free in gifview: %d",stackavail()); - stopmsg(0,msg); - } -#endif - - /* using stack for decoder byte buf rather than static mem */ - set_byte_buff(byte_buf); - - status = 0; - - /* initialize the col and row count for write-lines */ - colcount = g_row_count = 0; - - /* Open the file */ - if (outln == outline_stereo) - strcpy(temp1,stereomapname); - else - strcpy(temp1,readname); - if (has_ext(temp1) == NULL) { - strcat(temp1,DEFAULTFRACTALTYPE); - if ((fpin = fopen(temp1,"rb")) != NULL) { - fclose(fpin); - } - else { - if (outln == outline_stereo) - strcpy(temp1,stereomapname); - else - strcpy(temp1,readname); - strcat(temp1,ALTERNATEFRACTALTYPE); - } - } - fpin = fopen(temp1, "rb"); - if (fpin == NULL) { - return (-1); - } - - /* Get the screen description */ - for (i = 0; i < 13; i++) - { - int tmp; - - buffer[i] = (BYTE)(tmp = get_byte()); - if (tmp < 0) - { - close_file(); - return(-1); - } - } - - if (strncmp((char *)buffer,"GIF87a",3) || /* use updated GIF specs */ - buffer[3] < '0' || buffer[3] > '9' || - buffer[4] < '0' || buffer[4] > '9' || - buffer[5] < 'A' || buffer[5] > 'z' ) - { - close_file(); - return(-1); - } - - width = buffer[6] | (buffer[7] << 8); - height = buffer[8] | (buffer[9] << 8); - planes = (buffer[10] & 0x0F) + 1; - gifview_image_twidth = width; - - if ((buffer[10] & 0x80)==0) /* color map (better be!) */ - { - close_file(); - return(-1); - } - numcolors = 1 << planes; - - if (dither_flag && numcolors>2 && colors==2 && outln==out_line) { - outln = out_line_dither; - } - - for (i = 0; i < (int)numcolors; i++) - { - for (j = 0; j < 3; j++) { - if ((k = get_byte()) < 0) - { - close_file(); - return(-1); - } - if ((!display3d || (g_glasses_type != 1 && g_glasses_type != 2)) - && !dontreadcolor) - g_dac_box[i][j] = (BYTE)(k >> 2); /* TODO: don't right shift color table by 2 */ - } - } - colorstate = 1; /* colors aren't default and not a known .map file */ - - /* don't read if glasses */ - if (display3d && mapset && g_glasses_type!=1 && g_glasses_type != 2) - { - ValidateLuts(MAP_name); /* read the palette file */ - spindac(0,1); /* load it, but don't spin */ - } - if (g_dac_box[0][0] != 255) - spindac(0,1); /* update the DAC */ - if (driver_diskp()){ /* disk-video */ - char fname[FILE_MAX_FNAME]; - char ext[FILE_MAX_EXT]; - char tmpname[15]; - char msg[40]; - splitpath(temp1,NULL,NULL,fname,ext); - makepath(tmpname,NULL,NULL,fname,ext); - sprintf(msg,"restoring %s",tmpname); - dvid_status(1,msg); - } - dontreadcolor = 0; - - /* Now display one or more GIF objects */ - finished = 0; - while (!finished) - { - switch (get_byte()) - { - case ';': - /* End of the GIF dataset */ - - finished = 1; - status = 0; - break; - - case '!': /* GIF Extension Block */ - get_byte(); /* read (and ignore) the ID */ - while ((i = get_byte()) > 0) /* get the data length */ - for (j = 0; j < i; j++) - get_byte(); /* flush the data */ - break; - case ',': - /* - * Start of an image object. Read the image description. - */ - - for (i = 0; i < 9; i++) - { - int tmp; - - buffer[i] = (BYTE)(tmp = get_byte()); - if (tmp < 0) - { - status = -1; - break; - } - } - if (status < 0) - { - finished = 1; - break; - } - - left = buffer[0] | (buffer[1] << 8); - top = buffer[2] | (buffer[3] << 8); - width = buffer[4] | (buffer[5] << 8); - height = buffer[6] | (buffer[7] << 8); - - /* adjustments for handling MIGs */ - gifview_image_top = top; - if (skipxdots > 0) - gifview_image_top /= (skipydots+1); - gifview_image_left = left; - if (skipydots > 0) - gifview_image_left /= (skipxdots+1); - if (outln==out_line) - { - /* what about continuous potential???? */ - if (width != gifview_image_twidth || top != 0) - { /* we're using normal decoding and we have a MIG */ - outln = out_line_migs; - } - else if (width > DECODERLINE_WIDTH && skipxdots == 0) - { - outln = out_line_too_wide; - } - } - - if (pot16bit) width >>= 1; - - /* Skip local color palette */ - if ((buffer[8] & 0x80)==0x80) { /* local map? */ - int numcolors; /* make this local */ - planes = (buffer[8] & 0x0F) + 1; - numcolors = 1 << planes; - /* skip local map */ - for (i = 0; i < numcolors; i++) { - for (j = 0; j < 3; j++) { - if ((k = get_byte()) < 0) { - close_file(); - return(-1); - } - } - } - } - - /* initialize the row count for write-lines */ - g_row_count = 0; - - if (calc_status == CALCSTAT_IN_PROGRESS) /* should never be so, but make sure */ - calc_status = CALCSTAT_PARAMS_CHANGED; - busy = 1; /* for slideshow CALCWAIT */ - /* - * Call decoder(width) via timer. - * Width is limited to DECODERLINE_WIDTH. - */ - if (skipxdots == 0) - width = min(width,DECODERLINE_WIDTH); - status = timer(1,NULL,width); - busy = 0; /* for slideshow CALCWAIT */ - if (calc_status == CALCSTAT_IN_PROGRESS) /* e.g., set by line3d */ - { - calctime = timer_interval; /* note how long it took */ - if (driver_key_pressed() != 0) { - calc_status = CALCSTAT_NON_RESUMABLE; /* interrupted, not resumable */ - finished = 1; - } - else - calc_status = CALCSTAT_COMPLETED; /* complete */ - } - /* Hey! the decoder doesn't read the last (0-length) block!! */ - if (get_byte() != 0) { - status = -1; - finished = 1; - } - break; - default: - status = -1; - finished = 1; - break; - } - } - close_file(); - if (driver_diskp()) { /* disk-video */ - dvid_status(0,"Restore completed"); - dvid_status(1,""); - } - - if (ditherbuf != NULL) { /* we're done, free dither memory */ - free(ditherbuf); - ditherbuf = NULL; - } - - return(status); -} - -static void close_file() -{ - fclose(fpin); - fpin = NULL; -} - -/* routine for MIGS that generates partial output lines */ - -static int out_line_migs(BYTE *pixels, int linelen) -{ - int row, startcol, stopcol; - - row = gifview_image_top + g_row_count; - startcol = gifview_image_left; - stopcol = startcol+linelen-1; - put_line(row, startcol, stopcol, pixels); - g_row_count++; - - return(0); -} - -static int out_line_dither(BYTE *pixels, int linelen) -{ - int i,nexterr,brt,err; - if (ditherbuf == NULL) - ditherbuf = (char *)malloc(linelen+1); - memset( ditherbuf, 0, linelen+1); - - nexterr = (rand()&0x1f)-16; - for (i=0;i>4; /* brightness from 0 to 63 */ -#else - brt = (g_dac_box[pixels[i]][0]*5+g_dac_box[pixels[i]][1]*9 + - g_dac_box[pixels[i]][2]*2)>>4; /* brightness from 0 to 63 */ -#endif - brt += nexterr; - if (brt>32) { - pixels[i] = 1; - err = brt-63; - } else { - pixels[i] = 0; - err = brt; - } - nexterr = ditherbuf[i+1]+err/3; - ditherbuf[i] = (char)(err/3); - ditherbuf[i+1] = (char)(err/3); - } - return out_line(pixels, linelen); -} - -/* routine for images wider than the row buffer */ - -static int out_line_too_wide(BYTE *pixels, int linelen) -{ - /* int twidth = gifview_image_twidth;*/ - int twidth = xdots; - int extra; - while (linelen > 0) - { - extra = colcount+linelen-twidth; - if (extra > 0) /* line wraps */ - { - put_line(g_row_count, colcount, twidth-1, pixels); - pixels += twidth-colcount; - linelen -= twidth-colcount; - colcount = twidth; - } - else - { - put_line(g_row_count, colcount, colcount+linelen-1, pixels); - colcount += linelen; - linelen = 0; - } - if (colcount >= twidth) - { - colcount = 0; - g_row_count++; - } - } - return(0); -} - -static int put_sound_line(int row, int colstart, int colstop, BYTE *pixels) -{ - int col; - for (col=colstart; col<=colstop; col++) - { - putcolor(col,row,*pixels); - if (orbit_delay > 0) - sleepms(orbit_delay); - w_snd((int)((int)(*pixels++)*3000/colors+basehertz)); - if (driver_key_pressed()) - { - driver_mute(); - return(-1); - } - } - return(0); -} - -int sound_line(BYTE *pixels, int linelen) -{ - /* int twidth = gifview_image_twidth;*/ - int twidth = xdots; - int extra; - int ret=0; - while (linelen > 0) - { - extra = colcount+linelen-twidth; - if (extra > 0) /* line wraps */ - { - if (put_sound_line(g_row_count, colcount, twidth-1, pixels)) - break; - pixels += twidth-colcount; - linelen -= twidth-colcount; - colcount = twidth; - } - else - { - if (put_sound_line(g_row_count, colcount, colcount+linelen-1, pixels)) - break; - colcount += linelen; - linelen = 0; - } - if (colcount >= twidth) - { - colcount = 0; - g_row_count++; - } - } - driver_mute(); - if (driver_key_pressed()) - ret = -1; - return(ret); -} - -int pot_line(BYTE *pixels, int linelen) -{ - int row,col,saverowcount; - if (g_row_count == 0) - if (pot_startdisk() < 0) - return -1; - saverowcount = g_row_count; - row = (g_row_count >>= 1); - if ((saverowcount & 1) != 0) /* odd line */ - row += ydots; - else if (!driver_diskp()) /* even line - display the line too */ - out_line(pixels,linelen); - for (col = 0; col < xdots; ++col) - writedisk(col+sxoffs,row+syoffs,*(pixels+col)); - g_row_count = saverowcount + 1; - return(0); -} diff --git a/fractint/common/hcmplx.c b/fractint/common/hcmplx.c deleted file mode 100644 index 7cfbb59d6..000000000 --- a/fractint/common/hcmplx.c +++ /dev/null @@ -1,97 +0,0 @@ -/* some hyper complex functions */ - /* see Fractint.c for a description of the "include" hierarchy */ -#include "port.h" -#include "prototyp.h" - -void HComplexMult(_HCMPLX *arg1, _HCMPLX *arg2, _HCMPLX *out) -{ - /* it is possible to reoganize this code and reduce the multiplies - from 16 to 10, but on my 486 it is SLOWER !!! so I left it - like this - Tim Wegner */ - out->x = arg1->x * arg2->x - arg1->y * arg2->y - - arg1->z * arg2->z + arg1->t * arg2->t; - out->y = arg1->y * arg2->x + arg1->x * arg2->y - - arg1->t * arg2->z - arg1->z * arg2->t; - out->z = arg1->z * arg2->x - arg1->t * arg2->y - + arg1->x * arg2->z - arg1->y * arg2->t; - out->t = arg1->t * arg2->x + arg1->z * arg2->y - + arg1->y * arg2->z + arg1->x * arg2->t; -} - -void HComplexSqr(_HCMPLX *arg, _HCMPLX *out) -{ - out->x = arg->x * arg->x - arg->y * arg->y - - arg->z * arg->z + arg->t * arg->t; - out->y = 2 * arg->x * arg->y - 2 * arg->z * arg->t; - out->z = 2 * arg->z * arg->x - 2 * arg->t * arg->y; - out->t = 2 * arg->t * arg->x + 2 * arg->z * arg->y; -} - -int HComplexInv(_HCMPLX *arg, _HCMPLX *out) -{ - double det, mod, xt_minus_yz; - - det = (sqr(arg->x - arg->t) + sqr(arg->y + arg->z))* - (sqr(arg->x + arg->t) + sqr(arg->y - arg->z)); - - if (det == 0.0) - return(-1); - mod = sqr(arg->x) + sqr(arg->y) + sqr(arg->z) + sqr(arg->t); - xt_minus_yz = arg->x * arg->t - arg->y * arg->z; - - out->x = ( arg->x * mod - 2 * arg->t * xt_minus_yz)/det; - out->y = (-arg->y * mod - 2 * arg->z * xt_minus_yz)/det; - out->z = (-arg->z * mod - 2 * arg->y * xt_minus_yz)/det; - out->t = ( arg->t * mod - 2 * arg->x * xt_minus_yz)/det; - return(0); -} - -void HComplexAdd(_HCMPLX *arg1, _HCMPLX *arg2, _HCMPLX *out) -{ - out->x = arg1->x + arg2->x; - out->y = arg1->y + arg2->y; - out->z = arg1->z + arg2->z; - out->t = arg1->t + arg2->t; -} - -void HComplexSub(_HCMPLX *arg1, _HCMPLX *arg2, _HCMPLX *out) -{ - out->x = arg1->x - arg2->x; - out->y = arg1->y - arg2->y; - out->z = arg1->z - arg2->z; - out->t = arg1->t - arg2->t; -} - -void HComplexMinus(_HCMPLX *arg1, _HCMPLX *out) -{ - out->x = -arg1->x; - out->y = -arg1->y; - out->z = -arg1->z; - out->t = -arg1->t; -} - -/* extends the unary function f to *h1 */ -void HComplexTrig0(_HCMPLX *h, _HCMPLX *out) -{ - /* This is the whole beauty of Hypercomplex numbers - *ANY* unary - complex valued function of a complex variable can easily - be generalized to hypercomplex numbers */ - - _CMPLX a,b, resulta,resultb; - - /* convert to duplex form */ - a.x = h->x - h->t; - a.y = h->y + h->z; - b.x = h->x + h->t; - b.y = h->y - h->z; - - /* apply function to each part */ - CMPLXtrig0(a,resulta); - CMPLXtrig0(b,resultb); - - /* convert back */ - out->x = (resulta.x + resultb.x)/2; - out->y = (resulta.y + resultb.y)/2; - out->z = (resulta.y - resultb.y)/2; - out->t = (resultb.x - resulta.x)/2; -} diff --git a/fractint/common/help.c b/fractint/common/help.c deleted file mode 100644 index 208c3c3ad..000000000 --- a/fractint/common/help.c +++ /dev/null @@ -1,1564 +0,0 @@ -/* - * help.c - * - * - * - * Revision history: - * - * 2-26-90 EAN Initial version. - * - * - */ - -#ifndef TEST /* kills all those assert macros in production version */ -#define NDEBUG -#endif - -#define INCLUDE_COMMON /* include common code in helpcom.h */ - -#if !defined(XFRACT) -#include -#endif -#include -#include -#include -#include -#include -#include - /* see Fractint.c for a description of the "include" hierarchy */ -#include "port.h" -#include "prototyp.h" -#include "helpdefs.h" -#include "drivers.h" - -#define MAX_HIST 16 /* number of pages we'll remember */ -#define ACTION_CALL 0 /* values returned by help_topic() */ -#define ACTION_PREV 1 -#define ACTION_PREV2 2 /* special - go back two topics */ -#define ACTION_INDEX 3 -#define ACTION_QUIT 4 -#define F_HIST (1<<0) /* flags for help_topic() */ -#define F_INDEX (1<<1) -#define MAX_PAGE_SIZE (80*25) /* no page of text may be larger */ -#define TEXT_START_ROW 2 /* start print the help text here */ - -typedef struct -{ - BYTE r, c; - int width; - unsigned offset; - int topic_num; - unsigned topic_off; -} LINK; - -typedef struct -{ - int topic_num; - unsigned topic_off; -} LABEL; - -typedef struct -{ - unsigned offset; - unsigned len; - int margin; -} PAGE; - -typedef struct -{ - int topic_num; - unsigned topic_off; - int link; -} HIST; - -struct help_sig_info -{ - unsigned long sig; - int version; - unsigned long base; /* only if added to fractint.exe */ -}; - -void print_document(char *outfname, int (*msg_func)(int,int), int save_extraseg ); -static int print_doc_msg_func(int pnum, int num_pages); - -/* stuff from fractint */ - -static FILE *help_file = NULL; /* help file handle */ -static long base_off; /* offset to help info in help file */ -static int max_links; /* max # of links in any page */ -static int max_pages; /* max # of pages in any topic */ -static int num_label; /* number of labels */ -static int num_topic; /* number of topics */ -static int curr_hist = 0; /* current pos in history */ - -/* these items alloc'ed in init_help... */ - -static long *topic_offset; /* 4*num_topic */ -static LABEL *label; /* 4*num_label */ -static HIST *hist; /* 6*MAX_HIST (96 bytes) */ - -/* these items alloc'ed only while help is active... */ - -static char *buffer; /* MAX_PAGE_SIZE (2048 bytes) */ -static LINK *link_table; /* 10*max_links */ -static PAGE *page_table; /* 4*max_pages */ - -static void help_seek(long pos) -{ - fseek(help_file, base_off + pos, SEEK_SET); -} - -static void displaycc(int row, int col, int color, int ch) -{ - char s[] = { (char) ch, 0 }; - driver_put_string(row, col, color, s); -} - -static void display_text(int row, int col, int color, char *text, unsigned len) -{ - while (len-- != 0) - { - if (*text == CMD_LITERAL) - { - ++text; - --len; - } - displaycc(row, col++, color, *text++); - } -} - -static void display_parse_text(char *text, unsigned len, int start_margin, int *num_link, LINK *link) -{ - char *curr; - int row, col; - int tok; - int size, width; - - g_text_cbase = SCREEN_INDENT; - g_text_rbase = TEXT_START_ROW; - - curr = text; - row = 0; - col = 0; - - size = width = 0; - - if (start_margin >= 0) - tok = TOK_PARA; - else - tok = -1; - - while (1) - { - switch (tok) - { - case TOK_PARA: - { - int indent, margin; - - if (size > 0) - { - ++curr; - indent = *curr++; - margin = *curr++; - len -= 3; - } - else - { - indent = start_margin; - margin = start_margin; - } - - col = indent; - - while (1) - { - tok = find_token_length(ONLINE, curr, len, &size, &width); - - if (tok == TOK_DONE || tok == TOK_NL || tok == TOK_FF) - { - break; - } - - if (tok == TOK_PARA) - { - col = 0; /* fake a new-line */ - row++; - break; - } - - if (tok == TOK_XONLINE || tok == TOK_XDOC) - { - curr += size; - len -= size; - continue; - } - - /* now tok is TOK_SPACE or TOK_LINK or TOK_WORD */ - - if (col+width > SCREEN_WIDTH) - { /* go to next line... */ - col = margin; - ++row; - - if (tok == TOK_SPACE) - { - width = 0; /* skip spaces at start of a line */ - } - } - - if (tok == TOK_LINK) - { - display_text(row, col, C_HELP_LINK, curr+1+3*sizeof(int), width); - if (num_link != NULL) - { - link[*num_link].r = (BYTE)row; - link[*num_link].c = (BYTE)col; - link[*num_link].topic_num = getint(curr+1); - link[*num_link].topic_off = getint(curr+1+sizeof(int)); - link[*num_link].offset = (unsigned) ((curr+1+3*sizeof(int)) - text); - link[*num_link].width = width; - ++(*num_link); - } - } - else if (tok == TOK_WORD) - { - display_text(row, col, C_HELP_BODY, curr, width); - } - - col += width; - curr += size; - len -= size; - } - - width = size = 0; - break; - } - - case TOK_CENTER: - col = find_line_width(ONLINE, curr, len); - col = (SCREEN_WIDTH - col)/2; - if (col < 0) - { - col = 0; - } - break; - - case TOK_NL: - col = 0; - ++row; - break; - - case TOK_LINK: - display_text(row, col, C_HELP_LINK, curr+1+3*sizeof(int), width); - if (num_link != NULL) - { - link[*num_link].r = (BYTE)row; - link[*num_link].c = (BYTE)col; - link[*num_link].topic_num = getint(curr+1); - link[*num_link].topic_off = getint(curr+1+sizeof(int)); - link[*num_link].offset = (unsigned) ((curr+1+3*sizeof(int)) - text); - link[*num_link].width = width; - ++(*num_link); - } - break; - - case TOK_XONLINE: /* skip */ - case TOK_FF: /* ignore */ - case TOK_XDOC: /* ignore */ - case TOK_DONE: - case TOK_SPACE: - break; - - case TOK_WORD: - display_text(row, col, C_HELP_BODY, curr, width); - break; - } /* switch */ - - curr += size; - len -= size; - col += width; - - if (len == 0) - { - break; - } - - tok = find_token_length(ONLINE, curr, len, &size, &width); - } /* while (1) */ - - g_text_cbase = 0; - g_text_rbase = 0; -} - -static void color_link(LINK *link, int color) -{ - g_text_cbase = SCREEN_INDENT; - g_text_rbase = TEXT_START_ROW; - - driver_set_attr(link->r, link->c, color, link->width); - - g_text_cbase = 0; - g_text_rbase = 0; -} - -/* #define PUT_KEY(name, descrip) - putstring(-1,-1,C_HELP_INSTR_KEYS,name), - putstring(-1,-1,C_HELP_INSTR," "descrip" ") -*/ -#if defined(_WIN32) -#define PUT_KEY(name_,desc_) put_key(name_,desc_) -#else -#if !defined(XFRACT) -#define PUT_KEY(name, descrip) \ - driver_put_string(-1,-1,C_HELP_INSTR,name), \ - driver_put_string(-1,-1,C_HELP_INSTR,":"descrip" ") -#else -#define PUT_KEY(name, descrip) \ - driver_put_string(-1,-1,C_HELP_INSTR,name); \ - driver_put_string(-1,-1,C_HELP_INSTR,":"); \ - driver_put_string(-1,-1,C_HELP_INSTR,descrip); \ - driver_put_string(-1,-1,C_HELP_INSTR," ") -#endif -#endif - -static void put_key(char *name, char *descrip) -{ - driver_put_string(-1, -1, C_HELP_INSTR, name); - driver_put_string(-1, -1, C_HELP_INSTR, ":"); - driver_put_string(-1, -1, C_HELP_INSTR, descrip); - driver_put_string(-1, -1, C_HELP_INSTR, " "); -} - -static void helpinstr(void) -{ - int ctr; - - for (ctr = 0; ctr < 80; ctr++) - { - driver_put_string(24, ctr, C_HELP_INSTR, " "); - } - - driver_move_cursor(24, 1); - PUT_KEY("F1", "Index"); -#if !defined(XFRACT) && !defined(_WIN32) - PUT_KEY("\030\031\033\032", "Select"); -#else - PUT_KEY("K J H L", "Select"); -#endif - PUT_KEY("Enter", "Go to"); - PUT_KEY("Backspace", "Last topic"); - PUT_KEY("Escape", "Exit help"); -} - -static void printinstr(void) -{ - int ctr; - - for (ctr = 0; ctr < 80; ctr++) - { - driver_put_string(24, ctr, C_HELP_INSTR, " "); - } - - driver_move_cursor(24, 1); - PUT_KEY("Escape", "Abort"); -} - -#undef PUT_KEY - -static void display_page(char *title, char *text, unsigned text_len, - int page, int num_pages, int start_margin, - int *num_link, LINK *link) -{ - char temp[9]; - - helptitle(); - helpinstr(); - driver_set_attr(2, 0, C_HELP_BODY, 80*22); - putstringcenter(1, 0, 80, C_HELP_HDG, title); - sprintf(temp, "%2d of %d", page+1, num_pages); -#if !defined(XFRACT) && !defined(_WIN32) - driver_put_string(1, 79-(6 + ((num_pages>=10)?2:1)), C_HELP_INSTR, temp); -#else - /* Some systems (Ultrix) mess up if you write to column 80 */ - driver_put_string(1, 78-(6 + ((num_pages>=10)?2:1)), C_HELP_INSTR, temp); -#endif - - if (text != NULL) - { - display_parse_text(text, text_len, start_margin, num_link, link); - } - - driver_hide_text_cursor(); -} - -/* - * int overlap(int a, int a2, int b, int b2); - * - * If a, a2, b, and b2 are points on a line, this function returns the - * distance of intersection between a-->a2 and b-->b2. If there is no - * intersection between the lines this function will return a negative number - * representing the distance between the two lines. - * - * There are six possible cases of intersection between the lines: - * - * a a2 - * | | - * b b2 | | b b2 - * |---(1)---| | | |---(2)---| - * | | - * b | b2 b | b2 - * |------(3)----| |------(4)-----| - * | | - * b | | b2 - * |------+--------(5)----------+---| - * | | - * | b b2 | - * | |--(6)--| | - * | | - * | | - * - */ - -static int overlap(int a, int a2, int b, int b2) -{ - if (b < a) - { - if (b2 >= a2) - { - return a2 - a; /* case (5) */ - } - - return b2 - a; /* case (1), case (3) */ - } - - if (b2 <= a2) - { - return b2 - b; /* case (6) */ - } - - return a2 - b; /* case (2), case (4) */ -} - -static int dist1(int a, int b) -{ - int t = a - b; - - return (abs(t)); -} - -static int find_link_updown(LINK *link, int num_link, int curr_link, int up) -{ - int ctr, curr_c2, best_overlap = 0, temp_overlap; - LINK *curr, *temp, *best; - int temp_dist; - - curr = &link[curr_link]; - best = NULL; - curr_c2 = curr->c + curr->width - 1; - - for (ctr=0, temp=link; ctrr < curr->r) || (!up && temp->r > curr->r))) - { - temp_overlap = overlap(curr->c, curr_c2, temp->c, temp->c+temp->width-1); - /* if >= 3 lines between, prioritize on vertical distance: */ - if ((temp_dist = dist1(temp->r, curr->r)) >= 4) - { - temp_overlap -= temp_dist*100; - } - - if (best != NULL) - { - if (best_overlap >= 0 && temp_overlap >= 0) - { /* if they're both under curr set to closest in y dir */ - if (dist1(best->r, curr->r) > temp_dist) - { - best = NULL; - } - } - else - { - if (best_overlap < temp_overlap) - { - best = NULL; - } - } - } - - if (best == NULL) - { - best = temp; - best_overlap = temp_overlap; - } - } - } - - return (best == NULL) ? -1 : (int)(best-link); -} - -static int find_link_leftright(LINK *link, int num_link, int curr_link, int left) -{ - int ctr, curr_c2, best_c2 = 0, temp_c2, best_dist = 0, temp_dist; - LINK *curr, *temp, *best; - - curr = &link[curr_link]; - best = NULL; - curr_c2 = curr->c + curr->width - 1; - - for (ctr = 0, temp = link; ctr < num_link; ctr++, temp++) - { - temp_c2 = temp->c + temp->width - 1; - - if (ctr != curr_link && - ((left && temp_c2 < (int) curr->c) || (!left && (int) temp->c > curr_c2))) - { - temp_dist = dist1(curr->r, temp->r); - - if (best != NULL) - { - if (best_dist == 0 && temp_dist == 0) /* if both on curr's line... */ - { - if ((left && dist1(curr->c, best_c2) > dist1(curr->c, temp_c2)) || - (!left && dist1(curr_c2, best->c) > dist1(curr_c2, temp->c))) - { - best = NULL; - } - } - else if (best_dist >= temp_dist) /* if temp is closer... */ - { - best = NULL; - } - } - else - { - best = temp; - best_dist = temp_dist; - best_c2 = temp_c2; - } - } - } /* for */ - - return (best == NULL) ? -1 : (int) (best-link); -} - -#ifdef __CLINT__ -# pragma argsused -#endif - -static int find_link_key(LINK *link, int num_link, int curr_link, int key) - { - link = NULL; /* just for warning */ - switch (key) - { - case FIK_TAB: return ( (curr_link>=num_link-1) ? -1 : curr_link+1 ); - case FIK_SHF_TAB: return ( (curr_link<=0) ? -1 : curr_link-1 ); - default: assert(0); return (-1); - } - } - -static int do_move_link(LINK *link, int num_link, int *curr, int (*f)(LINK *,int,int,int), int val) - { - int t; - - if (num_link > 1) - { - if ( f == NULL ) - t = val; - else - t = (*f)(link, num_link, *curr, val); - - if ( t >= 0 && t != *curr ) - { - color_link(&link[*curr], C_HELP_LINK); - *curr = t; - color_link(&link[*curr], C_HELP_CURLINK); - return (1); - } - } - - return (0); - } - -static int help_topic(HIST *curr, HIST *next, int flags) - { - int len; - int key; - int num_pages; - int num_link; - int page; - int curr_link; - char title[81]; - long where; - int draw_page; - int action; - BYTE ch; - - where = topic_offset[curr->topic_num]+sizeof(int); /* to skip flags */ - curr_link = curr->link; - - help_seek(where); - - fread(&num_pages, sizeof(int), 1, help_file); - assert(num_pages>0 && num_pages<=max_pages); - - fread(page_table, 3*sizeof(int), num_pages, help_file); - - fread(&ch, sizeof(char), 1, help_file); - len = ch; - assert(len<81); - fread(title, sizeof(char), len, help_file); - title[len] = '\0'; - - where += sizeof(int) + num_pages*3*sizeof(int) + 1 + len + sizeof(int); - - for (page=0; pagetopic_off >= page_table[page].offset && - curr->topic_off < page_table[page].offset+page_table[page].len ) - break; - - assert(page < num_pages); - - action = -1; - draw_page = 2; - - do - { - if (draw_page) - { - help_seek(where+page_table[page].offset); - fread(buffer, sizeof(char), page_table[page].len, help_file); - - num_link = 0; - display_page(title, buffer, page_table[page].len, page, num_pages, - page_table[page].margin, &num_link, link_table); - - if (draw_page==2) - { - assert(num_link<=0 || (curr_link>=0 && curr_link 0) - color_link(&link_table[curr_link], C_HELP_CURLINK); - - draw_page = 0; - } - - key = driver_get_key(); - - switch (key) - { - case FIK_PAGE_DOWN: - if (page0) - { - page--; - draw_page = 1; - } - break; - - case FIK_HOME: - if ( page != 0 ) - { - page = 0; - draw_page = 1; - } - else - do_move_link(link_table, num_link, &curr_link, NULL, 0); - break; - - case FIK_END: - if ( page != num_pages-1 ) - { - page = num_pages-1; - draw_page = 3; - } - else - do_move_link(link_table, num_link, &curr_link, NULL, num_link-1); - break; - - case FIK_TAB: - if ( !do_move_link(link_table, num_link, &curr_link, find_link_key, key) && - page0 ) - { - --page; - draw_page = 3; - } - break; - - case FIK_DOWN_ARROW: - if ( !do_move_link(link_table, num_link, &curr_link, find_link_updown, 0) && - page0 ) - { - --page; - draw_page = 3; - } - break; - - case FIK_LEFT_ARROW: - do_move_link(link_table, num_link, &curr_link, find_link_leftright, 1); - break; - - case FIK_RIGHT_ARROW: - do_move_link(link_table, num_link, &curr_link, find_link_leftright, 0); - break; - - case FIK_ESC: /* exit help */ - action = ACTION_QUIT; - break; - - case FIK_BACKSPACE: /* prev topic */ - case FIK_ALT_F1: - if (flags & F_HIST) - action = ACTION_PREV; - break; - - case FIK_F1: /* help index */ - if (!(flags & F_INDEX)) - action = ACTION_INDEX; - break; - - case FIK_ENTER: - case FIK_ENTER_2: - if (num_link > 0) - { - next->topic_num = link_table[curr_link].topic_num; - next->topic_off = link_table[curr_link].topic_off; - action = ACTION_CALL; - } - break; - } /* switch */ - } - while ( action == -1 ); - - curr->topic_off = page_table[page].offset; - curr->link = curr_link; - - return (action); - } - -int help(int action) -{ - HIST curr; - int oldlookatmouse; - int oldhelpmode; - int flags; - HIST next; - - if (helpmode == -1) /* is help disabled? */ - { - return 0; - } - - if (help_file == NULL) - { - driver_buzzer(BUZZER_ERROR); - return 0; - } - - buffer = (char *) malloc((long) MAX_PAGE_SIZE); - link_table = (LINK *) malloc(sizeof(LINK)*max_links); - page_table = (PAGE *) malloc(sizeof(PAGE)*max_pages); - - if ((buffer == NULL) || (NULL == link_table) || (NULL == page_table)) - { - driver_buzzer(BUZZER_ERROR); - return 0; - } - - oldlookatmouse = lookatmouse; - lookatmouse = 0; - timer_start -= clock_ticks(); - driver_stack_screen(); - - if (helpmode >= 0) - { - next.topic_num = label[helpmode].topic_num; - next.topic_off = label[helpmode].topic_off; - } - else - { - next.topic_num = helpmode; - next.topic_off = 0; - } - - oldhelpmode = helpmode; - - if (curr_hist <= 0) - action = ACTION_CALL; /* make sure it isn't ACTION_PREV! */ - - do - { - switch (action) - { - case ACTION_PREV2: - if (curr_hist > 0) - curr = hist[--curr_hist]; - - /* fall-through */ - - case ACTION_PREV: - if (curr_hist > 0) - curr = hist[--curr_hist]; - break; - - case ACTION_QUIT: - break; - - case ACTION_INDEX: - next.topic_num = label[FIHELP_INDEX].topic_num; - next.topic_off = label[FIHELP_INDEX].topic_off; - - /* fall-through */ - - case ACTION_CALL: - curr = next; - curr.link = 0; - break; - } /* switch */ - - flags = 0; - if (curr.topic_num == label[FIHELP_INDEX].topic_num) - flags |= F_INDEX; - if (curr_hist > 0) - flags |= F_HIST; - - if ( curr.topic_num >= 0 ) - action = help_topic(&curr, &next, flags); - else - { - if ( curr.topic_num == -100 ) - { - print_document("FRACTINT.DOC", print_doc_msg_func, 1); - action = ACTION_PREV2; - } - else if ( curr.topic_num == -101 ) - action = ACTION_PREV2; - else - { - display_page("Unknown Help Topic", NULL, 0, 0, 1, 0, NULL, NULL); - action = -1; - while (action == -1) - { - switch (driver_get_key()) - { - case FIK_ESC: action = ACTION_QUIT; break; - case FIK_ALT_F1: action = ACTION_PREV; break; - case FIK_F1: action = ACTION_INDEX; break; - } /* switch */ - } /* while */ - } - } /* else */ - - if ( action != ACTION_PREV && action != ACTION_PREV2 ) - { - if (curr_hist >= MAX_HIST) - { - int ctr; - - for (ctr=0; ctr= 300) /* DOS version 3.00+ ? */ - { - extern char **__argv; - strcpy(path, __argv[0]); /* note: __argv may be undocumented in MSC */ - if (strcmp(filename,"FRACTINT.EXE")==0) - if (can_read_file(path)) - return (1); - ptr = strrchr(path, SLASHC); - if (ptr == NULL) - ptr = path; - else - ++ptr; - strcpy(ptr, filename); - return (1); - } - - return (0); -#else - strcpy(path,SRCDIR); - strcat(path,"/"); - strcat(path,filename); - return 1; -#endif - } - -static int find_file(char *filename, char *path) -{ - if (exe_path(filename, path)) - { - if (can_read_file(path)) - { - return 1; - } - } - findpath(filename, path); - return path[0] ? 1 : 0; -} - -static int _read_help_topic(int topic, int off, int len, VOIDPTR buf) - { - static int curr_topic = -1; - static long curr_base; - static int curr_len; - int read_len; - - if ( topic != curr_topic ) - { - int t; - char ch; - - curr_topic = topic; - - curr_base = topic_offset[topic]; - - curr_base += sizeof(int); /* skip flags */ - - help_seek(curr_base); - fread(&t, sizeof(int), 1, help_file); /* read num_pages */ - curr_base += sizeof(int) + t*3*sizeof(int); /* skip page info */ - - if (t>0) - help_seek(curr_base); - fread(&ch, sizeof(char), 1, help_file); /* read title_len */ - t = ch; - curr_base += 1 + t; /* skip title */ - - if (t>0) - help_seek(curr_base); - fread(&curr_len, sizeof(int), 1, help_file); /* read topic len */ - curr_base += sizeof(int); - } - - read_len = (off+len > curr_len) ? curr_len - off : len; - - if (read_len > 0) - { - help_seek(curr_base + off); - fread(buf, sizeof(char), read_len, help_file); - } - - return ( curr_len - (off+len) ); - } - -int read_help_topic(int label_num, int off, int len, VOIDPTR buf) - /* - * reads text from a help topic. Returns number of bytes from (off+len) - * to end of topic. On "EOF" returns a negative number representing - * number of bytes not read. - */ - { - int ret; - ret = _read_help_topic(label[label_num].topic_num, - label[label_num].topic_off + off, len, buf); - return ( ret ); - } - -#define PRINT_BUFFER_SIZE (32767) /* max. size of help topic in doc. */ -#define TEMP_FILE_NAME "HELP.$$$" /* temp file for storing extraseg */ - /* while printing document */ -#define MAX_NUM_TOPIC_SEC (10) /* max. number of topics under any */ - /* single section (CONTENT) */ - -typedef struct PRINT_DOC_INFO - { - int cnum; /* current CONTENT num */ - int tnum; /* current topic num */ - - long content_pos; /* current CONTENT item offset in file */ - int num_page; /* total number of pages in document */ - - int num_contents, /* total number of CONTENT entries */ - num_topic; /* number of topics in current CONTENT */ - - int topic_num[MAX_NUM_TOPIC_SEC]; /* topic_num[] for current CONTENT entry */ - - char buffer[PRINT_BUFFER_SIZE]; /* text buffer */ - - char id[81]; /* buffer to store id in */ - char title[81]; /* buffer to store title in */ - -#if !defined(XFRACT) && !defined(_WIN32) - int (*msg_func)(int pnum, int num_page); -#else - int (*msg_func)(); - int pnum; -#endif - - FILE *file; /* file to sent output to */ - int margin; /* indent text by this much */ - int start_of_line; /* are we at the beginning of a line? */ - int spaces; /* number of spaces in a row */ - } PRINT_DOC_INFO; - -void print_document(char *outfname, int (*msg_func)(int,int), int save_extraseg ); - -static void printerc(PRINT_DOC_INFO *info, int c, int n) - { - while ( n-- > 0 ) - { - if (c==' ') - ++info->spaces; - - else if (c=='\n' || c=='\f') - { - info->start_of_line = 1; - info->spaces = 0; /* strip spaces before a new-line */ - fputc(c, info->file); - } - - else - { - if (info->start_of_line) - { - info->spaces += info->margin; - info->start_of_line = 0; - } - - while (info->spaces > 0) - { - fputc(' ', info->file); - --info->spaces; - } - - fputc(c, info->file); - } - } - } - -static void printers(PRINT_DOC_INFO *info, char *s, int n) - { - if (n > 0) - { - while ( n-- > 0 ) - printerc(info, *s++, 1); - } - else - { - while ( *s != '\0' ) - printerc(info, *s++, 1); - } - } - -static int print_doc_get_info(int cmd, PD_INFO *pd, PRINT_DOC_INFO *info) - { - int tmp; - int t; - BYTE ch; - - switch (cmd) - { - case PD_GET_CONTENT: - if ( ++info->cnum >= info->num_contents ) - return (0); - - help_seek( info->content_pos ); - - fread(&t, sizeof(int), 1, help_file); /* read flags */ - info->content_pos += sizeof(int); - pd->new_page = (t & 1) ? 1 : 0; - - fread(&ch, sizeof(char), 1, help_file); /* read id len */ - - t = ch; - if (t >= 80) - { - tmp = ftell(help_file); - } - assert(t<80); - fread(info->id, sizeof(char), t, help_file); /* read the id */ - info->content_pos += 1 + t; - info->id[t] = '\0'; - - fread(&ch, sizeof(char), 1, help_file); /* read title len */ - t = ch; - assert(t<80); - fread(info->title, sizeof(char), t, help_file); /* read the title */ - info->content_pos += 1 + t; - info->title[t] = '\0'; - - fread(&ch, sizeof(char), 1, help_file); /* read num_topic */ - t = ch; - assert(ttopic_num, sizeof(int), t, help_file); /* read topic_num[] */ - info->num_topic = t; - info->content_pos += 1 + t*sizeof(int); - - info->tnum = -1; - - pd->id = info->id; - pd->title = info->title; - return (1); - - case PD_GET_TOPIC: - if ( ++info->tnum >= info->num_topic ) - return (0); - - t = _read_help_topic(info->topic_num[info->tnum], 0, PRINT_BUFFER_SIZE, info->buffer); - - assert(t <= 0); - - pd->curr = info->buffer; - pd->len = PRINT_BUFFER_SIZE + t; /* same as ...SIZE - abs(t) */ - return (1); - - case PD_GET_LINK_PAGE: - pd->i = getint(pd->s+sizeof(long)); - return ( (pd->i == -1) ? 0 : 1 ); - - case PD_RELEASE_TOPIC: - return (1); - - default: - return (0); - } - } - -static int print_doc_output(int cmd, PD_INFO *pd, PRINT_DOC_INFO *info) - { - switch (cmd) - { - case PD_HEADING: - { - char line[81]; - char buff[40]; - int width = PAGE_WIDTH + PAGE_INDENT; - int keep_going; - - if ( info->msg_func != NULL ) - keep_going = (*info->msg_func)(pd->pnum, info->num_page); - else - keep_going = 1; - - info->margin = 0; - - memset(line, ' ', 81); - sprintf(buff, "Fractint Version %d.%01d%c",g_release/100, (g_release%100)/10, - ( (g_release%10) ? '0'+(g_release%10) : ' ') ); - memmove(line + ((width-(int)(strlen(buff))) / 2)-4, buff, strlen(buff)); - - sprintf(buff, "Page %d", pd->pnum); - memmove(line + (width - (int)strlen(buff)), buff, strlen(buff)); - - printerc(info, '\n', 1); - printers(info, line, width); - printerc(info, '\n', 2); - - info->margin = PAGE_INDENT; - - return ( keep_going ); - } - - case PD_FOOTING: - info->margin = 0; - printerc(info, '\f', 1); - info->margin = PAGE_INDENT; - return (1); - - case PD_PRINT: - printers(info, pd->s, pd->i); - return (1); - - case PD_PRINTN: - printerc(info, *pd->s, pd->i); - return (1); - - case PD_PRINT_SEC: - info->margin = TITLE_INDENT; - if (pd->id[0] != '\0') - { - printers(info, pd->id, 0); - printerc(info, ' ', 1); - } - printers(info, pd->title, 0); - printerc(info, '\n', 1); - info->margin = PAGE_INDENT; - return (1); - - case PD_START_SECTION: - case PD_START_TOPIC: - case PD_SET_SECTION_PAGE: - case PD_SET_TOPIC_PAGE: - case PD_PERIODIC: - return (1); - - default: - return (0); - } - } - -static int print_doc_msg_func(int pnum, int num_pages) - { - char temp[10]; - int key; - - if ( pnum == -1 ) /* successful completion */ - { - driver_buzzer(BUZZER_COMPLETE); - putstringcenter(7, 0, 80, C_HELP_LINK, "Done -- Press any key"); - driver_get_key(); - return (0); - } - - if ( pnum == -2 ) /* aborted */ - { - driver_buzzer(BUZZER_INTERRUPT); - putstringcenter(7, 0, 80, C_HELP_LINK, "Aborted -- Press any key"); - driver_get_key(); - return (0); - } - - if (pnum == 0) /* initialization */ - { - helptitle(); - printinstr(); - driver_set_attr(2, 0, C_HELP_BODY, 80*22); - putstringcenter(1, 0, 80, C_HELP_HDG, "Generating FRACTINT.DOC"); - - driver_put_string(7, 30, C_HELP_BODY, "Completed:"); - - driver_hide_text_cursor(); - } - - sprintf(temp, "%d%%", (int)( (100.0 / num_pages) * pnum ) ); - driver_put_string(7, 41, C_HELP_LINK, temp); - - while ( driver_key_pressed() ) - { - key = driver_get_key(); - if ( key == FIK_ESC ) - return (0); /* user abort */ - } - - return (1); /* AOK -- continue */ - } - -int makedoc_msg_func(int pnum, int num_pages) -{ - char buffer[80] = ""; - int result = 0; - - if (pnum >= 0) - { - sprintf(buffer, "\rcompleted %d%%", (int) ((100.0 / num_pages) * pnum)); - result = 1; - } - else if (pnum == -2) - { - sprintf(buffer, "\n*** aborted\n"); - } - stopmsg(0, buffer); - return result; -} - -void print_document(char *outfname, int (*msg_func)(int,int), int save_extraseg ) - { - PRINT_DOC_INFO info; - int success = 0; - FILE *temp_file = NULL; - char *msg = NULL; - -/* help_seek((long)sizeof(int)+sizeof(long)); Strange -- should be 8 -- CWM */ - help_seek(16L); /* indeed it should - Bert */ - fread(&info.num_contents, sizeof(int), 1, help_file); - fread(&info.num_page, sizeof(int), 1, help_file); - - info.cnum = info.tnum = -1; - info.content_pos = 6*sizeof(int) + num_topic*sizeof(long) + num_label*2*sizeof(int); - info.msg_func = msg_func; - - if ( msg_func != NULL ) - msg_func(0, info.num_page); /* initialize */ - - if ( save_extraseg ) - { - if ( (temp_file=fopen(TEMP_FILE_NAME, "wb")) == NULL ) - { - msg = "Unable to create temporary file.\n"; - goto ErrorAbort; - } - - if ( fwrite(info.buffer, sizeof(char), PRINT_BUFFER_SIZE, temp_file) != PRINT_BUFFER_SIZE ) - { - msg = "Error writing temporary file.\n"; - goto ErrorAbort; - } - } - - info.file = fopen(outfname, "wt"); - if (info.file == NULL ) - { - msg = "Unable to create output file.\n"; - goto ErrorAbort; - } - - info.margin = PAGE_INDENT; - info.start_of_line = 1; - info.spaces = 0; - - success = process_document((PD_FUNC)print_doc_get_info, - (PD_FUNC)print_doc_output, &info); - fclose(info.file); - - if ( save_extraseg ) - { - if ( fseek(temp_file, 0L, SEEK_SET) != 0L ) - { - msg = "Error reading temporary file.\nSystem may be corrupt!\nSave your image and re-start FRACTINT!\n"; - goto ErrorAbort; - } - - if ( fread(info.buffer, sizeof(char), PRINT_BUFFER_SIZE, temp_file) != PRINT_BUFFER_SIZE ) - { - msg = "Error reading temporary file.\nSystem may be corrupt!\nSave your image and re-start FRACTINT!\n"; - goto ErrorAbort; - } - } - -ErrorAbort: - if (temp_file != NULL) - { - fclose(temp_file); - remove(TEMP_FILE_NAME); - temp_file = NULL; - } - - if ( msg != NULL ) - { - helptitle(); - stopmsg(STOPMSG_NO_STACK, msg); - } - - else if ( msg_func != NULL ) - msg_func((success) ? -1 : -2, info.num_page ); - } - -int init_help(void) -{ - struct help_sig_info hs = { 0 }; - char path[FILE_MAX_PATH+1]; - - help_file = NULL; - -#ifndef WINFRACT -#if !defined(XFRACT) && !defined(_WIN32) - if (help_file == -1) /* now look for help files in FRACTINT.EXE */ - { -/* - static char err_not_in_exe[] = "Help not found in FRACTINT.EXE!\n"; -*/ - - if (find_file("FRACTINT.EXE", path)) - { - if ((help_file = open(path, O_RDONLY|O_BINARY)) != -1) - { - long help_offset; - - for (help_offset = -((long)sizeof(hs)); help_offset >= -128L; help_offset--) - { - fseek(help_file, help_offset, SEEK_END); - fread((char *)&hs, sizeof(hs)); - if (hs.sig == HELP_SIG) - { - break; - } - } - - if (hs.sig != HELP_SIG) - { - close(help_file); - help_file = -1; - } - else - { - if (hs.version != FIHELP_VERSION) - { - close(help_file); - help_file = -1; - stopmsg(STOPMSG_NO_STACK, "Wrong help version in FRACTINT.EXE!\n"); - } - else - { - base_off = hs.base; - } - } - } - else - { - stopmsg(STOPMSG_NO_STACK, "Help system was unable to open FRACTINT.EXE!\n"); - } - } - else - { - stopmsg(STOPMSG_NO_STACK, "Help system couldn't find FRACTINT.EXE!\n"); - } - } -#endif -#endif - - if (help_file == NULL) /* look for FRACTINT.HLP */ - { - if (find_file("fractint.hlp", path)) - { - if ((help_file = fopen(path, "rb")) != NULL) - { - fread(&hs, sizeof(long)+sizeof(int), 1, help_file); - - if (hs.sig != HELP_SIG) - { - fclose(help_file); - stopmsg(STOPMSG_NO_STACK, "Invalid help signature in FRACTINT.HLP!\n"); - } - else if (hs.version != FIHELP_VERSION) - { - fclose(help_file); - stopmsg(STOPMSG_NO_STACK, "Wrong help version in FRACTINT.HLP!\n"); - } - else - { - base_off = sizeof(long)+sizeof(int); - } - } - } - } - - if (help_file == NULL) /* Can't find the help files anywhere! */ - { - static char msg[] = -#if !defined(XFRACT) && !defined(_WIN32) - {"Help Files aren't in FRACTINT.EXE, and couldn't find FRACTINT.HLP!\n"}; -#else - {"Couldn't find fractint.hlp; set FRACTDIR to proper directory with setenv.\n"}; -#endif - stopmsg(STOPMSG_NO_STACK, msg); - } - - help_seek(0L); - - fread(&max_pages, sizeof(int), 1, help_file); - fread(&max_links, sizeof(int), 1, help_file); - fread(&num_topic, sizeof(int), 1, help_file); - fread(&num_label, sizeof(int), 1, help_file); - help_seek((long)6*sizeof(int)); /* skip num_contents and num_doc_pages */ - - assert(max_pages > 0); - assert(max_links >= 0); - assert(num_topic > 0); - assert(num_label > 0); - - /* allocate all three arrays */ - topic_offset = (long *) malloc(sizeof(long)*num_topic); - label = (LABEL *) malloc(sizeof(LABEL)*num_label); - hist = (HIST *) malloc(sizeof(HIST)*MAX_HIST); - - if ((topic_offset == NULL) || (NULL == label) || (NULL == hist)) - { - fclose(help_file); - help_file = NULL; - stopmsg(STOPMSG_NO_STACK, "Not enough memory for help system!\n"); - - return (-2); - } - - /* read in the tables... */ - fread(topic_offset, sizeof(long), num_topic, help_file); - fread(label, sizeof(LABEL), num_label, help_file); - - /* finished! */ - - return 0; /* success */ -} - -void end_help(void) - { - if (help_file != NULL) - { - fclose(help_file); - free(topic_offset); - free(label); - free(hist); - help_file = NULL; - } - } diff --git a/fractint/common/history.c b/fractint/common/history.c deleted file mode 100644 index 0a56d37e9..000000000 --- a/fractint/common/history.c +++ /dev/null @@ -1,359 +0,0 @@ -/* HISTORY.C - History routines taken out of framain2.c to make them accessable - to WinFract */ - - /* see Fractint.c for a description of the "include" hierarchy */ -#include "port.h" -#include "prototyp.h" -#include "fractype.h" - -/* routines in this module */ -/* -void _fastcall restore_history_info(int); -void _fastcall save_history_info(void); -*/ - -int historyptr = -1; /* user pointer into history tbl */ -static int saveptr = 0; /* save ptr into history tbl */ -int historyflag; /* are we backing off in history? */ - - -void _fastcall save_history_info() -{ - HISTORY current,last; - - if(maxhistory <= 0 || bf_math || history == 0) - return; - MoveFromMemory((BYTE far *)&last,(U16)sizeof(HISTORY),1L,(long)saveptr,history); - - far_memset((void far *)¤t,0,sizeof(HISTORY)); - current.fractal_type = (short)fractype ; - current.xmin = xxmin ; - current.xmax = xxmax ; - current.ymin = yymin ; - current.ymax = yymax ; - current.creal = param[0] ; - current.cimag = param[1] ; - current.dparm3 = param[2] ; - current.dparm4 = param[3] ; - current.dparm5 = param[4] ; - current.dparm6 = param[5] ; - current.dparm7 = param[6] ; - current.dparm8 = param[7] ; - current.dparm9 = param[8] ; - current.dparm10 = param[9] ; - current.fillcolor = (short)fillcolor ; - current.potential[0] = potparam[0] ; - current.potential[1] = potparam[1] ; - current.potential[2] = potparam[2] ; - current.rflag = (short)rflag ; - current.rseed = (short)rseed ; - current.inside = (short)inside ; - current.logmap = LogFlag ; - current.invert[0] = inversion[0] ; - current.invert[1] = inversion[1] ; - current.invert[2] = inversion[2] ; - current.decomp = (short)decomp[0]; ; - current.biomorph = (short)biomorph ; - current.symmetry = (short)forcesymmetry ; - current.init3d[0] = (short)init3d[0] ; - current.init3d[1] = (short)init3d[1] ; - current.init3d[2] = (short)init3d[2] ; - current.init3d[3] = (short)init3d[3] ; - current.init3d[4] = (short)init3d[4] ; - current.init3d[5] = (short)init3d[5] ; - current.init3d[6] = (short)init3d[6] ; - current.init3d[7] = (short)init3d[7] ; - current.init3d[8] = (short)init3d[8] ; - current.init3d[9] = (short)init3d[9] ; - current.init3d[10] = (short)init3d[10] ; - current.init3d[11] = (short)init3d[12] ; - current.init3d[12] = (short)init3d[13] ; - current.init3d[13] = (short)init3d[14] ; - current.init3d[14] = (short)init3d[15] ; - current.init3d[15] = (short)init3d[16] ; - current.previewfactor = (short)previewfactor ; - current.xtrans = (short)xtrans ; - current.ytrans = (short)ytrans ; - current.red_crop_left = (short)red_crop_left ; - current.red_crop_right = (short)red_crop_right ; - current.blue_crop_left = (short)blue_crop_left ; - current.blue_crop_right = (short)blue_crop_right ; - current.red_bright = (short)red_bright ; - current.blue_bright = (short)blue_bright ; - current.xadjust = (short)xadjust ; - current.yadjust = (short)yadjust ; - current.eyeseparation = (short)eyeseparation ; - current.glassestype = (short)glassestype ; - current.outside = (short)outside ; - current.x3rd = xx3rd ; - current.y3rd = yy3rd ; - current.stdcalcmode = usr_stdcalcmode ; - current.three_pass = three_pass ; - current.stoppass = (short)stoppass; - current.distest = distest ; - current.trigndx[0] = trigndx[0] ; - current.trigndx[1] = trigndx[1] ; - current.trigndx[2] = trigndx[2] ; - current.trigndx[3] = trigndx[3] ; - current.finattract = (short)finattract ; - current.initorbit[0] = initorbit.x ; - current.initorbit[1] = initorbit.y ; - current.useinitorbit = useinitorbit ; - current.periodicity = (short)periodicitycheck ; - current.pot16bit = (short)disk16bit ; - current.release = (short)release ; - current.save_release = (short)save_release ; - current.flag3d = (short)display3d ; - current.ambient = (short)Ambient ; - current.randomize = (short)RANDOMIZE ; - current.haze = (short)haze ; - current.transparent[0] = (short)transparent[0] ; - current.transparent[1] = (short)transparent[1] ; - current.rotate_lo = (short)rotate_lo ; - current.rotate_hi = (short)rotate_hi ; - current.distestwidth = (short)distestwidth ; - current.mxmaxfp = mxmaxfp ; - current.mxminfp = mxminfp ; - current.mymaxfp = mymaxfp ; - current.myminfp = myminfp ; - current.zdots = (short)zdots ; - current.originfp = originfp ; - current.depthfp = depthfp ; - current.heightfp = heightfp ; - current.widthfp = widthfp ; - current.distfp = distfp ; - current.eyesfp = eyesfp ; - current.orbittype = (short)neworbittype ; - current.juli3Dmode = (short)juli3Dmode ; - current.maxfn = maxfn ; - current.major_method = (short)major_method ; - current.minor_method = (short)minor_method ; - current.bailout = bailout ; - current.bailoutest = (short)bailoutest ; - current.iterations = maxit ; - current.old_demm_colors = (short)old_demm_colors; - current.logcalc = (short)Log_Fly_Calc; - current.ismand = (short)ismand; - current.closeprox = closeprox; - current.nobof = (short)nobof; - current.orbit_delay = (short)orbit_delay; - current.orbit_interval = orbit_interval; - current.oxmin = oxmin; - current.oxmax = oxmax; - current.oymin = oymin; - current.oymax = oymax; - current.ox3rd = ox3rd; - current.oy3rd = oy3rd; - current.keep_scrn_coords= (short)keep_scrn_coords; - current.drawmode = drawmode; - far_memcpy(current.dac,dacbox,256*3); - switch(fractype) - { - case FORMULA: - case FFORMULA: - far_strncpy(current.filename,FormFileName,FILE_MAX_PATH); - far_strncpy(current.itemname,FormName,ITEMNAMELEN+1); - break; - case IFS: - case IFS3D: - far_strncpy(current.filename,IFSFileName,FILE_MAX_PATH); - far_strncpy(current.itemname,IFSName,ITEMNAMELEN+1); - break; - case LSYSTEM: - far_strncpy(current.filename,LFileName,FILE_MAX_PATH); - far_strncpy(current.itemname,LName,ITEMNAMELEN+1); - break; - default: - *(current.filename) = 0; - *(current.itemname) = 0; - break; - } - if (historyptr == -1) /* initialize the history file */ - { - int i; - for (i = 0; i < maxhistory; i++) - MoveToMemory((BYTE far *)¤t,(U16)sizeof(HISTORY),1L,(long)i,history); - historyflag = saveptr = historyptr = 0; /* initialize history ptr */ - } - else if(historyflag == 1) - historyflag = 0; /* coming from user history command, don't save */ - else if(far_memcmp(¤t,&last,sizeof(HISTORY))) - { - if(++saveptr >= maxhistory) /* back to beginning of circular buffer */ - saveptr = 0; - if(++historyptr >= maxhistory) /* move user pointer in parallel */ - historyptr = 0; - MoveToMemory((BYTE far *)¤t,(U16)sizeof(HISTORY),1L,(long)saveptr,history); - } -} - -void _fastcall restore_history_info(int i) -{ - HISTORY last; - if(maxhistory <= 0 || bf_math || history == 0) - return; - MoveFromMemory((BYTE far *)&last,(U16)sizeof(HISTORY),1L,(long)i,history); - invert = 0; - calc_status = 0; - resuming = 0; - fractype = last.fractal_type ; - xxmin = last.xmin ; - xxmax = last.xmax ; - yymin = last.ymin ; - yymax = last.ymax ; - param[0] = last.creal ; - param[1] = last.cimag ; - param[2] = last.dparm3 ; - param[3] = last.dparm4 ; - param[4] = last.dparm5 ; - param[5] = last.dparm6 ; - param[6] = last.dparm7 ; - param[7] = last.dparm8 ; - param[8] = last.dparm9 ; - param[9] = last.dparm10 ; - fillcolor = last.fillcolor ; - potparam[0] = last.potential[0] ; - potparam[1] = last.potential[1] ; - potparam[2] = last.potential[2] ; - rflag = last.rflag ; - rseed = last.rseed ; - inside = last.inside ; - LogFlag = last.logmap ; - inversion[0] = last.invert[0] ; - inversion[1] = last.invert[1] ; - inversion[2] = last.invert[2] ; - decomp[0] = last.decomp ; - usr_biomorph = last.biomorph ; - biomorph = last.biomorph ; - forcesymmetry = last.symmetry ; - init3d[0] = last.init3d[0] ; - init3d[1] = last.init3d[1] ; - init3d[2] = last.init3d[2] ; - init3d[3] = last.init3d[3] ; - init3d[4] = last.init3d[4] ; - init3d[5] = last.init3d[5] ; - init3d[6] = last.init3d[6] ; - init3d[7] = last.init3d[7] ; - init3d[8] = last.init3d[8] ; - init3d[9] = last.init3d[9] ; - init3d[10] = last.init3d[10] ; - init3d[12] = last.init3d[11] ; - init3d[13] = last.init3d[12] ; - init3d[14] = last.init3d[13] ; - init3d[15] = last.init3d[14] ; - init3d[16] = last.init3d[15] ; - previewfactor = last.previewfactor ; - xtrans = last.xtrans ; - ytrans = last.ytrans ; - red_crop_left = last.red_crop_left ; - red_crop_right = last.red_crop_right ; - blue_crop_left = last.blue_crop_left ; - blue_crop_right = last.blue_crop_right; - red_bright = last.red_bright ; - blue_bright = last.blue_bright ; - xadjust = last.xadjust ; - yadjust = last.yadjust ; - eyeseparation = last.eyeseparation ; - glassestype = last.glassestype ; - outside = last.outside ; - xx3rd = last.x3rd ; - yy3rd = last.y3rd ; - usr_stdcalcmode = last.stdcalcmode ; - stdcalcmode = last.stdcalcmode ; - three_pass = last.three_pass ; - stoppass = last.stoppass ; - distest = last.distest ; - usr_distest = last.distest ; - trigndx[0] = last.trigndx[0] ; - trigndx[1] = last.trigndx[1] ; - trigndx[2] = last.trigndx[2] ; - trigndx[3] = last.trigndx[3] ; - finattract = last.finattract ; - initorbit.x = last.initorbit[0] ; - initorbit.y = last.initorbit[1] ; - useinitorbit = last.useinitorbit ; - periodicitycheck = last.periodicity ; - usr_periodicitycheck = last.periodicity ; - disk16bit = last.pot16bit ; - release = last.release ; - save_release = last.save_release ; - display3d = last.flag3d ; - Ambient = last.ambient ; - RANDOMIZE = last.randomize ; - haze = last.haze ; - transparent[0] = last.transparent[0] ; - transparent[1] = last.transparent[1] ; - rotate_lo = last.rotate_lo ; - rotate_hi = last.rotate_hi ; - distestwidth = last.distestwidth ; - mxmaxfp = last.mxmaxfp ; - mxminfp = last.mxminfp ; - mymaxfp = last.mymaxfp ; - myminfp = last.myminfp ; - zdots = last.zdots ; - originfp = last.originfp ; - depthfp = last.depthfp ; - heightfp = last.heightfp ; - widthfp = last.widthfp ; - distfp = last.distfp ; - eyesfp = last.eyesfp ; - neworbittype = last.orbittype ; - juli3Dmode = last.juli3Dmode ; - maxfn = last.maxfn ; - major_method = (enum Major)last.major_method ; - minor_method = (enum Minor)last.minor_method ; - bailout = last.bailout ; - bailoutest = (enum bailouts)last.bailoutest ; - maxit = last.iterations ; - old_demm_colors = last.old_demm_colors; - curfractalspecific = &fractalspecific[fractype]; - potflag = (potparam[0] != 0.0); - if (inversion[0] != 0.0) - invert = 3; - Log_Fly_Calc = last.logcalc; - ismand = last.ismand; - closeprox = last.closeprox; - nobof = last.nobof; - orbit_delay = last.orbit_delay; - orbit_interval = last.orbit_interval; - oxmin = last.oxmin; - oxmax = last.oxmax; - oymin = last.oymin; - oymax = last.oymax; - ox3rd = last.ox3rd; - oy3rd = last.oy3rd; - keep_scrn_coords = last.keep_scrn_coords; - if (keep_scrn_coords) set_orbit_corners = 1; - drawmode = last.drawmode; - usr_floatflag = (char)((curfractalspecific->isinteger) ? 0 : 1); - far_memcpy(dacbox,last.dac,256*3); - far_memcpy(olddacbox,last.dac,256*3); - if(mapdacbox) - far_memcpy(mapdacbox,last.dac,256*3); - spindac(0,1); - if(fractype == JULIBROT || fractype == JULIBROTFP) - savedac = 0; - else - savedac = 1; - switch(fractype) - { - case FORMULA: - case FFORMULA: - far_strncpy(FormFileName,last.filename,FILE_MAX_PATH); - far_strncpy(FormName, last.itemname,ITEMNAMELEN+1); - break; - case IFS: - case IFS3D: - far_strncpy(IFSFileName,last.filename,FILE_MAX_PATH); - far_strncpy(IFSName ,last.itemname,ITEMNAMELEN+1); - break; - case LSYSTEM: - far_strncpy(LFileName,last.filename,FILE_MAX_PATH); - far_strncpy(LName ,last.itemname,ITEMNAMELEN+1); - break; - default: - break; - } -} - diff --git a/fractint/common/intro.c b/fractint/common/intro.c deleted file mode 100644 index 419fe5b69..000000000 --- a/fractint/common/intro.c +++ /dev/null @@ -1,118 +0,0 @@ - -/* - * intro.c - * - * FRACTINT intro screen (authors & credits) - * - * - */ - -#include - - /* see Fractint.c for a description of the "include" hierarchy */ -#include "port.h" -#include "prototyp.h" -#include "helpdefs.h" -#include "drivers.h" - -/* stuff from fractint */ - -#ifdef XFRACT -extern int slowdisplay; -#endif - -void intro(void) -{ - /* following overlayed data safe if "putstrings" are resident */ -#ifdef XFRACT - static char PRESS_ENTER[] = {"Press ENTER for main menu, Shift-1 for help."}; -#else - static char PRESS_ENTER[] = {"Press ENTER for main menu, F1 for help."}; -#endif - int toprow, botrow, i, j, delaymax; - char oldchar; - int authors[100]; /* this should be enough for awhile */ - char credits[32768]; - char screen_text[32768]; - int oldlookatmouse; - int oldhelpmode; - - timer_start -= clock_ticks(); /* "time out" during help */ - oldlookatmouse = lookatmouse; - oldhelpmode = helpmode; - lookatmouse = 0; /* de-activate full mouse checking */ - - i = 32767 + read_help_topic(INTRO_AUTHORS, 0, 32767, screen_text); - screen_text[i++] = '\0'; - i = 32767 + read_help_topic(INTRO_CREDITS, 0, 32767, credits); - credits[i++] = '\0'; - - j = 0; - authors[j] = 0; /* find the start of each credit-line */ - for (i = 0; credits[i] != 0; i++) - if (credits[i] == 10) - authors[++j] = i+1; - authors[j+1] = i; - - helptitle(); -#define END_MAIN_AUTHOR 5 - toprow = END_MAIN_AUTHOR+1; -#ifndef XFRACT - botrow = 21; -#else - botrow = 20; - putstringcenter(21,0,80,C_TITLE, - "Unix/X port of fractint by Ken Shirriff"); -#endif - putstringcenter(1,0,80,C_TITLE, PRESS_ENTER); - driver_put_string(2,0,C_CONTRIB,screen_text); - driver_set_attr(2,0,C_AUTHDIV1,80); - driver_set_attr(END_MAIN_AUTHOR,0,C_AUTHDIV1,80); - driver_set_attr(22,0,C_AUTHDIV2,80); - driver_set_attr(3,0,C_PRIMARY,80*(END_MAIN_AUTHOR-3)); - driver_set_attr(23,0,C_TITLE_LOW,160); - for (i = 3; i < END_MAIN_AUTHOR; ++i) - driver_set_attr(i,21,C_CONTRIB,58); - driver_set_attr(toprow,0,C_CONTRIB,(21-END_MAIN_AUTHOR)*80); - i = botrow - toprow; - srand((unsigned int)clock_ticks()); - j = rand()%(j-(botrow-toprow)); /* first to use */ - i = j+botrow-toprow; /* last to use */ - oldchar = credits[authors[i+1]]; - credits[authors[i+1]] = 0; - driver_put_string(toprow,0,C_CONTRIB,credits+authors[j]); - credits[authors[i+1]] = oldchar; - delaymax = 10; - driver_hide_text_cursor(); - helpmode = HELPMENU; - while (! driver_key_pressed()) - { -#ifdef XFRACT - if (slowdisplay) delaymax *= 15; -#endif - for (j = 0; j < delaymax && !(driver_key_pressed()); j++) - driver_delay(100); - if (driver_key_pressed() == FIK_SPACE) - { /* spacebar pauses */ - driver_get_key(); - driver_wait_key_pressed(0); - if (driver_key_pressed() == FIK_SPACE) - driver_get_key(); - } - delaymax = 15; - driver_scroll_up(toprow, botrow); - i++; - if (credits[authors[i]] == 0) - i = 0; - oldchar = credits[authors[i+1]]; - credits[authors[i+1]] = 0; - driver_put_string(botrow,0,C_CONTRIB,&credits[authors[i]]); - driver_set_attr(botrow,0,C_CONTRIB,80); - credits[authors[i+1]] = oldchar; - driver_hide_text_cursor(); /* turn it off */ - } - - lookatmouse = oldlookatmouse; /* restore the mouse-checking */ - helpmode = oldhelpmode; - return; -} diff --git a/fractint/common/jb.c b/fractint/common/jb.c deleted file mode 100644 index 0e6ab524d..000000000 --- a/fractint/common/jb.c +++ /dev/null @@ -1,462 +0,0 @@ -/* see Fractint.c for a description of the "include" hierarchy */ -#include "port.h" -#include "prototyp.h" -#include "helpdefs.h" -#include "fractype.h" -#include "drivers.h" - -/* these need to be accessed elsewhere for saving data */ -double mxminfp = -.83; -double myminfp = -.25; -double mxmaxfp = -.83; -double mymaxfp = .25; - -static long mxmin, mymin; -static long x_per_inch, y_per_inch, inch_per_xdot, inch_per_ydot; -static double x_per_inchfp, y_per_inchfp, inch_per_xdotfp, inch_per_ydotfp; -static int bbase; -static long xpixel, ypixel; -static double xpixelfp, ypixelfp; -static long initz, djx, djy, dmx, dmy; -static double initzfp, djxfp, djyfp, dmxfp, dmyfp; -static long jx, jy, mx, my, xoffset, yoffset; -static double jxfp, jyfp, mxfp, myfp, xoffsetfp, yoffsetfp; - -struct Perspective -{ - long x, y, zx, zy; -}; - -struct Perspectivefp -{ - double x, y, zx, zy; -}; - -struct Perspective LeftEye, RightEye, *Per; -struct Perspectivefp LeftEyefp, RightEyefp, *Perfp; - -_LCMPLX jbc; -_CMPLX jbcfp; - -#ifndef XFRACT -static double fg, fg16; -#endif -int zdots = 128; - -float originfp = (float)8.0; -float heightfp = (float)7.0; -float widthfp = (float)10.0; -float distfp = (float)24.0; -float eyesfp = (float)2.5; -float depthfp = (float)8.0; -float brratiofp = (float)1.0; -static long width, dist, depth, brratio; -#ifndef XFRACT -static long eyes; -#endif -int juli3Dmode = 0; - -int neworbittype = JULIA; - -int -JulibrotSetup(void) -{ -#ifndef XFRACT - long origin; -#endif - int r = 0; - char *mapname; - -#ifndef XFRACT - if (colors < 255) - { - stopmsg(0, "Sorry, but Julibrots require a 256-color video mode"); - return (0); - } -#endif - - xoffsetfp = (xxmax + xxmin) / 2; /* Calculate average */ - yoffsetfp = (yymax + yymin) / 2; /* Calculate average */ - dmxfp = (mxmaxfp - mxminfp) / zdots; - dmyfp = (mymaxfp - myminfp) / zdots; - floatparm = &jbcfp; - x_per_inchfp = (xxmin - xxmax) / widthfp; - y_per_inchfp = (yymax - yymin) / heightfp; - inch_per_xdotfp = widthfp / xdots; - inch_per_ydotfp = heightfp / ydots; - initzfp = originfp - (depthfp / 2); - if (juli3Dmode == 0) - RightEyefp.x = 0.0; - else - RightEyefp.x = eyesfp / 2; - LeftEyefp.x = -RightEyefp.x; - LeftEyefp.y = RightEyefp.y = 0; - LeftEyefp.zx = RightEyefp.zx = distfp; - LeftEyefp.zy = RightEyefp.zy = distfp; - bbase = 128; - -#ifndef XFRACT - if (fractalspecific[fractype].isinteger > 0) - { - long jxmin, jxmax, jymin, jymax, mxmax, mymax; - if (fractalspecific[neworbittype].isinteger == 0) - { - stopmsg(0, "Julibrot orbit type isinteger mismatch"); - } - if (fractalspecific[neworbittype].isinteger > 1) - bitshift = fractalspecific[neworbittype].isinteger; - fg = (double) (1L << bitshift); - fg16 = (double) (1L << 16); - jxmin = (long) (xxmin * fg); - jxmax = (long) (xxmax * fg); - xoffset = (jxmax + jxmin) / 2; /* Calculate average */ - jymin = (long) (yymin * fg); - jymax = (long) (yymax * fg); - yoffset = (jymax + jymin) / 2; /* Calculate average */ - mxmin = (long) (mxminfp * fg); - mxmax = (long) (mxmaxfp * fg); - mymin = (long) (myminfp * fg); - mymax = (long) (mymaxfp * fg); - origin = (long) (originfp * fg16); - depth = (long) (depthfp * fg16); - width = (long) (widthfp * fg16); - dist = (long) (distfp * fg16); - eyes = (long) (eyesfp * fg16); - brratio = (long) (brratiofp * fg16); - dmx = (mxmax - mxmin) / zdots; - dmy = (mymax - mymin) / zdots; - longparm = &jbc; - - x_per_inch = (long) ((xxmin - xxmax) / widthfp * fg); - y_per_inch = (long) ((yymax - yymin) / heightfp * fg); - inch_per_xdot = (long) ((widthfp / xdots) * fg16); - inch_per_ydot = (long) ((heightfp / ydots) * fg16); - initz = origin - (depth / 2); - if (juli3Dmode == 0) - RightEye.x = 0l; - else - RightEye.x = eyes / 2; - LeftEye.x = -RightEye.x; - LeftEye.y = RightEye.y = 0l; - LeftEye.zx = RightEye.zx = dist; - LeftEye.zy = RightEye.zy = dist; - bbase = (int) (128.0 * brratiofp); - } -#endif - - if (juli3Dmode == 3) - { - savedac = 0; - mapname = Glasses1Map; - } - else - mapname = GreyFile; - if (savedac != 1) - { - if (ValidateLuts(mapname) != 0) - return (0); - spindac(0, 1); /* load it, but don't spin */ - if (savedac == 2) - savedac = 1; - } - return (r >= 0); -} - - -int -jb_per_pixel(void) -{ - jx = multiply(Per->x - xpixel, initz, 16); - jx = divide(jx, dist, 16) - xpixel; - jx = multiply(jx << (bitshift - 16), x_per_inch, bitshift); - jx += xoffset; - djx = divide(depth, dist, 16); - djx = multiply(djx, Per->x - xpixel, 16) << (bitshift - 16); - djx = multiply(djx, x_per_inch, bitshift) / zdots; - - jy = multiply(Per->y - ypixel, initz, 16); - jy = divide(jy, dist, 16) - ypixel; - jy = multiply(jy << (bitshift - 16), y_per_inch, bitshift); - jy += yoffset; - djy = divide(depth, dist, 16); - djy = multiply(djy, Per->y - ypixel, 16) << (bitshift - 16); - djy = multiply(djy, y_per_inch, bitshift) / zdots; - - return (1); -} - -int -jbfp_per_pixel(void) -{ - jxfp = ((Perfp->x - xpixelfp) * initzfp / distfp - xpixelfp) * x_per_inchfp; - jxfp += xoffsetfp; - djxfp = (depthfp / distfp) * (Perfp->x - xpixelfp) * x_per_inchfp / zdots; - - jyfp = ((Perfp->y - ypixelfp) * initzfp / distfp - ypixelfp) * y_per_inchfp; - jyfp += yoffsetfp; - djyfp = depthfp / distfp * (Perfp->y - ypixelfp) * y_per_inchfp / zdots; - - return (1); -} - -static int zpixel, plotted; -static long n; - -int -zline(long x, long y) -{ - xpixel = x; - ypixel = y; - mx = mxmin; - my = mymin; - switch (juli3Dmode) - { - case 0: - case 1: - Per = &LeftEye; - break; - case 2: - Per = &RightEye; - break; - case 3: - if ((row + col) & 1) - Per = &LeftEye; - else - Per = &RightEye; - break; - } - jb_per_pixel(); - for (zpixel = 0; zpixel < zdots; zpixel++) - { - lold.x = jx; - lold.y = jy; - jbc.x = mx; - jbc.y = my; - if (driver_key_pressed()) - return (-1); - ltempsqrx = multiply(lold.x, lold.x, bitshift); - ltempsqry = multiply(lold.y, lold.y, bitshift); - for (n = 0; n < maxit; n++) - if (fractalspecific[neworbittype].orbitcalc()) - break; - if (n == maxit) - { - if (juli3Dmode==3) - { - color = (int) (128l * zpixel / zdots); - if ((row + col) & 1) - { - - (*plot) (col, row, 127 - color); - } - else - { - color = (int) (multiply((long) color << 16, brratio, 16) >> 16); - if (color < 1) - color = 1; - if (color > 127) - color = 127; - (*plot) (col, row, 127 + bbase - color); - } - } - else - { - color = (int) (254l * zpixel / zdots); - (*plot) (col, row, color + 1); - } - plotted = 1; - break; - } - mx += dmx; - my += dmy; - jx += djx; - jy += djy; - } - return (0); -} - -int -zlinefp(double x, double y) -{ -#ifdef XFRACT - static int keychk = 0; -#endif - xpixelfp = x; - ypixelfp = y; - mxfp = mxminfp; - myfp = myminfp; - switch (juli3Dmode) - { - case 0: - case 1: - Perfp = &LeftEyefp; - break; - case 2: - Perfp = &RightEyefp; - break; - case 3: - if ((row + col) & 1) - Perfp = &LeftEyefp; - else - Perfp = &RightEyefp; - break; - } - jbfp_per_pixel(); - for (zpixel = 0; zpixel < zdots; zpixel++) - { - /* Special initialization for Mandelbrot types */ - if ((neworbittype == QUATFP || neworbittype == HYPERCMPLXFP) - && save_release > 2002) - { - old.x = 0.0; - old.y = 0.0; - jbcfp.x = 0.0; - jbcfp.y = 0.0; - qc = jxfp; - qci = jyfp; - qcj = mxfp; - qck = myfp; - } - else - { - old.x = jxfp; - old.y = jyfp; - jbcfp.x = mxfp; - jbcfp.y = myfp; - qc = param[0]; - qci = param[1]; - qcj = param[2]; - qck = param[3]; - } -#ifdef XFRACT - if (keychk++ > 500) - { - keychk = 0; - if (driver_key_pressed()) - return (-1); - } -#else - if (driver_key_pressed()) - return (-1); -#endif - tempsqrx = sqr(old.x); - tempsqry = sqr(old.y); - - for (n = 0; n < maxit; n++) - if (fractalspecific[neworbittype].orbitcalc()) - break; - if (n == maxit) - { - if (juli3Dmode == 3) - { - color = (int) (128l * zpixel / zdots); - if ((row + col) & 1) - (*plot) (col, row, 127 - color); - else - { - color = (int)(color * brratiofp); - if (color < 1) - color = 1; - if (color > 127) - color = 127; - (*plot) (col, row, 127 + bbase - color); - } - } - else - { - color = (int) (254l * zpixel / zdots); - (*plot) (col, row, color + 1); - } - plotted = 1; - break; - } - mxfp += dmxfp; - myfp += dmyfp; - jxfp += djxfp; - jyfp += djyfp; - } - return (0); -} - -int -Std4dFractal(void) -{ - long x, y; - int xdot, ydot; - c_exp = (int)param[2]; - if (neworbittype == LJULIAZPOWER) - { - if (c_exp < 1) - c_exp = 1; - if (param[3] == 0.0 && debugflag != 6000 && (double)c_exp == param[2]) - fractalspecific[neworbittype].orbitcalc = longZpowerFractal; - else - fractalspecific[neworbittype].orbitcalc = longCmplxZpowerFractal; - } - - for (y = 0, ydot = (ydots >> 1) - 1; ydot >= 0; ydot--, y -= inch_per_ydot) - { - plotted = 0; - x = -(width >> 1); - for (xdot = 0; xdot < xdots; xdot++, x += inch_per_xdot) - { - col = xdot; - row = ydot; - if (zline(x, y) < 0) - return (-1); - col = xdots - col - 1; - row = ydots - row - 1; - if (zline(-x, -y) < 0) - return (-1); - } - if (plotted == 0) - { - if (y == 0) - plotted = -1; /* no points first pass; don't give up */ - else - break; - } - } - return (0); -} -int -Std4dfpFractal(void) -{ - double x, y; - int xdot, ydot; - c_exp = (int)param[2]; - - if (neworbittype == FPJULIAZPOWER) - { - if (param[3] == 0.0 && debugflag != 6000 && (double)c_exp == param[2]) - fractalspecific[neworbittype].orbitcalc = floatZpowerFractal; - else - fractalspecific[neworbittype].orbitcalc = floatCmplxZpowerFractal; - get_julia_attractor (param[0], param[1]); /* another attractor? */ - } - - for (y = 0, ydot = (ydots >> 1) - 1; ydot >= 0; ydot--, y -= inch_per_ydotfp) - { - plotted = 0; - x = -widthfp / 2; - for (xdot = 0; xdot < xdots; xdot++, x += inch_per_xdotfp) - { - col = xdot; - row = ydot; - if (zlinefp(x, y) < 0) - return (-1); - col = xdots - col - 1; - row = ydots - row - 1; - if (zlinefp(-x, -y) < 0) - return (-1); - } - if (plotted == 0) - { - if (y == 0) - plotted = -1; /* no points first pass; don't give up */ - else - break; - } - } - return (0); -} diff --git a/fractint/common/jiim.c b/fractint/common/jiim.c deleted file mode 100644 index 5ae1e93a0..000000000 --- a/fractint/common/jiim.c +++ /dev/null @@ -1,1281 +0,0 @@ -/* - * JIIM.C - * - * Generates Inverse Julia in real time, lets move a cursor which determines - * the J-set. - * - * The J-set is generated in a fixed-size window, a third of the screen. - * - * The routines used to set/move the cursor and to save/restore the - * window were "borrowed" from editpal.c (TW - now we *use* the editpal code) - * (if you don't know how to write good code, look for someone who does) - * - * JJB [jbuhler@gidef.edu.ar] - * TIW Tim Wegner - * MS Michael Snyder - * KS Ken Shirriff - * Revision History: - * - * 7-28-92 JJB Initial release out of editpal.c - * 7-29-92 JJB Added SaveRect() & RestoreRect() - now the - * screen is restored after leaving. - * 7-30-92 JJB Now, if the cursor goes into the window, the - * window is moved to the other side of the screen. - * Worked from the first time! - * 10-09-92 TIW A major rewrite that merged cut routines duplicated - * in EDITPAL.C and added orbits feature. - * 11-02-92 KS Made cursor blink - * 11-18-92 MS Altered Inverse Julia to use MIIM method. - * 11-25-92 MS Modified MIIM support routines to better be - * shared with stand-alone inverse julia in - * LORENZ.C, and to use DISKVID for swap space. - * 05-05-93 TIW Boy this change file really got out of date. - * Added orbits capability, various commands, some - * of Dan Farmer's ideas like circles and lines - * connecting orbits points. - * 12-18-93 TIW Removed use of float only for orbits, fixed a - * helpmode bug. - * - */ - -#include - -#ifndef USE_VARARGS -#include -#else -#include -#endif - - /* see Fractint.c for a description of the "include" hierarchy */ -#include "port.h" -#include "prototyp.h" -#include "helpdefs.h" -#include "fractype.h" -#include "drivers.h" - -#define MAXRECT 1024 /* largest width of SaveRect/RestoreRect */ - -#define newx(size) mem_alloc(size) -#define delete(block) block=NULL - -int show_numbers =0; /* toggle for display of coords */ -U16 memory_handle = 0; -FILE *file; -int windows = 0; /* windows management system */ - -int xc, yc; /* corners of the window */ -int xd, yd; /* dots in the window */ -double xcjul = BIG; -double ycjul = BIG; - -/* circle routines from Dr. Dobbs June 1990 */ -int xbase, ybase; -unsigned int xAspect, yAspect; - -void SetAspect(double aspect) -{ - xAspect = 0; - yAspect = 0; - aspect = fabs(aspect); - if (aspect != 1.0) { - if (aspect > 1.0) - yAspect = (unsigned int)(65536.0 / aspect); - else - xAspect = (unsigned int)(65536.0 * aspect); - } -} - -void _fastcall c_putcolor(int x, int y, int color) - { - /* avoid writing outside window */ - if ( x < xc || y < yc || x >= xc + xd || y >= yc + yd ) - return ; - if (y >= sydots - show_numbers) /* avoid overwriting coords */ - return; - if (windows == 2) /* avoid overwriting fractal */ - if (0 <= x && x < xdots && 0 <= y && y < ydots) - return; - putcolor(x, y, color); - } - - -int c_getcolor(int x, int y) - { - /* avoid reading outside window */ - if ( x < xc || y < yc || x >= xc + xd || y >= yc + yd ) - return 1000; - if (y >= sydots - show_numbers) /* avoid overreading coords */ - return 1000; - if (windows == 2) /* avoid overreading fractal */ - if (0 <= x && x < xdots && 0 <= y && y < ydots) - return 1000; - return getcolor(x, y); - } - -void circleplot(int x, int y, int color) -{ - if (xAspect == 0) - if (yAspect == 0) - c_putcolor(x+xbase, y+ybase,color); - else - c_putcolor(x+xbase, (short)(ybase + (((long) y * (long) yAspect) >> 16)),color); - else - c_putcolor((int)(xbase + (((long) x * (long) xAspect) >> 16)), y+ybase, color); -} - -void plot8(int x, int y, int color) -{ - circleplot(x,y,color); - circleplot(-x,y,color); - circleplot(x,-y,color); - circleplot(-x,-y,color); - circleplot(y,x,color); - circleplot(-y,x,color); - circleplot(y,-x,color); - circleplot(-y,-x,color); -} - -void circle(int radius, int color) -{ - int x,y,sum; - - x = 0; - y = radius << 1; - sum = 0; - - while (x <= y) - { - if ( !(x & 1) ) /* plot if x is even */ - plot8( x >> 1, (y+1) >> 1, color); - sum += (x << 1) + 1; - x++; - if (sum > 0) - { - sum -= (y << 1) - 1; - y--; - } - } -} - - -/* - * MIIM section: - * - * Global variables and service functions used for computing - * MIIM Julias will be grouped here (and shared by code in LORENZ.C) - * - */ - - - long ListFront, ListBack, ListSize; /* head, tail, size of MIIM Queue */ - long lsize, lmax; /* how many in queue (now, ever) */ - int maxhits = 1; - int OKtoMIIM; - int SecretExperimentalMode; - float luckyx = 0, luckyy = 0; - -static void fillrect(int x, int y, int width, int depth, int color) -{ - /* fast version of fillrect */ - if (hasinverse == 0) - return; - memset(dstack, color % colors, width); - while (depth-- > 0) - { - if (driver_key_pressed()) /* we could do this less often when in fast modes */ - return; - putrow(x, y++, width, (char *)dstack); - } -} - -/* - * Queue/Stack Section: - * - * Defines a buffer that can be used as a FIFO queue or LIFO stack. - */ - -int -QueueEmpty() /* True if NO points remain in queue */ -{ - return (ListFront == ListBack); -} - -#if 0 /* not used */ -int -QueueFull() /* True if room for NO more points in queue */ -{ - return (((ListFront + 1) % ListSize) == ListBack); -} -#endif - -int -QueueFullAlmost() /* True if room for ONE more point in queue */ -{ - return (((ListFront + 2) % ListSize) == ListBack); -} - -void -ClearQueue() -{ - ListFront = ListBack = lsize = lmax = 0; -} - - -/* - * Queue functions for MIIM julia: - * move to JIIM.C when done - */ - -int Init_Queue(unsigned long request) -{ - if (driver_diskp()) - { - stopmsg(0, "Don't try this in disk video mode, kids...\n"); - ListSize = 0; - return 0; - } - -#if 0 - if (xmmquery() && debugflag != 420) /* use LARGEST extended mem */ - if ((largest = xmmlongest()) > request / 128) - request = (unsigned long) largest * 128L; -#endif - - for (ListSize = request; ListSize > 1024; ListSize /= 2) - switch (common_startdisk(ListSize * 8, 1, 256)) - { - case 0: /* success */ - ListFront = ListBack = 0; - lsize = lmax = 0; - return 1; - case -1: - continue; /* try smaller queue size */ - case -2: - ListSize = 0; /* cancelled by user */ - return 0; - } - - /* failed to get memory for MIIM Queue */ - ListSize = 0; - return 0; -} - -void -Free_Queue() -{ - enddisk(); - ListFront = ListBack = ListSize = lsize = lmax = 0; -} - -int -PushLong(long x, long y) -{ - if (((ListFront + 1) % ListSize) != ListBack) - { - if (ToMemDisk(8*ListFront, sizeof(x), &x) && - ToMemDisk(8*ListFront +sizeof(x), sizeof(y), &y)) - { - ListFront = (ListFront + 1) % ListSize; - if (++lsize > lmax) - { - lmax = lsize; - luckyx = (float)x; - luckyy = (float)y; - } - return 1; - } - } - return 0; /* fail */ -} - -int -PushFloat(float x, float y) -{ - if (((ListFront + 1) % ListSize) != ListBack) - { - if (ToMemDisk(8*ListFront, sizeof(x), &x) && - ToMemDisk(8*ListFront +sizeof(x), sizeof(y), &y)) - { - ListFront = (ListFront + 1) % ListSize; - if (++lsize > lmax) - { - lmax = lsize; - luckyx = x; - luckyy = y; - } - return 1; - } - } - return 0; /* fail */ -} - -_CMPLX -PopFloat() -{ - _CMPLX pop; - float popx, popy; - - if (!QueueEmpty()) - { - ListFront--; - if (ListFront < 0) - ListFront = ListSize - 1; - if (FromMemDisk(8*ListFront, sizeof(popx), &popx) && - FromMemDisk(8*ListFront +sizeof(popx), sizeof(popy), &popy)) - { - pop.x = popx; - pop.y = popy; - --lsize; - } - return pop; - } - pop.x = 0; - pop.y = 0; - return pop; -} - -LCMPLX -PopLong() -{ - LCMPLX pop; - - if (!QueueEmpty()) - { - ListFront--; - if (ListFront < 0) - ListFront = ListSize - 1; - if (FromMemDisk(8*ListFront, sizeof(pop.x), &pop.x) && - FromMemDisk(8*ListFront +sizeof(pop.x), sizeof(pop.y), &pop.y)) - --lsize; - return pop; - } - pop.x = 0; - pop.y = 0; - return pop; -} - -int -EnQueueFloat(float x, float y) -{ - return PushFloat(x, y); -} - -int -EnQueueLong(long x, long y) -{ - return PushLong(x, y); -} - -_CMPLX -DeQueueFloat() -{ - _CMPLX out; - float outx, outy; - - if (ListBack != ListFront) - { - if (FromMemDisk(8*ListBack, sizeof(outx), &outx) && - FromMemDisk(8*ListBack +sizeof(outx), sizeof(outy), &outy)) - { - ListBack = (ListBack + 1) % ListSize; - out.x = outx; - out.y = outy; - lsize--; - } - return out; - } - out.x = 0; - out.y = 0; - return out; -} - -LCMPLX -DeQueueLong() -{ - LCMPLX out; - out.x = 0; - out.y = 0; - - if (ListBack != ListFront) - { - if (FromMemDisk(8*ListBack, sizeof(out.x), &out.x) && - FromMemDisk(8*ListBack +sizeof(out.x), sizeof(out.y), &out.y)) - { - ListBack = (ListBack + 1) % ListSize; - lsize--; - } - return out; - } - out.x = 0; - out.y = 0; - return out; -} - - - -/* - * End MIIM section; - */ - -static void SaveRect(int x, int y, int width, int depth) -{ - char buff[MAXRECT]; - int yoff; - if (hasinverse == 0) - return; - /* first, do any de-allocationg */ - - if (memory_handle != 0) - MemoryRelease(memory_handle); - - /* allocate space and store the rect */ - - memset(dstack, g_color_dark, width); - /* TODO: MemoryAlloc */ - if ((memory_handle = MemoryAlloc( (U16)width, (long)depth, MEMORY)) != 0) - { - Cursor_Hide(); - for (yoff=0; yoff= MAXRECT ) - { - /* this mode puts orbit/julia in an overlapping window 1/3 the size of - the physical screen */ - windows = 0; /* full screen or large view window */ - xd = g_vesa_x_res / 3; - yd = g_vesa_y_res / 3; - xc = g_video_start_x + xd * 2; - yc = g_video_start_y + yd * 2; - xoff = g_video_start_x + xd * 5 / 2; - yoff = g_video_start_y + yd * 5 / 2; - } - else if (xdots > g_vesa_x_res/3 && ydots > g_vesa_y_res/3) - { - /* Julia/orbit and fractal don't overlap */ - windows = 1; - xd = g_vesa_x_res - xdots; - yd = g_vesa_y_res - ydots; - xc = g_video_start_x + xdots; - yc = g_video_start_y + ydots; - xoff = xc + xd/2; - yoff = yc + yd/2; - - } - else - { - /* Julia/orbit takes whole screen */ - windows = 2; - xd = g_vesa_x_res; - yd = g_vesa_y_res; - xc = g_video_start_x; - yc = g_video_start_y; - xoff = g_video_start_x + xd/2; - yoff = g_video_start_y + yd/2; - } - - xfactor = (int)(xd/5.33); - yfactor = (int)(-yd/4); - - if (windows == 0) - SaveRect(xc,yc,xd,yd); - else if (windows == 2) /* leave the fractal */ - { - fillrect(xdots, yc, xd-xdots, yd, g_color_dark); - fillrect(xc , ydots, xdots, yd-ydots, g_color_dark); - } - else /* blank whole window */ - fillrect(xc, yc, xd, yd, g_color_dark); - - setup_convert_to_screen(&cvt); - - /* reuse last location if inside window */ - col = (int)(cvt.a*SaveC.x + cvt.b*SaveC.y + cvt.e + .5); - row = (int)(cvt.c*SaveC.x + cvt.d*SaveC.y + cvt.f + .5); - if (col < 0 || col >= xdots || - row < 0 || row >= ydots) - { - cr = (xxmax + xxmin) / 2.0; - ci = (yymax + yymin) / 2.0; - } - else - { - cr = SaveC.x; - ci = SaveC.y; - } - - old_x = old_y = -1; - - col = (int)(cvt.a*cr + cvt.b*ci + cvt.e + .5); - row = (int)(cvt.c*cr + cvt.d*ci + cvt.f + .5); - - /* possible extraseg arrays have been trashed, so set up again */ - if (integerfractal) - fill_lx_array(); - else - fill_dx_array(); - - Cursor_SetPos(col, row); - Cursor_Show(); - color = g_color_bright; - - iter = 1; - still = 1; - zoom = 1; - -#ifdef XFRACT - Cursor_StartMouseTracking(); -#endif - - while (still) - { - int dcol, drow; - if (actively_computing) { - Cursor_CheckBlink(); - } else { - Cursor_WaitKey(); - } - if (driver_key_pressed() || first_time) /* prevent burning up UNIX CPU */ - { - first_time = 0; - while (driver_key_pressed()) - { - Cursor_WaitKey(); - kbdchar = driver_get_key(); - - dcol = drow = 0; - xcjul = BIG; - ycjul = BIG; - switch (kbdchar) - { - case 1143: /* ctrl - keypad 5 */ - case 1076: /* keypad 5 */ - break; /* do nothing */ - case FIK_CTL_PAGE_UP: - dcol = 4; - drow = -4; - break; - case FIK_CTL_PAGE_DOWN: - dcol = 4; - drow = 4; - break; - case FIK_CTL_HOME: - dcol = -4; - drow = -4; - break; - case FIK_CTL_END: - dcol = -4; - drow = 4; - break; - case FIK_PAGE_UP: - dcol = 1; - drow = -1; - break; - case FIK_PAGE_DOWN: - dcol = 1; - drow = 1; - break; - case FIK_HOME: - dcol = -1; - drow = -1; - break; - case FIK_END: - dcol = -1; - drow = 1; - break; - case FIK_UP_ARROW: - drow = -1; - break; - case FIK_DOWN_ARROW: - drow = 1; - break; - case FIK_LEFT_ARROW: - dcol = -1; - break; - case FIK_RIGHT_ARROW: - dcol = 1; - break; - case FIK_CTL_UP_ARROW: - drow = -4; - break; - case FIK_CTL_DOWN_ARROW: - drow = 4; - break; - case FIK_CTL_LEFT_ARROW: - dcol = -4; - break; - case FIK_CTL_RIGHT_ARROW: - dcol = 4; - break; - case 'z': - case 'Z': - zoom = (float)1.0; - break; - case '<': - case ',': - zoom /= (float)1.15; - break; - case '>': - case '.': - zoom *= (float)1.15; - break; - case FIK_SPACE: - xcjul = cr; - ycjul = ci; - goto finish; - /* break; */ - case 'c': /* circle toggle */ - case 'C': /* circle toggle */ - mode = mode ^ 1; - break; - case 'l': - case 'L': - mode = mode ^ 2; - break; - case 'n': - case 'N': - show_numbers = 8 - show_numbers; - if (windows == 0 && show_numbers == 0) - { - Cursor_Hide(); - cleartempmsg(); - Cursor_Show(); - } - break; - case 'p': - case 'P': - get_a_number(&cr,&ci); - exact = 1; - col = (int)(cvt.a*cr + cvt.b*ci + cvt.e + .5); - row = (int)(cvt.c*cr + cvt.d*ci + cvt.f + .5); - dcol = drow = 0; - break; - case 'h': /* hide fractal toggle */ - case 'H': /* hide fractal toggle */ - if (windows == 2) - windows = 3; - else if (windows == 3 && xd == g_vesa_x_res) - { - RestoreRect(g_video_start_x, g_video_start_y, xdots, ydots); - windows = 2; - } - break; -#ifdef XFRACT - case FIK_ENTER: - break; -#endif - case '0': - case '1': - case '2': -/* case '3': */ /* don't use '3', it's already meaningful */ - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - if (which == JIIM) - { - SecretExperimentalMode = kbdchar - '0'; - break; - } - default: - still = 0; -/* ismand = (short)(1 - ismand); */ - } /* switch */ - if (kbdchar == 's' || kbdchar == 'S') - goto finish; - if (dcol > 0 || drow > 0) - exact = 0; - col += dcol; - row += drow; -#ifdef XFRACT - if (kbdchar == FIK_ENTER) { - /* We want to use the position of the cursor */ - exact=0; - col = Cursor_GetX(); - row = Cursor_GetY(); - } -#endif - - /* keep cursor in logical screen */ - if (col >= xdots) { - col = xdots -1; exact = 0; - } - if (row >= ydots) { - row = ydots -1; exact = 0; - } - if (col < 0) { - col = 0; exact = 0; - } - if (row < 0) { - row = 0; exact = 0; - } - - Cursor_SetPos(col,row); - } /* end while (driver_key_pressed) */ - - if (exact == 0) - { - if (integerfractal) - { - cr = lxpixel(); - ci = lypixel(); - cr /= (1L<xc && col < xc+xd && row>yc && row < yc+yd) - { - RestoreRect(xc,yc,xd,yd); - if (xc == g_video_start_x + xd*2) - xc = g_video_start_x + 2; - else - xc = g_video_start_x + xd*2; - xoff = xc + xd / 2; - SaveRect(xc,yc,xd,yd); - } - if (windows == 2) - { - fillrect(xdots, yc, xd-xdots, yd-show_numbers, g_color_dark); - fillrect(xc , ydots, xdots, yd-ydots-show_numbers, g_color_dark); - } - else - fillrect(xc, yc, xd, yd, g_color_dark); - - } /* end if (driver_key_pressed) */ - - if (which == JIIM) - { - if (hasinverse == 0) - continue; -/* - * MIIM code: - * If we have MIIM queue allocated, then use MIIM method. - */ - if (OKtoMIIM) - { - if (QueueEmpty()) - { - if (maxhits < colors - 1 && maxhits < 5 && - (luckyx != 0.0 || luckyy != 0.0)) - { - int i; - - lsize = lmax = 0; - old.x = g_new.x = luckyx; - old.y = g_new.y = luckyy; - luckyx = luckyy = (float)0.0; - for (i=0; i<199; i++) - { - old = ComplexSqrtFloat(old.x - cr, old.y - ci); - g_new = ComplexSqrtFloat(g_new.x - cr, g_new.y - ci); - EnQueueFloat( (float)g_new.x, (float)g_new.y); - EnQueueFloat((float)-old.x, (float)-old.y); - } - maxhits++; - } - else - continue; /* loop while (still) */ - } - - old = DeQueueFloat(); - -#if 0 /* try a different new method */ - if (lsize < (lmax / 8) && maxhits < 5) /* NEW METHOD */ - if (maxhits < colors - 1) - maxhits++; -#endif - x = (int)(old.x * xfactor * zoom + xoff); - y = (int)(old.y * yfactor * zoom + yoff); - color = c_getcolor(x, y); - if (color < maxhits) - { - c_putcolor(x, y, color + 1); - g_new = ComplexSqrtFloat(old.x - cr, old.y - ci); - EnQueueFloat( (float)g_new.x, (float)g_new.y); - EnQueueFloat((float)-g_new.x, (float)-g_new.y); - } - } - else - { -/* - * end Msnyder code, commence if not MIIM code. - */ - old.x -= cr; - old.y -= ci; - r = old.x*old.x + old.y*old.y; - if (r > 10.0) - { - old.x = old.y = 0.0; /* avoids math error */ - iter = 1; - r = 0; - } - iter++; - color = ((count++)>>5)%colors; /* chg color every 32 pts */ - if (color==0) - color = 1; - -/* r = sqrt(old.x*old.x + old.y*old.y); calculated above */ - r = sqrt(r); - g_new.x = sqrt(fabs((r + old.x)/2)); - if (old.y < 0) - g_new.x = -g_new.x; - - g_new.y = sqrt(fabs((r - old.x)/2)); - - - switch (SecretExperimentalMode) { - case 0: /* unmodified random walk */ - default: - if (rand() % 2) - { - g_new.x = -g_new.x; - g_new.y = -g_new.y; - } - x = (int)(g_new.x * xfactor * zoom + xoff); - y = (int)(g_new.y * yfactor * zoom + yoff); - break; - case 1: /* always go one direction */ - if (SaveC.y < 0) - { - g_new.x = -g_new.x; - g_new.y = -g_new.y; - } - x = (int)(g_new.x * xfactor * zoom + xoff); - y = (int)(g_new.y * yfactor * zoom + yoff); - break; - case 2: /* go one dir, draw the other */ - if (SaveC.y < 0) - { - g_new.x = -g_new.x; - g_new.y = -g_new.y; - } - x = (int)(-g_new.x * xfactor * zoom + xoff); - y = (int)(-g_new.y * yfactor * zoom + yoff); - break; - case 4: /* go negative if max color */ - x = (int)(g_new.x * xfactor * zoom + xoff); - y = (int)(g_new.y * yfactor * zoom + yoff); - if (c_getcolor(x, y) == colors - 1) - { - g_new.x = -g_new.x; - g_new.y = -g_new.y; - x = (int)(g_new.x * xfactor * zoom + xoff); - y = (int)(g_new.y * yfactor * zoom + yoff); - } - break; - case 5: /* go positive if max color */ - g_new.x = -g_new.x; - g_new.y = -g_new.y; - x = (int)(g_new.x * xfactor * zoom + xoff); - y = (int)(g_new.y * yfactor * zoom + yoff); - if (c_getcolor(x, y) == colors - 1) - { - x = (int)(g_new.x * xfactor * zoom + xoff); - y = (int)(g_new.y * yfactor * zoom + yoff); - } - break; - case 7: - if (SaveC.y < 0) - { - g_new.x = -g_new.x; - g_new.y = -g_new.y; - } - x = (int)(-g_new.x * xfactor * zoom + xoff); - y = (int)(-g_new.y * yfactor * zoom + yoff); - if (iter > 10) - { - if (mode == 0) /* pixels */ - c_putcolor(x, y, color); - else if (mode & 1) /* circles */ - { - xbase = x; - ybase = y; - circle((int)(zoom*(xd >> 1)/iter),color); - } - if ((mode & 2) && x > 0 && y > 0 && old_x > 0 && old_y > 0) - { - driver_draw_line(x, y, old_x, old_y, color); - } - old_x = x; - old_y = y; - } - x = (int)(g_new.x * xfactor * zoom + xoff); - y = (int)(g_new.y * yfactor * zoom + yoff); - break; - case 8: /* go in long zig zags */ - if (rancnt >= 300) - rancnt = -300; - if (rancnt < 0) - { - g_new.x = -g_new.x; - g_new.y = -g_new.y; - } - x = (int)(g_new.x * xfactor * zoom + xoff); - y = (int)(g_new.y * yfactor * zoom + yoff); - break; - case 9: /* "random run" */ - switch (randir) { - case 0: /* go random direction for a while */ - if (rand() % 2) - { - g_new.x = -g_new.x; - g_new.y = -g_new.y; - } - if (++rancnt > 1024) - { - rancnt = 0; - if (rand() % 2) - randir = 1; - else - randir = -1; - } - break; - case 1: /* now go negative dir for a while */ - g_new.x = -g_new.x; - g_new.y = -g_new.y; - /* fall through */ - case -1: /* now go positive dir for a while */ - if (++rancnt > 512) - randir = rancnt = 0; - break; - } - x = (int)(g_new.x * xfactor * zoom + xoff); - y = (int)(g_new.y * yfactor * zoom + yoff); - break; - } /* end switch SecretMode (sorry about the indentation) */ - } /* end if not MIIM */ - } - else /* orbits */ - { - if (iter < maxit) - { - color = (int)iter%colors; - if (integerfractal) - { - old.x = lold.x; old.x /= fudge; - old.y = lold.y; old.y /= fudge; - } - x = (int)((old.x - init.x) * xfactor * 3 * zoom + xoff); - y = (int)((old.y - init.y) * yfactor * 3 * zoom + yoff); - if ((*ORBITCALC)()) - iter = maxit; - else - iter++; - } - else - { - x = y = -1; - actively_computing = 0; - } - } - if (which == ORBIT || iter > 10) - { - if (mode == 0) /* pixels */ - c_putcolor(x, y, color); - else if (mode & 1) /* circles */ - { - xbase = x; - ybase = y; - circle((int)(zoom*(xd >> 1)/iter),color); - } - if ((mode & 2) && x > 0 && y > 0 && old_x > 0 && old_y > 0) - { - driver_draw_line(x, y, old_x, old_y, color); - } - old_x = x; - old_y = y; - } - old = g_new; - lold = lnew; - } /* end while (still) */ -finish: - -/* - * Msnyder code: - * free MIIM queue - */ - - Free_Queue(); -/* - * end Msnyder code. - */ - - if (kbdchar != 's'&& kbdchar != 'S') - { - Cursor_Hide(); - if (windows == 0) - RestoreRect(xc,yc,xd,yd); - else if (windows >= 2 ) - { - if (windows == 2) - { - fillrect(xdots, yc, xd-xdots, yd, g_color_dark); - fillrect(xc , ydots, xdots, yd-ydots, g_color_dark); - } - else - fillrect(xc, yc, xd, yd, g_color_dark); - if (windows == 3 && xd == g_vesa_x_res) /* unhide */ - { - RestoreRect(0, 0, xdots, ydots); - windows = 2; - } - Cursor_Hide(); - savehasinverse = hasinverse; - hasinverse = 1; - SaveRect(0,0,xdots,ydots); - sxoffs = oldsxoffs; - syoffs = oldsyoffs; - RestoreRect(0,0,xdots,ydots); - hasinverse = savehasinverse; - } - } - Cursor_Destroy(); -#ifdef XFRACT - Cursor_EndMouseTracking(); -#endif - delete(line_buff); - - if (memory_handle != 0) { - MemoryRelease(memory_handle); - memory_handle = 0; - } -#if 0 - if (memory) /* done with memory, free it */ - { - free(memory); - memory = NULL; - } -#endif - - lookatmouse = oldlookatmouse; - using_jiim = 0; - calctype = oldcalctype; - debugflag = old_debugflag; /* yo Chuck! */ - helpmode = oldhelpmode; - if (kbdchar == 's' || kbdchar == 'S') - { - viewwindow = viewxdots = viewydots = 0; - viewreduction = (float)4.2; - viewcrop = 1; - finalaspectratio = screenaspect; - xdots = sxdots; - ydots = sydots; - dxsize = xdots - 1; - dysize = ydots - 1; - sxoffs = 0; - syoffs = 0; - freetempmsg(); - } - else - cleartempmsg(); - if (file != NULL) - { - fclose(file); - file = NULL; - dir_remove(tempdir,scrnfile); - } - show_numbers = 0; - driver_unget_key(kbdchar); - - if (curfractalspecific->calctype == calcfroth) - froth_cleanup(); -} diff --git a/fractint/common/line3d.c b/fractint/common/line3d.c deleted file mode 100644 index dccb8c10f..000000000 --- a/fractint/common/line3d.c +++ /dev/null @@ -1,2522 +0,0 @@ -/************************************************************************/ -/* This file contains a 3D replacement for the out_line function called */ -/* by the decoder. The purpose is to apply various 3D transformations */ -/* before displaying points. Called once per line of the input file. */ -/* */ -/* Original Author Tim Wegner, with extensive help from Marc Reinig. */ -/* July 1994 - TW broke out several pieces of code and added pragma */ -/* to eliminate compiler warnings. Did a long-overdue */ -/* formatting cleanup. */ -/************************************************************************/ - -#include - - /* see Fractint.c for a description of the "include" hierarchy */ -#include "port.h" -#include "prototyp.h" -#include "drivers.h" - -struct point -{ - int x; - int y; - int color; -}; - -struct f_point -{ - float x; - float y; - float color; -}; - -struct minmax -{ - int minx; - int maxx; -}; - -/* routines in this module */ -int line3d(BYTE *, unsigned); -int _fastcall targa_color(int, int, int); -int targa_validate(char *); -static int first_time(int, VECTOR); -static int H_R(BYTE *, BYTE *, BYTE *, unsigned long, unsigned long, unsigned long); -static int line3dmem(void); -static int R_H(BYTE, BYTE, BYTE, unsigned long *, unsigned long *, unsigned long *); -static int set_pixel_buff(BYTE *, BYTE *, unsigned); -int startdisk1(char *, FILE *, int); -static void set_upr_lwr(void); -static int _fastcall end_object(int); -static int _fastcall offscreen(struct point); -static int _fastcall out_triangle(struct f_point, struct f_point, struct f_point, int, int, int); -static int _fastcall RAY_Header(void); -static int _fastcall start_object(void); -static void corners(MATRIX, int, double *, double *, double *, double *, double *, double *); -static void draw_light_box(double *, double *, MATRIX); -static void draw_rect(VECTOR, VECTOR, VECTOR, VECTOR, int, int); -static void File_Error(char *, int); -static void line3d_cleanup(void); -static void _fastcall clipcolor(int, int, int); -static void _fastcall interpcolor(int, int, int); -static void _fastcall putatriangle(struct point, struct point, struct point, int); -static void _fastcall putminmax(int, int, int); -static void _fastcall triangle_bounds(float pt_t[3][3]); -static void _fastcall T_clipcolor(int, int, int); -static void _fastcall vdraw_line(double *, double *, int color); -static void (_fastcall * fillplot) (int, int, int); -static void (_fastcall * normalplot) (int, int, int); - -/* static variables */ -static float deltaphi; /* increment of latitude, longitude */ -static double rscale; /* surface roughness factor */ -static long xcenter, ycenter; /* circle center */ -static double sclx, scly, sclz; /* scale factors */ -static double R; /* radius values */ -static double Rfactor; /* for intermediate calculation */ -static LMATRIX llm; /* "" */ -static LVECTOR lview; /* for perspective views */ -static double zcutoff; /* perspective backside cutoff value */ -static float twocosdeltaphi; -static float cosphi, sinphi; /* precalculated sin/cos of longitude */ -static float oldcosphi1, oldsinphi1; -static float oldcosphi2, oldsinphi2; -static BYTE *fraction; /* float version of pixels array */ -static float min_xyz[3], max_xyz[3]; /* For Raytrace output */ -static int line_length1; -static int T_header_24 = 18;/* Size of current Targa-24 header */ -static FILE *File_Ptr1 = NULL; -static unsigned int IAmbient; -static int rand_factor; -static int HAZE_MULT; -static void File_Error(char *File_Name1, int ERROR); -static BYTE T24 = 24; -static BYTE T32 = 32; -static BYTE upr_lwr[4]; -static int T_Safe; /* Original Targa Image successfully copied to targa_temp */ -static VECTOR light_direction; -static BYTE Real_Color; /* Actual color of cur pixel */ -static int RO, CO, CO_MAX; /* For use in Acrospin support */ -static int localpreviewfactor; -static int zcoord = 256; -static double aspect; /* aspect ratio */ -static int evenoddrow; -static float *sinthetaarray; /* all sine thetas go here */ -static float *costhetaarray; /* all cosine thetas go here */ -static double rXrscale; /* precalculation factor */ -static int persp; /* flag for indicating perspective transformations */ -static struct point p1, p2, p3; -static struct f_point f_bad;/* out of range value */ -static struct point bad; /* out of range value */ -static long num_tris; /* number of triangles output to ray trace file */ - -/* global variables defined here */ -struct f_point *f_lastrow = NULL; -void (_fastcall * standardplot) (int, int, int); -MATRIX m; /* transformation matrix */ -int Ambient; -int RANDOMIZE; -int haze; -int Real_V = 0; /* mrr Actual value of V for fillytpe>4 monochrome images */ -char light_name[FILE_MAX_PATH] = "fract001"; -int Targa_Overlay, error; -char targa_temp[14] = "fractemp.tga"; -int P = 250; /* Perspective dist used when viewing light vector */ -BYTE back_color[3]; -char ray_name[FILE_MAX_PATH] = "fract001"; -char preview = 0; -char showbox = 0; -int previewfactor = 20; -int xadjust = 0; -int yadjust = 0; -int xxadjust; -int yyadjust; -int xshift; -int yshift; -int bad_value = -10000; /* set bad values to this */ -int bad_check = -3000; /* check values against this to determine if good */ -struct point *lastrow = NULL; /* this array remembers the previous line */ -int RAY = 0; /* Flag to generate Ray trace compatible files in 3d */ -int BRIEF = 0; /* 1 = short ray trace files */ - -/* array of min and max x values used in triangle fill */ -static struct minmax *minmax_x; -VECTOR view; /* position of observer for perspective */ -VECTOR cross; -static VECTOR tmpcross; - -static struct point oldlast = { 0, 0, 0 }; /* old pixels */ - - -int line3d(BYTE * pixels, unsigned linelen) -{ - int tout; /* triangle has been sent to ray trace file */ - int RND; - float f_water = (float)0.0; /* transformed WATERLINE for ray trace files */ - double r0; - int xcenter0 = 0; - int ycenter0 = 0; /* Unfudged versions */ - double r; /* sphere radius */ - float costheta, sintheta; /* precalculated sin/cos of latitude */ - int next; /* used by preview and grid */ - int col; /* current column (original GIF) */ - struct point cur; /* current pixels */ - struct point old; /* old pixels */ - struct f_point f_cur; - struct f_point f_old; - VECTOR v; /* double vector */ - VECTOR v1, v2; - VECTOR crossavg; - char crossnotinit; /* flag for crossavg init indication */ - LVECTOR lv; /* long equivalent of v */ - LVECTOR lv0; /* long equivalent of v */ - int lastdot; - long fudge; - - fudge = 1L << 16; - - - if (transparent[0] || transparent[1]) - plot = normalplot = T_clipcolor; /* Use transparent plot function */ - else /* Use the usual FRACTINT plot function with - * clipping */ - plot = normalplot = clipcolor; - - currow = g_row_count; /* use separate variable to allow for - * pot16bit files */ - if (pot16bit) - currow >>= 1; - - /************************************************************************/ - /* This IF clause is executed ONCE per image. All precalculations are */ - /* done here, with out any special concern about speed. DANGER - */ - /* communication with the rest of the program is generally via static */ - /* or global variables. */ - /************************************************************************/ - if (g_row_count++ == 0) - { - int err; - if ((err = first_time(linelen, v)) != 0) - return err; - if (xdots > OLDMAXPIXELS) - return -1; - tout = 0; - crossavg[0] = 0; - crossavg[1] = 0; - crossavg[2] = 0; - xcenter0 = (int) (xcenter = xdots / 2 + xshift); - ycenter0 = (int) (ycenter = ydots / 2 - yshift); - } - /* make sure these pixel coordinates are out of range */ - old = bad; - f_old = f_bad; - - /* copies pixels buffer to float type fraction buffer for fill purposes */ - if (pot16bit) - { - if (set_pixel_buff(pixels, fraction, linelen)) - return 0; - } - else if (grayflag) /* convert color numbers to grayscale values */ - for (col = 0; col < (int) linelen; col++) - { - int pal, colornum; - colornum = pixels[col]; - /* effectively (30*R + 59*G + 11*B)/100 scaled 0 to 255 */ - pal = ((int) g_dac_box[colornum][0] * 77 + - (int) g_dac_box[colornum][1] * 151 + - (int) g_dac_box[colornum][2] * 28); - pal >>= 6; - pixels[col] = (BYTE) pal; - } - crossnotinit = 1; - col = 0; - - CO = 0; - - /*************************************************************************/ - /* This section of code allows the operation of a preview mode when the */ - /* preview flag is set. Enabled, it allows the drawing of only the first */ - /* line of the source image, then every 10th line, until and including */ - /* the last line. For the undrawn lines, only necessary calculations are */ - /* made. As a bonus, in non-sphere mode a box is drawn to help visualize */ - /* the effects of 3D transformations. Thanks to Marc Reinig for this idea*/ - /* and code -- BTW, Marc did NOT put the goto in, but WE did, to avoid */ - /* copying code here, and to avoid a HUGE "if-then" construct. Besides, */ - /* we have ALREADY sinned, so why not sin some more? */ - /*************************************************************************/ - lastdot = min(xdots - 1, (int) linelen - 1); - if (FILLTYPE >= 5) - if (haze && Targa_Out) - { - HAZE_MULT = (int) (haze * ( - (float) ((long) (ydots - 1 - currow) * - (long) (ydots - 1 - currow)) / - (float) ((long) (ydots - 1) * (long) (ydots - 1)))); - HAZE_MULT = 100 - HAZE_MULT; - } - - if (previewfactor >= ydots || previewfactor > lastdot) - previewfactor = min(ydots - 1, lastdot); - - localpreviewfactor = ydots / previewfactor; - - tout = 0; - /* Insure last line is drawn in preview and filltypes <0 */ - if ((RAY || preview || FILLTYPE < 0) && (currow != ydots - 1) && - (currow % localpreviewfactor) && /* Draw mod preview lines */ - !(!RAY && (FILLTYPE > 4) && (currow == 1))) - /* Get init geometry in lightsource modes */ - goto reallythebottom; /* skip over most of the line3d calcs */ - if (driver_diskp()) - { - char s[40]; - sprintf(s, "mapping to 3d, reading line %d", currow); - dvid_status(1, s); - } - - if (!col && RAY && currow != 0) - start_object(); - /* PROCESS ROW LOOP BEGINS HERE */ - while (col < (int) linelen) - { - if ((RAY || preview || FILLTYPE < 0) && - (col != lastdot) &&/* if this is not the last col */ - /* if not the 1st or mod factor col */ - (col % (int) (aspect * localpreviewfactor)) && - (!(!RAY && FILLTYPE > 4 && col == 1))) - goto loopbottom; - - f_cur.color = (float) (cur.color = Real_Color = pixels[col]); - - if (RAY || preview || FILLTYPE < 0) - { - next = (int) (col + aspect * localpreviewfactor); - if (next == col) - next = col + 1; - } - else - next = col + 1; - if (next >= lastdot) - next = lastdot; - - if (cur.color > 0 && cur.color < WATERLINE) - f_cur.color = (float) (cur.color = Real_Color = (BYTE)WATERLINE); /* "lake" */ - else if (pot16bit) - f_cur.color += ((float) fraction[col]) / (float) (1 << 8); - - if (SPHERE) /* sphere case */ - { - sintheta = sinthetaarray[col]; - costheta = costhetaarray[col]; - - if (sinphi < 0 && !(RAY || FILLTYPE < 0)) - { - cur = bad; - f_cur = f_bad; - goto loopbottom; /* another goto ! */ - } - /************************************************************/ - /* KEEP THIS FOR DOCS - original formula -- */ - /* if (rscale < 0.0) */ - /* r = 1.0+((double)cur.color/(double)zcoord)*rscale; */ - /* else */ - /* r = 1.0-rscale+((double)cur.color/(double)zcoord)*rscale;*/ - /* R = (double)ydots/2; */ - /* r = r*R; */ - /* cur.x = xdots/2 + sclx*r*sintheta*aspect + xup ; */ - /* cur.y = ydots/2 + scly*r*costheta*cosphi - yup ; */ - /************************************************************/ - - if (rscale < 0.0) - r = R + Rfactor * (double) f_cur.color * costheta; - else if (rscale > 0.0) - r = R - rXrscale + Rfactor * (double) f_cur.color * costheta; - else - r = R; - /* Allow Ray trace to go through so display ok */ - if (persp || RAY) - { /* mrr how do lv[] and cur and f_cur all relate */ - /* NOTE: fudge was pre-calculated above in r and R */ - /* (almost) guarantee negative */ - lv[2] = (long) (-R - r * costheta * sinphi); /* z */ - if ((lv[2] > zcutoff) && !FILLTYPE < 0) - { - cur = bad; - f_cur = f_bad; - goto loopbottom; /* another goto ! */ - } - lv[0] = (long) (xcenter + sintheta * sclx * r); /* x */ - lv[1] = (long) (ycenter + costheta * cosphi * scly * r); /* y */ - - if ((FILLTYPE >= 5) || RAY) - { /* calculate illumination normal before persp */ - - r0 = r / 65536L; - f_cur.x = (float) (xcenter0 + sintheta * sclx * r0); - f_cur.y = (float) (ycenter0 + costheta * cosphi * scly * r0); - f_cur.color = (float) (-r0 * costheta * sinphi); - } - if (!(usr_floatflag || RAY)) - { - if (longpersp(lv, lview, 16) == -1) - { - cur = bad; - f_cur = f_bad; - goto loopbottom; /* another goto ! */ - } - cur.x = (int) (((lv[0] + 32768L) >> 16) + xxadjust); - cur.y = (int) (((lv[1] + 32768L) >> 16) + yyadjust); - } - if (usr_floatflag || overflow || RAY) - { - v[0] = lv[0]; - v[1] = lv[1]; - v[2] = lv[2]; - v[0] /= fudge; - v[1] /= fudge; - v[2] /= fudge; - perspective(v); - cur.x = (int) (v[0] + .5 + xxadjust); - cur.y = (int) (v[1] + .5 + yyadjust); - } - } - /* mrr Not sure how this an 3rd if above relate */ - else if (!(persp && RAY)) - { - /* mrr Why the xx- and yyadjust here and not above? */ - cur.x = (int) (f_cur.x = (float) (xcenter - + sintheta * sclx * r + xxadjust)); - cur.y = (int) (f_cur.y = (float) (ycenter - + costheta * cosphi * scly * r + yyadjust)); - if (FILLTYPE >= 5 || RAY) /* mrr why do we do this for - * filltype>5? */ - f_cur.color = (float) (-r * costheta * sinphi * sclz); - v[0] = v[1] = v[2] = 0; /* MRR Why do we do this? */ - } - } - else - /* non-sphere 3D */ - { - if (!usr_floatflag && !RAY) - { - if (FILLTYPE >= 5) /* flag to save vector before - * perspective */ - lv0[0] = 1; /* in longvmultpersp calculation */ - else - lv0[0] = 0; - - /* use 32-bit multiply math to snap this out */ - lv[0] = col; - lv[0] = lv[0] << 16; - lv[1] = currow; - lv[1] = lv[1] << 16; - if (filetype || pot16bit) /* don't truncate fractional - * part */ - lv[2] = (long) (f_cur.color * 65536.0); - else - /* there IS no fractaional part here! */ - { - lv[2] = (long) f_cur.color; - lv[2] = lv[2] << 16; - } - - if (longvmultpersp(lv, llm, lv0, lv, lview, 16) == -1) - { - cur = bad; - f_cur = f_bad; - goto loopbottom; - } - - cur.x = (int) (((lv[0] + 32768L) >> 16) + xxadjust); - cur.y = (int) (((lv[1] + 32768L) >> 16) + yyadjust); - if (FILLTYPE >= 5 && !overflow) - { - f_cur.x = (float) lv0[0]; - f_cur.x /= (float)65536.0; - f_cur.y = (float) lv0[1]; - f_cur.y /= (float)65536.0; - f_cur.color = (float) lv0[2]; - f_cur.color /= (float)65536.0; - } - } - - if (usr_floatflag || overflow || RAY) - /* do in float if integer math overflowed or doing Ray trace */ - { - /* slow float version for comparison */ - v[0] = col; - v[1] = currow; - v[2] = f_cur.color; /* Actually the z value */ - - mult_vec(v); /* matrix*vector routine */ - - if (FILLTYPE > 4 || RAY) - { - f_cur.x = (float) v[0]; - f_cur.y = (float) v[1]; - f_cur.color = (float) v[2]; - - if (RAY == 6) - { - f_cur.x = f_cur.x * ((float)2.0 / xdots) - (float)1.0; - f_cur.y = f_cur.y * ((float)2.0 / ydots) - (float)1.0; - f_cur.color = -f_cur.color * ((float)2.0 / numcolors) - (float)1.0; - } - } - - if (persp && !RAY) - perspective(v); - cur.x = (int) (v[0] + xxadjust + .5); - cur.y = (int) (v[1] + yyadjust + .5); - - v[0] = 0; - v[1] = 0; - v[2] = WATERLINE; - mult_vec(v); - f_water = (float) v[2]; - } - } - - if (RANDOMIZE) - if (cur.color > WATERLINE) - { - RND = rand15() >> 8; /* 7-bit number */ - RND = RND * RND >> rand_factor; /* n-bit number */ - - if (rand() & 1) - RND = -RND; /* Make +/- n-bit number */ - - if ((int) (cur.color) + RND >= colors) - cur.color = colors - 2; - else if ((int) (cur.color) + RND <= WATERLINE) - cur.color = WATERLINE + 1; - else - cur.color = cur.color + RND; - Real_Color = (BYTE)cur.color; - } - - if (RAY) - { - if (col && currow && - old.x > bad_check && - old.x < (xdots - bad_check) && - lastrow[col].x > bad_check && - lastrow[col].y > bad_check && - lastrow[col].x < (xdots - bad_check) && - lastrow[col].y < (ydots - bad_check)) - { - /* Get rid of all the triangles in the plane at the base of - * the object */ - - if (f_cur.color == f_water && - f_lastrow[col].color == f_water && - f_lastrow[next].color == f_water) - goto loopbottom; - - if (RAY != 6) /* Output the vertex info */ - out_triangle(f_cur, f_old, f_lastrow[col], - cur.color, old.color, lastrow[col].color); - - tout = 1; - - driver_draw_line(old.x, old.y, cur.x, cur.y, old.color); - driver_draw_line(old.x, old.y, lastrow[col].x, - lastrow[col].y, old.color); - driver_draw_line(lastrow[col].x, lastrow[col].y, - cur.x, cur.y, cur.color); - num_tris++; - } - - if (col < lastdot && currow && - lastrow[col].x > bad_check && - lastrow[col].y > bad_check && - lastrow[col].x < (xdots - bad_check) && - lastrow[col].y < (ydots - bad_check) && - lastrow[next].x > bad_check && - lastrow[next].y > bad_check && - lastrow[next].x < (xdots - bad_check) && - lastrow[next].y < (ydots - bad_check)) - { - /* Get rid of all the triangles in the plane at the base of - * the object */ - - if (f_cur.color == f_water && - f_lastrow[col].color == f_water && - f_lastrow[next].color == f_water) - goto loopbottom; - - if (RAY != 6) /* Output the vertex info */ - out_triangle(f_cur, f_lastrow[col], f_lastrow[next], - cur.color, lastrow[col].color, lastrow[next].color); - - tout = 1; - - driver_draw_line(lastrow[col].x, lastrow[col].y, cur.x, cur.y, - cur.color); - driver_draw_line(lastrow[next].x, lastrow[next].y, cur.x, cur.y, - cur.color); - driver_draw_line(lastrow[next].x, lastrow[next].y, lastrow[col].x, - lastrow[col].y, lastrow[col].color); - num_tris++; - } - - if (RAY == 6) /* Output vertex info for Acrospin */ - { - fprintf(File_Ptr1, "% #4.4f % #4.4f % #4.4f R%dC%d\n", - f_cur.x, f_cur.y, f_cur.color, RO, CO); - if (CO > CO_MAX) - CO_MAX = CO; - CO++; - } - goto loopbottom; - } - - switch (FILLTYPE) - { - case -1: - if (col && - old.x > bad_check && - old.x < (xdots - bad_check)) - driver_draw_line(old.x, old.y, cur.x, cur.y, cur.color); - if (currow && - lastrow[col].x > bad_check && - lastrow[col].y > bad_check && - lastrow[col].x < (xdots - bad_check) && - lastrow[col].y < (ydots - bad_check)) - driver_draw_line(lastrow[col].x, lastrow[col].y, cur.x, - cur.y, cur.color); - break; - - case 0: - (*plot) (cur.x, cur.y, cur.color); - break; - - case 1: /* connect-a-dot */ - if ((old.x < xdots) && (col) && - old.x > bad_check && - old.y > bad_check) /* Don't draw from old to cur on col - * 0 */ - driver_draw_line(old.x, old.y, cur.x, cur.y, cur.color); - break; - - case 2: /* with interpolation */ - case 3: /* no interpolation */ - /*************************************************************/ - /* "triangle fill" - consider four points: current point, */ - /* previous point same row, point opposite current point in */ - /* previous row, point after current point in previous row. */ - /* The object is to fill all points inside the two triangles.*/ - /* */ - /* lastrow[col].x/y___ lastrow[next] */ - /* / 1 / */ - /* / 1 / */ - /* / 1 / */ - /* oldrow/col ________ trow/col */ - /*************************************************************/ - - if (currow && !col) - putatriangle(lastrow[next], lastrow[col], cur, cur.color); - if (currow && col) /* skip first row and first column */ - { - if (col == 1) - putatriangle(lastrow[col], oldlast, old, old.color); - - if (col < lastdot) - putatriangle(lastrow[next], lastrow[col], cur, cur.color); - putatriangle(old, lastrow[col], cur, cur.color); - } - break; - - case 4: /* "solid fill" */ - if (SPHERE) - { - if (persp) - { - old.x = (int) (xcenter >> 16); - old.y = (int) (ycenter >> 16); - } - else - { - old.x = (int) xcenter; - old.y = (int) ycenter; - } - } - else - { - lv[0] = col; - lv[1] = currow; - lv[2] = 0; - - /* apply fudge bit shift for integer math */ - lv[0] = lv[0] << 16; - lv[1] = lv[1] << 16; - /* Since 0, unnecessary lv[2] = lv[2] << 16; */ - - if (longvmultpersp(lv, llm, lv0, lv, lview, 16)) - { - cur = bad; - f_cur = f_bad; - goto loopbottom; /* another goto ! */ - } - - /* Round and fudge back to original */ - old.x = (int) ((lv[0] + 32768L) >> 16); - old.y = (int) ((lv[1] + 32768L) >> 16); - } - if (old.x < 0) - old.x = 0; - if (old.x >= xdots) - old.x = xdots - 1; - if (old.y < 0) - old.y = 0; - if (old.y >= ydots) - old.y = ydots - 1; - driver_draw_line(old.x, old.y, cur.x, cur.y, cur.color); - break; - - case 5: - case 6: - /* light-source modulated fill */ - if (currow && col) /* skip first row and first column */ - { - if (f_cur.color < bad_check || f_old.color < bad_check || - f_lastrow[col].color < bad_check) - break; - - v1[0] = f_cur.x - f_old.x; - v1[1] = f_cur.y - f_old.y; - v1[2] = f_cur.color - f_old.color; - - v2[0] = f_lastrow[col].x - f_cur.x; - v2[1] = f_lastrow[col].y - f_cur.y; - v2[2] = f_lastrow[col].color - f_cur.color; - - cross_product(v1, v2, cross); - - /* normalize cross - and check if non-zero */ - if (normalize_vector(cross)) - { - if (debugflag) - { - stopmsg(0, "debug, cur.color=bad"); - } - cur.color = (int)(f_cur.color = (float) bad.color); - } - else - { - /* line-wise averaging scheme */ - if (LIGHTAVG > 0) - { - if (crossnotinit) - { - /* initialize array of old normal vectors */ - crossavg[0] = cross[0]; - crossavg[1] = cross[1]; - crossavg[2] = cross[2]; - crossnotinit = 0; - } - tmpcross[0] = (crossavg[0] * LIGHTAVG + cross[0]) / - (LIGHTAVG + 1); - tmpcross[1] = (crossavg[1] * LIGHTAVG + cross[1]) / - (LIGHTAVG + 1); - tmpcross[2] = (crossavg[2] * LIGHTAVG + cross[2]) / - (LIGHTAVG + 1); - cross[0] = tmpcross[0]; - cross[1] = tmpcross[1]; - cross[2] = tmpcross[2]; - if (normalize_vector(cross)) - { - /* this shouldn't happen */ - if (debugflag) - { - stopmsg(0, "debug, normal vector err2"); - /* use next instead if you ever need details: - * static char tmp[] = {"debug, vector err"}; - * char msg[200]; #ifndef XFRACT - * sprintf(msg,"%s\n%f %f %f\n%f %f %f\n%f %f - * %f", #else sprintf(msg,"%s\n%f %f %f\n%f %f - * %f\n%f %f %f", #endif tmp, f_cur.x, f_cur.y, - * f_cur.color, f_lastrow[col].x, - * f_lastrow[col].y, f_lastrow[col].color, - * f_lastrow[col-1].x, - * f_lastrow[col-1].y,f_lastrow[col-1].color); - * stopmsg(0,msg); */ - } - cur.color = (int)(f_cur.color = (float) colors); - } - } - crossavg[0] = tmpcross[0]; - crossavg[1] = tmpcross[1]; - crossavg[2] = tmpcross[2]; - - /* dot product of unit vectors is cos of angle between */ - /* we will use this value to shade surface */ - - cur.color = (int) (1 + (colors - 2) * - (1.0 - dot_product(cross, light_direction))); - } - /* if colors out of range, set them to min or max color index - * but avoid background index. This makes colors "opaque" so - * SOMETHING plots. These conditions shouldn't happen but just - * in case */ - if (cur.color < 1) /* prevent transparent colors */ - cur.color = 1;/* avoid background */ - if (cur.color > colors - 1) - cur.color = colors - 1; - - /* why "col < 2"? So we have sufficient geometry for the fill */ - /* algorithm, which needs previous point in same row to have */ - /* already been calculated (variable old) */ - /* fix ragged left margin in preview */ - if (col == 1 && currow > 1) - putatriangle(lastrow[next], lastrow[col], cur, cur.color); - - if (col < 2 || currow < 2) /* don't have valid colors - * yet */ - break; - - if (col < lastdot) - putatriangle(lastrow[next], lastrow[col], cur, cur.color); - putatriangle(old, lastrow[col], cur, cur.color); - - plot = standardplot; - } - break; - } /* End of CASE statement for fill type */ - loopbottom: - if (RAY || (FILLTYPE != 0 && FILLTYPE != 4)) - { - /* for triangle and grid fill purposes */ - oldlast = lastrow[col]; - old = lastrow[col] = cur; - - /* for illumination model purposes */ - f_old = f_lastrow[col] = f_cur; - if (currow && RAY && col >= lastdot) - /* if we're at the end of a row, close the object */ - { - end_object(tout); - tout = 0; - if (ferror(File_Ptr1)) - { - fclose(File_Ptr1); - remove(light_name); - File_Error(ray_name, 2); - return -1; - } - } - } - col++; - } /* End of while statement for plotting line */ - RO++; - reallythebottom: - - /* stuff that HAS to be done, even in preview mode, goes here */ - if (SPHERE) - { - /* incremental sin/cos phi calc */ - if (currow == 0) - { - sinphi = oldsinphi2; - cosphi = oldcosphi2; - } - else - { - sinphi = twocosdeltaphi * oldsinphi2 - oldsinphi1; - cosphi = twocosdeltaphi * oldcosphi2 - oldcosphi1; - oldsinphi1 = oldsinphi2; - oldsinphi2 = sinphi; - oldcosphi1 = oldcosphi2; - oldcosphi2 = cosphi; - } - } - return 0; /* decoder needs to know all is well !!! */ -} - -/* vector version of line draw */ -static void _fastcall vdraw_line(double *v1, double *v2, int color) -{ - int x1, y1, x2, y2; - x1 = (int) v1[0]; - y1 = (int) v1[1]; - x2 = (int) v2[0]; - y2 = (int) v2[1]; - driver_draw_line(x1, y1, x2, y2, color); -} - -static void corners(MATRIX m, int show, double *pxmin, double *pymin, double *pzmin, double *pxmax, double *pymax, double *pzmax) -{ - int i, j; - VECTOR S[2][4]; /* Holds the top an bottom points, - * S[0][]=bottom */ - - /* define corners of box fractal is in in x,y,z plane "b" stands for - * "bottom" - these points are the corners of the screen in the x-y plane. - * The "t"'s stand for Top - they are the top of the cube where 255 color - * points hit. */ - - *pxmin = *pymin = *pzmin = (int) INT_MAX; - *pxmax = *pymax = *pzmax = (int) INT_MIN; - - for (j = 0; j < 4; ++j) - for (i = 0; i < 3; i++) - S[0][j][i] = S[1][j][i] = 0; - - S[0][1][0] = S[0][2][0] = S[1][1][0] = S[1][2][0] = xdots - 1; - S[0][2][1] = S[0][3][1] = S[1][2][1] = S[1][3][1] = ydots - 1; - S[1][0][2] = S[1][1][2] = S[1][2][2] = S[1][3][2] = zcoord - 1; - - for (i = 0; i < 4; ++i) - { - /* transform points */ - vmult(S[0][i], m, S[0][i]); - vmult(S[1][i], m, S[1][i]); - - /* update minimums and maximums */ - if (S[0][i][0] <= *pxmin) - *pxmin = S[0][i][0]; - if (S[0][i][0] >= *pxmax) - *pxmax = S[0][i][0]; - if (S[1][i][0] <= *pxmin) - *pxmin = S[1][i][0]; - if (S[1][i][0] >= *pxmax) - *pxmax = S[1][i][0]; - if (S[0][i][1] <= *pymin) - *pymin = S[0][i][1]; - if (S[0][i][1] >= *pymax) - *pymax = S[0][i][1]; - if (S[1][i][1] <= *pymin) - *pymin = S[1][i][1]; - if (S[1][i][1] >= *pymax) - *pymax = S[1][i][1]; - if (S[0][i][2] <= *pzmin) - *pzmin = S[0][i][2]; - if (S[0][i][2] >= *pzmax) - *pzmax = S[0][i][2]; - if (S[1][i][2] <= *pzmin) - *pzmin = S[1][i][2]; - if (S[1][i][2] >= *pzmax) - *pzmax = S[1][i][2]; - } - - if (show) - { - if (persp) - { - for (i = 0; i < 4; i++) - { - perspective(S[0][i]); - perspective(S[1][i]); - } - } - - /* Keep the box surrounding the fractal */ - for (j = 0; j < 2; j++) - for (i = 0; i < 4; ++i) - { - S[j][i][0] += xxadjust; - S[j][i][1] += yyadjust; - } - - draw_rect(S[0][0], S[0][1], S[0][2], S[0][3], 2, 1); /* Bottom */ - - draw_rect(S[0][0], S[1][0], S[0][1], S[1][1], 5, 0); /* Sides */ - draw_rect(S[0][2], S[1][2], S[0][3], S[1][3], 6, 0); - - draw_rect(S[1][0], S[1][1], S[1][2], S[1][3], 8, 1); /* Top */ - } -} - -/* This function draws a vector from origin[] to direct[] and a box - around it. The vector and box are transformed or not depending on - FILLTYPE. -*/ - -static void draw_light_box(double *origin, double *direct, MATRIX light_m) -{ - VECTOR S[2][4]; - int i, j; - double temp; - - S[1][0][0] = S[0][0][0] = origin[0]; - S[1][0][1] = S[0][0][1] = origin[1]; - - S[1][0][2] = direct[2]; - - for (i = 0; i < 2; i++) - { - S[i][1][0] = S[i][0][0]; - S[i][1][1] = direct[1]; - S[i][1][2] = S[i][0][2]; - S[i][2][0] = direct[0]; - S[i][2][1] = S[i][1][1]; - S[i][2][2] = S[i][0][2]; - S[i][3][0] = S[i][2][0]; - S[i][3][1] = S[i][0][1]; - S[i][3][2] = S[i][0][2]; - } - - /* transform the corners if necessary */ - if (FILLTYPE == 6) - for (i = 0; i < 4; i++) - { - vmult(S[0][i], light_m, S[0][i]); - vmult(S[1][i], light_m, S[1][i]); - } - - /* always use perspective to aid viewing */ - temp = view[2]; /* save perspective distance for a later - * restore */ - view[2] = -P * 300.0 / 100.0; - - for (i = 0; i < 4; i++) - { - perspective(S[0][i]); - perspective(S[1][i]); - } - view[2] = temp; /* Restore perspective distance */ - - /* Adjust for aspect */ - for (i = 0; i < 4; i++) - { - S[0][i][0] = S[0][i][0] * aspect; - S[1][i][0] = S[1][i][0] * aspect; - } - - /* draw box connecting transformed points. NOTE order and COLORS */ - draw_rect(S[0][0], S[0][1], S[0][2], S[0][3], 2, 1); - - vdraw_line(S[0][0], S[1][2], 8); - - /* sides */ - draw_rect(S[0][0], S[1][0], S[0][1], S[1][1], 4, 0); - draw_rect(S[0][2], S[1][2], S[0][3], S[1][3], 5, 0); - - draw_rect(S[1][0], S[1][1], S[1][2], S[1][3], 3, 1); - - /* Draw the "arrow head" */ - for (i = -3; i < 4; i++) - for (j = -3; j < 4; j++) - if (abs(i) + abs(j) < 6) - plot((int) (S[1][2][0] + i), (int) (S[1][2][1] + j), 10); -} - -static void draw_rect(VECTOR V0, VECTOR V1, VECTOR V2, VECTOR V3, int color, int rect) -{ - VECTOR V[4]; - int i; - - /* Since V[2] is not used by vdraw_line don't bother setting it */ - for (i = 0; i < 2; i++) - { - V[0][i] = V0[i]; - V[1][i] = V1[i]; - V[2][i] = V2[i]; - V[3][i] = V3[i]; - } - if (rect) /* Draw a rectangle */ - { - for (i = 0; i < 4; i++) - if (fabs(V[i][0] - V[(i + 1) % 4][0]) < -2 * bad_check && - fabs(V[i][1] - V[(i + 1) % 4][1]) < -2 * bad_check) - vdraw_line(V[i], V[(i + 1) % 4], color); - } - else - /* Draw 2 lines instead */ - { - for (i = 0; i < 3; i += 2) - if (fabs(V[i][0] - V[i + 1][0]) < -2 * bad_check && - fabs(V[i][1] - V[i + 1][1]) < -2 * bad_check) - vdraw_line(V[i], V[i + 1], color); - } - return; -} - -/* replacement for plot - builds a table of min and max x's instead of plot */ -/* called by draw_line as part of triangle fill routine */ -static void _fastcall putminmax(int x, int y, int color) -{ - color = 0; /* to supress warning only */ - if (y >= 0 && y < ydots) - { - if (x < minmax_x[y].minx) - minmax_x[y].minx = x; - if (x > minmax_x[y].maxx) - minmax_x[y].maxx = x; - } -} - -/* - This routine fills in a triangle. Extreme left and right values for - each row are calculated by calling the line function for the sides. - Then rows are filled in with horizontal lines -*/ -#define MAXOFFSCREEN 2 /* allow two of three points to be off screen */ - -static void _fastcall putatriangle(struct point pt1, struct point pt2, struct point pt3, int color) -{ - int miny, maxy; - int x, y, xlim; - - /* Too many points off the screen? */ - if ((offscreen(pt1) + offscreen(pt2) + offscreen(pt3)) > MAXOFFSCREEN) - return; - - p1 = pt1; /* needed by interpcolor */ - p2 = pt2; - p3 = pt3; - - /* fast way if single point or single line */ - if (p1.y == p2.y && p1.x == p2.x) - { - plot = fillplot; - if (p1.y == p3.y && p1.x == p3.x) - (*plot) (p1.x, p1.y, color); - else - driver_draw_line(p1.x, p1.y, p3.x, p3.y, color); - plot = normalplot; - return; - } - else if ((p3.y == p1.y && p3.x == p1.x) || (p3.y == p2.y && p3.x == p2.x)) - { - plot = fillplot; - driver_draw_line(p1.x, p1.y, p2.x, p2.y, color); - plot = normalplot; - return; - } - - /* find min max y */ - miny = maxy = p1.y; - if (p2.y < miny) - miny = p2.y; - else - maxy = p2.y; - if (p3.y < miny) - miny = p3.y; - else if (p3.y > maxy) - maxy = p3.y; - - /* only worried about values on screen */ - if (miny < 0) - miny = 0; - if (maxy >= ydots) - maxy = ydots - 1; - - for (y = miny; y <= maxy; y++) - { - minmax_x[y].minx = (int) INT_MAX; - minmax_x[y].maxx = (int) INT_MIN; - } - - /* set plot to "fake" plot function */ - plot = putminmax; - - /* build table of extreme x's of triangle */ - driver_draw_line(p1.x, p1.y, p2.x, p2.y, 0); - driver_draw_line(p2.x, p2.y, p3.x, p3.y, 0); - driver_draw_line(p3.x, p3.y, p1.x, p1.y, 0); - - for (y = miny; y <= maxy; y++) - { - xlim = minmax_x[y].maxx; - for (x = minmax_x[y].minx; x <= xlim; x++) - (*fillplot) (x, y, color); - } - plot = normalplot; -} - -static int _fastcall offscreen(struct point pt) -{ - if (pt.x >= 0) - if (pt.x < xdots) - if (pt.y >= 0) - if (pt.y < ydots) - return 0; /* point is ok */ - if (abs(pt.x) > 0 - bad_check || abs(pt.y) > 0 - bad_check) - return 99; /* point is bad */ - return 1; /* point is off the screen */ -} - -static void _fastcall clipcolor(int x, int y, int color) -{ - if (0 <= x && x < xdots && - 0 <= y && y < ydots && - 0 <= color && color < filecolors) - { - standardplot(x, y, color); - - if (Targa_Out) - /* standardplot modifies color in these types */ - if (!(g_glasses_type == 1 || g_glasses_type == 2)) - targa_color(x, y, color); - } -} - -/*********************************************************************/ -/* This function is the same as clipcolor but checks for color being */ -/* in transparent range. Intended to be called only if transparency */ -/* has been enabled. */ -/*********************************************************************/ - -static void _fastcall T_clipcolor(int x, int y, int color) -{ - if (0 <= x && x < xdots && /* is the point on screen? */ - 0 <= y && y < ydots && /* Yes? */ - 0 <= color && color < colors && /* Colors in valid range? */ - /* Lets make sure its not a transparent color */ - (transparent[0] > color || color > transparent[1])) - { - standardplot(x, y, color);/* I guess we can plot then */ - if (Targa_Out) - /* standardplot modifies color in these types */ - if (!(g_glasses_type == 1 || g_glasses_type == 2)) - targa_color(x, y, color); - } -} - -/************************************************************************/ -/* A substitute for plotcolor that interpolates the colors according */ -/* to the x and y values of three points (p1,p2,p3) which are static in */ -/* this routine */ -/* */ -/* In Light source modes, color is light value, not actual color */ -/* Real_Color always contains the actual color */ -/************************************************************************/ - -static void _fastcall interpcolor(int x, int y, int color) -{ - int D, d1, d2, d3; - - /* this distance formula is not the usual one - but it has the virtue that - * it uses ONLY additions (almost) and it DOES go to zero as the points - * get close. */ - - d1 = abs(p1.x - x) + abs(p1.y - y); - d2 = abs(p2.x - x) + abs(p2.y - y); - d3 = abs(p3.x - x) + abs(p3.y - y); - - D = (d1 + d2 + d3) << 1; - if (D) - { /* calculate a weighted average of colors long casts prevent integer - overflow. This can evaluate to zero */ - color = (int) (((long) (d2 + d3) * (long) p1.color + - (long) (d1 + d3) * (long) p2.color + - (long) (d1 + d2) * (long) p3.color) / D); - } - - if (0 <= x && x < xdots && - 0 <= y && y < ydots && - 0 <= color && color < colors && - (transparent[1] == 0 || (int) Real_Color > transparent[1] || - transparent[0] > (int) Real_Color)) - { - if (Targa_Out) - /* standardplot modifies color in these types */ - if (!(g_glasses_type == 1 || g_glasses_type == 2)) - D = targa_color(x, y, color); - - if (FILLTYPE >= 5) { - if (Real_V && Targa_Out) - color = D; - else - { - color = (1 + (unsigned) color * IAmbient) / 256; - if (color == 0) - color = 1; - } - } - standardplot(x, y, color); - } -} - -/* - In non light source modes, both color and Real_Color contain the - actual pixel color. In light source modes, color contains the - light value, and Real_Color contains the origninal color - - This routine takes a pixel modifies it for lightshading if appropriate - and plots it in a Targa file. Used in plot3d.c -*/ - -int _fastcall targa_color(int x, int y, int color) -{ - unsigned long H, S, V; - BYTE RGB[3]; - - if (FILLTYPE == 2 || g_glasses_type == 1 || g_glasses_type == 2 || truecolor) - Real_Color = (BYTE)color; /* So Targa gets interpolated color */ - - switch (truemode) - { - case 0: - default: - { - RGB[0] = (BYTE)(g_dac_box[Real_Color][0] << 2); /* Move color space to */ - RGB[1] = (BYTE)(g_dac_box[Real_Color][1] << 2); /* 256 color primaries */ - RGB[2] = (BYTE)(g_dac_box[Real_Color][2] << 2); /* from 64 colors */ - break; - } - case 1: - { - RGB[0] = (BYTE)((realcoloriter >> 16) & 0xff); /* red */ - RGB[1] = (BYTE)((realcoloriter >> 8 ) & 0xff); /* green */ - RGB[2] = (BYTE)((realcoloriter ) & 0xff); /* blue */ - break; - } - } - - /* Now lets convert it to HSV */ - R_H(RGB[0], RGB[1], RGB[2], &H, &S, &V); - - /* Modify original S and V components */ - if (FILLTYPE > 4 && !(g_glasses_type == 1 || g_glasses_type == 2)) - /* Adjust for Ambient */ - V = (V * (65535L - (unsigned) (color * IAmbient))) / 65535L; - - if (haze) - { - /* Haze lowers sat of colors */ - S = (unsigned long) (S * HAZE_MULT) / 100; - if (V >= 32640) /* Haze reduces contrast */ - { - V = V - 32640; - V = (unsigned long) ((V * HAZE_MULT) / 100); - V = V + 32640; - } - else - { - V = 32640 - V; - V = (unsigned long) ((V * HAZE_MULT) / 100); - V = 32640 - V; - } - } - /* Now lets convert it back to RGB. Original Hue, modified Sat and Val */ - H_R(&RGB[0], &RGB[1], &RGB[2], H, S, V); - - if (Real_V) - V = (35 * (int) RGB[0] + 45 * (int) RGB[1] + 20 * (int) RGB[2]) / 100; - - /* Now write the color triple to its transformed location */ - /* on the disk. */ - targa_writedisk(x + sxoffs, y + syoffs, RGB[0], RGB[1], RGB[2]); - - return (int) (255 - V); -} - -static int set_pixel_buff(BYTE * pixels, BYTE * fraction, unsigned linelen) -{ - int i; - if ((evenoddrow++ & 1) == 0) /* even rows are color value */ - { - for (i = 0; i < (int) linelen; i++) /* add the fractional part in - * odd row */ - fraction[i] = pixels[i]; - return 1; - } - else - /* swap */ - { - BYTE tmp; - for (i = 0; i < (int) linelen; i++) /* swap so pixel has color */ - { - tmp = pixels[i]; - pixels[i] = fraction[i]; - fraction[i] = tmp; - } - } - return 0; -} - -/************************************************************************** - - Common routine for printing error messages to the screen for Targa - and other files - -**************************************************************************/ - -static void File_Error(char *File_Name1, int ERROR) -{ - char msgbuf[200]; - - error = ERROR; - switch (ERROR) - { - case 1: /* Can't Open */ - sprintf(msgbuf, "OOPS, couldn't open < %s >", File_Name1); - break; - case 2: /* Not enough room */ - sprintf(msgbuf, "OOPS, ran out of disk space. < %s >", File_Name1); - break; - case 3: /* Image wrong size */ - sprintf(msgbuf, "OOPS, image wrong size\n"); - break; - case 4: /* Wrong file type */ - sprintf(msgbuf, "OOPS, can't handle this type of file.\n"); - break; - } - stopmsg(0, msgbuf); - return; -} - - -/************************************************************************/ -/* */ -/* This function opens a TARGA_24 file for reading and writing. If */ -/* its a new file, (overlay == 0) it writes a header. If it is to */ -/* overlay an existing file (overlay == 1) it copies the original */ -/* header whose lenght and validity was determined in */ -/* Targa_validate. */ -/* */ -/* It Verifies there is enough disk space, and leaves the file */ -/* at the start of the display data area. */ -/* */ -/* If this is an overlay, closes source and copies to "targa_temp" */ -/* If there is an error close the file. */ -/* */ -/* **********************************************************************/ - -int startdisk1(char *File_Name2, FILE * Source, int overlay) -{ - int i, j, k, inc; - FILE *fps; - - /* Open File for both reading and writing */ - fps = dir_fopen(workdir,File_Name2, "w+b"); - if (fps == NULL) - { - File_Error(File_Name2, 1); - return -1; /* Oops, somethings wrong! */ - } - - inc = 1; /* Assume we are overlaying a file */ - - /* Write the header */ - if (overlay) /* We are overlaying a file */ - for (i = 0; i < T_header_24; i++) /* Copy the header from the Source */ - fputc(fgetc(Source), fps); - else - { /* Write header for a new file */ - /* ID field size = 0, No color map, Targa type 2 file */ - for (i = 0; i < 12; i++) - { - if (i == 0 && truecolor != 0) - { - set_upr_lwr(); - fputc(4, fps); /* make room to write an extra number */ - T_header_24 = 18 + 4; - } - else if (i == 2) - fputc(i, fps); - else - fputc(0, fps); - } - /* Write image size */ - for (i = 0; i < 4; i++) - fputc(upr_lwr[i], fps); - fputc(T24, fps); /* Targa 24 file */ - fputc(T32, fps); /* Image at upper left */ - inc = 3; - } - - if (truecolor) /* write maxit */ - { - fputc((BYTE)(maxit & 0xff), fps); - fputc((BYTE)((maxit>>8 ) & 0xff), fps); - fputc((BYTE)((maxit>>16) & 0xff), fps); - fputc((BYTE)((maxit>>24) & 0xff), fps); - } - - /* Finished with the header, now lets work on the display area */ - for (i = 0; i < ydots; i++) /* "clear the screen" (write to the disk) */ - { - for (j = 0; j < line_length1; j = j + inc) - { - if (overlay) - fputc(fgetc(Source), fps); - else - for (k = 2; k > -1; k--) - fputc(back_color[k], fps); /* Targa order (B, G, R) */ - } - if (ferror(fps)) - { - /* Almost certainly not enough disk space */ - fclose(fps); - if (overlay) - fclose(Source); - dir_remove(workdir,File_Name2); - File_Error(File_Name2, 2); - return -2; - } - if (driver_key_pressed()) - return -3; - } - - if (targa_startdisk(fps, T_header_24) != 0) - { - enddisk(); - dir_remove(workdir,File_Name2); - return -4; - } - return 0; -} - -int targa_validate(char *File_Name) -{ - FILE *fp; - int i; - - /* Attempt to open source file for reading */ - fp = dir_fopen(workdir,File_Name, "rb"); - if (fp == NULL) - { - File_Error(File_Name, 1); - return -1; /* Oops, file does not exist */ - } - - T_header_24 += fgetc(fp); /* Check ID field and adjust header size */ - - if (fgetc(fp)) /* Make sure this is an unmapped file */ - { - File_Error(File_Name, 4); - return -1; - } - - if (fgetc(fp) != 2) /* Make sure it is a type 2 file */ - { - File_Error(File_Name, 4); - return -1; - } - - /* Skip color map specification */ - for (i = 0; i < 5; i++) - fgetc(fp); - - for (i = 0; i < 4; i++) - { - /* Check image origin */ - fgetc(fp); - } - /* Check Image specs */ - for (i = 0; i < 4; i++) - if (fgetc(fp) != (int) upr_lwr[i]) - { - File_Error(File_Name, 3); - return -1; - } - - if (fgetc(fp) != (int) T24) - error = 4; /* Is it a targa 24 file? */ - if (fgetc(fp) != (int) T32) - error = 4; /* Is the origin at the upper left? */ - if (error == 4) - { - File_Error(File_Name, 4); - return -1; - } - rewind(fp); - - /* Now that we know its a good file, create a working copy */ - if (startdisk1(targa_temp, fp, 1)) - return -1; - - fclose(fp); /* Close the source */ - - T_Safe = 1; /* Original file successfully copied to - * targa_temp */ - return 0; -} - -static int R_H(BYTE R, BYTE G, BYTE B, unsigned long *H, unsigned long *S, unsigned long *V) -{ - unsigned long R1, G1, B1, DENOM; - BYTE MIN; - - *V = R; - MIN = G; - if (R < G) - { - *V = G; - MIN = R; - if (G < B) - *V = B; - if (B < R) - MIN = B; - } - else - { - if (B < G) - MIN = B; - if (R < B) - *V = B; - } - DENOM = *V - MIN; - if (*V != 0 && DENOM != 0) - { - *S = ((DENOM << 16) / *V) - 1; - } - else - *S = 0; /* Color is black! and Sat has no meaning */ - if (*S == 0) /* R=G=B => shade of grey and Hue has no meaning */ - { - *H = 0; - *V = *V << 8; - return 1; /* v or s or both are 0 */ - } - if (*V == MIN) - { - *H = 0; - *V = *V << 8; - return 0; - } - R1 = (((*V - R) * 60) << 6) / DENOM; /* distance of color from red */ - G1 = (((*V - G) * 60) << 6) / DENOM; /* distance of color from green */ - B1 = (((*V - B) * 60) << 6) / DENOM; /* distance of color from blue */ - if (*V == R) { - if (MIN == G) - *H = (300 << 6) + B1; - else - *H = (60 << 6) - G1; - } - if (*V == G) { - if (MIN == B) - *H = (60 << 6) + R1; - else - *H = (180 << 6) - B1; - } - if (*V == B) { - if (MIN == R) - *H = (180 << 6) + G1; - else - *H = (300 << 6) - R1; - } - *V = *V << 8; - return 0; -} - -static int H_R(BYTE *R, BYTE *G, BYTE *B, unsigned long H, unsigned long S, unsigned long V) -{ - unsigned long P1, P2, P3; - int RMD, I; - - if (H >= 23040) - H = H % 23040; /* Makes h circular */ - I = (int) (H / 3840); - RMD = (int) (H % 3840); /* RMD = fractional part of H */ - - P1 = ((V * (65535L - S)) / 65280L) >> 8; - P2 = (((V * (65535L - (S * RMD) / 3840)) / 65280L) - 1) >> 8; - P3 = (((V * (65535L - (S * (3840 - RMD)) / 3840)) / 65280L)) >> 8; - V = V >> 8; - switch (I) - { - case 0: - *R = (BYTE) V; - *G = (BYTE) P3; - *B = (BYTE) P1; - break; - case 1: - *R = (BYTE) P2; - *G = (BYTE) V; - *B = (BYTE) P1; - break; - case 2: - *R = (BYTE) P1; - *G = (BYTE) V; - *B = (BYTE) P3; - break; - case 3: - *R = (BYTE) P1; - *G = (BYTE) P2; - *B = (BYTE) V; - break; - case 4: - *R = (BYTE) P3; - *G = (BYTE) P1; - *B = (BYTE) V; - break; - case 5: - *R = (BYTE) V; - *G = (BYTE) P1; - *B = (BYTE) P2; - break; - } - return 0; -} - - -/***************************************************************************/ -/* */ -/* EB & DG fiddled with outputs for Rayshade so they work. with v4.x. */ -/* EB == eli brandt. ebrandt@jarthur.claremont.edu */ -/* DG == dan goldwater. daniel_goldwater@brown.edu & dgold@math.umass.edu */ -/* (NOTE: all the stuff we fiddled with is commented with "EB & DG" ) */ -/* general raytracing code info/notes: */ -/* */ -/* ray == 0 means no raytracer output ray == 7 is for dxf */ -/* ray == 1 is for dkb/pov ray == 4 is for mtv */ -/* ray == 2 is for vivid ray == 5 is for rayshade */ -/* ray == 3 is for raw ray == 6 is for acrospin */ -/* */ -/* rayshade needs counterclockwise triangles. raytracers that support */ -/* the 'heightfield' primitive include rayshade and pov. anyone want to */ -/* write code to make heightfields? they are *MUCH* faster to trace than */ -/* triangles when doing landscapes... */ -/* */ -/* stuff EB & DG changed: */ -/* made the rayshade output create a "grid" aggregate object (one of */ -/* rayshade's primitives), instead of a global grid. as a result, the */ -/* grid can be optimized based on the number of triangles. */ -/* the z component of the grid can always be 1 since the surface formed */ -/* by the triangles is flat */ -/* (ie, it doesnt curve over itself). this is a major optimization. */ -/* the x and y grid size is also optimized for a 4:3 aspect ratio image, */ -/* to get the fewest possible traingles in each grid square. */ -/* also, we fixed the rayshade code so it actually produces output that */ -/* works with rayshade. */ -/* (maybe the old code was for a really old version of rayshade?). */ -/* */ -/***************************************************************************/ - -/********************************************************************/ -/* */ -/* This routine writes a header to a ray tracer data file. It */ -/* Identifies the version of FRACTINT which created it an the */ -/* key 3D parameters in effect at the time. */ -/* */ -/********************************************************************/ - -static int _fastcall RAY_Header(void) -{ - /* Open the ray tracing output file */ - check_writefile(ray_name, ".ray"); - File_Ptr1 = fopen(ray_name, "w"); - if (File_Ptr1 == NULL) - return -1; /* Oops, somethings wrong! */ - - if (RAY == 2) - fprintf(File_Ptr1, "//"); - if (RAY == 4) - fprintf(File_Ptr1, "#"); - if (RAY == 5) - fprintf(File_Ptr1, "/*\n"); - if (RAY == 6) - fprintf(File_Ptr1, "--"); - if (RAY == 7) - fprintf(File_Ptr1, " 0\nSECTION\n 2\nTABLES\n 0\nTABLE\n 2\nLAYER\n\ - 70\n 2\n 0\nLAYER\n 2\n0\n 70\n 0\n 62\n 7\n 6\nCONTINUOUS\n\ - 0\nLAYER\n 2\nFRACTAL\n 70\n 64\n 62\n 1\n 6\nCONTINUOUS\n 0\n\ -ENDTAB\n 0\nENDSEC\n 0\nSECTION\n 2\nENTITIES\n"); - - if (RAY != 7) - fprintf(File_Ptr1, "{ Created by FRACTINT Ver. %#4.2f }\n\n", g_release / 100.); - - if (RAY == 5) - fprintf(File_Ptr1, "*/\n"); - - - /* Set the default color */ - if (RAY == 1) - { - fprintf(File_Ptr1, "DECLARE F_Dflt = COLOR RED 0.8 GREEN 0.4 BLUE 0.1\n"); - } - if (BRIEF) - { - if (RAY == 2) - { - fprintf(File_Ptr1, "surf={diff=0.8 0.4 0.1;}\n"); - } - if (RAY == 4) - { - fprintf(File_Ptr1, "f 0.8 0.4 0.1 0.95 0.05 5 0 0\n"); - } - if (RAY == 5) - fprintf(File_Ptr1, "applysurf diffuse 0.8 0.4 0.1"); - } - if (RAY != 7) - fprintf(File_Ptr1, "\n"); - - /* EB & DG: open "grid" opject, a speedy way to do aggregates in rayshade */ - if (RAY == 5) - fprintf(File_Ptr1, - "/* make a gridded aggregate. this size grid is fast for landscapes. */\n" - "/* make z grid = 1 always for landscapes. */\n\n" - "grid 33 25 1\n"); - - if (RAY == 6) - fprintf(File_Ptr1, "Set Layer 1\nSet Color 2\nEndpointList X Y Z Name\n"); - - return 0; -} - - -/********************************************************************/ -/* */ -/* This routine describes the triangle to the ray tracer, it */ -/* sets the color of the triangle to the average of the color */ -/* of its verticies and sets the light parameters to arbitrary */ -/* values. */ -/* */ -/* Note: numcolors (number of colors in the source */ -/* file) is used instead of colors (number of colors avail. with */ -/* display) so you can generate ray trace files with your LCD */ -/* or monochrome display */ -/* */ -/********************************************************************/ - -static int _fastcall out_triangle(struct f_point pt1, struct f_point pt2, struct f_point pt3, int c1, int c2, int c3) -{ - int i, j; - float c[3]; - float pt_t[3][3]; - - /* Normalize each vertex to screen size and adjust coordinate system */ - pt_t[0][0] = 2 * pt1.x / xdots - 1; - pt_t[0][1] = (2 * pt1.y / ydots - 1); - pt_t[0][2] = -2 * pt1.color / numcolors - 1; - pt_t[1][0] = 2 * pt2.x / xdots - 1; - pt_t[1][1] = (2 * pt2.y / ydots - 1); - pt_t[1][2] = -2 * pt2.color / numcolors - 1; - pt_t[2][0] = 2 * pt3.x / xdots - 1; - pt_t[2][1] = (2 * pt3.y / ydots - 1); - pt_t[2][2] = -2 * pt3.color / numcolors - 1; - - /* Color of triangle is average of colors of its verticies */ - if (!BRIEF) - for (i = 0; i <= 2; i++) -#ifdef __SVR4 - c[i] = (float) ((int)(g_dac_box[c1][i] + g_dac_box[c2][i] + g_dac_box[c3][i]) - / (3 * 63)); -#else - c[i] = (float) (g_dac_box[c1][i] + g_dac_box[c2][i] + g_dac_box[c3][i]) - / (3 * 63); -#endif - - /* get rid of degenerate triangles: any two points equal */ - if ((pt_t[0][0] == pt_t[1][0] && - pt_t[0][1] == pt_t[1][1] && - pt_t[0][2] == pt_t[1][2]) || - - (pt_t[0][0] == pt_t[2][0] && - pt_t[0][1] == pt_t[2][1] && - pt_t[0][2] == pt_t[2][2]) || - - (pt_t[2][0] == pt_t[1][0] && - pt_t[2][1] == pt_t[1][1] && - pt_t[2][2] == pt_t[1][2])) - return 0; - - /* Describe the triangle */ - if (RAY == 1) - fprintf(File_Ptr1, " OBJECT\n TRIANGLE "); - if (RAY == 2 && !BRIEF) - fprintf(File_Ptr1, "surf={diff="); - if (RAY == 4 && !BRIEF) - fprintf(File_Ptr1, "f"); - if (RAY == 5 && !BRIEF) - fprintf(File_Ptr1, "applysurf diffuse "); - - if (!BRIEF && RAY != 1 && RAY != 7) - for (i = 0; i <= 2; i++) - fprintf(File_Ptr1, "% #4.4f ", c[i]); - - if (RAY == 2) - { - if (!BRIEF) - fprintf(File_Ptr1, ";}\n"); - fprintf(File_Ptr1, "polygon={points=3;"); - } - if (RAY == 4) - { - if (!BRIEF) - fprintf(File_Ptr1, "0.95 0.05 5 0 0\n"); - fprintf(File_Ptr1, "p 3"); - } - if (RAY == 5) - { - if (!BRIEF) - fprintf(File_Ptr1, "\n"); - /* EB & DG: removed "T" after "triangle" */ - fprintf(File_Ptr1, "triangle"); - } - - if (RAY == 7) - fprintf(File_Ptr1, " 0\n3DFACE\n 8\nFRACTAL\n 62\n%3d\n", min(255, max(1, c1))); - - for (i = 0; i <= 2; i++) /* Describe each Vertex */ - { - if (RAY != 7) - fprintf(File_Ptr1, "\n"); - - if (RAY == 1) - fprintf(File_Ptr1, " <"); - if (RAY == 2) - fprintf(File_Ptr1, " vertex = "); - if (RAY > 3 && RAY != 7) - fprintf(File_Ptr1, " "); - - for (j = 0; j <= 2; j++) - { - if (RAY == 7) - { - /* write 3dface entity to dxf file */ - fprintf(File_Ptr1, "%3d\n%g\n", 10 * (j + 1) + i, pt_t[i][j]); - if (i == 2) /* 3dface needs 4 vertecies */ - fprintf(File_Ptr1, "%3d\n%g\n", 10 * (j + 1) + i + 1, - pt_t[i][j]); - } - else if (!(RAY == 4 || RAY == 5)) - fprintf(File_Ptr1, "% #4.4f ", pt_t[i][j]); /* Right handed */ - else - fprintf(File_Ptr1, "% #4.4f ", pt_t[2 - i][j]); /* Left handed */ - } - - if (RAY == 1) - fprintf(File_Ptr1, ">"); - if (RAY == 2) - fprintf(File_Ptr1, ";"); - } - - if (RAY == 1) - { - fprintf(File_Ptr1, " END_TRIANGLE \n"); - if (!BRIEF) - { - fprintf(File_Ptr1, - " TEXTURE\n" - " COLOR RED% #4.4f GREEN% #4.4f BLUE% #4.4f\n" - " AMBIENT 0.25 DIFFUSE 0.75 END_TEXTURE\n", - c[0], c[1], c[2]); - } - fprintf(File_Ptr1, " COLOR F_Dflt END_OBJECT"); - triangle_bounds(pt_t); /* update bounding info */ - } - if (RAY == 2) - fprintf(File_Ptr1, "}"); - if (RAY == 3 && !BRIEF) - fprintf(File_Ptr1, "\n"); - - if (RAY != 7) - fprintf(File_Ptr1, "\n"); - - return 0; -} - -/********************************************************************/ -/* */ -/* This routine calculates the min and max values of a triangle */ -/* for use in creating ray tracer data files. The values of min */ -/* and max x, y, and z are assumed to be global. */ -/* */ -/********************************************************************/ - -static void _fastcall triangle_bounds(float pt_t[3][3]) -{ - int i, j; - - for (i = 0; i <= 2; i++) - for (j = 0; j <= 2; j++) - { - if (pt_t[i][j] < min_xyz[j]) - min_xyz[j] = pt_t[i][j]; - if (pt_t[i][j] > max_xyz[j]) - max_xyz[j] = pt_t[i][j]; - } - return; -} - -/********************************************************************/ -/* */ -/* This routine starts a composite object for ray trace data files */ -/* */ -/********************************************************************/ - -static int _fastcall start_object(void) -{ - if (RAY != 1) - return 0; - - /* Reset the min/max values, for bounding box */ - min_xyz[0] = min_xyz[1] = min_xyz[2] = (float)999999.0; - max_xyz[0] = max_xyz[1] = max_xyz[2] = (float)-999999.0; - - fprintf(File_Ptr1, "COMPOSITE\n"); - return 0; -} - -/********************************************************************/ -/* */ -/* This routine adds a bounding box for the triangles drawn */ -/* in the last block and completes the composite object created. */ -/* It uses the globals min and max x,y and z calculated in */ -/* z calculated in Triangle_Bounds(). */ -/* */ -/********************************************************************/ - -static int _fastcall end_object(int triout) -{ - if (RAY == 7) - return 0; - if (RAY == 1) - { - if (triout) - { - /* Make sure the bounding box is slightly larger than the object */ - int i; - for (i = 0; i <= 2; i++) - { - if (min_xyz[i] == max_xyz[i]) - { - min_xyz[i] -= (float)0.01; - max_xyz[i] += (float)0.01; - } - else - { - min_xyz[i] -= (max_xyz[i] - min_xyz[i]) * (float)0.01; - max_xyz[i] += (max_xyz[i] - min_xyz[i]) * (float)0.01; - } - } - - /* Add the bounding box info */ - fprintf(File_Ptr1, " BOUNDED_BY\n INTERSECTION\n"); - fprintf(File_Ptr1, " PLANE <-1.0 0.0 0.0 > % #4.3f END_PLANE\n", -min_xyz[0]); - fprintf(File_Ptr1, " PLANE < 1.0 0.0 0.0 > % #4.3f END_PLANE\n", max_xyz[0]); - fprintf(File_Ptr1, " PLANE < 0.0 -1.0 0.0 > % #4.3f END_PLANE\n", -min_xyz[1]); - fprintf(File_Ptr1, " PLANE < 0.0 1.0 0.0 > % #4.3f END_PLANE\n", max_xyz[1]); - fprintf(File_Ptr1, " PLANE < 0.0 0.0 -1.0 > % #4.3f END_PLANE\n", -min_xyz[2]); - fprintf(File_Ptr1, " PLANE < 0.0 0.0 1.0 > % #4.3f END_PLANE\n", max_xyz[2]); - fprintf(File_Ptr1, " END_INTERSECTION\n END_BOUND\n"); - } - - /* Complete the composite object statement */ - fprintf(File_Ptr1, "END_%s\n", "COMPOSITE"); - } - - if (RAY != 6 && RAY != 5) - fprintf(File_Ptr1, "\n"); /* EB & DG: too many newlines */ - - return 0; -} - -static void line3d_cleanup(void) -{ - int i, j; - if (RAY && File_Ptr1) - { /* Finish up the ray tracing files */ - if (RAY != 5 && RAY != 7) - fprintf(File_Ptr1, "\n"); /* EB & DG: too many newlines */ - if (RAY == 2) - fprintf(File_Ptr1, "\n\n//"); - if (RAY == 4) - fprintf(File_Ptr1, "\n\n#"); - - if (RAY == 5) - /* EB & DG: end grid aggregate */ - fprintf(File_Ptr1, "end\n\n/*good landscape:*/\n%s%s\n/*", - "screen 640 480\neyep 0 2.1 0.8\nlookp 0 0 -0.95\nlight 1 point -2 1 1.5\n", "background .3 0 0\nreport verbose\n"); - if (RAY == 6) - { - fprintf(File_Ptr1, "LineList From To\n"); - for (i = 0; i < RO; i++) - for (j = 0; j <= CO_MAX; j++) - { - if (j < CO_MAX) - fprintf(File_Ptr1, "R%dC%d R%dC%d\n", i, j, i, j + 1); - if (i < RO - 1) - fprintf(File_Ptr1, "R%dC%d R%dC%d\n", i, j, i + 1, j); - if (i && i < RO && j < CO_MAX) - fprintf(File_Ptr1, "R%dC%d R%dC%d\n", i, j, i - 1, j + 1); - } - fprintf(File_Ptr1, "\n\n--"); - } - if (RAY != 7) - fprintf(File_Ptr1, "{ No. Of Triangles = %ld }*/\n\n", num_tris); - if (RAY == 7) - fprintf(File_Ptr1, " 0\nENDSEC\n 0\nEOF\n"); - fclose(File_Ptr1); - File_Ptr1 = NULL; - } - if (Targa_Out) - { /* Finish up targa files */ - T_header_24 = 18; /* Reset Targa header size */ - enddisk(); - if (!debugflag && (!T_Safe || error) && Targa_Overlay) - { - dir_remove(workdir, light_name); - rename(targa_temp, light_name); - } - if (!debugflag && Targa_Overlay) - dir_remove(workdir, targa_temp); - } - usr_floatflag &= 1; /* strip second bit */ - error = T_Safe = 0; -} - -static void set_upr_lwr(void) -{ - upr_lwr[0] = (BYTE)(xdots & 0xff); - upr_lwr[1] = (BYTE)(xdots >> 8); - upr_lwr[2] = (BYTE)(ydots & 0xff); - upr_lwr[3] = (BYTE)(ydots >> 8); - line_length1 = 3 * xdots; /* line length @ 3 bytes per pixel */ -} - -static int first_time(int linelen, VECTOR v) -{ - int err; - MATRIX lightm; /* m w/no trans, keeps obj. on screen */ - float twocosdeltatheta; - double xval, yval, zval; /* rotation values */ - /* corners of transformed xdotx by ydots x colors box */ - double xmin, ymin, zmin, xmax, ymax, zmax; - int i, j; - double v_length; - VECTOR origin, direct, tmp; - float theta, theta1, theta2; /* current,start,stop latitude */ - float phi1, phi2; /* current start,stop longitude */ - float deltatheta; /* increment of latitude */ - outln_cleanup = line3d_cleanup; - - calctime = evenoddrow = 0; - /* mark as in-progress, and enable timer display */ - calc_status = CALCSTAT_IN_PROGRESS; - - IAmbient = (unsigned int) (255 * (float) (100 - Ambient) / 100.0); - if (IAmbient < 1) - IAmbient = 1; - - num_tris = 0; - - /* Open file for RAY trace output and write header */ - if (RAY) - { - RAY_Header(); - xxadjust = yyadjust = 0; /* Disable shifting in ray tracing */ - xshift = yshift = 0; - } - - CO_MAX = CO = RO = 0; - - set_upr_lwr(); - error = 0; - - if (g_which_image < 2) - T_Safe = 0; /* Not safe yet to mess with the source image */ - - if (Targa_Out && !((g_glasses_type == 1 || g_glasses_type == 2) - && g_which_image == 2)) - { - if (Targa_Overlay) - { - /* Make sure target file is a supportable Targa File */ - if (targa_validate(light_name)) - return -1; - } - else - { - check_writefile(light_name, ".tga"); - if (startdisk1(light_name, NULL, 0)) /* Open new file */ - return -1; - } - } - - rand_factor = 14 - RANDOMIZE; - - zcoord = filecolors; - - if ((err=line3dmem()) != 0) - return err; - - - /* get scale factors */ - sclx = XSCALE / 100.0; - scly = YSCALE / 100.0; - if (ROUGH) - sclz = -ROUGH / 100.0; - else - rscale = sclz = -0.0001; /* if rough=0 make it very flat but plot - * something */ - - /* aspect ratio calculation - assume screen is 4 x 3 */ - aspect = (double) xdots *.75 / (double) ydots; - - if (SPHERE == FALSE) /* skip this slow stuff in sphere case */ - { - /*********************************************************************/ - /* What is done here is to create a single matrix, m, which has */ - /* scale, rotation, and shift all combined. This allows us to use */ - /* a single matrix to transform any point. Additionally, we create */ - /* two perspective vectors. */ - /* */ - /* Start with a unit matrix. Add scale and rotation. Then calculate */ - /* the perspective vectors. Finally add enough translation to center */ - /* the final image plus whatever shift the user has set. */ - /*********************************************************************/ - - /* start with identity */ - identity(m); - identity(lightm); - - /* translate so origin is in center of box, so that when we rotate */ - /* it, we do so through the center */ - trans((double) xdots / (-2.0), (double) ydots / (-2.0), - (double) zcoord / (-2.0), m); - trans((double) xdots / (-2.0), (double) ydots / (-2.0), - (double) zcoord / (-2.0), lightm); - - /* apply scale factors */ - scale(sclx, scly, sclz, m); - scale(sclx, scly, sclz, lightm); - - /* rotation values - converting from degrees to radians */ - xval = XROT / 57.29577; - yval = YROT / 57.29577; - zval = ZROT / 57.29577; - - if (RAY) - { - xval = yval = zval = 0; - } - - xrot(xval, m); - xrot(xval, lightm); - yrot(yval, m); - yrot(yval, lightm); - zrot(zval, m); - zrot(zval, lightm); - - /* Find values of translation that make all x,y,z negative */ - /* m current matrix */ - /* 0 means don't show box */ - /* returns minimum and maximum values of x,y,z in fractal */ - corners(m, 0, &xmin, &ymin, &zmin, &xmax, &ymax, &zmax); - } - - /* perspective 3D vector - lview[2] == 0 means no perspective */ - - /* set perspective flag */ - persp = 0; - if (ZVIEWER != 0) - { - persp = 1; - if (ZVIEWER < 80) /* force float */ - usr_floatflag |= 2; /* turn on second bit */ - } - - /* set up view vector, and put viewer in center of screen */ - lview[0] = xdots >> 1; - lview[1] = ydots >> 1; - - /* z value of user's eye - should be more negative than extreme negative - * part of image */ - if (SPHERE) /* sphere case */ - lview[2] = -(long) ((double) ydots * (double) ZVIEWER / 100.0); - else /* non-sphere case */ - lview[2] = (long) ((zmin - zmax) * (double) ZVIEWER / 100.0); - - view[0] = lview[0]; - view[1] = lview[1]; - view[2] = lview[2]; - lview[0] = lview[0] << 16; - lview[1] = lview[1] << 16; - lview[2] = lview[2] << 16; - - if (SPHERE == FALSE) /* sphere skips this */ - { - /* translate back exactly amount we translated earlier plus enough to - * center image so maximum values are non-positive */ - trans(((double) xdots - xmax - xmin) / 2, - ((double) ydots - ymax - ymin) / 2, -zmax, m); - - /* Keep the box centered and on screen regardless of shifts */ - trans(((double) xdots - xmax - xmin) / 2, - ((double) ydots - ymax - ymin) / 2, -zmax, lightm); - - trans((double) (xshift), (double) (-yshift), 0.0, m); - - /* matrix m now contains ALL those transforms composed together !! - * convert m to long integers shifted 16 bits */ - for (i = 0; i < 4; i++) - for (j = 0; j < 4; j++) - llm[i][j] = (long) (m[i][j] * 65536.0); - - } - else - /* sphere stuff goes here */ - { - /* Sphere is on side - north pole on right. Top is -90 degrees - * latitude; bottom 90 degrees */ - - /* Map X to this LATITUDE range */ - theta1 = (float) (THETA1 * PI / 180.0); - theta2 = (float) (THETA2 * PI / 180.0); - - /* Map Y to this LONGITUDE range */ - phi1 = (float) (PHI1 * PI / 180.0); - phi2 = (float) (PHI2 * PI / 180.0); - - theta = theta1; - - /*********************************************************************/ - /* Thanks to Hugh Bray for the following idea: when calculating */ - /* a table of evenly spaced sines or cosines, only a few initial */ - /* values need be calculated, and the remaining values can be */ - /* gotten from a derivative of the sine/cosine angle sum formula */ - /* at the cost of one multiplication and one addition per value! */ - /* */ - /* This idea is applied once here to get a complete table for */ - /* latitude, and near the bottom of this routine to incrementally */ - /* calculate longitude. */ - /* */ - /* Precalculate 2*cos(deltaangle), sin(start) and sin(start+delta). */ - /* Then apply recursively: */ - /* sin(angle+2*delta) = sin(angle+delta) * 2cosdelta - sin(angle) */ - /* */ - /* Similarly for cosine. Neat! */ - /*********************************************************************/ - - deltatheta = (float) (theta2 - theta1) / (float) linelen; - - /* initial sin,cos theta */ - sinthetaarray[0] = (float) sin((double) theta); - costhetaarray[0] = (float) cos((double) theta); - sinthetaarray[1] = (float) sin((double) (theta + deltatheta)); - costhetaarray[1] = (float) cos((double) (theta + deltatheta)); - - /* sin,cos delta theta */ - twocosdeltatheta = (float) (2.0 * cos((double) deltatheta)); - - /* build table of other sin,cos with trig identity */ - for (i = 2; i < (int) linelen; i++) - { - sinthetaarray[i] = sinthetaarray[i - 1] * twocosdeltatheta - - sinthetaarray[i - 2]; - costhetaarray[i] = costhetaarray[i - 1] * twocosdeltatheta - - costhetaarray[i - 2]; - } - - /* now phi - these calculated as we go - get started here */ - deltaphi = (float) (phi2 - phi1) / (float) height; - - /* initial sin,cos phi */ - - sinphi = oldsinphi1 = (float) sin((double) phi1); - cosphi = oldcosphi1 = (float) cos((double) phi1); - oldsinphi2 = (float) sin((double) (phi1 + deltaphi)); - oldcosphi2 = (float) cos((double) (phi1 + deltaphi)); - - /* sin,cos delta phi */ - twocosdeltaphi = (float) (2.0 * cos((double) deltaphi)); - - - /* affects how rough planet terrain is */ - if (ROUGH) - rscale = .3 * ROUGH / 100.0; - - /* radius of planet */ - R = (double) (ydots) / 2; - - /* precalculate factor */ - rXrscale = R * rscale; - - sclz = sclx = scly = RADIUS / 100.0; /* Need x,y,z for RAY */ - - /* adjust x scale factor for aspect */ - sclx *= aspect; - - /* precalculation factor used in sphere calc */ - Rfactor = rscale * R / (double) zcoord; - - if (persp) /* precalculate fudge factor */ - { - double radius; - double zview; - double angle; - - xcenter = xcenter << 16; - ycenter = ycenter << 16; - - Rfactor *= 65536.0; - R *= 65536.0; - - /* calculate z cutoff factor attempt to prevent out-of-view surfaces - * from being written */ - zview = -(long) ((double) ydots * (double) ZVIEWER / 100.0); - radius = (double) (ydots) / 2; - angle = atan(-radius / (zview + radius)); - zcutoff = -radius - sin(angle) * radius; - zcutoff *= 1.1; /* for safety */ - zcutoff *= 65536L; - } - } - - /* set fill plot function */ - if (FILLTYPE != 3) - fillplot = interpcolor; - else - { - fillplot = clipcolor; - - if (transparent[0] || transparent[1]) - /* If transparent colors are set */ - fillplot = T_clipcolor;/* Use the transparent plot function */ - } - - /* Both Sphere and Normal 3D */ - direct[0] = light_direction[0] = XLIGHT; - direct[1] = light_direction[1] = -YLIGHT; - direct[2] = light_direction[2] = ZLIGHT; - - /* Needed because sclz = -ROUGH/100 and light_direction is transformed in - * FILLTYPE 6 but not in 5. */ - if (FILLTYPE == 5) - direct[2] = light_direction[2] = -ZLIGHT; - - if (FILLTYPE == 6) /* transform light direction */ - { - /* Think of light direction as a vector with tail at (0,0,0) and head - * at (light_direction). We apply the transformation to BOTH head and - * tail and take the difference */ - - v[0] = 0.0; - v[1] = 0.0; - v[2] = 0.0; - vmult(v, m, v); - vmult(light_direction, m, light_direction); - - for (i = 0; i < 3; i++) - light_direction[i] -= v[i]; - } - normalize_vector(light_direction); - - if (preview && showbox) - { - normalize_vector(direct); - - /* move light vector to be more clear with grey scale maps */ - origin[0] = (3 * xdots) / 16; - origin[1] = (3 * ydots) / 4; - if (FILLTYPE == 6) - origin[1] = (11 * ydots) / 16; - - origin[2] = 0.0; - - v_length = min(xdots, ydots) / 2; - if (persp && ZVIEWER <= P) - v_length *= (long) (P + 600) / ((long) (ZVIEWER + 600) * 2); - - /* Set direct[] to point from origin[] in direction of untransformed - * light_direction (direct[]). */ - for (i = 0; i < 3; i++) - direct[i] = origin[i] + direct[i] * v_length; - - /* center light box */ - for (i = 0; i < 2; i++) - { - tmp[i] = (direct[i] - origin[i]) / 2; - origin[i] -= tmp[i]; - direct[i] -= tmp[i]; - } - - /* Draw light source vector and box containing it, draw_light_box will - * transform them if necessary. */ - draw_light_box(origin, direct, lightm); - /* draw box around original field of view to help visualize effect of - * rotations 1 means show box - xmin etc. do nothing here */ - if (!SPHERE) - corners(m, 1, &xmin, &ymin, &zmin, &xmax, &ymax, &zmax); - } - - /* bad has values caught by clipping */ - f_bad.x = (float) (bad.x = bad_value); - f_bad.y = (float) (bad.y = bad_value); - f_bad.color = (float) (bad.color = bad_value); - for (i = 0; i < (int) linelen; i++) - { - lastrow[i] = bad; - f_lastrow[i] = f_bad; - } - got_status = 3; - return 0; -} /* end of once-per-image intializations */ - -static int line3dmem(void) -{ - /*********************************************************************/ - /* Memory allocation - assumptions - a 64K segment starting at */ - /* extraseg has been grabbed. It may have other purposes elsewhere, */ - /* but it is assumed that it is totally free for use here. Our */ - /* strategy is to assign all the pointers needed here to various*/ - /* spots in the extra segment, depending on the pixel dimensions of */ - /* the video mode, and check whether we have run out. There is */ - /* basically one case where the extra segment is not big enough */ - /* -- SPHERE mode with a fill type that uses putatriangle() (array */ - /* minmax_x) at the largest legal resolution of MAXPIXELSxMAXPIXELS */ - /* or thereabouts. In that case we use farmemalloc to grab memory */ - /* for minmax_x. This memory is never freed. */ - /*********************************************************************/ - long check_extra; /* keep track ofd extraseg array use */ - - /* lastrow stores the previous row of the original GIF image for - the purpose of filling in gaps with triangle procedure */ - /* first 8k of extraseg now used in decoder TW 3/95 */ - /* TODO: allocate real memory, not reuse shared segment */ - lastrow = (struct point *) malloc(sizeof(struct point)*xdots); - - check_extra = sizeof(*lastrow) * xdots; - if (SPHERE) - { - sinthetaarray = (float *) (lastrow + xdots); - check_extra += sizeof(*sinthetaarray) * xdots; - costhetaarray = (float *) (sinthetaarray + xdots); - check_extra += sizeof(*costhetaarray) * xdots; - f_lastrow = (struct f_point *) (costhetaarray + xdots); - } - else - { - f_lastrow = (struct f_point *) (lastrow + xdots); - } - check_extra += sizeof(*f_lastrow) * (xdots); - if (pot16bit) - { - fraction = (BYTE *) (f_lastrow + xdots); - check_extra += sizeof(*fraction) * xdots; - } - minmax_x = (struct minmax *) NULL; - - /* these fill types call putatriangle which uses minmax_x */ - if (FILLTYPE == 2 || FILLTYPE == 3 || FILLTYPE == 5 || FILLTYPE == 6) - { - /* end of arrays if we use extra segement */ - check_extra += sizeof(struct minmax) * ydots; - if (check_extra > (1L << 16)) /* run out of extra segment? */ - { - static struct minmax *got_mem = NULL; - if (debugflag == 2222) - stopmsg(0,"malloc minmax"); - /* not using extra segment so decrement check_extra */ - check_extra -= sizeof(struct minmax) * ydots; - if (got_mem == NULL) - got_mem = (struct minmax *) (malloc(OLDMAXPIXELS * - sizeof(struct minmax))); - if (got_mem) - minmax_x = got_mem; - else - return -1; - } - else /* ok to use extra segment */ - { - if (pot16bit) - minmax_x = (struct minmax *) (fraction + xdots); - else - minmax_x = (struct minmax *) (f_lastrow + xdots); - } - } - if (debugflag == 2222 || check_extra > (1L << 16)) - { - char tmpmsg[70]; - sprintf(tmpmsg, "used %ld of extra segment", check_extra); - stopmsg(STOPMSG_NO_BUZZER, tmpmsg); - } - return 0; -} diff --git a/fractint/common/loadfdos.c b/fractint/common/loadfdos.c deleted file mode 100644 index 8f7b4f8f4..000000000 --- a/fractint/common/loadfdos.c +++ /dev/null @@ -1,510 +0,0 @@ -/* - loadfdos.c - subroutine of loadfile.c (read_overlay) which sets - up video (mode, screen size). - This module is linked as an overlay, should only be called from loadfile.c - - This code was split to a separate module to isolate the DOS only aspects - of loading an image. get_video_mode should return with: - return code 0 for ok, -1 for error or cancelled by user - video parameters setup for the mainline, in the dos case this means - setting g_init_mode to video mode, based on this fractint.c will set up - for and call setvideomode - set viewwindow on if file going to be loaded into a view smaller than - physical screen, in this case also set viewreduction, viewxdots, - viewydots, and finalaspectratio - set skipxdots and skipydots, to 0 if all pixels are to be loaded, - to 1 for every 2nd pixel, 2 for every 3rd, etc - - In WinFract, at least initially, get_video_mode can do just the - following: - set overall image x & y dimensions (sxdots and sydots) to filexdots - and fileydots (note that filecolors is the number of colors in the - gif, not sure if that is of any use...) - if current window smaller than new sxdots and sydots, use scroll bars, - if larger perhaps reduce the window size? whatever - set viewwindow to 0 (no need? it always is for now in windows vsn?) - set finalaspectratio to .75 (ditto?) - set skipxdots and skipydots to 0 - return 0 - -*/ - -#include - /* see Fractint.c for a description of the "include" hierarchy */ -#include "port.h" -#include "prototyp.h" -#include "helpdefs.h" - -/* routines in this module */ - -#ifndef XFRACT -static int vidcompare(VOIDCONSTPTR ,VOIDCONSTPTR ); -static void format_item(int,char *); -static int check_modekey(int,int); -static void format_vid_inf(int i,char *err,char *buf); -#endif -static double vid_aspect(int tryxdots,int tryydots); - -struct vidinf { - int entnum; /* g_video_entry subscript */ - unsigned flags; /* flags for sort's compare, defined below */ - }; -/* defines for flags; done this way instead of bit union to ensure ordering; - these bits represent the sort sequence for video mode list */ -#define VI_EXACT 0x8000 /* unless the one and only exact match */ -#define VI_NOKEY 512 /* if no function key assigned */ -#define VI_SSMALL 128 /* screen smaller than file's screen */ -#define VI_SBIG 64 /* screen bigger than file's screen */ -#define VI_VSMALL 32 /* screen smaller than file's view */ -#define VI_VBIG 16 /* screen bigger than file's view */ -#define VI_CSMALL 8 /* mode has too few colors */ -#define VI_CBIG 4 /* mode has excess colors */ -#define VI_ASPECT 1 /* aspect ratio bad */ - -#ifndef XFRACT -static int vidcompare(VOIDCONSTPTR p1,VOIDCONSTPTR p2) -{ - struct vidinf CONST *ptr1,*ptr2; - ptr1 = (struct vidinf CONST *)p1; - ptr2 = (struct vidinf CONST *)p2; - if (ptr1->flags < ptr2->flags) return(-1); - if (ptr1->flags > ptr2->flags) return(1); - if (g_video_table[ptr1->entnum].keynum < g_video_table[ptr2->entnum].keynum) return(-1); - if (g_video_table[ptr1->entnum].keynum > g_video_table[ptr2->entnum].keynum) return(1); - if (ptr1->entnum < ptr2->entnum) return(-1); - return(1); -} - -static void format_vid_inf(int i,char *err,char *buf) -{ - char kname[5]; - memcpy((char *)&g_video_entry,(char *)&g_video_table[i], - sizeof(g_video_entry)); - vidmode_keyname(g_video_entry.keynum,kname); - sprintf(buf,"%-5s %-25s %-4s %5d %5d %3d %-25s", /* 78 chars */ - kname, g_video_entry.name, err, - g_video_entry.xdots, g_video_entry.ydots, - g_video_entry.colors, g_video_entry.comment); - g_video_entry.xdots = 0; /* so tab_display knows to display nothing */ -} -#endif - -static double vid_aspect(int tryxdots,int tryydots) -{ /* calc resulting aspect ratio for specified dots in current mode */ - return (double)tryydots / (double)tryxdots - * (double)g_video_entry.xdots / (double)g_video_entry.ydots - * screenaspect; - } - -#ifndef XFRACT -static struct vidinf *vidptr; -#endif - -int get_video_mode(struct fractal_info *info,struct ext_blk_3 *blk_3_info) -{ - struct vidinf vid[MAXVIDEOMODES]; - int i, j; - int gotrealmode; - double ftemp,ftemp2; - unsigned tmpflags; - - int tmpxdots,tmpydots; - float tmpreduce; -#ifndef XFRACT - char *nameptr; - int *attributes; - int oldhelpmode; -#endif - VIDEOINFO *vident; - - g_init_mode = -1; - - /* try to find exact match for vid mode */ - for (i = 0; i < g_video_table_len; ++i) - { - vident = &g_video_table[i]; - if (info->xdots == vident->xdots && info->ydots == vident->ydots - && filecolors == vident->colors) - { - g_init_mode = i; - break; - } - } - - /* exit in makepar mode if no exact match of video mode in file */ - if (*s_makepar == '\0' && g_init_mode == -1) - return 0; - - if (g_init_mode == -1) /* try to find very good match for vid mode */ - { - for (i = 0; i < g_video_table_len; ++i) - { - vident = &g_video_table[i]; - if (info->xdots == vident->xdots && info->ydots == vident->ydots - && filecolors == vident->colors) - { - g_init_mode = i; - break; - } - } - } - - /* setup table entry for each vid mode, flagged for how well it matches */ - for (i = 0; i < g_video_table_len; ++i) - { - memcpy((char *)&g_video_entry, (char *)&g_video_table[i], - sizeof(g_video_entry)); - tmpflags = VI_EXACT; - if (g_video_entry.keynum == 0) - { - tmpflags |= VI_NOKEY; - } - if (info->xdots > g_video_entry.xdots || info->ydots > g_video_entry.ydots) - { - tmpflags |= VI_SSMALL; - } - else if (info->xdots < g_video_entry.xdots || info->ydots < g_video_entry.ydots) - { - tmpflags |= VI_SBIG; - } - if (filexdots > g_video_entry.xdots || fileydots > g_video_entry.ydots) - { - tmpflags |= VI_VSMALL; - } - else if (filexdots < g_video_entry.xdots || fileydots < g_video_entry.ydots) - { - tmpflags |= VI_VBIG; - } - if (filecolors > g_video_entry.colors) - { - tmpflags |= VI_CSMALL; - } - if (filecolors < g_video_entry.colors) - { - tmpflags |= VI_CBIG; - } - if (i == g_init_mode) - { - tmpflags -= VI_EXACT; - } - if (fileaspectratio != 0 && (tmpflags & VI_VSMALL) == 0) - { - ftemp = vid_aspect(filexdots, fileydots); - if (ftemp < fileaspectratio * 0.98 || - ftemp > fileaspectratio * 1.02) - { - tmpflags |= VI_ASPECT; - } - } - vid[i].entnum = i; - vid[i].flags = tmpflags; - } - - if (fastrestore && !askvideo) - { - g_init_mode = g_adapter; - } - -#ifndef XFRACT - gotrealmode = 0; - if ((g_init_mode < 0 || (askvideo && !initbatch)) && *s_makepar != '\0') - { - /* no exact match or (askvideo=yes and batch=no), and not - in makepar mode, talk to user */ - - qsort(vid, g_video_table_len, sizeof(vid[0]), vidcompare); /* sort modes */ - - attributes = (int *)&dstack[1000]; - for (i = 0; i < g_video_table_len; ++i) - { - attributes[i] = 1; - } - vidptr = &vid[0]; /* for format_item */ - - /* format heading */ - if (info->info_id[0] == 'G') - { - strcpy(temp1, " Non-fractal GIF"); - } - else - { - nameptr = curfractalspecific->name; - if (*nameptr == '*') - { - ++nameptr; - } - if (display3d) - { - nameptr = "3D Transform"; - } - if ((!strcmp(nameptr, "formula")) || - (!strcmp(nameptr, "lsystem")) || - (!strncmp(nameptr, "ifs", 3))) /* for ifs and ifs3d */ - { - sprintf(temp1, "Type: %s -> %s", nameptr, blk_3_info->form_name); - } - else - { - sprintf(temp1, "Type: %s", nameptr); - } - } - sprintf((char *)dstack, "File: %-44s %d x %d x %d\n%-52s", - readname, filexdots, fileydots, filecolors, temp1); - if (info->info_id[0] != 'G') - { - if (save_system) - { - strcat((char *)dstack, "WinFract "); - } - sprintf(temp1, "v%d.%01d", save_release/100, (save_release%100)/10); - if (save_release%100) - { - i = (int) strlen(temp1); - temp1[i] = (char)((save_release%10) + '0'); - temp1[i+1] = 0; - } - if (save_system == 0 && save_release <= 1410) - { - strcat(temp1, " or earlier"); - } - strcat((char *)dstack, temp1); - } - strcat((char *)dstack, "\n"); - if (info->info_id[0] != 'G' && save_system == 0) - { - if (g_init_mode < 0) - { - strcat((char *)dstack, "Saved in unknown video mode."); - } - else - { - format_vid_inf(g_init_mode, "", temp1); - strcat((char *)dstack, temp1); - } - } - if (fileaspectratio != 0 && fileaspectratio != screenaspect) - { - strcat((char *)dstack, - "\nWARNING: non-standard aspect ratio; loading will change your iew settings"); - } - strcat((char *)dstack, "\n"); - /* set up instructions */ - strcpy(temp1, "Select a video mode. Use the cursor keypad to move the pointer.\n" - "Press ENTER for selected mode, or use a video mode function key.\n" - "Press F1 for help, "); - if (info->info_id[0] != 'G') - { - strcat(temp1, "TAB for fractal information, "); - } - strcat(temp1, "ESCAPE to back out."); - - oldhelpmode = helpmode; - helpmode = HELPLOADFILE; - i = fullscreen_choice(0, (char *) dstack, - "key...name......................err...xdot..ydot.clr.comment..................", - temp1, g_video_table_len, NULL, attributes, - 1, 13, 78, 0, format_item, NULL, NULL, check_modekey); - helpmode = oldhelpmode; - if (i == -1) - { - return -1; - } - if (i < 0) /* returned -100 - g_video_table entry number */ - { - g_init_mode = -100 - i; - gotrealmode = 1; - } - else - { - g_init_mode = vid[i].entnum; - } - } -#else - g_init_mode = 0; - j = g_video_table[0].keynum; - gotrealmode = 0; -#endif - - if (gotrealmode == 0) /* translate from temp table to permanent */ - { - if ((j = g_video_table[i=g_init_mode].keynum) != 0) - { - for (g_init_mode = 0; g_init_mode < MAXVIDEOMODES-1; ++g_init_mode) - { - if (g_video_table[g_init_mode].keynum == j) - { - break; - } - } - if (g_init_mode >= MAXVIDEOMODES-1) - { - j = 0; - } - } - if (j == 0) /* mode has no key, add to reserved slot at end */ - { - memcpy((char *)&g_video_table[g_init_mode=MAXVIDEOMODES-1], - (char *)&g_video_table[i], sizeof(*g_video_table)); - } - } - - /* ok, we're going to return with a video mode */ - memcpy((char *)&g_video_entry, (char *)&g_video_table[g_init_mode], - sizeof(g_video_entry)); - - if (viewwindow && - filexdots == g_video_entry.xdots && fileydots == g_video_entry.ydots) - { - /* pull image into a view window */ - if (calc_status != CALCSTAT_COMPLETED) /* if not complete */ - { - calc_status = CALCSTAT_PARAMS_CHANGED; /* can't resume anyway */ - } - if (viewxdots) - { - viewreduction = (float) (g_video_entry.xdots / viewxdots); - viewxdots = viewydots = 0; /* easier to use auto reduction */ - } - viewreduction = (float)((int)(viewreduction + 0.5)); /* need integer value */ - skipxdots = skipydots = (short)(viewreduction - 1); - return 0; - } - - skipxdots = skipydots = 0; /* set for no reduction */ - if (g_video_entry.xdots < filexdots || g_video_entry.ydots < fileydots) - { - /* set up to load only every nth pixel to make image fit */ - if (calc_status != CALCSTAT_COMPLETED) /* if not complete */ - { - calc_status = CALCSTAT_PARAMS_CHANGED; /* can't resume anyway */ - } - skipxdots = skipydots = 1; - while (skipxdots * g_video_entry.xdots < filexdots) - { - ++skipxdots; - } - while (skipydots * g_video_entry.ydots < fileydots) - { - ++skipydots; - } - i = j = 0; - for (;;) - { - tmpxdots = (filexdots + skipxdots - 1) / skipxdots; - tmpydots = (fileydots + skipydots - 1) / skipydots; - /* reduce further if that improves aspect */ - if ((ftemp = vid_aspect(tmpxdots, tmpydots)) > fileaspectratio) - { - if (j) - { - break; /* already reduced x, don't reduce y */ - } - ftemp2 = vid_aspect(tmpxdots, (fileydots+skipydots)/(skipydots+1)); - if (ftemp2 < fileaspectratio && - ftemp/fileaspectratio *0.9 <= fileaspectratio/ftemp2) - { - break; /* further y reduction is worse */ - } - ++skipydots; - ++i; - } - else - { - if (i) - { - break; /* already reduced y, don't reduce x */ - } - ftemp2 = vid_aspect((filexdots+skipxdots)/(skipxdots+1), tmpydots); - if (ftemp2 > fileaspectratio && - fileaspectratio/ftemp *0.9 <= ftemp2/fileaspectratio) - { - break; /* further x reduction is worse */ - } - ++skipxdots; - ++j; - } - } - filexdots = tmpxdots; - fileydots = tmpydots; - --skipxdots; - --skipydots; - } - - if ((finalaspectratio = fileaspectratio) == 0) /* assume display correct */ - { - finalaspectratio = (float)vid_aspect(filexdots, fileydots); - } - if (finalaspectratio >= screenaspect-0.02 - && finalaspectratio <= screenaspect+0.02) - { - finalaspectratio = screenaspect; - } - i = (int)(finalaspectratio * 1000.0 + 0.5); - finalaspectratio = (float)(i/1000.0); /* chop precision to 3 decimals */ - - /* setup view window stuff */ - viewwindow = viewxdots = viewydots = 0; - if (filexdots != g_video_entry.xdots || fileydots != g_video_entry.ydots) - { - /* image not exactly same size as screen */ - viewwindow = 1; - ftemp = finalaspectratio - * (double)g_video_entry.ydots / (double)g_video_entry.xdots - / screenaspect; - if (finalaspectratio <= screenaspect) - { - i = (int)((double)g_video_entry.xdots / (double)filexdots * 20.0 + 0.5); - tmpreduce = (float)(i/20.0); /* chop precision to nearest .05 */ - i = (int)((double)g_video_entry.xdots / tmpreduce + 0.5); - j = (int)((double)i * ftemp + 0.5); - } - else - { - i = (int)((double)g_video_entry.ydots / (double)fileydots * 20.0 + 0.5); - tmpreduce = (float)(i/20.0); /* chop precision to nearest .05 */ - j = (int)((double)g_video_entry.ydots / tmpreduce + 0.5); - i = (int)((double)j / ftemp + 0.5); - } - if (i != filexdots || j != fileydots) /* too bad, must be explicit */ - { - viewxdots = filexdots; - viewydots = fileydots; - } - else - { - viewreduction = tmpreduce; /* ok, this works */ - } - } - if (*s_makepar && !fastrestore && !initbatch && - (fabs(finalaspectratio - screenaspect) > .00001 || viewxdots != 0)) - { - stopmsg(STOPMSG_NO_BUZZER, - "Warning: iew parameters are being set to non-standard values.\n" - "Remember to reset them when finished with this image!"); - } - return 0; -} - -#ifndef XFRACT -static void format_item(int choice,char *buf) -{ - char errbuf[10]; - unsigned tmpflags; - errbuf[0] = 0; - tmpflags = vidptr[choice].flags; - if (tmpflags & (VI_VSMALL+VI_CSMALL+VI_ASPECT)) strcat(errbuf,"*"); - if (tmpflags & VI_VSMALL) strcat(errbuf,"R"); - if (tmpflags & VI_CSMALL) strcat(errbuf,"C"); - if (tmpflags & VI_ASPECT) strcat(errbuf,"A"); - if (tmpflags & VI_VBIG) strcat(errbuf,"v"); - if (tmpflags & VI_CBIG) strcat(errbuf,"c"); - format_vid_inf(vidptr[choice].entnum,errbuf,buf); -} - -static int check_modekey(int curkey,int choice) -{ - int i; - i=choice; /* avoid warning */ - return (((i = check_vidmode_key(0,curkey)) >= 0) ? -100-i : 0); -} -#endif diff --git a/fractint/common/loadfile.c b/fractint/common/loadfile.c deleted file mode 100644 index e0796f6d5..000000000 --- a/fractint/common/loadfile.c +++ /dev/null @@ -1,2113 +0,0 @@ -/* - loadfile.c - load an existing fractal image, control level -*/ - -#include -#include -#include - /* see Fractint.c for a description of the "include" hierarchy */ -#include "port.h" -#include "prototyp.h" -#include "fractype.h" -#include "helpdefs.h" -#include "targa_lc.h" -#include "drivers.h" - -/* routines in this module */ - -static int find_fractal_info(char *,struct fractal_info *, - struct ext_blk_2 *, - struct ext_blk_3 *, - struct ext_blk_4 *, - struct ext_blk_5 *, - struct ext_blk_6 *, - struct ext_blk_7 *); -static void load_ext_blk(char *loadptr,int loadlen); -static void skip_ext_blk(int *,int *); -static void backwardscompat(struct fractal_info *info); -static int fix_bof(void); -static int fix_period_bof(void); - -int filetype; -int loaded3d; -static FILE *fp; -int fileydots, filexdots, filecolors; -float fileaspectratio; -short skipxdots,skipydots; /* for decoder, when reducing image */ -int bad_outside = 0; -int ldcheck = 0; - -int read_overlay() /* read overlay/3D files, if reqr'd */ -{ - struct fractal_info read_info; - char oldfloatflag; - char msg[110]; - struct ext_blk_2 blk_2_info; - struct ext_blk_3 blk_3_info; - struct ext_blk_4 blk_4_info; - struct ext_blk_5 blk_5_info; - struct ext_blk_6 blk_6_info; - struct ext_blk_7 blk_7_info; - - showfile = 1; /* for any abort exit, pretend done */ - g_init_mode = -1; /* no viewing mode set yet */ - oldfloatflag = usr_floatflag; - loaded3d = 0; - if (fastrestore) - { - viewwindow = 0; - } - if (has_ext(readname) == NULL) - { - strcat(readname, ".gif"); - } - - if (find_fractal_info(readname, &read_info, &blk_2_info, &blk_3_info, - &blk_4_info, &blk_5_info, &blk_6_info, &blk_7_info)) - { - /* didn't find a useable file */ - sprintf(msg, "Sorry, %s isn't a file I can decode.", readname); - stopmsg(0, msg); - return -1; - } - - maxit = read_info.iterationsold; - fractype = read_info.fractal_type; - if (fractype < 0 || fractype >= num_fractal_types) - { - sprintf(msg, "Warning: %s has a bad fractal type; using 0", readname); - fractype = 0; - } - curfractalspecific = &fractalspecific[fractype]; - xxmin = read_info.xmin; - xxmax = read_info.xmax; - yymin = read_info.ymin; - yymax = read_info.ymax; - param[0] = read_info.creal; - param[1] = read_info.cimag; - save_release = 1100; /* unless we find out better later on */ - - invert = 0; - if (read_info.version > 0) - { - param[2] = read_info.parm3; - roundfloatd(¶m[2]); - param[3] = read_info.parm4; - roundfloatd(¶m[3]); - potparam[0] = read_info.potential[0]; - potparam[1] = read_info.potential[1]; - potparam[2] = read_info.potential[2]; - if (*s_makepar == '\0') - { - colors = read_info.colors; - } - potflag = (potparam[0] != 0.0); - rflag = read_info.rflag; - rseed = read_info.rseed; - inside = read_info.inside; - LogFlag = read_info.logmapold; - inversion[0] = read_info.invert[0]; - inversion[1] = read_info.invert[1]; - inversion[2] = read_info.invert[2]; - if (inversion[0] != 0.0) - { - invert = 3; - } - decomp[0] = read_info.decomp[0]; - decomp[1] = read_info.decomp[1]; - usr_biomorph = read_info.biomorph; - forcesymmetry = read_info.symmetry; - } - - if (read_info.version > 1) - { - save_release = 1200; - if (!display3d - && (read_info.version <= 4 || read_info.flag3d > 0 - || (curfractalspecific->flags & PARMS3D) )) - { - int i; - for (i = 0; i < 16; i++) - { - init3d[i] = read_info.init3d[i]; - } - previewfactor = read_info.previewfactor; - xtrans = read_info.xtrans; - ytrans = read_info.ytrans; - red_crop_left = read_info.red_crop_left; - red_crop_right = read_info.red_crop_right; - blue_crop_left = read_info.blue_crop_left; - blue_crop_right = read_info.blue_crop_right; - red_bright = read_info.red_bright; - blue_bright = read_info.blue_bright; - xadjust = read_info.xadjust; - g_eye_separation = read_info.eyeseparation; - g_glasses_type = read_info.glassestype; - } - } - - if (read_info.version > 2) - { - save_release = 1300; - outside = read_info.outside; - } - - calc_status = CALCSTAT_PARAMS_CHANGED; /* defaults if version < 4 */ - xx3rd = xxmin; - yy3rd = yymin; - usr_distest = 0; - calctime = 0; - if (read_info.version > 3) - { - save_release = 1400; - xx3rd = read_info.x3rd; - yy3rd = read_info.y3rd; - calc_status = read_info.calc_status; - usr_stdcalcmode = read_info.stdcalcmode; - three_pass = 0; - if (usr_stdcalcmode == 127) - { - three_pass = 1; - usr_stdcalcmode = '3'; - } - usr_distest = read_info.distestold; - usr_floatflag = (char)read_info.floatflag; - bailout = read_info.bailoutold; - calctime = read_info.calctime; - trigndx[0] = read_info.trigndx[0]; - trigndx[1] = read_info.trigndx[1]; - trigndx[2] = read_info.trigndx[2]; - trigndx[3] = read_info.trigndx[3]; - finattract = read_info.finattract; - initorbit.x = read_info.initorbit[0]; - initorbit.y = read_info.initorbit[1]; - useinitorbit = read_info.useinitorbit; - usr_periodicitycheck = read_info.periodicity; - } - - pot16bit = 0; - save_system = 0; - if (read_info.version > 4) - { - pot16bit = read_info.pot16bit; - if (pot16bit) - { - filexdots >>= 1; - } - fileaspectratio = read_info.faspectratio; - if (fileaspectratio < 0.01) /* fix files produced in early v14.1 */ - { - fileaspectratio = screenaspect; - } - save_system = read_info.system; - save_release = read_info.release; /* from fmt 5 on we know real number */ - if (read_info.version == 5 /* except a few early fmt 5 cases: */ - && (save_release <= 0 || save_release >= 4000)) - { - save_release = 1410; - save_system = 0; - } - if (!display3d && read_info.flag3d > 0) - { - loaded3d = 1; - Ambient = read_info.ambient; - RANDOMIZE = read_info.randomize; - haze = read_info.haze; - transparent[0] = read_info.transparent[0]; - transparent[1] = read_info.transparent[1]; - } - } - - rotate_lo = 1; rotate_hi = 255; - distestwidth = 71; - if (read_info.version > 5) - { - rotate_lo = read_info.rotate_lo; - rotate_hi = read_info.rotate_hi; - distestwidth = read_info.distestwidth; - } - - if (read_info.version > 6) - { - param[2] = read_info.dparm3; - param[3] = read_info.dparm4; - } - - if (read_info.version > 7) - { - fillcolor = read_info.fillcolor; - } - - if (read_info.version > 8) - { - mxmaxfp = read_info.mxmaxfp ; - mxminfp = read_info.mxminfp ; - mymaxfp = read_info.mymaxfp ; - myminfp = read_info.myminfp ; - zdots = read_info.zdots ; - originfp = read_info.originfp ; - depthfp = read_info.depthfp ; - heightfp = read_info.heightfp ; - widthfp = read_info.widthfp ; - distfp = read_info.distfp ; - eyesfp = read_info.eyesfp ; - neworbittype = read_info.orbittype ; - juli3Dmode = read_info.juli3Dmode ; - maxfn = (char)read_info.maxfn ; - major_method = (enum Major)read_info.inversejulia >> 8; - minor_method = (enum Minor)read_info.inversejulia & 255; - param[4] = read_info.dparm5; - param[5] = read_info.dparm6; - param[6] = read_info.dparm7; - param[7] = read_info.dparm8; - param[8] = read_info.dparm9; - param[9] = read_info.dparm10; - } - - if (read_info.version < 4 && read_info.version != 0) /* pre-version 14.0? */ - { - backwardscompat(&read_info); /* translate obsolete types */ - if (LogFlag) - { - LogFlag = 2; - } - usr_floatflag = (char) (curfractalspecific->isinteger ? 0 : 1); - } - - if (read_info.version < 5 && read_info.version != 0) /* pre-version 15.0? */ - { - if (LogFlag == 2) /* logmap=old changed again in format 5! */ - { - LogFlag = -1; - } - if (decomp[0] > 0 && decomp[1] > 0) - { - bailout = decomp[1]; - } - } - if (potflag) /* in version 15.x and 16.x logmap didn't work with pot */ - { - if (read_info.version == 6 || read_info.version == 7) - { - LogFlag = 0; - } - } - set_trig_pointers(-1); - - if (read_info.version < 9 && read_info.version != 0) /* pre-version 18.0? */ - { - /* forcesymmetry==1000 means we want to force symmetry but don't - know which symmetry yet, will find out in setsymmetry() */ - if (outside == REAL || outside == IMAG || outside == MULT || outside == SUM - || outside == ATAN) - { - if (forcesymmetry == 999) - { - forcesymmetry = 1000; - } - } - } - if (save_release < 1725 && read_info.version != 0) /* pre-version 17.25 */ - { - set_if_old_bif(); /* translate bifurcation types */ - functionpreloaded = 1; - } - - if (read_info.version > 9) - { /* post-version 18.22 */ - bailout = read_info.bailout; /* use long bailout */ - bailoutest = (enum bailouts) read_info.bailoutest; - } - else - { - bailoutest = Mod; - } - setbailoutformula(bailoutest); - - if (read_info.version > 9) - { - /* post-version 18.23 */ - maxit = read_info.iterations; /* use long maxit */ - /* post-version 18.27 */ - old_demm_colors = read_info.old_demm_colors; - } - - if (read_info.version > 10) /* post-version 19.20 */ - { - LogFlag = read_info.logmap; - usr_distest = read_info.distest; - } - - if (read_info.version > 11) /* post-version 19.20, inversion fix */ - { - inversion[0] = read_info.dinvert[0]; - inversion[1] = read_info.dinvert[1]; - inversion[2] = read_info.dinvert[2]; - Log_Fly_Calc = read_info.logcalc; - stoppass = read_info.stoppass; - } - - if (read_info.version > 12) /* post-version 19.60 */ - { - quick_calc = read_info.quick_calc; - closeprox = read_info.closeprox; - if (fractype == FPPOPCORN || fractype == LPOPCORN || - fractype == FPPOPCORNJUL || fractype == LPOPCORNJUL || - fractype == LATOO) - { - functionpreloaded = 1; - } - } - - nobof = 0; - if (read_info.version > 13) /* post-version 20.1.2 */ - { - nobof = read_info.nobof; - } - - /* if (read_info.version > 14) post-version 20.1.12 */ - /* modified saved evolver structure JCO 12JUL01 */ - Log_Auto_Calc = 0; /* make sure it's turned off */ - - orbit_interval = 1; - if (read_info.version > 15) /* post-version 20.3.2 */ - { - orbit_interval = read_info.orbit_interval; - } - - orbit_delay = 0; - math_tol[0] = 0.05; - math_tol[1] = 0.05; - if (read_info.version > 16) /* post-version 20.4.0 */ - { - orbit_delay = read_info.orbit_delay; - math_tol[0] = read_info.math_tol[0]; - math_tol[1] = read_info.math_tol[1]; - } - - backwards_v18(); - backwards_v19(); - backwards_v20(); - - if (display3d) /* PB - a klooge till the meaning of */ - { - usr_floatflag = oldfloatflag; /* floatflag in line3d is clarified */ - } - - if (overlay3d) - { - g_init_mode = g_adapter; /* use previous adapter mode for overlays */ - if (filexdots > xdots || fileydots > ydots) - { - stopmsg(0, "Can't overlay with a larger image"); - g_init_mode = -1; - return -1; - } - } - else - { - int olddisplay3d, i; - char oldfloatflag; - olddisplay3d = display3d; - oldfloatflag = floatflag; - display3d = loaded3d; /* for display during next */ - floatflag = usr_floatflag; /* ditto */ - i = get_video_mode(&read_info, &blk_3_info); -#if defined(_WIN32) - _ASSERTE(_CrtCheckMemory()); -#endif - display3d = olddisplay3d; - floatflag = oldfloatflag; - if (i) - { - if (blk_2_info.got_data == 1) - { - MemoryRelease((U16) blk_2_info.resume_data); - blk_2_info.length = 0; - } - g_init_mode = -1; - return -1; - } - } - - if (display3d) - { - calc_status = CALCSTAT_PARAMS_CHANGED; - fractype = PLASMA; - curfractalspecific = &fractalspecific[PLASMA]; - param[0] = 0; - if (!initbatch) - { - if (get_3d_params() < 0) - { - g_init_mode = -1; - return -1; - } - } - } - - if (resume_info != 0) /* free the prior area if there is one */ - { - MemoryRelease(resume_info); - resume_info = 0; - } - - if (blk_2_info.got_data == 1) - { - resume_info = (U16) blk_2_info.resume_data; - resume_len = blk_2_info.length; - } - - if (blk_3_info.got_data == 1) - { - char *nameptr; - switch (read_info.fractal_type) - { - case LSYSTEM: - nameptr = LName; - break; - - case IFS: - case IFS3D: - nameptr = IFSName; - break; - - default: - nameptr = FormName; - uses_p1 = blk_3_info.uses_p1; - uses_p2 = blk_3_info.uses_p2; - uses_p3 = blk_3_info.uses_p3; - uses_ismand = blk_3_info.uses_ismand; - ismand = blk_3_info.ismand; - uses_p4 = blk_3_info.uses_p4; - uses_p5 = blk_3_info.uses_p5; - break; - } - blk_3_info.form_name[ITEMNAMELEN] = 0; - strcpy(nameptr, blk_3_info.form_name); - /* perhaps in future add more here, check block_len for backward compatibility */ - } - - if (rangeslen) /* free prior ranges */ - { - free(ranges); - ranges = NULL; - rangeslen = 0; - } - - if (blk_4_info.got_data == 1) - { - ranges = (int *) blk_4_info.range_data; - rangeslen = blk_4_info.length; -#ifdef XFRACT - fix_ranges(ranges,rangeslen,1); -#endif - } - - if (blk_5_info.got_data == 1) - { - bf_math = 1; - init_bf_length(read_info.bflength); - memcpy((char *) bfxmin, blk_5_info.apm_data, blk_5_info.length); - free(blk_5_info.apm_data); - } - else - { - bf_math = 0; - } - - if (blk_6_info.got_data == 1) - { - struct evolution_info resume_e_info; - GENEBASE gene[NUMGENES]; - int i; - - /* TODO: MemoryAlloc */ - if (gene_handle == 0) - { - gene_handle = MemoryAlloc((U16) sizeof(gene), 1L, MEMORY); - } - MoveFromMemory((BYTE *)&gene, (U16) sizeof(gene), 1L, 0L, gene_handle); - if (read_info.version < 15) /* This is VERY Ugly! JCO 14JUL01 */ - { - /* Increasing NUMGENES moves ecount in the data structure */ - /* We added 4 to NUMGENES, so ecount is at NUMGENES-4 */ - blk_6_info.ecount = blk_6_info.mutate[NUMGENES - 4]; - } - if (blk_6_info.ecount != blk_6_info.gridsz*blk_6_info.gridsz - && calc_status != CALCSTAT_COMPLETED) - { - calc_status = CALCSTAT_RESUMABLE; - /* TODO: MemoryAlloc */ - if (evolve_handle == 0) - { - evolve_handle = MemoryAlloc((U16) sizeof(resume_e_info), 1L, MEMORY); - } - resume_e_info.paramrangex = blk_6_info.paramrangex; - resume_e_info.paramrangey = blk_6_info.paramrangey; - resume_e_info.opx = blk_6_info.opx; - resume_e_info.opy = blk_6_info.opy; - resume_e_info.odpx = blk_6_info.odpx; - resume_e_info.odpy = blk_6_info.odpy; - resume_e_info.px = blk_6_info.px; - resume_e_info.py = blk_6_info.py; - resume_e_info.sxoffs = blk_6_info.sxoffs; - resume_e_info.syoffs = blk_6_info.syoffs; - resume_e_info.xdots = blk_6_info.xdots; - resume_e_info.ydots = blk_6_info.ydots; - resume_e_info.gridsz = blk_6_info.gridsz; - resume_e_info.evolving = blk_6_info.evolving; - resume_e_info.this_gen_rseed = blk_6_info.this_gen_rseed; - resume_e_info.fiddlefactor = blk_6_info.fiddlefactor; - resume_e_info.ecount = blk_6_info.ecount; - MoveToMemory((BYTE *) &resume_e_info, (U16) sizeof(resume_e_info), 1L, 0L, evolve_handle); - } - else - { - if (evolve_handle != 0) /* Image completed, release it. */ - { - MemoryRelease(evolve_handle); - } - evolve_handle = 0; - calc_status = CALCSTAT_COMPLETED; - } - paramrangex = blk_6_info.paramrangex; - paramrangey = blk_6_info.paramrangey; - opx = newopx = blk_6_info.opx; - opy = newopy = blk_6_info.opy; - odpx = newodpx = (char) blk_6_info.odpx; - odpy = newodpy = (char) blk_6_info.odpy; - px = blk_6_info.px; - py = blk_6_info.py; - sxoffs = blk_6_info.sxoffs; - syoffs = blk_6_info.syoffs; - xdots = blk_6_info.xdots; - ydots = blk_6_info.ydots; - gridsz = blk_6_info.gridsz; - this_gen_rseed = blk_6_info.this_gen_rseed; - fiddlefactor = blk_6_info.fiddlefactor; - evolving = viewwindow = (int) blk_6_info.evolving; - dpx = paramrangex/(gridsz - 1); - dpy = paramrangey/(gridsz - 1); - if (read_info.version > 14) - { - for (i = 0; i < NUMGENES; i++) - { - gene[i].mutate = (int) blk_6_info.mutate[i]; - } - } - else - { - for (i = 0; i < 6; i++) - { - gene[i].mutate = (int) blk_6_info.mutate[i]; - } - for (i = 6; i < 10; i++) - { - gene[i].mutate = 0; - } - for (i = 10; i < NUMGENES; i++) - { - gene[i].mutate = (int) blk_6_info.mutate[i-4]; - } - } - MoveToMemory((BYTE *) &gene, (U16) sizeof(gene), 1L, 0L, gene_handle); - param_history(0); /* store history */ - } - else - { - evolving = FALSE; - } - - if (blk_7_info.got_data == 1) - { - oxmin = blk_7_info.oxmin; - oxmax = blk_7_info.oxmax; - oymin = blk_7_info.oymin; - oymax = blk_7_info.oymax; - ox3rd = blk_7_info.ox3rd; - oy3rd = blk_7_info.oy3rd; - keep_scrn_coords = blk_7_info.keep_scrn_coords; - drawmode = blk_7_info.drawmode; - if (keep_scrn_coords) - { - set_orbit_corners = 1; - } - } - - showfile = 0; /* trigger the file load */ - return 0; -} - -static int find_fractal_info(char *gif_file,struct fractal_info *info, - struct ext_blk_2 *blk_2_info, - struct ext_blk_3 *blk_3_info, - struct ext_blk_4 *blk_4_info, - struct ext_blk_5 *blk_5_info, - struct ext_blk_6 *blk_6_info, - struct ext_blk_7 *blk_7_info) -{ - BYTE gifstart[18]; - char temp1[81]; - int scan_extend, block_type, block_len, data_len; - int fractinf_len; - int hdr_offset; - struct formula_info fload_info; - struct evolution_info eload_info; - struct orbits_info oload_info; - int i, j, k = 0; - - blk_2_info->got_data = 0; /* initialize to no data */ - blk_3_info->got_data = 0; /* initialize to no data */ - blk_4_info->got_data = 0; /* initialize to no data */ - blk_5_info->got_data = 0; /* initialize to no data */ - blk_6_info->got_data = 0; /* initialize to no data */ - blk_7_info->got_data = 0; /* initialize to no data */ - - fp = fopen(gif_file,"rb"); - if (fp==NULL) - return(-1); - fread(gifstart,13,1,fp); - if (strncmp((char *)gifstart,"GIF",3) != 0) { /* not GIF, maybe old .tga? */ - fclose(fp); - return(-1); - } - - filetype = 0; /* GIF */ - GET16(gifstart[6],filexdots); - GET16(gifstart[8],fileydots); - filecolors = 2 << (gifstart[10] & 7); - fileaspectratio = 0; /* unknown */ - if (gifstart[12]) { /* calc reasonably close value from gif header */ - fileaspectratio = (float)((64.0 / ((double)(gifstart[12]) + 15.0)) - * (double)fileydots / (double)filexdots); - if ( fileaspectratio > screenaspect-0.03 - && fileaspectratio < screenaspect+0.03) - fileaspectratio = screenaspect; - } - else - if (fileydots * 4 == filexdots * 3) /* assume the common square pixels */ - fileaspectratio = screenaspect; - - if (*s_makepar == 0 && (gifstart[10] & 0x80)!=0) - { - for (i = 0; i < filecolors; i++) - { - for (j = 0; j < 3; j++) { - if ((k = getc(fp)) < 0) - break; - g_dac_box[i][j] = (BYTE)(k >> 2); - } - if (k < 0) - break; - } - } - - /* Format of .gif extension blocks is: - 1 byte '!', extension block identifier - 1 byte extension block number, 255 - 1 byte length of id, 11 - 11 bytes alpha id, "fractintnnn" with fractint, nnn is secondary id - n * { - 1 byte length of block info in bytes - x bytes block info - } - 1 byte 0, extension terminator - To scan extension blocks, we first look in file at length of fractal_info - (the main extension block) from end of file, looking for a literal known - to be at start of our block info. Then we scan forward a bit, in case - the file is from an earlier fractint vsn with shorter fractal_info. - If fractal_info is found and is from vsn>=14, it includes the total length - of all extension blocks; we then scan them all first to last to load - any optional ones which are present. - Defined extension blocks: - fractint001 header, always present - fractint002 resume info for interrupted resumable image - fractint003 additional formula type info - fractint004 ranges info - fractint005 extended precision parameters - fractint006 evolver params - */ - - memset(info,0,FRACTAL_INFO_SIZE); - fractinf_len = FRACTAL_INFO_SIZE + (FRACTAL_INFO_SIZE+254)/255; - fseek(fp,(long)(-1-fractinf_len),SEEK_END); - /* TODO: revise this to read members one at a time so we get natural alignment - of fields within the FRACTAL_INFO structure for the platform */ - fread(info,1,FRACTAL_INFO_SIZE,fp); - if (strcmp(INFO_ID,info->info_id) == 0) { -#ifdef XFRACT - decode_fractal_info(info,1); -#endif - hdr_offset = -1-fractinf_len; - } else { - /* didn't work 1st try, maybe an older vsn, maybe junk at eof, scan: */ - int offset,i; - char tmpbuf[110]; - hdr_offset = 0; - offset = 80; /* don't even check last 80 bytes of file for id */ - while (offset < fractinf_len+513) { /* allow 512 garbage at eof */ - offset += 100; /* go back 100 bytes at a time */ - fseek(fp,(long)(0-offset),SEEK_END); - fread(tmpbuf,1,110,fp); /* read 10 extra for string compare */ - for (i = 0; i < 100; ++i) - if (!strcmp(INFO_ID,&tmpbuf[i])) { /* found header? */ - strcpy(info->info_id,INFO_ID); - fseek(fp,(long)(hdr_offset=i-offset),SEEK_END); - /* TODO: revise this to read members one at a time so we get natural alignment - of fields within the FRACTAL_INFO structure for the platform */ - fread(info,1,FRACTAL_INFO_SIZE,fp); -#ifdef XFRACT - decode_fractal_info(info,1); -#endif - offset = 10000; /* force exit from outer loop */ - break; - } - } - } - - if (hdr_offset) { /* we found INFO_ID */ - - if (info->version >= 4) { - /* first reload main extension block, reasons: - might be over 255 chars, and thus earlier load might be bad - find exact endpoint, so scan back to start of ext blks works - */ - fseek(fp,(long)(hdr_offset-15),SEEK_END); - scan_extend = 1; - while (scan_extend) { - if (fgetc(fp) != '!' /* if not what we expect just give up */ - || fread(temp1,1,13,fp) != 13 - || strncmp(&temp1[2],"fractint",8)) - break; - temp1[13] = 0; - block_type = atoi(&temp1[10]); /* e.g. "fractint002" */ - switch (block_type) { - case 1: /* "fractint001", the main extension block */ - if (scan_extend == 2) { /* we've been here before, done now */ - scan_extend = 0; - break; - } - load_ext_blk((char *)info,FRACTAL_INFO_SIZE); -#ifdef XFRACT - decode_fractal_info(info,1); -#endif - scan_extend = 2; - /* now we know total extension len, back up to first block */ - fseek(fp,0L-info->tot_extend_len,SEEK_CUR); - break; - case 2: /* resume info */ - skip_ext_blk(&block_len,&data_len); /* once to get lengths */ - /* TODO: MemoryAlloc */ - blk_2_info->resume_data = MemoryAlloc((U16)1,(long)data_len,MEMORY); - if (blk_2_info->resume_data == 0) - info->calc_status = CALCSTAT_NON_RESUMABLE; /* not resumable after all */ - else { - fseek(fp,(long)(0-block_len),SEEK_CUR); - load_ext_blk((char *)block,data_len); - MoveToMemory((BYTE *)block,(U16)1,(long)data_len,0,(U16)blk_2_info->resume_data); - blk_2_info->length = data_len; - blk_2_info->got_data = 1; /* got data */ - } - break; - case 3: /* formula info */ - skip_ext_blk(&block_len,&data_len); /* once to get lengths */ - /* check data_len for backward compatibility */ - fseek(fp,(long)(0-block_len),SEEK_CUR); - load_ext_blk((char *)&fload_info,data_len); - strcpy(blk_3_info->form_name,fload_info.form_name); - blk_3_info->length = data_len; - blk_3_info->got_data = 1; /* got data */ - if (data_len < sizeof(fload_info)) { /* must be old GIF */ - blk_3_info->uses_p1 = 1; - blk_3_info->uses_p2 = 1; - blk_3_info->uses_p3 = 1; - blk_3_info->uses_ismand = 0; - blk_3_info->ismand = 1; - blk_3_info->uses_p4 = 0; - blk_3_info->uses_p5 = 0; - } - else { - blk_3_info->uses_p1 = fload_info.uses_p1; - blk_3_info->uses_p2 = fload_info.uses_p2; - blk_3_info->uses_p3 = fload_info.uses_p3; - blk_3_info->uses_ismand = fload_info.uses_ismand; - blk_3_info->ismand = fload_info.ismand; - blk_3_info->uses_p4 = fload_info.uses_p4; - blk_3_info->uses_p5 = fload_info.uses_p5; - } - break; - case 4: /* ranges info */ - skip_ext_blk(&block_len,&data_len); /* once to get lengths */ - if ((blk_4_info->range_data = (int *)malloc((long)data_len)) != NULL) { - fseek(fp,(long)(0-block_len),SEEK_CUR); - load_ext_blk((char *)blk_4_info->range_data,data_len); - blk_4_info->length = data_len/2; - blk_4_info->got_data = 1; /* got data */ - } - break; - case 5: /* extended precision parameters */ - skip_ext_blk(&block_len,&data_len); /* once to get lengths */ - if ((blk_5_info->apm_data = (char *)malloc((long)data_len)) != NULL) { - fseek(fp,(long)(0-block_len),SEEK_CUR); - load_ext_blk(blk_5_info->apm_data,data_len); - blk_5_info->length = data_len; - blk_5_info->got_data = 1; /* got data */ - } - break; - case 6: /* evolver params */ - skip_ext_blk(&block_len,&data_len); /* once to get lengths */ - fseek(fp,(long)(0-block_len),SEEK_CUR); - load_ext_blk((char *)&eload_info,data_len); - /* XFRACT processing of doubles here */ -#ifdef XFRACT - decode_evolver_info(&eload_info,1); -#endif - blk_6_info->length = data_len; - blk_6_info->got_data = 1; /* got data */ - - blk_6_info->paramrangex = eload_info.paramrangex; - blk_6_info->paramrangey = eload_info.paramrangey; - blk_6_info->opx = eload_info.opx; - blk_6_info->opy = eload_info.opy; - blk_6_info->odpx = (char)eload_info.odpx; - blk_6_info->odpy = (char)eload_info.odpy; - blk_6_info->px = eload_info.px; - blk_6_info->py = eload_info.py; - blk_6_info->sxoffs = eload_info.sxoffs; - blk_6_info->syoffs = eload_info.syoffs; - blk_6_info->xdots = eload_info.xdots; - blk_6_info->ydots = eload_info.ydots; - blk_6_info->gridsz = eload_info.gridsz; - blk_6_info->evolving = eload_info.evolving; - blk_6_info->this_gen_rseed = eload_info.this_gen_rseed; - blk_6_info->fiddlefactor = eload_info.fiddlefactor; - blk_6_info->ecount = eload_info.ecount; - for (i = 0; i < NUMGENES; i++) - blk_6_info->mutate[i] = eload_info.mutate[i]; - break; - case 7: /* orbits parameters */ - skip_ext_blk(&block_len,&data_len); /* once to get lengths */ - fseek(fp,(long)(0-block_len),SEEK_CUR); - load_ext_blk((char *)&oload_info,data_len); - /* XFRACT processing of doubles here */ -#ifdef XFRACT - decode_orbits_info(&oload_info,1); -#endif - blk_7_info->length = data_len; - blk_7_info->got_data = 1; /* got data */ - blk_7_info->oxmin = oload_info.oxmin; - blk_7_info->oxmax = oload_info.oxmax; - blk_7_info->oymin = oload_info.oymin; - blk_7_info->oymax = oload_info.oymax; - blk_7_info->ox3rd = oload_info.ox3rd; - blk_7_info->oy3rd = oload_info.oy3rd; - blk_7_info->keep_scrn_coords= oload_info.keep_scrn_coords; - blk_7_info->drawmode = oload_info.drawmode; - break; - default: - skip_ext_blk(&block_len,&data_len); - } - } - } - - fclose(fp); - fileaspectratio = screenaspect; /* if not >= v15, this is correct */ - return(0); - } - - strcpy(info->info_id, "GIFFILE"); - info->iterations = 150; - info->iterationsold = 150; - info->fractal_type = PLASMA; - info->xmin = -1; - info->xmax = 1; - info->ymin = -1; - info->ymax = 1; - info->x3rd = -1; - info->y3rd = -1; - info->creal = 0; - info->cimag = 0; - info->videomodeax=255; - info->videomodebx=255; - info->videomodecx=255; - info->videomodedx=255; - info->dotmode = 0; - info->xdots = (short)filexdots; - info->ydots = (short)fileydots; - info->colors = (short)filecolors; - info->version = 0; /* this forces lots more init at calling end too */ - - /* zero means we won */ - fclose(fp); - return(0); -} - -static void load_ext_blk(char *loadptr,int loadlen) -{ - int len; - while ((len = fgetc(fp)) > 0) { - while (--len >= 0) { - if (--loadlen >= 0) - *(loadptr++) = (char)fgetc(fp); - else - fgetc(fp); /* discard excess characters */ - } - } -} - -static void skip_ext_blk(int *block_len, int *data_len) -{ - int len; - *data_len = 0; - *block_len = 1; - while ((len = fgetc(fp)) > 0) { - fseek(fp,(long)len,SEEK_CUR); - *data_len += len; - *block_len += len + 1; - } -} - - -/* switch obsolete fractal types to new generalizations */ -static void backwardscompat(struct fractal_info *info) -{ - switch (fractype) { - case LAMBDASINE: - fractype = LAMBDATRIGFP; - trigndx[0] = SIN; - break; - case LAMBDACOS : - fractype = LAMBDATRIGFP; - trigndx[0] = COS; - break; - case LAMBDAEXP : - fractype = LAMBDATRIGFP; - trigndx[0] = EXP; - break; - case MANDELSINE : - fractype = MANDELTRIGFP; - trigndx[0] = SIN; - break; - case MANDELCOS : - fractype = MANDELTRIGFP; - trigndx[0] = COS; - break; - case MANDELEXP : - fractype = MANDELTRIGFP; - trigndx[0] = EXP; - break; - case MANDELSINH : - fractype = MANDELTRIGFP; - trigndx[0] = SINH; - break; - case LAMBDASINH : - fractype = LAMBDATRIGFP; - trigndx[0] = SINH; - break; - case MANDELCOSH : - fractype = MANDELTRIGFP; - trigndx[0] = COSH; - break; - case LAMBDACOSH : - fractype = LAMBDATRIGFP; - trigndx[0] = COSH; - break; - case LMANDELSINE : - fractype = MANDELTRIG; - trigndx[0] = SIN; - break; - case LLAMBDASINE : - fractype = LAMBDATRIG; - trigndx[0] = SIN; - break; - case LMANDELCOS : - fractype = MANDELTRIG; - trigndx[0] = COS; - break; - case LLAMBDACOS : - fractype = LAMBDATRIG; - trigndx[0] = COS; - break; - case LMANDELSINH : - fractype = MANDELTRIG; - trigndx[0] = SINH; - break; - case LLAMBDASINH : - fractype = LAMBDATRIG; - trigndx[0] = SINH; - break; - case LMANDELCOSH : - fractype = MANDELTRIG; - trigndx[0] = COSH; - break; - case LLAMBDACOSH : - fractype = LAMBDATRIG; - trigndx[0] = COSH; - break; - case LMANDELEXP : - fractype = MANDELTRIG; - trigndx[0] = EXP; - break; - case LLAMBDAEXP : - fractype = LAMBDATRIG; - trigndx[0] = EXP; - break; - case DEMM : - fractype = MANDELFP; - usr_distest = (info->ydots - 1) * 2; - break; - case DEMJ : - fractype = JULIAFP; - usr_distest = (info->ydots - 1) * 2; - break; - case MANDELLAMBDA : - useinitorbit = 2; - break; - } - curfractalspecific = &fractalspecific[fractype]; -} - -/* switch old bifurcation fractal types to new generalizations */ -void set_if_old_bif(void) -{ -/* set functions if not set already, may need to check 'functionpreloaded' - before calling this routine. JCO 7/5/92 */ - - switch (fractype) { - case BIFURCATION: - case LBIFURCATION: - case BIFSTEWART: - case LBIFSTEWART: - case BIFLAMBDA: - case LBIFLAMBDA: - set_trig_array(0, "ident"); - break; - - case BIFEQSINPI: - case LBIFEQSINPI: - case BIFADSINPI: - case LBIFADSINPI: - set_trig_array(0, "sin"); - break; - } -} - -/* miscellaneous function variable defaults */ -void set_function_parm_defaults(void) -{ - switch (fractype) - { - case FPPOPCORN: - case LPOPCORN: - case FPPOPCORNJUL: - case LPOPCORNJUL: - set_trig_array(0, "sin"); - set_trig_array(1, "tan"); - set_trig_array(2, "sin"); - set_trig_array(3, "tan"); - break; - case LATOO: - set_trig_array(0, "sin"); - set_trig_array(1, "sin"); - set_trig_array(2, "sin"); - set_trig_array(3, "sin"); - break; - } -} - -void backwards_v18(void) -{ - if (!functionpreloaded) - set_if_old_bif(); /* old bifs need function set, JCO 7/5/92 */ - if (fractype==MANDELTRIG && usr_floatflag==1 - && save_release < 1800 && bailout == 0) - bailout = 2500; - if (fractype==LAMBDATRIG && usr_floatflag==1 - && save_release < 1800 && bailout == 0) - bailout = 2500; -} - -void backwards_v19(void) -{ - if (fractype==MARKSJULIA && save_release < 1825) { - if (param[2] == 0) - param[2] = 2; - else - param[2] += 1; - } - if (fractype==MARKSJULIAFP && save_release < 1825) { - if (param[2] == 0) - param[2] = 2; - else - param[2] += 1; - } - if ((fractype==FORMULA || fractype==FFORMULA) && save_release < 1824) - inversion[0] = inversion[1] = inversion[2] = invert = 0; - if (fix_bof()) - no_mag_calc = 1; /* fractal has old bof60/61 problem with magnitude */ - else - no_mag_calc = 0; - if (fix_period_bof()) - use_old_period = 1; /* fractal uses old periodicity method */ - else - use_old_period = 0; - if (save_release < 1827 && distest) - use_old_distest = 1; /* use old distest code */ - else - use_old_distest = 0; /* use new distest code */ -} - -void backwards_v20(void) -{ /* Fractype == FP type is not seen from PAR file ????? */ - if ((fractype == MANDELFP || fractype == JULIAFP || - fractype == MANDEL || fractype == JULIA) && - (outside <= REAL && outside >= SUM) && save_release <= 1960) - bad_outside = 1; - else - bad_outside = 0; - if ((fractype == FORMULA || fractype == FFORMULA) && - (save_release < 1900 || debugflag == 94)) - ldcheck = 1; - else - ldcheck = 0; - if (inside == EPSCROSS && save_release < 1961) - closeprox = 0.01; - if (!functionpreloaded) - set_function_parm_defaults(); -} - -int check_back(void) { -/* - put the features that need to save the value in save_release for backwards - compatibility in this routine -*/ -int ret = 0; - if (fractype == LYAPUNOV || - fractype == FROTH || fractype == FROTHFP || - fix_bof() || fix_period_bof() || use_old_distest || decomp[0] == 2 || - (fractype == FORMULA && save_release <= 1920) || - (fractype == FFORMULA && save_release <= 1920) || - (LogFlag != 0 && save_release <= 2001) || - (fractype == TRIGSQR && save_release < 1900) || - (inside == STARTRAIL && save_release < 1825) || - (maxit > 32767 && save_release <= 1950) || - (distest && save_release <=1950) || - ((outside <= REAL && outside >= ATAN) && - save_release <= 1960) || - (fractype == FPPOPCORN && save_release <= 1960) || - (fractype == LPOPCORN && save_release <= 1960) || - (fractype == FPPOPCORNJUL && save_release <= 1960) || - (fractype == LPOPCORNJUL && save_release <= 1960) || - (inside == FMODI && save_release <= 2000) || - ((inside == ATANI || outside == ATAN) && save_release <= 2002) || - (fractype == LAMBDATRIGFP && trigndx[0] == EXP && save_release <= 2002) || - ((fractype == JULIBROT || fractype == JULIBROTFP) && - (neworbittype == QUATFP || neworbittype == HYPERCMPLXFP) && - save_release <= 2002) - ) - ret = 1; - return(ret); -} - -static int fix_bof(void) -{ -int ret = 0; - if (inside <= BOF60 && inside >= BOF61 && save_release < 1826) - if ((curfractalspecific->calctype == StandardFractal && - (curfractalspecific->flags & BAILTEST) == 0) || - (fractype==FORMULA || fractype==FFORMULA)) - ret = 1; -return (ret); -} - -static int fix_period_bof(void) -{ -int ret = 0; - if (inside <= BOF60 && inside >= BOF61 && save_release < 1826) - ret = 1; -return (ret); -} - -/* browse code RB*/ - -#define MAX_WINDOWS_OPEN 450 - - struct window { /* for fgetwindow on screen browser */ - struct coords itl; /* screen coordinates */ - struct coords ibl; - struct coords itr; - struct coords ibr; - double win_size; /* box size for drawindow() */ - char name[13]; /* for filename */ - int boxcount; /* bytes of saved screen info */ - }; - -/* prototypes */ -static void drawindow( int, struct window * ); -static char is_visible_window - ( struct window *, struct fractal_info *, struct ext_blk_5 * ); -static void transform( struct dblcoords * ); -static char paramsOK( struct fractal_info * ); -static char typeOK( struct fractal_info *, struct ext_blk_3 * ); -static char functionOK( struct fractal_info *, int ); -static void check_history( char *, char * ); -static void bfsetup_convert_to_screen( void ); -static void bftransform( bf_t, bf_t, struct dblcoords * ); - -char browsename[13]; /* name for browse file */ -U16 browsehandle; -U16 boxxhandle; -U16 boxyhandle; -U16 boxvalueshandle; - -/* here because must be visible inside several routines */ -static struct affine *cvt; -static bf_t bt_a, bt_b, bt_c, bt_d, bt_e, bt_f; -static bf_t n_a, n_b, n_c, n_d, n_e, n_f; -int oldbf_math; - -/* fgetwindow reads all .GIF files and draws window outlines on the screen */ -int fgetwindow(void) - { - struct affine stack_cvt; - struct fractal_info read_info; - struct ext_blk_2 blk_2_info; - struct ext_blk_3 blk_3_info; - struct ext_blk_4 blk_4_info; - struct ext_blk_5 blk_5_info; - struct ext_blk_6 blk_6_info; - struct ext_blk_7 blk_7_info; - time_t thistime,lastime; - char mesg[40],newname[60],oldname[60]; - int c,i,index,done,wincount,toggle,color_of_box; - struct window winlist; - char drive[FILE_MAX_DRIVE]; - char dir[FILE_MAX_DIR]; - char fname[FILE_MAX_FNAME]; - char ext[FILE_MAX_EXT]; - char tmpmask[FILE_MAX_PATH]; - int vid_too_big = 0; - int no_memory = 0; - U16 vidlength; - BYTE *winlistptr = (BYTE *)&winlist; - int saved; -#ifdef XFRACT - U32 blinks; -#endif - - oldbf_math = bf_math; - bf_math = BIGFLT; - if (!oldbf_math) { - int oldcalc_status = calc_status; /* kludge because next sets it = 0 */ - fractal_floattobf(); - calc_status = oldcalc_status; - } - saved = save_stack(); - bt_a = alloc_stack(rbflength+2); - bt_b = alloc_stack(rbflength+2); - bt_c = alloc_stack(rbflength+2); - bt_d = alloc_stack(rbflength+2); - bt_e = alloc_stack(rbflength+2); - bt_f = alloc_stack(rbflength+2); - - if ((vidlength = (U16)(sxdots + sydots)) > (U16)4096) - vid_too_big = 2; - /* 4096 based on 4096B in boxx... max 1/4 pixels plotted, and need words */ - /* 4096 = 10240/2.5 based on size of boxx+boxy+boxvalues */ -#ifdef XFRACT - vidlength = 4; /* Xfractint only needs the 4 corners saved. */ -#endif - /* TODO: MemoryAlloc */ - browsehandle = MemoryAlloc((U16)sizeof(struct window),(long)MAX_WINDOWS_OPEN,MEMORY); - boxxhandle = MemoryAlloc((U16)(vidlength),(long)MAX_WINDOWS_OPEN,MEMORY); - boxyhandle = MemoryAlloc((U16)(vidlength),(long)MAX_WINDOWS_OPEN,MEMORY); - boxvalueshandle = MemoryAlloc((U16)(vidlength>>1),(long)MAX_WINDOWS_OPEN,MEMORY); - if (!browsehandle || !boxxhandle || !boxyhandle || !boxvalueshandle) - no_memory = 1; - - /* set up complex-plane-to-screen transformation */ - if (oldbf_math) { - bfsetup_convert_to_screen(); - } - else { - cvt = &stack_cvt; /* use stack */ - setup_convert_to_screen(cvt); - /* put in bf variables */ - floattobf(bt_a, cvt->a); - floattobf(bt_b, cvt->b); - floattobf(bt_c, cvt->c); - floattobf(bt_d, cvt->d); - floattobf(bt_e, cvt->e); - floattobf(bt_f, cvt->f); - } - find_special_colors(); - color_of_box = g_color_medium; -rescan: /* entry for changed browse parms */ - time(&lastime); - toggle = 0; - wincount = 0; - no_sub_images = FALSE; - splitpath(readname,drive,dir,NULL,NULL); - splitpath(browsemask,NULL,NULL,fname,ext); - makepath(tmpmask,drive,dir,fname,ext); - done=(vid_too_big==2) || no_memory || fr_findfirst(tmpmask); - /* draw all visible windows */ - while (!done) - { - if (driver_key_pressed()) - { - driver_get_key(); - break; - } - splitpath(DTA.filename,NULL,NULL,fname,ext); - makepath(tmpmask,drive,dir,fname,ext); - if ( !find_fractal_info(tmpmask,&read_info,&blk_2_info,&blk_3_info, - &blk_4_info,&blk_5_info,&blk_6_info, - &blk_7_info) && - (typeOK(&read_info,&blk_3_info) || !brwschecktype) && - (paramsOK(&read_info) || !brwscheckparms) && - stricmp(browsename,DTA.filename) && - blk_6_info.got_data != 1 && - is_visible_window(&winlist,&read_info,&blk_5_info) - ) - { - strcpy(winlist.name,DTA.filename); - drawindow(color_of_box,&winlist); - boxcount <<= 1; /*boxcount*2;*/ /* double for byte count */ - winlist.boxcount = boxcount; - MoveToMemory(winlistptr,(U16)sizeof(struct window),1L,(long)wincount,browsehandle); - MoveToMemory((BYTE *)boxx,vidlength,1L,(long)wincount,boxxhandle); - MoveToMemory((BYTE *)boxy,vidlength,1L,(long)wincount,boxyhandle); - MoveToMemory((BYTE *)boxvalues,(U16)(vidlength>>1),1L,(long)wincount,boxvalueshandle); - wincount++; - } - - if (blk_2_info.got_data == 1) /* Clean up any memory allocated */ - MemoryRelease((U16)blk_2_info.resume_data); - if (blk_4_info.got_data == 1) /* Clean up any memory allocated */ - free(blk_4_info.range_data); - if (blk_5_info.got_data == 1) /* Clean up any memory allocated */ - free(blk_5_info.apm_data); - - done=(fr_findnext() || wincount >= MAX_WINDOWS_OPEN); - } - - if (no_memory) - { - texttempmsg("Sorry...not enough memory to browse.");/* doesn't work if NO memory available, go figure */ - } - if (wincount >= MAX_WINDOWS_OPEN) - { /* hard code message at MAX_WINDOWS_OPEN = 450 */ - texttempmsg("Sorry...no more space, 450 displayed."); - } - if (vid_too_big==2) - { - texttempmsg("Xdots + Ydots > 4096."); - } - c=0; - if (wincount) - { - driver_buzzer(BUZZER_COMPLETE); /*let user know we've finished */ - index=0;done = 0; - MoveFromMemory(winlistptr,(U16)sizeof(struct window),1L,(long)index,browsehandle); - MoveFromMemory((BYTE *)boxx,vidlength,1L,(long)index,boxxhandle); - MoveFromMemory((BYTE *)boxy,vidlength,1L,(long)index,boxyhandle); - MoveFromMemory((BYTE *)boxvalues,(U16)(vidlength>>1),1L,(long)index,boxvalueshandle); - showtempmsg(winlist.name); - while ( !done) /* on exit done = 1 for quick exit, - done = 2 for erase boxes and exit - done = 3 for rescan - done = 4 for set boxes and exit to save image */ - { -#ifdef XFRACT - blinks = 1; -#endif - while (!driver_key_pressed()) - { - time(&thistime); - if (difftime(thistime,lastime) > .2 ) { - lastime=thistime; - toggle = 1- toggle; - } - if (toggle) - drawindow(g_color_bright,&winlist); /* flash current window */ - else - drawindow(g_color_dark,&winlist); -#ifdef XFRACT - blinks++; -#endif - } -#ifdef XFRACT - if ((blinks & 1) == 1) /* Need an odd # of blinks, so next one leaves box turned off */ - drawindow(g_color_bright,&winlist); -#endif - - c=driver_get_key(); - switch (c) { - case FIK_RIGHT_ARROW: - case FIK_LEFT_ARROW: - case FIK_DOWN_ARROW: - case FIK_UP_ARROW: - cleartempmsg(); - drawindow(color_of_box,&winlist);/* dim last window */ - if (c==FIK_RIGHT_ARROW || c== FIK_UP_ARROW) { - index++; /* shift attention to next window */ - if (index >= wincount) index=0; - } - else { - index -- ; - if ( index < 0 ) index = wincount -1 ; - } - MoveFromMemory(winlistptr,(U16)sizeof(struct window),1L,(long)index,browsehandle); - MoveFromMemory((BYTE *)boxx,vidlength,1L,(long)index,boxxhandle); - MoveFromMemory((BYTE *)boxy,vidlength,1L,(long)index,boxyhandle); - MoveFromMemory((BYTE *)boxvalues,(U16)(vidlength>>1),1L,(long)index,boxvalueshandle); - showtempmsg(winlist.name); - break; -#ifndef XFRACT - case FIK_CTL_INSERT: - color_of_box += key_count(FIK_CTL_INSERT); - for (i=0 ; i < wincount ; i++) { - MoveFromMemory(winlistptr,(U16)sizeof(struct window),1L,(long)i,browsehandle); - drawindow(color_of_box,&winlist); - } - MoveFromMemory(winlistptr,(U16)sizeof(struct window),1L,(long)index,browsehandle); - drawindow(color_of_box,&winlist); - break; - - case FIK_CTL_DEL: - color_of_box -= key_count(FIK_CTL_DEL); - for (i=0 ; i < wincount ; i++) { - MoveFromMemory(winlistptr,(U16)sizeof(struct window),1L,(long)i,browsehandle); - drawindow(color_of_box,&winlist); - } - MoveFromMemory(winlistptr,(U16)sizeof(struct window),1L,(long)index,browsehandle); - drawindow(color_of_box,&winlist); - break; -#endif - case FIK_ENTER: - case FIK_ENTER_2: /* this file please */ - strcpy(browsename,winlist.name); - done = 1; - break; - - case FIK_ESC: - case 'l': - case 'L': -#ifdef XFRACT - /* Need all boxes turned on, turn last one back on. */ - drawindow(g_color_bright,&winlist); -#endif - autobrowse = FALSE; - done = 2; - break; - - case 'D': /* delete file */ - cleartempmsg(); - _snprintf(mesg, NUM_OF(mesg), "Delete %s? (Y/N)", winlist.name); - showtempmsg(mesg); - driver_wait_key_pressed(0); - cleartempmsg(); - c = driver_get_key(); - if ( c == 'Y' && doublecaution ) { - texttempmsg("ARE YOU SURE???? (Y/N)"); - if ( driver_get_key() != 'Y') c = 'N'; - } - if ( c == 'Y' ) { - splitpath(readname,drive,dir,NULL,NULL); - splitpath(winlist.name,NULL,NULL,fname,ext); - makepath(tmpmask,drive,dir,fname,ext); - if ( !unlink(tmpmask)) { - /* do a rescan */ - done = 3; - strcpy(oldname,winlist.name); - tmpmask[0] = '\0'; - check_history(oldname,tmpmask); - break; - } - else if ( errno == EACCES ) { - texttempmsg("Sorry...it's a read only file, can't del"); - showtempmsg(winlist.name); - break; - } - } - { - texttempmsg("file not deleted (phew!)"); - } - showtempmsg(winlist.name); - break; - - case 'R': - cleartempmsg(); - driver_stack_screen(); - newname[0] = 0; - strcpy(mesg, "Enter the new filename for "); - splitpath(readname,drive,dir,NULL,NULL); - splitpath(winlist.name,NULL,NULL,fname,ext); - makepath(tmpmask,drive,dir,fname,ext); - strcpy(newname,tmpmask); - strcat(mesg,tmpmask); - i = field_prompt(mesg,NULL,newname,60,NULL); - driver_unstack_screen(); - if ( i != -1) - if (!rename(tmpmask,newname)) { - if (errno == EACCES) - { - texttempmsg("Sorry....can't rename"); - } - else { - splitpath(newname,NULL,NULL,fname,ext); - makepath(tmpmask,NULL,NULL,fname,ext); - strcpy(oldname,winlist.name); - check_history(oldname,tmpmask); - strcpy(winlist.name,tmpmask); - } - } - MoveToMemory(winlistptr,(U16)sizeof(struct window),1L,(long)index,browsehandle); - showtempmsg(winlist.name); - break; - - case 2: /* ctrl B */ - cleartempmsg(); - driver_stack_screen(); - done = abs(get_browse_params()); - driver_unstack_screen(); - showtempmsg(winlist.name); - break; - - case 's': /* save image with boxes */ - autobrowse = FALSE; - drawindow(color_of_box,&winlist); /* current window white */ - done = 4; - break; - - case '\\': /*back out to last image */ - done = 2; - break; - - default: - break; - } /*switch */ - } /*while*/ - - /* now clean up memory (and the screen if necessary) */ - cleartempmsg(); - if (done >= 1 && done < 4) { - for (index=wincount-1;index>=0;index--){ /* don't need index, reuse it */ - MoveFromMemory(winlistptr,(U16)sizeof(struct window),1L,(long)index,browsehandle); - boxcount = winlist.boxcount; - MoveFromMemory((BYTE *)boxx,vidlength,1L,(long)index,boxxhandle); - MoveFromMemory((BYTE *)boxy,vidlength,1L,(long)index,boxyhandle); - MoveFromMemory((BYTE *)boxvalues,(U16)(vidlength>>1),1L,(long)index,boxvalueshandle); - boxcount >>= 1; - if (boxcount > 0 ) -#ifdef XFRACT - /* Turn all boxes off */ - drawindow(g_color_bright,&winlist); -#else - clearbox(); -#endif - } - } - if (done == 3) { - goto rescan; /* hey everybody I just used the g word! */ - } - }/*if*/ - else { - driver_buzzer(BUZZER_INTERRUPT); /*no suitable files in directory! */ - texttempmsg("Sorry.. I can't find anything"); - no_sub_images = TRUE; - } - - MemoryRelease(browsehandle); - MemoryRelease(boxxhandle); - MemoryRelease(boxyhandle); - MemoryRelease(boxvalueshandle); - restore_stack(saved); - if (!oldbf_math) - free_bf_vars(); - bf_math = oldbf_math; - floatflag = usr_floatflag; - - return(c); -} - - -static void drawindow(int colour,struct window *info) -{ -#ifndef XFRACT - int cross_size; - struct coords ibl,itr; -#endif - - boxcolor=colour; - boxcount = 0; - if (info->win_size >= minbox) { - /* big enough on screen to show up as a box so draw it */ - /* corner pixels */ -#ifndef XFRACT - addbox(info->itl); - addbox(info->itr); - addbox(info->ibl); - addbox(info->ibr); - drawlines(info->itl,info->itr,info->ibl.x-info->itl.x,info->ibl.y-info->itl.y); /* top & bottom lines */ - drawlines(info->itl,info->ibl,info->itr.x-info->itl.x,info->itr.y-info->itl.y); /* left & right lines */ -#else - boxx[0] = info->itl.x + sxoffs; - boxy[0] = info->itl.y + syoffs; - boxx[1] = info->itr.x + sxoffs; - boxy[1] = info->itr.y + syoffs; - boxx[2] = info->ibr.x + sxoffs; - boxy[2] = info->ibr.y + syoffs; - boxx[3] = info->ibl.x + sxoffs; - boxy[3] = info->ibl.y + syoffs; - boxcount = 4; -#endif - dispbox(); - } - else { /* draw crosshairs */ -#ifndef XFRACT - cross_size = ydots / 45; - if (cross_size < 2) cross_size = 2; - itr.x = info->itl.x - cross_size; - itr.y = info->itl.y; - ibl.y = info->itl.y - cross_size; - ibl.x = info->itl.x; - drawlines(info->itl,itr,ibl.x-itr.x,0); /* top & bottom lines */ - drawlines(info->itl,ibl,0,itr.y-ibl.y); /* left & right lines */ - dispbox(); -#endif - } -} - -/* maps points onto view screen*/ -static void transform(struct dblcoords *point) -{ - double tmp_pt_x; - tmp_pt_x = cvt->a * point->x + cvt->b * point->y + cvt->e; - point->y = cvt->c * point->x + cvt->d * point->y + cvt->f; - point->x = tmp_pt_x; -} - -static char is_visible_window - ( struct window *list, struct fractal_info *info, - struct ext_blk_5 *blk_5_info ) -{ - struct dblcoords tl,tr,bl,br; - bf_t bt_x, bt_y; - bf_t bt_xmin, bt_xmax, bt_ymin, bt_ymax, bt_x3rd, bt_y3rd; - int saved; - int two_len; - int cornercount, cant_see; - int orig_bflength, - orig_bnlength, - orig_padding, - orig_rlength, - orig_shiftfactor, - orig_rbflength; - double toobig, tmp_sqrt; - toobig = sqrt(sqr((double)sxdots)+sqr((double)sydots)) * 1.5; - /* arbitrary value... stops browser zooming out too far */ - cornercount=0; - cant_see = 0; - - saved = save_stack(); - /* Save original values. */ - orig_bflength = bflength; - orig_bnlength = bnlength; - orig_padding = padding; - orig_rlength = rlength; - orig_shiftfactor = shiftfactor; - orig_rbflength = rbflength; -/* - if (oldbf_math && info->bf_math && (bnlength+4 < info->bflength)) { - bnlength = info->bflength; - calc_lengths(); - } -*/ - two_len = bflength + 2; - bt_x = alloc_stack(two_len); - bt_y = alloc_stack(two_len); - bt_xmin = alloc_stack(two_len); - bt_xmax = alloc_stack(two_len); - bt_ymin = alloc_stack(two_len); - bt_ymax = alloc_stack(two_len); - bt_x3rd = alloc_stack(two_len); - bt_y3rd = alloc_stack(two_len); - - if (info->bf_math) { - bf_t bt_t1, bt_t2, bt_t3, bt_t4, bt_t5, bt_t6; - int di_bflength, two_di_len, two_rbf; - - di_bflength = info->bflength + bnstep; - two_di_len = di_bflength + 2; - two_rbf = rbflength + 2; - - n_a = alloc_stack(two_rbf); - n_b = alloc_stack(two_rbf); - n_c = alloc_stack(two_rbf); - n_d = alloc_stack(two_rbf); - n_e = alloc_stack(two_rbf); - n_f = alloc_stack(two_rbf); - - convert_bf(n_a, bt_a, rbflength, orig_rbflength); - convert_bf(n_b, bt_b, rbflength, orig_rbflength); - convert_bf(n_c, bt_c, rbflength, orig_rbflength); - convert_bf(n_d, bt_d, rbflength, orig_rbflength); - convert_bf(n_e, bt_e, rbflength, orig_rbflength); - convert_bf(n_f, bt_f, rbflength, orig_rbflength); - - bt_t1 = alloc_stack(two_di_len); - bt_t2 = alloc_stack(two_di_len); - bt_t3 = alloc_stack(two_di_len); - bt_t4 = alloc_stack(two_di_len); - bt_t5 = alloc_stack(two_di_len); - bt_t6 = alloc_stack(two_di_len); - - memcpy((char *)bt_t1,blk_5_info->apm_data,(two_di_len)); - memcpy((char *)bt_t2,blk_5_info->apm_data+two_di_len,(two_di_len)); - memcpy((char *)bt_t3,blk_5_info->apm_data+2*two_di_len,(two_di_len)); - memcpy((char *)bt_t4,blk_5_info->apm_data+3*two_di_len,(two_di_len)); - memcpy((char *)bt_t5,blk_5_info->apm_data+4*two_di_len,(two_di_len)); - memcpy((char *)bt_t6,blk_5_info->apm_data+5*two_di_len,(two_di_len)); - - convert_bf(bt_xmin, bt_t1, two_len, two_di_len); - convert_bf(bt_xmax, bt_t2, two_len, two_di_len); - convert_bf(bt_ymin, bt_t3, two_len, two_di_len); - convert_bf(bt_ymax, bt_t4, two_len, two_di_len); - convert_bf(bt_x3rd, bt_t5, two_len, two_di_len); - convert_bf(bt_y3rd, bt_t6, two_len, two_di_len); - } - - /* tranform maps real plane co-ords onto the current screen view - see above */ - if (oldbf_math || info->bf_math) { - if (!info->bf_math) { - floattobf(bt_x, info->xmin); - floattobf(bt_y, info->ymax); - } - else { - copy_bf(bt_x, bt_xmin); - copy_bf(bt_y, bt_ymax); - } - bftransform(bt_x, bt_y, &tl); - } - else { - tl.x=info->xmin; - tl.y=info->ymax; - transform(&tl); - } - list->itl.x=(int)(tl.x + 0.5); - list->itl.y=(int)(tl.y + 0.5); - if (oldbf_math || info->bf_math) { - if (!info->bf_math) { - floattobf(bt_x, (info->xmax)-(info->x3rd-info->xmin)); - floattobf(bt_y, (info->ymax)+(info->ymin-info->y3rd)); - } - else { - neg_a_bf(sub_bf(bt_x, bt_x3rd, bt_xmin)); - add_a_bf(bt_x, bt_xmax); - sub_bf(bt_y, bt_ymin, bt_y3rd); - add_a_bf(bt_y, bt_ymax); - } - bftransform(bt_x, bt_y, &tr); - } - else { - tr.x=(info->xmax)-(info->x3rd-info->xmin); - tr.y=(info->ymax)+(info->ymin-info->y3rd); - transform(&tr); - } - list->itr.x=(int)(tr.x + 0.5); - list->itr.y=(int)(tr.y + 0.5); - if (oldbf_math || info->bf_math) { - if (!info->bf_math) { - floattobf(bt_x, info->x3rd); - floattobf(bt_y, info->y3rd); - } - else { - copy_bf(bt_x, bt_x3rd); - copy_bf(bt_y, bt_y3rd); - } - bftransform(bt_x, bt_y, &bl); - } - else { - bl.x=info->x3rd; - bl.y=info->y3rd; - transform(&bl); - } - list->ibl.x=(int)(bl.x + 0.5); - list->ibl.y=(int)(bl.y + 0.5); - if (oldbf_math || info->bf_math) { - if (!info->bf_math) { - floattobf(bt_x, info->xmax); - floattobf(bt_y, info->ymin); - } - else { - copy_bf(bt_x, bt_xmax); - copy_bf(bt_y, bt_ymin); - } - bftransform(bt_x, bt_y, &br); - } - else { - br.x=info->xmax; - br.y=info->ymin; - transform(&br); - } - list->ibr.x=(int)(br.x + 0.5); - list->ibr.y=(int)(br.y + 0.5); - - tmp_sqrt = sqrt(sqr(tr.x-bl.x) + sqr(tr.y-bl.y)); - list->win_size = tmp_sqrt; /* used for box vs crosshair in drawindow() */ - if (tmp_sqrt < toosmall ) cant_see = 1; - /* reject anything too small onscreen */ - if (tmp_sqrt > toobig ) cant_see = 1; - /* or too big... */ - - /* restore original values */ - bflength = orig_bflength; - bnlength = orig_bnlength; - padding = orig_padding; - rlength = orig_rlength; - shiftfactor = orig_shiftfactor; - rbflength = orig_rbflength; - - restore_stack(saved); - if (cant_see) /* do it this way so bignum stack is released */ - return(FALSE); - - /* now see how many corners are on the screen, accept if one or more */ - if ( tl.x >=(0-sxoffs) && tl.x <= (sxdots-sxoffs) && tl.y >=(0-syoffs) && tl.y<= (sydots-syoffs) ) cornercount ++; - if ( bl.x >=(0-sxoffs) && bl.x <= (sxdots-sxoffs) && bl.y >=(0-syoffs) && bl.y<= (sydots-syoffs) ) cornercount ++; - if ( tr.x >=(0-sxoffs) && tr.x <= (sxdots-sxoffs) && tr.y >=(0-syoffs) && tr.y<= (sydots-syoffs) ) cornercount ++; - if ( br.x >=(0-sxoffs) && br.x <= (sxdots-sxoffs) && br.y >=(0-syoffs) && br.y<= (sydots-syoffs) ) cornercount ++; - - if (cornercount >=1 ) return( TRUE ); - else return( FALSE ); - } - -static char paramsOK( struct fractal_info *info ) -{ -double tmpparm3, tmpparm4; -double tmpparm5, tmpparm6; -double tmpparm7, tmpparm8; -double tmpparm9, tmpparm10; -#define MINDIF 0.001 - - if ( info->version > 6) { - tmpparm3 = info->dparm3; - tmpparm4 = info->dparm4; - } - else{ - tmpparm3 = info->parm3; - roundfloatd(&tmpparm3); - tmpparm4 = info->parm4; - roundfloatd(&tmpparm4); - } - if ( info->version > 8) { - tmpparm5 = info->dparm5; - tmpparm6 = info->dparm6; - tmpparm7 = info->dparm7; - tmpparm8 = info->dparm8; - tmpparm9 = info->dparm9; - tmpparm10 = info->dparm10; - } - else{ - tmpparm5 = 0.0; - tmpparm6 = 0.0; - tmpparm7 = 0.0; - tmpparm8 = 0.0; - tmpparm9 = 0.0; - tmpparm10 = 0.0; - } - if ( fabs(info->creal - param[0]) < MINDIF && - fabs(info->cimag - param[1]) < MINDIF && - fabs(tmpparm3 - param[2]) < MINDIF && - fabs(tmpparm4 - param[3]) < MINDIF && - fabs(tmpparm5 - param[4]) < MINDIF && - fabs(tmpparm6 - param[5]) < MINDIF && - fabs(tmpparm7 - param[6]) < MINDIF && - fabs(tmpparm8 - param[7]) < MINDIF && - fabs(tmpparm9 - param[8]) < MINDIF && - fabs(tmpparm10 - param[9]) < MINDIF && - info->invert[0] - inversion[0] < MINDIF) - return(1); /* parameters are in range */ - else - return(0); -} - -static char functionOK( struct fractal_info *info, int numfn) -{ - int i, mzmatch; - mzmatch = 0; - for (i=0; itrigndx[i] != trigndx[i] ) - mzmatch++; - } - if (mzmatch > 0) - return(0); - else - return(1); /* they all match */ -} - -static char typeOK( struct fractal_info *info, struct ext_blk_3 *blk_3_info ) -{ - int numfn; - if ( (fractype == FORMULA || fractype == FFORMULA) && - (info->fractal_type == FORMULA || info->fractal_type == FFORMULA) ) - { - if ( !stricmp(blk_3_info->form_name,FormName) ) - { - numfn = maxfn; - if (numfn>0) - return(functionOK(info, numfn)); - else - return(1); /* match up formula names with no functions */ - } - else - return(0); /* two formulas but names don't match */ - } - else if (info->fractal_type == fractype || - info->fractal_type == curfractalspecific->tofloat) - { - numfn = (curfractalspecific->flags >> 6) & 7; - if (numfn>0) - return(functionOK(info, numfn)); - else - return(1); /* match types with no functions */ - } - else - return(0); /* no match */ -} - -static void check_history ( char *oldname, char *newname ) -{ -int i; - -/* file_name_stack[] is maintained in framain2.c. It is the history */ -/* file for the browser and holds a maximum of 16 images. The history */ -/* file needs to be adjusted if the rename or delete functions of the */ -/* browser are used. */ -/* name_stack_ptr is also maintained in framain2.c. It is the index into */ -/* file_name_stack[]. */ - - for (i=0;ix = cvt->a * point->x + cvt->b * point->y + cvt->e; */ - mult_bf(bt_tmp1, n_a, bt_x); - mult_bf(bt_tmp2, n_b, bt_y); - add_a_bf(bt_tmp1, bt_tmp2); - add_a_bf(bt_tmp1, n_e); - point->x = (double)bftofloat(bt_tmp1); - -/* point->y = cvt->c * point->x + cvt->d * point->y + cvt->f; */ - mult_bf(bt_tmp1, n_c, bt_x); - mult_bf(bt_tmp2, n_d, bt_y); - add_a_bf(bt_tmp1, bt_tmp2); - add_a_bf(bt_tmp1, n_f); - point->y = (double)bftofloat(bt_tmp1); - - restore_stack(saved); -} diff --git a/fractint/common/loadmap.c b/fractint/common/loadmap.c deleted file mode 100644 index c82d3b80a..000000000 --- a/fractint/common/loadmap.c +++ /dev/null @@ -1,78 +0,0 @@ -/** loadmap.c **/ - - -#include - - /* see Fractint.c for a description of the "include" hierarchy */ -#include "port.h" -#include "prototyp.h" - -/***************************************************************************/ - -#define dac ((Palettetype *)g_dac_box) - -int ValidateLuts( char * fn ) -{ -FILE * f; -unsigned r, g, b, index; -char line[160]; -char temp[FILE_MAX_PATH+1]; -char temp_fn[FILE_MAX_PATH]; - strcpy(temp,MAP_name); - strcpy(temp_fn,fn); -#ifdef XFRACT - merge_pathnames(temp,temp_fn,3); -#else - merge_pathnames(temp,temp_fn,0); -#endif - if (has_ext(temp) == NULL) /* Did name have an extension? */ - strcat(temp,".map"); /* No? Then add .map */ - findpath( temp, line); /* search the dos path */ - f = fopen( line, "r" ); - if (f == NULL) { - sprintf(line,"Could not load color map %s",fn); - stopmsg(0,line); - return 1; - } - for ( index = 0; index < 256; index++ ) { - if (fgets(line,100,f) == NULL) - break; - sscanf( line, "%u %u %u", &r, &g, &b ); - /** load global dac values **/ - dac[index].red = (BYTE)((r%256) >> 2);/* maps default to 8 bits */ - dac[index].green = (BYTE)((g%256) >> 2);/* DAC wants 6 bits */ - dac[index].blue = (BYTE)((b%256) >> 2); - } - fclose( f ); - while (index < 256) { /* zap unset entries */ - dac[index].red = dac[index].blue = dac[index].green = 40; - ++index; - } - colorstate = 2; - strcpy(colorfile,fn); - return 0; -} - - -/***************************************************************************/ - -int SetColorPaletteName(char * fn) -{ - if (ValidateLuts(fn) != 0) - { - return 1; - } - if (mapdacbox == NULL) - { - mapdacbox = (char *) malloc(768L); - if (mapdacbox == NULL) - { - stopmsg(0, "Insufficient memory for color map."); - return 1; - } - } - memcpy((char *) mapdacbox, (char *) g_dac_box, 768); - /* PB, 900829, removed atexit(RestoreMap) stuff, goodbye covers it */ - return 0; -} - diff --git a/fractint/common/lorenz.c b/fractint/common/lorenz.c deleted file mode 100644 index 3f1ffe019..000000000 --- a/fractint/common/lorenz.c +++ /dev/null @@ -1,2823 +0,0 @@ -/* - This file contains two 3 dimensional orbit-type fractal - generators - IFS and LORENZ3D, along with code to generate - red/blue 3D images. Tim Wegner -*/ - -#include - /* see Fractint.c for a description of the "include" hierarchy */ -#include "port.h" -#include "prototyp.h" -#include "fractype.h" -#include "drivers.h" - -/* orbitcalc is declared with no arguments so jump through hoops here */ -#define LORBIT(x,y,z) \ - (*(int(*)(long *,long *,long *))curfractalspecific->orbitcalc)(x,y,z) -#define FORBIT(x,y,z) \ - (*(int(*)(double*,double*,double*))curfractalspecific->orbitcalc)(x,y,z) - -#define RANDOM(x) (rand()%(x)) -/* BAD_PIXEL is used to cutoff orbits that are diverging. It might be better -to test the actual floating point orbit values, but this seems safe for now. -A higher value cannot be used - to test, turn off math coprocessor and -use +2.24 for type ICONS. If BAD_PIXEL is set to 20000, this will abort -Fractint with a math error. Note that this approach precludes zooming in very -far to an orbit type. */ - -#define BAD_PIXEL 10000L /* pixels can't get this big */ - -struct l_affine -{ - /* weird order so a,b,e and c,d,f are vectors */ - long a; - long b; - long e; - long c; - long d; - long f; -}; -struct long3dvtinf /* data used by 3d view transform subroutine */ -{ - long orbit[3]; /* interated function orbit value */ - long iview[3]; /* perspective viewer's coordinates */ - long viewvect[3]; /* orbit transformed for viewing */ - long viewvect1[3]; /* orbit transformed for viewing */ - long maxvals[3]; - long minvals[3]; - MATRIX doublemat; /* transformation matrix */ - MATRIX doublemat1; /* transformation matrix */ - long longmat[4][4]; /* long version of matrix */ - long longmat1[4][4]; /* long version of matrix */ - int row,col; /* results */ - int row1,col1; - struct l_affine cvt; -}; - -struct float3dvtinf /* data used by 3d view transform subroutine */ -{ - double orbit[3]; /* interated function orbit value */ - double viewvect[3]; /* orbit transformed for viewing */ - double viewvect1[3]; /* orbit transformed for viewing */ - double maxvals[3]; - double minvals[3]; - MATRIX doublemat; /* transformation matrix */ - MATRIX doublemat1; /* transformation matrix */ - int row,col; /* results */ - int row1,col1; - struct affine cvt; -}; - -/* Routines in this module */ - -static int ifs2d(void); -static int ifs3d(void); -static int ifs3dlong(void); -static int ifs3dfloat(void); -static int l_setup_convert_to_screen(struct l_affine *); -static void setupmatrix(MATRIX); -static int long3dviewtransf(struct long3dvtinf *inf); -static int float3dviewtransf(struct float3dvtinf *inf); -static FILE *open_orbitsave(void); -static void _fastcall plothist(int x, int y, int color); -static int realtime; - -S32 maxct; -static int t; -static long l_dx,l_dy,l_dz,l_dt,l_a,l_b,l_c,l_d; -static long l_adt,l_bdt,l_cdt,l_xdt,l_ydt; -static long initorbitlong[3]; - -static double dx,dy,dz,dt,a,b,c,d; -static double adt,bdt,cdt,xdt,ydt,zdt; -static double initorbitfp[3]; - -/* - * The following declarations used for Inverse Julia. MVS - */ - -static char NoQueue[] = - "Not enough memory: switching to random walk.\n"; - -static int mxhits; -int run_length; -/* -enum {breadth_first, depth_first, random_walk, random_run} major_method; -enum {left_first, right_first} minor_method; -*/ -enum Major major_method; -enum Minor minor_method; -struct affine cvt; -struct l_affine lcvt; - -double Cx, Cy; -long CxLong, CyLong; - -/* - * end of Inverse Julia declarations; - */ - -/* these are potential user parameters */ -int connect = 1; /* flag to connect points with a line */ -int euler = 0; /* use implicit euler approximation for dynamic system */ -int waste = 100; /* waste this many points before plotting */ -int projection = 2; /* projection plane - default is to plot x-y */ - -/******************************************************************/ -/* zoom box conversion functions */ -/******************************************************************/ - -/* - Conversion of complex plane to screen coordinates for rotating zoom box. - Assume there is an affine transformation mapping complex zoom parallelogram - to rectangular screen. We know this map must map parallelogram corners to - screen corners, so we have following equations: - - a*xxmin+b*yymax+e == 0 (upper left) - c*xxmin+d*yymax+f == 0 - - a*xx3rd+b*yy3rd+e == 0 (lower left) - c*xx3rd+d*yy3rd+f == ydots-1 - - a*xxmax+b*yymin+e == xdots-1 (lower right) - c*xxmax+d*yymin+f == ydots-1 - - First we must solve for a,b,c,d,e,f - (which we do once per image), - then we just apply the transformation to each orbit value. -*/ - -/* - Thanks to Sylvie Gallet for the following. The original code for - setup_convert_to_screen() solved for coefficients of the - complex-plane-to-screen transformation using a very straight-forward - application of determinants to solve a set of simulataneous - equations. The procedure was simple and general, but inefficient. - The inefficiecy wasn't hurting anything because the routine was called - only once per image, but it seemed positively sinful to use it - because the code that follows is SO much more compact, at the - expense of being less general. Here are Sylvie's notes. I have further - optimized the code a slight bit. - Tim Wegner - July, 1996 - Sylvie's notes, slightly edited follow: - - You don't need 3x3 determinants to solve these sets of equations because - the unknowns e and f have the same coefficient: 1. - - First set of 3 equations: - a*xxmin+b*yymax+e == 0 - a*xx3rd+b*yy3rd+e == 0 - a*xxmax+b*yymin+e == xdots-1 - To make things easy to read, I just replace xxmin, xxmax, xx3rd by x1, - x2, x3 (ditto for yy...) and xdots-1 by xd. - - a*x1 + b*y2 + e == 0 (1) - a*x3 + b*y3 + e == 0 (2) - a*x2 + b*y1 + e == xd (3) - - I subtract (1) to (2) and (3): - a*x1 + b*y2 + e == 0 (1) - a*(x3-x1) + b*(y3-y2) == 0 (2)-(1) - a*(x2-x1) + b*(y1-y2) == xd (3)-(1) - - I just have to calculate a 2x2 determinant: - det == (x3-x1)*(y1-y2) - (y3-y2)*(x2-x1) - - And the solution is: - a = -xd*(y3-y2)/det - b = xd*(x3-x1)/det - e = - a*x1 - b*y2 - -The same technique can be applied to the second set of equations: - - c*xxmin+d*yymax+f == 0 - c*xx3rd+d*yy3rd+f == ydots-1 - c*xxmax+d*yymin+f == ydots-1 - - c*x1 + d*y2 + f == 0 (1) - c*x3 + d*y3 + f == yd (2) - c*x2 + d*y1 + f == yd (3) - - c*x1 + d*y2 + f == 0 (1) - c*(x3-x2) + d*(y3-y1) == 0 (2)-(3) - c*(x2-x1) + d*(y1-y2) == yd (3)-(1) - - det == (x3-x2)*(y1-y2) - (y3-y1)*(x2-x1) - - c = -yd*(y3-y1)/det - d = yd*(x3-x2))det - f = - c*x1 - d*y2 - - - Sylvie -*/ - -int setup_convert_to_screen(struct affine *scrn_cnvt) -{ - double det, xd, yd; - - det = (xx3rd-xxmin)*(yymin-yymax) + (yymax-yy3rd)*(xxmax-xxmin); - if (det == 0) - return(-1); - xd = dxsize/det; - scrn_cnvt->a = xd*(yymax-yy3rd); - scrn_cnvt->b = xd*(xx3rd-xxmin); - scrn_cnvt->e = -scrn_cnvt->a*xxmin - scrn_cnvt->b*yymax; - - det = (xx3rd-xxmax)*(yymin-yymax) + (yymin-yy3rd)*(xxmax-xxmin); - if (det == 0) - return(-1); - yd = dysize/det; - scrn_cnvt->c = yd*(yymin-yy3rd); - scrn_cnvt->d = yd*(xx3rd-xxmax); - scrn_cnvt->f = -scrn_cnvt->c*xxmin - scrn_cnvt->d*yymax; - return(0); -} - -static int l_setup_convert_to_screen(struct l_affine *l_cvt) -{ - struct affine cvt; - - /* MCP 7-7-91, This function should return a something! */ - if (setup_convert_to_screen(&cvt)) - return(-1); - l_cvt->a = (long)(cvt.a*fudge); l_cvt->b = (long)(cvt.b*fudge); l_cvt->c = (long)(cvt.c*fudge); - l_cvt->d = (long)(cvt.d*fudge); l_cvt->e = (long)(cvt.e*fudge); l_cvt->f = (long)(cvt.f*fudge); - - /* MCP 7-7-91 */ - return(0); -} - -/******************************************************************/ -/* setup functions - put in fractalspecific[fractype].per_image */ -/******************************************************************/ - -static double orbit; -static long l_orbit; -static long l_sinx,l_cosx; - -int orbit3dlongsetup() -{ - maxct = 0L; - connect = 1; - waste = 100; - projection = 2; - if (fractype==LHENON || fractype==KAM || fractype==KAM3D || - fractype==INVERSEJULIA) - connect=0; - if (fractype==LROSSLER) - waste = 500; - if (fractype==LLORENZ) - projection = 1; - - initorbitlong[0] = fudge; /* initial conditions */ - initorbitlong[1] = fudge; - initorbitlong[2] = fudge; - - if (fractype==LHENON) - { - l_a = (long)(param[0]*fudge); - l_b = (long)(param[1]*fudge); - l_c = (long)(param[2]*fudge); - l_d = (long)(param[3]*fudge); - } - else if (fractype==KAM || fractype==KAM3D) - { - maxct = 1L; - a = param[0]; /* angle */ - if (param[1] <= 0.0) - param[1] = .01; - l_b = (long)(param[1]*fudge); /* stepsize */ - l_c = (long)(param[2]*fudge); /* stop */ - t = (int)(l_d = (long)(param[3])); /* points per orbit */ - - l_sinx = (long)(sin(a)*fudge); - l_cosx = (long)(cos(a)*fudge); - l_orbit = 0; - initorbitlong[0] = initorbitlong[1] = initorbitlong[2] = 0; - } - else if (fractype == INVERSEJULIA) - { - LCMPLX Sqrt; - - CxLong = (long)(param[0] * fudge); - CyLong = (long)(param[1] * fudge); - - mxhits = (int) param[2]; - run_length = (int) param[3]; - if (mxhits <= 0) - mxhits = 1; - else if (mxhits >= colors) - mxhits = colors - 1; - param[2] = mxhits; - - setup_convert_to_screen(&cvt); - /* Note: using bitshift of 21 for affine, 24 otherwise */ - - lcvt.a = (long)(cvt.a * (1L << 21)); - lcvt.b = (long)(cvt.b * (1L << 21)); - lcvt.c = (long)(cvt.c * (1L << 21)); - lcvt.d = (long)(cvt.d * (1L << 21)); - lcvt.e = (long)(cvt.e * (1L << 21)); - lcvt.f = (long)(cvt.f * (1L << 21)); - - Sqrt = ComplexSqrtLong(fudge - 4 * CxLong, -4 * CyLong); - - switch (major_method) { - case breadth_first: - if (Init_Queue((long)32*1024) == 0) - { /* can't get queue memory: fall back to random walk */ - stopmsg(STOPMSG_INFO_ONLY | STOPMSG_NO_BUZZER, NoQueue); - major_method = random_walk; - goto lrwalk; - } - EnQueueLong((fudge + Sqrt.x) / 2, Sqrt.y / 2); - EnQueueLong((fudge - Sqrt.x) / 2, -Sqrt.y / 2); - break; - case depth_first: - if (Init_Queue((long)32*1024) == 0) - { /* can't get queue memory: fall back to random walk */ - stopmsg(STOPMSG_INFO_ONLY | STOPMSG_NO_BUZZER, NoQueue); - major_method = random_walk; - goto lrwalk; - } - switch (minor_method) { - case left_first: - PushLong((fudge + Sqrt.x) / 2, Sqrt.y / 2); - PushLong((fudge - Sqrt.x) / 2, -Sqrt.y / 2); - break; - case right_first: - PushLong((fudge - Sqrt.x) / 2, -Sqrt.y / 2); - PushLong((fudge + Sqrt.x) / 2, Sqrt.y / 2); - break; - } - break; - case random_walk: -lrwalk: - lnew.x = initorbitlong[0] = fudge + Sqrt.x / 2; - lnew.y = initorbitlong[1] = Sqrt.y / 2; - break; - case random_run: - lnew.x = initorbitlong[0] = fudge + Sqrt.x / 2; - lnew.y = initorbitlong[1] = Sqrt.y / 2; - break; - } - } - else - { - l_dt = (long)(param[0]*fudge); - l_a = (long)(param[1]*fudge); - l_b = (long)(param[2]*fudge); - l_c = (long)(param[3]*fudge); - } - - /* precalculations for speed */ - l_adt = multiply(l_a,l_dt,bitshift); - l_bdt = multiply(l_b,l_dt,bitshift); - l_cdt = multiply(l_c,l_dt,bitshift); - return(1); -} - -#define COSB dx -#define SINABC dy - -int orbit3dfloatsetup() -{ - maxct = 0L; - connect = 1; - waste = 100; - projection = 2; - - if (fractype==FPHENON || fractype==FPPICKOVER || fractype==FPGINGERBREAD - || fractype == KAMFP || fractype == KAM3DFP - || fractype == FPHOPALONG || fractype == INVERSEJULIAFP) - connect=0; - if (fractype==FPLORENZ3D1 || fractype==FPLORENZ3D3 || - fractype==FPLORENZ3D4) - waste = 750; - if (fractype==FPROSSLER) - waste = 500; - if (fractype==FPLORENZ) - projection = 1; /* plot x and z */ - - initorbitfp[0] = 1; /* initial conditions */ - initorbitfp[1] = 1; - initorbitfp[2] = 1; - if (fractype==FPGINGERBREAD) - { - initorbitfp[0] = param[0]; /* initial conditions */ - initorbitfp[1] = param[1]; - } - - if (fractype==ICON || fractype==ICON3D) /* DMF */ - { - initorbitfp[0] = 0.01; /* initial conditions */ - initorbitfp[1] = 0.003; - connect = 0; - waste = 2000; - } - - if (fractype==LATOO) /* HB */ - { - connect = 0; - } - - if (fractype==FPHENON || fractype==FPPICKOVER) - { - a = param[0]; - b = param[1]; - c = param[2]; - d = param[3]; - } - else if (fractype==ICON || fractype==ICON3D) /* DMF */ - { - initorbitfp[0] = 0.01; /* initial conditions */ - initorbitfp[1] = 0.003; - connect = 0; - waste = 2000; - /* Initialize parameters */ - a = param[0]; - b = param[1]; - c = param[2]; - d = param[3]; - } - else if (fractype==KAMFP || fractype==KAM3DFP) - { - maxct = 1L; - a = param[0]; /* angle */ - if (param[1] <= 0.0) - param[1] = .01; - b = param[1]; /* stepsize */ - c = param[2]; /* stop */ - t = (int)(l_d = (long)(param[3])); /* points per orbit */ - sinx = sin(a); - cosx = cos(a); - orbit = 0; - initorbitfp[0] = initorbitfp[1] = initorbitfp[2] = 0; - } - else if (fractype==FPHOPALONG || fractype==FPMARTIN || fractype==CHIP - || fractype==QUADRUPTWO || fractype==THREEPLY) - { - initorbitfp[0] = 0; /* initial conditions */ - initorbitfp[1] = 0; - initorbitfp[2] = 0; - connect = 0; - a = param[0]; - b = param[1]; - c = param[2]; - d = param[3]; - if (fractype==THREEPLY) - { - COSB = cos(b); - SINABC = sin(a+b+c); - } - } - else if (fractype == INVERSEJULIAFP) - { - _CMPLX Sqrt; - - Cx = param[0]; - Cy = param[1]; - - mxhits = (int) param[2]; - run_length = (int) param[3]; - if (mxhits <= 0) - mxhits = 1; - else if (mxhits >= colors) - mxhits = colors - 1; - param[2] = mxhits; - - setup_convert_to_screen(&cvt); - - /* find fixed points: guaranteed to be in the set */ - Sqrt = ComplexSqrtFloat(1 - 4 * Cx, -4 * Cy); - switch ((int) major_method) { - case breadth_first: - if (Init_Queue((long)32*1024) == 0) - { /* can't get queue memory: fall back to random walk */ - stopmsg(STOPMSG_INFO_ONLY | STOPMSG_NO_BUZZER, NoQueue); - major_method = random_walk; - goto rwalk; - } - EnQueueFloat((float)((1 + Sqrt.x) / 2), (float)(Sqrt.y / 2)); - EnQueueFloat((float)((1 - Sqrt.x) / 2), (float)(-Sqrt.y / 2)); - break; - case depth_first: /* depth first (choose direction) */ - if (Init_Queue((long)32*1024) == 0) - { /* can't get queue memory: fall back to random walk */ - stopmsg(STOPMSG_INFO_ONLY | STOPMSG_NO_BUZZER, NoQueue); - major_method = random_walk; - goto rwalk; - } - switch (minor_method) { - case left_first: - PushFloat((float)((1 + Sqrt.x) / 2), (float)(Sqrt.y / 2)); - PushFloat((float)((1 - Sqrt.x) / 2), (float)(-Sqrt.y / 2)); - break; - case right_first: - PushFloat((float)((1 - Sqrt.x) / 2), (float)(-Sqrt.y / 2)); - PushFloat((float)((1 + Sqrt.x) / 2), (float)(Sqrt.y / 2)); - break; - } - break; - case random_walk: -rwalk: - g_new.x = initorbitfp[0] = 1 + Sqrt.x / 2; - g_new.y = initorbitfp[1] = Sqrt.y / 2; - break; - case random_run: /* random run, choose intervals */ - major_method = random_run; - g_new.x = initorbitfp[0] = 1 + Sqrt.x / 2; - g_new.y = initorbitfp[1] = Sqrt.y / 2; - break; - } - } - else - { - dt = param[0]; - a = param[1]; - b = param[2]; - c = param[3]; - - } - - /* precalculations for speed */ - adt = a*dt; - bdt = b*dt; - cdt = c*dt; - - return(1); -} - -/******************************************************************/ -/* orbit functions - put in fractalspecific[fractype].orbitcalc */ -/******************************************************************/ - -/* Julia sets by inverse iterations added by Juan J. Buhler 4/3/92 */ -/* Integrated with Lorenz by Tim Wegner 7/20/92 */ -/* Add Modified Inverse Iteration Method, 11/92 by Michael Snyder */ - -int -Minverse_julia_orbit() -{ - static int random_dir = 0, random_len = 0; - int newrow, newcol; - int color, leftright; - - /* - * First, compute new point - */ - switch (major_method) { - case breadth_first: - if (QueueEmpty()) - return -1; - g_new = DeQueueFloat(); - break; - case depth_first: - if (QueueEmpty()) - return -1; - g_new = PopFloat(); - break; - case random_walk: -#if 0 - g_new = ComplexSqrtFloat(g_new.x - Cx, g_new.y - Cy); - if (RANDOM(2)) - { - g_new.x = -g_new.x; - g_new.y = -g_new.y; - } -#endif - break; - case random_run: -#if 0 - g_new = ComplexSqrtFloat(g_new.x - Cx, g_new.y - Cy); - if (random_len == 0) - { - random_len = RANDOM(run_length); - random_dir = RANDOM(3); - } - switch (random_dir) { - case 0: /* left */ - break; - case 1: /* right */ - g_new.x = -g_new.x; - g_new.y = -g_new.y; - break; - case 2: /* random direction */ - if (RANDOM(2)) - { - g_new.x = -g_new.x; - g_new.y = -g_new.y; - } - break; - } -#endif - break; - } - - /* - * Next, find its pixel position - */ - newcol = (int)(cvt.a * g_new.x + cvt.b * g_new.y + cvt.e); - newrow = (int)(cvt.c * g_new.x + cvt.d * g_new.y + cvt.f); - - /* - * Now find the next point(s), and flip a coin to choose one. - */ - - g_new = ComplexSqrtFloat(g_new.x - Cx, g_new.y - Cy); - leftright = (RANDOM(2)) ? 1 : -1; - - if (newcol < 1 || newcol >= xdots || newrow < 1 || newrow >= ydots) - { - /* - * MIIM must skip points that are off the screen boundary, - * since it cannot read their color. - */ - switch (major_method) { - case breadth_first: - EnQueueFloat((float)(leftright * g_new.x), (float)(leftright * g_new.y)); - return 1; - case depth_first: - PushFloat ((float)(leftright * g_new.x), (float)(leftright * g_new.y)); - return 1; - case random_run: - case random_walk: - break; - } - } - - /* - * Read the pixel's color: - * For MIIM, if color >= mxhits, discard the point - * else put the point's children onto the queue - */ - color = getcolor(newcol, newrow); - switch (major_method) { - case breadth_first: - if (color < mxhits) - { - putcolor(newcol, newrow, color+1); -/* g_new = ComplexSqrtFloat(g_new.x - Cx, g_new.y - Cy); */ - EnQueueFloat( (float)g_new.x, (float)g_new.y); - EnQueueFloat((float)-g_new.x, (float)-g_new.y); - } - break; - case depth_first: - if (color < mxhits) - { - putcolor(newcol, newrow, color+1); -/* g_new = ComplexSqrtFloat(g_new.x - Cx, g_new.y - Cy); */ - if (minor_method == left_first) - { - if (QueueFullAlmost()) - PushFloat((float)-g_new.x, (float)-g_new.y); - else - { - PushFloat( (float)g_new.x, (float)g_new.y); - PushFloat((float)-g_new.x, (float)-g_new.y); - } - } - else - { - if (QueueFullAlmost()) - PushFloat( (float)g_new.x, (float)g_new.y); - else - { - PushFloat((float)-g_new.x, (float)-g_new.y); - PushFloat( (float)g_new.x, (float)g_new.y); - } - } - } - break; - case random_run: - if (random_len-- == 0) - { - random_len = RANDOM(run_length); - random_dir = RANDOM(3); - } - switch (random_dir) { - case 0: /* left */ - break; - case 1: /* right */ - g_new.x = -g_new.x; - g_new.y = -g_new.y; - break; - case 2: /* random direction */ - g_new.x = leftright * g_new.x; - g_new.y = leftright * g_new.y; - break; - } - if (color < colors-1) - putcolor(newcol, newrow, color+1); - break; - case random_walk: - if (color < colors-1) - putcolor(newcol, newrow, color+1); - g_new.x = leftright * g_new.x; - g_new.y = leftright * g_new.y; - break; - } - return 1; - -} - -int -Linverse_julia_orbit() -{ - static int random_dir = 0, random_len = 0; - int newrow, newcol; - int color; - - /* - * First, compute new point - */ - switch (major_method) { - case breadth_first: - if (QueueEmpty()) - return -1; - lnew = DeQueueLong(); - break; - case depth_first: - if (QueueEmpty()) - return -1; - lnew = PopLong(); - break; - case random_walk: - lnew = ComplexSqrtLong(lnew.x - CxLong, lnew.y - CyLong); - if (RANDOM(2)) - { - lnew.x = -lnew.x; - lnew.y = -lnew.y; - } - break; - case random_run: - lnew = ComplexSqrtLong(lnew.x - CxLong, lnew.y - CyLong); - if (random_len == 0) - { - random_len = RANDOM(run_length); - random_dir = RANDOM(3); - } - switch (random_dir) { - case 0: /* left */ - break; - case 1: /* right */ - lnew.x = -lnew.x; - lnew.y = -lnew.y; - break; - case 2: /* random direction */ - if (RANDOM(2)) - { - lnew.x = -lnew.x; - lnew.y = -lnew.y; - } - break; - } - } - - /* - * Next, find its pixel position - * - * Note: had to use a bitshift of 21 for this operation because - * otherwise the values of lcvt were truncated. Used bitshift - * of 24 otherwise, for increased precision. - */ - newcol = (int)((multiply(lcvt.a, lnew.x >> (bitshift - 21), 21) + - multiply(lcvt.b, lnew.y >> (bitshift - 21), 21) + lcvt.e) >> 21); - newrow = (int)((multiply(lcvt.c, lnew.x >> (bitshift - 21), 21) + - multiply(lcvt.d, lnew.y >> (bitshift - 21), 21) + lcvt.f) >> 21); - - if (newcol < 1 || newcol >= xdots || newrow < 1 || newrow >= ydots) - { - /* - * MIIM must skip points that are off the screen boundary, - * since it cannot read their color. - */ - if (RANDOM(2)) - color = 1; - else - color = -1; - switch (major_method) { - case breadth_first: - lnew = ComplexSqrtLong(lnew.x - CxLong, lnew.y - CyLong); - EnQueueLong(color * lnew.x, color * lnew.y); - break; - case depth_first: - lnew = ComplexSqrtLong(lnew.x - CxLong, lnew.y - CyLong); - PushLong(color * lnew.x, color * lnew.y); - break; - case random_run: - random_len--; - case random_walk: - break; - } - return 1; - } - - /* - * Read the pixel's color: - * For MIIM, if color >= mxhits, discard the point - * else put the point's children onto the queue - */ - color = getcolor(newcol, newrow); - switch (major_method) { - case breadth_first: - if (color < mxhits) - { - putcolor(newcol, newrow, color+1); - lnew = ComplexSqrtLong(lnew.x - CxLong, lnew.y - CyLong); - EnQueueLong( lnew.x, lnew.y); - EnQueueLong(-lnew.x, -lnew.y); - } - break; - case depth_first: - if (color < mxhits) - { - putcolor(newcol, newrow, color+1); - lnew = ComplexSqrtLong(lnew.x - CxLong, lnew.y - CyLong); - if (minor_method == left_first) - { - if (QueueFullAlmost()) - PushLong(-lnew.x, -lnew.y); - else - { - PushLong( lnew.x, lnew.y); - PushLong(-lnew.x, -lnew.y); - } - } - else - { - if (QueueFullAlmost()) - PushLong( lnew.x, lnew.y); - else - { - PushLong(-lnew.x, -lnew.y); - PushLong( lnew.x, lnew.y); - } - } - } - break; - case random_run: - random_len--; - /* fall through */ - case random_walk: - if (color < colors-1) - putcolor(newcol, newrow, color+1); - break; - } - return 1; -} - -#if 0 -int inverse_julia_orbit(double *x, double *y, double *z) -{ - double r, xo, yo; - int waste; - if (*z >= 1.0) /* this assumes intial value is 1.0!!! */ - { - waste = 20; /* skip these points at first */ - *z = 0; - } - else - waste = 1; - while (waste--) - { - xo = *x - param[0]; - yo = *y - param[1]; - r = sqrt(xo*xo + yo*yo); - *x = sqrt((r + xo)/2); - if (yo < 0) - *x = - *x; - *y = sqrt((r - xo)/2); - if (RANDOM(10) > 4) - { - *x = -(*x); - *y = -(*y); - } - } - return(0); -} -#endif - -int lorenz3dlongorbit(long *l_x, long *l_y, long *l_z) -{ - l_xdt = multiply(*l_x,l_dt,bitshift); - l_ydt = multiply(*l_y,l_dt,bitshift); - l_dx = -multiply(l_adt,*l_x,bitshift) + multiply(l_adt,*l_y,bitshift); - l_dy = multiply(l_bdt,*l_x,bitshift) -l_ydt -multiply(*l_z,l_xdt,bitshift); - l_dz = -multiply(l_cdt,*l_z,bitshift) + multiply(*l_x,l_ydt,bitshift); - - *l_x += l_dx; - *l_y += l_dy; - *l_z += l_dz; - return(0); -} - -int lorenz3d1floatorbit(double *x, double *y, double *z) -{ - double norm; - - xdt = (*x)*dt; - ydt = (*y)*dt; - zdt = (*z)*dt; - - /* 1-lobe Lorenz */ - norm = sqrt((*x)*(*x)+(*y)*(*y)); - dx = (-adt-dt)*(*x) + (adt-bdt)*(*y) + (dt-adt)*norm + ydt*(*z); - dy = (bdt-adt)*(*x) - (adt+dt)*(*y) + (bdt+adt)*norm - xdt*(*z) - - norm*zdt; - dz = (ydt/2) - cdt*(*z); - - *x += dx; - *y += dy; - *z += dz; - return(0); -} - -int lorenz3dfloatorbit(double *x, double *y, double *z) -{ - xdt = (*x)*dt; - ydt = (*y)*dt; - zdt = (*z)*dt; - - /* 2-lobe Lorenz (the original) */ - dx = -adt*(*x) + adt*(*y); - dy = bdt*(*x) - ydt - (*z)*xdt; - dz = -cdt*(*z) + (*x)*ydt; - - *x += dx; - *y += dy; - *z += dz; - return(0); -} - -int lorenz3d3floatorbit(double *x, double *y, double *z) -{ - double norm; - - xdt = (*x)*dt; - ydt = (*y)*dt; - zdt = (*z)*dt; - - /* 3-lobe Lorenz */ - norm = sqrt((*x)*(*x)+(*y)*(*y)); - dx = (-(adt+dt)*(*x) + (adt-bdt+zdt)*(*y)) / 3 + - ((dt-adt)*((*x)*(*x)-(*y)*(*y)) + - 2*(bdt+adt-zdt)*(*x)*(*y))/(3*norm); - dy = ((bdt-adt-zdt)*(*x) - (adt+dt)*(*y)) / 3 + - (2*(adt-dt)*(*x)*(*y) + - (bdt+adt-zdt)*((*x)*(*x)-(*y)*(*y)))/(3*norm); - dz = (3*xdt*(*x)*(*y)-ydt*(*y)*(*y))/2 - cdt*(*z); - - *x += dx; - *y += dy; - *z += dz; - return(0); -} - -int lorenz3d4floatorbit(double *x, double *y, double *z) -{ - xdt = (*x)*dt; - ydt = (*y)*dt; - zdt = (*z)*dt; - - /* 4-lobe Lorenz */ - dx = (-adt*(*x)*(*x)*(*x) + (2*adt+bdt-zdt)*(*x)*(*x)*(*y) + - (adt-2*dt)*(*x)*(*y)*(*y) + (zdt-bdt)*(*y)*(*y)*(*y)) / - (2 * ((*x)*(*x)+(*y)*(*y))); - dy = ((bdt-zdt)*(*x)*(*x)*(*x) + (adt-2*dt)*(*x)*(*x)*(*y) + - (-2*adt-bdt+zdt)*(*x)*(*y)*(*y) - adt*(*y)*(*y)*(*y)) / - (2 * ((*x)*(*x)+(*y)*(*y))); - dz = (2*xdt*(*x)*(*x)*(*y) - 2*xdt*(*y)*(*y)*(*y) - cdt*(*z)); - - *x += dx; - *y += dy; - *z += dz; - return(0); -} - -int henonfloatorbit(double *x, double *y, double *z) -{ - double newx,newy; - *z = *x; /* for warning only */ - newx = 1 + *y - a*(*x)*(*x); - newy = b*(*x); - *x = newx; - *y = newy; - return(0); -} - -int henonlongorbit(long *l_x, long *l_y, long *l_z) -{ - long newx,newy; - *l_z = *l_x; /* for warning only */ - newx = multiply(*l_x,*l_x,bitshift); - newx = multiply(newx,l_a,bitshift); - newx = fudge + *l_y - newx; - newy = multiply(l_b,*l_x,bitshift); - *l_x = newx; - *l_y = newy; - return(0); -} - -int rosslerfloatorbit(double *x, double *y, double *z) -{ - xdt = (*x)*dt; - ydt = (*y)*dt; - - dx = -ydt - (*z)*dt; - dy = xdt + (*y)*adt; - dz = bdt + (*z)*xdt - (*z)*cdt; - - *x += dx; - *y += dy; - *z += dz; - return(0); -} - -int pickoverfloatorbit(double *x, double *y, double *z) -{ - double newx,newy,newz; - newx = sin(a*(*y)) - (*z)*cos(b*(*x)); - newy = (*z)*sin(c*(*x)) - cos(d*(*y)); - newz = sin(*x); - *x = newx; - *y = newy; - *z = newz; - return(0); -} -/* page 149 "Science of Fractal Images" */ -int gingerbreadfloatorbit(double *x, double *y, double *z) -{ - double newx; - *z = *x; /* for warning only */ - newx = 1 - (*y) + fabs(*x); - *y = *x; - *x = newx; - return(0); -} - -int rosslerlongorbit(long *l_x, long *l_y, long *l_z) -{ - l_xdt = multiply(*l_x,l_dt,bitshift); - l_ydt = multiply(*l_y,l_dt,bitshift); - - l_dx = -l_ydt - multiply(*l_z,l_dt,bitshift); - l_dy = l_xdt + multiply(*l_y,l_adt,bitshift); - l_dz = l_bdt + multiply(*l_z,l_xdt,bitshift) - - multiply(*l_z,l_cdt,bitshift); - - *l_x += l_dx; - *l_y += l_dy; - *l_z += l_dz; - - return(0); -} - -/* OSTEP = Orbit Step (and inner orbit value) */ -/* NTURNS = Outside Orbit */ -/* TURN2 = Points per orbit */ -/* a = Angle */ - - -int kamtorusfloatorbit(double *r, double *s, double *z) -{ - double srr; - if (t++ >= l_d) - { - orbit += b; - (*r) = (*s) = orbit/3; - t = 0; - *z = orbit; - if (orbit > c) - return(1); - } - srr = (*s)-(*r)*(*r); - (*s)=(*r)*sinx+srr*cosx; - (*r)=(*r)*cosx-srr*sinx; - return(0); -} - -int kamtoruslongorbit(long *r, long *s, long *z) -{ - long srr; - if (t++ >= l_d) - { - l_orbit += l_b; - (*r) = (*s) = l_orbit/3; - t = 0; - *z = l_orbit; - if (l_orbit > l_c) - return(1); - } - srr = (*s)-multiply((*r),(*r),bitshift); - (*s)=multiply((*r),l_sinx,bitshift)+multiply(srr,l_cosx,bitshift); - (*r)=multiply((*r),l_cosx,bitshift)-multiply(srr,l_sinx,bitshift); - return(0); -} - -int hopalong2dfloatorbit(double *x, double *y, double *z) -{ - double tmp; - *z = *x; /* for warning only */ - tmp = *y - sign(*x)*sqrt(fabs(b*(*x)-c)); - *y = a - *x; - *x = tmp; - return(0); -} - -/* from Michael Peters and HOP */ -int chip2dfloatorbit(double *x, double *y, double *z) -{ - double tmp; - *z = *x; /* for warning only */ - tmp = *y - sign(*x) * cos(sqr(log(fabs(b*(*x)-c)))) - * atan(sqr(log(fabs(c*(*x)-b)))); - *y = a - *x; - *x = tmp; - return(0); -} - -/* from Michael Peters and HOP */ -int quadruptwo2dfloatorbit(double *x, double *y, double *z) -{ - double tmp; - *z = *x; /* for warning only */ - tmp = *y - sign(*x) * sin(log(fabs(b*(*x)-c))) - * atan(sqr(log(fabs(c*(*x)-b)))); - *y = a - *x; - *x = tmp; - return(0); -} - -/* from Michael Peters and HOP */ -int threeply2dfloatorbit(double *x, double *y, double *z) -{ - double tmp; - *z = *x; /* for warning only */ - tmp = *y - sign(*x)*(fabs(sin(*x)*COSB+c-(*x)*SINABC)); - *y = a - *x; - *x = tmp; - return(0); -} - -int martin2dfloatorbit(double *x, double *y, double *z) -{ - double tmp; - *z = *x; /* for warning only */ - tmp = *y - sin(*x); - *y = a - *x; - *x = tmp; - return(0); -} - -int mandelcloudfloat(double *x, double *y, double *z) -{ - double newx,newy,x2,y2; -#ifndef XFRACT - newx = *z; /* for warning only */ -#endif - x2 = (*x)*(*x); - y2 = (*y)*(*y); - if (x2+y2>2) return 1; - newx = x2-y2+a; - newy = 2*(*x)*(*y)+b; - *x = newx; - *y = newy; - return(0); -} - -int dynamfloat(double *x, double *y, double *z) -{ - _CMPLX cp,tmp; - double newx,newy; -#ifndef XFRACT - newx = *z; /* for warning only */ -#endif - cp.x = b* *x; - cp.y = 0; - CMPLXtrig0(cp, tmp); - newy = *y + dt*sin(*x + a*tmp.x); - if (euler) { - *y = newy; - } - - cp.x = b* *y; - cp.y = 0; - CMPLXtrig0(cp, tmp); - newx = *x - dt*sin(*y + a*tmp.x); - *x = newx; - *y = newy; - return(0); -} - -/* dmf */ -#undef LAMBDA -#define LAMBDA param[0] -#define ALPHA param[1] -#define BETA param[2] -#define GAMMA param[3] -#define OMEGA param[4] -#define DEGREE param[5] - -int iconfloatorbit(double *x, double *y, double *z) -{ - - double oldx, oldy, zzbar, zreal, zimag, za, zb, zn, p; - int i; - - oldx = *x; - oldy = *y; - - zzbar = oldx * oldx + oldy * oldy; - zreal = oldx; - zimag = oldy; - - for (i=1; i <= DEGREE-2; i++) { - za = zreal * oldx - zimag * oldy; - zb = zimag * oldx + zreal * oldy; - zreal = za; - zimag = zb; - } - zn = oldx * zreal - oldy * zimag; - p = LAMBDA + ALPHA * zzbar + BETA * zn; - *x = p * oldx + GAMMA * zreal - OMEGA * oldy; - *y = p * oldy - GAMMA * zimag + OMEGA * oldx; - - *z = zzbar; - return(0); -} -#ifdef LAMBDA /* Tim says this will make me a "good citizen" */ -#undef LAMBDA /* Yeah, but you were bad, Dan - LAMBDA was already */ -#undef ALPHA /* defined! TW */ -#undef BETA -#undef GAMMA -#endif - -/* hb */ -#define PAR_A param[0] -#define PAR_B param[1] -#define PAR_C param[2] -#define PAR_D param[3] - -int latoofloatorbit(double *x, double *y, double *z) -{ - - double xold, yold, tmp; - - xold = *z; /* for warning only */ - - xold = *x; - yold = *y; - -/* *x = sin(yold * PAR_B) + PAR_C * sin(xold * PAR_B); */ - old.x = yold * PAR_B; - old.y = 0; /* old = (y * B) + 0i (in the complex)*/ - CMPLXtrig0(old,g_new); - tmp = (double) g_new.x; - old.x = xold * PAR_B; - old.y = 0; /* old = (x * B) + 0i */ - CMPLXtrig1(old,g_new); - *x = PAR_C * g_new.x + tmp; - -/* *y = sin(xold * PAR_A) + PAR_D * sin(yold * PAR_A); */ - old.x = xold * PAR_A; - old.y = 0; /* old = (y * A) + 0i (in the complex)*/ - CMPLXtrig2(old,g_new); - tmp = (double) g_new.x; - old.x = yold * PAR_A; - old.y = 0; /* old = (x * B) + 0i */ - CMPLXtrig3(old,g_new); - *y = PAR_D * g_new.x + tmp; - - return(0); -} - -#undef PAR_A -#undef PAR_B -#undef PAR_C -#undef PAR_D - -/**********************************************************************/ -/* Main fractal engines - put in fractalspecific[fractype].calctype */ -/**********************************************************************/ - -int inverse_julia_per_image() -{ - int color = 0; - - if (resuming) /* can't resume */ - return -1; - - while (color >= 0) /* generate points */ - { - if (check_key()) - { - Free_Queue(); - return -1; - } - color = curfractalspecific->orbitcalc(); - old = g_new; - } - Free_Queue(); - return 0; -} - -int orbit2dfloat() -{ - FILE *fp; - double *soundvar; - double x, y, z; - int color, col, row; - int count; - int oldrow, oldcol; - double *p0, *p1, *p2; - struct affine cvt; - int ret; - - soundvar = p0 = p1 = p2 = NULL; - - fp = open_orbitsave(); - /* setup affine screen coord conversion */ - setup_convert_to_screen(&cvt); - - /* set up projection scheme */ - switch (projection) - { - case 0: p0 = &z; p1 = &x; p2 = &y; break; - case 1: p0 = &x; p1 = &z; p2 = &y; break; - case 2: p0 = &x; p1 = &y; p2 = &z; break; - } - switch (soundflag & SOUNDFLAG_ORBITMASK) - { - case SOUNDFLAG_X: soundvar = &x; break; - case SOUNDFLAG_Y: soundvar = &y; break; - case SOUNDFLAG_Z: soundvar = &z; break; - } - - if (inside > 0) - { - color = inside; - } - else - { - color = 2; - } - - oldcol = oldrow = -1; - x = initorbitfp[0]; - y = initorbitfp[1]; - z = initorbitfp[2]; - coloriter = 0L; - count = ret = 0; - if (maxit > 0x1fffffL || maxct) - { - maxct = 0x7fffffffL; - } - else - { - maxct = maxit*1024L; - } - - if (resuming) - { - start_resume(); - get_resume(sizeof(count), &count, sizeof(color), &color, - sizeof(oldrow), &oldrow, sizeof(oldcol), &oldcol, - sizeof(x), &x, sizeof(y), &y, sizeof(z), &z, sizeof(t), &t, - sizeof(orbit), &orbit, sizeof(coloriter), &coloriter, - 0); - end_resume(); - } - - while (coloriter++ <= maxct) /* loop until keypress or maxit */ - { - if (driver_key_pressed()) - { - driver_mute(); - alloc_resume(100, 1); - put_resume(sizeof(count), &count, sizeof(color), &color, - sizeof(oldrow), &oldrow, sizeof(oldcol), &oldcol, - sizeof(x), &x, sizeof(y), &y, sizeof(z), &z, sizeof(t), &t, - sizeof(orbit), &orbit, sizeof(coloriter), &coloriter, - 0); - ret = -1; - break; - } - if (++count > 1000) - { /* time to switch colors? */ - count = 0; - if (++color >= colors) /* another color to switch to? */ - { - color = 1; /* (don't use the background color) */ - } - } - - col = (int) (cvt.a*x + cvt.b*y + cvt.e); - row = (int) (cvt.c*x + cvt.d*y + cvt.f); - if (col >= 0 && col < xdots && row >= 0 && row < ydots) - { - if ((soundflag & SOUNDFLAG_ORBITMASK) > SOUNDFLAG_BEEP) - { - w_snd((int) (*soundvar*100 + basehertz)); - } - if ((fractype != ICON) && (fractype != LATOO)) - { - if (oldcol != -1 && connect) - { - driver_draw_line(col, row, oldcol, oldrow, color % colors); - } - else - { - (*plot)(col, row, color % colors); - } - } - else - { - /* should this be using plothist()? */ - color = getcolor(col, row)+1; - if (color < colors) /* color sticks on last value */ - { - (*plot)(col, row, color); - } - } - - oldcol = col; - oldrow = row; - } - else if ((long) abs(row) + (long) abs(col) > BAD_PIXEL) /* sanity check */ - { - return ret; - } - else - { - oldrow = oldcol = -1; - } - - if (FORBIT(p0, p1, p2)) - { - break; - } - if (fp) - { - fprintf(fp, "%g %g %g 15\n", *p0, *p1, 0.0); - } - } - if (fp) - { - fclose(fp); - } - return ret; -} - -int orbit2dlong() -{ - FILE *fp; - long *soundvar; - long x, y, z; - int color, col, row; - int count; - int oldrow, oldcol; - long *p0, *p1, *p2; - struct l_affine cvt; - int ret, start; - - start = 1; - soundvar = p0 = p1 = p2 = NULL; - fp = open_orbitsave(); - - /* setup affine screen coord conversion */ - l_setup_convert_to_screen(&cvt); - - /* set up projection scheme */ - switch (projection) - { - case 0: p0 = &z; p1 = &x; p2 = &y; break; - case 1: p0 = &x; p1 = &z; p2 = &y; break; - case 2: p0 = &x; p1 = &y; p2 = &z; break; - } - switch (soundflag & SOUNDFLAG_ORBITMASK) - { - case SOUNDFLAG_X: soundvar = &x; break; - case SOUNDFLAG_Y: soundvar = &y; break; - case SOUNDFLAG_Z: soundvar = &z; break; - } - - if (inside > 0) - { - color = inside; - } - else - { - color = 2; - } - if (color >= colors) - { - color = 1; - } - oldcol = oldrow = -1; - x = initorbitlong[0]; - y = initorbitlong[1]; - z = initorbitlong[2]; - count = ret = 0; - if (maxit > 0x1fffffL || maxct) - { - maxct = 0x7fffffffL; - } - else - { - maxct = maxit*1024L; - } - coloriter = 0L; - - if (resuming) - { - start_resume(); - get_resume(sizeof(count), &count, sizeof(color), &color, - sizeof(oldrow), &oldrow, sizeof(oldcol), &oldcol, - sizeof(x), &x, sizeof(y), &y, sizeof(z), &z, sizeof(t), &t, - sizeof(l_orbit), &l_orbit, sizeof(coloriter), &coloriter, - 0); - end_resume(); - } - - while (coloriter++ <= maxct) /* loop until keypress or maxit */ - { - if (driver_key_pressed()) - { - driver_mute(); - alloc_resume(100, 1); - put_resume(sizeof(count), &count, sizeof(color), &color, - sizeof(oldrow), &oldrow, sizeof(oldcol), &oldcol, - sizeof(x), &x, sizeof(y), &y, sizeof(z), &z, sizeof(t), &t, - sizeof(l_orbit), &l_orbit, sizeof(coloriter), &coloriter, - 0); - ret = -1; - break; - } - if (++count > 1000) - { /* time to switch colors? */ - count = 0; - if (++color >= colors) /* another color to switch to? */ - { - color = 1; /* (don't use the background color) */ - } - } - - col = (int)((multiply(cvt.a, x, bitshift) + multiply(cvt.b, y, bitshift) + cvt.e) >> bitshift); - row = (int)((multiply(cvt.c, x, bitshift) + multiply(cvt.d, y, bitshift) + cvt.f) >> bitshift); - if (overflow) - { - overflow = 0; - return ret; - } - if (col >= 0 && col < xdots && row >= 0 && row < ydots) - { - if ((soundflag & SOUNDFLAG_ORBITMASK) > SOUNDFLAG_BEEP) - { - double yy; - yy = *soundvar; - yy = yy/fudge; - w_snd((int)(yy*100+basehertz)); - } - if (oldcol != -1 && connect) - { - driver_draw_line(col, row, oldcol, oldrow, color%colors); - } - else if (!start) - { - (*plot)(col, row, color%colors); - } - oldcol = col; - oldrow = row; - start = 0; - } - else if ((long)abs(row) + (long)abs(col) > BAD_PIXEL) /* sanity check */ - { - return ret; - } - else - { - oldrow = oldcol = -1; - } - - /* Calculate the next point */ - if (LORBIT(p0, p1, p2)) - { - break; - } - if (fp) - { - fprintf(fp, "%g %g %g 15\n", (double)*p0/fudge, (double)*p1/fudge, 0.0); - } - } - if (fp) - { - fclose(fp); - } - return ret; -} - -static int orbit3dlongcalc(void) -{ - FILE *fp; - unsigned long count; - int oldcol,oldrow; - int oldcol1,oldrow1; - struct long3dvtinf inf; - int color; - int ret; - - /* setup affine screen coord conversion */ - l_setup_convert_to_screen(&inf.cvt); - - oldcol1 = oldrow1 = oldcol = oldrow = -1; - color = 2; - if (color >= colors) - color = 1; - - inf.orbit[0] = initorbitlong[0]; - inf.orbit[1] = initorbitlong[1]; - inf.orbit[2] = initorbitlong[2]; - - if (driver_diskp()) /* this would KILL a disk drive! */ - notdiskmsg(); - - fp = open_orbitsave(); - - count = ret = 0; - if (maxit > 0x1fffffL || maxct) - maxct = 0x7fffffffL; - else - maxct = maxit*1024L; - coloriter = 0L; - while (coloriter++ <= maxct) /* loop until keypress or maxit */ - { - /* calc goes here */ - if (++count > 1000) - { /* time to switch colors? */ - count = 0; - if (++color >= colors) /* another color to switch to? */ - color = 1; /* (don't use the background color) */ - } - if (driver_key_pressed()) - { - driver_mute(); - ret = -1; - break; - } - - LORBIT(&inf.orbit[0],&inf.orbit[1],&inf.orbit[2]); - if (fp) - fprintf(fp,"%g %g %g 15\n",(double)inf.orbit[0]/fudge,(double)inf.orbit[1]/fudge,(double)inf.orbit[2]/fudge); - if (long3dviewtransf(&inf)) - { - /* plot if inside window */ - if (inf.col >= 0) - { - if (realtime) - g_which_image=1; - if ((soundflag & SOUNDFLAG_ORBITMASK) > SOUNDFLAG_BEEP) - { - double yy; - yy = inf.viewvect[((soundflag & SOUNDFLAG_ORBITMASK) - SOUNDFLAG_X)]; - yy = yy/fudge; - w_snd((int)(yy*100+basehertz)); - } - if (oldcol != -1 && connect) - driver_draw_line(inf.col,inf.row,oldcol,oldrow,color%colors); - else - (*plot)(inf.col,inf.row,color%colors); - } - else if (inf.col == -2) - return(ret); - oldcol = inf.col; - oldrow = inf.row; - if (realtime) - { - g_which_image=2; - /* plot if inside window */ - if (inf.col1 >= 0) - { - if (oldcol1 != -1 && connect) - driver_draw_line(inf.col1,inf.row1,oldcol1,oldrow1,color%colors); - else - (*plot)(inf.col1,inf.row1,color%colors); - } - else if (inf.col1 == -2) - return(ret); - oldcol1 = inf.col1; - oldrow1 = inf.row1; - } - } - } - if (fp) - fclose(fp); - return(ret); -} - - -static int orbit3dfloatcalc(void) -{ - FILE *fp; - unsigned long count; - int oldcol,oldrow; - int oldcol1,oldrow1; - int color; - int ret; - struct float3dvtinf inf; - - /* setup affine screen coord conversion */ - setup_convert_to_screen(&inf.cvt); - - oldcol = oldrow = -1; - oldcol1 = oldrow1 = -1; - color = 2; - if (color >= colors) - color = 1; - inf.orbit[0] = initorbitfp[0]; - inf.orbit[1] = initorbitfp[1]; - inf.orbit[2] = initorbitfp[2]; - - if (driver_diskp()) /* this would KILL a disk drive! */ - notdiskmsg(); - - fp = open_orbitsave(); - - ret = 0; - if (maxit > 0x1fffffL || maxct) - maxct = 0x7fffffffL; - else - maxct = maxit*1024L; - count = coloriter = 0L; - while (coloriter++ <= maxct) /* loop until keypress or maxit */ - { - /* calc goes here */ - if (++count > 1000) - { /* time to switch colors? */ - count = 0; - if (++color >= colors) /* another color to switch to? */ - color = 1; /* (don't use the background color) */ - } - - if (driver_key_pressed()) - { - driver_mute(); - ret = -1; - break; - } - - FORBIT(&inf.orbit[0],&inf.orbit[1],&inf.orbit[2]); - if (fp) - fprintf(fp,"%g %g %g 15\n",inf.orbit[0],inf.orbit[1],inf.orbit[2]); - if (float3dviewtransf(&inf)) - { - /* plot if inside window */ - if (inf.col >= 0) - { - if (realtime) - g_which_image=1; - if ((soundflag & SOUNDFLAG_ORBITMASK) > SOUNDFLAG_BEEP) { - w_snd((int)(inf.viewvect[((soundflag & SOUNDFLAG_ORBITMASK) - SOUNDFLAG_X)]*100+basehertz)); - } - if (oldcol != -1 && connect) - driver_draw_line(inf.col,inf.row,oldcol,oldrow,color%colors); - else - (*plot)(inf.col,inf.row,color%colors); - } - else if (inf.col == -2) - return(ret); - oldcol = inf.col; - oldrow = inf.row; - if (realtime) - { - g_which_image=2; - /* plot if inside window */ - if (inf.col1 >= 0) - { - if (oldcol1 != -1 && connect) - driver_draw_line(inf.col1,inf.row1,oldcol1,oldrow1,color%colors); - else - (*plot)(inf.col1,inf.row1,color%colors); - } - else if (inf.col1 == -2) - return(ret); - oldcol1 = inf.col1; - oldrow1 = inf.row1; - } - } - } - if (fp) - fclose(fp); - return(ret); -} - -int dynam2dfloatsetup() -{ - connect = 0; - euler = 0; - d = param[0]; /* number of intervals */ - if (d<0) { - d = -d; - connect = 1; - } - else if (d==0) { - d = 1; - } - if (fractype==DYNAMICFP) { - a = param[2]; /* parameter */ - b = param[3]; /* parameter */ - dt = param[1]; /* step size */ - if (dt<0) { - dt = -dt; - euler = 1; - } - if (dt==0) dt = 0.01; - } - if (outside == SUM) { - plot = plothist; - } - return(1); -} - -/* - * This is the routine called to perform a time-discrete dynamical - * system image. - * The starting positions are taken by stepping across the image in steps - * of parameter1 pixels. maxit differential equation steps are taken, with - * a step size of parameter2. - */ -int dynam2dfloat() -{ - FILE *fp; - double *soundvar = NULL; - double x,y,z; - int color,col,row; - long count; - int oldrow, oldcol; - double *p0,*p1; - struct affine cvt; - int ret; - int xstep, ystep; /* The starting position step number */ - double xpixel, ypixel; /* Our pixel position on the screen */ - - fp = open_orbitsave(); - /* setup affine screen coord conversion */ - setup_convert_to_screen(&cvt); - - p0 = &x; - p1 = &y; - - - if ((soundflag & SOUNDFLAG_ORBITMASK)==SOUNDFLAG_X) - soundvar = &x; - else if ((soundflag & SOUNDFLAG_ORBITMASK)==SOUNDFLAG_Y) - soundvar = &y; - else if ((soundflag & SOUNDFLAG_ORBITMASK)==SOUNDFLAG_Z) - soundvar = &z; - - count = 0; - if (inside > 0) - color = inside; - if (color >= colors) - color = 1; - oldcol = oldrow = -1; - - xstep = -1; - ystep = 0; - - if (resuming) { - start_resume(); - get_resume(sizeof(count),&count, sizeof(color),&color, - sizeof(oldrow),&oldrow, sizeof(oldcol),&oldcol, - sizeof(x),&x, sizeof(y), &y, sizeof(xstep), &xstep, - sizeof(ystep), &ystep, 0); - end_resume(); - } - - ret = 0; - while (1) - { - if (driver_key_pressed()) - { - driver_mute(); - alloc_resume(100,1); - put_resume(sizeof(count),&count, sizeof(color),&color, - sizeof(oldrow),&oldrow, sizeof(oldcol),&oldcol, - sizeof(x),&x, sizeof(y), &y, sizeof(xstep), &xstep, - sizeof(ystep), &ystep, 0); - ret = -1; - break; - } - - xstep ++; - if (xstep>=d) { - xstep = 0; - ystep ++; - if (ystep>d) { - driver_mute(); - ret = -1; - break; - } - } - - xpixel = dxsize*(xstep+.5)/d; - ypixel = dysize*(ystep+.5)/d; - x = (double)((xxmin+delxx*xpixel) + (delxx2*ypixel)); - y = (double)((yymax-delyy*ypixel) + (-delyy2*xpixel)); - if (fractype==MANDELCLOUD) { - a = x; - b = y; - } - oldcol = -1; - - if (++color >= colors) /* another color to switch to? */ - color = 1; /* (don't use the background color) */ - - for (count=0;count= 0 && col < xdots && row >= 0 && row < ydots ) - { - if ((soundflag & SOUNDFLAG_ORBITMASK) > SOUNDFLAG_BEEP) - w_snd((int)(*soundvar*100+basehertz)); - - if (count>=orbit_delay) { - if (oldcol != -1 && connect) - driver_draw_line(col,row,oldcol,oldrow,color%colors); - else if (count > 0 || fractype != MANDELCLOUD) - (*plot)(col,row,color%colors); - } - oldcol = col; - oldrow = row; - } - else if ((long)abs(row) + (long)abs(col) > BAD_PIXEL) /* sanity check */ - return(ret); - else - oldrow = oldcol = -1; - - if (FORBIT(p0, p1, NULL)) - break; - if (fp) - fprintf(fp,"%g %g %g 15\n",*p0,*p1,0.0); - } - } - if (fp) - fclose(fp); - return(ret); -} - -int keep_scrn_coords = 0; -int set_orbit_corners = 0; -long orbit_interval; -double oxmin, oymin, oxmax, oymax, ox3rd, oy3rd; -struct affine o_cvt; -static int o_color; - -int setup_orbits_to_screen(struct affine *scrn_cnvt) -{ - double det, xd, yd; - - det = (ox3rd-oxmin)*(oymin-oymax) + (oymax-oy3rd)*(oxmax-oxmin); - if (det == 0) - return(-1); - xd = dxsize/det; - scrn_cnvt->a = xd*(oymax-oy3rd); - scrn_cnvt->b = xd*(ox3rd-oxmin); - scrn_cnvt->e = -scrn_cnvt->a*oxmin - scrn_cnvt->b*oymax; - - det = (ox3rd-oxmax)*(oymin-oymax) + (oymin-oy3rd)*(oxmax-oxmin); - if (det == 0) - return(-1); - yd = dysize/det; - scrn_cnvt->c = yd*(oymin-oy3rd); - scrn_cnvt->d = yd*(ox3rd-oxmax); - scrn_cnvt->f = -scrn_cnvt->c*oxmin - scrn_cnvt->d*oymax; - return(0); -} - -int plotorbits2dsetup(void) -{ - -#ifndef XFRACT - if (curfractalspecific->isinteger != 0) { - int tofloat = curfractalspecific->tofloat; - if (tofloat == NOFRACTAL) - return(-1); - floatflag = usr_floatflag = 1; /* force floating point */ - curfractalspecific = &fractalspecific[tofloat]; - fractype = tofloat; - } -#endif - - PER_IMAGE(); - - /* setup affine screen coord conversion */ - if (keep_scrn_coords) { - if (setup_orbits_to_screen(&o_cvt)) - return(-1); - } else { - if (setup_convert_to_screen(&o_cvt)) - return(-1); - } - /* set so truncation to int rounds to nearest */ - o_cvt.e += 0.5; - o_cvt.f += 0.5; - - if (orbit_delay >= maxit) /* make sure we get an image */ - orbit_delay = (int)(maxit - 1); - - o_color = 1; - - if (outside == SUM) { - plot = plothist; - } - return(1); -} - -int plotorbits2dfloat(void) -{ - double *soundvar = NULL; - double x,y,z; - int col,row; - long count; - - if (driver_key_pressed()) - { - driver_mute(); - alloc_resume(100,1); - put_resume(sizeof(o_color),&o_color, 0); - return(-1); - } - -#if 0 - col = (int)(o_cvt.a*g_new.x + o_cvt.b*g_new.y + o_cvt.e); - row = (int)(o_cvt.c*g_new.x + o_cvt.d*g_new.y + o_cvt.f); - if ( col >= 0 && col < xdots && row >= 0 && row < ydots ) - (*plot)(col,row,1); - return(0); -#endif - - if ((soundflag & SOUNDFLAG_ORBITMASK)==SOUNDFLAG_X) - soundvar = &x; - else if ((soundflag & SOUNDFLAG_ORBITMASK)==SOUNDFLAG_Y) - soundvar = &y; - else if ((soundflag & SOUNDFLAG_ORBITMASK)==SOUNDFLAG_Z) - soundvar = &z; - - if (resuming) { - start_resume(); - get_resume(sizeof(o_color),&o_color, 0); - end_resume(); - } - - if (inside > 0) - o_color = inside; - else { /* inside <= 0 */ - o_color++; - if (o_color >= colors) /* another color to switch to? */ - o_color = 1; /* (don't use the background color) */ - } - - PER_PIXEL(); /* initialize the calculations */ - - for (count = 0; count < maxit; count++) { - - if (ORBITCALC() == 1 && periodicitycheck) - continue; /* bailed out, don't plot */ - - if (count < orbit_delay || count%orbit_interval) - continue; /* don't plot it */ - - /* else count >= orbit_delay and we want to plot it */ - col = (int)(o_cvt.a*g_new.x + o_cvt.b*g_new.y + o_cvt.e); - row = (int)(o_cvt.c*g_new.x + o_cvt.d*g_new.y + o_cvt.f); -#ifdef XFRACT - if ( col >= 0 && col < xdots && row >= 0 && row < ydots ) -#else -/* don't know why the next line is necessary, the one above should work */ - if ( col > 0 && col < xdots && row > 0 && row < ydots ) -#endif - { /* plot if on the screen */ - if ((soundflag & SOUNDFLAG_ORBITMASK) > SOUNDFLAG_BEEP) - w_snd((int)(*soundvar*100+basehertz)); - - (*plot)(col,row,o_color%colors); - } - else - { /* off screen, don't continue unless periodicity=0 */ - if (periodicitycheck) - return(0); /* skip to next pixel */ - } - } - return(0); -} - -/* this function's only purpose is to manage funnyglasses related */ -/* stuff so the code is not duplicated for ifs3d() and lorenz3d() */ -int funny_glasses_call(int (*calc)(void)) -{ - int status; - status = 0; - if (g_glasses_type) - g_which_image = 1; - else - g_which_image = 0; - plot_setup(); - plot = standardplot; - status = calc(); - if (realtime && g_glasses_type < 3) - { - realtime = 0; - goto done; - } - if (g_glasses_type && status == 0 && display3d) - { - if (g_glasses_type==3) { /* photographer's mode */ - int i; - stopmsg(STOPMSG_INFO_ONLY, - "First image (left eye) is ready. Hit any key to see it,\n" - "then hit to save, hit any other key to create second image."); - for (i = driver_get_key(); i == 's' || i == 'S'; i = driver_get_key()) { - savetodisk(savename); - } - /* is there a better way to clear the screen in graphics mode? */ - driver_set_video_mode(&g_video_entry); - } - g_which_image = 2; - if (curfractalspecific->flags & INFCALC) - curfractalspecific->per_image(); /* reset for 2nd image */ - plot_setup(); - plot = standardplot; - /* is there a better way to clear the graphics screen ? */ - if ((status = calc()) != 0) - goto done; - if (g_glasses_type==3) /* photographer's mode */ - stopmsg(STOPMSG_INFO_ONLY,"Second image (right eye) is ready"); - } -done: - if (g_glasses_type == 4 && sxdots >= 2*xdots) - { - /* turn off view windows so will save properly */ - sxoffs = syoffs = 0; - xdots = sxdots; - ydots = sydots; - viewwindow = 0; - } - return(status); -} - -/* double version - mainly for testing */ -static int ifs3dfloat(void) -{ - int color_method; - FILE *fp; - int color; - - double newx,newy,newz,r,sum; - - int k; - int ret; - - struct float3dvtinf inf; - - float *ffptr; - - /* setup affine screen coord conversion */ - setup_convert_to_screen(&inf.cvt); - srand(1); - color_method = (int)param[0]; - if (driver_diskp()) /* this would KILL a disk drive! */ - notdiskmsg(); - - inf.orbit[0] = 0; - inf.orbit[1] = 0; - inf.orbit[2] = 0; - - fp = open_orbitsave(); - - ret = 0; - if (maxit > 0x1fffffL) - maxct = 0x7fffffffL; - else - maxct = maxit*1024; - coloriter = 0L; - while (coloriter++ <= maxct) /* loop until keypress or maxit */ - { - if (driver_key_pressed()) /* keypress bails out */ - { - ret = -1; - break; - } - r = rand(); /* generate a random number between 0 and 1 */ - r /= RAND_MAX; - - /* pick which iterated function to execute, weighted by probability */ - sum = ifs_defn[12]; /* [0][12] */ - k = 0; - while ( sum < r && ++k < numaffine*IFS3DPARM) - { - sum += ifs_defn[k*IFS3DPARM+12]; - if (ifs_defn[(k+1)*IFS3DPARM+12] == 0) break; /* for safety */ - } - - /* calculate image of last point under selected iterated function */ - ffptr = ifs_defn + k*IFS3DPARM; /* point to first parm in row */ - newx = *ffptr * inf.orbit[0] + - *(ffptr+1) * inf.orbit[1] + - *(ffptr+2) * inf.orbit[2] + *(ffptr+9); - newy = *(ffptr+3) * inf.orbit[0] + - *(ffptr+4) * inf.orbit[1] + - *(ffptr+5) * inf.orbit[2] + *(ffptr+10); - newz = *(ffptr+6) * inf.orbit[0] + - *(ffptr+7) * inf.orbit[1] + - *(ffptr+8) * inf.orbit[2] + *(ffptr+11); - - inf.orbit[0] = newx; - inf.orbit[1] = newy; - inf.orbit[2] = newz; - if (fp) - fprintf(fp,"%g %g %g 15\n",newx,newy,newz); - if (float3dviewtransf(&inf)) - { - /* plot if inside window */ - if (inf.col >= 0) - { - if (realtime) - g_which_image=1; - if (color_method) - color = (k%colors)+1; - else - color = getcolor(inf.col,inf.row)+1; - if ( color < colors ) /* color sticks on last value */ - (*plot)(inf.col,inf.row,color); - } - else if (inf.col == -2) - return(ret); - if (realtime) - { - g_which_image=2; - /* plot if inside window */ - if (inf.col1 >= 0) - { - if (color_method) - color = (k%colors)+1; - else - color = getcolor(inf.col1,inf.row1)+1; - if ( color < colors ) /* color sticks on last value */ - (*plot)(inf.col1,inf.row1,color); - } - else if (inf.col1 == -2) - return(ret); - } - } - } /* end while */ - if (fp) - fclose(fp); - return(ret); -} - -int ifs() /* front-end for ifs2d and ifs3d */ -{ - if (ifs_defn == NULL && ifsload() < 0) - return(-1); - if (driver_diskp()) /* this would KILL a disk drive! */ - notdiskmsg(); - return((ifs_type == 0) ? ifs2d() : ifs3d()); -} - - -/* IFS logic shamelessly converted to integer math */ -static int ifs2d(void) -{ - int color_method; - FILE *fp; - int col; - int row; - int color; - int ret; - long *localifs; - long *lfptr; - long x,y,newx,newy,r,sum, tempr; - - int i,j,k; - struct l_affine cvt; - /* setup affine screen coord conversion */ - l_setup_convert_to_screen(&cvt); - - srand(1); - color_method = (int)param[0]; - localifs = (long *) malloc(numaffine*IFSPARM*sizeof(long)); - if (localifs == NULL) - { - stopmsg(0,insufficient_ifs_mem); - return(-1); - } - - for (i = 0; i < numaffine; i++) /* fill in the local IFS array */ - for (j = 0; j < IFSPARM; j++) - localifs[i*IFSPARM+j] = (long)(ifs_defn[i*IFSPARM+j] * fudge); - - tempr = fudge / 32767; /* find the proper rand() fudge */ - - fp = open_orbitsave(); - - x = y = 0; - ret = 0; - if (maxit > 0x1fffffL) - maxct = 0x7fffffffL; - else - maxct = maxit*1024L; - coloriter = 0L; - while (coloriter++ <= maxct) /* loop until keypress or maxit */ - { - if (driver_key_pressed()) /* keypress bails out */ - { - ret = -1; - break; - } - r = rand15(); /* generate fudged random number between 0 and 1 */ - r *= tempr; - - /* pick which iterated function to execute, weighted by probability */ - sum = localifs[6]; /* [0][6] */ - k = 0; - while ( sum < r && k < numaffine-1) /* fixed bug of error if sum < 1 */ - sum += localifs[++k*IFSPARM+6]; - /* calculate image of last point under selected iterated function */ - lfptr = localifs + k*IFSPARM; /* point to first parm in row */ - newx = multiply(lfptr[0],x,bitshift) + - multiply(lfptr[1],y,bitshift) + lfptr[4]; - newy = multiply(lfptr[2],x,bitshift) + - multiply(lfptr[3],y,bitshift) + lfptr[5]; - x = newx; - y = newy; - if (fp) - fprintf(fp,"%g %g %g 15\n",(double)newx/fudge,(double)newy/fudge,0.0); - - /* plot if inside window */ - col = (int)((multiply(cvt.a,x,bitshift) + multiply(cvt.b,y,bitshift) + cvt.e) >> bitshift); - row = (int)((multiply(cvt.c,x,bitshift) + multiply(cvt.d,y,bitshift) + cvt.f) >> bitshift); - if ( col >= 0 && col < xdots && row >= 0 && row < ydots ) - { - /* color is count of hits on this pixel */ - if (color_method) - color = (k%colors)+1; - else - color = getcolor(col,row)+1; - if ( color < colors ) /* color sticks on last value */ - (*plot)(col,row,color); - } - else if ((long)abs(row) + (long)abs(col) > BAD_PIXEL) /* sanity check */ - return(ret); - } - if (fp) - fclose(fp); - free(localifs); - return(ret); -} - -static int ifs3dlong(void) -{ - int color_method; - FILE *fp; - int color; - int ret; - - long *localifs; - long *lfptr; - long newx,newy,newz,r,sum, tempr; - - int i,j,k; - - struct long3dvtinf inf; - srand(1); - color_method = (int)param[0]; - localifs = (long *) malloc(numaffine*IFS3DPARM*sizeof(long)); - if (localifs == NULL) - { - stopmsg(0,insufficient_ifs_mem); - return(-1); - } - - /* setup affine screen coord conversion */ - l_setup_convert_to_screen(&inf.cvt); - - for (i = 0; i < numaffine; i++) /* fill in the local IFS array */ - for (j = 0; j < IFS3DPARM; j++) - localifs[i*IFS3DPARM+j] = (long)(ifs_defn[i*IFS3DPARM+j] * fudge); - - tempr = fudge / 32767; /* find the proper rand() fudge */ - - inf.orbit[0] = 0; - inf.orbit[1] = 0; - inf.orbit[2] = 0; - - fp = open_orbitsave(); - - ret = 0; - if (maxit > 0x1fffffL) - maxct = 0x7fffffffL; - else - maxct = maxit*1024L; - coloriter = 0L; - while (coloriter++ <= maxct) /* loop until keypress or maxit */ - { - if (driver_key_pressed()) /* keypress bails out */ - { - ret = -1; - break; - } - r = rand15(); /* generate fudged random number between 0 and 1 */ - r *= tempr; - - /* pick which iterated function to execute, weighted by probability */ - sum = localifs[12]; /* [0][12] */ - k = 0; - while ( sum < r && ++k < numaffine*IFS3DPARM) - { - sum += localifs[k*IFS3DPARM+12]; - if (ifs_defn[(k+1)*IFS3DPARM+12] == 0) break; /* for safety */ - } - - /* calculate image of last point under selected iterated function */ - lfptr = localifs + k*IFS3DPARM; /* point to first parm in row */ - - /* calculate image of last point under selected iterated function */ - newx = multiply(lfptr[0], inf.orbit[0], bitshift) + - multiply(lfptr[1], inf.orbit[1], bitshift) + - multiply(lfptr[2], inf.orbit[2], bitshift) + lfptr[9]; - newy = multiply(lfptr[3], inf.orbit[0], bitshift) + - multiply(lfptr[4], inf.orbit[1], bitshift) + - multiply(lfptr[5], inf.orbit[2], bitshift) + lfptr[10]; - newz = multiply(lfptr[6], inf.orbit[0], bitshift) + - multiply(lfptr[7], inf.orbit[1], bitshift) + - multiply(lfptr[8], inf.orbit[2], bitshift) + lfptr[11]; - - inf.orbit[0] = newx; - inf.orbit[1] = newy; - inf.orbit[2] = newz; - if (fp) - fprintf(fp,"%g %g %g 15\n",(double)newx/fudge,(double)newy/fudge,(double)newz/fudge); - - if (long3dviewtransf(&inf)) - { - if ((long)abs(inf.row) + (long)abs(inf.col) > BAD_PIXEL) /* sanity check */ - return(ret); - /* plot if inside window */ - if (inf.col >= 0) - { - if (realtime) - g_which_image=1; - if (color_method) - color = (k%colors)+1; - else - color = getcolor(inf.col,inf.row)+1; - if ( color < colors ) /* color sticks on last value */ - (*plot)(inf.col,inf.row,color); - } - if (realtime) - { - g_which_image=2; - /* plot if inside window */ - if (inf.col1 >= 0) - { - if (color_method) - color = (k%colors)+1; - else - color = getcolor(inf.col1,inf.row1)+1; - if ( color < colors ) /* color sticks on last value */ - (*plot)(inf.col1,inf.row1,color); - } - } - } - } - if (fp) - fclose(fp); - free(localifs); - return(ret); -} - -static void setupmatrix(MATRIX doublemat) -{ - /* build transformation matrix */ - identity (doublemat); - - /* apply rotations - uses the same rotation variables as line3d.c */ - xrot ((double)XROT / 57.29577,doublemat); - yrot ((double)YROT / 57.29577,doublemat); - zrot ((double)ZROT / 57.29577,doublemat); - - /* apply scale */ -/* scale((double)XSCALE/100.0,(double)YSCALE/100.0,(double)ROUGH/100.0,doublemat);*/ - -} - -int orbit3dfloat() -{ - display3d = -1; - if (0 < g_glasses_type && g_glasses_type < 3) - realtime = 1; - else - realtime = 0; - return(funny_glasses_call(orbit3dfloatcalc)); -} - -int orbit3dlong() -{ - display3d = -1; - if (0 < g_glasses_type && g_glasses_type < 3) - realtime = 1; - else - realtime = 0; - return(funny_glasses_call(orbit3dlongcalc)); -} - -static int ifs3d(void) -{ - display3d = -1; - - if (0 < g_glasses_type && g_glasses_type < 3) - realtime = 1; - else - realtime = 0; - if (floatflag) - return(funny_glasses_call(ifs3dfloat)); /* double version of ifs3d */ - else - return(funny_glasses_call(ifs3dlong)); /* long version of ifs3d */ -} - - - -static int long3dviewtransf(struct long3dvtinf *inf) -{ - int i,j; - double tmpx, tmpy, tmpz; - long tmp; - - if (coloriter == 1) /* initialize on first call */ - { - for (i=0; i<3; i++) - { - inf->minvals[i] = 1L << 30; - inf->maxvals[i] = -inf->minvals[i]; - } - setupmatrix(inf->doublemat); - if (realtime) - setupmatrix(inf->doublemat1); - /* copy xform matrix to long for for fixed point math */ - for (i = 0; i < 4; i++) - for (j = 0; j < 4; j++) - { - inf->longmat[i][j] = (long)(inf->doublemat[i][j] * fudge); - if (realtime) - inf->longmat1[i][j] = (long)(inf->doublemat1[i][j] * fudge); - } - } - - /* 3D VIEWING TRANSFORM */ - longvmult(inf->orbit,inf->longmat,inf->viewvect,bitshift); - if (realtime) - longvmult(inf->orbit,inf->longmat1,inf->viewvect1,bitshift); - - if (coloriter <= waste) /* waste this many points to find minz and maxz */ - { - /* find minz and maxz */ - for (i=0; i<3; i++) - if ((tmp = inf->viewvect[i]) < inf->minvals[i]) - inf->minvals[i] = tmp; - else if (tmp > inf->maxvals[i]) - inf->maxvals[i] = tmp; - - if (coloriter == waste) /* time to work it out */ - { - inf->iview[0] = inf->iview[1] = 0L; /* center viewer on origin */ - - /* z value of user's eye - should be more negative than extreme - negative part of image */ - inf->iview[2] = (long)((inf->minvals[2]-inf->maxvals[2])*(double)ZVIEWER/100.0); - - /* center image on origin */ - tmpx = (-inf->minvals[0]-inf->maxvals[0])/(2.0*fudge); /* center x */ - tmpy = (-inf->minvals[1]-inf->maxvals[1])/(2.0*fudge); /* center y */ - - /* apply perspective shift */ - tmpx += ((double)xshift*(xxmax-xxmin))/(xdots); - tmpy += ((double)yshift*(yymax-yymin))/(ydots); - tmpz = -((double)inf->maxvals[2]) / fudge; - trans(tmpx,tmpy,tmpz,inf->doublemat); - - if (realtime) - { - /* center image on origin */ - tmpx = (-inf->minvals[0]-inf->maxvals[0])/(2.0*fudge); /* center x */ - tmpy = (-inf->minvals[1]-inf->maxvals[1])/(2.0*fudge); /* center y */ - - tmpx += ((double)xshift1*(xxmax-xxmin))/(xdots); - tmpy += ((double)yshift1*(yymax-yymin))/(ydots); - tmpz = -((double)inf->maxvals[2]) / fudge; - trans(tmpx,tmpy,tmpz,inf->doublemat1); - } - for (i=0; i<3; i++) - view[i] = (double)inf->iview[i] / fudge; - - /* copy xform matrix to long for for fixed point math */ - for (i = 0; i < 4; i++) - for (j = 0; j < 4; j++) - { - inf->longmat[i][j] = (long)(inf->doublemat[i][j] * fudge); - if (realtime) - inf->longmat1[i][j] = (long)(inf->doublemat1[i][j] * fudge); - } - } - return(0); - } - - /* apply perspective if requested */ - if (ZVIEWER) - { - if (debugflag==22 || ZVIEWER < 100) /* use float for small persp */ - { - /* use float perspective calc */ - VECTOR tmpv; - for (i=0; i<3; i++) - tmpv[i] = (double)inf->viewvect[i] / fudge; - perspective(tmpv); - for (i=0; i<3; i++) - inf->viewvect[i] = (long)(tmpv[i]*fudge); - if (realtime) - { - for (i=0; i<3; i++) - tmpv[i] = (double)inf->viewvect1[i] / fudge; - perspective(tmpv); - for (i=0; i<3; i++) - inf->viewvect1[i] = (long)(tmpv[i]*fudge); - } - } - else - { - longpersp(inf->viewvect,inf->iview,bitshift); - if (realtime) - longpersp(inf->viewvect1,inf->iview,bitshift); - } - } - - /* work out the screen positions */ - inf->row = (int)(((multiply(inf->cvt.c,inf->viewvect[0],bitshift) + - multiply(inf->cvt.d,inf->viewvect[1],bitshift) + inf->cvt.f) - >> bitshift) - + yyadjust); - inf->col = (int)(((multiply(inf->cvt.a,inf->viewvect[0],bitshift) + - multiply(inf->cvt.b,inf->viewvect[1],bitshift) + inf->cvt.e) - >> bitshift) - + xxadjust); - if (inf->col < 0 || inf->col >= xdots || inf->row < 0 || inf->row >= ydots) - { - if ((long)abs(inf->col)+(long)abs(inf->row) > BAD_PIXEL) - inf->col= inf->row = -2; - else - inf->col= inf->row = -1; - } - if (realtime) - { - inf->row1 = (int)(((multiply(inf->cvt.c,inf->viewvect1[0],bitshift) + - multiply(inf->cvt.d,inf->viewvect1[1],bitshift) + - inf->cvt.f) >> bitshift) - + yyadjust1); - inf->col1 = (int)(((multiply(inf->cvt.a,inf->viewvect1[0],bitshift) + - multiply(inf->cvt.b,inf->viewvect1[1],bitshift) + - inf->cvt.e) >> bitshift) - + xxadjust1); - if (inf->col1 < 0 || inf->col1 >= xdots || inf->row1 < 0 || inf->row1 >= ydots) - { - if ((long)abs(inf->col1)+(long)abs(inf->row1) > BAD_PIXEL) - inf->col1= inf->row1 = -2; - else - inf->col1= inf->row1 = -1; - } - } - return(1); -} - -static int float3dviewtransf(struct float3dvtinf *inf) -{ - int i; - double tmpx, tmpy, tmpz; - double tmp; - - if (coloriter == 1) /* initialize on first call */ - { - for (i=0; i<3; i++) - { - inf->minvals[i] = 100000.0; /* impossible value */ - inf->maxvals[i] = -100000.0; - } - setupmatrix(inf->doublemat); - if (realtime) - setupmatrix(inf->doublemat1); - } - - /* 3D VIEWING TRANSFORM */ - vmult(inf->orbit,inf->doublemat,inf->viewvect ); - if (realtime) - vmult(inf->orbit,inf->doublemat1,inf->viewvect1); - - if (coloriter <= waste) /* waste this many points to find minz and maxz */ - { - /* find minz and maxz */ - for (i=0; i<3; i++) - if ((tmp = inf->viewvect[i]) < inf->minvals[i]) - inf->minvals[i] = tmp; - else if (tmp > inf->maxvals[i]) - inf->maxvals[i] = tmp; - if (coloriter == waste) /* time to work it out */ - { - view[0] = view[1] = 0; /* center on origin */ - /* z value of user's eye - should be more negative than extreme - negative part of image */ - view[2] = (inf->minvals[2]-inf->maxvals[2])*(double)ZVIEWER/100.0; - - /* center image on origin */ - tmpx = (-inf->minvals[0]-inf->maxvals[0])/(2.0); /* center x */ - tmpy = (-inf->minvals[1]-inf->maxvals[1])/(2.0); /* center y */ - - /* apply perspective shift */ - tmpx += ((double)xshift*(xxmax-xxmin))/(xdots); - tmpy += ((double)yshift*(yymax-yymin))/(ydots); - tmpz = -(inf->maxvals[2]); - trans(tmpx,tmpy,tmpz,inf->doublemat); - - if (realtime) - { - /* center image on origin */ - tmpx = (-inf->minvals[0]-inf->maxvals[0])/(2.0); /* center x */ - tmpy = (-inf->minvals[1]-inf->maxvals[1])/(2.0); /* center y */ - - tmpx += ((double)xshift1*(xxmax-xxmin))/(xdots); - tmpy += ((double)yshift1*(yymax-yymin))/(ydots); - tmpz = -(inf->maxvals[2]); - trans(tmpx,tmpy,tmpz,inf->doublemat1); - } - } - return(0); - } - - /* apply perspective if requested */ - if (ZVIEWER) - { - perspective(inf->viewvect); - if (realtime) - perspective(inf->viewvect1); - } - inf->row = (int)(inf->cvt.c*inf->viewvect[0] + inf->cvt.d*inf->viewvect[1] - + inf->cvt.f + yyadjust); - inf->col = (int)(inf->cvt.a*inf->viewvect[0] + inf->cvt.b*inf->viewvect[1] - + inf->cvt.e + xxadjust); - if (inf->col < 0 || inf->col >= xdots || inf->row < 0 || inf->row >= ydots) - { - if ((long)abs(inf->col)+(long)abs(inf->row) > BAD_PIXEL) - inf->col= inf->row = -2; - else - inf->col= inf->row = -1; - } - if (realtime) - { - inf->row1 = (int)(inf->cvt.c*inf->viewvect1[0] + inf->cvt.d*inf->viewvect1[1] - + inf->cvt.f + yyadjust1); - inf->col1 = (int)(inf->cvt.a*inf->viewvect1[0] + inf->cvt.b*inf->viewvect1[1] - + inf->cvt.e + xxadjust1); - if (inf->col1 < 0 || inf->col1 >= xdots || inf->row1 < 0 || inf->row1 >= ydots) - { - if ((long)abs(inf->col1)+(long)abs(inf->row1) > BAD_PIXEL) - inf->col1= inf->row1 = -2; - else - inf->col1= inf->row1 = -1; - } - } - return(1); -} - -static FILE *open_orbitsave(void) -{ - FILE *fp; - if ((orbitsave&1) && (fp = fopen("orbits.raw", "w")) != NULL) - { - fprintf(fp,"pointlist x y z color\n"); - return fp; - } - return NULL; -} - -/* Plot a histogram by incrementing the pixel each time it it touched */ -static void _fastcall plothist(int x, int y, int color) -{ - color = getcolor(x,y)+1; - if (color >= colors) - color = 1; - putcolor(x,y,color); -} - diff --git a/fractint/common/lsys.c b/fractint/common/lsys.c deleted file mode 100644 index ee6422beb..000000000 --- a/fractint/common/lsys.c +++ /dev/null @@ -1,1010 +0,0 @@ - -#include -#if !defined(_WIN32) -#include -#endif - - /* see Fractint.c for a description of the "include" hierarchy */ -#include "port.h" -#include "prototyp.h" -#include "lsys.h" -#include "drivers.h" - -struct lsys_cmd { - void (*f)(struct lsys_turtlestatei *); - long n; - char ch; -}; - -static int _fastcall readLSystemFile(char *); -static void _fastcall free_rules_mem(void); -static int _fastcall rule_present(char symbol); -static int _fastcall save_rule(char *,char **); -static int _fastcall append_rule(char *rule, int index); -static void free_lcmds(void); -static struct lsys_cmd * _fastcall findsize(struct lsys_cmd *,struct lsys_turtlestatei *, struct lsys_cmd **,int); -static struct lsys_cmd * drawLSysI(struct lsys_cmd *command,struct lsys_turtlestatei *ts, struct lsys_cmd **rules,int depth); -static int lsysi_findscale(struct lsys_cmd *command, struct lsys_turtlestatei *ts, struct lsys_cmd **rules, int depth); -static struct lsys_cmd *LSysISizeTransform(char *s, struct lsys_turtlestatei *ts); -static struct lsys_cmd *LSysIDrawTransform(char *s, struct lsys_turtlestatei *ts); -static void _fastcall lsysi_dosincos(void); - -static void lsysi_doslash(struct lsys_turtlestatei *cmd); -static void lsysi_dobslash(struct lsys_turtlestatei *cmd); -static void lsysi_doat(struct lsys_turtlestatei *cmd); -static void lsysi_dopipe(struct lsys_turtlestatei *cmd); -static void lsysi_dosizedm(struct lsys_turtlestatei *cmd); -static void lsysi_dosizegf(struct lsys_turtlestatei *cmd); -static void lsysi_dodrawd(struct lsys_turtlestatei *cmd); -static void lsysi_dodrawm(struct lsys_turtlestatei *cmd); -static void lsysi_dodrawg(struct lsys_turtlestatei *cmd); -static void lsysi_dodrawf(struct lsys_turtlestatei *cmd); -static void lsysi_dodrawc(struct lsys_turtlestatei *cmd); -static void lsysi_dodrawgt(struct lsys_turtlestatei *cmd); -static void lsysi_dodrawlt(struct lsys_turtlestatei *cmd); - -/* Some notes to Adrian from PB, made when I integrated with v15: - printfs changed to work with new user interface - bug at end of readLSystemFile, the line which said rulind=0 fixed - to say *rulind=0 - the calloc was not worthwhile, it was just for a 54 byte area, cheaper - to keep it as a static; but there was a static 201 char buffer I - changed to not be static - use of strdup was a nono, caused problems running out of space cause - the memory allocated each time was never freed; I've changed to - use memory and to free when done - */ - -#define sins ((long *)(boxy)) -#define coss (((long *)(boxy)+50)) /* 50 after the start of sins */ -static char *ruleptrs[MAXRULES]; -static struct lsys_cmd *rules2[MAXRULES]; -char maxangle; -static char loaded=0; - - -int _fastcall ispow2(int n) -{ - return (n == (n & -n)); -} - -LDBL _fastcall getnumber(char **str) -{ - char numstr[30]; - LDBL ret; - int i,root,inverse; - - root=0; - inverse=0; - strcpy(numstr,""); - (*str)++; - switch (**str) - { - case 'q': - root=1; - (*str)++; - break; - case 'i': - inverse=1; - (*str)++; - break; - } - switch (**str) - { - case 'q': - root=1; - (*str)++; - break; - case 'i': - inverse=1; - (*str)++; - break; - } - i=0; - while ((**str<='9' && **str>='0') || **str=='.') - { - numstr[i++]= **str; - (*str)++; - } - (*str)--; - numstr[i]=0; - ret=atof(numstr); - if (ret <= 0.0) /* this is a sanity check, JCO 8/31/94 */ - return 0; - if (root) - ret=sqrtl(ret); - if (inverse) - ret = 1.0/ret; - return ret; -} - -static int _fastcall readLSystemFile(char *str) -{ - int c; - char **rulind; - int err=0; - int linenum,check=0; - char inline1[MAX_LSYS_LINE_LEN+1],fixed[MAX_LSYS_LINE_LEN+1],*word; - FILE *infile; - char msgbuf[481]; /* enough for 6 full lines */ - - if (find_file_item(LFileName,str,&infile, 2) < 0) - return -1; - while ((c = fgetc(infile)) != '{') - if (c == EOF) return -1; - maxangle=0; - for (linenum=0; linenum -1) /* Max line length chars */ - { - linenum++; - if ((word = strchr(inline1,';')) != NULL) /* strip comment */ - *word = 0; - strlwr(inline1); - - if ((int)strspn(inline1," \t\n") < (int)strlen(inline1)) /* not a blank line */ - { - word=strtok(inline1," =\t\n"); - if (!strcmp(word,"axiom")) - { - if (save_rule(strtok(NULL," \t\n"),&ruleptrs[0])) { - strcat(msgbuf,"Error: out of memory\n"); - ++err; - break; - } - check=1; - } - else if (!strcmp(word,"angle")) - { - maxangle=(char)atoi(strtok(NULL," \t\n")); - check=1; - } - else if (!strcmp(word,"}")) - break; - else if (!word[1]) - { - char *temp; - int index, memerr = 0; - - if (strchr("+-/\\@|!c<>][", *word)) - { - sprintf(&msgbuf[strlen(msgbuf)], - "Syntax error line %d: Redefined reserved symbol %s\n",linenum,word); - ++err; - break; - } - temp = strtok(NULL," =\t\n"); - index = rule_present(*word); - - if (!index) - { - strcpy(fixed,word); - if (temp) - strcat(fixed,temp); - memerr = save_rule(fixed,rulind++); - } - else if (temp) - { - strcpy(fixed,temp); - memerr = append_rule(fixed,index); - } - if (memerr) { - strcat(msgbuf, "Error: out of memory\n"); - ++err; - break; - } - check=1; - } - else - if (err<6) - { - sprintf(&msgbuf[strlen(msgbuf)], - "Syntax error line %d: %s\n",linenum,word); - ++err; - } - if (check) - { - check=0; - if ((word=strtok(NULL," \t\n"))!=NULL) - if (err<6) - { - sprintf(&msgbuf[strlen(msgbuf)], - "Extra text after command line %d: %s\n",linenum,word); - ++err; - } - } - } - } - fclose(infile); - if (!ruleptrs[0] && err<6) - { - strcat(msgbuf,"Error: no axiom\n"); - ++err; - } - if ((maxangle<3||maxangle>50) && err<6) - { - strcat(msgbuf,"Error: illegal or missing angle\n"); - ++err; - } - if (err) - { - msgbuf[strlen(msgbuf)-1]=0; /* strip trailing \n */ - stopmsg(0,msgbuf); - return -1; - } - *rulind=NULL; - return 0; -} - -int Lsystem(void) -{ - int order; - char **rulesc; - struct lsys_cmd **sc; - int stackoflow = 0; - - if ( (!loaded) && LLoad()) - return -1; - - overflow = 0; /* reset integer math overflow flag */ - - order=(int)param[0]; - if (order<=0) - order=0; - if (usr_floatflag) - overflow = 1; - else { - struct lsys_turtlestatei ts; - - ts.stackoflow = 0; - ts.maxangle = maxangle; - ts.dmaxangle = (char)(maxangle - 1); - - sc = rules2; - for (rulesc = ruleptrs; *rulesc; rulesc++) - *sc++ = LSysISizeTransform(*rulesc, &ts); - *sc = NULL; - - lsysi_dosincos(); - if (lsysi_findscale(rules2[0], &ts, &rules2[1], order)) { - ts.realangle = ts.angle = ts.reverse = 0; - - free_lcmds(); - sc = rules2; - for (rulesc = ruleptrs; *rulesc; rulesc++) - *sc++ = LSysIDrawTransform(*rulesc, &ts); - *sc = NULL; - - /* !! HOW ABOUT A BETTER WAY OF PICKING THE DEFAULT DRAWING COLOR */ - if ((ts.curcolor=15) > colors) - ts.curcolor=(char)(colors-1); - drawLSysI(rules2[0], &ts, &rules2[1], order); - } - stackoflow = ts.stackoflow; - } - - if (stackoflow) { - stopmsg(0, "insufficient memory, try a lower order"); - } - else if (overflow) { - struct lsys_turtlestatef ts; - - overflow = 0; - - ts.stackoflow = 0; - ts.maxangle = maxangle; - ts.dmaxangle = (char)(maxangle - 1); - - sc = rules2; - for (rulesc = ruleptrs; *rulesc; rulesc++) - *sc++ = LSysFSizeTransform(*rulesc, &ts); - *sc = NULL; - - lsysf_dosincos(); - if (lsysf_findscale(rules2[0], &ts, &rules2[1], order)) { - ts.realangle = ts.angle = ts.reverse = 0; - - free_lcmds(); - sc = rules2; - for (rulesc = ruleptrs; *rulesc; rulesc++) - *sc++ = LSysFDrawTransform(*rulesc, &ts); - *sc = NULL; - - /* !! HOW ABOUT A BETTER WAY OF PICKING THE DEFAULT DRAWING COLOR */ - if ((ts.curcolor=15) > colors) - ts.curcolor=(char)(colors-1); - lsys_prepfpu(&ts); - drawLSysF(rules2[0], &ts, &rules2[1], order); - lsys_donefpu(&ts); - } - overflow = 0; - } - free_rules_mem(); - free_lcmds(); - loaded=0; - return 0; -} - -int LLoad(void) -{ - if (readLSystemFile(LName)) { /* error occurred */ - free_rules_mem(); - loaded=0; - return -1; - } - loaded=1; - return 0; -} - -static void _fastcall free_rules_mem(void) -{ - int i; - for (i=0; i=0) *(tmpfar++)= *(rule++); - return 0; -} - -static int _fastcall append_rule(char *rule, int index) -{ - char *dst, *old, *sav; - int i, j; - - old = sav = ruleptrs[index]; - for (i = 0; *(old++); i++) - ; - j = (int) strlen(rule) + 1; - dst = (char *)malloc((long)(i + j)); - if (dst == NULL) - return -1; - - old = sav; - ruleptrs[index] = dst; - while (i-- > 0) *(dst++) = *(old++); - while (j-- > 0) *(dst++) = *(rule++); - free(sav); - return 0; -} - -static void free_lcmds(void) -{ - struct lsys_cmd **sc = rules2; - - while (*sc) - free(*sc++); -} - -#if defined(XFRACT) || defined(_WIN32) -#define lsysi_doslash_386 lsysi_doslash -#define lsysi_dobslash_386 lsysi_dobslash -#define lsys_doat lsysi_doat -#define lsys_dosizegf lsysi_dosizegf -#define lsys_dodrawg lsysi_dodrawg -void lsys_prepfpu(struct lsys_turtlestatef *x) { } -void lsys_donefpu(struct lsys_turtlestatef *x) { } -#endif - -/* integer specific routines */ - -#if defined(XFRACT) || defined(_WIN32) -static void lsysi_doplus(struct lsys_turtlestatei *cmd) -{ - if (cmd->reverse) { - if (++cmd->angle == cmd->maxangle) - cmd->angle = 0; - } - else { - if (cmd->angle) - cmd->angle--; - else - cmd->angle = cmd->dmaxangle; - } -} -#else -extern void lsysi_doplus(struct lsys_turtlestatei *cmd); -#endif - -#if defined(XFRACT) || defined(_WIN32) -/* This is the same as lsys_doplus, except maxangle is a power of 2. */ -static void lsysi_doplus_pow2(struct lsys_turtlestatei *cmd) -{ - if (cmd->reverse) { - cmd->angle++; - cmd->angle &= cmd->dmaxangle; - } - else { - cmd->angle--; - cmd->angle &= cmd->dmaxangle; - } -} -#else -extern void lsysi_doplus_pow2(struct lsys_turtlestatei *cmd); -#endif - -#if defined(XFRACT) || defined(_WIN32) -static void lsysi_dominus(struct lsys_turtlestatei *cmd) -{ - if (cmd->reverse) { - if (cmd->angle) - cmd->angle--; - else - cmd->angle = cmd->dmaxangle; - } - else { - if (++cmd->angle == cmd->maxangle) - cmd->angle = 0; - } -} -#else -extern void lsysi_dominus(struct lsys_turtlestatei *cmd); -#endif - -#if defined(XFRACT) || defined(_WIN32) -static void lsysi_dominus_pow2(struct lsys_turtlestatei *cmd) -{ - if (cmd->reverse) { - cmd->angle--; - cmd->angle &= cmd->dmaxangle; - } - else { - cmd->angle++; - cmd->angle &= cmd->dmaxangle; - } -} -#else -extern void lsysi_dominus_pow2(struct lsys_turtlestatei *cmd); -#endif - -static void lsysi_doslash(struct lsys_turtlestatei *cmd) -{ - if (cmd->reverse) - cmd->realangle -= cmd->num; - else - cmd->realangle += cmd->num; -} - -#if !defined(XFRACT) && !defined(_WIN32) -extern void lsysi_doslash_386(struct lsys_turtlestatei *cmd); -#endif - -static void lsysi_dobslash(struct lsys_turtlestatei *cmd) -{ - if (cmd->reverse) - cmd->realangle += cmd->num; - else - cmd->realangle -= cmd->num; -} - -#if !defined(XFRACT) && !defined(_WIN32) -extern void lsysi_dobslash_386(struct lsys_turtlestatei *cmd); -#endif - -static void lsysi_doat(struct lsys_turtlestatei *cmd) -{ - cmd->size = multiply(cmd->size, cmd->num, 19); -} - -static void lsysi_dopipe(struct lsys_turtlestatei *cmd) -{ - cmd->angle = (char)(cmd->angle + (char)(cmd->maxangle / 2)); - cmd->angle %= cmd->maxangle; -} - -#if defined(XFRACT) || defined(_WIN32) -static void lsysi_dopipe_pow2(struct lsys_turtlestatei *cmd) -{ - cmd->angle += cmd->maxangle >> 1; - cmd->angle &= cmd->dmaxangle; -} -#else -extern void lsysi_dopipe_pow2(struct lsys_turtlestatei *cmd); -#endif - -#if defined(XFRACT) || defined(_WIN32) -static void lsysi_dobang(struct lsys_turtlestatei *cmd) -{ - cmd->reverse = ! cmd->reverse; -} -#else -extern void lsysi_dobang(struct lsys_turtlestatei *cmd); -#endif - -static void lsysi_dosizedm(struct lsys_turtlestatei *cmd) -{ - double angle = (double) cmd->realangle * ANGLE2DOUBLE; - double s, c; - long fixedsin, fixedcos; - - FPUsincos(&angle, &s, &c); - fixedsin = (long) (s * FIXEDLT1); - fixedcos = (long) (c * FIXEDLT1); - - cmd->xpos = cmd->xpos + (multiply(multiply(cmd->size, cmd->aspect, 19), fixedcos, 29)); - cmd->ypos = cmd->ypos + (multiply(cmd->size, fixedsin, 29)); - -/* xpos+=size*aspect*cos(realangle*PI/180); */ -/* ypos+=size*sin(realangle*PI/180); */ - if (cmd->xpos>cmd->xmax) cmd->xmax=cmd->xpos; - if (cmd->ypos>cmd->ymax) cmd->ymax=cmd->ypos; - if (cmd->xposxmin) cmd->xmin=cmd->xpos; - if (cmd->yposymin) cmd->ymin=cmd->ypos; -} - -static void lsysi_dosizegf(struct lsys_turtlestatei *cmd) -{ - cmd->xpos = cmd->xpos + (multiply(cmd->size, coss[(int)cmd->angle], 29)); - cmd->ypos = cmd->ypos + (multiply(cmd->size, sins[(int)cmd->angle], 29)); -/* xpos+=size*coss[angle]; */ -/* ypos+=size*sins[angle]; */ - if (cmd->xpos>cmd->xmax) cmd->xmax=cmd->xpos; - if (cmd->ypos>cmd->ymax) cmd->ymax=cmd->ypos; - if (cmd->xposxmin) cmd->xmin=cmd->xpos; - if (cmd->yposymin) cmd->ymin=cmd->ypos; -} - -static void lsysi_dodrawd(struct lsys_turtlestatei *cmd) -{ - double angle = (double) cmd->realangle * ANGLE2DOUBLE; - double s, c; - long fixedsin, fixedcos; - int lastx, lasty; - - FPUsincos(&angle, &s, &c); - fixedsin = (long) (s * FIXEDLT1); - fixedcos = (long) (c * FIXEDLT1); - - lastx=(int) (cmd->xpos >> 19); - lasty=(int) (cmd->ypos >> 19); - cmd->xpos = cmd->xpos + (multiply(multiply(cmd->size, cmd->aspect, 19), fixedcos, 29)); - cmd->ypos = cmd->ypos + (multiply(cmd->size, fixedsin, 29)); -/* xpos+=size*aspect*cos(realangle*PI/180); */ -/* ypos+=size*sin(realangle*PI/180); */ - driver_draw_line(lastx,lasty,(int)(cmd->xpos >> 19),(int)(cmd->ypos >> 19),cmd->curcolor); -} - -static void lsysi_dodrawm(struct lsys_turtlestatei *cmd) -{ - double angle = (double) cmd->realangle * ANGLE2DOUBLE; - double s, c; - long fixedsin, fixedcos; - - FPUsincos(&angle, &s, &c); - fixedsin = (long) (s * FIXEDLT1); - fixedcos = (long) (c * FIXEDLT1); - -/* xpos+=size*aspect*cos(realangle*PI/180); */ -/* ypos+=size*sin(realangle*PI/180); */ - cmd->xpos = cmd->xpos + (multiply(multiply(cmd->size, cmd->aspect, 19), fixedcos, 29)); - cmd->ypos = cmd->ypos + (multiply(cmd->size, fixedsin, 29)); -} - -static void lsysi_dodrawg(struct lsys_turtlestatei *cmd) -{ - cmd->xpos = cmd->xpos + (multiply(cmd->size, coss[(int)cmd->angle], 29)); - cmd->ypos = cmd->ypos + (multiply(cmd->size, sins[(int)cmd->angle], 29)); -/* xpos+=size*coss[angle]; */ -/* ypos+=size*sins[angle]; */ -} - -static void lsysi_dodrawf(struct lsys_turtlestatei *cmd) -{ - int lastx = (int) (cmd->xpos >> 19); - int lasty = (int) (cmd->ypos >> 19); - cmd->xpos = cmd->xpos + (multiply(cmd->size, coss[(int)cmd->angle], 29)); - cmd->ypos = cmd->ypos + (multiply(cmd->size, sins[(int)cmd->angle], 29)); -/* xpos+=size*coss[angle]; */ -/* ypos+=size*sins[angle]; */ - driver_draw_line(lastx,lasty,(int)(cmd->xpos >> 19),(int)(cmd->ypos >> 19),cmd->curcolor); -} - -static void lsysi_dodrawc(struct lsys_turtlestatei *cmd) -{ - cmd->curcolor = (char)(((int) cmd->num) % colors); -} - -static void lsysi_dodrawgt(struct lsys_turtlestatei *cmd) -{ - cmd->curcolor = (char)(cmd->curcolor - (char)cmd->num); - cmd->curcolor %= colors; - if (cmd->curcolor == 0) - cmd->curcolor = (char)(colors-1); -} - -static void lsysi_dodrawlt(struct lsys_turtlestatei *cmd) -{ - cmd->curcolor = (char)(cmd->curcolor + (char)cmd->num); - if ((cmd->curcolor %= colors) == 0) - cmd->curcolor = 1; -} - -static struct lsys_cmd * _fastcall -findsize(struct lsys_cmd *command, struct lsys_turtlestatei *ts, struct lsys_cmd **rules, int depth) -{ - struct lsys_cmd **rulind; - int tran; - -if (overflow) /* integer math routines overflowed */ - return NULL; - - if (stackavail() < 400) { /* leave some margin for calling subrtns */ - ts->stackoflow = 1; - return NULL; - } - - while (command->ch && command->ch !=']') { - if (! (ts->counter++)) { - /* let user know we're not dead */ - if (thinking(1, "L-System thinking (higher orders take longer)")) { - ts->counter--; - return NULL; - } - } - tran=0; - if (depth) { - for (rulind=rules; *rulind; rulind++) - if ((*rulind)->ch==command->ch) { - tran=1; - if (findsize((*rulind)+1,ts,rules,depth-1) == NULL) - return(NULL); - } - } - if (!depth || !tran) { - if (command->f) { - ts->num = command->n; - (*command->f)(ts); - } - else if (command->ch == '[') { - char saveang,saverev; - long savesize,savex,savey; - unsigned long saverang; - - saveang=ts->angle; - saverev=ts->reverse; - savesize=ts->size; - saverang=ts->realangle; - savex=ts->xpos; - savey=ts->ypos; - command = findsize(command+1, ts, rules, depth); - if (command == NULL) - return(NULL); - ts->angle=saveang; - ts->reverse=saverev; - ts->size=savesize; - ts->realangle=saverang; - ts->xpos=savex; - ts->ypos=savey; - } - } - command++; - } - return command; -} - -static int -lsysi_findscale(struct lsys_cmd *command, struct lsys_turtlestatei *ts, struct lsys_cmd **rules, int depth) -{ - float horiz,vert; - double xmin, xmax, ymin, ymax; - double locsize; - double locaspect; - struct lsys_cmd *fsret; - - locaspect=screenaspect*xdots/ydots; - ts->aspect = FIXEDPT(locaspect); - ts->xpos = - ts->ypos = - ts->xmin = - ts->xmax = - ts->ymax = - ts->ymin = - ts->realangle = - ts->angle = - ts->reverse = - ts->counter = 0; - ts->size=FIXEDPT(1L); - fsret = findsize(command,ts,rules,depth); - thinking(0, NULL); /* erase thinking message if any */ - xmin = (double) ts->xmin / FIXEDMUL; - xmax = (double) ts->xmax / FIXEDMUL; - ymin = (double) ts->ymin / FIXEDMUL; - ymax = (double) ts->ymax / FIXEDMUL; - if (fsret == NULL) - return 0; - if (xmax == xmin) - horiz = (float)1E37; - else - horiz = (float)((xdots-10)/(xmax-xmin)); - if (ymax == ymin) - vert = (float)1E37; - else - vert = (float)((ydots-6) /(ymax-ymin)); - locsize = (vertxpos = FIXEDPT(xdots/2); - else -/* ts->xpos = FIXEDPT(-xmin*(locsize)+5+((xdots-10)-(locsize)*(xmax-xmin))/2); */ - ts->xpos = FIXEDPT((xdots-locsize*(xmax+xmin))/2); - if (vert == 1E37) - ts->ypos = FIXEDPT(ydots/2); - else -/* ts->ypos = FIXEDPT(-ymin*(locsize)+3+((ydots-6)-(locsize)*(ymax-ymin))/2); */ - ts->ypos = FIXEDPT((ydots-locsize*(ymax+ymin))/2); - ts->size = FIXEDPT(locsize); - - return 1; -} - -static struct lsys_cmd * -drawLSysI(struct lsys_cmd *command,struct lsys_turtlestatei *ts, struct lsys_cmd **rules,int depth) -{ - struct lsys_cmd **rulind; - int tran; - - if (overflow) /* integer math routines overflowed */ - return NULL; - - if (stackavail() < 400) { /* leave some margin for calling subrtns */ - ts->stackoflow = 1; - return NULL; - } - - - while (command->ch && command->ch !=']') { - if (!(ts->counter++)) { - if (driver_key_pressed()) { - ts->counter--; - return NULL; - } - } - tran=0; - if (depth) { - for (rulind=rules; *rulind; rulind++) - if ((*rulind)->ch == command->ch) { - tran=1; - if (drawLSysI((*rulind)+1,ts,rules,depth-1) == NULL) - return NULL; - } - } - if (!depth||!tran) { - if (command->f) { - ts->num = command->n; - (*command->f)(ts); - } - else if (command->ch == '[') { - char saveang,saverev,savecolor; - long savesize,savex,savey; - unsigned long saverang; - - saveang=ts->angle; - saverev=ts->reverse; - savesize=ts->size; - saverang=ts->realangle; - savex=ts->xpos; - savey=ts->ypos; - savecolor=ts->curcolor; - command = drawLSysI(command+1, ts, rules, depth); - if (command == NULL) - return(NULL); - ts->angle=saveang; - ts->reverse=saverev; - ts->size=savesize; - ts->realangle=saverang; - ts->xpos=savex; - ts->ypos=savey; - ts->curcolor=savecolor; - } - } - command++; - } - return command; -} - -static struct lsys_cmd * -LSysISizeTransform(char *s, struct lsys_turtlestatei *ts) -{ - struct lsys_cmd *ret; - struct lsys_cmd *doub; - int maxval = 10; - int n = 0; - void (*f)(); - long num; - - void (*plus)() = (ispow2(ts->maxangle)) ? lsysi_doplus_pow2 : lsysi_doplus; - void (*minus)() = (ispow2(ts->maxangle)) ? lsysi_dominus_pow2 : lsysi_dominus; - void (*pipe)() = (ispow2(ts->maxangle)) ? lsysi_dopipe_pow2 : lsysi_dopipe; - - void (*slash)() = (cpu >= 386) ? lsysi_doslash_386 : lsysi_doslash; - void (*bslash)() = (cpu >= 386) ? lsysi_dobslash_386 : lsysi_dobslash; - void (*at)() = (cpu >= 386) ? lsysi_doat_386 : lsysi_doat; - void (*dogf)() = (cpu >= 386) ? lsysi_dosizegf_386 : lsysi_dosizegf; - - ret = (struct lsys_cmd *) malloc((long) maxval * sizeof(struct lsys_cmd)); - if (ret == NULL) { - ts->stackoflow = 1; - return NULL; - } - while (*s) { - f = NULL; - num = 0; - ret[n].ch = *s; - switch (*s) { - case '+': f = plus; break; - case '-': f = minus; break; - case '/': f = slash; num = (long) (getnumber(&s) * 11930465L); break; - case '\\': f = bslash; num = (long) (getnumber(&s) * 11930465L); break; - case '@': f = at; num = FIXEDPT(getnumber(&s)); break; - case '|': f = pipe; break; - case '!': f = lsysi_dobang; break; - case 'd': - case 'm': f = lsysi_dosizedm; break; - case 'g': - case 'f': f = dogf; break; - case '[': num = 1; break; - case ']': num = 2; break; - default: - num = 3; - break; - } -#if defined(XFRACT) - ret[n].f = (void (*)())f; -#else - ret[n].f = (void (*)(struct lsys_turtlestatei *))f; -#endif - ret[n].n = num; - if (++n == maxval) { - doub = (struct lsys_cmd *) malloc((long) maxval*2*sizeof(struct lsys_cmd)); - if (doub == NULL) { - free(ret); - ts->stackoflow = 1; - return NULL; - } - memcpy(doub, ret, maxval*sizeof(struct lsys_cmd)); - free(ret); - ret = doub; - maxval <<= 1; - } - s++; - } - ret[n].ch = 0; - ret[n].f = NULL; - ret[n].n = 0; - n++; - - doub = (struct lsys_cmd *) malloc((long) n*sizeof(struct lsys_cmd)); - if (doub == NULL) { - free(ret); - ts->stackoflow = 1; - return NULL; - } - memcpy(doub, ret, n*sizeof(struct lsys_cmd)); - free(ret); - return doub; -} - -static struct lsys_cmd * -LSysIDrawTransform(char *s, struct lsys_turtlestatei *ts) -{ - struct lsys_cmd *ret; - struct lsys_cmd *doub; - int maxval = 10; - int n = 0; - void (*f)(); - long num; - - void (*plus)() = (ispow2(ts->maxangle)) ? lsysi_doplus_pow2 : lsysi_doplus; - void (*minus)() = (ispow2(ts->maxangle)) ? lsysi_dominus_pow2 : lsysi_dominus; - void (*pipe)() = (ispow2(ts->maxangle)) ? lsysi_dopipe_pow2 : lsysi_dopipe; - - void (*slash)() = (cpu >= 386) ? lsysi_doslash_386 : lsysi_doslash; - void (*bslash)() = (cpu >= 386) ? lsysi_dobslash_386 : lsysi_dobslash; - void (*at)() = (cpu >= 386) ? lsysi_doat_386 : lsysi_doat; - void (*drawg)() = (cpu >= 386) ? lsysi_dodrawg_386 : lsysi_dodrawg; - - ret = (struct lsys_cmd *) malloc((long) maxval * sizeof(struct lsys_cmd)); - if (ret == NULL) { - ts->stackoflow = 1; - return NULL; - } - while (*s) { - f = NULL; - num = 0; - ret[n].ch = *s; - switch (*s) { - case '+': f = plus; break; - case '-': f = minus; break; - case '/': f = slash; num = (long) (getnumber(&s) * 11930465L); break; - case '\\': f = bslash; num = (long) (getnumber(&s) * 11930465L); break; - case '@': f = at; num = FIXEDPT(getnumber(&s)); break; - case '|': f = pipe; break; - case '!': f = lsysi_dobang; break; - case 'd': f = lsysi_dodrawd; break; - case 'm': f = lsysi_dodrawm; break; - case 'g': f = drawg; break; - case 'f': f = lsysi_dodrawf; break; - case 'c': f = lsysi_dodrawc; num = (long) getnumber(&s); break; - case '<': f = lsysi_dodrawlt; num = (long) getnumber(&s); break; - case '>': f = lsysi_dodrawgt; num = (long) getnumber(&s); break; - case '[': num = 1; break; - case ']': num = 2; break; - default: - num = 3; - break; - } -#ifdef XFRACT - ret[n].f = (void (*)())f; -#else - ret[n].f = (void (*)(struct lsys_turtlestatei *))f; -#endif - ret[n].n = num; - if (++n == maxval) { - doub = (struct lsys_cmd *) malloc((long) maxval*2*sizeof(struct lsys_cmd)); - if (doub == NULL) { - free(ret); - ts->stackoflow = 1; - return NULL; - } - memcpy(doub, ret, maxval*sizeof(struct lsys_cmd)); - free(ret); - ret = doub; - maxval <<= 1; - } - s++; - } - ret[n].ch = 0; - ret[n].f = NULL; - ret[n].n = 0; - n++; - - doub = (struct lsys_cmd *) malloc((long) n*sizeof(struct lsys_cmd)); - if (doub == NULL) { - free(ret); - ts->stackoflow = 1; - return NULL; - } - memcpy(doub, ret, n*sizeof(struct lsys_cmd)); - free(ret); - return doub; -} - -static void _fastcall lsysi_dosincos(void) -{ - double locaspect; - double TWOPI = 2.0 * PI; - double twopimax; - double twopimaxi; - double s, c; - int i; - - locaspect=screenaspect*xdots/ydots; - twopimax = TWOPI / maxangle; - for (i=0; i -#if !defined(_WIN32) -#include -#endif - - /* see Fractint.c for a description of the "include" hierarchy */ -#include "port.h" -#include "prototyp.h" -#include "lsys.h" -#include "drivers.h" - -#ifdef max -#undef max -#endif - -struct lsys_cmd { - void (*f)(struct lsys_turtlestatef *); - int ptype; - union { - long n; - LDBL nf; - } parm; - char ch; -}; - -#define sins_f ((LDBL *)(boxy)) -#define coss_f (((LDBL *)(boxy)+50)) - -static struct lsys_cmd * _fastcall findsize(struct lsys_cmd *,struct lsys_turtlestatef *, struct lsys_cmd **,int); - -/* Define blanks for portability */ -#if defined(XFRACT) || defined(_WIN32) -void lsysf_prepfpu(struct lsys_turtlestatef *x) { } -void lsysf_donefpu(struct lsys_turtlestatef *x) { } -#endif - - -#if defined(XFRACT) || defined(_WIN32) -static void lsysf_doplus(struct lsys_turtlestatef *cmd) -{ - if (cmd->reverse) { - if (++cmd->angle == cmd->maxangle) - cmd->angle = 0; - } - else { - if (cmd->angle) - cmd->angle--; - else - cmd->angle = cmd->dmaxangle; - } -} -#else -extern void lsysf_doplus(struct lsys_turtlestatef *cmd); -#endif - -#if defined(XFRACT) || defined(_WIN32) -/* This is the same as lsys_doplus, except maxangle is a power of 2. */ -static void lsysf_doplus_pow2(struct lsys_turtlestatef *cmd) -{ - if (cmd->reverse) { - cmd->angle++; - cmd->angle &= cmd->dmaxangle; - } - else { - cmd->angle--; - cmd->angle &= cmd->dmaxangle; - } -} -#else -extern void lsysf_doplus_pow2(struct lsys_turtlestatef *cmd); -#endif - -#if defined(XFRACT) || defined(_WIN32) -static void lsysf_dominus(struct lsys_turtlestatef *cmd) -{ - if (cmd->reverse) { - if (cmd->angle) - cmd->angle--; - else - cmd->angle = cmd->dmaxangle; - } - else { - if (++cmd->angle == cmd->maxangle) - cmd->angle = 0; - } -} -#else -extern void lsysf_dominus(struct lsys_turtlestatef *cmd); -#endif - -#if defined(XFRACT) || defined(_WIN32) -static void lsysf_dominus_pow2(struct lsys_turtlestatef *cmd) -{ - if (cmd->reverse) { - cmd->angle--; - cmd->angle &= cmd->dmaxangle; - } - else { - cmd->angle++; - cmd->angle &= cmd->dmaxangle; - } -} -#else -extern void lsysf_dominus_pow2(struct lsys_turtlestatef *cmd); -#endif - -#if defined(XFRACT) || defined(_WIN32) -static void lsysf_doslash(struct lsys_turtlestatef *cmd) -{ - if (cmd->reverse) - cmd->realangle -= cmd->parm.nf; - else - cmd->realangle += cmd->parm.nf; -} -#else -extern void lsysf_doslash(struct lsys_turtlestatef *cmd); -#endif - -#if defined(XFRACT) || defined(_WIN32) -static void lsysf_dobslash(struct lsys_turtlestatef *cmd) -{ - if (cmd->reverse) - cmd->realangle += cmd->parm.nf; - else - cmd->realangle -= cmd->parm.nf; -} -#else -extern void lsysf_dobslash(struct lsys_turtlestatef *cmd); -#endif - -#if defined(XFRACT) || defined(_WIN32) -static void lsysf_doat(struct lsys_turtlestatef *cmd) -{ - cmd->size *= cmd->parm.nf; -} -#else -extern void lsysf_doat(struct lsys_turtlestatef *cmd, long n); -#endif - -static void -lsysf_dopipe(struct lsys_turtlestatef *cmd) -{ - cmd->angle = (char)(cmd->angle + cmd->maxangle / 2); - cmd->angle %= cmd->maxangle; -} - -#if defined(XFRACT) || defined(_WIN32) -static void lsysf_dopipe_pow2(struct lsys_turtlestatef *cmd) -{ - cmd->angle += cmd->maxangle >> 1; - cmd->angle &= cmd->dmaxangle; -} -#else -extern void lsysf_dopipe_pow2(struct lsys_turtlestatef *cmd); -#endif - -#if defined(XFRACT) || defined(_WIN32) -static void lsysf_dobang(struct lsys_turtlestatef *cmd) -{ - cmd->reverse = ! cmd->reverse; -} -#else -extern void lsysf_dobang(struct lsys_turtlestatef *cmd); -#endif - -#if defined(XFRACT) || defined(_WIN32) -static void lsysf_dosizedm(struct lsys_turtlestatef *cmd) -{ - double angle = (double) cmd->realangle; - double s, c; - - s = sin(angle); - c = cos(angle); - - cmd->xpos += cmd->size * cmd->aspect * c; - cmd->ypos += cmd->size * s; - - if (cmd->xpos>cmd->xmax) cmd->xmax=cmd->xpos; - if (cmd->ypos>cmd->ymax) cmd->ymax=cmd->ypos; - if (cmd->xposxmin) cmd->xmin=cmd->xpos; - if (cmd->yposymin) cmd->ymin=cmd->ypos; -} -#else -extern void lsysf_dosizedm(struct lsys_turtlestatef *cmd, long n); -#endif - -#if defined(XFRACT) || defined(_WIN32) -static void lsysf_dosizegf(struct lsys_turtlestatef *cmd) -{ - cmd->xpos += cmd->size * coss_f[(int)cmd->angle]; - cmd->ypos += cmd->size * sins_f[(int)cmd->angle]; - - if (cmd->xpos>cmd->xmax) cmd->xmax=cmd->xpos; - if (cmd->ypos>cmd->ymax) cmd->ymax=cmd->ypos; - if (cmd->xposxmin) cmd->xmin=cmd->xpos; - if (cmd->yposymin) cmd->ymin=cmd->ypos; -} -#else -extern void lsysf_dosizegf(struct lsys_turtlestatef *cmd); -#endif - -#if defined(XFRACT) || defined(_WIN32) -static void lsysf_dodrawd(struct lsys_turtlestatef *cmd) -{ - double angle = (double) cmd->realangle; - double s, c; - int lastx, lasty; - s = sin(angle); - c = cos(angle); - - lastx=(int) cmd->xpos; - lasty=(int) cmd->ypos; - - cmd->xpos += cmd->size * cmd->aspect * c; - cmd->ypos += cmd->size * s; - - driver_draw_line(lastx, lasty, (int) cmd->xpos, (int) cmd->ypos, cmd->curcolor); -} -#else -extern void lsysf_dodrawd(struct lsys_turtlestatef *cmd); -#endif - -#if defined(XFRACT) || defined(_WIN32) -static void lsysf_dodrawm(struct lsys_turtlestatef *cmd) -{ - double angle = (double) cmd->realangle; - double s, c; - - s = sin(angle); - c = cos(angle); - - cmd->xpos += cmd->size * cmd->aspect * c; - cmd->ypos += cmd->size * s; -} -#else -extern void lsysf_dodrawm(struct lsys_turtlestatef *cmd); -#endif - -#if defined(XFRACT) || defined(_WIN32) -static void lsysf_dodrawg(struct lsys_turtlestatef *cmd) -{ - cmd->xpos += cmd->size * coss_f[(int)cmd->angle]; - cmd->ypos += cmd->size * sins_f[(int)cmd->angle]; -} -#else -extern void lsysf_dodrawg(struct lsys_turtlestatef *cmd); -#endif - -#if defined(XFRACT) || defined(_WIN32) -static void lsysf_dodrawf(struct lsys_turtlestatef *cmd) -{ - int lastx = (int) cmd->xpos; - int lasty = (int) cmd->ypos; - cmd->xpos += cmd->size * coss_f[(int)cmd->angle]; - cmd->ypos += cmd->size * sins_f[(int)cmd->angle]; - driver_draw_line(lastx,lasty,(int) cmd->xpos, (int) cmd->ypos, cmd->curcolor); -} -#else -extern void lsysf_dodrawf(struct lsys_turtlestatef *cmd); -#endif - -static void lsysf_dodrawc(struct lsys_turtlestatef *cmd) -{ - cmd->curcolor = (char)(((int) cmd->parm.n) % colors); -} - -static void lsysf_dodrawgt(struct lsys_turtlestatef *cmd) -{ - cmd->curcolor = (char)(cmd->curcolor - cmd->parm.n); - cmd->curcolor %= colors; - if (cmd->curcolor == 0) - cmd->curcolor = (char)(colors-1); -} - -static void lsysf_dodrawlt(struct lsys_turtlestatef *cmd) -{ - cmd->curcolor = (char)(cmd->curcolor + cmd->parm.n); - cmd->curcolor %= colors; - if (cmd->curcolor == 0) - cmd->curcolor = 1; -} - -static struct lsys_cmd * _fastcall -findsize(struct lsys_cmd *command, struct lsys_turtlestatef *ts, struct lsys_cmd **rules, int depth) -{ - struct lsys_cmd **rulind; - int tran; - - if (overflow) /* integer math routines overflowed */ - return NULL; - - if (stackavail() < 400) { /* leave some margin for calling subrtns */ - ts->stackoflow = 1; - return NULL; - } - - - while (command->ch && command->ch !=']') { - if (! (ts->counter++)) { - /* let user know we're not dead */ - if (thinking(1, "L-System thinking (higher orders take longer)")) { - ts->counter--; - return NULL; - } - } - tran=0; - if (depth) { - for (rulind=rules; *rulind; rulind++) - if ((*rulind)->ch==command->ch) { - tran=1; - if (findsize((*rulind)+1,ts,rules,depth-1) == NULL) - return(NULL); - } - } - if (!depth || !tran) { - if (command->f) { - switch (command->ptype) { - case 4: - ts->parm.n = command->parm.n; - break; - case 10: - ts->parm.nf = command->parm.nf; - break; - default: - break; - } - (*command->f)(ts); - } - else if (command->ch == '[') { - char saveang,saverev; - LDBL savesize,savex,savey,saverang; - - lsys_donefpu(ts); - saveang=ts->angle; - saverev=ts->reverse; - savesize=ts->size; - saverang=ts->realangle; - savex=ts->xpos; - savey=ts->ypos; - lsys_prepfpu(ts); - command = findsize(command+1, ts, rules, depth); - if (command == NULL) - return(NULL); - lsys_donefpu(ts); - ts->angle=saveang; - ts->reverse=saverev; - ts->size=savesize; - ts->realangle=saverang; - ts->xpos=savex; - ts->ypos=savey; - lsys_prepfpu(ts); - } - } - command++; - } - return command; -} - -int _fastcall -lsysf_findscale(struct lsys_cmd *command, struct lsys_turtlestatef *ts, struct lsys_cmd **rules, int depth) -{ - float horiz,vert; - LDBL xmin, xmax, ymin, ymax; - LDBL locsize; - LDBL locaspect; - struct lsys_cmd *fsret; - - locaspect=screenaspect*xdots/ydots; - ts->aspect = locaspect; - ts->xpos = - ts->ypos = - ts->xmin = - ts->xmax = - ts->ymax = - ts->ymin = 0; - ts->angle = - ts->reverse = - ts->counter = 0; - ts->realangle = 0; - ts->size = 1; - lsys_prepfpu(ts); - fsret = findsize(command,ts,rules,depth); - lsys_donefpu(ts); - thinking(0, NULL); /* erase thinking message if any */ - xmin = ts->xmin; - xmax = ts->xmax; - ymin = ts->ymin; - ymax = ts->ymax; -/* locsize = ts->size; */ - if (fsret == NULL) - return 0; - if (xmax == xmin) - horiz = (float)1E37; - else - horiz = (float)((xdots-10)/(xmax-xmin)); - if (ymax == ymin) - vert = (float)1E37; - else - vert = (float)((ydots-6) /(ymax-ymin)); - locsize = (vertxpos = xdots/2; - else -/* ts->xpos = -xmin*(locsize)+5+((xdots-10)-(locsize)*(xmax-xmin))/2; */ - ts->xpos = (xdots-locsize*(xmax+xmin))/2; - if (vert == 1E37) - ts->ypos = ydots/2; - else -/* ts->ypos = -ymin*(locsize)+3+((ydots-6)-(locsize)*(ymax-ymin))/2; */ - ts->ypos = (ydots-locsize*(ymax+ymin))/2; - ts->size = locsize; - - return 1; -} - -struct lsys_cmd * _fastcall -drawLSysF(struct lsys_cmd *command,struct lsys_turtlestatef *ts, struct lsys_cmd **rules,int depth) -{ - struct lsys_cmd **rulind; - int tran; - - if (overflow) /* integer math routines overflowed */ - return NULL; - - - if (stackavail() < 400) { /* leave some margin for calling subrtns */ - ts->stackoflow = 1; - return NULL; - } - - - while (command->ch && command->ch !=']') { - if (!(ts->counter++)) { - if (driver_key_pressed()) { - ts->counter--; - return NULL; - } - } - tran=0; - if (depth) { - for (rulind=rules; *rulind; rulind++) - if ((*rulind)->ch == command->ch) { - tran=1; - if (drawLSysF((*rulind)+1,ts,rules,depth-1) == NULL) - return NULL; - } - } - if (!depth||!tran) { - if (command->f) { - switch (command->ptype) { - case 4: - ts->parm.n = command->parm.n; - break; - case 10: - ts->parm.nf = command->parm.nf; - break; - default: - break; - } - (*command->f)(ts); - } - else if (command->ch == '[') { - char saveang,saverev,savecolor; - LDBL savesize,savex,savey,saverang; - - lsys_donefpu(ts); - saveang=ts->angle; - saverev=ts->reverse; - savesize=ts->size; - saverang=ts->realangle; - savex=ts->xpos; - savey=ts->ypos; - savecolor=ts->curcolor; - lsys_prepfpu(ts); - command = drawLSysF(command+1, ts, rules, depth); - if (command == NULL) - return(NULL); - lsys_donefpu(ts); - ts->angle=saveang; - ts->reverse=saverev; - ts->size=savesize; - ts->realangle=saverang; - ts->xpos=savex; - ts->ypos=savey; - ts->curcolor=savecolor; - lsys_prepfpu(ts); - } - } - command++; - } - return command; -} - -struct lsys_cmd * -LSysFSizeTransform(char *s, struct lsys_turtlestatef *ts) -{ - struct lsys_cmd *ret; - struct lsys_cmd *doub; - int max = 10; - int n = 0; - void (*f)(); - long num; - int ptype; - double PI180 = PI / 180.0; - - void (*plus)() = (ispow2(ts->maxangle)) ? lsysf_doplus_pow2 : lsysf_doplus; - void (*minus)() = (ispow2(ts->maxangle)) ? lsysf_dominus_pow2 : lsysf_dominus; - void (*pipe)() = (ispow2(ts->maxangle)) ? lsysf_dopipe_pow2 : lsysf_dopipe; - - void (*slash)() = lsysf_doslash; - void (*bslash)() = lsysf_dobslash; - void (*at)() = lsysf_doat; - void (*dogf)() = lsysf_dosizegf; - - ret = (struct lsys_cmd *) malloc((long) max * sizeof(struct lsys_cmd)); - if (ret == NULL) { - ts->stackoflow = 1; - return NULL; - } - while (*s) { - f = NULL; - num = 0; - ptype = 4; - ret[n].ch = *s; - switch (*s) { - case '+': f = plus; break; - case '-': f = minus; break; - case '/': f = slash; ptype = 10; ret[n].parm.nf = getnumber(&s) * PI180; break; - case '\\': f = bslash; ptype = 10; ret[n].parm.nf = getnumber(&s) * PI180; break; - case '@': f = at; ptype = 10; ret[n].parm.nf = getnumber(&s); break; - case '|': f = pipe; break; - case '!': f = lsysf_dobang; break; - case 'd': - case 'm': f = lsysf_dosizedm; break; - case 'g': - case 'f': f = dogf; break; - case '[': num = 1; break; - case ']': num = 2; break; - default: - num = 3; - break; - } -#if defined(XFRACT) - ret[n].f = (void (*)())f; -#else - ret[n].f = (void (*)(struct lsys_turtlestatef *))f; -#endif - if (ptype == 4) - ret[n].parm.n = num; - ret[n].ptype = ptype; - if (++n == max) { - doub = (struct lsys_cmd *) malloc((long) max*2*sizeof(struct lsys_cmd)); - if (doub == NULL) { - free(ret); - ts->stackoflow = 1; - return NULL; - } - memcpy(doub, ret, max*sizeof(struct lsys_cmd)); - free(ret); - ret = doub; - max <<= 1; - } - s++; - } - ret[n].ch = 0; - ret[n].f = NULL; - ret[n].parm.n = 0; - n++; - - doub = (struct lsys_cmd *) malloc((long) n*sizeof(struct lsys_cmd)); - if (doub == NULL) { - free(ret); - ts->stackoflow = 1; - return NULL; - } - memcpy(doub, ret, n*sizeof(struct lsys_cmd)); - free(ret); - return doub; -} - -struct lsys_cmd * -LSysFDrawTransform(char *s, struct lsys_turtlestatef *ts) -{ - struct lsys_cmd *ret; - struct lsys_cmd *doub; - int max = 10; - int n = 0; - void (*f)(); - LDBL num; - int ptype; - LDBL PI180 = PI / 180.0; - - void (*plus)() = (ispow2(ts->maxangle)) ? lsysf_doplus_pow2 : lsysf_doplus; - void (*minus)() = (ispow2(ts->maxangle)) ? lsysf_dominus_pow2 : lsysf_dominus; - void (*pipe)() = (ispow2(ts->maxangle)) ? lsysf_dopipe_pow2 : lsysf_dopipe; - - void (*slash)() = lsysf_doslash; - void (*bslash)() = lsysf_dobslash; - void (*at)() = lsysf_doat; - void (*drawg)() = lsysf_dodrawg; - - ret = (struct lsys_cmd *) malloc((long) max * sizeof(struct lsys_cmd)); - if (ret == NULL) { - ts->stackoflow = 1; - return NULL; - } - while (*s) { - f = NULL; - num = 0; - ptype = 4; - ret[n].ch = *s; - switch (*s) { - case '+': f = plus; break; - case '-': f = minus; break; - case '/': f = slash; ptype = 10; ret[n].parm.nf = getnumber(&s) * PI180; break; - case '\\': f = bslash; ptype = 10; ret[n].parm.nf = getnumber(&s) * PI180; break; - case '@': f = at; ptype = 10; ret[n].parm.nf = getnumber(&s); break; - case '|': f = pipe; break; - case '!': f = lsysf_dobang; break; - case 'd': f = lsysf_dodrawd; break; - case 'm': f = lsysf_dodrawm; break; - case 'g': f = drawg; break; - case 'f': f = lsysf_dodrawf; break; - case 'c': f = lsysf_dodrawc; num = getnumber(&s); break; - case '<': f = lsysf_dodrawlt; num = getnumber(&s); break; - case '>': f = lsysf_dodrawgt; num = getnumber(&s); break; - case '[': num = 1; break; - case ']': num = 2; break; - default: - num = 3; - break; - } -#if defined(XFRACT) - ret[n].f = (void (*)())f; -#else - ret[n].f = (void (*)(struct lsys_turtlestatef *))f; -#endif - if (ptype == 4) - ret[n].parm.n = (long)num; - ret[n].ptype = ptype; - if (++n == max) { - doub = (struct lsys_cmd *) malloc((long) max*2*sizeof(struct lsys_cmd)); - if (doub == NULL) { - free(ret); - ts->stackoflow = 1; - return NULL; - } - memcpy(doub, ret, max*sizeof(struct lsys_cmd)); - free(ret); - ret = doub; - max <<= 1; - } - s++; - } - ret[n].ch = 0; - ret[n].f = NULL; - ret[n].parm.n = 0; - n++; - - doub = (struct lsys_cmd *) malloc((long) n*sizeof(struct lsys_cmd)); - if (doub == NULL) { - free(ret); - ts->stackoflow = 1; - return NULL; - } - memcpy(doub, ret, n*sizeof(struct lsys_cmd)); - free(ret); - return doub; -} - -void _fastcall lsysf_dosincos(void) -{ - LDBL locaspect; - LDBL TWOPI = 2.0 * PI; - LDBL twopimax; - LDBL twopimaxi; - int i; - - locaspect=screenaspect*xdots/ydots; - twopimax = TWOPI / maxangle; - for (i=0; i -#include -#if !defined(_WIN32) -#include -#endif - -#ifndef USE_VARARGS -#include -#else -#include -#endif - -#include -#include - -#include "port.h" -#include "prototyp.h" -#include "drivers.h" - -/* Memory allocation routines. */ - -/* For far memory: */ -#define FAR_RESERVE 8192L /* amount of far mem we will leave avail. */ -/* For disk memory: */ -#define DISKWRITELEN 2048L /* max # bytes transferred to/from disk mem at once */ - -BYTE *charbuf = NULL; -//int numEXThandles; -//long ext_xfer_size; -//U16 start_avail_extra = 0; - -#define MAXHANDLES 256 /* arbitrary #, suitably big */ -char memfile[] = "handle.$$$"; -int numTOTALhandles; - -char memstr[3][9] = {{"nowhere"}, {"memory"}, {"disk"}}; - -struct nowhere { - enum stored_at_values stored_at; /* first 2 entries must be the same */ - long size; /* for each of these data structures */ - }; - -struct linearmem { - enum stored_at_values stored_at; - long size; - BYTE *memory; - }; - -struct disk { - enum stored_at_values stored_at; - long size; - FILE *file; - }; - -union mem { - struct nowhere Nowhere; - struct linearmem Linearmem; - struct disk Disk; - }; - -union mem handletable[MAXHANDLES]; - -/* Routines in this module */ -static int _fastcall CheckDiskSpace(long howmuch); -static int check_for_mem(int stored_at, long howmuch); -static U16 next_handle(void); -static int CheckBounds (long start, long length, U16 handle); -static void WhichDiskError(int); -static void DisplayError(int stored_at, long howmuch); - -/* Routines in this module, visible to outside routines */ - -void DisplayMemory (void); -void DisplayHandle (U16 handle); -int MemoryType (U16 handle); -void InitMemory (void); -void ExitCheck (void); -U16 MemoryAlloc(U16 size, long count, int stored_at); -void MemoryRelease(U16 handle); -int MoveToMemory(BYTE *buffer,U16 size,long count,long offset,U16 handle); -int MoveFromMemory(BYTE *buffer,U16 size,long count,long offset,U16 handle); -int SetMemory(int value,U16 size,long count,long offset,U16 handle); - -/* Memory handling support routines */ - -static int _fastcall CheckDiskSpace(long howmuch) -{ - /* TODO */ - return TRUE; -} - -static void WhichDiskError(int I_O) -{ - /* Set I_O == 1 after a file create, I_O == 2 after a file set value */ - /* Set I_O == 3 after a file write, I_O == 4 after a file read */ - char buf[MSGLEN]; - char *pats[4] = - { - "Create file error %d: %s", - "Set file error %d: %s", - "Write file error %d: %s", - "Read file error %d: %s" - }; - sprintf(buf, pats[(1 <= I_O && I_O <= 4) ? (I_O-1) : 0], errno, strerror(errno)); - if (debugflag == 10000) - if (stopmsg(STOPMSG_CANCEL | STOPMSG_NO_BUZZER,(char *)buf) == -1) - goodbye(); /* bailout if ESC */ -} - -int MemoryType(U16 handle) -{ - return handletable[handle].Nowhere.stored_at; -} - -static void DisplayError(int stored_at, long howmuch) -{ -/* This routine is used to display an error message when the requested */ -/* memory type cannot be allocated due to insufficient memory, AND there */ -/* is also insufficient disk space to use as memory. */ - - char buf[MSGLEN*2]; - sprintf(buf,"Allocating %ld Bytes of %s memory failed.\n" - "Alternate disk space is also insufficient. Goodbye", - howmuch,memstr[stored_at]); - stopmsg(0,buf); -} - -static int check_for_mem(int stored_at, long howmuch) -{ -/* This function returns an adjusted stored_at value. */ -/* This is where the memory requested can be allocated. */ - - long maxmem; - BYTE *temp; - int use_this_type; - - use_this_type = NOWHERE; - maxmem = (long)USHRT_MAX; - - if (debugflag == 420) - stored_at = DISK; - if (debugflag == 422) - stored_at = MEMORY; - - switch (stored_at) - { - case MEMORY: /* check_for_mem */ - if (maxmem > howmuch) { - temp = (BYTE *)malloc(howmuch + FAR_RESERVE); - if (temp != NULL) { /* minimum free space + requested amount */ - free(temp); - use_this_type = MEMORY; - break; - } - } - - case DISK: /* check_for_mem */ - default: /* just in case a nonsense number gets used */ - if (CheckDiskSpace(howmuch)) { - use_this_type = DISK; - break; - } - /* failed, fall through, no memory available */ - - case NOWHERE: /* check_for_mem */ - use_this_type = NOWHERE; - break; - - } /* end of switch */ - - return(use_this_type); -} - -static U16 next_handle() -{ - U16 counter = 1; /* don't use handle 0 */ - - while (handletable[counter].Nowhere.stored_at != NOWHERE && - counter < MAXHANDLES) - counter++; - return (counter); -} - -static int CheckBounds (long start, long length, U16 handle) -{ - if (handletable[handle].Nowhere.size - start - length < 0) - { - stopmsg(STOPMSG_INFO_ONLY | STOPMSG_NO_BUZZER, "Memory reference out of bounds."); - DisplayHandle(handle); - return (1); - } - if (length > (long)USHRT_MAX) - { - stopmsg(STOPMSG_INFO_ONLY | STOPMSG_NO_BUZZER, "Tried to move > 65,535 bytes."); - DisplayHandle(handle); - return (1); - } - if (handletable[handle].Nowhere.stored_at == DISK && - (stackavail() <= DISKWRITELEN) ) - { - stopmsg(STOPMSG_INFO_ONLY | STOPMSG_NO_BUZZER, "Stack space insufficient for disk memory."); - DisplayHandle(handle); - return (1); - } - if (length <= 0) - { - stopmsg(STOPMSG_INFO_ONLY | STOPMSG_NO_BUZZER, "Zero or negative length."); - DisplayHandle(handle); - return (1); - } - if (start < 0) - { - stopmsg(STOPMSG_INFO_ONLY | STOPMSG_NO_BUZZER, "Negative offset."); - DisplayHandle(handle); - return (1); - } - return (0); -} - -void DisplayMemory (void) -{ - char buf[MSGLEN]; - extern unsigned long get_disk_space(void); - - sprintf(buf, "disk=%lu", get_disk_space()); - stopmsg(STOPMSG_INFO_ONLY | STOPMSG_NO_BUZZER, buf); -} - -void DisplayHandle (U16 handle) -{ - char buf[MSGLEN]; - - sprintf(buf,"Handle %u, type %s, size %li",handle,memstr[handletable[handle].Nowhere.stored_at], - handletable[handle].Nowhere.size); - if (stopmsg(STOPMSG_CANCEL | STOPMSG_NO_BUZZER,(char *)buf) == -1) - goodbye(); /* bailout if ESC, it's messy, but should work */ -} - -void InitMemory (void) -{ - int counter; - - numTOTALhandles = 0; - for (counter = 0; counter < MAXHANDLES; counter++) - { - handletable[counter].Nowhere.stored_at = NOWHERE; - handletable[counter].Nowhere.size = 0; - } -} - -void ExitCheck (void) -{ - U16 i; - if (numTOTALhandles != 0) { - stopmsg(0, "Error - not all memory released, I'll get it."); - for (i = 1; i < MAXHANDLES; i++) - if (handletable[i].Nowhere.stored_at != NOWHERE) { - char buf[MSGLEN]; - sprintf(buf,"Memory type %s still allocated. Handle = %i.", - memstr[handletable[i].Nowhere.stored_at],i); - stopmsg(0,(char *)buf); - MemoryRelease(i); - } - } -} - -/* * * * * */ -/* Memory handling routines */ - -U16 MemoryAlloc(U16 size, long count, int stored_at) -{ -/* Returns handle number if successful, 0 or NULL if failure */ - U16 handle = 0; - int success, use_this_type; - long toallocate; - - success = FALSE; - toallocate = count * size; - if (toallocate <= 0) /* we failed, can't allocate > 2,147,483,647 */ - return((U16)success); /* or it wraps around to negative */ - -/* check structure for requested memory type (add em up) to see if - sufficient amount is available to grant request */ - - use_this_type = check_for_mem(stored_at, toallocate); - if (use_this_type == NOWHERE) { - DisplayError(stored_at, toallocate); - goodbye(); - } - -/* get next available handle */ - - handle = next_handle(); - - if (handle >= MAXHANDLES || handle <= 0) { - DisplayHandle(handle); - return((U16)success); - /* Oops, do something about this! ????? */ - } - -/* attempt to allocate requested memory type */ - switch (use_this_type) - { - default: - case NOWHERE: /* MemoryAlloc */ - use_this_type = NOWHERE; /* in case nonsense value is passed */ - break; - - case MEMORY: /* MemoryAlloc */ -/* Availability of memory checked in check_for_mem() */ - handletable[handle].Linearmem.memory = (BYTE *)malloc(toallocate); - handletable[handle].Linearmem.size = toallocate; - handletable[handle].Linearmem.stored_at = MEMORY; - numTOTALhandles++; - success = TRUE; - break; - - case DISK: /* MemoryAlloc */ - memfile[9] = (char)(handle % 10 + (int)'0'); - memfile[8] = (char)((handle % 100) / 10 + (int)'0'); - memfile[7] = (char)((handle % 1000) / 100 + (int)'0'); - if (disktarga) - handletable[handle].Disk.file = dir_fopen(workdir,light_name, "a+b"); - else - handletable[handle].Disk.file = dir_fopen(tempdir,memfile, "w+b"); - rewind(handletable[handle].Disk.file); - if (fseek(handletable[handle].Disk.file,toallocate,SEEK_SET) != 0) - handletable[handle].Disk.file = NULL; - if (handletable[handle].Disk.file == NULL) { - handletable[handle].Disk.stored_at = NOWHERE; - use_this_type = NOWHERE; - WhichDiskError(1); - DisplayMemory(); - driver_buzzer(BUZZER_ERROR); - break; - } - numTOTALhandles++; - success = TRUE; - fclose(handletable[handle].Disk.file); /* so clusters aren't lost if we crash while running */ - if (disktarga) - handletable[handle].Disk.file = dir_fopen(workdir,light_name, "r+b"); - else - handletable[handle].Disk.file = dir_fopen(tempdir,memfile,"r+b"); /* reopen */ - rewind(handletable[handle].Disk.file); - handletable[handle].Disk.size = toallocate; - handletable[handle].Disk.stored_at = DISK; - use_this_type = DISK; - break; - } /* end of switch */ - - if (stored_at != use_this_type && debugflag == 10000) { - char buf[MSGLEN]; - sprintf(buf,"Asked for %s, allocated %lu bytes of %s, handle = %u.", - memstr[stored_at],toallocate,memstr[use_this_type],handle); - stopmsg(STOPMSG_INFO_ONLY | STOPMSG_NO_BUZZER,(char *)buf); - DisplayMemory(); - } - - if (success) - return (handle); - else /* return 0 if failure */ - return 0; -} - -void MemoryRelease(U16 handle) -{ - switch (handletable[handle].Nowhere.stored_at) - { - case NOWHERE: /* MemoryRelease */ - break; - - case MEMORY: /* MemoryRelease */ - free(handletable[handle].Linearmem.memory); - handletable[handle].Linearmem.memory = NULL; - handletable[handle].Linearmem.size = 0; - handletable[handle].Linearmem.stored_at = NOWHERE; - numTOTALhandles--; - break; - - case DISK: /* MemoryRelease */ - memfile[9] = (char)(handle % 10 + (int)'0'); - memfile[8] = (char)((handle % 100) / 10 + (int)'0'); - memfile[7] = (char)((handle % 1000) / 100 + (int)'0'); - fclose(handletable[handle].Disk.file); - dir_remove(tempdir,memfile); - handletable[handle].Disk.file = NULL; - handletable[handle].Disk.size = 0; - handletable[handle].Disk.stored_at = NOWHERE; - numTOTALhandles--; - break; - } /* end of switch */ -} - -int MoveToMemory(BYTE *buffer,U16 size,long count,long offset,U16 handle) -{ /* buffer is a pointer to local memory */ -/* Always start moving from the beginning of buffer */ -/* offset is the number of units from the start of the allocated "Memory" */ -/* to start moving the contents of buffer to */ -/* size is the size of the unit, count is the number of units to move */ -/* Returns TRUE if successful, FALSE if failure */ - BYTE diskbuf[DISKWRITELEN]; - long start; /* offset to first location to move to */ - long tomove; /* number of bytes to move */ - U16 numwritten; - int success; - - success = FALSE; - start = (long)offset * size; - tomove = (long)count * size; - if (debugflag == 10000) - if (CheckBounds(start, tomove, handle)) - return(success); /* out of bounds, don't do it */ - - switch (handletable[handle].Nowhere.stored_at) - { - case NOWHERE: /* MoveToMemory */ - DisplayHandle(handle); - break; - - case MEMORY: /* MoveToMemory */ -#if defined(_WIN32) - _ASSERTE(handletable[handle].Linearmem.size >= size*count + start); -#endif - memcpy(handletable[handle].Linearmem.memory + start, buffer, size*count); - success = TRUE; /* No way to gauge success or failure */ - break; - - case DISK: /* MoveToMemory */ - rewind(handletable[handle].Disk.file); - fseek(handletable[handle].Disk.file,start,SEEK_SET); - while (tomove > DISKWRITELEN) - { - memcpy(diskbuf,buffer,(U16)DISKWRITELEN); - numwritten = (U16)write1(diskbuf,(U16)DISKWRITELEN,1,handletable[handle].Disk.file); - if (numwritten != 1) { - WhichDiskError(3); - goto diskerror; - } - tomove -= DISKWRITELEN; - buffer += DISKWRITELEN; - } - memcpy(diskbuf,buffer,(U16)tomove); - numwritten = (U16)write1(diskbuf,(U16)tomove,1,handletable[handle].Disk.file); - if (numwritten != 1) { - WhichDiskError(3); - break; - } - success = TRUE; -diskerror: - break; - } /* end of switch */ - if (!success && debugflag == 10000) - DisplayHandle(handle); - return (success); -} - -int MoveFromMemory(BYTE *buffer,U16 size,long count,long offset,U16 handle) -{ /* buffer points is the location to move the data to */ -/* offset is the number of units from the beginning of buffer to start moving */ -/* size is the size of the unit, count is the number of units to move */ -/* Returns TRUE if successful, FALSE if failure */ - BYTE diskbuf[DISKWRITELEN]; - long start; /* first location to move */ - long tomove; /* number of bytes to move */ - U16 numread, i; - int success; - - success = FALSE; - start = (long)offset * size; - tomove = (long)count * size; - if (debugflag == 10000) - if (CheckBounds(start, tomove, handle)) - return(success); /* out of bounds, don't do it */ - - switch (handletable[handle].Nowhere.stored_at) - { - case NOWHERE: /* MoveFromMemory */ - DisplayHandle(handle); - break; - - case MEMORY: /* MoveFromMemory */ - for (i=0; i DISKWRITELEN) - { - numread = (U16)fread(diskbuf,(U16)DISKWRITELEN,1,handletable[handle].Disk.file); - if (numread != 1 && !feof(handletable[handle].Disk.file)) { - WhichDiskError(4); - goto diskerror; - } - memcpy(buffer,diskbuf,(U16)DISKWRITELEN); - tomove -= DISKWRITELEN; - buffer += DISKWRITELEN; - } - numread = (U16)fread(diskbuf,(U16)tomove,1,handletable[handle].Disk.file); - if (numread != 1 && !feof(handletable[handle].Disk.file)) { - WhichDiskError(4); - break; - } - memcpy(buffer,diskbuf,(U16)tomove); - success = TRUE; -diskerror: - break; - } /* end of switch */ - if (!success && debugflag == 10000) - DisplayHandle(handle); - return (success); -} - -int SetMemory(int value,U16 size,long count,long offset,U16 handle) -{ /* value is the value to set memory to */ -/* offset is the number of units from the start of allocated memory */ -/* size is the size of the unit, count is the number of units to set */ -/* Returns TRUE if successful, FALSE if failure */ - BYTE diskbuf[DISKWRITELEN]; - long start; /* first location to set */ - long tomove; /* number of bytes to set */ - U16 numwritten, i; - int success; - - success = FALSE; - start = (long)offset * size; - tomove = (long)count * size; - if (debugflag == 10000) - if (CheckBounds(start, tomove, handle)) - return(success); /* out of bounds, don't do it */ - - switch (handletable[handle].Nowhere.stored_at) - { - case NOWHERE: /* SetMemory */ - DisplayHandle(handle); - break; - - case MEMORY: /* SetMemory */ - for (i=0; i DISKWRITELEN) - { - numwritten = (U16)write1(diskbuf,(U16)DISKWRITELEN,1,handletable[handle].Disk.file); - if (numwritten != 1) { - WhichDiskError(2); - goto diskerror; - } - tomove -= DISKWRITELEN; - } - numwritten = (U16)write1(diskbuf,(U16)tomove,1,handletable[handle].Disk.file); - if (numwritten != 1) { - WhichDiskError(2); - break; - } - success = TRUE; -diskerror: - break; - } /* end of switch */ - if (!success && debugflag == 10000) - DisplayHandle(handle); - return (success); -} - diff --git a/fractint/common/miscfrac.c b/fractint/common/miscfrac.c deleted file mode 100644 index 10bbdc71f..000000000 --- a/fractint/common/miscfrac.c +++ /dev/null @@ -1,2363 +0,0 @@ -/* - -Miscellaneous fractal-specific code (formerly in CALCFRAC.C) - -*/ - -#include -#include - /* see Fractint.c for a description of the "include" hierarchy */ -#include "port.h" -#include "prototyp.h" -#include "fractype.h" -#include "targa_lc.h" -#include "drivers.h" - -/* routines in this module */ - -static void set_Plasma_palette(void); -static U16 _fastcall adjust(int xa,int ya,int x,int y,int xb,int yb); -static void _fastcall subDivide(int x1,int y1,int x2,int y2); -static int _fastcall new_subD (int x1,int y1,int x2,int y2, int recur); -static void verhulst(void); -static void Bif_Period_Init(void); -static int _fastcall Bif_Periodic(long); -static void set_Cellular_palette(void); - -U16 (_fastcall *getpix)(int,int) = (U16(_fastcall *)(int,int))getcolor; - -typedef void (_fastcall *PLOT)(int,int,int); - -/***************** standalone engine for "test" ********************/ - -int test(void) -{ - int startrow,startpass,numpasses; - startrow = startpass = 0; - if (resuming) - { - start_resume(); - get_resume(sizeof(startrow),&startrow,sizeof(startpass),&startpass,0); - end_resume(); - } - if (teststart()) /* assume it was stand-alone, doesn't want passes logic */ - return(0); - numpasses = (stdcalcmode == '1') ? 0 : 1; - for (passes=startpass; passes <= numpasses ; passes++) - { - for (row = startrow; row <= iystop; row=row+1+numpasses) - { - for (col = 0; col <= ixstop; col++) /* look at each point on screen */ - { - register int color; - init.x = dxpixel(); - init.y = dypixel(); - if (driver_key_pressed()) - { - testend(); - alloc_resume(20,1); - put_resume(sizeof(row),&row,sizeof(passes),&passes,0); - return(-1); - } - color = testpt(init.x,init.y,parm.x,parm.y,maxit,inside); - if (color >= colors) { /* avoid trouble if color is 0 */ - if (colors < 16) - color &= g_and_color; - else - color = ((color-1) % g_and_color) + 1; /* skip color zero */ - } - (*plot)(col,row,color); - if (numpasses && (passes == 0)) - (*plot)(col,row+1,color); - } - } - startrow = passes + 1; - } - testend(); - return(0); -} - -/***************** standalone engine for "plasma" ********************/ - -static int iparmx; /* iparmx = parm.x * 8 */ -static int shiftvalue; /* shift based on #colors */ -static int recur1=1; -static int pcolors; -static int recur_level = 0; -U16 max_plasma; - -/* returns a random 16 bit value that is never 0 */ -U16 rand16(void) -{ - U16 value; - value = (U16)rand15(); - value <<= 1; - value = (U16)(value + (rand15()&1)); - if (value < 1) - value = 1; - return(value); -} - -void _fastcall putpot(int x, int y, U16 color) -{ - if (color < 1) - color = 1; - putcolor(x, y, color >> 8 ? color >> 8 : 1); /* don't write 0 */ - /* we don't write this if driver_diskp() because the above putcolor - was already a "writedisk" in that case */ - if (!driver_diskp()) - writedisk(x+sxoffs,y+syoffs,color >> 8); /* upper 8 bits */ - writedisk(x+sxoffs,y+sydots+syoffs,color&255); /* lower 8 bits */ -} - -/* fixes border */ -void _fastcall putpotborder(int x, int y, U16 color) -{ - if ((x==0) || (y==0) || (x==xdots-1) || (y==ydots-1)) - color = (U16)outside; - putpot(x,y,color); -} - -/* fixes border */ -void _fastcall putcolorborder(int x, int y, int color) -{ - if ((x==0) || (y==0) || (x==xdots-1) || (y==ydots-1)) - color = outside; - if (color < 1) - color = 1; - putcolor(x,y,color); -} - -U16 _fastcall getpot(int x, int y) -{ - U16 color; - - color = (U16)readdisk(x+sxoffs,y+syoffs); - color = (U16)((color << 8) + (U16) readdisk(x+sxoffs,y+sydots+syoffs)); - return(color); -} - -static int plasma_check; /* to limit kbd checking */ - -static U16 _fastcall adjust(int xa,int ya,int x,int y,int xb,int yb) -{ - S32 pseudorandom; - pseudorandom = ((S32)iparmx)*((rand15()-16383)); -/* pseudorandom = pseudorandom*(abs(xa-xb)+abs(ya-yb));*/ - pseudorandom = pseudorandom * recur1; - pseudorandom = pseudorandom >> shiftvalue; - pseudorandom = (((S32)getpix(xa,ya)+(S32)getpix(xb,yb)+1)>>1)+pseudorandom; - if (max_plasma == 0) - { - if (pseudorandom >= pcolors) - pseudorandom = pcolors-1; - } - else if (pseudorandom >= (S32)max_plasma) - pseudorandom = max_plasma; - if (pseudorandom < 1) - pseudorandom = 1; - plot(x,y,(U16)pseudorandom); - return((U16)pseudorandom); -} - - -static int _fastcall new_subD (int x1,int y1,int x2,int y2, int recur) -{ - int x,y; - int nx1; - int nx; - int ny1, ny; - S32 i, v; - - struct sub { - BYTE t; /* top of stack */ - int v[16]; /* subdivided value */ - BYTE r[16]; /* recursion level */ - }; - - static struct sub subx, suby; - - /* - recur1=1; - for (i=1;i<=recur;i++) - recur1 = recur1 * 2; - recur1=320/recur1; - */ - recur1 = (int)(320L >> recur); - suby.t = 2; - ny = suby.v[0] = y2; - ny1 = suby.v[2] = y1; - suby.r[0] = suby.r[2] = 0; - suby.r[1] = 1; - y = suby.v[1] = (ny1 + ny) >> 1; - - while (suby.t >= 1) - { - if ((++plasma_check & 0x0f) == 1) - if (driver_key_pressed()) - { - plasma_check--; - return(1); - } - while (suby.r[suby.t-1] < (BYTE)recur) - { - /* 1. Create new entry at top of the stack */ - /* 2. Copy old top value to new top value. */ - /* This is largest y value. */ - /* 3. Smallest y is now old mid point */ - /* 4. Set new mid point recursion level */ - /* 5. New mid point value is average */ - /* of largest and smallest */ - - suby.t++; - ny1 = suby.v[suby.t] = suby.v[suby.t-1]; - ny = suby.v[suby.t-2]; - suby.r[suby.t] = suby.r[suby.t-1]; - y = suby.v[suby.t-1] = (ny1 + ny) >> 1; - suby.r[suby.t-1] = (BYTE)(max(suby.r[suby.t], suby.r[suby.t-2])+1); - } - subx.t = 2; - nx = subx.v[0] = x2; - nx1 = subx.v[2] = x1; - subx.r[0] = subx.r[2] = 0; - subx.r[1] = 1; - x = subx.v[1] = (nx1 + nx) >> 1; - - while (subx.t >= 1) - { - while (subx.r[subx.t-1] < (BYTE)recur) - { - subx.t++; /* move the top ofthe stack up 1 */ - nx1 = subx.v[subx.t] = subx.v[subx.t-1]; - nx = subx.v[subx.t-2]; - subx.r[subx.t] = subx.r[subx.t-1]; - x = subx.v[subx.t-1] = (nx1 + nx) >> 1; - subx.r[subx.t-1] = (BYTE)(max(subx.r[subx.t], - subx.r[subx.t-2])+1); - } - - i = getpix(nx, y); - if (i == 0) - i = adjust(nx,ny1,nx,y ,nx,ny); - v = i; - i = getpix(x, ny); - if (i == 0) - i = adjust(nx1,ny,x ,ny,nx,ny); - v += i; - if (getpix(x,y) == 0) - { - i = getpix(x, ny1); - if (i == 0) - i = adjust(nx1,ny1,x ,ny1,nx,ny1); - v += i; - i = getpix(nx1, y); - if (i == 0) - i = adjust(nx1,ny1,nx1,y ,nx1,ny); - v += i; - plot(x,y,(U16)((v + 2) >> 2)); - } - - if (subx.r[subx.t-1] == (BYTE)recur) subx.t = (BYTE)(subx.t - 2); - } - - if (suby.r[suby.t-1] == (BYTE)recur) suby.t = (BYTE)(suby.t - 2); - } - return(0); -} - -static void _fastcall subDivide(int x1,int y1,int x2,int y2) -{ - int x,y; - S32 v,i; - if ((++plasma_check & 0x7f) == 1) - if (driver_key_pressed()) - { - plasma_check--; - return; - } - if (x2-x1<2 && y2-y1<2) - return; - recur_level++; - recur1 = (int)(320L >> recur_level); - - x = (x1+x2)>>1; - y = (y1+y2)>>1; - v=getpix(x,y1); - if (v == 0) - v=adjust(x1,y1,x ,y1,x2,y1); - i=v; - v=getpix(x2,y); - if (v == 0) - v=adjust(x2,y1,x2,y ,x2,y2); - i+=v; - v=getpix(x,y2); - if (v == 0) - v=adjust(x1,y2,x ,y2,x2,y2); - i+=v; - v=getpix(x1,y); - if (v == 0) - v=adjust(x1,y1,x1,y ,x1,y2); - i+=v; - - if (getpix(x,y) == 0) - plot(x,y,(U16)((i+2)>>2)); - - subDivide(x1,y1,x ,y); - subDivide(x ,y1,x2,y); - subDivide(x ,y ,x2,y2); - subDivide(x1,y ,x ,y2); - recur_level--; -} - - -int plasma() -{ - int i,k, n; - U16 rnd[4]; - int OldPotFlag, OldPot16bit; - - OldPotFlag=OldPot16bit=plasma_check = 0; - - if (colors < 4) { - stopmsg(0, - "Plasma Clouds can currently only be run in a 4-or-more-color video\n" - "mode (and color-cycled only on VGA adapters [or EGA adapters in their\n" - "640x350x16 mode])."); - return(-1); - } - iparmx = (int)(param[0] * 8); - if (parm.x <= 0.0) iparmx = 0; - if (parm.x >= 100) iparmx = 800; - param[0] = (double)iparmx / 8.0; /* let user know what was used */ - if (param[1] < 0) param[1] = 0; /* limit parameter values */ - if (param[1] > 1) param[1] = 1; - if (param[2] < 0) param[2] = 0; /* limit parameter values */ - if (param[2] > 1) param[2] = 1; - if (param[3] < 0) param[3] = 0; /* limit parameter values */ - if (param[3] > 1) param[3] = 1; - - if ((!rflag) && param[2] == 1) - --rseed; - if (param[2] != 0 && param[2] != 1) - rseed = (int)param[2]; - max_plasma = (U16)param[3]; /* max_plasma is used as a flag for potential */ - - if (max_plasma != 0) - { - if (pot_startdisk() >= 0) - { - /* max_plasma = (U16)(1L << 16) -1; */ - max_plasma = 0xFFFF; - if (outside >= 0) - plot = (PLOT)putpotborder; - else - plot = (PLOT)putpot; - getpix = getpot; - OldPotFlag = potflag; - OldPot16bit = pot16bit; - } - else - { - max_plasma = 0; /* can't do potential (startdisk failed) */ - param[3] = 0; - if (outside >= 0) - plot = putcolorborder; - else - plot = putcolor; - getpix = (U16(_fastcall *)(int,int))getcolor; - } - } - else - { - if (outside >= 0) - plot = putcolorborder; - else - plot = putcolor; - getpix = (U16(_fastcall *)(int,int))getcolor; - } - srand(rseed); - if (!rflag) ++rseed; - - if (colors == 256) /* set the (256-color) palette */ - set_Plasma_palette(); /* skip this if < 256 colors */ - - if (colors > 16) - shiftvalue = 18; - else - { - if (colors > 4) - shiftvalue = 22; - else - { - if (colors > 2) - shiftvalue = 24; - else - shiftvalue = 25; - } - } - if (max_plasma != 0) - shiftvalue = 10; - - if (max_plasma == 0) - { - pcolors = min(colors, max_colors); - for (n = 0; n < 4; n++) - rnd[n] = (U16)(1+(((rand15()/pcolors)*(pcolors-1))>>(shiftvalue-11))); - } - else - for (n = 0; n < 4; n++) - rnd[n] = rand16(); - if (debugflag==3600) - for (n = 0; n < 4; n++) - rnd[n] = 1; - - plot( 0, 0, rnd[0]); - plot(xdots-1, 0, rnd[1]); - plot(xdots-1,ydots-1, rnd[2]); - plot( 0,ydots-1, rnd[3]); - - recur_level = 0; - if (param[1] == 0) - subDivide(0,0,xdots-1,ydots-1); - else - { - recur1 = i = k = 1; - while (new_subD(0,0,xdots-1,ydots-1,i)==0) - { - k = k * 2; - if (k >(int)max(xdots-1,ydots-1)) - break; - if (driver_key_pressed()) - { - n = 1; - goto done; - } - i++; - } - } - if (!driver_key_pressed()) - n = 0; - else - n = 1; - done: - if (max_plasma != 0) - { - potflag = OldPotFlag; - pot16bit = OldPot16bit; - } - plot = putcolor; - getpix = (U16(_fastcall *)(int,int))getcolor; - return(n); -} - -#define dac ((Palettetype *)g_dac_box) -static void set_Plasma_palette() -{ - static Palettetype Red = { 63, 0, 0 }; - static Palettetype Green = { 0, 63, 0 }; - static Palettetype Blue = { 0, 0,63 }; - int i; - - if (mapdacbox || colorpreloaded) return; /* map= specified */ - - dac[0].red = 0 ; - dac[0].green= 0 ; - dac[0].blue = 0 ; - for (i=1; i<=85; i++) - { -#ifdef __SVR4 - dac[i].red = (BYTE)((i*(int)Green.red + (86-i)*(int)Blue.red)/85); - dac[i].green = (BYTE)((i*(int)Green.green + (86-i)*(int)Blue.green)/85); - dac[i].blue = (BYTE)((i*(int)Green.blue + (86-i)*(int)Blue.blue)/85); - - dac[i+85].red = (BYTE)((i*(int)Red.red + (86-i)*(int)Green.red)/85); - dac[i+85].green = (BYTE)((i*(int)Red.green + (86-i)*(int)Green.green)/85); - dac[i+85].blue = (BYTE)((i*(int)Red.blue + (86-i)*(int)Green.blue)/85); - - dac[i+170].red = (BYTE)((i*(int)Blue.red + (86-i)*(int)Red.red)/85); - dac[i+170].green = (BYTE)((i*(int)Blue.green + (86-i)*(int)Red.green)/85); - dac[i+170].blue = (BYTE)((i*(int)Blue.blue + (86-i)*(int)Red.blue)/85); -#else - dac[i].red = (BYTE)((i*Green.red + (86-i)*Blue.red)/85); - dac[i].green = (BYTE)((i*Green.green + (86-i)*Blue.green)/85); - dac[i].blue = (BYTE)((i*Green.blue + (86-i)*Blue.blue)/85); - - dac[i+85].red = (BYTE)((i*Red.red + (86-i)*Green.red)/85); - dac[i+85].green = (BYTE)((i*Red.green + (86-i)*Green.green)/85); - dac[i+85].blue = (BYTE)((i*Red.blue + (86-i)*Green.blue)/85); - dac[i+170].red = (BYTE)((i*Blue.red + (86-i)*Red.red)/85); - dac[i+170].green = (BYTE)((i*Blue.green + (86-i)*Red.green)/85); - dac[i+170].blue = (BYTE)((i*Blue.blue + (86-i)*Red.blue)/85); -#endif - } - spindac(0,1); -} - -/***************** standalone engine for "diffusion" ********************/ - -#define RANDOM(x) (rand()%(x)) - -int diffusion() -{ - int xmax,ymax,xmin,ymin; /* Current maximum coordinates */ - int border; /* Distance between release point and fractal */ - int mode; /* Determines diffusion type: 0 = central (classic) */ - /* 1 = falling particles */ - /* 2 = square cavity */ - int colorshift; /* If zero, select colors at random, otherwise shift */ - /* the color every colorshift points */ - - int colorcount,currentcolor; - - int i; - double cosine,sine,angle; - int x,y; - float r, radius; - - if (driver_diskp()) - notdiskmsg(); - - x = y = -1; - bitshift = 16; - fudge = 1L << 16; - - border = (int)param[0]; - mode = (int)param[1]; - colorshift = (int)param[2]; - - colorcount = colorshift; /* Counts down from colorshift */ - currentcolor = 1; /* Start at color 1 (color 0 is probably invisible)*/ - - if (mode > 2) - mode=0; - - if (border <= 0) - border = 10; - - srand(rseed); - if (!rflag) ++rseed; - - if (mode == 0) { - xmax = xdots / 2 + border; /* Initial box */ - xmin = xdots / 2 - border; - ymax = ydots / 2 + border; - ymin = ydots / 2 - border; - } - if (mode == 1) { - xmax = xdots / 2 + border; /* Initial box */ - xmin = xdots / 2 - border; - ymin = ydots - border; - } - if (mode == 2) { - if (xdots > ydots) - radius = (float) (ydots - border); - else - radius = (float) (xdots - border); - } - if (resuming) /* restore worklist, if we can't the above will stay in place */ - { - start_resume(); - if (mode != 2) - get_resume(sizeof(xmax),&xmax,sizeof(xmin),&xmin,sizeof(ymax),&ymax, - sizeof(ymin),&ymin,0); - else - get_resume(sizeof(xmax),&xmax,sizeof(xmin),&xmin,sizeof(ymax),&ymax, - sizeof(radius),&radius,0); - end_resume(); - } - - switch (mode) { - case 0: /* Single seed point in the center */ - putcolor(xdots / 2, ydots / 2,currentcolor); - break; - case 1: /* Line along the bottom */ - for (i=0;i<=xdots;i++) - putcolor(i,ydots-1,currentcolor); - break; - case 2: /* Large square that fills the screen */ - if (xdots > ydots) - for (i=0;i> 1; /* divide by 2 */ - y = y >> 1; - break; - case 1: /* Release new point on the line ymin somewhere between xmin - and xmax */ - y=ymin; - x=RANDOM(xmax-xmin) + (xdots-xmax+xmin)/2; - break; - case 2: /* Release new point on a circle inside the box with radius - given by the radius variable */ - angle=2*(double)rand()/(RAND_MAX/PI); - FPUsincos(&angle,&sine,&cosine); - x = (int)(cosine*radius + xdots); - y = (int)(sine *radius + ydots); - x = x >> 1; - y = y >> 1; - break; - } - - /* Loop as long as the point (x,y) is surrounded by color 0 */ - /* on all eight sides */ - - while ((getcolor(x+1,y+1) == 0) && (getcolor(x+1,y) == 0) && - (getcolor(x+1,y-1) == 0) && (getcolor(x ,y+1) == 0) && - (getcolor(x ,y-1) == 0) && (getcolor(x-1,y+1) == 0) && - (getcolor(x-1,y) == 0) && (getcolor(x-1,y-1) == 0)) - { - /* Erase moving point */ - if (show_orbit) - putcolor(x,y,0); - - if (mode==0){ /* Make sure point is inside the box */ - if (x==xmax) - x--; - else if (x==xmin) - x++; - if (y==ymax) - y--; - else if (y==ymin) - y++; - } - - if (mode==1) /* Make sure point is on the screen below ymin, but - we need a 1 pixel margin because of the next random step.*/ - { - if (x>=xdots-1) - x--; - else if (x<=1) - x++; - if (yxmax) || ((x-border)ymax)) - { - /* Increase box size, but not past the edge of the screen */ - ymin--; - ymax++; - xmin--; - xmax++; - if ((ymin==0) || (xmin==0)) - return 0; - } - break; - case 1: /* Decrease ymin, but not past top of screen */ - if (y-border < ymin) - ymin--; - if (ymin==0) - return 0; - break; - case 2: /* Decrease the radius where points are released to stay away - from the fractal. It might be decreased by 1 or 2 */ - r = sqr((float)x-xdots/2) + sqr((float)y-ydots/2); - if (r<=border*border) - return 0; - while ((radius-border)*(radius-border) > r) - radius--; - break; - } - } -} - - - -/************ standalone engine for "bifurcation" types ***************/ - -/***************************************************************/ -/* The following code now forms a generalised Fractal Engine */ -/* for Bifurcation fractal typeS. By rights it now belongs in */ -/* CALCFRACT.C, but it's easier for me to leave it here ! */ - -/* Original code by Phil Wilson, hacked around by Kev Allen. */ - -/* Besides generalisation, enhancements include Periodicity */ -/* Checking during the plotting phase (AND halfway through the */ -/* filter cycle, if possible, to halve calc times), quicker */ -/* floating-point calculations for the standard Verhulst type, */ -/* and new bifurcation types (integer bifurcation, f.p & int */ -/* biflambda - the real equivalent of complex Lambda sets - */ -/* and f.p renditions of bifurcations of r*sin(Pi*p), which */ -/* spurred Mitchel Feigenbaum on to discover his Number). */ - -/* To add further types, extend the fractalspecific[] array in */ -/* usual way, with Bifurcation as the engine, and the name of */ -/* the routine that calculates the next bifurcation generation */ -/* as the "orbitcalc" routine in the fractalspecific[] entry. */ - -/* Bifurcation "orbitcalc" routines get called once per screen */ -/* pixel column. They should calculate the next generation */ -/* from the doubles Rate & Population (or the longs lRate & */ -/* lPopulation if they use integer math), placing the result */ -/* back in Population (or lPopulation). They should return 0 */ -/* if all is ok, or any non-zero value if calculation bailout */ -/* is desirable (eg in case of errors, or the series tending */ -/* to infinity). Have fun ! */ -/***************************************************************/ - -#define DEFAULTFILTER 1000 /* "Beauty of Fractals" recommends using 5000 - (p.25), but that seems unnecessary. Can - override this value with a nonzero param1 */ - -#define SEED 0.66 /* starting value for population */ - -static int *verhulst_array; -unsigned long filter_cycles; -static unsigned int half_time_check; -static long lPopulation, lRate; -double Population, Rate; -static int mono, outside_x; -static long LPI; - -int Bifurcation(void) -{ - unsigned long array_size; - int row, column; - column = 0; - if (resuming) - { - start_resume(); - get_resume(sizeof(column),&column,0); - end_resume(); - } - array_size = (iystop + 1) * sizeof(int); /* should be iystop + 1 */ - if ((verhulst_array = (int *) malloc(array_size)) == NULL) - { - stopmsg(0, "Insufficient free memory for calculation."); - return(-1); - } - - LPI = (long)(PI * fudge); - - for (row = 0; row <= iystop; row++) /* should be iystop */ - verhulst_array[row] = 0; - - mono = 0; - if (colors == 2) - mono = 1; - if (mono) - { - if (inside) - { - outside_x = 0; - inside = 1; - } - else - outside_x = 1; - } - - filter_cycles = (parm.x <= 0) ? DEFAULTFILTER : (long)parm.x; - half_time_check = FALSE; - if (periodicitycheck && (unsigned long)maxit < filter_cycles) - { - filter_cycles = (filter_cycles - maxit + 1) / 2; - half_time_check = TRUE; - } - - if (integerfractal) - linit.y = ymax - iystop*dely; /* Y-value of */ - else - init.y = (double)(yymax - iystop*delyy); /* bottom pixels */ - - while (column <= ixstop) - { - if (driver_key_pressed()) - { - free((char *)verhulst_array); - alloc_resume(10,1); - put_resume(sizeof(column),&column,0); - return(-1); - } - - if (integerfractal) - lRate = xmin + column*delx; - else - Rate = (double)(xxmin + column*delxx); - verhulst(); /* calculate array once per column */ - - for (row = iystop; row >= 0; row--) /* should be iystop & >=0 */ - { - int color; - color = verhulst_array[row]; - if (color && mono) - color = inside; - else if ((!color) && mono) - color = outside_x; - else if (color>=colors) - color = colors-1; - verhulst_array[row] = 0; - (*plot)(column,row,color); /* was row-1, but that's not right? */ - } - column++; - } - free((char *)verhulst_array); - return(0); -} - -static void verhulst() /* P. F. Verhulst (1845) */ -{ - unsigned int pixel_row, errors; - unsigned long counter; - - if (integerfractal) - lPopulation = (parm.y == 0) ? (long)(SEED*fudge) : (long)(parm.y*fudge); - else - Population = (parm.y == 0 ) ? SEED : parm.y; - - errors = overflow = FALSE; - - for (counter=0 ; counter < filter_cycles ; counter++) - { - errors = curfractalspecific->orbitcalc(); - if (errors) - return; - } - if (half_time_check) /* check for periodicity at half-time */ - { - Bif_Period_Init(); - for (counter=0 ; counter < (unsigned long)maxit ; counter++) - { - errors = curfractalspecific->orbitcalc(); - if (errors) return; - if (periodicitycheck && Bif_Periodic(counter)) break; - } - if (counter >= (unsigned long)maxit) /* if not periodic, go the distance */ - { - for (counter=0 ; counter < filter_cycles ; counter++) - { - errors = curfractalspecific->orbitcalc(); - if (errors) return; - } - } - } - - if (periodicitycheck) Bif_Period_Init(); - for (counter=0 ; counter < (unsigned long)maxit ; counter++) - { - errors = curfractalspecific->orbitcalc(); - if (errors) return; - - /* assign population value to Y coordinate in pixels */ - if (integerfractal) - pixel_row = iystop - (int)((lPopulation - linit.y) / dely); /* iystop */ - else - pixel_row = iystop - (int)((Population - init.y) / delyy); - - /* if it's visible on the screen, save it in the column array */ - if (pixel_row <= (unsigned int)iystop) /* JCO 6/6/92 */ - verhulst_array[ pixel_row ] ++; - if (periodicitycheck && Bif_Periodic(counter)) - { - if (pixel_row <= (unsigned int)iystop) /* JCO 6/6/92 */ - verhulst_array[ pixel_row ] --; - break; - } - } -} -static long lBif_closenuf, lBif_savedpop; /* poss future use */ -static double Bif_closenuf, Bif_savedpop; -static int Bif_savedinc; -static long Bif_savedand; - -static void Bif_Period_Init() -{ - Bif_savedinc = 1; - Bif_savedand = 1; - if (integerfractal) - { - lBif_savedpop = -1; - lBif_closenuf = dely / 8; - } - else - { - Bif_savedpop = -1.0; - Bif_closenuf = (double)delyy / 8.0; - } -} - -static int _fastcall Bif_Periodic (long time) /* Bifurcation Population Periodicity Check */ -/* Returns : 1 if periodicity found, else 0 */ -{ - if ((time & Bif_savedand) == 0) /* time to save a new value */ - { - if (integerfractal) lBif_savedpop = lPopulation; - else Bif_savedpop = Population; - if (--Bif_savedinc == 0) - { - Bif_savedand = (Bif_savedand << 1) + 1; - Bif_savedinc = 4; - } - } - else /* check against an old save */ - { - if (integerfractal) - { - if (labs(lBif_savedpop-lPopulation) <= lBif_closenuf) - return(1); - } - else - { - if (fabs(Bif_savedpop-Population) <= Bif_closenuf) - return(1); - } - } - return(0); -} - -/**********************************************************************/ -/* */ -/* The following are Bifurcation "orbitcalc" routines... */ -/* */ -/**********************************************************************/ -#if defined(XFRACT) || defined(_WIN32) -int BifurcLambda() /* Used by lyanupov */ - { - Population = Rate * Population * (1 - Population); - return (fabs(Population) > BIG); - } -#endif - -/* Modified formulas below to generalize bifurcations. JCO 7/3/92 */ - -#define LCMPLXtrig0(arg,out) Arg1->l = (arg); ltrig0(); (out)=Arg1->l -#define CMPLXtrig0(arg,out) Arg1->d = (arg); dtrig0(); (out)=Arg1->d - -int BifurcVerhulstTrig() - { -/* Population = Pop + Rate * fn(Pop) * (1 - fn(Pop)) */ - tmp.x = Population; - tmp.y = 0; - CMPLXtrig0(tmp, tmp); - Population += Rate * tmp.x * (1 - tmp.x); - return (fabs(Population) > BIG); - } - -int LongBifurcVerhulstTrig() - { -#if !defined(XFRACT) - ltmp.x = lPopulation; - ltmp.y = 0; - LCMPLXtrig0(ltmp, ltmp); - ltmp.y = ltmp.x - multiply(ltmp.x,ltmp.x,bitshift); - lPopulation += multiply(lRate,ltmp.y,bitshift); -#endif - return (overflow); - } - -int BifurcStewartTrig() - { -/* Population = (Rate * fn(Population) * fn(Population)) - 1.0 */ - tmp.x = Population; - tmp.y = 0; - CMPLXtrig0(tmp, tmp); - Population = (Rate * tmp.x * tmp.x) - 1.0; - return (fabs(Population) > BIG); - } - -int LongBifurcStewartTrig() - { -#if !defined(XFRACT) - ltmp.x = lPopulation; - ltmp.y = 0; - LCMPLXtrig0(ltmp, ltmp); - lPopulation = multiply(ltmp.x,ltmp.x,bitshift); - lPopulation = multiply(lPopulation,lRate, bitshift); - lPopulation -= fudge; -#endif - return (overflow); - } - -int BifurcSetTrigPi() - { - tmp.x = Population * PI; - tmp.y = 0; - CMPLXtrig0(tmp, tmp); - Population = Rate * tmp.x; - return (fabs(Population) > BIG); - } - -int LongBifurcSetTrigPi() - { -#if !defined(XFRACT) - ltmp.x = multiply(lPopulation,LPI,bitshift); - ltmp.y = 0; - LCMPLXtrig0(ltmp, ltmp); - lPopulation = multiply(lRate,ltmp.x,bitshift); -#endif - return (overflow); - } - -int BifurcAddTrigPi() - { - tmp.x = Population * PI; - tmp.y = 0; - CMPLXtrig0(tmp, tmp); - Population += Rate * tmp.x; - return (fabs(Population) > BIG); - } - -int LongBifurcAddTrigPi() - { -#if !defined(XFRACT) - ltmp.x = multiply(lPopulation,LPI,bitshift); - ltmp.y = 0; - LCMPLXtrig0(ltmp, ltmp); - lPopulation += multiply(lRate,ltmp.x,bitshift); -#endif - return (overflow); - } - -int BifurcLambdaTrig() - { -/* Population = Rate * fn(Population) * (1 - fn(Population)) */ - tmp.x = Population; - tmp.y = 0; - CMPLXtrig0(tmp, tmp); - Population = Rate * tmp.x * (1 - tmp.x); - return (fabs(Population) > BIG); - } - -int LongBifurcLambdaTrig() - { -#if !defined(XFRACT) - ltmp.x = lPopulation; - ltmp.y = 0; - LCMPLXtrig0(ltmp, ltmp); - ltmp.y = ltmp.x - multiply(ltmp.x,ltmp.x,bitshift); - lPopulation = multiply(lRate,ltmp.y,bitshift); -#endif - return (overflow); - } - -#define LCMPLXpwr(arg1,arg2,out) Arg2->l = (arg1); Arg1->l = (arg2);\ - lStkPwr(); Arg1++; Arg2++; (out) = Arg2->l - -long beta; - -int BifurcMay() - { /* X = (lambda * X) / (1 + X)^beta, from R.May as described in Pickover, - Computers, Pattern, Chaos, and Beauty, page 153 */ - tmp.x = 1.0 + Population; - tmp.x = pow(tmp.x, -beta); /* pow in math.h included with mpmath.h */ - Population = (Rate * Population) * tmp.x; - return (fabs(Population) > BIG); - } - -int LongBifurcMay() - { -#if !defined(XFRACT) - ltmp.x = lPopulation + fudge; - ltmp.y = 0; - lparm2.x = beta * fudge; - LCMPLXpwr(ltmp, lparm2, ltmp); - lPopulation = multiply(lRate,lPopulation,bitshift); - lPopulation = divide(lPopulation,ltmp.x,bitshift); -#endif - return (overflow); - } - -int BifurcMaySetup() - { - - beta = (long)param[2]; - if (beta < 2) - beta = 2; - param[2] = (double)beta; - - timer(0,curfractalspecific->calctype); - return(0); - } - -/* Here Endeth the Generalised Bifurcation Fractal Engine */ - -/* END Phil Wilson's Code (modified slightly by Kev Allen et. al. !) */ - - -/******************* standalone engine for "popcorn" ********************/ - -int popcorn() /* subset of std engine */ -{ - int start_row; - start_row = 0; - if (resuming) - { - start_resume(); - get_resume(sizeof(start_row),&start_row,0); - end_resume(); - } - kbdcount=max_kbdcount; - plot = noplot; - tempsqrx = ltempsqrx = 0; /* PB added this to cover weird BAILOUTs */ - for (row = start_row; row <= iystop; row++) - { - reset_periodicity = 1; - for (col = 0; col <= ixstop; col++) - { - if (StandardFractal() == -1) /* interrupted */ - { - alloc_resume(10,1); - put_resume(sizeof(row),&row,0); - return(-1); - } - reset_periodicity = 0; - } - } - calc_status = CALCSTAT_COMPLETED; - return(0); -} - -/******************* standalone engine for "lyapunov" *********************/ -/*** Roy Murphy [76376,721] ***/ -/*** revision history: ***/ -/*** initial version: Winter '91 ***/ -/*** Fall '92 integration of Nicholas Wilt's ASM speedups ***/ -/*** Jan 93' integration with calcfrac() yielding boundary tracing, ***/ -/*** tesseral, and solid guessing, and inversion, inside=nnn ***/ -/*** save_release behavior: ***/ -/*** 1730 & prior: ignores inside=, calcmode='1', (a,b)->(x,y) ***/ -/*** 1731: other calcmodes and inside=nnn ***/ -/*** 1732: the infamous axis swap: (b,a)->(x,y), ***/ -/*** the order parameter becomes a long int ***/ -/**************************************************************************/ -int lyaLength, lyaSeedOK; -int lyaRxy[34]; - -#define WES 1 /* define WES to be 0 to use Nick's lyapunov.obj */ -#if WES -int lyapunov_cycles(double, double); -#else -int lyapunov_cycles(int, double, double, double); -#endif - -int lyapunov_cycles_in_c(long, double, double); - -int lyapunov () { - double a, b; - - if (driver_key_pressed()) { - return -1; - } - overflow=FALSE; - if (param[1]==1) Population = (1.0+rand())/(2.0+RAND_MAX); - else if (param[1]==0) { - if (fabs(Population)>BIG || Population==0 || Population==1) - Population = (1.0+rand())/(2.0+RAND_MAX); - } - else Population = param[1]; - (*plot)(col, row, 1); - if (invert) { - invertz2(&init); - a = init.y; - b = init.x; - } - else { - a = dypixel(); - b = dxpixel(); - } -#if !defined(XFRACT) && !defined(_WIN32) - /* the assembler routines don't work for a & b outside the - ranges 0 < a < 4 and 0 < b < 4. So, fall back on the C - routines if part of the image sticks out. - */ -#if WES - color=lyapunov_cycles(a, b); -#else - if (lyaSeedOK && a>0 && b>0 && a<=4 && b<=4) - color=lyapunov_cycles(filter_cycles, Population, a, b); - else - color=lyapunov_cycles_in_c(filter_cycles, a, b); -#endif -#else - color=lyapunov_cycles_in_c(filter_cycles, a, b); -#endif - if (inside>0 && color==0) - color = inside; - else if (color>=colors) - color = colors-1; - (*plot)(col, row, color); - return color; -} - - -int lya_setup () { - /* This routine sets up the sequence for forcing the Rate parameter - to vary between the two values. It fills the array lyaRxy[] and - sets lyaLength to the length of the sequence. - - The sequence is coded in the bit pattern in an integer. - Briefly, the sequence starts with an A the leading zero bits - are ignored and the remaining bit sequence is decoded. The - sequence ends with a B. Not all possible sequences can be - represented in this manner, but every possible sequence is - either represented as itself, as a rotation of one of the - representable sequences, or as the inverse of a representable - sequence (swapping 0s and 1s in the array.) Sequences that - are the rotation and/or inverses of another sequence will generate - the same lyapunov exponents. - - A few examples follow: - number sequence - 0 ab - 1 aab - 2 aabb - 3 aaab - 4 aabbb - 5 aabab - 6 aaabb (this is a duplicate of 4, a rotated inverse) - 7 aaaab - 8 aabbbb etc. - */ - - long i; - int t; - - if ((filter_cycles=(long)param[2])==0) - filter_cycles=maxit/2; - lyaSeedOK = param[1]>0 && param[1]<=1 && debugflag!=90; - lyaLength = 1; - - i = (long)param[0]; -#if !defined(XFRACT) - if (save_release<1732) i &= 0x0FFFFL; /* make it a short to reproduce prior stuff*/ -#endif - lyaRxy[0] = 1; - for (t=31; t>=0; t--) - if (i & (1<=0; t--) - lyaRxy[lyaLength++] = (i & (1<=0; t--) - lyaRxy[t] = !lyaRxy[t]; - if (save_release<1731) { /* ignore inside=, stdcalcmode */ - stdcalcmode='1'; - if (inside==1) inside = 0; - } - if (inside<0) { - stopmsg(0,"Sorry, inside options other than inside=nnn are not supported by the lyapunov"); - inside=1; - } - if (usr_stdcalcmode == 'o') { /* Oops,lyapunov type */ - usr_stdcalcmode = '1'; /* doesn't use new & breaks orbits */ - stdcalcmode = '1'; - } - return 1; -} - -int lyapunov_cycles_in_c(long filter_cycles, double a, double b) { - int color, count, lnadjust; - long i; - double lyap, total, temp; - /* e10=22026.4657948 e-10=0.0000453999297625 */ - - total = 1.0; - lnadjust = 0; - for (i=0; iorbitcalc()) { - overflow = TRUE; - goto jumpout; - } - } - } - for (i=0; i < maxit/2; i++) { - for (count = 0; count < lyaLength; count++) { - Rate = lyaRxy[count] ? a : b; - if (curfractalspecific->orbitcalc()) { - overflow = TRUE; - goto jumpout; - } - temp = fabs(Rate-2.0*Rate*Population); - total *= temp; - if (total==0) { - overflow = TRUE; - goto jumpout; - } - } - while (total > 22026.4657948) { - total *= 0.0000453999297625; - lnadjust += 10; - } - while (total < 0.0000453999297625) { - total *= 22026.4657948; - lnadjust -= 10; - } - } - -jumpout: - if (overflow || total <= 0 || (temp = log(total) + lnadjust) > 0) - color = 0; - else { - if (LogFlag) - lyap = -temp/((double) lyaLength*i); - else - lyap = 1 - exp(temp/((double) lyaLength*i)); - color = 1 + (int)(lyap * (colors-1)); - } - return color; -} - - -/******************* standalone engine for "cellular" ********************/ -/* Originally coded by Ken Shirriff. - Modified beyond recognition by Jonathan Osuch. - Original or'd the neighborhood, changed to sum the neighborhood - Changed prompts and error messages - Added CA types - Set the palette to some standard? CA colors - Changed *cell_array to near and used dstack so put_line and get_line - could be used all the time - Made space bar generate next screen - Increased string/rule size to 16 digits and added CA types 9/20/92 -*/ - -#define BAD_T 1 -#define BAD_MEM 2 -#define STRING1 3 -#define STRING2 4 -#define TABLEK 5 -#define TYPEKR 6 -#define RULELENGTH 7 -#define INTERUPT 8 - -#define CELLULAR_DONE 10 - -static BYTE *cell_array[2]; - -S16 r, k_1, rule_digits; -int lstscreenflag; - -void abort_cellular(int err, int t) -{ - int i; - switch (err) - { - case BAD_T: - { - char msg[30]; - sprintf(msg,"Bad t=%d, aborting\n", t); - stopmsg(0, msg); - } - break; - case BAD_MEM: - { - stopmsg(0, "Insufficient free memory for calculation"); - } - break; - case STRING1: - { - stopmsg(0, "String can be a maximum of 16 digits"); - } - break; - case STRING2: - { - static char msg[]={"Make string of 0's through 's" }; - msg[27] = (char)(k_1 + 48); /* turn into a character value */ - stopmsg(0,msg); - } - break; - case TABLEK: - { - static char msg[]={"Make Rule with 0's through 's" }; - msg[27] = (char)(k_1 + 48); /* turn into a character value */ - stopmsg(0,msg); - } - break; - case TYPEKR: - { - stopmsg(0, "Type must be 21, 31, 41, 51, 61, 22, 32, 42, 23, 33, 24, 25, 26, 27"); - } - break; - case RULELENGTH: - { - static char msg[]={"Rule must be digits long" }; - i = rule_digits / 10; - if (i==0) - msg[14] = (char)(rule_digits + 48); - else { - msg[13] = (char)(i+48); - msg[14] = (char)((rule_digits % 10) + 48); - } - stopmsg(0,msg); - } - break; - case INTERUPT: - { - stopmsg(0, "Interrupted, can't resume"); - } - break; - case CELLULAR_DONE: - break; - } - if (cell_array[0] != NULL) -#if !defined(XFRACT) && !defined(_WIN32) - cell_array[0] = NULL; -#else - free((char *)cell_array[0]); -#endif - if (cell_array[1] != NULL) -#if !defined(XFRACT) && !defined(_WIN32) - cell_array[1] = NULL; -#else - free((char *)cell_array[1]); -#endif -} - -int cellular () { - S16 start_row; - S16 filled, notfilled; - U16 cell_table[32]; - U16 init_string[16]; - U16 kr, k; - U32 lnnmbr; - U16 i, twor; - S16 t, t2; - S32 randparam; - double n; - char buf[30]; - - set_Cellular_palette(); - - randparam = (S32)param[0]; - lnnmbr = (U32)param[3]; - kr = (U16)param[2]; - switch (kr) { - case 21: - case 31: - case 41: - case 51: - case 61: - case 22: - case 32: - case 42: - case 23: - case 33: - case 24: - case 25: - case 26: - case 27: - break; - default: - abort_cellular(TYPEKR, 0); - return -1; - /* break; */ - } - - r = (S16)(kr % 10); /* Number of nearest neighbors to sum */ - k = (U16)(kr / 10); /* Number of different states, k=3 has states 0,1,2 */ - k_1 = (S16)(k - 1); /* Highest state value, k=3 has highest state value of 2 */ - rule_digits = (S16)((r * 2 + 1) * k_1 + 1); /* Number of digits in the rule */ - - if ((!rflag) && randparam == -1) - --rseed; - if (randparam != 0 && randparam != -1) { - n = param[0]; - sprintf(buf,"%.16g",n); /* # of digits in initial string */ - t = (S16)strlen(buf); - if (t>16 || t <= 0) { - abort_cellular(STRING1, 0); - return -1; - } - for (i=0;i<16;i++) - init_string[i] = 0; /* zero the array */ - t2 = (S16) ((16 - t)/2); - for (i=0;i<(U16)t;i++) { /* center initial string in array */ - init_string[i+t2] = (U16)(buf[i] - 48); /* change character to number */ - if (init_string[i+t2]>(U16)k_1) { - abort_cellular(STRING2, 0); - return -1; - } - } - } - - srand(rseed); - if (!rflag) ++rseed; - -/* generate rule table from parameter 1 */ -#if !defined(XFRACT) - n = param[1]; -#else - /* gcc can't manage to convert a big double to an unsigned long properly. */ - if (param[1]>0x7fffffff) { - n = (param[1]-0x7fffffff); - n += 0x7fffffff; - } else { - n = param[1]; - } -#endif - if (n == 0) { /* calculate a random rule */ - n = rand()%(int)k; - for (i=1;i<(U16)rule_digits;i++) { - n *= 10; - n += rand()%(int)k; - } - param[1] = n; - } - sprintf(buf,"%.*g",rule_digits ,n); - t = (S16)strlen(buf); - if (rule_digits < t || t < 0) { /* leading 0s could make t smaller */ - abort_cellular(RULELENGTH, 0); - return -1; - } - for (i=0;i<(U16)rule_digits;i++) /* zero the table */ - cell_table[i] = 0; - for (i=0;i<(U16)t;i++) { /* reverse order */ - cell_table[i] = (U16)(buf[t-i-1] - 48); /* change character to number */ - if (cell_table[i]>(U16)k_1) { - abort_cellular(TABLEK, 0); - return -1; - } - } - - - start_row = 0; -#if !defined(XFRACT) && !defined(_WIN32) - /* two 4096 byte arrays, at present at most 2024 + 1 bytes should be */ - /* needed in each array (max screen width + 1) */ - cell_array[0] = (BYTE *)&dstack[0]; /* dstack is in general.asm */ - cell_array[1] = (BYTE *)&boxy[0]; /* boxy is in general.asm */ -#else - cell_array[0] = (BYTE *)malloc(ixstop+1); - cell_array[1] = (BYTE *)malloc(ixstop+1); -#endif - if (cell_array[0]==NULL || cell_array[1]==NULL) { - abort_cellular(BAD_MEM, 0); - return(-1); - } - -/* nxtscreenflag toggled by space bar in fractint.c, 1 for continuous */ -/* 0 to stop on next screen */ - - filled = 0; - notfilled = (S16)(1-filled); - if (resuming && !nxtscreenflag && !lstscreenflag) { - start_resume(); - get_resume(sizeof(start_row),&start_row,0); - end_resume(); - get_line(start_row,0,ixstop,cell_array[filled]); - } - else if (nxtscreenflag && !lstscreenflag) { - start_resume(); - end_resume(); - get_line(iystop,0,ixstop,cell_array[filled]); - param[3] += iystop + 1; - start_row = -1; /* after 1st iteration its = 0 */ - } - else { - if (rflag || randparam==0 || randparam==-1){ - for (col=0;col<=ixstop;col++) { - cell_array[filled][col] = (BYTE)(rand()%(int)k); - } - } /* end of if random */ - - else { - for (col=0;col<=ixstop;col++) { /* Clear from end to end */ - cell_array[filled][col] = 0; - } - i = 0; - for (col=(ixstop-16)/2;col<(ixstop+16)/2;col++) { /* insert initial */ - cell_array[filled][col] = (BYTE)init_string[i++]; /* string */ - } - } /* end of if not random */ - if (lnnmbr != 0) - lstscreenflag = 1; - else - lstscreenflag = 0; - put_line(start_row,0,ixstop,cell_array[filled]); - } - start_row++; - -/* This section calculates the starting line when it is not zero */ -/* This section can't be resumed since no screen output is generated */ -/* calculates the (lnnmbr - 1) generation */ - if (lstscreenflag) { /* line number != 0 & not resuming & not continuing */ - U32 big_row; - for (big_row = (U32)start_row; big_row < lnnmbr; big_row++) { - thinking(1, "Cellular thinking (higher start row takes longer)"); - if (rflag || randparam==0 || randparam==-1){ - /* Use a random border */ - for (i=0;i<=(U16)r;i++) { - cell_array[notfilled][i]=(BYTE)(rand()%(int)k); - cell_array[notfilled][ixstop-i]=(BYTE)(rand()%(int)k); - } - } - else { - /* Use a zero border */ - for (i=0;i<=(U16)r;i++) { - cell_array[notfilled][i]=0; - cell_array[notfilled][ixstop-i]=0; - } - } - - t = 0; /* do first cell */ - for (twor=(U16)(r+r),i=0;i<=twor;i++) - t = (S16)(t + (S16)cell_array[filled][i]); - if (t>rule_digits || t<0) { - thinking(0, NULL); - abort_cellular(BAD_T, t); - return(-1); - } - cell_array[notfilled][r] = (BYTE)cell_table[t]; - - /* use a rolling sum in t */ - for (col=r+1;colrule_digits || t<0) { - thinking(0, NULL); - abort_cellular(BAD_T, t); - return(-1); - } - cell_array[notfilled][col] = (BYTE)cell_table[t]; - } - - filled = notfilled; - notfilled = (S16)(1-filled); - if (driver_key_pressed()) { - thinking(0, NULL); - abort_cellular(INTERUPT, 0); - return -1; - } - } - start_row = 0; - thinking(0, NULL); - lstscreenflag = 0; - } - -/* This section does all the work */ -contloop: - for (row = start_row; row <= iystop; row++) { - - if (rflag || randparam==0 || randparam==-1){ - /* Use a random border */ - for (i=0;i<=(U16)r;i++) { - cell_array[notfilled][i]=(BYTE)(rand()%(int)k); - cell_array[notfilled][ixstop-i]=(BYTE)(rand()%(int)k); - } - } - else { - /* Use a zero border */ - for (i=0;i<=(U16)r;i++) { - cell_array[notfilled][i]=0; - cell_array[notfilled][ixstop-i]=0; - } - } - - t = 0; /* do first cell */ - for (twor=(U16)(r+r),i=0;i<=twor;i++) - t = (S16)(t + (S16)cell_array[filled][i]); - if (t>rule_digits || t<0) { - thinking(0, NULL); - abort_cellular(BAD_T, t); - return(-1); - } - cell_array[notfilled][r] = (BYTE)cell_table[t]; - - /* use a rolling sum in t */ - for (col=r+1;colrule_digits || t<0) { - thinking(0, NULL); - abort_cellular(BAD_T, t); - return(-1); - } - cell_array[notfilled][col] = (BYTE)cell_table[t]; - } - - filled = notfilled; - notfilled = (S16)(1-filled); - put_line(row,0,ixstop,cell_array[filled]); - if (driver_key_pressed()) { - abort_cellular(CELLULAR_DONE, 0); - alloc_resume(10,1); - put_resume(sizeof(row),&row,0); - return -1; - } - } - if (nxtscreenflag) { - param[3] += iystop + 1; - start_row = 0; - goto contloop; - } - abort_cellular(CELLULAR_DONE, 0); - return 1; -} - -int CellularSetup(void) -{ - if (!resuming) { - nxtscreenflag = 0; /* initialize flag */ - } - timer(0,curfractalspecific->calctype); - return(0); -} - -static void set_Cellular_palette() -{ - static Palettetype Red = { 42, 0, 0 }; - static Palettetype Green = { 10,35,10 }; - static Palettetype Blue = { 13,12,29 }; - static Palettetype Yellow = { 60,58,18 }; - static Palettetype Brown = { 42,21, 0 }; - - if (mapdacbox && colorstate != 0) return; /* map= specified */ - - dac[0].red = 0 ; - dac[0].green= 0 ; - dac[0].blue = 0 ; - - dac[1].red = Red.red; - dac[1].green = Red.green; - dac[1].blue = Red.blue; - - dac[2].red = Green.red; - dac[2].green = Green.green; - dac[2].blue = Green.blue; - - dac[3].red = Blue.red; - dac[3].green = Blue.green; - dac[3].blue = Blue.blue; - - dac[4].red = Yellow.red; - dac[4].green = Yellow.green; - dac[4].blue = Yellow.blue; - - dac[5].red = Brown.red; - dac[5].green = Brown.green; - dac[5].blue = Brown.blue; - - spindac(0,1); -} - -/* frothy basin routines */ - -#define FROTH_BITSHIFT 28 -#define FROTH_D_TO_L(x) ((long)((x)*(1L<fl.f.a*fsp->fl.f.a/4) - - -struct froth_double_struct { - double a; - double halfa; - double top_x1; - double top_x2; - double top_x3; - double top_x4; - double left_x1; - double left_x2; - double left_x3; - double left_x4; - double right_x1; - double right_x2; - double right_x3; - double right_x4; - }; - -struct froth_long_struct { - long a; - long halfa; - long top_x1; - long top_x2; - long top_x3; - long top_x4; - long left_x1; - long left_x2; - long left_x3; - long left_x4; - long right_x1; - long right_x2; - long right_x3; - long right_x4; - }; - -struct froth_struct { - int repeat_mapping; - int altcolor; - int attractors; - int shades; - union { /* This was made into a union to save 56 malloc()'ed bytes. */ - struct froth_double_struct f; - struct froth_long_struct l; - } fl; - }; - -struct froth_struct *fsp=NULL; /* froth_struct pointer */ - -/* color maps which attempt to replicate the images of James Alexander. */ -static void set_Froth_palette(void) - { - char *mapname; - - if (colorstate != 0) /* 0 means g_dac_box matches default */ - return; - if (colors >= 16) - { - if (colors >= 256) - { - if (fsp->attractors == 6) - mapname = "froth6.map"; - else - mapname = "froth3.map"; - } - else /* colors >= 16 */ - { - if (fsp->attractors == 6) - mapname = "froth616.map"; - else - mapname = "froth316.map"; - } - if (ValidateLuts(mapname) != 0) - return; - colorstate = 0; /* treat map as default */ - spindac(0,1); - } - } - -int froth_setup(void) - { - double sin_theta, cos_theta, x0, y0; - - sin_theta = SQRT3/2; /* sin(2*PI/3) */ - cos_theta = -0.5; /* cos(2*PI/3) */ - - /* check for NULL as safety net */ - if (fsp == NULL) - fsp = (struct froth_struct *)malloc(sizeof (struct froth_struct)); - if (fsp == NULL) - { - stopmsg(0, "Sorry, not enough memory to run the frothybasin fractal type"); - return 0; - } - - /* for the all important backwards compatibility */ - if (save_release <= 1821) /* book version is 18.21 */ - { - /* use old release parameters */ - - fsp->repeat_mapping = ((int)param[0] == 6 || (int)param[0] == 2); /* map 1 or 2 times (3 or 6 basins) */ - fsp->altcolor = (int)param[1]; - param[2] = 0; /* throw away any value used prior to 18.20 */ - - fsp->attractors = !fsp->repeat_mapping ? 3 : 6; - - /* use old values */ /* old names */ - fsp->fl.f.a = 1.02871376822; /* A */ - fsp->fl.f.halfa = fsp->fl.f.a/2; /* A/2 */ - - fsp->fl.f.top_x1 = -1.04368901270; /* X1MIN */ - fsp->fl.f.top_x2 = 1.33928675524; /* X1MAX */ - fsp->fl.f.top_x3 = -0.339286755220; /* XMIDT */ - fsp->fl.f.top_x4 = -0.339286755220; /* XMIDT */ - - fsp->fl.f.left_x1 = 0.07639837810; /* X3MAX2 */ - fsp->fl.f.left_x2 = -1.11508950586; /* X2MIN2 */ - fsp->fl.f.left_x3 = -0.27580275066; /* XMIDL */ - fsp->fl.f.left_x4 = -0.27580275066; /* XMIDL */ - - fsp->fl.f.right_x1 = 0.96729063460; /* X2MAX1 */ - fsp->fl.f.right_x2 = -0.22419724936; /* X3MIN1 */ - fsp->fl.f.right_x3 = 0.61508950585; /* XMIDR */ - fsp->fl.f.right_x4 = 0.61508950585; /* XMIDR */ - - } - else /* use new code */ - { - if (param[0] != 2) - param[0] = 1; - fsp->repeat_mapping = (int)param[0] == 2; - if (param[1] != 0) - param[1] = 1; - fsp->altcolor = (int)param[1]; - fsp->fl.f.a = param[2]; - - fsp->attractors = fabs(fsp->fl.f.a) <= FROTH_CRITICAL_A ? (!fsp->repeat_mapping ? 3 : 6) - : (!fsp->repeat_mapping ? 2 : 3); - - /* new improved values */ - /* 0.5 is the value that causes the mapping to reach a minimum */ - x0 = 0.5; - /* a/2 is the value that causes the y value to be invariant over the mappings */ - y0 = fsp->fl.f.halfa = fsp->fl.f.a/2; - fsp->fl.f.top_x1 = froth_top_x_mapping(x0); - fsp->fl.f.top_x2 = froth_top_x_mapping(fsp->fl.f.top_x1); - fsp->fl.f.top_x3 = froth_top_x_mapping(fsp->fl.f.top_x2); - fsp->fl.f.top_x4 = froth_top_x_mapping(fsp->fl.f.top_x3); - - /* rotate 120 degrees counter-clock-wise */ - fsp->fl.f.left_x1 = fsp->fl.f.top_x1 * cos_theta - y0 * sin_theta; - fsp->fl.f.left_x2 = fsp->fl.f.top_x2 * cos_theta - y0 * sin_theta; - fsp->fl.f.left_x3 = fsp->fl.f.top_x3 * cos_theta - y0 * sin_theta; - fsp->fl.f.left_x4 = fsp->fl.f.top_x4 * cos_theta - y0 * sin_theta; - - /* rotate 120 degrees clock-wise */ - fsp->fl.f.right_x1 = fsp->fl.f.top_x1 * cos_theta + y0 * sin_theta; - fsp->fl.f.right_x2 = fsp->fl.f.top_x2 * cos_theta + y0 * sin_theta; - fsp->fl.f.right_x3 = fsp->fl.f.top_x3 * cos_theta + y0 * sin_theta; - fsp->fl.f.right_x4 = fsp->fl.f.top_x4 * cos_theta + y0 * sin_theta; - - } - - /* if 2 attractors, use same shades as 3 attractors */ - fsp->shades = (colors-1) / max(3,fsp->attractors); - - /* rqlim needs to be at least sq(1+sqrt(1+sq(a))), */ - /* which is never bigger than 6.93..., so we'll call it 7.0 */ - if (rqlim < 7.0) - rqlim=7.0; - set_Froth_palette(); - /* make the best of the .map situation */ - orbit_color = fsp->attractors != 6 && colors >= 16 ? (fsp->shades<<1)+1 : colors-1; - - if (integerfractal) - { - struct froth_long_struct tmp_l; - - tmp_l.a = FROTH_D_TO_L(fsp->fl.f.a); - tmp_l.halfa = FROTH_D_TO_L(fsp->fl.f.halfa); - - tmp_l.top_x1 = FROTH_D_TO_L(fsp->fl.f.top_x1); - tmp_l.top_x2 = FROTH_D_TO_L(fsp->fl.f.top_x2); - tmp_l.top_x3 = FROTH_D_TO_L(fsp->fl.f.top_x3); - tmp_l.top_x4 = FROTH_D_TO_L(fsp->fl.f.top_x4); - - tmp_l.left_x1 = FROTH_D_TO_L(fsp->fl.f.left_x1); - tmp_l.left_x2 = FROTH_D_TO_L(fsp->fl.f.left_x2); - tmp_l.left_x3 = FROTH_D_TO_L(fsp->fl.f.left_x3); - tmp_l.left_x4 = FROTH_D_TO_L(fsp->fl.f.left_x4); - - tmp_l.right_x1 = FROTH_D_TO_L(fsp->fl.f.right_x1); - tmp_l.right_x2 = FROTH_D_TO_L(fsp->fl.f.right_x2); - tmp_l.right_x3 = FROTH_D_TO_L(fsp->fl.f.right_x3); - tmp_l.right_x4 = FROTH_D_TO_L(fsp->fl.f.right_x4); - - fsp->fl.l = tmp_l; - } - return 1; - } - -void froth_cleanup(void) - { - if (fsp != NULL) - free(fsp); - /* set to NULL as a flag that froth_cleanup() has been called */ - fsp = NULL; - } - - -/* Froth Fractal type */ -int calcfroth(void) /* per pixel 1/2/g, called with row & col set */ - { - int found_attractor=0; - - if (check_key()) { - return -1; - } - - if (fsp == NULL) - { /* error occured allocating memory for fsp */ - return 0; - } - - orbit_ptr = 0; - coloriter = 0; - if (showdot>0) - (*plot) (col, row, showdot%colors); - if (!integerfractal) /* fp mode */ - { - if (invert) - { - invertz2(&tmp); - old = tmp; - } - else - { - old.x = dxpixel(); - old.y = dypixel(); - } - - while (!found_attractor - && ((tempsqrx=sqr(old.x)) + (tempsqry=sqr(old.y)) < rqlim) - && (coloriter < maxit)) - { - /* simple formula: z = z^2 + conj(z*(-1+ai)) */ - /* but it's the attractor that makes this so interesting */ - g_new.x = tempsqrx - tempsqry - old.x - fsp->fl.f.a*old.y; - old.y += (old.x+old.x)*old.y - fsp->fl.f.a*old.x; - old.x = g_new.x; - if (fsp->repeat_mapping) - { - g_new.x = sqr(old.x) - sqr(old.y) - old.x - fsp->fl.f.a*old.y; - old.y += (old.x+old.x)*old.y - fsp->fl.f.a*old.x; - old.x = g_new.x; - } - - coloriter++; - - if (show_orbit) { - if (driver_key_pressed()) - break; - plot_orbit(old.x, old.y, -1); - } - - if (fabs(fsp->fl.f.halfa-old.y) < FROTH_CLOSE - && old.x >= fsp->fl.f.top_x1 && old.x <= fsp->fl.f.top_x2) - { - if ((!fsp->repeat_mapping && fsp->attractors == 2) - || (fsp->repeat_mapping && fsp->attractors == 3)) - found_attractor = 1; - else if (old.x <= fsp->fl.f.top_x3) - found_attractor = 1; - else if (old.x >= fsp->fl.f.top_x4) { - if (!fsp->repeat_mapping) - found_attractor = 1; - else - found_attractor = 2; - } - } - else if (fabs(FROTH_SLOPE*old.x - fsp->fl.f.a - old.y) < FROTH_CLOSE - && old.x <= fsp->fl.f.right_x1 && old.x >= fsp->fl.f.right_x2) - { - if (!fsp->repeat_mapping && fsp->attractors == 2) - found_attractor = 2; - else if (fsp->repeat_mapping && fsp->attractors == 3) - found_attractor = 3; - else if (old.x >= fsp->fl.f.right_x3) { - if (!fsp->repeat_mapping) - found_attractor = 2; - else - found_attractor = 4; - } - else if (old.x <= fsp->fl.f.right_x4) { - if (!fsp->repeat_mapping) - found_attractor = 3; - else - found_attractor = 6; - } - } - else if (fabs(-FROTH_SLOPE*old.x - fsp->fl.f.a - old.y) < FROTH_CLOSE - && old.x <= fsp->fl.f.left_x1 && old.x >= fsp->fl.f.left_x2) - { - if (!fsp->repeat_mapping && fsp->attractors == 2) - found_attractor = 2; - else if (fsp->repeat_mapping && fsp->attractors == 3) - found_attractor = 2; - else if (old.x >= fsp->fl.f.left_x3) { - if (!fsp->repeat_mapping) - found_attractor = 3; - else - found_attractor = 5; - } - else if (old.x <= fsp->fl.f.left_x4) { - if (!fsp->repeat_mapping) - found_attractor = 2; - else - found_attractor = 3; - } - } - } - } - else /* integer mode */ - { - if (invert) - { - invertz2(&tmp); - lold.x = (long)(tmp.x * fudge); - lold.y = (long)(tmp.y * fudge); - } - else - { - lold.x = lxpixel(); - lold.y = lypixel(); - } - - while (!found_attractor && ((lmagnitud = (ltempsqrx=lsqr(lold.x)) + (ltempsqry=lsqr(lold.y))) < llimit) - && (lmagnitud >= 0) && (coloriter < maxit)) - { - /* simple formula: z = z^2 + conj(z*(-1+ai)) */ - /* but it's the attractor that makes this so interesting */ - lnew.x = ltempsqrx - ltempsqry - lold.x - multiply(fsp->fl.l.a,lold.y,bitshift); - lold.y += (multiply(lold.x,lold.y,bitshift)<<1) - multiply(fsp->fl.l.a,lold.x,bitshift); - lold.x = lnew.x; - if (fsp->repeat_mapping) - { - lmagnitud = (ltempsqrx=lsqr(lold.x)) + (ltempsqry=lsqr(lold.y)); - if ((lmagnitud > llimit) || (lmagnitud < 0)) - break; - lnew.x = ltempsqrx - ltempsqry - lold.x - multiply(fsp->fl.l.a,lold.y,bitshift); - lold.y += (multiply(lold.x,lold.y,bitshift)<<1) - multiply(fsp->fl.l.a,lold.x,bitshift); - lold.x = lnew.x; - } - coloriter++; - - if (show_orbit) { - if (driver_key_pressed()) - break; - iplot_orbit(lold.x, lold.y, -1); - } - - if (labs(fsp->fl.l.halfa-lold.y) < FROTH_LCLOSE - && lold.x > fsp->fl.l.top_x1 && lold.x < fsp->fl.l.top_x2) - { - if ((!fsp->repeat_mapping && fsp->attractors == 2) - || (fsp->repeat_mapping && fsp->attractors == 3)) - found_attractor = 1; - else if (lold.x <= fsp->fl.l.top_x3) - found_attractor = 1; - else if (lold.x >= fsp->fl.l.top_x4) { - if (!fsp->repeat_mapping) - found_attractor = 1; - else - found_attractor = 2; - } - } - else if (labs(multiply(FROTH_LSLOPE,lold.x,bitshift)-fsp->fl.l.a-lold.y) < FROTH_LCLOSE - && lold.x <= fsp->fl.l.right_x1 && lold.x >= fsp->fl.l.right_x2) - { - if (!fsp->repeat_mapping && fsp->attractors == 2) - found_attractor = 2; - else if (fsp->repeat_mapping && fsp->attractors == 3) - found_attractor = 3; - else if (lold.x >= fsp->fl.l.right_x3) { - if (!fsp->repeat_mapping) - found_attractor = 2; - else - found_attractor = 4; - } - else if (lold.x <= fsp->fl.l.right_x4) { - if (!fsp->repeat_mapping) - found_attractor = 3; - else - found_attractor = 6; - } - } - else if (labs(multiply(-FROTH_LSLOPE,lold.x,bitshift)-fsp->fl.l.a-lold.y) < FROTH_LCLOSE) - { - if (!fsp->repeat_mapping && fsp->attractors == 2) - found_attractor = 2; - else if (fsp->repeat_mapping && fsp->attractors == 3) - found_attractor = 2; - else if (lold.x >= fsp->fl.l.left_x3) { - if (!fsp->repeat_mapping) - found_attractor = 3; - else - found_attractor = 5; - } - else if (lold.x <= fsp->fl.l.left_x4) { - if (!fsp->repeat_mapping) - found_attractor = 2; - else - found_attractor = 3; - } - } - } - } - if (show_orbit) - scrub_orbit(); - - realcoloriter = coloriter; - if ((kbdcount -= abs((int)realcoloriter)) <= 0) - { - if (check_key()) - return (-1); - kbdcount = max_kbdcount; - } - -/* inside - Here's where non-palette based images would be nice. Instead, */ -/* we'll use blocks of (colors-1)/3 or (colors-1)/6 and use special froth */ -/* color maps in attempt to replicate the images of James Alexander. */ - if (found_attractor) - { - if (colors >= 256) - { - if (!fsp->altcolor) - { - if (coloriter > fsp->shades) - coloriter = fsp->shades; - } - else - coloriter = fsp->shades * coloriter / maxit; - if (coloriter == 0) - coloriter = 1; - coloriter += fsp->shades * (found_attractor-1); - } - else if (colors >= 16) - { /* only alternate coloring scheme available for 16 colors */ - long lshade; - -/* Trying to make a better 16 color distribution. */ -/* Since their are only a few possiblities, just handle each case. */ -/* This is a mostly guess work here. */ - lshade = (coloriter<<16)/maxit; - if (fsp->attractors != 6) /* either 2 or 3 attractors */ - { - if (lshade < 2622) /* 0.04 */ - coloriter = 1; - else if (lshade < 10486) /* 0.16 */ - coloriter = 2; - else if (lshade < 23593) /* 0.36 */ - coloriter = 3; - else if (lshade < 41943L) /* 0.64 */ - coloriter = 4; - else - coloriter = 5; - coloriter += 5 * (found_attractor-1); - } - else /* 6 attractors */ - { - if (lshade < 10486) /* 0.16 */ - coloriter = 1; - else - coloriter = 2; - coloriter += 2 * (found_attractor-1); - } - } - else /* use a color corresponding to the attractor */ - coloriter = found_attractor; - oldcoloriter = coloriter; - } - else /* outside, or inside but didn't get sucked in by attractor. */ - coloriter = 0; - - color = abs((int)(coloriter)); - - (*plot)(col, row, color); - - return color; - } - -/* -These last two froth functions are for the orbit-in-window feature. -Normally, this feature requires StandardFractal, but since it is the -attractor that makes the frothybasin type so unique, it is worth -putting in as a stand-alone. -*/ - -int froth_per_pixel(void) - { - if (!integerfractal) /* fp mode */ - { - old.x = dxpixel(); - old.y = dypixel(); - tempsqrx=sqr(old.x); - tempsqry=sqr(old.y); - } - else /* integer mode */ - { - lold.x = lxpixel(); - lold.y = lypixel(); - ltempsqrx = multiply(lold.x, lold.x, bitshift); - ltempsqry = multiply(lold.y, lold.y, bitshift); - } - return 0; - } - -int froth_per_orbit(void) - { - if (!integerfractal) /* fp mode */ - { - g_new.x = tempsqrx - tempsqry - old.x - fsp->fl.f.a*old.y; - g_new.y = 2.0*old.x*old.y - fsp->fl.f.a*old.x + old.y; - if (fsp->repeat_mapping) - { - old = g_new; - g_new.x = sqr(old.x) - sqr(old.y) - old.x - fsp->fl.f.a*old.y; - g_new.y = 2.0*old.x*old.y - fsp->fl.f.a*old.x + old.y; - } - - if ((tempsqrx=sqr(g_new.x)) + (tempsqry=sqr(g_new.y)) >= rqlim) - return 1; - old = g_new; - } - else /* integer mode */ - { - lnew.x = ltempsqrx - ltempsqry - lold.x - multiply(fsp->fl.l.a,lold.y,bitshift); - lnew.y = lold.y + (multiply(lold.x,lold.y,bitshift)<<1) - multiply(fsp->fl.l.a,lold.x,bitshift); - if (fsp->repeat_mapping) - { - if ((ltempsqrx=lsqr(lnew.x)) + (ltempsqry=lsqr(lnew.y)) >= llimit) - return 1; - lold = lnew; - lnew.x = ltempsqrx - ltempsqry - lold.x - multiply(fsp->fl.l.a,lold.y,bitshift); - lnew.y = lold.y + (multiply(lold.x,lold.y,bitshift)<<1) - multiply(fsp->fl.l.a,lold.x,bitshift); - } - if ((ltempsqrx=lsqr(lnew.x)) + (ltempsqry=lsqr(lnew.y)) >= llimit) - return 1; - lold = lnew; - } - return 0; - } - diff --git a/fractint/common/miscovl.c b/fractint/common/miscovl.c deleted file mode 100644 index 60039c3ae..000000000 --- a/fractint/common/miscovl.c +++ /dev/null @@ -1,2443 +0,0 @@ -/* - Overlayed odds and ends that don't fit anywhere else. -*/ - -#include -#include -#include - -#ifndef XFRACT -#if !defined(_WIN32) -#include -#endif -#include -#include -#endif - -#ifndef USE_VARARGS -#include -#else -#include -#endif - - /* see Fractint.c for a description of the "include" hierarchy */ -#include "port.h" -#include "prototyp.h" -#include "fractype.h" -#include "helpdefs.h" -#include "drivers.h" - -/* routines in this module */ - -void write_batch_parms(char *colorinf,int colorsonly, int maxcolor,int i, int j); -void expand_comments(char *target, char *source); - -#ifndef USE_VARARGS -static void put_parm(char *parm,...); -#else -static void put_parm(); -#endif - -static void put_parm_line(void); -static int getprec(double,double,double); -int getprecbf(int); -static void put_float(int,double,int); -static void put_bf(int slash,bf_t r, int prec); -static void put_filename(char *keyword,char *fname); -#ifndef XFRACT -static int check_modekey(int curkey,int choice); -#endif -static int entcompare(VOIDCONSTPTR p1,VOIDCONSTPTR p2); -static void update_fractint_cfg(void); -static void strip_zeros(char *buf); - -char par_comment[4][MAXCMT]; - -/* JIIM */ - -FILE *parmfile; - -#define PAR_KEY(x) ( x < 10 ? '0' + x : 'a' - 10 + x) - -#ifdef _MSC_VER -#pragma optimize("e",off) /* MSC 6.00A messes up next rtn with "e" on */ -#endif - -void make_batch_file() -{ -#define MAXPROMPTS 18 - int colorsonly = 0; - /** added for pieces feature **/ - double pdelx = 0.0; - double pdely = 0.0; - double pdelx2 = 0.0; - double pdely2 = 0.0; - unsigned int pxdots, pydots, xm, ym; - double pxxmin = 0.0, pyymax = 0.0; - char vidmde[5]; - int promptnum; - int piecespromts; - int have3rd = 0; - /****/ - - int i,j; - char inpcommandfile[80], inpcommandname[ITEMNAMELEN+1]; - char inpcomment[4][MAXCMT]; - struct fullscreenvalues paramvalues[18]; - char *choices[MAXPROMPTS]; - int gotinfile; - char outname[FILE_MAX_PATH+1], buf[256], buf2[128]; - FILE *infile = NULL; - FILE *fpbat = NULL; - char colorspec[14]; - int maxcolor; - int maxcolorindex = 0; - char *sptr = NULL, *sptr2; - int oldhelpmode; - - if (s_makepar[1] == 0) /* makepar map case */ - colorsonly = 1; - - driver_stack_screen(); - oldhelpmode = helpmode; - helpmode = HELPPARMFILE; - - maxcolor = colors; - strcpy(colorspec,"y"); -#ifndef XFRACT - if ((g_got_real_dac && !g_really_ega) || (g_is_true_color && !truemode)) -#else - if ((g_got_real_dac && !g_really_ega) || (g_is_true_color && !truemode) || fake_lut) -#endif - { - --maxcolor; -/* if (maxit < maxcolor) remove 2 lines */ -/* maxcolor = maxit; so that whole palette is always saved */ - if (inside > 0 && inside > maxcolor) - maxcolor = inside; - if (outside > 0 && outside > maxcolor) - maxcolor = outside; - if (distest < 0 && 0 - distest > maxcolor) - maxcolor = (int)(0 - distest); - if (decomp[0] > maxcolor) - maxcolor = decomp[0] - 1; - if (potflag && potparam[0] >= maxcolor) - maxcolor = (int)potparam[0]; - if (++maxcolor > 256) - maxcolor = 256; - if (colorstate == 0) - { /* default colors */ - if (mapdacbox) - { - colorspec[0] = '@'; - sptr = MAP_name; - } - } - else if (colorstate == 2) - { /* colors match colorfile */ - colorspec[0] = '@'; - sptr = colorfile; - } - else /* colors match no .map that we know of */ - strcpy (colorspec,"y"); - - if (colorspec[0] == '@') - { - if ((sptr2 = strrchr(sptr, SLASHC)) != NULL) - sptr = sptr2 + 1; - if ((sptr2 = strrchr(sptr, ':')) != NULL) - sptr = sptr2 + 1; - strncpy(&colorspec[1], sptr, 12); - colorspec[13] = 0; - } - } - strcpy(inpcommandfile, CommandFile); - strcpy(inpcommandname, CommandName); - for (i=0; i<4; i++) - { - expand_comments(CommandComment[i], par_comment[i]); - strcpy(inpcomment[i], CommandComment[i]); - } - - if (CommandName[0] == 0) - strcpy(inpcommandname, "test"); - /* TW added these - and Bert moved them */ - pxdots = xdots; - pydots = ydots; - xm = ym = 1; - if (*s_makepar == 0) - goto skip_UI; - - vidmode_keyname(g_video_entry.keynum, vidmde); - while (1) - { -prompt_user: - promptnum = 0; - choices[promptnum] = "Parameter file"; - paramvalues[promptnum].type = 0x100 + MAXCMT - 1; - paramvalues[promptnum++].uval.sbuf = inpcommandfile; - choices[promptnum] = "Name"; - paramvalues[promptnum].type = 0x100 + ITEMNAMELEN; - paramvalues[promptnum++].uval.sbuf = inpcommandname; - choices[promptnum] = "Main comment"; - paramvalues[promptnum].type = 0x100 + MAXCMT - 1; - paramvalues[promptnum++].uval.sbuf = inpcomment[0]; - choices[promptnum] = "Second comment"; - paramvalues[promptnum].type = 0x100 + MAXCMT - 1; - paramvalues[promptnum++].uval.sbuf = inpcomment[1]; - choices[promptnum] = "Third comment"; - paramvalues[promptnum].type = 0x100 + MAXCMT - 1; - paramvalues[promptnum++].uval.sbuf = inpcomment[2]; - choices[promptnum] = "Fourth comment"; - paramvalues[promptnum].type = 0x100 + MAXCMT - 1; - paramvalues[promptnum++].uval.sbuf = inpcomment[3]; -#ifndef XFRACT - if ((g_got_real_dac && !g_really_ega) || (g_is_true_color && !truemode)) -#else - if ((g_got_real_dac && !g_really_ega) || (g_is_true_color && !truemode) || fake_lut) -#endif - { - choices[promptnum] = "Record colors?"; - paramvalues[promptnum].type = 0x100 + 13; - paramvalues[promptnum++].uval.sbuf = colorspec; - choices[promptnum] = " (no | yes | only for full info | @filename to point to a map file)"; - paramvalues[promptnum++].type = '*'; - choices[promptnum] = "# of colors"; - maxcolorindex = promptnum; - paramvalues[promptnum].type = 'i'; - paramvalues[promptnum++].uval.ival = maxcolor; - choices[promptnum] = " (if recording full color info)"; - paramvalues[promptnum++].type = '*'; - } - choices[promptnum] = "Maximum line length"; - paramvalues[promptnum].type = 'i'; - paramvalues[promptnum++].uval.ival = maxlinelength; - choices[promptnum] = ""; - paramvalues[promptnum++].type = '*'; - choices[promptnum] = " **** The following is for generating images in pieces ****"; - paramvalues[promptnum++].type = '*'; - choices[promptnum] = "X Multiples"; - piecespromts = promptnum; - paramvalues[promptnum].type = 'i'; - paramvalues[promptnum++].uval.ival = xm; - choices[promptnum] = "Y Multiples"; - paramvalues[promptnum].type = 'i'; - paramvalues[promptnum++].uval.ival = ym; -#ifndef XFRACT - choices[promptnum] = "Video mode"; - paramvalues[promptnum].type = 0x100 + 4; - paramvalues[promptnum++].uval.sbuf = vidmde; -#endif - - if (fullscreen_prompt("Save Current Parameters",promptnum, choices, paramvalues, 0, NULL) < 0) - break; - - if (*colorspec == 'o' || s_makepar[1] == 0) - { - strcpy(colorspec,"y"); - colorsonly = 1; - } - - strcpy(CommandFile, inpcommandfile); - if (has_ext(CommandFile) == NULL) - strcat(CommandFile, ".par"); /* default extension .par */ - strcpy(CommandName, inpcommandname); - for (i=0; i<4; i++) - strncpy(CommandComment[i], inpcomment[i], MAXCMT); -#ifndef XFRACT - if ((g_got_real_dac && !g_really_ega) || (g_is_true_color && !truemode)) -#else - if ((g_got_real_dac && !g_really_ega) || (g_is_true_color && !truemode) || fake_lut) -#endif - if (paramvalues[maxcolorindex].uval.ival > 0 && - paramvalues[maxcolorindex].uval.ival <= 256) - maxcolor = paramvalues[maxcolorindex].uval.ival; - promptnum = piecespromts; - { - int newmaxlinelength; - newmaxlinelength = paramvalues[promptnum-3].uval.ival; - if (maxlinelength != newmaxlinelength && - newmaxlinelength >= MINMAXLINELENGTH && - newmaxlinelength <= MAXMAXLINELENGTH) - maxlinelength = newmaxlinelength; - } - xm = paramvalues[promptnum++].uval.ival; - - ym = paramvalues[promptnum++].uval.ival; - - /* sanity checks */ - { - long xtotal, ytotal; -#ifndef XFRACT - int i; - - /* get resolution from the video name (which must be valid) */ - pxdots = pydots = 0; - if ((i = check_vidmode_keyname(vidmde)) > 0) - if ((i = check_vidmode_key(0, i)) >= 0) { - /* get the resolution of this video mode */ - pxdots = g_video_table[i].xdots; - pydots = g_video_table[i].ydots; - } - if (pxdots == 0 && (xm > 1 || ym > 1)) { - /* no corresponding video mode! */ - stopmsg(0, "Invalid video mode entry!"); - goto prompt_user; - } -#endif - - /* bounds range on xm, ym */ - if (xm < 1 || xm > 36 || ym < 1 || ym > 36) { - stopmsg(0, "X and Y components must be 1 to 36"); - goto prompt_user; - } - - /* another sanity check: total resolution cannot exceed 65535 */ - xtotal = xm; ytotal = ym; - xtotal *= pxdots; ytotal *= pydots; - if (xtotal > 65535L || ytotal > 65535L) { - stopmsg(0, "Total resolution (X or Y) cannot exceed 65535"); - goto prompt_user; - } - } -skip_UI: - if (*s_makepar == 0) - { - if (filecolors > 0) - strcpy(colorspec, "y"); - else - strcpy(colorspec, "n"); - if (s_makepar[1] == 0) - maxcolor = 256; - else - maxcolor = filecolors; - } - strcpy(outname, CommandFile); - gotinfile = 0; - if (access(CommandFile, 0) == 0) - { /* file exists */ - gotinfile = 1; - if (access(CommandFile, 6)) - { - sprintf(buf, "Can't write %s", CommandFile); - stopmsg(0, buf); - continue; - } - i = (int) strlen(outname); - while (--i >= 0 && outname[i] != SLASHC) - outname[i] = 0; - strcat(outname, "fractint.tmp"); - infile = fopen(CommandFile, "rt"); -#ifndef XFRACT - setvbuf(infile, tstack, _IOFBF, 4096); /* improves speed */ -#endif - } - parmfile = fopen(outname, "wt"); - if (parmfile == NULL) - { - sprintf(buf, "Can't create %s", outname); - stopmsg(0, buf); - if (gotinfile) - fclose(infile); - continue; - } - - if (gotinfile) - { - while (file_gets(buf, 255, infile) >= 0) - { - if (strchr(buf, '{')/* entry heading? */ - && sscanf(buf, " %40[^ \t({]", buf2) - && stricmp(buf2, CommandName) == 0) - { /* entry with same name */ - _snprintf(buf2, NUM_OF(buf2), "File already has an entry named %s\n%s", - CommandName, (*s_makepar == 0) ? - "... Replacing ..." : "Continue to replace it, Cancel to back out"); - if (stopmsg(STOPMSG_CANCEL | STOPMSG_INFO_ONLY, buf2) < 0) - { /* cancel */ - fclose(infile); - fclose(parmfile); - unlink(outname); - goto prompt_user; - } - while (strchr(buf, '}') == NULL - && file_gets(buf, 255, infile) > 0) - ; /* skip to end of set */ - break; - } - fputs(buf, parmfile); - fputc('\n', parmfile); - } - } -/***** start here*/ - if (xm > 1 || ym > 1) - { - if (xxmin != xx3rd || yymin != yy3rd) - have3rd = 1; - else - have3rd = 0; - fpbat = dir_fopen(workdir,"makemig.bat", "w"); - if (fpbat == NULL) - xm = ym = 0; - pdelx = (xxmax - xx3rd) / (xm * pxdots - 1); /* calculate stepsizes */ - pdely = (yymax - yy3rd) / (ym * pydots - 1); - pdelx2 = (xx3rd - xxmin) / (ym * pydots - 1); - pdely2 = (yy3rd - yymin) / (xm * pxdots - 1); - - /* save corners */ - pxxmin = xxmin; - pyymax = yymax; - } - for (i = 0; i < (int)xm; i++) /* columns */ - for (j = 0; j < (int)ym; j++) /* rows */ - { - if (xm > 1 || ym > 1) - { - int w; - char c; - char PCommandName[80]; - w=0; - while (w < (int)strlen(CommandName)) - { - c = CommandName[w]; - if (isspace(c) || c == 0) - break; - PCommandName[w] = c; - w++; - } - PCommandName[w] = 0; - { - char buf[20]; - sprintf(buf,"_%c%c",PAR_KEY(i),PAR_KEY(j)); - strcat(PCommandName,buf); - } - fprintf(parmfile, "%-19s{",PCommandName); - xxmin = pxxmin + pdelx*(i*pxdots) + pdelx2*(j*pydots); - xxmax = pxxmin + pdelx*((i+1)*pxdots - 1) + pdelx2*((j+1)*pydots - 1); - yymin = pyymax - pdely*((j+1)*pydots - 1) - pdely2*((i+1)*pxdots - 1); - yymax = pyymax - pdely*(j*pydots) - pdely2*(i*pxdots); - if (have3rd) - { - xx3rd = pxxmin + pdelx*(i*pxdots) + pdelx2*((j+1)*pydots - 1); - yy3rd = pyymax - pdely*((j+1)*pydots - 1) - pdely2*(i*pxdots); - } - else - { - xx3rd = xxmin; - yy3rd = yymin; - } - fprintf(fpbat,"Fractint batch=yes overwrite=yes @%s/%s\n",CommandFile,PCommandName); - fprintf(fpbat,"If Errorlevel 2 goto oops\n"); - } - else - fprintf(parmfile, "%-19s{", CommandName); - { - /* guarantee that there are no blank comments above the last - non-blank par_comment */ - int i, last; - for (last=-1,i=0; i<4; i++) - if (*par_comment[i]) - last=i; - for (i=0; i 1 || ym > 1) - { - fprintf(parmfile," video=%s", vidmde); - fprintf(parmfile," savename=frmig_%c%c\n", PAR_KEY(i), PAR_KEY(j)); - } - fprintf(parmfile, " }\n\n"); - } - if (xm > 1 || ym > 1) - { - fprintf(fpbat,"Fractint makemig=%d/%d\n",xm,ym); - fprintf(fpbat,"Rem Simplgif fractmig.gif simplgif.gif in case you need it\n"); - fprintf(fpbat,":oops\n"); - fclose(fpbat); - } -/*******end here */ - - if (gotinfile) - { /* copy the rest of the file */ - do - { - i = file_gets(buf, 255, infile); - } while (i == 0); /* skip blanks */ - while (i >= 0) - { - fputs(buf, parmfile); - fputc('\n', parmfile); - i = file_gets(buf, 255, infile); - } - fclose(infile); - } - fclose(parmfile); - if (gotinfile) - { /* replace the original file with the new */ - unlink(CommandFile); /* success assumed on these lines */ - rename(outname, CommandFile); /* since we checked earlier with - * access */ - } - break; - } - helpmode = oldhelpmode; - driver_unstack_screen(); -} - -#ifdef C6 -#pragma optimize("e",on) /* back to normal */ -#endif - -static struct write_batch_data /* buffer for parms to break lines nicely */ -{ - int len; - char buf[10000]; -} s_wbdata; - -void write_batch_parms(char *colorinf, int colorsonly, int maxcolor, int ii, int jj) -{ - int i,j,k; - double Xctr, Yctr; - LDBL Magnification; - double Xmagfactor, Rotation, Skew; - char *sptr; - char buf[81]; - bf_t bfXctr=NULL, bfYctr=NULL; - int saved; - saved = save_stack(); - if (bf_math) - { - bfXctr = alloc_stack(bflength+2); - bfYctr = alloc_stack(bflength+2); - } - - s_wbdata.len = 0; /* force first parm to start on new line */ - - /* Using near string boxx for buffer after saving to extraseg */ - - if (colorsonly) - goto docolors; - if (display3d <= 0) { /* a fractal was generated */ - - /****** fractal only parameters in this section *******/ - put_parm(" reset"); - if (check_back()) - put_parm("=%d",min(save_release,g_release)); - else - put_parm("=%d",g_release); - - sptr = curfractalspecific->name; - if (*sptr == '*') ++sptr; - put_parm( " %s=%s", "type",sptr); - - if (fractype == JULIBROT || fractype == JULIBROTFP) - { - put_parm(" %s=%.15g/%.15g/%.15g/%.15g", - "julibrotfromto", mxmaxfp,mxminfp,mymaxfp,myminfp); - /* these rarely change */ - if (originfp != 8 || heightfp != 7 || widthfp != 10 || distfp != 24 - || depthfp != 8 || zdots != 128) - put_parm(" %s=%d/%g/%g/%g/%g/%g", "julibrot3d", - zdots, originfp, depthfp, heightfp, widthfp,distfp); - if (eyesfp != 0) - put_parm(" %s=%g", "julibroteyes",eyesfp); - if (neworbittype != JULIA) - { - char *name; - name = fractalspecific[neworbittype].name; - if (*name=='*') - name++; - put_parm(" %s=%s", "orbitname",name); - } - if (juli3Dmode != 0) - put_parm(" %s=%s", "3dmode",juli3Doptions[juli3Dmode]); - } - if (fractype == FORMULA || fractype == FFORMULA) - { - put_filename("formulafile",FormFileName); - put_parm( " %s=%s", "formulaname",FormName); - if (uses_ismand) - put_parm(" %s=%c", "ismand",ismand?'y':'n'); - } - if (fractype == LSYSTEM) - { - put_filename("lfile",LFileName); - put_parm( " %s=%s", "lname",LName); - } - if (fractype == IFS || fractype == IFS3D) - { - put_filename("ifsfile",IFSFileName); - put_parm( " %s=%s", "ifs",IFSName); - } - if (fractype == INVERSEJULIA || fractype == INVERSEJULIAFP) - put_parm( " %s=%s/%s", "miim",JIIMmethod[major_method], JIIMleftright[minor_method]); - - showtrig(buf); /* this function is in miscres.c */ - if (buf[0]) - put_parm(buf); - - if (usr_stdcalcmode != 'g') - put_parm(" %s=%c", "passes",usr_stdcalcmode); - - - if (stoppass != 0) - put_parm(" %s=%c%c", "passes",usr_stdcalcmode,(char)stoppass + '0'); - - if (usemag) - { - if (bf_math) - { - int digits; - cvtcentermagbf(bfXctr, bfYctr, &Magnification, &Xmagfactor, &Rotation, &Skew); - digits = getprecbf(MAXREZ); - put_parm(" %s=", "center-mag"); - put_bf(0,bfXctr,digits); - put_bf(1,bfYctr,digits); - } - else /* !bf_math */ - { - cvtcentermag(&Xctr, &Yctr, &Magnification, &Xmagfactor, &Rotation, &Skew); - put_parm(" %s=", "center-mag"); -/* convert 1000 fudged long to double, 1000/1<<24 = 6e-5 */ - put_parm(ddelmin > 6e-5 ? "%g/%g" : "%+20.17lf/%+20.17lf", Xctr, Yctr); - } -#ifdef USE_LONG_DOUBLE - put_parm("/%.7Lg",Magnification); /* precision of magnification not critical, but magnitude is */ -#else - put_parm("/%.7lg",Magnification); /* precision of magnification not critical, but magnitude is */ -#endif - /* Round to avoid ugly decimals, precision here is not critical */ - /* Don't round Xmagfactor if it's small */ - if (fabs(Xmagfactor) > 0.5) /* or so, exact value isn't important */ - Xmagfactor = (sign(Xmagfactor) * (long)(fabs(Xmagfactor) * 1e4 + 0.5)) / 1e4; - /* Just truncate these angles. Who cares about 1/1000 of a degree */ - /* Somebody does. Some rotated and/or skewed images are slightly */ - /* off when recreated from a PAR using 1/1000. */ - /* JCO 08052001 */ -#if 0 - Rotation = (long)(Rotation * 1e3)/1e3; - Skew = (long)(Skew * 1e3)/1e3; -#endif - if (Xmagfactor != 1 || Rotation != 0 || Skew != 0) - { /* Only put what is necessary */ - /* The difference with Xmagfactor is that it is normally */ - /* near 1 while the others are normally near 0 */ - if (fabs(Xmagfactor) >= 1) - put_float(1,Xmagfactor,5); /* put_float() uses %g */ - else /* abs(Xmagfactor) is < 1 */ - put_float(1,Xmagfactor,4); /* put_float() uses %g */ - if (Rotation != 0 || Skew != 0) - { - /* Use precision=6 here. These angle have already been rounded */ - /* to 3 decimal places, but angles like 123.456 degrees need 6 */ - /* sig figs to get 3 decimal places. Trailing 0's are dropped anyway. */ - /* Changed to 18 to address rotated and skewed problem w/ PARs */ - /* JCO 08052001 */ - put_float(1,Rotation,18); - if (Skew != 0) - { - put_float(1,Skew,18); - } - } - } - } - else /* not usemag */ - { - put_parm( " %s=", "corners"); - if (bf_math) - { - int digits; - digits = getprecbf(MAXREZ); - put_bf(0,bfxmin,digits); - put_bf(1,bfxmax,digits); - put_bf(1,bfymin,digits); - put_bf(1,bfymax,digits); - if (cmp_bf(bfx3rd,bfxmin) || cmp_bf(bfy3rd,bfymin)) - { - put_bf(1,bfx3rd,digits); - put_bf(1,bfy3rd,digits); - } - } - else - { - int xdigits,ydigits; - xdigits = getprec(xxmin,xxmax,xx3rd); - ydigits = getprec(yymin,yymax,yy3rd); - put_float(0,xxmin,xdigits); - put_float(1,xxmax,xdigits); - put_float(1,yymin,ydigits); - put_float(1,yymax,ydigits); - if (xx3rd != xxmin || yy3rd != yymin) - { - put_float(1,xx3rd,xdigits); - put_float(1,yy3rd,ydigits); - } - } - } - - for (i = (MAXPARAMS-1); i >= 0; --i) - if (typehasparm((fractype==JULIBROT || fractype==JULIBROTFP) - ?neworbittype:fractype,i,NULL)) break; - - if (i >= 0) { - if (fractype == CELLULAR || fractype == ANT) - put_parm(" %s=%.1f", "params",param[0]); - else - { -#ifdef USE_LONG_DOUBLE - if (debugflag == 750) - put_parm(" %s=%.17Lg", "params",(long double)param[0]); - else -#endif - put_parm(" %s=%.17g", "params",param[0]); - } - for (j = 1; j <= i; ++j) - if (fractype == CELLULAR || fractype == ANT) - put_parm("/%.1f",param[j]); - else - { -#ifdef USE_LONG_DOUBLE - if (debugflag == 750) - put_parm("/%.17Lg",(long double)param[j]); - else -#endif - put_parm("/%.17g",param[j]); - } - } - - if (useinitorbit == 2) - put_parm( " %s=pixel", "initorbit"); - else if (useinitorbit == 1) - put_parm( " %s=%.15g/%.15g", "initorbit",initorbit.x,initorbit.y); - - if (floatflag) - put_parm( " %s=y", "float"); - - if (maxit != 150) - put_parm(" %s=%ld", "maxiter",maxit); - - if (bailout && (potflag == 0 || potparam[2] == 0.0)) - put_parm(" %s=%ld", "bailout",bailout); - - if (bailoutest != Mod) { - put_parm(" %s=", "bailoutest"); - if (bailoutest == Real) - put_parm("real"); - else if (bailoutest == Imag) - put_parm("imag"); - else if (bailoutest == Or) - put_parm("or"); - else if (bailoutest == And) - put_parm("and"); - else if (bailoutest == Manh) - put_parm("manh"); - else if (bailoutest == Manr) - put_parm("manr"); - else - put_parm("mod"); /* default, just in case */ - } - if (fillcolor != -1) { - put_parm(" %s=", "fillcolor"); - put_parm( "%d",fillcolor); - } - if (inside != 1) { - put_parm(" %s=", "inside"); - if (inside == -1) - put_parm("maxiter"); - else if (inside == ZMAG) - put_parm("zmag"); - else if (inside == BOF60) - put_parm("bof60"); - else if (inside == BOF61) - put_parm("bof61"); - else if (inside == EPSCROSS) - put_parm("epsiloncross"); - else if (inside == STARTRAIL) - put_parm("startrail"); - else if (inside == PERIOD) - put_parm("period"); - else if (inside == FMODI) - put_parm("fmod"); - else if (inside == ATANI) - put_parm("atan"); - else - put_parm( "%d",inside); - } - if (closeprox != 0.01 && (inside == EPSCROSS || inside == FMODI - || outside==FMOD) ) { - put_parm(" %s=%.15g", "proximity",closeprox); - } - if (outside != -1) - { - put_parm(" %s=", "outside"); - if (outside == REAL) - put_parm("real"); - else if (outside == IMAG) - put_parm("imag"); - else if (outside == MULT) - put_parm("mult"); - else if (outside == SUM) - put_parm("summ"); - else if (outside == ATAN) - put_parm("atan"); - else if (outside == FMOD) - put_parm("fmod"); - else if (outside == TDIS) - put_parm("tdis"); - else - put_parm( "%d",outside); - } - - if (LogFlag && !rangeslen) { - put_parm( " %s=", "logmap"); - if (LogFlag == -1) - put_parm( "old"); - else if (LogFlag == 1) - put_parm("yes"); - else - put_parm( "%ld", LogFlag); - } - - if (Log_Fly_Calc && LogFlag && !rangeslen) { - put_parm( " %s=", "logmode"); - if (Log_Fly_Calc == 1) - put_parm( "fly"); - else if (Log_Fly_Calc == 2) - put_parm( "table"); - } - - if (potflag) { - put_parm( " %s=%d/%g/%d", "potential", - (int)potparam[0],potparam[1],(int)potparam[2]); - if (pot16bit) - put_parm( "/%s", "16bit"); - } - if (invert) - put_parm( " %s=%-1.15lg/%-1.15lg/%-1.15lg", "invert", - inversion[0], inversion[1], inversion[2]); - if (decomp[0]) - put_parm( " %s=%d", "decomp", decomp[0]); - if (distest) { - put_parm( " %s=%ld/%d/%d/%d", "distest", distest, distestwidth, - pseudox?pseudox:xdots,pseudoy?pseudoy:ydots); - } - if (old_demm_colors) - put_parm( " %s=y", "olddemmcolors"); - if (usr_biomorph != -1) - put_parm( " %s=%d", "biomorph", usr_biomorph); - if (finattract) - put_parm(" %s=y", "finattract"); - - if (forcesymmetry != 999) { - if (forcesymmetry == 1000 && ii == 1 && jj == 1) - stopmsg(0, "Regenerate before to get correct symmetry"); - put_parm( " %s=", "symmetry"); - if (forcesymmetry==XAXIS) - put_parm("xaxis"); - else if (forcesymmetry==YAXIS) - put_parm("yaxis"); - else if (forcesymmetry==XYAXIS) - put_parm("xyaxis"); - else if (forcesymmetry==ORIGIN) - put_parm("origin"); - else if (forcesymmetry==PI_SYM) - put_parm("pi"); - else - put_parm("none"); - } - - if (periodicitycheck != 1) - put_parm( " %s=%d", "periodicity",periodicitycheck); - - if (rflag) - put_parm( " %s=%d", "rseed",rseed); - - if (rangeslen) { - put_parm(" %s=", "ranges"); - i = 0; - while (i < rangeslen) { - if (i) - put_parm("/"); - if (ranges[i] == -1) { - put_parm("-%d/",ranges[++i]); - ++i; - } - put_parm("%d",ranges[i++]); - } - } - } - - if (display3d >= 1) { - /***** 3d transform only parameters in this section *****/ - if (display3d == 2) - put_parm( " %s=%s", "3d", "overlay"); - else - put_parm( " %s=%s", "3d", "yes"); - if (loaded3d == 0) - put_filename("filename", readname); - if (SPHERE) { - put_parm( " %s=y", "sphere"); - put_parm( " %s=%d/%d", "latitude", THETA1, THETA2); - put_parm( " %s=%d/%d", "longitude", PHI1, PHI2); - put_parm( " %s=%d", "radius", RADIUS); - } - put_parm( " %s=%d/%d", "scalexyz", XSCALE, YSCALE); - put_parm( " %s=%d", "roughness", ROUGH); - put_parm( " %s=%d", "waterline", WATERLINE); - if (FILLTYPE) - put_parm( " %s=%d", "filltype", FILLTYPE); - if (transparent[0] || transparent[1]) - put_parm( " %s=%d/%d", "transparent", transparent[0],transparent[1]); - if (preview) { - put_parm( " %s=%s", "preview", "yes"); - if (showbox) - put_parm( " %s=%s", "showbox", "yes"); - put_parm( " %s=%d", "coarse",previewfactor); - } - if (RAY) { - put_parm( " %s=%d", "ray",RAY); - if (BRIEF) - put_parm(" %s=y", "brief"); - } - if (FILLTYPE > 4) { - put_parm( " %s=%d/%d/%d", "lightsource", XLIGHT, YLIGHT, ZLIGHT); - if (LIGHTAVG) - put_parm(" %s=%d", "smoothing", LIGHTAVG); - } - if (RANDOMIZE) - put_parm( " %s=%d", "randomize",RANDOMIZE); - if (Targa_Out) - put_parm( " %s=y", "fullcolor"); - if (grayflag) - put_parm( " %s=y", "usegrayscale"); - if (Ambient) - put_parm( " %s=%d", "ambient",Ambient); - if (haze) - put_parm( " %s=%d", "haze",haze); - if (back_color[0] != 51 || back_color[1] != 153 || back_color[2] != 200) - put_parm( " %s=%d/%d/%d", "background",back_color[0],back_color[1], - back_color[2]); - } - - if (display3d) { /* universal 3d */ - /***** common (fractal & transform) 3d parameters in this section *****/ - if (!SPHERE || display3d < 0) - put_parm( " %s=%d/%d/%d", "rotation", XROT, YROT, ZROT); - put_parm( " %s=%d", "perspective", ZVIEWER); - put_parm( " %s=%d/%d", "xyshift", XSHIFT, YSHIFT); - if (xtrans || ytrans) - put_parm( " %s=%d/%d", "xyadjust",xtrans,ytrans); - if (g_glasses_type) { - put_parm( " %s=%d", "stereo",g_glasses_type); - put_parm( " %s=%d", "interocular",g_eye_separation); - put_parm( " %s=%d", "converge",xadjust); - put_parm( " %s=%d/%d/%d/%d", "crop", - red_crop_left,red_crop_right,blue_crop_left,blue_crop_right); - put_parm( " %s=%d/%d", "bright", - red_bright,blue_bright); - } - } - - /***** universal parameters in this section *****/ - - if (viewwindow == 1) - { - put_parm(" %s=%g/%g", "viewwindows",viewreduction,finalaspectratio); - if (viewcrop) - put_parm("/%s", "yes"); - else - put_parm("/%s", "no"); - put_parm("/%d/%d",viewxdots,viewydots); - } - - if (colorsonly == 0) - { - if (rotate_lo != 1 || rotate_hi != 255) - put_parm( " %s=%d/%d", "cyclerange",rotate_lo,rotate_hi); - - if (basehertz != 440) - put_parm(" %s=%d", "hertz",basehertz); - - if (soundflag != (SOUNDFLAG_BEEP | SOUNDFLAG_SPEAKER)) { - if ((soundflag & SOUNDFLAG_ORBITMASK) == SOUNDFLAG_OFF) - put_parm(" %s=%s", "sound", "off"); - else if ((soundflag & SOUNDFLAG_ORBITMASK) == SOUNDFLAG_BEEP) - put_parm(" %s=%s", "sound", "beep"); - else if ((soundflag & SOUNDFLAG_ORBITMASK) == SOUNDFLAG_X) - put_parm(" %s=%s", "sound","x"); - else if ((soundflag & SOUNDFLAG_ORBITMASK) == SOUNDFLAG_Y) - put_parm(" %s=%s", "sound","y"); - else if ((soundflag & SOUNDFLAG_ORBITMASK) == SOUNDFLAG_Z) - put_parm(" %s=%s", "sound","z"); -#ifndef XFRACT - if ((soundflag & SOUNDFLAG_ORBITMASK) && (soundflag & SOUNDFLAG_ORBITMASK) <= SOUNDFLAG_Z) { - if (soundflag & SOUNDFLAG_SPEAKER) - put_parm("/pc"); - if (soundflag & SOUNDFLAG_OPL3_FM) - put_parm("/fm"); - if (soundflag & SOUNDFLAG_MIDI) - put_parm("/midi"); - if (soundflag & SOUNDFLAG_QUANTIZED) - put_parm("/quant"); - } -#endif - } - -#ifndef XFRACT - if (fm_vol != 63) - put_parm(" %s=%d", "volume",fm_vol); - - if (hi_atten != 0) { - if (hi_atten == 1) - put_parm(" %s=%s", "attenuate", "low"); - else if (hi_atten == 2) - put_parm(" %s=%s", "attenuate", "mid"); - else if (hi_atten == 3) - put_parm(" %s=%s", "attenuate", "high"); - else /* just in case */ - put_parm(" %s=%s", "attenuate", "none"); - } - - if (polyphony != 0) - put_parm(" %s=%d", "polyphony",polyphony+1); - - if (fm_wavetype !=0) - put_parm(" %s=%d", "wavetype",fm_wavetype); - - if (fm_attack != 5) - put_parm(" %s=%d", "attack",fm_attack); - - if (fm_decay != 10) - put_parm(" %s=%d", "decay",fm_decay); - - if (fm_sustain != 13) - put_parm(" %s=%d", "sustain",fm_sustain); - - if (fm_release != 5) - put_parm(" %s=%d", "srelease",fm_release); - - if (soundflag & SOUNDFLAG_QUANTIZED) { /* quantize turned on */ - for (i=0; i<=11; i++) if (scale_map[i] != i+1) i=15; - if (i>12) - put_parm(" %s=%d/%d/%d/%d/%d/%d/%d/%d/%d/%d/%d/%d", "scalemap",scale_map[0],scale_map[1],scale_map[2],scale_map[3] - ,scale_map[4],scale_map[5],scale_map[6],scale_map[7],scale_map[8] - ,scale_map[9],scale_map[10],scale_map[11]); - } - -#endif - - if (nobof > 0) - put_parm(" %s=%s", "nobof", "yes"); - - if (orbit_delay > 0) - put_parm(" %s=%d", "orbitdelay",orbit_delay); - - if (orbit_interval != 1) - put_parm(" %s=%d", "orbitinterval",orbit_interval); - - if (start_showorbit > 0) - put_parm(" %s=%s", "showorbit", "yes"); - - if (keep_scrn_coords) - put_parm(" %s=%s", "screencoords", "yes"); - - if (usr_stdcalcmode == 'o' && set_orbit_corners && keep_scrn_coords) - { - int xdigits,ydigits; - put_parm( " %s=", "orbitcorners"); - xdigits = getprec(oxmin,oxmax,ox3rd); - ydigits = getprec(oymin,oymax,oy3rd); - put_float(0,oxmin,xdigits); - put_float(1,oxmax,xdigits); - put_float(1,oymin,ydigits); - put_float(1,oymax,ydigits); - if (ox3rd != oxmin || oy3rd != oymin) - { - put_float(1,ox3rd,xdigits); - put_float(1,oy3rd,ydigits); - } - } - - if (drawmode != 'r') - put_parm(" %s=%c", "orbitdrawmode", drawmode); - - if (math_tol[0] != 0.05 || math_tol[1] != 0.05) - put_parm(" %s=%g/%g", "mathtolerance",math_tol[0],math_tol[1]); - - } - - if (*colorinf != 'n') - { - if (recordcolors=='c' && *colorinf == '@') - { - put_parm_line(); - put_parm("; %s=", "colors"); - put_parm(colorinf); - put_parm_line(); - } -docolors: - put_parm(" %s=", "colors"); - if (recordcolors !='c' && recordcolors != 'y' && *colorinf == '@') - put_parm(colorinf); - else { - int curc,scanc,force,diffmag = -1; - int delta,diff1[4][3],diff2[4][3]; - curc = force = 0; -#ifdef XFRACT - if (fake_lut && !truemode) loaddac(); /* stupid kludge JCO 6/23/2001 */ -#endif - while (1) { - /* emit color in rgb 3 char encoded form */ - for (j = 0; j < 3; ++j) { - if ((k = g_dac_box[curc][j]) < 10) k += '0'; - else if (k < 36) k += ('A' - 10); - else k += ('_' - 36); - buf[j] = (char)k; - } - buf[3] = 0; - put_parm(buf); - if (++curc >= maxcolor) /* quit if done last color */ - break; - if (debugflag == 920) /* lossless compression */ - continue; - /* Next a P Branderhorst special, a tricky scan for smooth-shaded - ranges which can be written as to compress .par file entry. - Method used is to check net change in each color value over - spans of 2 to 5 color numbers. First time for each span size - the value change is noted. After first time the change is - checked against noted change. First time it differs, a - a difference of 1 is tolerated and noted as an alternate - acceptable change. When change is not one of the tolerated - values, loop exits. */ - if (force) { - --force; - continue; - } - scanc = curc; - while (scanc < maxcolor) { /* scan while same diff to next */ - if ((i = scanc - curc) > 3) /* check spans up to 4 steps */ - i = 3; - for (k = 0; k <= i; ++k) { - for (j = 0; j < 3; ++j) { /* check pattern of chg per color */ - /* Sylvie Gallet's fix */ - if (debugflag != 910 && scanc > (curc+4) && scanc < maxcolor-5) - if (abs(2*g_dac_box[scanc][j] - g_dac_box[scanc-5][j] - - g_dac_box[scanc+5][j]) >= 2) - break; - /* end Sylvie's fix */ - delta = (int)g_dac_box[scanc][j] - (int)g_dac_box[scanc-k-1][j]; - if (k == scanc - curc) - diff1[k][j] = diff2[k][j] = delta; - else - if (delta != diff1[k][j] && delta != diff2[k][j]) { - diffmag = abs(delta - diff1[k][j]); - if (diff1[k][j] != diff2[k][j] || diffmag != 1) - break; - diff2[k][j] = delta; - } - } - if (j < 3) break; /* must've exited from inner loop above */ - } - if (k <= i) break; /* must've exited from inner loop above */ - ++scanc; - } - /* now scanc-1 is next color which must be written explicitly */ - if (scanc - curc > 2) { /* good, we have a shaded range */ - if (scanc != maxcolor) { - if (diffmag < 3) { /* not a sharp slope change? */ - force = 2; /* force more between ranges, to stop */ - --scanc; /* "drift" when load/store/load/store/ */ - } - if (k) { /* more of the same */ - force += k; - --scanc; - } - } - if (--scanc - curc > 1) { - put_parm("<%d>",scanc-curc); - curc = scanc; - } - else /* changed our mind */ - force = 0; - } - } - } - } - - while (s_wbdata.len) /* flush the buffer */ - put_parm_line(); - - restore_stack(saved); -} - -static void put_filename(char *keyword,char *fname) -{ - char *p; - if (*fname && !endswithslash(fname)) { - if ((p = strrchr(fname, SLASHC)) != NULL) - { - fname = p+1; - if (*fname == 0) return; - } - put_parm(" %s=%s",keyword,fname); - } -} - -#ifndef USE_VARARGS -static void put_parm(char *parm,...) -#else -static void put_parm(va_alist) -va_dcl -#endif -{ - char *bufptr; - va_list args; - -#ifndef USE_VARARGS - va_start(args,parm); -#else - char * parm; - - va_start(args); - parm = va_arg(args,char *); -#endif - if (*parm == ' ' /* starting a new parm */ - && s_wbdata.len == 0) /* skip leading space */ - ++parm; - bufptr = s_wbdata.buf + s_wbdata.len; - vsprintf(bufptr,parm,args); - while (*(bufptr++)) - ++s_wbdata.len; - while (s_wbdata.len > 200) - put_parm_line(); -} - -int maxlinelength=72; -#define MAXLINELEN maxlinelength -#define NICELINELEN (MAXLINELEN-4) - -static void put_parm_line() -{ - int len,c; - if ((len = s_wbdata.len) > NICELINELEN) { - len = NICELINELEN+1; - while (--len != 0 && s_wbdata.buf[len] != ' ') { } - if (len == 0) { - len = NICELINELEN-1; - while (++len < MAXLINELEN - && s_wbdata.buf[len] && s_wbdata.buf[len] != ' ') { } - } - } - c = s_wbdata.buf[len]; - s_wbdata.buf[len] = 0; - fputs(" ",parmfile); - fputs(s_wbdata.buf,parmfile); - if (c && c != ' ') - fputc('\\',parmfile); - fputc('\n',parmfile); - s_wbdata.buf[len] = (char)c; - if (c == ' ') - ++len; - s_wbdata.len -= len; - strcpy(s_wbdata.buf,s_wbdata.buf+len); -} - -int getprecbf_mag() -{ - double Xmagfactor, Rotation, Skew; - LDBL Magnification; - bf_t bXctr, bYctr; - int saved,dec; - - saved = save_stack(); - bXctr = alloc_stack(bflength+2); - bYctr = alloc_stack(bflength+2); - /* this is just to find Magnification */ - cvtcentermagbf(bXctr, bYctr, &Magnification, &Xmagfactor, &Rotation, &Skew); - restore_stack(saved); - - /* I don't know if this is portable, but something needs to */ - /* be used in case compiler's LDBL_MAX is not big enough */ - if (Magnification > LDBL_MAX || Magnification < -LDBL_MAX) - return(-1); - - dec = getpower10(Magnification) + 4; /* 4 digits of padding sounds good */ - return(dec); -} - -static int getprec(double a,double b,double c) -{ - double diff,temp; - int digits; - double highv = 1.0E20; - diff = fabs(a - b); - if (diff == 0.0) diff = highv; - temp = fabs(a - c); - if (temp == 0.0) temp = highv; - if (temp < diff) diff = temp; - temp = fabs(b - c); - if (temp == 0.0) temp = highv; - if (temp < diff) diff = temp; - digits = 7; - if (debugflag >= 700 && debugflag < 720 ) - digits = debugflag - 700; - while (diff < 1.0 && digits <= DBL_DIG+1) { - diff *= 10; - ++digits; - } - return(digits); -} - -/* This function calculates the precision needed to distiguish adjacent - pixels at Fractint's maximum resolution of MAXPIXELS by MAXPIXELS - (if rez==MAXREZ) or at current resolution (if rez==CURRENTREZ) */ -int getprecbf(int rezflag) -{ - bf_t del1,del2, one, bfxxdel, bfxxdel2, bfyydel, bfyydel2; - int digits,dec; - int saved; - int rez; - saved = save_stack(); - del1 = alloc_stack(bflength+2); - del2 = alloc_stack(bflength+2); - one = alloc_stack(bflength+2); - bfxxdel = alloc_stack(bflength+2); - bfxxdel2 = alloc_stack(bflength+2); - bfyydel = alloc_stack(bflength+2); - bfyydel2 = alloc_stack(bflength+2); - floattobf(one,1.0); - if (rezflag == MAXREZ) - rez = OLDMAXPIXELS -1; - else - rez = xdots-1; - - /* bfxxdel = (bfxmax - bfx3rd)/(xdots-1) */ - sub_bf(bfxxdel, bfxmax, bfx3rd); - div_a_bf_int(bfxxdel, (U16)rez); - - /* bfyydel2 = (bfy3rd - bfymin)/(xdots-1) */ - sub_bf(bfyydel2, bfy3rd, bfymin); - div_a_bf_int(bfyydel2, (U16)rez); - - if (rezflag == CURRENTREZ) - rez = ydots-1; - - /* bfyydel = (bfymax - bfy3rd)/(ydots-1) */ - sub_bf(bfyydel, bfymax, bfy3rd); - div_a_bf_int(bfyydel, (U16)rez); - - /* bfxxdel2 = (bfx3rd - bfxmin)/(ydots-1) */ - sub_bf(bfxxdel2, bfx3rd, bfxmin); - div_a_bf_int(bfxxdel2, (U16)rez); - - abs_a_bf(add_bf(del1,bfxxdel,bfxxdel2)); - abs_a_bf(add_bf(del2,bfyydel,bfyydel2)); - if (cmp_bf(del2,del1) < 0) - copy_bf(del1, del2); - if (cmp_bf(del1,clear_bf(del2)) == 0) - { - restore_stack(saved); - return(-1); - } - digits = 1; - while (cmp_bf(del1,one) < 0) - { - digits++; - mult_a_bf_int(del1,10); - } - digits = max(digits,3); - restore_stack(saved); - dec = getprecbf_mag(); - return(max(digits,dec)); -} - -#ifdef _MSC_VER -#pragma optimize("e",off) /* MSC 7.00 messes up next with "e" on */ -#endif - -/* This function calculates the precision needed to distiguish adjacent - pixels at Fractint's maximum resolution of MAXPIXELS by MAXPIXELS - (if rez==MAXREZ) or at current resolution (if rez==CURRENTREZ) */ -int getprecdbl(int rezflag) -{ - LDBL del1,del2, xdel, xdel2, ydel, ydel2; - int digits; - LDBL rez; - if (rezflag == MAXREZ) - rez = OLDMAXPIXELS -1; - else - rez = xdots-1; - - xdel = ((LDBL)xxmax - (LDBL)xx3rd)/rez; - ydel2 = ((LDBL)yy3rd - (LDBL)yymin)/rez; - - if (rezflag == CURRENTREZ) - rez = ydots-1; - - ydel = ((LDBL)yymax - (LDBL)yy3rd)/rez; - xdel2 = ((LDBL)xx3rd - (LDBL)xxmin)/rez; - - del1 = fabsl(xdel) + fabsl(xdel2); - del2 = fabsl(ydel) + fabsl(ydel2); - if (del2 < del1) - del1 = del2; - if (del1 == 0) - { -#ifdef DEBUG - showcornersdbl("getprecdbl"); -#endif - return(-1); - } - digits = 1; - while (del1 < 1.0) - { - digits++; - del1 *= 10; - } - digits = max(digits,3); - return(digits); -} - -#ifdef _MSC_VER -#pragma optimize("e",on) -#endif - -/* - Strips zeros from the non-exponent part of a number. This logic - was originally in put_bf(), but is split into this routine so it can be - shared with put_float(), which had a bug in Fractint 19.2 (used to strip - zeros from the exponent as well.) -*/ - -static void strip_zeros(char *buf) -{ - char *dptr, *bptr, *exptr; - strlwr(buf); - if ((dptr = strchr(buf,'.')) != 0) { - ++dptr; - if ((exptr = strchr(buf,'e')) !=0) /* scientific notation with 'e'? */ - bptr = exptr; - else - bptr = buf + strlen(buf); - while (--bptr > dptr && *bptr == '0') - *bptr = 0; - if (exptr && bptr < exptr -1) - strcat(buf,exptr); - } -} - -static void put_float(int slash,double fnum,int prec) -{ char buf[40]; - char *bptr; - bptr = buf; - if (slash) - *(bptr++) = '/'; -/* sprintf(bptr,"%1.*f",prec,fnum); */ -#ifdef USE_LONG_DOUBLE - /* Idea of long double cast is to squeeze out another digit or two - which might be needed (we have found cases where this digit makes - a difference.) But lets not do this at lower precision */ - if (prec > 15) - sprintf(bptr,"%1.*Lg",prec,(long double)fnum); - else -#endif - sprintf(bptr,"%1.*g",prec,(double)fnum); - strip_zeros(bptr); - put_parm(buf); -} - -static void put_bf(int slash,bf_t r, int prec) -{ - char *buf; /* "/-1.xxxxxxE-1234" */ - char *bptr; - /* buf = malloc(decimals+11); */ - buf = s_wbdata.buf+5000; /* end of use suffix buffer, 5000 bytes safe */ - bptr = buf; - if (slash) - *(bptr++) = '/'; - bftostr(bptr, prec, r); - strip_zeros(bptr); - put_parm(buf); -} - -#if 0 -void edit_text_colors() -{ - /* TODO: make this work for a driver situation */ - int save_debugflag,save_lookatmouse; - int row,col,bkgrd; - int rowf,colf,rowt,colt; - char *vidmem; - char *savescreen; - char *farp1; char *farp2; - int i,j,k; - save_debugflag = debugflag; - save_lookatmouse = lookatmouse; - debugflag = 0; /* don't get called recursively */ - lookatmouse = 2; /* text mouse sensitivity */ - row = col = bkgrd = rowt = rowf = colt = colf = 0; - /* TODO: allocate real memory, not reuse shared segment */ - vidmem = MK_FP(0xB800,0); - while (1) { - if (row < 0) row = 0; - if (row > 24) row = 24; - if (col < 0) col = 0; - if (col > 79) col = 79; - driver_move_cursor(row,col); - i = driver_get_key(); - if (i >= 'a' && i <= 'z') i -= 32; /* uppercase */ - switch (i) { - case 27: /* esc */ - debugflag = save_debugflag; - lookatmouse = save_lookatmouse; - driver_hide_text_cursor(); - return; - case '/': - farp1 = savescreen = (char *)malloc(4000L); - farp2 = vidmem; - for (i = 0; i < 4000; ++i) { /* save and blank */ - *(farp1++) = *farp2; - *(farp2++) = 0; - } - for (i = 0; i < 8; ++i) /* 8 bkgrd attrs */ - for (j = 0; j < 16; ++j) { /* 16 fgrd attrs */ - k = i*16 + j; - farp1 = vidmem + i*320 + j*10; - *(farp1++) = ' '; *(farp1++) = (char)k; - *(farp1++) = (char)(i+'0'); *(farp1++) = (char)k; - *(farp1++) = (char)((j < 10) ? j+'0' : j+'A'-10); *(farp1++) = (char)k; - *(farp1++) = ' '; *(farp1++) = (char)k; - } - driver_get_key(); - farp1 = vidmem; - farp2 = savescreen; - for (i = 0; i < 4000; ++i) /* restore */ - *(farp1++) = *(farp2++); - free(savescreen); - break; - case ',': - rowf = row; colf = col; break; - case '.': - rowt = row; colt = col; break; - case ' ': /* next color is background */ - bkgrd = 1; break; - case 1075: /* cursor left */ - --col; break; - case 1077: /* cursor right */ - ++col; break; - case 1072: /* cursor up */ - --row; break; - case 1080: /* cursor down */ - ++row; break; - case 13: /* enter */ - *(vidmem + row*160 + col*2) = (char)driver_get_key(); - break; - default: - if (i >= '0' && i <= '9') i -= '0'; - else if (i >= 'A' && i <= 'F') i -= 'A'-10; - else break; - for (j = rowf; j <= rowt; ++j) - for (k = colf; k <= colt; ++k) { - farp1 = vidmem + j*160 + k*2 + 1; - if (bkgrd) *farp1 = (char)((*farp1 & 15) + i * 16); - else *farp1 = (char)((*farp1 & 0xf0) + i); - } - bkgrd = 0; - } - } -} -#endif - -static int *entsptr; -static int modes_changed; - -int select_video_mode(int curmode) -{ - int entnums[MAXVIDEOMODES]; - int attributes[MAXVIDEOMODES]; - int i,k,ret; -#ifndef XFRACT - int oldtabmode,oldhelpmode; -#endif - - for (i = 0; i < g_video_table_len; ++i) /* init tables */ - { - entnums[i] = i; - attributes[i] = 1; - } - entsptr = entnums; /* for indirectly called subroutines */ - - qsort(entnums,g_video_table_len,sizeof(entnums[0]),entcompare); /* sort modes */ - - /* pick default mode */ - if (curmode < 0) - { - g_video_entry.videomodeax = 19; /* vga */ - g_video_entry.colors = 256; - } - else - { - memcpy((char *) &g_video_entry, (char *) &g_video_table[curmode], sizeof(g_video_entry)); - } -#ifndef XFRACT - for (i = 0; i < g_video_table_len; ++i) /* find default mode */ - { - if (g_video_entry.videomodeax == g_video_table[entnums[i]].videomodeax && - g_video_entry.colors == g_video_table[entnums[i]].colors && - (curmode < 0 || - memcmp((char *) &g_video_entry, (char *) &g_video_table[entnums[i]], sizeof(g_video_entry)) == 0)) - { - break; - } - } - if (i >= g_video_table_len) /* no match, default to first entry */ - { - i = 0; - } - - oldtabmode = tabmode; - oldhelpmode = helpmode; - modes_changed = 0; - tabmode = 0; - helpmode = HELPVIDSEL; - i = fullscreen_choice(CHOICE_HELP, - "Select Video Mode", - "key...name.......................xdot..ydot.colr.driver......comment......", - NULL, g_video_table_len, NULL, attributes, - 1, 16, 74, i, format_vid_table, NULL, NULL, check_modekey); - tabmode = oldtabmode; - helpmode = oldhelpmode; - if (i == -1) - { - /* update fractint.cfg for new key assignments */ - if (modes_changed && g_bad_config == 0 && - stopmsg(STOPMSG_CANCEL | STOPMSG_NO_BUZZER | STOPMSG_INFO_ONLY, - "Save new function key assignments or cancel changes?") == 0) - { - update_fractint_cfg(); - } - return -1; - } - /* picked by function key or ENTER key */ - i = (i < 0) ? (-1 - i) : entnums[i]; -#endif - /* the selected entry now in g_video_entry */ - memcpy((char *) &g_video_entry, (char *) &g_video_table[i], sizeof(g_video_entry)); - -#ifndef XFRACT - /* copy fractint.cfg table to resident table, note selected entry */ - k = 0; - for (i = 0; i < g_video_table_len; ++i) - { - if (g_video_table[i].keynum > 0) - { - if (memcmp((char *)&g_video_entry,(char *)&g_video_table[i], - sizeof(g_video_entry)) == 0) - { - k = g_video_table[i].keynum; - } - } - } -#else - k = g_video_table[0].keynum; -#endif - ret = k; - if (k == 0) /* selected entry not a copied (assigned to key) one */ - { - memcpy((char *)&g_video_table[MAXVIDEOMODES-1], - (char *)&g_video_entry,sizeof(*g_video_table)); - ret = 1400; /* special value for check_vidmode_key */ - } - - /* update fractint.cfg for new key assignments */ - if (modes_changed && g_bad_config == 0) - { - update_fractint_cfg(); - } - - return ret; -} - -void format_vid_table(int choice,char *buf) -{ - char local_buf[81]; - char kname[5]; - int truecolorbits; - memcpy((char *)&g_video_entry,(char *)&g_video_table[entsptr[choice]], - sizeof(g_video_entry)); - vidmode_keyname(g_video_entry.keynum,kname); - sprintf(buf,"%-5s %-25s %5d %5d ", /* 44 chars */ - kname, g_video_entry.name, g_video_entry.xdots, g_video_entry.ydots); - truecolorbits = g_video_entry.dotmode/1000; - if (truecolorbits == 0) - sprintf(local_buf,"%s%3d", /* 47 chars */ - buf, g_video_entry.colors); - else - sprintf(local_buf,"%s%3s", /* 47 chars */ - buf, (truecolorbits == 4)?" 4g": - (truecolorbits == 3)?"16m": - (truecolorbits == 2)?"64k": - (truecolorbits == 1)?"32k":"???"); - sprintf(buf,"%s %.12s %.12s", /* 74 chars */ - local_buf, g_video_entry.driver->name, g_video_entry.comment); -} - -#ifndef XFRACT -static int check_modekey(int curkey,int choice) -{ - int i,j,k,ret; - if ((i = check_vidmode_key(1,curkey)) >= 0) - return(-1-i); - i = entsptr[choice]; - ret = 0; - if ( (curkey == '-' || curkey == '+') - && (g_video_table[i].keynum == 0 || g_video_table[i].keynum >= 1084)) { - if (g_bad_config) - stopmsg(0,"Missing or bad FRACTINT.CFG file. Can't reassign keys."); - else { - if (curkey == '-') { /* deassign key? */ - if (g_video_table[i].keynum >= 1084) { - g_video_table[i].keynum = 0; - modes_changed = 1; - } - } - else { /* assign key? */ - j = getakeynohelp(); - if (j >= 1084 && j <= 1113) { - for (k = 0; k < g_video_table_len; ++k) { - if (g_video_table[k].keynum == j) { - g_video_table[k].keynum = 0; - ret = -1; /* force redisplay */ - } - } - g_video_table[i].keynum = j; - modes_changed = 1; - } - } - } - } - return(ret); -} -#endif - -static int entcompare(VOIDCONSTPTR p1,VOIDCONSTPTR p2) -{ - int i,j; - i = g_video_table[*((int *)p1)].keynum; - if (i == 0) i = 9999; - j = g_video_table[*((int *)p2)].keynum; - if (j == 0) j = 9999; - if (i < j || (i == j && *((int *)p1) < *((int *)p2))) - return(-1); - return(1); -} - -static void update_fractint_cfg() -{ - extern int g_cfg_line_nums[]; -#ifndef XFRACT - char cfgname[100],outname[100],buf[121],kname[5]; - FILE *cfgfile,*outfile; - int i,j,linenum,nextlinenum,nextmode; - struct videoinfo vident; - - findpath("fractint.cfg",cfgname); - - if (access(cfgname,6)) { - sprintf(buf,"Can't write %s",cfgname); - stopmsg(0,buf); - return; - } - strcpy(outname,cfgname); - i = (int) strlen(outname); - while (--i >= 0 && outname[i] != SLASHC) - outname[i] = 0; - strcat(outname,"fractint.tmp"); - outfile = fopen(outname,"w"); - if (outfile == NULL) { - sprintf(buf,"Can't create %s",outname); - stopmsg(0,buf); - return; - } - cfgfile = fopen(cfgname,"r"); - - linenum = nextmode = 0; - nextlinenum = g_cfg_line_nums[0]; - while (fgets(buf,120,cfgfile)) { - int truecolorbits; - char colorsbuf[10]; - ++linenum; - if (linenum == nextlinenum) { /* replace this line */ - memcpy((char *)&vident,(char *)&g_video_table[nextmode], - sizeof(g_video_entry)); - vidmode_keyname(vident.keynum,kname); - strcpy(buf,vident.name); - i = (int) strlen(buf); - while (i && buf[i-1] == ' ') /* strip trailing spaces to compress */ - --i; - j = i + 5; - while (j < 32) { /* tab to column 33 */ - buf[i++] = '\t'; - j += 8; - } - buf[i] = 0; - truecolorbits = vident.dotmode/1000; - if (truecolorbits == 0) - sprintf(colorsbuf,"%3d",vident.colors); - else - sprintf(colorsbuf,"%3s", - (truecolorbits == 4)?" 4g": - (truecolorbits == 3)?"16m": - (truecolorbits == 2)?"64k": - (truecolorbits == 1)?"32k":"???"); - fprintf(outfile,"%-4s,%s,%4x,%4x,%4x,%4x,%4d,%5d,%5d,%s,%s\n", - kname, - buf, - vident.videomodeax, - vident.videomodebx, - vident.videomodecx, - vident.videomodedx, - vident.dotmode%1000, /* remove true-color flag, keep g_text_safe */ - vident.xdots, - vident.ydots, - colorsbuf, - vident.comment); - if (++nextmode >= g_video_table_len) - nextlinenum = 32767; - else - nextlinenum = g_cfg_line_nums[nextmode]; - } - else - fputs(buf,outfile); - } - - fclose(cfgfile); - fclose(outfile); - unlink(cfgname); /* success assumed on these lines */ - rename(outname,cfgname); /* since we checked earlier with access */ -#endif -} - -/* make_mig() takes a collection of individual GIF images (all - presumably the same resolution and all presumably generated - by Fractint and its "divide and conquer" algorithm) and builds - a single multiple-image GIF out of them. This routine is - invoked by the "batch=stitchmode/x/y" option, and is called - with the 'x' and 'y' parameters -*/ - -void make_mig(unsigned int xmult, unsigned int ymult) -{ - unsigned int xstep, ystep; - unsigned int xres, yres; - unsigned int allxres, allyres, xtot, ytot; - unsigned int xloc, yloc; - unsigned char ichar; - unsigned int allitbl, itbl; - unsigned int i; - char gifin[15], gifout[15]; - int errorflag, inputerrorflag; - unsigned char *temp; - FILE *out, *in; - - errorflag = 0; /* no errors so */ - inputerrorflag = 0; - allxres = allyres = allitbl = 0; - out = in = NULL; - - strcpy(gifout,"fractmig.gif"); - - temp= &olddacbox[0][0]; /* a safe place for our temp data */ - - gif87a_flag = 1; /* for now, force this */ - - /* process each input image, one at a time */ - for (ystep = 0; ystep < ymult; ystep++) - { - for (xstep = 0; xstep < xmult; xstep++) - { - if (xstep == 0 && ystep == 0) /* first time through? */ - { - printf(" \n Generating multi-image GIF file %s using", gifout); - printf(" %d X and %d Y components\n\n", xmult, ymult); - /* attempt to create the output file */ - out = fopen(gifout,"wb"); - if (out == NULL) - { - printf("Cannot create output file %s!\n", gifout); - exit(1); - } - } - - sprintf(gifin, "frmig_%c%c.gif", PAR_KEY(xstep), PAR_KEY(ystep)); - - in = fopen(gifin,"rb"); - if (in == NULL) - { - printf("Can't open file %s!\n", gifin); - exit(1); - } - - /* (read, but only copy this if it's the first time through) */ - if (fread(temp,13,1,in) != 1) /* read the header and LDS */ - { - inputerrorflag = 1; - } - memcpy(&xres, &temp[6], 2); /* X-resolution */ - memcpy(&yres, &temp[8], 2); /* Y-resolution */ - - if (xstep == 0 && ystep == 0) /* first time through? */ - { - allxres = xres; /* save the "master" resolution */ - allyres = yres; - xtot = xres * xmult; /* adjust the image size */ - ytot = yres * ymult; - memcpy(&temp[6], &xtot, 2); - memcpy(&temp[8], &ytot, 2); - if (gif87a_flag) - { - temp[3] = '8'; - temp[4] = '7'; - temp[5] = 'a'; - } - temp[12] = 0; /* reserved */ - if (fwrite(temp,13,1,out) != 1) /* write out the header */ - { - errorflag = 1; - } - } /* end of first-time-through */ - - ichar = (char)(temp[10] & 0x07); /* find the color table size */ - itbl = 1 << (++ichar); - ichar = (char)(temp[10] & 0x80); /* is there a global color table? */ - if (xstep == 0 && ystep == 0) /* first time through? */ - { - allitbl = itbl; /* save the color table size */ - } - if (ichar != 0) /* yup */ - { - /* (read, but only copy this if it's the first time through) */ - if (fread(temp,3*itbl,1,in) != 1) /* read the global color table */ - { - inputerrorflag = 2; - } - if (xstep == 0 && ystep == 0) /* first time through? */ - { - if (fwrite(temp,3*itbl,1,out) != 1) /* write out the GCT */ - { - errorflag = 2; - } - } - } - - if (xres != allxres || yres != allyres || itbl != allitbl) - { - /* Oops - our pieces don't match */ - printf("File %s doesn't have the same resolution as its predecessors!\n", gifin); - exit(1); - } - - for (;;) /* process each information block */ - { - memset(temp,0,10); - if (fread(temp,1,1,in) != 1) /* read the block identifier */ - { - inputerrorflag = 3; - } - - if (temp[0] == 0x2c) /* image descriptor block */ - { - if (fread(&temp[1],9,1,in) != 1) /* read the Image Descriptor */ - { - inputerrorflag = 4; - } - memcpy(&xloc, &temp[1], 2); /* X-location */ - memcpy(&yloc, &temp[3], 2); /* Y-location */ - xloc += (xstep * xres); /* adjust the locations */ - yloc += (ystep * yres); - memcpy(&temp[1], &xloc, 2); - memcpy(&temp[3], &yloc, 2); - if (fwrite(temp,10,1,out) != 1) /* write out the Image Descriptor */ - { - errorflag = 4; - } - - ichar = (char)(temp[9] & 0x80); /* is there a local color table? */ - if (ichar != 0) /* yup */ - { - if (fread(temp,3*itbl,1,in) != 1) /* read the local color table */ - { - inputerrorflag = 5; - } - if (fwrite(temp,3*itbl,1,out) != 1) /* write out the LCT */ - { - errorflag = 5; - } - } - - if (fread(temp,1,1,in) != 1) /* LZH table size */ - { - inputerrorflag = 6; - } - if (fwrite(temp,1,1,out) != 1) - { - errorflag = 6; - } - for (;;) - { - if (errorflag != 0 || inputerrorflag != 0) /* oops - did something go wrong? */ - { - break; - } - if (fread(temp,1,1,in) != 1) /* block size */ - { - inputerrorflag = 7; - } - if (fwrite(temp,1,1,out) != 1) - { - errorflag = 7; - } - i = temp[0]; - if (i == 0) - { - break; - } - if (fread(temp,i,1,in) != 1) /* LZH data block */ - { - inputerrorflag = 8; - } - if (fwrite(temp,i,1,out) != 1) - { - errorflag = 8; - } - } - } - - if (temp[0] == 0x21) /* extension block */ - { - /* (read, but only copy this if it's the last time through) */ - if (fread(&temp[2],1,1,in) != 1) /* read the block type */ - { - inputerrorflag = 9; - } - if ((!gif87a_flag) && xstep == xmult-1 && ystep == ymult-1) - { - if (fwrite(temp,2,1,out) != 1) - { - errorflag = 9; - } - } - for (;;) - { - if (errorflag != 0 || inputerrorflag != 0) /* oops - did something go wrong? */ - { - break; - } - if (fread(temp,1,1,in) != 1) /* block size */ - { - inputerrorflag = 10; - } - if ((!gif87a_flag) && xstep == xmult-1 && ystep == ymult-1) - { - if (fwrite(temp,1,1,out) != 1) - { - errorflag = 10; - } - } - i = temp[0]; - if (i == 0) - { - break; - } - if (fread(temp,i,1,in) != 1) /* data block */ - { - inputerrorflag = 11; - } - if ((!gif87a_flag) && xstep == xmult-1 && ystep == ymult-1) - { - if (fwrite(temp,i,1,out) != 1) - { - errorflag = 11; - } - } - } - } - - if (temp[0] == 0x3b) /* end-of-stream indicator */ - { - break; /* done with this file */ - } - - if (errorflag != 0 || inputerrorflag != 0) /* oops - did something go wrong? */ - { - break; - } - } - fclose(in); /* done with an input GIF */ - - if (errorflag != 0 || inputerrorflag != 0) /* oops - did something go wrong? */ - { - break; - } - } - - if (errorflag != 0 || inputerrorflag != 0) /* oops - did something go wrong? */ - { - break; - } - } - - temp[0] = 0x3b; /* end-of-stream indicator */ - if (fwrite(temp,1,1,out) != 1) - { - errorflag = 12; - } - fclose(out); /* done with the output GIF */ - - if (inputerrorflag != 0) /* uh-oh - something failed */ - { - printf("\007 Process failed = early EOF on input file %s\n", gifin); - /* following line was for debugging - printf("inputerrorflag = %d\n", inputerrorflag); - */ - } - - if (errorflag != 0) /* uh-oh - something failed */ - { - printf("\007 Process failed = out of disk space?\n"); - /* following line was for debugging - printf("errorflag = %d\n", errorflag); - */ - } - - /* now delete each input image, one at a time */ - if (errorflag == 0 && inputerrorflag == 0) - { - for (ystep = 0; ystep < ymult; ystep++) - { - for (xstep = 0; xstep < xmult; xstep++) - { - sprintf(gifin, "frmig_%c%c.gif", PAR_KEY(xstep), PAR_KEY(ystep)); - remove(gifin); - } - } - } - - /* tell the world we're done */ - if (errorflag == 0 && inputerrorflag == 0) - { - printf("File %s has been created (and its component files deleted)\n", gifout); - } -} - -/* This routine copies the current screen to by flipping x-axis, y-axis, - or both. Refuses to work if calculation in progress or if fractal - non-resumable. Clears zoombox if any. Resets corners so resulting fractal - is still valid. */ -void flip_image(int key) -{ - int i, j, ixhalf, iyhalf, tempdot; - - /* fractal must be rotate-able and be finished */ - if ((curfractalspecific->flags&NOROTATE) != 0 - || calc_status == CALCSTAT_IN_PROGRESS - || calc_status == CALCSTAT_RESUMABLE) - return; - if (bf_math) - clear_zoombox(); /* clear, don't copy, the zoombox */ - ixhalf = xdots / 2; - iyhalf = ydots / 2; - switch (key) - { - case 24: /* control-X - reverse X-axis */ - for (i = 0; i < ixhalf; i++) - { - if (driver_key_pressed()) - break; - for (j = 0; j < ydots; j++) - { - tempdot=getcolor(i,j); - putcolor(i, j, getcolor(xdots-1-i,j)); - putcolor(xdots-1-i, j, tempdot); - } - } - sxmin = xxmax + xxmin - xx3rd; - symax = yymax + yymin - yy3rd; - sxmax = xx3rd; - symin = yy3rd; - sx3rd = xxmax; - sy3rd = yymin; - if (bf_math) - { - add_bf(bfsxmin, bfxmax, bfxmin); /* sxmin = xxmax + xxmin - xx3rd; */ - sub_a_bf(bfsxmin, bfx3rd); - add_bf(bfsymax, bfymax, bfymin); /* symax = yymax + yymin - yy3rd; */ - sub_a_bf(bfsymax, bfy3rd); - copy_bf(bfsxmax, bfx3rd); /* sxmax = xx3rd; */ - copy_bf(bfsymin, bfy3rd); /* symin = yy3rd; */ - copy_bf(bfsx3rd, bfxmax); /* sx3rd = xxmax; */ - copy_bf(bfsy3rd, bfymin); /* sy3rd = yymin; */ - } - break; - case 25: /* control-Y - reverse Y-aXis */ - for (j = 0; j < iyhalf; j++) - { - if (driver_key_pressed()) - break; - for (i = 0; i < xdots; i++) - { - tempdot=getcolor(i,j); - putcolor(i, j, getcolor(i,ydots-1-j)); - putcolor(i,ydots-1-j, tempdot); - } - } - sxmin = xx3rd; - symax = yy3rd; - sxmax = xxmax + xxmin - xx3rd; - symin = yymax + yymin - yy3rd; - sx3rd = xxmin; - sy3rd = yymax; - if (bf_math) - { - copy_bf(bfsxmin, bfx3rd); /* sxmin = xx3rd; */ - copy_bf(bfsymax, bfy3rd); /* symax = yy3rd; */ - add_bf(bfsxmax, bfxmax, bfxmin); /* sxmax = xxmax + xxmin - xx3rd; */ - sub_a_bf(bfsxmax, bfx3rd); - add_bf(bfsymin, bfymax, bfymin); /* symin = yymax + yymin - yy3rd; */ - sub_a_bf(bfsymin, bfy3rd); - copy_bf(bfsx3rd, bfxmin); /* sx3rd = xxmin; */ - copy_bf(bfsy3rd, bfymax); /* sy3rd = yymax; */ - } - break; - case 26: /* control-Z - reverse X and Y aXis */ - for (i = 0; i < ixhalf; i++) - { - if (driver_key_pressed()) - break; - for (j = 0; j < ydots; j++) - { - tempdot=getcolor(i,j); - putcolor(i, j, getcolor(xdots-1-i,ydots-1-j)); - putcolor(xdots-1-i, ydots-1-j, tempdot); - } - } - sxmin = xxmax; - symax = yymin; - sxmax = xxmin; - symin = yymax; - sx3rd = xxmax + xxmin - xx3rd; - sy3rd = yymax + yymin - yy3rd; - if (bf_math) - { - copy_bf(bfsxmin, bfxmax); /* sxmin = xxmax; */ - copy_bf(bfsymax, bfymin); /* symax = yymin; */ - copy_bf(bfsxmax, bfxmin); /* sxmax = xxmin; */ - copy_bf(bfsymin, bfymax); /* symin = yymax; */ - add_bf(bfsx3rd, bfxmax, bfxmin); /* sx3rd = xxmax + xxmin - xx3rd; */ - sub_a_bf(bfsx3rd, bfx3rd); - add_bf(bfsy3rd, bfymax, bfymin); /* sy3rd = yymax + yymin - yy3rd; */ - sub_a_bf(bfsy3rd, bfy3rd); - } - break; - } - reset_zoom_corners(); - calc_status = CALCSTAT_PARAMS_CHANGED; -} -static char *expand_var(char *var, char *buf) -{ - time_t ltime; - char *str, *out; - - time( <ime ); - str = ctime(<ime); - - /* ctime format */ - /* Sat Aug 17 21:34:14 1996 */ - /* 012345678901234567890123 */ - /* 1 2 */ - if (strcmp(var,"year") == 0) /* 4 chars */ - { - str[24] = '\0'; - out = &str[20]; - } - else if (strcmp(var,"month") == 0) /* 3 chars */ - { - str[7] = '\0'; - out = &str[4]; - } - else if (strcmp(var,"day") == 0) /* 2 chars */ - { - str[10] = '\0'; - out = &str[8]; - } - else if (strcmp(var,"hour") == 0) /* 2 chars */ - { - str[13] = '\0'; - out = &str[11]; - } - else if (strcmp(var,"min") == 0) /* 2 chars */ - { - str[16] = '\0'; - out = &str[14]; - } - else if (strcmp(var,"sec") == 0) /* 2 chars */ - { - str[19] = '\0'; - out = &str[17]; - } - else if (strcmp(var,"time") == 0) /* 8 chars */ - { - str[19] = '\0'; - out = &str[11]; - } - else if (strcmp(var,"date") == 0) - { - str[10] = '\0'; - str[24] = '\0'; - out = &str[4]; - strcat(out,", "); - strcat(out,&str[20]); - } - else if (strcmp(var,"calctime") == 0) - { - get_calculation_time(buf,calctime); - out = buf; - } - else if (strcmp(var,"version") == 0) /* 4 chars */ - { - sprintf(buf,"%d",g_release); - out = buf; - } - else if (strcmp(var,"patch") == 0) /* 1 or 2 chars */ - { - sprintf(buf,"%d",g_patch_level); - out = buf; - } - else if (strcmp(var,"xdots") == 0) /* 2 to 4 chars */ - { - sprintf(buf,"%d",xdots); - out = buf; - } - else if (strcmp(var,"ydots") == 0) /* 2 to 4 chars */ - { - sprintf(buf,"%d",ydots); - out = buf; - } - else if (strcmp(var,"vidkey") == 0) /* 2 to 3 chars */ - { - char vidmde[5]; - vidmode_keyname(g_video_entry.keynum, vidmde); - sprintf(buf,"%s",vidmde); - out = buf; - } - else - { - char buff[80]; - _snprintf(buff, NUM_OF(buff), "Unknown comment variable %s", var); - stopmsg(0,buff); - out = ""; - } - return(out); -} - -#define MAXVNAME 13 - -static const char esc_char = '$'; - -/* extract comments from the comments= command */ -void expand_comments(char *target, char *source) -{ - int i,j, k, escape = 0; - char c, oldc, varname[MAXVNAME]; - i=j=k=0; - c = oldc = 0; - while (i < MAXCMT && j < MAXCMT && (c = *(source+i++)) != '\0') - { - if (c == '\\' && oldc != '\\') - { - oldc = c; - continue; - } - /* expand underscores to blanks */ - if (c == '_' && oldc != '\\') - c = ' '; - /* esc_char marks start and end of variable names */ - if (c == esc_char && oldc != '\\') - escape = 1 - escape; - if (c != esc_char && escape != 0) /* if true, building variable name */ - { - if (k < MAXVNAME-1) - varname[k++] = c; - } - /* got variable name */ - else if (c == esc_char && escape == 0 && oldc != '\\') - { - char buf[100]; - char *varstr; - varname[k] = 0; - varstr = expand_var(varname,buf); - strncpy(target+j,varstr,MAXCMT-j-1); - j += (int) strlen(varstr); - } - else if (c == esc_char && escape != 0 && oldc != '\\') - k = 0; - else if ((c != esc_char || oldc == '\\') && escape == 0) - *(target+j++) = c; - oldc = c; - } - if (*source != '\0') - *(target+min(j,MAXCMT-1)) = '\0'; -} - -/* extract comments from the comments= command */ -void parse_comments(char *value) -{ - int i; - char *next,save; - for (i=0; i<4; i++) - { - save = '\0'; - if (*value == 0) - break; - next = strchr(value,'/'); - if (*value != '/') - { - if (next != NULL) - { - save = *next; - *next = '\0'; - } - strncpy(par_comment[i],value, MAXCMT); - } - if (next == NULL) - break; - if (save != '\0') - *next = save; - value = next+1; - } -} - -void init_comments() -{ - int i; - for (i=0; i<4; i++) - par_comment[i][0] = '\0'; -} diff --git a/fractint/common/miscres.c b/fractint/common/miscres.c deleted file mode 100644 index d15e179fe..000000000 --- a/fractint/common/miscres.c +++ /dev/null @@ -1,1745 +0,0 @@ -/* - Resident odds and ends that don't fit anywhere else. -*/ - -#include -#include -#include -#if !defined(_WIN32) -#include -#endif - -#ifndef XFRACT -#include -#endif - -#ifndef USE_VARARGS -#include -#else -#include -#endif - - /* see Fractint.c for a description of the "include" hierarchy */ -#include "port.h" -#include "prototyp.h" -#include "fractype.h" -#include "helpdefs.h" -#include "drivers.h" - -/* routines in this module */ - -static void trigdetails(char *); -static void area(void); - -#ifndef XFRACT - -void findpath(char *filename, char *fullpathname) /* return full pathnames */ -{ - char fname[FILE_MAX_FNAME]; - char ext[FILE_MAX_EXT]; - char temp_path[FILE_MAX_PATH]; - - splitpath(filename ,NULL,NULL,fname,ext); - makepath(temp_path,"" ,"" ,fname,ext); - - if (checkcurdir != 0 && access(temp_path,0) == 0) /* file exists */ - { - strcpy(fullpathname,temp_path); - return; - } - - strcpy(temp_path,filename); /* avoid side effect changes to filename */ - - if (temp_path[0] == SLASHC || (temp_path[0] && temp_path[1] == ':')) - { - if (access(temp_path,0) == 0) /* file exists */ - { - strcpy(fullpathname,temp_path); - return; - } - else - { - splitpath(temp_path ,NULL,NULL,fname,ext); - makepath(temp_path,"" ,"" ,fname,ext); - } - } - fullpathname[0] = 0; /* indicate none found */ - _searchenv(temp_path,"PATH",fullpathname); - if (fullpathname[0] != 0) /* found it! */ - { - if (strncmp(&fullpathname[2],SLASHSLASH,2) == 0) /* stupid klooge! */ - { - strcpy(&fullpathname[3],temp_path); - } - } -} -#endif - - -void notdiskmsg() -{ - stopmsg(0, - "This type may be slow using a real-disk based 'video' mode, but may not \n" - "be too bad if you have enough expanded or extended memory. Press to \n" - "abort if it appears that your disk drive is working too hard."); -} - -/* Wrapping version of putstring for long numbers */ -/* row -- pointer to row variable, internally incremented if needed */ -/* col1 -- starting column */ -/* col2 -- last column */ -/* color -- attribute (same as for putstring) */ -/* maxrow -- max number of rows to write */ -/* returns 0 if success, 1 if hit maxrow before done */ -int putstringwrap(int *row,int col1,int col2,int color,char *str,int maxrow) -{ - char save1, save2; - int length, decpt, padding, startrow, done; - done = 0; - startrow = *row; - length = (int) strlen(str); - padding = 3; /* space between col1 and decimal. */ - /* find decimal point */ - for (decpt=0; decpt < length; decpt++) - if (str[decpt] == '.') - break; - if (decpt >= length) - decpt = 0; - if (decpt < padding) - padding -= decpt; - else - padding = 0; - col1 += padding; - decpt += col1+1; /* column just past where decimal is */ - while (length > 0) - { - if (col2-col1 < length) - { - if ((*row - startrow + 1) >= maxrow) - done = 1; - else - done = 0; - save1 = str[col2-col1+1]; - save2 = str[col2-col1+2]; - if (done) - str[col2-col1+1] = '+'; - else - str[col2-col1+1] = '\\'; - str[col2-col1+2] = 0; - driver_put_string(*row,col1,color,str); - if (done == 1) - break; - str[col2-col1+1] = save1; - str[col2-col1+2] = save2; - str += col2-col1; - (*row)++; - } else - driver_put_string(*row,col1,color,str); - length -= col2-col1; - col1 = decpt; /* align with decimal */ - } - return(done); -} - -#define rad_to_deg(x) ((x)*(180.0/PI)) /* most people "think" in degrees */ -#define deg_to_rad(x) ((x)*(PI/180.0)) -/* -convert corners to center/mag -Rotation angles indicate how much the IMAGE has been rotated, not the -zoom box. Same goes for the Skew angles -*/ - -#ifdef _MSC_VER -#pragma optimize( "", off ) -#endif - -void cvtcentermag(double *Xctr, double *Yctr, LDBL *Magnification, double *Xmagfactor, double *Rotation, double *Skew) -{ - double Width, Height; - double a, b; /* bottom, left, diagonal */ - double a2, b2, c2; /* squares of above */ - double tmpx1, tmpx2, tmpy1, tmpy2, tmpa; /* temporary x, y, angle */ - - /* simple normal case first */ - if (xx3rd == xxmin && yy3rd == yymin) - { /* no rotation or skewing, but stretching is allowed */ - Width = xxmax - xxmin; - Height = yymax - yymin; - *Xctr = (xxmin + xxmax)/2.0; - *Yctr = (yymin + yymax)/2.0; - *Magnification = 2.0/Height; - *Xmagfactor = Height / (DEFAULTASPECT * Width); - *Rotation = 0.0; - *Skew = 0.0; - } - else - { - /* set up triangle ABC, having sides abc */ - /* side a = bottom, b = left, c = diagonal not containing (x3rd,y3rd) */ - tmpx1 = xxmax - xxmin; - tmpy1 = yymax - yymin; - c2 = tmpx1*tmpx1 + tmpy1*tmpy1; - - tmpx1 = xxmax - xx3rd; - tmpy1 = yymin - yy3rd; - a2 = tmpx1*tmpx1 + tmpy1*tmpy1; - a = sqrt(a2); - *Rotation = -rad_to_deg(atan2( tmpy1, tmpx1 )); /* negative for image rotation */ - - tmpx2 = xxmin - xx3rd; - tmpy2 = yymax - yy3rd; - b2 = tmpx2*tmpx2 + tmpy2*tmpy2; - b = sqrt(b2); - - tmpa = acos((a2+b2-c2)/(2*a*b)); /* save tmpa for later use */ - *Skew = 90.0 - rad_to_deg(tmpa); - - *Xctr = (xxmin + xxmax)*0.5; - *Yctr = (yymin + yymax)*0.5; - - Height = b * sin(tmpa); - - *Magnification = 2.0/Height; /* 1/(h/2) */ - *Xmagfactor = Height / (DEFAULTASPECT * a); - - /* if vector_a cross vector_b is negative */ - /* then adjust for left-hand coordinate system */ - if ( tmpx1*tmpy2 - tmpx2*tmpy1 < 0 && debugflag != 4010) - { - *Skew = -*Skew; - *Xmagfactor = -*Xmagfactor; - *Magnification = -*Magnification; - } - } - /* just to make par file look nicer */ - if (*Magnification < 0) - { - *Magnification = -*Magnification; - *Rotation += 180; - } -#ifdef DEBUG - { - double txmin, txmax, tx3rd, tymin, tymax, ty3rd; - double error; - txmin = xxmin; - txmax = xxmax; - tx3rd = xx3rd; - tymin = yymin; - tymax = yymax; - ty3rd = yy3rd; - cvtcorners(*Xctr, *Yctr, *Magnification, *Xmagfactor, *Rotation, *Skew); - error = sqr(txmin - xxmin) + - sqr(txmax - xxmax) + - sqr(tx3rd - xx3rd) + - sqr(tymin - yymin) + - sqr(tymax - yymax) + - sqr(ty3rd - yy3rd); - if (error > .001) - showcornersdbl("cvtcentermag problem"); - xxmin = txmin; - xxmax = txmax; - xx3rd = tx3rd; - yymin = tymin; - yymax = tymax; - yy3rd = ty3rd; - } -#endif - return; -} - - -/* convert center/mag to corners */ -void cvtcorners(double Xctr, double Yctr, LDBL Magnification, double Xmagfactor, double Rotation, double Skew) -{ - double x, y; - double h, w; /* half height, width */ - double tanskew, sinrot, cosrot; - - if (Xmagfactor == 0.0) - Xmagfactor = 1.0; - - h = (double)(1/Magnification); - w = h / (DEFAULTASPECT * Xmagfactor); - - if (Rotation == 0.0 && Skew == 0.0) - { /* simple, faster case */ - xx3rd = xxmin = Xctr - w; - xxmax = Xctr + w; - yy3rd = yymin = Yctr - h; - yymax = Yctr + h; - return; - } - - /* in unrotated, untranslated coordinate system */ - tanskew = tan(deg_to_rad(Skew)); - xxmin = -w + h*tanskew; - xxmax = w - h*tanskew; - xx3rd = -w - h*tanskew; - yymax = h; - yy3rd = yymin = -h; - - /* rotate coord system and then translate it */ - Rotation = deg_to_rad(Rotation); - sinrot = sin(Rotation); - cosrot = cos(Rotation); - - /* top left */ - x = xxmin * cosrot + yymax * sinrot; - y = -xxmin * sinrot + yymax * cosrot; - xxmin = x + Xctr; - yymax = y + Yctr; - - /* bottom right */ - x = xxmax * cosrot + yymin * sinrot; - y = -xxmax * sinrot + yymin * cosrot; - xxmax = x + Xctr; - yymin = y + Yctr; - - /* bottom left */ - x = xx3rd * cosrot + yy3rd * sinrot; - y = -xx3rd * sinrot + yy3rd * cosrot; - xx3rd = x + Xctr; - yy3rd = y + Yctr; - - return; -} - -/* convert corners to center/mag using bf */ -void cvtcentermagbf(bf_t Xctr, bf_t Yctr, LDBL *Magnification, double *Xmagfactor, double *Rotation, double *Skew) -{ - /* needs to be LDBL or won't work past 307 (-DBL_MIN_10_EXP) or so digits */ - LDBL Width, Height; - LDBL a, b; /* bottom, left, diagonal */ - LDBL a2, b2, c2; /* squares of above */ - LDBL tmpx1, tmpx2, tmpy=0.0, tmpy1, tmpy2 ; - double tmpa; /* temporary x, y, angle */ - bf_t bfWidth, bfHeight; - bf_t bftmpx, bftmpy; - int saved; - int signx; - - saved = save_stack(); - - /* simple normal case first */ - /* if (xx3rd == xxmin && yy3rd == yymin) */ - if (!cmp_bf(bfx3rd, bfxmin) && !cmp_bf(bfy3rd, bfymin)) - { /* no rotation or skewing, but stretching is allowed */ - bfWidth = alloc_stack(bflength+2); - bfHeight = alloc_stack(bflength+2); - /* Width = xxmax - xxmin; */ - sub_bf(bfWidth, bfxmax, bfxmin); - Width = bftofloat(bfWidth); - /* Height = yymax - yymin; */ - sub_bf(bfHeight, bfymax, bfymin); - Height = bftofloat(bfHeight); - /* *Xctr = (xxmin + xxmax)/2; */ - add_bf(Xctr, bfxmin, bfxmax); - half_a_bf(Xctr); - /* *Yctr = (yymin + yymax)/2; */ - add_bf(Yctr, bfymin, bfymax); - half_a_bf(Yctr); - *Magnification = 2/Height; - *Xmagfactor = (double)(Height / (DEFAULTASPECT * Width)); - *Rotation = 0.0; - *Skew = 0.0; - } - else - { - bftmpx = alloc_stack(bflength+2); - bftmpy = alloc_stack(bflength+2); - - /* set up triangle ABC, having sides abc */ - /* side a = bottom, b = left, c = diagonal not containing (x3rd,y3rd) */ - /* IMPORTANT: convert from bf AFTER subtracting */ - - /* tmpx = xxmax - xxmin; */ - sub_bf(bftmpx, bfxmax, bfxmin); - tmpx1 = bftofloat(bftmpx); - /* tmpy = yymax - yymin; */ - sub_bf(bftmpy, bfymax, bfymin); - tmpy1 = bftofloat(bftmpy); - c2 = tmpx1*tmpx1 + tmpy1*tmpy1; - - /* tmpx = xxmax - xx3rd; */ - sub_bf(bftmpx, bfxmax, bfx3rd); - tmpx1 = bftofloat(bftmpx); - - /* tmpy = yymin - yy3rd; */ - sub_bf(bftmpy, bfymin, bfy3rd); - tmpy1 = bftofloat(bftmpy); - a2 = tmpx1*tmpx1 + tmpy1*tmpy1; - a = sqrtl(a2); - - /* divide tmpx and tmpy by |tmpx| so that double version of atan2() can be used */ - /* atan2() only depends on the ratio, this puts it in double's range */ - signx = sign(tmpx1); - if (signx) - tmpy = tmpy1/tmpx1 * signx; /* tmpy = tmpy / |tmpx| */ - *Rotation = (double)(-rad_to_deg(atan2( (double)tmpy, signx ))); /* negative for image rotation */ - - /* tmpx = xxmin - xx3rd; */ - sub_bf(bftmpx, bfxmin, bfx3rd); - tmpx2 = bftofloat(bftmpx); - /* tmpy = yymax - yy3rd; */ - sub_bf(bftmpy, bfymax, bfy3rd); - tmpy2 = bftofloat(bftmpy); - b2 = tmpx2*tmpx2 + tmpy2*tmpy2; - b = sqrtl(b2); - - tmpa = acos((double)((a2+b2-c2)/(2*a*b))); /* save tmpa for later use */ - *Skew = 90 - rad_to_deg(tmpa); - - /* these are the only two variables that must use big precision */ - /* *Xctr = (xxmin + xxmax)/2; */ - add_bf(Xctr, bfxmin, bfxmax); - half_a_bf(Xctr); - /* *Yctr = (yymin + yymax)/2; */ - add_bf(Yctr, bfymin, bfymax); - half_a_bf(Yctr); - - Height = b * sin(tmpa); - *Magnification = 2/Height; /* 1/(h/2) */ - *Xmagfactor = (double)(Height / (DEFAULTASPECT * a)); - - /* if vector_a cross vector_b is negative */ - /* then adjust for left-hand coordinate system */ - if ( tmpx1*tmpy2 - tmpx2*tmpy1 < 0 && debugflag != 4010) - { - *Skew = -*Skew; - *Xmagfactor = -*Xmagfactor; - *Magnification = -*Magnification; - } - } - if (*Magnification < 0) - { - *Magnification = -*Magnification; - *Rotation += 180; - } - restore_stack(saved); - return; -} - - -/* convert center/mag to corners using bf */ -void cvtcornersbf(bf_t Xctr, bf_t Yctr, LDBL Magnification, double Xmagfactor, double Rotation, double Skew) -{ - LDBL x, y; - LDBL h, w; /* half height, width */ - LDBL xmin, ymin, xmax, ymax, x3rd, y3rd; - double tanskew, sinrot, cosrot; - bf_t bfh, bfw; - bf_t bftmp; - int saved; - - saved = save_stack(); - bfh = alloc_stack(bflength+2); - bfw = alloc_stack(bflength+2); - - if (Xmagfactor == 0.0) - Xmagfactor = 1.0; - - h = 1/Magnification; - floattobf(bfh, h); - w = h / (DEFAULTASPECT * Xmagfactor); - floattobf(bfw, w); - - if (Rotation == 0.0 && Skew == 0.0) - { /* simple, faster case */ - /* xx3rd = xxmin = Xctr - w; */ - sub_bf(bfxmin, Xctr, bfw); - copy_bf(bfx3rd, bfxmin); - /* xxmax = Xctr + w; */ - add_bf(bfxmax, Xctr, bfw); - /* yy3rd = yymin = Yctr - h; */ - sub_bf(bfymin, Yctr, bfh); - copy_bf(bfy3rd, bfymin); - /* yymax = Yctr + h; */ - add_bf(bfymax, Yctr, bfh); - restore_stack(saved); - return; - } - - bftmp = alloc_stack(bflength+2); - /* in unrotated, untranslated coordinate system */ - tanskew = tan(deg_to_rad(Skew)); - xmin = -w + h*tanskew; - xmax = w - h*tanskew; - x3rd = -w - h*tanskew; - ymax = h; - y3rd = ymin = -h; - - /* rotate coord system and then translate it */ - Rotation = deg_to_rad(Rotation); - sinrot = sin(Rotation); - cosrot = cos(Rotation); - - /* top left */ - x = xmin * cosrot + ymax * sinrot; - y = -xmin * sinrot + ymax * cosrot; - /* xxmin = x + Xctr; */ - floattobf(bftmp, x); - add_bf(bfxmin, bftmp, Xctr); - /* yymax = y + Yctr; */ - floattobf(bftmp, y); - add_bf(bfymax, bftmp, Yctr); - - /* bottom right */ - x = xmax * cosrot + ymin * sinrot; - y = -xmax * sinrot + ymin * cosrot; - /* xxmax = x + Xctr; */ - floattobf(bftmp, x); - add_bf(bfxmax, bftmp, Xctr); - /* yymin = y + Yctr; */ - floattobf(bftmp, y); - add_bf(bfymin, bftmp, Yctr); - - /* bottom left */ - x = x3rd * cosrot + y3rd * sinrot; - y = -x3rd * sinrot + y3rd * cosrot; - /* xx3rd = x + Xctr; */ - floattobf(bftmp, x); - add_bf(bfx3rd, bftmp, Xctr); - /* yy3rd = y + Yctr; */ - floattobf(bftmp, y); - add_bf(bfy3rd, bftmp, Yctr); - - restore_stack(saved); - return; -} - -#ifdef _MSC_VER -#pragma optimize( "", on ) -#endif - -void updatesavename(char *filename) /* go to the next file name */ -{ - char *save, *hold; - char drive[FILE_MAX_DRIVE]; - char dir[FILE_MAX_DIR]; - char fname[FILE_MAX_FNAME]; - char ext[FILE_MAX_EXT]; - - splitpath(filename ,drive,dir,fname,ext); - - hold = fname + strlen(fname) - 1; /* start at the end */ - while (hold >= fname && (*hold == ' ' || isdigit(*hold))) /* skip backwards */ - hold--; - hold++; /* recover first digit */ - while (*hold == '0') /* skip leading zeros */ - hold++; - save = hold; - while (*save) { /* check for all nines */ - if (*save != '9') - break; - save++; - } - if (!*save) /* if the whole thing is nines then back */ - save = hold - 1; /* up one place. Note that this will eat */ - /* your last letter if you go to far. */ - else - save = hold; - sprintf(save,"%ld",atol(hold)+1); /* increment the number */ - makepath(filename,drive,dir,fname,ext); -} - -int check_writefile(char *name,char *ext) -{ - /* after v16 release, change encoder.c to also use this routine */ - char openfile[FILE_MAX_DIR]; - char opentype[20]; - /* int i; */ - char *period; -nextname: - strcpy(openfile,name); - strcpy(opentype,ext); -#if 0 - for (i = 0; i < (int)strlen(openfile); i++) - if (openfile[i] == '.') { - strcpy(opentype,&openfile[i]); - openfile[i] = 0; - } -#endif - if ((period = has_ext(openfile)) != NULL) - { - strcpy(opentype,period); - *period = 0; - } - strcat(openfile,opentype); - if (access(openfile,0) != 0) /* file doesn't exist */ - { - strcpy(name,openfile); - return 0; - } - /* file already exists */ - if (fract_overwrite == 0) { - updatesavename(name); - goto nextname; - } - return 1; -} - -/* ('check_key()' was moved to FRACTINT.C for MSC7-overlay speed purposes) */ -/* ('timer()' was moved to FRACTINT.C for MSC7-overlay speed purposes) */ - -BYTE trigndx[] = {SIN,SQR,SINH,COSH}; -#if !defined(XFRACT) -void (*ltrig0)(void) = lStkSin; -void (*ltrig1)(void) = lStkSqr; -void (*ltrig2)(void) = lStkSinh; -void (*ltrig3)(void) = lStkCosh; -void (*mtrig0)(void) = mStkSin; -void (*mtrig1)(void) = mStkSqr; -void (*mtrig2)(void) = mStkSinh; -void (*mtrig3)(void) = mStkCosh; -#endif -void (*dtrig0)(void) = dStkSin; -void (*dtrig1)(void) = dStkSqr; -void (*dtrig2)(void) = dStkSinh; -void (*dtrig3)(void) = dStkCosh; - -/* struct trig_funct_lst trigfn[] was moved to prompts1.c */ - -void showtrig(char *buf) /* return display form of active trig functions */ -{ - char tmpbuf[30]; - *buf = 0; /* null string if none */ - trigdetails(tmpbuf); - if (tmpbuf[0]) - sprintf(buf," function=%s",tmpbuf); -} - -static void trigdetails(char *buf) -{ - int i, numfn; - char tmpbuf[20]; - if (fractype==JULIBROT || fractype==JULIBROTFP) - numfn = (fractalspecific[neworbittype].flags >> 6) & 7; - else - numfn = (curfractalspecific->flags >> 6) & 7; - if (curfractalspecific == &fractalspecific[FORMULA] || - curfractalspecific == &fractalspecific[FFORMULA] ) - numfn = maxfn; - *buf = 0; /* null string if none */ - if (numfn>0) { - strcpy(buf,trigfn[trigndx[0]].name); - i = 0; - while (++i < numfn) { - sprintf(tmpbuf,"/%s",trigfn[trigndx[i]].name); - strcat(buf,tmpbuf); - } - } -} - -/* set array of trig function indices according to "function=" command */ -int set_trig_array(int k, char *name) -{ - char trigname[10]; - int i; - char *slash; - strncpy(trigname,name,6); - trigname[6] = 0; /* safety first */ - - if ((slash = strchr(trigname,'/')) != NULL) - *slash = 0; - - strlwr(trigname); - - for (i=0; i= 0) - { - sprintf(msg,"%3ld:%02ld:%02ld.%02ld", ctime/360000L, - (ctime%360000L)/6000, (ctime%6000)/100, ctime%100); - } - else - strcpy(msg, "A long time! (> 24.855 days)"); -} - -static void show_str_var(char *name, char *var, int *row, char *msg) -{ - if (var == NULL) - return; - if (*var != 0) - { - sprintf(msg,"%s=%s",name,var); - driver_put_string((*row)++,2,C_GENERAL_HI,msg); - } -} - -static void -write_row(int row, const char *format, ...) -{ - char text[78] = { 0 }; - va_list args; - - va_start(args, format); - _vsnprintf(text, NUM_OF(text), format, args); - va_end(args); - - driver_put_string(row, 2, C_GENERAL_HI, text); -} - -int tab_display_2(char *msg) -{ - extern long maxptr, maxstack, startstack; - int row, key = 0; - - helptitle(); - driver_set_attr(1, 0, C_GENERAL_MED, 24*80); /* init rest to background */ - - row = 1; - putstringcenter(row++, 0, 80, C_PROMPT_HI, "Top Secret Developer's Screen"); - - write_row(++row, "Version %d patch %d", g_release, g_patch_level); - write_row(++row, "%ld of %ld bignum memory used", maxptr, maxstack); - write_row(++row, " %ld used for bignum globals", startstack); - write_row(++row, " %ld stack used == %ld variables of length %d", - maxptr-startstack, (long)((maxptr-startstack)/(rbflength+2)), rbflength+2); - if (bf_math) - { - write_row(++row, "intlength %-d bflength %-d ", intlength, bflength); - } - row++; - show_str_var("tempdir", tempdir, &row, msg); - show_str_var("workdir", workdir, &row, msg); -// show_str_var("printfile", PrintName, &row, msg); - show_str_var("filename", readname, &row, msg); - show_str_var("formulafile", FormFileName, &row, msg); - show_str_var("savename", savename, &row, msg); - show_str_var("parmfile", CommandFile, &row, msg); - show_str_var("ifsfile", IFSFileName, &row, msg); - show_str_var("autokeyname", autoname, &row, msg); - show_str_var("lightname", light_name, &row, msg); - show_str_var("map", MAP_name, &row, msg); - write_row(row++, "Sizeof fractalspecific array %d", - num_fractal_types*(int)sizeof(struct fractalspecificstuff)); - write_row(row++, "calc_status %d pixel [%d, %d]", calc_status, col, row); - if (fractype == FORMULA || fractype == FFORMULA) - { - write_row(row++, "total_formula_mem %ld Max_Ops (posp) %u Max_Args (vsp) %u", - total_formula_mem, posp, vsp); - write_row(row++, " Store ptr %d Loadptr %d Max_Ops var %u Max_Args var %u LastInitOp %d", - StoPtr, LodPtr, Max_Ops, Max_Args, LastInitOp); - } - else if (rhombus_stack[0]) - { - write_row(row++, "SOI Recursion %d stack free %d %d %d %d %d %d %d %d %d %d", - max_rhombus_depth+1, - rhombus_stack[0], rhombus_stack[1], rhombus_stack[2], - rhombus_stack[3], rhombus_stack[4], rhombus_stack[5], - rhombus_stack[6], rhombus_stack[7], rhombus_stack[8], - rhombus_stack[9]); - } - -/* - write_row(row++, "xdots %d ydots %d sxdots %d sydots %d", xdots, ydots, sxdots, sydots); -*/ - write_row(row++, "%dx%d dm=%d %s (%s)", xdots, ydots, dotmode, - g_driver->name, g_driver->description); - write_row(row++, "xxstart %d xxstop %d yystart %d yystop %d %s uses_ismand %d", - xxstart, xxstop, yystart, yystop, -#if !defined(XFRACT) && !defined(_WIN32) - curfractalspecific->orbitcalc == fFormula ? "fast parser" : -#endif - curfractalspecific->orbitcalc == Formula ? "slow parser" : - curfractalspecific->orbitcalc == BadFormula ? "bad formula" : - "", uses_ismand); -/* - write_row(row++, "ixstart %d ixstop %d iystart %d iystop %d bitshift %d", - ixstart, ixstop, iystart, iystop, bitshift); -*/ - write_row(row++, "minstackavail %d llimit2 %ld use_grid %d", - minstackavail, llimit2, use_grid); - putstringcenter(24, 0, 80, C_GENERAL_LO, "Press Esc to continue, Backspace for first screen"); - *msg = 0; - - /* display keycodes while waiting for ESC, BACKSPACE or TAB */ - while ((key != FIK_ESC) && (key != FIK_BACKSPACE) && (key != FIK_TAB)) - { - driver_put_string(row, 2, C_GENERAL_HI, msg); - key = getakeynohelp(); - sprintf(msg, "%d (0x%04x) ", key, key); - } - return (key != FIK_ESC); -} - -int tab_display() /* display the status of the current image */ -{ - int s_row, i, j, addrow = 0; - double Xctr, Yctr; - LDBL Magnification; - double Xmagfactor, Rotation, Skew; - bf_t bfXctr = NULL, bfYctr = NULL; - char msg[350]; - char *msgptr; - int key; - int saved=0; - int dec; - int k; - int hasformparam = 0; - - if (calc_status < CALCSTAT_PARAMS_CHANGED) /* no active fractal image */ - { - return 0; /* (no TAB on the credits screen) */ - } - if (calc_status == CALCSTAT_IN_PROGRESS) /* next assumes CLK_TCK is 10^n, n>=2 */ - { - calctime += (clock_ticks() - timer_start) / (CLK_TCK/100); - } - driver_stack_screen(); - if (bf_math) - { - saved = save_stack(); - bfXctr = alloc_stack(bflength+2); - bfYctr = alloc_stack(bflength+2); - } - if (fractype == FORMULA || fractype == FFORMULA) - { - for (i = 0; i < MAXPARAMS; i += 2) - { - if (!paramnotused(i)) - { - hasformparam++; - } - } - } - -top: - k = 0; /* initialize here so parameter line displays correctly on return - from control-tab */ - helptitle(); - driver_set_attr(1, 0, C_GENERAL_MED, 24*80); /* init rest to background */ - s_row = 2; - driver_put_string(s_row, 2, C_GENERAL_MED, "Fractal type:"); - if (display3d > 0) - { - driver_put_string(s_row, 16, C_GENERAL_HI, "3D Transform"); - } - else - { - driver_put_string(s_row, 16, C_GENERAL_HI, - curfractalspecific->name[0] == '*' ? - &curfractalspecific->name[1] : curfractalspecific->name); - i = 0; - if (fractype == FORMULA || fractype == FFORMULA) - { - driver_put_string(s_row+1, 3, C_GENERAL_MED, "Item name:"); - driver_put_string(s_row+1, 16, C_GENERAL_HI, FormName); - i = (int) strlen(FormName)+1; - driver_put_string(s_row+2, 3, C_GENERAL_MED, "Item file:"); - if ((int) strlen(FormFileName) >= 29) - { - addrow = 1; - } - driver_put_string(s_row+2+addrow, 16, C_GENERAL_HI, FormFileName); - } - trigdetails(msg); - driver_put_string(s_row+1, 16+i, C_GENERAL_HI, msg); - if (fractype == LSYSTEM) - { - driver_put_string(s_row+1, 3, C_GENERAL_MED, "Item name:"); - driver_put_string(s_row+1, 16, C_GENERAL_HI, LName); - driver_put_string(s_row+2, 3, C_GENERAL_MED, "Item file:"); - if ((int) strlen(LFileName) >= 28) - { - addrow = 1; - } - driver_put_string(s_row+2+addrow, 16, C_GENERAL_HI, LFileName); - } - if (fractype == IFS || fractype == IFS3D) - { - driver_put_string(s_row+1, 3, C_GENERAL_MED, "Item name:"); - driver_put_string(s_row+1, 16, C_GENERAL_HI, IFSName); - driver_put_string(s_row+2, 3, C_GENERAL_MED, "Item file:"); - if ((int) strlen(IFSFileName) >= 28) - { - addrow = 1; - } - driver_put_string(s_row+2+addrow, 16, C_GENERAL_HI, IFSFileName); - } - } - - switch (calc_status) - { - case 0: msgptr = "Parms chgd since generated"; - break; - case 1: msgptr = "Still being generated"; - break; - case 2: msgptr = "Interrupted, resumable"; - break; - case 3: msgptr = "Interrupted, non-resumable"; - break; - case 4: msgptr = "Image completed"; - break; - default: msgptr = ""; - } - driver_put_string(s_row, 45, C_GENERAL_HI, msgptr); - if (initbatch && calc_status != CALCSTAT_PARAMS_CHANGED) - { - driver_put_string(-1, -1, C_GENERAL_HI, " (Batch mode)"); - } - - if (helpmode == HELPCYCLING) - { - driver_put_string(s_row+1, 45, C_GENERAL_HI, "You are in color-cycling mode"); - } - ++s_row; - /* if (bf_math == 0) */ - ++s_row; - - i = j = 0; - if (display3d > 0) - { - if (usr_floatflag) - { - j = 1; - } - } - else if (floatflag) - { - j = (usr_floatflag) ? 1 : 2; - } - - if (bf_math == 0) - { - if (j) - { - driver_put_string(s_row, 45, C_GENERAL_HI, "Floating-point"); - driver_put_string(-1, -1, C_GENERAL_HI, - (j == 1) ? " flag is activated" : " in use (required)"); - } - else - { - driver_put_string(s_row, 45, C_GENERAL_HI, "Integer math is in use"); - } - } - else - { - sprintf(msg, "(%-d decimals)", decimals /*getprecbf(CURRENTREZ)*/); - driver_put_string(s_row, 45, C_GENERAL_HI, "Arbitrary precision "); - driver_put_string(-1, -1, C_GENERAL_HI, msg); - } - i = 1; - - s_row += i; - - if (calc_status == CALCSTAT_IN_PROGRESS || calc_status == CALCSTAT_RESUMABLE) - { - if (curfractalspecific->flags&NORESUME) - { - driver_put_string(s_row++, 2, C_GENERAL_HI, - "Note: can't resume this type after interrupts other than and "); - } - } - s_row += addrow; - driver_put_string(s_row, 2, C_GENERAL_MED, "Savename: "); - driver_put_string(s_row, -1, C_GENERAL_HI, savename); - - ++s_row; - - if (got_status >= 0 && (calc_status == CALCSTAT_IN_PROGRESS || calc_status == CALCSTAT_RESUMABLE)) - { - switch (got_status) - { - case 0: - sprintf(msg, "%d Pass Mode", totpasses); - driver_put_string(s_row, 2, C_GENERAL_HI, msg); - if (usr_stdcalcmode == '3') - { - driver_put_string(s_row, -1, C_GENERAL_HI, " (threepass)"); - } - break; - case 1: - driver_put_string(s_row, 2, C_GENERAL_HI, "Solid Guessing"); - if (usr_stdcalcmode == '3') - { - driver_put_string(s_row, -1, C_GENERAL_HI, " (threepass)"); - } - break; - case 2: - driver_put_string(s_row, 2, C_GENERAL_HI, "Boundary Tracing"); - break; - case 3: - sprintf(msg, "Processing row %d (of %d) of input image", currow, fileydots); - driver_put_string(s_row, 2, C_GENERAL_HI, msg); - break; - case 4: - driver_put_string(s_row, 2, C_GENERAL_HI, "Tesseral"); - break; - case 5: - driver_put_string(s_row, 2, C_GENERAL_HI, "Diffusion"); - break; - case 6: - driver_put_string(s_row, 2, C_GENERAL_HI, "Orbits"); - break; - } - ++s_row; - if (got_status == 5 ) - { - sprintf(msg, "%2.2f%% done, counter at %lu of %lu (%u bits)", - (100.0 * dif_counter)/dif_limit, - dif_counter, dif_limit, bits); - driver_put_string(s_row, 2, C_GENERAL_MED, msg); - ++s_row; - } - else - if (got_status != 3) - { - sprintf(msg, "Working on block (y, x) [%d, %d]...[%d, %d], ", - yystart, xxstart, yystop, xxstop); - driver_put_string(s_row, 2, C_GENERAL_MED, msg); - if (got_status == 2 || got_status == 4) /* btm or tesseral */ - { - driver_put_string(-1, -1, C_GENERAL_MED, "at "); - sprintf(msg, "[%d, %d]", currow, curcol); - driver_put_string(-1, -1, C_GENERAL_HI, msg); - } - else - { - if (totpasses > 1) - { - driver_put_string(-1, -1, C_GENERAL_MED, "pass "); - sprintf(msg, "%d", curpass); - driver_put_string(-1, -1, C_GENERAL_HI, msg); - driver_put_string(-1, -1, C_GENERAL_MED, " of "); - sprintf(msg, "%d", totpasses); - driver_put_string(-1, -1, C_GENERAL_HI, msg); - driver_put_string(-1, -1, C_GENERAL_MED, ", "); - } - driver_put_string(-1, -1, C_GENERAL_MED, "at row "); - sprintf(msg, "%d", currow); - driver_put_string(-1, -1, C_GENERAL_HI, msg); - driver_put_string(-1, -1, C_GENERAL_MED, " col "); - sprintf(msg, "%d", col); - driver_put_string(-1, -1, C_GENERAL_HI, msg); - } - ++s_row; - } - } - driver_put_string(s_row, 2, C_GENERAL_MED, "Calculation time:"); - get_calculation_time(msg, calctime); - driver_put_string(-1, -1, C_GENERAL_HI, msg); - if ((got_status == 5) && (calc_status == CALCSTAT_IN_PROGRESS)) /* estimate total time */ - { - driver_put_string(-1, -1, C_GENERAL_MED, " estimated total time: "); - get_calculation_time( msg, (long)(calctime*((dif_limit*1.0)/dif_counter)) ); - driver_put_string(-1, -1, C_GENERAL_HI, msg); - } - - if ((curfractalspecific->flags&INFCALC) && (coloriter != 0)) - { - driver_put_string(s_row, -1, C_GENERAL_MED, " 1000's of points:"); - sprintf(msg, " %ld of %ld", coloriter-2, maxct); - driver_put_string(s_row, -1, C_GENERAL_HI, msg); - } - - ++s_row; - if (bf_math == 0) - { - ++s_row; - } - _snprintf(msg, NUM_OF(msg), "Driver: %s, %s", g_driver->name, g_driver->description); - driver_put_string(s_row++, 2, C_GENERAL_MED, msg); - if (g_video_entry.xdots && bf_math == 0) - { - sprintf(msg, "Video: %dx%dx%d %s %s", - g_video_entry.xdots, g_video_entry.ydots, g_video_entry.colors, - g_video_entry.name, g_video_entry.comment); - driver_put_string(s_row++, 2, C_GENERAL_MED, msg); - } - if (!(curfractalspecific->flags&NOZOOM)) - { - adjust_corner(); /* make bottom left exact if very near exact */ - if (bf_math) - { - int truncate, truncaterow; - dec = min(320, decimals); - adjust_cornerbf(); /* make bottom left exact if very near exact */ - cvtcentermagbf(bfXctr, bfYctr, &Magnification, &Xmagfactor, &Rotation, &Skew); - /* find alignment information */ - msg[0] = 0; - truncate = 0; - if (dec < decimals) - { - truncate = 1; - } - truncaterow = row; - driver_put_string(++s_row, 2, C_GENERAL_MED, "Ctr"); - driver_put_string(s_row, 8, C_GENERAL_MED, "x"); - bftostr(msg, dec, bfXctr); - if (putstringwrap(&s_row, 10, 78, C_GENERAL_HI, msg, 5) == 1) - { - truncate = 1; - } - driver_put_string(++s_row, 8, C_GENERAL_MED, "y"); - bftostr(msg, dec, bfYctr); - if (putstringwrap(&s_row, 10, 78, C_GENERAL_HI, msg, 5) == 1 || truncate) - { - driver_put_string(truncaterow, 2, C_GENERAL_MED, "(Center values shown truncated to 320 decimals)"); - } - driver_put_string(++s_row, 2, C_GENERAL_MED, "Mag"); -#ifdef USE_LONG_DOUBLE - sprintf(msg, "%10.8Le", Magnification); -#else - sprintf(msg, "%10.8le", Magnification); -#endif - driver_put_string(-1, 11, C_GENERAL_HI, msg); - driver_put_string(++s_row, 2, C_GENERAL_MED, "X-Mag-Factor"); - sprintf(msg, "%11.4f ", Xmagfactor); - driver_put_string(-1, -1, C_GENERAL_HI, msg); - driver_put_string(-1, -1, C_GENERAL_MED, "Rotation"); - sprintf(msg, "%9.3f ", Rotation); - driver_put_string(-1, -1, C_GENERAL_HI, msg); - driver_put_string(-1, -1, C_GENERAL_MED, "Skew"); - sprintf(msg, "%9.3f", Skew); - driver_put_string(-1, -1, C_GENERAL_HI, msg); - } - else /* bf != 1 */ - { - driver_put_string(s_row, 2, C_GENERAL_MED, "Corners: X Y"); - driver_put_string(++s_row, 3, C_GENERAL_MED, "Top-l"); - sprintf(msg, "%20.16f %20.16f", xxmin, yymax); - driver_put_string(-1, 17, C_GENERAL_HI, msg); - driver_put_string(++s_row, 3, C_GENERAL_MED, "Bot-r"); - sprintf(msg, "%20.16f %20.16f", xxmax, yymin); - driver_put_string(-1, 17, C_GENERAL_HI, msg); - - if (xxmin != xx3rd || yymin != yy3rd) - { - driver_put_string(++s_row, 3, C_GENERAL_MED, "Bot-l"); - sprintf(msg, "%20.16f %20.16f", xx3rd, yy3rd); - driver_put_string(-1, 17, C_GENERAL_HI, msg); - } - cvtcentermag(&Xctr, &Yctr, &Magnification, &Xmagfactor, &Rotation, &Skew); - driver_put_string(s_row += 2, 2, C_GENERAL_MED, "Ctr"); - sprintf(msg, "%20.16f %20.16f ", Xctr, Yctr); - driver_put_string(-1, -1, C_GENERAL_HI, msg); - driver_put_string(-1, -1, C_GENERAL_MED, "Mag"); -#ifdef USE_LONG_DOUBLE - sprintf(msg, " %10.8Le", Magnification); -#else - sprintf(msg, " %10.8le", Magnification); -#endif - driver_put_string(-1, -1, C_GENERAL_HI, msg); - driver_put_string(++s_row, 2, C_GENERAL_MED, "X-Mag-Factor"); - sprintf(msg, "%11.4f ", Xmagfactor); - driver_put_string(-1, -1, C_GENERAL_HI, msg); - driver_put_string(-1, -1, C_GENERAL_MED, "Rotation"); - sprintf(msg, "%9.3f ", Rotation); - driver_put_string(-1, -1, C_GENERAL_HI, msg); - driver_put_string(-1, -1, C_GENERAL_MED, "Skew"); - sprintf(msg, "%9.3f", Skew); - driver_put_string(-1, -1, C_GENERAL_HI, msg); - } - } - - if (typehasparm(fractype, 0, msg) || hasformparam) - { - for (i = 0; i < MAXPARAMS; i++) - { - int col; - char p[50]; - if (typehasparm(fractype, i, p)) - { - if (k%4 == 0) - { - s_row++; - col = 9; - } - else - col = -1; - if (k == 0) /* only true with first displayed parameter */ - driver_put_string(++s_row, 2, C_GENERAL_MED, "Params "); - sprintf(msg, "%3d: ", i+1); - driver_put_string(s_row, col, C_GENERAL_MED, msg); - if (*p == '+') - sprintf(msg, "%-12d", (int)param[i]); - else if (*p == '#') - sprintf(msg, "%-12lu", (U32)param[i]); - else - sprintf(msg, "%-12.9f", param[i]); - driver_put_string(-1, -1, C_GENERAL_HI, msg); - k++; - } - } - } - driver_put_string(s_row += 2, 2, C_GENERAL_MED, "Current (Max) Iteration: "); - sprintf(msg, "%ld (%ld)", coloriter, maxit); - driver_put_string(-1, -1, C_GENERAL_HI, msg); - driver_put_string(-1, -1, C_GENERAL_MED, " Effective bailout: "); - sprintf(msg, "%f", rqlim); - driver_put_string(-1, -1, C_GENERAL_HI, msg); - - if (fractype == PLASMA || fractype == ANT || fractype == CELLULAR) - { - driver_put_string(++s_row, 2, C_GENERAL_MED, "Current 'rseed': "); - sprintf(msg, "%d", rseed); - driver_put_string(-1, -1, C_GENERAL_HI, msg); - } - - if (invert) - { - driver_put_string(++s_row, 2, C_GENERAL_MED, "Inversion radius: "); - sprintf(msg, "%12.9f", f_radius); - driver_put_string(-1, -1, C_GENERAL_HI, msg); - driver_put_string(-1, -1, C_GENERAL_MED, " xcenter: "); - sprintf(msg, "%12.9f", f_xcenter); - driver_put_string(-1, -1, C_GENERAL_HI, msg); - driver_put_string(-1, -1, C_GENERAL_MED, " ycenter: "); - sprintf(msg, "%12.9f", f_ycenter); - driver_put_string(-1, -1, C_GENERAL_HI, msg); - } - - if ((s_row += 2) < 23) - { - ++s_row; - } - /*waitforkey:*/ - putstringcenter(/*s_row*/24, 0, 80, C_GENERAL_LO, spressanykey); - driver_hide_text_cursor(); -#ifdef XFRACT - while (driver_key_pressed()) - { - driver_get_key(); - } -#endif - key = getakeynohelp(); - if (key == FIK_F6) - { - driver_stack_screen(); - area(); - driver_unstack_screen(); - goto top; - } - else if (key == FIK_CTL_TAB || key == FIK_SHF_TAB || key == FIK_F7) - { - if (tab_display_2(msg)) - { - goto top; - } - } - driver_unstack_screen(); - timer_start = clock_ticks(); /* tab display was "time out" */ - if (bf_math) - { - restore_stack(saved); - } - return 0; -} - -static void area(void) -{ - /* apologies to UNIX folks, we PC guys have to save near space */ - char *msg; - int x,y; - char buf[160]; - long cnt=0; - if (inside<0) { - stopmsg(0, "Need solid inside to compute area"); - return; - } - for (y=0;y0 && outside<0 && maxit>inside) { - msg = "Warning: inside may not be unique\n"; - } else { - msg = ""; - } - sprintf(buf,"%s%ld inside pixels of %ld%s%f", - msg,cnt,(long)xdots*(long)ydots,". Total area ", - cnt/((float)xdots*(float)ydots)*(xxmax-xxmin)*(yymax-yymin)); - stopmsg(STOPMSG_NO_BUZZER,buf); -} - -int endswithslash(char *fl) -{ - int len; - len = (int) strlen(fl); - if (len) - if (fl[--len] == SLASHC) - return(1); - return(0); -} - -/* --------------------------------------------------------------------- */ -static char seps[] = {"' ','\t',\n',\r'"}; -char *get_ifs_token(char *buf,FILE *ifsfile) -{ - char *bufptr; - while (1) - { - if (file_gets(buf,200,ifsfile) < 0) - return(NULL); - else - { - if ((bufptr = strchr(buf,';')) != NULL) /* use ';' as comment to eol */ - *bufptr = 0; - if ((bufptr = strtok(buf, seps)) != NULL) - return(bufptr); - } - } -} - -char insufficient_ifs_mem[]={"Insufficient memory for IFS"}; -int numaffine; -int ifsload() /* read in IFS parameters */ -{ - int i; - FILE *ifsfile; - char buf[201]; - char *bufptr; - int ret,rowsize; - - if (ifs_defn) { /* release prior parms */ - free((char *)ifs_defn); - ifs_defn = NULL; - } - - ifs_type = 0; - rowsize = IFSPARM; - if (find_file_item(IFSFileName,IFSName,&ifsfile, 3) < 0) - return(-1); - - file_gets(buf,200,ifsfile); - if ((bufptr = strchr(buf,';')) != NULL) /* use ';' as comment to eol */ - *bufptr = 0; - - strlwr(buf); - bufptr = &buf[0]; - while (*bufptr) { - if (strncmp(bufptr,"(3d)",4) == 0) { - ifs_type = 1; - rowsize = IFS3DPARM; - } - ++bufptr; - } - - for (i = 0; i < (NUMIFS+1)*IFS3DPARM; ++i) - ((float *)tstack)[i] = 0; - i = ret = 0; - bufptr = get_ifs_token(buf,ifsfile); - while (bufptr != NULL) - { - if (sscanf(bufptr," %f ",&((float *)tstack)[i]) != 1) - break ; - if (++i >= NUMIFS*rowsize) - { - stopmsg(0, "IFS definition has too many lines"); - ret = -1; - break; - } - bufptr = strtok( NULL, seps ); - if (bufptr==NULL) - { - bufptr = get_ifs_token(buf,ifsfile); - if (bufptr == NULL) - { - ret = -1; - break; - } - } - if (ret == -1) - break; - if (*bufptr == '}') - break; - } - - if ((i % rowsize) != 0 || *bufptr != '}') { - stopmsg(0, "invalid IFS definition"); - ret = -1; - } - if (i == 0 && ret == 0) { - stopmsg(0, "Empty IFS definition"); - ret = -1; - } - fclose(ifsfile); - - if (ret == 0) { - numaffine = i/rowsize; - if ((ifs_defn = (float *)malloc( - (long)((NUMIFS+1)*IFS3DPARM*sizeof(float)))) == NULL) { - stopmsg(0,insufficient_ifs_mem); - ret = -1; - } - else - for (i = 0; i < (NUMIFS+1)*IFS3DPARM; ++i) - ifs_defn[i] = ((float *)tstack)[i]; - } - return(ret); -} -/* TW 5-31-94 - added search of current directory for entry files if - entry item not found */ - -int find_file_item(char *filename,char *itemname,FILE **fileptr, int itemtype) -{ - FILE *infile=NULL; - int found = 0; - char parsearchname[ITEMNAMELEN + 6]; - char drive[FILE_MAX_DRIVE]; - char dir[FILE_MAX_DIR]; - char fname[FILE_MAX_FNAME]; - char ext[FILE_MAX_EXT]; - char fullpath[FILE_MAX_PATH]; - char defaultextension[5]; - - - splitpath(filename,drive,dir,fname,ext); - makepath(fullpath,"","",fname,ext); - if (stricmp(filename, CommandFile)) { - if ((infile=fopen(filename, "rb")) != NULL) { - if (scan_entries(infile, NULL, itemname) == -1) { - found = 1; - } - else { - fclose(infile); - infile = NULL; - } - } - - if (!found && checkcurdir) { - makepath(fullpath,"",DOTSLASH,fname,ext); - if ((infile=fopen(fullpath, "rb")) != NULL) { - if (scan_entries(infile, NULL, itemname) == -1) { - strcpy(filename, fullpath); - found = 1; - } - else { - fclose(infile); - infile = NULL; - } - } - } - } - - switch (itemtype) { - case 1: - strcpy(parsearchname, "frm:"); - strcat(parsearchname, itemname); - parsearchname[ITEMNAMELEN + 5] = (char) 0; /*safety*/ - strcpy(defaultextension, ".frm"); - splitpath(searchfor.frm,drive,dir,NULL,NULL); - break; - case 2: - strcpy(parsearchname, "lsys:"); - strcat(parsearchname, itemname); - parsearchname[ITEMNAMELEN + 5] = (char) 0; /*safety*/ - strcpy(defaultextension, ".l"); - splitpath(searchfor.lsys,drive,dir,NULL,NULL); - break; - case 3: - strcpy(parsearchname, "ifs:"); - strcat(parsearchname, itemname); - parsearchname[ITEMNAMELEN + 5] = (char) 0; /*safety*/ - strcpy(defaultextension, ".ifs"); - splitpath(searchfor.ifs,drive,dir,NULL,NULL); - break; - default: - strcpy(parsearchname, itemname); - parsearchname[ITEMNAMELEN + 5] = (char) 0; /*safety*/ - strcpy(defaultextension, ".par"); - splitpath(searchfor.par,drive,dir,NULL,NULL); - break; - } - - if (!found) { - if ((infile=fopen(CommandFile, "rb")) != NULL) { - if (scan_entries(infile, NULL, parsearchname) == -1) { - strcpy(filename, CommandFile); - found = 1; - } - else { - fclose(infile); - infile = NULL; - } - } - } - - if (!found) { - makepath(fullpath,drive,dir,fname,ext); - if ((infile=fopen(fullpath, "rb")) != NULL) { - if (scan_entries(infile, NULL, itemname) == -1) { - strcpy(filename, fullpath); - found = 1; - } - else { - fclose(infile); - infile = NULL; - } - } - } - - if (!found) { /* search for file */ - int out; - makepath(fullpath,drive,dir,"*",defaultextension); - out = fr_findfirst(fullpath); - while (out == 0) { - char msg[200]; - DTA.filename[FILE_MAX_FNAME+FILE_MAX_EXT-2]=0; - sprintf(msg,"Searching %13s for %s ",DTA.filename,itemname); - showtempmsg(msg); - if (!(DTA.attribute & SUBDIR) && - strcmp(DTA.filename,".")&& - strcmp(DTA.filename,"..")) { - splitpath(DTA.filename,NULL,NULL,fname,ext); - makepath(fullpath,drive,dir,fname,ext); - if ((infile=fopen(fullpath, "rb")) != NULL) { - if (scan_entries(infile, NULL, itemname) == -1) { - strcpy(filename, fullpath); - found = 1; - break; - } - else { - fclose(infile); - infile = NULL; - } - } - } - out = fr_findnext(); - } - cleartempmsg(); - } - - if (!found && orgfrmsearch && itemtype == 1) { - splitpath(orgfrmdir,drive,dir,NULL,NULL); - fname[0] = '_'; - fname[1] = (char) 0; - if (isalpha(itemname[0])) { - if (strnicmp(itemname, "carr", 4)) { - fname[1] = itemname[0]; - fname[2] = (char) 0; - } - else if (isdigit(itemname[4])) { - strcat(fname, "rc"); - fname[3] = itemname[4]; - fname[4] = (char) 0; - } - else { - strcat(fname, "rc"); - } - } - else if (isdigit(itemname[0])) { - strcat(fname, "num"); - } - else { - strcat(fname, "chr"); - } - makepath(fullpath,drive,dir,fname,defaultextension); - if ((infile=fopen(fullpath, "rb")) != NULL) { - if (scan_entries(infile, NULL, itemname) == -1) { - strcpy(filename, fullpath); - found = 1; - } - else { - fclose(infile); - infile = NULL; - } - } - } - - if (!found) { - sprintf(fullpath,"'%s' file entry item not found",itemname); - stopmsg(0,fullpath); - return(-1); - } - /* found file */ - if (fileptr != NULL) - *fileptr = infile; - else if (infile != NULL) - fclose(infile); - return(0); -} - - -int file_gets(char *buf,int maxlen,FILE *infile) -{ - int len,c; - /* similar to 'fgets', but file may be in either text or binary mode */ - /* returns -1 at eof, length of string otherwise */ - if (feof(infile)) return -1; - len = 0; - while (len < maxlen) { - c = getc(infile); - if (c == EOF || c == '\032') { - if (len) break; - return -1; - } - if (c == '\n') break; /* linefeed is end of line */ - if (c != '\r') buf[len++] = (char)c; /* ignore c/r */ - } - buf[len] = 0; - return len; -} - -int matherr_ct = 0; - -#if !defined(_WIN32) -#ifndef XFRACT -#ifdef WINFRACT -/* call this something else to dodge the QC4WIN bullet... */ -int win_matherr( struct exception *except ) -#else -int _cdecl _matherr( struct exception *except ) -#endif -{ - if (debugflag != 0) - { - static FILE *fp=NULL; - if (matherr_ct++ == 0) - if (debugflag == 4000 || debugflag == 3200) - stopmsg(0, "Math error, but we'll try to keep going"); - if (fp==NULL) - fp = fopen("matherr","w"); - if (matherr_ct < 100) - { - fprintf(fp,"err #%d: %d\nname: %s\narg: %e\n", - matherr_ct, except->type, except->name, except->arg1); - fflush(fp); - } - else - matherr_ct = 100; - - } - if ( except->type == DOMAIN ) - { - char buf[40]; - sprintf(buf,"%e",except->arg1); - /* This test may be unnecessary - from my experiments if the - argument is too large or small the error is TLOSS not DOMAIN */ - if (strstr(buf,"IN")||strstr(buf,"NAN")) /* trashed arg? */ - /* "IND" with MSC, "INF" with BC++ */ - { - if ( strcmp( except->name, "sin") == 0 ) - { - except->retval = 0.0; - return(1); - } - else if ( strcmp( except->name, "cos") == 0 ) - { - except->retval = 1.0; - return(1); - } - else if ( strcmp( except->name, "log") == 0 ) - { - except->retval = 1.0; - return(1); - } - } - } - if ( except->type == TLOSS ) - { - /* try valiantly to keep going */ - if ( strcmp( except->name, "sin") == 0 ) - { - except->retval = 0.5; - return(1); - } - else if ( strcmp( except->name, "cos") == 0 ) - { - except->retval = 0.5; - return(1); - } - } - /* shucks, no idea what went wrong, but our motto is "keep going!" */ - except->retval = 1.0; - return(1); -} -#endif -#endif - -void roundfloatd(double *x) /* make double converted from float look ok */ -{ - char buf[30]; - sprintf(buf,"%-10.7g",*x); - *x = atof(buf); -} - -void fix_inversion(double *x) /* make double converted from string look ok */ -{ - char buf[30]; - sprintf(buf,"%-1.15lg",*x); - *x = atof(buf); -} - -#if _MSC_VER == 800 -#ifdef FIXTAN_DEFINED -#undef tan -/* !!!!! stupid MSVC tan(x) bug fix !!!!!!!! */ -/* tan(x) can return -tan(x) if -pi/2 < x < pi/2 */ -/* if tan(x) has been called before outside this range. */ -double fixtan( double x ) - { - double y; - - y = tan(x); - if ((x > -PI/2 && x < 0 && y > 0) || (x > 0 && x < PI/2 && y < 0)) - y = -y; - return y; - } -#define tan fixtan -#endif -#endif - - diff --git a/fractint/common/mpmath_c.c b/fractint/common/mpmath_c.c deleted file mode 100644 index 1a435379d..000000000 --- a/fractint/common/mpmath_c.c +++ /dev/null @@ -1,2016 +0,0 @@ -/* MPMath_c.c (C) 1989, Mark C. Peterson, CompuServe [70441,3353] - All rights reserved. - - Code may be used in any program provided the author is credited - either during program execution or in the documentation. Source - code may be distributed only in combination with public domain or - shareware source code. Source code may be modified provided the - copyright notice and this message is left unchanged and all - modifications are clearly documented. - - I would appreciate a copy of any work which incorporates this code, - however this is optional. - - Mark C. Peterson - 405-C Queen St. Suite #181 - Southington, CT 06489 - (203) 276-9721 -*/ - - - /* see Fractint.c for a description of the "include" hierarchy */ -#include "port.h" -#include "prototyp.h" - -#if !defined(XFRACT) - -struct MP *MPsub(struct MP x, struct MP y) { - y.Exp ^= 0x8000; - return(MPadd(x, y)); -} - -/* added by TW */ -struct MP *MPsub086(struct MP x, struct MP y) { - y.Exp ^= 0x8000; - return(MPadd086(x, y)); -} - -/* added by TW */ -struct MP *MPsub386(struct MP x, struct MP y) { - y.Exp ^= 0x8000; - return(MPadd386(x, y)); -} - -struct MP *MPabs(struct MP x) { - Ans = x; - Ans.Exp &= 0x7fff; - return(&Ans); -} - -struct MPC MPCsqr(struct MPC x) { - struct MPC z; - - z.x = *pMPsub(*pMPmul(x.x, x.x), *pMPmul(x.y, x.y)); - z.y = *pMPmul(x.x, x.y); - z.y.Exp++; - return(z); -} - -struct MP MPCmod(struct MPC x) { - return(*pMPadd(*pMPmul(x.x, x.x), *pMPmul(x.y, x.y))); -} - -struct MPC MPCmul(struct MPC x, struct MPC y) { - struct MPC z; - - z.x = *pMPsub(*pMPmul(x.x, y.x), *pMPmul(x.y, y.y)); - z.y = *pMPadd(*pMPmul(x.x, y.y), *pMPmul(x.y, y.x)); - return(z); -} - -struct MPC MPCdiv(struct MPC x, struct MPC y) { - struct MP mod; - - mod = MPCmod(y); - y.y.Exp ^= 0x8000; - y.x = *pMPdiv(y.x, mod); - y.y = *pMPdiv(y.y, mod); - return(MPCmul(x, y)); -} - -struct MPC MPCadd(struct MPC x, struct MPC y) { - struct MPC z; - - z.x = *pMPadd(x.x, y.x); - z.y = *pMPadd(x.y, y.y); - return(z); -} - -struct MPC MPCsub(struct MPC x, struct MPC y) { - struct MPC z; - - z.x = *pMPsub(x.x, y.x); - z.y = *pMPsub(x.y, y.y); - return(z); -} - -struct MPC MPCone = { {0x3fff, 0x80000000l}, - {0, 0l} - }; - -struct MPC MPCpow(struct MPC x, int exp) { - struct MPC z; - struct MPC zz; - - if (exp & 1) - z = x; - else - z = MPCone; - exp >>= 1; - while (exp) { - zz.x = *pMPsub(*pMPmul(x.x, x.x), *pMPmul(x.y, x.y)); - zz.y = *pMPmul(x.x, x.y); - zz.y.Exp++; - x = zz; - if (exp & 1) { - zz.x = *pMPsub(*pMPmul(z.x, x.x), *pMPmul(z.y, x.y)); - zz.y = *pMPadd(*pMPmul(z.x, x.y), *pMPmul(z.y, x.x)); - z = zz; - } - exp >>= 1; - } - return(z); -} - -int MPCcmp(struct MPC x, struct MPC y) { - struct MPC z; - - if (pMPcmp(x.x, y.x) || pMPcmp(x.y, y.y)) { - z.x = MPCmod(x); - z.y = MPCmod(y); - return(pMPcmp(z.x, z.y)); - } - else - return(0); -} - -_CMPLX MPC2cmplx(struct MPC x) { - _CMPLX z; - - z.x = *pMP2d(x.x); - z.y = *pMP2d(x.y); - return(z); -} - -struct MPC cmplx2MPC(_CMPLX z) { - struct MPC x; - - x.x = *pd2MP(z.x); - x.y = *pd2MP(z.y); - return(x); -} - -/* function pointer versions added by Tim Wegner 12/07/89 */ -/* int (*ppMPcmp)() = MPcmp086; */ -int (*pMPcmp)(struct MP x, struct MP y) = MPcmp086; -struct MP *(*pMPmul)(struct MP x, struct MP y)= MPmul086; -struct MP *(*pMPdiv)(struct MP x, struct MP y)= MPdiv086; -struct MP *(*pMPadd)(struct MP x, struct MP y)= MPadd086; -struct MP *(*pMPsub)(struct MP x, struct MP y)= MPsub086; -struct MP *(*pd2MP)(double x) = d2MP086 ; -double *(*pMP2d)(struct MP m) = MP2d086 ; -/* struct MP *(*pfg2MP)(long x, int fg) = fg2MP086; */ - -void setMPfunctions(void) { - if (cpu >= 386) - { - pMPmul = MPmul386; - pMPdiv = MPdiv386; - pMPadd = MPadd386; - pMPsub = MPsub386; - pMPcmp = MPcmp386; - pd2MP = d2MP386 ; - pMP2d = MP2d386 ; - } - else - { - pMPmul = MPmul086; - pMPdiv = MPdiv086; - pMPadd = MPadd086; - pMPsub = MPsub086; - pMPcmp = MPcmp086; - pd2MP = d2MP086 ; - pMP2d = MP2d086 ; - } -} -#endif /* XFRACT */ - -#ifndef sqr -#define sqr(x) ((x)*(x)) -#endif - -_CMPLX ComplexPower(_CMPLX xx, _CMPLX yy) { - _CMPLX z, cLog, t; - double e2x, siny, cosy; - - /* fixes power bug - if any complaints, backwards compatibility hook - goes here TIW 3/95 */ - if (ldcheck == 0) - if (xx.x == 0 && xx.y == 0) { - z.x = z.y = 0.0; - return(z); - } - - FPUcplxlog(&xx, &cLog); - FPUcplxmul(&cLog, &yy, &t); - - if (fpu >= 387) - FPUcplxexp387(&t, &z); - else { - if (t.x < -690) - e2x = 0; - else - e2x = exp(t.x); - FPUsincos(&t.y, &siny, &cosy); - z.x = e2x * cosy; - z.y = e2x * siny; - } - return(z); -} - -/* - - The following Complex function routines added by Tim Wegner November 1994. - -*/ - -#define Sqrtz(z,rz) (*(rz) = ComplexSqrtFloat((z).x, (z).y)) - -/* rz=Arcsin(z)=-i*Log{i*z+sqrt(1-z*z)} */ -void Arcsinz(_CMPLX z,_CMPLX *rz) -{ - _CMPLX tempz1,tempz2; - - FPUcplxmul( &z, &z, &tempz1); - tempz1.x = 1 - tempz1.x; tempz1.y = -tempz1.y; /* tempz1 = 1 - tempz1 */ - Sqrtz( tempz1, &tempz1); - - tempz2.x = -z.y; tempz2.y = z.x; /* tempz2 = i*z */ - tempz1.x += tempz2.x; tempz1.y += tempz2.y; /* tempz1 += tempz2 */ - FPUcplxlog( &tempz1, &tempz1); - rz->x = tempz1.y; rz->y = -tempz1.x; /* rz = (-i)*tempz1 */ -} /* end. Arcsinz */ - - -/* rz=Arccos(z)=-i*Log{z+sqrt(z*z-1)} */ -void Arccosz(_CMPLX z,_CMPLX *rz) -{ - _CMPLX temp; - - FPUcplxmul( &z, &z, &temp); - temp.x -= 1; /* temp = temp - 1 */ - Sqrtz( temp, &temp); - - temp.x += z.x; temp.y += z.y; /* temp = z + temp */ - - FPUcplxlog( &temp, &temp); - rz->x = temp.y; rz->y = -temp.x; /* rz = (-i)*tempz1 */ -} /* end. Arccosz */ - -void Arcsinhz(_CMPLX z,_CMPLX *rz) -{ - _CMPLX temp; - - FPUcplxmul( &z, &z, &temp); - temp.x += 1; /* temp = temp + 1 */ - Sqrtz( temp, &temp); - temp.x += z.x; temp.y += z.y; /* temp = z + temp */ - FPUcplxlog( &temp, rz); -} /* end. Arcsinhz */ - -/* rz=Arccosh(z)=Log(z+sqrt(z*z-1)} */ -void Arccoshz(_CMPLX z,_CMPLX *rz) -{ - _CMPLX tempz; - FPUcplxmul( &z, &z, &tempz); - tempz.x -= 1; /* tempz = tempz - 1 */ - Sqrtz( tempz, &tempz); - tempz.x = z.x + tempz.x; tempz.y = z.y + tempz.y; /* tempz = z + tempz */ - FPUcplxlog( &tempz, rz); -} /* end. Arccoshz */ - -/* rz=Arctanh(z)=1/2*Log{(1+z)/(1-z)} */ -void Arctanhz(_CMPLX z,_CMPLX *rz) -{ - _CMPLX temp0,temp1,temp2; - - if ( z.x == 0.0){ - rz->x = 0; - rz->y = atan( z.y); - return; - } - else{ - if ( fabs(z.x) == 1.0 && z.y == 0.0){ - return; - } - else if ( fabs( z.x) < 1.0 && z.y == 0.0){ - rz->x = log((1+z.x)/(1-z.x))/2; - rz->y = 0; - return; - } - else{ - temp0.x = 1 + z.x; temp0.y = z.y; /* temp0 = 1 + z */ - temp1.x = 1 - z.x; temp1.y = -z.y; /* temp1 = 1 - z */ - FPUcplxdiv( &temp0, &temp1, &temp2); - FPUcplxlog( &temp2, &temp2); - rz->x = .5*temp2.x; rz->y = .5*temp2.y; /* rz = .5*temp2 */ - return; - } - } -} /* end. Arctanhz */ - -/* rz=Arctan(z)=i/2*Log{(1-i*z)/(1+i*z)} */ -void Arctanz(_CMPLX z,_CMPLX *rz) -{ - _CMPLX temp0,temp1,temp2,temp3; - if ( z.x == 0.0 && z.y == 0.0) - rz->x = rz->y = 0; - else if ( z.x != 0.0 && z.y == 0.0){ - rz->x = atan( z.x); - rz->y = 0; - } - else if ( z.x == 0.0 && z.y != 0.0){ - temp0.x = z.y; temp0.y = 0.0; - Arctanhz( temp0, &temp0); - rz->x = -temp0.y; rz->y = temp0.x; /* i*temp0 */ - } - else if ( z.x != 0.0 && z.y != 0.0){ - - temp0.x = -z.y; temp0.y = z.x; /* i*z */ - temp1.x = 1 - temp0.x; temp1.y = -temp0.y; /* temp1 = 1 - temp0 */ - temp2.x = 1 + temp0.x; temp2.y = temp0.y; /* temp2 = 1 + temp0 */ - - FPUcplxdiv( &temp1, &temp2, &temp3); - FPUcplxlog( &temp3, &temp3); - rz->x = -temp3.y*.5; rz->y = .5*temp3.x; /* .5*i*temp0 */ - } -} /* end. Arctanz */ - -#define SinCosFudge 0x10000L -#ifdef LONGSQRT -long lsqrt(long f) -{ - int N; - unsigned long y0, z; - static long a=0, b=0, c=0; /* constant factors */ - - if (f == 0) - return f; - if (f < 0) - return 0; - - if (a==0) /* one-time compute consts */ - { - a = (long)(fudge * .41731); - b = (long)(fudge * .59016); - c = (long)(fudge * .7071067811); - } - - N = 0; - while (f & 0xff000000L) /* shift arg f into the */ - { /* range: 0.5 <= f < 1 */ - N++; - f /= 2; - } - while (!(f & 0xff800000L)) - { - N--; - f *= 2; - } - - y0 = a + multiply(b, f, bitshift); /* Newton's approximation */ - - z = y0 + divide (f, y0, bitshift); - y0 = (z>>2) + divide(f, z, bitshift); - - if (N % 2) - { - N++; - y0 = multiply(c,y0, bitshift); - } - N /= 2; - if (N >= 0) - return y0 << N; /* correct for shift above */ - else - return y0 >> -N; -} -#endif -LCMPLX ComplexSqrtLong(long x, long y) -{ - double mag, theta; - long maglong, thetalong; - LCMPLX result; - -#ifndef LONGSQRT - mag = sqrt(sqrt(((double) multiply(x,x,bitshift))/fudge + - ((double) multiply(y,y,bitshift))/ fudge)); - maglong = (long)(mag * fudge); -#else - maglong = lsqrt(lsqrt(multiply(x,x,bitshift)+multiply(y,y,bitshift))); -#endif - theta = atan2((double) y/fudge, (double) x/fudge)/2; - thetalong = (long)(theta * SinCosFudge); - SinCos086(thetalong, &result.y, &result.x); - result.x = multiply(result.x << (bitshift - 16), maglong, bitshift); - result.y = multiply(result.y << (bitshift - 16), maglong, bitshift); - return result; -} - -_CMPLX ComplexSqrtFloat(double x, double y) -{ - double mag; - double theta; - _CMPLX result; - - if (x == 0.0 && y == 0.0) - result.x = result.y = 0.0; - else - { - mag = sqrt(sqrt(x*x + y*y)); - theta = atan2(y, x) / 2; - FPUsincos(&theta, &result.y, &result.x); - result.x *= mag; - result.y *= mag; - } - return result; -} - - -/***** FRACTINT specific routines and variables *****/ - -#ifndef TESTING_MATH - -BYTE *LogTable = (BYTE *)0; -long MaxLTSize; -int Log_Calc = 0; -static double mlf; -static unsigned long lf; - - /* int LogFlag; - LogFlag == 1 -- standard log palettes - LogFlag == -1 -- 'old' log palettes - LogFlag > 1 -- compress counts < LogFlag into color #1 - LogFlag < -1 -- use quadratic palettes based on square roots && compress - */ - -void SetupLogTable(void) { - float l, f, c, m; - unsigned long prev, limit, sptop; - unsigned n; - - if (save_release > 1920 || Log_Fly_Calc == 1) { /* set up on-the-fly variables */ - if (LogFlag > 0) { /* new log function */ - lf = (LogFlag > 1) ? LogFlag : 0; - if (lf >= (unsigned long)MaxLTSize) - lf = MaxLTSize - 1; - mlf = (colors - (lf?2:1)) / log(MaxLTSize - lf); - } else if (LogFlag == -1) { /* old log function */ - mlf = (colors - 1) / log(MaxLTSize); - } else if (LogFlag <= -2) { /* sqrt function */ - if ((lf = 0 - LogFlag) >= (unsigned long)MaxLTSize) - lf = MaxLTSize - 1; - mlf = (colors - 2) / sqrt(MaxLTSize - lf); - } - } - - if (Log_Calc) - return; /* LogTable not defined, bail out now */ - - if (save_release > 1920 && !Log_Calc) { - Log_Calc = 1; /* turn it on */ - for (prev = 0; prev <= (unsigned long)MaxLTSize; prev++) - LogTable[prev] = (BYTE)logtablecalc((long)prev); - Log_Calc = 0; /* turn it off, again */ - return; - } - - if (LogFlag > -2) { - lf = (LogFlag > 1) ? LogFlag : 0; - if (lf >= (unsigned long)MaxLTSize) - lf = MaxLTSize - 1; - Fg2Float((long)(MaxLTSize-lf), 0, m); - fLog14(m, m); - Fg2Float((long)(colors-(lf?2:1)), 0, c); - fDiv(m, c, m); - for (prev = 1; prev <= lf; prev++) - LogTable[prev] = 1; - for (n = (lf?2:1); n < (unsigned int)colors; n++) { - Fg2Float((long)n, 0, f); - fMul16(f, m, f); - fExp14(f, l); - limit = (unsigned long)Float2Fg(l, 0) + lf; - if (limit > (unsigned long)MaxLTSize || n == (unsigned int)(colors-1)) - limit = MaxLTSize; - while (prev <= limit) - LogTable[prev++] = (BYTE)n; - } - } else { - if ((lf = 0 - LogFlag) >= (unsigned long)MaxLTSize) - lf = MaxLTSize - 1; - Fg2Float((long)(MaxLTSize-lf), 0, m); - fSqrt14(m, m); - Fg2Float((long)(colors-2), 0, c); - fDiv(m, c, m); - for (prev = 1; prev <= lf; prev++) - LogTable[prev] = 1; - for (n = 2; n < (unsigned int)colors; n++) { - Fg2Float((long)n, 0, f); - fMul16(f, m, f); - fMul16(f, f, l); - limit = (unsigned long)(Float2Fg(l, 0) + lf); - if (limit > (unsigned long)MaxLTSize || n == (unsigned int)(colors-1)) - limit = MaxLTSize; - while (prev <= limit) - LogTable[prev++] = (BYTE)n; - } - } - LogTable[0] = 0; - if (LogFlag != -1) - for (sptop = 1; sptop < (unsigned long)MaxLTSize; sptop++) /* spread top to incl unused colors */ - if (LogTable[sptop] > LogTable[sptop-1]) - LogTable[sptop] = (BYTE)(LogTable[sptop-1]+1); -} - -long logtablecalc(long citer) { - long ret = 0; - - if (LogFlag == 0 && !rangeslen) /* Oops, how did we get here? */ - return(citer); - if (LogTable && !Log_Calc) - return(LogTable[(long)min(citer, MaxLTSize)]); - - if (LogFlag > 0) { /* new log function */ - if ((unsigned long)citer <= lf + 1) - ret = 1; - else if ((citer - lf) / log(citer - lf) <= mlf) { - if (save_release < 2002) - ret = (long)(citer - lf + (lf?1:0)); - else - ret = (long)(citer - lf); - } - else - ret = (long)(mlf * log(citer - lf)) + 1; - } else if (LogFlag == -1) { /* old log function */ - if (citer == 0) - ret = 1; - else - ret = (long)(mlf * log(citer)) + 1; - } else if (LogFlag <= -2) { /* sqrt function */ - if ((unsigned long)citer <= lf) - ret = 1; - else if ((unsigned long)(citer - lf) <= (unsigned long)(mlf * mlf)) - ret = (long)(citer - lf + 1); - else - ret = (long)(mlf * sqrt(citer - lf)) + 1; - } - return (ret); -} - -long ExpFloat14(long xx) { - static float fLogTwo = (float)0.6931472; - int f; - long Ans; - - f = 23 - (int)RegFloat2Fg(RegDivFloat(xx, *(long*)&fLogTwo), 0); - Ans = ExpFudged(RegFloat2Fg(xx, 16), f); - return(RegFg2Float(Ans, (char)f)); -} - -double TwoPi; -_CMPLX temp, BaseLog; -_CMPLX cdegree = { 3.0, 0.0 }, croot = { 1.0, 0.0 }; - -int ComplexNewtonSetup(void) { - threshold = .001; - periodicitycheck = 0; - if (param[0] != 0.0 || param[1] != 0.0 || param[2] != 0.0 || - param[3] != 0.0) { - croot.x = param[2]; - croot.y = param[3]; - cdegree.x = param[0]; - cdegree.y = param[1]; - FPUcplxlog(&croot, &BaseLog); - TwoPi = asin(1.0) * 4; - } - return(1); -} - -int ComplexNewton(void) { - _CMPLX cd1; - - /* new = ((cdegree-1) * old**cdegree) + croot - ---------------------------------- - cdegree * old**(cdegree-1) */ - - cd1.x = cdegree.x - 1.0; - cd1.y = cdegree.y; - - temp = ComplexPower(old, cd1); - FPUcplxmul(&temp, &old, &g_new); - - tmp.x = g_new.x - croot.x; - tmp.y = g_new.y - croot.y; - if ((sqr(tmp.x) + sqr(tmp.y)) < threshold) - return(1); - - FPUcplxmul(&g_new, &cd1, &tmp); - tmp.x += croot.x; - tmp.y += croot.y; - - FPUcplxmul(&temp, &cdegree, &cd1); - FPUcplxdiv(&tmp, &cd1, &old); - if (overflow) - { - return(1); - } - g_new = old; - return(0); -} - -int ComplexBasin(void) { - _CMPLX cd1; - double mod; - - /* new = ((cdegree-1) * old**cdegree) + croot - ---------------------------------- - cdegree * old**(cdegree-1) */ - - cd1.x = cdegree.x - 1.0; - cd1.y = cdegree.y; - - temp = ComplexPower(old, cd1); - FPUcplxmul(&temp, &old, &g_new); - - tmp.x = g_new.x - croot.x; - tmp.y = g_new.y - croot.y; - if ((sqr(tmp.x) + sqr(tmp.y)) < threshold) { - if (fabs(old.y) < .01) - old.y = 0.0; - FPUcplxlog(&old, &temp); - FPUcplxmul(&temp, &cdegree, &tmp); - mod = tmp.y/TwoPi; - coloriter = (long)mod; - if (fabs(mod - coloriter) > 0.5) { - if (mod < 0.0) - coloriter--; - else - coloriter++; - } - coloriter += 2; - if (coloriter < 0) - coloriter += 128; - return(1); - } - - FPUcplxmul(&g_new, &cd1, &tmp); - tmp.x += croot.x; - tmp.y += croot.y; - - FPUcplxmul(&temp, &cdegree, &cd1); - FPUcplxdiv(&tmp, &cd1, &old); - if (overflow) - { - return(1); - } - g_new = old; - return(0); -} - -/* - * Generate a gaussian distributed number. - * The right half of the distribution is folded onto the lower half. - * That is, the curve slopes up to the peak and then drops to 0. - * The larger slope is, the smaller the standard deviation. - * The values vary from 0+offset to range+offset, with the peak - * at range+offset. - * To make this more complicated, you only have a - * 1 in Distribution*(1-Probability/Range*con)+1 chance of getting a - * Gaussian; otherwise you just get offset. - */ -int GausianNumber(int Probability, int Range) { - int n, r; - long Accum = 0, p; - - p = divide((long)Probability << 16, (long)Range << 16, 16); - p = multiply(p, con, 16); - p = multiply((long)Distribution << 16, p, 16); - if (!(rand15() % (Distribution - (int)(p >> 16) + 1))) { - for (n = 0; n < Slope; n++) - Accum += rand15(); - Accum /= Slope; - r = (int)(multiply((long)Range << 15, Accum, 15) >> 14); - r = r - Range; - if (r < 0) - r = -r; - return(Range - r + Offset); - } - return(Offset); -} - -#endif - -#if defined(_WIN32) -/* -MP2d086 PROC uses si di, xExp:WORD, xMant:DWORD - sub xExp, (1 SHL 14) - (1 SHL 10) - jo Overflow - - mov bx, xExp - and bx, 0111100000000000b - jz InRangeOfDouble - -Overflow: - mov MPOverflow, 1 - xor ax, ax - xor dx, dx - xor bx, bx - jmp StoreAns - -InRangeOfDouble: - mov si, xExp - mov ax, si - mov cl, 5 - shl si, cl - shl ax, 1 - rcr si, 1 - - mov dx, WORD PTR [xMant+2] - mov ax, WORD PTR [xMant] - shl ax, 1 - rcl dx, 1 - - mov bx, ax - mov di, dx - mov cl, 12 - shr dx, cl - shr ax, cl - mov cl, 4 - shl bx, cl - shl di, cl - or ax, di - or dx, si - -StoreAns: - mov WORD PTR Double+6, dx - mov WORD PTR Double+4, ax - mov WORD PTR Double+2, bx - xor bx, bx - mov WORD PTR Double, bx - - lea ax, Double - mov dx, ds - ret -MP2d086 ENDP -*/ -double *MP2d086(struct MP x) -{ - /* TODO: implement */ - static double ans = 0.0; - _ASSERTE(0 && "MP2d086 called."); - return &ans; -} - -/* -d2MP086 PROC uses si di, x:QWORD - mov dx, word ptr [x+6] - mov ax, word ptr [x+4] - mov bx, word ptr [x+2] - mov cx, word ptr [x] - mov si, dx - shl si, 1 - pushf - mov cl, 4 - shr si, cl - popf - rcr si, 1 - add si, (1 SHL 14) - (1 SHL 10) - - mov di, ax ; shl dx:ax:bx 12 bits - mov cl, 12 - shl dx, cl - shl ax, cl - mov cl, 4 - shr di, cl - shr bx, cl - or dx, di - or ax, bx - stc - rcr dx, 1 - rcr ax, 1 - -StoreAns: - mov Ans.Exp, si - mov word ptr Ans.Mant+2, dx - mov word ptr Ans.Mant, ax - - lea ax, Ans - mov dx, ds - ret -d2MP086 ENDP -*/ -struct MP *d2MP086(double x) -{ - /* TODO: implement */ - if (0.0 == x) - { - Ans.Exp = 0; - Ans.Mant = 0; - } - else - { - __asm - { - mov dx, word ptr [x+6] - mov ax, word ptr [x+4] - mov bx, word ptr [x+2] - mov cx, word ptr [x] - xor esi, esi - mov si, dx - shl si, 1 - pushf - mov cl, 4 - shr si, cl - popf - rcr si, 1 - add si, (1 SHL 14) - (1 SHL 10) - - mov di, ax ; shl dx:ax:bx 12 bits - mov cl, 12 - shl dx, cl - shl ax, cl - mov cl, 4 - shr di, cl - shr bx, cl - or dx, di - or ax, bx - stc - rcr dx, 1 - rcr ax, 1 - - mov Ans.Exp, esi - mov word ptr Ans.Mant+2, dx - mov word ptr Ans.Mant, ax - } - } - return &Ans; -} - -/* -MPadd086 PROC uses si di, xExp:WORD, xMant:DWORD, yExp:WORD, yMant:DWORD - mov si, xExp - mov dx, WORD PTR [xMant+2] - mov ax, WORD PTR [xMant] - - mov di, yExp - - mov cx, si - xor cx, di - js Subtract - jz SameMag - - cmp si, di - jg XisGreater - - xchg si, di - xchg dx, WORD PTR [yMant+2] - xchg ax, WORD PTR [yMant] - -XisGreater: - mov cx, si - sub cx, di - cmp cx, 32 - jl ChkSixteen - jmp StoreAns - -ChkSixteen: - cmp cx, 16 - jl SixteenBitShift - - sub cx, 16 - mov bx, WORD PTR [yMant+2] - shr bx, cl - mov WORD PTR [yMant], bx - mov WORD PTR [yMant+2], 0 - jmp SameMag - -SixteenBitShift: - mov bx, WORD PTR [yMant+2] - shr WORD PTR [yMant+2], cl - shr WORD PTR [yMant], cl - neg cl - add cl, 16 - shl bx, cl - or WORD PTR [yMant], bx - -SameMag: - add ax, WORD PTR [yMant] - adc dx, WORD PTR [yMant+2] - jc ShiftCarry - jmp StoreAns - -ShiftCarry: - rcr dx, 1 - rcr ax, 1 - add si, 1 - jo Overflow - jmp StoreAns - -Overflow: - mov MPOverflow, 1 - -ZeroAns: - xor si, si - xor ax, ax - xor dx, dx - jmp StoreAns - -Subtract: - xor di, 8000h - mov cx, si - sub cx, di - jnz DifferentMag - - cmp dx, WORD PTR [yMant+2] - jg SubtractNumbers - jne SwapNumbers - - cmp ax, WORD PTR [yMant] - jg SubtractNumbers - je ZeroAns - -SwapNumbers: - xor si, 8000h - xchg ax, WORD PTR [yMant] - xchg dx, WORD PTR [yMant+2] - jmp SubtractNumbers - -DifferentMag: - or cx, cx - jns NoSwap - - xchg si, di - xchg ax, WORD PTR [yMant] - xchg dx, WORD PTR [yMant+2] - xor si, 8000h - neg cx - -NoSwap: - cmp cx, 32 - jge StoreAns - - cmp cx, 16 - jl SixteenBitShift2 - - sub cx, 16 - mov bx, WORD PTR [yMant+2] - shr bx, cl - mov WORD PTR [yMant], bx - mov WORD PTR [yMant+2], 0 - jmp SubtractNumbers - -SixteenBitShift2: - mov bx, WORD PTR [yMant+2] - shr WORD PTR [yMant+2], cl - shr WORD PTR [yMant], cl - neg cl - add cl, 16 - shl bx, cl - or WORD PTR [yMant], bx - -SubtractNumbers: - sub ax, WORD PTR [yMant] - sbb dx, WORD PTR [yMant+2] - -BitScanRight: - or dx, dx - js StoreAns - - shl ax, 1 - rcl dx, 1 - sub si, 1 - jno BitScanRight - jmp Overflow - -StoreAns: - mov Ans.Exp, si - mov WORD PTR Ans.Mant+2, dx - mov WORD PTR Ans.Mant, ax - - lea ax, Ans - mov dx, ds - ret -MPadd086 ENDP -*/ -struct MP *MPadd086(struct MP x, struct MP y) -{ - /* TODO: implement */ - _ASSERTE(0 && "MPadd086 called."); - return &Ans; -} - -/* -MPcmp086 PROC uses si di, xExp:WORD, xMant:DWORD, yExp:WORD, yMant:DWORD -LOCAL Rev:WORD, Flag:WORD - mov Rev, 0 - mov Flag, 0 - mov ax, xExp - mov dx, WORD PTR [xMant] - mov si, WORD PTR [xMant+2] - mov bx, yExp - mov cx, WORD PTR [yMant] - mov di, WORD PTR [yMant+2] - or ax, ax - jns AtLeastOnePos - - or bx, bx - jns AtLeastOnePos - - mov Rev, 1 - and ah, 7fh - and bh, 7fh - -AtLeastOnePos: - cmp ax, bx - jle Cmp1 - - mov Flag, 1 - jmp ChkRev - -Cmp1: - je Cmp2 - - mov Flag, -1 - jmp ChkRev - -Cmp2: - cmp si, di - jbe Cmp3 - - mov Flag, 1 - jmp ChkRev - -Cmp3: - je Cmp4 - - mov Flag, -1 - jmp ChkRev - -Cmp4: - cmp dx, cx - jbe Cmp5 - - mov Flag, 1 - jmp ChkRev - -Cmp5: - je ChkRev - - mov Flag, -1 - -ChkRev: - or Rev, 0 - jz ExitCmp - - neg Flag - -ExitCmp: - mov ax, Flag - ret -MPcmp086 ENDP -*/ -int MPcmp086(struct MP x, struct MP y) -{ - /* TODO: implement */ - _ASSERTE(0 && "MPcmp086 called."); - return 0; -} - -/* -MPdiv086 PROC uses si di, xExp:WORD, xMant:DWORD, yExp:WORD, \ - yMant:DWORD - mov ax, xExp - mov bx, yExp - xor ch, ch - shl bh, 1 - rcr ch, 1 - shr bh, 1 - xor ah, ch - - sub bx, (1 SHL 14) - 2 - sub ax, bx - jno NoOverflow - -Overflow: - mov MPOverflow, 1 - -ZeroAns: - xor ax, ax - xor dx, dx - mov Ans.Exp, dx - jmp StoreMant - -NoOverflow: - mov Ans.Exp, ax - - mov dx, WORD PTR [xMant+2] - mov ax, WORD PTR [xMant] - or dx, dx - jz ZeroAns - - mov cx, WORD PTR [yMant+2] - mov bx, WORD PTR [yMant] - or cx, cx - jz Overflow - - cmp dx, cx - jl Divide - - shr dx, 1 - rcr ax, 1 - add Ans.Exp, 1 - jo Overflow - -Divide: - div cx - mov si, dx - mov dx, bx - mov bx, ax - mul dx - xor di, di - cmp dx, si - jnc RemReallyNeg - - xchg ax, di - xchg dx, si - sub ax, di - sbb dx, si - - shr dx, 1 - rcr ax, 1 - div cx - mov dx, bx - shl ax, 1 - adc dx, 0 - jmp StoreMant - -RemReallyNeg: - sub ax, di - sbb dx, si - - shr dx, 1 - rcr ax, 1 - div cx - mov dx, bx - mov bx, ax - xor ax, ax - xor cx, cx - shl bx, 1 - rcl cx, 1 - sub ax, bx - sbb dx, cx - jno StoreMant - - shl ax, 1 - rcl dx, 1 - dec Ans.Exp - -StoreMant: - mov WORD PTR Ans.Mant, ax - mov WORD PTR Ans.Mant+2, dx - lea ax, Ans - mov dx, ds - ret -MPdiv086 ENDP -*/ -struct MP *MPdiv086(struct MP x, struct MP y) -{ - /* TODO: implement */ - _ASSERTE(0 && "MPdiv086 called."); - return &Ans; -} - -/* -MPmul086 PROC uses si di, xExp:WORD, xMant:DWORD, yExp:WORD, yMant:DWORD - mov ax, xExp - mov bx, yExp - xor ch, ch - shl bh, 1 - rcr ch, 1 - shr bh, 1 - xor ah, ch - - sub bx, (1 SHL 14) - 2 - add ax, bx - jno NoOverflow - -Overflow: - or word ptr [xMant+2], 0 - jz ZeroAns - or word ptr [yMant+2], 0 - jz ZeroAns - - mov MPOverflow, 1 - -ZeroAns: - xor ax, ax - xor dx, dx - mov Ans.Exp, ax - jmp StoreMant - -NoOverflow: - mov Ans.Exp, ax - - mov si, word ptr [xMant+2] - mov bx, word ptr [xMant] - mov di, word ptr [yMant+2] - mov cx, word ptr [yMant] - - mov ax, si - or ax, bx - jz ZeroAns - - mov ax, di - or ax, cx - jz ZeroAns - - mov ax, cx - mul bx - push dx - - mov ax, cx - mul si - push ax - push dx - - mov ax, bx - mul di - push ax - push dx - - mov ax, si - mul di - pop bx - pop cx - pop si - pop di - - add ax, bx - adc dx, 0 - pop bx - add di, bx - adc ax, 0 - adc dx, 0 - add di, cx - adc ax, si - adc dx, 0 - - or dx, dx - js StoreMant - - shl di, 1 - rcl ax, 1 - rcl dx, 1 - sub Ans.Exp, 1 - jo Overflow - -StoreMant: - mov word ptr Ans.Mant+2, dx - mov word ptr Ans.Mant, ax - - lea ax, Ans - mov dx, ds - ret -MPmul086 ENDP -*/ -struct MP *MPmul086(struct MP x, struct MP y) -{ - /* TODO: implement */ - __asm - { - xor eax, eax - xor ebx, ebx - mov eax, x.Exp - mov ebx, y.Exp - xor ch, ch - shl bh, 1 - rcr ch, 1 - shr bh, 1 - xor ah, ch - - sub bx, (1 SHL 14) - 2 - add ax, bx - jno NoOverflow - - Overflow: - or word ptr [x.Mant+2], 0 - jz ZeroAns - or word ptr [y.Mant+2], 0 - jz ZeroAns - - mov MPOverflow, 1 - - ZeroAns: - xor ax, ax - xor dx, dx - mov Ans.Exp, eax - jmp StoreMant - - NoOverflow: - mov Ans.Exp, eax - - mov si, word ptr [x.Mant+2] - mov bx, word ptr [x.Mant] - mov di, word ptr [y.Mant+2] - mov cx, word ptr [y.Mant] - - mov ax, si - or ax, bx - jz ZeroAns - - mov ax, di - or ax, cx - jz ZeroAns - - mov ax, cx - mul bx - push dx - - mov ax, cx - mul si - push ax - push dx - - mov ax, bx - mul di - push ax - push dx - - mov ax, si - mul di - pop bx - pop cx - pop si - pop di - - add ax, bx - adc dx, 0 - pop bx - add di, bx - adc ax, 0 - adc dx, 0 - add di, cx - adc ax, si - adc dx, 0 - - or dx, dx - js StoreMant - - shl di, 1 - rcl ax, 1 - rcl dx, 1 - sub Ans.Exp, 1 - jo Overflow - - StoreMant: - mov word ptr Ans.Mant+2, dx - mov word ptr Ans.Mant, ax - } - - return &Ans; -} - -/* -d2MP386 PROC uses si di, x:QWORD - mov si, WORD PTR [x+6] -.386 - mov edx, DWORD PTR [x+4] - mov eax, DWORD PTR [x] - - mov ebx, edx - shl ebx, 1 - or ebx, eax - jnz NonZero - - xor si, si - xor edx, edx - jmp StoreAns - -NonZero: - shl si, 1 - pushf - shr si, 4 - popf - rcr si, 1 - add si, (1 SHL 14) - (1 SHL 10) - - shld edx, eax, 12 - stc - rcr edx, 1 - -StoreAns: - mov Ans.Exp, si - mov Ans.Mant, edx - - lea ax, Ans - mov dx, ds -.8086 - ret -d2MP386 ENDP -*/ -struct MP *d2MP386(double x) -{ - /* TODO: implement */ - _ASSERTE(0 && "d2MP386 called."); - return &Ans; -} - -/* -MP2d386 PROC uses si di, xExp:WORD, xMant:DWORD - sub xExp, (1 SHL 14) - (1 SHL 10) -.386 - jo Overflow - - mov bx, xExp - and bx, 0111100000000000b - jz InRangeOfDouble - -Overflow: - mov MPOverflow, 1 - xor eax, eax - xor edx, edx - jmp StoreAns - -InRangeOfDouble: - mov bx, xExp - mov ax, bx - shl bx, 5 - shl ax, 1 - rcr bx, 1 - shr bx, 4 - - mov edx, xMant - shl edx, 1 - xor eax, eax - shrd eax, edx, 12 - shrd edx, ebx, 12 - -StoreAns: - mov DWORD PTR Double+4, edx - mov DWORD PTR Double, eax - - lea ax, Double - mov dx, ds -.8086 - ret -MP2d386 ENDP -*/ -double *MP2d386(struct MP x) -{ - /* TODO: implement */ - static double ans = 0.0; - _ASSERTE(0 && "MP2d386 called."); - return &ans; -} - -/* -MPadd086 PROC uses si di, xExp:WORD, xMant:DWORD, yExp:WORD, yMant:DWORD - mov si, xExp - mov dx, WORD PTR [xMant+2] - mov ax, WORD PTR [xMant] - - mov di, yExp - - mov cx, si - xor cx, di - js Subtract - jz SameMag - - cmp si, di - jg XisGreater - - xchg si, di - xchg dx, WORD PTR [yMant+2] - xchg ax, WORD PTR [yMant] - -XisGreater: - mov cx, si - sub cx, di - cmp cx, 32 - jl ChkSixteen - jmp StoreAns - -ChkSixteen: - cmp cx, 16 - jl SixteenBitShift - - sub cx, 16 - mov bx, WORD PTR [yMant+2] - shr bx, cl - mov WORD PTR [yMant], bx - mov WORD PTR [yMant+2], 0 - jmp SameMag - -SixteenBitShift: - mov bx, WORD PTR [yMant+2] - shr WORD PTR [yMant+2], cl - shr WORD PTR [yMant], cl - neg cl - add cl, 16 - shl bx, cl - or WORD PTR [yMant], bx - -SameMag: - add ax, WORD PTR [yMant] - adc dx, WORD PTR [yMant+2] - jc ShiftCarry - jmp StoreAns - -ShiftCarry: - rcr dx, 1 - rcr ax, 1 - add si, 1 - jo Overflow - jmp StoreAns - -Overflow: - mov MPOverflow, 1 - -ZeroAns: - xor si, si - xor ax, ax - xor dx, dx - jmp StoreAns - -Subtract: - xor di, 8000h - mov cx, si - sub cx, di - jnz DifferentMag - - cmp dx, WORD PTR [yMant+2] - jg SubtractNumbers - jne SwapNumbers - - cmp ax, WORD PTR [yMant] - jg SubtractNumbers - je ZeroAns - -SwapNumbers: - xor si, 8000h - xchg ax, WORD PTR [yMant] - xchg dx, WORD PTR [yMant+2] - jmp SubtractNumbers - -DifferentMag: - or cx, cx - jns NoSwap - - xchg si, di - xchg ax, WORD PTR [yMant] - xchg dx, WORD PTR [yMant+2] - xor si, 8000h - neg cx - -NoSwap: - cmp cx, 32 - jge StoreAns - - cmp cx, 16 - jl SixteenBitShift2 - - sub cx, 16 - mov bx, WORD PTR [yMant+2] - shr bx, cl - mov WORD PTR [yMant], bx - mov WORD PTR [yMant+2], 0 - jmp SubtractNumbers - -SixteenBitShift2: - mov bx, WORD PTR [yMant+2] - shr WORD PTR [yMant+2], cl - shr WORD PTR [yMant], cl - neg cl - add cl, 16 - shl bx, cl - or WORD PTR [yMant], bx - -SubtractNumbers: - sub ax, WORD PTR [yMant] - sbb dx, WORD PTR [yMant+2] - -BitScanRight: - or dx, dx - js StoreAns - - shl ax, 1 - rcl dx, 1 - sub si, 1 - jno BitScanRight - jmp Overflow - -StoreAns: - mov Ans.Exp, si - mov WORD PTR Ans.Mant+2, dx - mov WORD PTR Ans.Mant, ax - - lea ax, Ans - mov dx, ds - ret -MPadd086 ENDP -*/ -struct MP *MPadd(struct MP x, struct MP y) -{ - /* TODO: implement */ - _ASSERTE(0 && "MPadd called."); - return &Ans; -} - -/* -MPadd386 PROC uses si di, xExp:WORD, xMant:DWORD, yExp:WORD, \ - yMant:DWORD - mov si, xExp -.386 - mov eax, xMant - - mov di, yExp - mov edx, yMant - - mov cx, si - xor cx, di - js Subtract - jz SameMag - - cmp si, di - jg XisGreater - - xchg si, di - xchg eax, edx - -XisGreater: - mov cx, si - sub cx, di - cmp cx, 32 - jge StoreAns - - shr edx, cl - -SameMag: - add eax, edx - jnc StoreAns - - rcr eax, 1 - add si, 1 - jno StoreAns - -Overflow: - mov MPOverflow, 1 - -ZeroAns: - xor si, si - xor edx, edx - jmp StoreAns - -Subtract: - xor di, 8000h - mov cx, si - sub cx, di - jnz DifferentMag - - cmp eax, edx - jg SubtractNumbers - je ZeroAns - - xor si, 8000h - xchg eax, edx - jmp SubtractNumbers - -DifferentMag: - or cx, cx - jns NoSwap - - xchg si, di - xchg eax, edx - xor si, 8000h - neg cx - -NoSwap: - cmp cx, 32 - jge StoreAns - - shr edx, cl - -SubtractNumbers: - sub eax, edx - bsr ecx, eax - neg cx - add cx, 31 - shl eax, cl - sub si, cx - jo Overflow - -StoreAns: - mov Ans.Exp, si - mov Ans.Mant, eax - - lea ax, Ans - mov dx, ds -.8086 - ret -MPadd386 ENDP -*/ -struct MP *MPadd386(struct MP x, struct MP y) -{ - /* TODO: implement */ - _ASSERTE(0 && "MPadd386 called."); - return &Ans; -} - -/* -MPcmp386 PROC uses si di, xExp:WORD, xMant:DWORD, yExp:WORD, yMant:DWORD - mov si, 0 - mov di, si -.386 - mov ax, xExp - mov edx, xMant - mov bx, yExp - mov ecx, yMant - or ax, ax - jns AtLeastOnePos - - or bx, bx - jns AtLeastOnePos - - mov si, 1 - and ah, 7fh - and bh, 7fh - -AtLeastOnePos: - cmp ax, bx - jle Cmp1 - - mov di, 1 - jmp ChkRev - -Cmp1: - je Cmp2 - - mov di, -1 - jmp ChkRev - -Cmp2: - cmp edx, ecx - jbe Cmp3 - - mov di, 1 - jmp ChkRev - -Cmp3: - je ChkRev - - mov di, -1 - -ChkRev: - or si, si - jz ExitCmp - - neg di - -ExitCmp: - mov ax, di -.8086 - ret -MPcmp386 ENDP -*/ -int MPcmp386(struct MP x, struct MP y) -{ - /* TODO: implement */ - _ASSERTE(0 && "MPcmp386 called."); - return 0; -} - -/* -MPdiv386 PROC uses si di, xExp:WORD, xMant:DWORD, yExp:WORD, \ - yMant:DWORD - mov ax, xExp - mov bx, yExp -.386 - xor ch, ch - shl bh, 1 - rcr ch, 1 - shr bh, 1 - xor ah, ch - - sub bx, (1 SHL 14) - 2 - sub ax, bx - jno NoOverflow - -Overflow: - mov MPOverflow, 1 - -ZeroAns: - xor eax, eax - mov Ans.Exp, ax - jmp StoreMant - -NoOverflow: - mov Ans.Exp, ax - - xor eax, eax - mov edx, xMant - mov ecx, yMant - or edx, edx - jz ZeroAns - - or ecx, ecx - jz Overflow - - cmp edx, ecx - jl Divide - - shr edx, 1 - rcr eax, 1 - add Ans.Exp, 1 - jo Overflow - -Divide: - div ecx - -StoreMant: - mov Ans.Mant, eax - lea ax, Ans - mov dx, ds -.8086 - ret -MPdiv386 ENDP -*/ -struct MP *MPdiv386(struct MP x, struct MP y) -{ - /* TODO: implement */ - _ASSERTE(0 && "MPdiv386 called."); - return &Ans; -} - -/* -MPmul386 PROC uses si di, xExp:WORD, xMant:DWORD, yExp:WORD, \ - yMant:DWORD - mov ax, xExp - mov bx, yExp -.386 - xor ch, ch - shl bh, 1 - rcr ch, 1 - shr bh, 1 - xor ah, ch - - sub bx, (1 SHL 14) - 2 - add ax, bx - jno NoOverflow - -Overflow: - or WORD PTR [xMant+2], 0 - jz ZeroAns - or WORD PTR [yMant+2], 0 - jz ZeroAns - - mov MPOverflow, 1 - -ZeroAns: - xor edx, edx - mov Ans.Exp, dx - jmp StoreMant - -NoOverflow: - mov Ans.Exp, ax - - mov eax, xMant - mov edx, yMant - or eax, eax - jz ZeroAns - - or edx, edx - jz ZeroAns - - mul edx - - or edx, edx - js StoreMant - - shld edx, eax, 1 - sub Ans.Exp, 1 - jo Overflow - -StoreMant: - mov Ans.Mant, edx - lea ax, Ans - mov dx, ds -.8086 - ret -MPmul386 ENDP -*/ -struct MP *MPmul386(struct MP x, struct MP y) -{ - /* TODO: implement */ - _ASSERTE(0 && "MPmul386 called."); - return &Ans; -} - -/* -*/ -struct MP *d2MP(double x) -{ - return ((cpu >= 386)? d2MP386 : d2MP086)(x); -} - -struct MP *MPmul(struct MP x, struct MP y) -{ - return ((cpu >= 386) ? MPmul386 : MPmul086)(x, y); -} - -struct MP *MPdiv(struct MP x, struct MP y) -{ - return ((cpu >= 386) ? MPdiv386 : MPdiv086)(x, y); -} - -int MPcmp(struct MP x, struct MP y) -{ - return ((cpu >= 386) ? MPcmp386 : MPcmp086)(x, y); -} - -/* -fg2MP086 PROC x:DWORD, fg:WORD - mov ax, WORD PTR [x] - mov dx, WORD PTR [x+2] - mov cx, ax - or cx, dx - jz ExitFg2MP - - mov cx, 1 SHL 14 + 30 - sub cx, fg - - or dx, dx - jns BitScanRight - - or ch, 80h - not ax - not dx - add ax, 1 - adc dx, 0 - -BitScanRight: - shl ax, 1 - rcl dx, 1 - dec cx - or dx, dx - jns BitScanRight - -ExitFg2MP: - mov Ans.Exp, cx - mov WORD PTR Ans.Mant+2, dx - mov WORD PTR Ans.Mant, ax - lea ax, Ans - mov dx, ds - ret -fg2MP086 ENDP -*/ -struct MP *fg2MP086(long x, int fg) -{ - _ASSERTE(0 && "fg2MP086 called"); - return &Ans; -} - -/* -fg2MP386 PROC x:DWORD, fg:WORD - mov bx, 1 SHL 14 + 30 - sub bx, fg -.386 - mov edx, x - - or edx, edx - jnz ChkNegMP - - mov bx, dx - jmp StoreAns - -ChkNegMP: - jns BitScanRight - - or bh, 80h - neg edx - -BitScanRight: - bsr ecx, edx - neg cx - add cx, 31 - sub bx, cx - shl edx, cl - -StoreAns: - mov Ans.Exp, bx - mov Ans.Mant, edx -.8086 - lea ax, Ans - mov dx, ds - ret -fg2MP386 ENDP -*/ -struct MP *fg2MP386(long x, int fg) -{ - _ASSERTE(0 && "fg2MP386 called"); - return &Ans; -} - -struct MP *fg2MP(long x, int fg) -{ - return ((cpu >= 386) ? fg2MP386 : fg2MP086)(x, fg); -} -#endif diff --git a/fractint/common/parser.c b/fractint/common/parser.c deleted file mode 100644 index a429c559b..000000000 --- a/fractint/common/parser.c +++ /dev/null @@ -1,4925 +0,0 @@ -/* Parser.c (C) 1990, Mark C. Peterson, CompuServe [70441,3353] - All rights reserved. - - Code may be used in any program provided the author is credited - either during program execution or in the documentation. Source - code may be distributed only in combination with public domain or - shareware source code. Source code may be modified provided the - copyright notice and this message is left unchanged and all - modifications are clearly documented. - - I would appreciate a copy of any work which incorporates this code, - however this is optional. - - Mark C. Peterson - 405-C Queen St. Suite #181 - Southington, CT 06489 - (203) 276-9721 -*/ - -/* Chuck Ebbert (CompuServe [76306,1226] ) changed code marked 'CAE fp' */ -/* for fast 387 floating-point math. See PARSERA.ASM and PARSERFP.C */ -/* (13 Dec 1992.) */ -/* */ -/* Modified 12 July 1993 by CAE to fix crash when formula not found. */ - -#include -#include -#include - - /* see Fractint.c for a description of the "include" hierarchy */ -#include "port.h" -#include "prototyp.h" -#include "drivers.h" - -#ifdef WATCH_MP -double x1, y1, x2, y2; -#endif - -enum MATH_TYPE MathType = D_MATH; -/* moved _LCMPLX and union ARg to mpmath.h -6-20-90 TIW */ - -#define MAX_OPS 250 -#define MAX_ARGS 100 -#define MAX_BOXX 8192 /* max size of boxx array */ - -unsigned Max_Ops = MAX_OPS; -unsigned Max_Args = MAX_ARGS; - -unsigned long number_of_ops, number_of_loads, number_of_stores, number_of_jumps; - -struct PEND_OP { - void (*f)(void); - int p; -}; - -#if !defined(XFRACT) && !defined(_WIN32) -/* reuse an array in the decoder */ -JUMP_CONTROL_ST *jump_control = (JUMP_CONTROL_ST *) sizeofstring; -#else -JUMP_CONTROL_ST jump_control[MAX_JUMPS]; -#endif - -int jump_index, InitJumpIndex; - -static int frm_prescan (FILE * open_file); - -#define CASE_TERMINATOR case',':\ - case '\n':\ - case '(':\ - case ')':\ - case '!':\ - case '=':\ - case '<':\ - case '>':\ - case '|':\ - case '&':\ - case '}':\ - case ':':\ - case '+':\ - case '-':\ - case '*':\ - case '/':\ - case '^' - -#define CASE_ALPHA case 'a':\ - case 'b':\ - case 'c':\ - case 'd':\ - case 'e':\ - case 'f':\ - case 'g':\ - case 'h':\ - case 'i':\ - case 'j':\ - case 'k':\ - case 'l':\ - case 'm':\ - case 'n':\ - case 'o':\ - case 'p':\ - case 'q':\ - case 'r':\ - case 's':\ - case 't':\ - case 'u':\ - case 'v':\ - case 'w':\ - case 'x':\ - case 'y':\ - case 'z' - -#define CASE_NUM case '0':\ - case '1':\ - case '2':\ - case '3':\ - case '4':\ - case '5':\ - case '6':\ - case '7':\ - case '8':\ - case '9' - - /* token_type definitions */ -#define NOT_A_TOKEN 0 -#define PARENS 1 -#define PARAM_VARIABLE 2 -#define USER_NAMED_VARIABLE 3 -#define PREDEFINED_VARIABLE 4 -#define REAL_CONSTANT 5 -#define COMPLEX_CONSTANT 6 -#define FUNCTION 7 -#define PARAM_FUNCTION 8 -#define FLOW_CONTROL 9 -#define OPERATOR 10 -#define END_OF_FORMULA 11 - - /* token IDs */ -#define END_OF_FILE 1 -#define ILLEGAL_CHARACTER 2 -#define ILLEGAL_VARIABLE_NAME 3 -#define TOKEN_TOO_LONG 4 -#define FUNC_USED_AS_VAR 5 -#define JUMP_MISSING_BOOLEAN 6 -#define JUMP_WITH_ILLEGAL_CHAR 7 -#define UNDEFINED_FUNCTION 8 -#define ILLEGAL_OPERATOR 9 -#define ILL_FORMED_CONSTANT 10 -#define OPEN_PARENS 1 -#define CLOSE_PARENS -1 - -struct token_st { - char token_str[80]; - int token_type; - int token_id; - _CMPLX token_const; -}; - - -/* CAE fp added MAX_STORES and LOADS */ -/* MAX_STORES must be even to make Unix alignment work */ -/* TW made dependent on Max_Ops */ - -#define MAX_STORES ((Max_Ops/4)*2) /* at most only half the ops can be stores */ -#define MAX_LOADS ((unsigned)(Max_Ops*.8)) /* and 80% can be loads */ -/* PB 901103 made some of the following static for safety */ - -static struct PEND_OP o[2300]; - -#if 0 -static void ops_allocate(void); -static void vars_allocate(void); -#endif - -struct var_list_st { - char name[34]; - struct var_list_st * next_item; -} * var_list; - -struct const_list_st { - _CMPLX complex_const; - struct const_list_st * next_item; -} * complx_list, * real_list; - -static void parser_allocate(void); - -union Arg *Arg1, *Arg2; -/* PB 910417 removed unused "a" array */ - -/* CAE fp made some of the following non-static for PARSERA.ASM */ -/* Some of these variables should be renamed for safety */ -union Arg s[20], **Store, **Load; /* static CAE fp */ -int StoPtr, LodPtr, OpPtr; /* static CAE fp */ -int var_count; -int complx_count; -int real_count; - - -void (**f)(void) = (void (**)(void))0; /* static CAE fp */ - -short int ismand = 1; - -unsigned int posp, vsp, LastOp; /* CAE fp made non-static */ -static unsigned int n, NextOp, InitN; -static int paren, ExpectingArg; -struct ConstArg *v = (struct ConstArg *)0; /* was static CAE fp */ -int InitLodPtr, InitStoPtr, InitOpPtr, LastInitOp; /* was static CAE fp */ -static int Delta16; -double fgLimit; /* TIW 05-04-91 */ -static double fg; -static int ShiftBack; /* TIW 06-18-90 */ -static int SetRandom; /* MCP 11-21-91 */ -static int Randomized; -static unsigned long RandNum; -short uses_p1, uses_p2, uses_p3, uses_p4, uses_p5, uses_jump; -short uses_ismand; -unsigned int chars_in_formula; - -#if !defined(XFRACT) -#define ChkLongDenom(denom)\ - if ((denom == 0 || overflow) && save_release > 1920) {\ - overflow = 1;\ - return;\ - }\ - else if (denom == 0)\ - return -#endif - -#define ChkFloatDenom(denom)\ - if (fabs(denom) <= DBL_MIN) {\ - if (save_release > 1920) overflow = 1;\ - return;\ - } - -#define LastSqr v[4].a - -/* ParseErrs() defines; all calls to ParseErrs(), or any variable which will - be used as the argument in a call to ParseErrs(), should use one of these - defines. -*/ - -#define PE_NO_ERRORS_FOUND -1 -#define PE_SHOULD_BE_ARGUMENT 0 -#define PE_SHOULD_BE_OPERATOR 1 -#define PE_NEED_A_MATCHING_OPEN_PARENS 2 -#define PE_NEED_MORE_CLOSE_PARENS 3 -#define PE_UNDEFINED_OPERATOR 4 -#define PE_UNDEFINED_FUNCTION 5 -#define PE_TABLE_OVERFLOW 6 -#define PE_NO_MATCH_RIGHT_PAREN 7 -#define PE_NO_LEFT_BRACKET_FIRST_LINE 8 -#define PE_UNEXPECTED_EOF 9 -#define PE_INVALID_SYM_USING_NOSYM 10 -#define PE_FORMULA_TOO_LARGE 11 -#define PE_INSUFFICIENT_MEM_FOR_TYPE_FORMULA 12 -#define PE_COULD_NOT_OPEN_FILE_WHERE_FORMULA_LOCATED 13 -#define PE_JUMP_NOT_FIRST 14 -#define PE_NO_CHAR_AFTER_THIS_JUMP 15 -#define PE_JUMP_NEEDS_BOOLEAN 16 -#define PE_ENDIF_REQUIRED_AFTER_ELSE 17 -#define PE_ENDIF_WITH_NO_IF 18 -#define PE_MISPLACED_ELSE_OR_ELSEIF 19 -#define PE_UNMATCHED_IF_IN_INIT_SECTION 20 -#define PE_IF_WITH_NO_ENDIF 21 -#define PE_ERROR_IN_PARSING_JUMP_STATEMENTS 22 -#define PE_TOO_MANY_JUMPS 23 -#define PE_FORMULA_NAME_TOO_LARGE 24 -#define PE_ILLEGAL_ASSIGNMENT 25 -#define PE_ILLEGAL_VAR_NAME 26 -#define PE_INVALID_CONST 27 -#define PE_ILLEGAL_CHAR 28 -#define PE_NESTING_TO_DEEP 29 -#define PE_UNMATCHED_MODULUS 30 -#define PE_FUNC_USED_AS_VAR 31 -#define PE_NO_NEG_AFTER_EXPONENT 32 -#define PE_TOKEN_TOO_LONG 33 -#define PE_SECOND_COLON 34 -#define PE_INVALID_CALL_TO_PARSEERRS 35 - -static char *ParseErrs(int which) -{ - int lasterr; - static char e0[] = {"Should be an Argument"}; - static char e1[] = {"Should be an Operator"}; - static char e2[] = {"')' needs a matching '('"}; - static char e3[] = {"Need more ')'"}; - static char e4[] = {"Undefined Operator"}; - static char e5[] = {"Undefined Function"}; - static char e6[] = {"Table overflow"}; - static char e7[] = {"Didn't find matching ')' in symmetry declaration"}; - static char e8[] = {"No '{' found on first line"}; - static char e9[] = {"Unexpected EOF!"}; - static char e10[] = {"Symmetry below is invalid, will use NOSYM"}; - static char e11[] = {"Formula is too large"}; - static char e12[] = {"Insufficient memory to run fractal type 'formula'"}; - static char e13[] = {"Could not open file where formula located"}; - static char e14[] = {"No characters may precede jump instruction"}; - static char e15[] = {"No characters may follow this jump instruction"}; - static char e16[] = {"Jump instruction missing required (boolean argument)"}; - static char e17[] = {"Next jump after \"else\" must be \"endif\""}; - static char e18[] = {"\"endif\" has no matching \"if\""}; - static char e19[] = {"Misplaced \"else\" or \"elseif()\""}; - static char e20[] = {"\"if ()\" in initialization has no matching \"endif\""}; - static char e21[] = {"\"if ()\" has no matching \"endif\""}; - static char e22[] = {"Error in parsing jump statements"}; - static char e23[] = {"Formula has too many jump commands"}; - static char e24[] = {"Formula name has too many characters"}; - static char e25[] = {"Only variables are allowed to left of assignment"}; - static char e26[] = {"Illegal variable name"}; - static char e27[] = {"Invalid constant expression"}; - static char e28[] = {"This character not supported by parser"}; - static char e29[] = {"Nesting of parentheses exceeds maximum depth"}; - static char e30[] = {"Unmatched modulus operator \"|\" in this expression"}; /*last one */ - static char e31[] = {"Can't use function name as variable"}; - static char e32[] = {"Negative exponent must be enclosed in parens"}; - static char e33[] = {"Variable or constant exceeds 32 character limit"}; - static char e34[] = {"Only one \":\" permitted in a formula"}; - static char e35[] = {"Invalid ParseErrs code"}; - static char *ErrStrings[] = { e0,e1,e2,e3,e4,e5, - e6,e7,e8,e9,e10, - e11,e12,e13,e14,e15, - e16,e17,e18,e19,e20, - e21,e22,e23,e24,e25, - e26, e27, e28, e29, e30, - e31, e32, e33, e34, e35 - }; - lasterr = sizeof(ErrStrings)/sizeof(ErrStrings[0]) - 1; - if (which > lasterr) - which = lasterr; - return (char *)ErrStrings[which]; -} - -/* use the following when only float functions are implemented to - get MP math and Integer math */ - -#if !defined(XFRACT) -#define FUNCT -#ifdef FUNCT /* use function form save space - isn't really slower */ - -static void mStkFunct(void (*fct)(void)) /* call lStk via dStk */ -{ - Arg1->d = MPC2cmplx(Arg1->m); - (*fct)(); - Arg1->m = cmplx2MPC(Arg1->d); -} - -static void lStkFunct(void (*fct)(void)) /* call lStk via dStk */ -{ - double y; - /* - intermediate variable needed for safety because of - different size of double and long in Arg union - */ - y = (double)Arg1->l.y / fg; - Arg1->d.x = (double)Arg1->l.x / fg; - Arg1->d.y = y; - (*fct)(); - if (fabs(Arg1->d.x) < fgLimit && fabs(Arg1->d.y) < fgLimit) { - Arg1->l.x = (long)(Arg1->d.x * fg); - Arg1->l.y = (long)(Arg1->d.y * fg); - } - else - overflow = 1; -} -#else /* use Macro form for (?) greater speed */ - /* call lStk via dStk */ -#define mStkFunct(fct) \ - Arg1->d = MPC2cmplx(Arg1->m);\ - (*fct)();\ - Arg1->m = cmplx2MPC(Arg1->d); - - -/* call lStk via dStk */ -#define lStkFunct(fct) {\ - double y;\ - y = (double)Arg1->l.y / fg;\ - Arg1->d.x = (double)Arg1->l.x / fg;\ - Arg1->d.y = y;\ - (*fct)();\ - if (fabs(Arg1->d.x) < fgLimit && fabs(Arg1->d.y) < fgLimit) {\ - Arg1->l.x = (long)(Arg1->d.x * fg);\ - Arg1->l.y = (long)(Arg1->d.y * fg);\ - }\ - else\ - overflow = 1;\ -} - - -#endif - -#endif - -/* Random number code, MCP 11-21-91 */ - -unsigned long NewRandNum(void) -{ - return RandNum = ((RandNum << 15) + rand15()) ^ RandNum; -} - -void lRandom(void) -{ - v[7].a.l.x = NewRandNum() >> (32 - bitshift); - v[7].a.l.y = NewRandNum() >> (32 - bitshift); -} - -void dRandom(void) -{ - long x, y; - - /* Use the same algorithm as for fixed math so that they will generate - the same fractals when the srand() function is used. */ - x = NewRandNum() >> (32 - bitshift); - y = NewRandNum() >> (32 - bitshift); - v[7].a.d.x = ((double)x / (1L << bitshift)); - v[7].a.d.y = ((double)y / (1L << bitshift)); - -} - -#if !defined(XFRACT) -void mRandom(void) -{ - long x, y; - - /* Use the same algorithm as for fixed math so that they will generate - the same fractals when the srand() function is used. */ - x = NewRandNum() >> (32 - bitshift); - y = NewRandNum() >> (32 - bitshift); - v[7].a.m.x = *fg2MP(x, bitshift); - v[7].a.m.y = *fg2MP(y, bitshift); -} -#endif - -void SetRandFnct(void) -{ - unsigned Seed; - - if (!SetRandom) - RandNum = Arg1->l.x ^ Arg1->l.y; - - Seed = (unsigned)RandNum ^ (unsigned)(RandNum >> 16); - srand(Seed); - SetRandom = 1; - - /* Clear out the seed */ - NewRandNum(); - NewRandNum(); - NewRandNum(); -} - -void RandomSeed(void) -{ - time_t ltime; - - /* Use the current time to randomize the random number sequence. */ - time(<ime); - srand((unsigned int)ltime); - - NewRandNum(); - NewRandNum(); - NewRandNum(); - Randomized = 1; -} - -#if !defined(XFRACT) -void lStkSRand(void) -{ - SetRandFnct(); - lRandom(); - Arg1->l = v[7].a.l; -} -#endif - -#if !defined(XFRACT) -void mStkSRand(void) -{ - Arg1->l.x = Arg1->m.x.Mant ^ (long)Arg1->m.x.Exp; - Arg1->l.y = Arg1->m.y.Mant ^ (long)Arg1->m.y.Exp; - SetRandFnct(); - mRandom(); - Arg1->m = v[7].a.m; -} -#endif - -void dStkSRand(void) -{ - Arg1->l.x = (long)(Arg1->d.x * (1L << bitshift)); - Arg1->l.y = (long)(Arg1->d.y * (1L << bitshift)); - SetRandFnct(); - dRandom(); - Arg1->d = v[7].a.d; -} - -void (*StkSRand)(void) = dStkSRand; - - -void dStkLodDup() -{ - Arg1+=2; - Arg2+=2; - *Arg2 = *Arg1 = *Load[LodPtr]; - LodPtr+=2; -} - -void dStkLodSqr() -{ - Arg1++; - Arg2++; - Arg1->d.y = Load[LodPtr]->d.x * Load[LodPtr]->d.y * 2.0; - Arg1->d.x = (Load[LodPtr]->d.x * Load[LodPtr]->d.x) - (Load[LodPtr]->d.y * Load[LodPtr]->d.y); - LodPtr++; -} - -void dStkLodSqr2() -{ - Arg1++; - Arg2++; - LastSqr.d.x = Load[LodPtr]->d.x * Load[LodPtr]->d.x; - LastSqr.d.y = Load[LodPtr]->d.y * Load[LodPtr]->d.y; - Arg1->d.y = Load[LodPtr]->d.x * Load[LodPtr]->d.y * 2.0; - Arg1->d.x = LastSqr.d.x - LastSqr.d.y; - LastSqr.d.x += LastSqr.d.y; - LastSqr.d.y = 0; - LodPtr++; -} - -void dStkStoDup(){} -void dStkStoSqr(){} -void dStkStoSqr0(){} - -void dStkLodDbl() -{ - Arg1++; - Arg2++; - Arg1->d.x = Load[LodPtr]->d.x * 2.0; - Arg1->d.y = Load[LodPtr]->d.y * 2.0; - LodPtr++; -} - -void dStkStoDbl(){} -void dStkReal2(){} - -void dStkSqr0() -{ - LastSqr.d.y = Arg1->d.y * Arg1->d.y; /* use LastSqr as temp storage */ - Arg1->d.y = Arg1->d.x * Arg1->d.y * 2.0; - Arg1->d.x = Arg1->d.x * Arg1->d.x - LastSqr.d.y; -} - - -void dStkSqr3() -{ - Arg1->d.x = Arg1->d.x * Arg1->d.x; -} - - - -void dStkAbs(void) { - Arg1->d.x = fabs(Arg1->d.x); - Arg1->d.y = fabs(Arg1->d.y); -} - -#if !defined(XFRACT) -void mStkAbs(void) { - if (Arg1->m.x.Exp < 0) - Arg1->m.x.Exp = -Arg1->m.x.Exp; - if (Arg1->m.y.Exp < 0) - Arg1->m.y.Exp = -Arg1->m.y.Exp; -} - -void lStkAbs(void) { - Arg1->l.x = labs(Arg1->l.x); - Arg1->l.y = labs(Arg1->l.y); -} -#endif - -void (*StkAbs)(void) = dStkAbs; - -void dStkSqr(void) { - LastSqr.d.x = Arg1->d.x * Arg1->d.x; - LastSqr.d.y = Arg1->d.y * Arg1->d.y; - Arg1->d.y = Arg1->d.x * Arg1->d.y * 2.0; - Arg1->d.x = LastSqr.d.x - LastSqr.d.y; - LastSqr.d.x += LastSqr.d.y; - LastSqr.d.y = 0; -} - -#if !defined(XFRACT) -void mStkSqr(void) { - LastSqr.m.x = *MPmul(Arg1->m.x, Arg1->m.x); - LastSqr.m.y = *MPmul(Arg1->m.y, Arg1->m.y); - Arg1->m.y = *MPmul(Arg1->m.x, Arg1->m.y); - Arg1->m.y.Exp++; - Arg1->m.x = *MPsub(LastSqr.m.x, LastSqr.m.y); - LastSqr.m.x = *MPadd(LastSqr.m.x, LastSqr.m.y); - LastSqr.m.y.Mant = (long)(LastSqr.m.y.Exp = 0); -} - -void lStkSqr(void) { - LastSqr.l.x = multiply(Arg1->l.x, Arg1->l.x, bitshift); - LastSqr.l.y = multiply(Arg1->l.y, Arg1->l.y, bitshift); - Arg1->l.y = multiply(Arg1->l.x, Arg1->l.y, bitshift) << 1; - Arg1->l.x = LastSqr.l.x - LastSqr.l.y; - LastSqr.l.x += LastSqr.l.y; - LastSqr.l.y = 0L; -} -#endif - -void (*StkSqr)(void) = dStkSqr; - -void dStkAdd(void) { - Arg2->d.x += Arg1->d.x; - Arg2->d.y += Arg1->d.y; - Arg1--; - Arg2--; -} - -#if !defined(XFRACT) - -void mStkAdd(void) { - Arg2->m = MPCadd(Arg2->m, Arg1->m); - Arg1--; - Arg2--; -} - -void lStkAdd(void) { - Arg2->l.x += Arg1->l.x; - Arg2->l.y += Arg1->l.y; - Arg1--; - Arg2--; -} -#endif - -void (*StkAdd)(void) = dStkAdd; - -void dStkSub(void) { - Arg2->d.x -= Arg1->d.x; - Arg2->d.y -= Arg1->d.y; - Arg1--; - Arg2--; -} - -#if !defined(XFRACT) -void mStkSub(void) { - Arg2->m = MPCsub(Arg2->m, Arg1->m); - Arg1--; - Arg2--; -} - -void lStkSub(void) { - Arg2->l.x -= Arg1->l.x; - Arg2->l.y -= Arg1->l.y; - Arg1--; - Arg2--; -} -#endif - -void (*StkSub)(void) = dStkSub; - -void dStkConj(void) { - Arg1->d.y = -Arg1->d.y; -} - -#if !defined(XFRACT) -void mStkConj(void) { - Arg1->m.y.Exp ^= 0x8000; -} - -void lStkConj(void) { - Arg1->l.y = -Arg1->l.y; -} -#endif - -void (*StkConj)(void) = dStkConj; - -void dStkFloor(void) { - Arg1->d.x = floor(Arg1->d.x); - Arg1->d.y = floor(Arg1->d.y); -} - -#if !defined(XFRACT) -void mStkFloor(void) { - mStkFunct(dStkFloor); /* call lStk via dStk */ -} - -void lStkFloor(void) { - /* - * Kill fractional part. This operation truncates negative numbers - * toward negative infinity as desired. - */ - Arg1->l.x = (Arg1->l.x) >> bitshift; - Arg1->l.y = (Arg1->l.y) >> bitshift; - Arg1->l.x = (Arg1->l.x) << bitshift; - Arg1->l.y = (Arg1->l.y) << bitshift; -} -#endif - -void (*StkFloor)(void) = dStkFloor; - -void dStkCeil(void) { - Arg1->d.x = ceil(Arg1->d.x); - Arg1->d.y = ceil(Arg1->d.y); -} - -#if !defined(XFRACT) -void mStkCeil(void) { - mStkFunct(dStkCeil); /* call lStk via dStk */ -} - -void lStkCeil(void) { - /* the shift operation does the "floor" operation, so we - negate everything before the operation */ - Arg1->l.x = (-Arg1->l.x) >> bitshift; - Arg1->l.y = (-Arg1->l.y) >> bitshift; - Arg1->l.x = -((Arg1->l.x) << bitshift); - Arg1->l.y = -((Arg1->l.y) << bitshift); -} -#endif - -void (*StkCeil)(void) = dStkCeil; - -void dStkTrunc(void) { - Arg1->d.x = (int)(Arg1->d.x); - Arg1->d.y = (int)(Arg1->d.y); -} - -#if !defined(XFRACT) -void mStkTrunc(void) { - mStkFunct(dStkTrunc); /* call lStk via dStk */ -} - -void lStkTrunc(void) { - /* shifting and shifting back truncates positive numbers, - so we make the numbers positive */ - int signx, signy; - signx = sign(Arg1->l.x); - signy = sign(Arg1->l.y); - Arg1->l.x = labs(Arg1->l.x); - Arg1->l.y = labs(Arg1->l.y); - Arg1->l.x = (Arg1->l.x) >> bitshift; - Arg1->l.y = (Arg1->l.y) >> bitshift; - Arg1->l.x = (Arg1->l.x) << bitshift; - Arg1->l.y = (Arg1->l.y) << bitshift; - Arg1->l.x = signx*Arg1->l.x; - Arg1->l.y = signy*Arg1->l.y; -} -#endif - -void (*StkTrunc)(void) = dStkTrunc; - -void dStkRound(void) { - Arg1->d.x = floor(Arg1->d.x+.5); - Arg1->d.y = floor(Arg1->d.y+.5); -} - -#if !defined(XFRACT) -void mStkRound(void) { - mStkFunct(dStkRound); /* call lStk via dStk */ -} - -void lStkRound(void) { - /* Add .5 then truncate */ - Arg1->l.x += (1L<l.y += (1L<d.y = Arg1->d.x = 0.0; -} - -#if !defined(XFRACT) -void mStkZero(void) { - Arg1->m.x.Mant = Arg1->m.x.Exp = 0; - Arg1->m.y.Mant = Arg1->m.y.Exp = 0; -} - -void lStkZero(void) { - Arg1->l.y = Arg1->l.x = 0; -} -#endif - -void (*StkZero)(void) = dStkZero; - -void dStkOne(void) { - Arg1->d.x = 1.0; - Arg1->d.y = 0.0; -} - -#if !defined(XFRACT) -void mStkOne(void) { - Arg1->m = MPCone; -} - -void lStkOne(void) { - Arg1->l.x = (long) fg; - Arg1->l.y = 0L; -} -#endif - -void (*StkOne)(void) = dStkOne; - - -void dStkReal(void) { - Arg1->d.y = 0.0; -} - -#if !defined(XFRACT) -void mStkReal(void) { - Arg1->m.y.Mant = (long)(Arg1->m.y.Exp = 0); -} - -void lStkReal(void) { - Arg1->l.y = 0l; -} -#endif - -void (*StkReal)(void) = dStkReal; - -void dStkImag(void) { - Arg1->d.x = Arg1->d.y; - Arg1->d.y = 0.0; -} - -#if !defined(XFRACT) -void mStkImag(void) { - Arg1->m.x = Arg1->m.y; - Arg1->m.y.Mant = (long)(Arg1->m.y.Exp = 0); -} - -void lStkImag(void) { - Arg1->l.x = Arg1->l.y; - Arg1->l.y = 0l; -} -#endif - -void (*StkImag)(void) = dStkImag; - -void dStkNeg(void) { - Arg1->d.x = -Arg1->d.x; - Arg1->d.y = -Arg1->d.y; -} - -#if !defined(XFRACT) -void mStkNeg(void) { - Arg1->m.x.Exp ^= 0x8000; - Arg1->m.y.Exp ^= 0x8000; -} - -void lStkNeg(void) { - Arg1->l.x = -Arg1->l.x; - Arg1->l.y = -Arg1->l.y; -} -#endif - -void (*StkNeg)(void) = dStkNeg; - -void dStkMul(void) { - FPUcplxmul(&Arg2->d, &Arg1->d, &Arg2->d); - Arg1--; - Arg2--; -} - -#if !defined(XFRACT) -void mStkMul(void) { - Arg2->m = MPCmul(Arg2->m, Arg1->m); - Arg1--; - Arg2--; -} - -void lStkMul(void) { - long x, y; - - x = multiply(Arg2->l.x, Arg1->l.x, bitshift) - - multiply(Arg2->l.y, Arg1->l.y, bitshift); - y = multiply(Arg2->l.y, Arg1->l.x, bitshift) + - multiply(Arg2->l.x, Arg1->l.y, bitshift); - Arg2->l.x = x; - Arg2->l.y = y; - Arg1--; - Arg2--; -} -#endif - -void (*StkMul)(void) = dStkMul; - -void dStkDiv(void) { - FPUcplxdiv(&Arg2->d, &Arg1->d, &Arg2->d); - Arg1--; - Arg2--; -} - -#if !defined(XFRACT) -void mStkDiv(void) { - Arg2->m = MPCdiv(Arg2->m, Arg1->m); - Arg1--; - Arg2--; -} - -void lStkDiv(void) { - long x, y, mod, x2, y2; - - mod = multiply(Arg1->l.x, Arg1->l.x, bitshift) + - multiply(Arg1->l.y, Arg1->l.y, bitshift); - x = divide(Arg1->l.x, mod, bitshift); - y = -divide(Arg1->l.y, mod, bitshift); - /* pb 900617 changed next 4 lines to use x2,y2 instead of x,y */ - x2 = multiply(Arg2->l.x, x, bitshift) - multiply(Arg2->l.y, y, bitshift); - y2 = multiply(Arg2->l.y, x, bitshift) + multiply(Arg2->l.x, y, bitshift); - Arg2->l.x = x2; - Arg2->l.y = y2; - Arg1--; - Arg2--; -} -#endif - -void (*StkDiv)(void) = dStkDiv; - -void dStkMod(void) { - Arg1->d.x = (Arg1->d.x * Arg1->d.x) + (Arg1->d.y * Arg1->d.y); - Arg1->d.y = 0.0; -} - -#if !defined(XFRACT) -void mStkMod(void) { - Arg1->m.x = MPCmod(Arg1->m); - Arg1->m.y.Mant = (long)(Arg1->m.y.Exp = 0); -} - -void lStkMod(void) { -/* Arg1->l.x = multiply(Arg2->l.x, Arg1->l.x, bitshift) + */ -/* multiply(Arg2->l.y, Arg1->l.y, bitshift); */ -/*** I don't understand how this ever worked correctly! JCO 12/31/94 ***/ - Arg1->l.x = multiply(Arg1->l.x, Arg1->l.x, bitshift) + - multiply(Arg1->l.y, Arg1->l.y, bitshift); - if (Arg1->l.x < 0) - overflow = 1; - Arg1->l.y = 0L; -} - -void lStkModOld(void) { - Arg1->l.x = multiply(Arg2->l.x, Arg1->l.x, bitshift) + - multiply(Arg2->l.y, Arg1->l.y, bitshift); - if (Arg1->l.x < 0) - overflow = 1; - Arg1->l.y = 0L; -} -#endif - -void (*StkMod)(void) = dStkMod; - -void StkSto(void) { - *Store[StoPtr++] = *Arg1; -} - -void (*PtrStkSto)(void) = StkSto; - -void StkLod(void) { - Arg1++; - Arg2++; - *Arg1 = *Load[LodPtr++]; -} - -void StkClr(void) { - s[0] = *Arg1; - Arg1 = &s[0]; - Arg2 = Arg1; - Arg2--; -} - -void (*PtrStkClr)(void) = StkClr; - -/* MCP 4-9-91, Added Flip() */ - -void dStkFlip(void) { - double t; - - t = Arg1->d.x; - Arg1->d.x = Arg1->d.y; - Arg1->d.y = t; -} - -#if !defined(XFRACT) -void mStkFlip(void) { - struct MP t; - - t = Arg1->m.x; - Arg1->m.x = Arg1->m.y; - Arg1->m.y = t; -} - -void lStkFlip(void) { - long t; - - t = Arg1->l.x; - Arg1->l.x = Arg1->l.y; - Arg1->l.y = t; -} -#endif - -void (*StkFlip)(void) = dStkFlip; - -void dStkSin(void) { - double sinx, cosx, sinhy, coshy; - - FPUsincos(&Arg1->d.x, &sinx, &cosx); - FPUsinhcosh(&Arg1->d.y, &sinhy, &coshy); - Arg1->d.x = sinx*coshy; - Arg1->d.y = cosx*sinhy; -} - -#if !defined(XFRACT) -void mStkSin(void) { - mStkFunct(dStkSin); /* call lStk via dStk */ -} - -void lStkSin(void) { - long x, y, sinx, cosx, sinhy, coshy; - x = Arg1->l.x >> Delta16; - y = Arg1->l.y >> Delta16; - SinCos086(x, &sinx, &cosx); - SinhCosh086(y, &sinhy, &coshy); - Arg1->l.x = multiply(sinx, coshy, ShiftBack); /* TIW 06-18-90 */ - Arg1->l.y = multiply(cosx, sinhy, ShiftBack); /* TIW 06-18-90 */ -} -#endif - -void (*StkSin)(void) = dStkSin; - -/* The following functions are supported by both the parser and for fn - variable replacement. TIW 04-22-91 */ - -void dStkTan(void) { - double sinx, cosx, sinhy, coshy, denom; - Arg1->d.x *= 2; - Arg1->d.y *= 2; - FPUsincos(&Arg1->d.x, &sinx, &cosx); - FPUsinhcosh(&Arg1->d.y, &sinhy, &coshy); - denom = cosx + coshy; - ChkFloatDenom(denom); - Arg1->d.x = sinx/denom; - Arg1->d.y = sinhy/denom; -} - -#if !defined(XFRACT) -void mStkTan(void) { - mStkFunct(dStkTan); /* call lStk via dStk */ -} - -void lStkTan(void) { - long x, y, sinx, cosx, sinhy, coshy, denom; - x = Arg1->l.x >> Delta16; - x = x << 1; - y = Arg1->l.y >> Delta16; - y = y << 1; - SinCos086(x, &sinx, &cosx); - SinhCosh086(y, &sinhy, &coshy); - denom = cosx + coshy; - ChkLongDenom(denom); - Arg1->l.x = divide(sinx,denom,bitshift); - Arg1->l.y = divide(sinhy,denom,bitshift); -} -#endif - -void (*StkTan)(void) = dStkTan; - -void dStkTanh(void) { - double siny, cosy, sinhx, coshx, denom; - Arg1->d.x *= 2; - Arg1->d.y *= 2; - FPUsincos(&Arg1->d.y, &siny, &cosy); - FPUsinhcosh(&Arg1->d.x, &sinhx, &coshx); - denom = coshx + cosy; - ChkFloatDenom(denom); - Arg1->d.x = sinhx/denom; - Arg1->d.y = siny/denom; -} - -#if !defined(XFRACT) -void mStkTanh(void) { - mStkFunct(dStkTanh); /* call lStk via dStk */ -} - -void lStkTanh(void) { - long x, y, siny, cosy, sinhx, coshx, denom; - x = Arg1->l.x >> Delta16; - x = x << 1; - y = Arg1->l.y >> Delta16; - y = y << 1; - SinCos086(y, &siny, &cosy); - SinhCosh086(x, &sinhx, &coshx); - denom = coshx + cosy; - ChkLongDenom(denom); - Arg1->l.x = divide(sinhx,denom,bitshift); - Arg1->l.y = divide(siny,denom,bitshift); -} -#endif - -void (*StkTanh)(void) = dStkTanh; - -void dStkCoTan(void) { - double sinx, cosx, sinhy, coshy, denom; - Arg1->d.x *= 2; - Arg1->d.y *= 2; - FPUsincos(&Arg1->d.x, &sinx, &cosx); - FPUsinhcosh(&Arg1->d.y, &sinhy, &coshy); - denom = coshy - cosx; - ChkFloatDenom(denom); - Arg1->d.x = sinx/denom; - Arg1->d.y = -sinhy/denom; -} - -#if !defined(XFRACT) -void mStkCoTan(void) { - mStkFunct(dStkCoTan); /* call lStk via dStk */ -} - -void lStkCoTan(void) { - long x, y, sinx, cosx, sinhy, coshy, denom; - x = Arg1->l.x >> Delta16; - x = x << 1; - y = Arg1->l.y >> Delta16; - y = y << 1; - SinCos086(x, &sinx, &cosx); - SinhCosh086(y, &sinhy, &coshy); - denom = coshy - cosx; - ChkLongDenom(denom); - Arg1->l.x = divide(sinx,denom,bitshift); - Arg1->l.y = -divide(sinhy,denom,bitshift); -} -#endif - -void (*StkCoTan)(void) = dStkCoTan; - -void dStkCoTanh(void) { - double siny, cosy, sinhx, coshx, denom; - Arg1->d.x *= 2; - Arg1->d.y *= 2; - FPUsincos(&Arg1->d.y, &siny, &cosy); - FPUsinhcosh(&Arg1->d.x, &sinhx, &coshx); - denom = coshx - cosy; - ChkFloatDenom(denom); - Arg1->d.x = sinhx/denom; - Arg1->d.y = -siny/denom; -} - -#if !defined(XFRACT) -void mStkCoTanh(void) { - mStkFunct(dStkCoTanh); /* call lStk via dStk */ -} - -void lStkCoTanh(void) { - long x, y, siny, cosy, sinhx, coshx, denom; - x = Arg1->l.x >> Delta16; - x = x << 1; - y = Arg1->l.y >> Delta16; - y = y << 1; - SinCos086(y, &siny, &cosy); - SinhCosh086(x, &sinhx, &coshx); - denom = coshx - cosy; - ChkLongDenom(denom); - Arg1->l.x = divide(sinhx,denom,bitshift); - Arg1->l.y = -divide(siny,denom,bitshift); -} -#endif - -void (*StkCoTanh)(void) = dStkCoTanh; - -/* The following functions are not directly used by the parser - support - for the parser was not provided because the existing parser language - represents these quite easily. They are used for fn variable support - in miscres.c but are placed here because they follow the pattern of - the other parser functions. TIW 04-22-91 */ - -void dStkRecip(void) { - double mod; - mod =Arg1->d.x * Arg1->d.x + Arg1->d.y * Arg1->d.y; - ChkFloatDenom(mod); - Arg1->d.x = Arg1->d.x/mod; - Arg1->d.y = -Arg1->d.y/mod; -} - -#if !defined(XFRACT) -void mStkRecip(void) { - struct MP mod; - mod = *MPadd(*MPmul(Arg1->m.x, Arg1->m.x),*MPmul(Arg1->m.y, Arg1->m.y)); - if (mod.Mant == 0L) { - overflow = 1; - return; - } - Arg1->m.x = *MPdiv(Arg1->m.x,mod); - Arg1->m.y = *MPdiv(Arg1->m.y,mod); - Arg1->m.y.Exp ^= 0x8000; -} - -void lStkRecip(void) { - long mod; - mod = multiply(Arg1->l.x,Arg1->l.x,bitshift) - + multiply(Arg1->l.y,Arg1->l.y,bitshift); - if (save_release > 1920) { - ChkLongDenom(mod); - } else if (mod<=0L) return; - Arg1->l.x = divide(Arg1->l.x,mod,bitshift); - Arg1->l.y = -divide(Arg1->l.y,mod,bitshift); -} -#endif - -void StkIdent(void) { /* do nothing - the function Z */ -} -/* End TIW 04-22-91 */ - -void dStkSinh(void) { - double siny, cosy, sinhx, coshx; - - FPUsincos(&Arg1->d.y, &siny, &cosy); - FPUsinhcosh(&Arg1->d.x, &sinhx, &coshx); - Arg1->d.x = sinhx*cosy; - Arg1->d.y = coshx*siny; -} - -#if !defined(XFRACT) -void mStkSinh(void) { - mStkFunct(dStkSinh); /* call lStk via dStk */ -} - -void lStkSinh(void) { - long x, y, sinhx, coshx, siny, cosy; - - x = Arg1->l.x >> Delta16; - y = Arg1->l.y >> Delta16; - SinCos086(y, &siny, &cosy); - SinhCosh086(x, &sinhx, &coshx); - Arg1->l.x = multiply(cosy, sinhx, ShiftBack); /* TIW 06-18-90 */ - Arg1->l.y = multiply(siny, coshx, ShiftBack); /* TIW 06-18-90 */ -} -#endif - -void (*StkSinh)(void) = dStkSinh; - -void dStkCos(void) { - double sinx, cosx, sinhy, coshy; - - FPUsincos(&Arg1->d.x, &sinx, &cosx); - FPUsinhcosh(&Arg1->d.y, &sinhy, &coshy); - Arg1->d.x = cosx*coshy; - Arg1->d.y = -sinx*sinhy; /* TIW 04-25-91 sign */ -} - -#if !defined(XFRACT) -void mStkCos(void) { - mStkFunct(dStkCos); /* call lStk via dStk */ -} - -void lStkCos(void) { - long x, y, sinx, cosx, sinhy, coshy; - - x = Arg1->l.x >> Delta16; - y = Arg1->l.y >> Delta16; - SinCos086(x, &sinx, &cosx); - SinhCosh086(y, &sinhy, &coshy); - Arg1->l.x = multiply(cosx, coshy, ShiftBack); /* TIW 06-18-90 */ - Arg1->l.y = -multiply(sinx, sinhy, ShiftBack); /* TIW 04-25-91 sign */ -} -#endif - -void (*StkCos)(void) = dStkCos; - -/* Bogus version of cos, to replicate bug which was in regular cos till v16: */ - -void dStkCosXX(void) { - dStkCos(); - Arg1->d.y = -Arg1->d.y; -} - -#if !defined(XFRACT) -void mStkCosXX(void) { - mStkFunct(dStkCosXX); /* call lStk via dStk */ -} - -void lStkCosXX(void) { - lStkCos(); - Arg1->l.y = -Arg1->l.y; -} -#endif - -void (*StkCosXX)(void) = dStkCosXX; - -void dStkCosh(void) { - double siny, cosy, sinhx, coshx; - - FPUsincos(&Arg1->d.y, &siny, &cosy); - FPUsinhcosh(&Arg1->d.x, &sinhx, &coshx); - Arg1->d.x = coshx*cosy; - Arg1->d.y = sinhx*siny; -} - -#if !defined(XFRACT) -void mStkCosh(void) { - mStkFunct(dStkCosh); /* call lStk via dStk */ -} - -void lStkCosh(void) { - long x, y, sinhx, coshx, siny, cosy; - - x = Arg1->l.x >> Delta16; - y = Arg1->l.y >> Delta16; - SinCos086(y, &siny, &cosy); - SinhCosh086(x, &sinhx, &coshx); - Arg1->l.x = multiply(cosy, coshx, ShiftBack); /* TIW 06-18-90 */ - Arg1->l.y = multiply(siny, sinhx, ShiftBack); /* TIW 06-18-90 */ -} -#endif - -void (*StkCosh)(void) = dStkCosh; - -/* TIW added arc functions here 11-25-94 */ - -void dStkASin(void) { - Arcsinz(Arg1->d, &(Arg1->d)); -} - -#if !defined(XFRACT) -void mStkASin(void) { - mStkFunct(dStkASin); -} - -void lStkASin(void) { - lStkFunct(dStkASin); -} -#endif - -void (*StkASin)(void) = dStkASin; - -void dStkASinh(void) { - Arcsinhz(Arg1->d, &(Arg1->d)); -} - -#if !defined(XFRACT) -void mStkASinh(void) { - mStkFunct(dStkASinh); -} - -void lStkASinh(void) { - lStkFunct(dStkASinh); -} -#endif - -void (*StkASinh)(void) = dStkASinh; - -void dStkACos(void) { - Arccosz(Arg1->d, &(Arg1->d)); -} - -#if !defined(XFRACT) -void mStkACos(void) { - mStkFunct(dStkACos); -} - -void lStkACos(void) { - lStkFunct(dStkACos); -} -#endif - -void (*StkACos)(void) = dStkACos; - -void dStkACosh(void) { - Arccoshz(Arg1->d, &(Arg1->d)); -} - -#if !defined(XFRACT) -void mStkACosh(void) { - mStkFunct(dStkACosh); -} - -void lStkACosh(void) { - lStkFunct(dStkACosh); -} -#endif - -void (*StkACosh)(void) = dStkACosh; - -void dStkATan(void) { - Arctanz(Arg1->d, &(Arg1->d)); -} - -#if !defined(XFRACT) -void mStkATan(void) { - mStkFunct(dStkATan); -} - -void lStkATan(void) { - lStkFunct(dStkATan); -} -#endif - -void (*StkATan)(void) = dStkATan; - -void dStkATanh(void) { - Arctanhz(Arg1->d, &(Arg1->d)); -} - -#if !defined(XFRACT) -void mStkATanh(void) { - mStkFunct(dStkATanh); -} - -void lStkATanh(void) { - lStkFunct(dStkATanh); -} -#endif - -void (*StkATanh)(void) = dStkATanh; - -void dStkSqrt(void) { - Arg1->d = ComplexSqrtFloat(Arg1->d.x, Arg1->d.y); -} - -#if !defined(XFRACT) -void mStkSqrt(void) { - mStkFunct(dStkSqrt); -} - -void lStkSqrt(void) { - /* lStkFunct(dStkSqrt); */ - Arg1->l = ComplexSqrtLong(Arg1->l.x, Arg1->l.y); -} -#endif - -void (*StkSqrt)(void) = dStkSqrt; - -void dStkCAbs(void) { - Arg1->d.x = sqrt(sqr(Arg1->d.x)+sqr(Arg1->d.y)); - Arg1->d.y = 0.0; -} - -#if !defined(XFRACT) -void mStkCAbs(void) { - mStkFunct(dStkCAbs); -} - -void lStkCAbs(void) { - lStkFunct(dStkCAbs); -} -#endif - -void (*StkCAbs)(void) = dStkCAbs; - -/* TIW end arc functions 11-25-94 */ - -void dStkLT(void) { - Arg2->d.x = (double)(Arg2->d.x < Arg1->d.x); - Arg2->d.y = 0.0; - Arg1--; - Arg2--; -} - -#if !defined(XFRACT) -void mStkLT(void) { - Arg2->m.x = *fg2MP((long)(MPcmp(Arg2->m.x, Arg1->m.x) == -1), 0); - Arg2->m.y.Mant = (long)(Arg2->m.y.Exp = 0); - Arg1--; - Arg2--; -} - -void lStkLT(void) { - Arg2->l.x = (long)(Arg2->l.x < Arg1->l.x) << bitshift; /* JCO 12/26/94 */ - Arg2->l.y = 0l; - Arg1--; - Arg2--; -} -#endif - -void (*StkLT)(void) = dStkLT; - -void dStkGT(void) { - Arg2->d.x = (double)(Arg2->d.x > Arg1->d.x); - Arg2->d.y = 0.0; - Arg1--; - Arg2--; -} - -#if !defined(XFRACT) -void mStkGT(void) { - Arg2->m.x = *fg2MP((long)(MPcmp(Arg2->m.x, Arg1->m.x) == 1), 0); - Arg2->m.y.Mant = (long)(Arg2->m.y.Exp = 0); - Arg1--; - Arg2--; -} - -void lStkGT(void) { - Arg2->l.x = (long)(Arg2->l.x > Arg1->l.x) << bitshift; /* JCO 12/26/94 */ - Arg2->l.y = 0l; - Arg1--; - Arg2--; -} -#endif - -void (*StkGT)(void) = dStkGT; - -void dStkLTE(void) { - Arg2->d.x = (double)(Arg2->d.x <= Arg1->d.x); - Arg2->d.y = 0.0; - Arg1--; - Arg2--; -} - -#if !defined(XFRACT) -void mStkLTE(void) { - int comp; - - comp = MPcmp(Arg2->m.x, Arg1->m.x); - Arg2->m.x = *fg2MP((long)(comp == -1 || comp == 0), 0); - Arg2->m.y.Mant = (long)(Arg2->m.y.Exp = 0); - Arg1--; - Arg2--; -} - -void lStkLTE(void) { - Arg2->l.x = (long)(Arg2->l.x <= Arg1->l.x) << bitshift; /* JCO 12/26/94 */ - Arg2->l.y = 0l; - Arg1--; - Arg2--; -} -#endif - -void (*StkLTE)(void) = dStkLTE; - -void dStkGTE(void) { - Arg2->d.x = (double)(Arg2->d.x >= Arg1->d.x); - Arg2->d.y = 0.0; - Arg1--; - Arg2--; -} - -#if !defined(XFRACT) -void mStkGTE(void) { - int comp; - - comp = MPcmp(Arg2->m.x, Arg1->m.x); - Arg2->m.x = *fg2MP((long)(comp == 1 || comp == 0), 0); - Arg2->m.y.Mant = (long)(Arg2->m.y.Exp = 0); - Arg1--; - Arg2--; -} - -void lStkGTE(void) { - Arg2->l.x = (long)(Arg2->l.x >= Arg1->l.x) << bitshift; /* JCO 12/26/94 */ - Arg2->l.y = 0l; - Arg1--; - Arg2--; -} -#endif - -void (*StkGTE)(void) = dStkGTE; - -void dStkEQ(void) { - Arg2->d.x = (double)(Arg2->d.x == Arg1->d.x); - Arg2->d.y = 0.0; - Arg1--; - Arg2--; -} - -#if !defined(XFRACT) -void mStkEQ(void) { - int comp; - - comp = MPcmp(Arg2->m.x, Arg1->m.x); - Arg2->m.x = *fg2MP((long)(comp == 0), 0); - Arg2->m.y.Mant = (long)(Arg2->m.y.Exp = 0); - Arg1--; - Arg2--; -} - -void lStkEQ(void) { - Arg2->l.x = (long)(Arg2->l.x == Arg1->l.x) << bitshift; /* JCO 12/26/94 */ - Arg2->l.y = 0l; - Arg1--; - Arg2--; -} -#endif - -void (*StkEQ)(void) = dStkEQ; - -void dStkNE(void) { - Arg2->d.x = (double)(Arg2->d.x != Arg1->d.x); - Arg2->d.y = 0.0; - Arg1--; - Arg2--; -} - -#if !defined(XFRACT) -void mStkNE(void) { - int comp; - - comp = MPcmp(Arg2->m.x, Arg1->m.x); - Arg2->m.x = *fg2MP((long)(comp != 0), 0); - Arg2->m.y.Mant = (long)(Arg2->m.y.Exp = 0); - Arg1--; - Arg2--; -} - -void lStkNE(void) { - Arg2->l.x = (long)(Arg2->l.x != Arg1->l.x) << bitshift; /* JCO 12/26/94 */ - Arg2->l.y = 0l; - Arg1--; - Arg2--; -} -#endif - -void (*StkNE)(void) = dStkNE; - -void dStkOR(void) { - Arg2->d.x = (double)(Arg2->d.x || Arg1->d.x); - Arg2->d.y = 0.0; - Arg1--; - Arg2--; -} - -#if !defined(XFRACT) -void mStkOR(void) { - Arg2->m.x = *fg2MP((long)(Arg2->m.x.Mant || Arg1->m.x.Mant), 0); - Arg2->m.y.Mant = (long)(Arg2->m.y.Exp = 0); - Arg1--; - Arg2--; -} - -void lStkOR(void) { - Arg2->l.x = (long)(Arg2->l.x || Arg1->l.x) << bitshift; /* JCO 12/26/94 */ - Arg2->l.y = 0l; - Arg1--; - Arg2--; -} -#endif - -void (*StkOR)(void) = dStkOR; - -void dStkAND(void) { - Arg2->d.x = (double)(Arg2->d.x && Arg1->d.x); - Arg2->d.y = 0.0; - Arg1--; - Arg2--; -} - -#if !defined(XFRACT) -void mStkAND(void) { - Arg2->m.x = *fg2MP((long)(Arg2->m.x.Mant && Arg1->m.x.Mant), 0); - Arg2->m.y.Mant = (long)(Arg2->m.y.Exp = 0); - Arg1--; - Arg2--; -} - -void lStkAND(void) { - Arg2->l.x = (long)(Arg2->l.x && Arg1->l.x) << bitshift; /* JCO 12/26/94 */ - Arg2->l.y = 0l; - Arg1--; - Arg2--; -} -#endif - -void (*StkAND)(void) = dStkAND; -void dStkLog(void) { - FPUcplxlog(&Arg1->d, &Arg1->d); -} - -#if !defined(XFRACT) -void mStkLog(void) { - mStkFunct(dStkLog); /* call lStk via dStk */ -} - -void lStkLog(void) { - lStkFunct(dStkLog); -} -#endif - -void (*StkLog)(void) = dStkLog; - -void FPUcplxexp(_CMPLX *x, _CMPLX *z) { - double e2x, siny, cosy; - - if (fpu >= 387) - FPUcplxexp387(x, z); - else { - e2x = exp(x->x); - FPUsincos(&x->y, &siny, &cosy); - z->x = e2x * cosy; - z->y = e2x * siny; - } -} - - void dStkExp(void) { - FPUcplxexp(&Arg1->d, &Arg1->d); - } - -#if !defined(XFRACT) -void mStkExp(void) { - mStkFunct(dStkExp); /* call lStk via dStk */ -} - -void lStkExp(void) { - lStkFunct(dStkExp); -} -#endif - -void (*StkExp)(void) = dStkExp; - -void dStkPwr(void) { - Arg2->d = ComplexPower(Arg2->d, Arg1->d); - Arg1--; - Arg2--; -} - -#if !defined(XFRACT) -void mStkPwr(void) { - _CMPLX x, y; - - x = MPC2cmplx(Arg2->m); - y = MPC2cmplx(Arg1->m); - x = ComplexPower(x, y); - Arg2->m = cmplx2MPC(x); - Arg1--; - Arg2--; -} - -void lStkPwr(void) { - _CMPLX x, y; - - x.x = (double)Arg2->l.x / fg; - x.y = (double)Arg2->l.y / fg; - y.x = (double)Arg1->l.x / fg; - y.y = (double)Arg1->l.y / fg; - x = ComplexPower(x, y); - if (fabs(x.x) < fgLimit && fabs(x.y) < fgLimit) { - Arg2->l.x = (long)(x.x * fg); - Arg2->l.y = (long)(x.y * fg); - } - else - overflow = 1; - Arg1--; - Arg2--; -} -#endif - -void (*StkPwr)(void) = dStkPwr; - -void EndInit(void) { - LastInitOp = OpPtr; - InitJumpIndex = jump_index; -} - -void (*PtrEndInit)(void) = EndInit; - -void StkJump (void) -{ - OpPtr = jump_control[jump_index].ptrs.JumpOpPtr; - LodPtr = jump_control[jump_index].ptrs.JumpLodPtr; - StoPtr = jump_control[jump_index].ptrs.JumpStoPtr; - jump_index = jump_control[jump_index].DestJumpIndex; -} - -void dStkJumpOnFalse (void) -{ - if (Arg1->d.x == 0) - StkJump(); - else - jump_index++; -} - -void mStkJumpOnFalse (void) -{ -#if !defined(XFRACT) - if (Arg1->m.x.Mant == 0) - StkJump(); - else - jump_index++; -#endif -} - -void lStkJumpOnFalse (void) -{ - if (Arg1->l.x == 0) - StkJump(); - else - jump_index++; -} - -void (*StkJumpOnFalse)(void) = dStkJumpOnFalse; - -void dStkJumpOnTrue (void) -{ - if (Arg1->d.x) - StkJump(); - else - jump_index++; -} - -void mStkJumpOnTrue (void) -{ -#if !defined(XFRACT) - if (Arg1->m.x.Mant) - StkJump(); - else - jump_index++; -#endif -} - -void lStkJumpOnTrue (void) -{ - if (Arg1->l.x) - StkJump(); - else - jump_index++; -} - -void (*StkJumpOnTrue)(void) = dStkJumpOnTrue; - -void StkJumpLabel (void) -{ - jump_index++; -} - - -unsigned SkipWhiteSpace(char *Str) { - unsigned n, Done; - - for (Done = n = 0; !Done; n++) { - switch (Str[n]) { - case ' ': - case '\t': - case '\n': - case '\r': - break; - default: - Done = 1; - } - } - return n - 1; -} - -/* detect if constant is part of a (a,b) construct */ -static int isconst_pair(char *Str) { - int n,j; - int answer = 0; - /* skip past first number */ - for (n = 0; isdigit(Str[n]) || Str[n] == '.'; n++); - if (Str[n] == ',') { - j = n + SkipWhiteSpace(&Str[n+1]) + 1; - if (isdigit(Str[j]) - || (Str[j] == '-' && (isdigit(Str[j+1]) || Str[j+1] == '.')) - || Str[j] == '.') { - answer = 1; - } - } - return answer; -} - -struct ConstArg *isconst(char *Str, int Len) { - _CMPLX z; - unsigned n, j; - /* next line enforces variable vs constant naming convention */ - for (n = 0; n < vsp; n++) { - if (v[n].len == Len) { - if (!strnicmp(v[n].s, Str, Len)) - { - if (n == 1) /* The formula uses 'p1'. */ - uses_p1 = 1; - if (n == 2) /* The formula uses 'p2'. */ - uses_p2 = 1; - if (n == 7) /* The formula uses 'rand'. */ - RandomSeed(); - if (n == 8) /* The formula uses 'p3'. */ - uses_p3 = 1; - if (n == 13) /* The formula uses 'ismand'. */ - uses_ismand = 1; - if (n == 17) /* The formula uses 'p4'. */ - uses_p4 = 1; - if (n == 18) /* The formula uses 'p5'. */ - uses_p5 = 1; -#if !defined(XFRACT) - if (n == 10 || n == 11 || n == 12) - if (MathType == L_MATH) - driver_unget_key('f'); -#endif - if (!isconst_pair(Str)) - return &v[n]; - } - } - } - v[vsp].s = Str; - v[vsp].len = Len; - v[vsp].a.d.x = v[vsp].a.d.y = 0.0; - -#if !defined(XFRACT) - /* v[vsp].a should already be zeroed out */ - switch (MathType) { - case M_MATH: - v[vsp].a.m.x.Mant = v[vsp].a.m.x.Exp = 0; - v[vsp].a.m.y.Mant = v[vsp].a.m.y.Exp = 0; - break; - case L_MATH: - v[vsp].a.l.x = v[vsp].a.l.y = 0; - break; - } -#endif - - if (isdigit(Str[0]) - || (Str[0] == '-' && (isdigit(Str[1]) || Str[1] == '.')) - || Str[0] == '.') { - if (o[posp-1].f == StkNeg) { - posp--; - Str = Str - 1; - InitN--; - v[vsp].len++; - } - for (n = 1; isdigit(Str[n]) || Str[n] == '.'; n++); - if (Str[n] == ',') { - j = n + SkipWhiteSpace(&Str[n+1]) + 1; - if (isdigit(Str[j]) - || (Str[j] == '-' && (isdigit(Str[j+1]) || Str[j+1] == '.')) - || Str[j] == '.') { - z.y = atof(&Str[j]); - for (; isdigit(Str[j]) || Str[j] == '.' || Str[j] == '-'; j++); - v[vsp].len = j; - } - else - z.y = 0.0; - } - else - z.y = 0.0; - z.x = atof(Str); - switch (MathType) { - case D_MATH: - v[vsp].a.d = z; - break; -#if !defined(XFRACT) - case M_MATH: - v[vsp].a.m = cmplx2MPC(z); - break; - case L_MATH: - v[vsp].a.l.x = (long)(z.x * fg); - v[vsp].a.l.y = (long)(z.y * fg); - break; -#endif - } - v[vsp].s = Str; - } - return &v[vsp++]; -} - - -struct FNCT_LIST { - char *s; /* TIW 03-31-91 added far */ - void (**ptr)(void); -}; - -/* TIW 03-30-91 START */ -void (*StkTrig0)(void) = dStkSin; -void (*StkTrig1)(void) = dStkSqr; -void (*StkTrig2)(void) = dStkSinh; -void (*StkTrig3)(void) = dStkCosh; - -char * JumpList[] = { - "if", - "elseif", - "else", - "endif", - "" -}; - - - -int isjump(char *Str, int Len) -{ - /* return values - 0 - Not a jump - 1 - if - 2 - elseif - 3 - else - 4 - endif - */ - - int i; - - for (i = 0; *JumpList[i]; i++) - if ((int) strlen(JumpList[i]) == Len) - if (!strnicmp(JumpList[i], Str, Len)) - return i + 1; - return 0; -} - - -char maxfn = 0; -/* TIW 03-30-91 STOP */ - -struct FNCT_LIST FnctList[] = { /* TIW 03-31-91 added far */ - {"sin", &StkSin}, - {"sinh", &StkSinh}, - {"cos", &StkCos}, - {"cosh", &StkCosh}, - {"sqr", &StkSqr}, - {"log", &StkLog}, - {"exp", &StkExp}, - {"abs", &StkAbs}, - {"conj", &StkConj}, - {"real", &StkReal}, - {"imag", &StkImag}, - {"fn1", &StkTrig0}, /* TIW 03-30-91 */ - {"fn2", &StkTrig1}, /* TIW 03-30-91 */ - {"fn3", &StkTrig2}, /* TIW 03-30-91 */ - {"fn4", &StkTrig3}, /* TIW 03-30-91 */ - {"flip", &StkFlip}, /* MCP 4-9-91 */ - {"tan", &StkTan}, /* TIW 04-22-91 */ - {"tanh", &StkTanh}, /* TIW 04-22-91 */ - {"cotan", &StkCoTan}, /* TIW 04-24-91 */ - {"cotanh",&StkCoTanh}, /* TIW 04-24-91 */ - {"cosxx", &StkCosXX}, /* PB 04-28-91 */ - {"srand", &StkSRand}, /* MCP 11-21-91 */ - {"asin", &StkASin}, /* TIW 11-26-94 */ - {"asinh", &StkASinh}, /* TIW 11-26-94 */ - {"acos", &StkACos}, /* TIW 11-26-94 */ - {"acosh", &StkACosh}, /* TIW 11-26-94 */ - {"atan", &StkATan}, /* TIW 11-26-94 */ - {"atanh", &StkATanh}, /* TIW 11-26-94 */ - {"sqrt", &StkSqrt}, /* TIW 11-26-94 */ - {"cabs", &StkCAbs}, /* TIW 11-26-94 */ - {"floor", &StkFloor}, /* TIW 06-30-96 */ - {"ceil", &StkCeil}, /* TIW 06-30-96 */ - {"trunc", &StkTrunc}, /* TIW 06-30-96 */ - {"round", &StkRound}, /* TIW 06-30-96 */ -}; - -char *OPList[] = { - ",", /* 0 */ - "!=", /* 1 */ - "=", /* 2 */ - "==", /* 3 */ - "<", /* 4 */ - "<=", /* 5 */ - ">", /* 6 */ - ">=", /* 7 */ - "|", /* 8 */ - "||", /* 9 */ - "&&", /* 10 */ - ":", /* 11 */ - "+", /* 12 */ - "-", /* 13 */ - "*", /* 14 */ - "/", /* 15 */ - "^" /* 16 */ -}; - - -void NotAFnct(void) { } -void FnctNotFound(void) { } - -/* determine if s names a function and if so which one */ -/* TIW 04-22-91 */ -int whichfn(char *s, int len) -{ - int out; - if (len != 3) - out = 0; - else if (strnicmp(s,"fn",2)) - out = 0; - else - out = atoi(s+2); - if (out < 1 || out > 4) - out = 0; - return out; -} - -#if !defined(XFRACT) -void (*isfunct(char *Str, int Len))(void) -#else -void (*isfunct(char *Str, int Len))(void) -#endif -{ - unsigned n; - int functnum; /* TIW 04-22-91 */ - - n = SkipWhiteSpace(&Str[Len]); - if (Str[Len+n] == '(') { - for (n = 0; n < sizeof(FnctList) / sizeof(struct FNCT_LIST); n++) { - if ((int) strlen(FnctList[n].s) == Len) { /* TIW 03-31-91 added far */ - if (!strnicmp(FnctList[n].s, Str, Len)) { /* TIW 03-31-91 added far */ - /* count function variables */ - if ((functnum = whichfn(Str, Len)) != 0) /* TIW 04-22-91 */ - if (functnum > maxfn) /* TIW 04-22-91 */ - maxfn = (char)functnum; /* TIW 04-22-91 */ - return *FnctList[n].ptr; - } - } - } - return FnctNotFound; - } - return NotAFnct; -} - -void RecSortPrec(void) { - int ThisOp = NextOp++; - while (o[ThisOp].p > o[NextOp].p && NextOp < posp) - RecSortPrec(); - f[OpPtr++] = o[ThisOp].f; -} - -static char *Constants[] = { - "pixel", /* v[0] */ - "p1", /* v[1] */ - "p2", /* v[2] */ - "z", /* v[3] */ - "LastSqr", /* v[4] */ - "pi", /* v[5] */ - "e", /* v[6] */ - "rand", /* v[7] */ - "p3", /* v[8] */ - "whitesq", /* v[9] */ - "scrnpix", /* v[10] */ - "scrnmax", /* v[11] */ - "maxit", /* v[12] */ - "ismand", /* v[13] */ - "center", /* v[14] */ - "magxmag", /* v[15] */ - "rotskew", /* v[16] */ - "p4", /* v[17] */ - "p5" /* v[18] */ -}; - -struct SYMETRY { - char *s; - int n; -} SymStr[] = { - {"NOSYM", 0}, - {"XAXIS_NOPARM", -1}, - {"XAXIS", 1}, - {"YAXIS_NOPARM", -2}, - {"YAXIS", 2}, - {"XYAXIS_NOPARM",-3}, - {"XYAXIS", 3}, - {"ORIGIN_NOPARM",-4}, - {"ORIGIN", 4}, - {"PI_SYM_NOPARM",-5}, - {"PI_SYM", 5}, - {"XAXIS_NOIMAG", -6}, - {"XAXIS_NOREAL", 6}, - {"NOPLOT", 99}, - {"", 0} -}; - -static int ParseStr(char *Str, int pass) { - struct ConstArg *c; - int ModFlag = 999, Len, Equals = 0, Mod[20], mdstk = 0; - int jumptype; - double const_pi, const_e; - double Xctr, Yctr, Xmagfactor, Rotation, Skew; - LDBL Magnification; - SetRandom = Randomized = 0; - uses_jump = 0; - jump_index = 0; - if (!typespecific_workarea) { - stopmsg(0,ParseErrs(PE_INSUFFICIENT_MEM_FOR_TYPE_FORMULA)); - return 1; - } - switch (MathType) { - case D_MATH: - StkAdd = dStkAdd; - StkSub = dStkSub; - StkNeg = dStkNeg; - StkMul = dStkMul; - StkSin = dStkSin; - StkSinh = dStkSinh; - StkLT = dStkLT; - StkLTE = dStkLTE; - StkMod = dStkMod; - StkSqr = dStkSqr; - StkCos = dStkCos; - StkCosh = dStkCosh; - StkLog = dStkLog; - StkExp = dStkExp; - StkPwr = dStkPwr; - StkDiv = dStkDiv; - StkAbs = dStkAbs; - StkReal = dStkReal; - StkImag = dStkImag; - StkConj = dStkConj; - StkTrig0 = dtrig0; /* TIW 03-30-91 */ - StkTrig1 = dtrig1; /* TIW 03-30-91 */ - StkTrig2 = dtrig2; /* TIW 03-30-91 */ - StkTrig3 = dtrig3; /* TIW 03-30-91 */ - StkFlip = dStkFlip; - StkTan = dStkTan; /* TIW 04-22-91 */ - StkTanh = dStkTanh; /* TIW 04-22-91 */ - StkCoTan = dStkCoTan; /* TIW 04-24-91 */ - StkCoTanh = dStkCoTanh; /* TIW 04-24-91 */ - StkCosXX = dStkCosXX; /* PB 04-28-91 */ - StkGT = dStkGT; /* MCP 11-3-91 */ - StkGTE = dStkGTE; /* MCP 11-3-91 */ - StkEQ = dStkEQ; /* MCP 11-3-91 */ - StkNE = dStkNE; /* MCP 11-3-91 */ - StkAND = dStkAND; /* MCP 11-3-91 */ - StkOR = dStkOR ; /* MCP 11-3-91 */ - StkSRand = dStkSRand; /* MCP 11-21-91 */ - StkASin = dStkASin; /* TIW 11-25-94 */ - StkASinh = dStkASinh; /* TIW 11-25-94 */ - StkACos = dStkACos; /* TIW 11-25-94 */ - StkACosh = dStkACosh; /* TIW 11-25-94 */ - StkATan = dStkATan; /* TIW 11-25-94 */ - StkATanh = dStkATanh; /* TIW 11-25-94 */ - StkCAbs = dStkCAbs; /* TIW 11-25-94 */ - StkSqrt = dStkSqrt; /* TIW 11-25-94 */ - StkZero = dStkZero; /* JCO 12-31-94 */ - StkFloor = dStkFloor; /* TIW 06-30-96 */ - StkCeil = dStkCeil; /* TIW 06-30-96 */ - StkTrunc = dStkTrunc; /* TIW 06-30-96 */ - StkRound = dStkRound; /* TIW 06-30-96 */ - StkJumpOnTrue = dStkJumpOnTrue; /* GGM 02-10-97 */ - StkJumpOnFalse = dStkJumpOnFalse; /* GGM 02-10-97 */ - StkOne = dStkOne; /* GGM 10-08-97 */ - break; -#if !defined(XFRACT) - case M_MATH: - StkAdd = mStkAdd; - StkSub = mStkSub; - StkNeg = mStkNeg; - StkMul = mStkMul; - StkSin = mStkSin; - StkSinh = mStkSinh; - StkLT = mStkLT; - StkLTE = mStkLTE; - StkMod = mStkMod; - StkSqr = mStkSqr; - StkCos = mStkCos; - StkCosh = mStkCosh; - StkLog = mStkLog; - StkExp = mStkExp; - StkPwr = mStkPwr; - StkDiv = mStkDiv; - StkAbs = mStkAbs; - StkReal = mStkReal; - StkImag = mStkImag; - StkConj = mStkConj; - StkTrig0 = mtrig0; /* TIW 03-30-91 */ - StkTrig1 = mtrig1; /* TIW 03-30-91 */ - StkTrig2 = mtrig2; /* TIW 03-30-91 */ - StkTrig3 = mtrig3; /* TIW 03-30-91 */ - StkFlip = mStkFlip; - StkTan = mStkTan; /* TIW 04-22-91 */ - StkTanh = mStkTanh;/* TIW 04-22-91 */ - StkCoTan = mStkCoTan; /* TIW 04-24-91 */ - StkCoTanh = mStkCoTanh;/* TIW 04-24-91 */ - StkCosXX = mStkCosXX; /* PB 04-28-91 */ - StkGT = mStkGT; /* MCP 11-3-91 */ - StkGTE = mStkGTE; /* MCP 11-3-91 */ - StkEQ = mStkEQ; /* MCP 11-3-91 */ - StkNE = mStkNE; /* MCP 11-3-91 */ - StkAND = mStkAND; /* MCP 11-3-91 */ - StkOR = mStkOR ; /* MCP 11-3-91 */ - StkSRand = mStkSRand; /* MCP 11-21-91 */ - StkASin = mStkASin; /* TIW 11-25-94 */ - StkACos = mStkACos; /* TIW 11-25-94 */ - StkACosh = mStkACosh; /* TIW 11-25-94 */ - StkATan = mStkATan; /* TIW 11-25-94 */ - StkATanh = mStkATanh; /* TIW 11-25-94 */ - StkCAbs = mStkCAbs; /* TIW 11-25-94 */ - StkSqrt = mStkSqrt; /* TIW 11-25-94 */ - StkZero = mStkZero; /* JCO 12-31-94 */ - StkFloor = mStkFloor; /* TIW 06-30-96 */ - StkCeil = mStkCeil; /* TIW 06-30-96 */ - StkTrunc = mStkTrunc; /* TIW 06-30-96 */ - StkRound = mStkRound; /* TIW 06-30-96 */ - StkJumpOnTrue = mStkJumpOnTrue; /* GGM 02-10-97 */ - StkJumpOnFalse = mStkJumpOnFalse; /* GGM 02-10-97 */ - StkOne = mStkOne; /* GGM 10-08-97 */ - break; - case L_MATH: - Delta16 = bitshift - 16; - ShiftBack = 32 - bitshift; /* TW 06-18-90 */ - StkAdd = lStkAdd; - StkSub = lStkSub; - StkNeg = lStkNeg; - StkMul = lStkMul; - StkSin = lStkSin; - StkSinh = lStkSinh; - StkLT = lStkLT; - StkLTE = lStkLTE; - if (save_release > 1826) - StkMod = lStkMod; - else - StkMod = lStkModOld; - StkSqr = lStkSqr; - StkCos = lStkCos; - StkCosh = lStkCosh; - StkLog = lStkLog; - StkExp = lStkExp; - StkPwr = lStkPwr; - StkDiv = lStkDiv; - StkAbs = lStkAbs; - StkReal = lStkReal; - StkImag = lStkImag; - StkConj = lStkConj; - StkTrig0 = ltrig0; /* TIW 03-30-91 */ - StkTrig1 = ltrig1; /* TIW 03-30-91 */ - StkTrig2 = ltrig2; /* TIW 03-30-91 */ - StkTrig3 = ltrig3; /* TIW 03-30-91 */ - StkFlip = lStkFlip; - StkTan = lStkTan; /* TIW 04-22-91 */ - StkTanh = lStkTanh; /* TIW 04-22-91 */ - StkCoTan = lStkCoTan; /* TIW 04-24-91 */ - StkCoTanh = lStkCoTanh; /* TIW 04-24-91 */ - StkCosXX = lStkCosXX; /* PB 04-28-91 */ - StkGT = lStkGT; /* MCP 11-3-91 */ - StkGTE = lStkGTE; /* MCP 11-3-91 */ - StkEQ = lStkEQ; /* MCP 11-3-91 */ - StkNE = lStkNE; /* MCP 11-3-91 */ - StkAND = lStkAND; /* MCP 11-3-91 */ - StkOR = lStkOR ; /* MCP 11-3-91 */ - StkSRand = lStkSRand; /* MCP 11-21-91 */ - StkASin = lStkASin; /* TIW 11-25-94 */ - StkACos = lStkACos; /* TIW 11-25-94 */ - StkACosh = lStkACosh; /* TIW 11-25-94 */ - StkATan = lStkATan; /* TIW 11-25-94 */ - StkATanh = lStkATanh; /* TIW 11-25-94 */ - StkCAbs = lStkCAbs; /* TIW 11-25-94 */ - StkSqrt = lStkSqrt; /* TIW 11-25-94 */ - StkZero = lStkZero; /* JCO 12-31-94 */ - StkFloor = lStkFloor; /* TIW 06-30-96 */ - StkCeil = lStkCeil; /* TIW 06-30-96 */ - StkTrunc = lStkTrunc; /* TIW 06-30-96 */ - StkRound = lStkRound; /* TIW 06-30-96 */ - StkJumpOnTrue = lStkJumpOnTrue; /* GGM 02-10-97 */ - StkJumpOnFalse = lStkJumpOnFalse; /* GGM 02-10-97 */ - StkOne = lStkOne; /* GGM 10-08-97 */ - break; -#endif - } - maxfn = 0; /* TIW 03-30-91 */ - for (vsp = 0; vsp < sizeof(Constants) / sizeof(char*); vsp++) { - v[vsp].s = Constants[vsp]; - v[vsp].len = (int) strlen(Constants[vsp]); - } - cvtcentermag(&Xctr, &Yctr, &Magnification, &Xmagfactor, &Rotation, &Skew); - const_pi = atan(1.0) * 4; - const_e = exp(1.0); - v[7].a.d.x = v[7].a.d.y = 0.0; - v[11].a.d.x = (double)xdots; - v[11].a.d.y = (double)ydots; - v[12].a.d.x = (double)maxit; - v[12].a.d.y = 0; - v[13].a.d.x = (double)ismand; - v[13].a.d.y = 0; - v[14].a.d.x = Xctr; - v[14].a.d.y = Yctr; - v[15].a.d.x = (double)Magnification; - v[15].a.d.y = Xmagfactor; - v[16].a.d.x = Rotation; - v[16].a.d.y = Skew; - - switch (MathType) { - case D_MATH: - v[1].a.d.x = param[0]; - v[1].a.d.y = param[1]; - v[2].a.d.x = param[2]; - v[2].a.d.y = param[3]; - v[5].a.d.x = const_pi; - v[5].a.d.y = 0.0; - v[6].a.d.x = const_e; - v[6].a.d.y = 0.0; - v[8].a.d.x = param[4]; - v[8].a.d.y = param[5]; - v[17].a.d.x = param[6]; - v[17].a.d.y = param[7]; - v[18].a.d.x = param[8]; - v[18].a.d.y = param[9]; - break; -#if !defined(XFRACT) - case M_MATH: - v[1].a.m.x = *d2MP(param[0]); - v[1].a.m.y = *d2MP(param[1]); - v[2].a.m.x = *d2MP(param[2]); - v[2].a.m.y = *d2MP(param[3]); - v[5].a.m.x = *d2MP(const_pi); - v[5].a.m.y = *d2MP(0.0); - v[6].a.m.x = *d2MP(const_e); - v[6].a.m.y = *d2MP(0.0); - v[8].a.m.x = *d2MP(param[4]); - v[8].a.m.y = *d2MP(param[5]); - v[11].a.m = cmplx2MPC(v[11].a.d); - v[12].a.m = cmplx2MPC(v[12].a.d); - v[13].a.m = cmplx2MPC(v[13].a.d); - v[14].a.m = cmplx2MPC(v[14].a.d); - v[15].a.m = cmplx2MPC(v[15].a.d); - v[16].a.m = cmplx2MPC(v[16].a.d); - v[17].a.m.x = *d2MP(param[6]); - v[17].a.m.y = *d2MP(param[7]); - v[18].a.m.x = *d2MP(param[8]); - v[18].a.m.y = *d2MP(param[9]); - break; - case L_MATH: - v[1].a.l.x = (long)(param[0] * fg); - v[1].a.l.y = (long)(param[1] * fg); - v[2].a.l.x = (long)(param[2] * fg); - v[2].a.l.y = (long)(param[3] * fg); - v[5].a.l.x = (long)(const_pi * fg); - v[5].a.l.y = 0L; - v[6].a.l.x = (long)(const_e * fg); - v[6].a.l.y = 0L; - v[8].a.l.x = (long)(param[4] * fg); - v[8].a.l.y = (long)(param[5] * fg); - v[11].a.l.x = xdots; v[11].a.l.x <<= bitshift; - v[11].a.l.y = ydots; v[11].a.l.y <<= bitshift; - v[12].a.l.x = maxit; v[12].a.l.x <<= bitshift; - v[12].a.l.y = 0L; - v[13].a.l.x = ismand; v[13].a.l.x <<= bitshift; - v[13].a.l.y = 0L; - v[14].a.l.x = (long)(v[14].a.d.x * fg); - v[14].a.l.y = (long)(v[14].a.d.y * fg); - v[15].a.l.x = (long)(v[15].a.d.x * fg); - v[15].a.l.y = (long)(v[15].a.d.y * fg); - v[16].a.l.x = (long)(v[16].a.d.x * fg); - v[16].a.l.y = (long)(v[16].a.d.y * fg); - v[17].a.l.x = (long)(param[6] * fg); - v[17].a.l.y = (long)(param[7] * fg); - v[18].a.l.x = (long)(param[8] * fg); - v[18].a.l.y = (long)(param[9] * fg); - break; -#endif - } - - LastInitOp = paren = OpPtr = LodPtr = StoPtr = posp = 0; - ExpectingArg = 1; - for (n = 0; Str[n]; n++) { - if (!Str[n]) - break; - InitN = n; - switch (Str[n]) { - case ' ': - case '\t': - case '\r': - case '\n': - break; - case '(': - paren++; - break; - case ')': - paren--; - break; - case '|': - if (Str[n+1] == '|') { - ExpectingArg = 1; - n++; - o[posp].f = StkOR; - o[posp++].p = 7 - (paren + Equals)*15; - } - else if (ModFlag == paren-1) { - paren--; - ModFlag = Mod[--mdstk]; - } - else { - Mod[mdstk++] = ModFlag; - o[posp].f = StkMod; - o[posp++].p = 2 - (paren + Equals)*15; - ModFlag = paren++; - } - break; - case ',': - case ';': - if (!ExpectingArg) { - ExpectingArg = 1; - o[posp].f = (void(*)(void))0; - o[posp++].p = 15; - o[posp].f = StkClr; - o[posp++].p = -30000; - Equals = paren = 0; - } - break; - case ':': - ExpectingArg = 1; - o[posp].f = (void(*)(void))0; - o[posp++].p = 15; - o[posp].f = EndInit; - o[posp++].p = -30000; - Equals = paren = 0; - LastInitOp = 10000; - break; - case '+': - ExpectingArg = 1; - o[posp].f = StkAdd; - o[posp++].p = 4 - (paren + Equals)*15; - break; - case '-': - if (ExpectingArg) { - o[posp].f = StkNeg; - o[posp++].p = 2 - (paren + Equals)*15; - } - else { - o[posp].f = StkSub; - o[posp++].p = 4 - (paren + Equals)*15; - ExpectingArg = 1; - } - break; - case '&': - ExpectingArg = 1; - n++; - o[posp].f = StkAND; - o[posp++].p = 7 - (paren + Equals)*15; - break; - case '!': - ExpectingArg = 1; - n++; - o[posp].f = StkNE; - o[posp++].p = 6 - (paren + Equals)*15; - break; - case '<': - ExpectingArg = 1; - if (Str[n+1] == '=') { - n++; - o[posp].f = StkLTE; - } - else - o[posp].f = StkLT; - o[posp++].p = 6 - (paren + Equals)*15; - break; - case '>': - ExpectingArg = 1; - if (Str[n+1] == '=') { - n++; - o[posp].f = StkGTE; - } - else - o[posp].f = StkGT; - o[posp++].p = 6 - (paren + Equals)*15; - break; - case '*': - ExpectingArg = 1; - o[posp].f = StkMul; - o[posp++].p = 3 - (paren + Equals)*15; - break; - case '/': - ExpectingArg = 1; - o[posp].f = StkDiv; - o[posp++].p = 3 - (paren + Equals)*15; - break; - case '^': - ExpectingArg = 1; - o[posp].f = StkPwr; - o[posp++].p = 2 - (paren + Equals)*15; - break; - case '=': - ExpectingArg = 1; - if (Str[n+1] == '=') { - n++; - o[posp].f = StkEQ; - o[posp++].p = 6 - (paren + Equals)*15; - } - else { - o[posp-1].f = StkSto; - o[posp-1].p = 5 - (paren + Equals)*15; - Store[StoPtr++] = Load[--LodPtr]; - Equals++; - } - break; - default: - while (isalnum(Str[n+1]) || Str[n+1] == '.' || Str[n+1] == '_') - n++; - Len = (n+1)-InitN; - ExpectingArg = 0; - if ((jumptype = isjump(&Str[InitN], Len)) != 0) { - uses_jump = 1; - switch (jumptype) { - case 1: /* if */ - ExpectingArg = 1; - jump_control[jump_index++].type = 1; - o[posp].f = StkJumpOnFalse; - o[posp++].p = 1; - break; - case 2: /* elseif */ - ExpectingArg = 1; - jump_control[jump_index++].type = 2; - jump_control[jump_index++].type = 2; - o[posp].f = StkJump; - o[posp++].p = 1; - o[posp].f = (void(*)(void))0; - o[posp++].p = 15; - o[posp].f = StkClr; - o[posp++].p = -30000; - o[posp].f = StkJumpOnFalse; - o[posp++].p = 1; - break; - case 3: /* else */ - jump_control[jump_index++].type = 3; - o[posp].f = StkJump; - o[posp++].p = 1; - break; - case 4: /* endif */ - jump_control[jump_index++].type = 4; - o[posp].f = StkJumpLabel; - o[posp++].p = 1; - break; - default: - break; - } - } - else { - o[posp].f = isfunct(&Str[InitN], Len); - if (o[posp].f != NotAFnct) { - o[posp++].p = 1 - (paren + Equals)*15; - ExpectingArg = 1; - } - else { - c = isconst(&Str[InitN], Len); - Load[LodPtr++] = &(c->a); - o[posp].f = StkLod; - o[posp++].p = 1 - (paren + Equals)*15; - n = InitN + c->len - 1; - } - } - break; - } - } - o[posp].f = (void(*)(void))0; - o[posp++].p = 16; - NextOp = 0; - LastOp = posp; - while (NextOp < posp) { - if (o[NextOp].f) - RecSortPrec(); - else { - NextOp++; - LastOp--; - } - } - return 0; -} - - -int Formula(void) { - if (FormName[0] == 0 || overflow) return 1; - - LodPtr = InitLodPtr; - StoPtr = InitStoPtr; - OpPtr = InitOpPtr; - jump_index=InitJumpIndex; - /* Set the random number, MCP 11-21-91 */ - if (SetRandom || Randomized) - { - switch (MathType) - { - case D_MATH: - dRandom(); - break; -#if !defined(XFRACT) - case L_MATH: - lRandom(); - break; - case M_MATH: - mRandom(); -#endif - } - } - - Arg1 = &s[0]; - Arg2 = Arg1-1; - while (OpPtr < (int)LastOp) { - f[OpPtr](); - OpPtr++; -#ifdef WATCH_MP - x1 = *MP2d(Arg1->m.x); - y1 = *MP2d(Arg1->m.y); - x2 = *MP2d(Arg2->m.x); - y2 = *MP2d(Arg2->m.y); -#endif - } - - switch (MathType) { - case D_MATH: - old = g_new = v[3].a.d; - return Arg1->d.x == 0.0; -#if !defined(XFRACT) - case M_MATH: - old = g_new = MPC2cmplx(v[3].a.m); - return Arg1->m.x.Exp == 0 && Arg1->m.x.Mant == 0; - case L_MATH: - lold = lnew = v[3].a.l; - if (overflow) - return 1; - return Arg1->l.x == 0L; -#endif - } - return 1; -} - -int form_per_pixel(void) { - if (FormName[0] == 0) return 1; - overflow = LodPtr = StoPtr = OpPtr = jump_index = 0; - Arg1 = &s[0]; - Arg2 = Arg1; - Arg2--; - - - v[10].a.d.x = (double)col; - v[10].a.d.y = (double)row; - - switch (MathType) { - case D_MATH: - if ((row+col)&1) - v[9].a.d.x = 1.0; - else - v[9].a.d.x = 0.0; - v[9].a.d.y = 0.0; - break; - - -#if !defined(XFRACT) - case M_MATH: - if ((row+col)&1) - v[9].a.m = MPCone; - else { - v[9].a.m.x.Mant = v[9].a.m.x.Exp = 0; - v[9].a.m.y.Mant = v[9].a.m.y.Exp = 0; - } - v[10].a.m = cmplx2MPC(v[10].a.d); - break; - case L_MATH: - v[9].a.l.x = (long) (((row+col)&1) * fg); - v[9].a.l.y = 0L; - v[10].a.l.x = col; v[10].a.l.x <<= bitshift; - v[10].a.l.y = row; v[10].a.l.y <<= bitshift; - break; -#endif - } - - /* TW started additions for inversion support here 4/17/94 */ - { - if (invert) - { - invertz2(&old); - switch (MathType) - { - case D_MATH: - v[0].a.d.x = old.x; - v[0].a.d.y = old.y; - break; -#if !defined(XFRACT) - case M_MATH: - v[0].a.m.x = *d2MP(old.x); - v[0].a.m.y = *d2MP(old.y); - break; - case L_MATH: - /* watch out for overflow */ - if (sqr(old.x)+sqr(old.y) >= 127) - { - old.x = 8; /* value to bail out in one iteration */ - old.y = 8; - } - /* convert to fudged longs */ - v[0].a.l.x = (long)(old.x*fg); - v[0].a.l.y = (long)(old.y*fg); - break; -#endif - } - } - else - /* TW end of inversion support changes here 4/17/94 */ - switch (MathType) - { - case D_MATH: - v[0].a.d.x = dxpixel(); - v[0].a.d.y = dypixel(); - break; -#if !defined(XFRACT) - case M_MATH: - v[0].a.m.x = *d2MP(dxpixel()); - v[0].a.m.y = *d2MP(dypixel()); - break; - case L_MATH: - v[0].a.l.x = lxpixel(); - v[0].a.l.y = lypixel(); - break; -#endif - } - } - - if (LastInitOp) - LastInitOp = LastOp; - while (OpPtr < LastInitOp) { - f[OpPtr](); - OpPtr++; - } - InitLodPtr = LodPtr; - InitStoPtr = StoPtr; - InitOpPtr = OpPtr; - /* Set old variable for orbits TIW 12-18-93 */ - switch (MathType) { - case D_MATH: - old = v[3].a.d; - break; -#if !defined(XFRACT) - case M_MATH: - old = MPC2cmplx(v[3].a.m); - break; - case L_MATH: - lold = v[3].a.l; - break; -#endif - } - - if (overflow) - return 0; - else - return 1; -} - -int fill_if_group(int endif_index, JUMP_PTRS_ST* jump_data) -{ - int i = endif_index; - int ljp = endif_index; /* ljp means "last jump processed" */ - while (i > 0) { - i--; - switch (jump_control[i].type) { - case 1: /*if (); this concludes processing of this group*/ - jump_control[i].ptrs = jump_data[ljp]; - jump_control[i].DestJumpIndex = ljp + 1; - return i; - case 2: /*elseif* ( 2 jumps, the else and the if*/ - /* first, the "if" part */ - jump_control[i].ptrs = jump_data[ljp]; - jump_control[i].DestJumpIndex = ljp + 1; - - /* then, the else part */ - i--; /*fall through to "else" is intentional*/ - case 3: - jump_control[i].ptrs = jump_data[endif_index]; - jump_control[i].DestJumpIndex = endif_index + 1; - ljp = i; - break; - case 4: /*endif*/ - i = fill_if_group(i, jump_data); - break; - default: - break; - } - } - return -1; /* should never get here */ -} - -int fill_jump_struct(void) -{ /* Completes all entries in jump structure. Returns 1 on error) */ - /* On entry, jump_index is the number of jump functions in the formula*/ - int i = 0; - int loadcount = 0; - int storecount = 0; - int checkforelse = 0; - void (*JumpFunc)(void) = NULL; - int find_new_func = 1; - - JUMP_PTRS_ST jump_data[MAX_JUMPS]; - - for (OpPtr = 0; OpPtr < (int) LastOp; OpPtr++) { - if (find_new_func) { - switch (jump_control[i].type) { - case 1: - JumpFunc = StkJumpOnFalse; - break; - case 2: - checkforelse = !checkforelse; - if (checkforelse) - JumpFunc = StkJump; - else - JumpFunc = StkJumpOnFalse; - break; - case 3: - JumpFunc = StkJump; - break; - case 4: - JumpFunc = StkJumpLabel; - break; - default: - break; - } - find_new_func = 0; - } - if (*(f[OpPtr]) == StkLod) - loadcount++; - else if (*(f[OpPtr]) == StkSto) - storecount++; - else if (*(f[OpPtr]) == JumpFunc) { - jump_data[i].JumpOpPtr = OpPtr; - jump_data[i].JumpLodPtr = loadcount; - jump_data[i].JumpStoPtr = storecount; - i++; - find_new_func = 1; - } - } - - /* Following for safety only; all should always be false */ - if (i != jump_index || jump_control[i - 1].type != 4 - || jump_control[0].type != 1) { - return 1; - } - - while (i > 0) { - i--; - i = fill_if_group(i, jump_data); - } - return i < 0 ? 1 : 0; -} - -static char *FormStr; - -int frmgetchar (FILE * openfile) -{ - int c; - int done = 0; - int linewrap = 0; - while (!done) { - c = getc(openfile); - switch (c) { - case '\r': case ' ' : case '\t' : - break; - case '\\': - linewrap = 1; - break; - case ';' : - while ((c = getc(openfile)) != '\n' && c != EOF && c != '\032') - {} - if (c == EOF || c == '\032') - done = 1; - case '\n' : - if (!linewrap) - done = 1; - linewrap = 0; - break; - default: - done = 1; - break; - } - } - return tolower(c); -} - -/* This function also gets flow control info */ - -void getfuncinfo(struct token_st * tok) -{ - int i; - for (i=0; i < sizeof(FnctList)/ sizeof(struct FNCT_LIST); i++) { - if (!strcmp(FnctList[i].s, tok->token_str)) { - tok->token_id = i; - if (i >= 11 && i <= 14) - tok->token_type = PARAM_FUNCTION; - else - tok->token_type = FUNCTION; - return; - } - } - - for (i=0; i < 4; i++) { /*pick up flow control*/ - if (!strcmp(JumpList[i], tok->token_str)) { - tok->token_type = FLOW_CONTROL; - tok->token_id = i + 1; - return; - } - } - tok->token_type = NOT_A_TOKEN; - tok->token_id = UNDEFINED_FUNCTION; - return; -} - -void getvarinfo(struct token_st * tok) -{ - int i; - - for (i=0; i < sizeof(Constants) / sizeof(char*); i++) { - if (!strcmp(Constants[i], tok->token_str)) { - tok->token_id = i; - switch (i) { - case 1: case 2: case 8: case 13: case 17: case 18: - tok->token_type = PARAM_VARIABLE; - break; - default: - tok->token_type = PREDEFINED_VARIABLE; - break; - } - return; - } - } - tok->token_type = USER_NAMED_VARIABLE; - tok->token_id = 0; -} - -/* fills in token structure where numeric constant is indicated */ -/* Note - this function will be called twice to fill in the components - of a complex constant. See is_complex_constant() below. */ - -/* returns 1 on success, 0 on NOT_A_TOKEN */ - -int frmgetconstant(FILE * openfile, struct token_st * tok) -{ - int c; - int i = 1; - int getting_base = 1; - long filepos = ftell(openfile); - int got_decimal_already = 0; - int done = 0; - tok->token_const.x = 0.0; /*initialize values to 0*/ - tok->token_const.y = 0.0; - if (tok->token_str[0] == '.') - got_decimal_already = 1; - while (!done) { - switch (c=frmgetchar(openfile)) { - case EOF: case '\032': - tok->token_str[i] = (char) 0; - tok->token_type = NOT_A_TOKEN; - tok->token_id = END_OF_FILE; - return 0; - CASE_NUM: - tok->token_str[i++] = (char) c; - filepos=ftell(openfile); - break; - case '.': - if (got_decimal_already || !getting_base) { - tok->token_str[i++] = (char) c; - tok->token_str[i++] = (char) 0; - tok->token_type = NOT_A_TOKEN; - tok->token_id = ILL_FORMED_CONSTANT; - return 0; - } - else { - tok->token_str[i++] = (char) c; - got_decimal_already = 1; - filepos=ftell(openfile); - } - break; - default : - if (c == 'e' && getting_base && (isdigit(tok->token_str[i-1]) || (tok->token_str[i-1] == '.' && i > 1))) { - tok->token_str[i++] = (char) c; - getting_base = 0; - got_decimal_already = 0; - filepos=ftell(openfile); - c = frmgetchar(openfile); - if (c == '-' || c == '+') { - tok->token_str[i++] = (char) c; - filepos = ftell(openfile); - } - else { - fseek(openfile, filepos, SEEK_SET); - } - } - else if (isalpha(c) || c == '_') { - tok->token_str[i++] = (char) c; - tok->token_str[i++] = (char) 0; - tok->token_type = NOT_A_TOKEN; - tok->token_id = ILL_FORMED_CONSTANT; - return 0; - } - else if (tok->token_str[i-1] == 'e' || (tok->token_str[i-1] == '.' && i == 1)) { - tok->token_str[i++] = (char) c; - tok->token_str[i++] = (char) 0; - tok->token_type = NOT_A_TOKEN; - tok->token_id = ILL_FORMED_CONSTANT; - return 0; - } - else { - fseek(openfile, filepos, SEEK_SET); - tok->token_str[i++] = (char) 0; - done = 1; - } - break; - } - if (i == 33 && tok->token_str[32]) { - tok->token_str[33] = (char) 0; - tok->token_type = NOT_A_TOKEN; - tok->token_id = TOKEN_TOO_LONG; - return 0; - } - } /* end of while loop. Now fill in the value */ - tok->token_const.x = atof(tok->token_str); - tok->token_type = REAL_CONSTANT; - tok->token_id = 0; - return 1; -} - -void is_complex_constant(FILE * openfile, struct token_st * tok) -{ - /* should test to make sure tok->token_str[0] == '(' */ - struct token_st temp_tok; - long filepos; - int c; - int sign_value = 1; - int done = 0; - int getting_real = 1; - FILE * debug_token = NULL; - tok->token_str[1] = (char) 0; /* so we can concatenate later */ - - filepos = ftell(openfile); - if (debugflag == 96) { - debug_token = fopen("frmconst.txt","at"); - } - - while (!done) { - switch (c = frmgetchar(openfile)) { - CASE_NUM : case '.': - if (debug_token != NULL) { - fprintf(debug_token, "Set temp_tok.token_str[0] to %c\n", c); - } - temp_tok.token_str[0] = (char) c; - break; - case '-' : - if (debug_token != NULL) { - fprintf(debug_token, "First char is a minus\n"); - } - sign_value = -1; - c = frmgetchar(openfile); - if (c == '.' || isdigit(c)) { - if (debug_token != NULL) { - fprintf(debug_token, "Set temp_tok.token_str[0] to %c\n", c); - } - temp_tok.token_str[0] = (char) c; - } - else { - if (debug_token != NULL) { - fprintf(debug_token, "First char not a . or NUM\n"); - } - done = 1; - } - break; - default: - if (debug_token != NULL) { - fprintf(debug_token, "First char not a . or NUM\n"); - } - done = 1; - break; - } - if (debug_token != NULL) { - fprintf(debug_token, "Calling frmgetconstant unless done is 1; done is %d\n", done); - } - if (!done && frmgetconstant (openfile, &temp_tok)) { - c = frmgetchar(openfile); - if (debug_token != NULL) { - fprintf(debug_token, "frmgetconstant returned 1; next token is %c\n", c); - } - if (getting_real && c == ',') { /*we have the real part now*/ - if (sign_value == -1) { - strcat(tok->token_str, "-"); - } - strcat(tok->token_str, temp_tok.token_str); - strcat(tok->token_str, ","); - tok->token_const.x = temp_tok.token_const.x * sign_value; - getting_real = 0; - sign_value = 1; - } - else if (!getting_real && c == ')') { /* we have the complex part */ - if (sign_value == -1) { - strcat(tok->token_str, "-"); - } - strcat(tok->token_str, temp_tok.token_str); - strcat(tok->token_str, ")"); - tok->token_const.y = temp_tok.token_const.x * sign_value; - tok->token_type = tok->token_const.y ? COMPLEX_CONSTANT : REAL_CONSTANT; - tok->token_id = 0; - if (debug_token != NULL) { - fprintf(debug_token, "Exiting with type set to %d\n", tok->token_const.y ? COMPLEX_CONSTANT : REAL_CONSTANT); - fclose (debug_token); - } - return; - } - else - done = 1; - } - else - done = 1; - } - fseek (openfile, filepos, SEEK_SET); - tok->token_str[1] = (char) 0; - tok->token_const.y = tok->token_const.x = 0.0; - tok->token_type = PARENS; - tok->token_id = OPEN_PARENS; - if (debug_token != NULL) { - fprintf(debug_token, "Exiting with ID set to OPEN_PARENS\n"); - fclose (debug_token); - } - return; -} - -int frmgetalpha(FILE * openfile, struct token_st * tok) -{ - int c; - int i = 1; - int var_name_too_long = 0; - long filepos; - long last_filepos = ftell(openfile); - while ((c=frmgetchar(openfile)) != EOF && c != '\032') { - filepos = ftell(openfile); - switch (c) { - CASE_ALPHA: CASE_NUM: case '_': - if (i<79) - tok->token_str[i++] = (char) c; - else { - tok->token_str[i] = (char) 0; - } - if (i == 33) { - var_name_too_long=1; - } - last_filepos = filepos; - break; - default: - if (c == '.') { /*illegal character in variable or func name*/ - tok->token_type = NOT_A_TOKEN; - tok->token_id = ILLEGAL_VARIABLE_NAME; - tok->token_str[i++] = '.'; - tok->token_str[i] = (char) 0; - return 0; - } - else if (var_name_too_long) { - tok->token_type = NOT_A_TOKEN; - tok->token_id = TOKEN_TOO_LONG; - tok->token_str[i] = (char) 0; - fseek(openfile, last_filepos, SEEK_SET); - return 0; - } - tok->token_str[i] = (char) 0; - fseek(openfile, last_filepos, SEEK_SET); - getfuncinfo(tok); - if (c=='(') { /*getfuncinfo() correctly filled structure*/ - if (tok->token_type == NOT_A_TOKEN) - return 0; - else if (tok->token_type == FLOW_CONTROL && (tok->token_id == 3 || tok->token_id == 4)) { - tok->token_type = NOT_A_TOKEN; - tok->token_id = JUMP_WITH_ILLEGAL_CHAR; - return 0; - } - else - return 1; - } - /*can't use function names as variables*/ - else if (tok->token_type == FUNCTION || tok->token_type == PARAM_FUNCTION) { - tok->token_type = NOT_A_TOKEN; - tok->token_id = FUNC_USED_AS_VAR; - return 0; - } - else if (tok->token_type == FLOW_CONTROL && (tok->token_id == 1 || tok->token_id == 2)) { - tok->token_type = NOT_A_TOKEN; - tok->token_id = JUMP_MISSING_BOOLEAN; - return 0; - } - else if (tok->token_type == FLOW_CONTROL && (tok->token_id == 3 || tok->token_id == 4)) { - if (c == ',' || c == '\n' || c == ':') - return 1; - else { - tok->token_type = NOT_A_TOKEN; - tok->token_id = JUMP_WITH_ILLEGAL_CHAR; - return 0; - } - } - else { - getvarinfo(tok); - return 1; - } - } - } - tok->token_str[0] = (char) 0; - tok->token_type = NOT_A_TOKEN; - tok->token_id = END_OF_FILE; - return 0; -} - -void frm_get_eos (FILE * openfile, struct token_st * this_token) -{ - long last_filepos = ftell(openfile); - int c; - - for (c = frmgetchar(openfile); (c == '\n' || c == ',' || c == ':'); c = frmgetchar(openfile)) - { - if (c == ':') { - this_token->token_str[0] = ':'; - } - last_filepos = ftell(openfile); - } - if (c == '}') { - this_token->token_str[0] = '}'; - this_token->token_type = END_OF_FORMULA; - this_token->token_id = 0; - } - else { - fseek (openfile, last_filepos, SEEK_SET); - if (this_token->token_str[0] == '\n') { - this_token->token_str[0] = ','; - } - } -} - -/*frmgettoken fills token structure; returns 1 on success and 0 on - NOT_A_TOKEN and END_OF_FORMULA -*/ - -int frmgettoken(FILE * openfile, struct token_st * this_token) -{ - int c; - int i=1; - long filepos; - - switch (c = frmgetchar(openfile)) { - CASE_NUM: case '.': - this_token->token_str[0] = (char) c; - return frmgetconstant(openfile, this_token); - CASE_ALPHA: case '_': - this_token->token_str[0] = (char) c; - return frmgetalpha(openfile, this_token); - CASE_TERMINATOR: - this_token->token_type = OPERATOR; /* this may be changed below */ - this_token->token_str[0] = (char) c; - filepos = ftell(openfile); - if (c=='<' || c=='>' || c=='=') { - c=frmgetchar(openfile); - if (c == '=') - this_token->token_str[i++] = (char) c; - else { - fseek(openfile, filepos, SEEK_SET); - } - } - else if (c=='!') { - c=frmgetchar(openfile); - if (c == '=') - this_token->token_str[i++] = (char) c; - else { - fseek(openfile, filepos, SEEK_SET); - this_token->token_str[1] = (char) 0; - this_token->token_type = NOT_A_TOKEN; - this_token->token_id = ILLEGAL_OPERATOR; - return 0; - } - } - else if (c=='|') { - c=frmgetchar(openfile); - if (c == '|') - this_token->token_str[i++] = (char) c; - else - fseek(openfile, filepos, SEEK_SET); - } - else if (c=='&') { - c=frmgetchar(openfile); - if (c == '&') - this_token->token_str[i++] = (char) c; - else { - fseek(openfile, filepos, SEEK_SET); - this_token->token_str[1] = (char) 0; - this_token->token_type = NOT_A_TOKEN; - this_token->token_id = ILLEGAL_OPERATOR; - return 0; - } - } - else if (this_token->token_str[0] == '}') { - this_token->token_type = END_OF_FORMULA; - this_token->token_id = 0; - } - else if (this_token->token_str[0] == '\n' - || this_token->token_str[0] == ',' - || this_token->token_str[0] == ':' ) { - frm_get_eos(openfile, this_token); - } - else if (this_token->token_str[0] == ')') { - this_token->token_type = PARENS; - this_token->token_id = CLOSE_PARENS; - } - else if (this_token->token_str[0] == '(') { - /* the following function will set token_type to PARENS and - token_id to OPEN_PARENS if this is not the start of a - complex constant */ - is_complex_constant(openfile, this_token); - return 1; - } - this_token->token_str[i] = (char) 0; - if (this_token->token_type == OPERATOR) { - for (i=0; i < sizeof(OPList)/sizeof(OPList[0]); i++) { - if (!strcmp(OPList[i], this_token->token_str)) { - this_token->token_id = i; - } - } - } - return this_token->token_str[0] == '}' ? 0 : 1; - case EOF: case '\032': - this_token->token_str[0] = (char) 0; - this_token->token_type = NOT_A_TOKEN; - this_token->token_id = END_OF_FILE; - return 0; - default: - this_token->token_str[0] = (char) c; - this_token->token_str[1] = (char) 0; - this_token->token_type = NOT_A_TOKEN; - this_token->token_id = ILLEGAL_CHARACTER; - return 0; - } -} - -int frm_get_param_stuff (char * Name) -{ - FILE *debug_token = NULL; - int c; - struct token_st current_token; - FILE * entry_file = NULL; - uses_p1 = uses_p2 = uses_p3 = uses_ismand = maxfn = 0; - uses_p4 = uses_p5 = 0; - - if (FormName[0] == 0 ) { - return 0; /* and don't reset the pointers */ - } - if (find_file_item(FormFileName,Name,&entry_file, 1)) { - stopmsg(0, ParseErrs(PE_COULD_NOT_OPEN_FILE_WHERE_FORMULA_LOCATED)); - return 0; - } - while ((c=frmgetchar(entry_file)) != '{' && c != EOF && c != '\032') - {} - if (c != '{') { - stopmsg(0,ParseErrs(PE_UNEXPECTED_EOF)); - fclose(entry_file); - return 0; - } - - if (debugflag == 96) { - if ((debug_token = fopen("frmtokens.txt","at")) != NULL) - fprintf(debug_token,"%s\n", Name); - } - while (frmgettoken(entry_file, ¤t_token)) { - if (debug_token != NULL) { - fprintf(debug_token,"%s\n", current_token.token_str); - fprintf(debug_token,"token_type is %d\n", current_token.token_type); - fprintf(debug_token,"token_id is %d\n", current_token.token_id); - if (current_token.token_type == REAL_CONSTANT || current_token.token_type == COMPLEX_CONSTANT) { - fprintf(debug_token,"Real value is %f\n", current_token.token_const.x); - fprintf(debug_token,"Imag value is %f\n", current_token.token_const.y); - } - fprintf(debug_token,"\n"); - } - switch (current_token.token_type) { - case PARAM_VARIABLE: - if (current_token.token_id == 1) - uses_p1 = 1; - else if (current_token.token_id == 2) - uses_p2 = 1; - else if (current_token.token_id == 8) - uses_p3 = 1; - else if (current_token.token_id == 13) - uses_ismand = 1; - else if (current_token.token_id == 17) - uses_p4 = 1; - else if (current_token.token_id == 18) - uses_p5 = 1; - break; - case PARAM_FUNCTION: - if ((current_token.token_id - 10) > maxfn) - maxfn = (char) (current_token.token_id - 10); - break; - } - } - fclose(entry_file); - if (debug_token) - fclose(debug_token); - if (current_token.token_type != END_OF_FORMULA) { - uses_p1 = uses_p2 = uses_p3 = uses_ismand = maxfn = 0; - uses_p4 = uses_p5 = 0; - return 0; - } - return 1; -} - -/* frm_check_name_and_sym(): - error checking to the open brace on the first line; return 1 - on success, 2 if an invalid symmetry is found, and 0 if errors - are found which should cause the formula not to be executed -*/ - -int frm_check_name_and_sym (FILE * open_file, int report_bad_sym) -{ - long filepos = ftell(open_file); - int c, i, done, at_end_of_name; - - /* first, test name */ - done = at_end_of_name = i = 0; - while (!done) { - switch (c = getc(open_file)) { - case EOF: case '\032': - stopmsg(0,ParseErrs(PE_UNEXPECTED_EOF)); - return 0; - case '\r': case '\n': - stopmsg(0,ParseErrs(PE_NO_LEFT_BRACKET_FIRST_LINE)); - return 0; - case ' ': case '\t': - at_end_of_name = 1; - break; - case '(': case '{': - done = 1; - break; - default : - if (!at_end_of_name) - i++; - break; - } - } - - if (i > ITEMNAMELEN) { - int j; - int k = (int) strlen(ParseErrs(PE_FORMULA_NAME_TOO_LARGE)); - char msgbuf[100]; - strcpy(msgbuf, ParseErrs(PE_FORMULA_NAME_TOO_LARGE)); - strcat(msgbuf, ":\n "); - fseek(open_file, filepos, SEEK_SET); - for (j = 0; j < i && j < 25; j++) - msgbuf[j+k+2] = (char) getc(open_file); - msgbuf[j+k+2] = (char) 0; - stopmsg(STOPMSG_FIXED_FONT, msgbuf); - return 0; - } - /* get symmetry */ - symmetry = 0; - if (c == '(') { - char sym_buf[20]; - done = i = 0; - while (!done) { - switch (c = getc(open_file)) { - case EOF: case '\032': - stopmsg(0,ParseErrs(PE_UNEXPECTED_EOF)); - return 0; - case '\r': case '\n': - stopmsg(STOPMSG_FIXED_FONT,ParseErrs(PE_NO_LEFT_BRACKET_FIRST_LINE)); - return 0; - case '{': - stopmsg(STOPMSG_FIXED_FONT,ParseErrs(PE_NO_MATCH_RIGHT_PAREN)); - return 0; - case ' ': case '\t': - break; - case ')': - done = 1; - break; - default : - if (i < 19) - sym_buf[i++] = (char) toupper(c); - break; - } - } - sym_buf[i] = (char) 0; - for (i = 0; SymStr[i].s[0]; i++) { - if (!stricmp(SymStr[i].s, sym_buf)) { - symmetry = SymStr[i].n; - break; - } - } - if (SymStr[i].s[0] == (char) 0 && report_bad_sym) { - char * msgbuf = (char *) malloc((int) strlen(ParseErrs(PE_INVALID_SYM_USING_NOSYM)) - + (int) strlen(sym_buf) + 6); - strcpy(msgbuf, ParseErrs(PE_INVALID_SYM_USING_NOSYM)); - strcat(msgbuf, ":\n "); - strcat(msgbuf, sym_buf); - stopmsg(STOPMSG_FIXED_FONT, msgbuf); - free(msgbuf); - } - } - if (c != '{') { - done = 0; - while (!done) { - switch (c = getc(open_file)) { - case EOF: case '\032': - stopmsg(STOPMSG_FIXED_FONT,ParseErrs(PE_UNEXPECTED_EOF)); - return 0; - case '\r': case '\n': - stopmsg(STOPMSG_FIXED_FONT,ParseErrs(PE_NO_LEFT_BRACKET_FIRST_LINE)); - return 0; - case '{': - done = 1; - break; - default : - break; - } - } - } - return 1; -} - - -static char *PrepareFormula(FILE * File, int from_prompts1c) { - - /* GGM 5-23-96: replaces FindFormula(). This function sets the - symmetry and converts a formula into a string with no spaces, - and one comma after each expression except where the ':' is placed - and except the final expression in the formula. The open file passed - as an argument is open in "rb" mode and is positioned at the first - letter of the name of the formula to be prepared. This function - is called from RunForm() below. - */ - - FILE *debug_fp = NULL; - char *FormulaStr; - struct token_st temp_tok; - int Done; - long filepos = ftell(File); - -/* char debugmsg[500]; -*/ - - /*Test for a repeat*/ - - if (frm_check_name_and_sym(File, from_prompts1c) == 0) { - fseek(File, filepos, SEEK_SET); - return NULL; - } - if (!frm_prescan(File)) { - fseek(File, filepos, SEEK_SET); - return NULL; - } - - if (chars_in_formula > 8190) { - fseek(File, filepos, SEEK_SET); - return NULL; - } - - if (debugflag == 96) - { - if ((debug_fp = fopen("debugfrm.txt","at")) != NULL) { - fprintf(debug_fp,"%s\n",FormName); - if (symmetry != 0) - fprintf(debug_fp,"%s\n", SymStr[symmetry].s); - } - } - - FormulaStr = (char *)boxx; - FormulaStr[0] = (char) 0; /* To permit concantenation later */ - - Done = 0; - - /*skip opening end-of-lines */ - while (!Done) { - frmgettoken(File, &temp_tok); - if (temp_tok.token_type == NOT_A_TOKEN) { - stopmsg(STOPMSG_FIXED_FONT, "Unexpected token error in PrepareFormula\n"); - fseek(File, filepos, SEEK_SET); - return NULL; - } - else if (temp_tok.token_type == END_OF_FORMULA) { - stopmsg(STOPMSG_FIXED_FONT, "Formula has no executable instructions\n"); - fseek(File, filepos, SEEK_SET); - return NULL; - } - if (temp_tok.token_str[0] == ',') - ; - else { - strcat(FormulaStr, temp_tok.token_str); - Done = 1; - } - } - - Done = 0; - while (!Done) { - frmgettoken(File, &temp_tok); - switch (temp_tok.token_type) { - case NOT_A_TOKEN: - stopmsg(STOPMSG_FIXED_FONT, "Unexpected token error in PrepareFormula\n"); - fseek(File, filepos, SEEK_SET); - return NULL; - case END_OF_FORMULA: - Done = 1; - fseek(File, filepos, SEEK_SET); - break; - default: - strcat(FormulaStr, temp_tok.token_str); - break; - } - } - - if (debug_fp != NULL && FormulaStr != NULL) - fprintf(debug_fp," %s\n",FormulaStr); - if (debug_fp != NULL) - fclose(debug_fp); - - -/* sprintf(debugmsg, "Chars in formula per boxx is %u.\n", strlen(FormulaStr)); - stopmsg(0, debugmsg); -*/ - return FormulaStr; -} - -int BadFormula(void) { - /* moved from Parsera.Asm by CAE 12 July 1993 */ - - /* this is called when a formula is bad, instead of calling */ - /* the normal functions which will produce undefined results */ - return 1; -} - -int RunForm(char *Name, int from_prompts1c) { /* returns 1 if an error occurred */ - - FILE * entry_file = NULL; - - /* CAE changed fn 12 July 1993 to fix problem when formula not found */ - - /* first set the pointers so they point to a fn which always returns 1 */ - curfractalspecific->per_pixel = BadFormula; - curfractalspecific->orbitcalc = BadFormula; - - if (FormName[0] == 0 ){ - return 1; /* and don't reset the pointers */ - } - - /* TW 5-31-94 add search for FRM files in directory */ - if (find_file_item(FormFileName,Name,&entry_file, 1)) { - stopmsg(0, ParseErrs(PE_COULD_NOT_OPEN_FILE_WHERE_FORMULA_LOCATED)); - return 1; - } - - FormStr = PrepareFormula(entry_file, from_prompts1c ); - fclose(entry_file); - - if (FormStr) /* No errors while making string */ - { - parser_allocate(); /* ParseStr() will test if this alloc worked */ - if (ParseStr(FormStr,1)) - return 1; /* parse failed, don't change fn pointers */ - else - { - if (uses_jump == 1 && fill_jump_struct() == 1) { - stopmsg(0, ParseErrs(PE_ERROR_IN_PARSING_JUMP_STATEMENTS)); - return 1; - } - - /* all parses succeeded so set the pointers back to good functions*/ - curfractalspecific->per_pixel = form_per_pixel; - curfractalspecific->orbitcalc = Formula; - return 0; - } - } - else - return 1; /* error in making string*/ -} - - -int fpFormulaSetup(void) { - - int RunFormRes; /* CAE fp */ - /* TODO: when parsera.c contains assembly equivalents, remove !defined(_WIN32) */ -#if !defined(XFRACT) && !defined(_WIN32) - if (fpu > 0) { - MathType = D_MATH; - /* CAE changed below for fp */ - RunFormRes = !RunForm(FormName, 0); /* RunForm() returns 1 for failure */ - if (RunFormRes && fpu >=387 && debugflag != 90 && (orbitsave&2) == 0 - && !Randomized) - return CvtStk(); /* run fast assembler code in parsera.asm */ - return RunFormRes; - } - else { - MathType = M_MATH; - return !RunForm(FormName, 0); - } -#else - MathType = D_MATH; - RunFormRes = !RunForm(FormName, 0); /* RunForm() returns 1 for failure */ -#if 0 - if (RunFormRes && fpu == -1 && debugflag != 90 && (orbitsave&2) == 0 - && !Randomized) - return CvtStk(); /* run fast assembler code in parsera.asm */ -#endif - return RunFormRes; -#endif -} - -int intFormulaSetup(void) { -#if defined(XFRACT) || defined(_WIN32) - static int been_here = 0; - if (!been_here) - { - stopmsg(0, "This integer fractal type is unimplemented;\n" - "Use float=yes to get a real image."); - been_here = 1; - } - return 0; -#else - MathType = L_MATH; - fg = (double)(1L << bitshift); - fgLimit = (double)0x7fffffffL / fg; - ShiftBack = 32 - bitshift; -#endif - return !RunForm(FormName, 0); - } - - -/* TIW added 06-20-90 so functions can be called from fractals.c */ -void init_misc() -{ - static struct ConstArg vv[5]; - static union Arg argfirst,argsecond; - if (!v) - v = vv; - Arg1 = &argfirst; Arg2 = &argsecond; /* needed by all the ?Stk* functions */ - fg = (double)(1L << bitshift); - fgLimit = (double)0x7fffffffL / fg; - ShiftBack = 32 - bitshift; - Delta16 = bitshift - 16; - bitshiftless1 = bitshift-1; - uses_p1 = uses_p2 = uses_p3 = uses_jump = uses_ismand = 0; - uses_p4 = uses_p5 = 0; -} - - -/* PB 910417 here to end changed. - Allocate sub-arrays from one main malloc, using global variable - typespecific_workarea; calcfrac.c releases this area when calculation - ends or is terminated. - Moved the "f" array to be allocated as part of this. - */ - -long total_formula_mem; -static void parser_allocate(void) -{ - /* CAE fp changed below for v18 */ - /* Note that XFRACT will waste about 6k here for pfls */ - /* Somewhat more memory is now allocated than in v17 here */ - /* however Store and Load were reduced in size to help make up for it */ - long f_size,Store_size,Load_size,v_size, p_size; - int pass, is_bad_form=0; - long end_dx_array; - /* TW Jan 1 1996 Made two passes to determine actual values of - Max_Ops and Max_Args. */ - for (pass = 0; pass < 2; pass++) - { - free_workarea(); - if (pass == 0) - { - Max_Ops = 2300; /* this value uses up about 64K memory */ - Max_Args = (unsigned) (Max_Ops/2.5); - } - f_size = sizeof(void (**)(void))*Max_Ops; - Store_size = sizeof(union Arg *)*MAX_STORES; - Load_size = sizeof(union Arg *)*MAX_LOADS; - v_size = sizeof(struct ConstArg)*Max_Args; - p_size = sizeof(struct fls *)*Max_Ops; - total_formula_mem = f_size + Load_size + Store_size + v_size + p_size /*+ jump_size*/ - + sizeof(struct PEND_OP)*Max_Ops; - end_dx_array = use_grid ? 2*(xdots + ydots)*sizeof(double) : 0; - - typespecific_workarea = malloc(f_size + Load_size + Store_size + v_size + p_size); - f = (void (**)(void)) typespecific_workarea; - Store = (union Arg **) (f + Max_Ops); - Load = (union Arg **) (Store + MAX_STORES); - v = (struct ConstArg *) (Load + MAX_LOADS); - pfls = (struct fls *) (v + Max_Args); - - if (pass == 0) - { - is_bad_form = ParseStr(FormStr, pass); - if (is_bad_form == 0) - { - /* per Chuck Ebbert, fudge these up a little */ - Max_Ops = posp + 4; - Max_Args = vsp + 4; - } - } - } - uses_p1 = uses_p2 = uses_p3 = uses_p4 = uses_p5 = 0; -} - -void free_workarea() -{ - if (typespecific_workarea) - { - free(typespecific_workarea); - } - typespecific_workarea = NULL; - Store = (union Arg **) NULL; - Load = (union Arg **) NULL; - v = (struct ConstArg *) NULL; - f = (void (**)(void)) NULL; /* CAE fp */ - pfls = (struct fls * ) NULL; /* CAE fp */ - total_formula_mem = 0; -} - - -struct error_data_st { - long start_pos; - long error_pos; - int error_number; -} errors[3]; - - -void frm_error(FILE * open_file, long begin_frm) -{ - struct token_st tok; -/* char debugmsg[500]; -*/ int i, chars_to_error=0, chars_in_error=0, token_count; - int statement_len, line_number; - int done; - char msgbuf[900]; - long filepos; - int j; - int initialization_error; - strcpy (msgbuf, "\n"); - - for (j=0; j < 3 && errors[j].start_pos; j++) { - initialization_error = errors[j].error_number == PE_SECOND_COLON ? 1 : 0; - fseek(open_file, begin_frm, SEEK_SET); - line_number = 1; - while (ftell(open_file) != errors[j].error_pos) { - i = fgetc(open_file); - if (i == '\n') { - line_number++; - } - else if (i == EOF || i == '}') { - stopmsg(0, "Unexpected EOF or end-of-formula in error function.\n"); - fseek (open_file, errors[j].error_pos, SEEK_SET); - frmgettoken(open_file, &tok); /*reset file to end of error token */ - return; - } - } - sprintf(&msgbuf[(int) strlen(msgbuf)], "Error(%d) at line %d: %s\n ", errors[j].error_number, line_number, ParseErrs(errors[j].error_number)); - i = (int) strlen(msgbuf); -/* sprintf(debugmsg, "msgbuf is: %s\n and i is %d\n", msgbuf, i); - stopmsg (0, debugmsg); -*/ fseek(open_file, errors[j].start_pos, SEEK_SET); - statement_len = token_count = 0; - done = 0; - while (!done) { - filepos = ftell (open_file); - if (filepos == errors[j].error_pos) { -/* stopmsg(0, "About to get error token\n"); -*/ chars_to_error = statement_len; - frmgettoken(open_file, &tok); - chars_in_error = (int) strlen(tok.token_str); - statement_len += chars_in_error; - token_count++; -/* sprintf(debugmsg, "Error is %s\nChars in error is %d\nChars to error is %d\n", tok.token_str, chars_in_error, chars_to_error); - stopmsg (0, debugmsg); -*/ } - else { - frmgettoken(open_file, &tok); -/* sprintf(debugmsg, "Just got %s\n", tok.token_str); - stopmsg (0, debugmsg); -*/ statement_len += (int) strlen(tok.token_str); - token_count++; - } - if ((tok.token_type == END_OF_FORMULA) - || (tok.token_type == OPERATOR - && (tok.token_id == 0 || tok.token_id == 11)) - || (tok.token_type == NOT_A_TOKEN && tok.token_id == END_OF_FILE)){ - done = 1; - if (token_count > 1 && !initialization_error) { - token_count--; - } - } - } - fseek(open_file, errors[j].start_pos, SEEK_SET); - if (chars_in_error < 74) { - while (chars_to_error + chars_in_error > 74) { -/* stopmsg(0, "chars in error less than 74, but late in line"); -*/ frmgettoken(open_file, &tok); - chars_to_error -= (int) strlen(tok.token_str); - token_count--; - } - } - else { - fseek(open_file, errors[j].error_pos, SEEK_SET); - chars_to_error = 0; - token_count = 1; - } -/* stopmsg(0, "Back to beginning of statement to build msgbuf"); -*/ while ((int) strlen(&msgbuf[i]) <=74 && token_count--) { - frmgettoken (open_file, &tok); - strcat (msgbuf, tok.token_str); -/* stopmsg(0, &msgbuf[i]); -*/ } - fseek (open_file, errors[j].error_pos, SEEK_SET); - frmgettoken (open_file, &tok); - if ((int) strlen(&msgbuf[i]) > 74) - msgbuf[i + 74] = (char) 0; - strcat(msgbuf, "\n"); - i = (int) strlen(msgbuf); - while (chars_to_error-- > -2) - strcat (msgbuf, " "); -/* sprintf(debugmsg, "Going into final line, chars in error is %d", chars_in_error); - stopmsg(0, debugmsg); -*/ - if (errors[j].error_number == PE_TOKEN_TOO_LONG) { - chars_in_error = 33; - } - while (chars_in_error-- && (int) strlen(&msgbuf[i]) <=74) - strcat (msgbuf, "^"); - strcat (msgbuf, "\n"); - } - stopmsg (8, msgbuf); - return; -} - -void display_var_list() -{ - struct var_list_st * p; - stopmsg(0, "List of user defined variables:\n"); - for (p = var_list; p; p=p->next_item) { - stopmsg(0, p->name); - } - -} - -void display_const_lists() -{ - struct const_list_st * p; - char msgbuf[800]; - stopmsg (0, "Complex constants are:"); - for (p = complx_list; p; p=p->next_item) { - sprintf(msgbuf, "%f, %f\n", p->complex_const.x, p->complex_const.y); - stopmsg(0, msgbuf); - } - stopmsg (0, "Real constants are:"); - for (p = real_list; p; p=p->next_item) { - sprintf(msgbuf, "%f, %f\n", p->complex_const.x, p->complex_const.y); - stopmsg(0, msgbuf); - } -} - - -struct var_list_st *var_list_alloc() { - return (struct var_list_st *) malloc(sizeof(struct var_list_st)); -} - - -struct const_list_st *const_list_alloc() { - return (struct const_list_st *) malloc(sizeof(struct const_list_st)); -} - -void init_var_list() -{ - struct var_list_st * temp, * p; - for (p = var_list; p; p=temp) { - temp = p->next_item; - free(p); - } - var_list = NULL; -} - - -void init_const_lists() -{ - struct const_list_st * temp, * p; - for (p = complx_list; p; p=temp) { - temp = p->next_item; - free(p); - } - complx_list = NULL; - for (p = real_list; p; p=temp) { - temp = p->next_item; - free(p); - } - real_list = NULL; -} - -struct var_list_st * add_var_to_list (struct var_list_st * p, struct token_st tok) { - if (p == NULL) { - p = var_list_alloc(); - if (p == NULL) - return NULL; - strcpy(p->name, tok.token_str); - p->next_item = NULL; - } - else if (strcmp(p->name, tok.token_str) == 0) { - } - else { - p->next_item = add_var_to_list(p->next_item, tok); - if (p->next_item == NULL) - return NULL; - } - return p; -} - -struct const_list_st * add_const_to_list (struct const_list_st * p, struct token_st tok) { - if (p == NULL) { - p = const_list_alloc(); - if (p == NULL) - return NULL; - p->complex_const.x = tok.token_const.x; - p->complex_const.y = tok.token_const.y; - p->next_item = NULL; - } - else if (p->complex_const.x == tok.token_const.x && p->complex_const.y == tok.token_const.y) { - } - else - { - p->next_item = add_const_to_list(p->next_item, tok); - if (p->next_item == NULL) - return NULL; - } - return p; -} - -void count_lists() -{ -/* char msgbuf[800]; -*/ struct var_list_st * p; - struct const_list_st * q; - - var_count = 0; - complx_count = 0; - real_count = 0; - - for (p = var_list; p; p=p->next_item) { - var_count++; - } - for (q = complx_list; q; q=q->next_item) { - complx_count++; - } - for (q = real_list; q; q=q->next_item) { - real_count++; - } -/* sprintf(msgbuf, "Number of vars is %d\nNumber of complx is %d\nNumber of real is %d\n", var_count, complx_count, real_count); - stopmsg(0, msgbuf); -*/ -} - - - -/*frm_prescan() takes an open file with the file pointer positioned at - the beginning of the relevant formula, and parses the formula, token - by token, for syntax errors. The function also accumulates data for - memory allocation to be done later. - - The function returns 1 if success, and 0 if errors are found. -*/ - -int disable_fastparser; -int must_use_float; - - -int frm_prescan (FILE * open_file) -{ - long filepos; - int i; - long statement_pos, orig_pos; - int done = 0; - struct token_st this_token; - int errors_found = 0; - int ExpectingArg = 1; - int NewStatement = 1; - int assignment_ok = 1; - int already_got_colon = 0; - unsigned long else_has_been_used = 0; - unsigned long waiting_for_mod = 0; - int waiting_for_endif = 0; - int max_parens = sizeof(long) * 8; -/* char debugmsg[800]; - stopmsg (0, "Entering prescan"); -*/ - - disable_fastparser = 0; - must_use_float = 0; - - number_of_ops = number_of_loads = number_of_stores = number_of_jumps = (unsigned) 0L; - chars_in_formula = (unsigned) 0; - uses_jump = (short) 0; - paren = 0; - - init_var_list(); - init_const_lists(); - - orig_pos = statement_pos = ftell(open_file); - for (i = 0; i < 3; i++) { - errors[i].start_pos = 0L; - errors[i].error_pos = 0L; - errors[i].error_number = 0; - } - - while (!done) { -/* char msgbuf[80] = "Just got "; -*/ filepos = ftell (open_file); - frmgettoken (open_file, &this_token); -/* strcat(msgbuf, this_token.token_str); - stopmsg (0, msgbuf); - sprintf (debugmsg, "Errors structure\n0: %ld, %ld, %d\n1: %ld, %ld, %d\n2: %ld, %ld, %d\n\n", - errors[0].start_pos, errors[0].error_pos, errors[0].error_number, - errors[1].start_pos, errors[1].error_pos, errors[1].error_number, - errors[2].start_pos, errors[2].error_pos, errors[2].error_number); - stopmsg (0, debugmsg); -*/ - chars_in_formula += (int) strlen(this_token.token_str); - switch (this_token.token_type) { - case NOT_A_TOKEN: - assignment_ok = 0; - switch (this_token.token_id) { - case END_OF_FILE: - stopmsg(0,ParseErrs(PE_UNEXPECTED_EOF)); - fseek(open_file, orig_pos, SEEK_SET); - return 0; - case ILLEGAL_CHARACTER: - if (!errors_found || errors[errors_found-1].start_pos != statement_pos) { - errors[errors_found].start_pos = statement_pos; - errors[errors_found].error_pos = filepos; - errors[errors_found++].error_number = PE_ILLEGAL_CHAR; - } - break; - case ILLEGAL_VARIABLE_NAME: - if (!errors_found || errors[errors_found-1].start_pos != statement_pos) { - errors[errors_found].start_pos = statement_pos; - errors[errors_found].error_pos = filepos; - errors[errors_found++].error_number = PE_ILLEGAL_VAR_NAME; - } - break; - case TOKEN_TOO_LONG: - if (!errors_found || errors[errors_found-1].start_pos != statement_pos) { - errors[errors_found].start_pos = statement_pos; - errors[errors_found].error_pos = filepos; - errors[errors_found++].error_number = PE_TOKEN_TOO_LONG; - } - break; - case FUNC_USED_AS_VAR: - if (!errors_found || errors[errors_found-1].start_pos != statement_pos) { - errors[errors_found].start_pos = statement_pos; - errors[errors_found].error_pos = filepos; - errors[errors_found++].error_number = PE_FUNC_USED_AS_VAR; - } - break; - case JUMP_MISSING_BOOLEAN: - if (!errors_found || errors[errors_found-1].start_pos != statement_pos) { - errors[errors_found].start_pos = statement_pos; - errors[errors_found].error_pos = filepos; - errors[errors_found++].error_number = PE_JUMP_NEEDS_BOOLEAN; - } - break; - case JUMP_WITH_ILLEGAL_CHAR: - if (!errors_found || errors[errors_found-1].start_pos != statement_pos) { - errors[errors_found].start_pos = statement_pos; - errors[errors_found].error_pos = filepos; - errors[errors_found++].error_number = PE_NO_CHAR_AFTER_THIS_JUMP; - } - break; - case UNDEFINED_FUNCTION: - if (!errors_found || errors[errors_found-1].start_pos != statement_pos) { - errors[errors_found].start_pos = statement_pos; - errors[errors_found].error_pos = filepos; - errors[errors_found++].error_number = PE_UNDEFINED_FUNCTION; - } - break; - case ILLEGAL_OPERATOR: - if (!errors_found || errors[errors_found-1].start_pos != statement_pos) { - errors[errors_found].start_pos = statement_pos; - errors[errors_found].error_pos = filepos; - errors[errors_found++].error_number = PE_UNDEFINED_OPERATOR; - } - break; - case ILL_FORMED_CONSTANT: - if (!errors_found || errors[errors_found-1].start_pos != statement_pos) { - errors[errors_found].start_pos = statement_pos; - errors[errors_found].error_pos = filepos; - errors[errors_found++].error_number = PE_INVALID_CONST; - } - break; - default: - stopmsg(0, "Unexpected arrival at default case in prescan()"); - fseek(open_file, orig_pos, SEEK_SET); - return 0; - } - break; - case PARENS: - assignment_ok = 0; - NewStatement = 0; - switch (this_token.token_id) { - case OPEN_PARENS: - if (++paren > max_parens) { - if (!errors_found || errors[errors_found-1].start_pos != statement_pos) { - errors[errors_found].start_pos = statement_pos; - errors[errors_found].error_pos = filepos; - errors[errors_found++].error_number = PE_NESTING_TO_DEEP; - } - } - else if (!ExpectingArg) { - if (!errors_found || errors[errors_found-1].start_pos != statement_pos) { - errors[errors_found].start_pos = statement_pos; - errors[errors_found].error_pos = filepos; - errors[errors_found++].error_number = PE_SHOULD_BE_OPERATOR; - } - } - waiting_for_mod = waiting_for_mod << 1; - break; - case CLOSE_PARENS: - if (paren) { - paren--; - } - else { - if (!errors_found || errors[errors_found-1].start_pos != statement_pos) { - errors[errors_found].start_pos = statement_pos; - errors[errors_found].error_pos = filepos; - errors[errors_found++].error_number = PE_NEED_A_MATCHING_OPEN_PARENS; - } - paren = 0; - } - if (waiting_for_mod & 1L) { - if (!errors_found || errors[errors_found-1].start_pos != statement_pos) { - errors[errors_found].start_pos = statement_pos; - errors[errors_found].error_pos = filepos; - errors[errors_found++].error_number = PE_UNMATCHED_MODULUS; - } - } - else { - waiting_for_mod = waiting_for_mod >> 1; - } - if (ExpectingArg) { - if (!errors_found || errors[errors_found-1].start_pos != statement_pos) { - errors[errors_found].start_pos = statement_pos; - errors[errors_found].error_pos = filepos; - errors[errors_found++].error_number = PE_SHOULD_BE_ARGUMENT; - } - } - break; - default: - break; - } - break; - case PARAM_VARIABLE: /*i.e. p1, p2, p3, p4 or p5*/ - number_of_ops++; - number_of_loads++; - NewStatement = 0; - if (!ExpectingArg) { - if (!errors_found || errors[errors_found-1].start_pos != statement_pos) { - errors[errors_found].start_pos = statement_pos; - errors[errors_found].error_pos = filepos; - errors[errors_found++].error_number = PE_SHOULD_BE_OPERATOR; - } - } - switch (this_token.token_id) { - case 1: - break; - case 2: - break; - case 8: - break; - case 17: - break; - case 18: - break; - default: - break; - } - ExpectingArg = 0; - break; - case USER_NAMED_VARIABLE: /* i.e. c, iter, etc. */ - number_of_ops++; - number_of_loads++; - NewStatement = 0; - if (!ExpectingArg) { - if (!errors_found || errors[errors_found-1].start_pos != statement_pos) { - errors[errors_found].start_pos = statement_pos; - errors[errors_found].error_pos = filepos; - errors[errors_found++].error_number = PE_SHOULD_BE_OPERATOR; - } - } - ExpectingArg = 0; -/* var_list = add_var_to_list (var_list, this_token); - if (var_list == NULL) { - stopmsg(0, ParseErrs(PE_INSUFFICIENT_MEM_FOR_TYPE_FORMULA)); - fseek(open_file, orig_pos, SEEK_SET); - init_var_list(); - init_const_lists(); - return 0; - } -*/ break; - case PREDEFINED_VARIABLE: /* i.e. z, pixel, whitesq, etc. */ - number_of_ops++; - number_of_loads++; - NewStatement = 0; - if (!ExpectingArg) { - if (!errors_found || errors[errors_found-1].start_pos != statement_pos) { - errors[errors_found].start_pos = statement_pos; - errors[errors_found].error_pos = filepos; - errors[errors_found++].error_number = PE_SHOULD_BE_OPERATOR; - } - } - switch (this_token.token_id) { - case 0: /* pixel */ - break; - case 3: /* z */ - break; - case 4: /* LastSqr */ - break; - case 5: /* pi */ - break; - case 6: /* e */ - break; - case 7: /* rand */ - break; - case 9: /* whitesq */ - break; - case 10: /* scrnpix */ - break; - case 11: /* scrnmax */ - break; - case 12: /* maxit */ - break; - case 13: /* ismand */ - break; - default: - break; - } - ExpectingArg = 0; - break; - case REAL_CONSTANT: /* i.e. 4, (4,0), etc.) */ - assignment_ok = 0; - number_of_ops++; - number_of_loads++; - NewStatement = 0; - if (!ExpectingArg) { - if (!errors_found || errors[errors_found-1].start_pos != statement_pos) { - errors[errors_found].start_pos = statement_pos; - errors[errors_found].error_pos = filepos; - errors[errors_found++].error_number = PE_SHOULD_BE_OPERATOR; - } - } - ExpectingArg = 0; -/* real_list = add_const_to_list (real_list, this_token); - if (real_list == NULL) { - stopmsg(0, ParseErrs(PE_INSUFFICIENT_MEM_FOR_TYPE_FORMULA)); - fseek(open_file, orig_pos, SEEK_SET); - init_var_list(); - init_const_lists(); - return 0; - } -*/ break; - case COMPLEX_CONSTANT: /* i.e. (1,2) etc. */ - assignment_ok = 0; - number_of_ops++; - number_of_loads++; - NewStatement = 0; - if (!ExpectingArg) { - if (!errors_found || errors[errors_found-1].start_pos != statement_pos) { - errors[errors_found].start_pos = statement_pos; - errors[errors_found].error_pos = filepos; - errors[errors_found++].error_number = PE_SHOULD_BE_OPERATOR; - } - } - ExpectingArg = 0; -/* complx_list = add_const_to_list (complx_list, this_token); - if (complx_list == NULL) { - stopmsg(0, ParseErrs(PE_INSUFFICIENT_MEM_FOR_TYPE_FORMULA)); - fseek(open_file, orig_pos, SEEK_SET); - init_var_list(); - init_const_lists(); - return 0; - } -*/ break; - case FUNCTION: - assignment_ok = 0; - NewStatement = 0; - number_of_ops++; - if (!ExpectingArg) { - if (!errors_found || errors[errors_found-1].start_pos != statement_pos) { - errors[errors_found].start_pos = statement_pos; - errors[errors_found].error_pos = filepos; - errors[errors_found++].error_number = PE_SHOULD_BE_OPERATOR; - } - } - switch (this_token.token_id) { - case 0: - break; - case 1: - break; - case 2: - break; - case 3: - break; - case 4: - break; - case 5: - break; - case 6: - break; - case 7: - break; - case 8: - break; - case 9: - break; - case 10: - break; - case 15: - break; - case 16: - break; - case 17: - break; - case 18: - break; - case 19: - break; - case 20: - break; - case 21: - break; - case 22: - break; - case 23: - break; - case 24: - break; - case 25: - break; - case 26: - break; - case 27: - break; - case 28: - break; - case 29: - break; - case 30: - break; - case 31: - break; - case 32: - break; - case 33: - break; - case 34: - break; - default: - break; - } - break; - case PARAM_FUNCTION: - assignment_ok = 0; - NewStatement = 0; - number_of_ops++; - if (!ExpectingArg) { - if (!errors_found || errors[errors_found-1].start_pos != statement_pos) { - errors[errors_found].start_pos = statement_pos; - errors[errors_found].error_pos = filepos; - errors[errors_found++].error_number = PE_SHOULD_BE_OPERATOR; - } - } - switch (this_token.token_id) { - case 11: - break; - case 12: - break; - case 13: - break; - case 14: - break; - default: - break; - } - NewStatement = 0; - break; - case FLOW_CONTROL: - assignment_ok = 0; - number_of_ops++; - number_of_jumps++; - if (!NewStatement) { - if (!errors_found || errors[errors_found-1].start_pos != statement_pos) { - errors[errors_found].start_pos = statement_pos; - errors[errors_found].error_pos = filepos; - errors[errors_found++].error_number = PE_JUMP_NOT_FIRST; - } - } - else { - uses_jump = 1; - switch (this_token.token_id) { - case 1: /* if */ - else_has_been_used = else_has_been_used << 1; - waiting_for_endif++; - break; - case 2: /*ELSEIF*/ - number_of_ops += 3; /*else + two clear statements*/ - number_of_jumps++; /* this involves two jumps */ - if (else_has_been_used % 2) { - if (!errors_found || errors[errors_found-1].start_pos != statement_pos) { - errors[errors_found].start_pos = statement_pos; - errors[errors_found].error_pos = filepos; - errors[errors_found++].error_number = PE_ENDIF_REQUIRED_AFTER_ELSE; - } - } - else if (!waiting_for_endif) { - if (!errors_found || errors[errors_found-1].start_pos != statement_pos) { - errors[errors_found].start_pos = statement_pos; - errors[errors_found].error_pos = filepos; - errors[errors_found++].error_number = PE_MISPLACED_ELSE_OR_ELSEIF; - } - } - break; - case 3: /*ELSE*/ - if (else_has_been_used % 2) { - if (!errors_found || errors[errors_found-1].start_pos != statement_pos) { - errors[errors_found].start_pos = statement_pos; - errors[errors_found].error_pos = filepos; - errors[errors_found++].error_number = PE_ENDIF_REQUIRED_AFTER_ELSE; - } - } - else if (!waiting_for_endif) { - if (!errors_found || errors[errors_found-1].start_pos != statement_pos) { - errors[errors_found].start_pos = statement_pos; - errors[errors_found].error_pos = filepos; - errors[errors_found++].error_number = PE_MISPLACED_ELSE_OR_ELSEIF; - } - } - else_has_been_used = else_has_been_used | 1; - break; - case 4: /*ENDIF*/ - else_has_been_used = else_has_been_used >> 1; - waiting_for_endif--; - if (waiting_for_endif < 0) { - if (!errors_found || errors[errors_found-1].start_pos != statement_pos) { - errors[errors_found].start_pos = statement_pos; - errors[errors_found].error_pos = filepos; - errors[errors_found++].error_number = PE_ENDIF_WITH_NO_IF; - } - waiting_for_endif = 0; - } - break; - default: - break; - } - } - break; - case OPERATOR: - number_of_ops++; /*This will be corrected below in certain cases*/ - switch (this_token.token_id) { - case 0: case 11: /* end of statement and : */ - number_of_ops++; /* ParseStr inserts a dummy op*/ - if (paren) { - if (!errors_found || errors[errors_found-1].start_pos != statement_pos) { - errors[errors_found].start_pos = statement_pos; - errors[errors_found].error_pos = filepos; - errors[errors_found++].error_number = PE_NEED_MORE_CLOSE_PARENS; - } - paren = 0; - } - if (waiting_for_mod) { - if (!errors_found || errors[errors_found-1].start_pos != statement_pos) { - errors[errors_found].start_pos = statement_pos; - errors[errors_found].error_pos = filepos; - errors[errors_found++].error_number = PE_UNMATCHED_MODULUS; - } - waiting_for_mod = 0; - } - if (!ExpectingArg) { - if (this_token.token_id == 11) - number_of_ops += 2; - else - number_of_ops++; - } - else if (!NewStatement) { - if (!errors_found || errors[errors_found-1].start_pos != statement_pos) { - errors[errors_found].start_pos = statement_pos; - errors[errors_found].error_pos = filepos; - errors[errors_found++].error_number = PE_SHOULD_BE_ARGUMENT; - } - } - if (this_token.token_id == 11 && waiting_for_endif) { - if (!errors_found || errors[errors_found-1].start_pos != statement_pos) { - errors[errors_found].start_pos = statement_pos; - errors[errors_found].error_pos = filepos; - errors[errors_found++].error_number = PE_UNMATCHED_IF_IN_INIT_SECTION; - } - waiting_for_endif = 0; - } - if (this_token.token_id == 11 && already_got_colon) { - if (!errors_found || errors[errors_found-1].start_pos != statement_pos) { - errors[errors_found].start_pos = statement_pos; - errors[errors_found].error_pos = filepos; - errors[errors_found++].error_number = PE_SECOND_COLON; - } - } - if (this_token.token_id == 11) - already_got_colon = 1; - NewStatement = ExpectingArg = assignment_ok = 1; - statement_pos = ftell(open_file); - break; - case 1: /* != */ - assignment_ok = 0; - if (ExpectingArg) { - if (!errors_found || errors[errors_found-1].start_pos != statement_pos) { - errors[errors_found].start_pos = statement_pos; - errors[errors_found].error_pos = filepos; - errors[errors_found++].error_number = PE_SHOULD_BE_ARGUMENT; - } - } - ExpectingArg = 1; - break; - case 2: /* = */ - number_of_ops--; /*this just converts a load to a store*/ - number_of_loads--; - number_of_stores++; - if (!assignment_ok) { - if (!errors_found || errors[errors_found-1].start_pos != statement_pos) { - errors[errors_found].start_pos = statement_pos; - errors[errors_found].error_pos = filepos; - errors[errors_found++].error_number = PE_ILLEGAL_ASSIGNMENT; - } - } - ExpectingArg = 1; - break; - case 3: /* == */ - assignment_ok = 0; - if (ExpectingArg) { - if (!errors_found || errors[errors_found-1].start_pos != statement_pos) { - errors[errors_found].start_pos = statement_pos; - errors[errors_found].error_pos = filepos; - errors[errors_found++].error_number = PE_SHOULD_BE_ARGUMENT; - } - } - ExpectingArg = 1; - break; - case 4: /* < */ - assignment_ok = 0; - if (ExpectingArg) { - if (!errors_found || errors[errors_found-1].start_pos != statement_pos) { - errors[errors_found].start_pos = statement_pos; - errors[errors_found].error_pos = filepos; - errors[errors_found++].error_number = PE_SHOULD_BE_ARGUMENT; - } - } - ExpectingArg = 1; - break; - case 5: /* <= */ - assignment_ok = 0; - if (ExpectingArg) { - if (!errors_found || errors[errors_found-1].start_pos != statement_pos) { - errors[errors_found].start_pos = statement_pos; - errors[errors_found].error_pos = filepos; - errors[errors_found++].error_number = PE_SHOULD_BE_ARGUMENT; - } - } - ExpectingArg = 1; - break; - case 6: /* > */ - assignment_ok = 0; - if (ExpectingArg) { - if (!errors_found || errors[errors_found-1].start_pos != statement_pos) { - errors[errors_found].start_pos = statement_pos; - errors[errors_found].error_pos = filepos; - errors[errors_found++].error_number = PE_SHOULD_BE_ARGUMENT; - } - } - ExpectingArg = 1; - break; - case 7: /* >= */ - assignment_ok = 0; - if (ExpectingArg) { - if (!errors_found || errors[errors_found-1].start_pos != statement_pos) { - errors[errors_found].start_pos = statement_pos; - errors[errors_found].error_pos = filepos; - errors[errors_found++].error_number = PE_SHOULD_BE_ARGUMENT; - } - } - ExpectingArg = 1; - break; - case 8: /* | */ /* (half of the modulus operator */ - assignment_ok = 0; - if (!waiting_for_mod & 1L) { - number_of_ops--; - } - if (!(waiting_for_mod & 1L) && !ExpectingArg) { - if (!errors_found || errors[errors_found-1].start_pos != statement_pos) { - errors[errors_found].start_pos = statement_pos; - errors[errors_found].error_pos = filepos; - errors[errors_found++].error_number = PE_SHOULD_BE_OPERATOR; - } - } - else if ((waiting_for_mod & 1L) && ExpectingArg) { - if (!errors_found || errors[errors_found-1].start_pos != statement_pos) { - errors[errors_found].start_pos = statement_pos; - errors[errors_found].error_pos = filepos; - errors[errors_found++].error_number = PE_SHOULD_BE_ARGUMENT; - } - } - waiting_for_mod = waiting_for_mod ^ 1L; /*switch right bit*/ - break; - case 9: /* || */ - assignment_ok = 0; - if (ExpectingArg) { - if (!errors_found || errors[errors_found-1].start_pos != statement_pos) { - errors[errors_found].start_pos = statement_pos; - errors[errors_found].error_pos = filepos; - errors[errors_found++].error_number = PE_SHOULD_BE_ARGUMENT; - } - } - ExpectingArg = 1; - break; - case 10: /* && */ - assignment_ok = 0; - if (ExpectingArg) { - if (!errors_found || errors[errors_found-1].start_pos != statement_pos) { - errors[errors_found].start_pos = statement_pos; - errors[errors_found].error_pos = filepos; - errors[errors_found++].error_number = PE_SHOULD_BE_ARGUMENT; - } - } - ExpectingArg = 1; - break; - case 12: /* + */ /* case 11 (":") is up with case 0 */ - assignment_ok = 0; - if (ExpectingArg) { - if (!errors_found || errors[errors_found-1].start_pos != statement_pos) { - errors[errors_found].start_pos = statement_pos; - errors[errors_found].error_pos = filepos; - errors[errors_found++].error_number = PE_SHOULD_BE_ARGUMENT; - } - } - ExpectingArg = 1; - break; - case 13: /* - */ - assignment_ok = 0; - ExpectingArg = 1; - break; - case 14: /* * */ - assignment_ok = 0; - if (ExpectingArg) { - if (!errors_found || errors[errors_found-1].start_pos != statement_pos) { - errors[errors_found].start_pos = statement_pos; - errors[errors_found].error_pos = filepos; - errors[errors_found++].error_number = PE_SHOULD_BE_ARGUMENT; - } - } - ExpectingArg = 1; - break; - case 15: /* / */ - assignment_ok = 0; - if (ExpectingArg) { - if (!errors_found || errors[errors_found-1].start_pos != statement_pos) { - errors[errors_found].start_pos = statement_pos; - errors[errors_found].error_pos = filepos; - errors[errors_found++].error_number = PE_SHOULD_BE_ARGUMENT; - } - } - ExpectingArg = 1; - break; - case 16: /* ^ */ - assignment_ok = 0; - if (ExpectingArg) { - if (!errors_found || errors[errors_found-1].start_pos != statement_pos) { - errors[errors_found].start_pos = statement_pos; - errors[errors_found].error_pos = filepos; - errors[errors_found++].error_number = PE_SHOULD_BE_ARGUMENT; - } - } - filepos = ftell(open_file); - frmgettoken (open_file, &this_token); - if (this_token.token_str[0] == '-') { - if (!errors_found || errors[errors_found-1].start_pos != statement_pos) { - errors[errors_found].start_pos = statement_pos; - errors[errors_found].error_pos = filepos; - errors[errors_found++].error_number = PE_NO_NEG_AFTER_EXPONENT; - } - } - else - fseek(open_file, filepos, SEEK_SET); - ExpectingArg = 1; - break; - default: - break; - } - break; - case END_OF_FORMULA: - number_of_ops+= 3; /* Just need one, but a couple of extra just for the heck of it */ - if (paren) { - if (!errors_found || errors[errors_found-1].start_pos != statement_pos) { - errors[errors_found].start_pos = statement_pos; - errors[errors_found].error_pos = filepos; - errors[errors_found++].error_number = PE_NEED_MORE_CLOSE_PARENS; - } - paren = 0; - } - if (waiting_for_mod) { - if (!errors_found || errors[errors_found-1].start_pos != statement_pos) { - errors[errors_found].start_pos = statement_pos; - errors[errors_found].error_pos = filepos; - errors[errors_found++].error_number = PE_UNMATCHED_MODULUS; - } - waiting_for_mod = 0; - } - if (waiting_for_endif) { - if (!errors_found || errors[errors_found-1].start_pos != statement_pos) { - errors[errors_found].start_pos = statement_pos; - errors[errors_found].error_pos = filepos; - errors[errors_found++].error_number = PE_IF_WITH_NO_ENDIF; - } - waiting_for_endif = 0; - } - if (ExpectingArg && !NewStatement) { - if (!errors_found || errors[errors_found-1].start_pos != statement_pos) { - errors[errors_found].start_pos = statement_pos; - errors[errors_found].error_pos = filepos; - errors[errors_found++].error_number = PE_SHOULD_BE_ARGUMENT; - } - statement_pos = ftell(open_file); - } - - if (number_of_jumps >= MAX_JUMPS) { - if (!errors_found || errors[errors_found-1].start_pos != statement_pos) { - errors[errors_found].start_pos = statement_pos; - errors[errors_found].error_pos = filepos; - errors[errors_found++].error_number = PE_TOO_MANY_JUMPS; - } - } - - - - done = 1; - break; - default: - break; - } - if (errors_found == 3) - done = 1; - } - if (errors[0].start_pos) { -/* sprintf (debugmsg, "Errors structure on entering frm_error\n 0: %ld, %ld, %d\n1: %ld, %ld, %d\n2: %ld, %ld, %d\n\n", - errors[0].start_pos, errors[0].error_pos, errors[0].error_number, - errors[1].start_pos, errors[1].error_pos, errors[1].error_number, - errors[2].start_pos, errors[2].error_pos, errors[2].error_number); - stopmsg (0, debugmsg); -*/ frm_error(open_file, orig_pos); - fseek(open_file, orig_pos, SEEK_SET); - return 0; - } - fseek(open_file, orig_pos, SEEK_SET); - -/* display_var_list(); - display_const_lists(); -*/ count_lists(); - -/* sprintf(debugmsg, "Chars in formula per prescan() is %u.\n", chars_in_formula); - stopmsg(0, debugmsg); -*/ return 1; -} - diff --git a/fractint/common/parserfp.c b/fractint/common/parserfp.c deleted file mode 100644 index 6f9cca351..000000000 --- a/fractint/common/parserfp.c +++ /dev/null @@ -1,1444 +0,0 @@ -/* PARSERFP.C -- Part of FRACTINT fractal drawer. */ - -/* By Chuck Ebbert CompuServe [76306,1226] */ -/* internet: 76306.1226@compuserve.com */ - -/* Fast floating-point parser code. The functions beginning with */ -/* "fStk" are in PARSERA.ASM. PARSER.C calls this code after */ -/* it has parsed the formula. */ - -/* Converts the function pointers/load pointers/store pointers */ -/* built by parsestr() into an optimized array of function */ -/* pointer/operand pointer pairs. */ - -/* As of 31 Dec 93, also generates executable code in memory. */ -/* Define the varible COMPILER to generate executable code. */ -/* COMPILER must also be defined in PARSERA.ASM. */ - - -/* Revision history: */ - -/* 15 Mar 1997 TIW */ -/* Fixed if/else bug, replaced stopmsg with pstopmsg */ - -/* 09 Mar 1997 TIW/GGM */ -/* Added support for if/else */ - -/* 30 Jun 1996 TIW */ -/* Removed function names if TESTFP not defined to save memory */ -/* Function fStkFloor added to support new 'floor' function */ -/* Function fStkCeil added to support new 'ceil' function */ -/* Function fStkTrunc added to support new 'trunc' function */ -/* Function fStkRound added to support new 'round' function */ - -/* 15 Feb 1995 CAE */ -/* added safety tests to pointer conversion code */ -/* added the capability for functions to require 4 free regs */ - -/* 8 Feb 1995 CAE */ -/* Comments changed. */ - -/* 8 Jan 1995 JCO */ -/* Function fStkASin added to support new 'asin' function in v19 */ -/* Function fStkASinh added to support new 'asinh' function in v19 */ -/* Function fStkACos added to support new 'acos' function in v19 */ -/* Function fStkACosh added to support new 'acosh' function in v19 */ -/* Function fStkATan added to support new 'atan' function in v19 */ -/* Function fStkATanh added to support new 'atanh' function in v19 */ -/* Function fStkSqrt added to support new 'sqrt' function in v19 */ -/* Function fStkCAbs added to support new 'cabs' function in v19 */ -/* Added support for a third parameter p3 */ - -/* 31 Dec 1993 CAE */ -/* Fixed optimizer bug discovered while testing compiler. */ - -/* 29 Dec 1993 CAE */ -/* Added compiler. */ - -/* 04 Dec 1993 CAE */ -/* Added optimizations for LodImagAdd/Sub/Mul. */ - -/* 06 Nov 1993 CAE */ -/* Added optimizer support for LodRealPwr and ORClr2 functions. */ -/* If stack top is a real, a simpler sqr() or mod() fn will be */ -/* called (fStkSqr3() was added.) */ -/* The identities x^0=1, x^1=x, and x^-1=recip(x) are now used by the */ -/* optimizer. (fStkOne() was added for this.) */ - -/* 31 Oct 1993 CAE */ -/* Optimizer converts '2*x' and 'x*2' to 'x+x'. */ -/* " recognizes LastSqr as a real if not stored to. */ - -/* 9 Oct 1993 CAE */ -/* Functions are now converted via table search. */ -/* Added "real" stack count variable and debug msgs for stack size. */ -/* Added optimizer extension for commutative multiply. */ -/* P1, P2 will be treated as consts if they are never stored to. */ -/* Function fStkStoClr2 now emitted for sto,clr with 2 on stack. */ -/* " fStkZero added to support new 'zero' function in v18 */ -/* Added optimization for x^2 -> sqr(x). */ -/* Changed "stopmsg" to "DBUGMSG" and made all macros upper case. */ -/* (debugflag=324 now needed for debug msgs to print.) */ - -/* 12 July 1993 (for v18.1) by CAE to fix optimizer bug */ - -/* 22 MAR 1993 (for Fractint v18.0) */ - -/* ******************************************************************* */ -/* */ -/* (c) Copyright 1992-1995 Chuck Ebbert. All rights reserved. */ -/* */ -/* This code may be freely distributed and used in non-commercial */ -/* programs provided the author is credited either during program */ -/* execution or in the documentation, and this copyright notice */ -/* is left intact. Sale of this code, or its use in any commercial */ -/* product requires permission from the author. Nominal */ -/* distribution and handling fees may be charged by shareware and */ -/* freeware distributors. */ -/* */ -/* ******************************************************************* */ - -/* Uncomment the next line to enable debug messages. */ -/* #define TESTFP 1 */ - -/* Use startup parameter "debugflag=324" to show debug messages after */ -/* compiling with above #define uncommented. */ - -#include -#include -#include - - /* see Fractint.c for a description of the "include" hierarchy */ -#include "port.h" -#include "prototyp.h" - -/* global data */ -struct fls *pfls = (struct fls *)0; - -#if !defined(XFRACT) - -/* not moved to PROTOTYPE.H because these only communicate within - PARSER.C and other parser modules */ - -extern union Arg *Arg1, *Arg2; -extern double _1_, _2_; -extern union Arg s[20], * *Store, * *Load; -extern int StoPtr, LodPtr, OpPtr; -extern unsigned int vsp, LastOp; -extern struct ConstArg *v; -extern int InitLodPtr, InitStoPtr, InitOpPtr, LastInitOp; -extern void (* *f)(void); -extern JUMP_CONTROL_ST *jump_control; -extern int uses_jump, jump_index; - -typedef void OLD_FN(void); /* old C functions */ - -OLD_FN StkLod, StkClr, StkSto, EndInit, StkJumpLabel; -OLD_FN dStkAdd, dStkSub, dStkMul, dStkDiv; -OLD_FN dStkSqr, dStkMod; -OLD_FN dStkSin, dStkCos, dStkSinh, dStkCosh, dStkCosXX; -OLD_FN dStkTan, dStkTanh, dStkCoTan, dStkCoTanh; -OLD_FN dStkLog, dStkExp, dStkPwr; -OLD_FN dStkLT, dStkLTE; -OLD_FN dStkFlip, dStkReal, dStkImag; -OLD_FN dStkConj, dStkNeg, dStkAbs; -OLD_FN dStkRecip, StkIdent; -OLD_FN dStkGT, dStkGTE, dStkNE, dStkEQ; -OLD_FN dStkAND, dStkOR; -OLD_FN dStkZero; -OLD_FN dStkSqrt; -OLD_FN dStkASin, dStkACos, dStkASinh, dStkACosh; -OLD_FN dStkATanh, dStkATan; -OLD_FN dStkCAbs; -OLD_FN dStkFloor; -OLD_FN dStkCeil; -OLD_FN dStkTrunc; -OLD_FN dStkRound; -OLD_FN StkJump, dStkJumpOnTrue, dStkJumpOnFalse; -OLD_FN dStkOne; - -typedef void ( NEW_FN)(void); /* new 387-only ASM functions */ - -NEW_FN fStkPull2; /* pull up fpu stack from 2 to 4 */ -NEW_FN fStkPush2; /* push down fpu stack from 8 to 6 */ -NEW_FN fStkPush2a; /* push down fpu stack from 6 to 4 */ -NEW_FN fStkPush4; /* push down fpu stack from 8 to 4 */ -NEW_FN fStkLodDup; /* lod, dup */ -NEW_FN fStkLodSqr; /* lod, sqr, dont save magnitude(i.e. lastsqr) */ -NEW_FN fStkLodSqr2; /* lod, sqr, save lastsqr */ -NEW_FN fStkStoDup; /* store, duplicate */ -NEW_FN fStkStoSqr; /* store, sqr, save lastsqr */ -NEW_FN fStkStoSqr0; /* store, sqr, dont save lastsqr */ -NEW_FN fStkLodDbl; /* load, double */ -NEW_FN fStkStoDbl; /* store, double */ -NEW_FN fStkReal2; /* fast ver. of real */ -NEW_FN fStkSqr; /* sqr, save magnitude in lastsqr */ -NEW_FN fStkSqr0; /* sqr, no save magnitude */ -NEW_FN fStkClr1; /* clear fpu */ -NEW_FN fStkClr2; /* test stack top, clear fpu */ -NEW_FN fStkStoClr1; /* store, clr1 */ -NEW_FN fStkAdd, fStkSub; -NEW_FN fStkSto, fStkSto2; /* fast ver. of sto */ -NEW_FN fStkLod, fStkEndInit; -NEW_FN fStkMod, fStkMod2; /* faster mod */ -NEW_FN fStkLodMod2, fStkStoMod2; -NEW_FN fStkLTE, fStkLodLTEMul, fStkLTE2, fStkLodLTE; -NEW_FN fStkLodLTE2, fStkLodLTEAnd2; -NEW_FN fStkLT, fStkLodLTMul, fStkLT2, fStkLodLT; -NEW_FN fStkLodLT2; -NEW_FN fStkGTE, fStkLodGTE, fStkLodGTE2; -NEW_FN fStkGT, fStkGT2, fStkLodGT, fStkLodGT2; -NEW_FN fStkEQ, fStkLodEQ, fStkNE, fStkLodNE; -NEW_FN fStkAND, fStkANDClr2, fStkOR, fStkORClr2; -NEW_FN fStkSin, fStkSinh, fStkCos, fStkCosh, fStkCosXX; -NEW_FN fStkTan, fStkTanh, fStkCoTan, fStkCoTanh; -NEW_FN fStkLog, fStkExp, fStkPwr; -NEW_FN fStkMul, fStkDiv; -NEW_FN fStkFlip, fStkReal, fStkImag, fStkRealFlip, fStkImagFlip; -NEW_FN fStkConj, fStkNeg, fStkAbs, fStkRecip; -NEW_FN fStkLodReal, fStkLodRealC, fStkLodImag; -NEW_FN fStkLodRealFlip, fStkLodRealAbs; -NEW_FN fStkLodRealMul, fStkLodRealAdd, fStkLodRealSub, fStkLodRealPwr; -NEW_FN fStkLodImagMul, fStkLodImagAdd, fStkLodImagSub; /* CAE 4Dec93 */ -NEW_FN fStkLodImagFlip, fStkLodImagAbs; -NEW_FN fStkLodConj; -NEW_FN fStkLodAdd, fStkLodSub, fStkLodSubMod, fStkLodMul; -NEW_FN fStkPLodAdd, fStkPLodSub; /* push-lod-add/sub */ -NEW_FN fStkIdent; -NEW_FN fStkStoClr2; /* store, clear stack by popping */ -NEW_FN fStkZero; /* to support new parser fn. */ -NEW_FN fStkDbl; /* double the stack top CAE 31OCT93 */ -NEW_FN fStkOne, fStkSqr3; /* sqr3 is sqr/mag of a real CAE 09NOV93 */ -NEW_FN fStkSqrt; -NEW_FN fStkASin, fStkACos, fStkASinh, fStkACosh; -NEW_FN fStkATanh, fStkATan; -NEW_FN fStkCAbs; -NEW_FN fStkFloor, fStkCeil, fStkTrunc, fStkRound; /* rounding functions */ -NEW_FN fStkJump, fStkJumpOnTrue, fStkJumpOnFalse, fStkJumpLabel; /* flow */ -NEW_FN fStkOne; /* to support new parser fn. */ - -/* check to see if a const is being loaded */ -/* the really awful hack below gets the first char of the name */ -/* of the variable being accessed */ -/* if first char not alpha, or const p1, p2, or p3 are being accessed */ -/* then this is a const. */ -#define IS_CONST(x) \ - (!isalpha(**(((char * *)x ) - 2 ) ) \ - || (x==&PARM1 && p1const ) \ - || (x==&PARM2 && p2const ) \ - || (x==&PARM3 && p3const ) \ - || (x==&PARM4 && p4const ) \ - || (x==&PARM5 && p5const ) ) - -/* is stack top a real? */ -#define STACK_TOP_IS_REAL \ - ( prevfptr == fStkReal || prevfptr == fStkReal2 \ - || prevfptr == fStkLodReal || prevfptr == fStkLodRealC \ - || prevfptr == fStkLodRealAbs \ - || prevfptr == fStkImag || prevfptr == fStkLodImag ) - -/* remove push operator from stack top */ -#define REMOVE_PUSH --cvtptrx, stkcnt+=2 - -#define CLEAR_STK 127 -#define FNPTR(x) pfls[(x)].function /* function pointer */ -#define OPPTR(x) pfls[(x)].operand /* operand pointer */ -#define NO_OPERAND (union Arg *)0 -#define NO_FUNCTION (void ( *)(void))0 -#define LASTSQR v[4].a -#define PARM1 v[1].a -#define PARM2 v[2].a -#define PARM3 v[8].a -#define PARM4 v[17].a -#define PARM5 v[18].a -#define MAX_STACK 8 /* max # of stack register avail */ - -#ifdef TESTFP -int pstopmsg(int x,char *msg) -{ - static FILE *fp = NULL; - if (fp == NULL) - fp = fopen("fpdebug.txt","w"); - if (fp) - { - fprintf(fp,"%s\n",msg); - fflush(fp); - } - return(x); /* just to quiet warnings */ -} - -#define stopmsg pstopmsg - -#define DBUGMSG(y) if (debugflag==324 || debugflag==322 ) stopmsg(0, (y)) -#define DBUGMSG1(y,p) \ - if (debugflag==324 || debugflag==322 ){ \ - sprintf(cDbgMsg, (y), (p) ); \ - stopmsg(0, cDbgMsg ); \ - } -#define DBUGMSG2(y,p,q) \ - if (debugflag==324 || debugflag==322 ){ \ - sprintf(cDbgMsg, (y), (p), (q) ); \ - stopmsg(0, cDbgMsg ); \ - } -#define DBUGMSG3(y,p,q,r) \ - if (debugflag==324 || debugflag==322 ){ \ - sprintf(cDbgMsg, (y), (p), (q), (r) ); \ - stopmsg(0, cDbgMsg ); \ - } -#define DBUGMSG4(y,p,q,r,s) \ - if (debugflag==324 || debugflag==322 ){ \ - sprintf(cDbgMsg, (y), (p), (q), (r), (s) ); \ - stopmsg(0, cDbgMsg ); \ - } -#define FNAME(a,b,c,d,e,f) a,b,c,d,e,f /* use the function name string */ -#else - -#define DBUGMSG(y) -#define DBUGMSG1(y,p) -#define DBUGMSG2(y,p,q) -#define DBUGMSG3(y,p,q,r) -#define DBUGMSG4(y,p,q,r,s) -#define FNAME(a,b,c,d,e,f) b,c,d,e,f /* don't use the function name string */ -#endif /* TESTFP */ - -#define FN_LOD 0 -#define FN_CLR 1 -#define FN_ADD 2 -#define FN_SUB 3 -#define FN_MUL 4 -#define FN_DIV 5 -#define FN_STO 6 -#define FN_SQR 7 -#define FN_ENDINIT 8 -#define FN_MOD 9 -#define FN_LTE 10 -#define FN_SIN 11 -#define FN_COS 12 -#define FN_SINH 13 -#define FN_COSH 14 -#define FN_COSXX 15 -#define FN_TAN 16 -#define FN_TANH 17 -#define FN_COTAN 18 -#define FN_COTANH 19 -#define FN_LOG 20 -#define FN_EXP 21 -#define FN_PWR 22 -#define FN_LT 23 -#define FN_FLIP 24 -#define FN_REAL 25 -#define FN_IMAG 26 -#define FN_CONJ 27 -#define FN_NEG 28 -#define FN_ABS 29 -#define FN_RECIP 30 -#define FN_IDENT 31 -#define FN_GT 32 -#define FN_GTE 33 -#define FN_NE 34 -#define FN_EQ 35 -#define FN_AND 36 -#define FN_OR 37 -#define FN_ZERO 38 -#define FN_SQRT 39 -#define FN_ASIN 40 -#define FN_ACOS 41 -#define FN_ASINH 42 -#define FN_ACOSH 43 -#define FN_ATANH 44 -#define FN_ATAN 45 -#define FN_CABS 46 -#define FN_FLOOR 47 -#define FN_CEIL 48 -#define FN_TRUNC 49 -#define FN_ROUND 50 -#define FN_JUMP 51 -#define FN_JUMP_ON_TRUE 52 -#define FN_JUMP_ON_FALSE 53 -#define FN_JUMP_LABEL 54 -#define FN_ONE 55 - - -/* number of "old" functions in the table. */ -/* these are the ones that the parser outputs */ - -#define LAST_OLD_FN FN_ONE -#define NUM_OLD_FNS LAST_OLD_FN + 1 - -/* total number of functions in the table. */ - -#define LAST_FN FN_ONE -#define NUM_FNS LAST_FN + 1 - -static unsigned char - realstkcnt, /* how many scalars are really on stack */ - stkcnt, /* # scalars on FPU stack */ - lastsqrused, /* was lastsqr loaded in the formula? */ - lastsqrreal, /* was lastsqr stored explicitly in the formula? */ - p1const, /* is p1 a constant? */ - p2const, /* ...and p2? */ - p3const, /* ...and p3? */ - p4const, /* ...and p4? */ - p5const; /* ...and p5? */ - -static unsigned int - cvtptrx; /* subscript of next free entry in pfls */ - -static void ( *prevfptr )(void); /* previous function pointer */ - -/* the entries in this table must be in the same order as */ -/* the #defines above */ -/* this table is searched sequentially */ -struct fn_entry { - -#ifdef TESTFP - char *fname; /* function name */ -#endif - void (*infn)(void); /* 'old' function pointer */ - /* (infn points to an operator fn in parser.c) */ - - void ( *outfn)(void); /* pointer to equiv. fast fn. */ - - char min_regs; /* min regs needed on stack by this fn. */ - /* (legal values are 0, 2, 4) */ - - char free_regs; /* free regs required by this fn */ - /* (legal values are 0, 2, 4) */ - - char delta; /* net change to # of values on the fp stack */ - /* (legal values are -2, 0, +2) */ - -} static afe[NUM_OLD_FNS] = { /* array of function entries */ - - {FNAME("Lod", StkLod, fStkLod, 0, 2, +2) }, /* 0 */ - {FNAME("Clr", StkClr, fStkClr1, 0, 0, CLEAR_STK) }, /* 1 */ - {FNAME("+", dStkAdd, fStkAdd, 4, 0, -2) }, /* 2 */ - {FNAME("-", dStkSub, fStkSub, 4, 0, -2) }, /* 3 */ - {FNAME("*", dStkMul, fStkMul, 4, 2, -2) }, /* 4 */ - {FNAME("/", dStkDiv, fStkDiv, 4, 2, -2) }, /* 5 */ - {FNAME("Sto", StkSto, fStkSto, 2, 0, 0) }, /* 6 */ - {FNAME("Sqr", dStkSqr, fStkSqr, 2, 2, 0) }, /* 7 */ - {FNAME(":", EndInit, fStkEndInit,0, 0, CLEAR_STK) }, /* 8 */ - {FNAME("Mod", dStkMod, fStkMod, 2, 0, 0) }, /* 9 */ - {FNAME("<=", dStkLTE, fStkLTE, 4, 0, -2) }, /* 10 */ - {FNAME("Sin", dStkSin, fStkSin, 2, 2, 0) }, /* 11 */ - {FNAME("Cos", dStkCos, fStkCos, 2, 2, 0) }, /* 12 */ - {FNAME("Sinh", dStkSinh, fStkSinh, 2, 2, 0) }, /* 13 */ - {FNAME("Cosh", dStkCosh, fStkCosh, 2, 2, 0) }, /* 14 */ - {FNAME("Cosxx", dStkCosXX, fStkCosXX, 2, 2, 0) }, /* 15 */ - {FNAME("Tan", dStkTan, fStkTan, 2, 2, 0) }, /* 16 */ - {FNAME("Tanh", dStkTanh, fStkTanh, 2, 2, 0) }, /* 17 */ - {FNAME("CoTan", dStkCoTan, fStkCoTan, 2, 2, 0) }, /* 18 */ - {FNAME("CoTanh", dStkCoTanh, fStkCoTanh, 2, 2, 0) }, /* 19 */ - {FNAME("Log", dStkLog, fStkLog, 2, 2, 0) }, /* 20 */ - {FNAME("Exp", dStkExp, fStkExp, 2, 2, 0) }, /* 21 */ - {FNAME("^", dStkPwr, fStkPwr, 4, 2, -2) }, /* 22 */ - {FNAME("<", dStkLT, fStkLT, 4, 0, -2) }, /* 23 */ - {FNAME("Flip", dStkFlip, fStkFlip, 2, 0, 0) }, /* 24 */ - {FNAME("Real", dStkReal, fStkReal, 2, 0, 0) }, /* 25 */ - {FNAME("Imag", dStkImag, fStkImag, 2, 0, 0) }, /* 26 */ - {FNAME("Conj", dStkConj, fStkConj, 2, 0, 0) }, /* 27 */ - {FNAME("Neg", dStkNeg, fStkNeg, 2, 0, 0) }, /* 28 */ - {FNAME("Abs", dStkAbs, fStkAbs, 2, 0, 0) }, /* 29 */ - {FNAME("Recip", dStkRecip, fStkRecip, 2, 2, 0) }, /* 30 */ - {FNAME("Ident", StkIdent, fStkIdent, 2, 0, 0) }, /* 31 */ - {FNAME(">", dStkGT, fStkGT, 4, 0, -2) }, /* 32 */ - {FNAME(">=", dStkGTE, fStkGTE, 4, 0, -2) }, /* 33 */ - {FNAME("!=", dStkNE, fStkNE, 4, 0, -2) }, /* 34 */ - {FNAME("==", dStkEQ, fStkEQ, 4, 0, -2) }, /* 35 */ - {FNAME("&&", dStkAND, fStkAND, 4, 0, -2) }, /* 36 */ - {FNAME("||", dStkOR, fStkOR, 4, 0, -2) }, /* 37 */ - {FNAME("Zero", dStkZero, fStkZero, 2, 0, 0) }, /* 38 */ - {FNAME("Sqrt", dStkSqrt, fStkSqrt, 2, 2, 0) }, /* 39 */ - {FNAME("ASin", dStkASin, fStkASin, 2, 4, 0) }, /* 40 */ - {FNAME("ACos", dStkACos, fStkACos, 2, 4, 0) }, /* 41 */ - {FNAME("ASinh", dStkASinh, fStkASinh, 2, 4, 0) }, /* 42 */ - {FNAME("ACosh", dStkACosh, fStkACosh, 2, 4, 0) }, /* 43 */ - {FNAME("ATanh", dStkATanh, fStkATanh, 2, 4, 0) }, /* 44 */ - {FNAME("ATan", dStkATan, fStkATan, 2, 4, 0) }, /* 45 */ - {FNAME("CAbs", dStkCAbs, fStkCAbs, 2, 0, 0) }, /* 46 */ - {FNAME("Floor", dStkFloor, fStkFloor, 2, 0, 0) }, /* 47 */ - {FNAME("Ceil", dStkCeil, fStkCeil, 2, 0, 0) }, /* 48 */ - {FNAME("Trunc", dStkTrunc, fStkTrunc, 2, 0, 0) }, /* 49 */ - {FNAME("Round", dStkRound, fStkRound, 2, 0, 0) }, /* 50 */ - {FNAME("Jump", StkJump, fStkJump, 0, 0, 0)},/* 51 */ - {FNAME("JumpOnTrue", dStkJumpOnTrue, fStkJumpOnTrue, 2, 0, 0)},/* 52 */ - {FNAME("JumpOnFalse", dStkJumpOnFalse, fStkJumpOnFalse,2, 0, 0)},/* 53 */ - {FNAME("JumpLabel", StkJumpLabel, fStkJumpLabel, 0, 0, 0)},/* 54 */ - {FNAME("One", dStkOne, fStkOne, 2, 0, 0) } /* 55 */ -}; - -#ifdef TESTFP -static char cDbgMsg[255]; -#endif /* TESTFP */ - -static int CvtFptr(void ( * ffptr)(void), int MinStk, int FreeStk, - int Delta ) -{ - union Arg *otemp; /* temp operand ptr */ - union Arg *testload; -#ifdef TESTFP - int prevstkcnt; -#endif - double dTemp; - - int Max_On_Stack = MAX_STACK - FreeStk; /* max regs allowed on stack */ - int Num_To_Push; /* number of regs to push */ - - /* first do some sanity checks */ /* CAE 15Feb95 */ - if ( (Delta != -2 && Delta != 0 && Delta != 2 && Delta != CLEAR_STK) - || (FreeStk != 0 && FreeStk != 2 && FreeStk != 4) - || (MinStk != 0 && MinStk != 2 && MinStk != 4) ){ -awful_error: - stopmsg (0,"FATAL INTERNAL PARSER ERROR!"); - return 0; /* put out dire message and revert to old parser */ - } - - /* this if statement inserts a stack push or pull into the token array */ - /* it would be much better to do this *after* optimization */ - if ((int)stkcnt < MinStk ) { /* not enough operands on fpu stack */ - DBUGMSG2("Inserted pull. Stack: %2d --> %2d", stkcnt, stkcnt+2 ); - OPPTR(cvtptrx) = NO_OPERAND; - FNPTR(cvtptrx++) = fStkPull2; /* so adjust the stack, pull operand */ - stkcnt += 2; - } - else if ((int)stkcnt > Max_On_Stack ) { /* too many operands */ - - Num_To_Push = stkcnt - Max_On_Stack; - if (Num_To_Push == 2 ){ - if (stkcnt == MAX_STACK ){ - /* push stack down from max to max-2 */ - FNPTR(cvtptrx) = fStkPush2; - } - else if (stkcnt == MAX_STACK - 2 ){ - /* push stack down from max-2 to max-4 */ - FNPTR(cvtptrx) = fStkPush2a; - } - else { - goto awful_error; - } - DBUGMSG2("Inserted push. Stack: %2d --> %2d", stkcnt, stkcnt-2 ); - OPPTR(cvtptrx++) = NO_OPERAND; - stkcnt -= 2; - } - else if (Num_To_Push == 4 ){ - /* push down from max to max-4 */ - FNPTR(cvtptrx) = fStkPush4; - DBUGMSG2("Inserted push. Stack: %2d --> %2d", stkcnt, stkcnt-4 ); - OPPTR(cvtptrx++) = NO_OPERAND; - stkcnt -= 4; - } - else { - goto awful_error; - } - } - - /* set the operand pointer here for store function */ - if (ffptr == fStkSto ){ - OPPTR(cvtptrx) = (void *)FP_OFF((Store[StoPtr++])); - } - else if (ffptr == fStkLod && debugflag == 322 ){ - /* when disabling optimizer, set load pointer here */ - OPPTR(cvtptrx) = (void *)FP_OFF((Load[LodPtr++])); - } - else { /* the optimizer will set the pointer for load fn. */ - OPPTR(cvtptrx) = NO_OPERAND; - } - - if (debugflag == 322 ){ - goto SkipOptimizer; - } /* -------------------------- begin optimizer --------------------- */ - - /* This optimizer grew from a simple if statement into a monster. */ - - /* Most of the bugs in the optimizer have been in the code that */ - /* juggles the overflow stack. */ - - /* For the following: */ - /* * == cvtptrx points to this */ - /* () == this is about to be added to the array */ - - /* ******************************************************************** */ - if (ffptr == fStkLod) { /* about to add Lod to the array */ - - if (prevfptr == fStkLod && Load[LodPtr-1] == Load[LodPtr] ) { - /* previous non-adjust operator was Lod of same operand */ - /* ? lodx ? (*lodx) */ - if (FNPTR(--cvtptrx) == fStkPush2 ){ /* prev fn was push */ - /* ? lod *push (lod) */ - --cvtptrx; /* found *lod push (lod) */ - if (FNPTR(cvtptrx-1) == fStkPush2){ /* always more ops here */ - DBUGMSG("push *lod push (lod) -> push4 (*loddup)" ); - FNPTR(cvtptrx-1) = fStkPush4; - } - else { /* prev op not push */ - DBUGMSG("op *lod push (lod) -> op pusha(p=0) (*loddup)" ); - OPPTR(cvtptrx) = NO_OPERAND; /* use 'alternate' push fn. */ - FNPTR(cvtptrx++) = fStkPush2a; /* push w/2 free on stack */ - /* operand ptr will be set below */ - } - } - else { /* never push *lod (lod) so must be */ - DBUGMSG("op *lod (lod) -> op (*loddup)" ); - } - ffptr = fStkLodDup; - } - else if (prevfptr == fStkSto2 - && Store[StoPtr-1] == Load[LodPtr] ){ - /* store, load of same value */ - /* only one operand on stack here when prev oper is Sto2 */ - DBUGMSG("*sto2 (lod) -> (*stodup)" ); - --cvtptrx; - ffptr = fStkStoDup; - } - /* This may cause roundoff problems when later operators */ - /* use the rounded value that was stored here, while the next */ - /* operator uses the more accurate internal value. */ - else if (prevfptr == fStkStoClr2 - && Store[StoPtr-1] == Load[LodPtr] ){ - /* store, clear, load same value found */ - /* only one operand was on stack so this is safe */ - DBUGMSG("*StoClr2 (Lod) -> (*Sto2)" ); - --cvtptrx; - ffptr = fStkSto2; /* use different Sto fn */ - } - else { - testload = Load[LodPtr]; - if (testload == &LASTSQR && lastsqrreal ){ - /* -- LastSqr is a real. CAE 31OCT93 */ - DBUGMSG("(*lod[lastsqr]) -> (*lodreal)" ); - ffptr = fStkLodReal; - } - else if (IS_CONST(testload) && testload->d.y == 0.0 ){ - DBUGMSG("(*lod) -> (*lodrealc)" ); - ffptr = fStkLodRealC; /* a real const is being loaded */ - } - } - /* set the operand ptr here */ - OPPTR(cvtptrx) = (void *)FP_OFF((Load[LodPtr++])); - } - /* ******************************************************************** */ - else if (ffptr == fStkAdd ){ - - if (prevfptr == fStkLodDup ){ /* there is never a push before add */ - --cvtptrx; /* found ? *loddup (add) */ - if (cvtptrx!=0 && FNPTR(cvtptrx-1) == fStkPush2a ){ - /* because push lod lod is impossible so is push loddup */ - DBUGMSG("pusha *loddup (add) -> (*loddbl),stk+=2" ); - REMOVE_PUSH; - OPPTR(cvtptrx) = OPPTR(cvtptrx+1); /* fix opptr */ - } - else if (cvtptrx!=0 && FNPTR(cvtptrx-1) == fStkPush4 ){ - DBUGMSG("push4 *loddup (add) -> push2 (*loddbl),stk+=2" ); - FNPTR(cvtptrx-1) = fStkPush2; - stkcnt += 2; /* CAE added 12 July 1993 to fix bug */ - } - else { - DBUGMSG("op *loddup (add) -> op (*loddbl)" ); - } - ffptr = fStkLodDbl; - } - else if (prevfptr == fStkStoDup ){ - DBUGMSG("stodup (*add) -> (*stodbl)" ); - /* there are always exactly 4 on stack here */ - --cvtptrx; - ffptr = fStkStoDbl; - } - else if (prevfptr == fStkLod ){ /* have found lod (*add) */ - --cvtptrx; /* ? *lod (add) */ - if (FNPTR(cvtptrx-1) == fStkPush2 ){ - DBUGMSG("*push load (add) -> (*plodadd),stk+=2" ); - REMOVE_PUSH; - OPPTR(cvtptrx) = OPPTR(cvtptrx+1); /* fix opptrs */ - ffptr = fStkPLodAdd; - } - else { - DBUGMSG("op *lod (add) -> op (*lodadd)" ); - ffptr = fStkLodAdd; - } - } - else if (prevfptr == fStkLodReal || prevfptr == fStkLodRealC ){ - --cvtptrx; /* found ? *lodreal (add) */ - if (FNPTR(cvtptrx-1) == fStkPush2 ){ - DBUGMSG("*push lodreal (add) -> (*lodrealadd),stk+=2" ); - REMOVE_PUSH; - OPPTR(cvtptrx) = OPPTR(cvtptrx+1); /* fix opptrs */ - } - else { - DBUGMSG("*lodreal (add) -> (*lodrealadd)" ); - } - ffptr = fStkLodRealAdd; - } - else if (prevfptr == fStkLodImag ){ /* CAE 4DEC93 */ - --cvtptrx; /* found ? *lodimag (add) */ - if (FNPTR(cvtptrx-1) == fStkPush2 ){ - DBUGMSG("*push lodimag (add) -> (*lodimagadd),stk+=2" ); - REMOVE_PUSH; - OPPTR(cvtptrx) = OPPTR(cvtptrx+1); /* fix opptrs */ - } - else { - DBUGMSG("*lodimag (add) -> (*lodimagadd)" ); - } - ffptr = fStkLodImagAdd; - } - } - /* ******************************************************************** */ - else if (ffptr == fStkSub ){ - - if (prevfptr == fStkLod ){ - /* found lod (*sub) */ - --cvtptrx; /* *lod (sub) */ - /* there is never a sequence (lod push sub ) */ - if (FNPTR(cvtptrx-1) == fStkPush2 ){ - DBUGMSG("*push lod (sub) -> (*plodsub),stk+=2" ); - REMOVE_PUSH; - OPPTR(cvtptrx) = OPPTR(cvtptrx+1); /* fix opptrs */ - ffptr = fStkPLodSub; - } - else { - DBUGMSG("*lod (sub) -> (*lodsub)" ); - ffptr = fStkLodSub; - } - } - else if (prevfptr == fStkLodReal || prevfptr == fStkLodRealC ){ - --cvtptrx; /* ? *lodreal (sub) */ - if (FNPTR(cvtptrx-1) == fStkPush2 ){ - DBUGMSG("*push lodreal (sub) -> (*lodrealsub),stk+=2" ); - REMOVE_PUSH; - OPPTR(cvtptrx) = OPPTR(cvtptrx+1); /* fix opptrs */ - } - else { - DBUGMSG("*lodreal (sub) -> (*lodrealsub)" ); - } - ffptr = fStkLodRealSub; - } - else if (prevfptr == fStkLodImag ){ /* CAE 4DEC93 */ - --cvtptrx; /* ? *lodimag (sub) */ - if (FNPTR(cvtptrx-1) == fStkPush2 ){ - DBUGMSG("*push lodimag (sub) -> (*lodimagsub),stk+=2" ); - REMOVE_PUSH; - OPPTR(cvtptrx) = OPPTR(cvtptrx+1); /* fix opptrs */ - } - else { - DBUGMSG("*lodimag (sub) -> (*lodimagsub)" ); - } - ffptr = fStkLodImagSub; - } - } - /* ******************************************************************** */ - else if (ffptr == fStkMul ){ - - if (prevfptr == fStkLodDup ){ - /* found loddup ? (*mul) */ - if (FNPTR(--cvtptrx) == fStkPush2 ){ - DBUGMSG("loddup *push (mul) -> (*lodsqr),stk+=2" ); - REMOVE_PUSH; - } - else { - DBUGMSG("*loddup (mul) -> (*lodsqr)" ); - } - ffptr = fStkLodSqr; - } - else if (prevfptr == fStkStoDup ){ /* no pushes here, 4 on stk. */ - DBUGMSG("stodup (mul) -> (*stosqr0)" ); - --cvtptrx; - ffptr = fStkStoSqr0; /* dont save lastsqr here ever */ - } - else if (prevfptr == fStkLod ){ - --cvtptrx; /* lod *? (mul) */ - if (FNPTR(cvtptrx) == fStkPush2 ){ /* lod *push (mul) */ - --cvtptrx; /* ? *lod push (mul) */ - if (FNPTR(cvtptrx-1) == fStkPush2 ){ - DBUGMSG("push *lod push (mul) -> push4 (*lodmul)" ); - FNPTR(cvtptrx-1) = fStkPush4; - } - else { - DBUGMSG("op *lod push (mul) -> op pusha (*lodmul)" ); - OPPTR(cvtptrx+1) = OPPTR(cvtptrx); /* fix operand ptr */ - FNPTR(cvtptrx) = fStkPush2a; - OPPTR(cvtptrx) = NO_OPERAND; - cvtptrx++; - } - } - else { - DBUGMSG("*lod (mul) -> (*lodmul)" ); - } - ffptr = fStkLodMul; - - /********************** begin extension *** CAE 9 Oct 93 ****/ - /* change loadreal a, lodmul b --> lod b, lodrealmul a */ - - FNPTR(cvtptrx) = NO_FUNCTION; /* mark the pending fn as null */ - if (FNPTR(cvtptrx-1) == fStkPush4 - || FNPTR(cvtptrx-1) == fStkPush2a ){ - --cvtptrx; /* look back past this push */ - } - - if (FNPTR(cvtptrx-1) == fStkLodRealC - && Load[LodPtr-2]->d.x == _2_ ){ - /* -- Convert '2*a' into 'a+a'. CAE 31OCT93 */ - if (FNPTR(cvtptrx) == NO_FUNCTION ){ - DBUGMSG("lodreal[2] (*lodmul[b])" - " -> (*loddbl[b])" ); - OPPTR(cvtptrx-1) = OPPTR(cvtptrx); - } - else if (FNPTR(cvtptrx) == fStkPush2a ){ - DBUGMSG("lodreal[2] *pusha (lodmul[b])" - " -> loddbl[b],stk+=2" ); - OPPTR(cvtptrx-1) = OPPTR(cvtptrx+1); - stkcnt += 2; - } - else if (FNPTR(cvtptrx) == fStkPush4 ){ - DBUGMSG("lodreal[2] *push4 (lodmul[b])" - " -> loddbl[b],stk+=4" ); - OPPTR(cvtptrx-1) = OPPTR(cvtptrx+1); - stkcnt += 4; - } - FNPTR(--cvtptrx) = NO_FUNCTION; /* so no increment later */ - ffptr = fStkLodDbl; - } - else if (FNPTR(cvtptrx-1) == fStkLodReal - || FNPTR(cvtptrx-1) == fStkLodRealC ){ - /* lodreal *?push?? (*?lodmul) */ - otemp = OPPTR(cvtptrx-1); /* save previous fn's operand */ - FNPTR(cvtptrx-1) = fStkLod; /* prev fn = lod */ - /* Moved setting of prev lodptr to below CAE 31DEC93 */ - /* This was a bug causing a bad loadptr to be set here */ - /* 3 lines marked 'prev lodptr=this' below replace this line */ - if (FNPTR(cvtptrx) == NO_FUNCTION ){ - DBUGMSG("lodreal[a] (*lodmul[b])" - " -> lod[b] (*lodrealmul[a])" ); - OPPTR(cvtptrx-1) = OPPTR(cvtptrx); /* prev lodptr=this */ - } - else if (FNPTR(cvtptrx) == fStkPush2a ){ - DBUGMSG("lodreal[a] *pusha (lodmul[b])" - " -> lod[b] (*lodrealmul[a]),stk+=2" ); - /* set this fn ptr to null so cvtptrx won't be incr later */ - FNPTR(cvtptrx) = NO_FUNCTION; - OPPTR(cvtptrx-1) = OPPTR(cvtptrx+1); /* prev lodptr=this */ - stkcnt += 2; - } - else if (FNPTR(cvtptrx) == fStkPush4 ){ - DBUGMSG("lodreal[a] *push4 (lodmul[b])" - " -> lod[b] push2 (*lodrealmul[a]),stk+=2" ); - FNPTR(cvtptrx++) = fStkPush2; - OPPTR(cvtptrx-2) = OPPTR(cvtptrx); /* prev lodptr=this */ - /* we know cvtptrx points to a null function now */ - stkcnt += 2; - } - OPPTR(cvtptrx) = otemp; /* switch the operands */ - ffptr = fStkLodRealMul; /* next fn is now lodrealmul */ - } - - if (FNPTR(cvtptrx) != NO_FUNCTION ){ - cvtptrx++; /* adjust cvtptrx back to normal if needed */ - } - /* ********************** end extension *********************** */ - } - else if (prevfptr == fStkLodReal || prevfptr == fStkLodRealC ){ - - --cvtptrx; /* found lodreal *? (mul) */ - if (FNPTR(cvtptrx) == fStkPush2 ){ - DBUGMSG("lodreal *push2 (mul) -> (*lodrealmul),stk+=2" ); - REMOVE_PUSH; - } - else { - DBUGMSG("*lodreal (mul) -> (*lodrealmul)" ); - } - ffptr = fStkLodRealMul; - - /********************** begin extension *** CAE 31OCT93 ****/ - if (prevfptr == fStkLodRealC /* use prevfptr here */ - && Load[LodPtr-1]->d.x == _2_ ){ - if (FNPTR(cvtptrx) == fStkPush2 ){ - DBUGMSG("push (*lodrealmul[2]) -> (*dbl),stk+=2" ); - REMOVE_PUSH; - } - else { - DBUGMSG("*lodrealmul[2] -> (*dbl)" ); - } - OPPTR(cvtptrx) = NO_OPERAND; - ffptr = fStkDbl; - - if (FNPTR(cvtptrx-1) == fStkLod ){ - DBUGMSG("lod (*dbl) -> (*loddbl)" ); - --cvtptrx; - ffptr = fStkLodDbl; - } - else if (FNPTR(cvtptrx-1) == fStkSto2 ){ - DBUGMSG("sto2 (*dbl) -> (*stodbl)" ); - --cvtptrx; - ffptr = fStkStoDbl; - } - } - /************************ end extension *** CAE 31OCT93 ****/ - } - else if (prevfptr == fStkLodImag ){ /* CAE 4DEC93 */ - - --cvtptrx; /* found lodimag *? (mul) */ - if (FNPTR(cvtptrx) == fStkPush2 ){ - DBUGMSG("lodimag *push2 (mul) -> (*lodimagmul),stk+=2" ); - REMOVE_PUSH; - } - else { - DBUGMSG("*lodimag (mul) -> (*lodimagmul)" ); - } - ffptr = fStkLodImagMul; - } - else if (prevfptr == fStkLodLT && FNPTR(cvtptrx-1) != fStkPull2 ){ - /* this shortcut fails if Lod LT Pull Mul found */ - DBUGMSG("LodLT (*Mul) -> (*LodLTMul)" ); - --cvtptrx; /* never lod LT Push Mul here */ - ffptr = fStkLodLTMul; - } - else if (prevfptr == fStkLodLTE && FNPTR(cvtptrx-1) != fStkPull2 ){ - DBUGMSG("LodLTE (*mul) -> (*LodLTEmul)" ); - --cvtptrx; - ffptr = fStkLodLTEMul; - } - } - /* ******************************************************************** */ - else if (ffptr == fStkClr1 && prevfptr == fStkSto ){ - - --cvtptrx; - if (stkcnt == 2 ){ - DBUGMSG("sto (*clr1) -> (*stoclr2)" ); - ffptr = fStkStoClr2; - } - else { - DBUGMSG("sto (*clr1) -> (*stoclr1)" ); - ffptr = fStkStoClr1; - } - } - /* ******************************************************************** */ - else if (ffptr == fStkDiv ){ - - if (prevfptr == fStkLodRealC && vsp < Max_Args - 1 ){ - /* have found a divide by a real constant */ - /* and there is space to create a new one */ - /* lodrealc ? (*div) */ - if (FNPTR(--cvtptrx) == fStkPush2 ){ - DBUGMSG("lodrealc *push (div) -> (*lodrealmul),stk+=2" ); - REMOVE_PUSH; - } - else { - DBUGMSG("*lodrealc (div) -> (*lodrealmul)" ); - } - v[vsp].s = (void *)0; /* this constant has no name */ - v[vsp].len = 0; - v[vsp].a.d.x = _1_ / Load[LodPtr-1]->d.x; - v[vsp].a.d.y = 0.0; - { - void *p = &v[vsp++].a; - OPPTR(cvtptrx) = (void *)FP_OFF(p); /* isn't C fun! */ - } - ffptr = fStkLodRealMul; - } - } - /* ******************************************************************** */ - else if (ffptr == fStkReal ){ - - if (prevfptr == fStkLod ){ - DBUGMSG("lod (*real) -> (*lodreal)" ); - --cvtptrx; - ffptr = fStkLodReal; - } - else if (stkcnt < MAX_STACK ){ - DBUGMSG("(*real) -> (*real2)" ); - ffptr = fStkReal2; - } - } - /* ******************************************************************** */ - else if (ffptr == fStkImag && prevfptr == fStkLod ){ - - DBUGMSG("lod (*imag) -> lodimag" ); - --cvtptrx; - ffptr = fStkLodImag; - } - /* ******************************************************************** */ - else if (ffptr == fStkConj && prevfptr == fStkLod ){ - - DBUGMSG("lod (*conj) -> (*lodconj)" ); - --cvtptrx; - ffptr = fStkLodConj; - } - /* ******************************************************************** */ - else if (ffptr == fStkMod && stkcnt < MAX_STACK ){ - - DBUGMSG("(*mod) -> (*mod2)" ); - ffptr = fStkMod2; /* use faster version if room on stack */ - if (prevfptr == fStkLod ){ - DBUGMSG("lod (*mod2) -> (*lodmod2)" ); - --cvtptrx; - ffptr = fStkLodMod2; - } - else if (prevfptr == fStkSto || prevfptr == fStkSto2 ){ - DBUGMSG("sto (*mod2) -> (*stomod2)" ); - --cvtptrx; - ffptr = fStkStoMod2; - } - else if (prevfptr == fStkLodSub ){ - DBUGMSG("lodsub (*mod2) -> (*lodsubmod)" ); - --cvtptrx; - ffptr = fStkLodSubMod; - } - else if (STACK_TOP_IS_REAL){ /* CAE 06NOV93 */ - DBUGMSG("(*mod2[st real]) -> (*sqr3)" ); - ffptr = fStkSqr3; - } - } - /* ******************************************************************** */ - else if (ffptr == fStkFlip ){ - - if (prevfptr == fStkReal || prevfptr == fStkReal2 ){ - DBUGMSG("real (*flip) -> (*realflip)" ); - --cvtptrx; - ffptr = fStkRealFlip; - } - else if (prevfptr == fStkImag ){ - DBUGMSG("imag (*flip) -> (*imagflip)" ); - --cvtptrx; - ffptr = fStkImagFlip; - } - else if (prevfptr == fStkLodReal ){ - DBUGMSG("lodreal (*flip) -> (*lodrealflip)" ); - --cvtptrx; - ffptr = fStkLodRealFlip; - } - else if (prevfptr == fStkLodImag ){ - DBUGMSG("lodimag (*flip) -> (*lodimagflip)" ); - --cvtptrx; - ffptr = fStkLodImagFlip; - } - } - /* ******************************************************************** */ - else if (ffptr == fStkAbs ){ - - if (prevfptr == fStkLodReal ){ - DBUGMSG("lodreal (*abs) -> (*lodrealabs)" ); - --cvtptrx; - ffptr = fStkLodRealAbs; - } - else if (prevfptr == fStkLodImag ){ - DBUGMSG("lodimag (*abs) -> (*lodimagabs)" ); - --cvtptrx; - ffptr = fStkLodImagAbs; - } - } - /* ******************************************************************** */ - else if (ffptr == fStkSqr ){ - - if (prevfptr == fStkLod && FNPTR(cvtptrx-1) != fStkPush2 ){ - DBUGMSG("lod (*sqr) -> (*lodsqr)" ); - --cvtptrx; - ffptr = fStkLodSqr; /* assume no need to save lastsqr */ - if (lastsqrused){ - DBUGMSG("(*lodsqr) -> (*lodsqr2)" ); - ffptr = fStkLodSqr2; /* lastsqr is being used */ - } - } - else if (prevfptr == fStkSto2 ){ - DBUGMSG("sto2 (*sqr) -> (*stosqr0)" ); - --cvtptrx; - ffptr = fStkStoSqr0; /* assume no need to save lastsqr */ - if (lastsqrused) { - DBUGMSG("(*stosqr0) -> (*stosqr)" ); - ffptr = fStkStoSqr; /* save lastsqr */ - } - } - else { - if (!lastsqrused) { - DBUGMSG("(*sqr) -> (*sqr0)" ); - ffptr = fStkSqr0; /* don't save lastsqr */ - if (STACK_TOP_IS_REAL){ /* CAE 06NOV93 */ - DBUGMSG("(*sqr0[st real]) -> (*sqr3)" ); - ffptr = fStkSqr3; - } - } - } - } - /* ******************************************************************** */ - else if (ffptr == fStkPwr ){ - - if (prevfptr == fStkLodRealC ){ - dTemp = Load[LodPtr-1]->d.x; - if (dTemp == _2_ || dTemp == _1_ || dTemp == -1.0 || dTemp == 0.0 ){ - /* change ^[-1,0,1,or 2] to recip,one,ident,sqr CAE 06NOV93 */ - if (FNPTR(cvtptrx-1) == fStkPush2 ){ - DBUGMSG("LodRealC[-1,0,1,2] Push (*Pwr)" - " -> (*[recip,1,ident,Sqr0]), stk+=2" ); - REMOVE_PUSH; /* lod[?] (push) *pwr */ - } - else { - DBUGMSG("LodRealC[-1,0,1,2] (*Pwr)" - " -> (*[recip,1,ident,sqr0])" ); - } - --cvtptrx; - OPPTR(cvtptrx) = NO_OPERAND; - if (dTemp == _2_ ){ - DBUGMSG("[]=Sqr0" ); - ffptr = fStkSqr0; /* no need to compute lastsqr here */ - if (FNPTR(cvtptrx-1) == fStkLod ){ - DBUGMSG("Lod (*Sqr0) -> (*LodSqr)" ); - --cvtptrx; - ffptr = fStkLodSqr; /* dont save lastsqr */ - } - else if (FNPTR(cvtptrx-1) == fStkSto2 ){ - DBUGMSG("Sto2 (*Sqr0) -> (*StoSqr0)" ); - --cvtptrx; - ffptr = fStkStoSqr0; /* dont save lastsqr */ - } - } - else if (dTemp == _1_ ){ - DBUGMSG("[]=Ident" ); - ffptr = fStkIdent; - } - else if (dTemp == 0.0 ){ - DBUGMSG("[]=One" ); - ffptr = fStkOne; - } - else if (dTemp == -1.0 ){ - DBUGMSG("[]=Recip" ); - ffptr = fStkRecip; - } - } - else if (FNPTR(cvtptrx-1) == prevfptr ){ - --cvtptrx; - ffptr = fStkLodRealPwr; /* see comments below */ - } - } - else if (prevfptr == fStkLodReal && FNPTR(cvtptrx-1) == prevfptr ){ - /* CAE 6NOV93 */ - /* don't handle pushes here, lodrealpwr needs 4 free */ - DBUGMSG("LodReal (*Pwr) -> (*LodRealPwr)" ); - --cvtptrx; - ffptr = fStkLodRealPwr; - } - } - /* ******************************************************************** */ - else if (ffptr == fStkLTE ){ - - if (prevfptr == fStkLod - || prevfptr == fStkLodReal || prevfptr == fStkLodRealC ){ - DBUGMSG("Lod (*LTE) -> (*LodLTE)" ); - --cvtptrx; - ffptr = fStkLodLTE; - } - } - /* ******************************************************************** */ - else if (ffptr == fStkLT ){ - - if (prevfptr == fStkLod || prevfptr == fStkLodReal - || prevfptr == fStkLodRealC ){ - DBUGMSG("Lod (*LT) -> (*LodLT)" ); - --cvtptrx; - ffptr = fStkLodLT; - } - } - /* ******************************************************************** */ - else if (ffptr == fStkGT ){ - - if (prevfptr == fStkLod - || prevfptr == fStkLodReal || prevfptr == fStkLodRealC ){ - DBUGMSG("Lod (*GT) -> (*LodGT)" ); - --cvtptrx; - ffptr = fStkLodGT; - } - } - /* ******************************************************************** */ - else if (ffptr == fStkGTE ){ - - if (prevfptr == fStkLod - || prevfptr == fStkLodReal || prevfptr == fStkLodRealC ){ - DBUGMSG("Lod (*GTE) -> (*LodGTE)" ); - --cvtptrx; - ffptr = fStkLodGTE; - } - } - /* ******************************************************************** */ - else if (ffptr == fStkNE ){ - - if (prevfptr == fStkLod - || prevfptr == fStkLodReal || prevfptr == fStkLodRealC ){ - DBUGMSG("Lod (*NE) -> (*LodNE)" ); - --cvtptrx; - ffptr = fStkLodNE; - } - } - /* ******************************************************************** */ - else if (ffptr == fStkEQ ){ - - if (prevfptr == fStkLod - || prevfptr == fStkLodReal || prevfptr == fStkLodRealC ){ - DBUGMSG("Lod (*EQ) -> (*LodEQ)" ); - --cvtptrx; - ffptr = fStkLodEQ; - } - } - /* ******************************************************************** */ -SkipOptimizer: /* ------------- end of optimizer ----------------------- */ - - FNPTR(cvtptrx++) = prevfptr = ffptr; -#ifdef TESTFP - prevstkcnt = stkcnt; -#endif - if (Delta == CLEAR_STK ){ - realstkcnt = stkcnt = 0; - } - else { - stkcnt = (unsigned char)(stkcnt + Delta); - realstkcnt = (unsigned char)(realstkcnt + Delta); - } - - DBUGMSG3("Stack: %2d --> %2d, Real stack: %2d", - prevstkcnt, stkcnt, realstkcnt ); - - return 1; /* return 1 for success */ -} - -int fpfill_jump_struct(void) -{ /* Completes all entries in jump structure. Returns 1 on error) */ - /* On entry, jump_index is the number of jump functions in the formula*/ - int i = 0; - int checkforelse = 0; - NEW_FN * JumpFunc = NULL; - int find_new_func = 1; - JUMP_PTRS_ST jump_data[MAX_JUMPS]; - - for (OpPtr = 0; OpPtr < (int) LastOp; OpPtr++) { - if (find_new_func) { - switch (jump_control[i].type) { - case 1: - JumpFunc = fStkJumpOnFalse; - break; - case 2: - checkforelse = !checkforelse; - if (checkforelse) - JumpFunc = fStkJump; - else - JumpFunc = fStkJumpOnFalse; - break; - case 3: - JumpFunc = fStkJump; - break; - case 4: - JumpFunc = fStkJumpLabel; - break; - default: - break; - } - find_new_func = 0; - } - if (pfls[OpPtr].function == JumpFunc) { - jump_data[i].JumpOpPtr = OpPtr*4; - i++; - find_new_func = 1; - } - } - - /* Following for safety only; all should always be false */ - if (i != jump_index || jump_control[i - 1].type != 4 - || jump_control[0].type != 1) { - return 1; - } - - while (i > 0) { - i--; - i = fill_if_group(i, jump_data); - } - return i < 0 ? 1 : 0; -} - -extern int fform_per_pixel(void); /* these fns are in parsera.asm */ -extern int BadFormula(void); -extern void (Img_Setup )(void); - -int CvtStk() { /* convert the array of ptrs */ - extern char FormName[]; - void (*ftst)(void); - void ( *ntst)(void); - union Arg *testoperand; - struct fn_entry *pfe; - int fnfound; - - lastsqrreal = 1; /* assume lastsqr is real (not stored explicitly) */ - p1const = p2const = p3const = (unsigned char)1; /* . . . p1, p2, p3 const */ - p4const = p5const = (unsigned char)1; /* . . . p4, p5 const */ - lastsqrused = 0; /* ... and LastSqr is not used */ - - /* now see if the above assumptions are true */ - for (OpPtr = LodPtr = StoPtr = 0; OpPtr < (int)LastOp; OpPtr++ ){ - ftst = f[OpPtr]; - if (ftst == StkLod ){ - if (Load[LodPtr++] == &LASTSQR ){ - lastsqrused = 1; - } - } - else if (ftst == StkSto ){ - testoperand = Store[StoPtr++]; - if (testoperand == &PARM1 ){ - p1const = 0; - } - else if (testoperand == &PARM2 ){ - p2const = 0; - } - else if (testoperand == &PARM3 ){ - p3const = 0; - } - else if (testoperand == &PARM4 ){ - p4const = 0; - } - else if (testoperand == &PARM5 ){ - p5const = 0; - } - else if (testoperand == &LASTSQR ){ - lastsqrreal = 0; - } - } - } - - if (!p1const) { - DBUGMSG("p1 not constant" ); - } - if (!p2const) { - DBUGMSG("p2 not constant" ); - } - if (!p3const) { - DBUGMSG("p3 not constant" ); - } - if (!p4const) { - DBUGMSG("p4 not constant" ); - } - if (!p5const) { - DBUGMSG("p5 not constant" ); - } - if (lastsqrused) { - DBUGMSG("LastSqr loaded" ); - if (!lastsqrreal) { - DBUGMSG("LastSqr stored" ); - } - } - - if (f[LastOp-1] != StkClr ){ - DBUGMSG("Missing clr added at end" ); - /* should be safe to modify this */ - f[LastOp++] = StkClr; - } - - prevfptr = (void ( *)(void))0; - cvtptrx = realstkcnt = stkcnt = 0; - - for (OpPtr = LodPtr = StoPtr = 0; OpPtr < (int)LastOp; OpPtr++) { - ftst = f[OpPtr]; - fnfound = 0; - for (pfe = &afe[0]; pfe <= &afe[LAST_OLD_FN]; pfe++ ){ - if (ftst == pfe->infn ){ - fnfound = 1; - ntst = pfe->outfn; - if (ntst == fStkClr1 && OpPtr == (int)(LastOp-1) ){ - ntst = fStkClr2; /* convert the last clear to a clr2 */ - DBUGMSG("Last fn (CLR) --> (is really CLR2)" ); - } - if (ntst == fStkIdent && debugflag != 322 ){ - /* ident will be skipped here */ - /* this is really part of the optimizer */ - DBUGMSG("IDENT was skipped" ); - } - else { - DBUGMSG4("fn=%s, minstk=%1i, freestk=%1i, delta=%3i", - pfe->fname, - (int)(pfe->min_regs), - (int)(pfe->free_regs), - (int)(pfe->delta) ); - if (!CvtFptr(ntst, - pfe->min_regs, - pfe->free_regs, - pfe->delta) ){ - return 1; - } - } - } - } - if (!fnfound ){ - /* return success so old code will be used */ - /* stopmsg(0, "Fast 387 parser failed, reverting to slower code." );*/ - return 1; /* this should only happen if random numbers are used */ - } - } /* end for */ - - if (debugflag == 322 ){ - goto skipfinalopt; - } /* ------------------------------ final optimizations ---------- */ - - /* cvtptrx -> one past last operator (always clr2) */ - --cvtptrx; /* now it points to the last operator */ - ntst = FNPTR(cvtptrx-1); - /* ntst is the next-to-last operator */ - - if (ntst == fStkLT ){ - DBUGMSG("LT Clr2 -> LT2" ); - FNPTR(cvtptrx-1) = fStkLT2; - } - else if (ntst == fStkLodLT ){ - DBUGMSG("LodLT Clr2 -> LodLT2" ); - FNPTR(cvtptrx-1) = fStkLodLT2; - } - else if (ntst == fStkLTE ){ - DBUGMSG("LTE Clr2 -> LTE2" ); - FNPTR(cvtptrx-1) = fStkLTE2; - } - else if (ntst == fStkLodLTE ){ - DBUGMSG("LodLTE Clr2 -> LodLTE2" ); - FNPTR(cvtptrx-1) = fStkLodLTE2; - } - else if (ntst == fStkGT ){ - DBUGMSG("GT Clr2 -> GT2" ); - FNPTR(cvtptrx-1) = fStkGT2; - } - else if (ntst == fStkLodGT ){ - DBUGMSG("LodGT Clr2 -> LodGT2" ); - FNPTR(cvtptrx-1) = fStkLodGT2; - } - else if (ntst == fStkLodGTE ){ - DBUGMSG("LodGTE Clr2 -> LodGTE2" ); - FNPTR(cvtptrx-1) = fStkLodGTE2; - } - else if (ntst == fStkAND ){ - DBUGMSG("AND Clr2 -> ANDClr2" ); - FNPTR(cvtptrx-1) = fStkANDClr2; - ntst = FNPTR(cvtptrx-2); - if (ntst == fStkLodLTE ){ - DBUGMSG("LodLTE ANDClr2 -> LodLTEAnd2" ); - --cvtptrx; - FNPTR(cvtptrx-1) = fStkLodLTEAnd2; - } - } - else if (ntst == fStkOR ){ /* CAE 06NOV93 */ - DBUGMSG("OR Clr2 -> ORClr2" ); - FNPTR(cvtptrx-1) = fStkORClr2; - } - else { - ++cvtptrx; /* adjust this back since no optimization was found */ - } - -skipfinalopt: /* -------------- end of final optimizations ------------ */ - - LastOp = cvtptrx; /* save the new operator count */ - LASTSQR.d.y = 0.0; /* do this once per image */ - - /* now change the pointers */ - if (FormName[0] != 0 && - (uses_jump == 0 || fpfill_jump_struct() == 0)){ /* but only if parse succeeded */ - curfractalspecific->per_pixel = fform_per_pixel; - curfractalspecific->orbitcalc = fFormula; - } - else { - curfractalspecific->per_pixel = BadFormula; - curfractalspecific->orbitcalc = BadFormula; - } - - Img_Setup(); /* call assembler setup code */ - return 1; -} - -#endif /* XFRACT */ diff --git a/fractint/common/plot3d.c b/fractint/common/plot3d.c deleted file mode 100644 index 818f2acf8..000000000 --- a/fractint/common/plot3d.c +++ /dev/null @@ -1,488 +0,0 @@ -/* - This file includes miscellaneous plot functions and logic - for 3D, used by lorenz.c and line3d.c - By Tim Wegner and Marc Reinig. -*/ - - /* see Fractint.c for a description of the "include" hierarchy */ -#include "port.h" -#include "prototyp.h" -#include "fractype.h" - -/* Use these palette indices for red/blue - same on ega/vga */ -#define PAL_BLUE 1 -#define PAL_RED 2 -#define PAL_MAGENTA 3 - -int g_which_image; -int xxadjust1; -int yyadjust1; -int g_eye_separation = 0; -int g_glasses_type = 0; -int xshift1; -int yshift1; -int xtrans = 0; -int ytrans = 0; -int red_local_left; -int red_local_right; -int blue_local_left; -int blue_local_right; -int red_crop_left = 4; -int red_crop_right = 0; -int blue_crop_left = 0; -int blue_crop_right = 4; -int red_bright = 80; -int blue_bright = 100; - -BYTE T_RED; - -/* Bresenham's algorithm for drawing line */ -void cdecl draw_line (int X1, int Y1, int X2, int Y2, int color) - -{ /* uses Bresenham algorithm to draw a line */ - int dX, dY; /* vector components */ - int row, col, - final, /* final row or column number */ - G, /* used to test for new row or column */ - inc1, /* G increment when row or column doesn't change */ - inc2; /* G increment when row or column changes */ - char pos_slope; - - dX = X2 - X1; /* find vector components */ - dY = Y2 - Y1; - pos_slope = (char)(dX > 0); /* is slope positive? */ - if (dY < 0) - pos_slope = (char)!pos_slope; - if (abs (dX) > abs (dY)) /* shallow line case */ - { - if (dX > 0) /* determine start point and last column */ - { - col = X1; - row = Y1; - final = X2; - } - else - { - col = X2; - row = Y2; - final = X1; - } - inc1 = 2 * abs (dY); /* determine increments and initial G */ - G = inc1 - abs (dX); - inc2 = 2 * (abs (dY) - abs (dX)); - if (pos_slope) - while (col <= final) /* step through columns checking for new row */ - { - (*plot) (col, row, color); - col++; - if (G >= 0) /* it's time to change rows */ - { - row++; /* positive slope so increment through the rows */ - G += inc2; - } - else /* stay at the same row */ - G += inc1; - } - else - while (col <= final) /* step through columns checking for new row */ - { - (*plot) (col, row, color); - col++; - if (G > 0) /* it's time to change rows */ - { - row--; /* negative slope so decrement through the rows */ - G += inc2; - } - else /* stay at the same row */ - G += inc1; - } - } /* if |dX| > |dY| */ - else /* steep line case */ - { - if (dY > 0) /* determine start point and last row */ - { - col = X1; - row = Y1; - final = Y2; - } - else - { - col = X2; - row = Y2; - final = Y1; - } - inc1 = 2 * abs (dX); /* determine increments and initial G */ - G = inc1 - abs (dY); - inc2 = 2 * (abs (dX) - abs (dY)); - if (pos_slope) - while (row <= final) /* step through rows checking for new column */ - { - (*plot) (col, row, color); - row++; - if (G >= 0) /* it's time to change columns */ - { - col++; /* positive slope so increment through the columns */ - G += inc2; - } - else /* stay at the same column */ - G += inc1; - } - else - while (row <= final) /* step through rows checking for new column */ - { - (*plot) (col, row, color); - row++; - if (G > 0) /* it's time to change columns */ - { - col--; /* negative slope so decrement through the columns */ - G += inc2; - } - else /* stay at the same column */ - G += inc1; - } - } -} /* draw_line */ - -#if 0 -/* use this for continuous colors later */ -void _fastcall plot3dsuperimpose16b(int x,int y,int color) -{ - int tmp; - if (color != 0) /* Keeps index 0 still 0 */ - { - color = colors - color; /* Reverses color order */ - color = color / 4; - if (color == 0) - color = 1; - } - color = 3; - tmp = getcolor(x,y); - - /* map to 4 colors */ - if (g_which_image == 1) /* RED */ - { - if (red_local_left < x && x < red_local_right) - { - putcolor(x,y,color|tmp); - if (Targa_Out) - targa_color(x, y, color|tmp); - } - } - else if (g_which_image == 2) /* BLUE */ - if (blue_local_left < x && x < blue_local_right) - { - color = color <<2; - putcolor(x,y,color|tmp); - if (Targa_Out) - targa_color(x, y, color|tmp); - } -} - -#endif - -void _fastcall plot3dsuperimpose16(int x,int y,int color) -{ - int tmp; - - tmp = getcolor(x,y); - - if (g_which_image == 1) /* RED */ - { - color = PAL_RED; - if (tmp > 0 && tmp != color) - color = PAL_MAGENTA; - if (red_local_left < x && x < red_local_right) - { - putcolor(x,y,color); - if (Targa_Out) - targa_color(x, y, color); - } - } - else if (g_which_image == 2) /* BLUE */ - if (blue_local_left < x && x < blue_local_right) - { - color = PAL_BLUE; - if (tmp > 0 && tmp != color) - color = PAL_MAGENTA; - putcolor(x,y,color); - if (Targa_Out) - targa_color(x, y, color); - } -} - - -void _fastcall plot3dsuperimpose256(int x,int y,int color) -{ - int tmp; - BYTE t_c; - - t_c = (BYTE)(255-color); - - if (color != 0) /* Keeps index 0 still 0 */ - { - color = colors - color; /* Reverses color order */ - if (max_colors == 236) - color = 1 + color / 21; /* Maps colors 1-255 to 13 even ranges */ - else - color = 1 + color / 18; /* Maps colors 1-255 to 15 even ranges */ - } - - tmp = getcolor(x,y); - /* map to 16 colors */ - if (g_which_image == 1) /* RED */ - { - if (red_local_left < x && x < red_local_right) - { - /* Overwrite prev Red don't mess w/blue */ - putcolor(x,y,color|(tmp&240)); - if (Targa_Out) { - if (!ILLUMINE) - targa_color(x, y, color|(tmp&240)); - else - targa_writedisk (x+sxoffs, y+syoffs, t_c, 0, 0); - } - } - } - else if (g_which_image == 2) /* BLUE */ - if (blue_local_left < x && x < blue_local_right) - { - /* Overwrite previous blue, don't mess with existing red */ - color = color <<4; - putcolor(x,y,color|(tmp&15)); - if (Targa_Out) { - if (!ILLUMINE) - targa_color(x, y, color|(tmp&15)); - else - { - targa_readdisk (x+sxoffs, y+syoffs, &T_RED, (BYTE *)&tmp, (BYTE *)&tmp); - targa_writedisk (x+sxoffs, y+syoffs, T_RED, 0, t_c); - } - } - } -} - -void _fastcall plotIFS3dsuperimpose256(int x,int y,int color) -{ - int tmp; - BYTE t_c; - - t_c = (BYTE)(255-color); - - if (color != 0) /* Keeps index 0 still 0 */ - { - /* my mind is fried - lower indices = darker colors is EASIER! */ - color = colors - color; /* Reverses color order */ - if (max_colors == 236) - color = 1 + color / 21; /* Maps colors 1-255 to 13 even ranges */ - else - color = 1 + color / 18; /* Looks weird but maps colors 1-255 to 15 - relatively even ranges */ - } - - tmp = getcolor(x,y); - /* map to 16 colors */ - if (g_which_image == 1) /* RED */ - { - if (red_local_left < x && x < red_local_right) - { - putcolor(x,y,color|tmp); - if (Targa_Out) { - if (!ILLUMINE) - targa_color(x, y, color|tmp); - else - targa_writedisk (x+sxoffs, y+syoffs, t_c, 0, 0); - } - } - } - else if (g_which_image == 2) /* BLUE */ - if (blue_local_left < x && x < blue_local_right) - { - color = color <<4; - putcolor(x,y,color|tmp); - if (Targa_Out) { - if (!ILLUMINE) - targa_color(x, y, color|tmp); - else - { - targa_readdisk (x+sxoffs, y+syoffs, &T_RED, (BYTE *)&tmp, (BYTE *)&tmp); - targa_writedisk (x+sxoffs, y+syoffs, T_RED, 0, t_c); - } - } - } -} - -void _fastcall plot3dalternate(int x,int y,int color) -{ - BYTE t_c; - - t_c = (BYTE)(255-color); - /* lorez high color red/blue 3D plot function */ - /* if which image = 1, compresses color to lower 128 colors */ - - /* my mind is STILL fried - lower indices = darker colors is EASIER! */ - color = colors - color; - if ((g_which_image == 1) && !((x+y)&1)) /* - lower half palette */ - { - if (red_local_left < x && x < red_local_right) - { - putcolor(x,y,color>>1); - if (Targa_Out) { - if (!ILLUMINE) - targa_color(x, y, color>>1); - else - targa_writedisk (x+sxoffs, y+syoffs, t_c, 0, 0); - } - } - } - else if ((g_which_image == 2) && ((x+y)&1) ) /* - upper half palette */ - { - if (blue_local_left < x && x < blue_local_right) - { - putcolor(x,y,(color>>1)+(colors>>1)); - if (Targa_Out) { - if (!ILLUMINE) - targa_color(x, y, (color>>1)+(colors>>1)); - else - targa_writedisk (x+sxoffs, y+syoffs, T_RED, 0, t_c); - } - } - } -} - -void _fastcall plot3dcrosseyedA(int x,int y,int color) -{ - x /= 2; - y /= 2; - if (g_which_image == 2) - x += xdots/2; - if (g_row_count >= ydots/2) - /* hidden surface kludge */ - if (getcolor(x,y) != 0) - return; - putcolor(x,y,color); -} - -void _fastcall plot3dcrosseyedB(int x,int y,int color) -{ - x /= 2; - y /= 2; - if (g_which_image == 2) - x += xdots/2; - putcolor(x,y,color); -} - -void _fastcall plot3dcrosseyedC(int x,int y,int color) -{ - if (g_row_count >= ydots/2) - /* hidden surface kludge */ - if (getcolor(x,y) != 0) - return; - putcolor(x,y,color); -} - -void plot_setup() -{ - double d_red_bright = 0; - double d_blue_bright = 0; - int i; - - /* set funny glasses plot function */ - switch (g_glasses_type) - { - case 1: - standardplot = plot3dalternate; - break; - - case 2: - if (colors == 256) - if (fractype != IFS3D) - standardplot = plot3dsuperimpose256; - else - standardplot = plotIFS3dsuperimpose256; - else - standardplot = plot3dsuperimpose16; - break; - - case 4: /* crosseyed mode */ - if (sxdots < 2*xdots) - { - if (XROT == 0 && YROT == 0) - standardplot = plot3dcrosseyedA; /* use hidden surface kludge */ - else - standardplot = plot3dcrosseyedB; - } - else if (XROT == 0 && YROT == 0) - standardplot = plot3dcrosseyedC; /* use hidden surface kludge */ - else - standardplot = putcolor; - break; - - default: - standardplot = putcolor; - break; - } - - xshift1 = xshift = (int)((XSHIFT * (double)xdots)/100); - yshift1 = yshift = (int)((YSHIFT * (double)ydots)/100); - - if (g_glasses_type) - { - red_local_left = (int)((red_crop_left * (double)xdots)/100.0); - red_local_right = (int)(((100 - red_crop_right) * (double)xdots)/100.0); - blue_local_left = (int)((blue_crop_left * (double)xdots)/100.0); - blue_local_right = (int)(((100 - blue_crop_right) * (double)xdots)/100.0); - d_red_bright = (double)red_bright/100.0; - d_blue_bright = (double)blue_bright/100.0; - - switch (g_which_image) - { - case 1: - xshift += (int)((g_eye_separation* (double)xdots)/200); - xxadjust = (int)(((xtrans+xadjust)* (double)xdots)/100); - xshift1 -= (int)((g_eye_separation* (double)xdots)/200); - xxadjust1 = (int)(((xtrans-xadjust)* (double)xdots)/100); - if (g_glasses_type == 4 && sxdots >= 2*xdots) - sxoffs = sxdots / 2 - xdots; - break; - - case 2: - xshift -= (int)((g_eye_separation* (double)xdots)/200); - xxadjust = (int)(((xtrans-xadjust)* (double)xdots)/100); - if (g_glasses_type == 4 && sxdots >= 2*xdots) - sxoffs = sxdots / 2; - break; - } - } - else - xxadjust = (int)((xtrans* (double)xdots)/100); - yyadjust = (int)(-(ytrans* (double)ydots)/100); - - if (mapset) - { - ValidateLuts(MAP_name); /* read the palette file */ - if (g_glasses_type==1 || g_glasses_type==2) - { - if (g_glasses_type == 2 && colors < 256) - { - g_dac_box[PAL_RED ][0] = 63; - g_dac_box[PAL_RED ][1] = 0; - g_dac_box[PAL_RED ][2] = 0; - - g_dac_box[PAL_BLUE ][0] = 0; - g_dac_box[PAL_BLUE ][1] = 0; - g_dac_box[PAL_BLUE ][2] = 63; - - g_dac_box[PAL_MAGENTA][0] = 63; - g_dac_box[PAL_MAGENTA][1] = 0; - g_dac_box[PAL_MAGENTA][2] = 63; - } - for (i=0;i<256;i++) - { - g_dac_box[i][0] = (BYTE)(g_dac_box[i][0] * d_red_bright); - g_dac_box[i][2] = (BYTE)(g_dac_box[i][2] * d_blue_bright); - } - } - spindac(0,1); /* load it, but don't spin */ - } -} - diff --git a/fractint/common/prompts1.c b/fractint/common/prompts1.c deleted file mode 100644 index 6176d4bae..000000000 --- a/fractint/common/prompts1.c +++ /dev/null @@ -1,3018 +0,0 @@ -/* - Various routines that prompt for things. -*/ - -#include -#include -#ifdef XFRACT -#ifndef __386BSD__ -#include -#include -#endif -#endif -#if !defined(__386BSD__) -#if !defined(_WIN32) -#include -#endif -#endif - - /* see Fractint.c for a description of the "include" hierarchy */ -#include "port.h" -#include "prototyp.h" -#include "fractype.h" -#include "helpdefs.h" - -#ifdef __hpux -#include -#define getwd(a) getcwd(a,MAXPATHLEN) -#endif - -#ifdef __SVR4 -#include -#define getwd(a) getcwd(a,MAXPATHLEN) -#endif -#include "drivers.h" - -/* Routines used in prompts2.c */ - - int prompt_checkkey(int curkey); - int prompt_checkkey_scroll(int curkey); - long get_file_entry(int,char *,char *,char *,char *); - -/* Routines in this module */ - -int prompt_valuestring(char *buf,struct fullscreenvalues *val); -static int input_field_list(int attr,char *fld,int vlen,char **list,int llen, - int row,int col,int (*checkkey)(int)); -static int select_fracttype(int t); -static int sel_fractype_help(int curkey, int choice); - int select_type_params(int newfractype,int oldfractype); - void set_default_parms(void); -static long gfe_choose_entry(int,char *,char *,char *); -static int check_gfe_key(int curkey,int choice); -static void load_entry_text(FILE *entfile,char *buf,int maxlines, int startrow, int startcol); -static void format_parmfile_line(int,char *); -static int get_light_params(void ); -static int check_mapfile(void ); -static int get_funny_glasses_params(void ); - -#define GETFORMULA 0 -#define GETLSYS 1 -#define GETIFS 2 -#define GETPARM 3 - -static char funnyglasses_map_name[16]; -char ifsmask[13] = {"*.ifs"}; -char formmask[13] = {"*.frm"}; -char lsysmask[13] = {"*.l"}; -char Glasses1Map[] = "glasses1.map"; -char MAP_name[FILE_MAX_DIR] = ""; -int mapset = 0; -int julibrot; /* flag for julibrot */ - -/* --------------------------------------------------------------------- */ - -int promptfkeys; - - /* These need to be global because F6 exits fullscreen_prompt() */ -int scroll_row_status; /* will be set to first line of extra info to - be displayed ( 0 = top line) */ -int scroll_column_status; /* will be set to first column of extra info to - be displayed ( 0 = leftmost column )*/ - -int fullscreen_prompt( /* full-screen prompting routine */ - char *hdg, /* heading, lines separated by \n */ - int numprompts, /* there are this many prompts (max) */ - char **prompts, /* array of prompting pointers */ - struct fullscreenvalues *values, /* array of values */ - int fkeymask, /* bit n on if Fn to cause return */ - char *extrainfo /* extra info box to display, \n separated */ - ) -{ - char *hdgscan; - int titlelines,titlewidth,titlerow; - int maxpromptwidth,maxfldwidth,maxcomment; - int boxrow,boxlines; - int boxcol,boxwidth; - int extralines,extrawidth,extrarow; - int instrrow; - int promptrow,promptcol,valuecol; - int curchoice = 0; - int done, i, j; - int anyinput; - int savelookatmouse; - int curtype, curlen; - char buf[81]; - - /* scrolling related variables */ - FILE * scroll_file = NULL; /* file with extrainfo entry to scroll */ - long scroll_file_start = 0; /* where entry starts in scroll_file */ - int in_scrolling_mode = 0; /* will be 1 if need to scroll extrainfo */ - int lines_in_entry = 0; /* total lines in entry to be scrolled */ - int vertical_scroll_limit = 0; /* don't scroll down if this is top line */ - int widest_entry_line = 0; /* length of longest line in entry */ - int rewrite_extrainfo = 0; /* if 1: rewrite extrainfo to text box */ - char blanks[78]; /* used to clear text box */ - - savelookatmouse = lookatmouse; - lookatmouse = 0; - promptfkeys = fkeymask; - memset(blanks,' ',77); /* initialize string of blanks */ - blanks[77] = (char) 0; - - /* If applicable, open file for scrolling extrainfo. The function - find_file_item() opens the file and sets the file pointer to the - beginning of the entry. - */ - if (extrainfo && *extrainfo) - { - if (fractype == FORMULA || fractype == FFORMULA) { - find_file_item(FormFileName, FormName, &scroll_file, 1); - in_scrolling_mode = 1; - scroll_file_start = ftell(scroll_file); - } - else if (fractype == LSYSTEM) { - find_file_item(LFileName, LName, &scroll_file, 2); - in_scrolling_mode = 1; - scroll_file_start = ftell(scroll_file); - } - else if (fractype == IFS || fractype == IFS3D) { - find_file_item(IFSFileName, IFSName, &scroll_file, 3); - in_scrolling_mode = 1; - scroll_file_start = ftell(scroll_file); - } - } - - /* initialize widest_entry_line and lines_in_entry */ - if (in_scrolling_mode && scroll_file != NULL) { - int comment = 0; - int c = 0; - int widthct = 0; - while ((c = fgetc(scroll_file)) != EOF && c != '\032') { - if (c == ';') - comment = 1; - else if (c == '\n') { - comment = 0; - lines_in_entry++; - widthct = -1; - } - else if (c == '\t') - widthct += 7 - widthct % 8; - else if ( c == '\r') - continue; - if (++widthct > widest_entry_line) - widest_entry_line = widthct; - if (c == '}' && !comment) { - lines_in_entry++; - break; - } - } - if (c == EOF || c == '\032') { /* should never happen */ - fclose(scroll_file); - in_scrolling_mode = 0; - } - } - - - - helptitle(); /* clear screen, display title line */ - driver_set_attr(1,0,C_PROMPT_BKGRD,24*80); /* init rest of screen to background */ - - - hdgscan = hdg; /* count title lines, find widest */ - i = titlewidth = 0; - titlelines = 1; - while (*hdgscan) { - if (*(hdgscan++) == '\n') { - ++titlelines; - i = -1; - } - if (++i > titlewidth) - titlewidth = i; - } - extralines = extrawidth = i = 0; - if ((hdgscan = extrainfo) != 0) { - if (*hdgscan == 0) - extrainfo = NULL; - else { /* count extra lines, find widest */ - extralines = 3; - while (*hdgscan) { - if (*(hdgscan++) == '\n') { - if (extralines + numprompts + titlelines >= 20) { - *hdgscan = 0; /* full screen, cut off here */ - break; - } - ++extralines; - i = -1; - } - if (++i > extrawidth) - extrawidth = i; - } - } - } - - /* if entry fits in available space, shut off scrolling */ - if (in_scrolling_mode && scroll_row_status == 0 - && lines_in_entry == extralines - 2 - && scroll_column_status == 0 - && strchr(extrainfo, '\021') == NULL) { - in_scrolling_mode = 0; - fclose(scroll_file); - scroll_file = NULL; - } - - /*initialize vertical scroll limit. When the top line of the text - box is the vertical scroll limit, the bottom line is the end of the - entry, and no further down scrolling is necessary. - */ - if (in_scrolling_mode) - vertical_scroll_limit = lines_in_entry - (extralines - 2); - - /* work out vertical positioning */ - i = numprompts + titlelines + extralines + 3; /* total rows required */ - j = (25 - i) / 2; /* top row of it all when centered */ - j -= j / 4; /* higher is better if lots extra */ - boxlines = numprompts; - titlerow = 1 + j; - promptrow = boxrow = titlerow + titlelines; - if (titlerow > 2) { /* room for blank between title & box? */ - --titlerow; - --boxrow; - ++boxlines; - } - instrrow = boxrow+boxlines; - if (instrrow + 3 + extralines < 25) { - ++boxlines; /* blank at bottom of box */ - ++instrrow; - if (instrrow + 3 + extralines < 25) - ++instrrow; /* blank before instructions */ - } - extrarow = instrrow + 2; - if (numprompts > 1) /* 3 instructions lines */ - ++extrarow; - if (extrarow + extralines < 25) - ++extrarow; - - if (in_scrolling_mode) /* set box to max width if in scrolling mode */ - extrawidth = 76; - - /* work out horizontal positioning */ - maxfldwidth = maxpromptwidth = maxcomment = anyinput = 0; - for (i = 0; i < numprompts; i++) { - if (values[i].type == 'y') { - static char *noyes[2] = {"no", "yes"}; - values[i].type = 'l'; - values[i].uval.ch.vlen = 3; - values[i].uval.ch.list = noyes; - values[i].uval.ch.llen = 2; - } - j = (int) strlen(prompts[i]); - if (values[i].type == '*') { - if (j > maxcomment) maxcomment = j; - } - else { - anyinput = 1; - if (j > maxpromptwidth) maxpromptwidth = j; - j = prompt_valuestring(buf,&values[i]); - if (j > maxfldwidth) maxfldwidth = j; - } - } - boxwidth = maxpromptwidth + maxfldwidth + 2; - if (maxcomment > boxwidth) boxwidth = maxcomment; - if ((boxwidth += 4) > 80) boxwidth = 80; - boxcol = (80 - boxwidth) / 2; /* center the box */ - promptcol = boxcol + 2; - valuecol = boxcol + boxwidth - maxfldwidth - 2; - if (boxwidth <= 76) { /* make margin a bit wider if we can */ - boxwidth += 2; - --boxcol; - } - if ((j = titlewidth) < extrawidth) - j = extrawidth; - if ((i = j + 4 - boxwidth) > 0) { /* expand box for title/extra */ - if (boxwidth + i > 80) - i = 80 - boxwidth; - boxwidth += i; - boxcol -= i / 2; - } - i = (90 - boxwidth) / 20; - boxcol -= i; - promptcol -= i; - valuecol -= i; - - /* display box heading */ - for (i = titlerow; i < boxrow; ++i) - driver_set_attr(i,boxcol,C_PROMPT_HI,boxwidth); - - { - char buffer[256], *hdgline = buffer; - /* center each line of heading independently */ - int i; - strcpy(hdgline, hdg); - for (i=0; i 0) ? "Press ENTER to exit, ESC to back out, "FK_F1" for help" : "Press ENTER to exit"); - driver_hide_text_cursor(); - g_text_cbase = 2; - while (1) { - if (rewrite_extrainfo) { - rewrite_extrainfo = 0; - fseek(scroll_file, scroll_file_start, SEEK_SET); - load_entry_text(scroll_file, extrainfo, extralines - 2, - scroll_row_status, scroll_column_status); - for (i=1; i <= extralines - 2; i++) - driver_put_string(extrarow+i,0,C_PROMPT_TEXT,blanks); - driver_put_string(extrarow+1,0,C_PROMPT_TEXT,extrainfo); - } - /* TODO: rework key interaction to blocking wait */ - while (!driver_key_pressed()) { } - done = driver_get_key(); - switch (done) { - case FIK_ESC: - done = -1; - case FIK_ENTER: - case FIK_ENTER_2: - goto fullscreen_exit; - case FIK_CTL_DOWN_ARROW: /* scrolling key - down one row */ - if (in_scrolling_mode && scroll_row_status < vertical_scroll_limit) { - scroll_row_status++; - rewrite_extrainfo = 1; - } - break; - case FIK_CTL_UP_ARROW: /* scrolling key - up one row */ - if (in_scrolling_mode && scroll_row_status > 0) { - scroll_row_status--; - rewrite_extrainfo = 1; - } - break; - case FIK_CTL_LEFT_ARROW: /* scrolling key - left one column */ - if (in_scrolling_mode && scroll_column_status > 0) { - scroll_column_status--; - rewrite_extrainfo = 1; - } - break; - case FIK_CTL_RIGHT_ARROW: /* scrolling key - right one column */ - if (in_scrolling_mode && strchr(extrainfo, '\021') != NULL) { - scroll_column_status++; - rewrite_extrainfo = 1; - } - break; - case FIK_CTL_PAGE_DOWN: /* scrolling key - down one screen */ - if (in_scrolling_mode && scroll_row_status < vertical_scroll_limit) { - scroll_row_status += extralines - 2; - if (scroll_row_status > vertical_scroll_limit) - scroll_row_status = vertical_scroll_limit; - rewrite_extrainfo = 1; - } - break; - case FIK_CTL_PAGE_UP: /* scrolling key - up one screen */ - if (in_scrolling_mode && scroll_row_status > 0) { - scroll_row_status -= extralines - 2; - if (scroll_row_status < 0) - scroll_row_status = 0; - rewrite_extrainfo = 1; - } - break; - case FIK_CTL_END: /* scrolling key - to end of entry */ - if (in_scrolling_mode) { - scroll_row_status = vertical_scroll_limit; - scroll_column_status = 0; - rewrite_extrainfo = 1; - } - break; - case FIK_CTL_HOME: /* scrolling key - to beginning of entry */ - if (in_scrolling_mode) { - scroll_row_status = scroll_column_status = 0; - rewrite_extrainfo = 1; - } - break; - case FIK_F2: - case FIK_F3: - case FIK_F4: - case FIK_F5: - case FIK_F6: - case FIK_F7: - case FIK_F8: - case FIK_F9: - case FIK_F10: - if (promptfkeys & (1<<(done+1-FIK_F1)) ) - goto fullscreen_exit; - } - } - } - - - /* display footing */ - if (numprompts > 1) - putstringcenter(instrrow++,0,80,C_PROMPT_BKGRD, - "Use " UPARR1 " and " DNARR1 " to select values to change"); - putstringcenter(instrrow+1,0,80,C_PROMPT_BKGRD, - (helpmode > 0) ? "Press ENTER when finished, ESCAPE to back out, or "FK_F1" for help" : "Press ENTER when finished (or ESCAPE to back out)"); - - done = 0; - while (values[curchoice].type == '*') ++curchoice; - - while (!done) { - if (rewrite_extrainfo) { - j = g_text_cbase; - g_text_cbase = 2; - fseek(scroll_file, scroll_file_start, SEEK_SET); - load_entry_text(scroll_file, extrainfo, extralines - 2, - scroll_row_status, scroll_column_status); - for (i=1; i <= extralines - 2; i++) - driver_put_string(extrarow+i,0,C_PROMPT_TEXT,blanks); - driver_put_string(extrarow+1,0,C_PROMPT_TEXT,extrainfo); - g_text_cbase = j; - } - - curtype = values[curchoice].type; - curlen = prompt_valuestring(buf,&values[curchoice]); - if (!rewrite_extrainfo) - putstringcenter(instrrow,0,80,C_PROMPT_BKGRD, - (curtype == 'l') ? "Use " LTARR1 " or " RTARR1 " to change value of selected field" : "Type in replacement value for selected field"); - else - rewrite_extrainfo = 0; - driver_put_string(promptrow+curchoice,promptcol,C_PROMPT_HI,prompts[curchoice]); - - if (curtype == 'l') { - i = input_field_list( - C_PROMPT_CHOOSE, buf, curlen, - values[curchoice].uval.ch.list, values[curchoice].uval.ch.llen, - promptrow+curchoice,valuecol, in_scrolling_mode ? prompt_checkkey_scroll : prompt_checkkey); - for (j = 0; j < values[curchoice].uval.ch.llen; ++j) - if (strcmp(buf,values[curchoice].uval.ch.list[j]) == 0) break; - values[curchoice].uval.ch.val = j; - } - else { - j = 0; - if (curtype == 'i') j = INPUTFIELD_NUMERIC | INPUTFIELD_INTEGER; - if (curtype == 'L') j = INPUTFIELD_NUMERIC | INPUTFIELD_INTEGER; - if (curtype == 'd') j = INPUTFIELD_NUMERIC | INPUTFIELD_DOUBLE; - if (curtype == 'D') j = INPUTFIELD_NUMERIC | INPUTFIELD_DOUBLE | INPUTFIELD_INTEGER; - if (curtype == 'f') j = INPUTFIELD_NUMERIC; - i = input_field(j, C_PROMPT_INPUT, buf, curlen, - promptrow+curchoice,valuecol, in_scrolling_mode ? prompt_checkkey_scroll : prompt_checkkey); - switch (values[curchoice].type) { - case 'd': - case 'D': - values[curchoice].uval.dval = atof(buf); - break; - case 'f': - values[curchoice].uval.dval = atof(buf); - roundfloatd(&values[curchoice].uval.dval); - break; - case 'i': - values[curchoice].uval.ival = atoi(buf); - break; - case 'L': - values[curchoice].uval.Lval = atol(buf); - break; - case 's': - strncpy(values[curchoice].uval.sval,buf,16); - break; - default: /* assume 0x100+n */ - strcpy(values[curchoice].uval.sbuf,buf); - } - } - - driver_put_string(promptrow+curchoice,promptcol,C_PROMPT_LO,prompts[curchoice]); - j = (int) strlen(buf); - memset(&buf[j],' ',80-j); buf[curlen] = 0; - driver_put_string(promptrow+curchoice, valuecol, C_PROMPT_LO, buf); - - switch (i) { - case 0: /* enter */ - done = 13; - break; - case -1: /* escape */ - case FIK_F2: - case FIK_F3: - case FIK_F4: - case FIK_F5: - case FIK_F6: - case FIK_F7: - case FIK_F8: - case FIK_F9: - case FIK_F10: - done = i; - break; - case FIK_PAGE_UP: - curchoice = -1; - case FIK_DOWN_ARROW: - do { - if (++curchoice >= numprompts) curchoice = 0; - } while (values[curchoice].type == '*'); - break; - case FIK_PAGE_DOWN: - curchoice = numprompts; - case FIK_UP_ARROW: - do { - if (--curchoice < 0) curchoice = numprompts - 1; - } while (values[curchoice].type == '*'); - break; - case FIK_CTL_DOWN_ARROW: /* scrolling key - down one row */ - if (in_scrolling_mode && scroll_row_status < vertical_scroll_limit) { - scroll_row_status++; - rewrite_extrainfo = 1; - } - break; - case FIK_CTL_UP_ARROW: /* scrolling key - up one row */ - if (in_scrolling_mode && scroll_row_status > 0) { - scroll_row_status--; - rewrite_extrainfo = 1; - } - break; - case FIK_CTL_LEFT_ARROW: /*scrolling key - left one column */ - if (in_scrolling_mode && scroll_column_status > 0) { - scroll_column_status--; - rewrite_extrainfo = 1; - } - break; - case FIK_CTL_RIGHT_ARROW: /* scrolling key - right one column */ - if (in_scrolling_mode && strchr(extrainfo, '\021') != NULL) { - scroll_column_status++; - rewrite_extrainfo = 1; - } - break; - case FIK_CTL_PAGE_DOWN: /* scrolling key - down on screen */ - if (in_scrolling_mode && scroll_row_status < vertical_scroll_limit) { - scroll_row_status += extralines - 2; - if (scroll_row_status > vertical_scroll_limit) - scroll_row_status = vertical_scroll_limit; - rewrite_extrainfo = 1; - } - break; - case FIK_CTL_PAGE_UP: /* scrolling key - up one screen */ - if (in_scrolling_mode && scroll_row_status > 0) { - scroll_row_status -= extralines - 2; - if (scroll_row_status < 0) - scroll_row_status = 0; - rewrite_extrainfo = 1; - } - break; - case FIK_CTL_END: /* scrolling key - go to end of entry */ - if (in_scrolling_mode) { - scroll_row_status = vertical_scroll_limit; - scroll_column_status = 0; - rewrite_extrainfo = 1; - } - break; - case FIK_CTL_HOME: /* scrolling key - go to beginning of entry */ - if (in_scrolling_mode) { - scroll_row_status = scroll_column_status = 0; - rewrite_extrainfo = 1; - } - break; - } - } - -fullscreen_exit: - driver_hide_text_cursor(); - lookatmouse = savelookatmouse; - if (scroll_file) { - fclose(scroll_file); - scroll_file = NULL; - } - return done; -} - -int prompt_valuestring(char *buf,struct fullscreenvalues *val) -{ /* format value into buf, return field width */ - int i,ret; - switch (val->type) { - case 'd': - ret = 20; - i = 16; /* cellular needs 16 (was 15)*/ - while (1) { - sprintf(buf,"%.*g",i,val->uval.dval); - if ((int)strlen(buf) <= ret) break; - --i; - } - break; - case 'D': - if (val->uval.dval<0) { /* We have to round the right way */ - sprintf(buf,"%ld",(long)(val->uval.dval-.5)); - } - else { - sprintf(buf,"%ld",(long)(val->uval.dval+.5)); - } - ret = 20; - break; - case 'f': - sprintf(buf,"%.7g",val->uval.dval); - ret = 14; - break; - case 'i': - sprintf(buf,"%d",val->uval.ival); - ret = 6; - break; - case 'L': - sprintf(buf,"%ld",val->uval.Lval); - ret = 10; - break; - case '*': - *buf = (char)(ret = 0); - break; - case 's': - strncpy(buf,val->uval.sval,16); - buf[15] = 0; - ret = 15; - break; - case 'l': - strcpy(buf,val->uval.ch.list[val->uval.ch.val]); - ret = val->uval.ch.vlen; - break; - default: /* assume 0x100+n */ - strcpy(buf,val->uval.sbuf); - ret = val->type & 0xff; - } - return ret; -} - -int prompt_checkkey(int curkey) -{ - switch (curkey) { - case FIK_PAGE_UP: - case FIK_DOWN_ARROW: - case FIK_PAGE_DOWN: - case FIK_UP_ARROW: - return curkey; - case FIK_F2: - case FIK_F3: - case FIK_F4: - case FIK_F5: - case FIK_F6: - case FIK_F7: - case FIK_F8: - case FIK_F9: - case FIK_F10: - if (promptfkeys & (1<<(curkey+1-FIK_F1)) ) - return curkey; - } - return 0; -} - -int prompt_checkkey_scroll(int curkey) -{ - switch (curkey) { - case FIK_PAGE_UP: - case FIK_DOWN_ARROW: - case FIK_CTL_DOWN_ARROW: - case FIK_PAGE_DOWN: - case FIK_UP_ARROW: - case FIK_CTL_UP_ARROW: - case FIK_CTL_LEFT_ARROW: - case FIK_CTL_RIGHT_ARROW: - case FIK_CTL_PAGE_DOWN: - case FIK_CTL_PAGE_UP: - case FIK_CTL_END: - case FIK_CTL_HOME: - return curkey; - case FIK_F2: - case FIK_F3: - case FIK_F4: - case FIK_F5: - case FIK_F6: - case FIK_F7: - case FIK_F8: - case FIK_F9: - case FIK_F10: - if (promptfkeys & (1<<(curkey+1-FIK_F1)) ) - return curkey; - } - return 0; -} - -static int input_field_list( - int attr, /* display attribute */ - char *fld, /* display form field value */ - int vlen, /* field length */ - char **list, /* list of values */ - int llen, /* number of entries in list */ - int row, /* display row */ - int col, /* display column */ - int (*checkkey)(int) /* routine to check non data keys, or NULL */ - ) -{ - int initval,curval; - char buf[81]; - int curkey; - int i, j; - int ret,savelookatmouse; - savelookatmouse = lookatmouse; - lookatmouse = 0; - for (initval = 0; initval < llen; ++initval) - if (strcmp(fld,list[initval]) == 0) break; - if (initval >= llen) initval = 0; - curval = initval; - ret = -1; - while (1) { - strcpy(buf,list[curval]); - i = (int) strlen(buf); - while (i < vlen) - buf[i++] = ' '; - buf[vlen] = 0; - driver_put_string(row,col,attr,buf); - curkey = driver_key_cursor(row,col); /* get a keystroke */ - switch (curkey) { - case FIK_ENTER: - case FIK_ENTER_2: - ret = 0; - goto inpfldl_end; - case FIK_ESC: - goto inpfldl_end; - case FIK_RIGHT_ARROW: - if (++curval >= llen) - curval = 0; - break; - case FIK_LEFT_ARROW: - if (--curval < 0) - curval = llen - 1; - break; - case FIK_F5: - curval = initval; - break; - default: - if (nonalpha(curkey)) { - if (checkkey && (ret = (*checkkey)(curkey)) != 0) - goto inpfldl_end; - break; /* non alphanum char */ - } - j = curval; - for (i = 0; i < llen; ++i) { - if (++j >= llen) - j = 0; - if ( (*list[j] & 0xdf) == (curkey & 0xdf)) { - curval = j; - break; - } - } - } - } -inpfldl_end: - strcpy(fld,list[curval]); - lookatmouse = savelookatmouse; - return ret; -} - - -/* --------------------------------------------------------------------- */ - -/* MCP 7-7-91, This is static code, but not called anywhere */ -#ifdef DELETE_UNUSED_CODE - -/* compare for sort of type table */ -static int compare(const VOIDPTR i, const VOIDPTR j) -{ - return(strcmp(fractalspecific[(int)*((BYTE*)i)].name, - fractalspecific[(int)*((BYTE*)j)].name)); -} - -/* --------------------------------------------------------------------- */ - -static void clear_line(int row, int start, int stop, int color) /* clear part of a line */ -{ - int col; - for (col=start; col<= stop; col++) - driver_put_string(row,col,color," "); -} - -#endif - -/* --------------------------------------------------------------------- */ - -int get_fracttype() /* prompt for and select fractal type */ -{ - int done,i,oldfractype,t; - done = -1; - oldfractype = fractype; - while (1) { - if ((t = select_fracttype(fractype)) < 0) - break; - i = select_type_params(t, fractype); - if (i == 0) { /* ok, all done */ - done = 0; - break; - } - if (i > 0) /* can't return to prior image anymore */ - done = 1; - } - if (done < 0) - fractype = oldfractype; - curfractalspecific = &fractalspecific[fractype]; - return done; -} - -struct FT_CHOICE { - char name[15]; - int num; - }; -static struct FT_CHOICE **ft_choices; /* for sel_fractype_help subrtn */ - -static int select_fracttype(int t) /* subrtn of get_fracttype, separated */ - /* so that storage gets freed up */ -{ - int oldhelpmode; - int numtypes, done; - int i, j; -#define MAXFTYPES 200 - char tname[40]; - struct FT_CHOICE storage[MAXFTYPES] = { 0 }; - struct FT_CHOICE *choices[MAXFTYPES]; - int attributes[MAXFTYPES]; - - /* steal existing array for "choices" */ - choices[0] = &storage[0]; - attributes[0] = 1; - for (i = 1; i < MAXFTYPES; ++i) { - choices[i] = &storage[i]; - attributes[i] = 1; - } - ft_choices = &choices[0]; - - /* setup context sensitive help */ - oldhelpmode = helpmode; - helpmode = HELPFRACTALS; - if (t == IFS3D) t = IFS; - i = j = -1; - while (fractalspecific[++i].name) { - if (julibrot) - if (!((fractalspecific[i].flags & OKJB) && *fractalspecific[i].name != '*')) - continue; - if (fractalspecific[i].name[0] == '*') - continue; - strcpy(choices[++j]->name,fractalspecific[i].name); - choices[j]->name[14] = 0; /* safety */ - choices[j]->num = i; /* remember where the real item is */ - } - numtypes = j + 1; - shell_sort(&choices, numtypes, sizeof(struct FT_CHOICE *), lccompare); /* sort list */ - j = 0; - for (i = 0; i < numtypes; ++i) /* find starting choice in sorted list */ - if (choices[i]->num == t || choices[i]->num == fractalspecific[t].tofloat) - j = i; - - tname[0] = 0; - done = fullscreen_choice(CHOICE_HELP | CHOICE_INSTRUCTIONS, - julibrot ? "Select Orbit Algorithm for Julibrot" : "Select a Fractal Type", - NULL, "Press "FK_F2" for a description of the highlighted type", numtypes, - (char **)choices,attributes,0,0,0,j,NULL,tname,NULL,sel_fractype_help); - if (done >= 0) { - done = choices[done]->num; - if ((done == FORMULA || done == FFORMULA) && !strcmp(FormFileName, CommandFile)) - strcpy(FormFileName, searchfor.frm); - if (done == LSYSTEM && !strcmp(LFileName, CommandFile)) - strcpy(LFileName, searchfor.lsys); - if ((done == IFS || done == IFS3D) && !strcmp(IFSFileName, CommandFile)) - strcpy(IFSFileName, searchfor.ifs); - } - - - helpmode = oldhelpmode; - return done; -} - -static int sel_fractype_help(int curkey,int choice) -{ - int oldhelpmode; - if (curkey == FIK_F2) { - oldhelpmode = helpmode; - helpmode = fractalspecific[(*(ft_choices+choice))->num].helptext; - help(0); - helpmode = oldhelpmode; - } - return 0; -} - -int select_type_params( /* prompt for new fractal type parameters */ - int newfractype, /* new fractal type */ - int oldfractype /* previous fractal type */ - ) -{ - int ret,oldhelpmode; - - oldhelpmode = helpmode; -sel_type_restart: - ret = 0; - fractype = newfractype; - curfractalspecific = &fractalspecific[fractype]; - - if (fractype == LSYSTEM) { - helpmode = HT_LSYS; - if (get_file_entry(GETLSYS,"L-System",lsysmask,LFileName,LName) < 0) { - ret = 1; - goto sel_type_exit; - } - } - if (fractype == FORMULA || fractype == FFORMULA) { - helpmode = HT_FORMULA; - if (get_file_entry(GETFORMULA,"Formula",formmask,FormFileName,FormName) < 0) { - ret = 1; - goto sel_type_exit; - } - } - if (fractype == IFS || fractype == IFS3D) { - helpmode = HT_IFS; - if (get_file_entry(GETIFS,"IFS",ifsmask,IFSFileName,IFSName) < 0) { - ret = 1; - goto sel_type_exit; - } - } - -/* Added the following to accommodate fn bifurcations. JCO 7/2/92 */ - if (((fractype == BIFURCATION) || (fractype == LBIFURCATION)) && - !((oldfractype == BIFURCATION) || (oldfractype == LBIFURCATION))) - set_trig_array(0, "ident"); - if (((fractype == BIFSTEWART) || (fractype == LBIFSTEWART)) && - !((oldfractype == BIFSTEWART) || (oldfractype == LBIFSTEWART))) - set_trig_array(0, "ident"); - if (((fractype == BIFLAMBDA) || (fractype == LBIFLAMBDA)) && - !((oldfractype == BIFLAMBDA) || (oldfractype == LBIFLAMBDA))) - set_trig_array(0, "ident"); - if (((fractype == BIFEQSINPI) || (fractype == LBIFEQSINPI)) && - !((oldfractype == BIFEQSINPI) || (oldfractype == LBIFEQSINPI))) - set_trig_array(0, "sin"); - if (((fractype == BIFADSINPI) || (fractype == LBIFADSINPI)) && - !((oldfractype == BIFADSINPI) || (oldfractype == LBIFADSINPI))) - set_trig_array(0, "sin"); - - /* - * Next assumes that user going between popcorn and popcornjul - * might not want to change function variables - */ - if (((fractype == FPPOPCORN ) || (fractype == LPOPCORN ) || - (fractype == FPPOPCORNJUL) || (fractype == LPOPCORNJUL)) && - !((oldfractype == FPPOPCORN ) || (oldfractype == LPOPCORN ) || - (oldfractype == FPPOPCORNJUL) || (oldfractype == LPOPCORNJUL))) - set_function_parm_defaults(); - - /* set LATOO function defaults */ - if (fractype == LATOO && oldfractype != LATOO) - { - set_function_parm_defaults(); - } - set_default_parms(); - - if (get_fract_params(0) < 0) - if (fractype == FORMULA || fractype == FFORMULA || - fractype == IFS || fractype == IFS3D || - fractype == LSYSTEM) - goto sel_type_restart; - else - ret = 1; - else { - if (newfractype != oldfractype) { - invert = 0; - inversion[0] = inversion[1] = inversion[2] = 0; - } - } - -sel_type_exit: - helpmode = oldhelpmode; - return ret; - -} - -void set_default_parms() -{ - int i,extra; - xxmin = curfractalspecific->xmin; - xxmax = curfractalspecific->xmax; - yymin = curfractalspecific->ymin; - yymax = curfractalspecific->ymax; - xx3rd = xxmin; - yy3rd = yymin; - - if (viewcrop && finalaspectratio != screenaspect) - aspectratio_crop(screenaspect,finalaspectratio); - for (i = 0; i < 4; i++) { - param[i] = curfractalspecific->paramvalue[i]; - if (fractype != CELLULAR && fractype != FROTH && fractype != FROTHFP && - fractype != ANT) - roundfloatd(¶m[i]); /* don't round cellular, frothybasin or ant */ - } - if ((extra=find_extra_param(fractype)) > -1) - for (i=0; i= MAXFRACTALS) - break; - } - } - return numfractals; -} - -char *juli3Doptions[] = {"monocular","lefteye","righteye","red-blue"}; - -/* JIIM */ -#ifdef RANDOM_RUN -static char JIIMstr1[] = "Breadth first, Depth first, Random Walk, Random Run?"; -char *JIIMmethod[] = {"breadth", "depth", "walk", "run"}; -#else -static char JIIMstr1[] = "Breadth first, Depth first, Random Walk"; -char *JIIMmethod[] = {"breadth", "depth", "walk"}; -#endif -static char JIIMstr2[] = "Left first or Right first?"; -char *JIIMleftright[] = {"left", "right"}; - -/* moved from miscres.c so sizeof structure can be accessed here */ -struct trig_funct_lst trigfn[] = -/* changing the order of these alters meaning of *.fra file */ -/* maximum 6 characters in function names or recheck all related code */ -{ -#if !defined(XFRACT) && !defined(_WIN32) - {"sin", lStkSin, dStkSin, mStkSin }, - {"cosxx", lStkCosXX, dStkCosXX, mStkCosXX }, - {"sinh", lStkSinh, dStkSinh, mStkSinh }, - {"cosh", lStkCosh, dStkCosh, mStkCosh }, - {"exp", lStkExp, dStkExp, mStkExp }, - {"log", lStkLog, dStkLog, mStkLog }, - {"sqr", lStkSqr, dStkSqr, mStkSqr }, - {"recip", lStkRecip, dStkRecip, mStkRecip }, /* from recip on new in v16 */ - {"ident", StkIdent, StkIdent, StkIdent }, - {"cos", lStkCos, dStkCos, mStkCos }, - {"tan", lStkTan, dStkTan, mStkTan }, - {"tanh", lStkTanh, dStkTanh, mStkTanh }, - {"cotan", lStkCoTan, dStkCoTan, mStkCoTan }, - {"cotanh",lStkCoTanh,dStkCoTanh,mStkCoTanh}, - {"flip", lStkFlip, dStkFlip, mStkFlip }, - {"conj", lStkConj, dStkConj, mStkConj }, - {"zero", lStkZero, dStkZero, mStkZero }, - {"asin", lStkASin, dStkASin, mStkASin }, - {"asinh", lStkASinh, dStkASinh, mStkASinh }, - {"acos", lStkACos, dStkACos, mStkACos }, - {"acosh", lStkACosh, dStkACosh, mStkACosh }, - {"atan", lStkATan, dStkATan, mStkATan }, - {"atanh", lStkATanh, dStkATanh, mStkATanh }, - {"cabs", lStkCAbs, dStkCAbs, mStkCAbs }, - {"abs", lStkAbs, dStkAbs, mStkAbs }, - {"sqrt", lStkSqrt, dStkSqrt, mStkSqrt }, - {"floor", lStkFloor, dStkFloor, mStkFloor }, - {"ceil", lStkCeil, dStkCeil, mStkCeil }, - {"trunc", lStkTrunc, dStkTrunc, mStkTrunc }, - {"round", lStkRound, dStkRound, mStkRound }, - {"one", lStkOne, dStkOne, mStkOne }, -#else - {"sin", dStkSin, dStkSin, dStkSin }, - {"cosxx", dStkCosXX, dStkCosXX, dStkCosXX }, - {"sinh", dStkSinh, dStkSinh, dStkSinh }, - {"cosh", dStkCosh, dStkCosh, dStkCosh }, - {"exp", dStkExp, dStkExp, dStkExp }, - {"log", dStkLog, dStkLog, dStkLog }, - {"sqr", dStkSqr, dStkSqr, dStkSqr }, - {"recip", dStkRecip, dStkRecip, dStkRecip }, /* from recip on new in v16 */ - {"ident", StkIdent, StkIdent, StkIdent }, - {"cos", dStkCos, dStkCos, dStkCos }, - {"tan", dStkTan, dStkTan, dStkTan }, - {"tanh", dStkTanh, dStkTanh, dStkTanh }, - {"cotan", dStkCoTan, dStkCoTan, dStkCoTan }, - {"cotanh",dStkCoTanh,dStkCoTanh,dStkCoTanh}, - {"flip", dStkFlip, dStkFlip, dStkFlip }, - {"conj", dStkConj, dStkConj, dStkConj }, - {"zero", dStkZero, dStkZero, dStkZero }, - {"asin", dStkASin, dStkASin, dStkASin }, - {"asinh", dStkASinh, dStkASinh, dStkASinh }, - {"acos", dStkACos, dStkACos, dStkACos }, - {"acosh", dStkACosh, dStkACosh, dStkACosh }, - {"atan", dStkATan, dStkATan, dStkATan }, - {"atanh", dStkATanh, dStkATanh, dStkATanh }, - {"cabs", dStkCAbs, dStkCAbs, dStkCAbs }, - {"abs", dStkAbs, dStkAbs, dStkAbs }, - {"sqrt", dStkSqrt, dStkSqrt, dStkSqrt }, - {"floor", dStkFloor, dStkFloor, dStkFloor }, - {"ceil", dStkCeil, dStkCeil, dStkCeil }, - {"trunc", dStkTrunc, dStkTrunc, dStkTrunc }, - {"round", dStkRound, dStkRound, dStkRound }, - {"one", dStkOne, dStkOne, dStkOne }, -#endif -}; - -#define NUMTRIGFN sizeof(trigfn)/sizeof(struct trig_funct_lst) - -const int numtrigfn = NUMTRIGFN; - -/* --------------------------------------------------------------------- */ -int get_fract_params(int caller) /* prompt for type-specific parms */ -{ - char *v0 = "From cx (real part)"; - char *v1 = "From cy (imaginary part)"; - char *v2 = "To cx (real part)"; - char *v3 = "To cy (imaginary part)"; - char *juliorbitname = NULL; - int i,j,k; - int curtype,numparams,numtrig; - struct fullscreenvalues paramvalues[30]; - char *choices[30]; - long oldbailout = 0L; - int promptnum; - char msg[120]; - char *type_name, *tmpptr; - char bailoutmsg[50]; - int ret = 0; - int oldhelpmode; - char parmprompt[MAXPARAMS][55]; - static char *trg[] = - { - "First Function", "Second Function", "Third Function", "Fourth Function" - }; - char *filename,*entryname; - FILE *entryfile; - char *trignameptr[NUMTRIGFN]; -#ifdef XFRACT - static /* Can't initialize aggregates on the stack */ -#endif - char *bailnameptr[] = {"mod", "real", "imag", "or", "and", "manh", "manr"}; - struct fractalspecificstuff *jborbit = NULL; - struct fractalspecificstuff *savespecific; - int firstparm = 0; - int lastparm = MAXPARAMS; - double oldparam[MAXPARAMS]; - int fkeymask = 0x40; - oldbailout = bailout; - if (fractype==JULIBROT || fractype==JULIBROTFP) - julibrot = 1; - else - julibrot = 0; - curtype = fractype; - if (curfractalspecific->name[0] == '*' - && (i = curfractalspecific->tofloat) != NOFRACTAL /* FIXED BUG HERE!! */ - && fractalspecific[i].name[0] != '*') - curtype = i; - curfractalspecific = &fractalspecific[curtype]; - tstack[0] = 0; - if ((i = curfractalspecific->helpformula) < -1) { - if (i == -2) { /* special for formula */ - filename = FormFileName; - entryname = FormName; - } - else if (i == -3) { /* special for lsystem */ - filename = LFileName; - entryname = LName; - } - else if (i == -4) { /* special for ifs */ - filename = IFSFileName; - entryname = IFSName; - } - else { /* this shouldn't happen */ - filename = NULL; - entryname = NULL; - } - if (find_file_item(filename,entryname,&entryfile, -1-i) == 0) { - load_entry_text(entryfile,tstack,17, 0, 0); - fclose(entryfile); - if (fractype == FORMULA || fractype == FFORMULA) - frm_get_param_stuff(entryname); /* no error check, should be okay, from above */ - } - } - else if (i >= 0) { - int c,lines; - read_help_topic(i,0,2000,tstack); /* need error handling here ?? */ - tstack[2000-i] = 0; - i = j = lines = 0; k = 1; - while ((c = tstack[i++]) != 0) { - /* stop at ctl, blank, or line with col 1 nonblank, max 16 lines */ - if (k && c == ' ' && ++k <= 5) { } /* skip 4 blanks at start of line */ - else { - if (c == '\n') { - if (k) break; /* blank line */ - if (++lines >= 16) break; - k = 1; - } - else if (c < 16) /* a special help format control char */ - break; - else { - if (k == 1) /* line starts in column 1 */ - break; - k = 0; - } - tstack[j++] = (char)c; - } - } - while (--j >= 0 && tstack[j] == '\n') { } - tstack[j+1] = 0; - } -gfp_top: - promptnum = 0; - if (julibrot) - { - i = select_fracttype(neworbittype); - if (i < 0) - { - if (ret == 0) - ret = -1; - julibrot = 0; - goto gfp_exit; - } - else - neworbittype = i; - jborbit = &fractalspecific[neworbittype]; - juliorbitname = jborbit->name; - } - - if (fractype == FORMULA || fractype == FFORMULA) { - if (uses_p1) /* set first parameter */ - firstparm = 0; - else if (uses_p2) - firstparm = 2; - else if (uses_p3) - firstparm = 4; - else if (uses_p4) - firstparm = 6; - else - firstparm = 8; /* uses_p5 or no parameter */ - - if (uses_p5) /* set last parameter */ - lastparm = 10; - else if (uses_p4) - lastparm = 8; - else if (uses_p3) - lastparm = 6; - else if (uses_p2) - lastparm = 4; - else - lastparm = 2; /* uses_p1 or no parameter */ - } - - savespecific = curfractalspecific; - if (julibrot) - { - curfractalspecific = jborbit; - firstparm = 2; /* in most case Julibrot does not need first two parms */ - if (neworbittype == QUATJULFP || /* all parameters needed */ - neworbittype == HYPERCMPLXJFP) - { - firstparm = 0; - lastparm = 4; - } - if (neworbittype == QUATFP || /* no parameters needed */ - neworbittype == HYPERCMPLXFP) - firstparm = 4; - } - numparams = 0; - j = 0; - for (i = firstparm; i < lastparm; i++) - { - char tmpbuf[30]; - if (!typehasparm(julibrot?neworbittype:fractype,i,parmprompt[j])) { - if (curtype == FORMULA || curtype == FFORMULA) - if (paramnotused(i)) - continue; - break; - } - numparams++; - choices[promptnum] = parmprompt[j++]; - paramvalues[promptnum].type = 'd'; - - if (choices[promptnum][0] == '+') - { - choices[promptnum]++; - paramvalues[promptnum].type = 'D'; - } - else if (choices[promptnum][0] == '#') - choices[promptnum]++; - sprintf(tmpbuf,"%.17g",param[i]); - paramvalues[promptnum].uval.dval = atof(tmpbuf); - oldparam[i] = paramvalues[promptnum++].uval.dval; - } - -/* The following is a goofy kludge to make reading in the formula - * parameters work. - */ - if (curtype == FORMULA || curtype == FFORMULA) - numparams = lastparm - firstparm; - - numtrig = (curfractalspecific->flags >> 6) & 7; - if (curtype==FORMULA || curtype==FFORMULA ) { - numtrig = maxfn; - } - - i = NUMTRIGFN; - while (--i >= 0) - trignameptr[i] = trigfn[i].name; - for (i = 0; i < numtrig; i++) { - paramvalues[promptnum].type = 'l'; - paramvalues[promptnum].uval.ch.val = trigndx[i]; - paramvalues[promptnum].uval.ch.llen = NUMTRIGFN; - paramvalues[promptnum].uval.ch.vlen = 6; - paramvalues[promptnum].uval.ch.list = trignameptr; - choices[promptnum++] = (char *)trg[i]; - } - type_name = curfractalspecific->name; - if (*type_name == '*') - ++type_name; - - i = curfractalspecific->orbit_bailout; - - if ( i != 0 && curfractalspecific->calctype == StandardFractal && - (curfractalspecific->flags & BAILTEST) ) { - paramvalues[promptnum].type = 'l'; - paramvalues[promptnum].uval.ch.val = (int)bailoutest; - paramvalues[promptnum].uval.ch.llen = 7; - paramvalues[promptnum].uval.ch.vlen = 6; - paramvalues[promptnum].uval.ch.list = bailnameptr; - choices[promptnum++] = "Bailout Test (mod, real, imag, or, and, manh, manr)"; - } - - if (i) { - if (potparam[0] != 0.0 && potparam[2] != 0.0) - { - paramvalues[promptnum].type = '*'; - choices[promptnum++] = "Bailout: continuous potential (Y screen) value in use"; - } - else - { - choices[promptnum] = "Bailout value (0 means use default)"; - paramvalues[promptnum].type = 'L'; - paramvalues[promptnum++].uval.Lval = (oldbailout = bailout); - paramvalues[promptnum].type = '*'; - tmpptr = type_name; - if (usr_biomorph != -1) - { - i = 100; - tmpptr = "biomorph"; - } - sprintf(bailoutmsg," (%s default is %d)",tmpptr,i); - choices[promptnum++] = bailoutmsg; - } - } - if (julibrot) - { - switch (neworbittype) - { - case QUATFP: - case HYPERCMPLXFP: - v0 = "From cj (3rd dim)"; v1 = "From ck (4th dim)"; v2 = "To cj (3rd dim)"; v3 = "To ck (4th dim)"; - break; - case QUATJULFP: - case HYPERCMPLXJFP: - v0 = "From zj (3rd dim)"; v1 = "From zk (4th dim)"; v2 = "To zj (3rd dim)"; v3 = "To zk (4th dim)"; - break; - default: - v0 = "From cx (real part)"; v1 = "From cy (imaginary part)"; v2 = "To cx (real part)"; v3 = "To cy (imaginary part)"; - break; - } - - curfractalspecific = savespecific; - paramvalues[promptnum].uval.dval = mxmaxfp; - paramvalues[promptnum].type = 'f'; - choices[promptnum++] = v0; - paramvalues[promptnum].uval.dval = mymaxfp; - paramvalues[promptnum].type = 'f'; - choices[promptnum++] = v1; - paramvalues[promptnum].uval.dval = mxminfp; - paramvalues[promptnum].type = 'f'; - choices[promptnum++] = v2; - paramvalues[promptnum].uval.dval = myminfp; - paramvalues[promptnum].type = 'f'; - choices[promptnum++] = v3; - paramvalues[promptnum].uval.ival = zdots; - paramvalues[promptnum].type = 'i'; - choices[promptnum++] = "Number of z pixels"; - - paramvalues[promptnum].type = 'l'; - paramvalues[promptnum].uval.ch.val = juli3Dmode; - paramvalues[promptnum].uval.ch.llen = 4; - paramvalues[promptnum].uval.ch.vlen = 9; - paramvalues[promptnum].uval.ch.list = juli3Doptions; - choices[promptnum++] = "3D Mode"; - - paramvalues[promptnum].uval.dval = eyesfp; - paramvalues[promptnum].type = 'f'; - choices[promptnum++] = "Distance between eyes"; - paramvalues[promptnum].uval.dval = originfp; - paramvalues[promptnum].type = 'f'; - choices[promptnum++] = "Location of z origin"; - paramvalues[promptnum].uval.dval = depthfp; - paramvalues[promptnum].type = 'f'; - choices[promptnum++] = "Depth of z"; - paramvalues[promptnum].uval.dval = heightfp; - paramvalues[promptnum].type = 'f'; - choices[promptnum++] = "Screen height"; - paramvalues[promptnum].uval.dval = widthfp; - paramvalues[promptnum].type = 'f'; - choices[promptnum++] = "Screen width"; - paramvalues[promptnum].uval.dval = distfp; - paramvalues[promptnum].type = 'f'; - choices[promptnum++] = "Distance to Screen"; - } - - if (curtype == INVERSEJULIA || curtype == INVERSEJULIAFP) - { - choices[promptnum] = JIIMstr1; - paramvalues[promptnum].type = 'l'; - paramvalues[promptnum].uval.ch.list = JIIMmethod; - paramvalues[promptnum].uval.ch.vlen = 7; -#ifdef RANDOM_RUN - paramvalues[promptnum].uval.ch.llen = 4; -#else - paramvalues[promptnum].uval.ch.llen = 3; /* disable random run */ -#endif - paramvalues[promptnum++].uval.ch.val = major_method; - - choices[promptnum] = JIIMstr2; - paramvalues[promptnum].type = 'l'; - paramvalues[promptnum].uval.ch.list = JIIMleftright; - paramvalues[promptnum].uval.ch.vlen = 5; - paramvalues[promptnum].uval.ch.llen = 2; - paramvalues[promptnum++].uval.ch.val = minor_method; - } - - if ((curtype==FORMULA || curtype==FFORMULA) && uses_ismand) { - choices[promptnum] = "ismand"; - paramvalues[promptnum].type = 'y'; - paramvalues[promptnum++].uval.ch.val = ismand?1:0; - } - - if (caller /* command ? */ -/* && (display3d > 0 || promptnum == 0)) */ - && (display3d > 0)) - { - stopmsg(STOPMSG_INFO_ONLY | STOPMSG_NO_BUZZER, "Current type has no type-specific parameters"); - goto gfp_exit; - } - if (julibrot) - sprintf(msg,"Julibrot Parameters (orbit= %s)",juliorbitname); - else - sprintf(msg,"Parameters for fractal type %s",type_name); - if (bf_math == 0) - { - strcat(msg,"\n(Press "FK_F6" for corner parameters)"); - } - else - fkeymask = 0; - scroll_row_status = 0; /* make sure we start at beginning of entry */ - scroll_column_status = 0; - while (1) - { - oldhelpmode = helpmode; - helpmode = curfractalspecific->helptext; - i = fullscreen_prompt(msg,promptnum,choices,paramvalues,fkeymask,tstack); - helpmode = oldhelpmode; - if (i < 0) - { - if (julibrot) - goto gfp_top; - if (ret == 0) - ret = -1; - goto gfp_exit; - } - if (i != FIK_F6) - break; - if (bf_math == 0) - if (get_corners() > 0) - ret = 1; - } - promptnum = 0; - for ( i = firstparm; i < numparams+firstparm; i++) - { - if (curtype == FORMULA || curtype == FFORMULA) - if (paramnotused(i)) - continue; - if (oldparam[i] != paramvalues[promptnum].uval.dval) - { - param[i] = paramvalues[promptnum].uval.dval; - ret = 1; - } - ++promptnum; - } - - for ( i = 0; i < numtrig; i++) - { - if (paramvalues[promptnum].uval.ch.val != (int)trigndx[i]) - { - set_trig_array(i,trigfn[paramvalues[promptnum].uval.ch.val].name); - ret = 1; - } - ++promptnum; - } - - if (julibrot) - { - savespecific = curfractalspecific; - curfractalspecific = jborbit; - } - - i = curfractalspecific->orbit_bailout; - - if ( i != 0 && curfractalspecific->calctype == StandardFractal && - (curfractalspecific->flags & BAILTEST) ) { - if (paramvalues[promptnum].uval.ch.val != (int)bailoutest) { - bailoutest = (enum bailouts)paramvalues[promptnum].uval.ch.val; - ret = 1; - } - promptnum++; - } - else - bailoutest = Mod; - setbailoutformula(bailoutest); - - if (i) { - if (potparam[0] != 0.0 && potparam[2] != 0.0) - promptnum++; - else - { - bailout = paramvalues[promptnum++].uval.Lval; - if (bailout != 0 && (bailout < 1 || bailout > 2100000000L)) - bailout = oldbailout; - if (bailout != oldbailout) - ret = 1; - promptnum++; - } - } - if (julibrot) - { - mxmaxfp = paramvalues[promptnum++].uval.dval; - mymaxfp = paramvalues[promptnum++].uval.dval; - mxminfp = paramvalues[promptnum++].uval.dval; - myminfp = paramvalues[promptnum++].uval.dval; - zdots = paramvalues[promptnum++].uval.ival; - juli3Dmode = paramvalues[promptnum++].uval.ch.val; - eyesfp = (float)paramvalues[promptnum++].uval.dval; - originfp = (float)paramvalues[promptnum++].uval.dval; - depthfp = (float)paramvalues[promptnum++].uval.dval; - heightfp = (float)paramvalues[promptnum++].uval.dval; - widthfp = (float)paramvalues[promptnum++].uval.dval; - distfp = (float)paramvalues[promptnum++].uval.dval; - ret = 1; /* force new calc since not resumable anyway */ - } - if (curtype == INVERSEJULIA || curtype == INVERSEJULIAFP) - { - if (paramvalues[promptnum].uval.ch.val != major_method || - paramvalues[promptnum+1].uval.ch.val != minor_method) - ret = 1; - major_method = (enum Major)paramvalues[promptnum++].uval.ch.val; - minor_method = (enum Minor)paramvalues[promptnum++].uval.ch.val; - } - if ((curtype==FORMULA || curtype==FFORMULA) && uses_ismand) - { - if (ismand != (short int)paramvalues[promptnum].uval.ch.val) - { - ismand = (short int)paramvalues[promptnum].uval.ch.val; - ret = 1; - } - ++promptnum; - } -gfp_exit: - curfractalspecific = &fractalspecific[fractype]; - return ret; -} - -int find_extra_param(int type) -{ - int i,ret,curtyp; - ret = -1; - i= -1; - - if (fractalspecific[type].flags&MORE) - { - while ((curtyp=moreparams[++i].type) != type && curtyp != -1); - if (curtyp == type) - ret = i; - } - return ret; -} - -void load_params(int fractype) -{ - int i, extra; - for (i = 0; i < 4; ++i) - { - param[i] = fractalspecific[fractype].paramvalue[i]; - if (fractype != CELLULAR && fractype != ANT) - roundfloatd(¶m[i]); /* don't round cellular or ant */ - } - if ((extra=find_extra_param(fractype)) > -1) - for (i=0; i= MAXENTRIES) - { - sprintf(buf, "Too many entries in file, first %ld used", MAXENTRIES); - stopmsg(0, buf); - break; - } - } - } - } - else if (c == EOF || c == '\032') - break; - } - return numentries; -} - -/* subrtn of get_file_entry, separated so that storage gets freed up */ -static long gfe_choose_entry(int type, char *title, char *filename, char *entryname) -{ -#ifdef XFRACT - char *o_instr = "Press "FK_F6" to select file, "FK_F2" for details, "FK_F4" to toggle sort "; - /* keep the above line length < 80 characters */ -#else - char *o_instr = "Press "FK_F6" to select different file, "FK_F2" for details, "FK_F4" to toggle sort "; -#endif - int numentries, i; - char buf[101]; - struct entryinfo storage[MAXENTRIES + 1]; - struct entryinfo *choices[MAXENTRIES + 1] = { NULL }; - int attributes[MAXENTRIES + 1] = { 0 }; - void (*formatitem)(int, char *); - int boxwidth, boxdepth, colwidth; - char instr[80]; - - static int dosort = 1; - - gfe_choices = &choices[0]; - gfe_title = title; - -retry: - for (i = 0; i < MAXENTRIES+1; i++) - { - choices[i] = &storage[i]; - attributes[i] = 1; - } - - numentries = 0; - helptitle(); /* to display a clue when file big and next is slow */ - - numentries = scan_entries(gfe_file, &storage[0], NULL); - if (numentries == 0) - { - stopmsg(0, "File doesn't contain any valid entries"); - fclose(gfe_file); - return -2; /* back to file list */ - } - strcpy(instr, o_instr); - if (dosort) - { - strcat(instr, "off"); - shell_sort((char *) &choices, numentries, sizeof(struct entryinfo *), lccompare); - } - else - { - strcat(instr, "on"); - } - - strcpy(buf, entryname); /* preset to last choice made */ - sprintf(temp1, "%s Selection\nFile: %s", title, filename); - formatitem = NULL; - boxwidth = colwidth = boxdepth = 0; - if (type == GETPARM) - { - formatitem = format_parmfile_line; - boxwidth = 1; - boxdepth = 16; - colwidth = 76; - } - - i = fullscreen_choice(CHOICE_INSTRUCTIONS | (dosort ? 0 : CHOICE_NOT_SORTED), - temp1, NULL, instr, numentries, (char **) choices, - attributes, boxwidth, boxdepth, colwidth, 0, - formatitem, buf, NULL, check_gfe_key); - if (i == -FIK_F4) - { - rewind(gfe_file); - dosort = 1-dosort; - goto retry; - } - fclose(gfe_file); - if (i < 0) - { - /* go back to file list or cancel */ - return (i == -FIK_F6) ? -2 : -1; - } - strcpy(entryname, choices[i]->name); - return choices[i]->point; -} - - -static int check_gfe_key(int curkey,int choice) -{ - char infhdg[60]; - char infbuf[25*80]; - int in_scrolling_mode = 0; /* 1 if entry doesn't fit available space */ - int top_line = 0; - int left_column = 0; - int i; - int done = 0; - int rewrite_infbuf = 0; /* if 1: rewrite the entry portion of screen */ - char blanks[79]; /* used to clear the entry portion of screen */ - memset(blanks, ' ', 78); - blanks[78] = (char) 0; - - if (curkey == FIK_F6) - return 0-FIK_F6; - if (curkey == FIK_F4) - return 0-FIK_F4; - if (curkey == FIK_F2) { - int widest_entry_line = 0; - int lines_in_entry = 0; - int comment = 0; - int c = 0; - int widthct = 0; - fseek(gfe_file,gfe_choices[choice]->point,SEEK_SET); - while ((c = fgetc(gfe_file)) != EOF && c != '\032') { - if (c == ';') - comment = 1; - else if (c == '\n') { - comment = 0; - lines_in_entry++; - widthct = -1; - } - else if (c == '\t') - widthct += 7 - widthct % 8; - else if ( c == '\r') - continue; - if (++widthct > widest_entry_line) - widest_entry_line = widthct; - if (c == '}' && !comment) { - lines_in_entry++; - break; - } - } - if (c == EOF || c == '\032') { /* should never happen */ - fseek(gfe_file,gfe_choices[choice]->point,SEEK_SET); - in_scrolling_mode = 0; - } - fseek(gfe_file,gfe_choices[choice]->point,SEEK_SET); - load_entry_text(gfe_file,infbuf, 17, 0, 0); - if (lines_in_entry > 17 || widest_entry_line > 74) - in_scrolling_mode = 1; - strcpy(infhdg,gfe_title); - strcat(infhdg," file entry:\n\n"); - /* ... instead, call help with buffer? heading added */ - driver_stack_screen(); - helptitle(); - driver_set_attr(1,0,C_GENERAL_MED,24*80); - - g_text_cbase = 0; - driver_put_string(2,1,C_GENERAL_HI,infhdg); - g_text_cbase = 2; /* left margin is 2 */ - driver_put_string(4,0,C_GENERAL_MED,infbuf); - - { - driver_put_string(-1,0,C_GENERAL_LO, - "\n\n Use "UPARR1", "DNARR1", "RTARR1", "LTARR1", PgUp, PgDown, Home, and End to scroll text\nAny other key to return to selection list"); - } - - while (!done) { - if (rewrite_infbuf) { - rewrite_infbuf = 0; - fseek(gfe_file,gfe_choices[choice]->point,SEEK_SET); - load_entry_text(gfe_file, infbuf, 17, top_line, left_column); - for (i = 4; i < (lines_in_entry < 17 ? lines_in_entry + 4 : 21); i++) - driver_put_string(i,0,C_GENERAL_MED,blanks); - driver_put_string(4,0,C_GENERAL_MED,infbuf); - } - i = getakeynohelp(); - if (i == FIK_DOWN_ARROW || i == FIK_CTL_DOWN_ARROW - || i == FIK_UP_ARROW || i == FIK_CTL_UP_ARROW - || i == FIK_LEFT_ARROW || i == FIK_CTL_LEFT_ARROW - || i == FIK_RIGHT_ARROW || i == FIK_CTL_RIGHT_ARROW - || i == FIK_HOME || i == FIK_CTL_HOME - || i == FIK_END || i == FIK_CTL_END - || i == FIK_PAGE_UP || i == FIK_CTL_PAGE_UP - || i == FIK_PAGE_DOWN || i == FIK_CTL_PAGE_DOWN) { - switch (i) { - case FIK_DOWN_ARROW: case FIK_CTL_DOWN_ARROW: /* down one line */ - if (in_scrolling_mode && top_line < lines_in_entry - 17) { - top_line++; - rewrite_infbuf = 1; - } - break; - case FIK_UP_ARROW: case FIK_CTL_UP_ARROW: /* up one line */ - if (in_scrolling_mode && top_line > 0) { - top_line--; - rewrite_infbuf = 1; - } - break; - case FIK_LEFT_ARROW: case FIK_CTL_LEFT_ARROW: /* left one column */ - if (in_scrolling_mode && left_column > 0) { - left_column--; - rewrite_infbuf = 1; - } - break; - case FIK_RIGHT_ARROW: case FIK_CTL_RIGHT_ARROW: /* right one column */ - if (in_scrolling_mode && strchr(infbuf, '\021') != NULL) { - left_column++; - rewrite_infbuf = 1; - } - break; - case FIK_PAGE_DOWN: case FIK_CTL_PAGE_DOWN: /* down 17 lines */ - if (in_scrolling_mode && top_line < lines_in_entry - 17) { - top_line += 17; - if (top_line > lines_in_entry - 17) - top_line = lines_in_entry - 17; - rewrite_infbuf = 1; - } - break; - case FIK_PAGE_UP: case FIK_CTL_PAGE_UP: /* up 17 lines */ - if (in_scrolling_mode && top_line > 0) { - top_line -= 17; - if (top_line < 0) - top_line = 0; - rewrite_infbuf = 1; - } - break; - case FIK_END: case FIK_CTL_END: /* to end of entry */ - if (in_scrolling_mode) { - top_line = lines_in_entry - 17; - left_column = 0; - rewrite_infbuf = 1; - } - break; - case FIK_HOME: case FIK_CTL_HOME: /* to beginning of entry */ - if (in_scrolling_mode) { - top_line = left_column = 0; - rewrite_infbuf = 1; - } - break; - default: - break; - } - } - else - done = 1; /* a key other than scrolling key was pressed */ - } - g_text_cbase = 0; - driver_hide_text_cursor(); - driver_unstack_screen(); - } - return 0; -} - -static void load_entry_text( - FILE *entfile, - char *buf, - int maxlines, - int startrow, - int startcol) -{ - /* Revised 12/14/96 by George Martin. Up to maxlines of an entry - is copied to *buf starting from row "startrow", and skipping - characters in each line up to "startcol". The terminating '\n' - is deleted if maxlines is reached before the end of the entry. - */ - - int linelen, i; - int comment=0; - int c = 0; - int tabpos = 7 - (startcol % 8); - - if (maxlines <= 0) { /* no lines to get! */ - *buf = (char) 0; - return; - } - - /*move down to starting row*/ - for (i = 0; i < startrow; i++) { - while ((c=fgetc(entfile)) != '\n' && c != EOF && c != '\032') { - if (c == ';') - comment = 1; - if (c == '}' && !comment) /* end of entry before start line */ - break; /* this should never happen */ - } - if (c == '\n') - comment = 0; - else { /* reached end of file or end of entry */ - *buf = (char) 0; - return; - } - } - - /* write maxlines of entry */ - while (maxlines-- > 0) { - comment = linelen = i = c = 0; - - /* skip line up to startcol */ - while (i++ < startcol && (c = fgetc(entfile)) != EOF && c != '\032') { - if (c == ';') - comment = 1; - if (c == '}' && !comment) { /*reached end of entry*/ - *buf = (char) 0; - return; - } - if ( c == '\r') { - i--; - continue; - } - if (c == '\t') - i += 7 - (i % 8); - if (c == '\n') { /*need to insert '\n', even for short lines*/ - *(buf++) = (char)c; - break; - } - } - if (c == EOF || c == '\032') { /* unexpected end of file */ - *buf = (char) 0; - return; - } - if (c == '\n') /* line is already completed */ - continue; - - if (i > startcol) { /* can happen because of character */ - while (i-- > startcol) { - *(buf++) = ' '; - linelen++; - } - } - - /*process rest of line into buf */ - while ((c = fgetc(entfile)) != EOF && c != '\032') { - if (c == ';') - comment = 1; - else if (c == '\n' || c == '\r') - comment = 0; - if (c != '\r') { - if (c == '\t') { - while ((linelen % 8) != tabpos && linelen < 75) { /* 76 wide max */ - *(buf++) = ' '; - ++linelen; - } - c = ' '; - } - if (c == '\n') { - *(buf++) = '\n'; - break; - } - if (++linelen > 75) { - if (linelen == 76) - *(buf++) = '\021'; - } - else - *(buf++) = (char)c; - if (c == '}' && !comment) { /*reached end of entry*/ - *(buf) = (char) 0; - return; - } - } - } - if (c == EOF || c == '\032') { /* unexpected end of file */ - *buf = (char) 0; - return; - } - } - if (*(buf-1) == '\n') /* specified that buf will not end with a '\n' */ - buf--; - *buf = (char) 0; -} - -static void format_parmfile_line(int choice,char *buf) -{ - int c,i; - char line[80]; - fseek(gfe_file,gfe_choices[choice]->point,SEEK_SET); - while (getc(gfe_file) != '{') { } - do - { - c = getc(gfe_file); - } while (c == ' ' || c == '\t' || c == ';'); - i = 0; - while (i < 56 && c != '\n' && c != '\r' && c != EOF && c != '\032') { - line[i++] = (char)((c == '\t') ? ' ' : c); - c = getc(gfe_file); - } - line[i] = 0; -#ifndef XFRACT - sprintf(buf,"%-20Fs%-56s",gfe_choices[choice]->name,line); -#else - sprintf(buf,"%-20s%-56s",gfe_choices[choice]->name,line); -#endif -} - -/* --------------------------------------------------------------------- */ - -int get_fract3d_params() /* prompt for 3D fractal parameters */ -{ - int i,k,ret,oldhelpmode; - struct fullscreenvalues uvalues[20]; - char *ifs3d_prompts[7] = - { - "X-axis rotation in degrees", - "Y-axis rotation in degrees", - "Z-axis rotation in degrees", - "Perspective distance [1 - 999, 0 for no persp]", - "X shift with perspective (positive = right)", - "Y shift with perspective (positive = up )", - "Stereo (R/B 3D)? (0=no,1=alternate,2=superimpose,3=photo,4=stereo pair)" - }; - - driver_stack_screen(); - k = 0; - uvalues[k].type = 'i'; - uvalues[k++].uval.ival = XROT; - uvalues[k].type = 'i'; - uvalues[k++].uval.ival = YROT; - uvalues[k].type = 'i'; - uvalues[k++].uval.ival = ZROT; - uvalues[k].type = 'i'; - uvalues[k++].uval.ival = ZVIEWER; - uvalues[k].type = 'i'; - uvalues[k++].uval.ival = XSHIFT; - uvalues[k].type = 'i'; - uvalues[k++].uval.ival = YSHIFT; - uvalues[k].type = 'i'; - uvalues[k++].uval.ival = g_glasses_type; - - oldhelpmode = helpmode; - helpmode = HELP3DFRACT; - i = fullscreen_prompt("3D Parameters",k,ifs3d_prompts,uvalues,0,NULL); - helpmode = oldhelpmode; - if (i < 0) { - ret = -1; - goto get_f3d_exit; - } - - ret = k = 0; - XROT = uvalues[k++].uval.ival; - YROT = uvalues[k++].uval.ival; - ZROT = uvalues[k++].uval.ival; - ZVIEWER = uvalues[k++].uval.ival; - XSHIFT = uvalues[k++].uval.ival; - YSHIFT = uvalues[k++].uval.ival; - g_glasses_type = uvalues[k++].uval.ival; - if (g_glasses_type < 0 || g_glasses_type > 4) g_glasses_type = 0; - if (g_glasses_type) - if (get_funny_glasses_params() || check_mapfile()) - ret = -1; - -get_f3d_exit: - driver_unstack_screen(); - return ret; -} - -/* --------------------------------------------------------------------- */ -/* These macros streamline the "save near space" campaign */ - -int get_3d_params() /* prompt for 3D parameters */ -{ - char *choices[11]; - int attributes[21]; - int sphere; - char *s; - char *prompts3d[21]; - struct fullscreenvalues uvalues[21]; - int i, k; - int oldhelpmode; - -#ifdef WINFRACT - { - extern int wintext_textmode; - if (wintext_textmode != 2) /* are we in textmode? */ - return 0; /* no - prompts are already handled */ - } -#endif -restart_1: - if (Targa_Out && overlay3d) - Targa_Overlay = 1; - - k= -1; - - prompts3d[++k] = "Preview Mode?"; - uvalues[k].type = 'y'; - uvalues[k].uval.ch.val = preview; - - prompts3d[++k] = " Show Box?"; - uvalues[k].type = 'y'; - uvalues[k].uval.ch.val = showbox; - - prompts3d[++k] = "Coarseness, preview/grid/ray (in y dir)"; - uvalues[k].type = 'i'; - uvalues[k].uval.ival = previewfactor; - - prompts3d[++k] = "Spherical Projection?"; - uvalues[k].type = 'y'; - uvalues[k].uval.ch.val = sphere = SPHERE; - - prompts3d[++k] = "Stereo (R/B 3D)? (0=no,1=alternate,2=superimpose,"; - uvalues[k].type = 'i'; - uvalues[k].uval.ival = g_glasses_type; - - prompts3d[++k] = " 3=photo,4=stereo pair)"; - uvalues[k].type = '*'; - - prompts3d[++k] = "Ray trace out? (0=No, 1=DKB/POVRay, 2=VIVID, 3=RAW,"; - uvalues[k].type = 'i'; - uvalues[k].uval.ival = RAY; - - prompts3d[++k] = " 4=MTV, 5=RAYSHADE, 6=ACROSPIN, 7=DXF)"; - uvalues[k].type = '*'; - - prompts3d[++k] = " Brief output?"; - uvalues[k].type = 'y'; - uvalues[k].uval.ch.val = BRIEF; - - check_writefile(ray_name,".ray"); - prompts3d[++k] = " Output File Name"; - uvalues[k].type = 's'; - strcpy(uvalues[k].uval.sval,ray_name); - - prompts3d[++k] = "Targa output?"; - uvalues[k].type = 'y'; - uvalues[k].uval.ch.val = Targa_Out; - - prompts3d[++k] = "Use grayscale value for depth? (if \"no\" uses color number)"; - uvalues[k].type = 'y'; - uvalues[k].uval.ch.val = grayflag; - - oldhelpmode = helpmode; - helpmode = HELP3DMODE; - - k = fullscreen_prompt("3D Mode Selection",k+1,prompts3d,uvalues,0,NULL); - helpmode = oldhelpmode; - if (k < 0) { - return -1; - } - - k=0; - - preview = (char)uvalues[k++].uval.ch.val; - - showbox = (char)uvalues[k++].uval.ch.val; - - previewfactor = uvalues[k++].uval.ival; - - sphere = uvalues[k++].uval.ch.val; - - g_glasses_type = uvalues[k++].uval.ival; - k++; - - RAY = uvalues[k++].uval.ival; - k++; - { - if (RAY == 1) - stopmsg(0, "DKB/POV-Ray output is obsolete but still works. See \"Ray Tracing Output\" in\n" - "the online documentation."); - } - BRIEF = uvalues[k++].uval.ch.val; - - strcpy(ray_name,uvalues[k++].uval.sval); - - Targa_Out = uvalues[k++].uval.ch.val; - grayflag = (char)uvalues[k++].uval.ch.val; - - /* check ranges */ - if (previewfactor < 2) - previewfactor = 2; - if (previewfactor > 2000) - previewfactor = 2000; - - if (sphere && !SPHERE) - { - SPHERE = TRUE; - set_3d_defaults(); - } - else if (!sphere && SPHERE) - { - SPHERE = FALSE; - set_3d_defaults(); - } - - if (g_glasses_type < 0) - g_glasses_type = 0; - if (g_glasses_type > 4) - g_glasses_type = 4; - if (g_glasses_type) - g_which_image = 1; - - if (RAY < 0) - RAY = 0; - if (RAY > 7) - RAY = 7; - - if (!RAY) - { - k = 0; - choices[k++] = "make a surface grid"; - choices[k++] = "just draw the points"; - choices[k++] = "connect the dots (wire frame)"; - choices[k++] = "surface fill (colors interpolated)"; - choices[k++] = "surface fill (colors not interpolated)"; - choices[k++] = "solid fill (bars up from \"ground\")"; - if (SPHERE) - { - choices[k++] = "light source"; - } - else - { - choices[k++] = "light source before transformation"; - choices[k++] = "light source after transformation"; - } - for (i = 0; i < k; ++i) - attributes[i] = 1; - helpmode = HELP3DFILL; - i = fullscreen_choice(CHOICE_HELP,"Select 3D Fill Type",NULL,NULL,k,(char * *)choices,attributes, - 0,0,0,FILLTYPE+1,NULL,NULL,NULL,NULL); - helpmode = oldhelpmode; - if (i < 0) - goto restart_1; - FILLTYPE = i-1; - - if (g_glasses_type) - { - if (get_funny_glasses_params()) - goto restart_1; - } - if (check_mapfile()) - goto restart_1; - } - restart_3: - - if (SPHERE) - { - k = -1; - prompts3d[++k] = "Longitude start (degrees)"; - prompts3d[++k] = "Longitude stop (degrees)"; - prompts3d[++k] = "Latitude start (degrees)"; - prompts3d[++k] = "Latitude stop (degrees)"; - prompts3d[++k] = "Radius scaling factor in pct"; - } - else - { - k = -1; - if (!RAY) - { - prompts3d[++k] = "X-axis rotation in degrees"; - prompts3d[++k] = "Y-axis rotation in degrees"; - prompts3d[++k] = "Z-axis rotation in degrees"; - } - prompts3d[++k] = "X-axis scaling factor in pct"; - prompts3d[++k] = "Y-axis scaling factor in pct"; - } - k = -1; - if (!(RAY && !SPHERE)) - { - uvalues[++k].uval.ival = XROT ; - uvalues[k].type = 'i'; - uvalues[++k].uval.ival = YROT ; - uvalues[k].type = 'i'; - uvalues[++k].uval.ival = ZROT ; - uvalues[k].type = 'i'; - } - uvalues[++k].uval.ival = XSCALE ; - uvalues[k].type = 'i'; - - uvalues[++k].uval.ival = YSCALE ; - uvalues[k].type = 'i'; - - prompts3d[++k] = "Surface Roughness scaling factor in pct"; - uvalues[k].type = 'i'; - uvalues[k].uval.ival = ROUGH ; - - prompts3d[++k] = "'Water Level' (minimum color value)"; - uvalues[k].type = 'i'; - uvalues[k].uval.ival = WATERLINE ; - - if (!RAY) - { - prompts3d[++k] = "Perspective distance [1 - 999, 0 for no persp])"; - uvalues[k].type = 'i'; - uvalues[k].uval.ival = ZVIEWER ; - - prompts3d[++k] = "X shift with perspective (positive = right)"; - uvalues[k].type = 'i'; - uvalues[k].uval.ival = XSHIFT ; - - prompts3d[++k] = "Y shift with perspective (positive = up )"; - uvalues[k].type = 'i'; - uvalues[k].uval.ival = YSHIFT ; - - prompts3d[++k] = "Image non-perspective X adjust (positive = right)"; - uvalues[k].type = 'i'; - uvalues[k].uval.ival = xtrans ; - - prompts3d[++k] = "Image non-perspective Y adjust (positive = up)"; - uvalues[k].type = 'i'; - uvalues[k].uval.ival = ytrans ; - - prompts3d[++k] = "First transparent color"; - uvalues[k].type = 'i'; - uvalues[k].uval.ival = transparent[0]; - - prompts3d[++k] = "Last transparent color"; - uvalues[k].type = 'i'; - uvalues[k].uval.ival = transparent[1]; - } - - prompts3d[++k] = "Randomize Colors (0 - 7, '0' disables)"; - uvalues[k].type = 'i'; - uvalues[k++].uval.ival = RANDOMIZE; - - if (SPHERE) - s = "Sphere 3D Parameters\n" - "Sphere is on its side; North pole to right\n" - "Long. 180 is top, 0 is bottom; Lat. -90 is left, 90 is right"; - else - s = "Planar 3D Parameters\n" - "Pre-rotation X axis is screen top; Y axis is left side\n" - "Pre-rotation Z axis is coming at you out of the screen!"; - - helpmode = HELP3DPARMS; - k = fullscreen_prompt(s,k,prompts3d,uvalues,0,NULL); - helpmode = oldhelpmode; - if (k < 0) - goto restart_1; - - k = 0; - if (!(RAY && !SPHERE)) - { - XROT = uvalues[k++].uval.ival; - YROT = uvalues[k++].uval.ival; - ZROT = uvalues[k++].uval.ival; - } - XSCALE = uvalues[k++].uval.ival; - YSCALE = uvalues[k++].uval.ival; - ROUGH = uvalues[k++].uval.ival; - WATERLINE = uvalues[k++].uval.ival; - if (!RAY) - { - ZVIEWER = uvalues[k++].uval.ival; - XSHIFT = uvalues[k++].uval.ival; - YSHIFT = uvalues[k++].uval.ival; - xtrans = uvalues[k++].uval.ival; - ytrans = uvalues[k++].uval.ival; - transparent[0] = uvalues[k++].uval.ival; - transparent[1] = uvalues[k++].uval.ival; - } - RANDOMIZE = uvalues[k++].uval.ival; - if (RANDOMIZE >= 7) RANDOMIZE = 7; - if (RANDOMIZE <= 0) RANDOMIZE = 0; - - if ((Targa_Out || ILLUMINE || RAY)) - if (get_light_params()) - goto restart_3; -return 0; -} - -/* --------------------------------------------------------------------- */ -static int get_light_params() -{ - char *prompts3d[13]; - struct fullscreenvalues uvalues[13]; - - int k; - int oldhelpmode; - - /* defaults go here */ - - k = -1; - - if (ILLUMINE || RAY) - { - prompts3d[++k] = "X value light vector"; - uvalues[k].type = 'i'; - uvalues[k].uval.ival = XLIGHT ; - - prompts3d[++k] = "Y value light vector"; - uvalues[k].type = 'i'; - uvalues[k].uval.ival = YLIGHT ; - - prompts3d[++k] = "Z value light vector"; - uvalues[k].type = 'i'; - uvalues[k].uval.ival = ZLIGHT ; - - if (!RAY) - { - prompts3d[++k] = "Light Source Smoothing Factor"; - uvalues[k].type = 'i'; - uvalues[k].uval.ival = LIGHTAVG ; - - prompts3d[++k] = "Ambient"; - uvalues[k].type = 'i'; - uvalues[k].uval.ival = Ambient; - } - } - - if (Targa_Out && !RAY) - { - prompts3d[++k] = "Haze Factor (0 - 100, '0' disables)"; - uvalues[k].type = 'i'; - uvalues[k].uval.ival= haze; - - if (!Targa_Overlay) - check_writefile(light_name,".tga"); - prompts3d[++k] = "Targa File Name (Assume .tga)"; - uvalues[k].type = 's'; - strcpy(uvalues[k].uval.sval,light_name); - - prompts3d[++k] = "Back Ground Color (0 - 255)"; - uvalues[k].type = '*'; - - prompts3d[++k] = " Red"; - uvalues[k].type = 'i'; - uvalues[k].uval.ival = (int)back_color[0]; - - prompts3d[++k] = " Green"; - uvalues[k].type = 'i'; - uvalues[k].uval.ival = (int)back_color[1]; - - prompts3d[++k] = " Blue"; - uvalues[k].type = 'i'; - uvalues[k].uval.ival = (int)back_color[2]; - - prompts3d[++k] = "Overlay Targa File? (Y/N)"; - uvalues[k].type = 'y'; - uvalues[k].uval.ch.val = Targa_Overlay; - - } - - prompts3d[++k] = ""; - - oldhelpmode = helpmode; - helpmode = HELP3DLIGHT; - k = fullscreen_prompt("Light Source Parameters",k,prompts3d,uvalues,0,NULL); - helpmode = oldhelpmode; - if (k < 0) - return -1; - - k = 0; - if (ILLUMINE) - { - XLIGHT = uvalues[k++].uval.ival; - YLIGHT = uvalues[k++].uval.ival; - ZLIGHT = uvalues[k++].uval.ival; - if (!RAY) - { - LIGHTAVG = uvalues[k++].uval.ival; - Ambient = uvalues[k++].uval.ival; - if (Ambient >= 100) Ambient = 100; - if (Ambient <= 0) Ambient = 0; - } - } - - if (Targa_Out && !RAY) - { - haze = uvalues[k++].uval.ival; - if (haze >= 100) haze = 100; - if (haze <= 0) haze = 0; - strcpy(light_name,uvalues[k++].uval.sval); - /* In case light_name conflicts with an existing name it is checked - again in line3d */ - k++; - back_color[0] = (char)(uvalues[k++].uval.ival % 255); - back_color[1] = (char)(uvalues[k++].uval.ival % 255); - back_color[2] = (char)(uvalues[k++].uval.ival % 255); - Targa_Overlay = uvalues[k].uval.ch.val; - } - return 0; -} - -/* --------------------------------------------------------------------- */ - - -static int check_mapfile() -{ - int askflag = 0; - int i,oldhelpmode; - if (dontreadcolor) - return 0; - strcpy(temp1,"*"); - if (mapset) - strcpy(temp1,MAP_name); - if (!(g_glasses_type == 1 || g_glasses_type == 2)) - askflag = 1; - else - merge_pathnames(temp1,funnyglasses_map_name,0); - - while (1) { - if (askflag) { - oldhelpmode = helpmode; - helpmode = -1; - i = field_prompt("Enter name of .MAP file to use,\n" - "or '*' to use palette from the image to be loaded.", - NULL,temp1,60,NULL); - helpmode = oldhelpmode; - if (i < 0) - return -1; - if (temp1[0] == '*') { - mapset = 0; - break; - } - } - memcpy(olddacbox,g_dac_box,256*3); /* save the DAC */ - i = ValidateLuts(temp1); - memcpy(g_dac_box,olddacbox,256*3); /* restore the DAC */ - if (i != 0) { /* Oops, somethings wrong */ - askflag = 1; - continue; - } - mapset = 1; - merge_pathnames(MAP_name,temp1,0); - break; - } - return 0; -} - -static int get_funny_glasses_params() -{ - char *prompts3d[10]; - - struct fullscreenvalues uvalues[10]; - - int k; - int oldhelpmode; - - /* defaults */ - if (ZVIEWER == 0) - ZVIEWER = 150; - if (g_eye_separation == 0) - { - if (fractype==IFS3D || fractype==LLORENZ3D || fractype==FPLORENZ3D) - { - g_eye_separation = 2; - xadjust = -2; - } - else - { - g_eye_separation = 3; - xadjust = 0; - } - } - - if (g_glasses_type == 1) - strcpy(funnyglasses_map_name,Glasses1Map); - else if (g_glasses_type == 2) - { - if (FILLTYPE == -1) - strcpy(funnyglasses_map_name,"grid.map"); - else - { - strcpy(funnyglasses_map_name,Glasses1Map); - funnyglasses_map_name[7] = '2'; - } - } - - k = -1; - prompts3d[++k] = "Interocular distance (as % of screen)"; - uvalues[k].type = 'i'; - uvalues[k].uval.ival= g_eye_separation; - - prompts3d[++k] = "Convergence adjust (positive = spread greater)"; - uvalues[k].type = 'i'; - uvalues[k].uval.ival = xadjust; - - prompts3d[++k] = "Left red image crop (% of screen)"; - uvalues[k].type = 'i'; - uvalues[k].uval.ival = red_crop_left; - - prompts3d[++k] = "Right red image crop (% of screen)"; - uvalues[k].type = 'i'; - uvalues[k].uval.ival = red_crop_right; - - prompts3d[++k] = "Left blue image crop (% of screen)"; - uvalues[k].type = 'i'; - uvalues[k].uval.ival = blue_crop_left; - - prompts3d[++k] = "Right blue image crop (% of screen)"; - uvalues[k].type = 'i'; - uvalues[k].uval.ival = blue_crop_right; - - prompts3d[++k] = "Red brightness factor (%)"; - uvalues[k].type = 'i'; - uvalues[k].uval.ival = red_bright; - - prompts3d[++k] = "Blue brightness factor (%)"; - uvalues[k].type = 'i'; - uvalues[k].uval.ival = blue_bright; - - if (g_glasses_type == 1 || g_glasses_type == 2) - { - prompts3d[++k] = "Map File name"; - uvalues[k].type = 's'; - strcpy(uvalues[k].uval.sval,funnyglasses_map_name); - } - - oldhelpmode = helpmode; - helpmode = HELP3DGLASSES; - k = fullscreen_prompt("Funny Glasses Parameters",k+1,prompts3d,uvalues,0,NULL); - helpmode = oldhelpmode; - if (k < 0) - return -1; - - k = 0; - g_eye_separation = uvalues[k++].uval.ival; - xadjust = uvalues[k++].uval.ival; - red_crop_left = uvalues[k++].uval.ival; - red_crop_right = uvalues[k++].uval.ival; - blue_crop_left = uvalues[k++].uval.ival; - blue_crop_right = uvalues[k++].uval.ival; - red_bright = uvalues[k++].uval.ival; - blue_bright = uvalues[k++].uval.ival; - - if (g_glasses_type == 1 || g_glasses_type == 2) - strcpy(funnyglasses_map_name,uvalues[k].uval.sval); - return 0; -} - -void setbailoutformula(enum bailouts test) { - - switch (test) { - case Mod: - default:{ - if (fpu >= 287 && debugflag != 72) /* Fast 287 math */ - floatbailout = (int ( *)(void))asmfpMODbailout; - else - floatbailout = (int ( *)(void))fpMODbailout; - if (cpu >=386 && debugflag != 8088) /* Fast 386 math */ - longbailout = (int ( *)(void))asm386lMODbailout; - else - longbailout = (int ( *)(void))asmlMODbailout; - bignumbailout = (int ( *)(void))bnMODbailout; - bigfltbailout = (int ( *)(void))bfMODbailout; - break;} - case Real: { - if (fpu >= 287 && debugflag != 72) /* Fast 287 math */ - floatbailout = (int ( *)(void))asmfpREALbailout; - else - floatbailout = (int ( *)(void))fpREALbailout; - if (cpu >=386 && debugflag != 8088) /* Fast 386 math */ - longbailout = (int ( *)(void))asm386lREALbailout; - else - longbailout = (int ( *)(void))asmlREALbailout; - bignumbailout = (int ( *)(void))bnREALbailout; - bigfltbailout = (int ( *)(void))bfREALbailout; - break;} - case Imag:{ - if (fpu >= 287 && debugflag != 72) /* Fast 287 math */ - floatbailout = (int ( *)(void))asmfpIMAGbailout; - else - floatbailout = (int ( *)(void))fpIMAGbailout; - if (cpu >=386 && debugflag != 8088) /* Fast 386 math */ - longbailout = (int ( *)(void))asm386lIMAGbailout; - else - longbailout = (int ( *)(void))asmlIMAGbailout; - bignumbailout = (int ( *)(void))bnIMAGbailout; - bigfltbailout = (int ( *)(void))bfIMAGbailout; - break;} - case Or:{ - if (fpu >= 287 && debugflag != 72) /* Fast 287 math */ - floatbailout = (int ( *)(void))asmfpORbailout; - else - floatbailout = (int ( *)(void))fpORbailout; - if (cpu >=386 && debugflag != 8088) /* Fast 386 math */ - longbailout = (int ( *)(void))asm386lORbailout; - else - longbailout = (int ( *)(void))asmlORbailout; - bignumbailout = (int ( *)(void))bnORbailout; - bigfltbailout = (int ( *)(void))bfORbailout; - break;} - case And:{ - if (fpu >= 287 && debugflag != 72) /* Fast 287 math */ - floatbailout = (int ( *)(void))asmfpANDbailout; - else - floatbailout = (int ( *)(void))fpANDbailout; - if (cpu >=386 && debugflag != 8088) /* Fast 386 math */ - longbailout = (int ( *)(void))asm386lANDbailout; - else - longbailout = (int ( *)(void))asmlANDbailout; - bignumbailout = (int ( *)(void))bnANDbailout; - bigfltbailout = (int ( *)(void))bfANDbailout; - break;} - case Manh:{ - if (fpu >= 287 && debugflag != 72) /* Fast 287 math */ - floatbailout = (int ( *)(void))asmfpMANHbailout; - else - floatbailout = (int ( *)(void))fpMANHbailout; - if (cpu >=386 && debugflag != 8088) /* Fast 386 math */ - longbailout = (int ( *)(void))asm386lMANHbailout; - else - longbailout = (int ( *)(void))asmlMANHbailout; - bignumbailout = (int ( *)(void))bnMANHbailout; - bigfltbailout = (int ( *)(void))bfMANHbailout; - break;} - case Manr:{ - if (fpu >= 287 && debugflag != 72) /* Fast 287 math */ - floatbailout = (int ( *)(void))asmfpMANRbailout; - else - floatbailout = (int ( *)(void))fpMANRbailout; - if (cpu >=386 && debugflag != 8088) /* Fast 386 math */ - longbailout = (int ( *)(void))asm386lMANRbailout; - else - longbailout = (int ( *)(void))asmlMANRbailout; - bignumbailout = (int ( *)(void))bnMANRbailout; - bigfltbailout = (int ( *)(void))bfMANRbailout; - break;} - } -} diff --git a/fractint/common/prompts2.c b/fractint/common/prompts2.c deleted file mode 100644 index 9d6764430..000000000 --- a/fractint/common/prompts2.c +++ /dev/null @@ -1,2665 +0,0 @@ -/* - Various routines that prompt for things. -*/ - -#include -#include - -#ifndef XFRACT -#include -#elif !defined(__386BSD__) && !defined(_WIN32) -#include -#include - -#ifdef DIRENT -#include -#elif !defined(__SVR4) -#include -#else -#include -#ifndef DIRENT -#define DIRENT -#endif -#endif - -#endif - -#if !defined(__386BSD__) -#if !defined(_WIN32) -#include -#endif -#endif - -#ifdef XFRACT -#include -#endif - -#ifdef __hpux -#include -#endif - -#ifdef __SVR4 -#include -#endif - -#if defined(_WIN32) -#include -#endif - - /* see Fractint.c for a description of the "include" hierarchy */ -#include "port.h" -#include "prototyp.h" -#include "fractype.h" -#include "helpdefs.h" -#include "drivers.h" - -/* Routines in this module */ - -static int check_f6_key(int curkey,int choice); -static int filename_speedstr(int, int, int, char *, int); -static int get_screen_corners(void); - -/* speed key state values */ -#define MATCHING 0 /* string matches list - speed key mode */ -#define TEMPLATE -2 /* wild cards present - buiding template */ -#define SEARCHPATH -3 /* no match - building path search name */ - -#define FILEATTR 0x37 /* File attributes; select all but volume labels */ -#define HIDDEN 2 -#define SYSTEM 4 -#define SUBDIR 16 -#define MAXNUMFILES 2977L - -struct DIR_SEARCH DTA; /* Allocate DTA and define structure */ - -#define GETFORMULA 0 -#define GETLSYS 1 -#define GETIFS 2 -#define GETPARM 3 - -char commandmask[13] = {"*.par"}; - -/* --------------------------------------------------------------------- */ -/* - get_toggles() is called from FRACTINT.C whenever the 'x' key - is pressed. This routine prompts for several options, - sets the appropriate variables, and returns the following code - to the calling routine: - - -1 routine was ESCAPEd - no need to re-generate the image. - 0 nothing changed, or minor variable such as "overwrite=". - No need to re-generate the image. - 1 major variable changed (such as "inside="). Re-generate - the image. - - Finally, remember to insert variables in the list *and* check - for them in the same order!!! -*/ - -int get_toggles() -{ - char *choices[20]; - int oldhelpmode; - char prevsavename[FILE_MAX_DIR+1]; - char *savenameptr; - struct fullscreenvalues uvalues[25]; - int i, j, k; - char old_usr_stdcalcmode; - long old_maxit,old_logflag; - int old_inside,old_outside,old_soundflag; - int old_biomorph,old_decomp; - int old_fillcolor; - int old_stoppass; - double old_closeprox; - char *calcmodes[] ={"1","2","3","g","g1","g2","g3","g4","g5","g6","b","s","t","d","o"}; - char *soundmodes[5]={"off", "beep","x","y","z"}; - char *insidemodes[]={"numb", "maxiter", "zmag", "bof60", "bof61", "epsiloncross", - "startrail", "period", "atan", "fmod"}; - char *outsidemodes[]={"numb", "iter", "real", "imag", "mult", "summ", "atan", - "fmod", "tdis"}; - - k = -1; - - choices[++k] = "Passes (1,2,3, g[uess], b[ound], t[ess], d[iffu], o[rbit])"; - uvalues[k].type = 'l'; - uvalues[k].uval.ch.vlen = 3; - uvalues[k].uval.ch.llen = sizeof(calcmodes)/sizeof(*calcmodes); - uvalues[k].uval.ch.list = calcmodes; - uvalues[k].uval.ch.val = (usr_stdcalcmode == '1') ? 0 - : (usr_stdcalcmode == '2') ? 1 - : (usr_stdcalcmode == '3') ? 2 - : (usr_stdcalcmode == 'g' && stoppass == 0) ? 3 - : (usr_stdcalcmode == 'g' && stoppass == 1) ? 4 - : (usr_stdcalcmode == 'g' && stoppass == 2) ? 5 - : (usr_stdcalcmode == 'g' && stoppass == 3) ? 6 - : (usr_stdcalcmode == 'g' && stoppass == 4) ? 7 - : (usr_stdcalcmode == 'g' && stoppass == 5) ? 8 - : (usr_stdcalcmode == 'g' && stoppass == 6) ? 9 - : (usr_stdcalcmode == 'b') ? 10 - : (usr_stdcalcmode == 's') ? 11 - : (usr_stdcalcmode == 't') ? 12 - : (usr_stdcalcmode == 'd') ? 13 - : /* "o"rbits */ 14; - old_usr_stdcalcmode = usr_stdcalcmode; - old_stoppass = stoppass; -#ifndef XFRACT - choices[++k] = "Floating Point Algorithm"; - uvalues[k].type = 'y'; - uvalues[k].uval.ch.val = usr_floatflag; -#endif - choices[++k] = "Maximum Iterations (2 to 2,147,483,647)"; - uvalues[k].type = 'L'; - uvalues[k].uval.Lval = old_maxit = maxit; - - choices[++k] = "Inside Color (0-# of colors, if Inside=numb)"; - uvalues[k].type = 'i'; - if (inside >= 0) - uvalues[k].uval.ival = inside; - else - uvalues[k].uval.ival = 0; - - choices[++k] = "Inside (numb,maxit,zmag,bof60,bof61,epscr,star,per,atan,fmod)"; - uvalues[k].type = 'l'; - uvalues[k].uval.ch.vlen = 12; - uvalues[k].uval.ch.llen = sizeof(insidemodes)/sizeof(*insidemodes); - uvalues[k].uval.ch.list = insidemodes; - if (inside >= 0) /* numb */ - uvalues[k].uval.ch.val = 0; - else if (inside == -1) /* maxiter */ - uvalues[k].uval.ch.val = 1; - else if (inside == ZMAG) - uvalues[k].uval.ch.val = 2; - else if (inside == BOF60) - uvalues[k].uval.ch.val = 3; - else if (inside == BOF61) - uvalues[k].uval.ch.val = 4; - else if (inside == EPSCROSS) - uvalues[k].uval.ch.val = 5; - else if (inside == STARTRAIL) - uvalues[k].uval.ch.val = 6; - else if (inside == PERIOD) - uvalues[k].uval.ch.val = 7; - else if (inside == ATANI) - uvalues[k].uval.ch.val = 8; - else if (inside == FMODI) - uvalues[k].uval.ch.val = 9; - old_inside = inside; - - choices[++k] = "Outside Color (0-# of colors, if Outside=numb)"; - uvalues[k].type = 'i'; - if (outside >= 0) - uvalues[k].uval.ival = outside; - else - uvalues[k].uval.ival = 0; - - choices[++k] = "Outside (numb,iter,real,imag,mult,summ,atan,fmod,tdis)"; - uvalues[k].type = 'l'; - uvalues[k].uval.ch.vlen = 4; - uvalues[k].uval.ch.llen = sizeof(outsidemodes)/sizeof(*outsidemodes); - uvalues[k].uval.ch.list = outsidemodes; - if (outside >= 0) /* numb */ - uvalues[k].uval.ch.val = 0; - else - uvalues[k].uval.ch.val = -outside; - old_outside = outside; - - choices[++k] = "Savename (.GIF implied)"; - uvalues[k].type = 's'; - strcpy(prevsavename,savename); - savenameptr = strrchr(savename, SLASHC); - if (savenameptr == NULL) - savenameptr = savename; - else - savenameptr++; /* point past slash */ - strcpy(uvalues[k].uval.sval,savenameptr); - - choices[++k] = "File Overwrite ('overwrite=')"; - uvalues[k].type = 'y'; - uvalues[k].uval.ch.val = fract_overwrite; - - choices[++k] = "Sound (off, beep, x, y, z)"; - uvalues[k].type = 'l'; - uvalues[k].uval.ch.vlen = 4; - uvalues[k].uval.ch.llen = 5; - uvalues[k].uval.ch.list = soundmodes; - uvalues[k].uval.ch.val = (old_soundflag = soundflag) & SOUNDFLAG_ORBITMASK; - - if (rangeslen == 0) { - choices[++k] = "Log Palette (0=no,1=yes,-1=old,+n=cmprsd,-n=sqrt, 2=auto)"; - uvalues[k].type = 'L'; - } - else { - choices[++k] = "Log Palette (n/a, ranges= parameter is in effect)"; - uvalues[k].type = '*'; - } - uvalues[k].uval.Lval = old_logflag = LogFlag; - - choices[++k] = "Biomorph Color (-1 means OFF)"; - uvalues[k].type = 'i'; - uvalues[k].uval.ival = old_biomorph = usr_biomorph; - - choices[++k] = "Decomp Option (2,4,8,..,256, 0=OFF)"; - uvalues[k].type = 'i'; - uvalues[k].uval.ival = old_decomp = decomp[0]; - - choices[++k] = "Fill Color (normal,#) (works with passes=t, b and d)"; - uvalues[k].type = 's'; - if (fillcolor < 0) - strcpy(uvalues[k].uval.sval, "normal"); - else - sprintf(uvalues[k].uval.sval,"%d",fillcolor); - old_fillcolor = fillcolor; - - choices[++k] = "Proximity value for inside=epscross and fmod"; - uvalues[k].type = 'f'; /* should be 'd', but prompts get messed up JCO */ - uvalues[k].uval.dval = old_closeprox = closeprox; - - oldhelpmode = helpmode; - helpmode = HELPXOPTS; - i = fullscreen_prompt("Basic Options\n(not all combinations make sense)",k+1,choices,uvalues,0,NULL); - helpmode = oldhelpmode; - if (i < 0) { - return(-1); - } - - /* now check out the results (*hopefully* in the same order ) */ - k = -1; - j = 0; /* return code */ - - usr_stdcalcmode = calcmodes[uvalues[++k].uval.ch.val][0]; - stoppass = (int)calcmodes[uvalues[k].uval.ch.val][1] - (int)'0'; - - if (stoppass < 0 || stoppass > 6 || usr_stdcalcmode != 'g') - stoppass = 0; - - if (usr_stdcalcmode == 'o' && fractype == LYAPUNOV) /* Oops,lyapunov type */ - /* doesn't use 'new' & breaks orbits */ - usr_stdcalcmode = old_usr_stdcalcmode; - - if (old_usr_stdcalcmode != usr_stdcalcmode) j++; - if (old_stoppass != stoppass) j++; -#ifndef XFRACT - if (uvalues[++k].uval.ch.val != usr_floatflag) { - usr_floatflag = (char)uvalues[k].uval.ch.val; - j++; - } -#endif - ++k; - maxit = uvalues[k].uval.Lval; - if (maxit < 0) maxit = old_maxit; - if (maxit < 2) maxit = 2; - - if (maxit != old_maxit) j++; - - inside = uvalues[++k].uval.ival; - if (inside < 0) inside = -inside; - if (inside >= colors) inside = (inside % colors) + (inside / colors); - - { int tmp; - tmp = uvalues[++k].uval.ch.val; - if (tmp > 0) - switch (tmp) - { - case 1: - inside = -1; /* maxiter */ - break; - case 2: - inside = ZMAG; - break; - case 3: - inside = BOF60; - break; - case 4: - inside = BOF61; - break; - case 5: - inside = EPSCROSS; - break; - case 6: - inside = STARTRAIL; - break; - case 7: - inside = PERIOD; - break; - case 8: - inside = ATANI; - break; - case 9: - inside = FMODI; - break; - } - } - if (inside != old_inside) j++; - - outside = uvalues[++k].uval.ival; - if (outside < 0) outside = -outside; - if (outside >= colors) outside = (outside % colors) + (outside / colors); - - { int tmp; - tmp = uvalues[++k].uval.ch.val; - if (tmp > 0) - outside = -tmp; - } - if (outside != old_outside) j++; - - strcpy(savenameptr,uvalues[++k].uval.sval); - if (strcmp(savename,prevsavename)) - resave_flag = started_resaves = 0; /* forget pending increment */ - fract_overwrite = (char)uvalues[++k].uval.ch.val; - - soundflag = ((soundflag >> 3) << 3) | (uvalues[++k].uval.ch.val); - if (soundflag != old_soundflag && ((soundflag & SOUNDFLAG_ORBITMASK) > SOUNDFLAG_BEEP || (old_soundflag & SOUNDFLAG_ORBITMASK) > SOUNDFLAG_BEEP)) - j++; - - LogFlag = uvalues[++k].uval.Lval; - if (LogFlag != old_logflag) { - j++; - Log_Auto_Calc = 0; /* turn it off, use the supplied value */ - } - - usr_biomorph = uvalues[++k].uval.ival; - if (usr_biomorph >= colors) usr_biomorph = (usr_biomorph % colors) + (usr_biomorph / colors); - if (usr_biomorph != old_biomorph) j++; - - decomp[0] = uvalues[++k].uval.ival; - if (decomp[0] != old_decomp) j++; - - if (strncmp(strlwr(uvalues[++k].uval.sval), "normal",4)==0) - fillcolor = -1; - else - fillcolor = atoi(uvalues[k].uval.sval); - if (fillcolor < 0) fillcolor = -1; - if (fillcolor >= colors) fillcolor = (fillcolor % colors) + (fillcolor / colors); - if (fillcolor != old_fillcolor) j++; - - ++k; - closeprox = uvalues[k].uval.dval; - if (closeprox != old_closeprox) j++; - -/* if (j >= 1) j = 1; need to know how many prompts changed for quick_calc JCO 6/23/2001 */ - - return(j); -} - -/* - get_toggles2() is similar to get_toggles, invoked by 'y' key -*/ - -int get_toggles2() -{ - char *choices[18]; - int oldhelpmode; - - struct fullscreenvalues uvalues[23]; - int i, j, k; - - int old_rotate_lo,old_rotate_hi; - int old_distestwidth; - double old_potparam[3],old_inversion[3]; - long old_usr_distest; - - /* fill up the choices (and previous values) arrays */ - k = -1; - - choices[++k] = "Look for finite attractor (0=no,>0=yes,<0=phase)"; - uvalues[k].type = 'i'; - uvalues[k].uval.ch.val = finattract; - - choices[++k] = "Potential Max Color (0 means off)"; - uvalues[k].type = 'i'; - uvalues[k].uval.ival = (int)(old_potparam[0] = potparam[0]); - - choices[++k] = " Slope"; - uvalues[k].type = 'd'; - uvalues[k].uval.dval = old_potparam[1] = potparam[1]; - - choices[++k] = " Bailout"; - uvalues[k].type = 'i'; - uvalues[k].uval.ival = (int)(old_potparam[2] = potparam[2]); - - choices[++k] = " 16 bit values"; - uvalues[k].type = 'y'; - uvalues[k].uval.ch.val = pot16bit; - - choices[++k] = "Distance Estimator (0=off, <0=edge, >0=on):"; - uvalues[k].type = 'L'; - uvalues[k].uval.Lval = old_usr_distest = usr_distest; - - choices[++k] = " width factor:"; - uvalues[k].type = 'i'; - uvalues[k].uval.ival = old_distestwidth = distestwidth; - - choices[++k] = "Inversion radius or \"auto\" (0 means off)"; - choices[++k] = " center X coordinate or \"auto\""; - choices[++k] = " center Y coordinate or \"auto\""; - k = k - 3; - for (i= 0; i < 3; i++) { - uvalues[++k].type = 's'; - old_inversion[i] = inversion[i]; - if (inversion[i] == AUTOINVERT) - sprintf(uvalues[k].uval.sval,"auto"); - else - sprintf(uvalues[k].uval.sval,"%-1.15lg",inversion[i]); - } - choices[++k] = " (use fixed radius & center when zooming)"; - uvalues[k].type = '*'; - - choices[++k] = "Color cycling from color (0 ... 254)"; - uvalues[k].type = 'i'; - uvalues[k].uval.ival = old_rotate_lo = rotate_lo; - - choices[++k] = " to color (1 ... 255)"; - uvalues[k].type = 'i'; - uvalues[k].uval.ival = old_rotate_hi = rotate_hi; - - oldhelpmode = helpmode; - helpmode = HELPYOPTS; - i = fullscreen_prompt("Extended Options\n" - "(not all combinations make sense)", - k+1,choices,uvalues,0,NULL); - helpmode = oldhelpmode; - if (i < 0) { - return(-1); - } - - /* now check out the results (*hopefully* in the same order ) */ - k = -1; - j = 0; /* return code */ - - if (uvalues[++k].uval.ch.val != finattract) { - finattract = uvalues[k].uval.ch.val; - j = 1; - } - - potparam[0] = uvalues[++k].uval.ival; - if (potparam[0] != old_potparam[0]) j = 1; - - potparam[1] = uvalues[++k].uval.dval; - if (potparam[0] != 0.0 && potparam[1] != old_potparam[1]) j = 1; - - potparam[2] = uvalues[++k].uval.ival; - if (potparam[0] != 0.0 && potparam[2] != old_potparam[2]) j = 1; - - if (uvalues[++k].uval.ch.val != pot16bit) { - pot16bit = uvalues[k].uval.ch.val; - if (pot16bit) { /* turned it on */ - if (potparam[0] != 0.0) j = 1; - } - else /* turned it off */ - if (!driver_diskp()) /* ditch the disk video */ - enddisk(); - else /* keep disk video, but ditch the fraction part at end */ - disk16bit = 0; - } - - ++k; -/* usr_distest = (uvalues[k].uval.ival > 32000) ? 32000 : uvalues[k].uval.ival; */ - usr_distest = uvalues[k].uval.Lval; - if (usr_distest != old_usr_distest) j = 1; - ++k; - distestwidth = uvalues[k].uval.ival; - if (usr_distest && distestwidth != old_distestwidth) j = 1; - - for (i = 0; i < 3; i++) { - if (uvalues[++k].uval.sval[0] == 'a' || uvalues[k].uval.sval[0] == 'A') - inversion[i] = AUTOINVERT; - else - inversion[i] = atof(uvalues[k].uval.sval); - if (old_inversion[i] != inversion[i] - && (i == 0 || inversion[0] != 0.0)) - j = 1; - } - invert = (inversion[0] == 0.0) ? 0 : 3; - ++k; - - rotate_lo = uvalues[++k].uval.ival; - rotate_hi = uvalues[++k].uval.ival; - if (rotate_lo < 0 || rotate_hi > 255 || rotate_lo > rotate_hi) { - rotate_lo = old_rotate_lo; - rotate_hi = old_rotate_hi; - } - - return(j); -} - - -/* - passes_options invoked by

key -*/ - -int passes_options(void) -{ - char *choices[20]; - int oldhelpmode; - char *passcalcmodes[] ={"rect","line"}; - - struct fullscreenvalues uvalues[25]; - int i, j, k; - int ret; - - int old_periodicity, old_orbit_delay, old_orbit_interval; - int old_keep_scrn_coords; - char old_drawmode; - - ret = 0; - -pass_option_restart: - /* fill up the choices (and previous values) arrays */ - k = -1; - - choices[++k] = "Periodicity (0=off, <0=show, >0=on, -255..+255)"; - uvalues[k].type = 'i'; - uvalues[k].uval.ival = old_periodicity = usr_periodicitycheck; - - choices[++k] = "Orbit delay (0 = none)"; - uvalues[k].type = 'i'; - uvalues[k].uval.ival = old_orbit_delay = orbit_delay; - - choices[++k] = "Orbit interval (1 ... 255)"; - uvalues[k].type = 'i'; - uvalues[k].uval.ival = old_orbit_interval = (int)orbit_interval; - - choices[++k] = "Maintain screen coordinates"; - uvalues[k].type = 'y'; - uvalues[k].uval.ch.val = old_keep_scrn_coords = keep_scrn_coords; - - choices[++k] = "Orbit pass shape (rect,line)"; -/* choices[++k] = "Orbit pass shape (rect,line,func)"; */ - uvalues[k].type = 'l'; - uvalues[k].uval.ch.vlen = 5; - uvalues[k].uval.ch.llen = sizeof(passcalcmodes)/sizeof(*passcalcmodes); - uvalues[k].uval.ch.list = passcalcmodes; - uvalues[k].uval.ch.val = (drawmode == 'r') ? 0 - : (drawmode == 'l') ? 1 - : /* function */ 2; - old_drawmode = drawmode; - - oldhelpmode = helpmode; - helpmode = HELPPOPTS; - i = fullscreen_prompt("Passes Options\n" - "(not all combinations make sense)\n" - "(Press "FK_F2" for corner parameters)\n" - "(Press "FK_F6" for calculation parameters)",k+1,choices,uvalues,0x44,NULL); - helpmode = oldhelpmode; - if (i < 0) { - return(-1); - } - - /* now check out the results (*hopefully* in the same order ) */ - k = -1; - j = 0; /* return code */ - - usr_periodicitycheck = uvalues[++k].uval.ival; - if (usr_periodicitycheck > 255) usr_periodicitycheck = 255; - if (usr_periodicitycheck < -255) usr_periodicitycheck = -255; - if (usr_periodicitycheck != old_periodicity) j = 1; - - - orbit_delay = uvalues[++k].uval.ival; - if (orbit_delay != old_orbit_delay) j = 1; - - - orbit_interval = uvalues[++k].uval.ival; - if (orbit_interval > 255) orbit_interval = 255; - if (orbit_interval < 1) orbit_interval = 1; - if (orbit_interval != old_orbit_interval) j = 1; - - keep_scrn_coords = uvalues[++k].uval.ch.val; - if (keep_scrn_coords != old_keep_scrn_coords) j = 1; - if (keep_scrn_coords == 0) set_orbit_corners = 0; - - { int tmp; - tmp = uvalues[++k].uval.ch.val; - switch (tmp) - { - default: - case 0: - drawmode = 'r'; - break; - case 1: - drawmode = 'l'; - break; - case 2: - drawmode = 'f'; - break; - } - } - if (drawmode != old_drawmode) j = 1; - - if (i == FIK_F2) { - if (get_screen_corners() > 0) { - ret = 1; - } - if (j) ret = 1; - goto pass_option_restart; - } - - if (i == FIK_F6) { - if (get_corners() > 0) { - ret = 1; - } - if (j) ret = 1; - goto pass_option_restart; - } - - return(j + ret); -} - - -/* for videomodes added new options "virtual x/y" that change "sx/ydots" */ -/* for diskmode changed "viewx/ydots" to "virtual x/y" that do as above */ -/* (since for diskmode they were updated by x/ydots that should be the */ -/* same as sx/ydots for that mode) */ -/* g_video_table and g_video_entry are now updated even for non-disk modes */ - -/* --------------------------------------------------------------------- */ -/* - get_view_params() is called from FRACTINT.C whenever the 'v' key - is pressed. Return codes are: - -1 routine was ESCAPEd - no need to re-generate the image. - 0 minor variable changed. No need to re-generate the image. - 1 View changed. Re-generate the image. -*/ - -int get_view_params() -{ - char *choices[16]; - int oldhelpmode; - struct fullscreenvalues uvalues[25]; - int i, k; - float old_viewreduction, old_aspectratio; - int old_viewwindow, old_viewxdots, old_viewydots, old_sxdots, old_sydots; - int xmax, ymax; - char dim1[50]; - char dim2[50]; - - driver_get_max_screen(&xmax, &ymax); - - old_viewwindow = viewwindow; - old_viewreduction = viewreduction; - old_aspectratio = finalaspectratio; - old_viewxdots = viewxdots; - old_viewydots = viewydots; - old_sxdots = sxdots; - old_sydots = sydots; - -get_view_restart: - /* fill up the previous values arrays */ - k = -1; - - if (!driver_diskp()) - { - choices[++k] = "Preview display? (no for full screen)"; - uvalues[k].type = 'y'; - uvalues[k].uval.ch.val = viewwindow; - - choices[++k] = "Auto window size reduction factor"; - uvalues[k].type = 'f'; - uvalues[k].uval.dval = viewreduction; - - choices[++k] = "Final media overall aspect ratio, y/x"; - uvalues[k].type = 'f'; - uvalues[k].uval.dval = finalaspectratio; - - choices[++k] = "Crop starting coordinates to new aspect ratio?"; - uvalues[k].type = 'y'; - uvalues[k].uval.ch.val = viewcrop; - - choices[++k] = "Explicit size x pixels (0 for auto size)"; - uvalues[k].type = 'i'; - uvalues[k].uval.ival = viewxdots; - - choices[++k] = " y pixels (0 to base on aspect ratio)"; - uvalues[k].type = 'i'; - uvalues[k].uval.ival = viewydots; - } - - choices[++k] = ""; - uvalues[k].type = '*'; - - choices[++k] = "Virtual screen total x pixels"; - uvalues[k].type = 'i'; - uvalues[k].uval.ival = sxdots; - - choices[++k] = driver_diskp() ? - " y pixels" : - " y pixels (0: by aspect ratio)"; - uvalues[k].type = 'i'; - uvalues[k].uval.ival = sydots; - - choices[++k] = "Keep aspect? (cuts both x & y when either too big)"; - uvalues[k].type = 'y'; - uvalues[k].uval.ch.val = video_cutboth; - - { - char *scrolltypes[] ={"fixed","relaxed"}; - choices[++k] = "Zoombox scrolling (f[ixed], r[elaxed])"; - uvalues[k].type = 'l'; - uvalues[k].uval.ch.vlen = 7; - uvalues[k].uval.ch.llen = sizeof(scrolltypes)/sizeof(*scrolltypes); - uvalues[k].uval.ch.list = scrolltypes; - uvalues[k].uval.ch.val = zscroll; - } - - choices[++k] = ""; - uvalues[k].type = '*'; - - sprintf(dim1, "Video memory limits: (for y = %4u) x <= %lu", ymax, xmax); - choices[++k]= dim1; - uvalues[k].type = '*'; - - sprintf(dim2, " (for x = %4u) y <= %lu", xmax, ymax); - choices[++k]= dim2; - uvalues[k].type = '*'; - - choices[++k] = ""; - uvalues[k].type = '*'; - - if (!driver_diskp()) - { - choices[++k] = "Press F4 to reset view parameters to defaults."; - uvalues[k].type = '*'; - } - - oldhelpmode = helpmode; /* this prevents HELP from activating */ - helpmode = HELPVIEW; - i = fullscreen_prompt("View Window Options",k+1,choices,uvalues,16,NULL); - helpmode = oldhelpmode; /* re-enable HELP */ - if (i < 0) - { - return -1; - } - - if (i == FIK_F4 && !driver_diskp()) - { - viewwindow = viewxdots = viewydots = 0; - viewreduction = (float) 4.2; - viewcrop = 1; - finalaspectratio = screenaspect; - sxdots = old_sxdots; - sydots = old_sydots; - video_cutboth = 1; - zscroll = 1; - goto get_view_restart; - } - - /* now check out the results (*hopefully* in the same order ) */ - k = -1; - - if (!driver_diskp()) - { - viewwindow = uvalues[++k].uval.ch.val; - viewreduction = (float) uvalues[++k].uval.dval; - finalaspectratio = (float) uvalues[++k].uval.dval; - viewcrop = uvalues[++k].uval.ch.val; - viewxdots = uvalues[++k].uval.ival; - viewydots = uvalues[++k].uval.ival; - } - - ++k; - - sxdots = uvalues[++k].uval.ival; - sydots = uvalues[++k].uval.ival; - video_cutboth = uvalues[++k].uval.ch.val; - zscroll = uvalues[++k].uval.ch.val; - - if ((xmax != -1) && (sxdots > xmax)) - { - sxdots = (int) xmax; - } - if (sxdots < 2) - { - sxdots = 2; - } - if (sydots == 0) /* auto by aspect ratio request */ - { - if (finalaspectratio == 0.0) - { - finalaspectratio = (viewwindow && viewxdots != 0 && viewydots != 0) ? - ((float) viewydots)/((float) viewxdots) : old_aspectratio; - } - sydots = (int) (finalaspectratio*sxdots + 0.5); - } - if ((ymax != -1) && (sydots > ymax)) - { - sydots = ymax; - } - if (sydots < 2) - { - sydots = 2; - } - - if (driver_diskp()) - { - g_video_entry.xdots = sxdots; - g_video_entry.ydots = sydots; - memcpy(&g_video_table[g_adapter], &g_video_entry, sizeof(g_video_entry)); - if (finalaspectratio == 0.0) - { - finalaspectratio = ((float) sydots)/((float) sxdots); - } - } - - if (viewxdots != 0 && viewydots != 0 && viewwindow && finalaspectratio == 0.0) - { - finalaspectratio = ((float) viewydots)/((float) viewxdots); - } - else if (finalaspectratio == 0.0 && (viewxdots == 0 || viewydots == 0)) - { - finalaspectratio = old_aspectratio; - } - - if (finalaspectratio != old_aspectratio && viewcrop) - { - aspectratio_crop(old_aspectratio, finalaspectratio); - } - - return (viewwindow != old_viewwindow - || sxdots != old_sxdots || sydots != old_sydots - || (viewwindow - && (viewreduction != old_viewreduction - || finalaspectratio != old_aspectratio - || viewxdots != old_viewxdots - || (viewydots != old_viewydots && viewxdots)))) ? 1 : 0; -} - -/* - get_cmd_string() is called from FRACTINT.C whenever the 'g' key - is pressed. Return codes are: - -1 routine was ESCAPEd - no need to re-generate the image. - 0 parameter changed, no need to regenerate - >0 parameter changed, regenerate -*/ - -int get_cmd_string() -{ - int oldhelpmode; - int i; - static char cmdbuf[61]; - - oldhelpmode = helpmode; - helpmode = HELPCOMMANDS; - i = field_prompt("Enter command string to use.",NULL,cmdbuf,60,NULL); - helpmode = oldhelpmode; - if (i >= 0 && cmdbuf[0] != 0) { - i = cmdarg(cmdbuf, CMDFILE_AT_AFTER_STARTUP); - if (debugflag == 98) - { - backwards_v18(); - backwards_v19(); - backwards_v20(); - } - } - - return(i); -} - - -/* --------------------------------------------------------------------- */ - -int Distribution = 30, Offset = 0, Slope = 25; -long con; - - - double starfield_values[4] = { - 30.0,100.0,5.0,0.0 - }; - -char GreyFile[] = "altern.map"; - -int starfield(void) -{ - int c; - busy = 1; - if (starfield_values[0] < 1.0) starfield_values[0] = 1.0; - if (starfield_values[0] > 100.0) starfield_values[0] = 100.0; - if (starfield_values[1] < 1.0) starfield_values[1] = 1.0; - if (starfield_values[1] > 100.0) starfield_values[1] = 100.0; - if (starfield_values[2] < 1.0) starfield_values[2] = 1.0; - if (starfield_values[2] > 100.0) starfield_values[2] = 100.0; - - Distribution = (int)(starfield_values[0]); - con = (long)(((starfield_values[1]) / 100.0) * (1L << 16)); - Slope = (int)(starfield_values[2]); - - if (ValidateLuts(GreyFile) != 0) { - stopmsg(0,"Unable to load ALTERN.MAP"); - busy = 0; - return(-1); - } - spindac(0,1); /* load it, but don't spin */ - for (row = 0; row < ydots; row++) { - for (col = 0; col < xdots; col++) { - if (driver_key_pressed()) { - driver_buzzer(BUZZER_INTERRUPT); - busy = 0; - return(1); - } - c = getcolor(col, row); - if (c == inside) - c = colors-1; - putcolor(col, row, GausianNumber(c, colors)); - } - } - driver_buzzer(BUZZER_COMPLETE); - busy = 0; - return(0); -} - -int get_starfield_params(void) { - struct fullscreenvalues uvalues[3]; - int oldhelpmode; - int i; - char *starfield_prompts[3] = - { - "Star Density in Pixels per Star", - "Percent Clumpiness", - "Ratio of Dim stars to Bright" - }; - - if (colors < 255) { - stopmsg(0,"starfield requires 256 color mode"); - return(-1); - } - for (i = 0; i < 3; i++) { - uvalues[i].uval.dval = starfield_values[i]; - uvalues[i].type = 'f'; - } - driver_stack_screen(); - oldhelpmode = helpmode; - helpmode = HELPSTARFLD; - i = fullscreen_prompt("Starfield Parameters",3,starfield_prompts,uvalues,0,NULL); - helpmode = oldhelpmode; - driver_unstack_screen(); - if (i < 0) { - return(-1); - } - for (i = 0; i < 3; i++) - starfield_values[i] = uvalues[i].uval.dval; - - return(0); -} - -static char *masks[] = {"*.pot","*.gif"}; - -int get_rds_params(void) { - char rds6[60]; - char *stereobars[] = {"none", "middle", "top"}; - struct fullscreenvalues uvalues[7]; - char *rds_prompts[7] = - { - "Depth Effect (negative reverses front and back)", - "Image width in inches", - "Use grayscale value for depth? (if \"no\" uses color number)", - "Calibration bars", - "Use image map? (if \"no\" uses random dots)", - " If yes, use current image map name? (see below)", - rds6 - }; - int oldhelpmode; - int i,k; - int ret; - static char reuse = 0; - driver_stack_screen(); - while (1) - { - ret = 0; - - k=0; - uvalues[k].uval.ival = AutoStereo_depth; - uvalues[k++].type = 'i'; - - uvalues[k].uval.dval = AutoStereo_width; - uvalues[k++].type = 'f'; - - uvalues[k].uval.ch.val = grayflag; - uvalues[k++].type = 'y'; - - uvalues[k].type = 'l'; - uvalues[k].uval.ch.list = stereobars; - uvalues[k].uval.ch.vlen = 6; - uvalues[k].uval.ch.llen = 3; - uvalues[k++].uval.ch.val = calibrate; - - uvalues[k].uval.ch.val = image_map; - uvalues[k++].type = 'y'; - - - if (*stereomapname != 0 && image_map) - { - char *p; - uvalues[k].uval.ch.val = reuse; - uvalues[k++].type = 'y'; - - uvalues[k++].type = '*'; - for (i=0; i) */ - k = -1; - - *x = uvalues[++k].uval.dval; - *y = uvalues[++k].uval.dval; - - driver_unstack_screen(); - return(i); -} - -/* --------------------------------------------------------------------- */ - -int get_commands() /* execute commands from file */ -{ - int ret; - FILE *parmfile; - long point; - int oldhelpmode; - ret = 0; - oldhelpmode = helpmode; - helpmode = HELPPARMFILE; - if ((point = get_file_entry(GETPARM,"Parameter Set", - commandmask,CommandFile,CommandName)) >= 0 - && (parmfile = fopen(CommandFile,"rb")) != NULL) { - fseek(parmfile,point,SEEK_SET); - ret = load_commands(parmfile); - } - helpmode = oldhelpmode; - return(ret); -} - -/* --------------------------------------------------------------------- */ - -void goodbye(void) /* we done. Bail out */ -{ - char goodbyemessage[40] = " Thank You for using "FRACTINT; - int ret; - - if (mapdacbox) - { - free(mapdacbox); - mapdacbox = NULL; - } - if (resume_info != 0) - { - end_resume(); - } - if (evolve_handle != 0) - { - MemoryRelease(evolve_handle); - } - if (gene_handle != 0) - { - MemoryRelease(gene_handle); - } - if (imgboxhandle != 0 || prmboxhandle != 0) - { - ReleaseParamBox(); - } - if (history != 0) - { - MemoryRelease(history); - } - if (oldhistory_handle != 0) - { - MemoryRelease(oldhistory_handle); - } - if (ifs_defn != NULL) - { - free(ifs_defn); - ifs_defn = NULL; - } - free_grid_pointers(); - free_ant_storage(); - enddisk(); - discardgraphics(); - ExitCheck(); -#ifdef WINFRACT - return; -#endif - if (*s_makepar != 0) - { - driver_set_for_text(); - } -#ifdef XFRACT - UnixDone(); - printf("\n\n\n%s\n",goodbyemessage); /* printf takes pointer */ -#endif - if (*s_makepar != 0) - { - driver_move_cursor(6,0); - discardgraphics(); /* if any emm/xmm tied up there, release it */ - } - stopslideshow(); - end_help(); - ret = 0; - if (initbatch == 3) /* exit with error code for batch file */ - { - ret = 2; - } - else if (initbatch == 4) - { - ret = 1; - } - close_drivers(); -#if defined(_WIN32) - _CrtDumpMemoryLeaks(); -#endif - exit(ret); -} - - -/* --------------------------------------------------------------------- */ - -#if !defined(_WIN32) -#ifdef XFRACT -static char searchdir[FILE_MAX_DIR]; -static char searchname[FILE_MAX_PATH]; -static char searchext[FILE_MAX_EXT]; -static DIR *currdir = NULL; -#endif -int fr_findfirst(char *path) /* Find 1st file (or subdir) meeting path/filespec */ -{ -#ifndef XFRACT - union REGS regs; - regs.h.ah = 0x1A; /* Set DTA to filedata */ - regs.x.dx = (unsigned)&DTA; - intdos(®s, ®s); - regs.h.ah = 0x4E; /* Find 1st file meeting path */ - regs.x.dx = (unsigned)path; - regs.x.cx = FILEATTR; - intdos(®s, ®s); - return(regs.x.ax); /* Return error code */ -#else - if (currdir != NULL) { - closedir(currdir); - currdir = NULL; - } - splitpath(path,NULL,searchdir,searchname,searchext); - if (searchdir[0]=='\0') { - currdir = opendir("."); - } else { - currdir = opendir(searchdir); - } - if (currdir==NULL) { - return -1; - } else { - return fr_findnext(); - } -#endif -} - -int fr_findnext() /* Find next file (or subdir) meeting above path/filespec */ -{ -#ifndef XFRACT - union REGS regs; - regs.h.ah = 0x4F; /* Find next file meeting path */ - regs.x.dx = (unsigned)&DTA; - intdos(®s, ®s); - return(regs.x.ax); -#else -#ifdef DIRENT - struct dirent *dirEntry; -#else - struct direct *dirEntry; -#endif - struct stat sbuf; - char thisname[FILE_MAX_PATH]; - char tmpname[FILE_MAX_PATH]; - char thisext[FILE_MAX_EXT]; - while (1) { - dirEntry = readdir(currdir); - if (dirEntry == NULL) { - closedir(currdir); - currdir = NULL; - return -1; - } else if (dirEntry->d_ino != 0) { - splitpath(dirEntry->d_name,NULL,NULL,thisname,thisext); - strncpy(DTA.filename,dirEntry->d_name,13); - DTA.filename[12]='\0'; - strcpy(tmpname,searchdir); - strcat(tmpname,dirEntry->d_name); - stat(tmpname,&sbuf); - DTA.size = sbuf.st_size; - if ((sbuf.st_mode&S_IFMT)==S_IFREG && - (searchname[0]=='*' || strcmp(searchname,thisname)==0) && - (searchext[0]=='*' || strcmp(searchext,thisext)==0)) { - DTA.attribute = 0; - return 0; - } - else if (((sbuf.st_mode&S_IFMT)==S_IFDIR) && - ((searchname[0]=='*' || searchext[0]=='*') || - (strcmp(searchname,thisname)==0))) { - DTA.attribute = SUBDIR; - return 0; - } - } - } -#endif -} -#endif /* !_WIN32 */ - -#if 0 -void heap_sort(void *ra1, int n, unsigned sz, int (__cdecl *fct)(VOIDPTR arg1, VOIDPTR arg2)) -{ - int ll,j,ir,i; - void *rra; - char *ra; - ra = (char *)ra1; - ra -= sz; - ll=(n>>1)+1; - ir=n; - - while (1) - { - if (ll>1) - rra = *((char **)(ra+(--ll)*sz)); - else - { - rra = *((char * *)(ra+ir*sz)); - *((char * *)(ra+ir*sz))=*((char * *)(ra+sz)); - if (--ir == 1) - { - *((char * *)(ra+sz))=rra; - return; - } - } - i = ll; - j = ll <<1; - while (j <= ir) - { - if (jname, DTA.filename, 13); - choices[filecount]->name[12] = 0; - choices[filecount]->type = 1; - strcpy(choices[filecount]->full_name, DTA.filename); - dircount++; - if (strcmp(DTA.filename, "..") == 0) - { - notroot = 1; - } - } - out = fr_findnext(); - } - tmpmask[masklen] = 0; - if (file_template[0]) - { - makepath(tmpmask, drive, dir, fname, ext); - } - do - { - if (numtemplates > 1) - { - strcpy(&(tmpmask[masklen]), masks[j]); - } - out = fr_findfirst(tmpmask); - while (out == 0 && filecount < MAXNUMFILES) - { - if (!(DTA.attribute & SUBDIR)) - { - if (rds) - { - putstringcenter(2, 0, 80, C_GENERAL_INPUT, DTA.filename); - - splitpath(DTA.filename, NULL, NULL, fname, ext); - /* just using speedstr as a handy buffer */ - makepath(speedstr, drive, dir, fname, ext); - strncpy(choices[++filecount]->name, DTA.filename, 13); - choices[filecount]->type = 0; - } - else - { - strncpy(choices[++filecount]->name, DTA.filename, 13); - choices[filecount]->type = 0; - strcpy(choices[filecount]->full_name, DTA.filename); - } - } - out = fr_findnext(); - } - } while (++j < numtemplates); - if (++filecount == 0) - { - strcpy(choices[filecount]->name, "*nofiles*"); - choices[filecount]->type = 0; - ++filecount; - } - - strcpy(instr, "Press " FK_F6 " for default directory, " FK_F4 " to toggle sort "); - if (dosort) - { - strcat(instr, "off"); - shell_sort(&choices, filecount, sizeof(CHOICE *), lccompare); /* sort file list */ - } - else - { - strcat(instr, "on"); - } - if (notroot == 0 && dir[0] && dir[0] != SLASHC) /* must be in root directory */ - { - splitpath(tmpmask, drive, dir, fname, ext); - strcpy(dir, SLASH); - makepath(tmpmask, drive, dir, fname, ext); - } - if (numtemplates > 1) - { - strcat(tmpmask, " "); - strcat(tmpmask, masks[0]); - } - sprintf(temp1, "%s\nTemplate: %s", hdg, tmpmask); - strcpy(speedstr, filename); - if (speedstr[0] == 0) - { - for (i = 0; i < filecount; i++) /* find first file */ - { - if (choices[i]->type == 0) - { - break; - } - } - if (i >= filecount) - { - i = 0; - } - } - - - i = fullscreen_choice(CHOICE_INSTRUCTIONS | (dosort ? 0 : CHOICE_NOT_SORTED), - temp1, NULL, instr, filecount, (char **) choices, - attributes, 5, 99, 12, i, NULL, speedstr, filename_speedstr, check_f6_key); - if (i == -FIK_F4) - { - dosort = 1 - dosort; - goto restart; - } - if (i == -FIK_F6) - { - static int lastdir = 0; - if (lastdir == 0) - { - strcpy(dir, fract_dir1); - } - else - { - strcpy(dir, fract_dir2); - } - fix_dirname(dir); - makepath(flname, drive, dir, "", ""); - lastdir = 1 - lastdir; - goto restart; - } - if (i < 0) - { - /* restore filename */ - strcpy(flname, old_flname); - return -1; - } - if (speedstr[0] == 0 || speedstate == MATCHING) - { - if (choices[i]->type) - { - if (strcmp(choices[i]->name, "..") == 0) /* go up a directory */ - { - if (strcmp(dir, DOTSLASH) == 0) - { - strcpy(dir, DOTDOTSLASH); - } - else - { - char *s = strrchr(dir, SLASHC); - if (s != NULL) /* trailing slash */ - { - *s = 0; - s = strrchr(dir, SLASHC); - if (s != NULL) - { - *(s + 1) = 0; - } - } - } - } - else /* go down a directory */ - { - strcat(dir, choices[i]->full_name); - } - fix_dirname(dir); - makepath(flname, drive, dir, "", ""); - goto restart; - } - splitpath(choices[i]->full_name, NULL, NULL, fname, ext); - makepath(flname, drive, dir, fname, ext); - } - else - { - if (speedstate == SEARCHPATH - && strchr(speedstr, '*') == 0 && strchr(speedstr, '?') == 0 - && ((fr_findfirst(speedstr) == 0 - && (DTA.attribute & SUBDIR))|| strcmp(speedstr, SLASH) == 0)) /* it is a directory */ - { - speedstate = TEMPLATE; - } - - if (speedstate == TEMPLATE) - { - /* extract from tempstr the pathname and template information, - being careful not to overwrite drive and directory if not - newly specified */ - char drive1[FILE_MAX_DRIVE]; - char dir1[FILE_MAX_DIR]; - char fname1[FILE_MAX_FNAME]; - char ext1[FILE_MAX_EXT]; - splitpath(speedstr, drive1, dir1, fname1, ext1); - if (drive1[0]) - { - strcpy(drive, drive1); - } - if (dir1[0]) - { - strcpy(dir, dir1); - } - makepath(flname, drive, dir, fname1, ext1); - if (strchr(fname1, '*') || strchr(fname1, '?') || - strchr(ext1, '*') || strchr(ext1, '?')) - { - makepath(file_template, "", "", fname1, ext1); - } - else if (isadirectory(flname)) - { - fix_dirname(flname); - } - goto restart; - } - else /* speedstate == SEARCHPATH */ - { - char fullpath[FILE_MAX_DIR]; - findpath(speedstr, fullpath); - if (fullpath[0]) - { - strcpy(flname, fullpath); - } - else - { /* failed, make diagnostic useful: */ - strcpy(flname, speedstr); - if (strchr(speedstr, SLASHC) == NULL) - { - splitpath(speedstr, NULL, NULL, fname, ext); - makepath(flname, drive, dir, fname, ext); - } - } - } - } - makepath(browsename, "", "", fname, ext); - return 0; -} - -#ifdef __CLINT__ -#pragma argsused -#endif - -static int check_f6_key(int curkey,int choice) -{ /* choice is dummy used by other routines called by fullscreen_choice() */ - choice = 0; /* to suppress warning only */ - if (curkey == FIK_F6) - return 0-FIK_F6; - else if (curkey == FIK_F4) - return 0-FIK_F4; - return 0; -} - -static int filename_speedstr(int row, int col, int vid, - char *speedstring, int speed_match) -{ - char *prompt; - if ( strchr(speedstring,':') - || strchr(speedstring,'*') || strchr(speedstring,'*') - || strchr(speedstring,'?')) { - speedstate = TEMPLATE; /* template */ - prompt = "File Template"; - } - else if (speed_match) { - speedstate = SEARCHPATH; /* does not match list */ - prompt = "Search Path for"; - } - else { - speedstate = MATCHING; - prompt = speed_prompt; - } - driver_put_string(row,col,vid,prompt); - return((int) strlen(prompt)); -} - -#if !defined(_WIN32) -int isadirectory(char *s) -{ - int len; - char sv; -#ifdef _MSC_VER - unsigned attrib = 0; -#endif - if (strchr(s,'*') || strchr(s,'?')) - return(0); /* for my purposes, not a directory */ - - len = (int) strlen(s); - if (len > 0) - sv = s[len-1]; /* last char */ - else - sv = 0; - -#ifdef _MSC_VER - if (_dos_getfileattr(s, &attrib) == 0 && ((attrib&_A_SUBDIR) != 0)) - { - return(1); /* not a directory or doesn't exist */ - } - else if (sv == SLASHC) - { - /* strip trailing slash and try again */ - s[len-1] = 0; - if (_dos_getfileattr(s, &attrib) == 0 && ((attrib&_A_SUBDIR) != 0)) - { - s[len-1] = sv; - return(1); - } - s[len-1] = sv; - } - return(0); -#else - if (fr_findfirst(s) != 0) /* couldn't find it */ - { - /* any better ideas?? */ - if (sv == SLASHC) /* we'll guess it is a directory */ - return(1); - else - return(0); /* no slashes - we'll guess it's a file */ - } - else if ((DTA.attribute & SUBDIR) != 0) { - if (sv == SLASHC) { - /* strip trailing slash and try again */ - s[len-1] = 0; - if (fr_findfirst(s) != 0) /* couldn't find it */ - return(0); - else if ((DTA.attribute & SUBDIR) != 0) - return(1); /* we're SURE it's a directory */ - else - return(0); - } else - return(1); /* we're SURE it's a directory */ - } - return(0); -#endif -} -#endif - -#ifndef XFRACT /* This routine moved to unix.c so we can use it in hc.c */ - -int splitpath(char *file_template,char *drive,char *dir,char *fname,char *ext) -{ - int length; - int len; - int offset; - char *tmp; - if (drive) - { - drive[0] = 0; - } - if (dir) - { - dir[0] = 0; - } - if (fname) - { - fname[0] = 0; - } - if (ext) - { - ext[0] = 0; - } - - length = (int) strlen(file_template); - if (length == 0) - { - return(0); - } - - offset = 0; - - /* get drive */ - if (length >= 2) - { - if (file_template[1] == ':') - { - if (drive) - { - drive[0] = file_template[offset++]; - drive[1] = file_template[offset++]; - drive[2] = 0; - } - else - { - offset++; - offset++; - } - } - } - - /* get dir */ - if (offset < length) - { - tmp = strrchr(file_template,SLASHC); - if (tmp) - { - tmp++; /* first character after slash */ - len = (int) (tmp - (char *)&file_template[offset]); - if (len >= 0 && len < FILE_MAX_DIR && dir) - { - strncpy(dir,&file_template[offset],min(len,FILE_MAX_DIR)); - } - if (len < FILE_MAX_DIR && dir) - { - dir[len] = 0; - } - offset += len; - } - } - else - { - return(0); - } - - /* get fname */ - if (offset < length) - { - tmp = strrchr(file_template,'.'); - if (tmp < strrchr(file_template,SLASHC) || tmp < strrchr(file_template,':')) - { - tmp = 0; /* in this case the '.' must be a directory */ - } - if (tmp) - { - /* tmp++; */ /* first character past "." */ - len = (int) (tmp - (char *)&file_template[offset]); - if ((len > 0) && (offset+len < length) && fname) - { - strncpy(fname,&file_template[offset],min(len,FILE_MAX_FNAME)); - if (len < FILE_MAX_FNAME) - { - fname[len] = 0; - } - else - { - fname[FILE_MAX_FNAME-1] = 0; - } - } - offset += len; - if ((offset < length) && ext) - { - strncpy(ext,&file_template[offset],FILE_MAX_EXT); - ext[FILE_MAX_EXT-1] = 0; - } - } - else if ((offset < length) && fname) - { - strncpy(fname,&file_template[offset],FILE_MAX_FNAME); - fname[FILE_MAX_FNAME-1] = 0; - } - } - return 0; -} -#endif - -int makepath(char *template_str, char *drive, char *dir, char *fname, char *ext) -{ - if (template_str) - *template_str = 0; - else - return(-1); -#ifndef XFRACT - if (drive) - strcpy(template_str,drive); -#endif - if (dir) - strcat(template_str,dir); - if (fname) - strcat(template_str,fname); - if (ext) - strcat(template_str,ext); - return 0; -} - - -/* fix up directory names */ -void fix_dirname(char *dirname) -{ - int length = (int) strlen(dirname); /* index of last character */ - - /* make sure dirname ends with a slash */ - if (length > 0) - if (dirname[length-1] == SLASHC) - return; - strcat(dirname,SLASH); -} - -static void dir_name(char *target, char *dir, char *name) -{ - *target = 0; - if (*dir != 0) - strcpy(target,dir); - strcat(target,name); -} - -/* removes file in dir directory */ -int dir_remove(char *dir,char *filename) -{ - char tmp[FILE_MAX_PATH]; - dir_name(tmp,dir,filename); - return(remove(tmp)); -} - -/* fopens file in dir directory */ -FILE *dir_fopen(char *dir, char *filename, char *mode ) -{ - char tmp[FILE_MAX_PATH]; - dir_name(tmp,dir,filename); - return(fopen(tmp,mode)); -} - -/* - See if double value was changed by input screen. Problem is that the - conversion from double to string and back can make small changes - in the value, so will it twill test as "different" even though it - is not -*/ -int cmpdbl(double old, double new) -{ - char buf[81]; - struct fullscreenvalues val; - - /* change the old value with the same torture the new value had */ - val.type = 'd'; /* most values on this screen are type d */ - val.uval.dval = old; - prompt_valuestring(buf,&val); /* convert "old" to string */ - - old = atof(buf); /* convert back */ - return(fabs(old-new)xmin; - xxmax = curfractalspecific->xmax; - yy3rd = yymin = curfractalspecific->ymin; - yymax = curfractalspecific->ymax; - if (viewcrop && finalaspectratio != screenaspect) - aspectratio_crop(screenaspect,finalaspectratio); - if (bf_math != 0) - fractal_floattobf(); - goto gc_loop; - } - - if (cmag) { - if ( cmpdbl(Xctr , values[0].uval.dval) - || cmpdbl(Yctr , values[1].uval.dval) - || cmpdbl((double)Magnification, values[2].uval.dval) - || cmpdbl(Xmagfactor , values[3].uval.dval) - || cmpdbl(Rotation , values[4].uval.dval) - || cmpdbl(Skew , values[5].uval.dval)) - { - Xctr = values[0].uval.dval; - Yctr = values[1].uval.dval; - Magnification = values[2].uval.dval; - Xmagfactor = values[3].uval.dval; - Rotation = values[4].uval.dval; - Skew = values[5].uval.dval; - if (Xmagfactor == 0) - Xmagfactor = 1; - cvtcorners(Xctr, Yctr, Magnification, Xmagfactor, Rotation, Skew); - } - } - - else { - if (drawmode == 'l') { - nump = 1; - xxmin = values[nump++].uval.dval; - yymax = values[nump++].uval.dval; - nump++; - xxmax = values[nump++].uval.dval; - yymin = values[nump++].uval.dval; - } else { - nump = 1; - xxmin = values[nump++].uval.dval; - yymax = values[nump++].uval.dval; - nump++; - xxmax = values[nump++].uval.dval; - yymin = values[nump++].uval.dval; - nump++; - xx3rd = values[nump++].uval.dval; - yy3rd = values[nump++].uval.dval; - if (xx3rd == 0 && yy3rd == 0) { - xx3rd = xxmin; - yy3rd = yymin; - } - } - } - - if (prompt_ret == FIK_F7 && drawmode != 'l') { /* toggle corners/center-mag mode */ - if (usemag == 0) - { - cvtcentermag(&Xctr, &Yctr, &Magnification, &Xmagfactor, &Rotation, &Skew); - usemag = 1; - } - else - usemag = 0; - goto gc_loop; - } - - if (!cmpdbl(oxxmin,xxmin) && !cmpdbl(oxxmax,xxmax) && !cmpdbl(oyymin,yymin) && - !cmpdbl(oyymax,yymax) && !cmpdbl(oxx3rd,xx3rd) && !cmpdbl(oyy3rd,yy3rd)) - { - /* no change, restore values to avoid drift */ - xxmin = oxxmin; xxmax = oxxmax; - yymin = oyymin; yymax = oyymax; - xx3rd = oxx3rd; yy3rd = oyy3rd; - return 0; - } - else - return(1); -} - -static int get_screen_corners(void) -{ - struct fullscreenvalues values[15]; - char *prompts[15]; - char xprompt[] = " X"; - char yprompt[] = " Y"; - char zprompt[] = " Z"; - int i,nump,prompt_ret; - int cmag; - double Xctr,Yctr; - LDBL Magnification; /* LDBL not really needed here, but used to match function parameters */ - double Xmagfactor,Rotation,Skew; - BYTE ousemag; - double oxxmin,oxxmax,oyymin,oyymax,oxx3rd,oyy3rd; - double svxxmin,svxxmax,svyymin,svyymax,svxx3rd,svyy3rd; - int oldhelpmode; - - oldhelpmode = helpmode; - ousemag = usemag; - - svxxmin = xxmin; /* save these for later since cvtcorners modifies them */ - svxxmax = xxmax; /* and we need to set them for cvtcentermag to work */ - svxx3rd = xx3rd; - svyymin = yymin; - svyymax = yymax; - svyy3rd = yy3rd; - - if (!set_orbit_corners && !keep_scrn_coords) { - oxmin = xxmin; - oxmax = xxmax; - ox3rd = xx3rd; - oymin = yymin; - oymax = yymax; - oy3rd = yy3rd; - } - - oxxmin = oxmin; oxxmax = oxmax; - oyymin = oymin; oyymax = oymax; - oxx3rd = ox3rd; oyy3rd = oy3rd; - - xxmin = oxmin; xxmax = oxmax; - yymin = oymin; yymax = oymax; - xx3rd = ox3rd; yy3rd = oy3rd; - -gsc_loop: - for (i = 0; i < 15; ++i) - values[i].type = 'd'; /* most values on this screen are type d */ - cmag = usemag; - cvtcentermag(&Xctr, &Yctr, &Magnification, &Xmagfactor, &Rotation, &Skew); - - nump = -1; - if (cmag) { - prompts[++nump]= "Center X"; - values[nump].uval.dval = Xctr; - prompts[++nump]= "Center Y"; - values[nump].uval.dval = Yctr; - prompts[++nump]= "Magnification"; - values[nump].uval.dval = (double)Magnification; - prompts[++nump]= "X Magnification Factor"; - values[nump].uval.dval = Xmagfactor; - prompts[++nump]= "Rotation Angle (degrees)"; - values[nump].uval.dval = Rotation; - prompts[++nump]= "Skew Angle (degrees)"; - values[nump].uval.dval = Skew; - prompts[++nump]= ""; - values[nump].type = '*'; - prompts[++nump]= "Press "FK_F7" to switch to \"corners\" mode"; - values[nump].type = '*'; - } else { - prompts[++nump]= "Top-Left Corner"; - values[nump].type = '*'; - prompts[++nump] = xprompt; - values[nump].uval.dval = oxmin; - prompts[++nump] = yprompt; - values[nump].uval.dval = oymax; - prompts[++nump]= "Bottom-Right Corner"; - values[nump].type = '*'; - prompts[++nump] = xprompt; - values[nump].uval.dval = oxmax; - prompts[++nump] = yprompt; - values[nump].uval.dval = oymin; - if (oxmin == ox3rd && oymin == oy3rd) - ox3rd = oy3rd = 0; - prompts[++nump]= "Bottom-left (zeros for top-left X, bottom-right Y)"; - values[nump].type = '*'; - prompts[++nump] = xprompt; - values[nump].uval.dval = ox3rd; - prompts[++nump] = yprompt; - values[nump].uval.dval = oy3rd; - prompts[++nump]= "Press "FK_F7" to switch to \"center-mag\" mode"; - values[nump].type = '*'; - } - - prompts[++nump]= "Press "FK_F4" to reset to type default values"; - values[nump].type = '*'; - - oldhelpmode = helpmode; - helpmode = HELPSCRNCOORDS; - prompt_ret = fullscreen_prompt("Screen Coordinates",nump+1, prompts, values, 0x90, NULL); - helpmode = oldhelpmode; - - if (prompt_ret < 0) { - usemag = ousemag; - oxmin = oxxmin; oxmax = oxxmax; - oymin = oyymin; oymax = oyymax; - ox3rd = oxx3rd; oy3rd = oyy3rd; - /* restore corners */ - xxmin = svxxmin; xxmax = svxxmax; - yymin = svyymin; yymax = svyymax; - xx3rd = svxx3rd; yy3rd = svyy3rd; - return(-1); - } - - if (prompt_ret == FIK_F4) { /* reset to type defaults */ - ox3rd = oxmin = curfractalspecific->xmin; - oxmax = curfractalspecific->xmax; - oy3rd = oymin = curfractalspecific->ymin; - oymax = curfractalspecific->ymax; - xxmin = oxmin; xxmax = oxmax; - yymin = oymin; yymax = oymax; - xx3rd = ox3rd; yy3rd = oy3rd; - if (viewcrop && finalaspectratio != screenaspect) - aspectratio_crop(screenaspect,finalaspectratio); - - oxmin = xxmin; oxmax = xxmax; - oymin = yymin; oymax = yymax; - ox3rd = xxmin; oy3rd = yymin; - goto gsc_loop; - } - - if (cmag) { - if ( cmpdbl(Xctr , values[0].uval.dval) - || cmpdbl(Yctr , values[1].uval.dval) - || cmpdbl((double)Magnification, values[2].uval.dval) - || cmpdbl(Xmagfactor , values[3].uval.dval) - || cmpdbl(Rotation , values[4].uval.dval) - || cmpdbl(Skew , values[5].uval.dval)) - { - Xctr = values[0].uval.dval; - Yctr = values[1].uval.dval; - Magnification = values[2].uval.dval; - Xmagfactor = values[3].uval.dval; - Rotation = values[4].uval.dval; - Skew = values[5].uval.dval; - if (Xmagfactor == 0) - Xmagfactor = 1; - cvtcorners(Xctr, Yctr, Magnification, Xmagfactor, Rotation, Skew); - /* set screen corners */ - oxmin = xxmin; oxmax = xxmax; - oymin = yymin; oymax = yymax; - ox3rd = xx3rd; oy3rd = yy3rd; - } - } - else { - nump = 1; - oxmin = values[nump++].uval.dval; - oymax = values[nump++].uval.dval; - nump++; - oxmax = values[nump++].uval.dval; - oymin = values[nump++].uval.dval; - nump++; - ox3rd = values[nump++].uval.dval; - oy3rd = values[nump++].uval.dval; - if (ox3rd == 0 && oy3rd == 0) { - ox3rd = oxmin; - oy3rd = oymin; - } - } - - if (prompt_ret == FIK_F7) { /* toggle corners/center-mag mode */ - if (usemag == 0) - { - cvtcentermag(&Xctr, &Yctr, &Magnification, &Xmagfactor, &Rotation, &Skew); - usemag = 1; - } - else - usemag = 0; - goto gsc_loop; - } - - if (!cmpdbl(oxxmin,oxmin) && !cmpdbl(oxxmax,oxmax) && !cmpdbl(oyymin,oymin) && - !cmpdbl(oyymax,oymax) && !cmpdbl(oxx3rd,ox3rd) && !cmpdbl(oyy3rd,oy3rd)) - { - /* no change, restore values to avoid drift */ - oxmin = oxxmin; oxmax = oxxmax; - oymin = oyymin; oymax = oyymax; - ox3rd = oxx3rd; oy3rd = oyy3rd; - /* restore corners */ - xxmin = svxxmin; xxmax = svxxmax; - yymin = svyymin; yymax = svyymax; - xx3rd = svxx3rd; yy3rd = svyy3rd; - return 0; - } - else { - set_orbit_corners = 1; - keep_scrn_coords = 1; - /* restore corners */ - xxmin = svxxmin; xxmax = svxxmax; - yymin = svyymin; yymax = svyymax; - xx3rd = svxx3rd; yy3rd = svyy3rd; - return(1); - } -} - -/* get browse parameters , called from fractint.c and loadfile.c - returns 3 if anything changes. code pinched from get_view_params */ - -int get_browse_params() -{ - char *choices[10]; - int oldhelpmode; - struct fullscreenvalues uvalues[25]; - int i, k; - int old_autobrowse,old_brwschecktype,old_brwscheckparms,old_doublecaution; - int old_minbox; - double old_toosmall; - char old_browsemask[13]; - - old_autobrowse = autobrowse; - old_brwschecktype = brwschecktype; - old_brwscheckparms = brwscheckparms; - old_doublecaution = doublecaution; - old_minbox = minbox; - old_toosmall = toosmall; - strcpy(old_browsemask,browsemask); - -get_brws_restart: - /* fill up the previous values arrays */ - k = -1; - - choices[++k] = "Autobrowsing? (y/n)"; - uvalues[k].type = 'y'; - uvalues[k].uval.ch.val = autobrowse; - - choices[++k] = "Ask about GIF video mode? (y/n)"; - uvalues[k].type = 'y'; - uvalues[k].uval.ch.val = askvideo; - - choices[++k] = "Check fractal type? (y/n)"; - uvalues[k].type = 'y'; - uvalues[k].uval.ch.val = brwschecktype; - - choices[++k] = "Check fractal parameters (y/n)"; - uvalues[k].type = 'y'; - uvalues[k].uval.ch.val = brwscheckparms; - - choices[++k] = "Confirm file deletes (y/n)"; - uvalues[k].type='y'; - uvalues[k].uval.ch.val = doublecaution; - - choices[++k] = "Smallest window to display (size in pixels)"; - uvalues[k].type = 'f'; - uvalues[k].uval.dval = toosmall; - - choices[++k] = "Smallest box size shown before crosshairs used (pix)"; - uvalues[k].type = 'i'; - uvalues[k].uval.ival = minbox; - choices[++k] = "Browse search filename mask "; - uvalues[k].type = 's'; - strcpy(uvalues[k].uval.sval,browsemask); - - choices[++k] = ""; - uvalues[k].type = '*'; - - choices[++k] = "Press "FK_F4" to reset browse parameters to defaults."; - uvalues[k].type = '*'; - - oldhelpmode = helpmode; /* this prevents HELP from activating */ - helpmode = HELPBRWSPARMS; - i = fullscreen_prompt("Browse ('L'ook) Mode Options",k+1,choices,uvalues,16,NULL); - helpmode = oldhelpmode; /* re-enable HELP */ - if (i < 0) { - return(0); - } - - if (i == FIK_F4) { - toosmall = 6; - autobrowse = FALSE; - askvideo = TRUE; - brwscheckparms = TRUE; - brwschecktype = TRUE; - doublecaution = TRUE; - minbox = 3; - strcpy(browsemask,"*.gif"); - goto get_brws_restart; - } - - /* now check out the results (*hopefully* in the same order ) */ - k = -1; - - autobrowse = uvalues[++k].uval.ch.val; - - askvideo = uvalues[++k].uval.ch.val; - - brwschecktype = (char)uvalues[++k].uval.ch.val; - - brwscheckparms = (char)uvalues[++k].uval.ch.val; - - doublecaution = uvalues[++k].uval.ch.val; - - toosmall = uvalues[++k].uval.dval; - if (toosmall < 0 ) toosmall = 0 ; - - minbox = uvalues[++k].uval.ival; - if (minbox < 1 ) minbox = 1; - if (minbox > 10) minbox = 10; - - strcpy(browsemask,uvalues[++k].uval.sval); - - i = 0; - if (autobrowse != old_autobrowse || - brwschecktype != old_brwschecktype || - brwscheckparms != old_brwscheckparms || - doublecaution != old_doublecaution || - toosmall != old_toosmall || - minbox != old_minbox || - !stricmp(browsemask,old_browsemask) ) - i = -3; - - if (evolving) { /* can't browse */ - autobrowse = 0; - i = 0; - } - - return(i); -} - -/* merge existing full path with new one */ -/* attempt to detect if file or directory */ - -#define ATFILENAME 0 -#define SSTOOLSINI 1 -#define ATCOMMANDINTERACTIVE 2 -#define ATFILENAMESETNAME 3 - -#define GETPATH (mode < 2) - -#ifndef XFRACT -#include -#endif - -/* copies the proposed new filename to the fullpath variable */ -/* does not copy directories for PAR files (modes 2 and 3) */ -/* attempts to extract directory and test for existence (modes 0 and 1) */ -int merge_pathnames(char *oldfullpath, char *newfilename, int mode) -{ - int isadir = 0; - int isafile = 0; - int len; - char drive[FILE_MAX_DRIVE]; - char dir[FILE_MAX_DIR]; - char fname[FILE_MAX_FNAME]; - char ext[FILE_MAX_EXT]; - char temp_path[FILE_MAX_PATH]; - - char drive1[FILE_MAX_DRIVE]; - char dir1[FILE_MAX_DIR]; - char fname1[FILE_MAX_FNAME]; - char ext1[FILE_MAX_EXT]; - - /* no dot or slash so assume a file */ - if (strchr(newfilename,'.')==NULL && strchr(newfilename,SLASHC) == NULL) - isafile=1; - if ((isadir = isadirectory(newfilename)) != 0) - fix_dirname(newfilename); -#if 0 - /* if slash by itself, it's a directory */ - if (strcmp(newfilename,SLASH)==0) - isadir = 1; -#endif -#ifndef XFRACT - /* if drive, colon, slash, is a directory */ - if ((int) strlen(newfilename) == 3 && - newfilename[1] == ':' && - newfilename[2] == SLASHC) - isadir = 1; - /* if drive, colon, with no slash, is a directory */ - if ((int) strlen(newfilename) == 2 && - newfilename[1] == ':') { - newfilename[2] = SLASHC; - newfilename[3] = 0; - isadir = 1; - } - /* if dot, slash, '0', its the current directory, set up full path */ - if (newfilename[0] == '.' && - newfilename[1] == SLASHC && newfilename[2] == 0) { - temp_path[0] = (char)('a' + _getdrive() - 1); - temp_path[1] = ':'; - temp_path[2] = 0; - expand_dirname(newfilename,temp_path); - strcat(temp_path,newfilename); - strcpy(newfilename,temp_path); - isadir = 1; - } - /* if dot, slash, its relative to the current directory, set up full path */ - if (newfilename[0] == '.' && - newfilename[1] == SLASHC) { - int len, test_dir=0; - temp_path[0] = (char)('a' + _getdrive() - 1); - temp_path[1] = ':'; - temp_path[2] = 0; - if (strrchr(newfilename,'.') == newfilename) - test_dir = 1; /* only one '.' assume its a directory */ - expand_dirname(newfilename,temp_path); - strcat(temp_path,newfilename); - strcpy(newfilename,temp_path); - if (!test_dir) { - len = (int) strlen(newfilename); - newfilename[len-1] = 0; /* get rid of slash added by expand_dirname */ - } - } -#else - findpath(newfilename,temp_path); - strcpy(newfilename,temp_path); -#endif - /* check existence */ - if (isadir==0 || isafile==1) - { - if (fr_findfirst(newfilename) == 0) { - if (DTA.attribute & SUBDIR) /* exists and is dir */ - { - fix_dirname(newfilename); /* add trailing slash */ - isadir = 1; - isafile = 0; - } - else - isafile = 1; - } - } - - splitpath(newfilename,drive,dir,fname,ext); - splitpath(oldfullpath,drive1,dir1,fname1,ext1); - if ((int) strlen(drive) != 0 && GETPATH) - strcpy(drive1,drive); - if ((int) strlen(dir) != 0 && GETPATH) - strcpy(dir1,dir); - if ((int) strlen(fname) != 0) - strcpy(fname1,fname); - if ((int) strlen(ext) != 0) - strcpy(ext1,ext); - if (isadir == 0 && isafile == 0 && GETPATH) - { - makepath(oldfullpath,drive1,dir1,NULL,NULL); - len = (int) strlen(oldfullpath); - if (len > 0) - { - char save; - /* strip trailing slash */ - save = oldfullpath[len-1]; - if (save == SLASHC) - oldfullpath[len-1] = 0; - if (access(oldfullpath,0)) - isadir = -1; - oldfullpath[len-1] = save; - } - } - makepath(oldfullpath,drive1,dir1,fname1,ext1); - return(isadir); -} - -/* extract just the filename/extension portion of a path */ -void extract_filename(char *target, char *source) -{ - char fname[FILE_MAX_FNAME]; - char ext[FILE_MAX_EXT]; - splitpath(source,NULL,NULL,fname,ext); - makepath(target,"","",fname,ext); -} - -/* tells if filename has extension */ -/* returns pointer to period or NULL */ -char *has_ext(char *source) -{ - char fname[FILE_MAX_FNAME]; - char ext[FILE_MAX_EXT]; - char *ret = NULL; - splitpath(source,NULL,NULL,fname,ext); - if (ext != NULL) - if (*ext != 0) - ret = strrchr(source,'.'); - return(ret); -} - - -/* I tried heap sort also - this is faster! */ -void shell_sort(void *v1, int n, unsigned sz, int (__cdecl *fct)(VOIDPTR arg1,VOIDPTR arg2)) -{ - int gap,i,j; - void *temp; - char *v; - v = (char *)v1; - for (gap = n/2; gap > 0; gap /= 2) - for (i = gap; i=0; j -= gap) - { - if (fct((char **)(v+j*sz),(char **)(v+(j+gap)*sz)) <= 0) - break; - temp = *(char **)(v+j*sz); - *(char **)(v+j*sz) = *(char **)(v+(j+gap)*sz); - *(char **)(v+(j+gap)*sz) = temp; - } -} diff --git a/fractint/common/realdos.c b/fractint/common/realdos.c deleted file mode 100644 index 4861dde78..000000000 --- a/fractint/common/realdos.c +++ /dev/null @@ -1,2007 +0,0 @@ -/* - Miscellaneous C routines used only in DOS Fractint. -*/ - -#include -#ifndef XFRACT -#include -#include -#endif -#include -#include -#include -#include - - /* see Fractint.c for a description of the "include" hierarchy */ -#include "port.h" -#include "prototyp.h" -#include "fractype.h" -#include "helpdefs.h" -#include "drivers.h" - -static int menu_checkkey(int curkey,int choice); - -/* uncomment following for production version */ -/* -#define PRODUCTION -*/ -int g_release = 2099; /* this has 2 implied decimals; increment it every synch */ -int g_patch_level = 8; /* patchlevel for DOS version */ -#ifdef XFRACT -int xrelease=304; -#endif - -/* int stopmsg(flags,message) displays message and waits for a key: - message should be a max of 9 lines with \n's separating them; - no leading or trailing \n's in message; - no line longer than 76 chars for best appearance; - flag options: - &1 if already in text display mode, stackscreen is not called - and message is displayed at (12,0) instead of (4,0) - &2 if continue/cancel indication is to be returned; - when not set, "Any key to continue..." is displayed - when set, "Escape to cancel, any other key to continue..." - -1 is returned for cancel, 0 for continue - &4 set to suppress buzzer - &8 for Fractint for Windows & parser - use a fixed pitch font - &16 for info only message (green box instead of red in DOS vsn) - */ -int stopmsg (int flags, char *msg) -{ - int ret,toprow,color,savelookatmouse; - static unsigned char batchmode = 0; - if (debugflag != 0 || initbatch >= 1) - { - static FILE *fp = NULL; - if (fp==NULL && initbatch == 0) - fp=dir_fopen(workdir,"stopmsg.txt","w"); - else - fp=dir_fopen(workdir,"stopmsg.txt","a"); - if (fp != NULL) - fprintf(fp,"%s\n",msg); - fclose(fp); - } - if (first_init) { /* & cmdfiles hasn't finished 1st try */ -#ifdef XFRACT - driver_set_for_text(); - driver_buzzer(BUZZER_ERROR); - driver_put_string(0,0,15, "*** Error during startup:"); - driver_put_string(2,0,15,msg); - driver_move_cursor(8,0); -#if !defined(WIN32) - sleep(1); -#endif - close_drivers(); - exit(1); -#else - printf("%s\n",msg); - dopause(1); /* pause deferred until after cmdfiles */ - return(0); -#endif - } - if (initbatch >= 1 || batchmode) { /* in batch mode */ - initbatch = 4; /* used to set errorlevel */ - batchmode = 1; /* fixes *second* stopmsg in batch mode bug */ - return (-1); - } - ret = 0; - savelookatmouse = lookatmouse; - lookatmouse = -13; - if ((flags & STOPMSG_NO_STACK)) - blankrows(toprow=12,10,7); - else { - driver_stack_screen(); - toprow = 4; - driver_move_cursor(4,0); - } - g_text_cbase = 2; /* left margin is 2 */ - driver_put_string(toprow,0,7,msg); - if (flags & STOPMSG_CANCEL) - driver_put_string(g_text_row+2,0,7, "Escape to cancel, any other key to continue..."); - else - driver_put_string(g_text_row+2,0,7, "Any key to continue..."); - g_text_cbase = 0; /* back to full line */ - color = (flags & STOPMSG_INFO_ONLY) ? C_STOP_INFO : C_STOP_ERR; - driver_set_attr(toprow,0,color,(g_text_row+1-toprow)*80); - driver_hide_text_cursor(); /* cursor off */ - if ((flags & STOPMSG_NO_BUZZER) == 0) - driver_buzzer((flags & STOPMSG_INFO_ONLY) ? 0 : 2); - while (driver_key_pressed()) /* flush any keyahead */ - driver_get_key(); - if (debugflag != 324) - if (getakeynohelp() == FIK_ESC) - ret = -1; - if ((flags & STOPMSG_NO_STACK)) - blankrows(toprow,10,7); - else - driver_unstack_screen(); - lookatmouse = savelookatmouse; - return ret; -} - - -static U16 temptextsave = 0; -static int textxdots,textydots; - -/* texttempmsg(msg) displays a text message of up to 40 characters, waits - for a key press, restores the prior display, and returns (without - eating the key). - It works in almost any video mode - does nothing in some very odd cases - (HCGA hi-res with old bios), or when there isn't 10k of temp mem free. */ -int texttempmsg(char *msgparm) -{ - if (showtempmsg(msgparm)) - { - return -1; - } - - driver_wait_key_pressed(0); /* wait for a keystroke but don't eat it */ - cleartempmsg(); - return 0; -} - -void freetempmsg() -{ - if (temptextsave != 0) - { - MemoryRelease(temptextsave); - } - temptextsave = 0; -} - -int showtempmsg(char *msgparm) -{ - static long size = 0; - char msg[41]; - BYTE buffer[640]; - BYTE *fontptr = NULL; - int i; - int xrepeat = 0; - int yrepeat = 0; - int save_sxoffs, save_syoffs; - - strncpy(msg, msgparm, 40); - msg[40] = 0; /* ensure max message len of 40 chars */ - if (driver_diskp()) /* disk video, screen in text mode, easy */ - { - dvid_status(0, msg); - return 0; - } - if (first_init) /* & cmdfiles hasn't finished 1st try */ - { - printf("%s\n", msg); - return 0; - } - - xrepeat = (sxdots >= 640) ? 2 : 1; - yrepeat = (sydots >= 300) ? 2 : 1; - textxdots = (int) strlen(msg) * xrepeat * 8; - textydots = yrepeat * 8; - - /* worst case needs 10k */ - if (temptextsave != 0) - { - if (size != (long) textxdots * (long) textydots) - { - freetempmsg(); - } - } - size = (long) textxdots * (long) textydots; - save_sxoffs = sxoffs; - save_syoffs = syoffs; - if (g_video_scroll) - { - sxoffs = g_video_start_x; - syoffs = g_video_start_y; - } - else - { - sxoffs = syoffs = 0; - } - if (temptextsave == 0) /* only save screen first time called */ - { - /* TODO: MemoryAlloc, MoveToMemory */ - temptextsave = MemoryAlloc((U16)textxdots, (long)textydots, MEMORY); - if (temptextsave == 0) - { - return -1; /* sorry, message not displayed */ - } - for (i = 0; i < textydots; ++i) - { - get_line(i, 0, textxdots-1, buffer); - MoveToMemory(buffer, (U16)textxdots, 1L, (long)i, temptextsave); - } - } - - find_special_colors(); /* get g_color_dark & g_color_medium set */ - driver_display_string(0, 0, g_color_medium, g_color_dark, msg); - sxoffs = save_sxoffs; - syoffs = save_syoffs; - - return 0; -} - -void cleartempmsg() -{ - BYTE buffer[640]; - int i; - int save_sxoffs, save_syoffs; - if (driver_diskp()) /* disk video, easy */ - { - dvid_status(0, ""); - } - else if (temptextsave != 0) - { - save_sxoffs = sxoffs; - save_syoffs = syoffs; - if (g_video_scroll) - { - sxoffs = g_video_start_x; - syoffs = g_video_start_y; - } - else - { - sxoffs = syoffs = 0; - } - for (i = 0; i < textydots; ++i) - { - MoveFromMemory(buffer, (U16)textxdots, 1L, (long)i, temptextsave); - put_line(i, 0, textxdots-1, buffer); - } - if (using_jiim == 0) /* jiim frees memory with freetempmsg() */ - { - MemoryRelease(temptextsave); - temptextsave = 0; - } - sxoffs = save_sxoffs; - syoffs = save_syoffs; - } -} - -void blankrows(int row,int rows,int attr) -{ - char buf[81]; - memset(buf,' ',80); - buf[80] = 0; - while (--rows >= 0) - driver_put_string(row++,0,attr,buf); -} - -void helptitle() -{ - char msg[MSGLEN],buf[MSGLEN]; - driver_set_clear(); /* clear the screen */ -#ifdef XFRACT - sprintf(msg,"XFRACTINT Version %d.%02d (FRACTINT Version %d.%02d)", - xrelease/100,xrelease%100, g_release/100,g_release%100); -#else - *msg=0; -#endif - sprintf(buf,"FRACTINT Version %d.%01d",g_release/100,(g_release%100)/10); - strcat(msg,buf); - if (g_release%10) { - sprintf(buf,"%01d",g_release%10); - strcat(msg,buf); - } - if (g_patch_level) { - sprintf(buf,".%d",g_patch_level); - strcat(msg,buf); - } - putstringcenter(0,0,80,C_TITLE,msg); - -/* uncomment next for production executable: */ -#if defined(PRODUCTION) || defined(XFRACT) - return; - /*NOTREACHED*/ -#else - if (debugflag == 3002) return; -#define DEVELOPMENT -#ifdef DEVELOPMENT - driver_put_string(0, 2, C_TITLE_DEV, "Development Version"); -#else - driver_put_string(0, 3, C_TITLE_DEV, "Customized Version"); -#endif - driver_put_string(0, 55, C_TITLE_DEV, "Not for Public Release"); -#endif -} - - -void footer_msg(int *i, int options, char *speedstring) -{ - putstringcenter((*i)++, 0, 80, C_PROMPT_BKGRD, - (speedstring) ? "Use the cursor keys or type a value to make a selection" - : "Use the cursor keys to highlight your selection"); - putstringcenter(*(i++), 0, 80, C_PROMPT_BKGRD, - (options & CHOICE_MENU) ? "Press ENTER for highlighted choice, or "FK_F1" for help" - : ((options & CHOICE_HELP) ? "Press ENTER for highlighted choice, ESCAPE to back out, or F1 for help" - : "Press ENTER for highlighted choice, or ESCAPE to back out")); -} - -int putstringcenter(int row, int col, int width, int attr, char *msg) -{ - char buf[81]; - int i,j,k; - i = 0; -#ifdef XFRACT - if (width>=80) width=79; /* Some systems choke in column 80 */ -#endif - while (msg[i]) ++i; /* strlen for a */ - if (i == 0) return(-1); - if (i >= width) i = width - 1; /* sanity check */ - j = (width - i) / 2; - j -= (width + 10 - i) / 20; /* when wide a bit left of center looks better */ - memset(buf,' ',width); - buf[width] = 0; - i = 0; - k = j; - while (msg[i]) buf[k++] = msg[i++]; /* strcpy for a */ - driver_put_string(row,col,attr,buf); - return j; -} - -/* ------------------------------------------------------------------------ */ - -char speed_prompt[]="Speed key string"; - -/* For file list purposes only, it's a directory name if first - char is a dot or last char is a slash */ -static int isadirname(char *name) -{ - if (*name == '.' || endswithslash(name)) - return 1; - else - return 0; -} - -void show_speedstring(int speedrow, - char *speedstring, - int (*speedprompt)(int,int,int,char *,int)) -{ - int speed_match = 0; - int i,j; - char buf[81]; - memset(buf,' ',80); - buf[80] = 0; - driver_put_string(speedrow,0,C_PROMPT_BKGRD,buf); - if (*speedstring) { /* got a speedstring on the go */ - driver_put_string(speedrow,15,C_CHOICE_SP_INSTR," "); - if (speedprompt) - j = speedprompt(speedrow,16,C_CHOICE_SP_INSTR,speedstring,speed_match); - else { - driver_put_string(speedrow,16,C_CHOICE_SP_INSTR,speed_prompt); - j = sizeof(speed_prompt)-1; - } - strcpy(buf,speedstring); - i = (int) strlen(buf); - while (i < 30) - buf[i++] = ' '; - buf[i] = 0; - driver_put_string(speedrow,16+j,C_CHOICE_SP_INSTR," "); - driver_put_string(speedrow,17+j,C_CHOICE_SP_KEYIN,buf); - driver_move_cursor(speedrow,17+j+(int) strlen(speedstring)); - } - else - driver_hide_text_cursor(); -} - -void process_speedstring(char *speedstring, - char **choices, /* array of choice strings */ - int curkey, - int *pcurrent, - int numchoices, - int is_unsorted) -{ - int i, comp_result; - - i = (int) strlen(speedstring); - if (curkey == 8 && i > 0) /* backspace */ - speedstring[--i] = 0; - if (33 <= curkey && curkey <= 126 && i < 30) - { -#ifndef XFRACT - curkey = tolower(curkey); -#endif - speedstring[i] = (char)curkey; - speedstring[++i] = 0; - } - if (i > 0) { /* locate matching type */ - *pcurrent = 0; - while (*pcurrent < numchoices - && (comp_result = strncasecmp(speedstring,choices[*pcurrent],i))!=0) { - if (comp_result < 0 && !is_unsorted) { - *pcurrent -= *pcurrent ? 1 : 0; - break; - } - else - ++*pcurrent; - } - if (*pcurrent >= numchoices) /* bumped end of list */ - *pcurrent = numchoices - 1; - /*if the list is unsorted, and the entry found is not the exact - entry, then go looking for the exact entry. - */ - else if (is_unsorted && choices[*pcurrent][i]) { - int temp = *pcurrent; - while (++temp < numchoices) { - if (!choices[temp][i] && !strncasecmp(speedstring, choices[temp], i)) { - *pcurrent = temp; - break; - } - } - } - } -} - - -int fullscreen_choice( - int options, /* &2 use menu coloring scheme */ - /* &4 include F1 for help in instructions */ - /* &8 add caller's instr after normal set */ - /* &16 menu items up one line */ - char *hdg, /* heading info, \n delimited */ - char *hdg2, /* column heading or NULL */ - char *instr, /* instructions, \n delimited, or NULL */ - int numchoices, /* How many choices in list */ - char **choices, /* array of choice strings */ - int *attributes, /* &3: 0 normal color, 1,3 highlight */ - /* &256 marks a dummy entry */ - int boxwidth, /* box width, 0 for calc (in items) */ - int boxdepth, /* box depth, 0 for calc, 99 for max */ - int colwidth, /* data width of a column, 0 for calc */ - int current, /* start with this item */ - void (*formatitem)(int,char*),/* routine to display an item or NULL */ - char *speedstring, /* returned speed key value, or NULL */ - int (*speedprompt)(int,int,int,char *,int),/* routine to display prompt or NULL */ - int (*checkkey)(int,int) /* routine to check keystroke or NULL */ -) - /* return is: n>=0 for choice n selected, - -1 for escape - k for checkkey routine return value k (if not 0 nor -1) - speedstring[0] != 0 on return if string is present - */ -{ - int titlelines, titlewidth; - int reqdrows; - int topleftrow, topleftcol; - int topleftchoice; - int speedrow = 0; /* speed key prompt */ - int boxitems; /* boxwidth*boxdepth */ - int curkey, increment, rev_increment = 0; - int redisplay; - int i, j, k = 0; - char *charptr; - char buf[81]; - char curitem[81]; - char *itemptr; - int ret, savelookatmouse; - int scrunch; /* scrunch up a line */ - - scrunch = (options & CHOICE_CRUNCH) ? 1 : 0; - savelookatmouse = lookatmouse; - lookatmouse = 0; - ret = -1; - /* preset current to passed string */ - if (speedstring && (i = (int) strlen(speedstring)) > 0) - { - current = 0; - if (options & CHOICE_NOT_SORTED) - { - while (current < numchoices && (k = strncasecmp(speedstring, choices[current], i)) != 0) - { - ++current; - } - if (k != 0) - { - current = 0; - } - } - else - { - while (current < numchoices && (k = strncasecmp(speedstring,choices[current],i)) > 0) - { - ++current; - } - if (k < 0 && current > 0) /* oops - overshot */ - { - --current; - } - } - if (current >= numchoices) /* bumped end of list */ - { - current = numchoices - 1; - } - } - - for (;;) - { - if (current >= numchoices) /* no real choice in the list? */ - { - goto fs_choice_end; - } - if ((attributes[current] & 256) == 0) - { - break; - } - ++current; /* scan for a real choice */ - } - - titlelines = titlewidth = 0; - if (hdg) - { - charptr = hdg; /* count title lines, find widest */ - i = 0; - titlelines = 1; - while (*charptr) - { - if (*(charptr++) == '\n') - { - ++titlelines; - i = -1; - } - if (++i > titlewidth) - { - titlewidth = i; - } - } - } - - if (colwidth == 0) /* find widest column */ - { - for (i = 0; i < numchoices; ++i) - { - int len; - if ((len = (int) strlen(choices[i])) > colwidth) - { - colwidth = len; - } - } - } - /* title(1), blank(1), hdg(n), blank(1), body(n), blank(1), instr(?) */ - reqdrows = 3 - scrunch; /* calc rows available */ - if (hdg) - { - reqdrows += titlelines + 1; - } - if (instr) /* count instructions lines */ - { - charptr = instr; - ++reqdrows; - while (*charptr) - { - if (*(charptr++) == '\n') - { - ++reqdrows; - } - } - if ((options & CHOICE_INSTRUCTIONS)) /* show std instr too */ - { - reqdrows += 2; - } - } - else - { - reqdrows += 2; /* standard instructions */ - } - if (speedstring) - { - ++reqdrows; /* a row for speedkey prompt */ - } - if (boxdepth > (i = 25 - reqdrows)) /* limit the depth to max */ - { - boxdepth = i; - } - if (boxwidth == 0) /* pick box width and depth */ - { - if (numchoices <= i - 2) /* single column is 1st choice if we can */ - { - boxdepth = numchoices; - boxwidth = 1; - } - else - { /* sort-of-wide is 2nd choice */ - boxwidth = 60 / (colwidth + 1); - if (boxwidth == 0 - || (boxdepth = (numchoices + boxwidth - 1)/boxwidth) > i - 2) - { - boxwidth = 80 / (colwidth + 1); /* last gasp, full width */ - if ((boxdepth = (numchoices + boxwidth - 1)/boxwidth) > i) - { - boxdepth = i; - } - } - } - } -#if 0 - if ((i = 77 / boxwidth - colwidth) > 3) /* spaces to add @ left each choice */ - { - i = 3; - } - if (i == 0) - { - i = 1; - } -#else - i = (80 / boxwidth - colwidth) / 2 - 1; - if (i == 0) /* to allow wider prompts */ - { - i = 1; - } - if (i < 0) - { - i = 0; - } - if (i > 3) - { - i = 3; - } -#endif - j = boxwidth * (colwidth += i) + i; /* overall width of box */ - if (j < titlewidth+2) - { - j = titlewidth + 2; - } - if (j > 80) - { - j = 80; - } - if (j <= 70 && boxwidth == 2) /* special case makes menus nicer */ - { - ++j; - ++colwidth; - } - k = (80 - j) / 2; /* center the box */ - k -= (90 - j) / 20; - topleftcol = k + i; /* column of topleft choice */ - i = (25 - reqdrows - boxdepth) / 2; - i -= i / 4; /* higher is better if lots extra */ - topleftrow = 3 + titlelines + i; /* row of topleft choice */ - - /* now set up the overall display */ - helptitle(); /* clear, display title line */ - driver_set_attr(1, 0, C_PROMPT_BKGRD, 24*80); /* init rest to background */ - for (i = topleftrow - 1 - titlelines; i < topleftrow + boxdepth + 1; ++i) - { - driver_set_attr(i, k, C_PROMPT_LO, j); /* draw empty box */ - } - if (hdg) - { - g_text_cbase = (80 - titlewidth) / 2; /* set left margin for putstring */ - g_text_cbase -= (90 - titlewidth) / 20; /* put heading into box */ - driver_put_string(topleftrow - titlelines - 1, 0, C_PROMPT_HI, hdg); - g_text_cbase = 0; - } - if (hdg2) /* display 2nd heading */ - { - driver_put_string(topleftrow - 1, topleftcol, C_PROMPT_MED, hdg2); - } - i = topleftrow + boxdepth + 1; - if (instr == NULL || (options & CHOICE_INSTRUCTIONS)) /* display default instructions */ - { - if (i < 20) - { - ++i; - } - if (speedstring) - { - speedrow = i; - *speedstring = 0; - if (++i < 22) - { - ++i; - } - } - i -= scrunch; - footer_msg(&i, options, speedstring); - } - if (instr) /* display caller's instructions */ - { - charptr = instr; - j = -1; - while ((buf[++j] = *(charptr++)) != 0) - { - if (buf[j] == '\n') - { - buf[j] = 0; - putstringcenter(i++, 0, 80, C_PROMPT_BKGRD, buf); - j = -1; - } - } - putstringcenter(i, 0, 80, C_PROMPT_BKGRD, buf); - } - - boxitems = boxwidth * boxdepth; - topleftchoice = 0; /* pick topleft for init display */ - while (current - topleftchoice >= boxitems - || (current - topleftchoice > boxitems/2 - && topleftchoice + boxitems < numchoices)) - { - topleftchoice += boxwidth; - } - redisplay = 1; - topleftrow -= scrunch; - for (;;) /* main loop */ - { - if (redisplay) /* display the current choices */ - { - memset(buf, ' ', 80); - buf[boxwidth*colwidth] = 0; - for (i = (hdg2) ? 0 : -1; i <= boxdepth; ++i) /* blank the box */ - { - driver_put_string(topleftrow + i, topleftcol, C_PROMPT_LO, buf); - } - for (i = 0; i + topleftchoice < numchoices && i < boxitems; ++i) - { - /* display the choices */ - k = attributes[j = i + topleftchoice] & 3; - if (k == 1) - { - k = C_PROMPT_LO; - } - else if (k == 3) - { - k = C_PROMPT_HI; - } - else - { - k = C_PROMPT_MED; - } - if (formatitem) - { - (*formatitem)(j, buf); - charptr=buf; - } - else - { - charptr = choices[j]; - } - driver_put_string(topleftrow + i/boxwidth, topleftcol + (i % boxwidth)*colwidth, - k, charptr); - } - /*** - ... format differs for summary/detail, whups, force box width to - ... be 72 when detail toggle available? (2 grey margin each - ... side, 1 blue margin each side) - ***/ - if (topleftchoice > 0 && hdg2 == NULL) - { - driver_put_string(topleftrow - 1, topleftcol, C_PROMPT_LO, "(more)"); - } - if (topleftchoice + boxitems < numchoices) - { - driver_put_string(topleftrow + boxdepth, topleftcol, C_PROMPT_LO, "(more)"); - } - redisplay = 0; - } - - i = current - topleftchoice; /* highlight the current choice */ - if (formatitem) - { - (*formatitem)(current, curitem); - itemptr = curitem; - } - else - { - itemptr = choices[current]; - } - driver_put_string(topleftrow + i/boxwidth, topleftcol + (i % boxwidth)*colwidth, - C_CHOICE_CURRENT, itemptr); - - if (speedstring) /* show speedstring if any */ - { - show_speedstring(speedrow, speedstring, speedprompt); - } - else - { - driver_hide_text_cursor(); - } - - driver_wait_key_pressed(0); /* enables help */ - curkey = driver_get_key(); -#ifdef XFRACT - if (curkey == FIK_F10) - { - curkey = ')'; - } - if (curkey == FIK_F9) - { - curkey = '('; - } - if (curkey == FIK_F8) - { - curkey = '*'; - } -#endif - - i = current - topleftchoice; /* unhighlight current choice */ - k = attributes[current] & 3; - if (k == 1) - { - k = C_PROMPT_LO; - } - else if (k == 3) - { - k = C_PROMPT_HI; - } - else - { - k = C_PROMPT_MED; - } - driver_put_string(topleftrow + i/boxwidth, topleftcol + (i % boxwidth)*colwidth, - k, itemptr); - - increment = 0; - switch (curkey) - { /* deal with input key */ - case FIK_ENTER: - case FIK_ENTER_2: - ret = current; - goto fs_choice_end; - case FIK_ESC: - goto fs_choice_end; - case FIK_DOWN_ARROW: - rev_increment = 0 - (increment = boxwidth); - break; - case FIK_CTL_DOWN_ARROW: - rev_increment = 0 - (increment = boxwidth); - { - int newcurrent = current; - while ((newcurrent += boxwidth) != current) - { - if (newcurrent >= numchoices) - { - newcurrent = (newcurrent % boxwidth) - boxwidth; - } - else if (!isadirname(choices[newcurrent])) - { - if (current != newcurrent) - { - current = newcurrent - boxwidth; - } - break; /* breaks the while loop */ - } - } - } - break; - case FIK_UP_ARROW: - increment = 0 - (rev_increment = boxwidth); - break; - case FIK_CTL_UP_ARROW: - increment = 0 - (rev_increment = boxwidth); - { - int newcurrent = current; - while ((newcurrent-=boxwidth) != current) - { - if (newcurrent < 0) - { - newcurrent = (numchoices - current) % boxwidth; - newcurrent = numchoices + (newcurrent ? boxwidth - newcurrent: 0); - } - else if (!isadirname(choices[newcurrent])) - { - if (current != newcurrent) - { - current = newcurrent + boxwidth; - } - break; /* breaks the while loop */ - } - } - } - break; - case FIK_RIGHT_ARROW: - increment = 1; rev_increment = -1; - break; - case FIK_CTL_RIGHT_ARROW: /* move to next file; if at last file, go to - first file */ - increment = 1; rev_increment = -1; - { - int newcurrent = current; - while (++newcurrent != current) - { - if (newcurrent >= numchoices) - { - newcurrent = -1; - } - else if (!isadirname(choices[newcurrent])) - { - if (current != newcurrent) - { - current = newcurrent - 1; - } - break; /* breaks the while loop */ - } - } - } - break; - case FIK_LEFT_ARROW: - increment = -1; rev_increment = 1; - break; - case FIK_CTL_LEFT_ARROW: /* move to previous file; if at first file, go to - last file */ - increment = -1; rev_increment = 1; - { - int newcurrent = current; - while (--newcurrent != current) - { - if (newcurrent < 0) - { - newcurrent = numchoices; - } - else if (!isadirname(choices[newcurrent])) - { - if (current != newcurrent) - { - current = newcurrent + 1; - } - break; /* breaks the while loop */ - } - } - } - break; - case FIK_PAGE_UP: - if (numchoices > boxitems) - { - topleftchoice -= boxitems; - increment = -boxitems; - rev_increment = boxwidth; - redisplay = 1; - } - break; - case FIK_PAGE_DOWN: - if (numchoices > boxitems) - { - topleftchoice += boxitems; - increment = boxitems; - rev_increment = -boxwidth; - redisplay = 1; - } - break; - case FIK_HOME: - current = -1; - increment = rev_increment = 1; - break; - case FIK_CTL_HOME: - current = -1; - increment = rev_increment = 1; - { - int newcurrent; - for (newcurrent = 0; newcurrent < numchoices; ++newcurrent) - { - if (!isadirname(choices[newcurrent])) - { - current = newcurrent - 1; - break; /* breaks the for loop */ - } - } - } - break; - case FIK_END: - current = numchoices; - increment = rev_increment = -1; - break; - case FIK_CTL_END: - current = numchoices; - increment = rev_increment = -1; - { - int newcurrent; - for (newcurrent = numchoices - 1; newcurrent >= 0; --newcurrent) - { - if (!isadirname(choices[newcurrent])) - { - current = newcurrent + 1; - break; /* breaks the for loop */ - } - } - } - break; - default: - if (checkkey) - { - if ((ret = (*checkkey)(curkey, current)) < -1 || ret > 0) - { - goto fs_choice_end; - } - if (ret == -1) - { - redisplay = -1; - } - } - ret = -1; - if (speedstring) - { - process_speedstring(speedstring, choices, curkey, ¤t, - numchoices, options & CHOICE_NOT_SORTED); - } - break; - } - if (increment) /* apply cursor movement */ - { - current += increment; - if (speedstring) /* zap speedstring */ - { - speedstring[0] = 0; - } - } - for (;;) - { /* adjust to a non-comment choice */ - if (current < 0 || current >= numchoices) - { - increment = rev_increment; - } - else if ((attributes[current] & 256) == 0) - { - break; - } - current += increment; - } - if (topleftchoice > numchoices - boxitems) - { - topleftchoice = ((numchoices + boxwidth - 1)/boxwidth)*boxwidth - boxitems; - } - if (topleftchoice < 0) - { - topleftchoice = 0; - } - while (current < topleftchoice) - { - topleftchoice -= boxwidth; - redisplay = 1; - } - while (current >= topleftchoice + boxitems) - { - topleftchoice += boxwidth; - redisplay = 1; - } - } - -fs_choice_end: - lookatmouse = savelookatmouse; - return ret; -} - -#ifndef XFRACT -/* case independent version of strncmp */ -int strncasecmp(char *s,char *t,int ct) -{ - for (; (tolower(*s) == tolower(*t)) && --ct ; s++,t++) - if (*s == '\0') - return(0); - return(tolower(*s) - tolower(*t)); -} -#endif - -static int menutype; -#define MENU_HDG 3 -#define MENU_ITEM 1 - -int main_menu(int fullmenu) -{ - char *choices[44]; /* 2 columns * 22 rows */ - int attributes[44]; - int choicekey[44]; - int i; - int nextleft, nextright; - int oldtabmode; - int showjuliatoggle; - oldtabmode = tabmode; - -top: - menutype = fullmenu; - tabmode = 0; - showjuliatoggle = 0; - for (i = 0; i < 44; ++i) - { - attributes[i] = 256; - choices[i] = ""; - choicekey[i] = -1; - } - nextleft = -2; - nextright = -1; - - if (fullmenu) - { - nextleft += 2; - choices[nextleft] = " CURRENT IMAGE "; - attributes[nextleft] = 256+MENU_HDG; - - nextleft += 2; - choicekey[nextleft] = 13; /* enter */ - attributes[nextleft] = MENU_ITEM; - choices[nextleft] = (calc_status == CALCSTAT_RESUMABLE) ? - "continue calculation " : - "return to image "; - - nextleft += 2; - choicekey[nextleft] = 9; /* tab */ - attributes[nextleft] = MENU_ITEM; - choices[nextleft] = "info about image "; - - nextleft += 2; - choicekey[nextleft] = 'o'; - attributes[nextleft] = MENU_ITEM; - choices[nextleft] = "orbits window "; - if (!(fractype==JULIA || fractype==JULIAFP || fractype==INVERSEJULIA)) - { - nextleft += 2; - } - } - - nextleft += 2; - choices[nextleft] = " NEW IMAGE "; - attributes[nextleft] = 256+MENU_HDG; - - nextleft += 2; - choicekey[nextleft] = FIK_DELETE; - attributes[nextleft] = MENU_ITEM; -#ifdef XFRACT - choices[nextleft] = "draw fractal "; -#else - choices[nextleft] = "select video mode... "; -#endif - - nextleft += 2; - choicekey[nextleft] = 't'; - attributes[nextleft] = MENU_ITEM; - choices[nextleft] = "select fractal type "; - - if (fullmenu) - { - if ((curfractalspecific->tojulia != NOFRACTAL - && param[0] == 0.0 && param[1] == 0.0) - || curfractalspecific->tomandel != NOFRACTAL) - { - nextleft += 2; - choicekey[nextleft] = FIK_SPACE; - attributes[nextleft] = MENU_ITEM; - choices[nextleft] = "toggle to/from julia "; - showjuliatoggle = 1; - } - if (fractype==JULIA || fractype==JULIAFP || fractype==INVERSEJULIA) - { - nextleft += 2; - choicekey[nextleft] = 'j'; - attributes[nextleft] = MENU_ITEM; - choices[nextleft] = "toggle to/from inverse "; - showjuliatoggle = 1; - } - - nextleft += 2; - choicekey[nextleft] = 'h'; - attributes[nextleft] = MENU_ITEM; - choices[nextleft] = "return to prior image "; - - nextleft += 2; - choicekey[nextleft] = FIK_BACKSPACE; - attributes[nextleft] = MENU_ITEM; - choices[nextleft] = "reverse thru history "; - } - else - { - nextleft += 2; - } - - nextleft += 2; - choices[nextleft] = " OPTIONS "; - attributes[nextleft] = 256+MENU_HDG; - - nextleft += 2; - choicekey[nextleft] = 'x'; - attributes[nextleft] = MENU_ITEM; - choices[nextleft] = "basic options... "; - - nextleft += 2; - choicekey[nextleft] = 'y'; - attributes[nextleft] = MENU_ITEM; - choices[nextleft] = "extended options... "; - - nextleft += 2; - choicekey[nextleft] = 'z'; - attributes[nextleft] = MENU_ITEM; - choices[nextleft] = "type-specific parms... "; - - nextleft += 2; - choicekey[nextleft] = 'p'; - attributes[nextleft] = MENU_ITEM; - choices[nextleft] = "passes options...

"; - - nextleft += 2; - choicekey[nextleft] = 'v'; - attributes[nextleft] = MENU_ITEM; - choices[nextleft] = "view window options... "; - - if (showjuliatoggle == 0) - { - nextleft += 2; - choicekey[nextleft] = 'i'; - attributes[nextleft] = MENU_ITEM; - choices[nextleft] = "fractal 3D parms... "; - } - - nextleft += 2; - choicekey[nextleft] = FIK_CTL_B; - attributes[nextleft] = MENU_ITEM; - choices[nextleft] = "browse parms... "; - - if (fullmenu) - { - nextleft += 2; - choicekey[nextleft] = FIK_CTL_E; - attributes[nextleft] = MENU_ITEM; - choices[nextleft] = "evolver parms... "; - -#ifndef XFRACT - nextleft += 2; - choicekey[nextleft] = FIK_CTL_F; - attributes[nextleft] = MENU_ITEM; - choices[nextleft] = "sound parms... "; -#endif - } - - nextright += 2; - attributes[nextright] = 256 + MENU_HDG; - choices[nextright] = " FILE "; - - nextright += 2; - choicekey[nextright] = '@'; - attributes[nextright] = MENU_ITEM; - choices[nextright] = "run saved command set... <@> "; - - if (fullmenu) - { - nextright += 2; - choicekey[nextright] = 's'; - attributes[nextright] = MENU_ITEM; - choices[nextright] = "save image to file "; - } - - nextright += 2; - choicekey[nextright] = 'r'; - attributes[nextright] = MENU_ITEM; - choices[nextright] = "load image from file... "; - - nextright += 2; - choicekey[nextright] = '3'; - attributes[nextright] = MENU_ITEM; - choices[nextright] = "3d transform from file...<3> "; - - if (fullmenu) - { - nextright += 2; - choicekey[nextright] = '#'; - attributes[nextright] = MENU_ITEM; - choices[nextright] = "3d overlay from file.....<#> "; - - nextright += 2; - choicekey[nextright] = 'b'; - attributes[nextright] = MENU_ITEM; - choices[nextright] = "save current parameters.. "; - - nextright += 2; - choicekey[nextright] = 16; - attributes[nextright] = MENU_ITEM; - choices[nextright] = "print image "; - } - - nextright += 2; - choicekey[nextright] = 'd'; - attributes[nextright] = MENU_ITEM; -#ifdef XFRACT - choices[nextright] = "shell to Linux/Unix "; -#else - choices[nextright] = "shell to dos "; -#endif - - nextright += 2; - choicekey[nextright] = 'g'; - attributes[nextright] = MENU_ITEM; - choices[nextright] = "give command string "; - - nextright += 2; - choicekey[nextright] = FIK_ESC; - attributes[nextright] = MENU_ITEM; - choices[nextright] = "quit "FRACTINT" "; - - nextright += 2; - choicekey[nextright] = FIK_INSERT; - attributes[nextright] = MENU_ITEM; - choices[nextright] = "restart "FRACTINT" "; - -#ifdef XFRACT - if (fullmenu && (g_got_real_dac || fake_lut) && colors >= 16) -#else - if (fullmenu && g_got_real_dac && colors >= 16) -#endif - { - nextright += 2; - choices[nextright] = " COLORS "; - attributes[nextright] = 256+MENU_HDG; - - nextright += 2; - choicekey[nextright] = 'c'; - attributes[nextright] = MENU_ITEM; - choices[nextright] = "color cycling mode "; - - nextright += 2; - choicekey[nextright] = '+'; - attributes[nextright] = MENU_ITEM; - choices[nextright] = "rotate palette <+>, <-> "; - - if (colors > 16) - { - if (!g_really_ega) - { - nextright += 2; - choicekey[nextright] = 'e'; - attributes[nextright] = MENU_ITEM; - choices[nextright] = "palette editing mode "; - } - - nextright += 2; - choicekey[nextright] = 'a'; - attributes[nextright] = MENU_ITEM; - choices[nextright] = "make starfield "; - } - } - - nextright += 2; - choicekey[nextright] = FIK_CTL_A; - attributes[nextright] = MENU_ITEM; - choices[nextright] = "ant automaton "; - - nextright += 2; - choicekey[nextright] = FIK_CTL_S; - attributes[nextright] = MENU_ITEM; - choices[nextright] = "stereogram "; - - i = driver_key_pressed() ? driver_get_key() : 0; - if (menu_checkkey(i, 0) == 0) - { - helpmode = HELPMAIN; /* switch help modes */ - nextleft += 2; - if (nextleft < nextright) - { - nextleft = nextright + 1; - } - i = fullscreen_choice(CHOICE_MENU | CHOICE_CRUNCH, - "MAIN MENU", - NULL, NULL, nextleft, (char **) choices, attributes, - 2, nextleft/2, 29, 0, NULL, NULL, NULL, menu_checkkey); - if (i == -1) /* escape */ - { - i = FIK_ESC; - } - else if (i < 0) - { - i = 0 - i; - } - else /* user selected a choice */ - { - i = choicekey[i]; - if (-10 == i) - { - helpmode = HELPZOOM; - help(0); - i = 0; - } - } - } - if (i == FIK_ESC) /* escape from menu exits Fractint */ - { - helptitle(); - driver_set_attr(1, 0, C_GENERAL_MED, 24*80); - for (i = 9; i <= 11; ++i) - { - driver_set_attr(i, 18, C_GENERAL_INPUT, 40); - } - putstringcenter(10, 18, 40, C_GENERAL_INPUT, -#ifdef XFRACT - "Exit from Xfractint (y/n)? y" -#else - "Exit from Fractint (y/n)? y" -#endif - ); - driver_hide_text_cursor(); - while ((i = driver_get_key()) != 'y' && i != 'Y' && i != 13) - { - if (i == 'n' || i == 'N') - { - goto top; - } - } - goodbye(); - } - if (i == FIK_TAB) - { - tab_display(); - i = 0; - } - if (i == FIK_ENTER || i == FIK_ENTER_2) - { - i = 0; /* don't trigger new calc */ - } - tabmode = oldtabmode; - return i; -} - -static int menu_checkkey(int curkey, int choice) -{ /* choice is dummy used by other routines called by fullscreen_choice() */ - int testkey; - testkey = choice; /* for warning only */ - testkey = (curkey>='A' && curkey<='Z') ? curkey+('a'-'A') : curkey; -#ifdef XFRACT - /* We use F2 for shift-@, annoyingly enough */ - if (testkey == FIK_F2) return(0-testkey); -#endif - if (testkey == '2') - testkey = '@'; - if (strchr("#@2txyzgvir3dj",testkey) || testkey == FIK_INSERT || testkey == FIK_CTL_B - || testkey == FIK_ESC || testkey == FIK_DELETE || testkey == FIK_CTL_F) /*RB 6== ctrl-F for sound menu */ - return(0-testkey); - if (menutype) { - if (strchr("\\sobpkrh",testkey) || testkey == FIK_TAB - || testkey == FIK_CTL_A || testkey == FIK_CTL_E || testkey == FIK_BACKSPACE - || testkey == FIK_CTL_P - || testkey == FIK_CTL_S || testkey == FIK_CTL_U) /* ctrl-A, E, H, P, S, U */ - return(0-testkey); - if (testkey == ' ') - if ((curfractalspecific->tojulia != NOFRACTAL - && param[0] == 0.0 && param[1] == 0.0) - || curfractalspecific->tomandel != NOFRACTAL) - return(0-testkey); - if (g_got_real_dac && colors >= 16) { - if (strchr("c+-",testkey)) - return(0-testkey); - if (colors > 16 - && (testkey == 'a' || (!g_really_ega && testkey == 'e'))) - return(0-testkey); - } - /* Alt-A and Alt-S */ - if (testkey == FIK_ALT_A || testkey == FIK_ALT_S ) - return(0-testkey); - } - if (check_vidmode_key(0,testkey) >= 0) - return(0-testkey); - return(0); -} - -int input_field( - int options, /* &1 numeric, &2 integer, &4 double */ - int attr, /* display attribute */ - char *fld, /* the field itself */ - int len, /* field length (declare as 1 larger for \0) */ - int row, /* display row */ - int col, /* display column */ - int (*checkkey)(int) /* routine to check non data keys, or NULL */ - ) -{ - char savefld[81]; - char buf[81]; - int insert, started, offset, curkey, display; - int i, j; - int ret,savelookatmouse; - savelookatmouse = lookatmouse; - lookatmouse = 0; - ret = -1; - strcpy(savefld,fld); - insert = started = offset = 0; - display = 1; - while (1) { - strcpy(buf,fld); - i = (int) strlen(buf); - while (i < len) - buf[i++] = ' '; - buf[len] = 0; - if (display) { /* display current value */ - driver_put_string(row,col,attr,buf); - display = 0; - } - curkey = driver_key_cursor(row+insert,col+offset); /* get a keystroke */ - if (curkey == 1047) curkey = 47; /* numeric slash */ - switch (curkey) { - case FIK_ENTER: - case FIK_ENTER_2: - ret = 0; - goto inpfld_end; - case FIK_ESC: - goto inpfld_end; - case FIK_RIGHT_ARROW: - if (offset < len-1) ++offset; - started = 1; - break; - case FIK_LEFT_ARROW: - if (offset > 0) --offset; - started = 1; - break; - case FIK_HOME: - offset = 0; - started = 1; - break; - case FIK_END: - offset = (int) strlen(fld); - started = 1; - break; - case FIK_BACKSPACE: - case 127: /* backspace */ - if (offset > 0) { - j = (int) strlen(fld); - for (i = offset-1; i < j; ++i) - fld[i] = fld[i+1]; - --offset; - } - started = display = 1; - break; - case FIK_DELETE: /* delete */ - j = (int) strlen(fld); - for (i = offset; i < j; ++i) - fld[i] = fld[i+1]; - started = display = 1; - break; - case FIK_INSERT: /* insert */ - insert ^= 0x8000; - started = 1; - break; - case FIK_F5: - strcpy(fld,savefld); - insert = started = offset = 0; - display = 1; - break; - default: - if (nonalpha(curkey)) { - if (checkkey && (ret = (*checkkey)(curkey)) != 0) - goto inpfld_end; - break; /* non alphanum char */ - } - if (offset >= len) break; /* at end of field */ - if (insert && started && strlen(fld) >= (size_t)len) - break; /* insert & full */ - if ((options & INPUTFIELD_NUMERIC) - && (curkey < '0' || curkey > '9') - && curkey != '+' && curkey != '-') { - if (options & INPUTFIELD_INTEGER) - break; - /* allow scientific notation, and specials "e" and "p" */ - if ( ((curkey != 'e' && curkey != 'E') || offset >= 18) - && ((curkey != 'p' && curkey != 'P') || offset != 0 ) - && curkey != '.') - break; - } - if (started == 0) /* first char is data, zap field */ - fld[0] = 0; - if (insert) { - j = (int) strlen(fld); - while (j >= offset) { - fld[j+1] = fld[j]; - --j; - } - } - if ((size_t)offset >= strlen(fld)) - fld[offset+1] = 0; - fld[offset++] = (char)curkey; - /* if "e" or "p" in first col make number e or pi */ - if ((options & (INPUTFIELD_NUMERIC | INPUTFIELD_INTEGER)) == INPUTFIELD_NUMERIC) { /* floating point */ - double tmpd; - int specialv; - char tmpfld[30]; - specialv = 0; - if (*fld == 'e' || *fld == 'E') { - tmpd = exp(1.0); - specialv = 1; - } - if (*fld == 'p' || *fld == 'P') { - tmpd = atan(1.0) * 4; - specialv = 1; - } - if (specialv) { - if ((options & INPUTFIELD_DOUBLE) == 0) - roundfloatd(&tmpd); - sprintf(tmpfld,"%.15g",tmpd); - tmpfld[len-1] = 0; /* safety, field should be long enough */ - strcpy(fld,tmpfld); - offset = 0; - } - } - started = display = 1; - } - } -inpfld_end: - lookatmouse = savelookatmouse; - return(ret); -} - -int field_prompt( - char *hdg, /* heading, \n delimited lines */ - char *instr, /* additional instructions or NULL */ - char *fld, /* the field itself */ - int len, /* field length (declare as 1 larger for \0) */ - int (*checkkey)(int) /* routine to check non data keys, or NULL */ - ) -{ - char *charptr; - int boxwidth,titlelines,titlecol,titlerow; - int promptcol; - int i,j; - char buf[81]; - helptitle(); /* clear screen, display title */ - driver_set_attr(1,0,C_PROMPT_BKGRD,24*80); /* init rest to background */ - charptr = hdg; /* count title lines, find widest */ - i = boxwidth = 0; - titlelines = 1; - while (*charptr) { - if (*(charptr++) == '\n') { - ++titlelines; - i = -1; - } - if (++i > boxwidth) - boxwidth = i; - } - if (len > boxwidth) - boxwidth = len; - i = titlelines + 4; /* total rows in box */ - titlerow = (25 - i) / 2; /* top row of it all when centered */ - titlerow -= titlerow / 4; /* higher is better if lots extra */ - titlecol = (80 - boxwidth) / 2; /* center the box */ - titlecol -= (90 - boxwidth) / 20; - promptcol = titlecol - (boxwidth-len)/2; - j = titlecol; /* add margin at each side of box */ - if ((i = (82-boxwidth)/4) > 3) - i = 3; - j -= i; - boxwidth += i * 2; - for (i = -1; i < titlelines+3; ++i) /* draw empty box */ - driver_set_attr(titlerow+i,j,C_PROMPT_LO,boxwidth); - g_text_cbase = titlecol; /* set left margin for putstring */ - driver_put_string(titlerow,0,C_PROMPT_HI,hdg); /* display heading */ - g_text_cbase = 0; - i = titlerow + titlelines + 4; - if (instr) { /* display caller's instructions */ - charptr = instr; - j = -1; - while ((buf[++j] = *(charptr++)) != 0) - if (buf[j] == '\n') { - buf[j] = 0; - putstringcenter(i++,0,80,C_PROMPT_BKGRD,buf); - j = -1; - } - putstringcenter(i,0,80,C_PROMPT_BKGRD,buf); - } - else /* default instructions */ - putstringcenter(i,0,80,C_PROMPT_BKGRD, "Press ENTER when finished (or ESCAPE to back out)"); - return input_field(0,C_PROMPT_INPUT,fld,len, - titlerow+titlelines+1,promptcol,checkkey); -} - - -/* thinking(1,message): - if thinking message not yet on display, it is displayed; - otherwise the wheel is updated - returns 0 to keep going, -1 if keystroke pending - thinking(0,NULL): - call this when thinking phase is done - */ - -int thinking(int options,char *msg) -{ - static int thinkstate = -1; - char *wheel[] = {"-","\\","|","/"}; - static int thinkcol; - static int count = 0; - char buf[81]; - if (options == 0) { - if (thinkstate >= 0) { - thinkstate = -1; - driver_unstack_screen(); - } - return(0); - } - if (thinkstate < 0) { - driver_stack_screen(); - thinkstate = 0; - helptitle(); - strcpy(buf," "); - strcat(buf,msg); - strcat(buf," "); - driver_put_string(4,10,C_GENERAL_HI,buf); - thinkcol = g_text_col - 3; - count = 0; - } - if ((count++)<100) { - return 0; - } - count = 0; - driver_put_string(4,thinkcol,C_GENERAL_HI,wheel[thinkstate]); - driver_hide_text_cursor(); /* turn off cursor */ - thinkstate = (thinkstate + 1) & 3; - return (driver_key_pressed()); -} - - -/* savegraphics/restoregraphics: video.asm subroutines */ - -unsigned long swaptotlen; -unsigned long swapoffset; -BYTE *swapvidbuf; -int swaplength; - -#define SWAPBLKLEN 4096 /* must be a power of 2 */ -U16 memhandle = 0; - -BYTE suffix[10000]; - -void discardgraphics() /* release expanded/extended memory if any in use */ -{ -#ifndef XFRACT - MemoryRelease(memhandle); - memhandle = 0; -#endif -} - -/*VIDEOINFO *g_video_table; /* temporarily loaded fractint.cfg info */ -int g_video_table_len; /* number of entries in above */ - -int showvidlength() -{ - int sz; - sz = (sizeof(VIDEOINFO)+sizeof(int))*MAXVIDEOMODES; - return(sz); -} - -int g_cfg_line_nums[MAXVIDEOMODES] = { 0 }; - -/* load_fractint_config - * - * Reads fractint.cfg, loading videoinfo entries into g_video_table. - * Sets the number of entries, sets g_video_table_len. - * Past g_video_table, g_cfg_line_nums are stored for update_fractint_cfg. - * If fractint.cfg is not found or invalid, issues a message - * (first time the problem occurs only, and only if options is - * zero) and uses the hard-coded table. - */ -void load_fractint_config(void) -{ - FILE *cfgfile; - VIDEOINFO vident; - int linenum; - long xdots, ydots; - int i, j, keynum, ax, bx, cx, dx, dotmode, colors; - char *fields[11]; - int textsafe2; - char tempstring[150]; - int truecolorbits; - - findpath("fractint.cfg",tempstring); - if (tempstring[0] == 0 /* can't find the file */ - || (cfgfile = fopen(tempstring,"r")) == NULL) /* can't open it */ - { - goto bad_fractint_cfg; - } - - linenum = 0; - while (g_video_table_len < MAXVIDEOMODES - && fgets(tempstring, 120, cfgfile)) - { - if (strchr(tempstring,'\n') == NULL) - { - /* finish reading the line */ - while (fgetc(cfgfile) != '\n' && !feof(cfgfile)); - } - ++linenum; - if (tempstring[0] == ';') - { - continue; /* comment line */ - } - tempstring[120] = 0; - tempstring[(int) strlen(tempstring)-1] = 0; /* zap trailing \n */ - i = j = -1; - /* key, mode name, ax, bx, cx, dx, dotmode, x, y, colors, comments, driver */ - for (;;) - { - if (tempstring[++i] < ' ') - { - if (tempstring[i] == 0) - { - break; - } - tempstring[i] = ' '; /* convert tab (or whatever) to blank */ - } - else if (tempstring[i] == ',' && ++j < 11) - { -#if defined(_WIN32) - _ASSERTE(j >= 0 && j < 11); -#endif - fields[j] = &tempstring[i+1]; /* remember start of next field */ - tempstring[i] = 0; /* make field a separate string */ - } - } - keynum = check_vidmode_keyname(tempstring); - sscanf(fields[1],"%x",&ax); - sscanf(fields[2],"%x",&bx); - sscanf(fields[3],"%x",&cx); - sscanf(fields[4],"%x",&dx); - dotmode = atoi(fields[5]); - xdots = atol(fields[6]); - ydots = atol(fields[7]); - colors = atoi(fields[8]); - if (colors == 4 && strchr(strlwr(fields[8]),'g')) - { - colors = 256; - truecolorbits = 4; /* 32 bits */ - } - else if (colors == 16 && strchr(fields[8],'m')) - { - colors = 256; - truecolorbits = 3; /* 24 bits */ - } - else if (colors == 64 && strchr(fields[8],'k')) - { - colors = 256; - truecolorbits = 2; /* 16 bits */ - } - else if (colors == 32 && strchr(fields[8],'k')) - { - colors = 256; - truecolorbits = 1; /* 15 bits */ - } - else - { - truecolorbits = 0; - } - - textsafe2 = dotmode / 100; - dotmode %= 100; - if (j < 9 || - keynum < 0 || - dotmode < 0 || dotmode > 30 || - textsafe2 < 0 || textsafe2 > 4 || - xdots < MINPIXELS || xdots > MAXPIXELS || - ydots < MINPIXELS || ydots > MAXPIXELS || - (colors != 0 && colors != 2 && colors != 4 && colors != 16 && - colors != 256) - ) - { - goto bad_fractint_cfg; - } - g_cfg_line_nums[g_video_table_len] = linenum; /* for update_fractint_cfg */ - - memset(&vident, 0, sizeof(vident)); - strncpy(&vident.name[0], fields[0], NUM_OF(vident.name)); - strncpy(&vident.comment[0], fields[9], NUM_OF(vident.comment)); - vident.name[25] = vident.comment[25] = 0; - vident.keynum = keynum; - vident.videomodeax = ax; - vident.videomodebx = bx; - vident.videomodecx = cx; - vident.videomodedx = dx; - vident.dotmode = truecolorbits * 1000 + textsafe2 * 100 + dotmode; - vident.xdots = (short)xdots; - vident.ydots = (short)ydots; - vident.colors = colors; - - /* if valid, add to supported modes */ - vident.driver = driver_find_by_name(fields[10]); - if (vident.driver != NULL) - { - if (vident.driver->validate_mode(vident.driver, &vident)) - { - /* look for a synonym mode and if found, overwite its key */ - int m; - int synonym_found = FALSE; - for (m = 0; m < g_video_table_len; m++) - { - VIDEOINFO *mode = &g_video_table[m]; - if ((mode->driver == vident.driver) && (mode->colors == vident.colors) && - (mode->xdots == vident.xdots) && (mode->ydots == vident.ydots) && - (mode->dotmode == vident.dotmode)) - { - if (0 == mode->keynum) - { - mode->keynum = vident.keynum; - } - synonym_found = TRUE; - break; - } - } - /* no synonym found, append it to current list of video modes */ - if (FALSE == synonym_found) - { - add_video_mode(vident.driver, &vident); - } - } - } - } - fclose(cfgfile); - return; - -bad_fractint_cfg: - g_bad_config = -1; /* bad, no message issued yet */ -} - -void bad_fractint_cfg_msg() -{ - stopmsg(0, - "File FRACTINT.CFG is missing or invalid.\n" - "See Hardware Support and Video Modes in the full documentation for help.\n" - "I will continue with only the built-in video modes available."); - g_bad_config = 1; /* bad, message issued */ -} - -int check_vidmode_key(int option,int k) -{ - int i; - /* returns g_video_table entry number if the passed keystroke is a */ - /* function key currently assigned to a video mode, -1 otherwise */ - if (k == 1400) /* special value from select_vid_mode */ - return(MAXVIDEOMODES-1); /* for last entry with no key assigned */ - if (k != 0) { - if (option == 0) { /* check resident video mode table */ - for (i = 0; i < MAXVIDEOMODES; ++i) { - if (g_video_table[i].keynum == k) - return(i); - } - } - else { /* check full g_video_table */ - for (i = 0; i < g_video_table_len; ++i) { - if (g_video_table[i].keynum == k) - return(i); - } - } - } - return(-1); -} - -int check_vidmode_keyname(char *kname) -{ - /* returns key number for the passed keyname, 0 if not a keyname */ - int i,keyset; - keyset = 1058; - if (*kname == 'S' || *kname == 's') { - keyset = 1083; - ++kname; - } - else if (*kname == 'C' || *kname == 'c') { - keyset = 1093; - ++kname; - } - else if (*kname == 'A' || *kname == 'a') { - keyset = 1103; - ++kname; - } - if (*kname != 'F' && *kname != 'f') - return(0); - if (*++kname < '1' || *kname > '9') - return(0); - i = *kname - '0'; - if (*++kname != 0 && *kname != ' ') { - if (*kname != '0' || i != 1) - return(0); - i = 10; - ++kname; - } - while (*kname) - if (*(kname++) != ' ') - return(0); - if ((i += keyset) < 2) - i = 0; - return(i); -} - -void vidmode_keyname(int k,char *buf) -{ - /* set buffer to name of passed key number */ - *buf = 0; - if (k > 0) { - if (k > 1103) { - *(buf++) = 'A'; - k -= 1103; - } - else if (k > 1093) { - *(buf++) = 'C'; - k -= 1093; - } - else if (k > 1083) { - *(buf++) = 'S'; - k -= 1083; - } - else - k -= 1058; - sprintf(buf,"F%d",k); - } -} diff --git a/fractint/common/rotate.c b/fractint/common/rotate.c deleted file mode 100644 index 5f2f61165..000000000 --- a/fractint/common/rotate.c +++ /dev/null @@ -1,471 +0,0 @@ -/* - rotate.c - Routines that manipulate the Video DAC on VGA Adapters -*/ - -#include -#include - - /* see Fractint.c for a description of the "include" hierarchy */ -#include "port.h" -#include "prototyp.h" -#include "helpdefs.h" -#include "drivers.h" - -/* routines in this module */ - -static void pauserotate(void); -static void set_palette(BYTE start[3], BYTE finish[3]); -static void set_palette2(BYTE start[3], BYTE finish[3]); -static void set_palette3(BYTE start[3], BYTE middle[3], BYTE finish[3]); - -static int paused; /* rotate-is-paused flag */ -static BYTE Red[3] = {63, 0, 0}; /* for shifted-Fkeys */ -static BYTE Green[3] = { 0,63, 0}; -static BYTE Blue[3] = { 0, 0,63}; -static BYTE Black[3] = { 0, 0, 0}; -static BYTE White[3] = {63,63,63}; -static BYTE Yellow[3] = {63,63, 0}; -static BYTE Brown[3] = {31,31, 0}; - -char mapmask[13] = {"*.map"}; - -void rotate(int direction) /* rotate-the-palette routine */ -{ -int kbdchar, more, last, next; -int fkey, step, fstep, istep, jstep, oldstep; -int incr, fromred=0, fromblue=0, fromgreen=0, tored=0, toblue=0, togreen=0; -int i, changecolor, changedirection; -int oldhelpmode; -int rotate_max,rotate_size; - -static int fsteps[] = {2,4,8,12,16,24,32,40,54,100}; /* (for Fkeys) */ - -#ifndef XFRACT - if (g_got_real_dac == 0 /* ??? no DAC to rotate! */ -#else - if (!(g_got_real_dac || fake_lut) /* ??? no DAC to rotate! */ -#endif - || colors < 16) { /* strange things happen in 2x modes */ - driver_buzzer(BUZZER_ERROR); - return; - } - - oldhelpmode = helpmode; /* save the old help mode */ - helpmode = HELPCYCLING; /* new help mode */ - - paused = 0; /* not paused */ - fkey = 0; /* no random coloring */ - oldstep = step = 1; /* single-step */ - fstep = 1; - changecolor = -1; /* no color (rgb) to change */ - changedirection = 0; /* no color direction to change */ - incr = 999; /* ready to randomize */ - srand((unsigned)time(NULL)); /* randomize things */ - - if (direction == 0) { /* firing up in paused mode? */ - pauserotate(); /* then force a pause */ - direction = 1; /* and set a rotate direction */ - } - - rotate_max = (rotate_hi < colors) ? rotate_hi : colors-1; - rotate_size = rotate_max - rotate_lo + 1; - last = rotate_max; /* last box that was filled */ - next = rotate_lo; /* next box to be filled */ - if (direction < 0) { - last = rotate_lo; - next = rotate_max; - } - - more = 1; - while (more) { - if (driver_diskp()) { - if (!paused) - pauserotate(); - } - else while (!driver_key_pressed()) { /* rotate until key hit, at least once so step=oldstep ok */ - if (fkey > 0) { /* randomizing is on */ - for (istep = 0; istep < step; istep++) { - jstep = next + (istep * direction); - while (jstep < rotate_lo) jstep += rotate_size; - while (jstep > rotate_max) jstep -= rotate_size; - if (++incr > fstep) { /* time to randomize */ - incr = 1; - fstep = ((fsteps[fkey-1]* (rand15() >> 8)) >> 6) + 1; - fromred = g_dac_box[last][0]; - fromgreen = g_dac_box[last][1]; - fromblue = g_dac_box[last][2]; - tored = rand15() >> 9; - togreen = rand15() >> 9; - toblue = rand15() >> 9; - } - g_dac_box[jstep][0] = (BYTE)(fromred + (((tored - fromred )*incr)/fstep)); - g_dac_box[jstep][1] = (BYTE)(fromgreen + (((togreen - fromgreen)*incr)/fstep)); - g_dac_box[jstep][2] = (BYTE)(fromblue + (((toblue - fromblue )*incr)/fstep)); - } - } - if (step >= rotate_size) step = oldstep; - spindac(direction, step); - } - if (step >= rotate_size) step = oldstep; - kbdchar = driver_get_key(); - if (paused && (kbdchar != ' ' - && kbdchar != 'c' - && kbdchar != FIK_HOME - && kbdchar != 'C' )) - paused = 0; /* clear paused condition */ - switch (kbdchar) { - case '+': /* '+' means rotate forward */ - case FIK_RIGHT_ARROW: /* RightArrow = rotate fwd */ - fkey = 0; - direction = 1; - last = rotate_max; - next = rotate_lo; - incr = 999; - break; - case '-': /* '-' means rotate backward */ - case FIK_LEFT_ARROW: /* LeftArrow = rotate bkwd */ - fkey = 0; - direction = -1; - last = rotate_lo; - next = rotate_max; - incr = 999; - break; - case FIK_UP_ARROW: /* UpArrow means speed up */ - g_dac_learn = 1; - if (++g_dac_count >= colors) --g_dac_count; - break; - case FIK_DOWN_ARROW: /* DownArrow means slow down */ - g_dac_learn = 1; - if (g_dac_count > 1) g_dac_count--; - break; - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - step = kbdchar - '0'; /* change step-size */ - if (step > rotate_size) step = rotate_size; - break; - case FIK_F1: /* FIK_F1 - FIK_F10: */ - case FIK_F2: /* select a shading factor */ - case FIK_F3: - case FIK_F4: - case FIK_F5: - case FIK_F6: - case FIK_F7: - case FIK_F8: - case FIK_F9: - case FIK_F10: -#ifndef XFRACT - fkey = kbdchar-1058; -#else - switch (kbdchar) { - case FIK_F1: - fkey = 1;break; - case FIK_F2: - fkey = 2;break; - case FIK_F3: - fkey = 3;break; - case FIK_F4: - fkey = 4;break; - case FIK_F5: - fkey = 5;break; - case FIK_F6: - fkey = 6;break; - case FIK_F7: - fkey = 7;break; - case FIK_F8: - fkey = 8;break; - case FIK_F9: - fkey = 9;break; - case FIK_F10: - fkey = 10;break; - } -#endif - if (g_really_ega) fkey = (fkey+1)>>1; /* limit on EGA */ - fstep = 1; - incr = 999; - break; - case FIK_ENTER: /* enter key: randomize all colors */ - case FIK_ENTER_2: /* also the Numeric-Keypad Enter */ - fkey = rand15()/3277 + 1; - if (g_really_ega) /* limit on EGAs */ - fkey = (fkey+1)>>1; - fstep = 1; - incr = 999; - oldstep = step; - step = rotate_size; - break; - case 'r': /* color changes */ - if (changecolor == -1) changecolor = 0; - case 'g': /* color changes */ - if (changecolor == -1) changecolor = 1; - case 'b': /* color changes */ - if (changecolor == -1) changecolor = 2; - if (changedirection == 0) changedirection = -1; - case 'R': /* color changes */ - if (changecolor == -1) changecolor = 0; - case 'G': /* color changes */ - if (changecolor == -1) changecolor = 1; - case 'B': /* color changes */ - if (driver_diskp()) break; - if (changecolor == -1) changecolor = 2; - if (changedirection == 0) changedirection = 1; - if (g_really_ega) break; /* no sense on real EGAs */ - for (i = 1; i < 256; i++) { - g_dac_box[i][changecolor] = (BYTE)(g_dac_box[i][changecolor] + changedirection); - if (g_dac_box[i][changecolor] == 64) - g_dac_box[i][changecolor] = 63; - if (g_dac_box[i][changecolor] == 255) - g_dac_box[i][changecolor] = 0; - } - changecolor = -1; /* clear flags for next time */ - changedirection = 0; - paused = 0; /* clear any pause */ - case ' ': /* use the spacebar as a "pause" toggle */ - case 'c': /* for completeness' sake, the 'c' too */ - case 'C': - pauserotate(); /* pause */ - break; - case '>': /* single-step */ - case '.': - case '<': - case ',': - if (kbdchar == '>' || kbdchar == '.') { - direction = -1; - last = rotate_lo; - next = rotate_max; - incr = 999; - } - else { - direction = 1; - last = rotate_max; - next = rotate_lo; - incr = 999; - } - fkey = 0; - spindac(direction,1); - if (! paused) - pauserotate(); /* pause */ - break; - case 'd': /* load colors from "default.map" */ - case 'D': - if (ValidateLuts("default") != 0) - break; - fkey = 0; /* disable random generation */ - pauserotate(); /* update palette and pause */ - break; - case 'a': /* load colors from "altern.map" */ - case 'A': - if (ValidateLuts("altern") != 0) - break; - fkey = 0; /* disable random generation */ - pauserotate(); /* update palette and pause */ - break; - case 'l': /* load colors from a specified map */ -#ifndef XFRACT /* L is used for FIK_RIGHT_ARROW in Unix keyboard mapping */ - case 'L': -#endif - load_palette(); - fkey = 0; /* disable random generation */ - pauserotate(); /* update palette and pause */ - break; - case 's': /* save the palette */ - case 'S': - save_palette(); - fkey = 0; /* disable random generation */ - pauserotate(); /* update palette and pause */ - break; - case FIK_ESC: /* escape */ - more = 0; /* time to bail out */ - break; - case FIK_HOME: /* restore palette */ - memcpy(g_dac_box,olddacbox,256*3); - pauserotate(); /* pause */ - break; - default: /* maybe a new palette */ - if (g_really_ega) break; /* no sense on real EGAs */ - fkey = 0; /* disable random generation */ - if (kbdchar == FIK_SF1) set_palette(Black, White); - if (kbdchar == FIK_SF2) set_palette(Red, Yellow); - if (kbdchar == FIK_SF3) set_palette(Blue, Green); - if (kbdchar == FIK_SF4) set_palette(Black, Yellow); - if (kbdchar == FIK_SF5) set_palette(Black, Red); - if (kbdchar == FIK_SF6) set_palette(Black, Blue); - if (kbdchar == FIK_SF7) set_palette(Black, Green); - if (kbdchar == FIK_SF8) set_palette(Blue, Yellow); - if (kbdchar == FIK_SF9) set_palette(Red, Green); - if (kbdchar == FIK_SF10) set_palette(Green, White); - if (kbdchar == 1094) set_palette2(Black, White); - if (kbdchar == 1095) set_palette2(Red, Yellow); - if (kbdchar == 1096) set_palette2(Blue, Green); - if (kbdchar == 1097) set_palette2(Black, Yellow); - if (kbdchar == 1098) set_palette2(Black, Red); - if (kbdchar == 1099) set_palette2(Black, Blue); - if (kbdchar == 1100) set_palette2(Black, Green); - if (kbdchar == 1101) set_palette2(Blue, Yellow); - if (kbdchar == 1102) set_palette2(Red, Green); - if (kbdchar == 1103) set_palette2(Green, White); - if (kbdchar == FIK_ALT_F1) set_palette3(Blue, Green, Red); - if (kbdchar == 1105) set_palette3(Blue, Yellow, Red); - if (kbdchar == 1106) set_palette3(Red, White, Blue); - if (kbdchar == 1107) set_palette3(Red, Yellow, White); - if (kbdchar == 1108) set_palette3(Black, Brown, Yellow); - if (kbdchar == 1109) set_palette3(Blue, Brown, Green); - if (kbdchar == 1110) set_palette3(Blue, Green, Green); - if (kbdchar == 1111) set_palette3(Blue, Green, White); - if (kbdchar == 1112) set_palette3(Green, Green, White); - if (kbdchar == 1113) set_palette3(Red, Blue, White); - pauserotate(); /* update palette and pause */ - break; - } - } - - helpmode = oldhelpmode; /* return to previous help mode */ -} - -static void pauserotate() /* pause-the-rotate routine */ -{ -int olddaccount; /* saved dac-count value goes here */ -BYTE olddac0,olddac1,olddac2; - - if (paused) /* if already paused , just clear */ - paused = 0; - else { /* else set border, wait for a key */ - olddaccount = g_dac_count; - olddac0 = g_dac_box[0][0]; - olddac1 = g_dac_box[0][1]; - olddac2 = g_dac_box[0][2]; - g_dac_count = 256; - g_dac_box[0][0] = 48; - g_dac_box[0][1] = 48; - g_dac_box[0][2] = 48; - spindac(0,1); /* show white border */ - if (driver_diskp()) - { - dvid_status(100," Paused in \"color cycling\" mode "); - } - driver_wait_key_pressed(0); /* wait for any key */ - - if (driver_diskp()) - dvid_status(0,""); - g_dac_box[0][0] = olddac0; - g_dac_box[0][1] = olddac1; - g_dac_box[0][2] = olddac2; - spindac(0,1); /* show black border */ - g_dac_count = olddaccount; - paused = 1; - } -} - -static void set_palette(BYTE start[3], BYTE finish[3]) -{ - int i, j; - g_dac_box[0][0] = g_dac_box[0][1] = g_dac_box[0][2] = 0; - for (i=1; i<=255; i++) /* fill the palette */ - for (j = 0; j < 3; j++) -#ifdef __SVR4 - g_dac_box[i][j] = (BYTE)((int)(i*start[j] + (256-i)*finish[j])/255); -#else - g_dac_box[i][j] = (BYTE)((i*start[j] + (256-i)*finish[j])/255); -#endif -} - -static void set_palette2(BYTE start[3], BYTE finish[3]) -{ - int i, j; - g_dac_box[0][0] = g_dac_box[0][1] = g_dac_box[0][2] = 0; - for (i=1; i<=128; i++) - for (j = 0; j < 3; j++) { -#ifdef __SVR4 - g_dac_box[i][j] = (BYTE)((int)(i*finish[j] + (128-i)*start[j] )/128); - g_dac_box[i+127][j] = (BYTE)((int)(i*start[j] + (128-i)*finish[j])/128); -#else - g_dac_box[i][j] = (BYTE)((i*finish[j] + (128-i)*start[j] )/128); - g_dac_box[i+127][j] = (BYTE)((i*start[j] + (128-i)*finish[j])/128); -#endif - } -} - -static void set_palette3(BYTE start[3], BYTE middle[3], BYTE finish[3]) -{ - int i, j; - g_dac_box[0][0] = g_dac_box[0][1] = g_dac_box[0][2] = 0; - for (i=1; i<=85; i++) - for (j = 0; j < 3; j++) { -#ifdef __SVR4 - g_dac_box[i][j] = (BYTE)((int)(i*middle[j] + (86-i)*start[j] )/85); - g_dac_box[i+85][j] = (BYTE)((int)(i*finish[j] + (86-i)*middle[j])/85); - g_dac_box[i+170][j] = (BYTE)((int)(i*start[j] + (86-i)*finish[j])/85); -#else - g_dac_box[i][j] = (BYTE)((i*middle[j] + (86-i)*start[j] )/85); - g_dac_box[i+85][j] = (BYTE)((i*finish[j] + (86-i)*middle[j])/85); - g_dac_box[i+170][j] = (BYTE)((i*start[j] + (86-i)*finish[j])/85); -#endif - } -} - - -void save_palette() -{ - char palname[FILE_MAX_PATH]; - FILE *dacfile; - int i,oldhelpmode; - strcpy(palname,MAP_name); - oldhelpmode = helpmode; - driver_stack_screen(); - temp1[0] = 0; - helpmode = HELPCOLORMAP; - i = field_prompt("Name of map file to write",NULL,temp1,60,NULL); - driver_unstack_screen(); - if (i != -1 && temp1[0]) { - if (strchr(temp1,'.') == NULL) - strcat(temp1,".map"); - merge_pathnames(palname,temp1,2); - dacfile = fopen(palname,"w"); - if (dacfile == NULL) - driver_buzzer(BUZZER_ERROR); - else { -#ifndef XFRACT - for (i = 0; i < colors; i++) -#else - for (i = 0; i < 256; i++) -#endif - fprintf(dacfile, "%3d %3d %3d\n", - g_dac_box[i][0] << 2, - g_dac_box[i][1] << 2, - g_dac_box[i][2] << 2); - memcpy(olddacbox,g_dac_box,256*3); - colorstate = 2; - strcpy(colorfile,temp1); - } - fclose(dacfile); - } - helpmode = oldhelpmode; -} - - -int load_palette(void) -{ - int i,oldhelpmode; - char filename[FILE_MAX_PATH]; - oldhelpmode = helpmode; - strcpy(filename,MAP_name); - driver_stack_screen(); - helpmode = HELPCOLORMAP; - i = getafilename("Select a MAP File",mapmask,filename); - driver_unstack_screen(); - if (i >= 0) - { - if (ValidateLuts(filename) == 0) - memcpy(olddacbox,g_dac_box,256*3); - merge_pathnames(MAP_name,filename,0); - } - helpmode = oldhelpmode; - return (i); -} - diff --git a/fractint/common/slideshw.c b/fractint/common/slideshw.c deleted file mode 100644 index e8e695396..000000000 --- a/fractint/common/slideshw.c +++ /dev/null @@ -1,378 +0,0 @@ -/***********************************************************************/ -/* These routines are called by driver_get_key to allow keystrokes to control */ -/* Fractint to be read from a file. */ -/***********************************************************************/ - -#include -#include -#include -#ifndef XFRACT -#include -#endif - - /* see Fractint.c for a description of the "include" hierarchy */ -#include "port.h" -#include "prototyp.h" -#include "drivers.h" - -static void sleep_secs(int); -static int showtempmsg_txt(int,int,int,int,char *); -static void message(int secs, char *buf); -static void slideshowerr(char *msg); -static int get_scancode(char *mn); -static void get_mnemonic(int code, char *mnemonic); - -#define MAX_MNEMONIC 20 /* max size of any mnemonic string */ - -struct scancodes -{ - int code; - char *mnemonic; -}; - -static struct scancodes scancodes[] = -{ - { FIK_ENTER, "ENTER" }, - { FIK_INSERT, "INSERT" }, - { FIK_DELETE, "DELETE" }, - { FIK_ESC, "ESC" }, - { FIK_TAB, "TAB" }, - { FIK_PAGE_UP, "PAGEUP" }, - { FIK_PAGE_DOWN, "PAGEDOWN" }, - { FIK_HOME, "HOME" }, - { FIK_END, "END" }, - { FIK_LEFT_ARROW, "LEFT" }, - { FIK_RIGHT_ARROW, "RIGHT" }, - { FIK_UP_ARROW, "UP" }, - { FIK_DOWN_ARROW, "DOWN" }, - { FIK_F1, "F1" }, - { FIK_CTL_RIGHT_ARROW, "CTRL_RIGHT"}, - { FIK_CTL_LEFT_ARROW, "CTRL_LEFT" }, - { FIK_CTL_DOWN_ARROW, "CTRL_DOWN" }, - { FIK_CTL_UP_ARROW, "CTRL_UP" }, - { FIK_CTL_END, "CTRL_END" }, - { FIK_CTL_HOME, "CTRL_HOME" }, - { -1, NULL } -}; -#define stop sizeof(scancodes)/sizeof(struct scancodes)-1 - -static int get_scancode(char *mn) -{ - int i; - i = 0; - for (i=0; i< stop; i++) - if (strcmp((char *)mn,scancodes[i].mnemonic)==0) - break; - return(scancodes[i].code); -} - -static void get_mnemonic(int code,char *mnemonic) -{ - int i; - i = 0; - *mnemonic = 0; - for (i=0; i< stop; i++) - if (code == scancodes[i].code) - { - strcpy(mnemonic,scancodes[i].mnemonic); - break; - } -} -#undef stop - -char busy = 0; -static FILE *fpss = NULL; -static long starttick; -static long ticks; -static int slowcount; -static unsigned int quotes; -static char calcwait = 0; -static int repeats = 0; -static int last1 = 0; - -/* places a temporary message on the screen in text mode */ -static int showtempmsg_txt(int row, int col, int attr,int secs,char *txt) -{ - int savescrn[80]; - int i; - - for (i=0; i<80; i++) - { - driver_move_cursor(row,i); - savescrn[i] = driver_get_char_attr(); - } - driver_put_string(row,col,attr,txt); - driver_hide_text_cursor(); - sleep_secs(secs); - for (i=0; i<80; i++) - { - driver_move_cursor(row,i); - driver_put_char_attr(savescrn[i]); - } - return(0); -} - -static void message(int secs, char *buf) -{ - char nearbuf[41] = { 0 }; - strncpy(nearbuf, buf, NUM_OF(nearbuf)-1); - showtempmsg_txt(0,0,7,secs,nearbuf); - if (showtempmsg(nearbuf) == 0) - { - sleep_secs(secs); - cleartempmsg(); - } -} - -/* this routine reads the file autoname and returns keystrokes */ -int slideshw() -{ - int out,err,i; - char buffer[81]; - if (calcwait) - { - if (calc_status == CALCSTAT_IN_PROGRESS || busy) /* restart timer - process not done */ - return(0); /* wait for calc to finish before reading more keystrokes */ - calcwait = 0; - } - if (fpss==NULL) /* open files first time through */ - if (startslideshow()==0) - { - stopslideshow(); - return (0); - } - - if (ticks) /* if waiting, see if waited long enough */ - { - if (clock_ticks() - starttick < ticks) /* haven't waited long enough */ - return(0); - ticks = 0; - } - if (++slowcount <= 18) - { - starttick = clock_ticks(); - ticks = CLK_TCK/5; /* a slight delay so keystrokes are visible */ - if (slowcount > 10) - ticks /= 2; - } - if (repeats>0) - { - repeats--; - return(last1); - } -start: - if (quotes) /* reading a quoted string */ - { - if ((out=fgetc(fpss)) != '\"' && out != EOF) - return(last1 = out); - quotes = 0; - } - /* skip white space: */ - while ((out=fgetc(fpss)) == ' ' || out == '\t' || out == '\n') { } - switch (out) - { - case EOF: - stopslideshow(); - return(0); - case '\"': /* begin quoted string */ - quotes = 1; - goto start; - case ';': /* comment from here to end of line, skip it */ - while ((out=fgetc(fpss)) != '\n' && out != EOF) { } - goto start; - case '*': - if (fscanf(fpss,"%d",&repeats) != 1 - || repeats <= 1 || repeats >= 256 || feof(fpss)) - { - slideshowerr("error in * argument"); - last1 = repeats = 0; - } - repeats -= 2; - return(out = last1); - } - - i = 0; - while (1) /* get a token */ - { - if (i < 80) - buffer[i++] = (char)out; - out=fgetc(fpss); - if (out == ' ' || out == '\t' || out == '\n' || out == EOF) - break; - } - buffer[i] = 0; - if (buffer[i-1] == ':') - goto start; - out = -12345; - if (isdigit(buffer[0])) /* an arbitrary scan code number - use it */ - out=atoi(buffer); - else if (strcmp((char *)buffer,"MESSAGE")==0) - { - int secs; - out = 0; - if (fscanf(fpss,"%d",&secs) != 1) - { - slideshowerr("MESSAGE needs argument"); - } - else - { - int len; - char buf[41]; - buf[40] = 0; - fgets(buf,40,fpss); - len = (int) strlen(buf); - buf[len-1]=0; /* zap newline */ - message(secs,(char *)buf); - } - out = 0; - } - else if (strcmp((char *)buffer,"GOTO")==0) - { - if (fscanf(fpss,"%s",buffer) != 1) - { - slideshowerr("GOTO needs target"); - out = 0; - } - else - { - char buffer1[80]; - rewind(fpss); - strcat(buffer,":"); - do - { - err = fscanf(fpss,"%s",buffer1); - } while ( err == 1 && strcmp(buffer1,buffer) != 0); - if (feof(fpss)) - { - slideshowerr("GOTO target not found"); - return(0); - } - goto start; - } - } - else if ((i = get_scancode(buffer)) > 0) - out = i; - else if (strcmp("WAIT",(char *)buffer)==0) - { - float fticks; - err = fscanf(fpss,"%f",&fticks); /* how many ticks to wait */ - driver_set_keyboard_timeout((int) (fticks*1000.f)); - fticks *= CLK_TCK; /* convert from seconds to ticks */ - if (err==1) - { - ticks = (long)fticks; - starttick = clock_ticks(); /* start timing */ - } - else - { - slideshowerr("WAIT needs argument"); - } - slowcount = out = 0; - } - else if (strcmp("CALCWAIT",(char *)buffer)==0) /* wait for calc to finish */ - { - calcwait = 1; - slowcount = out = 0; - } - else if ((i=check_vidmode_keyname(buffer)) != 0) - out = i; - if (out == -12345) - { - char msg[MSGLEN]; - sprintf(msg,"Can't understand %s",buffer); - slideshowerr(msg); - out = 0; - } - return(last1 = out); -} - -int -startslideshow() -{ - fpss=fopen(autoname,"r"); - if (fpss==NULL) - g_slides = SLIDES_OFF; - ticks = 0; - quotes = 0; - calcwait = 0; - slowcount = 0; - return(g_slides); -} - -void stopslideshow() -{ - if (fpss) - fclose(fpss); - fpss = NULL; - g_slides = SLIDES_OFF; -} - -void recordshw(int key) -{ - char mn[MAX_MNEMONIC]; - float dt; - dt = (float)ticks; /* save time of last call */ - ticks=clock_ticks(); /* current time */ - if (fpss==NULL) - { - fpss=fopen(autoname,"w"); - if (fpss==NULL) - return; - } - dt = ticks-dt; - dt /= CLK_TCK; /* dt now in seconds */ - if (dt > .5) /* don't bother with less than half a second */ - { - if (quotes) /* close quotes first */ - { - quotes=0; - fprintf(fpss,"\"\n"); - } - fprintf(fpss,"WAIT %4.1f\n",dt); - } - if (key >= 32 && key < 128) - { - if (!quotes) - { - quotes=1; - fputc('\"',fpss); - } - fputc(key,fpss); - } - else - { - if (quotes) /* not an ASCII character - turn off quotes */ - { - fprintf(fpss,"\"\n"); - quotes=0; - } - get_mnemonic(key,mn); - if (*mn) - fprintf(fpss,"%s",mn); - else if (check_vidmode_key(0,key) >= 0) - { - char buf[10]; - vidmode_keyname(key,buf); - fprintf(fpss,buf); - } - else /* not ASCII and not FN key */ - fprintf(fpss,"%4d",key); - fputc('\n',fpss); - } -} - -/* suspend process # of seconds */ -static void sleep_secs(int secs) -{ - long stop; - stop = clock_ticks() + (long)secs*CLK_TCK; - while (clock_ticks() < stop && kbhit() == 0) { } /* bailout if key hit */ -} - -static void slideshowerr(char *msg) -{ - char msgbuf[300] = { "Slideshow error:\n" }; - stopslideshow(); - strcat(msgbuf,msg); - stopmsg(0,msgbuf); -} diff --git a/fractint/common/soi.c b/fractint/common/soi.c deleted file mode 100644 index 90acabdba..000000000 --- a/fractint/common/soi.c +++ /dev/null @@ -1,1104 +0,0 @@ -/* - * soi.c -- SOI - * - * Simultaneous Orbit Iteration Image Generation Method. Computes - * rectangular regions by tracking the orbits of only a few key points. - * - * Copyright (c) 1994-1997 Michael R. Ganss. All Rights Reserved. - * - * This file is distributed under the same conditions as - * AlmondBread. For further information see - * . - * - */ -#include -#include -#if !defined(_WIN32) -#include -#endif -#include "port.h" -#include "prototyp.h" -#include "drivers.h" - -#define DBLS LDBL -#define FABS(x) fabsl(x) -/* the following needs to be changed back to frexpl once the portability - issue has been addressed JCO */ -#ifndef XFRACT -#define FREXP(x,y) frexpl(x,y) -#else -#define FREXP(x,y) frexp(x,y) -#endif - -#define TRUE 1 -#define FALSE 0 -#define EVERY 15 -#define BASIN_COLOR 0 - -int rhombus_stack[10]; -int rhombus_depth; -int max_rhombus_depth; -int minstackavail; -/* int minstack=1700; */ /* need this much stack to recurse */ -int minstack=2200; /* and this much stack to not crash when is pressed */ -static DBLS twidth; -static DBLS equal; -static char baxinxx = FALSE; - - -long iteration(register DBLS cr, register DBLS ci, - register DBLS re, register DBLS im, - long start) -{ - register long iter,offset=0; - int k,n; - register DBLS ren,imn,sre,sim; -#ifdef INTEL - register float mag; - register unsigned long bail=0x41800000,magi; /* bail=16.0 */ - register unsigned long eq=*(unsigned long *)&equal; -#else - register DBLS mag; -#endif - DBLS d; - int exponent; - - if (baxinxx) - { - sre=re; sim=im; - ren=re*re; - imn=im*im; - if (start!=0) - { - offset=maxit-start+7; - iter=offset>>3; - offset&=7; - offset=(8-offset); - } - else - iter=maxit>>3; - k=n=8; - - do - { - im=im*re; - re=ren-imn; - im+=im; - re+=cr; - im+=ci; - - imn=im*re; - ren=re+im; - re=re-im; - imn+=imn; - re=ren*re; - im=imn+ci; - re+=cr; - - imn=im*re; - ren=re+im; - re=re-im; - imn+=imn; - re=ren*re; - im=imn+ci; - re+=cr; - - imn=im*re; - ren=re+im; - re=re-im; - imn+=imn; - re=ren*re; - im=imn+ci; - re+=cr; - - imn=im*re; - ren=re+im; - re=re-im; - imn+=imn; - re=ren*re; - im=imn+ci; - re+=cr; - - imn=im*re; - ren=re+im; - re=re-im; - imn+=imn; - re=ren*re; - im=imn+ci; - re+=cr; - - imn=im*re; - ren=re+im; - re=re-im; - imn+=imn; - re=ren*re; - im=imn+ci; - re+=cr; - - imn=im*re; - ren=re+im; - re=re-im; - imn+=imn; - re=ren*re; - im=imn+ci; - re+=cr; - -#ifdef INTEL - mag=FABS(sre-re); - magi=*(unsigned long *)&mag; - if (magi>3; - offset&=7; - offset=(8-offset); - } - else - iter=maxit>>3; - - do - { - im=im*re; - re=ren-imn; - im+=im; - re+=cr; - im+=ci; - - imn=im*re; - ren=re+im; - re=re-im; - imn+=imn; - re=ren*re; - im=imn+ci; - re+=cr; - - imn=im*re; - ren=re+im; - re=re-im; - imn+=imn; - re=ren*re; - im=imn+ci; - re+=cr; - - imn=im*re; - ren=re+im; - re=re-im; - imn+=imn; - re=ren*re; - im=imn+ci; - re+=cr; - - imn=im*re; - ren=re+im; - re=re-im; - imn+=imn; - re=ren*re; - im=imn+ci; - re+=cr; - - imn=im*re; - ren=re+im; - re=re-im; - imn+=imn; - re=ren*re; - im=imn+ci; - re+=cr; - - imn=im*re; - ren=re+im; - re=re-im; - imn+=imn; - re=ren*re; - im=imn+ci; - re+=cr; - - imn=im*re; - ren=re+im; - re=re-im; - imn+=imn; - re=ren*re; - im=imn+ci; - re+=cr; - - imn=im*im; - ren=re*re; - mag=ren+imn; -#ifdef INTEL - magi=*(unsigned long *)&mag; -#endif - } -#ifdef INTEL - while (magi>3])); - } -} - -static void puthline(int x1,int y1,int x2,int color) -{ - int x; - for (x=x1; x<=x2; x++) - (*plot)(x,y1,color); -} - -static void putbox(int x1, int y1, int x2, int y2, int color) -{ - for (; y1<=y2; y1++) - puthline(x1,y1,x2,color); -} - -/* maximum side length beyond which we start regular scanning instead of - subdividing */ -#define SCAN 16 - -/* pixel interleave used in scanning */ -#define INTERLEAVE 4 - -/* compute the value of the interpolation polynomial at (x,y) */ -#define GET_REAL(x,y) \ -interpolate(cim1,midi,cim2,\ - interpolate(cre1,midr,cre2,zre1,zre5,zre2,x),\ - interpolate(cre1,midr,cre2,zre6,zre9,zre7,x),\ - interpolate(cre1,midr,cre2,zre3,zre8,zre4,x),y) -#define GET_IMAG(x,y) \ -interpolate(cre1,midr,cre2,\ - interpolate(cim1,midi,cim2,zim1,zim6,zim3,y),\ - interpolate(cim1,midi,cim2,zim5,zim9,zim8,y),\ - interpolate(cim1,midi,cim2,zim2,zim7,zim4,y),x) - -/* compute the value of the interpolation polynomial at (x,y) - from saved values before interpolation failed to stay within tolerance */ -#define GET_SAVED_REAL(x,y) \ -interpolate(cim1,midi,cim2,\ - interpolate(cre1,midr,cre2,sr1,sr5,sr2,x),\ - interpolate(cre1,midr,cre2,sr6,sr9,sr7,x),\ - interpolate(cre1,midr,cre2,sr3,sr8,sr4,x),y) -#define GET_SAVED_IMAG(x,y) \ -interpolate(cre1,midr,cre2,\ - interpolate(cim1,midi,cim2,si1,si6,si3,y),\ - interpolate(cim1,midi,cim2,si5,si9,si8,y),\ - interpolate(cim1,midi,cim2,si2,si7,si4,y),x) - -/* compute the value of the interpolation polynomial at (x,y) - during scanning. Here, key values do not change, so we can precompute - coefficients in one direction and simply evaluate the polynomial - during scanning. */ -#define GET_SCAN_REAL(x,y) \ -interpolate(cim1,midi,cim2,\ - EVALUATE(cre1,midr,br10,br11,br12,x),\ - EVALUATE(cre1,midr,br20,br21,br22,x),\ - EVALUATE(cre1,midr,br30,br31,br32,x),y) -#define GET_SCAN_IMAG(x,y) \ -interpolate(cre1,midr,cre2,\ - EVALUATE(cim1,midi,bi10,bi11,bi12,y),\ - EVALUATE(cim1,midi,bi20,bi21,bi22,y),\ - EVALUATE(cim1,midi,bi30,bi31,bi32,y),x) - -/* compute coefficients of Newton polynomial (b0,..,b2) from - (x0,w0),..,(x2,w2). */ -#define INTERPOLATE(x0,x1,x2,w0,w1,w2,b0,b1,b2) \ -b0=w0;\ -b1=(w1-w0)/(LDBL)(x1-x0);\ -b2=((w2-w1)/(LDBL)(x2-x1)-b1)/(x2-x0) - -/* evaluate Newton polynomial given by (x0,b0),(x1,b1) at x:=t */ -#define EVALUATE(x0,x1,b0,b1,b2,t) \ -((b2*(t-x1)+b1)*(t-x0)+b0) - -/* Newton Interpolation. - It computes the value of the interpolation polynomial given by - (x0,w0)..(x2,w2) at x:=t */ -static DBLS interpolate(DBLS x0, DBLS x1, DBLS x2, - DBLS w0, DBLS w1, DBLS w2, - DBLS t) -{ - register DBLS b0=w0,b1=w1,b2=w2,b; - - /*b0=(r0*b1-r1*b0)/(x1-x0); - b1=(r1*b2-r2*b1)/(x2-x1); - b0=(r0*b1-r2*b0)/(x2-x0); - - return (DBLS)b0;*/ - b=(b1-b0)/(x1-x0); - return (DBLS)((((b2-b1)/(x2-x1)-b)/(x2-x0))*(t-x1)+b)*(t-x0)+b0; - /* - if (t max_rhombus_depth) - max_rhombus_depth = rhombus_depth; - rhombus_stack[rhombus_depth] = avail; - - if (driver_key_pressed()) - { - status = 1; - goto rhombus_done; - } - if (iter>maxit) - { - putbox(x1,y1,x2,y2,0); - status = 0; - goto rhombus_done; - } - - if ((y2-y1<=SCAN) || (avail < minstack)) - { - /* finish up the image by scanning the rectangle */ - scan: - INTERPOLATE(cre1,midr,cre2,zre1,zre5,zre2,br10,br11,br12); - INTERPOLATE(cre1,midr,cre2,zre6,zre9,zre7,br20,br21,br22); - INTERPOLATE(cre1,midr,cre2,zre3,zre8,zre4,br30,br31,br32); - - INTERPOLATE(cim1,midi,cim2,zim1,zim6,zim3,bi10,bi11,bi12); - INTERPOLATE(cim1,midi,cim2,zim5,zim9,zim8,bi20,bi21,bi22); - INTERPOLATE(cim1,midi,cim2,zim2,zim7,zim4,bi30,bi31,bi32); - - restep=(cre2-cre1)/(x2-x1); - imstep=(cim2-cim1)/(y2-y1); - interstep=INTERLEAVE*restep; - - for (y=y1, im=cim1; yx-INTERLEAVE; z--,helpre-=restep) - { - zre=GET_SCAN_REAL(helpre,im); - zim=GET_SCAN_IMAG(helpre,im); - helpcolor=iteration(helpre,im,zre,zim,iter); - if (helpcolor < 0) - { - status = 1; - goto rhombus_done; - } - else if (helpcolor==savecolor) - break; - (*plot)(z,y,(int)(helpcolor&255)); - } - - if (savexsavex; z--,helpre-=restep) - { - zre=GET_SCAN_REAL(helpre,im); - zim=GET_SCAN_IMAG(helpre,im); - helpcolor=iteration(helpre,im,zre,zim,iter); - if (helpcolor < 0) - { - status = 1; - goto rhombus_done; - } - else if (helpcolor==savecolor) - break; - - (*plot)(z,y,(int)(helpcolor&255)); - } - - if (savex16.0|| - (rq2+iq2)>16.0|| - (rq3+iq3)>16.0|| - (rq4+iq4)>16.0|| - (rq5+iq5)>16.0|| - (rq6+iq6)>16.0|| - (rq7+iq7)>16.0|| - (rq8+iq8)>16.0|| - (rq9+iq9)>16.0|| - (trq1+tiq1)>16.0|| - (trq2+tiq2)>16.0|| - (trq3+tiq3)>16.0|| - (trq4+tiq4)>16.0) - break; - - /* if maximum number of iterations is reached, the whole rectangle - can be assumed part of M. This is of course best case behavior - of SOI, we seldomly get there */ - if (iter>maxit) - { - putbox(x1,y1,x2,y2,0); - status = 0; - goto rhombus_done; - } - - /* now for all test points, check whether they exceed the - allowed tolerance. if so, subdivide */ - l1=GET_REAL(cr1,ci1); - l1=(tzr1==0.0)? - (l1==0.0)?1.0:1000.0: - l1/tzr1; - if (FABS(1.0-l1)>twidth) - break; - - l2=GET_IMAG(cr1,ci1); - l2=(tzi1==0.0)? - (l2==0.0)?1.0:1000.0: - l2/tzi1; - if (FABS(1.0-l2)>twidth) - break; - - l1=GET_REAL(cr2,ci1); - l1=(tzr2==0.0)? - (l1==0.0)?1.0:1000.0: - l1/tzr2; - if (FABS(1.0-l1)>twidth) - break; - - l2=GET_IMAG(cr2,ci1); - l2=(tzi2==0.0)? - (l2==0.0)?1.0:1000.0: - l2/tzi2; - if (FABS(1.0-l2)>twidth) - break; - - l1=GET_REAL(cr1,ci2); - l1=(tzr3==0.0)? - (l1==0.0)?1.0:1000.0: - l1/tzr3; - if (FABS(1.0-l1)>twidth) - break; - - l2=GET_IMAG(cr1,ci2); - l2=(tzi3==0.0)? - (l2==0.0)?1.0:1000.0: - l2/tzi3; - if (FABS(1.0-l2)>twidth) - break; - - l1=GET_REAL(cr2,ci2); - l1=(tzr4==0.0)? - (l1==0.0)?1.0:1000.0: - l1/tzr4; - if (FABS(1.0-l1)>twidth) - break; - - l2=GET_IMAG(cr2,ci2); - l2=(tzi4==0.0)? - (l2==0.0)?1.0:1000.0: - l2/tzi4; - if (FABS(1.0-l2)>twidth) - break; - } - - iter--; - - /* this is a little heuristic I tried to improve performance. */ - if (iter-before<10) - { - zre1=sr1; zim1=si1; - zre2=sr2; zim2=si2; - zre3=sr3; zim3=si3; - zre4=sr4; zim4=si4; - zre5=sr5; zim5=si5; - zre6=sr6; zim6=si6; - zre7=sr7; zim7=si7; - zre8=sr8; zim8=si8; - zre9=sr9; zim9=si9; - goto scan; - } - - /* compute key values for subsequent rectangles */ - - re10=interpolate(cre1,midr,cre2,sr1,sr5,sr2,cr1); - im10=interpolate(cre1,midr,cre2,si1,si5,si2,cr1); - - re11=interpolate(cre1,midr,cre2,sr1,sr5,sr2,cr2); - im11=interpolate(cre1,midr,cre2,si1,si5,si2,cr2); - - re20=interpolate(cre1,midr,cre2,sr3,sr8,sr4,cr1); - im20=interpolate(cre1,midr,cre2,si3,si8,si4,cr1); - - re21=interpolate(cre1,midr,cre2,sr3,sr8,sr4,cr2); - im21=interpolate(cre1,midr,cre2,si3,si8,si4,cr2); - - re15=interpolate(cre1,midr,cre2,sr6,sr9,sr7,cr1); - im15=interpolate(cre1,midr,cre2,si6,si9,si7,cr1); - - re16=interpolate(cre1,midr,cre2,sr6,sr9,sr7,cr2); - im16=interpolate(cre1,midr,cre2,si6,si9,si7,cr2); - - re12=interpolate(cim1,midi,cim2,sr1,sr6,sr3,ci1); - im12=interpolate(cim1,midi,cim2,si1,si6,si3,ci1); - - re14=interpolate(cim1,midi,cim2,sr2,sr7,sr4,ci1); - im14=interpolate(cim1,midi,cim2,si2,si7,si4,ci1); - - re17=interpolate(cim1,midi,cim2,sr1,sr6,sr3,ci2); - im17=interpolate(cim1,midi,cim2,si1,si6,si3,ci2); - - re19=interpolate(cim1,midi,cim2,sr2,sr7,sr4,ci2); - im19=interpolate(cim1,midi,cim2,si2,si7,si4,ci2); - - re13=interpolate(cim1,midi,cim2,sr5,sr9,sr8,ci1); - im13=interpolate(cim1,midi,cim2,si5,si9,si8,ci1); - - re18=interpolate(cim1,midi,cim2,sr5,sr9,sr8,ci2); - im18=interpolate(cim1,midi,cim2,si5,si9,si8,ci2); - - re91=GET_SAVED_REAL(cr1,ci1); - re92=GET_SAVED_REAL(cr2,ci1); - re93=GET_SAVED_REAL(cr1,ci2); - re94=GET_SAVED_REAL(cr2,ci2); - - im91=GET_SAVED_IMAG(cr1,ci1); - im92=GET_SAVED_IMAG(cr2,ci1); - im93=GET_SAVED_IMAG(cr1,ci2); - im94=GET_SAVED_IMAG(cr2,ci2); - - RHOMBUS(cre1,midr,cim1,midi,x1,((x1+x2)>>1),y1,((y1+y2)>>1), - sr1,si1, - sr5,si5, - sr6,si6, - sr9,si9, - re10,im10, - re12,im12, - re13,im13, - re15,im15, - re91,im91, - iter); - RHOMBUS(midr,cre2,cim1,midi,(x1+x2)>>1,x2,y1,(y1+y2)>>1, - sr5,si5, - sr2,si2, - sr9,si9, - sr7,si7, - re11,im11, - re13,im13, - re14,im14, - re16,im16, - re92,im92, - iter); - RHOMBUS(cre1,midr,midi,cim2,x1,(x1+x2)>>1,(y1+y2)>>1,y2, - sr6,si6, - sr9,si9, - sr3,si3, - sr8,si8, - re15,im15, - re17,im17, - re18,im18, - re20,im20, - re93,im93, - iter); - RHOMBUS(midr,cre2,midi,cim2,(x1+x2)>>1,x2,(y1+y2)>>1,y2, - sr9,si9, - sr7,si7, - sr8,si8, - sr4,si4, - re16,im16, - re18,im18, - re19,im19, - re21,im21, - re94,im94, - iter); -rhombus_done: - rhombus_depth--; - return(status); -} - -void soi_ldbl(void) -{ - int status; - DBLS tolerance=0.1; - DBLS stepx, stepy; - DBLS xxminl, xxmaxl, yyminl, yymaxl; - minstackavail = 30000; - rhombus_depth = -1; - max_rhombus_depth = 0; - if (bf_math) - { - xxminl = bftofloat(bfxmin); - yyminl = bftofloat(bfymin); - xxmaxl = bftofloat(bfxmax); - yymaxl = bftofloat(bfymax); - } - else - { - xxminl = xxmin; - yyminl = yymin; - xxmaxl = xxmax; - yymaxl = yymax; - } - twidth=tolerance/(xdots-1); - stepx = (xxmaxl - xxminl) / xdots; - stepy = (yyminl - yymaxl) / ydots; - equal = (stepx < stepy ? stepx : stepy); - - RHOMBUS(xxminl,xxmaxl,yymaxl,yyminl, - 0,xdots,0,ydots, - xxminl,yymaxl, - xxmaxl,yymaxl, - xxminl,yyminl, - xxmaxl,yyminl, - (xxmaxl+xxminl)/2,yymaxl, - xxminl,(yymaxl+yyminl)/2, - xxmaxl,(yymaxl+yyminl)/2, - (xxmaxl+xxminl)/2,yyminl, - (xxminl+xxmaxl)/2,(yymaxl+yyminl)/2, - 1); -} diff --git a/fractint/common/soi1.c b/fractint/common/soi1.c deleted file mode 100644 index 3bd331e69..000000000 --- a/fractint/common/soi1.c +++ /dev/null @@ -1,953 +0,0 @@ -/* - * soi.c -- SOI - * - * Simultaneous Orbit Iteration Image Generation Method. Computes - * rectangular regions by tracking the orbits of only a few key points. - * - * Copyright (c) 1994-1997 Michael R. Ganss. All Rights Reserved. - * - * This file is distributed under the same conditions as - * AlmondBread. For further information see - * . - * - */ -#include -#include -#if !defined(_WIN32) -#include -#endif -#include "port.h" -#include "prototyp.h" -#include "drivers.h" - -#define DBLS double -#define FABS(x) fabs(x) -#define FREXP(x,y) frexp(x,y) - -#define TRUE 1 -#define FALSE 0 -#define EVERY 15 -#define BASIN_COLOR 0 - -extern int rhombus_stack[10]; -extern int rhombus_depth; -extern int max_rhombus_depth; -extern int minstackavail; -extern int minstack; /* need this much stack to recurse */ -static DBLS twidth; -static DBLS equal; - -#if 0 -static long iteration1(register DBLS cr, register DBLS ci, - register DBLS re, register DBLS im, - long start) -{ - DBLS oldreal, oldimag, newreal, newimag, magnitude; - long color; - magnitude = 0.0; - color = start; - oldreal = re; - oldimag = im; - while ((magnitude < 16.0) && (color < maxit)) { - newreal = oldreal * oldreal - oldimag * oldimag + cr; - newimag = 2 * oldreal * oldimag + ci; - color++; - oldreal = newreal; - oldimag = newimag; - magnitude = newreal * newreal + newimag * newimag; - } - if (color >= maxit) color = BASIN_COLOR; - return((int)color); -} -#endif - -static long iteration(register DBLS cr, register DBLS ci, - register DBLS re, register DBLS im, - long start) -{ - old.x = re; - old.y = im; - tempsqrx = sqr(old.x); - tempsqry = sqr(old.y); - floatparm = &init; - floatparm->x = cr; - floatparm->y = ci; - while (ORBITCALC()==0 && start < maxit) - start++; - if (start >= maxit) - start = BASIN_COLOR; - return(start); -} -#if 0 -JuliafpFractal() -{ - /* floating point version of classical Mandelbrot/Julia */ - new.x = tempsqrx - tempsqry + floatparm->x; - new.y = 2.0 * old.x * old.y + floatparm->y; - return(floatbailout()); -} -#endif - -static void puthline(int x1,int y1,int x2,int color) -{ - int x; - for (x=x1; x<=x2; x++) - (*plot)(x,y1,color); -} - -static void putbox(int x1, int y1, int x2, int y2, int color) -{ - for (; y1<=y2; y1++) - puthline(x1,y1,x2,color); -} - -/* maximum side length beyond which we start regular scanning instead of - subdividing */ -#define SCAN 16 - -/* pixel interleave used in scanning */ -#define INTERLEAVE 4 - -/* compute the value of the interpolation polynomial at (x,y) */ -#define GET_REAL(x,y) \ -interpolate(cim1,midi,cim2,\ - interpolate(cre1,midr,cre2,zre1,zre5,zre2,x),\ - interpolate(cre1,midr,cre2,zre6,zre9,zre7,x),\ - interpolate(cre1,midr,cre2,zre3,zre8,zre4,x),y) -#define GET_IMAG(x,y) \ -interpolate(cre1,midr,cre2,\ - interpolate(cim1,midi,cim2,zim1,zim6,zim3,y),\ - interpolate(cim1,midi,cim2,zim5,zim9,zim8,y),\ - interpolate(cim1,midi,cim2,zim2,zim7,zim4,y),x) - -/* compute the value of the interpolation polynomial at (x,y) - from saved values before interpolation failed to stay within tolerance */ -#define GET_SAVED_REAL(x,y) \ -interpolate(cim1,midi,cim2,\ - interpolate(cre1,midr,cre2,sr1,sr5,sr2,x),\ - interpolate(cre1,midr,cre2,sr6,sr9,sr7,x),\ - interpolate(cre1,midr,cre2,sr3,sr8,sr4,x),y) -#define GET_SAVED_IMAG(x,y) \ -interpolate(cre1,midr,cre2,\ - interpolate(cim1,midi,cim2,si1,si6,si3,y),\ - interpolate(cim1,midi,cim2,si5,si9,si8,y),\ - interpolate(cim1,midi,cim2,si2,si7,si4,y),x) - -/* compute the value of the interpolation polynomial at (x,y) - during scanning. Here, key values do not change, so we can precompute - coefficients in one direction and simply evaluate the polynomial - during scanning. */ -#define GET_SCAN_REAL(x,y) \ -interpolate(cim1,midi,cim2,\ - EVALUATE(cre1,midr,br10,br11,br12,x),\ - EVALUATE(cre1,midr,br20,br21,br22,x),\ - EVALUATE(cre1,midr,br30,br31,br32,x),y) -#define GET_SCAN_IMAG(x,y) \ -interpolate(cre1,midr,cre2,\ - EVALUATE(cim1,midi,bi10,bi11,bi12,y),\ - EVALUATE(cim1,midi,bi20,bi21,bi22,y),\ - EVALUATE(cim1,midi,bi30,bi31,bi32,y),x) - -/* compute coefficients of Newton polynomial (b0,..,b2) from - (x0,w0),..,(x2,w2). */ -#define INTERPOLATE(x0,x1,x2,w0,w1,w2,b0,b1,b2) \ -b0=w0;\ -b1=(w1-w0)/(x1-x0);\ -b2=((w2-w1)/(x2-x1)-b1)/(x2-x0) - -/* evaluate Newton polynomial given by (x0,b0),(x1,b1) at x:=t */ -#define EVALUATE(x0,x1,b0,b1,b2,t) \ -((b2*(t-x1)+b1)*(t-x0)+b0) - -/* Newton Interpolation. - It computes the value of the interpolation polynomial given by - (x0,w0)..(x2,w2) at x:=t */ -static DBLS interpolate(DBLS x0, DBLS x1, DBLS x2, - DBLS w0, DBLS w1, DBLS w2, - DBLS t) -{ - register DBLS b0=w0,b1=w1,b2=w2,b; - - /*b0=(r0*b1-r1*b0)/(x1-x0); - b1=(r1*b2-r2*b1)/(x2-x1); - b0=(r0*b1-r2*b0)/(x2-x0); - - return (DBLS)b0;*/ - b=(b1-b0)/(x1-x0); - return (DBLS)((((b2-b1)/(x2-x1)-b)/(x2-x0))*(t-x1)+b)*(t-x0)+b0; - /* - if (t max_rhombus_depth) - max_rhombus_depth = rhombus_depth; - rhombus_stack[rhombus_depth] = avail; - - if (driver_key_pressed()) - { - status = 1; - goto rhombus_done; - } - if (iter>maxit) - { - putbox(x1,y1,x2,y2,0); - status = 0; - goto rhombus_done; - } - - if ((y2-y1<=SCAN) || (avail < minstack)) - { - /* finish up the image by scanning the rectangle */ - scan: - INTERPOLATE(cre1,midr,cre2,zre1,zre5,zre2,br10,br11,br12); - INTERPOLATE(cre1,midr,cre2,zre6,zre9,zre7,br20,br21,br22); - INTERPOLATE(cre1,midr,cre2,zre3,zre8,zre4,br30,br31,br32); - - INTERPOLATE(cim1,midi,cim2,zim1,zim6,zim3,bi10,bi11,bi12); - INTERPOLATE(cim1,midi,cim2,zim5,zim9,zim8,bi20,bi21,bi22); - INTERPOLATE(cim1,midi,cim2,zim2,zim7,zim4,bi30,bi31,bi32); - - restep=(cre2-cre1)/(x2-x1); - imstep=(cim2-cim1)/(y2-y1); - interstep=INTERLEAVE*restep; - - for (y=y1, im=cim1; yx-INTERLEAVE; z--,helpre-=restep) - { - zre=GET_SCAN_REAL(helpre,im); - zim=GET_SCAN_IMAG(helpre,im); - helpcolor=iteration(helpre,im,zre,zim,iter); - if (helpcolor < 0) - { - status = 1; - goto rhombus_done; - } - else if (helpcolor==savecolor) - break; - (*plot)(z,y,(int)(helpcolor&255)); - } - - if (savexsavex; z--,helpre-=restep) - { - zre=GET_SCAN_REAL(helpre,im); - zim=GET_SCAN_IMAG(helpre,im); - helpcolor=iteration(helpre,im,zre,zim,iter); - if (helpcolor < 0) - { - status = 1; - goto rhombus_done; - } - else if (helpcolor==savecolor) - break; - - (*plot)(z,y,(int)(helpcolor&255)); - } - - if (savexx = cr;\ - floatparm->y = ci;\ - esc = ORBITCALC();\ - rq = tempsqrx;\ - iq = tempsqry;\ - zr = new.x;\ - zi = new.y - -#define SOI_ORBIT(zr,rq,zi,iq,cr,ci,esc) \ - zi=(zi+zi)*zr+ci;\ - zr=rq-iq+cr;\ - rq=zr*zr;\ - iq=zi*zi;\ - esc = ((rq+iq)>16.0)?1:0 - - /* iterate key values */ - SOI_ORBIT(zre1,rq1,zim1,iq1,cre1,cim1,esc1); -/* - zim1=(zim1+zim1)*zre1+cim1; - zre1=rq1-iq1+cre1; - rq1=zre1*zre1; - iq1=zim1*zim1; -*/ - SOI_ORBIT(zre2,rq2,zim2,iq2,cre2,cim1,esc2); -/* - zim2=(zim2+zim2)*zre2+cim1; - zre2=rq2-iq2+cre2; - rq2=zre2*zre2; - iq2=zim2*zim2; -*/ - SOI_ORBIT(zre3,rq3,zim3,iq3,cre1,cim2,esc3); -/* - zim3=(zim3+zim3)*zre3+cim2; - zre3=rq3-iq3+cre1; - rq3=zre3*zre3; - iq3=zim3*zim3; -*/ - SOI_ORBIT(zre4,rq4,zim4,iq4,cre2,cim2,esc4); -/* - zim4=(zim4+zim4)*zre4+cim2; - zre4=rq4-iq4+cre2; - rq4=zre4*zre4; - iq4=zim4*zim4; -*/ - SOI_ORBIT(zre5,rq5,zim5,iq5,midr,cim1,esc5); -/* - zim5=(zim5+zim5)*zre5+cim1; - zre5=rq5-iq5+midr; - rq5=zre5*zre5; - iq5=zim5*zim5; -*/ - SOI_ORBIT(zre6,rq6,zim6,iq6,cre1,midi,esc6); -/* - zim6=(zim6+zim6)*zre6+midi; - zre6=rq6-iq6+cre1; - rq6=zre6*zre6; - iq6=zim6*zim6; -*/ - SOI_ORBIT(zre7,rq7,zim7,iq7,cre2,midi,esc7); -/* - zim7=(zim7+zim7)*zre7+midi; - zre7=rq7-iq7+cre2; - rq7=zre7*zre7; - iq7=zim7*zim7; -*/ - SOI_ORBIT(zre8,rq8,zim8,iq8,midr,cim2,esc8); -/* - zim8=(zim8+zim8)*zre8+cim2; - zre8=rq8-iq8+midr; - rq8=zre8*zre8; - iq8=zim8*zim8; -*/ - SOI_ORBIT(zre9,rq9,zim9,iq9,midr,midi,esc9); -/* - zim9=(zim9+zim9)*zre9+midi; - zre9=rq9-iq9+midr; - rq9=zre9*zre9; - iq9=zim9*zim9; -*/ - /* iterate test point */ - SOI_ORBIT(tzr1,trq1,tzi1,tiq1,cr1,ci1,tesc1); -/* - tzi1=(tzi1+tzi1)*tzr1+ci1; - tzr1=trq1-tiq1+cr1; - trq1=tzr1*tzr1; - tiq1=tzi1*tzi1; -*/ - - SOI_ORBIT(tzr2,trq2,tzi2,tiq2,cr2,ci1,tesc2); -/* - tzi2=(tzi2+tzi2)*tzr2+ci1; - tzr2=trq2-tiq2+cr2; - trq2=tzr2*tzr2; - tiq2=tzi2*tzi2; -*/ - SOI_ORBIT(tzr3,trq3,tzi3,tiq3,cr1,ci2,tesc3); -/* - tzi3=(tzi3+tzi3)*tzr3+ci2; - tzr3=trq3-tiq3+cr1; - trq3=tzr3*tzr3; - tiq3=tzi3*tzi3; -*/ - SOI_ORBIT(tzr4,trq4,tzi4,tiq4,cr2,ci2,tesc4); -/* - tzi4=(tzi4+tzi4)*tzr4+ci2; - tzr4=trq4-tiq4+cr2; - trq4=tzr4*tzr4; - tiq4=tzi4*tzi4; -*/ - iter++; - - /* if one of the iterated values bails out, subdivide */ -/* - if ((rq1+iq1)>16.0|| - (rq2+iq2)>16.0|| - (rq3+iq3)>16.0|| - (rq4+iq4)>16.0|| - (rq5+iq5)>16.0|| - (rq6+iq6)>16.0|| - (rq7+iq7)>16.0|| - (rq8+iq8)>16.0|| - (rq9+iq9)>16.0|| - (trq1+tiq1)>16.0|| - (trq2+tiq2)>16.0|| - (trq3+tiq3)>16.0|| - (trq4+tiq4)>16.0) - break; -*/ - if (esc1||esc2||esc3||esc4||esc5||esc6||esc7||esc8||esc9|| - tesc1||tesc2||tesc3||tesc4) - break; - - /* if maximum number of iterations is reached, the whole rectangle - can be assumed part of M. This is of course best case behavior - of SOI, we seldomly get there */ - if (iter>maxit) - { - putbox(x1,y1,x2,y2,0); - status = 0; - goto rhombus_done; - } - - /* now for all test points, check whether they exceed the - allowed tolerance. if so, subdivide */ - l1=GET_REAL(cr1,ci1); - l1=(tzr1==0.0)? - (l1==0.0)?1.0:1000.0: - l1/tzr1; - if (FABS(1.0-l1)>twidth) - break; - - l2=GET_IMAG(cr1,ci1); - l2=(tzi1==0.0)? - (l2==0.0)?1.0:1000.0: - l2/tzi1; - if (FABS(1.0-l2)>twidth) - break; - - l1=GET_REAL(cr2,ci1); - l1=(tzr2==0.0)? - (l1==0.0)?1.0:1000.0: - l1/tzr2; - if (FABS(1.0-l1)>twidth) - break; - - l2=GET_IMAG(cr2,ci1); - l2=(tzi2==0.0)? - (l2==0.0)?1.0:1000.0: - l2/tzi2; - if (FABS(1.0-l2)>twidth) - break; - - l1=GET_REAL(cr1,ci2); - l1=(tzr3==0.0)? - (l1==0.0)?1.0:1000.0: - l1/tzr3; - if (FABS(1.0-l1)>twidth) - break; - - l2=GET_IMAG(cr1,ci2); - l2=(tzi3==0.0)? - (l2==0.0)?1.0:1000.0: - l2/tzi3; - if (FABS(1.0-l2)>twidth) - break; - - l1=GET_REAL(cr2,ci2); - l1=(tzr4==0.0)? - (l1==0.0)?1.0:1000.0: - l1/tzr4; - if (FABS(1.0-l1)>twidth) - break; - - l2=GET_IMAG(cr2,ci2); - l2=(tzi4==0.0)? - (l2==0.0)?1.0:1000.0: - l2/tzi4; - if (FABS(1.0-l2)>twidth) - break; - } - - iter--; - - /* this is a little heuristic I tried to improve performance. */ - if (iter-before<10) - { - zre1=sr1; zim1=si1; - zre2=sr2; zim2=si2; - zre3=sr3; zim3=si3; - zre4=sr4; zim4=si4; - zre5=sr5; zim5=si5; - zre6=sr6; zim6=si6; - zre7=sr7; zim7=si7; - zre8=sr8; zim8=si8; - zre9=sr9; zim9=si9; - goto scan; - } - - /* compute key values for subsequent rectangles */ - - re10=interpolate(cre1,midr,cre2,sr1,sr5,sr2,cr1); - im10=interpolate(cre1,midr,cre2,si1,si5,si2,cr1); - - re11=interpolate(cre1,midr,cre2,sr1,sr5,sr2,cr2); - im11=interpolate(cre1,midr,cre2,si1,si5,si2,cr2); - - re20=interpolate(cre1,midr,cre2,sr3,sr8,sr4,cr1); - im20=interpolate(cre1,midr,cre2,si3,si8,si4,cr1); - - re21=interpolate(cre1,midr,cre2,sr3,sr8,sr4,cr2); - im21=interpolate(cre1,midr,cre2,si3,si8,si4,cr2); - - re15=interpolate(cre1,midr,cre2,sr6,sr9,sr7,cr1); - im15=interpolate(cre1,midr,cre2,si6,si9,si7,cr1); - - re16=interpolate(cre1,midr,cre2,sr6,sr9,sr7,cr2); - im16=interpolate(cre1,midr,cre2,si6,si9,si7,cr2); - - re12=interpolate(cim1,midi,cim2,sr1,sr6,sr3,ci1); - im12=interpolate(cim1,midi,cim2,si1,si6,si3,ci1); - - re14=interpolate(cim1,midi,cim2,sr2,sr7,sr4,ci1); - im14=interpolate(cim1,midi,cim2,si2,si7,si4,ci1); - - re17=interpolate(cim1,midi,cim2,sr1,sr6,sr3,ci2); - im17=interpolate(cim1,midi,cim2,si1,si6,si3,ci2); - - re19=interpolate(cim1,midi,cim2,sr2,sr7,sr4,ci2); - im19=interpolate(cim1,midi,cim2,si2,si7,si4,ci2); - - re13=interpolate(cim1,midi,cim2,sr5,sr9,sr8,ci1); - im13=interpolate(cim1,midi,cim2,si5,si9,si8,ci1); - - re18=interpolate(cim1,midi,cim2,sr5,sr9,sr8,ci2); - im18=interpolate(cim1,midi,cim2,si5,si9,si8,ci2); - - re91=GET_SAVED_REAL(cr1,ci1); - re92=GET_SAVED_REAL(cr2,ci1); - re93=GET_SAVED_REAL(cr1,ci2); - re94=GET_SAVED_REAL(cr2,ci2); - - im91=GET_SAVED_IMAG(cr1,ci1); - im92=GET_SAVED_IMAG(cr2,ci1); - im93=GET_SAVED_IMAG(cr1,ci2); - im94=GET_SAVED_IMAG(cr2,ci2); - - RHOMBUS(cre1,midr,cim1,midi,x1,((x1+x2)>>1),y1,((y1+y2)>>1), - sr1,si1, - sr5,si5, - sr6,si6, - sr9,si9, - re10,im10, - re12,im12, - re13,im13, - re15,im15, - re91,im91, - iter); - RHOMBUS(midr,cre2,cim1,midi,(x1+x2)>>1,x2,y1,(y1+y2)>>1, - sr5,si5, - sr2,si2, - sr9,si9, - sr7,si7, - re11,im11, - re13,im13, - re14,im14, - re16,im16, - re92,im92, - iter); - RHOMBUS(cre1,midr,midi,cim2,x1,(x1+x2)>>1,(y1+y2)>>1,y2, - sr6,si6, - sr9,si9, - sr3,si3, - sr8,si8, - re15,im15, - re17,im17, - re18,im18, - re20,im20, - re93,im93, - iter); - RHOMBUS(midr,cre2,midi,cim2,(x1+x2)>>1,x2,(y1+y2)>>1,y2, - sr9,si9, - sr7,si7, - sr8,si8, - sr4,si4, - re16,im16, - re18,im18, - re19,im19, - re21,im21, - re94,im94, - iter); -rhombus_done: - rhombus_depth--; - return(status); -} - -void soi(void) -{ - int status; - DBLS tolerance=0.1; - DBLS stepx, stepy; - DBLS xxminl, xxmaxl, yyminl, yymaxl; - minstackavail = 30000; - rhombus_depth = -1; - max_rhombus_depth = 0; - if (bf_math) - { - xxminl = (DBLS)bftofloat(bfxmin); - yyminl = (DBLS)bftofloat(bfymin); - xxmaxl = (DBLS)bftofloat(bfxmax); - yymaxl = (DBLS)bftofloat(bfymax); - } - else - { - xxminl = xxmin; - yyminl = yymin; - xxmaxl = xxmax; - yymaxl = yymax; - } - twidth=tolerance/(xdots-1); - stepx = (xxmaxl - xxminl) / xdots; - stepy = (yyminl - yymaxl) / ydots; - equal = (stepx < stepy ? stepx : stepy); - - RHOMBUS(xxminl,xxmaxl,yymaxl,yyminl, - 0,xdots,0,ydots, - xxminl,yymaxl, - xxmaxl,yymaxl, - xxminl,yyminl, - xxmaxl,yyminl, - (xxmaxl+xxminl)/2,yymaxl, - xxminl,(yymaxl+yyminl)/2, - xxmaxl,(yymaxl+yyminl)/2, - (xxmaxl+xxminl)/2,yyminl, - (xxminl+xxmaxl)/2,(yymaxl+yyminl)/2, - 1); -} diff --git a/fractint/common/stereo.c b/fractint/common/stereo.c deleted file mode 100644 index a12d82a94..000000000 --- a/fractint/common/stereo.c +++ /dev/null @@ -1,363 +0,0 @@ -/* - STEREO.C a module to view 3D images. - Written in Borland 'C++' by Paul de Leeuw. - From an idea in "New Scientist" 9 October 1993 pages 26 - 29. - - Change History: - 11 June 94 - Modified to reuse existing Fractint arrays TW - 11 July 94 - Added depth parameter PDL - 14 July 94 - Added grayscale option and did general cleanup TW - 19 July 94 - Fixed negative depth PDL - 19 July 94 - Added calibration bars, get_min_max() TW - 24 Sep 94 - Added image save/restore, color cycle, and save TW - 28 Sep 94 - Added image map TW - 20 Mar 95 - Fixed endless loop bug with bad depth values TW - 23 Mar 95 - Allow arbitrary dimension image maps TW - - (TW is Tim Wegner, PDL is Paul de Leeuw) -*/ - -#include -#include - - /* see Fractint.c for a description of the "include" hierarchy */ -#include "port.h" -#include "prototyp.h" -#include "drivers.h" -#include "helpdefs.h" - -char stereomapname[FILE_MAX_DIR+1] = {""}; -int AutoStereo_depth = 100; -double AutoStereo_width = 10; -char grayflag = 0; /* flag to use gray value rather than color - * number */ -char calibrate = 1; /* add calibration bars to image */ -char image_map = 0; - -/* this structure permits variables to be temporarily static and visible - to routines in this file without permanently hogging memory */ - -static struct static_vars -{ - long avg; - long avgct; - long depth; - int barheight; - int ground; - int maxcc; - int maxc; - int minc; - int reverse; - int sep; - double width; - int x1; - int x2; - int xcen; - int y; - int y1; - int y2; - int ycen; - BYTE *savedac; -} *pv; - -#define AVG (pv->avg) -#define AVGCT (pv->avgct) -#define DEPTH (pv->depth) -#define BARHEIGHT (pv->barheight) -#define GROUND (pv->ground) -#define MAXCC (pv->maxcc) -#define MAXC (pv->maxc) -#define MINC (pv->minc) -#define REVERSE (pv->reverse) -#define SEP (pv->sep) -#define WIDTH (pv->width) -#define X1 (pv->x1) -#define X2 (pv->x2) -#define Y (pv->y) -#define Y1 (pv->y1) -#define Y2 (pv->y2) -#define XCEN (pv->xcen) -#define YCEN (pv->ycen) - -/* - The getdepth() function allows using the grayscale value of the color - as DEPTH, rather than the color number. Maybe I got a little too - sophisticated trying to avoid a divide, so the comment tells what all - the multiplies and shifts are trying to do. The result should be from - 0 to 255. -*/ - -typedef BYTE (*DACBOX)[256][3]; -#define dac (*((DACBOX)(pv->savedac))) - -static int getdepth(int xd, int yd) -{ - int pal; - pal = getcolor(xd, yd); - if (grayflag) - { - /* effectively (30*R + 59*G + 11*B)/100 scaled 0 to 255 */ - pal = ((int) dac[pal][0] * 77 + - (int) dac[pal][1] * 151 + - (int) dac[pal][2] * 28); - pal >>= 6; - } - return (pal); -} - -/* - Get min and max DEPTH value in picture -*/ - -static int get_min_max(void) -{ - int xd, yd, ldepth; - MINC = colors; - MAXC = 0; - for (yd = 0; yd < ydots; yd++) - { - if (driver_key_pressed()) - return (1); - if (yd == 20) - showtempmsg("Getting min and max"); - for (xd = 0; xd < xdots; xd++) - { - ldepth = getdepth(xd,yd); - if ( ldepth < MINC) - MINC = ldepth; - if (ldepth > MAXC) - MAXC = ldepth; - } - } - cleartempmsg(); - return(0); -} - -void toggle_bars(int *bars, int barwidth, int *colour) -{ - int i, j, ct; - find_special_colors(); - ct = 0; - for (i = XCEN; i < (XCEN) + barwidth; i++) - for (j = YCEN; j < (YCEN) + BARHEIGHT; j++) - { - if (*bars) - { - putcolor(i + (int)(AVG), j , g_color_bright); - putcolor(i - (int)(AVG), j , g_color_bright); - } - else - { - putcolor(i + (int)(AVG), j, colour[ct++]); - putcolor(i - (int)(AVG), j, colour[ct++]); - } - } - *bars = 1 - *bars; -} - -int outline_stereo(BYTE * pixels, int linelen) -{ - int i, j, x, s; - int *same = _alloca(sizeof(int)*xdots); - int *colour = _alloca(sizeof(int)*xdots); - if ((Y) >= ydots) - return(1); - - for (x = 0; x < xdots; ++x) - same[x] = x; - for (x = 0; x < xdots; ++x) - { - if (REVERSE) - SEP = GROUND - (int) (DEPTH * (getdepth(x, Y) - MINC) / MAXCC); - else - SEP = GROUND - (int) (DEPTH * (MAXCC - (getdepth(x, Y) - MINC)) / MAXCC); - SEP = (int)((SEP * 10.0) / WIDTH); /* adjust for media WIDTH */ - - /* get average value under calibration bars */ - if (X1 <= x && x <= X2 && Y1 <= Y && Y <= Y2) - { - AVG += SEP; - (AVGCT)++; - } - i = x - (SEP + (SEP & Y & 1)) / 2; - j = i + SEP; - if (0 <= i && j < xdots) - { - /* there are cases where next never terminates so we timeout */ - int ct = 0; - for (s = same[i]; s != i && s != j && ct++ < xdots; s = same[i]) - { - if (s > j) - { - same[i] = j; - i = j; - j = s; - } - else - i = s; - } - same[i] = j; - } - } - for (x = xdots - 1; x >= 0; x--) - { - if (same[x] == x) - /* colour[x] = rand()%colors; */ - colour[x] = (int)pixels[x%linelen]; - else - colour[x] = colour[same[x]]; - putcolor(x, Y, colour[x]); - } - (Y)++; - return(0); -} - - -/************************************************************************** - Convert current image into Auto Stereo Picture -**************************************************************************/ - -int do_AutoStereo(void) -{ - struct static_vars v; - BYTE savedacbox[256*3]; - int oldhelpmode, ret=0; - int i, j, done; - int bars, ct, kbdchar, barwidth; - time_t ltime; - unsigned char *buf = (unsigned char *)decoderline; - /* following two lines re-use existing arrays in Fractint */ - int *same = _alloca(sizeof(int)*xdots); - int *colour = _alloca(sizeof(int)*xdots); - - pv = &v; /* set static vars to stack structure */ - pv->savedac = savedacbox; - - /* Use the current time to randomize the random number sequence. */ - time(<ime); - srand((unsigned int)ltime); - - oldhelpmode = helpmode; - helpmode = RDSKEYS; - driver_save_graphics(); /* save graphics image */ - memcpy(savedacbox, g_dac_box, 256 * 3); /* save colors */ - - if (xdots > OLDMAXPIXELS) - { - stopmsg(0, "Stereo not allowed with resolution > 2048 pixels wide"); - driver_buzzer(BUZZER_INTERRUPT); - ret = 1; - goto exit_stereo; - } - - /* empircally determined adjustment to make WIDTH scale correctly */ - WIDTH = AutoStereo_width*.67; - if (WIDTH < 1) - WIDTH = 1; - GROUND = xdots / 8; - if (AutoStereo_depth < 0) - REVERSE = 1; - else - REVERSE = 0; - DEPTH = ((long) xdots * (long) AutoStereo_depth) / 4000L; - DEPTH = labs(DEPTH) + 1; - if (get_min_max()) - { - driver_buzzer(BUZZER_INTERRUPT); - ret = 1; - goto exit_stereo; - } - MAXCC = MAXC - MINC + 1; - AVG = AVGCT = 0L; - barwidth = 1 + xdots / 200; - BARHEIGHT = 1 + ydots / 20; - XCEN = xdots/2; - if (calibrate > 1) - YCEN = BARHEIGHT/2; - else - YCEN = ydots/2; - - /* box to average for calibration bars */ - X1 = XCEN - xdots/16; - X2 = XCEN + xdots/16; - Y1 = YCEN - BARHEIGHT/2; - Y2 = YCEN + BARHEIGHT/2; - - Y = 0; - if (image_map) - { - outln = outline_stereo; - while ((Y) < ydots) - if (gifview()) - { - ret = 1; - goto exit_stereo; - } - } - else - { - while (Y < ydots) - { - if (driver_key_pressed()) - { - ret = 1; - goto exit_stereo; - } - for (i=0; i -#ifndef XFRACT -#include -#endif - - /* see Fractint.c for a description of the "include" hierarchy */ -#include "port.h" -#include "prototyp.h" -#include "targa.h" -#include "drivers.h" - -/************* ****************/ - -void WriteTGA( int x, int y, int index ); -int ReadTGA ( int x, int y ); -void EndTGA ( void ); -void StartTGA( void ); -void ReopenTGA( void ); - -/************* ****************/ - -static unsigned _fastcall near Row16Calculate(unsigned,unsigned); -static void _fastcall near PutPix16(int,int,int); -static unsigned _fastcall near GetPix16(int,int); -static unsigned _fastcall near Row32Calculate(unsigned,unsigned); -static void _fastcall near PutPix32(int,int,int); -static unsigned _fastcall near GetPix32(int,int); -static void _fastcall near DoFirstPixel(int,int,int); -static void _fastcall fatalerror(char *); -static int GetLine(int); -static void _fastcall near SetDispReg(int,int); -static int VWait(void); -static void _fastcall SetVBorder(int,int); -static void _fastcall SetBorderColor(long); -static void _fastcall SetVertShift(int); -static void _fastcall SetInterlace(int); -static void _fastcall SetBlndReg(int); -static void _fastcall SetRGBorCV(int); -static void _fastcall SetVCRorCamera(int); -static void _fastcall SetMask(int); -static void _fastcall SetBlndReg(int); -static void _fastcall SetContrast(int); -static void _fastcall SetHue(int); -static void _fastcall SetSaturation(int); -static void _fastcall SetHBorder(int,int); -static void SetFixedRegisters(void); -static void _fastcall VCenterDisplay(int); -static void _fastcall SetOverscan(int); -static void _fastcall near TSetMode(int); -static int GraphInit(void); -static void GraphEnd(void); - -/************* ****************/ - -int xorTARGA; -unsigned *tga16 = NULL; /* [256] */ -long *tga32; /* [256] */ -static int last = 0; - -/************* ****************/ - -static int initialized; - -/************* ****************/ - -static void (near _fastcall *DoPixel) ( int x, int y, int index ); -static void (near _fastcall *PutPixel)( int x, int y, int index ); -static unsigned (near _fastcall *GetPixel)( int x, int y ); - -/**************************************************************************/ -#ifdef __BORLANDC__ -#if(__BORLANDC__ > 2) - #pragma warn -eff -#endif -#endif - -static unsigned _fastcall near Row16Calculate( unsigned line, unsigned x1 ) -{ - outp( DESTREG, (line >> 5) ); - return( ((line & 31) << 10) | (x1 << 1) ); /* calc the pixel offset */ -} - -/**************************************************************************/ - -static void _fastcall near PutPix16( int x, int y, int index ) -{ -unsigned * ip; - - /**************/ - ip = MK_FP( (void *) MEMSEG, (void *) Row16Calculate( y, x ) ); - if( ! xorTARGA ) - *ip = tga16[index]; - else - *ip = *ip ^ 0x7fff; -} - -/**************************************************************************/ - -static unsigned _fastcall near GetPix16( int x, int y ) -{ -register unsigned pixel, index; -unsigned * ip; - /**************/ - ip = MK_FP( MEMSEG, Row16Calculate( y, x ) ); - pixel = *ip & 0x7FFF; - if( pixel == tga16[last] ) return( last ); - for( index = 0; index < 256; index++ ) - if( pixel == tga16[index] ) { - last = index; - return( index ); - } - return( 0 ); -} - -/**************************************************************************/ - -static unsigned _fastcall near Row32Calculate( unsigned line, unsigned x1 ) -{ - outp( DESTREG, (line >> 4) ); - return ( ((line & 15) << 11) | (x1 << 2) ); /* calc the pixel offset */ -} - -/**************************************************************************/ - -static void _fastcall near PutPix32( int x, int y, int index ) -{ -long * lp; - lp = MK_FP( MEMSEG, Row32Calculate( y, x ) ); - if( ! xorTARGA ) - *lp = tga32[index]; - else - *lp = *lp ^ 0x00FFFFFFL; -} - -/**************************************************************************/ - -static unsigned _fastcall near GetPix32( int x, int y ) -{ -register int index; -long pixel; -long * lp; - - lp = MK_FP( MEMSEG, Row32Calculate( y, x ) ); - pixel = *lp & 0x00FFFFFFL; - if( pixel == tga32[last] ) return( last ); - for( index = 0; index < 256; index++ ) - if( pixel == tga32[index] ) { - last = index; - return( index ); - } - return( 0 ); -} - -/**************************************************************************/ - -static void _fastcall near DoFirstPixel( int x, int y, int index ) -{ -int cnt; - TSetMode( targa.mode | 1 ); - for( cnt = 0; cnt < targa.MaxBanks; cnt += 2 ) { /* erase */ - outp( DESTREG, cnt ); - outp( SRCREG, cnt + 1 ); - erasesegment(targa.memloc,0); /** general.asm **/ - } - TSetMode( targa.mode & 0xFFFE ); - PutPixel = DoPixel; - (*PutPixel)( x, y, index ); -} - -#ifdef __BORLANDC__ -#if(__BORLANDC__ > 2) - #pragma warn +eff -#endif -#endif - -/***************************************************************************/ - -void WriteTGA( int x, int y, int index ) -{ - OUTPORTB(MODEREG, targa.mode |= 1 ); /* TSetMode inline for speed */ - (*PutPixel)( x, sydots-y, index&0xFF ); /* fix origin to match EGA/VGA */ - OUTPORTB(MODEREG, targa.mode &= 0xFFFE ); -} - -/***************************************************************************/ - -int ReadTGA( int x, int y ) -{ -int val; - OUTPORTB(MODEREG, targa.mode |= 1 ); /* TSetMode inline for speed */ - val = (*GetPixel)( x, sydots-y ); - OUTPORTB(MODEREG, targa.mode &= 0xFFFE ); - return( val ); -} - -/***************************************************************************/ - -void EndTGA( void ) -{ - if( initialized ) { - GraphEnd(); - initialized = 0; - } -} - -/***************************************************************************/ - -void StartTGA() -{ -int i; -/* - This overlayed data safe because used in this file, any only used for - fatal error message! -*/ -static FCODE couldntfind[]={"Could not find Targa card"}; -static FCODE noenvvar[]={"TARGA environment variable missing"}; -static FCODE insuffmem[]={"Insufficient memory for Targa"}; - - /****************/ - if( initialized ) return; - initialized = 1; - - /****************/ - /* note that video.asm has already set the regualar video adapter */ - /* to text mode (ax in Targa table entries is 3); */ - /* that's necessary because TARGA can live at 0xA000, we DO NOT */ - /* want to have an EGA/VGA in graphics mode!! */ - ReopenTGA(); /* clear text screen and display message */ - - /****************/ - /*** look for and activate card ***/ - if ((i = GraphInit()) != 0) - fatalerror((i == -1) ? couldntfind : noenvvar); - - VCenterDisplay( sydots + 1 ); - - if (tga16 == NULL) - if ( (tga16 = (unsigned *)malloc(512L)) == NULL - || (tga32 = (long *)malloc(1024L)) == NULL) - fatalerror(insuffmem); - - SetTgaColors(); - - if( targa.boardType == 16 ) { - GetPixel = (unsigned (near _fastcall *)(int, int))GetPix16; - DoPixel = PutPix16; - } - else { - GetPixel = (unsigned (near _fastcall *)(int, int))GetPix32; - DoPixel = PutPix32; - } - PutPixel = DoFirstPixel; /* on first pixel --> erase */ - - if( sydots == 482 ) SetOverscan( 1 ); - - TSetMode( targa.mode & 0xFFFE ); - - /****************/ - if (mapdacbox == NULL && SetColorPaletteName("default") != 0) - exit( 1 ); /* stopmsg has already been issued */ - -} - -void ReopenTGA() -{ -static FCODE runningontarga[]={"Running On TrueVision TARGA Card"}; - helptitle(); - driver_put_string(2,20,7,runningontarga); - driver_move_cursor(6,0); /* in case of brutal exit */ -} - -static void _fastcall fatalerror(char *msg) -{ -static FCODE abortmsg[]={"...aborting!"}; - driver_put_string(4,20,15,msg); - driver_put_string(5,20,15,abortmsg); - driver_move_cursor(8,0); - exit(1); -} - - - -/*** the rest of this module used to be separate, in tgasubs.c, ***/ -/*** has now been merged into a single source ***/ - -/*******************************************************************/ - -static void _fastcall VCenterDisplay( int nLines ) -{ -int lines; -int top, bottom; -long color; - - lines = nLines >> 1; /* half value of last line 0..x */ - top = 140 - (lines >> 1); - bottom = top + lines; - SetVBorder( top, bottom ); - SetVertShift( 255 - lines ); /* skip lines we're not using */ - - if( targa.boardType == 16 ) - color = (12 << 10) | (12 << 5) | 12; - else - color = ((long)80 << 16) | (80 << 8) | 80; - SetBorderColor( color ); -} - - -/*****************************************************************/ - -static void _fastcall near SetDispReg(int reg, int value) -{ - targa.DisplayRegister[reg] = value; - - TSetMode(targa.mode&MSK_REGWRITE); /* select Index Register write */ - OUTPORTB(DRREG, reg); /* select sync register */ - /* - * Set Mask register to write value to - * display register and to set Bit 9 in the DR - */ - TSetMode( ((targa.mode|(~MSK_REGWRITE)) /* turn on write bit */ - & MSK_BIT9 ) /* turn off Bit 9 */ - | ((value&0x0100)>>1)); /* set bit 9 for value */ - OUTPORTB(DRREG, value); /* select sync register */ - } - -/*****************************************************************/ - -#define WAITCOUNT 60000L - -static int VWait() -{ -int rasterreg; -unsigned GiveUp; - - rasterreg = RASTERREG; - - /* - * If beyond bottom of frame wait for next field - */ - GiveUp= WAITCOUNT; - while ( (--GiveUp) && (GetLine(rasterreg) == 0) ) { } - if (GiveUp) { - /* - * Wait for the bottom of the border - */ - GiveUp= WAITCOUNT; - while ( (--GiveUp) && (GetLine(rasterreg) > 0) ) { } - } - - return ( ( GiveUp ) ? 0 : -1); -} - - -/*****************************************************************/ - -static void _fastcall SetVBorder(int top, int bottom) -{ - /* top border */ - if ( top < MIN_TOP ) top=MIN_TOP; - SetDispReg(TOPBORDER,top); - /* bottom border */ - if ( bottom > MAX_BOTTOM ) bottom=MAX_BOTTOM; - SetDispReg(BOTTOMBORDER,bottom); - - SetDispReg(DR10,top); - SetDispReg(DR11,bottom); -} - - -/*****************************************************************/ - -static void _fastcall SetRGBorCV(int type) -{ - /* set the contrast level */ - targa.RGBorCV = type; - targa.VCRCon = ( targa.VCRCon & MSK_RGBORCV ) | - (targa.RGBorCV<>16)); -} - -/*****************************************************************/ - -static void _fastcall SetMask(int mask) -{ - /* mask to valid values and output to mode register */ - targa.Mask = mask; - OUTPORTB(MASKREG, mask); -} - - -/*****************************************************************/ - -static void _fastcall SetVertShift(int preshift) -{ - /* set the Vertical Preshift count level */ - targa.VertShift = preshift; - OUTPORTB(VERTPAN, preshift); -} - - -/*****************************************************************/ - -static void _fastcall SetOverscan(int mode) -{ -long tempColor; - - targa.ovrscnOn = mode; - if ( mode == 0 ) { - INPORTB(UNDERREG); /* select underscan mode */ - SetHBorder( (DEF_LEFT+targa.xOffset), - (DEF_RIGHT+targa.xOffset)); - SetDispReg(4,352); - SetDispReg(5,1); - SetBorderColor(targa.BorderColor); - } - else { - INPORTB(OVERREG); /* select overrscan mode */ - SetDispReg(0,64); /* Set four of the display registers */ - SetDispReg(1,363); /* to values required for Overscan */ - SetDispReg(4,363); - SetDispReg(5,17); - tempColor = targa.BorderColor; - SetBorderColor(0L); - targa.BorderColor = tempColor; - } -} - - -/*****************************************************************/ - -static void _fastcall SetInterlace(int type) -{ - targa.InterlaceMode= type & MSK_INTERLACE; - SetDispReg(INTREG, targa.InterlaceMode); - /* - * SET THE INTERLACE BIT TO MATCH THE INTERLACE MODE AND - * SCREEN RESOLUTION - SCREEN PAGE - */ - if ( ( targa.InterlaceMode >= 2 ) && - ( targa.PageMode> 1 ) && - ( (targa.PageMode&1) != 0 ) ) - TSetMode(targa.mode|(~MSK_IBIT) ); - else - TSetMode(targa.mode& MSK_IBIT); -} - - -/*****************************************************************/ - -static void _fastcall SetBlndReg(int value) -{ - /* set the Vertical Preshift count level */ - if ( targa.boardType == 32 ) { - targa.VCRCon = (targa.VCRCon&0xfe) | value; - OUTPORTB(BLNDREG, value); - } -} - - -/*****************************************************************/ - -static void _fastcall near TSetMode(int mode) -{ - /* mask to valid values and output to mode register */ - OUTPORTB(MODEREG, mode ); - targa.mode = mode; -} - - -/*****************************************************************/ - -static void _fastcall SetContrast(int level) -{ - /* set the contrast level */ - targa.Contrast = level &((~MSK_CONTRAST)>>SHF_CONTRAST); - targa.VCRCon = ( targa.VCRCon & MSK_CONTRAST ) | - (targa.Contrast<>SHF_HUE); - /* mask to valid range */ - targa.SatHue = (targa.SatHue&MSK_HUE) | (targa.Hue<>SHF_SATURATION); - targa.SatHue = (targa.SatHue&MSK_SATURATION) | - (targa.Saturation<= 2 ) && - ( pageMode> 1 ) && - ( (pageMode&1) != 0 ) ) TSetMode(targa.mode|(~MSK_IBIT) ); - else - TSetMode(targa.mode& MSK_IBIT); -} -***/ - - -/*****************************************************************/ - -static void _fastcall SetHBorder(int left, int right) -{ - SetDispReg(LEFTBORDER, left); /* set horizontal left border */ - SetDispReg(RIGHTBORDER,right); /* set horizontal right border */ -/* - * Set DR 8 and 9 since they - * default to tracking DR0 and DR 1 - */ - SetDispReg(DR8,left); - SetDispReg(DR9,left); -} - - -/*****************************************************************/ - -/*** UNUSED -static void _fastcall SetGenlock(int OnOrOff) -{ - TSetMode( (targa.mode)&(MSK_GENLOCK) - |((OnOrOff<= '2' && *envptr <= '8') - switches |= (1 << ('8' - *envptr)); - ++envptr; - } - if (got_switches == 0) { /* all blanks, use default */ - targa.memloc = (signed int)0xA000; - targa.iobase = 0x220; - } - else { - targa.memloc = 0x8000 + ((switches & 0x70) << 8); - targa.iobase = 0x200 + ((switches & 0x0f) << 4); - } - - if ((envptr = getenv("TARGASET")) != NULL) { - for(;;) { /* parse next parameter */ - while (*envptr == ' ' || *envptr == ',') ++envptr; - if (*envptr == 0) break; - if (*envptr >= 'a' && *envptr <= 'z') *envptr -= ('a'-'A'); - i = atoi(envptr+1); - switch (*envptr) { - case 'T': - if (i == 16) targa.boardType = TYPE_16; - if (i == 24) targa.boardType = TYPE_24; - if (i == 32) targa.boardType = TYPE_32; - break; - /* case 'E' not done, meaning not clear */ - case 'X': - targa.xOffset = i; - break; - case 'Y': - targa.yOffset = i; - break; - case 'I': - targa.InterlaceMode = i; - break; - /* case 'N' not done, I don't know how to handle it */ - case 'R': - targa.RGBorCV = RGB; - break; - case 'B': - targa.VCRorCamera = CAMERA; - break; - case 'V': - targa.VCRorCamera = VCR; - break; - case 'G': - targa.AlwaysGenLock = 1; - break; - case 'C': - targa.Contrast = i * 31 / 100; - break; - case 'S': - targa.Saturation = i * 7 / 100; - break; - case 'H': - targa.Hue = i * 31 / 100; - break; - /* note: 'A' and 'O' defined but apply only to type M8 */ - /* case 'P' not handled cause I don't know how */ - } - while (*(++envptr) >= '0' && *envptr <= '9') { } - } - } - - if ( targa.boardType == TYPE_16 ) { - targa.MaxBanks = 16; - targa.BytesPerPixel = 2; - } - if ( targa.boardType == TYPE_24 ) { - targa.MaxBanks = 32; - targa.BytesPerPixel = 3; - } - if ( targa.boardType == TYPE_32 ) { - targa.MaxBanks = 32; - targa.BytesPerPixel = 4; - } - - /****** Compute # of rows per 32K bank ********/ - targa.RowsPerBank = 512/(targa.MaxBanks); - targa.AddressShift = targa.MaxBanks>>4; - - /* if initializing CVA: set these before we quit */ - SetSaturation(targa.Saturation); - SetHue(targa.Hue); - SetContrast( targa.Contrast); - - /* Set Genlock bit if always genlocked */ - /* Set before flipping and jerking screen */ - TSetMode( (targa.AlwaysGenLock<= maxit) color = inside; - return((int)color); -} diff --git a/fractint/common/tgaview.c b/fractint/common/tgaview.c deleted file mode 100644 index eb959f2b1..000000000 --- a/fractint/common/tgaview.c +++ /dev/null @@ -1,65 +0,0 @@ - -/* Routine to decode Targa 16 bit RGB file - */ - -/* 16 bit .tga files were generated for continuous potential "potfile"s - from version 9.? thru version 14. Replaced by double row gif type - file (.pot) in version 15. Delete this code after a few more revs. -*/ - - - /* see Fractint.c for a description of the "include" hierarchy */ -#include "port.h" -#include "prototyp.h" -#include "targa_lc.h" -#include "drivers.h" - -static FILE *fptarga = NULL; /* FILE pointer */ - -/* Main entry decoder */ -int -tgaview() -{ - int i; - int cs; - unsigned int width; - struct fractal_info info; - - fptarga = t16_open(readname, (int *)&width, (int *)&height, &cs, (U8 *)&info); - if (fptarga==NULL) - return(-1); - - g_row_count = 0; - for (i=0; i<(int)height; ++i) - { - t16_getline(fptarga, width, (U16 *)boxx); - if ((*outln)((void *)boxx,width)) - { - fclose(fptarga); - fptarga = NULL; - return(-1); - } - if (driver_key_pressed()) - { - fclose(fptarga); - fptarga = NULL; - return(-1); - } - } - fclose(fptarga); - fptarga = NULL; - return(0); -} - -/* Outline function for 16 bit data with 8 bit fudge */ -int -outlin16(BYTE *buffer,int linelen) -{ - int i; - U16 *buf; - buf = (U16 *)buffer; - for (i=0; i>8); - g_row_count++; - return(0); -} diff --git a/fractint/common/yourvid.c b/fractint/common/yourvid.c deleted file mode 100644 index bc3cf3528..000000000 --- a/fractint/common/yourvid.c +++ /dev/null @@ -1,146 +0,0 @@ -/* - - Roll-Your-Own video mode (DOTMODE 19) routines. - -Even if you don't have an assembler, you can add your own video-mode -routines to FRACTINT by adding a video mode of the appropriate resolution -to FRACTINT.CFG that uses dotmode 19 (which calls these routines to -perform all the dirty work) and modifying these routines accordingly. -The four routines are: - - startvideo() Do whatever you have to do to throw your adapter into - the appropriate video mode (in case it can't be accomplished - the "normal" way, with INT 10H and the AX/BX/CX/DX values - available via FRACTINT.CFG or FARVIDEO.ASM). This routine - will typically be empty (in which case the AX/BX/CX/DX values - in FRACTINT.CFG or FARVIDEO.ASM must be encoded appropriately - to accomplish the task), but some adapters like the 8514/A - and TARGA need special handling which would go here. - If you DO have to put something here, you should encode - AX = 0xFF so as to effectively convert the regular - video-switching code inside VIDEO.ASM to use - an invalid INT 10H call - "do-nothing" logic. - - endvideo() do whatever you have to do to get it out of that - special video mode (in case 'setvideo(3,0,0,0)' - won't do it) - this routine will typically be empty, - but some adapters like the 8514/A and TARGA need - special handling which would go here. - - writevideo(int x, int y, int color) write a pixel using color number - 'color' at screen coordinates x,y (where 0,0 is the - top left corner, and sxdots,0 is the top right corner) - - int readvideo(int x, int y) return the color number of pixel x,y - using the same coordinate logic as 'writevideo()' - - int readvideopalette() read the contents of the adapter's video - palette into the 'BYTE dacbox[256][3]' array - (up to 256 R/G/B triplets, each with values from 0 to 63). - Set dacbox[0][0] = 255 if there is no such palette. - Return a -1 if you want the normal internal EGA/VGA - routines to handle this function. - - int writevideopalette() write the contents of the adapter's video - palette from the 'BYTE dacbox[256][3]' array - (up to 256 R/G/B triplets, each with values from 0 to 63). - Return a -1 if you want the normal internal EGA/VGA - routines to handle this function. - -Finally, note that, although these example routines are written in "C", -they could just as easily (or maybe more easily!) have been written -in assembler. - -*/ - - /* see Fractint.c for a description of the "include" hierarchy */ -#include "port.h" -#include "prototyp.h" - -/* external variables (set in the FRACTINT.CFG file, but findable here */ -/* these are declared in PROTOTYPE.H */ - -#if 0 - int dotmode; /* video access method (= 19) */ - int sxdots, sydots; /* total # of dots on the screen */ - int colors; /* maximum colors available */ - -/* the video-palette array (named after the VGA adapter's video-DAC) */ - - BYTE dacbox[256][3]; - -#endif - -/* for demo purposes, these routines use VGA mode 13h - 320x200x256 */ - -int startvideo() -{ - -/* assume that the encoded values in FRACTINT.CFG or FARVIDEO.ASM - have been set to accomplish this (AX = 0x13, BX = CX = DX = 0) */ - -return(0); /* set flag: video started */ - -/* or, we could have done this instead and encoded AX = 0xFF - in FRACTINT.CFG/FARVIDEO.ASM: - -union REGS regs; - -regs.x.ax = 0x13; -int86(0x10,®s,®s); - -*/ - -} - -int endvideo() -{ - -return(0); /* set flag: video ended */ - -} - -void writevideo(int x, int y, int color) -{ -#if !defined(_WIN32) -union REGS regs; - -regs.h.ah = 0x0c; /* invoke INT 10H with AH = 0CH */ -regs.h.al = (char)color; -regs.x.bx = 0; -regs.x.cx = x; -regs.x.dx = y; -int86(0x10,®s,®s); -#endif -} - -int readvideo(int x, int y) -{ -#if defined(_WIN32) - return -1; -#else -union REGS regs; - -regs.x.ax = 0x0d00; /* invoke INT 10H with AH = 0DH */ -regs.x.bx = 0; -regs.x.cx = x; -regs.x.dx = y; -int86(0x10,®s,®s); - -return((unsigned int)regs.h.al); /* return pixel color */ -#endif -} - -int readvideopalette(void) -{ - -return (-1); /* let the internal routines do it */ - -} - -int writevideopalette(void) -{ - -return (-1); /* let the internal routines do it */ - -} diff --git a/fractint/common/zoom.c b/fractint/common/zoom.c deleted file mode 100644 index 14dfbcfbb..000000000 --- a/fractint/common/zoom.c +++ /dev/null @@ -1,784 +0,0 @@ -/* - zoom.c - routines for zoombox manipulation and for panning - -*/ - -#include - - /* see Fractint.c for a description of the "include" hierarchy */ -#include "port.h" -#include "prototyp.h" -#include "drivers.h" - -#define PIXELROUND 0.00001 - -int boxx[NUM_BOXES] = { 0 }; -int boxy[NUM_BOXES] = { 0 }; -int boxvalues[NUM_BOXES] = { 0 }; - -static void _fastcall zmo_calc(double, double, double *, double *, double); -static void _fastcall zmo_calcbf(bf_t,bf_t,bf_t,bf_t,bf_t,bf_t,bf_t,bf_t,bf_t); -static int check_pan(void); -static void fix_worklist(void); -static void _fastcall move_row(int fromrow,int torow,int col); - -/* big number declarations */ -void calc_corner(bf_t target,bf_t p1,double p2,bf_t p3,double p4,bf_t p5) -{ - bf_t btmp1, btmp2 ,btmp3; - int saved; saved = save_stack(); - btmp1 = alloc_stack(rbflength+2); - btmp2 = alloc_stack(rbflength+2); - btmp3 = alloc_stack(rbflength+2); - - /* use target as temporary variable */ - floattobf(btmp3, p2); - mult_bf(btmp1,btmp3,p3); - mult_bf(btmp2,floattobf(target, p4),p5); - add_bf(target,btmp1,btmp2); - add_a_bf(target,p1); - restore_stack(saved); -} - -int boxcolor; - -#ifndef XFRACT -void dispbox(void) -{ - int i; - int boxc = (colors-1)&boxcolor; - unsigned char *values = (unsigned char *)boxvalues; - int rgb[3]; - for (i=0; i abs(to.y-fr.y)) { /* delta.x > delta.y */ - if (fr.x>to.x) { /* swap so from.x is < to.x */ - tmpp = fr; fr = to; to = tmpp; } - xincr = (to.x-fr.x)*4/sxdots+1; /* do every 1st, 2nd, 3rd, or 4th dot */ - ctr = (to.x-fr.x-1)/xincr; - altdec = abs(to.y-fr.y)*xincr; - altinc = to.x-fr.x; - altctr = altinc/2; - yincr = (to.y>fr.y)?1:-1; - line2.x = (line1.x = fr.x) + dx; - line2.y = (line1.y = fr.y) + dy; - while (--ctr>=0) { - line1.x += xincr; - line2.x += xincr; - altctr -= altdec; - while (altctr<0) { - altctr += altinc; - line1.y += yincr; - line2.y += yincr; - } - addbox(line1); - addbox(line2); - } - } - - else { /* delta.y > delta.x */ - if (fr.y>to.y) { /* swap so from.y is < to.y */ - tmpp = fr; fr = to; to = tmpp; } - yincr = (to.y-fr.y)*4/sydots+1; /* do every 1st, 2nd, 3rd, or 4th dot */ - ctr = (to.y-fr.y-1)/yincr; - altdec = abs(to.x-fr.x)*yincr; - altinc = to.y-fr.y; - altctr = altinc/2; - xincr = (to.x>fr.x) ? 1 : -1; - line2.x = (line1.x = fr.x) + dx; - line2.y = (line1.y = fr.y) + dy; - while (--ctr>=0) { - line1.y += yincr; - line2.y += yincr; - altctr -= altdec; - while (altctr<0) { - altctr += altinc; - line1.x += xincr; - line2.x += xincr; - } - addbox(line1); - addbox(line2); - } - } - } - -void _fastcall addbox(struct coords point) -{ -#if defined(_WIN32) - _ASSERTE(boxcount < NUM_BOXES); -#endif - point.x += sxoffs; - point.y += syoffs; - if (point.x >= 0 && point.x < sxdots && - point.y >= 0 && point.y < sydots) { - boxx[boxcount] = point.x; - boxy[boxcount] = point.y; - ++boxcount; - } - } - -void moveboxf(double dx, double dy) -{ int align,row,col; - align = check_pan(); - if (dx!=0.0) { - if ((zbx += dx) + zwidth/2 < 0) /* center must stay onscreen */ - zbx = zwidth/-2; - if (zbx + zwidth/2 > 1) - zbx = 1.0 - zwidth/2; - if (align != 0 - && ((col = (int)(zbx*(dxsize+PIXELROUND))) & (align-1)) != 0) { - if (dx > 0) col += align; - col -= col & (align-1); /* adjust col to pass alignment */ - zbx = (double)col/dxsize; } - } - if (dy!=0.0) { - if ((zby += dy) + zdepth/2 < 0) - zby = zdepth/-2; - if (zby + zdepth/2 > 1) - zby = 1.0 - zdepth/2; - if (align != 0 - && ((row = (int)(zby*(dysize+PIXELROUND))) & (align-1)) != 0) { - if (dy > 0) row += align; - row -= row & (align-1); - zby = (double)row/dysize; } - } -#ifndef XFRACT - if (g_video_scroll != 0) { /* scroll screen center to the box center */ - col = (int)((zbx + zwidth/2)*(dxsize + PIXELROUND)) + sxoffs; - row = (int)((zby + zdepth/2)*(dysize + PIXELROUND)) + syoffs; - switch (zscroll) { - case 0: /* fixed - screen center fixed to the zoombox center */ - scroll_center(col,row); - break; - case 1: /* relaxed - as the zoombox center leaves the screen */ - if ((col -= g_video_start_x) > 0 && (col -= g_vesa_x_res - 1) < 0) - col = 0; - if ((row -= g_video_start_y) > 0 && (row -= g_vesa_y_res - 1) < 0) - row = 0; - if (col != 0 || row != 0) - scroll_relative(col, row); - break; - } - } -#endif - } - -static void _fastcall chgboxf(double dwidth, double ddepth) -{ - if (zwidth+dwidth > 1) - dwidth = 1.0-zwidth; - if (zwidth+dwidth < 0.05) - dwidth = 0.05-zwidth; - zwidth += dwidth; - if (zdepth+ddepth > 1) - ddepth = 1.0-zdepth; - if (zdepth+ddepth < 0.05) - ddepth = 0.05-zdepth; - zdepth += ddepth; - moveboxf(dwidth/-2,ddepth/-2); /* keep it centered & check limits */ - } - -void resizebox(int steps) -{ - double deltax,deltay; - if (zdepth*screenaspect > zwidth) { /* box larger on y axis */ - deltay = steps * 0.036 / screenaspect; - deltax = zwidth * deltay / zdepth; - } - else { /* box larger on x axis */ - deltax = steps * 0.036; - deltay = zdepth * deltax / zwidth; - } - chgboxf(deltax,deltay); - } - -void chgboxi(int dw, int dd) -{ /* change size by pixels */ - chgboxf( (double)dw/dxsize, (double)dd/dysize ); - } -#ifdef C6 -#pragma optimize("e",off) /* MSC 6.00A messes up next rtn with "e" on */ -#endif - -extern void show_three_bf(); - -static void _fastcall zmo_calcbf(bf_t bfdx, bf_t bfdy, - bf_t bfnewx, bf_t bfnewy,bf_t bfplotmx1, bf_t bfplotmx2, bf_t bfplotmy1, - bf_t bfplotmy2, bf_t bfftemp) -{ - bf_t btmp1, btmp2, btmp3, btmp4, btempx, btempy ; - bf_t btmp2a, btmp4a; - int saved; saved = save_stack(); - - btmp1 = alloc_stack(rbflength+2); - btmp2 = alloc_stack(rbflength+2); - btmp3 = alloc_stack(rbflength+2); - btmp4 = alloc_stack(rbflength+2); - btmp2a = alloc_stack(rbflength+2); - btmp4a = alloc_stack(rbflength+2); - btempx = alloc_stack(rbflength+2); - btempy = alloc_stack(rbflength+2); - - /* calc cur screen corner relative to zoombox, when zoombox co-ords - are taken as (0,0) topleft thru (1,1) bottom right */ - - /* tempx = dy * plotmx1 - dx * plotmx2; */ - mult_bf(btmp1,bfdy,bfplotmx1); - mult_bf(btmp2,bfdx,bfplotmx2); - sub_bf(btempx,btmp1,btmp2); - - /* tempy = dx * plotmy1 - dy * plotmy2; */ - mult_bf(btmp1,bfdx,bfplotmy1); - mult_bf(btmp2,bfdy,bfplotmy2); - sub_bf(btempy,btmp1,btmp2); - - /* calc new corner by extending from current screen corners */ - /* *newx = sxmin + tempx*(sxmax-sx3rd)/ftemp + tempy*(sx3rd-sxmin)/ftemp; */ - sub_bf(btmp1,bfsxmax,bfsx3rd); - mult_bf(btmp2,btempx,btmp1); - /* show_three_bf("fact1",btempx,"fact2",btmp1,"prod ",btmp2,70); */ - div_bf(btmp2a,btmp2,bfftemp); - /* show_three_bf("num ",btmp2,"denom",bfftemp,"quot ",btmp2a,70); */ - sub_bf(btmp3,bfsx3rd,bfsxmin); - mult_bf(btmp4,btempy,btmp3); - div_bf(btmp4a,btmp4,bfftemp); - add_bf(bfnewx,bfsxmin,btmp2a); - add_a_bf(bfnewx,btmp4a); - - /* *newy = symax + tempy*(sy3rd-symax)/ftemp + tempx*(symin-sy3rd)/ftemp; */ - sub_bf(btmp1,bfsy3rd,bfsymax); - mult_bf(btmp2,btempy,btmp1); - div_bf(btmp2a,btmp2,bfftemp); - sub_bf(btmp3,bfsymin,bfsy3rd); - mult_bf(btmp4,btempx,btmp3); - div_bf(btmp4a,btmp4,bfftemp); - add_bf(bfnewy,bfsymax,btmp2a); - add_a_bf(bfnewy,btmp4a); - restore_stack(saved); -} - -static void _fastcall zmo_calc(double dx, double dy, double *newx, double *newy, double ftemp) -{ - double tempx,tempy; - /* calc cur screen corner relative to zoombox, when zoombox co-ords - are taken as (0,0) topleft thru (1,1) bottom right */ - tempx = dy * plotmx1 - dx * plotmx2; - tempy = dx * plotmy1 - dy * plotmy2; - - /* calc new corner by extending from current screen corners */ - *newx = sxmin + tempx*(sxmax-sx3rd)/ftemp + tempy*(sx3rd-sxmin)/ftemp; - *newy = symax + tempy*(sy3rd-symax)/ftemp + tempx*(symin-sy3rd)/ftemp; -} - -void zoomoutbf(void) /* for ctl-enter, calc corners for zooming out */ -{ - /* (xxmin,yymax), etc, are already set to zoombox corners; - (sxmin,symax), etc, are still the screen's corners; - use the same logic as plot_orbit stuff to first calculate current screen - corners relative to the zoombox, as if the zoombox were a square with - upper left (0,0) and width/depth 1; ie calc the current screen corners - as if plotting them from the zoombox; - then extend these co-ords from current real screen corners to get - new actual corners - */ - bf_t savbfxmin,savbfymax,bfftemp; - bf_t tmp1, tmp2, tmp3, tmp4, tmp5, tmp6,bfplotmx1,bfplotmx2,bfplotmy1,bfplotmy2; - int saved; - saved = save_stack(); - savbfxmin = alloc_stack(rbflength+2); - savbfymax = alloc_stack(rbflength+2); - bfftemp = alloc_stack(rbflength+2); - tmp1 = alloc_stack(rbflength+2); - tmp2 = alloc_stack(rbflength+2); - tmp3 = alloc_stack(rbflength+2); - tmp4 = alloc_stack(rbflength+2); - tmp5 = alloc_stack(rbflength+2); - tmp6 = alloc_stack(rbflength+2); - bfplotmx1 = alloc_stack(rbflength+2); - bfplotmx2 = alloc_stack(rbflength+2); - bfplotmy1 = alloc_stack(rbflength+2); - bfplotmy2 = alloc_stack(rbflength+2); - /* ftemp = (yymin-yy3rd)*(xx3rd-xxmin) - (xxmax-xx3rd)*(yy3rd-yymax); */ - sub_bf(tmp1,bfymin,bfy3rd); - sub_bf(tmp2,bfx3rd,bfxmin); - sub_bf(tmp3,bfxmax,bfx3rd); - sub_bf(tmp4,bfy3rd,bfymax); - mult_bf(tmp5,tmp1,tmp2); - mult_bf(tmp6,tmp3,tmp4); - sub_bf(bfftemp,tmp5,tmp6); - /* plotmx1 = (xx3rd-xxmin); */ ; /* reuse the plotxxx vars is safe */ - copy_bf(bfplotmx1,tmp2); - /* plotmx2 = (yy3rd-yymax); */ - copy_bf(bfplotmx2,tmp4); - /* plotmy1 = (yymin-yy3rd); */ - copy_bf(bfplotmy1,tmp1); - /* plotmy2 = (xxmax-xx3rd); */; - copy_bf(bfplotmy2,tmp3); - - /* savxxmin = xxmin; savyymax = yymax; */ - copy_bf(savbfxmin,bfxmin); copy_bf(savbfymax,bfymax); - - sub_bf(tmp1,bfsxmin,savbfxmin); sub_bf(tmp2,bfsymax,savbfymax); - zmo_calcbf(tmp1,tmp2,bfxmin,bfymax,bfplotmx1,bfplotmx2,bfplotmy1, - bfplotmy2,bfftemp); - sub_bf(tmp1,bfsxmax,savbfxmin); sub_bf(tmp2,bfsymin,savbfymax); - zmo_calcbf(tmp1,tmp2,bfxmax,bfymin,bfplotmx1,bfplotmx2,bfplotmy1, - bfplotmy2,bfftemp); - sub_bf(tmp1,bfsx3rd,savbfxmin); sub_bf(tmp2,bfsy3rd,savbfymax); - zmo_calcbf(tmp1,tmp2,bfx3rd,bfy3rd,bfplotmx1,bfplotmx2,bfplotmy1, - bfplotmy2,bfftemp); - restore_stack(saved); -} - -void zoomoutdbl(void) /* for ctl-enter, calc corners for zooming out */ -{ - /* (xxmin,yymax), etc, are already set to zoombox corners; - (sxmin,symax), etc, are still the screen's corners; - use the same logic as plot_orbit stuff to first calculate current screen - corners relative to the zoombox, as if the zoombox were a square with - upper left (0,0) and width/depth 1; ie calc the current screen corners - as if plotting them from the zoombox; - then extend these co-ords from current real screen corners to get - new actual corners - */ - double savxxmin,savyymax,ftemp; - ftemp = (yymin-yy3rd)*(xx3rd-xxmin) - (xxmax-xx3rd)*(yy3rd-yymax); - plotmx1 = (xx3rd-xxmin); /* reuse the plotxxx vars is safe */ - plotmx2 = (yy3rd-yymax); - plotmy1 = (yymin-yy3rd); - plotmy2 = (xxmax-xx3rd); - savxxmin = xxmin; savyymax = yymax; - zmo_calc(sxmin-savxxmin,symax-savyymax,&xxmin,&yymax,ftemp); - zmo_calc(sxmax-savxxmin,symin-savyymax,&xxmax,&yymin,ftemp); - zmo_calc(sx3rd-savxxmin,sy3rd-savyymax,&xx3rd,&yy3rd,ftemp); -} - -void zoomout(void) /* for ctl-enter, calc corners for zooming out */ -{ - if (bf_math) - { - zoomoutbf(); - } - else - zoomoutdbl(); -} - -#ifdef C6 -#pragma optimize("e",on) /* back to normal */ -#endif - -void aspectratio_crop(float oldaspect,float newaspect) -{ - double ftemp,xmargin,ymargin; - if (newaspect > oldaspect) { /* new ratio is taller, crop x */ - ftemp = (1.0 - oldaspect / newaspect) / 2; - xmargin = (xxmax - xx3rd) * ftemp; - ymargin = (yymin - yy3rd) * ftemp; - xx3rd += xmargin; - yy3rd += ymargin; - } - else { /* new ratio is wider, crop y */ - ftemp = (1.0 - newaspect / oldaspect) / 2; - xmargin = (xx3rd - xxmin) * ftemp; - ymargin = (yy3rd - yymax) * ftemp; - xx3rd -= xmargin; - yy3rd -= ymargin; - } - xxmin += xmargin; - yymax += ymargin; - xxmax -= xmargin; - yymin -= ymargin; -} - -static int check_pan(void) /* return 0 if can't, alignment requirement if can */ -{ int i,j; - if ((calc_status != CALCSTAT_RESUMABLE && calc_status != CALCSTAT_COMPLETED) || evolving) - return(0); /* not resumable, not complete */ - if ( curfractalspecific->calctype != StandardFractal - && curfractalspecific->calctype != calcmand - && curfractalspecific->calctype != calcmandfp - && curfractalspecific->calctype != lyapunov - && curfractalspecific->calctype != calcfroth) - return(0); /* not a worklist-driven type */ - if (zwidth != 1.0 || zdepth != 1.0 || zskew != 0.0 || zrotate != 0.0) - return(0); /* not a full size unrotated unskewed zoombox */ - if (stdcalcmode == 't') - return(0); /* tesselate, can't do it */ - if (stdcalcmode == 'd') - return(0); /* diffusion scan: can't do it either */ - if (stdcalcmode == 'o') - return(0); /* orbits, can't do it */ - - /* can pan if we get this far */ - - if (calc_status == CALCSTAT_COMPLETED) - return(1); /* image completed, align on any pixel */ - if (potflag && pot16bit) - return(1); /* 1 pass forced so align on any pixel */ - if (stdcalcmode == 'b') - return(1); /* btm, align on any pixel */ - if (stdcalcmode != 'g' || (curfractalspecific->flags&NOGUESS)) { - if (stdcalcmode == '2' || stdcalcmode == '3') /* align on even pixel for 2pass */ - return(2); - return(1); /* assume 1pass */ - } - /* solid guessing */ - start_resume(); - get_resume(sizeof(num_worklist),&num_worklist,sizeof(worklist),worklist,0); - /* don't do end_resume! we're just looking */ - i = 9; - for (j=0; j= 0) - j = j>>1; /* reduce requirement */ - return(j); - } - -static void _fastcall move_row(int fromrow,int torow,int col) -/* move a row on the screen */ -{ int startcol,endcol,tocol; - memset(dstack,0,xdots); /* use dstack as a temp for the row; clear it */ - if (fromrow >= 0 && fromrow < ydots) { - tocol = startcol = 0; - endcol = xdots-1; - if (col < 0) { - tocol -= col; - endcol += col; } - if (col > 0) - startcol += col; - get_line(fromrow,startcol,endcol,(BYTE *)&dstack[tocol]); - } - put_line(torow,0,xdots-1,(BYTE *)dstack); - } - -int init_pan_or_recalc(int do_zoomout) /* decide to recalc, or to chg worklist & pan */ -{ int i,j,row,col,y,alignmask,listfull; - if (zwidth == 0.0) - return(0); /* no zoombox, leave calc_status as is */ - /* got a zoombox */ - if ((alignmask=check_pan()-1) < 0 || evolving) { - calc_status = CALCSTAT_PARAMS_CHANGED; /* can't pan, trigger recalc */ - return(0); } - if (zbx == 0.0 && zby == 0.0) { - clearbox(); - return(0); } /* box is full screen, leave calc_status as is */ - col = (int)(zbx*(dxsize+PIXELROUND)); /* calc dest col,row of topleft pixel */ - row = (int)(zby*(dysize+PIXELROUND)); - if (do_zoomout) { /* invert row and col */ - row = 0-row; - col = 0-col; } - if ((row&alignmask) != 0 || (col&alignmask) != 0) { - calc_status = CALCSTAT_PARAMS_CHANGED; /* not on useable pixel alignment, trigger recalc */ - return(0); } - /* pan */ - num_worklist = 0; - if (calc_status == CALCSTAT_RESUMABLE) { - start_resume(); - get_resume(sizeof(num_worklist),&num_worklist,sizeof(worklist),worklist,0); - } /* don't do end_resume! we might still change our mind */ - /* adjust existing worklist entries */ - for (i=0; i 0) { - listfull |= add_worklist(0,xdots-1,0,ydots-row,ydots-1,ydots-row,0,0); - j = ydots - row - 1; } - if (col < 0) - listfull |= add_worklist(0,0-col-1,0,i,j,i,0,0); - if (col > 0) - listfull |= add_worklist(xdots-col,xdots-1,xdots-col,i,j,i,0,0); - if (listfull != 0) { - if (stopmsg(STOPMSG_CANCEL, - "Tables full, can't pan current image.\n" - "Cancel resumes old image, continue pans and calculates a new one.")) { - zwidth = 0; /* cancel the zoombox */ - drawbox(1); } - else - calc_status = CALCSTAT_PARAMS_CHANGED; /* trigger recalc */ - return(0); } - /* now we're committed */ - calc_status = CALCSTAT_RESUMABLE; - clearbox(); - if (row > 0) /* move image up */ - for (y=0; y=0;) move_row(y+row,y,col); - fix_worklist(); /* fixup any out of bounds worklist entries */ - alloc_resume(sizeof(worklist)+20,2); /* post the new worklist */ - put_resume(sizeof(num_worklist),&num_worklist,sizeof(worklist),worklist,0); - return(0); - } - -static void _fastcall restart_window(int wknum) -/* force a worklist entry to restart */ -{ int yfrom,yto,xfrom,xto; - if ((yfrom = worklist[wknum].yystart) < 0) yfrom = 0; - if ((xfrom = worklist[wknum].xxstart) < 0) xfrom = 0; - if ((yto = worklist[wknum].yystop) >= ydots) yto = ydots - 1; - if ((xto = worklist[wknum].xxstop) >= xdots) xto = xdots - 1; - memset(dstack,0,xdots); /* use dstack as a temp for the row; clear it */ - while (yfrom <= yto) - put_line(yfrom++,xfrom,xto,(BYTE *)dstack); - worklist[wknum].sym = worklist[wknum].pass = 0; - worklist[wknum].yybegin = worklist[wknum].yystart; - worklist[wknum].xxbegin = worklist[wknum].xxstart; -} - -static void fix_worklist(void) /* fix out of bounds and symmetry related stuff */ -{ int i,j,k; - WORKLIST *wk; - for (i=0; iyystart >= ydots || wk->yystop < 0 - || wk->xxstart >= xdots || wk->xxstop < 0) { /* offscreen, delete */ - for (j=i+1; jyystart < 0) { /* partly off top edge */ - if ((wk->sym&1) == 0) { /* no sym, easy */ - wk->yystart = 0; - wk->xxbegin = 0; } - else { /* xaxis symmetry */ - if ((j = wk->yystop + wk->yystart) > 0 - && num_worklist < MAXCALCWORK) { /* split the sym part */ - worklist[num_worklist] = worklist[i]; - worklist[num_worklist].yystart = 0; - worklist[num_worklist++].yystop = j; - wk->yystart = j+1; } - else - wk->yystart = 0; - restart_window(i); /* restart the no-longer sym part */ - } - } - if (wk->yystop >= ydots) { /* partly off bottom edge */ - j = ydots-1; - if ((wk->sym&1) != 0) { /* uses xaxis symmetry */ - if ((k = wk->yystart + (wk->yystop - j)) < j) { - if (num_worklist >= MAXCALCWORK) /* no room to split */ - restart_window(i); - else { /* split it */ - worklist[num_worklist] = worklist[i]; - worklist[num_worklist].yystart = k; - worklist[num_worklist++].yystop = j; - j = k-1; } - } - wk->sym &= -1 - 1; } - wk->yystop = j; } - if (wk->xxstart < 0) { /* partly off left edge */ - if ((wk->sym&2) == 0) /* no sym, easy */ - wk->xxstart = 0; - else { /* yaxis symmetry */ - if ((j = wk->xxstop + wk->xxstart) > 0 - && num_worklist < MAXCALCWORK) { /* split the sym part */ - worklist[num_worklist] = worklist[i]; - worklist[num_worklist].xxstart = 0; - worklist[num_worklist++].xxstop = j; - wk->xxstart = j+1; } - else - wk->xxstart = 0; - restart_window(i); /* restart the no-longer sym part */ - } - } - if (wk->xxstop >= xdots) { /* partly off right edge */ - j = xdots-1; - if ((wk->sym&2) != 0) { /* uses xaxis symmetry */ - if ((k = wk->xxstart + (wk->xxstop - j)) < j) { - if (num_worklist >= MAXCALCWORK) /* no room to split */ - restart_window(i); - else { /* split it */ - worklist[num_worklist] = worklist[i]; - worklist[num_worklist].xxstart = k; - worklist[num_worklist++].xxstop = j; - j = k-1; } - } - wk->sym &= -1 - 2; } - wk->xxstop = j; } - if (wk->yybegin < wk->yystart) wk->yybegin = wk->yystart; - if (wk->yybegin > wk->yystop) wk->yybegin = wk->yystop; - if (wk->xxbegin < wk->xxstart) wk->xxbegin = wk->xxstart; - if (wk->xxbegin > wk->xxstop) wk->xxbegin = wk->xxstop; - } - tidy_worklist(); /* combine where possible, re-sort */ -} diff --git a/fractint/dos_help/.cvsignore b/fractint/dos_help/.cvsignore deleted file mode 100644 index 3ba4cfd3e..000000000 --- a/fractint/dos_help/.cvsignore +++ /dev/null @@ -1,4 +0,0 @@ -Debug -FRACTINT.HLP -HELPDEFS.H -Release \ No newline at end of file diff --git a/fractint/dos_help/hc.c b/fractint/dos_help/hc.c deleted file mode 100644 index 93a253e4e..000000000 --- a/fractint/dos_help/hc.c +++ /dev/null @@ -1,3962 +0,0 @@ - -/* - * hc.c - * - * Stand-alone FRACTINT help compiler. Compile in the COMPACT memory model. - * - * See HC.DOC for source file syntax. - * - * - * Revision History: - * - * 02-26-91 EAN Initial version. - * - * 03-21-91 EAN Modified for automatic paragraph formatting. - * Added several new commands: - * Format[+/-] Enable/disable paragraph formatting - * Doc[+/-] Enable/disable output to document. - * Online[+/-] Enable/disable output to online help. - * Label= Defines a label. Replaces ~(...) - * FF Forces a form-feed. Replaces ~~ - * FormatExclude=val Exclude lines past val from - * formatting. If before any topic sets - * global default, otherwise set local. - * FormatExclude= Set to global default. - * FormatExclude=n Disable exclusion. (global or local) - * FormatExclude[+/-] Enable/disable format exclusion. - * Center[+/-] Enable/disable centering of text. - * \ before nl Forces the end of a paragraph - * Support for commands embedded in text with new - * ~(...) format. - * Support for multiple commands on a line separated by - * commas. - * Support for implict links; explicit links must now - * start with an equal sign. - * 04-03-91 EAN Added "include" command (works like #include) - * 04-10-91 EAN Added support for "data" topics. - * Added Comment/EndComment commands for multi-line - * comments. - * Added CompressSpaces[+/-] command. - * Added DocContents command for document printing. - * Added BinInc command which includes a binary file - * in a data topic. - * Fixed tables to flow down instead of across the page. - * Makes no allowances for page breaks within tables. - * 11-03-94 TIW Increased buffer size. - * - */ - - -#define HC_C - -#define INCLUDE_COMMON /* tell helpcom.h to include common code */ - - -#ifdef XFRACT -#define strupr strlwr -#else -#include -#endif - -#if defined(_WIN32) -#include -#define _CRT_SECURE_NO_DEPRECATE -/* disable unsafe CRT warnings */ -#pragma warning(disable: 4996) -#endif - -#ifndef USE_VARARGS -#include -#else -#include -#endif - -#include -#include -#include - -#ifdef __TURBOC__ -# include -# define FNSPLIT fnsplit -#else -# define MAXFILE _MAX_FNAME -# define MAXEXT _MAX_EXT -# define FNSPLIT _splitpath -#endif - - -#include - /* see Fractint.c for a description of the "include" hierarchy */ -#include "port.h" -#include "helpcom.h" - -#ifdef XFRACT -#ifndef HAVESTRI -extern int stricmp(char *, char *); -extern int strnicmp(char *, char *, int); -#endif -extern int filelength(int); -extern int _splitpath(char *,char *,char *,char *,char *); -#endif - -/* - * When defined, SHOW_ERROR_LINE will cause the line number in HC.C where - * errors/warnings/messages are generated to be displayed at the start of - * the line. - * - * Used when debugging HC. Also useful for finding the line (in HC.C) that - * generated a error or warning. - */ - -#ifndef XFRACT -#define SHOW_ERROR_LINE -#endif - - -#define DEFAULT_SRC_FNAME "help.src" -#define DEFAULT_HLP_FNAME "fractint.hlp" -#define DEFAULT_EXE_FNAME "fractint.exe" -#define DEFAULT_DOC_FNAME "fractint.doc" - -#define TEMP_FNAME "HC.$$$" -#define SWAP_FNAME "HCSWAP.$$$" - -#define MAX_ERRORS (25) /* stop after this many errors */ -#define MAX_WARNINGS (25) /* stop after this many warnings */ - /* 0 = never stop */ - -#define INDEX_LABEL "FIHELP_INDEX" -#define DOCCONTENTS_TITLE "DocContent" - - - -/* #define BUFFER_SIZE (24*1024) */ -#define BUFFER_SIZE (30*1024) - - -typedef struct - { - int type; /* 0 = name is topic title, 1 = name is label, */ - /* 2 = "special topic"; name is NULL and */ - /* topic_num/topic_off is valid */ - int topic_num; /* topic number to link to */ - unsigned topic_off; /* offset into topic to link to */ - int doc_page; /* document page # to link to */ - char *name; /* name of label or title of topic to link to */ - char *srcfile; /* .SRC file link appears in */ - int srcline; /* .SRC file line # link appears in */ - } LINK; - - -typedef struct - { - unsigned offset; /* offset from start of topic text */ - unsigned length; /* length of page (in chars) */ - int margin; /* if > 0 then page starts in_para and text */ - /* should be indented by this much */ - } PAGE; - - -/* values for TOPIC.flags */ - -#define TF_IN_DOC (1) /* 1 if topic is part of the printed document */ -#define TF_DATA (2) /* 1 if it is a "data" topic */ - - -typedef struct - { - unsigned flags; /* see #defines for TF_??? */ - int doc_page; /* page number in document where topic starts */ - unsigned title_len; /* length of title */ - char *title; /* title for this topic */ - int num_page; /* number of pages */ - PAGE *page; /* list of pages */ - unsigned text_len; /* lenth of topic text */ - long text; /* topic text (all pages) */ - long offset; /* offset to topic from start of file */ - } TOPIC; - - -typedef struct - { - char *name; /* its name */ - int topic_num; /* topic number */ - unsigned topic_off; /* offset of label in the topic's text */ - int doc_page; - } LABEL; - - -/* values for CONTENT.flags */ - -#define CF_NEW_PAGE (1) /* true if section starts on a new page */ - - -#define MAX_CONTENT_TOPIC (10) - - -typedef struct - { - unsigned flags; - char *id; - char *name; - int doc_page; - unsigned page_num_pos; - int num_topic; - char is_label[MAX_CONTENT_TOPIC]; - char *topic_name[MAX_CONTENT_TOPIC]; - int topic_num[MAX_CONTENT_TOPIC]; - char *srcfile; - int srcline; - } CONTENT; - - -struct help_sig_info - { - unsigned long sig; - int version; - unsigned long base; - } ; - - -int num_topic = 0; /* topics */ -TOPIC *topic; - -int num_label = 0; /* labels */ -LABEL *label; - -int num_plabel = 0; /* private labels */ -LABEL *plabel; - -int num_link = 0; /* all links */ -LINK *a_link = 0; - -int num_contents = 0; /* the table-of-contents */ -CONTENT *contents; - -int quiet_mode = 0; /* true if "/Q" option used */ - -int max_pages = 0; /* max. pages in any topic */ -int max_links = 0; /* max. links on any page */ -int num_doc_pages = 0; /* total number of pages in document */ - -FILE *srcfile; /* .SRC file */ -int srcline = 0; /* .SRC line number (used for errors) */ -int srccol = 0; /* .SRC column. */ - -int version = -1; /* help file version */ - -int errors = 0, /* number of errors reported */ - warnings = 0; /* number of warnings reported */ - -char src_fname[81] = ""; /* command-line .SRC filename */ -char hdr_fname[81] = ""; /* .H filename */ -char hlp_fname[81] = ""; /* .HLP filename */ -char *src_cfname = NULL; /* current .SRC filename */ - -int format_exclude = 0; /* disable formatting at this col, 0 to */ - /* never disable formatting */ -FILE *swapfile; -long swappos; - -char *buffer; /* alloc'ed as BUFFER_SIZE bytes */ -char *curr; /* current position in the buffer */ -char cmd[128]; /* holds the current command */ -int compress_spaces; -int xonline; -int xdoc; - -#define MAX_INCLUDE_STACK (5) /* allow 5 nested includes */ - -struct - { - char *fname; - FILE *file; - int line; - int col; - } include_stack[MAX_INCLUDE_STACK]; -int include_stack_top = -1; - -void check_buffer(char *current, unsigned off, char *buffer); - -#define CHK_BUFFER(off) check_buffer(curr, off, buffer) - -#ifdef __WATCOMC__ -#define putw( x1, x2 ) fprintf( x2, "%c%c", x1&0xFF, x1>>8 ); -#endif - -#ifdef XFRACT -#define putw( x1, x2 ) fwrite( &(x1), 1, sizeof(int), x2); -#endif - -/* - * error/warning/message reporting functions. - */ - - -void report_errors(void) - { - printf("\n"); - printf("Compiler Status:\n"); - printf("%8d Error%c\n", errors, (errors==1) ? ' ' : 's'); - printf("%8d Warning%c\n", warnings, (warnings==1) ? ' ' : 's'); - } - - -void print_msg(char *type, int lnum, char *format, va_list arg) - { - if (type != NULL) - { - printf(" %s", type); - if (lnum>0) - printf(" %s %d", src_cfname, lnum); - printf(": "); - } - vprintf(format, arg); - printf("\n"); - } - - -#ifndef USE_VARARGS -void fatal(int diff, char *format, ...) -#else -void fatal(va_alist) - va_dcl -#endif - { - va_list arg; - -#ifndef USE_VARARGS - va_start(arg, format); -#else - int diff; - char *format; - va_start(arg); - diff = va_arg(arg,int); - format = va_arg(arg,char *); -#endif - - print_msg("Fatal", srcline-diff, format, arg); - va_end(arg); - - if ( errors || warnings ) - report_errors(); - - exit( errors + 1 ); - } - - -#ifndef USE_VARARGS -void error(int diff, char *format, ...) -#else -void error(va_alist) - va_dcl -#endif - { - va_list arg; - -#ifndef USE_VARARGS - va_start(arg, format); -#else - int diff; - char *format; - va_start(arg); - diff = va_arg(arg,int); - format = va_arg(arg,char *); -#endif - print_msg("Error", srcline-diff, format, arg); - va_end(arg); - - if (++errors >= MAX_ERRORS && MAX_ERRORS > 0) - fatal(0,"Too many errors!"); - } - - -#ifndef USE_VARARGS -void warn(int diff, char *format, ...) -#else -void warn(va_alist) - va_dcl -#endif - { - va_list arg; -#ifndef USE_VARARGS - va_start(arg, format); -#else - int diff; - char *format; - va_start(arg); - diff = va_arg(arg, int); - format = va_arg(arg, char *); -#endif - print_msg("Warning", srcline-diff, format, arg); - va_end(arg); - - if (++warnings >= MAX_WARNINGS && MAX_WARNINGS > 0) - fatal(0,"Too many warnings!"); - } - - -#ifndef USE_VARARGS -void notice(char *format, ...) -#else -void notice(va_alist) - va_dcl -#endif - { - va_list arg; -#ifndef USE_VARARGS - va_start(arg, format); -#else - char *format; - - va_start(arg); - format = va_arg(arg,char *); -#endif - print_msg("Note", srcline, format, arg); - va_end(arg); - } - - -#ifndef USE_VARARGS -void msg(char *format, ...) -#else -void msg(va_alist) -va_dcl -#endif - { - va_list arg; -#ifdef USE_VARARGS - char *format; -#endif - - if (quiet_mode) - return; -#ifndef USE_VARARGS - va_start(arg, format); -#else - va_start(arg); - format = va_arg(arg,char *); -#endif - print_msg(NULL, 0, format, arg); - va_end(arg); - } - - -#ifdef SHOW_ERROR_LINE -# define fatal (printf("[%04d] ", __LINE__), fatal) -# define error (printf("[%04d] ", __LINE__), error) -# define warn (printf("[%04d] ", __LINE__), warn) -# define notice (printf("[%04d] ", __LINE__), notice) -# define msg (printf((quiet_mode)?"":"[%04d] ", __LINE__), msg) -#endif - - -/* - * store-topic-text-to-disk stuff. - */ - - -void alloc_topic_text(TOPIC *t, unsigned size) - { - t->text_len = size; - t->text = swappos; - swappos += size; - fseek(swapfile, t->text, SEEK_SET); - fwrite(buffer, 1, t->text_len, swapfile); - } - - -char *get_topic_text(TOPIC *t) - { - fseek(swapfile, t->text, SEEK_SET); - fread(buffer, 1, t->text_len, swapfile); - return (buffer); - } - - -void release_topic_text(TOPIC *t, int save) - { - if ( save ) - { - fseek(swapfile, t->text, SEEK_SET); - fwrite(buffer, 1, t->text_len, swapfile); - } - } - - -/* - * memory-allocation functions. - */ - - -#define new(item) (item *)newx(sizeof(item)) -#define delete(item) free(item) - - -VOIDPTR newx(unsigned size) - { - VOIDPTR ptr; - - ptr = malloc(size); - - if (ptr == NULL) - fatal(0,"Out of memory!"); - - return (ptr); - } - - -VOIDPTR renewx(VOIDPTR ptr, unsigned size) - { - ptr = realloc(ptr, size); - - if (ptr == NULL) - fatal(0,"Out of memory!"); - - return (ptr); - } - - -char *dupstr(char *s, unsigned len) - { - char *ptr; - - if (len == 0) - len = (int) strlen(s) + 1; - - ptr = newx(len); - - memcpy(ptr, s, len); - - return (ptr); - } - - -#define LINK_ALLOC_SIZE (16) - - -int add_link(LINK *l) - { - if (num_link == 0) - a_link = newx( sizeof(LINK)*LINK_ALLOC_SIZE ); - - else if (num_link%LINK_ALLOC_SIZE == 0) - a_link = renewx(a_link, sizeof(LINK) * (num_link+LINK_ALLOC_SIZE) ); - - a_link[num_link] = *l; - - return( num_link++ ); - } - - -#define PAGE_ALLOC_SIZE (4) - - -int add_page(TOPIC *t, PAGE *p) - { - if (t->num_page == 0) - t->page = newx( sizeof(PAGE)*PAGE_ALLOC_SIZE ); - - else if (t->num_page%PAGE_ALLOC_SIZE == 0) - t->page = renewx(t->page, sizeof(PAGE) * (t->num_page+PAGE_ALLOC_SIZE) ); - - t->page[t->num_page] = *p; - - return ( t->num_page++ ); - } - - -#define TOPIC_ALLOC_SIZE (16) - - -int add_topic(TOPIC *t) - { - if (num_topic == 0) - topic = newx( sizeof(TOPIC)*TOPIC_ALLOC_SIZE ); - - else if (num_topic%TOPIC_ALLOC_SIZE == 0) - topic = renewx(topic, sizeof(TOPIC) * (num_topic+TOPIC_ALLOC_SIZE) ); - - topic[num_topic] = *t; - - return ( num_topic++ ); - } - - -#define LABEL_ALLOC_SIZE (16) - - -int add_label(LABEL *l) - { - if (l->name[0] == '@') /* if it's a private label... */ - { - if (num_plabel == 0) - plabel = newx( sizeof(LABEL)*LABEL_ALLOC_SIZE ); - - else if (num_plabel%LABEL_ALLOC_SIZE == 0) - plabel = renewx(plabel, sizeof(LABEL) * (num_plabel+LABEL_ALLOC_SIZE) ); - - plabel[num_plabel] = *l; - - return ( num_plabel++ ); - } - else - { - if (num_label == 0) - label = newx( sizeof(LABEL)*LABEL_ALLOC_SIZE ); - - else if (num_label%LABEL_ALLOC_SIZE == 0) - label = renewx(label, sizeof(LABEL) * (num_label+LABEL_ALLOC_SIZE) ); - - label[num_label] = *l; - - return ( num_label++ ); - } - } - - -#define CONTENTS_ALLOC_SIZE (16) - - -int add_content(CONTENT *c) - { - if (num_contents == 0) - contents = newx( sizeof(CONTENT)*CONTENTS_ALLOC_SIZE ); - - else if (num_contents%CONTENTS_ALLOC_SIZE == 0) - contents = renewx(contents, sizeof(CONTENT) * (num_contents+CONTENTS_ALLOC_SIZE) ); - - contents[num_contents] = *c; - - return ( num_contents++ ); - } - - -/* - * read_char() stuff - */ - - -#define READ_CHAR_BUFF_SIZE (32) - - -int read_char_buff[READ_CHAR_BUFF_SIZE]; -int read_char_buff_pos = -1; -int read_char_sp = 0; - - -void unread_char(int ch) - /* - * Will not handle new-lines or tabs correctly! - */ - { - if (read_char_buff_pos+1 >= READ_CHAR_BUFF_SIZE) - fatal(0,"Compiler Error -- Read char buffer overflow!"); - - read_char_buff[++read_char_buff_pos] = ch; - - --srccol; - } - - -void unread_string(char *s) - { - int p = (int) strlen(s); - - while (p-- > 0) - unread_char(s[p]); - } - - -int eos(void) /* end-of-source ? */ - { - return ( !((read_char_sp==0) && (read_char_buff_pos==0) && feof(srcfile)) ); - } - - -int _read_char(void) - { - int ch; - - if (srcline <= 0) - { - srcline = 1; - srccol = 0; - } - - if (read_char_buff_pos >= 0) - { - ++srccol; - return ( read_char_buff[read_char_buff_pos--] ); - } - - if (read_char_sp > 0) - { - --read_char_sp; - return (' '); - } - - if ( feof(srcfile) ) - return (-1); - - while (1) - { - ch = getc(srcfile); - - switch (ch) - { - case '\t': /* expand a tab */ - { - int diff = ( ( (srccol/8) + 1 ) * 8 ) - srccol; - - srccol += diff; - read_char_sp += diff; - break; - } - - case ' ': - ++srccol; - ++read_char_sp; - break; - - case '\n': - read_char_sp = 0; /* delete spaces before a \n */ - srccol = 0; - ++srcline; - return ('\n'); - - case -1: /* EOF */ - if (read_char_sp > 0) - { - --read_char_sp; - return (' '); - } - return (-1); - - default: - if (read_char_sp > 0) - { - ungetc(ch, srcfile); - --read_char_sp; - return (' '); - } - - ++srccol; - return (ch); - - } /* switch */ - } - } - - -int read_char(void) - { - int ch; - - ch = _read_char(); - - while (ch == ';' && srccol==1) /* skip over comments */ - { - ch = _read_char(); - - while (ch!='\n' && ch!=-1 ) - ch = _read_char(); - - ch = _read_char(); - } - - if (ch == '\\') /* process an escape code */ - { - ch = _read_char(); - - if (ch >= '0' && ch <= '9') - { - char buff[4]; - int ctr; - - for (ctr=0; ; ctr++) - { - if ( ch<'0' || ch>'9' || ch==-1 || ctr>=3 ) - { - unread_char(ch); - break; - } - buff[ctr] = ch; - ch = _read_char(); - } - buff[ctr] = '\0'; - ch = atoi(buff); - } - -#ifdef XFRACT - /* Convert graphics arrows into keyboard chars */ - if (ch>=24 && ch<=27) { - ch = "KJHL"[ch-24]; - } -#endif - ch |= 0x100; - } - - if ( (ch & 0xFF) == 0 ) - { - error(0,"Null character (\'\\0\') not allowed!"); - ch = 0x1FF; /* since we've had an error the file will not be written; */ - /* the value we return doesn't really matter */ - } - - return(ch); - } - - -/* - * misc. search functions. - */ - - -LABEL *find_label(char *name) - { - int l; - LABEL *lp; - - if (*name == '@') - { - for (l=0, lp=plabel; lname) == 0 ) - return (lp); - } - else - { - for (l=0, lp=label; lname) == 0 ) - return (lp); - } - - return (NULL); - } - - -int find_topic_title(char *title) - { - int t; - int len; - - while (*title == ' ') - ++title; - - len = (int) strlen(title) - 1; - while ( title[len] == ' ' && len > 0 ) - --len; - - ++len; - - if ( len > 2 && title[0] == '\"' && title[len-1] == '\"' ) - { - ++title; - len -= 2; - } - - for (t=0; t 0 ) - { - ch = read_char(); - - if ( ch == -1 ) - { - *buff++ = '\0'; - break; - } - - if ( (ch&0xFF) <= MAX_CMD ) - *buff++ = CMD_LITERAL; - - *buff++ = ch; - - if ( (ch&0x100)==0 && strchr(stop_chars, ch) != NULL ) - break; - } - - return ( buff-1 ); - } - - -void skip_over(char *skip) - { - int ch; - - while (1) - { - ch = read_char(); - - if ( ch == -1 ) - break; - - else if ( (ch&0x100) == 0 && strchr(skip, ch) == NULL ) - { - unread_char(ch); - break; - } - } - } - - -char *pchar(int ch) - { - static char buff[16]; - - if ( ch >= 0x20 && ch <= 0x7E ) - sprintf(buff, "\'%c\'", ch); - else - sprintf(buff, "\'\\x%02X\'", ch&0xFF); - - return (buff); - } - - -void put_spaces(int how_many) - { - if (how_many > 2 && compress_spaces) - { - if (how_many > 255) - { - error(0,"Too many spaces (over 255)."); - how_many = 255; - } - - *curr++ = CMD_SPACE; - *curr++ = (BYTE)how_many; - } - else - { - while (how_many-- > 0) - *curr++ = ' '; - } - } - - -int get_next_item(void) /* used by parse_contents() */ - { - int last; - char *ptr; - - skip_over(" \t\n"); - ptr = read_until(cmd, 128, ",}"); - last = (*ptr == '}'); - --ptr; - while ( ptr >= cmd && strchr(" \t\n",*ptr) ) /* strip trailing spaces */ - --ptr; - *(++ptr) = '\0'; - - return (last); - } - - -void process_contents(void) - { - CONTENT c; - char *ptr; - int indent; - int ch; - TOPIC t; - - t.flags = 0; - t.title_len = (unsigned) strlen(DOCCONTENTS_TITLE)+1; - t.title = dupstr(DOCCONTENTS_TITLE, t.title_len); - t.doc_page = -1; - t.num_page = 0; - - curr = buffer; - - c.flags = 0; - c.id = dupstr("",1); - c.name = dupstr("",1); - c.doc_page = -1; - c.page_num_pos = 0; - c.num_topic = 1; - c.is_label[0] = 0; - c.topic_name[0] = dupstr(DOCCONTENTS_TITLE,0); - c.srcline = -1; - add_content(&c); - - while (1) - { - ch = read_char(); - - if (ch == '{') /* process a CONTENT entry */ - { - int last; - - c.flags = 0; - c.num_topic = 0; - c.doc_page = -1; - c.srcfile = src_cfname; - c.srcline = srcline; - - if ( get_next_item() ) - { - error(0,"Unexpected end of DocContent entry."); - continue; - } - c.id = dupstr(cmd,0); - - if ( get_next_item() ) - { - error(0,"Unexpected end of DocContent entry."); - continue; - } - indent = atoi(cmd); - - last = get_next_item(); - - if ( cmd[0] == '\"' ) - { - ptr = cmd+1; - if (ptr[(int) strlen(ptr)-1] == '\"') - ptr[(int) strlen(ptr)-1] = '\0'; - else - warn(0,"Missing ending quote."); - - c.is_label[c.num_topic] = 0; - c.topic_name[c.num_topic] = dupstr(ptr,0); - ++c.num_topic; - c.name = dupstr(ptr,0); - } - else - c.name = dupstr(cmd,0); - - /* now, make the entry in the buffer */ - - sprintf(curr, "%-5s %*.0s%s", c.id, indent*2, "", c.name); - ptr = curr + (int) strlen(curr); - while ( (ptr-curr) < PAGE_WIDTH-10 ) - *ptr++ = '.'; - c.page_num_pos = (unsigned) ( (ptr-3) - buffer ); - curr = ptr; - - while (!last) - { - last = get_next_item(); - - if ( stricmp(cmd, "FF") == 0 ) - { - if ( c.flags & CF_NEW_PAGE ) - warn(0,"FF already present in this entry."); - c.flags |= CF_NEW_PAGE; - continue; - } - - if (cmd[0] == '\"') - { - ptr = cmd+1; - if (ptr[(int) strlen(ptr)-1] == '\"') - ptr[(int) strlen(ptr)-1] = '\0'; - else - warn(0,"Missing ending quote."); - - c.is_label[c.num_topic] = 0; - c.topic_name[c.num_topic] = dupstr(ptr,0); - } - else - { - c.is_label[c.num_topic] = 1; - c.topic_name[c.num_topic] = dupstr(cmd,0); - } - - if ( ++c.num_topic >= MAX_CONTENT_TOPIC ) - { - error(0,"Too many topics in DocContent entry."); - break; - } - } - - add_content(&c); - } - - else if (ch == '~') /* end at any command */ - { - unread_char(ch); - break; - } - - else - *curr++ = ch; - - CHK_BUFFER(0); - } - - alloc_topic_text(&t, (unsigned) (curr - buffer) ); - add_topic(&t); - } - - -int parse_link(void) /* returns length of link or 0 on error */ - { - char *ptr; - char *end; - int bad = 0; - int len; - LINK l; - int lnum; - int err_off; - - l.srcfile = src_cfname; - l.srcline = srcline; - l.doc_page = -1; - - end = read_until(cmd, 128, "}\n"); /* get the entire hot-link */ - - if (*end == '\0') - { - error(0,"Unexpected EOF in hot-link."); - return (0); - } - - if (*end == '\n') - { - err_off = 1; - warn(1,"Hot-link has no closing curly-brace (\'}\')."); - } - else - err_off = 0; - - *end = '\0'; - - if (cmd[0] == '=') /* it's an "explicit" link to a label or "special" */ - { - ptr = strchr(cmd, ' '); - - if (ptr == NULL) - ptr = end; - else - *ptr++ = '\0'; - - len = (int) (end - ptr); - - if ( cmd[1] == '-' ) - { - l.type = 2; /* type 2 = "special" */ - l.topic_num = atoi(cmd+1); - l.topic_off = 0; - l.name = NULL; - } - else - { - l.type = 1; /* type 1 = to a label */ - if ((int)strlen(cmd) > 32) - warn(err_off, "Label is long."); - if (cmd[1] == '\0') - { - error(err_off, "Explicit hot-link has no Label."); - bad = 1; - } - else - l.name = dupstr(cmd+1,0); - } - if (len == 0) - warn(err_off, "Explicit hot-link has no title."); - } - else - { - ptr = cmd; - l.type = 0; /* type 0 = topic title */ - len = (int) (end - ptr); - if (len == 0) - { - error(err_off, "Implicit hot-link has no title."); - bad = 1; - } - l.name = dupstr(ptr,len+1); - l.name[len] = '\0'; - } - - if ( !bad ) - { - CHK_BUFFER(1+3*sizeof(int)+len+1); - lnum = add_link(&l); - *curr++ = CMD_LINK; - setint(curr,lnum); - curr += 3*sizeof(int); - memcpy(curr, ptr, len); - curr += len; - *curr++ = CMD_LINK; - return (len); - } - else - return (0); - } - - -#define MAX_TABLE_SIZE (100) - - -int create_table(void) - { - char *ptr; - int width; - int cols; - int start_off; - int first_link; - int rows; - int r, c; - int ch; - int done; - int len; - int lnum; - int count; - char *title[MAX_TABLE_SIZE]; - char *table_start; - - ptr = strchr(cmd, '='); - - if (ptr == NULL) - return (0); /* should never happen! */ - - ptr++; - - len = sscanf(ptr, " %d %d %d", &width, &cols, &start_off); - - if (len < 3) - { - error(1,"Too few arguments to Table."); - return (0); - } - - if (width<=0 || width > 78 || cols<=0 || start_off<0 || start_off > 78) - { - error(1,"Argument out of range."); - return (0); - } - - done = 0; - - first_link = num_link; - table_start = curr; - count = 0; - - /* first, read all the links in the table */ - - do - { - - do - ch = read_char(); - while ( ch=='\n' || ch == ' ' ); - - if (done) - break; - - switch (ch) - { - case -1: - error(0,"Unexpected EOF in a Table."); - return(0); - - case '{': - if (count >= MAX_TABLE_SIZE) - fatal(0,"Table is too large."); - len = parse_link(); - curr = table_start; /* reset to the start... */ - title[count] = dupstr(curr+3*sizeof(int)+1, len+1); - if (len >= width) - { - warn(1,"Link is too long; truncating."); - len = width-1; - } - title[count][len] = '\0'; - ++count; - break; - - case '~': - { - int imbedded; - - ch = read_char(); - - if (ch=='(') - imbedded = 1; - else - { - imbedded = 0; - unread_char(ch); - } - - ptr = read_until(cmd, 128, ")\n,"); - - ch = *ptr; - *ptr = '\0'; - - if ( stricmp(cmd, "EndTable") == 0 ) - done = 1; - else - { - error(1,"Unexpected command in table \"%s\"", cmd); - warn(1,"Command will be ignored."); - } - - if (ch == ',') - { - if (imbedded) - unread_char('('); - unread_char('~'); - } - } - break; - - default: - error(0,"Unexpected character %s.", pchar(ch)); - break; - } - } - while (!done); - - /* now, put all the links into the buffer... */ - - rows = 1 + ( count / cols ); - - for (r=0; r= num_link ) - break; - - len = (int) strlen(title[lnum]); - *curr++ = CMD_LINK; - setint(curr,first_link+lnum); - curr += 3*sizeof(int); - memcpy(curr, title[lnum], len); - curr += len; - *curr++ = CMD_LINK; - - delete(title[lnum]); - - if ( c < cols-1 ) - put_spaces( width-len ); - } - *curr++ = '\n'; - } - - return (1); - } - - -void process_comment(void) - { - int ch; - - while ( 1 ) - { - ch = read_char(); - - if (ch == '~') - { - int imbedded; - char *ptr; - - ch = read_char(); - - if (ch=='(') - imbedded = 1; - else - { - imbedded = 0; - unread_char(ch); - } - - ptr = read_until(cmd, 128, ")\n,"); - - ch = *ptr; - *ptr = '\0'; - - if ( stricmp(cmd, "EndComment") == 0 ) - { - if (ch == ',') - { - if (imbedded) - unread_char('('); - unread_char('~'); - } - break; - } - } - - else if ( ch == -1 ) - { - error(0,"Unexpected EOF in Comment"); - break; - } - } - } - - -void process_bininc(void) - { - int handle; - long len; - - if ( (handle=open(cmd+7, O_RDONLY|O_BINARY)) == -1 ) - { - error(0,"Unable to open \"%s\"", cmd+7); - return ; - } - - len = filelength(handle); - - if ( len >= BUFFER_SIZE ) - { - error(0,"File \"%s\" is too large to BinInc (%dK).", cmd+7, (int)(len>>10)); - close(handle); - return ; - } - - /* - * Since we know len is less than BUFFER_SIZE (and therefore less then - * 64K) we can treat it as an unsigned. - */ - - CHK_BUFFER((unsigned)len); - - read(handle, curr, (unsigned)len); - - curr += (unsigned)len; - - close(handle); - } - - -void start_topic(TOPIC *t, char *title, int title_len) - { - t->flags = 0; - t->title_len = title_len; - t->title = dupstr(title, title_len+1); - t->title[title_len] = '\0'; - t->doc_page = -1; - t->num_page = 0; - curr = buffer; - } - - -void end_topic(TOPIC *t) - { - alloc_topic_text(t, (unsigned) (curr - buffer) ); - add_topic(t); - } - - -int end_of_sentence(char *ptr) /* true if ptr is at the end of a sentence */ - { - if ( *ptr == ')') - --ptr; - - if ( *ptr == '\"') - --ptr; - - return ( *ptr=='.' || *ptr=='?' || *ptr=='!' ); - } - - -void add_blank_for_split(void) /* add space at curr for merging two lines */ - { - if ( !is_hyphen(curr-1) ) /* no spaces if it's a hyphen */ - { - if ( end_of_sentence(curr-1) ) - *curr++ = ' '; /* two spaces at end of a sentence */ - *curr++ = ' '; - } - } - - -void put_a_char(int ch, TOPIC *t) - { - if (ch == '{' && !(t->flags & TF_DATA) ) /* is it a hot-link? */ - parse_link(); - else - { - if ( (ch&0xFF) <= MAX_CMD) - *curr++ = CMD_LITERAL; - *curr++ = ch; - } - } - - -enum STATES /* states for FSM's */ - { - S_Start, /* initial state, between paragraphs */ - S_StartFirstLine, /* spaces at start of first line */ - S_FirstLine, /* text on the first line */ - S_FirstLineSpaces, /* spaces on the first line */ - S_StartSecondLine, /* spaces at start of second line */ - S_Line, /* text on lines after the first */ - S_LineSpaces, /* spaces on lines after the first */ - S_StartLine, /* spaces at start of lines after second */ - S_FormatDisabled, /* format automatically disabled for this line */ - S_FormatDisabledSpaces, /* spaces in line which format is disabled */ - S_Spaces - } ; - - -void check_command_length(int eoff, int len) - { - if ((int) strlen(cmd) != len) - error(eoff, "Invalid text after a command \"%s\"", cmd+len); - } - - -void read_src(char *fname) - { - int ch; - char *ptr; - TOPIC t; - LABEL lbl; - char *margin_pos = NULL; - int in_topic = 0, - formatting = 1, - state = S_Start, - num_spaces = 0, - margin = 0, - in_para = 0, - centering = 0, - lformat_exclude = format_exclude, - again; - - xonline = xdoc = 0; - - src_cfname = fname; - - if ( (srcfile = fopen(fname, "rt")) == NULL ) - fatal(0,"Unable to open \"%s\"", fname); - - msg("Compiling: %s", fname); - - in_topic = 0; - - curr = buffer; - - while ( 1 ) - { - - ch = read_char(); - - if ( ch == -1 ) /* EOF? */ - { - if ( include_stack_top >= 0) - { - fclose(srcfile); - src_cfname = include_stack[include_stack_top].fname; - srcfile = include_stack[include_stack_top].file; - srcline = include_stack[include_stack_top].line; - srccol = include_stack[include_stack_top].col; - --include_stack_top; - continue; - } - else - { - if (in_topic) /* if we're in a topic, finish it */ - end_topic(&t); - if (num_topic == 0) - warn(0,".SRC file has no topics."); - break; - } - } - - if (ch == '~') /* is is a command? */ - { - int imbedded; - int eoff; - int done; - - ch = read_char(); - if (ch == '(') - { - imbedded = 1; - eoff = 0; - } - else - { - imbedded = 0; - eoff=0; - unread_char(ch); - } - - done = 0; - - while ( !done ) - { - do - ch = read_char(); - while (ch == ' '); - unread_char(ch); - - if (imbedded) - ptr = read_until(cmd, 128, ")\n,"); - else - ptr = read_until(cmd, 128, "\n,"); - - done = 1; - - if ( *ptr == '\0' ) - { - error(0,"Unexpected EOF in command."); - break; - } - - if (*ptr == '\n') - ++eoff; - - if ( imbedded && *ptr == '\n' ) - error(eoff,"Imbedded command has no closing parend (\')\')"); - - done = (*ptr != ','); /* we done if it's not a comma */ - - if ( *ptr != '\n' && *ptr != ')' && *ptr != ',' ) - { - error(0,"Command line too long."); - break; - } - - *ptr = '\0'; - - - /* commands allowed anytime... */ - - if ( strnicmp(cmd, "Topic=", 6) == 0 ) - { - if (in_topic) /* if we're in a topic, finish it */ - end_topic(&t); - else - in_topic = 1; - - if (cmd[6] == '\0') - warn(eoff,"Topic has no title."); - - else if ((int)strlen(cmd+6) > 70) - error(eoff,"Topic title is too long."); - - else if ((int)strlen(cmd+6) > 60) - warn(eoff,"Topic title is long."); - - if ( find_topic_title(cmd+6) != -1 ) - error(eoff,"Topic title already exists."); - - start_topic(&t, cmd+6, (unsigned)(ptr-(cmd+6))); - formatting = 1; - centering = 0; - state = S_Start; - in_para = 0; - num_spaces = 0; - xonline = xdoc = 0; - lformat_exclude = format_exclude; - compress_spaces = 1; - continue; - } - - else if ( strnicmp(cmd, "Data=", 5) == 0 ) - { - if (in_topic) /* if we're in a topic, finish it */ - end_topic(&t); - else - in_topic = 1; - - if (cmd[5] == '\0') - warn(eoff,"Data topic has no label."); - - if ( !validate_label_name(cmd+5) ) - { - error(eoff,"Label \"%s\" contains illegal characters.", cmd+5); - continue; - } - - if ( find_label(cmd+5) != NULL ) - { - error(eoff,"Label \"%s\" already exists", cmd+5); - continue; - } - - if ( cmd[5] == '@' ) - warn(eoff, "Data topic has a local label."); - - start_topic(&t, "", 0); - t.flags |= TF_DATA; - - if ((int)strlen(cmd+5) > 32) - warn(eoff,"Label name is long."); - - lbl.name = dupstr(cmd+5, 0); - lbl.topic_num = num_topic; - lbl.topic_off = 0; - lbl.doc_page = -1; - add_label(&lbl); - - formatting = 0; - centering = 0; - state = S_Start; - in_para = 0; - num_spaces = 0; - xonline = xdoc = 0; - lformat_exclude = format_exclude; - compress_spaces = 0; - continue; - } - - else if ( strnicmp(cmd, "DocContents", 11) == 0 ) - { - check_command_length(eoff, 11); - if (in_topic) /* if we're in a topic, finish it */ - end_topic(&t); - if (!done) - { - if (imbedded) - unread_char('('); - unread_char('~'); - done = 1; - } - compress_spaces = 1; - process_contents(); - in_topic = 0; - continue; - } - - else if ( stricmp(cmd, "Comment") == 0 ) - { - process_comment(); - continue; - } - - else if ( strnicmp(cmd, "FormatExclude", 13) == 0 ) - { - if (cmd[13] == '-') - { - check_command_length(eoff, 14); - if ( in_topic ) - { - if (lformat_exclude > 0) - lformat_exclude = -lformat_exclude; - else - warn(eoff,"\"FormatExclude-\" is already in effect."); - } - else - { - if (format_exclude > 0) - format_exclude = -format_exclude; - else - warn(eoff,"\"FormatExclude-\" is already in effect."); - } - } - else if (cmd[13] == '+') - { - check_command_length(eoff,14); - if ( in_topic ) - { - if (lformat_exclude < 0) - lformat_exclude = -lformat_exclude; - else - warn(eoff,"\"FormatExclude+\" is already in effect."); - } - else - { - if (format_exclude < 0) - format_exclude = -format_exclude; - else - warn(eoff,"\"FormatExclude+\" is already in effect."); - } - } - else if (cmd[13] == '=') - { - if (cmd[14] == 'n' || cmd[14] == 'N') - { - check_command_length(eoff,15); - if (in_topic) - lformat_exclude = 0; - else - format_exclude = 0; - } - else if (cmd[14] == '\0') - lformat_exclude = format_exclude; - else - { - int n = ( ( (in_topic) ? lformat_exclude : format_exclude) < 0 ) ? -1 : 1; - - lformat_exclude = atoi(cmd+14); - - if ( lformat_exclude <= 0 ) - { - error(eoff,"Invalid argument to FormatExclude="); - lformat_exclude = 0; - } - - lformat_exclude *= n; - - if ( !in_topic ) - format_exclude = lformat_exclude; - } - } - else - error(eoff,"Invalid format for FormatExclude"); - - continue; - } - - else if ( strnicmp(cmd, "Include ", 8) == 0 ) - { - if (include_stack_top >= MAX_INCLUDE_STACK-1) - error(eoff, "Too many nested Includes."); - else - { - ++include_stack_top; - include_stack[include_stack_top].fname = src_cfname; - include_stack[include_stack_top].file = srcfile; - include_stack[include_stack_top].line = srcline; - include_stack[include_stack_top].col = srccol; - strupr(cmd+8); - if ( (srcfile = fopen(cmd+8, "rt")) == NULL ) - { - error(eoff, "Unable to open \"%s\"", cmd+8); - srcfile = include_stack[include_stack_top--].file; - } - src_cfname = dupstr(cmd+8,0); /* never deallocate! */ - srcline = 1; - srccol = 0; - } - - continue; - } - - - /* commands allowed only before all topics... */ - - if ( !in_topic ) - { - if ( strnicmp(cmd, "HdrFile=", 8) == 0 ) - { - if (hdr_fname[0] != '\0') - warn(eoff,"Header Filename has already been defined."); - strcpy(hdr_fname, cmd+8); - strupr(hdr_fname); - } - - else if ( strnicmp(cmd, "HlpFile=", 8) == 0 ) - { - if (hlp_fname[0] != '\0') - warn(eoff,"Help Filename has already been defined."); - strcpy(hlp_fname, cmd+8); - strupr(hlp_fname); - } - - else if ( strnicmp(cmd, "Version=", 8) == 0 ) - { - if (version != -1) /* an unlikely value */ - warn(eoff,"Help version has already been defined"); - version = atoi(cmd+8); - } - - else - error(eoff,"Bad or unexpected command \"%s\"", cmd); - - continue; - } - - - /* commands allowed only in a topic... */ - - else - { - if (strnicmp(cmd, "FF", 2) == 0 ) - { - check_command_length(eoff,2); - if ( in_para ) - *curr++ = '\n'; /* finish off current paragraph */ - *curr++ = CMD_FF; - state = S_Start; - in_para = 0; - num_spaces = 0; - } - - else if (strnicmp(cmd, "DocFF", 5) == 0 ) - { - check_command_length(eoff,5); - if ( in_para ) - *curr++ = '\n'; /* finish off current paragraph */ - if (!xonline) - *curr++ = CMD_XONLINE; - *curr++ = CMD_FF; - if (!xonline) - *curr++ = CMD_XONLINE; - state = S_Start; - in_para = 0; - num_spaces = 0; - } - - else if (strnicmp(cmd, "OnlineFF", 8) == 0 ) - { - check_command_length(eoff,8); - if ( in_para ) - *curr++ = '\n'; /* finish off current paragraph */ - if (!xdoc) - *curr++ = CMD_XDOC; - *curr++ = CMD_FF; - if (!xdoc) - *curr++ = CMD_XDOC; - state = S_Start; - in_para = 0; - num_spaces = 0; - } - - else if ( strnicmp(cmd, "Label=", 6) == 0 ) - { - if ((int)strlen(cmd+6) <= 0) - error(eoff,"Label has no name."); - - else if ( !validate_label_name(cmd+6) ) - error(eoff,"Label \"%s\" contains illegal characters.", cmd+6); - - else if ( find_label(cmd+6) != NULL ) - error(eoff,"Label \"%s\" already exists", cmd+6); - - else - { - if ((int)strlen(cmd+6) > 32) - warn(eoff,"Label name is long."); - - if ( (t.flags & TF_DATA) && cmd[6] == '@' ) - warn(eoff, "Data topic has a local label."); - - lbl.name = dupstr(cmd+6, 0); - lbl.topic_num = num_topic; - lbl.topic_off = (unsigned)(curr - buffer); - lbl.doc_page = -1; - add_label(&lbl); - } - } - - else if ( strnicmp(cmd, "Table=", 6) == 0 ) - { - if ( in_para ) - { - *curr++ = '\n'; /* finish off current paragraph */ - in_para = 0; - num_spaces = 0; - state = S_Start; - } - - if (!done) - { - if (imbedded) - unread_char('('); - unread_char('~'); - done = 1; - } - - create_table(); - } - - else if ( strnicmp(cmd, "FormatExclude", 12) == 0 ) - { - if (cmd[13] == '-') - { - check_command_length(eoff,14); - if (lformat_exclude > 0) - lformat_exclude = -lformat_exclude; - else - warn(0,"\"FormatExclude-\" is already in effect."); - } - else if (cmd[13] == '+') - { - check_command_length(eoff,14); - if (lformat_exclude < 0) - lformat_exclude = -lformat_exclude; - else - warn(0,"\"FormatExclude+\" is already in effect."); - } - else - error(eoff,"Unexpected or invalid argument to FormatExclude."); - } - - else if ( strnicmp(cmd, "Format", 6) == 0 ) - { - if (cmd[6] == '+') - { - check_command_length(eoff,7); - if ( !formatting ) - { - formatting = 1; - in_para = 0; - num_spaces = 0; - state = S_Start; - } - else - warn(eoff,"\"Format+\" is already in effect."); - } - else if (cmd[6] == '-') - { - check_command_length(eoff,7); - if ( formatting ) - { - if ( in_para ) - *curr++ = '\n'; /* finish off current paragraph */ - state = S_Start; - in_para = 0; - formatting = 0; - num_spaces = 0; - state = S_Start; - } - else - warn(eoff,"\"Format-\" is already in effect."); - } - else - error(eoff,"Invalid argument to Format."); - } - - else if ( strnicmp(cmd, "Online", 6) == 0 ) - { - if (cmd[6] == '+') - { - check_command_length(eoff,7); - - if ( xonline ) - { - *curr++ = CMD_XONLINE; - xonline = 0; - } - else - warn(eoff,"\"Online+\" already in effect."); - } - else if (cmd[6] == '-') - { - check_command_length(eoff,7); - if ( !xonline ) - { - *curr++ = CMD_XONLINE; - xonline = 1; - } - else - warn(eoff,"\"Online-\" already in effect."); - } - else - error(eoff,"Invalid argument to Online."); - } - - else if ( strnicmp(cmd, "Doc", 3) == 0 ) - { - if (cmd[3] == '+') - { - check_command_length(eoff,4); - if ( xdoc ) - { - *curr++ = CMD_XDOC; - xdoc = 0; - } - else - warn(eoff,"\"Doc+\" already in effect."); - } - else if (cmd[3] == '-') - { - check_command_length(eoff,4); - if ( !xdoc ) - { - *curr++ = CMD_XDOC; - xdoc = 1; - } - else - warn(eoff,"\"Doc-\" already in effect."); - } - else - error(eoff,"Invalid argument to Doc."); - } - - else if ( strnicmp(cmd, "Center", 6) == 0 ) - { - if (cmd[6] == '+') - { - check_command_length(eoff,7); - if ( !centering ) - { - centering = 1; - if ( in_para ) - { - *curr++ = '\n'; - in_para = 0; - } - state = S_Start; /* for centering FSM */ - } - else - warn(eoff,"\"Center+\" already in effect."); - } - else if (cmd[6] == '-') - { - check_command_length(eoff,7); - if ( centering ) - { - centering = 0; - state = S_Start; /* for centering FSM */ - } - else - warn(eoff,"\"Center-\" already in effect."); - } - else - error(eoff,"Invalid argument to Center."); - } - - else if ( strnicmp(cmd, "CompressSpaces", 14) == 0 ) - { - check_command_length(eoff,15); - - if ( cmd[14] == '+' ) - { - if ( compress_spaces ) - warn(eoff,"\"CompressSpaces+\" is already in effect."); - else - compress_spaces = 1; - } - else if ( cmd[14] == '-' ) - { - if ( !compress_spaces ) - warn(eoff,"\"CompressSpaces-\" is already in effect."); - else - compress_spaces = 0; - } - else - error(eoff,"Invalid argument to CompressSpaces."); - } - - else if ( strnicmp("BinInc ", cmd, 7) == 0 ) - { - if ( !(t.flags & TF_DATA) ) - error(eoff,"BinInc allowed only in Data topics."); - else - process_bininc(); - } - - else - error(eoff,"Bad or unexpected command \"%s\".", cmd); - } /* else */ - - } /* while (!done) */ - - continue; - } - - if ( !in_topic ) - { - cmd[0] = ch; - ptr = read_until(cmd+1, 127, "\n~"); - if (*ptr == '~') - unread_char('~'); - *ptr = '\0'; - error(0,"Text outside of any topic \"%s\".", cmd); - continue; - } - - if ( centering ) - { - do - { - again = 0; /* default */ - - switch (state) - { - case S_Start: - if (ch == ' ') - ; /* do nothing */ - else if ( (ch&0xFF) == '\n' ) - *curr++ = ch; /* no need to center blank lines. */ - else - { - *curr++ = CMD_CENTER; - state = S_Line; - again = 1; - } - break; - - case S_Line: - put_a_char(ch, &t); - if ( (ch&0xFF) == '\n') - state = S_Start; - break; - } /* switch */ - } - while (again); - } - - else if ( formatting ) - { - int again; - - do - { - again = 0; /* default */ - - switch (state) - { - case S_Start: - if ( (ch&0xFF) == '\n' ) - *curr++ = ch; - else - { - state = S_StartFirstLine; - num_spaces = 0; - again = 1; - } - break; - - case S_StartFirstLine: - if ( ch == ' ') - ++num_spaces; - - else - { - if (lformat_exclude > 0 && num_spaces >= lformat_exclude ) - { - put_spaces(num_spaces); - num_spaces = 0; - state = S_FormatDisabled; - again = 1; - } - else - { - *curr++ = CMD_PARA; - *curr++ = (char)num_spaces; - *curr++ = (char)num_spaces; - margin_pos = curr - 1; - state = S_FirstLine; - again = 1; - in_para = 1; - } - } - break; - - case S_FirstLine: - if (ch == '\n') - { - state = S_StartSecondLine; - num_spaces = 0; - } - else if (ch == ('\n'|0x100) ) /* force end of para ? */ - { - *curr++ = '\n'; - in_para = 0; - state = S_Start; - } - else if ( ch == ' ' ) - { - state = S_FirstLineSpaces; - num_spaces = 1; - } - else - put_a_char(ch, &t); - break; - - case S_FirstLineSpaces: - if (ch == ' ') - ++num_spaces; - else - { - put_spaces(num_spaces); - state = S_FirstLine; - again = 1; - } - break; - - case S_StartSecondLine: - if ( ch == ' ') - ++num_spaces; - else if ((ch&0xFF) == '\n') /* a blank line means end of a para */ - { - *curr++ = '\n'; /* end the para */ - *curr++ = '\n'; /* for the blank line */ - in_para = 0; - state = S_Start; - } - else - { - if (lformat_exclude > 0 && num_spaces >= lformat_exclude ) - { - *curr++ = '\n'; - in_para = 0; - put_spaces(num_spaces); - num_spaces = 0; - state = S_FormatDisabled; - again = 1; - } - else - { - add_blank_for_split(); - margin = num_spaces; - *margin_pos = (char)num_spaces; - state = S_Line; - again = 1; - } - } - break; - - case S_Line: /* all lines after the first */ - if (ch == '\n') - { - state = S_StartLine; - num_spaces = 0; - } - else if (ch == ('\n' | 0x100) ) /* force end of para ? */ - { - *curr++ = '\n'; - in_para = 0; - state = S_Start; - } - else if ( ch == ' ' ) - { - state = S_LineSpaces; - num_spaces = 1; - } - else - put_a_char(ch, &t); - break; - - case S_LineSpaces: - if (ch == ' ') - ++num_spaces; - else - { - put_spaces(num_spaces); - state = S_Line; - again = 1; - } - break; - - case S_StartLine: /* for all lines after the second */ - if ( ch == ' ') - ++num_spaces; - else if ((ch&0xFF) == '\n') /* a blank line means end of a para */ - { - *curr++ = '\n'; /* end the para */ - *curr++ = '\n'; /* for the blank line */ - in_para = 0; - state = S_Start; - } - else - { - if ( num_spaces != margin ) - { - *curr++ = '\n'; - in_para = 0; - state = S_StartFirstLine; /* with current num_spaces */ - again = 1; - } - else - { - add_blank_for_split(); - state = S_Line; - again = 1; - } - } - break; - - case S_FormatDisabled: - if ( ch == ' ' ) - { - state = S_FormatDisabledSpaces; - num_spaces = 1; - } - else - { - if ( (ch&0xFF) == '\n' ) - state = S_Start; - put_a_char(ch, &t); - } - break; - - case S_FormatDisabledSpaces: - if ( ch == ' ' ) - ++num_spaces; - else - { - put_spaces(num_spaces); - num_spaces = 0; /* is this needed? */ - state = S_FormatDisabled; - again = 1; - } - break; - - } /* switch (state) */ - } - while (again); - } - - else - { - do - { - again = 0; /* default */ - - switch (state) - { - case S_Start: - if ( ch == ' ' ) - { - state = S_Spaces; - num_spaces = 1; - } - else - put_a_char(ch, &t); - break; - - case S_Spaces: - if (ch == ' ') - ++num_spaces; - else - { - put_spaces(num_spaces); - num_spaces = 0; /* is this needed? */ - state = S_Start; - again = 1; - } - break; - } /* switch */ - } - while (again); - } - - CHK_BUFFER(0); - } /* while ( 1 ) */ - - fclose(srcfile); - - srcline = -1; - } - - -/* - * stuff to resolve hot-link references. - */ - - -void make_hot_links(void) - /* - * calculate topic_num/topic_off for each link. - */ - { - LINK *l; - LABEL *lbl; - int lctr; - int t; - CONTENT *c; - int ctr; - - msg("Making hot-links."); - - /* - * Calculate topic_num for all entries in DocContents. Also set - * "TF_IN_DOC" flag for all topics included in the document. - */ - - for (lctr=0, c=contents; lctrnum_topic; ctr++) - { - if ( c->is_label[ctr] ) - { - lbl = find_label(c->topic_name[ctr]); - if (lbl == NULL) - { - src_cfname = c->srcfile; - srcline = c->srcline; - error(0,"Cannot find DocContent label \"%s\".", c->topic_name[ctr]); - srcline = -1; - } - else - { - if ( topic[lbl->topic_num].flags & TF_DATA ) - { - src_cfname = c->srcfile; - srcline = c->srcline; - error(0,"Label \"%s\" is a data-only topic.", c->topic_name[ctr]); - srcline = -1; - } - else - { - c->topic_num[ctr] = lbl->topic_num; - if ( topic[lbl->topic_num].flags & TF_IN_DOC ) - warn(0,"Topic \"%s\" appears in document more than once.", - topic[lbl->topic_num].title); - else - topic[lbl->topic_num].flags |= TF_IN_DOC; - } - } - - } - else - { - t = find_topic_title(c->topic_name[ctr]); - - if (t == -1) - { - src_cfname = c->srcfile; - srcline = c->srcline; - error(0,"Cannot find DocContent topic \"%s\".", c->topic_name[ctr]); - srcline = -1; /* back to reality */ - } - else - { - c->topic_num[ctr] = t; - if ( topic[t].flags & TF_IN_DOC ) - warn(0,"Topic \"%s\" appears in document more than once.", - topic[t].title); - else - topic[t].flags |= TF_IN_DOC; - } - } - } - } - - /* - * Find topic_num and topic_off for all hot-links. Also flag all hot- - * links which will (probably) appear in the document. - */ - - for (lctr=0, l=a_link; lctrtype ) - { - case 0: /* name is the title of the topic */ - t = find_topic_title(l->name); - if (t == -1) - { - src_cfname = l->srcfile; - srcline = l->srcline; /* pretend we are still in the source... */ - error(0,"Cannot find implicit hot-link \"%s\".", l->name); - srcline = -1; /* back to reality */ - } - else - { - l->topic_num = t; - l->topic_off = 0; - l->doc_page = (topic[t].flags & TF_IN_DOC) ? 0 : -1; - } - break; - - case 1: /* name is the name of a label */ - lbl = find_label(l->name); - if (lbl == NULL) - { - src_cfname = l->srcfile; - srcline = l->srcline; /* pretend again */ - error(0,"Cannot find explicit hot-link \"%s\".", l->name); - srcline = -1; - } - else - { - if ( topic[lbl->topic_num].flags & TF_DATA ) - { - src_cfname = l->srcfile; - srcline = l->srcline; - error(0,"Label \"%s\" is a data-only topic.", l->name); - srcline = -1; - } - else - { - l->topic_num = lbl->topic_num; - l->topic_off = lbl->topic_off; - l->doc_page = (topic[lbl->topic_num].flags & TF_IN_DOC) ? 0 : -1; - } - } - break; - - case 2: /* it's a "special" link; topic_off already has the value */ - break; - } - } - - } - - -/* - * online help pagination stuff - */ - - -void add_page_break(TOPIC *t, int margin, char *text, char *start, char *curr, int num_links) - { - PAGE p; - - p.offset = (unsigned) (start - text); - p.length = (unsigned) (curr - start); - p.margin = margin; - add_page(t, &p); - - if (max_links < num_links) - max_links = num_links; - } - - -void paginate_online(void) /* paginate the text for on-line help */ - { /* also calculates max_pages and max_links */ - int lnum; - char *start; - char *curr; - char *text; - TOPIC *t; - int tctr; - unsigned len; - int skip_blanks; - int num_links; - int col; - int tok; - int size, - width; - int start_margin; - - msg("Paginating online help."); - - for (t=topic, tctr=0; tctrflags & TF_DATA ) - continue; /* don't paginate data topics */ - - text = get_topic_text(t); - curr = text; - len = t->text_len; - - start = curr; - skip_blanks = 0; - lnum = 0; - num_links = 0; - col = 0; - start_margin = -1; - - while (len > 0) - { - tok = find_token_length(ONLINE, curr, len, &size, &width); - - switch ( tok ) - { - case TOK_PARA: - { - int indent, - margin; - - ++curr; - - indent = *curr++; - margin = *curr++; - - len -= 3; - - col = indent; - - while (1) - { - tok = find_token_length(ONLINE, curr, len, &size, &width); - - if (tok == TOK_DONE || tok == TOK_NL || tok == TOK_FF ) - break; - - if ( tok == TOK_PARA ) - { - col = 0; /* fake a nl */ - ++lnum; - break; - } - - if (tok == TOK_XONLINE || tok == TOK_XDOC ) - { - curr += size; - len -= size; - continue; - } - - /* now tok is TOK_SPACE or TOK_LINK or TOK_WORD */ - - if (col+width > SCREEN_WIDTH) - { /* go to next line... */ - if ( ++lnum >= SCREEN_DEPTH ) - { /* go to next page... */ - add_page_break(t, start_margin, text, start, curr, num_links); - start = curr + ( (tok == TOK_SPACE) ? size : 0 ); - start_margin = margin; - lnum = 0; - num_links = 0; - } - if ( tok == TOK_SPACE ) - width = 0; /* skip spaces at start of a line */ - - col = margin; - } - - col += width; - curr += size; - len -= size; - } - - skip_blanks = 0; - width = size = 0; - break; - } - - case TOK_NL: - if (skip_blanks && col == 0) - { - start += size; - break; - } - ++lnum; - if ( lnum >= SCREEN_DEPTH || (col == 0 && lnum==SCREEN_DEPTH-1) ) - { - add_page_break(t, start_margin, text, start, curr, num_links); - start = curr + size; - start_margin = -1; - lnum = 0; - num_links = 0; - skip_blanks = 1; - } - col = 0; - break; - - case TOK_FF: - col = 0; - if (skip_blanks) - { - start += size; - break; - } - add_page_break(t, start_margin, text, start, curr, num_links); - start_margin = -1; - start = curr + size; - lnum = 0; - num_links = 0; - break; - - case TOK_DONE: - case TOK_XONLINE: /* skip */ - case TOK_XDOC: /* ignore */ - case TOK_CENTER: /* ignore */ - break; - - case TOK_LINK: - ++num_links; - - /* fall-through */ - - default: /* TOK_SPACE, TOK_LINK, TOK_WORD */ - skip_blanks = 0; - break; - - } /* switch */ - - curr += size; - len -= size; - col += width; - } /* while */ - - if (!skip_blanks) - add_page_break(t, start_margin, text, start, curr, num_links); - - if (max_pages < t->num_page) - max_pages = t->num_page; - - release_topic_text(t, 0); - } /* for */ - } - - -/* - * paginate document stuff - */ - - -#define CNUM 0 -#define TNUM 1 -#define LINK_DEST_WARN 2 - - -typedef struct - { - int cnum, /* must match above #defines so pd_get_info() will work */ - tnum, - link_dest_warn; - - char *start; - CONTENT *c; - LABEL *lbl; - - } PAGINATE_DOC_INFO; - - -LABEL *find_next_label_by_topic(int t) - { - LABEL *temp, *g, *p; - int ctr; - - g = p = NULL; - - for (temp=label, ctr=0; ctrtopic_num == t && temp->doc_page == -1 ) - { - g = temp; - break; - } - else if (temp->topic_num > t) - break; - - for (temp=plabel, ctr=0; ctrtopic_num == t && temp->doc_page == -1 ) - { - p = temp; - break; - } - else if (temp->topic_num > t) - break; - - if ( p == NULL ) - return (g); - - else if ( g == NULL ) - return (p); - - else - return ( (g->topic_off < p->topic_off) ? g : p ); - } - - -void set_hot_link_doc_page(void) - /* - * Find doc_page for all hot-links. - */ - { - LINK *l; - LABEL *lbl; - int lctr; - int t; - - for (lctr=0, l=a_link; lctrtype ) - { - case 0: /* name is the title of the topic */ - t = find_topic_title(l->name); - if (t == -1) - { - src_cfname = l->srcfile; - srcline = l->srcline; /* pretend we are still in the source... */ - error(0,"Cannot find implicit hot-link \"%s\".", l->name); - srcline = -1; /* back to reality */ - } - else - l->doc_page = topic[t].doc_page; - break; - - case 1: /* name is the name of a label */ - lbl = find_label(l->name); - if (lbl == NULL) - { - src_cfname = l->srcfile; - srcline = l->srcline; /* pretend again */ - error(0,"Cannot find explicit hot-link \"%s\".", l->name); - srcline = -1; - } - else - l->doc_page = lbl->doc_page; - break; - - case 2: /* special topics don't appear in the document */ - break; - } - } - } - - -void set_content_doc_page(void) - /* - * insert page #'s in the DocContents - */ - { - CONTENT *c; - TOPIC *t; - char *base; - int tnum; - int ctr; - char buf[4]; - int len; - - tnum = find_topic_title(DOCCONTENTS_TITLE); - assert(tnum>=0); - t = &topic[tnum]; - - base = get_topic_text(t); - - for (ctr=1, c=contents+1; ctrdoc_page>=1); - sprintf(buf, "%d", c->doc_page); - len = (int) strlen(buf); - assert(len<=3); - memcpy(base+c->page_num_pos+(3-len), buf, len); - } - - release_topic_text(t, 1); - } - - -int pd_get_info(int cmd, PD_INFO *pd, int *info) - { /* this funtion also used by print_document() */ - CONTENT *c; - - switch (cmd) - { - case PD_GET_CONTENT: - if ( ++info[CNUM] >= num_contents ) - return (0); - c = &contents[info[CNUM]]; - info[TNUM] = -1; - pd->id = c->id; - pd->title = c->name; - pd->new_page = (c->flags & CF_NEW_PAGE) ? 1 : 0; - return (1); - - case PD_GET_TOPIC: - c = &contents[info[CNUM]]; - if ( ++info[TNUM] >= c->num_topic ) - return (0); - pd->curr = get_topic_text( &topic[c->topic_num[info[TNUM]]] ); - pd->len = topic[c->topic_num[info[TNUM]]].text_len; - return (1); - - case PD_GET_LINK_PAGE: - if ( a_link[getint(pd->s)].doc_page == -1 ) - { - if ( info[LINK_DEST_WARN] ) - { - src_cfname = a_link[getint(pd->s)].srcfile; - srcline = a_link[getint(pd->s)].srcline; - warn(0,"Hot-link destination is not in the document."); - srcline = -1; - } - return (0); - } - pd->i = a_link[getint(pd->s)].doc_page; - return (1); - - case PD_RELEASE_TOPIC: - c = &contents[info[CNUM]]; - release_topic_text(&topic[c->topic_num[info[TNUM]]], 0); - return (1); - - default: - return (0); - } - } - - -int paginate_doc_output(int cmd, PD_INFO *pd, PAGINATE_DOC_INFO *info) - { - switch (cmd) - { - case PD_FOOTING: - case PD_PRINT: - case PD_PRINTN: - case PD_PRINT_SEC: - return (1); - - case PD_HEADING: - ++num_doc_pages; - return (1); - - case PD_START_SECTION: - info->c = &contents[info->cnum]; - return (1); - - case PD_START_TOPIC: - info->start = pd->curr; - info->lbl = find_next_label_by_topic(info->c->topic_num[info->tnum]); - return (1); - - case PD_SET_SECTION_PAGE: - info->c->doc_page = pd->pnum; - return (1); - - case PD_SET_TOPIC_PAGE: - topic[info->c->topic_num[info->tnum]].doc_page = pd->pnum; - return (1); - - case PD_PERIODIC: - while ( info->lbl != NULL && (unsigned)(pd->curr - info->start) >= info->lbl->topic_off) - { - info->lbl->doc_page = pd->pnum; - info->lbl = find_next_label_by_topic(info->c->topic_num[info->tnum]); - } - return (1); - - default: - return (0); - } - } - - -void paginate_document(void) - { - PAGINATE_DOC_INFO info; - - if (num_contents == 0) - return ; - - msg("Paginating document."); - - info.cnum = info.tnum = -1; - info.link_dest_warn = 1; - - process_document((PD_FUNC)pd_get_info, (PD_FUNC)paginate_doc_output, &info); - - set_hot_link_doc_page(); - set_content_doc_page(); - } - - -/* - * label sorting stuff - */ - -int fcmp_LABEL(VOIDCONSTPTR a, VOIDCONSTPTR b) - { - char *an = ((LABEL *)a)->name, - *bn = ((LABEL *)b)->name; - int diff; - - /* compare the names, making sure that the index goes first */ - - if ( (diff=strcmp(an,bn)) == 0 ) - return (0); - - if ( strcmp(an, INDEX_LABEL) == 0 ) - return (-1); - - if ( strcmp(bn, INDEX_LABEL) == 0 ) - return (1); - - return ( diff ); - } - - -void sort_labels(void) - { - qsort(label, num_label, sizeof(LABEL), fcmp_LABEL); - qsort(plabel, num_plabel, sizeof(LABEL), fcmp_LABEL); - } - - -/* - * file write stuff. - */ - - -int compare_files(FILE *f1, FILE *f2) /* returns TRUE if different */ - { - if ( filelength(fileno(f1)) != filelength(fileno(f2)) ) - return (1); /* different if sizes are not the same */ - - while ( !feof(f1) && !feof(f2) ) - if ( getc(f1) != getc(f2) ) - return (1); - - return ( ( feof(f1) && feof(f2) ) ? 0 : 1); - } - - -void _write_hdr(char *fname, FILE *file) - { - int ctr; - char nfile[MAXFILE], - next[MAXEXT]; - - FNSPLIT(fname, NULL, NULL, nfile, next); - fprintf(file, "\n/*\n * %s%s\n", nfile, next); - FNSPLIT(src_fname, NULL, NULL, nfile, next); - fprintf(file, " *\n * Contains #defines for help.\n *\n"); - fprintf(file, " * Generated by HC from: %s%s\n *\n */\n\n\n", nfile, next); - - fprintf(file, "/* current help file version */\n"); - fprintf(file, "\n"); - fprintf(file, "#define %-32s %3d\n", "FIHELP_VERSION", version); - fprintf(file, "\n\n"); - - fprintf(file, "/* labels */\n\n"); - - for (ctr=0; ctrid) + /* id text */ - 1 + /* name length */ - (int) strlen(cp->name) + /* name text */ - 1 + /* number of topics */ - cp->num_topic*sizeof(int); /* topic numbers */ - - for (t=0, tp=topic; toffset = offset; - offset += (long)sizeof(int) + /* topic flags */ - sizeof(int) + /* number of pages */ - tp->num_page*3*sizeof(int) + /* page offset, length & starting margin */ - 1 + /* length of title */ - tp->title_len + /* title */ - sizeof(int) + /* length of text */ - tp->text_len; /* text */ - } - - } - - -void insert_real_link_info(char *curr, unsigned len) - /* - * Replaces link indexes in the help text with topic_num, topic_off and - * doc_page info. - */ - { - int size; - int tok; - LINK *l; - - while (len > 0) - { - tok = find_token_length(0, curr, len, &size, NULL); - - if ( tok == TOK_LINK ) - { - l = &a_link[ getint(curr+1) ]; - setint(curr+1,l->topic_num); - setint(curr+1+sizeof(int),l->topic_off); - setint(curr+1+2*sizeof(int),l->doc_page); - } - - len -= size; - curr += size; - } - } - - -void _write_help(FILE *file) - { - int t, p, l, c; - char *text; - TOPIC *tp; - CONTENT *cp; - struct help_sig_info hs; - - /* write the signature and version */ - - hs.sig = HELP_SIG; /* Edit line 17 of helpcom.h if this is a syntax error */ - hs.version = version; - - fwrite(&hs, sizeof(long)+sizeof(int), 1, file); - - /* write max_pages & max_links */ - - putw(max_pages, file); - putw(max_links, file); - - /* write num_topic, num_label and num_contents */ - - putw(num_topic, file); - putw(num_label, file); - putw(num_contents, file); - - /* write num_doc_page */ - - putw(num_doc_pages, file); - - /* write the offsets to each topic */ - - for (t=0; tflags, file); - - t = (int) strlen(cp->id); - putc((BYTE)t, file); - fwrite(cp->id, 1, t, file); - - t = (int) strlen(cp->name); - putc((BYTE)t, file); - fwrite(cp->name, 1, t, file); - - putc((BYTE)cp->num_topic, file); - fwrite(cp->topic_num, sizeof(int), cp->num_topic, file); - } - - /* write topics */ - - for (t=0, tp=topic; tflags, file); - - /* write offset, length and starting margin for each page */ - - putw(tp->num_page, file); - for (p=0; pnum_page; p++) - { - putw(tp->page[p].offset, file); - putw(tp->page[p].length, file); - putw(tp->page[p].margin, file); - } - - /* write the help title */ - - putc((BYTE)tp->title_len, file); - fwrite(tp->title, 1, tp->title_len, file); - - /* insert hot-link info & write the help text */ - - text = get_topic_text(tp); - - if ( !(tp->flags & TF_DATA) ) /* don't process data topics... */ - insert_real_link_info(text, tp->text_len); - - putw(tp->text_len, file); - fwrite(text, 1, tp->text_len, file); - - release_topic_text(tp, 0); /* don't save the text even though */ - /* insert_real_link_info() modified it */ - /* because we don't access the info after */ - /* this. */ - - } - } - - -void write_help(char *fname) - { - FILE *hlp; - - hlp = fopen(fname, "wb"); - - if (hlp == NULL) - fatal(0,"Cannot create .HLP file: \"%s\".", fname); - - msg("Writing: %s", fname); - - _write_help(hlp); - - fclose(hlp); - } - - -/* - * print document stuff. - */ - - -typedef struct - { - - /* - * Note: Don't move these first three or pd_get_info will work not - * correctly. - */ - - int cnum; - int tnum; - int link_dest_warn; /* = 0 */ - - FILE *file; - int margin; - int start_of_line; - int spaces; - } PRINT_DOC_INFO; - - -void printerc(PRINT_DOC_INFO *info, int c, int n) - { - while ( n-- > 0 ) - { - if (c==' ') - ++info->spaces; - - else if (c=='\n' || c=='\f') - { - info->start_of_line = 1; - info->spaces = 0; /* strip spaces before a new-line */ - putc(c, info->file); - } - - else - { - if (info->start_of_line) - { - info->spaces += info->margin; - info->start_of_line = 0; - } - - while (info->spaces > 0) - { - fputc(' ', info->file); - --info->spaces; - } - - fputc(c, info->file); - } - } - } - - -void printers(PRINT_DOC_INFO *info, char *s, int n) - { - if (n > 0) - { - while ( n-- > 0 ) - printerc(info, *s++, 1); - } - else - { - while ( *s != '\0' ) - printerc(info, *s++, 1); - } - } - - -int print_doc_output(int cmd, PD_INFO *pd, PRINT_DOC_INFO *info) - { - switch (cmd) - { - case PD_HEADING: - { - char buff[20]; - - info->margin = 0; - printers(info, "\n Fractint Version xx.xx Page ", 0); - sprintf(buff, "%d\n\n", pd->pnum); - printers(info, buff, 0); - info->margin = PAGE_INDENT; - return (1); - } - - case PD_FOOTING: - info->margin = 0; - printerc(info, '\f', 1); - info->margin = PAGE_INDENT; - return (1); - - case PD_PRINT: - printers(info, pd->s, pd->i); - return (1); - - case PD_PRINTN: - printerc(info, *pd->s, pd->i); - return (1); - - case PD_PRINT_SEC: - info->margin = TITLE_INDENT; - if (pd->id[0] != '\0') - { - printers(info, pd->id, 0); - printerc(info, ' ', 1); - } - printers(info, pd->title, 0); - printerc(info, '\n', 1); - info->margin = PAGE_INDENT; - return (1); - - case PD_START_SECTION: - case PD_START_TOPIC: - case PD_SET_SECTION_PAGE: - case PD_SET_TOPIC_PAGE: - case PD_PERIODIC: - return (1); - - default: - return (0); - } - } - - -void print_document(char *fname) - { - PRINT_DOC_INFO info; - - if (num_contents == 0) - fatal(0,".SRC has no DocContents."); - - msg("Printing to: %s", fname); - - info.cnum = info.tnum = -1; - info.link_dest_warn = 0; - - if ( (info.file = fopen(fname, "wt")) == NULL ) - fatal(0,"Couldn't create \"%s\"", fname); - - info.margin = PAGE_INDENT; - info.start_of_line = 1; - info.spaces = 0; - - process_document((PD_FUNC)pd_get_info, (PD_FUNC)print_doc_output, &info); - - fclose(info.file); - } - - -/* - * compiler status and memory usage report stuff. - */ - - -void report_memory(void) - { - long string = 0, /* bytes in strings */ - text = 0, /* bytes in topic text (stored on disk) */ - data = 0, /* bytes in active data structure */ - dead = 0; /* bytes in unused data structure */ - int ctr, ctr2; - - for (ctr=0; ctr 0) - dead += (LINK_ALLOC_SIZE-(num_link%LINK_ALLOC_SIZE)) * sizeof(LINK); - - for (ctr=0; ctr 0) - dead += (LABEL_ALLOC_SIZE-(num_label%LABEL_ALLOC_SIZE)) * sizeof(LABEL); - - for (ctr=0; ctr 0) - dead += (LABEL_ALLOC_SIZE-(num_plabel%LABEL_ALLOC_SIZE)) * sizeof(LABEL); - - for (ctr=0; ctr1; argc--, arg++) - { - switch ( (*arg)[0] ) - { - case '/': - case '-': - switch ( (*arg)[1] ) - { - case 'c': - if (mode == 0) - mode = MODE_COMPILE; - else - fatal(0,"Cannot have /c with /a, /d or /p"); - break; - - case 'a': - if (mode == 0) - mode = MODE_APPEND; - else - fatal(0,"Cannot have /a with /c, /d or /p"); - break; - - case 'd': - if (mode == 0) - mode = MODE_DELETE; - else - fatal(0,"Cannot have /d with /c, /a or /p"); - break; - - case 'p': - if (mode == 0) - mode = MODE_PRINT; - else - fatal(0,"Cannot have /p with /c, /a or /d"); - break; - - case 'm': - if (mode == MODE_COMPILE) - show_mem = 1; - else - fatal(0,"/m switch allowed only when compiling (/c)"); - break; - - case 's': - if (mode == MODE_COMPILE) - show_stats = 1; - else - fatal(0,"/s switch allowed only when compiling (/c)"); - break; - - case 'r': - if (mode == MODE_COMPILE || mode == MODE_PRINT) - strcpy(swappath, (*arg)+2); - else - fatal(0,"/r switch allowed when compiling (/c) or printing (/p)"); - break; - - case 'q': - quiet_mode = 1; - break; - - default: - fatal(0,"Bad command-line switch /%c", (*arg)[1]); - break; - } - break; - - default: /* assume it is a fname */ - if (fname1[0] == '\0') - strcpy(fname1, *arg); - else if (fname2[0] == '\0') - strcpy(fname2, *arg); - else - fatal(0,"Unexpected command-line argument \"%s\"", *arg); - break; - } /* switch */ - } /* for */ - - strupr(fname1); - strupr(fname2); - strupr(swappath); - - switch (mode) - { - case 0: - printf( "To compile a .SRC file:\n"); - printf( " HC /c [/s] [/m] [/r[path]] [src_file]\n"); - printf( " /s = report statistics.\n"); - printf( " /m = report memory usage.\n"); - printf( " /r[path] = set swap file path.\n"); - printf( " src_file = .SRC file. Default is \"%s\"\n", DEFAULT_SRC_FNAME); - printf( "To print a .SRC file:\n"); - printf( " HC /p [/r[path]] [src_file] [out_file]\n"); - printf( " /r[path] = set swap file path.\n"); - printf( " src_file = .SRC file. Default is \"%s\"\n", DEFAULT_SRC_FNAME); - printf( " out_file = Filename to print to. Default is \"%s\"\n", - DEFAULT_DOC_FNAME); - printf( "To append a .HLP file to an .EXE file:\n"); - printf( " HC /a [hlp_file] [exe_file]\n"); - printf( " hlp_file = .HLP file. Default is \"%s\"\n", DEFAULT_HLP_FNAME); - printf( " exe_file = .EXE file. Default is \"%s\"\n", DEFAULT_EXE_FNAME); - printf( "To delete help info from an .EXE file:\n"); - printf( " HC /d [exe_file]\n"); - printf( " exe_file = .EXE file. Default is \"%s\"\n", DEFAULT_EXE_FNAME); - printf( "\n"); - printf( "Use \"/q\" for quiet mode. (No status messages.)\n"); - break; - - case MODE_COMPILE: - if (fname2[0] != '\0') - fatal(0,"Unexpected command-line argument \"%s\"", fname2); - - strcpy(src_fname, (fname1[0]=='\0') ? DEFAULT_SRC_FNAME : fname1); - - strcat(swappath, SWAP_FNAME); - - if ( (swapfile=fopen(swappath, "w+b")) == NULL ) - fatal(0,"Cannot create swap file \"%s\"", swappath); - swappos = 0; - - read_src(src_fname); - - if (hdr_fname[0] == '\0') - error(0,"No .H file defined. (Use \"~HdrFile=\")"); - if (hlp_fname[0] == '\0') - error(0,"No .HLP file defined. (Use \"~HlpFile=\")"); - if (version == -1) - warn(0,"No help version has been defined. (Use \"~Version=\")"); - - /* order of these is very important... */ - - make_hot_links(); /* do even if errors since it may report */ - /* more... */ - - if ( !errors ) paginate_online(); - if ( !errors ) paginate_document(); - if ( !errors ) calc_offsets(); - if ( !errors ) sort_labels(); - if ( !errors ) write_hdr(hdr_fname); - if ( !errors ) write_help(hlp_fname); - - if ( show_stats ) - report_stats(); - - if ( show_mem ) - report_memory(); - - if ( errors || warnings ) - report_errors(); - - fclose(swapfile); - remove(swappath); - - break; - - case MODE_PRINT: - strcpy(src_fname, (fname1[0]=='\0') ? DEFAULT_SRC_FNAME : fname1); - - strcat(swappath, SWAP_FNAME); - - if ( (swapfile=fopen(swappath, "w+b")) == NULL ) - fatal(0,"Cannot create swap file \"%s\"", swappath); - swappos = 0; - - read_src(src_fname); - - make_hot_links(); - - if ( !errors ) paginate_document(); - if ( !errors ) print_document( (fname2[0]=='\0') ? DEFAULT_DOC_FNAME : fname2 ); - - if ( errors || warnings ) - report_errors(); - - fclose(swapfile); - remove(swappath); - - break; - - case MODE_APPEND: - add_hlp_to_exe( (fname1[0]=='\0') ? DEFAULT_HLP_FNAME : fname1, - (fname2[0]=='\0') ? DEFAULT_EXE_FNAME : fname2); - break; - - case MODE_DELETE: - if (fname2[0] != '\0') - fatal(0,"Unexpected argument \"%s\"", fname2); - delete_hlp_from_exe((fname1[0]=='\0') ? DEFAULT_EXE_FNAME : fname1); - break; - } - - free(buffer); - - return ( errors ); /* return the number of errors */ - } - -#if defined(_WIN32) -#pragma warning(push) -#pragma warning(disable : 4311) -#endif -void check_buffer(char *current, unsigned off, char *buffer) -{ - if ((unsigned) curr + off - (unsigned) buffer >= (BUFFER_SIZE-1024)) - { - fatal(0, "Buffer overflowerd -- Help topic too large."); - } -} -#if defined(_WIN32) -#pragma warning(pop) -#endif diff --git a/fractint/dos_help/hc.vcproj b/fractint/dos_help/hc.vcproj deleted file mode 100644 index 821d33ff0..000000000 --- a/fractint/dos_help/hc.vcproj +++ /dev/null @@ -1,135 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/fractint/dos_help/help.src b/fractint/dos_help/help.src deleted file mode 100644 index cec2ed552..000000000 --- a/fractint/dos_help/help.src +++ /dev/null @@ -1,2849 +0,0 @@ -; -; HELP.SRC -; -; -~HdrFile=HELPDEFS.H -~HlpFile=FRACTINT.HLP -~Version=100 -~FormatExclude=8 -; -; -; -~Topic=Main Help Index, Label=HELPMENU -~Label=FIHELP_INDEX - -~Format- - { Using Help } { Fractals and the PC } - { Introduction } { Distribution of Fractint } - { Conditions on Use } { Contacting the Authors } - { Getting Started } { The Stone Soup Story } - { New Features in 20.4.X } { A Word About the Authors } - { Other Fractal Products } - { Display Mode Commands } - { Color Cycling Commands } { Fractint on Unix } - { Palette Editing Commands } { Using Fractint With a Mouse } - { Video Adapter Notes } - { Summary of Fractal Types } { GIF Save File Format } - - { Doodads\, Bells\, and Whistles } { Common Problems } - { "3D" Images } - { Palette Maps } { Bibliography } - { Other Programs } - { Startup Parameters\, Parameter Files } { Revision History } - { Batch Mode } - { "Disk-Video" Modes } { Printing Fractint Documentation } - -~Format+ -; -; -; -~DocContents -{ , 0, "New Features in 20.4.X", FF} -{ , 0, "Introduction", "Conditions on Use", FF} - -{1. , 0, Fractint Commands, FF} -{1.1 , 1, "Getting Started"} -{1.2 , 1, "Plotting Commands"} -{1.3 , 1, "Zoom box Commands"} -{1.4 , 1, "Color Cycling Commands"} -{1.5 , 1, "Palette Editing Commands"} -{1.6 , 1, "Image Save/Restore Commands"} -{1.7 , 1, "Print Command"} -{1.8 , 1, "Parameter Save/Restore Commands"} -{1.9 , 1, "\"3D\" Commands"} -{1.10 , 1, "Interrupting and Resuming"} -{1.11 , 1, "Orbits Window"} -{1.12 , 1, "View Window"} -{1.13 , 1, "Video Mode Function Keys"} -{1.14 , 1, "Browse Commands"} -{1.15 , 1, "Evolver Commands"} -{1.16 , 1, "RDS Commands"} -{1.17 , 1, "Hints"} -{1.18 , 1, "Fractint on Unix"} - -{2. , 0, "Fractal Types", FF} -{2.1 , 1, "The Mandelbrot Set"} -{2.2 , 1, "Julia Sets"} -{2.3 , 1, "Julia Toggle Spacebar Commands"} -{2.4 , 1, "Inverse Julias"} -{2.5 , 1, "Newton domains of attraction"} -{2.6 , 1, "Newton"} -{2.7 , 1, "Complex Newton"} -{2.8 , 1, "Lambda Sets"} -{2.9 , 1, "Mandellambda Sets"} -{2.10 , 1, "Circle"} -{2.11 , 1, "Plasma Clouds"} -{2.12 , 1, "Lambdafn"} -{2.13 , 1, "Mandelfn"} -{2.14 , 1, "Barnsley Mandelbrot/Julia Sets"} -{2.15 , 1, "Barnsley IFS Fractals"} -{2.16 , 1, "Sierpinski Gasket"} -{2.17 , 1, "Quartic Mandelbrot/Julia"} -{2.18 , 1, "Distance Estimator"} -{2.19 , 1, "Pickover Mandelbrot/Julia Types"} -{2.20 , 1, "Pickover Popcorn"} -{2.21 , 1, "Peterson Variations"} -{2.22 , 1, "Unity"} -{2.23 , 1, "Scott Taylor / Lee Skinner Variations"} -{2.24 , 1, "Kam Torus"} -{2.25 , 1, "Bifurcation"} -{2.26 , 1, "Orbit Fractals"} -{2.27 , 1, "Lorenz Attractors"} -{2.28 , 1, "Rossler Attractors"} -{2.29 , 1, "Henon Attractors"} -{2.30 , 1, "Pickover Attractors"} -{2.31 , 1, "Gingerbreadman"} -{2.32 , 1, "Martin Attractors"} -{2.33 , 1, "Icon"} -{2.34 , 1, "Test"} -{2.35 , 1, "Formula"} -{2.36 , 1, "Julibrots"} -{2.37 , 1, "Diffusion Limited Aggregation"} -{2.38 , 1, "Magnetic Fractals"} -{2.39 , 1, "L-Systems"} -{2.40 , 1, "Lyapunov Fractals"} -{2.41 , 1, "fn||fn Fractals"} -{2.42 , 1, "Halley"} -{2.43 , 1, "Dynamic System"} -{2.44 , 1, "Mandelcloud"} -{2.45 , 1, "Quaternion"} -{2.46 , 1, "HyperComplex"} -{2.47 , 1, "Cellular Automata"} -{2.48 , 1, "Ant Automaton"} -{2.49 , 1, "Phoenix"} -{2.50 , 1, "Frothy Basins"} -{2.51 , 1, "Volterra-Lotka Fractals"} -{2.52 , 1, "Escher-Like Julia Sets"} -{2.53 , 1, "Latoocarfian"} -;{2.54 , 1, "Mandelbrot Mix 4"} - -{3. , 0, Doodads\, Bells\, and Whistles, FF} -{3.1 , 1, "Drawing Method"} -{3.2 , 1, "Palette Maps"} -{3.3 , 1, "Autokey Mode"} -{3.4 , 1, "Distance Estimator Method"} -{3.5 , 1, "Inversion"} -{3.6 , 1, "Decomposition"} -{3.7 , 1, "Logarithmic Palettes and Color Ranges"} -{3.8 , 1, "Biomorphs"} -{3.9 , 1, "Continuous Potential"} -{3.10 , 1, "Starfields"} -{3.11 , 1, "Bailout Test"} -{3.12 , 1, "Parameter Explorer/Evolver"} -{3.13 , 1, "Random Dot Stereograms (RDS)"} -{3.14 , 1, "Freestyle mode tutorial"} - -{4. , 0, "\"3D\" Images", "3D Overview", FF} -{4.1 , 1, "3D Mode Selection"} -{4.2 , 1, "Select Fill Type Screen"} -{4.3 , 1, "Stereo 3D Viewing"} -{4.4 , 1, "Rectangular Coordinate Transformation"} -{4.5 , 1, "3D Color Parameters"} -{4.6 , 1, "Light Source Parameters"} -{4.7 , 1, "Spherical Projection"} -{4.8 , 1, "3D Overlay Mode"} -{4.9 , 1, "Special Note for CGA or Hercules Users"} -{4.10 , 1, "Making Terrains"} -{4.11 , 1, "Making 3D Slides"} -{4.12 , 1, "Interfacing with Ray Tracing Programs"} - -{5. , 0, Command Line Parameters\, Parameter Files\, Batch Mode, "Introduction to Parameters", FF} -{5.1 , 1, "Using the DOS Command Line"} -{5.2 , 1, "Setting Defaults (SSTOOLS.INI File)"} -{5.3 , 1, "Parameter Files and the <@> Command"} -{5.4 , 1, "General Parameter Syntax"} -{5.5 , 1, "Startup Parameters"} -{5.6 , 1, "Calculation Mode Parameters"} -{5.7 , 1, "Fractal Type Parameters"} -{5.8 , 1, "Image Calculation Parameters"} -{5.9 , 1, "Color Parameters"} -{5.10 , 1, "Doodad Parameters"} -{5.11 , 1, "File Parameters"} -{5.12 , 1, "Video Parameters"} -{5.13 , 1, "Sound Parameters"} -{5.13.1,2, "Sound Controls"} -{5.13.2,2, "Advanced Sound Controls"} -{5.13.3,2, "Envelopes"} -{5.14 , 1, "Printer Parameters"} -{5.15 , 1, "PostScript Parameters"} -{5.16 , 1, "PaintJet Parameters"} -{5.17 , 1, "Plotter Parameters"} -{5.18 , 1, "3D Parameters"} -{5.19 , 1, "Batch Mode"} -{5.20 , 1, "Browser Parameters"} -{5.21 , 1, "Passes Parameters"} -{5.22 , 1, "Screen Coordinates Screen"} -{5.23 , 1, "Image Coordinates Screen"} - -{6. , 0, Hardware Support, FF} -{6.1 , 1, Notes on Video Modes\, \"Standard\" and Otherwise, - "Video Adapter Notes", "EGA", "Tweaked VGA", "Super-VGA", - "8514/A", "XGA", "Targa", "Targa+"} -{6.2 , 1, "\"Disk-Video\" Modes"} -{6.3 , 1, "Customized Video Modes\, FRACTINT.CFG"} - -{7. , 0, "Common Problems", FF} - -{8. , 0, "Fractals and the PC", FF} -{8.1 , 1, A Little History} -{8.1.1, 2, "Before Mandelbrot"} -{8.1.2, 2, "Who Is This Guy\, Anyway?"} -{8.2 , 1, A Little Code} -{8.2.1, 2, "Periodicity Logic"} -{8.2.2, 2, "Limitations of Integer Math (And How We Cope)"} -{8.2.3, 2, "Arbitrary Precision and Deep Zooming"} -{8.2.4, 2, "The Fractint \"Fractal Engine\" Architecture"} - -{Appendix A, 0, Mathematics of the Fractal Types, - "Summary of Fractal Types", - "Inside=bof60|bof61|zmag|fmod|period|atan", - "Inside=epscross|startrail", - "Finite Attractors", - "Trig Identities", - "Quaternion and Hypercomplex Algebra",FF} - -{Appendix B, 0, Stone Soup With Pixels: The Authors, - "The Stone Soup Story", - "A Word About the Authors", - "Distribution of Fractint", - "Contacting the Authors", FF} - -{Appendix C, 0, "GIF Save File Format", FF} - -{Appendix D, 0, "Other Fractal Products", FF} - -{Appendix E, 0, "Bibliography", FF} - -{Appendix F, 0, "Other Programs", FF} - -{Appendix G, 0, "Revision History", - "Version 20", - "Version 19", - "Version 18", - "Version 17", - "Version 16", - "Version 15", - "Versions 12 through 14", - "Versions 1 through 11", - FF} - -; -; End of DoContents -; -; -; -~Topic=Using Help -; This topic is online only. -Use the following keys in help mode: - - F1 Go to the main help index. - - PgDn/PgUp Go to the next/previous page. - - Backspace Go to the previous topic. - - Escape Exit help mode. - - Enter Select (go to) highlighted hot-link. - - Tab/Shift-Tab Move to the next/previous hot-link. - - \24 \25 \27 \26 Move to a hot-link. - - Home/End Move to the first/last hot-link. -; -; -; -~Topic=Printing Fractint Documentation -You can generate a text file containing full Fractint documentation by -selecting the "Generate FRACTINT.DOC now" hot-link below and pressing -Enter, or by using the DOS command "fractint makedoc=filename" ("filename" -is the name of the file to be written; it defaults to FRACTINT.DOC.) - -All information in the documentation file is also available in the online -help, so extracting it is a matter of preference - you can print the -file (e.g. DOS command "print fractint.doc" or "copy fractint.doc prn") -or read it with a text editor. It contains over 200 pages of information, -has a table of contents, and is cross-referenced by page number. - - {=-101 Exit without generating FRACTINT.DOC} - - {=-100 Generate FRACTINT.DOC now} - -Fractint's great (and pioneering but no longer unique) online help and -integrated documentation file software was written by Ethan Nagel. -; -; -; -~Topic=New Features in 20.4.X -This is a developer's "incremental" release. These incremental releases -typically have a short life and are updated frequently. They may have -bug fixes, and thus be more stable, but they may also have new features -which very likely have new bugs. - -Version 20.4.5 is an update of Fractint 20.0 based on the developer's - version 20.4.4. New features include: - -Patch 5 to Version 20.4.0\ - -Tim's changes (5/29/2006)\ - Moved version 20.0 change history to revision history to make room for - in help.src. - - Changed help screen to show just two main authors - decided - better not to show inactive authors. - - Removed commented out complex macros in fractals.c. - - Added commented out bf version of Mandelbrot in fractalp.c. Giving - thought to offerring bfmath as an option to bnmath, but if we fix the - current bignum problems, this may be moot. - - Added interation to screen. - -Jonathan's changes\ - Fixed the logic for calculating when to switch from using a grid to using - the on-the-fly calculation of an image's pixels. The logic was not - handling disk video images sized above 2048x2048 with floating point enabled. - - Added the savename to the disk video status screen. - - Fixed bug in the compare routine of bn_math that fixes long standing problem - with periodicity checking in deep zoomed images. - - Resurrected the documentation for ap_math that was at the beginning of bignum.c. - -Patch 4 to Version 20.4.0\ -Added minor changes so that Xfractint would compile under Cygwin. - - Added lines to the Xfractint makefile (commented out) for compiling in a - 64-bit environment. - - Fixed Xfractint so that built in calls to a different map file would - work. - - Modified the logic for calculating when to switch from using a grid - to using the on-the-fly calculation of an image's pixels. This affects - how large an image can be made when using integer math. The switch is - now made when (xdots + ydots) * sizeof(long) > 32768. - - Pulled the WinFract version 18.21 source into the CVS repository source - tree. This code now runs but still has many many bugs. - -Patch 3 to Version 20.4.0\ -Started the cleanup of the docs. Cleaned up the map directory. - - Fixed the Xfractint Makefile so that install would run. Added an - uninstall. - - Fixed Xfractint so that it can be run from an arbitrary directory and - still use the directory settings in sstools.ini. - -Patch 2 to Version 20.4.0\ -Fixed the display coordinates so they won't change, after an image had been - zoomed, when the maintain screen coordinates parameter is set to yes. - - Fixed the corner parameter screen and image parameter screen so that - rotating and/or skewing now doesn't get reset when changes are made. - -Patch 1 to Version 20.4.0\ -Added the mathtolerance and orbit_delay parameters to values written - to PARs and GIFs. - - Fixed how a mathtolerance parameter with a slash and a second number, but - no first number is read in. The slash was being interpreted as a double. - - Stole the

key for use by passes options. If you are brave enough to - try it, printing is still available using . - - Put periodicity and orbit delay on the new

screen. There are currently - two drawing modes available for the passes=orbits option. The rect(angle) - method plots the orbits in a rectangle that can be zoomed, rotated, and - skewed using the corner parameter screen, and the straight line method - plots the orbits between two points specified on the corner parameter - screen. The orbit interval parameter plots every nth orbit. The maintain - screen coordinates parameter lets you zoom into an image changing the - coordinates of the line or rectangle used to generate the image, but keeps - the display coordinates, set on the screen, the same. - - Updated the docs for center-mag and corners because center-mag is now the - default. - - Restructured the source to make it easier to maintain. - -Version 20.4.0\ -Incremented the version number to accommodate backwards compatibility for - the mandel based per-pixel routines that were not setting the Y variable. - - Added a passes=o option that draws an image by plotting the orbits of the - escape time fractals and leaving them on the screen. This technique uses - the same coordinates to draw an image as the other passes options, sets - "passes=1" and no symmetry, and then plots the orbits for each pixel. - See {Drawing Method}. - -Xfractint fixes: - Fixed the newton and newtbasin types in Xfractint so they would work - without using the FPU=387 option. - - Fixed the Xfractint mandelbrot code in calmanfp.c so that the image - generated matched the one produced by the StandardFractal() routine. - - Fixed the outside=sum option when used with the mandel fractal type. - - Fixed the command line option -geometry, which broke at 20.2.05. - -Patch 2 to Version 20.3.0\ -Fixed the inability to reload a PAR created from an arbitrary precision - fractal with a large magnification. - - Fixed the problem with a left mouse click not bringing up the zoom box - after an image is completed. - - Incorporated Gerald Dobiasovsky's fix for the julibrot type when used - with quat and hypercomplex. - - Fixed the display of subdirectories in Xfractint. - - Replaced control characters in realdos.c with the equivalent ascii values - to quiet complaints by CVS. - -Patch 1\ -Fixed the float bailout for the lambdafn fractal type when the EXP function - is used so the float and integer images match. - - Jan Andres contributed Xfractint fixes that allow compiling with newer - versions of gcc because varargs.h is no longer supported. Enabled the - use of the long double type on Solaris. Moved the getwd() macro definition - in prompts1.c after the #include lines, to avoid the mess that happens when - the prototype for getwd() is included but it's already defined as a macro. - Added some Solaris-specific comments to the Makefile. - - Fixed the sound in Xfractint so the beep turns off now. - - Changed lsys.c to use inline1 instead of the reserved word inline. - -Version 20.3.0\ -Incremented the version number to accommodate backwards compatibility for - the inside=atan and outside=atan options. - - Fixed inside=atan and outside=atan to use the full color palette instead - of limiting to 180 colors. - - Added Charlie Chernohorsky's virtual screen zoombox fix. See {View Window}. - - Added Gerald Dobiasovsky's fixes for the demo key files needed because - of menu prompt changes and pan/zoom size changes. - - Fixed evolver parameter entry. - - Fixed hypercomplex fractal type to turn off symmetry when a cj parameter - is used. - - Fixed the plasma type to show the value of the parameter that is actually - used in the image generation. - - Fixed the plasma type so that a parameter file uses the colors included - in the parameter entry instead of the default colors. - - Revised the plasma type prompt to reflect the values that can actually be - used. - - Increased the Lsystem line length from 160 characters to 255 characters. - - Fixed the browser so that it recognized the fractal type stored in images. - - Fixed the Xfractint FPUcplxdiv and FPUcplxlog routines in fpu087.c to - match the Fractint assembler code. - - Modified the Xfractint resume code to remove the Xfractint specific - sections since they are no longer needed (gcc macros match MSC macros). - -Patch 5\ -Made changes to allow Xfractint to find files that use upper case letters. - - Fixed a problem with the Cellular type that prevented entering an initial - row of greater than 32767 from working. Added a message about not being - able to resume after interrupting prior to rows being displayed on screen. - - Fixed an evolver bug which caused setting evolver parameters to turn - evolving on, even though evolving was actually turned off. - - Added Charlie Chernohorsky's truecolor speed up and his implementation - of virtual screen sizes for the VESA modes (dotmode=28). This feature - does not work consistently between different video cards, so it may be - turned off by using the startup command "virtual=n". - Use the screen to set the desired virtual screen size. See - {View Window}. Please remember that if either X or Y is greater than 2048, - solid guessing is turned off. This is for multiple reasons, so it is - likely it will NOT get fixed soon. There is also a problem with the - colorbars that appear when saving an image leaving bits of corruption - on the screen. This occurs in all the VESA truecolor modes. - - Added Charlie to the scrolling list of contributors. - - Added Charlie's fix for the l-system type which occurred when a push-pop - combination was on two different lines. - - Fixed the PAGE-UP/PAGE-DN zoombox in Xfractint so that it now appears on - the screen. Fixed ranges= in Xfractint so GIFs save correctly and - program doesn't end abruptly. - -Patch 4\ -Modified the Xfractint makefile and source files to allow compiling - without an assembler. - -Patch 3\ -This patch ran the Xfractint code through -Wall to clear up most of the - warnings. Updated the Xfractint man page. Turned on compiler - optimizations. - - Fixed the documentation for the Latoocarfian fractal type thanks to - comments by Pierre Desjardins on the Fractint Bug List. - -Patch 2\ -This patch adds the assembly language version of the mandelbrot code to - Xfractint. To use it, it is necessary to place the command line switch - fpu=387 in your sstools.ini file. The NASM assembler was used, but if you - don't have it available, not to worry, the object file is included. - - Modified the Xfractint C mandelbrot code to match the assembly version. - -Patch 1\ -Made a small change to the quickcalc logic used to recalculate the inside - pixels only when the iteration count is increased with a completed image. - Interrupting and resuming the calculation was leaving extra pixels on the - screen. - - Patched the Xfractint fractint.h file to match the DOS version. - - Fixed an Xfractint problem with color depths greater than 16 bits per pixel. - -Version 20.2.0\ -Incremented the version number to accommodate backwards compatibility for - the logmap option. - - Modified the logmap routine so that the color with index # 2 would be - displayed. - - Added a logmode=auto command line option that causes the logmap to adjust - automatically when zooming. Changing almost anything will turn this - feature off. It is best set using the screen prompt. - - Edited the help docs to document the move of the development area from - Compuserve to the web. - -Patch 13\ -Added parameters p4 and p5 to the evolver. This required splitting the - tweak central screen into two pages. - - Fixed an evolver bug that was causing the evolver to not exit cleanly. - - Changed the compile options on evolve.c to eliminate aliasing, which - started to cause problems with this patch. - -Patch 12\ -Fixed a problem with a finished image not redrawing if the maxiter was - increased and another parameter was changed. - - Added checks for p3, p4, and p5 to the browser for determining similar - images. - -Xfractint fixes: - Fixed the command line -disk segmentation fault. - - Fixed the Shell to Linux/Unix segmentation fault and the displayed prompt. - - Fixed the bug causing colors= data to be incorrect when in a truecolor mode. - - Removed or commented out extra lines of code and some experimental - routines. Some of this code was stealing key strokes. - - Changed the prompt for getting to the second screen. - -Patch 11\ -Fixed a bug that caused a panned image to miss part of a line when the - image was panned while the first row was being generated. - - Adjusted the time for keyboard checks when the showdot feature is used. Now - the iterations stop much quicker when a key is pressed. - - Fixed a problem with the float-only version that appeared when an incomplete - image was saved and restarted in the standard version. - - Fixed a problem in Xfractint pointed out by Ken on the Fractint bug list. - -Patch 10\ -Took out a sanity check in the VESA detection routines that certain graphics - cards don't pass, but work fine anyway. - -Patch 9\ -Fixed evolver bug that occurred when some formula functions were evolved - and others were not being evolved. - - Fixed a bug in the float-only version which truncated the image - coordinates when saved to a PAR. - -Patch 8\ -Added truecolor support to Fractint thanks to Bert Tyler. While in a - truecolor mode, the following features are disabled/changed:\ - Color Cycling\ - Palette Editor brings up the contents of the MAP directory\ - Saving the image still only produces a 256 color GIF\ - - Removed Bert's truecolor test code used with the test fractal type. - -Patch 7\ -Fixed a bug which caused the float only version to omit the name of the - formula/lsystem/ifs in saved GIFs. Fixed the julia_inverse fractal type - broken with the first patch to version 20.0. - - Incorporated Gerald Dobiasovsky's fix to make the background= command work. - - Added truecolor support to Xfractint thanks to Rich Thomson and Jean-Pierre - Demailly. - - Additional Xfractint fixes include the mandelcloud type and outside=atan - when used with type=mandel. - -Patch 6\ -Once again fixed the assignment of hotkeys to video modes so that the - fractint.cfg file is no longer corrupted. This problem was caused by - the section of code dealing with the true-color video modes. - -Patch 5\ -Updated the disk video help docs. The limit of disk video has been - 32767x32767 since version 20.0. - - Fixed the tab and evolver screens so that not using formula parameters - consecutively starting with p1 now displays the parameters properly. - The p4 and p5 parameters have still not been added to the evolver. - - Setting directories in sstools.ini can now be done relative to the - current directory. For example: .\\frm\\fract200.frm - -Patch 4\ -Modified the per image startup code for the circle type to turn off the - inside= option if startrail is used. Since the inside=startrail option - was locking up Fractint, no backwards compatibility is available. - - Made changes to the code for how sizeof() was being used. This fixes a - long standing problem with the cellular type in Xfractint. - - Modified the hard coded reading of GIF files in Xfractint to eliminate - the error message received after patch 3 changed the fractal_info - structure. - - Fixed a problem with the Xfractint parameter, formula, and lsystem screens. - -Patch 3\ -Fixed the incremental redraw so that interrupting the redraw no longer sets - passes=1. - - Added a command line option, nobof=yes, which allows the inside=bof60 and - bof61 options to function like the rest of the inside options. With - nobof=yes the images in "The Beauty of Fractals" are no longer reproduced. - - Increased the usable bailout values when using arbitrary precision math. - This is the best I can do with my minimal understanding of the ap-math - routines. If you are seeing extraneous pixels on your ap-math images when - you use a high bailout, lower the bailout until they go away. - - Made a change to the tab display routine to correct a problem with - displaying parameters when returning from the F6 and control-tab screens. - -Patch 2\ -Backed out the changes to the savegraphics() and restoregraphics() routines. - -Patch 1\ -Fixed the display screen so the video memory doesn't get overwritten. - This clears up the problem with extraneous dots with some fractal types. - It should be possible to remove the textsafe=save from your sstools.ini - file. - - Added Iain Stirling to the scrolling credits screen for his contribution - of the inside=fmod and outside=fmod options. - - Reworded the error message received when more memory is requested than - is available on your disk drive. - - The background= parameter, for 3D TGA files, is now saved to a PAR entry. - - Fixed the error message that appears when a parsing error occurs on - startup. - - Cleaned up the savegraphics() and restoregraphics() routines. This should - make them faster. - -Version 20.1.0\ -Incremented the version number to accommodate backwards compatibility for - the inside=fmod option. - - Fixed the assignment of hotkeys to video modes so that the fractint.cfg - file is no longer corrupted. Made the showdot= feature reset with - if it is entered using the screen. Added a check for the video size - before invoking the palette editor. Too small a size would crash Fractint. - - Fixed an extraseg conflict which occurred with arbitrary precision when - the key was used with various screens open (x,y,b). This conflict - also occurred when loading an ap math image at the video selection screen. - Cleaned up some of the ap math initialization code. - - Fixed an obscure bug that left memory allocated when an unfinished image - was being reloaded, but a video mode was not selected (escape was pressed). - - Added outside=fmod option. This is an extension of the inside=fmod option. - The magnitude used for the comparison is now based on the same calculation as - is used for the bailout test. This feature was contributed by Iain Stirling. - There is a problem with the mandel fractal type when outside=fmod is used - with inside=bof6x and bailoutest=real, imag, or manr. This is likely due - to changes made in the code so that bof images could be reproduced. Select - a different fractal type that produces the default mandel image to explore - using these parameters. - - Added outside=tdis option. This colors the pixels according to the total - distance traveled by the orbit. This feature was suggested by Steve Robinson - on the Fractint Wish List. - - Modified the inside and outside prompts on the screen. They are now - split into two separate prompts. One for entering a color number and the - other for changing the option. The left and right arrow keys can now be - used to change the inside and outside options. - - Fixed a bug that was causing a crash when mathtolerance= was used and - fractal types ifs, ifs3d, or lsystem were selected. - - Increased the minimum stack requirement for passes=s (SOI) to eliminate - crashes when the tab key was pressed. - -Patch 15\ -Added a prompt for the periodicity= option to the Extended Options - screen. - - Fixed another prompt problem with the stereogram prompt screen. - Put back in the evolver grid size limit based on screen resolution. - - Fixed an evolver save problem when a zoom box was present just prior to - the save. Note that the center image cannot be recreated once the - zoom box has been activated. This is not a problem if you are working - from a saved image, just restore it. - - Modified the routine that reports a view window that is too large so that - along with the full screen being used, the X and Y dimensions on the - screen reflect the full screen dimensions. - - The screen can now be used to set the resolution of disk video - modes. The limit is 32767x32767. First select a disk video mode using - . Then on the screen enter both an X and a Y value. If you go - back to the screen to see if the entry has been modified (it hasn't), - you will get strange results if you don't select a video mode. - -Patch 14\ -Fixed the generation of random numbers used by the evolver subimages. - Fixed the bug causing completed evolver images to regenerate when - restored. - -Patch 13\ -Added parameters p4 and p5 to the formula parser. Fixed the symmetry - for cases where XAXIS_NOREAL and XAXIS_NOIMAG are used with the formula - parser and multiple parameters are used. Each parameter is now checked. - -Patch 12\ -Fixed a 3D error introduced with patch 11. Fixed the stereogram screen - prompts to prevent out of bounds array accesses. - -Patch 11\ -Fixed an off by one error in the Xfractint type=julia code. Fixed the case - where the second image would not finish generating when the 3D parameter - Stereo=photo or stereo pair was used with an orbit type such as Lorenz. - -Patch 10\ -Fixed some user interface prompts that were wrong in Xfractint. Merged the - Xfractint version system with Fractint's. Thanks to Scott Boyd for - these changes. - -Patch 9\ -Fixed a bug that occurred when maxhistory=0 was used. Fixed a bug that - occurred when ismand was used in a formula and ctrl was pressed. - -Patch 8\ -Fixed a bug causing a lock up with lsystem and ifs fractal types when using - a disk video mode with an X or Y resolution greater than 2048. - -Patch 7\ -Updated Xfractint, copyright notice. - -Patch 6\ -Fixed fractint.cfg problems with extra commas or long lines. This allows - the output of makefcfg from certain video boards to be used without - editing. - -Added center, magxmag, and rotskew constants to parser. See - {=@PREDEFCENTERMAG Center-Mag Predefined Variables} - -Patch 5\ -Added new command truemode=iter, which is used to switch the ouput to the - truecolor Targa file to the number of iterates for each pixel. - -Made selecting the evolver feature turn off truecolor=yes. Each subimage was - being generated as a separate blank Targa file. - -Patch 4\ -Fixed the type=test bug. - -Patch 3\ -Fixed a bug in the pentium mandelbrot code that affected periodicity - checking. Fixed a problem with skewed zoom boxes leaving dots on the - screen. This also fixed browser boxes with the same problem. Fixed - the zoom box so it is visible in 2-color modes. - -Patch 2\ -Fixed a bug in the formula parser. - -Patch 1\ -Fixed the 2 and 16 color disk-video modes. Using truecolor=yes now - results in writing a fractxxx.tga file instead of iterates.tga. This - is not the same thing, so if somebody wants the output of the iterates.tga - file, let us know. Fixed the 3D targa modes. - -~OnlineFF - -For information on previous versions, see { Revision History }. -; -; -; -~Topic=Introduction -FRACTINT plots and manipulates images of "objects" -- actually, sets of -mathematical points -- that have fractal dimension. -See {"Fractals and the PC"} for some -historical and mathematical background on fractal geometry, a discipline -named and popularized by mathematician Benoit Mandelbrot. For now, these -sets of points have three important properties: - -1) They are generated by relatively simple calculations repeated over and -over, feeding the results of each step back into the next -- something -computers can do very rapidly. - -2) They are, quite literally, infinitely complex: they reveal more and -more detail without limit as you plot smaller and smaller areas. Fractint -lets you "zoom in" by positioning a small box and hitting to -redraw the boxed area at full-screen size; its maximum linear -"magnification" is over a trillionfold. - -3) They can be astonishingly beautiful, especially using PC color -displays' ability to assign colors to selected points, and (with VGA -displays or EGA in 640x350x16 mode) to "animate" the images by quickly -shifting those color assignments. -~OnlineFF - -For a demonstration of some of Fractint's features, run the demonstration -file included with this release (DEMO.BAT) by typing "demo" at the DOS -prompt. You can stop the demonstration at any time by pressing . - -The name FRACTINT was chosen because the program generates many of its -images using INTeger math, rather than the floating point calculations -used by most such programs. That means that you don't need a math co- -processor chip (aka floating point unit or FPU), although for a few -fractal types where floating point math is faster, the program recognizes -and automatically uses an 80x87 chip if it's present. It's even faster on -systems using Intel's 80386 and 80486 microprocessors, where the integer -math can be executed in their native 32-bit mode. - -Fractint works with many adapters and graphics modes from CGA to the -1024x768, 256-color XGA mode. Even "larger" images, up to 32767x32767x256, -can be plotted to expanded memory, extended memory, or disk: this bypasses -the screen and allows you to create images with higher resolution than -your current display can handle, and to run in "background" under multi- -tasking control programs such as DESQview and Windows 3. -~OnlineFF - -Fractint is an experiment in collaboration. Many volunteers have joined -Bert Tyler, the program's first author, in improving successive versions. -Through electronic mail messages, CompuServe's GO GRAPHICS forums, -new versions are hacked out and debugged a little at a time. -Fractint was born fast, and none of us has seen any other fractal plotter -close to the present version for speed, versatility, and all-around -wonderfulness. (If you have, tell us so we can steal somebody else's ideas -instead of each other's.) -See {The Stone Soup Story} and {A Word About the Authors} for information -about the authors, and see {Contacting the Authors} for how to contribute -your own ideas and code. -; -; -; -~Topic=Conditions on Use - -Fractint is freeware. The copyright is retained by the Stone Soup Group. - -Fractint may be freely copied and distributed in unmodified form but may -not be sold. (A nominal distribution fee may be charged for media and -handling by freeware and shareware distributors.) Fractint may be used -personally or in a business - if you can do your job better by using -Fractint, or using images from it, that's great! It may not be given away -with commercial products without explicit permission from the Stone Soup -Group. - -There is no warranty of Fractint's suitability for any purpose, nor any -acceptance of liability, express or implied. - - **********************************************************************\ - * Contribution policy: Don't want money. Got money. Want admiration. *\ - ********************************************************************** -~OnlineFF - -Source code for Fractint is also freely available - see -{Distribution of Fractint}. -See the FRACTSRC.DOC file included with the source for conditions on use. -(In most cases we just want credit.) -; -; -; -~Topic=Getting Started - -To start the program, enter FRACTINT at the DOS prompt. The program -displays an initial "credits" screen. If Fractint doesn't start properly, -please see {Common Problems}. - -Hitting gets you from the initial screen to the main menu. You can -select options from the menu by moving the highlight with the cursor arrow -keys -~Doc- -(\24 \25 \27 \26) -~Doc+ -and pressing , or you can enter commands directly. - -As soon as you select a video mode, Fractint begins drawing an image - the -"full" Mandelbrot set if you haven't selected another fractal type. - -For a quick start, after starting Fractint try one of the following:\ - If you have MCGA, VGA, or better: \ - If you have EGA: \ - If you have CGA: \ - Otherwise, monochrome: - -After the initial Mandelbrot image has been displayed, try zooming -into it (see {Zoom Box Commands}) and color cycling (see -{Color Cycling Commands}). -Once you're comfortable with these basics, start exploring other -functions from the main menu. - -Help is available from the menu and at most other points in Fractint by -pressing the key. - -AT ANY TIME, you can hit -~Doc- -one of the keys described in {Display Mode Commands} -~Doc+,Online- -a command key -~Online+ -to select a function. You do not need to wait for a calculation -to finish, nor do you have to return to the main menu. - -When entering commands, note that for the "typewriter" keys, upper and -lower case are equivalent, e.g. and have the same result. - -Many commands and parameters can be passed to FRACTINT as command-line -arguments or read from a configuration file; -~Doc- -see {Startup Parameters\, Parameter Files} for details. -~Doc+,Online- -see "Command Line Parameters, Parameter Files, Batch Mode" for details. -~Online+ -; -; -; -~Topic=Display Mode Commands -; -; This topic is online only - -~Format- - { Summary of Commands } - { Plotting Commands} - { Zoom Box Commands } - { Image Save/Restore Commands } - { Print Command } - { Parameter Save/Restore Commands } - { Interrupting and Resuming } - { Orbits Window } - { View Window } - { \"3D\" Commands } - { Video Mode Function Keys } - { Browse Commands } - { Evolver Commands } - { RDS Commands } - { Hints } -; -; -; -~Topic=Summary of Commands, Label=HELPMAIN -; This topic is online only -~Doc- - -Hit any of these keys at the menu or while drawing or viewing a fractal. -Commands marked with an '*' are also available at the credits screen. - -~Format- -{Plotting Commands} - * Delete,F2,F3,.. Select a Video Mode and draw (or redraw) current fractal - * F1 HELP! (Enter help mode) - Esc or m Go to main menu - h Redraw previous screen (you can 'back out' recursively) - Ctrl-H Redraw next screen in history circular buffer - Tab Display information about the current fractal image - * t Select a new fractal type and parameters - * x Set a number of options and doodads - * y Set extended options and doodads - * z Set fractal type-specific parameters - p Set passes options - c or + or - Enter Color-Cycling Mode (see {=HELPCYCLING Color Cycling Commands}) - e Enter Palette-Editing Mode (see {=HELPXHAIR Palette Editing Commands}) - Spacebar Mandelbrot/Julia Set toggle. - Enter Continue an interrupted calculation (e.g. after a save) - * f toggle the floating-point algorithm option ON or OFF - * i Set parameters for 3D fractal types - * Insert Restart the program (at the credits screen) - a Convert the current image into a fractal 'starfield' - Ctrl-A Turn on screen-eating ant automaton - Ctrl-S Convert current image to a Random Dot Stereogram (RDS) - o toggles 'orbits' option on and off during image generation - * d Shell to DOS (type 'exit' at the DOS prompt to return) - Ctrl-X Flip the current image along the screen's X-axis - Ctrl-Y Flip the current image along the screen's Y-axis - Ctrl-Z Flip the current image along the screen's Origin - -{Image Save/Restore Commands} - s Save the current screen image to disk - * r Restore a saved (or .GIF) image ('3' or 'o' for 3-D) - -{Orbits Window} - o Turns on Orbits Window mode after image generation - ctrl-o Turns on Orbits Window mode - -{View Window} - * v Set view window parameters (reduction, aspect ratio) - -{Print Command} - ctrl-p Print the screen (command-line options set printer type) - -{Parameter Save/Restore Commands} - b Save commands describing the current image in a file - (writes an entry to be used with @ command) - * @ or 2 Run a set of commands (in command line format) from a file - g Give a startup parameter: {Summary of all Parameters} - -{\"3D\" Commands} - * 3 3D transform a saved (or .GIF) image - # (shift-3) same as 3, but overlay the current image - -{Zoom Box Commands} - PageUp When no Zoom Box is active, bring one up - When active already, shrink it - PageDown Expand the Zoom Box - Expanding past the screen size cancels the Zoom Box - \24 \25 \27 \26 Pan (Move) the Zoom Box - Ctrl- \24 \25 \27 \26 Fast-Pan the Zoom Box (may require an enhanced keyboard) - Enter Redraw the Screen or area inside the Zoom Box - Ctrl-Enter 'Zoom-out' - expands the image so that your current - image is positioned inside the current zoom-box location. - Ctrl-Pad+/Pad- Rotate the Zoom Box - Ctrl-PgUp/PgDn Change Zoom Box vertical size (change its aspect ratio) - Ctrl-Home/End Change Zoom Box shape - Ctrl-Ins/Del Change Zoom Box color - -{Interrupting and Resuming} - -{Video Mode Function Keys} - -{Browse Commands} - L(ook) Enter Browsing Mode - -{Evolver Commands} - Ctrl-E Bring up {=HELPEVOL explorer/evolver} control screen - Alt-1 ... Alt-7 Enter evolver mode with selected level of - mutation: Alt-1 = low level, Alt-7 = maximum. - (dont use the keypad, just the 'top row' numbers) - When in evolve mode then just plain 1..7 also work - -{RDS Commands} - Ctrl-S Access RDS parameter screen - -~Doc+ -; -; -; -~Topic=Plotting Commands -Function keys & various combinations are used to select a video mode and -redraw the screen. For a quick start try one of the following:\ - If you have MCGA, VGA, or better: \ - If you have EGA: \ - If you have CGA: \ - Otherwise, monochrome: \ - -\ -Display a help screen. The function keys available in help mode are -displayed at the bottom of the help screen. - - or \ -Return from a displayed image to the main menu. - -\ -From the main menu, is used to exit from Fractint. - -\ -Same as choosing "select video mode" from the main menu. -Goes to the "select video mode" screen. See {Video Mode Function Keys}. - -\ -Redraw the previous image in the circular history buffer, revisiting fractals -you previously generated this session in reverse order. Fractint saves -the last ten images worth of information including fractal type, coordinates, -colors, and all options. Image information is saved only when some item -changes. After ten images the circular buffer wraps around and earlier -information is overwritten. You can set image capacity of the history feature -using the maxhistory= command. About 1200 bytes of memory is required -for each image slot. - -\ -Redraw the next image in the circular history buffer. Use this to return to -images you passed by when using . - -\ -Display the current fractal type, parameters, video mode, screen or (if -displayed) zoom-box coordinates, maximum iteration count, and other -information useful in keeping track of where you are. The Tab function is -non-destructive - if you press it while in the midst of generating an -image, you will continue generating it when you return. The Tab function -tells you if your image is still being generated or has finished - a handy -feature for those overnight, 1024x768 resolution fractal images. If the -image is incomplete, it also tells you whether it can be interrupted and -resumed. (Any function other than and counts as an -"interrupt".) - -The Tab screen also includes a pixel-counting function, which will count -the number of pixels colored in the inside color. This gives an estimate -of the area of the fractal. Note that the inside color must be different -from the outside color(s) for this to work; inside=0 is a good choice. - -\ -Select a fractal type. Move the cursor to your choice (or type the first -few letters of its name) and hit . Next you will be prompted for -any parameters used by the selected type - hit for the defaults. -See {Fractal Types} for a list of supported types. - -\ -Toggles the use of floating-point algorithms -(see {"Limitations of Integer Math (And How We Cope)"}). -Whether floating point is in -use is shown on the status screen. The floating point option can -also be turned on and off using the "X" options screen. -If you have a non-Intel floating point chip which supports the full 387 -instruction set, see the "FPU=" command in {Startup Parameters} -to get the most out of your chip. - -\ -Select a number of eXtended options. Brings up a full-screen menu of -options, any of which you can change at will. These options are:\ - "passes=" - see {Drawing Method}\ - Floating point toggle - see key description below\ - "maxiter=" - see {Image Calculation Parameters}\ - "inside=" and "outside=" - see {Color Parameters}\ - "savename=" filename - see {File Parameters}\ - "overwrite=" option - see {File Parameters}\ - "sound=" option - see {Sound Parameters}\ - "logmap=" - see {Logarithmic Palettes and Color Ranges}\ - "biomorph=" - see {Biomorphs}\ - "decomp=" - see {Decomposition}\ - "fillcolor=" - see {Drawing Method}\ - -\ -More options which we couldn't fit under the command:\ - "finattract=" - see {Finite Attractors}\ - "potential=" parameters - see {Continuous Potential}\ - "invert=" parameters - see {Inversion}\ - "distest=" parameters - see {Distance Estimator Method}\ - "cyclerange=" - see {Color Cycling Commands}\ - -

\ -Options that apply to the Passes feature:\ - "periodicity=" - see {Periodicity Logic}\ - "orbitdelay=" - see {Passes Parameters}\ - "orbitinterval=" - see {Passes Parameters}\ - "screencoords=" - see {Passes Parameters}\ - "orbitdrawmode=" - see {Passes Parameters}\ - -\ -Modify the parameters specific to the currently selected fractal type. -This command lets you modify the parameters which are requested when you -select a new fractal type with the command, without having to repeat -that selection. You can enter "e" or "p" in column one of the input fields -to get the numbers e and pi (2.71828... and 3.14159...).\ -From the fractal parameters screen, you can press to bring up a -sub parameter screen for the coordinates of the image's corners. -With selected fractal types, allows you to change the {Bailout Test}. -; With the IFS fractal type, brings up the IFS editor (see -; {=HT_IFS Barnsley IFS Fractals}). - -<+> or <->\ -Switch to color-cycling mode and begin cycling the palette -by shifting each color to the next "contour." See {Color Cycling Commands}.\ - -\ -Switch to color-cycling mode but do not start cycling. -The normally black "overscan" border of the screen changes to white. -See {Color Cycling Commands}. - -\ -Enter Palette-Editing Mode. See {Palette Editing Commands}. - -\ -Toggle between Mandelbrot set images and their corresponding Julia-set -images. Read the notes in {=HT_JULIA Fractal Types, Julia Sets} -before trying this option if you want to see anything interesting. - -\ -Toggle between Julia escape time fractal and the Inverse Julia orbit -fractal. See {=HT_INVERSE Inverse Julias} - -\ -Enter is used to resume calculation after a pause. It is only -necessary to do this when there is a message on the screen waiting to be -acknowledged, such as the message shown after you save an image to disk. - -\ -Modify 3D transformation parameters used with 3D fractal types such as -"Lorenz3D" and 3D "IFS" definitions, including the selection of -{=HELP3DGLASSES "funny glasses"} red/blue 3D. - -\ -Convert the current image into a fractal 'starfield'. See {Starfields}. - -\ -Unleash an image-eating ant automaton on current image. See {Ant Automaton}. - - (or )\ -Convert the current image into a Random Dot Stereogram (RDS). -See {Random Dot Stereograms (RDS)}. - - (the letter, not the number)\ -If pressed while an image is being generated, toggles the display of -intermediate results -- the "orbits" Fractint uses as it calculates values -for each point. Slows the display a bit, but shows you how clever the -program is behind the scenes. (See "A Little Code" in -{"Fractals and the PC"}.) - -\ -Shell to DOS. Return to Fractint by entering "exit" at a DOS prompt. - -\ -Restart at the "credits" screen and reset most variables to their initial -state. Variables which are not reset are: savename, lightname, video, -startup filename. - -\ -Enter Browsing Mode. See {Browse Commands}. - -\ -Enter Explorer/Evolver Mode. See {Evolver Commands}. -; -; -; -~Topic=Zoom Box Commands, Label=HELPZOOM - -Zoom Box functions can be invoked while an image is being generated or when -it has been completely drawn. Zooming is supported for most fractal types, -but not all. - -The general approach to using the zoom box is: Frame an area using -the keys described below, -then to expand what's in the frame to fill the -whole screen (zoom in); or to shrink the current image into -the framed area (zoom out). With a mouse, double-click the left button to -zoom in, double click the right button to zoom out. - -, \ -Use to initially bring up the zoom box. It starts at full screen -size. Subsequent use of these keys makes the zoom box smaller or larger. -Using to enlarge the zoom box when it is already at maximum -size removes the zoom box from the display. Moving the mouse away from you -or toward you while holding the left button down performs the same -functions as these keys. - -Using the cursor "arrow" keys -~Doc- -(\24 \25 \27 \26) -~Doc+ -or moving -the mouse without holding any buttons down, moves the zoom box. - -Holding while pressing cursor "arrow" keys moves the box 5 times -faster. (This only works with enhanced keyboards.) - -Panning: If you move a fullsize zoombox and don't change anything else -before performing the zoom, Fractint just moves what's already on the -screen and then fills in the new edges, to reduce drawing time. This -feature applies to most fractal types but not all. A side effect is that -while an image is incomplete, a full size zoom box moves in steps larger -than one pixel. Fractint keeps the box on multiple pixel boundaries, to -make panning possible. As a multi-pass (e.g. solid guessing) image -approaches completion, the zoom box can move in smaller increments. - -In addition to resizing the zoom box and moving it around, you can do some -rather warped things with it. If you're a new Fractint user, we recommend -skipping the rest of the zoom box functions for now and coming back to -them when you're comfortable with the basic zoom box functions. - -, \ -Holding and pressing the numeric keypad's + or - keys rotates the -zoom box. Moving the mouse left or right while holding the right button -down performs the same function. - -, \ -These commands change the zoom box's "aspect ratio", stretching or -shrinking it vertically. Moving the mouse away from you or toward you -while holding both buttons (or the middle button on a 3-button mouse) down -performs the same function. There are no commands to directly stretch or -shrink the zoom box horizontally - the same effect can be achieved by -combining vertical stretching and resizing. - -, \ -These commands "skew" the zoom box, moving the top and bottom edges in -opposite directions. Moving the mouse left or right while holding both -buttons (or the middle button on a 3-button mouse) down performs the same -function. There are no commands to directly skew the left and right edges -- the same effect can be achieved by using these functions combined with -rotation. - -, \ -These commands change the zoom box color. This is useful when you're -having trouble seeing the zoom box against the colors around it. Moving -the mouse away from you or toward you while holding the right button down -performs the same function. - -You may find it difficult to figure out what combination of size, position -rotation, stretch, and skew to use to get a particular result. (We do.)\ -A good way to get a feel for all these functions is to play with the -Gingerbreadman fractal type. Gingerbreadman's shape makes it easy to -see what you're doing to him. A warning though: Gingerbreadman will run -forever, he's never quite done! So, pre-empt with your next zoom when he's -baked enough. - -If you accidentally change your zoom box shape or rotate and -forget which way is up, just use to make it bigger until it -disappears, then to get a fresh one. With a -mouse, after removing the old zoom box from the display release and -re-press the left button for a fresh one. - -If your screen does not have a 4:3 "aspect ratio" (i.e. if the visible -display area on it is not 1.333 times as wide as it is high), rotating and -zooming will have some odd effects - angles will change, including the -zoom box's shape itself, circles (if you are so lucky as to see any with a -non-standard aspect ratio) become non-circular, and so on. The vast -majority of PC screens *do* have a 4:3 aspect ratio. - -Zooming is not implemented for the plasma and diffusion fractal types, nor -for overlayed and 3D images. A few fractal types support zooming but -do not support rotation and skewing - nothing happens when you try it. -; -; -; -~Topic=Image Save/Restore Commands, Label=HELPSAVEREST - - saves the current image to disk. All parameters required to recreate -the image are saved with it. Progress is marked by colored lines moving -down the screen's edges. - -The default filename for the first image saved after starting Fractint is -FRACT001.GIF; subsequent saves in the same session are automatically -incremented 002, 003... Use the "savename=" parameter or options -screen to change the name. By default, files left over from previous -sessions are not overwritten - the first unused FRACTnnn name is used. -Use the "overwrite=yes" parameter or options screen) to overwrite -existing files. - -A save operation can be interrupted by pressing any key. If you interrupt, -you'll be asked whether to keep or discard the partial file. - - restores an image previously saved with , or an ordinary GIF file. -After pressing you are shown the file names in the current directory -which match the current file mask. To select a file to restore, move the -cursor to it (or type the first few letters of its name) and press -. - -Directories are shown in the file list with a \"\\\" at the end of the name. -When you select a directory, the contents of that directory are shown. Or, -you can type the name of a different directory (and optionally a different -drive) and press for a new display. You can also type a mask such -as "*.XYZ" and press to display files whose name ends with the -matching suffix (XYZ). - -You can use to switch directories to the default fractint directory -or to your own directory which is specified through the DOS environment -variable "FRACTDIR". - -Once you have selected a file to restore, a summary description of the -file is shown, with a video mode selection list. Usually you can just -press to go past this screen and load the image. Other choices -available at this point are:\ - Cursor keys: select a different video mode\ - : display more information about the fractal\ - : for help about the "err" column in displayed video modes\ -If you restore a file into a video mode which does not have the same pixel -dimensions as the file, Fractint will make some adjustments: The view -window parameters (see command) will automatically be set to an -appropriate size, and if the image is larger than the screen dimensions, -it will be reduced by using only every Nth pixel during the restore. -; -; -; -~Topic=Print Command - -

\ - -Print the current fractal image on your (Laserjet, Paintjet, Epson- -compatible, PostScript, or HP-GL) printer. - -See {"Setting Defaults (SSTOOLS.INI File)"} and {"Printer Parameters"} -for how to let Fractint know about your printer setup. - -{"Disk-Video" Modes} can be used to -generate images for printing at higher resolutions than your screen -supports. -; -; -; -~Topic=Parameter Save/Restore Commands, Label=HELPPARMFILE - -Parameter files can be used to save/restore all options and settings -required to recreate particular images. The parameters required to -describe an image require very little disk space, especially compared with -saving the image itself. - -<@> or <2> - -The <@> or <2> command loads a set of parameters describing an image. -(Actually, it can also be used to set non-image parameters such as SOUND, -but at this point we're interested in images. Other uses of parameter -files are discussed in {"Parameter Files and the <@> Command"}.) - -When you hit <@> or <2>, Fractint displays the names of the entries in the -currently selected parameter file. The default parameter file, -FRACTINT.PAR, is included with the Fractint release and contains -parameters for some sample images. - -After pressing <@> or <2>, highlight an entry and press to load it, -or press to change to another parameter file. - -Note that parameter file entries specify all calculation related -parameters, but do not specify things like the video mode - the image will -be plotted in your currently selected mode. - - - -The command saves the parameters required to describe the currently -displayed image, which can subsequently be used with the <@> or <2> command -to recreate it. - -After you press , Fractint prompts for: - - Parameter file: The name of the file to store the parameters in. You - should use some name like "myimages" instead of fractint.par, so that - your images are kept separate from the ones released with new versions - of Fractint. You can use the PARMFILE= command in SSTOOLS.INI - to set the default parameter file name to "myimages" or whatever. - (See {"Setting Defaults (SSTOOLS.INI File)"} and "parmfile=" in - {"File Parameters"}.) - - Name: The name you want to assign to the entry, to be displayed when - the <@> or <2> command is used. - - Main comment: A comment to be shown beside the entry in the <@> command - display. - - Second, Third, and Fourth comment: Additional comments to store in the - file with the entry. These comments go in the file only, and are not - displayed by the <@> command. You can set these comments from the - command line - see {=@COMMENTS Comment= Command}. - - Record colors?: Whether color information should be included in the - entry. Usually the default value displayed by Fractint is what you want. - Allowed values are:\ - "no" - Don't record colors.\ - "@mapfilename" - When these parameters are used, load colors from the - named color map file. This is the default if you are currently using - colors from a color map file.\ - "yes" - Record the colors in detail. This is the default when you've - changed the display colors by using the palette editor or by color - cycling. The only reason that this isn't what Fractint always does - for the command is that color information can be bulky - up to - nearly 3K of disk space per map - which adds up to a lot for many - images. Smooth-shaded ranges of colors are compressed, so if that's - used a lot in an image the color information won't be as bulky.\ - "only" - Record only the colors in the PAR file, without any other - parameters. This is useful for converting color maps to PAR entries. - - # of colors: This only matters if "Record colors?" is set to "yes". It - specifies the number of colors to record. Recording less colors will - take less space. Usually the default value displayed by Fractint is what - you want. You might want to increase it in some cases, e.g. if you are - using a 256 color mode with maxiter 150, and have used the palette - editor to set all 256 possible colors for use with color cycling, then - you'll want to set the "# of colors" to 256. - - See the {=@RECORDCOLORS Recordcolors} command, which controls when mapfiles - are used and when compressed colors are written to PAR files. - - maxlinelength: This number controls the maximum width of a parameter - entry in a PAR file. The default is 72 characters. - - At the bottom of the input screen are inputs for Fractint's "pieces" - divide-and-conquer feature. You can create multiple PAR entries that - break an image up into pieces so that you can generate the image pieces - one by one. There are two reasons for doing this. The first is in case the - fractal is very slow, and you want to generate parts of the image at the - same time on several computers. The second is that you might want to make - an image greater than 2048 x 2048, the old pixel limit for Fractint. The - parameters for this feature are: - X Multiples - How many divisions of final image in the x direction\ - Y Multiples - How many divisions of final image in the y direction\ - Video mode - Fractint video mode for each piece (e.g. "F3")\ - - The last item defaults to the current video mode. If either X Multiples or - Y Multiples are greater than 1, then multiple numbered PAR entries for the - pieces are added to the PAR file, and a MAKEMIG.BAT file is created that - builds all of the component pieces and then stitches them together into - a "multi-image" GIF. The current limitations of the "divide and conquer" - algorithm are 36 or fewer X and Y multiples (so you are limited to "only" - 36x36=1296 component images), and a final resolution limit in both the - X and Y directions of 65,535 (a limitation of "only" four billion pixels - or so). - - The final image generated by MAKEMIG is a "multi-image" GIF file called - FRACTMIG.GIF. In case you have other software that can't handle - multi-image GIF files, MAKEMIG includes a final (but commented out) call - to SIMPLGIF, a companion program that reads a GIF file that may contain - little tricks like multiple images and creates a simple GIF from it. - Fair warning: SIMPLGIF needs room to build a composite image while it - works, and it does that using a temporary disk file equal to the size - of the final image - and a 64Kx64K GIF image requires a 4GB temporary - disk file! - - - -The command lets you give a startup parameter interactively. -; -; -; -~Topic= Options Screen, Label=HELPXOPTS -; This topic is online context-sensitive only. - - Passes - see {Drawing Method}\ - Fillcolor - see {Drawing Method}\ - Floating Point Algorithm - see notes below\ - Maximum Iterations - see {Image Calculation Parameters}\ - Inside and Outside colors - see {Color Parameters}\ - Savename and File Overwrite - see {File Parameters}\ - Sound option - see {Sound Parameters}\ - Log Palette - see {Logarithmic Palettes and Color Ranges}\ - Biomorph Color - see {Biomorphs}\ - Decomp Option - see {Decomposition}\ - -You can toggle the use of floating-point algorithms on this screen (see -{"Limitations of Integer Math (And How We Cope)"}). Whether floating -point is in use is shown on the status screen. If you have a -non-Intel floating point chip which supports the full 387 instruction set, -see the "FPU=" command in {Startup Parameters} to get the most out of your -chip. -; -; -~Topic= Options Screen, Label=HELPYOPTS -; This topic is online context-sensitive only. - - Finite attractor - see{ Finite Attractors }\ - - Potential parameters - see{ Continuous Potential }\ - - Distance Estimator parameters - see{ Distance Estimator Method }\ - - Inversion parameters - see{ Inversion }\ - - Color cycling range - see{ Color Cycling Commands }\ -; -; -~Topic=

Options Screen, Label=HELPPOPTS -; This topic is online context-sensitive only. - - Periodicity - see{ Passes Parameters }\ - - Orbit Delay - see{ Passes Parameters }\ - - Orbit Interval - see{ Passes Parameters }\ - - Maintain Screen Coordinates - see{ Passes Parameters }\ - - Orbit Draw Mode - see{ Passes Parameters }\ -; -; -~Topic=Image Coordinates Screen, Label=HELPCOORDS -; This topic is online context-sensitive only. - -You can directly enter corner coordinates on this screen instead of -using the zoom box to move around. You can also use to reset -the coordinates to the defaults for the current fractal type. - -There are two formats for the display: corners or center-mag. You can -toggle between the two by using . - -In corners mode, corner coordinate values are entered directly. Usually -only the top-left and bottom-right corners need be specified - the -bottom left corner can be entered as zeros to default to an ordinary -unrotated rectangular area. For rotated or skewed images, the bottom -left corner must also be specified. - -In center-mag mode the image area is described by entering the coordinates -for the center of the rectangle, and its magnification factor. Usually -only these three values are needed, but the user can also specify the amount -that the image is stretched, rotated and skewed. -; -; -~Topic=Screen Coordinates Screen, Label=HELPSCRNCOORDS -; This topic is online context-sensitive only. - -You can directly enter corner coordinates on this screen for use with the -passes='o' option. You can also use to reset the coordinates to the -defaults for the current fractal type. - -There are two formats for the display: corners or center-mag. You can -toggle between the two by using . - -In corners mode, corner coordinate values are entered directly. Usually -only the top-left and bottom-right corners need be specified - the -bottom left corner can be entered as zeros to default to an ordinary -unrotated rectangular area. For rotated or skewed images, the bottom -left corner must also be specified. - -In center-mag mode the screen area is described by entering the coordinates -for the center of the rectangle, and its magnification factor. Usually -only these three values are needed, but the user can also specify the amount -that the image is stretched, rotated and skewed. -; -; -; -~Topic=Interrupting and Resuming - -Fractint command keys can be loosely grouped as: - - o Keys which suspend calculation of the current image (if one is being - calculated) and automatically resume after the function. - (display status information) and (display help), are the only - keys in this group. - - o Keys which automatically trigger calculation of a new image. - Examples: selecting a video mode (e.g. ); selecting a fractal - type using ; using the screen to change an option such as - maximum iterations. - - o Keys which do something, then wait for you to indicate what to do - next. Examples: to go to main menu; to enter color cycling - mode; to bring up a zoom box. After using a command in this - group, calculation automatically resumes when you return from the - function (e.g. from color cycling, to clear zoom box). - There are a few fractal types which cannot resume calculation, they - are noted below. Note that after saving an image with , you must - press to clear the "saved" message from the screen and resume. - -An image which is aved before it completes can later be estored and -continued. The calculation is automatically resumed when you restore such -an image. - -When a slow fractal type resumes after an interruption in the third -category above, there may be a lag while nothing visible happens. This is -because most cases of resume restart at the beginning of a screen line. -If unsure, you can check whether calculation has resumed with the -key. - -The following fractal types cannot (currently) be resumed: plasma, 3d -transformations, julibrot, and 3d orbital types like lorenz3d. To check -whether resuming an image is possible, use the key while it is -calculating. It is resumable unless there is a note under the fractal -type saying it is not. - -The {Batch Mode} section discusses how to resume in batch mode. - -To estore and resume a "formula", "lsystem", or "ifs" type fractal your -"formulafile", "lfile", or "ifsfile" must contain the required name. -; -; -; -~Topic=Orbits Window, Label=HELP_ORBITS -The key turns on the Orbit mode. In this mode a cursor appears -over the fractal. A window appears showing the orbit used in the -calculation of the color at the point where the cursor is. Move the -cursor around the fractal using the arrow keys or the mouse and watch -the orbits change. Try entering the Orbits mode with View Windows () -turned on. The following keys take effect in Orbits mode.\ - Circle toggle - makes little circles with radii inversely\ - proportional to the iteration. Press again to toggle\ - back to point-by-point display of orbits.\ - Line toggle - connects orbits with lines (can use with )\ - Numbers toggle - shows complex coordinates & color number of\ - the cursor on the screen. Press again to turn off numbers.\ -

Enter pixel coordinates directly\ - Hide fractal toggle. Works only if View Windows is turned on\ - and set for a small window (such as the default size.) Hides the\ - fractal, allowing the orbit to take up the whole screen. Press\ - again to uncover the fractal.\ - Saves the fractal, cursor, orbits, and numbers as they\ - appear on the screen.\ -<<> or <,> Zoom orbits image smaller\ -<>> or <.> Zoom orbits image larger\ - Restore default zoom.\ -; -; -; -~Topic=View Window, Label=HELPVIEW - -The command is used to set the view window parameters described below. -These parameters can be used to:\ - o Define a small window on the screen which is to contain the generated - images. Using a small window speeds up calculation time (there are - fewer pixels to generate). You can use a small window to explore - quickly, then turn the view window off to recalculate the image at - full screen size. - o Generate an image with a different "aspect ratio"; e.g. in a square - window or in a tall skinny rectangle. - o View saved GIF images which have pixel dimensions different from any - mode supported by your hardware. This use of view windows occurs - automatically when you restore such an image. - o Define a disk video mode up to 32767x32767. First select a disk video - mode using . Then on the screen enter both an X and a Y value - at the Virtual Screen Total Pixels prompts. - o Define a virtual video mode up to the size that fits in video memory. - First select a VESA video mode (dotmode=28) using . Then on the - screen enter both an X and a Y value at the Virtual Screen Total - Pixels prompts. The Keep Aspect prompt is used if the asked for virtual - screen is larger than video memory. If set, the X and Y values will both - be reduced such that the ratio between them is maintained. If not set, - just the Y value will be reduced. - -"Preview display"\ -Set this to "yes" to turn on view window, "no" for full screen display. -While this is "no", the only view parameter which has any affect is "final -media aspect ratio". When a view window is being used, all other Fractint -functions continue to operate normally - you can zoom, color-cycle, and -all the rest. - -"Reduction factor"\ -When an explicit size is not given, this determines the view window size, -as a factor of the screen size. E.g. a reduction factor of 2 makes the -window 1/2 as big as the screen in both dimensions. - -"Final media aspect ratio"\ -This is the height of the final image you want, divided by the width. The -default is 0.75 because standard PC monitors have a height:width ratio of -3:4. E.g. set this to 2.0 for an image twice as high as it is wide. The -effect of this parameter is visible only when "preview display" is -enabled. If the explicit size of both x and y are set, setting this value -to 0 will cause the appropriate value to be calculated based on x and y. - -"Crop starting coordinates"\ -This parameter affects what happens when you change the aspect ratio. If -set to "no", then when you change aspect ratio, the prior image will be -squeezed or stretched to fit into the new shape. If set to "yes", the -prior image is "cropped" to avoid squeezing or stretching. - -"Explicit size"\ -Setting these to non-zero values over-rides the "reduction factor" with -explicit sizes in pixels. If only the "x pixels" size is specified, the "y -pixels" size is calculated automatically based on x and the aspect ratio. - -The following option is available when using disk video or virtual screen -modes: - -"Virtual screen"\ -Setting these allow defining a virtual screen as large as the available -video memory will permit. - -The following options are available when using virtual screen modes: - -"Keep aspect"\ -If this is set, when the asked for virtual screen is larger than video -memory the X and Y values will both be reduced such that the ratio between -them is maintained. If not set, just the Y value will be reduced. - -"Zoombox scrolling"\ -The fixed setting tries to maintain the zoombox in the center of the -screen by moving the virtual image. The relaxed setting moves the virtual -image when the zoombox reached the edges of the screen. - -More about final aspect ratio: If you want to produce a high quality -hard-copy image which is say 8" high by 5" down, based on a vertical -"slice" of an existing image, you could use a procedure like the -following. You'll need some method of converting a GIF image to your final -media (slide or whatever) - Fractint can only do the whole job with a -PostScript printer, it does not preserve aspect ratio with other printers. - o restore the existing image\ - o set view parameters: preview to yes, reduction to anything (say 2), - aspect ratio to 1.6, and crop to yes - o zoom, rotate, whatever, till you get the desired final image\ - o set preview display back to no\ - o trigger final calculation in some high res disk video mode, using the - appropriate video mode function key - o print directly to a PostScript printer, or save the result as a GIF - file and use external utilities to convert to hard copy. -; -; -; -~Topic=\"3D\" Commands - -See {\"3D\" Images} for details of these commands. - -<3>\ -Restore a saved image as a 3D "landscape", translating its color -information into "height". You will be prompted for all KINDS of options. - -<#>\ -Restore in 3D and overlay the result on the current screen. -; -; -; -~Topic=Video Mode Function Keys, Label=HELPVIDSEL - -Fractint supports *so* many video modes that we've given up trying to -reserve a keyboard combination for each of them. - -Any supported video mode can be selected by going to the "Select Video Mode" -screen (from main menu or by using ), then using the cursor up and down -arrow keys and/or and keys to highlight the desired mode, -then pressing . - -Up to 39 modes can be assigned to the keys F2-F10, SF1-SF10 +), -CF1-CF10 (+), and AF1-AF10 (+). The modes assigned to -function keys can be invoked directly by pressing the assigned key, without -going to the video mode selection screen. - -30 key combinations can be reassigned: to combined with any of -, , or . -The video modes assigned to through can not be -changed - these are assigned to the most common video modes, which might -be used in demonstration files or batches. - -To reassign a function key to a mode you often use, go to the "select -video mode" screen, highlight the video -mode, press the keypad (gray) <+> key, then press the desired -function key or key combination. The new key assignment will be remembered -for future runs. - -To unassign a key (so that it doesn't invoke any video -mode), highlight the mode currently selected by the key and press the -keypad (gray) <-> key. - -A note about the "select video modes" screen: -the video modes which are displayed with a 'B' suffix in the number -of colors are modes which have no custom programming - they use the BIOS -and are S-L-O-W ones. - -See {"Video Adapter Notes"} for comments about particular adapters. - -See {"Disk-Video" Modes} for a description of these non-display modes. - -See {"Customized Video Modes\, FRACTINT.CFG"} for information about -adding your own video modes. -; -; -; -~Topic=Browse Commands, Label=HELPBROWSE - -The following keystrokes function while browsing an image:\ - - Step through the outlines on the screen.\ - Selects the image to display.\ -<\\>, Recalls the last image selected.\ - Deletes the selected file.\ - Renames the selected file.\ - Saves the current image with the browser boxes\ - displayed.\ -, Toggles the browse mode off.\ - Brings up the {Browser Parameters} screen.\ - Change the browser boxes color.\ - -This is a "visual directory", here is how it works...\ -When 'L' or 'l' is pressed from a fractal display the current directory is -searched for any saved files that are deeper zooms of the current image and -their position shown on screen by a box (or crosshairs if the box would be -too small). See also {Browser Parameters} for more on how this is done. - -One outline flashes, the selected outline can be changed by using the -cursor keys. At the moment the outlines are selected in the order that -they appear in your directory, so don't worry if the flashing window jumps -all over the place! - -When enter is pressed, the selected image is loaded. In this mode a stack -of the last sixteen selected filenames is maintained and the '\\' or 'h' key -pops and loads the last image you were looking at. Using this it is -possible to set up sequences of images that allow easy exploration of your -favorite fractal without having to wait for recalc once the level of zoom -gets too high, great for demos! (also useful for keeping track of just -exactly where fract532.gif came from :-) ) - -You can also use this facility to tidy up your disk: by typing UPPER CASE 'D' -when a file is selected the browser will delete the file for you, after -making sure that you really mean it, you must reply to the "are you sure" -prompts with an UPPER CASE 'Y' and nothing else, otherwise the command is -ignored. Just to make absolutely sure you don't accidentally wipe out the -fruits of many hours of cpu time the default setting is to have the browser -prompt you twice, you can disable the second prompt within the parameters -screen, however, if you're feeling overconfident :-). - -To complement the Delete function there is a rename function, use the UPPER -CASE 'R' key for this. You need to enter the FULL new file name, no .GIF is -implied. - -It is possible to save the current image along with all of the displayed -boxes indicating subimages by pressing the 's' key. This exits the browse -mode to save the image and the boxes become a permanent part of the image. -Currently, the screen image ends up with stray dots colored after it is -saved. - -Esc backs out of image selecting mode.\ - -The browser can now use expanded memory or extended memory. If you have -more than 4 MB of expanded/extended memory available, you can use either. -If you don't have 4 MB of expanded/extended memory available, use expanded -memory as it will allocate as much as possible. The extended memory support -will silently fail and default to the use of far memory if 4 MB of extended -memory is not available. - -Here's a tip on how to zoom out beyond your starting point when browsing: -Suppose you restore a fractal deeply-zoomed down in a directory of -related zoomed images, and then bring up the browser. How do you zoom -out? You can't use "\\" because you started with the zoomed image, and -there is no browser command to detect the next outer image. What you -can do is exit the browser, press PgUp until the zoom box won't get any -smaller, zoom out with Ctrl-Enter, and before any image starts to -develop, call up the browser again, locate your zoomed image that you -started with, and see if there is another image that contains it - if -so, restore it with the browser. You can also use a view window to load -the first image, and then use the browser. - -POSSIBLE ERRORS: - -"Sorry..I can't find anything"\ -The browser can't locate any files which match the file name mask. -See {Browser Parameters} This is also displayed if you have less than -10K of far memory free when you run Fractint. - -"Sorry.... no more space"\ -At the moment the browser can only cope with 450 sub images at one time. -Any subsequent images are ignored. Make sure that the minimum image size -isn't set too small on the parameters screen. - -~OnlineFF -"Sorry .... out of memory"\ -The browser has run out of far, expanded, or extended memory in which to -store the pixels covered by the sub image boxes. Try again with the main -image at lower resolution, and/or reduce the number of TSRs resident in -memory when you start Fractint. Make sure you have expanded or extended -memory available. - -"Sorry...it's a read only file, can't del "\ -"Sorry....can't rename"\ -The file which you were trying to delete or rename has the read only -attribute set, you'll need to reset this with your operating system before -you can get rid of it. -; -; -; -~Topic=Browser Parameters, Label=HELPBRWSPARMS - -This Screen enables you to control Fractint's built in file browsing utility. -If you don't know what that is see {Browse Commands}. This screen is -selected with from just about anywhere. - -"Autobrowsing"\ -Select yes if you want the loaded image to be scanned for sub images -immediately without pressing 'L' every time. - -"Ask about GIF video mode"\ -Allows turning on and off the display of the video mode table when loading -GIFs. This has the same effect as the askvideo= command. - -"Type/Parm check"\ -Select whether the browser tests for fractal type or parms when deciding -whether a file is a sub image of the current screen or not. DISABLE WITH -CAUTION! or things could get confusing. These tests can be switched off -to allow such situations as wishing to display old images that were -generated using a formula type which is now implemented as a built in -fractal type. -~OnlineFF -"Confirm deletes"\ -Set this to No if you get fed up with the double prompting that the browser -gives when deleting a file. It won't get rid of the first prompt however. - -"Smallest window"\ -This parameter determines how small the image would have to be onscreen -before the browser decides not to include it in the selection of files. The size -is entered in decimal pixels so, for instance, this could be set to 0.2 to -allow images that are up to around three maximum zooms away (depending on -the current video resolution) to be loaded instantly. Set this to 0 to -enable all sub images to be detected. This can lead to a very cluttered -screen! The primary use is in conjunction with the search file mask (see -below) to allow location of high magnification images within an overall -view (like the whole Mset). - -"Smallest box"\ -This determines when the image location is shown as crosshairs rather than -a rather small box. Set this according to how good your eyesight is -(probably worse than before you started staring at fractals all the time :-)) -or the resolution of your screen. WARNING the crosshairs routine centers -the cursor on one corner of the image box at the moment so this looks -misleading if set too large. -~OnlineFF -"Search Mask"\ -Sets the file name pattern which the browser searches, this can be used -to search out the location of a file by setting this to the filename and -setting smallest image to 0 (see above). -; -; -; -~Topic=RDS Commands, Label=RDSKEYS -The following keystrokes function while viewing an RDS image:\ - - or -- Toggle calibration bars on and off.\ - or -- Return to RDS Parameters Screen.\ - -- Save RDS image, then restore original.\ -, <+>, <-> -- Color cycle RDS image.\ -Other keys -- Exit RDS mode, restore original image, and pass\ - keystroke on to main menu.\ - -For more about RDS, see {Random Dot Stereograms (RDS)} -; -; -; - -~Topic=Hints - -Remember, you do NOT have to wait for the program to finish a full screen -display before entering a command. If you see an interesting spot you want -to zoom in on while the screen is half-done, don't wait -- do it! If you -think after seeing the first few lines that another video mode would look -better, go ahead -- Fractint will shift modes and start the redraw at -once. When it finishes a display, it beeps and waits for your next -command. - -In general, the most interesting areas are the "border" areas where the -colors are changing rapidly. Zoom in on them for the best results. The -first Mandelbrot-set (default) fractal image has a large, solid-colored -interior that is the slowest to display; there's nothing to be seen by -zooming there. - -Plotting time is directly proportional to the number of pixels in a -screen, and hence increases with the resolution of the video mode. -You may want to start in a low-resolution mode for quick progress while -zooming in, and switch to a higher-resolution mode when things get -interesting. Or use the solid guessing mode and pre-empt with -a zoom before it finishes. Plotting time also varies with the maximum -iteration setting, the fractal type, and your choice of drawing mode. -Solid-guessing (the default) is fastest, but it can be wrong: -perfectionists will want to use dual-pass mode (its first-pass preview is -handy if you might zoom pre-emptively) or single-pass mode. - -When you start systematically exploring, you can save time (and hey, every -little bit helps -- these "objects" are INFINITE, remember!) by aving -your last screen in a session to a file, and then going straight to it the -next time by using the command FRACTINT FRACTxxx (the .GIF extension is -assumed), or by starting Fractint normally and then using the command -to reload the saved file. Or you could hit to create a parameter file -entry with the "recipe" for a given image, and next time use the <@> -command to re-plot it. -; -; -; -~Topic=Fractint on Unix - -Fractint has been ported to Unix to run under X Windows. This version is -called "Xfractint". Xfractint may be obtained by anonymous ftp, -see {Distribution of Fractint}. - -Xfractint is still under development and is not as reliable as the IBM PC -version. - -Contact xfractint@fractint.org for more information on Xfractint. -~FF -Xfractint is a straight port of the IBM PC version. Thus, it uses the -IBM user interface. If you do not have function keys, or Xfractint does -not accept them from your keyboard, use the following key mappings: - - IBM Unix\ - F1 to F10 Shift-1 to Shift-0\ - INSERT I\ - DELETE D\ - PAGE_UP U\ - PAGE_DOWN N\ - LEFT_ARROW H\ - RIGHT_ARROW L\ - UP_ARROW K\ - DOWN_ARROW J\ - HOME O\ - END E\ - CTL_PLUS \}\ - CTL_MINUS \{ - -Xfractint takes the following options: - --onroot\ -Puts the image on the root window. - --fast\ -Uses a faster drawing technique. - --disk\ -Uses disk video. - --geometry WxH[\{+-X}\{+-Y}]\ -Changes the geometry of the image window. - --display displayname\ -Specifies the X11 display to use. - --private\ -Allocates the entire colormap (i.e. more colors). - --share\ -Shares the current colormap. - --fixcolors n\ -Uses only n colors. - --slowdisplay\ -Prevents Xfractint from hanging on the title page with slow displays. - --simple\ -Uses simpler keyboard handling, which makes debugging easier. - -Common problems: - -If you get the message "Couldn't find fractint.hlp", you can\ -a) Do "setenv FRACTDIR /foo", replacing /foo with the directory containing -fractint.hlp.\ -b) Run Xfractint from the directory containing fractint.hlp, or\ -c) Copy fractint.hlp to /usr/local/bin/X11/fractint - -If you get the message "Invalid help signature", the problem is due to -byteorder. You are probably using a Sun help file on a Dec machine or -vice versa. - -If Xfractint doesn't accept input, try typing into both the graphics window -and the text window. On some systems, only one of these works. - -If you are using Openwindows and can't get Xfractint to accept input, add -to your .Xdefaults file:\ -OpenWindows.FocusLenience: True - -If you cannot view the GIFs that Xfractint creates, the problem is that -Xfractint creates GIF89a format and your viewer probably only handles -GIF87a format. Run "xfractint gif87a=y" to produce GIF87a format. - -Because many shifted characters are used to simulate IBM keys, you can't -enter capitalized filenames. -; -; -; -~Topic=Color Cycling Commands, Label=@ColorCycling - -~Doc- -See {=HELPCYCLING Color Cycling Command Summary} for a summary of commands. - -~Doc+ -Color-cycling mode is entered with the 'c', '+', or '-' keys from an image, -or with the 'c' key from Palette-Editing mode. - -The color-cycling commands are available ONLY for VGA adapters and EGA -adapters in 640x350x16 mode. You can also enter color-cycling while -using a disk-video mode, to load or save a palette - other functions are -not supported in disk-video. - -Note that the colors available on an EGA adapter (16 colors at a -time out of a palette of 64) are limited compared to those of VGA, super- -VGA, and MCGA (16 or 256 colors at a time out of a palette of 262,144). So -color-cycling in general looks a LOT better in the latter modes. Also, -because of the EGA palette restrictions, some commands are not available -with EGA adapters. - -Color cycling applies to the color numbers selected by the "cyclerange=" -command line parameter (also changeable via the options screen and via -the palette editor). By default, color numbers 1 to 255 inclusive are -cycled. On some images you might want to set "inside=0" ( options or -command line parameter) to exclude the "lake" from color cycling. - -When you are in color-cycling mode, you will either see the screen colors -cycling, or will see a white "overscan" border when paused, as a reminder -that you are still in this mode. The keyboard commands available once -you've entered color-cycling. are described below. - -\ -Bring up a HELP screen with commands specific to color cycling mode. - -\ -Leave color-cycling mode. - -\ -Restore original palette. - -<+> or <->\ -Begin cycling the palette by shifting each color to the next "contour." -<+> cycles the colors in one direction, <-> in the other. - -'<' or '>'\ -Force a color-cycling pause, disable random colorizing, and single-step -through a one color-cycle. For "fine-tuning" your image colors. - -Cursor up/down\ -Increase/decrease the cycling speed. High speeds may cause a harmless -flicker at the top of the screen. - - through \ -Switches from simple rotation to color selection using randomly generated -color bands of short (F2) to long (F10) duration. - -<1> through <9>\ -Causes the screen to be updated every 'n' color cycles (the default is 1). -Handy for slower computers. - -\ -Randomly selects a function key (F2 through F10) and then updates ALL the -screen colors prior to displaying them for instant, random colors. Hit -this over and over again (we do). - -\ -Pause cycling with white overscan area. Cycling restarts with any command -key (including another spacebar). - --\ -Pause cycling and reset the palette to a preset two color "straight" -assignment, such as a spread from black to white. (Not for EGA) - --\ -Pause & set a 2-color cyclical assignment, e.g. red->yellow->red (not EGA). - --\ -Pause & set a 3-color cyclical assignment, e.g. green->white->blue (not EGA). - -, , \ -Pause and increase the red, green, or blue component of all colors by a -small amount (not for EGA). Note the case distinction of this vs: - -, , \ -Pause and decrease the red, green, or blue component of all colors by a -small amount (not for EGA). - - or \ -Pause and load an external color map from the files DEFAULT.MAP or -ALTERN.MAP, supplied with the program. - -\ -Pause and load an external color map (.MAP file). Several .MAP files are -supplied with Fractint. See {Palette Maps}. - -\ -Pause, prompt for a filename, and save the current palette to the named -file (.MAP assumed). See {Palette Maps}. -; -; -; -~Topic=Color Cycling Command Summary, Label=HELPCYCLING -; This topic is online only - -~Format- - See {Color Cycling Commands} for full documentation. - - F1 HELP! (Enter help mode and display this screen) - Esc Exit from color-cycling mode - + or - (re)-set the direction of the color-cycling - Home Restore original palette -~Doc- - \27 \26 (re)-set the direction of the color-cycling (just like +/-) - \24 \25 SpeedUp/SlowDown the color cycling process -~Doc+,Online- - Right/Left Arrow (re)-set the direction of the color-cycling (just like +/-) - Up/Down Arrow SpeedUp/SlowDown the color cycling process -~Online+ - F2 thru F10 Select Short--Medium--Long (randomly-generated) color bands - 1 thru 9 Cycle through 'nn' colors between screen updates (default=1) - Enter Randomly (re)-select all new colors [TRY THIS ONE!] - Spacebar Pause until another key is hit - < or > Pause and single-step through one color-cycle -* SF1 thru AF10 Pause and reset the Palette to one of 30 fixed sequences - d or a pause and load the palette from DEFAULT.MAP or ALTERN.MAP - l load palette from a map file - s save palette to a map file -* r or g or b or force a pause and Lower (lower case) or Raise (upper case) -* R or G or B the Red, Green, or Blue component of the fractal image -; -; -; -~Topic=Palette Editing Commands - -~Doc- -See {=HELPXHAIR Palette Editing Command Summary} for a summary of commands. - -~Doc+ -Palette-editing mode provides a number of tools for modifying the colors -in an image. It can be used only with MCGA or higher adapters, and only -with 16 or 256 color video modes. -Many thanks to Ethan Nagel for creating the palette editor. - -Use the key to enter palette-editing mode from a displayed image or -from the main menu. - -When this mode is entered, an empty palette frame is displayed. You can -use the cursor keys to position the frame outline, and and - to change its size. (The upper and lower limits on the size -depend on the current video mode.) When the frame is positioned where you -want it, hit Enter to display the current palette in the frame. - -Note that the palette frame shows R(ed) G(reen) and B(lue) values for two -color registers at the top. The active color register has a solid frame, -the inactive register's frame is dotted. Within the active register, the -active color component is framed. - -With a video mode of 640x400 or higher, a status area appears between the -two color registers. This status area shows: - - nnn = color number at the cursor location\ - A = Auto mode\ - X, Y = exclusion modes\ - F = freesyle mode\ - T = stripe mode is waiting for #\ - -Using the commands described below, you can assign particular colors to -the registers and manipulate them. Note that at any given time there are -two colors "X"d - these are pre-empted by the editor to display the -palette frame. They can be edited but the results won't be visible. You -can change which two colors are borrowed ("X"d out) by using the -command. - -Once the palette frame is displayed and filled in, the following commands -are available: - -\ -Bring up a HELP screen with commands specific to palette-editing mode. - -\ -Leave palette-editing mode - -\ -Hide the palette frame to see full image; the cross-hair remains visible -and all functions remain enabled; hit again to restore the palette -display. - -Cursor keys\ -Move the cross-hair cursor around. In 'auto' mode (the default) the color -under the center of the cross-hair is automatically assigned to the active -color register. Control-Cursor keys move the cross-hair faster. A mouse -can also be used to move around. - - \ -Select the Red, Green, or Blue component of the active color register for -subsequent commands - - \ -Select previous or next color component in active register - -~onlineFF -<+> <->\ -Increase or decrease the active color component value by 1 Numeric keypad -(gray) + and - keys do the same. - - \ -Increase or decrease the active color component value by 5; Moving the -mouse up/down with left button held is the same - -<0> <1> <2> <3> <4> <5> <6>\ -Set the active color component's value to 0 10 20 ... 60 - -\ -Select the other color register as the active one. In the default 'auto' -mode this results in the now-inactive register being set to remember the -color under the cursor, and the now-active register changing from whatever -it had previously remembered to now follow the color. - -<,> <.>\ -Rotate the palette one step. By default colors 1 through 255 inclusive -are rotated. This range can be over-ridden with the "cyclerange" -parameter, the options screen, or the command described below. - -"<" ">"\ -Rotate the palette continuously (until next keystroke) - -\ -Set the color cycling range to the range of colors currently defined by -the color registers. - -\ -Enter Color-Cycling Mode. When you invoke color-cycling from here, it -will subsequently return to palette-editing when you from it. -See {Color Cycling Commands}. - -<=>\ -Create a smoothly shaded range of colors between the colors selected by -the two color registers. - -\ -Specify a gamma value for the shading created by <=>. - -\ -Duplicate the inactive color register's values to the active color -register. - -\ -Stripe-shade - create a smoothly shaded range of colors between the two -color registers, setting only every Nth register. After hitting , hit -a numeric key from 2 to 9 to specify N. For example, if you press -<3>, smooth shading is done between the two color registers, affecting -only every 3rd color between them. The other colors between them remain -unchanged. - -\ -Convert current palette to gray-scale. (If the or exclude ranges -described later are in force, only the active range of colors is converted -to gray-scale.) - - ... \ -Store the current palette in a temporary save area associated with the -function key. The temporary save palettes are useful for quickly -comparing different palettes or the effect of some changes - see next -command. The temporary palettes are only remembered until you exit from -palette-editing mode.\ -Starting with version 19.6, when palette editing mode is entered, the -original palette is stored in the area associated with F2. - - ... \ -Restore the palette from a temporary save area. If you haven't previously -saved a palette for the function key, you'll get a simple grey scale. - -\ -Pause and load an external color map (.MAP file). See {Palette Maps}. - -\ -Pause, prompt for a filename, and save the current palette to the named -file (.MAP assumed). See {Palette Maps}. - -\ -Invert frame colors. With some colors the palette is easier to see when -the frame colors are interchanged. - -<\\>\ -Move or resize the palette frame. The frame outline is drawn - it can -then be repositioned and sized with the cursor keys, and -, just as was done when first entering palette-editing mode. Hit -Enter when done moving/sizing. - -\ -Use the colors currently selected by the two color registers for the -palette editor's frame. When palette editing mode is entered, the last -two colors are "X"d out for use by the palette editor; this command can be -used to replace the default with two other color numbers. - -\ -Toggle 'auto' mode on or off. When on (the default), the active color -register follows the cursor; when off, must be pressed to set the -active register to the color under the cursor. - -\ -Only useful when 'auto' is off, as described above; double clicking the -left mouse button is the same as Enter. - -\ -Toggle 'exclude' mode on or off - when toggled on, only those image pixels -which match the active color are displayed. - -\ -Toggle 'exclude' range on or off - similar to , but all pixels matching -colors in the range of the two color registers are displayed. - -\ -Make a negative color palette - will convert only current color if in 'x' -mode or range between editors in 'y' mode or entire palette if in "normal" -mode. - -\ -<@> <\"> (English keyboard) (French keyboard)\ -<#> (English keyboard) <$> (French keyboard)\ -Swap R<->G, G<->B, and R<->B columns. , <@>, and <#> are shifted 1, 2, -and 3, which you may find easier to remember. - -\ -Undoes the last palette editor command. Will undo all the way to the -beginning of the current session. - -\ -Redoes the undone palette editor commands. - -\ -Toggles "Freestyle mode" on and off (Freestyle mode changes a range of -palette values smoothly from a center value outward). -With your cursor inside the palette box, press the key to enter -Freestyle mode. A default range of colors will be selected for you -centered at the cursor (the ends of the color range are noted by putting -dashed lines around the corresponding palette values). While in Freestyle -mode: - - Moving the mouse changes the location of the range of colors that are - affected. - - Control-Insert/Delete or the shifted-right-mouse-button changes the - size of the affected palette range. - - The normal color editing keys (R,G,B,1-6, etc) set the central color - of the affected palette range. - - Pressing ENTER or double-clicking the left mouse button makes the - palette changes permanent (if you don't perform this step, any - palette changes disappear when you press the key again to exit - freestyle mode). - - For more details see {Freestyle mode tutorial} -; -; -~Topic=Freestyle mode tutorial -It can be confusing working out what's going on in freestyle mode -so here's a quick walk through...\ - -Freestyle palette editing is intended to be a way of colouring an image in -an intuitive fashion with the minimum of keyboard usage. In fact everything is -controllable with the mouse, as the following shows: - -To start with, generate a plasma type fractal as it has all 256 colours on -screen at once. Now bring up the palette editor and press 'w' to set up -a greyscale palette as a blank canvas on which to splash some colour. -Pressing 'f' puts us in freestyle mode... crosshairs appear on the screen and -a colour band is applied, centred on the cursor. Although, at the moment, -the colour of this band is grey and you won't see much! - -In order to change the colour of the band, hold down the left mouse button and -drag up and down. This changes the amount of red in the band. You'll see the -values change in the status box above the palette grid. Double clicking the -right mouse button changes the colour component that's varied in an r-g-b-r- -cycle.... try it out and conjure up any shade you like! - -To vary the width of the band, drag up and down with the right button held down. -Slower machines may show some 'lag' during this operation, especially if they -have no math co-processor, so watch out as the mouse movements get buffered. - -Once you've got the band in a satisfactory position then double click the left -button to fix it in place. -Continue like this for as long as you like, adding different colours to the -grey palette. -You'll notice how the band relates to the existing colour, the RGB values give -the middle colour which are then smoothly shaded out to the colours at the ends -of the band. This can lead to some sudden jumps in the shading as the band is -moved about the screen and the edges come to overlap different areas of colour. - -For really violent jumps in shading try starting with an image that has areas -that change chaotically, such as a Mandlbrot set. You'll see what I mean when -you move the cross hairs into an area close to the 'lake' where the change in -value from one pixel to the next is sudden, chaotic and large. Watch out! the -strobing effect can be somewhat disturbing. This is nothing to worry about but -just a consequence of the manipulation of the palette and the way in which -the colour bands are calculated. - -I hope that you'll find this a useful tool in colouring an image. Remember that -the 'h' key can be used to hide the palette box and expose the whole image. - -; -~Topic=Palette Editing Command Summary, Label=HELPXHAIR -; This topic is online only. - -~Format- - See {Palette Editing Commands} for full documentation. - - F1 HELP! (Enter help mode and display this screen) - Esc Exit from palette editing mode - h Hide/unhide the palette frame - \24 \25 \27 \26 Move the cross-hair cursor around. Control-Cursor keys - move faster. A mouse can also be used to move around. - r or g or b Select the the Red, Green, or Blue component of the - active color register for subsequent commands - Insert or Delete Select previous or next color component in active register - + or - Increase or decrease the active color component by 1 - Pageup or Pagedn Increase or decrease the active color component by 5; - Moving the mouse up/down with left button held is the same - 0 1 2 3 4 5 6 Set active color component to 0 10 20 ... 60 - Space Select the other color register as the active one - , or . Rotate the palette one step - < or > Rotate the palette continuously (until next keystroke) - c Enter Color-Cycling Mode (see {=HELPCYCLING Color Cycling Commands}) - = Create a smoothly shaded range of colors - m Set the gamma value for '='. -~FF - d Duplicate the inactive color register in active color - t Stripe-shade; after hitting 't', hit a number from 2 to 9 - which is used as stripe width - Shift-F2,F3,..F9 Store the current palette in a temporary save area - associated with the function key - F2,F3,...,F9 Restore the palette from a temporary save area - w Convert palette (or current exclude range) to gray-scale - \\ Move or resize the palette frame - i Invert frame colors, useful with dark colors - a Toggle 'auto' mode on or off - when on, the active color - register follows the cursor; when off, Enter must be hit - to set the register to the color under the cursor - Enter Only useful when 'auto' is off, as described above; double - clicking the left mouse button is the same as Enter - x Toggle 'exclude' mode on or off - y Toggle 'exclude' range on or off - o Set the 'cyclerange' (range affected by color cycling - commands) to the range of the two registers - n Make a negative color palette - u Undoes the last command - e Redoes the last undone command -~FF - ! Swap red and green columns - @ \" or u-grave Swap green and blue columns - # pound or $ Swap red and blue columns - f Toggle Freestyle Palette-Editing Mode. See - {Palette Editing Commands} for details. - -; -; -~Topic=Parameter Explorer/Evolver, Label=HELPEVOL - - Since fractint is such a wonderfully complex program it has more than a few - parameters to tweak and options to select. To the inexperienced - user the choice is bewildering. Even for the experts the chaotic nature of - the mathematical processes involved make it difficult to know what to - change in order to achieve the desired effect. - - In order to help with this situation the Fractint parameter evolver has been - developed. It varies those parameters for you and puts the results - on screen as a grid of small images. You can then choose the one which you - like best and regenerate it full screen, or if you don't like any of the - variations, you can try again to see if anything better turns up! - - Enough explanations for now, lets see how easy it is to use: - - With the default Mandlebrot set on the screen simply hold down the 'Alt' key - and press the '1' key on the top row (DON'T use the numeric keypad to the - right, it won't work). You'll see a screen full of images generated starting - from the middle and spiraling outwards. The perfect Mandlebrot set will be - in the middle and the others will be warped and distorted by having had the - initial value of Z perturbed at random... but you don't need to know that - (which is the whole point really!). - - 'Alt-1' produces a low level of mutation of the fractal, only 'mild' - parameters are changed, those which have a more subtle effect. For much - wilder variations try pressing 'Alt-7' now. This give the maximum available - mutation with just about everything being twiddled and fiddled to rather - dramatic effect as you should now be seeing. - - To select an image for full screen display simply bring up a zoombox by - pressing 'Page-up' once. The center image will now have a white box around - it. Hold down the 'Ctrl' key and use the arrow keys to move this box around - until it's outlining an image you like. Pressing 'B' will now exit from - evolver mode and redraw the selected image full size. If, rather than exiting - from evolver mode, you just press 'enter', then a whole new set of images - is generated, all based around the one you selected (which is now the middle - image of the new set). - - From a basic point of view that's it! Just press alt-number to scramble - things when you're out of inspiration, it works for any of the fractal - types in fractint including formulae... easy! (chaotic, but easy :-) ) - - As this is a Fractint feature, there is, of course, a lot more to it - than the basics described above... - - For a start, there are some handy hotkeys to use, 'F2' and 'F3' are used to - alter the amount of mutation or the amount by which the selected parameters - can be varied. 'F2' halves the amount of mutation, 'F3' doubles it. So if - things on-screen are looking a bit samey just press 'F3' a few times to - crank up the mutation level. - - Using 'F2' to decrease mutation levels is a way of moving towards a goal - image. Say that a set of images contained one that looked a little like, - maybe, a cats face and you wished to try and get something more cat like. - To achieve this simply select the desired image and press 'F2'. The newly - generated images should be more alike, though probably still quite widely - varied. With luck, one of the new images will be even more cat like. Select - this one and press 'F2' again. Continue like this, selecting the center image - again if there are no improvements in the current generation, until - eventually all the images are alike and you've arrived at your goal (or at - least you're probably as close as it's possible to get with that fractal - type). - - As you look for more details in the images it is useful to reduce the number - of images per generation, thus producing larger sub images. Pressing 'F4' - will reduce the number of images per side on the grid by two and pressing - 'F5' increments the gridsize similarly. - - 'F6' will switch between normal random mutation and 'spread' random mutation. - In 'spread' mode the amount of mutation allowed in an image is varied - according to each images position in the grid. Those images near the center - are allowed a lesser degree of freedom of mutation than those around the - outside. This produces a sea of images, stable at the center with wilder - variations around the edges. This mode is best used with larger gridsizes - and becomes completely silly at a gridsize of three! - - 'Ctrl-e' brings up the evolver control screen on which you have manual access - to the evolution parameters varied by the hotkeys described above.\ - These are: - - Gridsize. The number of sub images per side of the screen. Use - odd numbers only. - - Max Mutation The maximum amount by which a parameter may be varied - - Mutation Reduction The Max mutation value is multiplied by this between - generations. This can be used to automatically goal - seek without having to use the 'F2' key. - - Grouting Turns on or off the gap between sub images, at large - values of gridsize this can reclaim valuable screen - area for display use. - - Pressing 'F6' brings up a screen from which you can control what parameters - get varied and in what manner. You'll notice that as well as the mutation - modes 'random' and 'spread' there are other ways of stirring things around, - read on...... - - As well as randomly mutating parameter values (referred to as 'evolver mode' - or just 'evolving') a chosen set of parameters can be varied steadily across - the screen thus allowing the user to explore what happens as a parameter is - slowly changed ('explorer mode' or 'exploring'). For example, to get - acquainted with parameter exploring and produce a map of the Julia sets, try - this:\ - Start Fractint and set the type to Julia and the resolution higher than - 320x200, once the default Julia set has been generated, press 'Ctrl-e' to - bring up the evolver/explorer control panel. - - Set evolve mode to yes and then press 'F6' to bring up the screen that allows - you to choose what gets varied. - - Now set the first entry (param1) to 'x' and the second (param2) to 'y'. This - tells Fractint to vary param1 (the real part of c) across the screen and - param2 (the imaginary part of c) down the screen. Make sure all the other - parameters are set to 'no' so that nothing else gets changed to confuse - things. - - Press 'Return' to go back to the main evolver control screen and you'll see - that a few more items have appeared. These control just how much the - parameters are varied across the screen and what their starting values - should be, leave them as they are but increase gridsz to 15. Also switch - on the parameter zoom box option. - - When you exit this control screen with the 'Return' key, you'll see a grid of - Julia sets generated all mapped out onto the imaginary plane, squint and - you'll be able to spot the underlying Mset! - - When you press 'Pageup' this time you'll notice that there are two boxes on - screen with a larger box centered around the normal selection box. - 'Ctrl-pageup' or 'Ctrl-pagedown' varies the size of this box which - represents the 'parameter' zoom box. The parameter zoombox allows you to - look at smaller areas of the parameter space in more detail. To explain - this further look at how the Julia sets change across the screen, around - the area of 'seahorse valley' on the underlying Mset, the Julia sets - undergo a sharp change in character. This area of change can be examined - in more detail using parameter zooming. Make the outer zoombox a few grids - across and select an image in the area of this change with the outer box - straddling it. Look at the images right in the corners of the parm zoombox, - when you press 'Enter' and a new generation of images is generated the same - images will be in the corners of the screen with more sub images between - them, allowing a finer look at how the change progresses. In this way, you - can observe the chaotic areas in parameter space with the unique pseudo four - dimensional view offered by the explorer. - - In the example shown above, you were just exploring the variation in two - 'real' parameters, i.e. they can take fractional values, and the idea of - being able to create an image half way between two others is valid. However, - many of the parameters in fractint are discrete, i.e. can be only one of a - set of specific values. Examples of discrete parameters are inside colouring - method or decomposition values and the way in which these are explored is - different in that parameter zooming has no meaning for discrete parameters. - - When a discrete parameter is set to vary with x or y it is simply cycled - through all possible values and round again. Words are getting clumsy so - it's time for another example methinks! - - First press 'Insert' to restart Fractint and get everything back to its - default values for a fresh start. Set the fractal type to 'fn*fn' this type - requires the user to choose two trig functions and this choice is made on - the 'Z' screen. There are around thirty different functions to choose from - and checking out all the different combinations is a not inconsiderable task - manually. With the explorer, however, it's a piece of cake! - - Set the screen resolution to the highest you can view and press 'Ctrl-e' - to bring up the control panel and enable evolving mode. Set the gridsize - to 29 and leave the parameters at their defaults. Now, press 'F6' to enter - 'variable tweak central' and set trig function 1 to 'x' and trig function 2 - to 'y', and all the others to 'no'. Exit the two screens and you'll see - generated all of the different combinations possible even if they are rather - small examples! - - To find out what particular combination of trig functions an image is using, - just select the image using the zoombox and bring up the 'z' screen. You - don't have to press 'Enter', simply highlighting the appropriate image with - the ctrl-arrow keys will do. - - And that just about sums up the evolver! Much more could be written but it's - better experienced, try writing your formulae with more variable parameters - and trig functions so that their behavior can be investigated. - - Try using it with any fractal type, if in doubt just see what happens! - - It should be noted here that some of the fractal types such as the IFS do not - terminate, they run on forever and as such aren't usable with the evolver as - the first sub image would never finish to allow the next one to generate. - These fractal types are detected and you won't be allowed to start the evolver - with these. - - There now only remains to mention that you can save image sets and restore - them later to carry on exploring from a different seed image: - 's' saves and 'r' restores as in normal fractint operation and the screenfull - is saved as a single gif file. - - Have fun! See {Evolver Commands}. -; -; -~Topic=Evolver Commands -~Format- - PageUp When no Zoom Box is active, brings one up. - When Zoom Box is active already, shrinks it. - PageDown Expands the Zoom Box. - Expanding past the screen size cancels the Zoom Box. -~Doc- - \24 \25 \27 \26 Pans (Moves) the Zoom Box. - Ctrl- \24 \25 \27 \26 Moves the Zoom Box to the next subimage. -~Doc+,Online- - Arrow key Pans (Moves) the Zoom Box. - Ctrl-Arrow key Moves the Zoom Box to the next subimage. -~Online+ - Enter Redraws the Screen or area inside the Zoom Box. - Ctrl-Enter 'Zoom-out' - expands the image so that your current image - is positioned inside the current zoom-box location. - Ctrl-Pad+/Pad- Rotates the inner Zoom Box. - Ctrl-PgUp/PgDn Changes inner Zoom Box vertical size. - Ctrl-Home/End Changes inner Zoom Box shape. - Ctrl-Ins/Del Changes inner Zoom Box color. - Ctrl-E Brings up the evolver screen. - Space Brings up the evolver screen once in evolver mode. - B Turns off evolver if in evolver mode. - F2 Halves the amount of mutation. - F3 Doubles the amount of mutation. - F4 Generates fewer, bigger images. - F5 Generates more, smaller images. - F6 Switches to/from 'spread' mode with fewer mutations around - the middle. -~Format+ - - -; Fractal Types: -~Include help2.src -; -; Doodads, 3D: -~Include help3.src -; -; Parameters, Video Adapters & Modes: -~Include help4.src -; -; The rest: -~Include help5.src -; -; diff --git a/fractint/dos_help/help2.src b/fractint/dos_help/help2.src deleted file mode 100644 index e96b597a3..000000000 --- a/fractint/dos_help/help2.src +++ /dev/null @@ -1,3233 +0,0 @@ -~Topic=Summary of Fractal Types, Label=HELPFRACTALS -~Format- -~Doc- -For detailed descriptions, select a hot-link below, see {Fractal Types}, -or use from the fractal type selection screen. -~Doc+,Online- -SUMMARY OF FRACTAL TYPES -~Online+ -~CompressSpaces- -; -; Note that prompts.c pulls formulas out of the following for screen, -; using the HF_xxx labels. It assumes a rigid formatting structure for -; the formulas: -; 4 leading blanks (which get stripped on screen) -; lines no wider than 76 characters (not counting initial 4 spaces) -; formula ends at any of: -; blank line -; line which begins in column 1 -; format ctl char (~xxx, {xxx}, \x) -; - -{=HT_ANT ant} -~Label=HF_ANT - Generalized Ant Automaton as described in the July 1994 Scientific - American. Some ants wander around the screen. A rule string (the first - parameter) determines the ant's direction. When the type 1 ant leaves a - cell of color k, it turns right if the kth symbol in the first parameter - is a 1, or left otherwise. Then the color in the old cell is incremented. - The 2nd parameter is a maximum iteration to guarantee that the fractal - will terminate. The 3rd parameter is the number of ants. The 4th is the - ant type 1 or 2. The 5th parameter determines if the ants wrap the screen - or stop at the edge. The 6th parameter is a random seed. You can slow - down the ants to see them better using the

screen Orbit Delay. - -{=HT_BARNS barnsleyj1} -~Label=HF_BARNSJ1 - z(0) = pixel; - if real(z) >= 0 - z(n+1) = (z-1)*c - else - z(n+1) = (z+1)*c - Two parameters: real and imaginary parts of c - -{=HT_BARNS barnsleyj2} -~Label=HF_BARNSJ2 - z(0) = pixel; - if real(z(n)) * imag(c) + real(c) * imag(z((n)) >= 0 - z(n+1) = (z(n)-1)*c - else - z(n+1) = (z(n)+1)*c - Two parameters: real and imaginary parts of c - -{=HT_BARNS barnsleyj3} -~Label=HF_BARNSJ3 - z(0) = pixel; - if real(z(n) > 0 then z(n+1) = (real(z(n))^2 - imag(z(n))^2 - 1) - + i * (2*real(z((n)) * imag(z((n))) else - z(n+1) = (real(z(n))^2 - imag(z(n))^2 - 1 + real(c) * real(z(n)) - + i * (2*real(z((n)) * imag(z((n)) + imag(c) * real(z(n)) - Two parameters: real and imaginary parts of c. - -{=HT_BARNS barnsleym1} -~Label=HF_BARNSM1 - z(0) = c = pixel; - if real(z) >= 0 then - z(n+1) = (z-1)*c - else z(n+1) = (z+1)*c. - Parameters are perturbations of z(0) - -{=HT_BARNS barnsleym2} -~Label=HF_BARNSM2 - z(0) = c = pixel; - if real(z)*imag(c) + real(c)*imag(z) >= 0 - z(n+1) = (z-1)*c - else - z(n+1) = (z+1)*c - Parameters are perturbations of z(0) - -{=HT_BARNS barnsleym3} -~Label=HF_BARNSM3 - z(0) = c = pixel; - if real(z(n) > 0 then z(n+1) = (real(z(n))^2 - imag(z(n))^2 - 1) - + i * (2*real(z((n)) * imag(z((n))) else - z(n+1) = (real(z(n))^2 - imag(z(n))^2 - 1 + real(c) * real(z(n)) - + i * (2*real(z((n)) * imag(z((n)) + imag(c) * real(z(n)) - Parameters are perturbations of z(0) - -{=HT_BIF bifurcation} -~Label=HF_BIFURCATION - Pictorial representation of a population growth model. - Let P = new population, p = oldpopulation, r = growth rate - The model is: P = p + r*fn(p)*(1-fn(p)). - Three parameters: Filter Cycles, Seed Population, and Function. - -{=HT_BIF bif+sinpi} -~Label=HF_BIFPLUSSINPI - Bifurcation variation: model is: P = p + r*fn(PI*p). - Three parameters: Filter Cycles, Seed Population, and Function. - -{=HT_BIF bif=sinpi} -~Label=HF_BIFEQSINPI - Bifurcation variation: model is: P = r*fn(PI*p). - Three parameters: Filter Cycles, Seed Population, and Function. - -{=HT_BIF biflambda} -~Label=HF_BIFLAMBDA - Bifurcation variation: model is: P = r*fn(p)*(1-fn(p)). - Three parameters: Filter Cycles, Seed Population, and Function. - -{=HT_BIF bifstewart} -~Label=HF_BIFSTEWART - Bifurcation variation: model is: P = (r*fn(p)*fn(p)) - 1. - Three parameters: Filter Cycles, Seed Population, and Function. - -{=HT_BIF bifmay} -~Label=HF_BIFMAY - Bifurcation variation: model is: P = r*p / ((1+p)^beta). - Three parameters: Filter Cycles, Seed Population, and Beta. - -~OnlineFF -{=HT_CELLULAR cellular} -~Label=HF_CELLULAR - One-dimensional cellular automata or line automata. The type of CA - is given by kr, where k is the number of different states of the - automata and r is the radius of the neighborhood. The next generation - is determined by the sum of the neighborhood and the specified rule. - Four parameters: Initial String, Rule, Type, and Starting Row Number. - For Type = 21, 31, 41, 51, 61, 22, 32, 42, 23, 33, 24, 25, 26, 27 - Rule = 4, 7, 10, 13, 16, 6, 11, 16, 8, 15, 10, 12, 14, 16 digits - -{=HT_MARTIN chip} -~Label=HF_CHIP - Chip attractor from Michael Peters - orbit in two dimensions. - z(0) = y(0) = 0; - x(n+1) = y(n) - sign(x(n)) * cos(sqr(ln(abs(b*x(n)-c)))) - * arctan(sqr(ln(abs(c*x(n)-b)))) - y(n+1) = a - x(n) - Parameters are a, b, and c. - -~OnlineFF -{=HT_CIRCLE circle} -~Label=HF_CIRCLE - Circle pattern by John Connett - x + iy = pixel - z = a*(x^2 + y^2) - c = integer part of z - color = c modulo(number of colors) - -{=HT_MARKS cmplxmarksjul} -~Label=HF_CMPLXMARKSJUL - A generalization of the marksjulia fractal. - z(0) = pixel; - z(n+1) = c^(exp-1)*z(n)^2 + c. - Four parameters: real and imaginary parts of c, - and real and imaginary parts of exponent. - -{=HT_MARKS cmplxmarksmand} -~Label=HF_CMPLXMARKSMAND - A generalization of the marksmandel fractal. - z(0) = c = pixel; - z(n+1) = c^(exp-1)*z(n)^2 + c. - Four parameters: real and imaginary parts of perturbation - of z(0), and real and imaginary parts of exponent. - -~OnlineFF -{=HT_NEWTCMPLX complexnewton\, complexbasin} -~Label=HF_COMPLEXNEWT - Newton fractal types extended to complex degrees. Complexnewton - colors pixels according to the number of iterations required to - escape to a root. Complexbasin colors pixels according to which - root captures the orbit. The equation is based on the newton - formula for solving the equation z^p = r - z(0) = pixel; - z(n+1) = ((p - 1) * z(n)^p + r)/(p * z(n)^(p - 1)). - Four parameters: real & imaginary parts of degree p and root r. - -{=HT_DIFFUS diffusion} -~Label=HF_DIFFUS - Diffusion Limited Aggregation. Randomly moving points - accumulate. Three parameters: border width (default 10), type, - and color change rate. - -~OnlineFF -{=HT_DYNAM dynamic} -~Label=HF_DYNAM - Time-discrete dynamic system. - x(0) = y(0) = start position. - y(n+1) = y(n) + f( x(n) ) - x(n+1) = x(n) - f( y(n) ) - f(k) = sin(k + a*fn1(b*k)) - For implicit Euler approximation: x(n+1) = x(n) - f( y(n+1) ) - Five parameters: start position step, dt, a, b, and the function fn1. - -{=HT_ESCHER escher_julia} -~Label=HF_ESCHER - Escher-like tiling of Julia sets from The Science of Fractal Images - z(0) = pixel - z(n+1) = z(n)^2 + (0, 0i) - The target set is a second, scaled, Julia set: - T = [ z: | (z * 15.0)^2 + c | < BAILOUT ] - Two parameters: real and imaginary parts of c - Iteration count and bailout size apply to both Julia sets. - -{=HT_SCOTSKIN fn(z)+fn(pix)} -~Label=HF_FNPLUSFNPIX - c = z(0) = pixel; - z(n+1) = fn1(z) + p*fn2(c) - Six parameters: real and imaginary parts of the perturbation - of z(0) and factor p, and the functions fn1, and fn2. - -{=HT_SCOTSKIN fn(z*z)} -~Label=HF_FNZTIMESZ - z(0) = pixel; - z(n+1) = fn(z(n)*z(n)) - One parameter: the function fn. - -~OnlineFF -{=HT_SCOTSKIN fn*fn} -~Label=HF_FNTIMESFN - z(0) = pixel; z(n+1) = fn1(n)*fn2(n) - Two parameters: the functions fn1 and fn2. - -{=HT_SCOTSKIN fn*z+z} -~Label=HF_FNXZPLUSZ - z(0) = pixel; z(n+1) = p1*fn(z(n))*z(n) + p2*z(n) - Five parameters: the real and imaginary components of - p1 and p2, and the function fn. - -{=HT_SCOTSKIN fn+fn} -~Label=HF_FNPLUSFN - z(0) = pixel; - z(n+1) = p1*fn1(z(n))+p2*fn2(z(n)) - Six parameters: The real and imaginary components of - p1 and p2, and the functions fn1 and fn2. - -{=HT_FORMULA formula} - Formula interpreter - write your own formulas as text files! - -~OnlineFF -{=HT_FROTH frothybasin} -~Label=HF_FROTH - Pixel color is determined by which attractor captures the orbit. The - shade of color is determined by the number of iterations required to - capture the orbit. - Z(0) = pixel; Z(n+1) = Z(n)^2 - C*conj(Z(n)) - where C = 1 + A*i, critical value of A = 1.028713768218725... - -{=HT_GINGER gingerbread} -~Label=HF_GINGER - Orbit in two dimensions defined by: - x(n+1) = 1 - y(n) + |x(n)| - y(n+1) = x(n) - Two parameters: initial values of x(0) and y(0). - -{=HT_HALLEY halley} -~Label=HF_HALLEY - Halley map for the function: F = z(z^a - 1) = 0 - z(0) = pixel; - z(n+1) = z(n) - R * F / [F' - (F" * F / 2 * F')] - bailout when: abs(mod(z(n+1)) - mod(z(n)) < epsilon - Four parameters: order a, real part of R, epsilon, - and imaginary part of R. - -~OnlineFF -{=HT_HENON henon} -~Label=HF_HENON - Orbit in two dimensions defined by: - x(n+1) = 1 + y(n) - a*x(n)*x(n) - y(n+1) = b*x(n) - Two parameters: a and b - -{=HT_MARTIN hopalong} -~Label=HF_HOPALONG - Hopalong attractor by Barry Martin - orbit in two dimensions. - z(0) = y(0) = 0; - x(n+1) = y(n) - sign(x(n))*sqrt(abs(b*x(n)-c)) - y(n+1) = a - x(n) - Parameters are a, b, and c. - -~FF -{=HT_HYPERC hypercomplex} -~Label=HF_HYPERC - HyperComplex Mandelbrot set. - h(0) = (0,0,0,0) - h(n+1) = fn(h(n)) + C. - where "fn" is sin, cos, log, sqr etc. - Two parameters: cj, ck - C = (xpixel,ypixel,cj,ck) - -{=HT_HYPERC hypercomplexj} -~Label=HF_HYPERCJ - HyperComplex Julia set. - h(0) = (xpixel,ypixel,zj,zk) - h(n+1) = fn(h(n)) + C. - where "fn" is sin, cos, log, sqr etc. - Six parameters: c1, ci, cj, ck - C = (c1,ci,cj,ck) - -~OnlineFF -{=HT_ICON icon, icon3d} -~Label=HF_ICON - Orbit in three dimensions defined by: - p = lambda + alpha * magnitude + beta * (x(n)*zreal - y(n)*zimag) - x(n+1) = p * x(n) + gamma * zreal - omega * y(n) - y(n+1) = p * y(n) - gamma * zimag + omega * x(n) - (3D version uses magnitude for z) - Parameters: Lambda, Alpha, Beta, Gamma, Omega, and Degree - -{=HT_IFS IFS} - Barnsley IFS (Iterated Function System) fractals. Apply - contractive affine mappings. - -{=HT_PICKMJ julfn+exp} -~Label=HF_JULFNPLUSEXP - A generalized Clifford Pickover fractal. - z(0) = pixel; - z(n+1) = fn(z(n)) + e^z(n) + c. - Three parameters: real & imaginary parts of c, and fn - -{=HT_PICKMJ julfn+zsqrd} -~Label=HF_JULFNPLUSZSQRD - z(0) = pixel; - z(n+1) = fn(z(n)) + z(n)^2 + c - Three parameters: real & imaginary parts of c, and fn - -{=HT_JULIA julia} -~Label=HF_JULIA - Classic Julia set fractal. - z(0) = pixel; z(n+1) = z(n)^2 + c. - Two parameters: real and imaginary parts of c. - -{=HT_INVERSE julia_inverse} -~Label=HF_INVERSE - Inverse Julia function - "orbit" traces Julia set in two dimensions. - z(0) = a point on the Julia Set boundary; z(n+1) = +- sqrt(z(n) - c) - Parameters: Real and Imaginary parts of c - Maximum Hits per Pixel (similar to max iters) - Breadth First, Depth First or Random Walk Tree Traversal - Left or Right First Branching (in Depth First mode only) - Try each traversal method, keeping everything else the same. - Notice the differences in the way the image evolves. Start with - a fairly low Maximum Hit limit, then increase it. The hit limit - cannot be higher than the maximum colors in your video mode. - -~OnlineFF -{=HT_FNORFN julia(fn||fn)} -~Label=HF_JULIAFNFN - z(0) = pixel; - if modulus(z(n)) < shift value, then - z(n+1) = fn1(z(n)) + c, - else - z(n+1) = fn2(z(n)) + c. - Five parameters: real, imag portions of c, shift value, fn1, fn2. - -{=HT_MANDJUL4 julia4} -~Label=HF_JULIA4 - Fourth-power Julia set fractals, a special case - of julzpower kept for speed. - z(0) = pixel; - z(n+1) = z(n)^4 + c. - Two parameters: real and imaginary parts of c. - -{=HT_JULIBROT julibrot} - 'Julibrot' 4-dimensional fractals. - -{=HT_PICKMJ julzpower} -~Label=HF_JULZPOWER - z(0) = pixel; - z(n+1) = z(n)^m + c. - Three parameters: real & imaginary parts of c, exponent m - -{=HT_PICKMJ julzzpwr} -~Label=HF_JULZZPWR - z(0) = pixel; - z(n+1) = z(n)^z(n) + z(n)^m + c. - Three parameters: real & imaginary parts of c, exponent m - -{=HT_KAM kamtorus, kamtorus3d} -~Label=HF_KAM - Series of orbits superimposed. - 3d version has 'orbit' the z dimension. - x(0) = y(0) = orbit/3; - x(n+1) = x(n)*cos(a) + (x(n)*x(n)-y(n))*sin(a) - y(n+1) = x(n)*sin(a) - (x(n)*x(n)-y(n))*cos(a) - After each orbit, 'orbit' is incremented by a step size. - Parameters: a, step size, stop value for 'orbit', and - points per orbit. - -{=HT_LAMBDA lambda} -~Label=HF_LAMBDA - Classic Lambda fractal. 'Julia' variant of Mandellambda. - z(0) = pixel; - z(n+1) = lambda*z(n)*(1 - z(n)). - Two parameters: real and imaginary parts of lambda. - -{=HT_LAMBDAFN lambdafn} -~Label=HF_LAMBDAFN - z(0) = pixel; - z(n+1) = lambda * fn(z(n)). - Three parameters: real, imag portions of lambda, and fn - -{=HT_FNORFN lambda(fn||fn)} -~Label=HF_LAMBDAFNFN - z(0) = pixel; - if modulus(z(n)) < shift value, then - z(n+1) = lambda * fn1(z(n)), - else - z(n+1) = lambda * fn2(z(n)). - Five parameters: real, imag portions of lambda, shift value, fn1, fn2 - -{=HT_LATOO latoocarfian} -~Label=HF_LATOO - Orbit in two dimensions defined by: - x(n+1) = fn1 (y(n) * b) + c * fn2(x(n) * b) - y(n+1) = fn3 (x(n) * a) + d * fn4(y(n) * a) - Parameters: a, b, c, d fn1..4 (all sin=original) - -~OnlineFF -{=HT_LORENZ lorenz, lorenz3d} -~Label=HF_LORENZ - Lorenz two lobe attractor - orbit in three dimensions. - In 2d the x and y components are projected to form the image. - z(0) = y(0) = z(0) = 1; - x(n+1) = x(n) + (-a*x(n)*dt) + ( a*y(n)*dt) - y(n+1) = y(n) + ( b*x(n)*dt) - ( y(n)*dt) - (z(n)*x(n)*dt) - z(n+1) = z(n) + (-c*z(n)*dt) + (x(n)*y(n)*dt) - Parameters are dt, a, b, and c. - -{=HT_LORENZ lorenz3d1} -~Label=HF_LORENZ3D1 - Lorenz one lobe attractor, 3D orbit (Rick Miranda and Emily Stone) - z(0) = y(0) = z(0) = 1; norm = sqrt(x(n)^2 + y(n)^2) - x(n+1) = x(n) + (-a*dt-dt)*x(n) + (a*dt-b*dt)*y(n) - + (dt-a*dt)*norm + y(n)*dt*z(n) - y(n+1) = y(n) + (b*dt-a*dt)*x(n) - (a*dt+dt)*y(n) - + (b*dt+a*dt)*norm - x(n)*dt*z(n) - norm*z(n)*dt - z(n+1) = z(n) +(y(n)*dt/2) - c*dt*z(n) - Parameters are dt, a, b, and c. - -~OnlineFF -{=HT_LORENZ lorenz3d3} -~Label=HF_LORENZ3D3 - Lorenz three lobe attractor, 3D orbit (Rick Miranda and Emily Stone) - z(0) = y(0) = z(0) = 1; norm = sqrt(x(n)^2 + y(n)^2) - x(n+1) = x(n) +(-(a*dt+dt)*x(n) + (a*dt-b*dt+z(n)*dt)*y(n))/3 - + ((dt-a*dt)*(x(n)^2-y(n)^2) - + 2*(b*dt+a*dt-z(n)*dt)*x(n)*y(n))/(3*norm) - y(n+1) = y(n) +((b*dt-a*dt-z(n)*dt)*x(n) - (a*dt+dt)*y(n))/3 - + (2*(a*dt-dt)*x(n)*y(n) - + (b*dt+a*dt-z(n)*dt)*(x(n)^2-y(n)^2))/(3*norm) - z(n+1) = z(n) +(3*x(n)*dt*x(n)*y(n)-y(n)*dt*y(n)^2)/2 - c*dt*z(n) - Parameters are dt, a, b, and c. - -~OnlineFF -{=HT_LORENZ lorenz3d4} -~Label=HF_LORENZ3D4 - Lorenz four lobe attractor, 3D orbit (Rick Miranda and Emily Stone) - z(0) = y(0) = z(0) = 1; - x(n+1) = x(n) +(-a*dt*x(n)^3 - + (2*a*dt+b*dt-z(n)*dt)*x(n)^2*y(n) + (a*dt-2*dt)*x(n)*y(n)^2 - + (z(n)*dt-b*dt)*y(n)^3) / (2 * (x(n)^2+y(n)^2)) - y(n+1) = y(n) +((b*dt-z(n)*dt)*x(n)^3 + (a*dt-2*dt)*x(n)^2*y(n) - + (-2*a*dt-b*dt+z(n)*dt)*x(n)*y(n)^2 - - a*dt*y(n)^3) / (2 * (x(n)^2+y(n)^2)) - z(n+1) = z(n) +(2*x(n)*dt*x(n)^2*y(n) - 2*x(n)*dt*y(n)^3 - c*dt*z(n)) - Parameters are dt, a, b, and c. - -{=HT_LSYS lsystem} - Using a turtle-graphics control language and starting with - an initial axiom string, carries out string substitutions the - specified number of times (the order), and plots the result. - -{=HT_LYAPUNOV lyapunov} - Derived from the Bifurcation fractal, the Lyapunov plots the Lyapunov - Exponent for a population model where the Growth parameter varies between - two values in a periodic manner. - -{=HT_MAGNET magnet1j} -~Label=HF_MAGJ1 - z(0) = pixel; - [ z(n)^2 + (c-1) ] 2 - z(n+1) = | ---------------- | - [ 2*z(n) + (c-2) ] - Parameters: the real and imaginary parts of c - -{=HT_MAGNET magnet1m} -~Label=HF_MAGM1 - z(0) = 0; c = pixel; - [ z(n)^2 + (c-1) ] 2 - z(n+1) = | ---------------- | - [ 2*z(n) + (c-2) ] - Parameters: the real & imaginary parts of perturbation of z(0) - -{=HT_MAGNET magnet2j} -~Label=HF_MAGJ2 - z(0) = pixel; - [ z(n)^3 + 3*(C-1)*z(n) + (C-1)*(C-2) ] 2 - z(n+1) = | -------------------------------------------- | - [ 3*(z(n)^2) + 3*(C-2)*z(n) + (C-1)*(C-2) + 1 ] - Parameters: the real and imaginary parts of c - -~OnlineFF -{=HT_MAGNET magnet2m} -~Label=HF_MAGM2 - z(0) = 0; c = pixel; - [ z(n)^3 + 3*(C-1)*z(n) + (C-1)*(C-2) ] 2 - z(n+1) = | -------------------------------------------- | - [ 3*(z(n)^2) + 3*(C-2)*z(n) + (C-1)*(C-2) + 1 ] - Parameters: the real and imaginary parts of perturbation of z(0) - -{=HT_MANDEL mandel} -~Label=HF_MANDEL - Classic Mandelbrot set fractal. - z(0) = c = pixel; - z(n+1) = z(n)^2 + c. - Two parameters: real & imaginary perturbations of z(0) - -{=HT_FNORFN mandel(fn||fn)} -~Label=HF_MANDELFNFN - c = pixel; - z(0) = p1 - if modulus(z(n)) < shift value, then - z(n+1) = fn1(z(n)) + c, - else - z(n+1) = fn2(z(n)) + c. - Five parameters: real, imaginary portions of p1, shift value, - fn1 and fn2. - -;{=HT_MANDELBROTMIX4 mandelbrotmix4} -;~Label=HF_MANDELBROTMIX4 -; From a Jim Muth favorite FOTD formula -; a=real(p1), b=imag(p1), d=real(p2), f=imag(p2), -; g=1/f, h=1/d, j=1/(f-b), z=(-a*b*g*h)^j, -; k=real(p3)+1, l=imag(p3)+100, c=fn1(pixel): -; z=k*((a*(z^b))+(d*(z^f)))+c -; Parameters: see above, sixth parameter used for bailout -; -{=HT_MANDELCLOUD mandelcloud} -~Label=HF_MANDELCLOUD - Displays orbits of Mandelbrot set: - z(0) = c = pixel; - z(n+1) = z(n)^2 + c. - One parameter: number of intervals - -{=HT_MANDJUL4 mandel4} -~Label=HF_MANDEL4 - Special case of mandelzpower kept for speed. - z(0) = c = pixel; - z(n+1) = z(n)^4 + c. - Parameters: real & imaginary perturbations of z(0) - -~OnlineFF -{=HT_MANDFN mandelfn} -~Label=HF_MANDFN - z(0) = c = pixel; - z(n+1) = c*fn(z(n)). - Parameters: real & imaginary perturbations of z(0), and fn - -{=HT_FNORFN manlam(fn||fn)} -~Label=HF_MANLAMFNFN - c = pixel; - z(0) = p1 - if modulus(z(n)) < shift value, then - z(n+1) = fn1(z(n)) * c, else - z(n+1) = fn2(z(n)) * c. - Five parameters: real, imaginary parts of p1, shift value, fn1, fn2. - -{=HT_MARTIN Martin} -~Label=HF_MARTIN - Attractor fractal by Barry Martin - orbit in two dimensions. - z(0) = y(0) = 0; - x(n+1) = y(n) - sin(x(n)) - y(n+1) = a - x(n) - Parameter is a (try a value near pi) - -~OnlineFF -{=HT_MLAMBDA mandellambda} -~Label=HF_MLAMBDA - z(0) = .5; lambda = pixel; - z(n+1) = lambda*z(n)*(1 - z(n)). - Parameters: real & imaginary perturbations of z(0) - -{=HT_PHOENIX mandphoenix} -~Label=HF_MANDPHOENIX - z(0) = c = pixel, y(0) = 0; - For degree = 0: - z(n+1) = z(n)^2 + c.x + c.y*y(n), y(n+1) = z(n) - For degree >= 2: - z(n+1) = z(n)^degree + c.x*z(n)^(degree-1) + c.y*y(n) - y(n+1) = z(n) - For degree <= -3: - z(n+1) = z(n)^|degree| + c.x*z(n)^(|degree|-2) + c.y*y(n) - y(n+1) = z(n) - Three parameters: real & imaginary perturbations of z(0), and degree. - -~OnlineFF -{=HT_PHOENIX mandphoenixclx} -~Label=HF_MANDPHOENIXCPLX - z(0) = c = pixel, y(0) = 0; - For degree = 0: - z(n+1) = z(n)^2 + c + p2*y(n), y(n+1) = z(n) - For degree >= 2: - z(n+1) = z(n)^degree + c*z(n)^(degree-1) + p2*y(n), y(n+1) = z(n) - For degree <= -3: - z(n+1) = z(n)^|degree| + c*z(n)^(|degree|-2) + p2*y(n), y(n+1) = z(n) - Five parameters: real & imaginary perturbations of z(0), real & - imaginary parts of p2, and degree. - -{=HT_PICKMJ manfn+exp} -~Label=HF_MANDFNPLUSEXP - 'Mandelbrot-Equivalent' for the julfn+exp fractal. - z(0) = c = pixel; - z(n+1) = fn(z(n)) + e^z(n) + C. - Parameters: real & imaginary perturbations of z(0), and fn - -{=HT_PICKMJ manfn+zsqrd} -~Label=HF_MANDFNPLUSZSQRD - 'Mandelbrot-Equivalent' for the Julfn+zsqrd fractal. - z(0) = c = pixel; - z(n+1) = fn(z(n)) + z(n)^2 + c. - Parameters: real & imaginary perturbations of z(0), and fn - -{=HT_SCOTSKIN manowar} -~Label=HF_MANOWAR - c = z1(0) = z(0) = pixel; - z(n+1) = z(n)^2 + z1(n) + c; - z1(n+1) = z(n); - Parameters: real & imaginary perturbations of z(0) - -{=HT_SCOTSKIN manowarj} -~Label=HF_MANOWARJ - z1(0) = z(0) = pixel; - z(n+1) = z(n)^2 + z1(n) + c; - z1(n+1) = z(n); - Parameters: real & imaginary parts of c - -~OnlineFF -{=HT_PICKMJ manzpower} -~Label=HF_MANZPOWER - 'Mandelbrot-Equivalent' for julzpower. - z(0) = c = pixel; - z(n+1) = z(n)^exp + c; try exp = e = 2.71828... - Parameters: real & imaginary perturbations of z(0), real & - imaginary parts of exponent exp. - -{=HT_PICKMJ manzzpwr} -~Label=HF_MANZZPWR - 'Mandelbrot-Equivalent' for the julzzpwr fractal. - z(0) = c = pixel - z(n+1) = z(n)^z(n) + z(n)^exp + C. - Parameters: real & imaginary perturbations of z(0), and exponent - -~OnlineFF -{=HT_MARKS marksjulia} -~Label=HF_MARKSJULIA - A variant of the julia-lambda fractal. - z(0) = pixel; - z(n+1) = c^(exp-1)*z(n)^2 + c. - Parameters: real & imaginary parts of c, and exponent - -{=HT_MARKS marksmandel} -~Label=HF_MARKSMAND - A variant of the mandel-lambda fractal. - z(0) = c = pixel; - z(n+1) = c^(exp-1)*z(n)^2 + c. - Parameters: real & imaginary parts of perturbations of z(0), - and exponent - -{=HT_MARKS marksmandelpwr} -~Label=HF_MARKSMANDPWR - The marksmandelpwr formula type generalized (it previously - had fn=sqr hard coded). - z(0) = pixel, c = z(0) ^ (z(0) - 1): - z(n+1) = c * fn(z(n)) + pixel, - Parameters: real and imaginary perturbations of z(0), and fn - -~OnlineFF -{=HT_NEWTBAS newtbasin} -~Label=HF_NEWTBAS - Based on the Newton formula for finding the roots of z^p - 1. - Pixels are colored according to which root captures the orbit. - z(0) = pixel; - z(n+1) = ((p-1)*z(n)^p + 1)/(p*z(n)^(p - 1)). - Two parameters: the polynomial degree p, and a flag to turn - on color stripes to show alternate iterations. - -{=HT_NEWT newton} -~Label=HF_NEWT - Based on the Newton formula for finding the roots of z^p - 1. - Pixels are colored according to the iteration when the orbit - is captured by a root. - z(0) = pixel; - z(n+1) = ((p-1)*z(n)^p + 1)/(p*z(n)^(p - 1)). - One parameter: the polynomial degree p. - -~OnlineFF -{=HT_PHOENIX phoenix} -~Label=HF_PHOENIX - z(0) = pixel, y(0) = 0; - For degree = 0: z(n+1) = z(n)^2 + p1.x + p2.x*y(n), y(n+1) = z(n) - For degree >= 2: - z(n+1) = z(n)^degree + p1.x*z(n)^(degree-1) + p2.x*y(n), y(n+1) = z(n) - For degree <= -3: - z(n+1) = z(n)^|degree| + p1.x*z(n)^(|degree|-2) - + p2.x*y(n), y(n+1) = z(n) - Three parameters: real parts of p1 & p2, and degree. - -{=HT_PHOENIX phoenixcplx} -~Label=HF_PHOENIXCPLX - z(0) = pixel, y(0) = 0; - For degree = 0: z(n+1) = z(n)^2 + p1 + p2*y(n), y(n+1) = z(n) - For degree >= 2: - z(n+1) = z(n)^degree + p1*z(n)^(degree-1) + p2*y(n), y(n+1) = z(n) - For degree <= -3: - z(n+1) = z(n)^|degree| + p1*z(n)^(|degree|-2) + p2*y(n), y(n+1) = z(n) - Five parameters: real & imaginary parts of p1 & p2, and degree. - -~OnlineFF -{=HT_PICK pickover} -~Label=HF_PICKOVER - Orbit in three dimensions defined by: - x(n+1) = sin(a*y(n)) - z(n)*cos(b*x(n)) - y(n+1) = z(n)*sin(c*x(n)) - cos(d*y(n)) - z(n+1) = sin(x(n)) - Parameters: a, b, c, and d. - -{=HT_PLASMA plasma} -~Label=HF_PLASMA - Random, cloud-like formations. Requires 4 or more colors. - A recursive algorithm repeatedly subdivides the screen and - colors pixels according to an average of surrounding pixels - and a random color, less random as the grid size decreases. - Four parameters: 'graininess' (0, 0.125 to 100, default = 2), - old/new algorithm, seed value used, 16-bit out output selection. - -~OnlineFF -{=HT_POPCORN popcorn} -~Label=HF_POPCORN - The orbits in 2D are plotted superimposed: - x(0) = xpixel, y(0) = ypixel; - x(n+1) = x(n) - real(h * fn1( y(n) + fn2(C * y(n) )) - - imag(h * fn3( x(n) + fn4(C * x(n) )) - y(n+1) = y(n) - real(h * fn3( x(n) + fn4(C * x(n) )) - - imag(h * fn1( y(n) + fn2(C * y(n) )) - Parameters: step size h, C, functions fn1..4 (original: sin,tan,sin,tan). - -{=HT_POPCORN popcornjul} -~Label=HF_POPCJUL - Julia using the generalized Pickover Popcorn formula: - x(0) = xpixel, y(0) = ypixel; - x(n+1) = x(n) - real(h * fn1( y(n) + fn2(C * y(n) )) - - imag(h * fn3( x(n) + fn4(C * x(n) )) - y(n+1) = y(n) - real(h * fn3( x(n) + fn4(C * x(n) )) - - imag(h * fn1( y(n) + fn2(C * y(n) )) - Parameters: step size h, C, functions fn1..4 (original: sin,tan,sin,tan). - -~OnlineFF -{=HT_MARTIN quadruptwo} -~Label=HF_QUADRUPTWO - Quadruptwo attractor from Michael Peters - orbit in two dimensions. - z(0) = y(0) = 0; - x(n+1) = y(n) - sign(x(n)) * sin(ln(abs(b*x(n)-c))) - * arctan(sqr(ln(abs(c*x(n)-b)))) - y(n+1) = a - x(n) - Parameters are a, b, and c. - -{=HT_QUAT quatjul} -~Label=HF_QUATJ - Quaternion Julia set. - q(0) = (xpixel,ypixel,zj,zk) - q(n+1) = q(n)*q(n) + c. - Four parameters: c, ci, cj, ck - c = (c1,ci,cj,ck) - -{=HT_QUAT quat} -~Label=HF_QUAT - Quaternion Mandelbrot set. - q(0) = (0,0,0,0) - q(n+1) = q(n)*q(n) + c. - Two parameters: cj,ck - c = (xpixel,ypixel,cj,ck) - -{=HT_ROSS rossler3D} -~Label=HF_ROSS - Orbit in three dimensions defined by: - x(0) = y(0) = z(0) = 1; - x(n+1) = x(n) - y(n)*dt - z(n)*dt - y(n+1) = y(n) + x(n)*dt + a*y(n)*dt - z(n+1) = z(n) + b*dt + x(n)*z(n)*dt - c*z(n)*dt - Parameters are dt, a, b, and c. - -{=HT_SIER sierpinski} -~Label=HF_SIER - Sierpinski gasket - Julia set producing a 'Swiss cheese triangle' - z(n+1) = (2*x,2*y-1) if y > .5; - else (2*x-1,2*y) if x > .5; - else (2*x,2*y) - No parameters. - -{=HT_SCOTSKIN spider} -~Label=HF_SPIDER - c(0) = z(0) = pixel; - z(n+1) = z(n)^2 + c(n); - c(n+1) = c(n)/2 + z(n+1) - Parameters: real & imaginary perturbation of z(0) - -{=HT_SCOTSKIN sqr(1/fn)} -~Label=HF_SQROVFN - z(0) = pixel; - z(n+1) = (1/fn(z(n))^2 - One parameter: the function fn. - -{=HT_SCOTSKIN sqr(fn)} -~Label=HF_SQRFN - z(0) = pixel; - z(n+1) = fn(z(n))^2 - One parameter: the function fn. - -{=HT_TEST test} -~Label=HF_TEST - 'test' point letting us (and you!) easily add fractal types via - the c module testpt.c. Default set up is a mandelbrot fractal. - Four parameters: user hooks (not used by default testpt.c). - -{=HT_SCOTSKIN tetrate} -~Label=HF_TETRATE - z(0) = c = pixel; - z(n+1) = c^z(n) - Parameters: real & imaginary perturbation of z(0) - -~OnlineFF -{=HT_MARTIN threeply} -~Label=HF_THREEPLY - Threeply attractor by Michael Peters - orbit in two dimensions. - z(0) = y(0) = 0; - x(n+1) = y(n) - sign(x(n)) * (abs(sin(x(n))*cos(b) - +c-x(n)*sin(a+b+c))) - y(n+1) = a - x(n) - Parameters are a, b, and c. - -{=HT_MARKS tim's_error} -~Label=HF_TIMSERR - A serendipitous coding error in marksmandelpwr brings to life - an ancient pterodactyl! (Try setting fn to sqr.) - z(0) = pixel, c = z(0) ^ (z(0) - 1): - tmp = fn(z(n)) - real(tmp) = real(tmp) * real(c) - imag(tmp) * imag(c); - imag(tmp) = real(tmp) * imag(c) - imag(tmp) * real(c); - z(n+1) = tmp + pixel; - Parameters: real & imaginary perturbations of z(0) and function fn - -~OnlineFF -{=HT_UNITY unity} -~Label=HF_UNITY - z(0) = pixel; - x = real(z(n)), y = imag(z(n)) - One = x^2 + y^2; - y = (2 - One) * x; - x = (2 - One) * y; - z(n+1) = x + i*y - No parameters. - -{=HT_VL volterra-lotka} -~Label=HF_VL - Volterra-Lotka fractal from The Beauty of Fractals - x(0) = xpixel, y(0) = ypixel; - dx/dt = x - xy = f(x,y) - dy/dt = -y + xy = g(x,y) - x(new) = x + h/2 * [ f(x,y) + f[x + pf(x,y), y + pg(x,y)] ] - y(new) = y + h/2 * [ g(x,y) + g[x + pf(x,y), y + pg(x,y)] ] - Two parameters: h and p - Recommended: zmag or bof60 inside coloring options - -~CompressSpaces+ -; -; -; -~Topic=Fractal Types - -A list of the fractal types and their mathematics can be found in the -{Summary of Fractal Types}. Some notes about how Fractint calculates -them are in "A Little Code" in {"Fractals and the PC"}. - -Fractint starts by default with the Mandelbrot set. You can change that by -using the command-line argument "TYPE=" followed by one of the -fractal type names, or by using the command and -selecting the type - if parameters are needed, you will be prompted for -them. - -In the text that follows, due to the limitations of the ASCII character -set, "a*b" means "a times b", and "a^b" means "a to the power b". - -~Doc- -Press for type selection list. -~FF -Select a fractal type: - -~Table=40 2 0 -{ The Mandelbrot Set } -{ Julia Sets } -{ Inverse Julias } -{ Newton domains of attraction } -{ Newton } -{ Complex Newton } -{ Lambda Sets } -{ Mandellambda Sets } -{ Plasma Clouds } -{ Lambdafn } -{ Mandelfn } -{ Barnsley Mandelbrot/Julia Sets } -{ Barnsley IFS Fractals } -{ Sierpinski Gasket } -{ Quartic Mandelbrot/Julia } -;{ Mandelbrot Mix 4 } -{ Distance Estimator } -{ Pickover Mandelbrot/Julia Types } -{ Pickover Popcorn } -{ Dynamic System } -{ Quaternion } -{ Peterson Variations } -{ Unity } -{ Circle } -{ Scott Taylor / Lee Skinner Variations } -{ Kam Torus } -{ Bifurcation } -{ Orbit Fractals } -{ Lorenz Attractors } -{ Rossler Attractors } -{ Henon Attractors } -{ Pickover Attractors } -{ Martin Attractors } -{ Gingerbreadman } -{ Test } -{ Formula } -{ Julibrots } -{ Diffusion Limited Aggregation } -{ Magnetic Fractals } -{ L-Systems } -{ Escher-Like Julia Sets } -{ Lyapunov Fractals } -{ fn||fn Fractals } -{ Halley } -{ Cellular Automata } -{ Phoenix } -{ Frothy Basins } -{ Icon } -{ Latoocarfian } -{ Hypercomplex } -~EndTable -~Doc+ -; -; -~Topic=The Mandelbrot Set, Label=HT_MANDEL -(type=mandel) - -This set is the classic: the only one implemented in many plotting -programs, and the source of most of the printed fractal images published -in recent years. Like most of the other types in Fractint, it is simply a -graph: the x (horizontal) and y (vertical) coordinate axes represent -ranges of two independent quantities, with various colors used to -symbolize levels of a third quantity which depends on the first two. So -far, so good: basic analytic geometry. - -Now things get a bit hairier. The x axis is ordinary, vanilla real -numbers. The y axis is an imaginary number, i.e. a real number times i, -where i is the square root of -1. Every point on the plane -- in this -case, your PC's display screen -- represents a complex number of the form: - - x-coordinate + i * y-coordinate - -If your math training stopped before you got to imaginary and complex -numbers, this is not the place to catch up. Suffice it to say that they -are just as "real" as the numbers you count fingers with (they're used -every day by electrical engineers) and they can undergo the same kinds of -algebraic operations. - -OK, now pick any complex number -- any point on the complex plane -- and -call it C, a constant. Pick another, this time one which can vary, and -call it Z. Starting with Z=0 (i.e., at the origin, where the real and -imaginary axes cross), calculate the value of the expression - - Z^2 + C - -Take the result, make it the new value of the variable Z, and calculate -again. Take that result, make it Z, and do it again, and so on: in -mathematical terms, iterate the function Z(n+1) = Z(n)^2 + C. For certain -values of C, the result "levels off" after a while. For all others, it -grows without limit. The Mandelbrot set you see at the start -- the solid- -colored lake (blue by default), the blue circles sprouting from it, and -indeed every point of that color -- is the set of all points C for which -the magnitude of Z is less than 2 after 150 iterations (150 is the default -setting, changeable via the options screen or "maxiter=" parameter). -All the surrounding "contours" of other colors represent points for which -the magnitude of Z exceeds 2 after 149 iterations (the contour closest to -the M-set itself), 148 iterations, (the next one out), and so on. - -We actually don't test for the magnitude of Z exceeding 2 - we test the -magnitude of Z squared against 4 instead because it is easier. This value -(FOUR usually) is known as the "bailout" value for the calculation, because -we stop iterating for the point when it is reached. The bailout value can -be changed on the options screen but the default is usually best. See -also {Bailout Test}. - -Some features of interest: - -1. Use the options screen to increase the maximum number of iterations. -Notice that the boundary of the M-set becomes more and more convoluted (the -technical terms are "wiggly," "squiggly," and "utterly bizarre") as the Z- -magnitudes for points that were still within the set after 150 iterations turn -out to exceed 2 after 200, 500, or 1200. In fact, it can be proven that -the true boundary is infinitely long: detail without limit. - -2. Although there appear to be isolated "islands" of blue, zoom in -- that -is, plot for a smaller range of coordinates to show more detail -- and -you'll see that there are fine "causeways" of blue connecting them to the -main set. As you zoomed, smaller islands became visible; the same is true -for them. In fact, there are no isolated points in the M-set: it is -"connected" in a strict mathematical sense. - -3. The upper and lower halves of the first image are symmetric (a fact -that Fractint makes use of here and in some other fractal types to speed -plotting). But notice that the same general features -- lobed discs, -spirals, starbursts -- tend to repeat themselves (although never exactly) -at smaller and smaller scales, so that it can be impossible to judge by -eye the scale of a given image. - -4. In a sense, the contour colors are window-dressing: mathematically, it -is the properties of the M-set itself that are interesting, and no -information about it would be lost if all points outside the set were -assigned the same color. If you're a serious, no-nonsense type, you may -want to cycle the colors just once to see the kind of silliness that other -people enjoy, and then never do it again. Go ahead. Just once, now. We -trust you. -; -; -~Topic=Julia Sets, Label=HT_JULIA -(type=julia) - -These sets were named for mathematician Gaston Julia, and can be generated -by a simple change in the iteration process described for the -{=HT_MANDEL Mandelbrot Set}. Start with a -specified value of C, "C-real + i * C-imaginary"; use as the initial value -of Z "x-coordinate + i * y-coordinate"; and repeat the same iteration, -Z(n+1) = Z(n)^2 + C. - -There is a Julia set corresponding to every point on the complex plane -- -an infinite number of Julia sets. But the most visually interesting tend -to be found for the same C values where the M-set image is busiest, i.e. -points just outside the boundary. Go too far inside, and the corresponding -Julia set is a circle; go too far outside, and it breaks up into scattered -points. In fact, all Julia sets for C within the M-set share the -"connected" property of the M-set, and all those for C outside lack it. - -Fractint's spacebar toggle lets you "flip" between any view of the M-set -and the Julia set for the point C at the center of that screen. You can -then toggle back, or zoom your way into the Julia set for a while and then -return to the M-set. So if the infinite complexity of the M-set palls, -remember: each of its infinite points opens up a whole new Julia set. - -Historically, the Julia sets came first: it was while looking at the M-set -as an "index" of all the Julia sets' origins that Mandelbrot noticed its -properties. - -The relationship between the {=HT_MANDEL Mandelbrot} set and Julia set can -hold between -other sets as well. Many of Fractint's types are "Mandelbrot/Julia" pairs -(sometimes called "M-sets" or "J-sets". All these are generated by -equations that are of the form z(k+1) = f(z(k),c), where the function -orbit is the sequence z(0), z(1), ..., and the variable c is a complex -parameter of the equation. The value c is fixed for "Julia" sets and is -equal to the first two parameters entered with the "params=Creal/Cimag" -command. The initial orbit value z(0) is the complex number corresponding -to the screen pixel. For Mandelbrot sets, the parameter c is the complex -number corresponding to the screen pixel. The value z(0) is c plus a -perturbation equal to the values of the first two parameters. See -the discussion of {=HT_MLAMBDA Mandellambda Sets}. -This approach may or may not be the -"standard" way to create "Mandelbrot" sets out of "Julia" sets. - -Some equations have additional parameters. These values are entered as the -third or fourth params= value for both Julia and Mandelbrot sets. The -variables x and y refer to the real and imaginary parts of z; similarly, -cx and cy are the real and imaginary parts of the parameter c and fx(z) -and fy(z) are the real and imaginary parts of f(z). The variable c is -sometimes called lambda for historical reasons. - -NOTE: if you use the "PARAMS=" argument to warp the M-set by starting with -an initial value of Z other than 0, the M-set/J-sets correspondence breaks -down and the spacebar toggle no longer works. -; -; -~Topic=Julia Toggle Spacebar Commands, Label=HELP_JIIM -The spacebar toggle has been enhanced for the classic Mandelbrot and Julia -types. When viewing the Mandelbrot, the spacebar turns on a window mode that -displays the Inverse Julia corresponding to the cursor position in a window. -Pressing the spacebar then causes the regular Julia escape time fractal -corresponding to the cursor position to be generated. The following keys -take effect in Inverse Julia mode. - - Generate the escape-time Julia Set corresponding to the cursor\ - position. Only works if fractal is a "Mandelbrot" type.\ - Numbers toggle - shows coordinates of the cursor on the\ - screen. Press again to turn off numbers.\ -

Enter new pixel coordinates directly\ - Hide fractal toggle. Works only if View Windows is turned on\ - and set for a small window (such as the default size.) Hides \ - the fractal, allowing the orbit to take up the whole screen. \ - Press again to uncover the fractal.\ - Saves the fractal, cursor, orbits, and numbers.\ -<<> or <,> Zoom inverse julia image smaller.\ -<>> or <.> Zoom inverse julia image larger.\ - Restore default zoom.\ - -The Julia Inverse window is only implemented for the classic Mandelbrot -(type=mandel). For other "Mandelbrot" types turns on the cursor -without the Julia window, and allows you to select coordinates of the -matching Julia set in a way similar to the use of the zoom box with the -Mandelbrot/Julia toggle in previous Fractint versions. -; -; -~Topic=Inverse Julias, Label=HT_INVERSE -(type=julia_inverse) - -Pick a function, such as the familiar Z(n) = Z(n-1) squared plus C -(the defining function of the Mandelbrot Set). If you pick a point Z(0) -at random from the complex plane, and repeatedly apply the function to it, -you get a sequence of new points called an orbit, which usually either -zips out toward infinity or zooms in toward one or more "attractor" points -near the middle of the plane. The set of all points that are "attracted" -to infinity is called the "Basin of Attraction" of infinity. Each of the -other attractors also has its own Basin of Attraction. Why is it called -a Basin? Imagine a lake, and all the water in it "draining" into the -attractor. The boundary between these basins is called the Julia Set of -the function. - -The boundary between the basins of attraction is sort of like a -repeller; all orbits move away from it, toward one of the attractors. -But if we define a new function as the inverse of the old one, as for -instance Z(n) = sqrt(Z(n-1) minus C), then the old attractors become -repellers, and the former boundary itself becomes the attractor! Now, -starting from any point, all orbits are drawn irresistibly to the Julia -Set! In fact, once an orbit reaches the boundary, it will continue to -hop about until it traces the entire Julia Set! This method for drawing -Julia Sets is called the Inverse Iteration Method, or IIM for short. - -Unfortunately, some parts of each Julia Set boundary are far more -attractive to inverse orbits than others are, so that as an orbit -traces out the set, it keeps coming back to these attractive parts -again and again, only occasionally visiting the less attractive parts. -Thus it may take an infinite length of time to draw the entire set. -To hasten the process, we can keep track of how many times each pixel -on our computer screen is visited by an orbit, and whenever an orbit -reaches a pixel that has already been visited more than a certain number -of times, we can consider that orbit finished and move on to another one. -This "hit limit" thus becomes similar to the iteration limit used in the -traditional escape-time fractal algorithm. This is called the Modified -Inverse Iteration Method, or MIIM, and is much faster than the IIM. - -Now, the inverse of Mandelbrot's classic function is a square root, and -the square root actually has two solutions; one positive, one negative. -Therefore at each step of each orbit of the inverse function there is -a decision; whether to use the positive or the negative square root. -Each one gives rise to a new point on the Julia Set, so each is a good -choice. This series of choices defines a binary decision tree, each -point on the Julia Set giving rise to two potential child points. -There are many interesting ways to traverse a binary tree, among them -Breadth first, Depth first (left or negative first), Depth first (right -or positive first), and completely at random. It turns out that most -traversal methods lead to the same or similar pictures, but that how the -image evolves as the orbits trace it out differs wildly depending on the -traversal method chosen. As far as we know, this fact is an original -discovery by Michael Snyder, and version 18.2 of FRACTINT was its first -publication. - -Pick a Julia constant such as Z(0) = (-.74543, .11301), the popular -Seahorse Julia, and try drawing it first Breadth first, then Depth first -(right first), Depth first (left first), and finally with Random Walk. - -Caveats: the video memory is used in the algorithm, to keep track of -how many times each pixel has been visited (by changing it's color). -Therefore the algorithm will not work well if you zoom in far enough that -part of the Julia Set is off the screen. - -Bugs: Not working with Disk Video. - Not resumeable. - -The key toggles between the Inverse Julia orbit and the -corresponding Julia escape time fractal. -; -; -~Topic=Newton domains of attraction, Label=HT_NEWTBAS -(type=newtbasin) - -The Newton formula is an algorithm used to find the roots of polynomial -equations by successive "guesses" that converge on the correct value as -you feed the results of each approximation back into the formula. It works -very well -- unless you are unlucky enough to pick a value that is on a -line BETWEEN two actual roots. In that case, the sequence explodes into -chaos, with results that diverge more and more wildly as you continue the -iteration. - -This fractal type shows the results for the polynomial Z^n - 1, which has -n roots in the complex plane. Use the ype command and enter "newtbasin" -in response to the prompt. You will be asked for a parameter, the "order" -of the equation (an integer from 3 through 10 -- 3 for x^3-1, 7 for x^7-1, -etc.). A second parameter is a flag to turn on alternating shades showing -changes in the number of iterations needed to attract an orbit. Some -people like stripes and some don't, as always, Fractint gives you a -choice! - -The coloring of the plot shows the "basins of attraction" for each root of -the polynomial -- i.e., an initial guess within any area of a given color -would lead you to one of the roots. As you can see, things get a bit weird -along certain radial lines or "spokes," those being the lines between -actual roots. By "weird," we mean infinitely complex in the good old -fractal sense. Zoom in and see for yourself. - -This fractal type is symmetric about the origin, with the number of -"spokes" depending on the order you select. It uses floating-point math if -you have an FPU, or a somewhat slower integer algorithm if you don't have -one. -~Doc- - -See also: {Newton} -~Doc+ -; -; -~Topic=Newton, Label=HT_NEWT -(type=newton) - -The generating formula here is identical to that for {=HT_NEWTBAS newtbasin}, -but the -coloring scheme is different. Pixels are colored not according to the root -that would be "converged on" if you started using Newton's formula from -that point, but according to the iteration when the value is close to a -root. For example, if the calculations for a particular pixel converge to -the 7th root on the 23rd iteration, NEWTBASIN will color that pixel using -color #7, but NEWTON will color it using color #23. - -If you have a 256-color mode, use it: the effects can be much livelier -than those you get with type=newtbasin, and color cycling becomes, like, -downright cosmic. If your "corners" choice is symmetrical, Fractint -exploits the symmetry for faster display. - -The applicable "params=" values are the same as newtbasin. Try "params=4." -Other values are 3 through 10. 8 has twice the symmetry and is faster. As -with newtbasin, an FPU helps. -; -; -~Topic=Complex Newton, Label=HT_NEWTCMPLX -(type=complexnewton/complexbasin) - -Well, hey, "Z^n - 1" is so boring when you can use "Z^a - b" where "a" and -"b" are complex numbers! The new "complexnewton" and "complexbasin" -fractal types are just the old {=HT_NEWT "newton"} and -{=HT_NEWTBAS "newtbasin"} fractal types with -this little added twist. When you select these fractal types, you are -prompted for four values (the real and imaginary portions of "a" and "b"). -If "a" has a complex portion, the fractal has a discontinuity along the -negative axis - relax, we finally figured out that it's *supposed* to be -there! -; -; -~Topic=Lambda Sets, Label=HT_LAMBDA -(type=lambda) - -This type calculates the Julia set of the formula lambda*Z*(1-Z). That is, -the value Z[0] is initialized with the value corresponding to each pixel -position, and the formula iterated. The pixel is colored according to the -iteration when the sum of the squares of the real and imaginary parts -exceeds 4. - -Two parameters, the real and imaginary parts of lambda, are required. Try -0 and 1 to see the classical fractal "dragon". Then try 0.2 and 1 for a -lot more detail to zoom in on. - -It turns out that all quadratic Julia-type sets can be calculated using -just the formula z^2+c (the "classic" Julia"), so that this type is -redundant, but we include it for reason of it's prominence in the history -of fractals. -; -; -~Topic=Mandellambda Sets, Label=HT_MLAMBDA -(type=mandellambda) - -This type is the "Mandelbrot equivalent" of the {=HT_LAMBDA lambda} set. -A comment is -in order here. Almost all the Fractint "Mandelbrot" sets are created from -orbits generated using formulas like z(n+1) = f(z(n),C), with z(0) and C -initialized to the complex value corresponding to the current pixel. Our -reasoning was that "Mandelbrots" are maps of the corresponding "Julias". -Using this scheme each pixel of a "Mandelbrot" is colored the same as the -Julia set corresponding to that pixel. However, Kevin Allen informs us -that the MANDELLAMBDA set appears in the literature with z(0) initialized -to a critical point (a point where the derivative of the formula is zero), -which in this case happens to be the point (.5,0). Since Kevin knows more -about Dr. Mandelbrot than we do, and Dr. Mandelbrot knows more about -fractals than we do, we defer! Starting with version 14 Fractint -calculates MANDELAMBDA Dr. Mandelbrot's way instead of our way. But ALL -THE OTHER "Mandelbrot" sets in Fractint are still calculated OUR way! -(Fortunately for us, for the classic Mandelbrot Set these two methods are -the same!) - -Well now, folks, apart from questions of faithfulness to fractals named in -the literature (which we DO take seriously!), if a formula makes a -beautiful fractal, it is not wrong. In fact some of the best fractals in -Fractint are the results of mistakes! Nevertheless, thanks to Kevin for -keeping us accurate! - -(See description of "initorbit=" command in {Image Calculation Parameters} -for a way to experiment with different orbit intializations). -; -; -~Topic=Circle, Label=HT_CIRCLE -(type=circle) - -This fractal types is from A. K. Dewdney's "Computer Recreations" column -in "Scientific American". It is attributed to John Connett of the -University of Minnesota. - -(Don't tell anyone, but this fractal type is not really a fractal!) - -Fascinating Moire patterns can be formed by calculating x^2 + y^2 for -each pixel in a piece of the complex plane. After multiplication by a -magnification factor (the parameter), the number is truncated to an integer -and mapped to a color via color = value modulo (number of colors). That is, -the integer is divided by the number of colors, and the remainder is the -color index value used. The resulting image is not a fractal because all -detail is lost after zooming in too far. Try it with different resolution -video modes - the results may surprise you! - -If inside=startrail is used, it will automatically be set to inside=norm by -Fractint. This is because type circle and inside=startrail locks up Fractint. -; -; -~Topic=Plasma Clouds, Label=HT_PLASMA -(type=plasma) - -Plasma clouds ARE real live fractals, even though we didn't know it at -first. They are generated by a recursive algorithm that randomly picks -colors of the corner of a rectangle, and then continues recursively -quartering previous rectangles. Random colors are averaged with those of -the outer rectangles so that small neighborhoods do not show much change, -for a smoothed-out, cloud-like effect. The more colors your video mode -supports, the better. The result, believe it or not, is a fractal -landscape viewed as a contour map, with colors indicating constant -elevation. To see this, save and view with the <3> command -(see {\"3D\" Images}) -and your "cloud" will be converted to a mountain! - -You've GOT to try {=@ColorCycling color cycling} on these (hit "+" or "-"). -If you -haven't been hypnotized by the drawing process, the writhing colors will -do it for sure. We have now implemented subliminal messages to exploit the -user's vulnerable state; their content varies with your bank balance, -politics, gender, accessibility to a Fractint programmer, and so on. A -free copy of Microsoft C to the first person who spots them. - -This type accepts four parameters. - -The first determines how abruptly the colors change. A value of .5 yields -bland clouds, while 50 yields very grainy ones. The default value is 2. - -The second determines whether to use the original algorithm (0) or a -modified one (1). The new one gives the same type of images but draws -the dots in a different order. It will let you see -what the final image will look like much sooner than the old one. - -The third determines whether to use a new seed for generating the -next plasma cloud (0) or to use the previous seed (1). - -The fourth parameter turns on 16-bit .POT output which provides much -smoother height gradations. This is especially useful for creating -mountain landscapes when using the plasma output with a ray tracer -such as POV-Ray. - -With parameter three set to 1, the next plasma cloud generated will be -identical to the previous but at whatever new resolution is desired. - -Zooming is ignored, as each plasma-cloud screen is generated randomly. - -The random number seed used for each plasma image is displayed on the - information screen, and can be entered with the command line -parameter "rseed=" to recreate a particular image. - -The algorithm is based on the Pascal program distributed by Bret Mulvey as -PLASMA.ARC. We have ported it to C and integrated it with Fractint's -graphics and animation facilities. This implementation does not use -floating-point math. The algorithm was modified starting with version 18 -so that the plasma effect is independent of screen resolution. - -Saved plasma-cloud screens are EXCELLENT starting images for fractal -"landscapes" created with the {\"3D\" commands}. -; -; -~Topic=Lambdafn, Label=HT_LAMBDAFN -(type=lambdafn) - -Function=[sin|cos|sinh|cosh|exp|log|sqr|...]) is specified with this type. -Prior to version 14, these types were lambdasine, lambdacos, lambdasinh, -lambdacos, and lambdaexp. Where we say "lambdasine" or some such below, -the good reader knows we mean "lambdafn with function=sin".) - -These types calculate the Julia set of the formula lambda*fn(Z), for -various values of the function "fn", where lambda and Z are both complex. -Two values, the real and imaginary parts of lambda, should be given in the -"params=" option. For the feathery, nested spirals of LambdaSines and the -frost-on-glass patterns of LambdaCosines, make the real part = 1, and try -values for the imaginary part ranging from 0.1 to 0.4 (hint: values near -0.4 have the best patterns). In these ranges the Julia set "explodes". For -the tongues and blobs of LambdaExponents, try a real part of 0.379 and an -imaginary part of 0.479. - -A coprocessor used to be almost mandatory: each LambdaSine/Cosine -iteration calculates a hyperbolic sine, hyperbolic cosine, a sine, and a -cosine (the LambdaExponent iteration "only" requires an exponent, sine, -and cosine operation)! However, Fractint now computes these -transcendental functions with fast integer math. In a few cases the fast -math is less accurate, so we have kept the old slow floating point code. -To use the old code, invoke with the float=yes option, and, if you DON'T -have a coprocessor, go on a LONG vacation! -; -; -~Topic=Halley, Label=HT_HALLEY -(type=halley) - -The Halley map is an algorithm used to find the roots of polynomial -equations by successive "guesses" that converge on the correct value as -you feed the results of each approximation back into the formula. It works -very well -- unless you are unlucky enough to pick a value that is on a -line BETWEEN two actual roots. In that case, the sequence explodes into -chaos, with results that diverge more and more wildly as you continue the -iteration. - -This fractal type shows the results for the polynomial Z(Z^a - 1), which -has a+1 roots in the complex plane. Use the ype command and enter -"halley" in response to the prompt. You will be asked for a parameter, the -"order" of the equation (an integer from 2 through 10 -- 2 for Z(Z^2 - 1), -7 for Z(Z^7 - 1), etc.). A second parameter is the relaxation coefficient, -and is used to control the convergence stability. A number greater than -one increases the chaotic behavior and a number less than one decreases the -chaotic behavior. The third parameter is the value used to determine when -the formula has converged. The test for convergence is -||Z(n+1)|^2 - |Z(n)|^2| < epsilon. This convergence test produces the -whisker-like projections which generally point to a root. -; -; -~Topic=Phoenix, Label=HT_PHOENIX -(type=phoenix, mandphoenix, phoenixcplx, mandphoenixclx) - -The phoenix type defaults to the original phoenix curve discovered by -Shigehiro Ushiki, "Phoenix", IEEE Transactions on Circuits and Systems, -Vol. 35, No. 7, July 1988, pp. 788-789. These images do not have the -X and Y axis swapped as is normal for this type. - -The mandphoenix type is the corresponding Mandelbrot set image of the -phoenix type. The spacebar toggles between the two as long as the -mandphoenix type has an initial z(0) of (0,0). The mandphoenix is not -an effective index to the phoenix type, so explore the wild blue yonder. - -To reproduce the Mandelbrot set image of the phoenix type as shown in -Stevens' book, "Fractal Programming in C", set initorbit=0/0 on the -command line or with the key. The colors need to be rotated one -position because Stevens uses the values from the previous calculation -instead of the current calculation to determine when to bailout. - -The phoenixcplx type is implemented using complex constants instead of the -real constants that Stevens used. This recreates the mapping as -originally presented by Ushiki. - -The mandphoenixclx type is the corresponding Mandelbrot set image of the -phoenixcplx type. The spacebar toggles between the two as long as the -mandphoenixclx type has a perturbation of z(0) = (0,0). The mandphoenixclx -is an effective index to the phoenixcplx type. -; -; -~Topic=fn||fn Fractals, Label=HT_FNORFN -(type=lambda(fn||fn), manlam(fn||fn), julia(fn||fn), mandel(fn||fn)) - -Two functions=[sin|cos|sinh|cosh|exp|log|sqr|...]) are specified with -these types. The two functions are alternately used in the calculation -based on a comparison between the modulus of the current Z and the -shift value. The first function is used if the modulus of Z is less -than the shift value and the second function is used otherwise. - -The lambda(fn||fn) type calculates the Julia set of the formula -lambda*fn(Z), for various values of the function "fn", where lambda -and Z are both complex. Two values, the real and imaginary parts of -lambda, should be given in the "params=" option. The third value is -the shift value. The space bar will generate the corresponding -"pseudo Mandelbrot" set, manlam(fn||fn). - -The manlam(fn||fn) type calculates the "pseudo Mandelbrot" set of the -formula fn(Z)*C, for various values of the function "fn", where C -and Z are both complex. Two values, the real and imaginary parts of -Z(0), should be given in the "params=" option. The third value is -the shift value. The space bar will generate the corresponding -julia set, lamda(fn||fn). - -The julia(fn||fn) type calculates the Julia set of the formula -fn(Z)+C, for various values of the function "fn", where C -and Z are both complex. Two values, the real and imaginary parts of -C, should be given in the "params=" option. The third value is -the shift value. The space bar will generate the corresponding -mandelbrot set, mandel(fn||fn). - -The mandel(fn||fn) type calculates the Mandelbrot set of the formula -fn(Z)+C, for various values of the function "fn", where C -and Z are both complex. Two values, the real and imaginary parts of -Z(0), should be given in the "params=" option. The third value is -the shift value. The space bar will generate the corresponding -julia set, julia(fn||fn). -; -; -~Topic=Mandelfn, Label=HT_MANDFN -(type=mandelfn) - -Function=[sin|cos|sinh|cosh|exp|log|sqr|...]) is specified with this type. -Prior to version 14, these types were mandelsine, mandelcos, mandelsinh, -mandelcos, and mandelexp. Same comment about our lapses into the old -terminology as above! - -These are "pseudo-Mandelbrot" mappings for the {=HT_LAMBDAFN LambdaFn} -Julia functions. -They map to their corresponding Julia sets via the spacebar command in -exactly the same fashion as the original M/J sets. In general, they are -interesting mainly because of that property (the function=exp set in -particular is rather boring). Generate the appropriate "Mandelfn" set, -zoom on a likely spot where the colors are changing rapidly, and hit the -spacebar key to plot the Julia set for that particular point. - -Try "FRACTINT TYPE=MANDELFN CORNERS=4.68/4.76/-.03/.03 FUNCTION=COS" for a -graphic demonstration that we're not taking Mandelbrot's name in vain -here. We didn't even know these little buggers were here until Mark -Peterson found this a few hours before the version incorporating Mandelfns -was released. - -Note: If you created images using the lambda or mandel "fn" types prior to -version 14, and you wish to update the fractal information in the "*.fra" -file, simply read the files and save again. You can do this in batch mode -via a command line such as: - - "fractint oldfile.fra savename=newfile.gif batch=yes" - -For example, this procedure can convert a version 13 "type=lambdasine" -image to a version 14 "type=lambdafn function=sin" GIF89a image. We do -not promise to keep this "backward compatibility" past version 14 - if you -want to keep the fractal information in your *.fra files accurate, we -recommend conversion. See {GIF Save File Format}. -; -; -~Topic=Barnsley Mandelbrot/Julia Sets, Label=HT_BARNS -(type=barnsleym1/.../j3) - -Michael Barnsley has written a fascinating college-level text, "Fractals -Everywhere," on fractal geometry and its graphic applications. (See -{Bibliography}.) In it, he applies the principle of the M and J -sets to more general functions of two complex variables. - -We have incorporated three of Barnsley's examples in Fractint. Their -appearance suggests polarized-light microphotographs of minerals, with -patterns that are less organic and more crystalline than those of the M/J -sets. Each example has both a "Mandelbrot" and a "Julia" type. Toggle -between them using the spacebar. - -The parameters have the same meaning as they do for the "regular" -Mandelbrot and Julia. For types M1, M2, and M3, they are used to "warp" -the image by setting the initial value of Z. For the types J1 through J3, -they are the values of C in the generating formulas. - -Be sure to try the rbit function while plotting these types. -; -; -~Topic=Barnsley IFS Fractals, Label=HT_IFS -(type=ifs) - -One of the most remarkable spin-offs of fractal geometry is the ability to -"encode" realistic images in very small sets of numbers -- parameters for -a set of functions that map a region of two-dimensional space onto itself. -In principle (and increasingly in practice), a scene of any level of -complexity and detail can be stored as a handful of numbers, achieving -amazing "compression" ratios... how about a super-VGA image of a forest, -more than 300,000 pixels at eight bits apiece, from a 1-KB "seed" file? - -Again, Michael Barnsley and his co-workers at the Georgia Institute of -Technology are to be thanked for pushing the development of these iterated -function systems (IFS). - -When you select this fractal type, Fractint scans the current IFS file -(default is FRACTINT.IFS, a set of definitions supplied with Fractint) for -IFS definitions, then prompts you for the IFS name you wish to run. Fern -and 3dfern are good ones to start with. You can press at the -selection screen if you want to select a different .IFS file you've -written. - -Note that some Barnsley IFS values generate images quite a bit smaller -than the initial (default) screen. Just bring up the zoom box, center it -on the small image, and hit to get a full-screen image. - -To change the number of dots Fractint generates for an IFS image before -stopping, you can change the "maximum iterations" parameter on the -options screen. - -Fractint supports two types of IFS images: 2D and 3D. In order to fully -appreciate 3D IFS images, since your monitor is presumably 2D, we have -added rotation, translation, and perspective capabilities. These share -values with the same variables used in Fractint's other 3D facilities; for -their meaning see {"Rectangular Coordinate Transformation"}. -You can enter these values from the command line using: - -rotation=xrot/yrot/zrot (try 30/30/30)\ -shift=xshift/yshift (shifts BEFORE applying perspective!)\ -perspective=viewerposition (try 200)\ - -Alternatively, entering from main screen will allow you to modify -these values. The defaults are the same as for regular 3D, and are not -always optimum for 3D IFS. With the 3dfern IFS type, try -rotation=30/30/30. Note that applying shift when using perspective changes -the picture -- your "point of view" is moved. - -A truly wild variation of 3D may be seen by entering "2" for the stereo -mode (see {"Stereo 3D Viewing"}), -putting on red/blue "funny glasses", and watching the fern develop -with full depth perception right there before your eyes! - -This feature USED to be dedicated to Bruce Goren, as a bribe to get him to -send us MORE knockout stereo slides of 3D ferns, now that we have made it -so easy! Bruce, what have you done for us *LATELY* ?? (Just kidding, -really!) - -Each line in an IFS definition (look at FRACTINT.IFS with your editor for -examples) contains the parameters for one of the generating functions, -e.g. in FERN: -~Format- - a b c d e f p - ___________________________________ - 0 0 0 .16 0 0 .01 - .85 .04 -.04 .85 0 1.6 .85 - .2 -.26 .23 .22 0 1.6 .07 --.15 .28 .26 .24 0 .44 .07 - -The values on each line define a matrix, vector, and probability: - matrix vector prob - |a b| |e| p - |c d| |f| -~Format+ - -The "p" values are the probabilities assigned to each function (how often -it is used), which add up to one. Fractint supports up to 32 functions, -although usually three or four are enough. - -3D IFS definitions are a bit different. The name is followed by (3D) in -the definition file, and each line of the definition contains 13 numbers: -a b c d e f g h i j k l p, defining: - matrix vector prob\ - |a b c| |j| p\ - |d e f| |k|\ - |g h i| |l|\ - -;You can experiment with changes to IFS definitions interactively by using -;Fractint's command. After selecting an IFS definition, hit to -;bring up the IFS editor. This editor displays the current IFS values, lets -;you modify them, and lets you save your modified values as a text file -;which you can then merge into an XXX.IFS file for future use with -;Fractint. -; -The program FDESIGN can be used to design IFS fractals - see -{=@FDESIGN FDESIGN}. - -You can save the points in your IFS fractal in the file ORBITS.RAW which is -overwritten each time a fractal is generated. The program Acrospin can -read this file and will let you view the fractal from any angle using -the cursor keys. See {=@ACROSPIN Acrospin}. -; -; -~Topic=Sierpinski Gasket, Label=HT_SIER -(type=sierpinski) - -Another pre-Mandelbrot classic, this one found by W. Sierpinski around -World War I. It is generated by dividing a triangle into four congruent -smaller triangles, doing the same to each of them, and so on, yea, even -unto infinity. (Notice how hard we try to avoid reiterating "iterating"?) - -If you think of the interior triangles as "holes", they occupy more and -more of the total area, while the "solid" portion becomes as hopelessly -fragile as that gasket you HAD to remove without damaging it -- you -remember, that Sunday afternoon when all the parts stores were closed? -There's a three-dimensional equivalent using nested tetrahedrons instead -of triangles, but it generates too much pyramid power to be safely -unleashed yet. - -There are no parameters for this type. We were able to implement it with -integer math routines, so it runs fairly quickly even without an FPU. -; -; -~Topic=Quartic Mandelbrot/Julia, Label=HT_MANDJUL4 -(type=mandel4/julia4) - -These fractal types are the moral equivalent of the original M and J sets, -except that they use the formula Z(n+1) = Z(n)^4 + C, which adds -additional pseudo-symmetries to the plots. The "Mandel4" set maps to the -"Julia4" set via -- surprise! -- the spacebar toggle. The M4 set is kind -of boring at first (the area between the "inside" and the "outside" of the -set is pretty thin, and it tends to take a few zooms to get to any -interesting sections), but it looks nice once you get there. The Julia -sets look nice right from the start. - -Other powers, like Z(n)^3 or Z(n)^7, work in exactly the same fashion. We -used this one only because we're lazy, and Z(n)^4 = (Z(n)^2)^2. -; -; -;~Topic=Mandelbrot Mix 4, Label=HT_MANDELBROTMIX4 -;(type=mandelbrotmix4) -; -;Jim Muth has been publishing a "Fractal of the Day" on the fractint mailing -;list for many years now. As often as not Jim picks the formula -;Mandelbrotmix4 as the fractal continent to explore. To honor Jim, the -;fractint authors have provided this fractal as a built-in type. -; -;The formula is: -; -;MandelbrotMix4 \{\; Jim Muth -;a=real(p1), b=imag(p1), d=real(p2), f=imag(p2), -;g=1/f, h=1/d, j=1/(f-b), z=(-a*b*g*h)^j, -;k=real(p3)+1, l=imag(p3)+100, c=fn1(pixel): -;z=k*((a*(z^b))+(d*(z^f)))+c, -;|z| < l \} -; -;Note that Jim uses l=imag(p3)+100, which is to say, the sixth scalar parameter, -;as the bailout. Our implementation follows Jim if the user requests -;the default bailout. -; -; -~Topic=Distance Estimator -(distest=nnn/nnn) - -This used to be type=demm and type=demj. These types have not died, but -are only hiding! They are equivalent to the mandel and julia types with -the "distest=" option selected with a predetermined value. - -The {Distance Estimator Method} -can be used to produce higher quality images of M and J sets, -especially suitable for printing in black and white. - -If you have some *.fra files made with the old types demm/demj, you may -want to convert them to the new form. See the {=HT_MANDFN Mandelfn} -section for directions to carry out the conversion. -; -; -~Topic=Pickover Mandelbrot/Julia Types, Label=HT_PICKMJ -(type=manfn+zsqrd/julfn+zsqrd, manzpowr/julzpowr, manzzpwr/julzzpwr, -manfn+exp/julfn+exp - formerly included man/julsinzsqrd and -man/julsinexp which have now been generalized) - -These types have been explored by Clifford A. Pickover, of the IBM Thomas -J. Watson Research center. As implemented in Fractint, they are regular -Mandelbrot/Julia set pairs that may be plotted with or without the -{=@Biomorphs "biomorph"} option Pickover used to create organic-looking -beasties (see -below). These types are produced with formulas built from the functions -z^z, z^n, sin(z), and e^z for complex z. Types with "power" or "pwr" in -their name have an exponent value as a third parameter. For example, -type=manzpower params=0/0/2 is our old friend the classical Mandelbrot, -and type=manzpower params=0/0/4 is the Quartic Mandelbrot. Other values of -the exponent give still other fractals. Since these WERE the original -"biomorph" types, we should give an example. Try: - - FRACTINT type=manfn+zsqrd biomorph=0 corners=-8/8/-6/6 function=sin - -to see a big biomorph digesting little biomorphs! -; -; -~Topic=Pickover Popcorn, Label=HT_POPCORN -(type=popcorn/popcornjul) - -Here is another Pickover idea. This one computes and plots the orbits of -the dynamic system defined by: - - x(n+1) = x(n) - real(h * fn1( y(n) + fn2(C * y(n) )) - - imag(h * fn3( x(n) + fn4(C * x(n) )) - y(n+1) = y(n) - real(h * fn3( x(n) + fn4(C * x(n) )) - - imag(h * fn1( y(n) + fn2(C * y(n) )) - -In the original the functions were: sin, tan, sin, tan, and C was 3. - -The initializers x(0) and y(0) equal to ALL the complex values within -the "corners" values, and h=.01. ALL these orbits are superimposed, -resulting in "popcorn" effect. You may want to use a maxiter value less -than normal - Pickover recommends a value of 50. Although you can zoom and -rotate popcorn, the results may not be what you'd expect, due to the -superimposing of orbits and arbitrary use of color. The orbits frequently -occur outside of the screen boundaries. To view the fractal in its entirety, -set the preview display to "yes" using the "V" command. - -As a bonus, type=popcornjul shows the Julia set generated by these same -equations with the usual escape-time coloring. Turn on orbit viewing with -the "O" command, and as you watch the orbit pattern you may get some insight -as to where the popcorn comes from. -; -; -~Topic=Dynamic System, Label=HT_DYNAM -(type=dynamic, dynamic2) - -These fractals are based on a cyclic system of differential equations: - x'(t) = -f(y(t))\ - y'(t) = f(x(t))\ -These equations are approximated by using a small time step dt, forming -a time-discrete dynamic system: - x(n+1) = x(n) - dt*f(y(n))\ - y(n+1) = y(n) + dt*f(x(n))\ -The initial values x(0) and y(0) are set to various points in the plane, -the dynamic system is iterated, and the resulting orbit points are plotted. - -In fractint, the function f is restricted to: - f(k) = sin(k + a*fn1(b*k)) -The parameters are the spacing of the initial points, the time step dt, -and the parameters (a,b,fn1) that affect the function f. -Normally the orbit points are plotted individually, but for a negative -spacing the points are connected. - -This fractal is similar to the {=HT_POPCORN Pickover Popcorn}. -~OnlineFF -A variant is the implicit Euler approximation: - y(n+1) = y(n) + dt*f(x(n))\ - x(n+1) = x(n) - dt*f(y(n+1))\ -This variant results in complex orbits. The implicit Euler approximation -is selected by entering dt<0. - -There are two options that have unusual effects on these fractals. The -Orbit Delay value controls how many initial points are computed before -the orbits are displayed on the screen. This allows the orbit to settle -down. The outside=summ option causes each pixel to increment color every -time an orbit touches it; the resulting display is a 2-d histogram. - -These fractals are discussed in Chapter 14 of Pickover's "Computers, -Pattern, Chaos, and Beauty". -; -; -~Topic=Mandelcloud, Label=HT_MANDELCLOUD -(type=mandelcloud) - -This fractal computes the Mandelbrot function, but displays it differently. -It starts with regularly spaced initial pixels and displays the resulting -orbits. This idea is somewhat similar to the {=HT_DYNAM Dynamic System}. - -There are two options that have unusual effects on this fractal. The -Orbit Delay value controls how many initial points are computed before -the orbits are displayed on the screen. This allows the orbit to settle -down. The outside=summ option causes each pixel to increment color every -time an orbit touches it; the resulting display is a 2-d histogram. - -This fractal was invented by Noel Giffin. - -; -; -~Topic=Peterson Variations, Label=HT_MARKS -(type=marksmandel, marksjulia, cmplxmarksmand, cmplxmarksjul, marksmandelpwr, -tim's_error) - -These fractal types are contributions of Mark Peterson. MarksMandel and -MarksJulia are two families of fractal types that are linked in the same -manner as the classic Mandelbrot/Julia sets: each MarksMandel set can be -considered as a mapping into the MarksJulia sets, and is linked with the -spacebar toggle. The basic equation for these sets is: - Z(n+1) = (lambda^(exp-1) * Z(n)^2) + lambda\ -where Z(0) = 0.0 and lambda is (x + iy) for MarksMandel. For MarksJulia, -Z(0) = (x + iy) and lambda is a constant (taken from the MarksMandel -spacebar toggle, if that method is used). The exponent is a positive -integer or a complex number. We call these "families" because each value -of the exponent yields a different MarksMandel set, which turns out to be -a kinda-polygon with (exponent) sides. The exponent value is the third -parameter, after the "initialization warping" values. Typically one would -use null warping values, and specify the exponent with something like -"PARAMS=0/0/5", which creates an unwarped, pentagonal MarksMandel set. - -In the process of coding MarksMandelPwr formula type, Tim Wegner -created the type "tim's_error" after making an interesting coding mistake. -; -; -~Topic=Unity, Label=HT_UNITY -(type=unity) - -This Peterson variation began with curiosity about other "Newton-style" -approximation processes. A simple one, - - One = (x * x) + (y * y); y = (2 - One) * x; x = (2 - One) * y; - -produces the fractal called Unity. - -One of its interesting features is the "ghost lines." The iteration loop -bails out when it reaches the number 1 to within the resolution of a -screen pixel. When you zoom a section of the image, the bailout criterion -is adjusted, causing some lines to become thinner and others thicker. - -Only one line in Unity that forms a perfect circle: the one at a radius of -1 from the origin. This line is actually infinitely thin. Zooming on it -reveals only a thinner line, up (down?) to the limit of accuracy for the -algorithm. The same thing happens with other lines in the fractal, such as -those around |x| = |y| = (1/2)^(1/2) = .7071 - -Try some other tortuous approximations using the {=HT_TEST TEST stub} and -let us know what you come up with! -; -; -~Topic=Scott Taylor / Lee Skinner Variations, Label=HT_SCOTSKIN -(type=fn(z*z), fn*fn, fn*z+z, fn+fn, fn+fn(pix), sqr(1/fn), sqr(fn), spider, -tetrate, manowar) - -Two of Fractint's faithful users went bonkers when we introduced the -"formula" type, and came up with all kinds of variations on escape-time -fractals using trig functions. We decided to put them in as regular -types, but there were just too many! So we defined the types with variable -functions and let you, the overwhelmed user, specify what the functions -should be! Thus Scott Taylor's "z = sin(z) + z^2" formula type is now the -"fn+fn" regular type, and EITHER function can be one of sin, cos, tan, cotan, -sinh, cosh, tanh, cotanh, exp, log, sqr, recip, ident, zero, one, conj, -flip, cosxx, asin, asinh, acos, acosh, atan, atanh, sqrt, abs, or cabs. - -Plus we give you 4 parameters to set, the complex -coefficients of the two functions! Thus the innocent-looking "fn+fn" type -is really 729 different types in disguise, not counting the damage -done by the parameters! - -Lee informs us that you should not judge fractals by their "outer" -appearance. For example, the images produced by z = sin(z) + z^2 and z = -sin(z) - z^2 look very similar, but are different when you zoom in. -; -; -~Topic=Kam Torus, Label=HT_KAM -(type=kamtorus, kamtorus3d) - -This type is created by superimposing orbits generated by a set of -equations, with a variable incremented each time. - - x(0) = y(0) = orbit/3;\ - x(n+1) = x(n)*cos(a) + (x(n)*x(n)-y(n))*sin(a)\ - y(n+1) = x(n)*sin(a) - (x(n)*x(n)-y(n))*cos(a)\ - -After each orbit, 'orbit' is incremented by a step size. The parameters -are angle "a", step size for incrementing 'orbit', stop value for 'orbit', -and points per orbit. Try this with a stop value of 5 with sound=x for -some weird fractal music (ok, ok, fractal noise)! You will also see the -KAM Torus head into some chaotic territory that Scott Taylor wanted to -hide from you by setting the defaults the way he did, but now we have -revealed all! - -The 3D variant is created by treating 'orbit' as the z coordinate. - -With both variants, you can adjust the "maxiter" value ( options -screen or parameter maxiter=) to change the number of orbits plotted. -; -; -~Topic=Bifurcation, Label=HT_BIF -(type=bifxxx) - -The wonder of fractal geometry is that such complex forms can arise from -such simple generating processes. A parallel surprise has emerged in the -study of dynamical systems: that simple, deterministic equations can yield -chaotic behavior, in which the system never settles down to a steady state -or even a periodic loop. Often such systems behave normally up to a -certain level of some controlling parameter, then go through a transition -in which there are two possible solutions, then four, and finally a -chaotic array of possibilities. - -This emerged many years ago in biological models of population growth. -Consider a (highly over-simplified) model in which the rate of growth is -partly a function of the size of the current population: - -New Population = Growth Rate * Old Population * (1 - Old Population) - -where population is normalized to be between 0 and 1. At growth rates less -than 200 percent, this model is stable: for any starting value, after -several generations the population settles down to a stable level. But for -rates over 200 percent, the equation's curve splits or "bifurcates" into -two discrete solutions, then four, and soon becomes chaotic. - -Type=bifurcation illustrates this model. (Although it's now considered a -poor one for real populations, it helped get people thinking about chaotic -systems.) The horizontal axis represents growth rates, from 190 percent -(far left) to 400 percent; the vertical axis normalized population values, -from 0 to 4/3. Notice that within the chaotic region, there are narrow -bands where there is a small, odd number of stable values. It turns out -that the geometry of this branching is fractal; zoom in where changing -pixel colors look suspicious, and see for yourself. - -Three parameters apply to bifurcations: Filter Cycles, Seed Population, -and Function or Beta. - -Filter Cycles (default 1000) is the number of iterations to be done before -plotting maxiter population values. This gives the iteration time to settle -into the characteristic patterns that constitute the bifurcation diagram, -and results in a clean-looking plot. However, using lower values produces -interesting results too. Set Filter Cycles to 1 for an unfiltered map. - -Seed Population (default 0.66) is the initial population value from which -all others are calculated. For filtered maps the final image is independent -of Seed Population value in the valid range (0.0 < Seed Population < 1.0). -~OnlineFF -Seed Population becomes effective in unfiltered maps - try setting Filter -Cycles to 1 (unfiltered) and Seed Population to 0.001 ("PARAMS=1/.001" on -the command line). This results in a map overlaid with nice curves. Each -Seed Population value results in a different set of curves. - -Function (default "ident") is the function applied to the old population -before the new population is determined. The "ident" function calculates -the same bifurcation fractal that was generated before these formulae -were generalized. - -Beta is used in the bifmay bifurcations and is the power to which the -denominator is raised. - -Note that fractint normally uses periodicity checking to speed up -bifurcation computation. However, in some cases a better quality image -will be obtained if you turn off periodicity checking with "periodicity=no"; -for instance, if you use a high number of iterations and a smooth -colormap. - -Many formulae can be used to produce bifurcations. Mitchel Feigenbaum -studied lots of bifurcations in the mid-70's, using a HP-65 calculator -(IBM PCs, Fractals, and Fractint, were all Sci-Fi then !). He studied -where bifurcations occurred, for the formula r*p*(1-p), the one described -above. He found that the ratios of lengths of adjacent areas of -bifurcation were four and a bit. These ratios vary, but, as the growth -rate increases, they tend to a limit of 4.669+. This helped him guess -where bifurcation points would be, and saved lots of time. - -When he studied bifurcations of r*sin(PI*p) he found a similar pattern, -which is not surprising in itself. However, 4.669+ popped out, again. -Different formulae, same number ? Now, THAT's surprising ! He tried many -other formulae and ALWAYS got 4.669+ - Hot Damn !!! So hot, in fact, that -he phoned home and told his Mom it would make him Famous ! He also went on -to tell other scientists. The rest is History... - -(It has been conjectured that if Feigenbaum had a copy of Fractint, and -used it to study bifurcations, he may never have found his Number, as it -only became obvious from long perusal of hand-written lists of values, -without the distraction of wild color-cycling effects !). -~OnlineFF -We now know that this number is as universal as PI or E. It appears in -situations ranging from fluid-flow turbulence, electronic oscillators, -chemical reactions, and even the Mandelbrot Set - yup, fraid so: -"budding" of the Mandelbrot Set along the negative real axis occurs at -intervals determined by Feigenbaum's Number, 4.669201660910..... - -Fractint does not make direct use of the Feigenbaum Number (YET !). -However, it does now reflect the fact that there is a whole sub-species of -Bifurcation-type fractals. Those implemented to date, and the related -formulae, (writing P for pop[n+1] and p for pop[n]) are : - -~Format- - bifurcation P = p + r*fn(p)*(1-fn(p)) Verhulst Bifurcations. - biflambda P = r*fn(p)*(1-fn(p)) Real equivalent of Lambda Sets. - bif+sinpi P = p + r*fn(PI*p) Population scenario based on... - bif=sinpi P = r*fn(PI*p) ...Feigenbaum's second formula. - bifstewart P = r*fn(p)*fn(p) - 1 Stewart Map. - bifmay P = r*p / ((1+p)^b) May Map. -~Format+ - -It took a while for bifurcations to appear here, despite them being over a -century old, and intimately related to chaotic systems. However, they are -now truly alive and well in Fractint! -; -; -~Topic=Orbit Fractals - -Orbit Fractals are generated by plotting an orbit path in two or three -dimensional space. - -See {Lorenz Attractors}, {Rossler Attractors}, -{Henon Attractors}, {Pickover Attractors}, {Gingerbreadman}, -and {Martin Attractors}. - -The orbit trajectory for these types can be saved in the file ORBITS.RAW -by invoking -Fractint with the "orbitsave=yes" command-line option. This file will -be overwritten each time you generate a new fractal, so rename it if you -want to save it. A nifty program called Acrospin can read these files and -rapidly rotate them in 3-D - see {=@ACROSPIN Acrospin}. -; -; -~Topic=Lorenz Attractors, Label=HT_LORENZ -(type=lorenz/lorenz3d) - -The "Lorenz Attractor" is a "simple" set of three deterministic equations -developed by Edward Lorenz while studying the non- repeatability of -weather patterns. The weather forecaster's basic problem is that even -very tiny changes in initial patterns ("the beating of a butterfly's -wings" - the official term is "sensitive dependence on initial -conditions") eventually reduces the best weather forecast to rubble. - -The lorenz attractor is the plot of the orbit of a dynamic system -consisting of three first order non-linear differential equations. The -solution to the differential equation is vector-valued function of one -variable. If you think of the variable as time, the solution traces an -orbit. The orbit is made up of two spirals at an angle to each other in -three dimensions. We change the orbit color as time goes on to add a -little dazzle to the image. The equations are: - - dx/dt = -a*x + a*y\ - dy/dt = b*x - y -z*x\ - dz/dt = -c*z + x*y\ - -We solve these differential equations approximately using a method known -as the first order taylor series. Calculus teachers everywhere will kill -us for saying this, but you treat the notation for the derivative dx/dt as -though it really is a fraction, with "dx" the small change in x that -happens when the time changes "dt". So multiply through the above -equations by dt, and you will have the change in the orbit for a small -time step. We add these changes to the old vector to get the new vector -after one step. This gives us: - - xnew = x + (-a*x*dt) + (a*y*dt)\ - ynew = y + (b*x*dt) - (y*dt) - (z*x*dt)\ - znew = z + (-c*z*dt) + (x*y*dt)\ - - (default values: dt = .02, a = 5, b = 15, c = 1)\ - -We connect the successive points with a line, project the resulting 3D -orbit onto the screen, and voila! The Lorenz Attractor! - -We have added two versions of the Lorenz Attractor. "Type=lorenz" is the -Lorenz attractor as seen in everyday 2D. "Type=lorenz3d" is the same set -of equations with the added twist that the results are run through our -perspective 3D routines, so that you get to view it from different angles -(you can modify your perspective "on the fly" by using the command.) -If you set the "stereo" option to "2", and have red/blue funny glasses on, -you will see the attractor orbit with depth perception. - -Hint: the default perspective values (x = 60, y = 30, z = 0) aren't the -best ones to use for fun Lorenz Attractor viewing. Experiment a bit - -start with rotation values of 0/0/0 and then change to 20/0/0 and 40/0/0 -to see the attractor from different angles.- and while you're at it, use a -non-zero perspective point Try 100 and see what happens when you get -*inside* the Lorenz orbits. Here comes one - Duck! While you are at it, -turn on the sound with the "X". This way you'll at least hear it coming! - -Different Lorenz attractors can be created using different parameters. -Four parameters are used. The first is the time-step (dt). The default -value is .02. A smaller value makes the plotting go slower; a larger value -is faster but rougher. A line is drawn to connect successive orbit values. -The 2nd, third, and fourth parameters are coefficients used in the -differential equation (a, b, and c). The default values are 5, 15, and 1. -Try changing these a little at a time to see the result. -; -; -~Topic=Rossler Attractors, Label=HT_ROSS -(type=rossler3D) - -This fractal is named after the German Otto Rossler, a non-practicing -medical doctor who approached chaos with a bemusedly philosophical -attitude. He would see strange attractors as philosophical objects. His -fractal namesake looks like a band of ribbon with a fold in it. All we can -say is we used the same calculus-teacher-defeating trick of multiplying -the equations by "dt" to solve the differential equation and generate the -orbit. This time we will skip straight to the orbit generator - if you -followed what we did above with type {=HT_LORENZ Lorenz} you can easily -reverse engineer the differential equations. - - xnew = x - y*dt - z*dt\ - ynew = y + x*dt + a*y*dt\ - znew = z + b*dt + x*z*dt - c*z*dt\ - -Default parameters are dt = .04, a = .2, b = .2, c = 5.7 -; -; -~Topic=Henon Attractors, Label=HT_HENON -(type=henon) - -Michel Henon was an astronomer at Nice observatory in southern France. He -came to the subject of fractals via investigations of the orbits of -astronomical objects. The strange attractor most often linked with -Henon's name comes not from a differential equation, but from the world of -discrete mathematics - difference equations. The Henon map is an example -of a very simple dynamic system that exhibits strange behavior. The orbit -traces out a characteristic banana shape, but on close inspection, the -shape is made up of thicker and thinner parts. Upon magnification, the -thicker bands resolve to still other thick and thin components. And so it -goes forever! The equations that generate this strange pattern perform the -mathematical equivalent of repeated stretching and folding, over and over -again. - - xnew = 1 + y - a*x*x\ - ynew = b*x\ - -The default parameters are a=1.4 and b=.3. -; -; -~Topic=Pickover Attractors, Label=HT_PICK -(type=pickover) - -Clifford A. Pickover of the IBM Thomas J. Watson Research center is such a -creative source for fractals that we attach his name to this one only with -great trepidation. Probably tomorrow he'll come up with another one and -we'll be back to square one trying to figure out a name! - -This one is the three dimensional orbit defined by: - - xnew = sin(a*y) - z*cos(b*x)\ - ynew = z*sin(c*x) - cos(d*y)\ - znew = sin(x)\ - -Default parameters are: a = 2.24, b = .43, c = -.65, d = -2.43 -; -; -~Topic=Gingerbreadman, Label=HT_GINGER -(type=gingerbreadman) - -This simple fractal is a charming example stolen from "Science of Fractal -Images", p. 149. - - xnew = 1 - y + |x|\ - ynew = x - -The initial x and y values are set by parameters, defaults x=-.1, y = 0. -; -; -~Topic=Martin Attractors, Label=HT_MARTIN -(type=hopalong/martin) - -These fractal types are from A. K. Dewdney's "Computer Recreations" column -in "Scientific American". They are attributed to Barry Martin of Aston -University in Birmingham, England. - -Hopalong is an "orbit" type fractal like lorenz. The image is obtained by -iterating this formula after setting z(0) = y(0) = 0:\ - x(n+1) = y(n) - sign(x(n))*sqrt(abs(b*x(n)-c))\ - y(n+1) = a - x(n)\ -Parameters are a, b, and c. The function "sign()" returns 1 if the argument -is positive, -1 if argument is negative. - -This fractal continues to develop in surprising ways after many iterations. - -Another Martin fractal is simpler. The iterated formula is:\ - x(n+1) = y(n) - sin(x(n))\ - y(n+1) = a - x(n)\ -The parameter is "a". Try values near the number pi. - -Michael Peters has based the HOP program on variations of these Martin types. -You will find three of these here: chip, quadruptwo, and threeply. -; -; -; -~Topic=Icon, Label=HT_ICON -(type=icon/icon3d) - - This fractal type was inspired by the book "Symmetry in Chaos" - by Michael Field and Martin Golubitsky (ISBN 0-19-853689-5, Oxford Press) - - To quote from the book's jacket, - - "Field and Golubitsky describe how a chaotic process eventually can - lead to symmetric patterns (in a river, for instance, photographs of - the turbulent movement of eddies, taken over time, often reveal - patterns on the average." - - The Icon type implemented here maps the classic population logistic - map of bifurcation fractals onto the complex plane in Dn symmetry. - - The initial points plotted are the more chaotic initial orbits, but - as you wait, delicate webs will begin to form as the orbits settle - into a more periodic pattern. Since pixels are colored by the number - of times they are hit, the more periodic paths will become clarified - with time. These fractals run continuously. - -There are 6 parameters: Lambda, Alpha, Beta, Gamma, Omega, and Degree - Omega 0 = Dn, or dihedral (rotation + reflectional) symmetry - !0 = Zn, or cyclic (rotational) symmetry - Degree = n, or Degree of symmetry -; -; -; -; -; New type include by Humberto R. Baptista, based on the -; Pickover book: Chaos In Wonderland -; -~Topic=Latoocarfian, Label=HT_LATOO -(type=latoocarfian) - -This fractal type first appeared in the book "Chaos in Wonderland" -by Clifford Pickover (ISBN 0-312-10743-9 St. Martin's Press) - -The Latoocarfians are beings that inhabit the moon Ganymede (of -Jupiter) and have their forms generated by these formulas. - -The initial points plotted are the more chaotic initial orbits, but -as you wait, delicate webs will begin to form as the orbits settle -into a more periodic pattern. Since pixels are colored by the number -of times they are hit, the more periodic paths will become clarified -with time. - -There are 4 parameters: a, b, c, d and we recomend: -a > -3, b < 3, c > 0.5, d < 1.5 -; -; -~Topic=Quaternion, Label=HT_QUAT -(type=quat,quatjul) - -These fractals are based on quaternions. Quaternions are an extension of -complex numbers, with 4 parts instead of 2. That is, a quaternion Q -equals a+ib+jc+kd, where a,b,c,d are reals. Quaternions have rules for -addition and multiplication. The normal Mandelbrot and Julia formulas -can be generalized to use quaternions instead of complex numbers. - -There is one complication. Complex numbers have 2 parts, so they can -be displayed on a plane. Quaternions have 4 parts, so they require 4 -dimensions to view. That is, the quaternion Mandelbrot set is actually a -4-dimensional object. Each quaternion C generates a 4-dimensional Julia set. - -One method of displaying the 4-dimensional object is to take a 3-dimensional -slice and render the resulting object in 3-dimensional perspective. -Fractint isn't that sophisticated, so it merely displays a 2-dimensional -slice of the resulting object. (Note: Now Fractint is that sophisticated! -See the Julibrot type!) - -In fractint, for the Julia set, you can specify the four parameters -of the quaternion constant: c=(c1,ci,cj,ck), but the 2-dimensional slice -of the z-plane Julia set is fixed to (xpixel,ypixel,0,0). - -For the Mandelbrot set, you can specify the position of the c-plane slice: -(xpixel,ypixel,cj,ck). - -These fractals are discussed in Chapter 10 of Pickover's "Computers, -Pattern, Chaos, and Beauty". - -See also {HyperComplex} and { Quaternion and Hypercomplex Algebra } - -; -; -~Topic=HyperComplex, Label=HT_HYPERC -(type=hypercomplex,hypercomplexj) - -These fractals are based on hypercomplex numbers, which like quaternions -are a four dimensional generalization of complex numbers. It is not -possible to fully generalize the complex numbers to four dimensions without -sacrificing some of the algebraic properties shared by real and complex -numbers. Quaternions violate the commutative law of multiplication, which -says z1*z2 = z2*z1. Hypercomplex numbers fail the rule that says all non-zero -elements have multiplicative inverses - that is, if z is not 0, there -should be a number 1/z such that (1/z)*(z) = 1. This law holds most of the -time but not all the time for hypercomplex numbers. - -However hypercomplex numbers have a wonderful property for fractal purposes. -Every function defined for complex numbers has a simple generalization -to hypercomplex numbers. Fractint's implementation takes advantage of this -by using "fn" variables - the iteration formula is\ - h(n+1) = fn(h(n)) + C.\ -where "fn" is the hypercomplex generalization of sin, cos, log, sqr etc. -~OnlineFF -You can see 3D versions of these fractals using fractal type Julibrot. -Hypercomplex numbers were brought to our attention by Clyde Davenport, -author of "A Hypercomplex Calculus with Applications to Relativity", -ISBN 0-9623837-0-8. - -See also {Quaternion} and { Quaternion and Hypercomplex Algebra } - -; -; - -~Topic=Cellular Automata, Label=HT_CELLULAR -(type=cellular) - -These fractals are generated by 1-dimensional cellular automata. Consider -a 1-dimensional line of cells, where each cell can have the value 0 or 1. -In each time step, the new value of a cell is computed from the old value -of the cell and the values of its neighbors. On the screen, each horizontal -row shows the value of the cells at any one time. The time axis proceeds -down the screen, with each row computed from the row above. - -Different classes of cellular automata can be described by how many different -states a cell can have (k), and how many neighbors on each side are examined -(r). Fractint implements the binary nearest neighbor cellular automata -(k=2,r=1), the binary next-nearest neighbor cellular automata (k=2,r=2), -and the ternary nearest neighbor cellular automata (k=3,r=1) and several -others. - -The rules used here determine the next state of a given cell by using the -sum of the states in the cell's neighborhood. The sum of the cells in the -neighborhood are mapped by rule to the new value of the cell. For the -binary nearest neighbor cellular automata, only the closest neighbor on -each side is used. This results in a 4 digit rule controlling the -generation of each new line: if each of the cells in the neighborhood is -1, the maximum sum is 1+1+1 = 3 and the sum can range from 0 to 3, or 4 -values. This results in a 4 digit rule. For instance, in the rule 1010, -starting from the right we have 0->0, 1->1, 2->0, 3->1. If the cell's -neighborhood sums to 2, the new cell value would be 0. - -For the next-nearest cellular automata (kr = 22), each pixel is determined -from the pixel value and the two neighbors on each side. This results in -a 6 digit rule. - -For the ternary nearest neighbor cellular automata (kr = 31), each cell -can have the value 0, 1, or 2. A single neighbor on each side is examined, -resulting in a 7 digit rule. - - kr #'s in rule example rule | kr #'s in rule example rule\ - 21 4 1010 | 42 16 2300331230331001\ - 31 7 1211001 | 23 8 10011001\ - 41 10 3311100320 | 33 15 021110101210010\ - 51 13 2114220444030 | 24 10 0101001110\ - 61 16 3452355321541340 | 25 12 110101011001\ - 22 6 011010 | 26 14 00001100000110\ - 32 11 21212002010 | 27 16 0010000000000110\ - -The starting row of cells can be set to a pattern of up to 16 digits or to a -random pattern. The borders are set to zeros if a pattern is entered or are -set randomly if the starting row is set randomly. - -A zero rule will randomly generate the rule to use. - -Hitting the space bar toggles between continuously generating the cellular -automata and stopping at the end of the current screen. - -Recommended reading: -"Computer Software in Science and Mathematics", Stephen Wolfram, Scientific -American, September, 1984. -"Abstract Mathematical Art", Kenneth E. Perry, BYTE, December, 1986. -"The Armchair Universe", A. K. Dewdney, W. H. Freeman and Company, 1988. -"Complex Patterns Generated by Next Nearest Neighbors Cellular Automata", -Wentian Li, Computers & Graphics, Volume 13, Number 4. -; -; -~Topic=Ant Automaton, Label=HT_ANT -(type=ant) - -This fractal type is the generalized Ant Automaton described in the "Computer -Recreations" column of the July 1994 Scientific American. The article -attributes this automaton to Greg Turk of Stanford University, Leonid A. -Bunivomitch of the Georgia Institute of Technology, and S. E. Troubetzkoy of -the University of Bielefeld. - -The ant wanders around the screen, starting at the middle. A rule string, -which the user can input as Fractint's first parameter, determines the ant's -direction. This rule string is stored as a double precision number in our -implementation. Only the digit 1 is significant -- all other digits are -treated as 0. When the type 1 ant leaves a cell (a pixel on the screen) of -color k, it turns right if the kth symbol in the rule string is a 1, or left -otherwise. Then the color in the abandoned cell is incremented. The type 2 -ant uses only the rule string to move around. If the digit of the rule string -is a 1, the ant turns right and puts a zero in current cell, otherwise it -turns left and put a number in the current cell. An empty rule string causes -the rule to be generated randomly. - -Fractint's 2nd parameter is a maximum iteration to guarantee that the fractal -will terminate. - -The 3rd parameter is the number of ants (up to 256). If you select 0 ants, -then the number oif ants is random. - -The 4th paramter allows you to select ant type 1 (the original), or type 2. - -The 5th parameter determines whether the ant's progress stops when the edge -of the screen is reaches (as in the original implementation), or whether the -ant's path wraps to the opposite side of the screen. You can slow down the -ant to see her better using the

screen Orbit Delay - try 10. - -The 6th parameter accepts a random seed, allowing you to duplicate images -using random values (empty rule string or 0 maximum ants. - -Try rule string 10. In this case, the ant moves in a seemingly random pattern, -then suddenly marches off in a straight line. This happens for many other -rule strings. The default 1100 produces symmetrical images. - -If the screen initially contains an image, the path of the ant changes. To -try this, generate a fractal, and press . Note that images -seeded with an image are not (yet) reproducible in PAR files. When started -using the keys, after the ant is finished the default fractal -type reverts to that of the underlying fractal. - -~Label=ANTCOMMANDS -Special keystrokes are in effect during the ant's march. The key -toggles a step-by-step mode. When in this mode, press to see each step -of the ant's progress. When orbit delay (on

screen) is set to 1, the step -mode is the default. - -If you press the right or left arrow during the ant's journey, you can -adjust the orbit delay factor with the arrow keys (increment by 10) or -ctrl-arrow keys (increment by 100). Press any other key to get out of the -orbit delay adjustment mode. Higher values cause slower motion. Changed values -are not saved after the ant is finished, but you can set the orbit delay -value in advance from the

screen. -; -; -; -~Topic=Test, Label=HT_TEST -(type=test) - -This is a stub that we (and you!) use for trying out new fractal types. -"Type=test" fractals make use of Fractint's structure and features for -whatever code is in the routine 'testpt()' (located in the small source -file TESTPT.C) to determine the color of a particular pixel. - -If you have a favorite fractal type that you believe would fit nicely into -Fractint, just rewrite the C function in TESTPT.C (or use the prototype -function there, which is a simple M-set implementation) with an algorithm -that computes a color based on a point in the complex plane. - -After you get it working, send your code to one of the authors and we -might just add it to the next release of Fractint, with full credit to -you. Our criteria are: 1) an interesting image and 2) a formula -significantly different from types already supported. (Bribery may also -work. THIS author is completely honest, but I don't trust those other -guys.) Be sure to include an explanation of your algorithm and the -parameters supported, preferably formatted as you see here to simplify -folding it into the documentation. -; -; -~Topic=Formula, Label=HT_FORMULA -(type=formula) - -This is a "roll-your-own" fractal interpreter - you don't even need a -compiler! - -To run a "type=formula" fractal, you first need a text file containing -formulas (there's a sample file - FRACTINT.FRM - included with this -distribution). When you select the "formula" fractal type, Fractint scans -the current formula file (default is FRACTINT.FRM) for formulas, then -prompts you for the formula name you wish to run. After prompting for any -parameters, the formula is parsed for syntax errors and then the fractal -is generated. If you want to use a different formula file, press when -you are prompted to select a formula name. - -There are two command-line options that work with type=formula -("formulafile=" and "formulaname="), useful when you are using this -fractal type in batch mode. - -The following documentation is supplied by Mark Peterson, who wrote the -formula interpreter: - -Formula fractals allow you to create your own fractal formulas. The -general format is: - - Mandelbrot(XAXIS) \{ z = Pixel: z = sqr(z) + pixel, |z| <= 4 \}\ - | | | | |\ - Name Symmetry Initial Iteration Bailout\ - Condition Criteria\ - -Initial conditions are set, then the iterations performed while the -bailout criteria remains true or until 'z' turns into a periodic loop. -All variables are created automatically by their usage and treated as -complex. If you declare 'v = 2' then the variable 'v' is treated as a -complex with an imaginary value of zero. - -NOTE: For periodicity checking, inside options, outside options, and -the passes=o option to work correctly it is necessary to leave the result -of the orbit calculation in the variable z. - -~OnlineFF -Sequential processing of the formula can be altered with the flow control\ -instructions - - IF(expr1)\ - statements\ - ELSEIF(expr2)\ - statements\ - .\ - .\ - ELSEIF(exprn)\ - statements\ - ELSE\ - statements\ - ENDIF\ - -where the expressions are evaluated and the statements executed are those\ -immediately following the first "true" expression (the real part of the\ -complex variable being nonzero). Nesting of IF..ENDIF blocks is permitted.\ - -~OnlineFF -~Format- - Predefined Variables (x, y) - -------------------------------------------- - z used for periodicity checking - p1 parameters 1 and 2 - p2 parameters 3 and 4 - p3 parameters 5 and 6 - p4 parameters 7 and 8 - p5 parameters 9 and 10 - pixel complex coordinates - LastSqr Modulus from the last sqr() function - rand Complex random number - pi (3.14159..., 0.0) - e (2.71828..., 0.0) - maxit (maxit, 0) maximum iterations - scrnmax (xdots, ydots) max horizontal/vertical resolution. - e.g. for SF7 scrnmax = (1024,768) - scrnpix (col, row) pixel screen coordinates. (col, row) ranges - from (0,0) to (xdots-1, ydots-1) - whitesq ((col+row) modulo 2, 0) i.e. thinking of the screen - coordinates as a large checker board, whitesq is (1,0) - for the white squares and (0,0) for the black ones. -~OnlineFF - Predefined Variables (Continued) - -------------------------------------------- - ismand 1 (true) by default, changes to 0 when the Mandelbrot/ - Julia SPACE toggle is pressed. This allows writing - formulas that have both "Mandelbrot" and "Julia" behavior. -~LABEL=@PREDEFCENTERMAG - center Zoom box (Xcenter, Ycenter) (see {=@CENTERMAG center-mag}) - magxmag Zoom box (Mag, Xmagnitude) (see {=@CENTERMAG center-mag}) - rotskew Zoom box (Rotation, Skew) (see {=@CENTERMAG center-mag}) - - Precedence - -------------------------------------------- - 1 sin(), cos(), sinh(), cosh(), cosxx(), tan(), cotan(), - tanh(), cotanh(), sqr(), log(), exp(), abs(), conj(), - real(), imag(), flip(), fn1(), fn2(), fn3(), fn4(), - srand(), asin(), asinh(), acos(), acosh(), atan(), - atanh(), sqrt(), cabs(), floor(), ceil(), trunc(), - round() - 2 - (negation), ^ (power) - 3 * (multiplication), / (division) - 4 + (addition), - (subtraction) - 5 = (assignment) -~OnlineFF - Precedence (Continued) - -------------------------------------------- - 6 < (less than), <= (less than or equal to) - > (greater than), >= (greater than or equal to) - == (equal to), != (not equal to) - 7 && (logical AND), || (logical OR) -~Format+ -Precedence may be overridden by use of parenthesis. Note the modulus squared -operator |z| is also parenthetic and always sets the imaginary component to -zero. This means 'c * |z - 4|' first subtracts 4 from z, calculates the -modulus squared then multiplies times 'c'. Nested modulus squared operators -require overriding parenthesis: - - c * |z + (|pixel|)|\ - -The functions fn1(...) to fn4(...) are variable functions - when used, -the user is prompted at run time (on the screen) to specify one of -sin, cos, sinh, cosh, exp, log, sqr, etc. for each required variable function. - -Most of the functions have their conventional meaning, here are a few notes on -others that are not conventional. -~Format- - abs() - returns abs(x)+i*abs(y) - |x+iy| - returns x*x+y*y - cabs() - returns sqrt(x*x+y*y) - conj() - returns the complex conjugate of the argument. That is, changes - sign of the imaginary component of argument: (x,y) becomes (x,-y) - cosxx() - duplicates a bug in the version 16 cos() function - flip() - Swap the real and imaginary components of the complex number. - e.g. (4,5) would become (5,4) - ident() - identity function. Leaves the value of the argument unchanged, - acting like a "z" term in a formula. - zero() - returns 0. - one() - returns 1. - floor() - largest integer not greater than the argument - floor(x+iy) = floor(x) + i*floor(y) - ceil() - smallest integer not less than the argument - trunc() - truncate fraction part toward zero - round() - round to nearest integer or up. e.g. round(2.5,3.4) = (3,3) -~Format+ - -The formulas are performed using either integer or floating point -mathematics depending on the floating point toggle. If you do not -have an FPU then type MPC math is performed in lieu of traditional -floating point. - -The 'rand' predefined variable is changed with each iteration to a new -random number with the real and imaginary components containing a value -between zero and 1. Use the srand() function to initialize the random -numbers to a consistent random number sequence. If a formula does not -contain the srand() function, then the formula compiler will use the system -time to initialize the sequence. This could cause a different fractal to be -generated each time the formula is used depending on how the formula is -written. - -A formula containing one of the predefined variables "maxit", "scrnpix" or -"scrnmax" will be automatically run in floating point mode. - -The rounding functions must be used cautiously; formulas that depend on -exact values of numbers will not work reliably in all cases. For example, -in floating point mode, trunc(6/3) returns 1 while trunc(6/real(3)) returns -2.\ -Note that if x is an integer, floor(x) = ceil(x) = trunc(x) = round(x) = x. - -Remember that when using integer math there is a limited dynamic range, so -what you think may be a fractal could really be just a limitation of the -integer math range. God may work with integers, but God's dynamic range is -many orders of magnitude greater than our puny 32 bit mathematics! Always -verify with the floating point toggle. -~OnlineFF -The possible values for symmetry are:\ -XAXIS, XAXIS_NOPARM\ -YAXIS, YAXIS_NOPARM\ -XYAXIS, XYAXIS_NOPARM\ -ORIGIN, ORIGIN_NOPARM\ -PI_SYM, PI_SYM_NOPARM\ -XAXIS_NOREAL\ -XAXIS_NOIMAG\ - -These will force the symmetry even if no symmetry is actually present, so try -your formulas without symmetry before you use these. - -For mathematical formulas of functions used in the parser language, see\ -{ Trig Identities} -; -; -~Topic=Frothy Basins, Label=HT_FROTH -(type=frothybasin) - -Frothy Basins, or Riddled Basins, were discovered by James C. Alexander of -the University of Maryland. The discussion below is derived from a two page -article entitled "Basins of Froth" in Science News, November 14, 1992 and -from correspondence with others, including Dr. Alexander. - -The equations that generate this fractal are not very different from those -that generate many other orbit fractals. - -~Format- - Z(0) = pixel; - Z(n+1) = Z(n)^2 - C*conj(Z(n)) - where C = 1 + A*i -~Format+ - -One of the things that makes this fractal so interesting is the shape of -the dynamical system's attractors. It is not at all uncommon for a -dynamical system to have non-point attractors. Shapes such as circles are -very common. Strange attractors are attractors which are themselves -fractal. What is unusual about this system, however, is that the -attractors intersect. This is the first case in which such a phenomenon -has been observed. The attractors for this system are made up of line -segments which overlap to form an equilateral triangle. This attractor -triangle can be seen by using the "show orbits" option (the 'o' key) or -the "orbits window" option (the ctrl-'o' key). - -The number of attractors present is dependant on the value of A, the -imaginary part of C. For values where A <= 1.028713768218725..., there -are three attractors. When A is larger than this critical value, two of -attractors merge into one, leaving only two attractors. An interesting -variation on this fractal can be generated by applying the above mapping -twice per each iteration. The result is that some of the attractors are -split into two parts, giving the system either six or three attractors, -depending on whether A is less than or greater than the critical value. - -These are also called "Riddled Basins" because each basin is riddled with -holes. Which attractor a point is eventually pulled into is extremely -sensitive to its initial position. A very slight change in any direction -may cause it to end up on a different attractor. As a result, the basins -are thoroughly intermingled. The effect appears to be a frothy mixture that -has been subjected to lots of stirring and folding. - -Pixel color is determined by which attractor captures the orbit. The shade -of color is determined by the number of iterations required to capture the -orbit. In Fractint, the actual shade of color used depends on how many -colors are available in the video mode being used. If 256 colors are -available, the default coloring scheme is determined by the number of -iterations that were required to capture the orbit. An alternative -coloring scheme can be used where the shade is determined by the -iterations required divided by the maximum iterations. This method is -especially useful on deeply zoomed images. If only 16 colors are -available, then only the alternative coloring scheme is used. If fewer -than 16 colors are available, then Fractint just colors the basins without -any shading. -; -; -~Topic=Julibrots, Label=HT_JULIBROT -(type=julibrot) - -The Julibrot fractal type uses a general-purpose renderer for visualizing -three dimensional solid fractals. Originally Mark Peterson developed -this rendering mechanism to view a 3-D sections of a 4-D structure he -called a "Julibrot". This structure, also called "layered Julia set" in -the fractal literature, hinges on the relationship between the Mandelbrot -and Julia sets. Each Julia set is created using a fixed value c in the -iterated formula z^2 + c. The Julibrot is created by layering Julia sets -in the x-y plane and continuously varying c, creating new Julia sets as z is -incremented. The solid shape thus created is rendered by shading the surface -using a brightness inversely proportional to the virtual viewer's eye. - -Starting with Fractint version 18, the Julibrot engine can be used -with other Julia formulas besides the classic z^2 + c. The first field on -the Julibrot parameter screen lets you select which orbit formula to use. - -You can also use the Julibrot renderer to visualize 3D cross sections of -true four dimensional Quaternion and Hypercomplex fractals. - -The Julibrot Parameter Screens - -Orbit Algorithm - select the orbit algorithm to use. The available - possibilities include 2-D Julia and both mandelbrot and Julia variants - of the 4-D Quaternion and Hypercomplex fractals. - -Orbit parameters - the next screen lets you fill in any parameters - belonging to the orbit algorithm. This list of parameters is not - necessarily the same as the list normally presented for the orbit - algorithm, because some of these parameters are used in the Julibrot - layering process. - - From/To Parameters - These parameters allow you to specify the "Mandelbrot" values used to - generate the layered Julias. The parameter c in the Julia formulas will - be incremented in steps ranging from the "from" x and y values to the - "to" x and y values. If the orbit formula is one of the "true" four - dimensional fractal types quat, quatj, hypercomplex, or hypercomplexj, - then these numbers are used with the 3rd and 4th dimensional values. - - The "from/to" variables are different for the different kinds of orbit - algorithm. - -~Format- - 2D Julia sets - complex number formula z' = f(z) + c - The "from/to" parameters change the values of c. - 4D Julia sets - Quaternion or Hypercomplex formula z' = f(z) + c - The four dimensions of c are set by the orbit parameters. - The first two dimensions of z are determined by the corners values. - The third and fourth dimensions of z are the "to/from" variables. - 4D Mandelbrot sets - Quaternion or Hypercomplex formula z' = f(z) + c - The first two dimensions of c are determined by the corners values. - The third and fourth dimensions of c are the "to/from" variables. -~Format+ - -Distance between the eyes - set this to 2.5 if you want a red/blue - anaglyph image, 0 for a normal greyscale image. - -Number of z pixels - this sets how many layers are rendered in the screen - z-axis. Use a higher value with higher resolution video modes. - -The remainder of the parameters are needed to construct the red/blue -picture so that the fractal appears with the desired depth and proper 'z' -location. With the origin set to 8 inches beyond the screen plane and the -depth of the fractal at 8 inches the default fractal will appear to start -at 4 inches beyond the screen and extend to 12 inches if your eyeballs are -2.5 inches apart and located at a distance of 24 inches from the screen. -The screen dimensions provide the reference frame. - -; -; -~Topic=Diffusion Limited Aggregation, Label=HT_DIFFUS -(type=diffusion) - -Standard diffusion begins with a single point in the center of the -screen. Subsequent points move around randomly until coming into -contact with a point already on the screen, at which time their -locations are fixed and they are drawn. This process repeats until -the fractals reaches the edge of the screen. Use the show orbits -function to see the points' random motion. - -One unfortunate problem is that on a large screen, this process will -tend to take eons. To speed things up, the points are restricted to a box -around the initial point. The first parameter to diffusion contains the -size of the border between the fractal and the edge of the box. If you -make this number small, the fractal will look more solid and will be -generated more quickly. - -The second parameter to diffusion changes the type of growth. If -you set it to 1, then the diffusion will start with a line along the -bottom of the screen. Points will appear above this line and the -fractal will grow upward. For this fractal, the points are -restricted to a box which is as wide as the screen but whose -distance from the fractal is given by the border size (the first -parameter). Initial points are released from a centered segment -along the top of this box which has a width equal to twice the -border size. - -If the second parameter is set to 2, then diffusion begins with a -square box on the screen. Points appear on a circle inside the box -whose distance from the box is equal to the border size. This -fractal grows very slowly since the points are not restricted to a -small box. - -The third and last parameter for diffusion controls the color of the -fractal. If it is set to zero then points are colored randomly. -Otherwise, it tells how often to shift the color of the points being -deposited. If you set it to 150, for example, then the color of the -points will shift every 150 points leading to a radial color pattern -if you are using the standards diffusion type. - -Diffusion was inspired by a Scientific American article a couple of -years back which includes actual pictures of real physical phenomena -that behave like this. - -Thanks to Adrian Mariano for providing the diffusion code and -documentation. Juan J. Buhler added additional options. -; -; -~Topic=Lyapunov Fractals, Label=HT_LYAPUNOV -(type=lyapunov) - -The Bifurcation fractal illustrates what happens in a simple population -model as the growth rate increases. The Lyapunov fractal expands that model -into two dimensions by letting the growth rate vary in a periodic fashion -between two values. Each pair of growth rates is run through a logistic -population model and a value called the Lyapunov Exponent is calculated for -each pair and is plotted. The Lyapunov Exponent is calculated by adding up -log | r - 2*r*x| over many cycles of the population model and dividing by the -number of cycles. Negative Lyapunov exponents indicate a stable, periodic -behavior and are plotted in color. Positive Lyapunov exponents indicate -chaos (or a diverging model) and are colored black. - -Order parameter. -Each possible periodic sequence yields a two dimensional space to explore. -The Order parameter selects a sequence. The default value 0 represents the -sequence ab which alternates between the two values of the growth parameter. -On the screen, the a values run vertically and the b values run -horizontally. Here is how to calculate the space parameter for any desired -sequence. Take your sequence of a's and b's and arrange it so that it starts -with at least 2 a's and ends with a b. It may be necessary to rotate the -sequence or swap a's and b's. Strike the first a and the last b off the list -and replace each remaining a with a 1 and each remaining b with a zero. -Interpret this as a binary number and convert it into decimal. - -An Example. -I like sonnets. A sonnet is a poem with fourteen lines that has the -following rhyming sequence: abba abba abab cc. Ignoring the rhyming couplet -at the end, let's calculate the Order parameter for this pattern. - - abbaabbaabab doesn't start with at least 2 a's \ - aabbaabababb rotate it \ - 1001101010 drop the first and last, replace with 0's and 1's \ - 512+64+32+8+2 = 618 - -An Order parameter of 618 gives the Lyapunov equivalent of a sonnet. "How do -I make thee? Let me count the ways..." - -Population Seed. -When two parts of a Lyapunov overlap, which spike overlaps which is strongly -dependent on the initial value of the population model. Any changes from -using a different starting value between 0 and 1 may be subtle. The values 0 -and 1 are interpreted in a special manner. A Seed of 1 will choose a random -number between 0 and 1 at the start of each pixel. A Seed of 0 will suppress -resetting the seed value between pixels unless the population model diverges -in which case a random seed will be used on the next pixel. - -Filter Cycles. -Like the Bifurcation model, the Lyapunov allow you to set the number of -cycles that will be run to allow the model to approach equilibrium before -the lyapunov exponent calculation is begun. The default value of 0 uses one -half of the iterations before beginning the calculation of the exponent. - -Reference. -A.K. Dewdney, Mathematical Recreations, Scientific American, Sept. 1991 -; -; -~Topic=Magnetic Fractals, Label=HT_MAGNET -(type=magnet1m/.../magnet2j) - -These fractals use formulae derived from the study of hierarchical -lattices, in the context of magnetic renormalisation transformations. -This kinda stuff is useful in an area of theoretical physics that deals -with magnetic phase-transitions (predicting at which temperatures a given -substance will be magnetic, or non-magnetic). In an attempt to clarify -the results obtained for Real temperatures (the kind that you and I can -feel), the study moved into the realm of Complex Numbers, aiming to spot -Real phase-transitions by finding the intersections of lines representing -Complex phase-transitions with the Real Axis. The first people to try -this were two physicists called Yang and Lee, who found the situation a -bit more complex than first expected, as the phase boundaries for Complex -temperatures are (surprise!) fractals. - -And that's all the technical (?) background you're getting here! For more -details (are you SERIOUS ?!) read "The Beauty of Fractals". When you -understand it all, you might like to rewrite this section, before you -start your new job as a professor of theoretical physics... - -In Fractint terms, the important bits of the above are "Fractals", -"Complex Numbers", "Formulae", and "The Beauty of Fractals". Lifting the -Formulae straight out of the Book and iterating them over the Complex -plane (just like the Mandelbrot set) produces Fractals. - -The formulae are a bit more complicated than the Z^2+C used for the -Mandelbrot Set, that's all. They are : - -~Format- - [ ] 2 - | Z^2 + (C-1) | - MAGNET1 : | ------------- | - | 2*Z + (C-2) | - [ ] - - [ ] 2 - | Z^3 + 3*(C-1)*Z + (C-1)*(C-2) | - MAGNET2 : | --------------------------------------- | - | 3*(Z^2) + 3*(C-2)*Z + (C-1)*(C-2) + 1 | - [ ] -~Format+ - -These aren't quite as horrific as they look (oh yeah ?!) as they only -involve two variables (Z and C), but cubing things, doing division, and -eventually squaring the result (all in Complex Numbers) don't exactly -spell S-p-e-e-d ! These are NOT the fastest fractals in Fractint ! - -As you might expect, for both formulae there is a single related -Mandelbrot-type set (magnet1m, magnet2m) and an infinite number of related -Julia-type sets (magnet1j, magnet2j), with the usual toggle between the -corresponding Ms and Js via the spacebar. - -If you fancy delving into the Julia-types by hand, you will be prompted -for the Real and Imaginary parts of the parameter denoted by C. The -result is symmetrical about the Real axis (and therefore the initial image -gets drawn in half the usual time) if you specify a value of Zero for the -Imaginary part of C. - -Fractint Historical Note: Another complication (besides the formulae) in -implementing these fractal types was that they all have a finite attractor -(1.0 + 0.0i), as well as the usual one (Infinity). This fact spurred the -development of Finite Attractor logic in Fractint. Without this code you -can still generate these fractals, but you usually end up with a pretty -boring image that is mostly deep blue "lake", courtesy of Fractint's -standard {Periodicity Logic}. -See {Finite Attractors} for more -information on this aspect of Fractint internals. - -(Thanks to Kevin Allen for Magnetic type documentation above). -; -; -~Topic=Volterra-Lotka Fractals, Label=HT_VL -(type=volterra-lotka) - -In The Beauty of Fractals, these images are offered as an example of -"how an apparently innocent system of differential equations gives rise -to unimaginably rich and complex behavior after discretization." The -Volterra-Lotka equations are a refinement of attempts to model predator- -prey systems. - -If x represents the prey population and y represents the predator -population, their relationship can be expressed as: - -~Format- - dx/dt = Ax - Bxy = f(x,y) - dy/dt = -Cy + Dxy = g(x,y) -~Format+ - -According to Peitgen and Richter, "Hence, x grows at a constant rate in -the absence of y, and y decays at a constant rate in the absence of x. -The prey is consumed in proportion to y, and the predators expand in -proportion to x." They proceed to "discretize" this system, by "mating" -the Euler and Heun methods. For purposes of image computation, their -formula (Equation 8.3 on page 125) can be interpreted as: - -~Format- - x(new) = x + h/2 * [ f(x,y) + f[x + pf(x,y), y + pg(x,y)] ] - y(new) = y + h/2 * [ g(x,y) + g[x + pf(x,y), y + pg(x,y)] ] -~Format+ - -This formula can be used to plot or connect single points, starting with -arbitrary values of x(0) and y(0), to produce typical "strange attractor" -images such as the ones commonly derived from the Henon or Lorenz formulae. -But to produce an escape-time fractal, we iterate this formula for all -(x, y) pairs that we can associate with pixels on our monitor screen. The -standard window is: 0.0 < x < 6.0; 0.0 < y < 4.5. Since the "unimaginably -rich and complex behavior" occurs with the points that do NOT escape, the -inside coloring method assumes considerable importance. - -The parameters h and p can be selected between 0.0 and 1.0, and this -determines the types of attractors that will result. Infinity and (1, 1) -are predictable attractors. For certain combinations, an "invariant -circle" (which is not strictly circular) and/or an orbit of period 9 also -are attractive. - -The invariant circle and periodic orbit change with each (h, p) pair, and -they must be determined empirically. That process would be thoroughly -impractical to implement through any kind of fixed formula. This is -especially true because even when these attractors are chosen, the -threshold for determining when a point is "close enough" is quite arbitrary, -and yet it affects the image considerably. The best compromise in the -context of a generalized formula is to use either the "zmag" or "bof60" -inside coloring options. See {Inside=bof60|bof61|zmag|fmod|period|atan} for -details. This formula performs best with a relatively high bailout value; -the default is set at 256, rather than the standard default of 4. - -~Format- -Reference: Peitgen, H.-O. and Richter, P.H. The Beauty of Fractals, - Springer-Verlag, 1986; Section 8, pp. 125-7. -~Format+ -; -; -~Topic=Escher-Like Julia Sets, Label=HT_ESCHER -(type=escher_julia) - -These unique variations on the Julia set theme, presented in The Science of -Fractal Images, challenge us to expand our pre-conceived notions of how -fractals should be iterated. We start with a very basic Julia formula: - -~Format- - z(n+1) = z(n)^2 + (0, 0i) -~Format+ - -The standard algorithm would test each iterated point to see if it "escapes to -infinity". If its size or "modulus" (its distance from the origin) exceeds a -preselected {Bailout Test} value, it is outside the Julia set, and it is banished -to the world of multicolored level sets which color-cycle spectacularly. But another -way of describing an escaped point is to say that it is "attracted" to infinity. We -make this decision by calculating whether the point falls within the "target set" -of all points closer to infinity than the boundary created by the bailout value. In -this way, the "disk around infinity" is conceptually no different from the disks -around {Finite Attractors} such as those used for Newton fractals. - -In the above formula, with c = (0, 0i), this standard algorithm yields a rather -unexciting circle. But along comes Peitgen to tell us that "since T [the target -set] can essentially be anything, this method has tremendous artistic potential. -For example, T could be a so-called p-norm disk ... or a scaled filled-in Julia -set or something designed by hand. This method opens a simple [beware when he uses -words like that] and systematic approach to Escher-like tilings." - -So, what we do is iterate the above formula, scale each iteration, and plug it into -a second Julia formula. This formula has a value of c selected by the user. If the -point converges to this non-circular target set: - -~Format- - T = [ z: | (z * 15.0)^2 + c | < BAILOUT ] -~Format+ - -we color it in proportion to the overall iteration count. If not, it will be -attracted to infinity and can be colored with the usual outside coloring -options. This formula uses a new Fractint programming feature which allows the use -of a customized coloring option for the points which converge to the target Julia -set, yet allows the other points to be handled by the standard fractal engine with -all of its options. - -With the proper palette and parameters for c, and using the {Inversion} option and -a solid outside color from the {Color Parameters}, you can create a solar eclipse, -with the corona composed of Julia-shaped flames radiating from the sun's surface. - -If you question the relevance of these images to Escher, check out his Circle Limit -series (especially III and IV). In his own words: "It is to be doubted whether there -exist today many ... artists of any kind, to whom the desire has come to penetrate to -the depths of infinity.... There is only one possible way of ... obtaining an -"infinity" entirely enclosed within a logical boundary line.... The largest ... shapes -are now found in the center and the limit of infinite number and infinite smallness -is reached at the circumference.... Not one single component ever reaches the edge. -For beyond that there is "absolute nothingness." And yet this round world cannot exist -without the emptiness around it, not simply because "within" presupposes "without", but -also because it is out there in the "nothingness" that the center points of the arcs -that go to build up the framework are fixed with such geometric exactitude." - -~Format- -References: - Ernst, B. The Magic Mirror of M. C. Escher, Barnes & Noble, 1994, pp. 102-11. - Peitgen, H.-O. and Saupe, D. The Science of Fractal Images, Springer-Verlag, - 1988; pp. 185, 187. -~Format+ -; -; -~Topic=L-Systems, Label=HT_LSYS -(type=lsystem) - -These fractals are constructed from line segments using rules specified in -drawing commands. Starting with an initial string, the axiom, -transformation rules are applied a specified number of times, to produce -the final command string which is used to draw the image. - -Like the type=formula fractals, this type requires a separate data file. -A sample file, FRACTINT.L, is included with this distribution. When you -select type lsystem, the current lsystem file is read and you are asked -for the lsystem name you wish to run. Press at this point if you wish -to use a different lsystem file. After selecting an lsystem, you are asked -for one parameter - the "order", or number of times to execute all the -transformation rules. It is wise to start with small orders, because the -size of the substituted command string grows exponentially and it is very -easy to exceed your resolution. (Higher orders take longer to generate -too.) The command line options "lname=" and "lfile=" can be used to over- -ride the default file name and lsystem name. - -Each L-System entry in the file contains a specification of the angle, the -axiom, and the transformation rules. Each item must appear on its own -line and each line must be less than 160 characters long. - -The statement "angle n" sets the angle to 360/n degrees; n must be an -integer greater than two and less than fifty. - -"Axiom string" defines the axiom. - -Transformation rules are specified as "a=string" and convert the single -character 'a' into "string." If more than one rule is specified for a -single character all of the strings will be added together. This allows -specifying transformations longer than the 160 character limit. -Transformation rules may operate on any characters except space, tab or -'}'. - -Any information after a ; (semi-colon) on a line is treated as a comment. - -Here is a sample lsystem: - -~Format- -Dragon \{ ; Name of lsystem, \{ indicates start - Angle 8 ; Specify the angle increment to 45 degrees - Axiom FX ; Starting character string - F= ; First rule: Delete 'F' - y=+FX--FY+ ; Change 'y' into "+fx--fy+" - x=-FX++FY- ; Similar transformation on 'x' -} ; final } indicates end - -The standard drawing commands are: - F Draw forward - G Move forward (without drawing) - + Increase angle - - Decrease angle - | Try to turn 180 degrees. (If angle is odd, the turn - will be the largest possible turn less than 180 degrees.) -~Format+ - -These commands increment angle by the user specified angle value. They -should be used when possible because they are fast. If greater flexibility -is needed, use the following commands which keep a completely separate -angle pointer which is specified in degrees. - -~Format- - D Draw forward - M Move forward - \\nn Increase angle nn degrees - /nn Decrease angle nn degrees - -Color control: - Cnn Select color nn - nn decrement color by nn - -Advanced commands: - ! Reverse directions (Switch meanings of +, - and \, /) - @nnn Multiply line segment size by nnn - nnn may be a plain number, or may be preceded by - I for inverse, or Q for square root. - (e.g. @IQ2 divides size by the square root of 2) - [ Push. Stores current angle and position on a stack - ] Pop. Return to location of last push -~Format+ - -Other characters are perfectly legal in command strings. They are ignored -for drawing purposes, but can be used to achieve complex translations. - -The characters '+', '-', '<', '>', '[', ']', '|', '!', '@', '/', '\\', -and 'c' are reserved symbols and cannot be redefined. For example, c=f+f -and <= , are syntax errors. - -The integer code produces incorrect results in five known instances, Peano2 -with order >= 7, SnowFlake1 with order >=6, and SnowFlake2, SnowFlake3, and -SnowflakeColor with order >= 5. If you see strange results, switch to the -floating point code. -; -; -; diff --git a/fractint/headers/.cvsignore b/fractint/headers/.cvsignore deleted file mode 100644 index ffe933a29..000000000 --- a/fractint/headers/.cvsignore +++ /dev/null @@ -1,2 +0,0 @@ -HELPDEFS.H -helpdefs.h diff --git a/fractint/headers/big.h b/fractint/headers/big.h deleted file mode 100644 index 181d69389..000000000 --- a/fractint/headers/big.h +++ /dev/null @@ -1,363 +0,0 @@ -/* big.h */ - -/* Wesley Loewer's Big Numbers. (C) 1994, Wesley B. Loewer */ - -#ifndef _BIG_H -#define _BIG_H - -/************************************************************* - The following allows the programmer to customize routines. - They can be selected here or on the compiler command line. -**************************************************************/ - -/* different pointer versions: near, based, far */ -/* huge pointers is not supported in assembly, only in C */ -/* uncomment only ONE of these or declare on compiler command line */ -/* #define BIG_NEAR */ -#if !defined(_WIN32) -#if defined(_MSC_VER) -# define BIG_BASED -#elif defined( __BORLANDC__) -# define BIG_FAR -#endif -#endif -/* #define BIG_HUGE */ /* C code only */ -/* #define BIG_ANSI_C */ /* C code only */ -/* In DOS, BIG_ANSI_C uses default pointer for model selected */ - - -/* Number of bytes to use for integer part for fixed decimal math, */ -/* does not effect floating point math at all. */ -#define BN_INT_LENGTH 4 - -/* #define CALCULATING_BIG_PI */ /* define for generating big_pi[] table */ - -/**************************************************************** - The rest is handled by the compiler -****************************************************************/ - -#ifndef BIG_NEAR -#ifndef BIG_BASED -#ifndef BIG_FAR -#ifndef BIG_HUGE -#ifndef BIG_ANSI_C -#error BIG_NEAR, BIG_BASED, BIG_FAR, BIG_HUGE, or BIG_ANSI_C must be defined. -#endif -#endif -#endif -#endif -#endif - -#define LOG10_256 2.4082399653118 -#define LOG_256 5.5451774444795 - -/* values that bf_math can hold, */ -/* 0 = bf_math is not being used */ -/* 1 = bf_math is being used */ -#define BIGNUM 1 /* bf_math is being used with bn_t numbers */ -#define BIGFLT 2 /* bf_math is being used with bf_t numbers */ - - -/* use this for dynamic allocation */ -#ifdef BIG_NEAR -extern _segment bignum_seg; -#define BIGDIST __near -#define BIG_NULL NULL -#define BIG_SIZE_T size_t -#define big_malloc(size) _nmalloc(size) -#define big_free(ptr) _nfree(ptr) -#endif - -#ifdef BIG_BASED -extern _segment bignum_seg; -#define BIGDIST __based(bignum_seg) -#define BIG_NULL _NULLOFF -#define BIG_SIZE_T size_t -#define big_malloc(size) _bmalloc(bignum_seg, (size)) -#define big_free(ptr) _bfree( bignum_seg, (ptr)) -#endif - -#ifdef BIG_FAR -#define BIGDIST __far -#define BIG_NULL NULL -#define BIG_SIZE_T size_t -#define big_malloc(size) _fmalloc( size ) -#define big_free(ptr) _ffree(ptr) -#endif - -#ifdef BIG_HUGE -#define BIGDIST __huge -#define BIG_NULL NULL -#define BIG_SIZE_T long -#define big_malloc(size) _halloc( (size), 1 ) -#define big_free(ptr) _hfree(ptr) -#endif - -#ifdef BIG_ANSI_C -#define USE_BIGNUM_C_CODE -#define BIGDIST -#define BIG_NULL NULL -#define BIG_SIZE_T size_t -#define big_malloc(size) malloc(size) -#define big_free(ptr) free(ptr) -#endif - -typedef unsigned char BIGDIST * big_t; -#define bn_t big_t /* for clarification purposes */ -#define bf_t big_t -#define bf10_t big_t - -#if 0 /* remove for Fractint */ -struct Complex -{ - LDBL x; - LDBL y; -}; -typedef struct Complex _CMPLX; -#else -#include "cmplx.h" -#endif - -struct BFComplex -{ - bn_t x; - bn_t y; -}; -typedef struct BFComplex _BFCMPLX; - -struct BNComplex -{ - bn_t x; - bn_t y; -}; -typedef struct BNComplex _BNCMPLX; - -/* globals */ -extern int fpu; -extern int cpu; - -extern int bf_math; - -extern int bnstep, intlength; -extern int bnlength, rlength, padding, decimals, shiftfactor; -extern int bflength, rbflength, bfpadding, bfdecimals; - -extern bn_t bntmp1, bntmp2, bntmp3, bntmp4, bntmp5, bntmp6; /* rlength */ -extern bn_t bntest1, bntest2, bntest3; /* rlength */ -extern bn_t bntmpcpy1, bntmpcpy2; /* bnlength */ -extern bn_t bn_pi; -extern bn_t bntmp; /* rlength */ - -extern bf_t bftmp1, bftmp2, bftmp3, bftmp4, bftmp5, bftmp6; /* rbflength+2 */ -extern bf_t bftest1, bftest2, bftest3; /* rbflength+2 */ -extern bf_t bftmpcpy1, bftmpcpy2; /* bflength+2 */ -extern bf_t bf_pi; -extern bf_t bftmp; /* rbflength */ - -extern bf10_t bf10tmp; /* dec+4 */ -extern big_t big_pi; - - -/* functions defined in biginit.c */ - -big_t big_alloc(size_t size); -/* void big_free(big_t memblock); now defined as a macro above */ - -void calc_lengths(void); -void init_big_dec(int dec); -void init_big_length(int bnl); -void init_big_pi(void); - - -/* functions defined in bignuma.asm or bignumc.c */ -extern bn_t clear_bn(bn_t r); -extern bn_t max_bn(bn_t r); -extern bn_t copy_bn(bn_t r, bn_t n); -extern int cmp_bn(bn_t n1, bn_t n2); -extern int is_bn_neg(bn_t n); -extern int is_bn_not_zero(bn_t n); -extern bn_t add_bn(bn_t r, bn_t n1, bn_t n2); -extern bn_t add_a_bn(bn_t r, bn_t n); -extern bn_t sub_bn(bn_t r, bn_t n1, bn_t n2); -extern bn_t sub_a_bn(bn_t r, bn_t n); -extern bn_t neg_bn(bn_t r, bn_t n); -extern bn_t neg_a_bn(bn_t r); -extern bn_t double_bn(bn_t r, bn_t n); -extern bn_t double_a_bn(bn_t r); -extern bn_t half_bn(bn_t r, bn_t n); -extern bn_t half_a_bn(bn_t r); -extern bn_t unsafe_full_mult_bn(bn_t r, bn_t n1, bn_t n2); -extern bn_t unsafe_mult_bn(bn_t r, bn_t n1, bn_t n2); -extern bn_t unsafe_full_square_bn(bn_t r, bn_t n); -extern bn_t unsafe_square_bn(bn_t r, bn_t n); -extern bn_t mult_bn_int(bn_t r, bn_t n, U16 u); -extern bn_t mult_a_bn_int(bn_t r, U16 u); -extern bn_t unsafe_div_bn_int(bn_t r, bn_t n, U16 u); -extern bn_t div_a_bn_int(bn_t r, U16 u); - -/* used to be in bigflta.asm or bigfltc.c */ -extern bf_t clear_bf(bf_t r); -extern bf_t copy_bf(bf_t r, bf_t n); -extern bf_t floattobf(bf_t r, LDBL f); -extern LDBL bftofloat(bf_t n); -extern LDBL bntofloat(bn_t n); -extern LDBL extract_256(LDBL f, int *exp_ptr); -extern LDBL scale_256( LDBL f, int n ); - -/* functions defined in bignum.c */ -#ifdef ACCESS_BY_BYTE -/* prototypes */ -extern U32 big_access32(BYTE BIGDIST *addr); -extern U16 big_access16(BYTE BIGDIST *addr); -extern S16 big_accessS16(S16 BIGDIST *addr); -extern U32 big_set32(BYTE BIGDIST *addr, U32 val); -extern U16 big_set16(BYTE BIGDIST *addr, U16 val); -extern S16 big_setS16(S16 BIGDIST *addr, S16 val); -#else -/* equivalent defines */ -#define big_access32(addr) (*(U32 BIGDIST *)(addr)) -#define big_access16(addr) (*(U16 BIGDIST *)(addr)) -#define big_accessS16(addr) (*(S16 BIGDIST *)(addr)) -#define big_set32(addr, val) (*(U32 BIGDIST *)(addr) = (U32)(val)) -#define big_set16(addr, val) (*(U16 BIGDIST *)(addr) = (U16)(val)) -#define big_setS16(addr, val) (*(S16 BIGDIST *)(addr) = (S16)(val)) -#endif - -extern void bn_hexdump(bn_t r); -extern bn_t strtobn(bn_t r, char *s); -extern char *unsafe_bntostr(char *s, int dec, bn_t r); -extern bn_t inttobn(bn_t r, long longval); -extern long bntoint(bn_t n); - -extern int sign_bn(bn_t n); -extern bn_t abs_bn(bn_t r, bn_t n); -extern bn_t abs_a_bn(bn_t r); -extern bn_t unsafe_inv_bn(bn_t r, bn_t n); -extern bn_t unsafe_div_bn(bn_t r, bn_t n1, bn_t n2); -extern bn_t sqrt_bn(bn_t r, bn_t n); -extern bn_t exp_bn(bn_t r, bn_t n); -extern bn_t unsafe_ln_bn(bn_t r, bn_t n); -extern bn_t unsafe_sincos_bn(bn_t s, bn_t c, bn_t n); -extern bn_t unsafe_atan_bn(bn_t r, bn_t n); -extern bn_t unsafe_atan2_bn(bn_t r, bn_t ny, bn_t nx); -extern int convert_bn(bn_t new,bn_t old,int newbnlength,int newintlength,int oldbnlength,int oldintlength); - - /* "safe" versions */ -extern bn_t full_mult_bn(bn_t r, bn_t n1, bn_t n2); -extern bn_t mult_bn(bn_t r, bn_t n1, bn_t n2); -extern bn_t full_square_bn(bn_t r, bn_t n); -extern bn_t square_bn(bn_t r, bn_t n); -extern bn_t div_bn_int(bn_t r, bn_t n, U16 u); -extern char *bntostr(char *s, int dec, bn_t r); -extern bn_t inv_bn(bn_t r, bn_t n); -extern bn_t div_bn(bn_t r, bn_t n1, bn_t n2); -extern bn_t ln_bn(bn_t r, bn_t n); -extern bn_t sincos_bn(bn_t s, bn_t c, bn_t n); -extern bn_t atan_bn(bn_t r, bn_t n); -extern bn_t atan2_bn(bn_t r, bn_t ny, bn_t nx); - - /* misc */ -extern int is_bn_zero(bn_t n); -extern bn_t floattobn(bn_t r, LDBL f); - -/************/ -/* bigflt.c */ -extern void bf_hexdump(bf_t r); -extern bf_t strtobf(bf_t r, char *s); -extern int strlen_needed_bf(); -extern char *unsafe_bftostr(char *s, int dec, bf_t r); -extern char *unsafe_bftostr_e(char *s, int dec, bf_t r); -extern char *unsafe_bftostr_f(char *s, int dec, bf_t r); -extern bn_t bftobn(bn_t n, bf_t f); -extern bn_t bntobf(bf_t f, bn_t n); -extern long bftoint(bf_t f); -extern bf_t inttobf(bf_t r, long longval); - -extern int sign_bf(bf_t n); -extern bf_t abs_bf(bf_t r, bf_t n); -extern bf_t abs_a_bf(bf_t r); -extern bf_t unsafe_inv_bf(bf_t r, bf_t n); -extern bf_t unsafe_div_bf(bf_t r, bf_t n1, bf_t n2); -extern bf_t unsafe_sqrt_bf(bf_t r, bf_t n); -extern bf_t exp_bf(bf_t r, bf_t n); -extern bf_t unsafe_ln_bf(bf_t r, bf_t n); -extern bf_t unsafe_sincos_bf(bf_t s, bf_t c, bf_t n); -extern bf_t unsafe_atan_bf(bf_t r, bf_t n); -extern bf_t unsafe_atan2_bf(bf_t r, bf_t ny, bf_t nx); - -extern bf_t add_bf(bf_t r, bf_t n1, bf_t n2); -extern bf_t add_a_bf(bf_t r, bf_t n); -extern bf_t sub_bf(bf_t r, bf_t n1, bf_t n2); -extern bf_t sub_a_bf(bf_t r, bf_t n); -extern bf_t full_mult_bf(bf_t r, bf_t n1, bf_t n2); -extern bf_t mult_bf(bf_t r, bf_t n1, bf_t n2); -extern bf_t full_square_bf(bf_t r, bf_t n); -extern bf_t square_bf(bf_t r, bf_t n); -extern bf_t mult_bf_int(bf_t r, bf_t n, U16 u); -extern bf_t div_bf_int(bf_t r, bf_t n, U16 u); - -extern char *bftostr(char *s, int dec, bf_t r); -extern char *bftostr_e(char *s, int dec, bf_t r); -extern char *bftostr_f(char *s, int dec, bf_t r); -extern bf_t inv_bf(bf_t r, bf_t n); -extern bf_t div_bf(bf_t r, bf_t n1, bf_t n2); -extern bf_t sqrt_bf(bf_t r, bf_t n); -extern bf_t ln_bf(bf_t r, bf_t n); -extern bf_t sincos_bf(bf_t s, bf_t c, bf_t n); -extern bf_t atan_bf(bf_t r, bf_t n); -extern bf_t atan2_bf(bf_t r, bf_t ny, bf_t nx); -extern int is_bf_zero(bf_t n); -extern int convert_bf(bf_t new, bf_t old, int newbflength, int oldbflength); - -extern LDBL extract_value(LDBL f, LDBL b, int *exp_ptr); -extern LDBL scale_value( LDBL f, LDBL b , int n ); -extern LDBL extract_10(LDBL f, int *exp_ptr); -extern LDBL scale_10( LDBL f, int n ); - -extern bf10_t unsafe_bftobf10(bf10_t s, int dec, bf_t n); -extern bf10_t mult_a_bf10_int(bf10_t s, int dec, U16 n); -extern bf10_t div_a_bf10_int (bf10_t s, int dec, U16 n); -extern char *bf10tostr_e(char *s, int dec, bf10_t n); -extern char *bf10tostr_f(char *s, int dec, bf10_t n); - -/* functions defined in bigfltc.c */ -extern bf_t norm_bf(bf_t r); -extern void norm_sign_bf(bf_t r, int positive); -extern S16 adjust_bf_add(bf_t n1, bf_t n2); -extern bf_t max_bf(bf_t r); -extern int cmp_bf(bf_t n1, bf_t n2); -extern int is_bf_neg(bf_t n); -extern int is_bf_not_zero(bf_t n); -extern bf_t unsafe_add_bf(bf_t r, bf_t n1, bf_t n2); -extern bf_t unsafe_add_a_bf(bf_t r, bf_t n); -extern bf_t unsafe_sub_bf(bf_t r, bf_t n1, bf_t n2); -extern bf_t unsafe_sub_a_bf(bf_t r, bf_t n); -extern bf_t neg_bf(bf_t r, bf_t n); -extern bf_t neg_a_bf(bf_t r); -extern bf_t double_bf(bf_t r, bf_t n); -extern bf_t double_a_bf(bf_t r); -extern bf_t half_bf(bf_t r, bf_t n); -extern bf_t half_a_bf(bf_t r); -extern bf_t unsafe_full_mult_bf(bf_t r, bf_t n1, bf_t n2); -extern bf_t unsafe_mult_bf(bf_t r, bf_t n1, bf_t n2); -extern bf_t unsafe_full_square_bf(bf_t r, bf_t n); -extern bf_t unsafe_square_bf(bf_t r, bf_t n); -extern bf_t unsafe_mult_bf_int(bf_t r, bf_t n, U16 u); -extern bf_t mult_a_bf_int(bf_t r, U16 u); -extern bf_t unsafe_div_bf_int(bf_t r, bf_t n, U16 u); -extern bf_t div_a_bf_int(bf_t r, U16 u); - -/****************************/ -/* bigcmplx.c */ -extern _CMPLX cmplxbntofloat(_BNCMPLX *s); -extern _CMPLX cmplxbftofloat(_BFCMPLX *s); -extern _BFCMPLX *cmplxlog_bf(_BFCMPLX *t, _BFCMPLX *s); -extern _BFCMPLX *cplxmul_bf( _BFCMPLX *t, _BFCMPLX *x, _BFCMPLX *y); -extern _BFCMPLX *ComplexPower_bf(_BFCMPLX *t, _BFCMPLX *xx, _BFCMPLX *yy); -extern _BNCMPLX *ComplexPower_bn(_BNCMPLX *t, _BNCMPLX *xx, _BNCMPLX *yy); -extern _BNCMPLX *cmplxlog_bn(_BNCMPLX *t, _BNCMPLX *s); -extern _BNCMPLX *cplxmul_bn( _BNCMPLX *t, _BNCMPLX *x, _BNCMPLX *y); - -#include "biginit.h" /* fractint only */ - -#endif /* _BIG_H */ diff --git a/fractint/headers/dosprot.h b/fractint/headers/dosprot.h deleted file mode 100644 index 7fad4ff64..000000000 --- a/fractint/headers/dosprot.h +++ /dev/null @@ -1,133 +0,0 @@ -#ifndef DOSPROT_H -#define DOSPROT_H - -/* This file contains prototypes for dos specific functions. */ - - -/* calmanp5 -- assembler file prototypes */ - -extern long cdecl calcmandfpasm_p5(void); -extern void cdecl calcmandfpasmstart_p5(void); - -/* general -- assembler file prototypes */ - -extern long cdecl multiply(long, long, int); -extern long cdecl divide(long, long, int); -extern int cdecl getakey(void); -/*extern void cdecl buzzer(int); */ -extern void cdecl buzzerpcspkr(int); -extern void cdecl farmemfree(VOIDPTR ); -extern int cdecl far_strlen( char far *); -extern int cdecl far_strnicmp(char far *, char far *,int); -extern void cdecl far_strcpy( char far *, char far *); -extern int cdecl far_strcmp( char far *, char far *); -extern void cdecl far_strcat( char far *, char far *); -extern void cdecl far_memset( VOIDPTR , int , unsigned); -extern void cdecl far_memcpy( VOIDPTR , VOIDFARPTR , int); -extern int cdecl far_memcmp( VOIDFARPTR , VOIDFARPTR , int); -extern BYTE far *cdecl emmquery(void); -extern unsigned int cdecl emmgetfree(void); -extern unsigned int cdecl emmallocate(unsigned int); -extern void cdecl emmdeallocate(unsigned int); -extern void cdecl emmgetpage(unsigned int, unsigned int); -extern void cdecl emmclearpage(unsigned int, unsigned int); -extern unsigned int *cdecl xmmquery(void); -extern unsigned int cdecl xmmlongest(void); -extern unsigned int cdecl xmmfree(void); -extern unsigned int cdecl xmmallocate(unsigned int); -extern void cdecl xmmdeallocate(unsigned int); -extern unsigned int cdecl xmmreallocate(unsigned int, unsigned int); -extern unsigned int cdecl xmmmoveextended(struct XMM_Move *); -extern int cdecl keypressed(void); -extern long cdecl readticker( void ); -extern void cdecl snd( int ); -extern void cdecl nosnd( void ); -extern void cdecl initasmvars( void ); - -#ifndef __BORLANDC__ -extern void cdecl enable( void ); -extern void cdecl disable( void ); -extern void cdecl delay( int ); -#endif - -extern int cdecl farread(int, VOIDFARPTR, unsigned); -extern int cdecl farwrite(int, VOIDFARPTR, unsigned); -extern long cdecl normalize(char far *); -extern void cdecl erasesegment(int, int); -extern int cdecl getakeynohelp( void ); -extern unsigned int cdecl cmpextra( unsigned int, char *, int ); -extern unsigned int cdecl fromextra( unsigned int, char *, int ); -extern unsigned int cdecl toextra( unsigned int, char *, int ); -extern void cdecl load_mat(double (*)[4]); - -/* sound.c file prototypes */ -extern int get_sound_params(void); -extern void buzzer(int); -extern int soundon(int); -extern void soundoff(void); -extern int initfm(void); -extern void mute(void); - -/* tplus -- C file prototypes */ - -extern void WriteTPWord(unsigned int ,unsigned int ); -extern void WriteTPByte(unsigned int ,unsigned int ); -extern unsigned int ReadTPWord(unsigned int ); -extern BYTE ReadTPByte(unsigned int ); -extern void DisableMemory(void ); -extern void EnableMemory(void ); -extern int TargapSys(int ,unsigned int ); -extern int _SetBoard(int ); -extern int TPlusLUT(BYTE far *,unsigned int ,unsigned int ,unsigned int ); -extern int SetVGA_LUT(void ); -extern int SetColorDepth(int ); -extern int SetBoard(int ); -extern int ResetBoard(int ); -extern int CheckForTPlus(void ); -extern int SetTPlusMode(int ,int ,int ,int ); -extern int FillTPlusRegion(unsigned int ,unsigned int ,unsigned int ,unsigned int ,unsigned long ); -extern void BlankScreen(unsigned long ); -extern void UnBlankScreen(void ); -extern void EnableOverlayCapture(void ); -extern void DisableOverlayCapture(void ); -extern void ClearTPlusScreen(void ); -extern int MatchTPlusMode(unsigned int ,unsigned int ,unsigned int ,unsigned int ,unsigned int ); -extern void TPlusZoom(int ); - -/* video -- assembler file prototypes */ - -extern void cdecl adapter_detect(void); -extern void cdecl scroll_center(int, int); -extern void cdecl scroll_relative(int, int); -extern void cdecl scroll_state(int); -extern void cdecl setvideotext(void); -extern void cdecl setnullvideo(void); -extern void cdecl setfortext(void); -extern void cdecl setforgraphics(void); -extern void cdecl swapnormwrite(void); -extern void cdecl setclear(void); -extern int cdecl keycursor(int,int); -extern void cdecl swapnormread(void); -extern void cdecl setvideomode(int, int, int, int); -extern void cdecl movewords(int,BYTE far*,BYTE far*); -extern void cdecl movecursor(int, int); -extern void cdecl get_line(int, int, int, BYTE *); -extern void cdecl put_line(int, int, int, BYTE *); -extern void cdecl setattr(int, int, int, int); -extern void cdecl putstring(int,int,int,char far *); -extern void cdecl spindac(int, int); -extern void cdecl find_special_colors(void); -extern char cdecl get_a_char(void); -extern void cdecl put_a_char(int); -extern void cdecl scrollup(int, int); -extern void cdecl home(void); -extern BYTE far *cdecl findfont(int); -extern int _fastcall getcolor(int, int); -extern void _fastcall putcolor_a(int, int, int); -extern void gettruecolor(int, int, int*, int*, int*); -extern void puttruecolor(int, int, int, int, int); -extern int out_line(BYTE *, int); -extern void (*swapsetup)(void); - -#endif - diff --git a/fractint/headers/drivers.h b/fractint/headers/drivers.h deleted file mode 100644 index 066a34906..000000000 --- a/fractint/headers/drivers.h +++ /dev/null @@ -1,300 +0,0 @@ -#if !defined(DRIVERS_H) -#define DRIVERS_H - -/*------------------------------------------------------------ - * Driver Methods: - * - * init - * Initialize the driver and return non-zero on success. - * - * terminate - * schedule_alarm - * - * window - * Do whatever is necessary to open up a window after the screen size - * has been set. In a windowed environment, the window may provide - * scroll bars to pan a cropped view across the screen. - * - * resize - * redraw - * read_palette, write_palette - * read_pixel, write_pixel - * read_span, write_span - * set_line_mode - * draw_line - * get_key - * key_cursor - * key_pressed - * wait_key_pressed - * unget_key - * shell - * set_video_mode - * put_string - * set_for_text, set_for_graphics, set_clear - * move_cursor - * hide_text_cursor - * set_attr - * scroll_up - * stack_screen, unstack_screen, discard_screen - * get_char_attr, put_char_attr - */ -struct tagDriver -{ - /* name of driver */ const char *name; - /* driver description */ const char *description; - /* init the driver */ int (*init)(Driver *drv, int *argc, char **argv); - /* validate a fractint.cfg mode */ int (*validate_mode)(Driver *drv, VIDEOINFO *mode); - /* find max screen extents */ void (*get_max_screen)(Driver *drv, int *xmax, int *ymax); - /* shutdown the driver */ void (*terminate)(Driver *drv); - /* pause this driver */ void (*pause)(Driver *drv); - /* resume this driver */ void (*resume)(Driver *drv); - /* refresh alarm */ void (*schedule_alarm)(Driver *drv, int secs); - /* creates a window */ void (*window)(Driver *drv); - /* handles window resize. */ int (*resize)(Driver *drv); - /* redraws the screen */ void (*redraw)(Driver *drv); - /* read palette into g_dac_box */ int (*read_palette)(Driver *drv); - /* write g_dac_box into palette */ int (*write_palette)(Driver *drv); - /* reads a single pixel */ int (*read_pixel)(Driver *drv, int x, int y); - /* writes a single pixel */ void (*write_pixel)(Driver *drv, int x, int y, int color); - /* reads a span of pixel */ void (*read_span)(Driver *drv, int y, int x, int lastx, BYTE *pixels); - /* writes a span of pixels */ void (*write_span)(Driver *drv, int y, int x, int lastx, BYTE *pixels); - void (*get_truecolor)(Driver *drv, int x, int y, int *r, int *g, int *b, int *a); - void (*put_truecolor)(Driver *drv, int x, int y, int r, int g, int b, int a); - /* set copy/xor line */ void (*set_line_mode)(Driver *drv, int mode); - /* draw line */ void (*draw_line)(Driver *drv, int x1, int y1, int x2, int y2, int color); - /* draw string in graphics mode */ void (*display_string)(Driver *drv, int x, int y, int fg, int bg, const char *text); - /* save graphics */ void (*save_graphics)(Driver *drv); - /* restore graphics */ void (*restore_graphics)(Driver *drv); - /* poll or block for a key */ int (*get_key)(Driver *drv); - int (*key_cursor)(Driver *drv, int row, int col); - int (*key_pressed)(Driver *drv); - int (*wait_key_pressed)(Driver *drv, int timeout); - void (*unget_key)(Driver *drv, int key); - /* invoke a command shell */ void (*shell)(Driver *drv); - void (*set_video_mode)(Driver *drv, VIDEOINFO *mode); - void (*put_string)(Driver *drv, int row, int col, int attr, const char *msg); - /* set for text mode & save gfx */ void (*set_for_text)(Driver *drv); - /* restores graphics and data */ void (*set_for_graphics)(Driver *drv); - /* clears text screen */ void (*set_clear)(Driver *drv); - /* text screen functions */ - void (*move_cursor)(Driver *drv, int row, int col); - void (*hide_text_cursor)(Driver *drv); - void (*set_attr)(Driver *drv, int row, int col, int attr, int count); - void (*scroll_up)(Driver *drv, int top, int bot); - void (*stack_screen)(Driver *drv); - void (*unstack_screen)(Driver *drv); - void (*discard_screen)(Driver *drv); - /* sound routines */ - int (*init_fm)(Driver *drv); - void (*buzzer)(Driver *drv, int kind); - int (*sound_on)(Driver *drv, int frequency); - void (*sound_off)(Driver *drv); - void (*mute)(Driver *drv); - - int (*diskp)(Driver *drv); - int (*get_char_attr)(Driver *drv); - void (*put_char_attr)(Driver *drv, int char_attr); - void (*delay)(Driver *drv, int ms); - void (*set_keyboard_timeout)(Driver *drv, int ms); - void (*flush)(Driver *drv); -}; - -#define STD_DRIVER_STRUCT(name_, desc_) \ - { \ - #name_, desc_, \ - name_##_init, \ - name_##_validate_mode, \ - name_##_get_max_screen, \ - name_##_terminate, \ - name_##_pause, \ - name_##_resume, \ - name_##_schedule_alarm, \ - name_##_window, \ - name_##_resize, \ - name_##_redraw, \ - name_##_read_palette, \ - name_##_write_palette, \ - name_##_read_pixel, \ - name_##_write_pixel, \ - name_##_read_span, \ - name_##_write_span, \ - name_##_get_truecolor, \ - name_##_put_truecolor, \ - name_##_set_line_mode, \ - name_##_draw_line, \ - name_##_display_string, \ - name_##_save_graphics, \ - name_##_restore_graphics, \ - name_##_get_key, \ - name_##_key_cursor, \ - name_##_key_pressed, \ - name_##_wait_key_pressed, \ - name_##_unget_key, \ - name_##_shell, \ - name_##_set_video_mode, \ - name_##_put_string, \ - name_##_set_for_text, \ - name_##_set_for_graphics, \ - name_##_set_clear, \ - name_##_move_cursor, \ - name_##_hide_text_cursor, \ - name_##_set_attr, \ - name_##_scroll_up, \ - name_##_stack_screen, \ - name_##_unstack_screen, \ - name_##_discard_screen, \ - name_##_init_fm, \ - name_##_buzzer, \ - name_##_sound_on, \ - name_##_sound_off, \ - name_##_mute, \ - name_##_diskp, \ - name_##_get_char_attr, \ - name_##_put_char_attr, \ - name_##_delay, \ - name_##_set_keyboard_timeout, \ - name_##_flush \ - } - -/* Define the drivers to be included in the compilation: - - HAVE_CURSES_DRIVER Curses based disk driver - HAVE_X11_DRIVER XFractint code path - HAVE_GDI_DRIVER Win32 GDI driver - HAVE_WIN32_DISK_DRIVER Win32 disk driver -*/ -#if defined(XFRACT) -#define HAVE_X11_DRIVER 1 -#define HAVE_GDI_DRIVER 0 -#define HAVE_WIN32_DISK_DRIVER 0 -#endif -#if defined(MSDOS) -#define HAVE_X11_DRIVER 0 -#define HAVE_GDI_DRIVER 0 -#define HAVE_WIN32_DISK_DRIVER 0 -#endif -#if defined(_WIN32) -#define HAVE_X11_DRIVER 0 -#define HAVE_GDI_DRIVER 1 -#define HAVE_WIN32_DISK_DRIVER 1 -#endif - -extern int init_drivers(int *argc, char **argv); -extern void add_video_mode(Driver *drv, VIDEOINFO *mode); -extern void close_drivers(void); -extern Driver *driver_find_by_name(const char *name); - -extern Driver *g_driver; /* current driver in use */ - -/* always use a function for this one */ -extern void driver_set_video_mode(VIDEOINFO *mode); - -#define USE_DRIVER_FUNCTIONS 1 - -#if defined(USE_DRIVER_FUNCTIONS) - -extern int driver_validate_mode(VIDEOINFO *mode); -extern void driver_get_max_screen(int *xmax, int *ymax); -extern void driver_terminate(void); -// pause and resume are only used internally in drivers.c -extern void driver_schedule_alarm(int secs); -extern void driver_window(void); -extern int driver_resize(void); -extern void driver_redraw(void); -extern int driver_read_palette(void); -extern int driver_write_palette(void); -extern int driver_read_pixel(int x, int y); -extern void driver_write_pixel(int x, int y, int color); -extern void driver_read_span(int y, int x, int lastx, BYTE *pixels); -extern void driver_write_span(int y, int x, int lastx, BYTE *pixels); -extern void driver_get_truecolor(int x, int y, int *r, int *g, int *b, int *a); -extern void driver_put_truecolor(int x, int y, int r, int g, int b, int a); -extern void driver_set_line_mode(int mode); -extern void driver_draw_line(int x1, int y1, int x2, int y2, int color); -extern int driver_get_key(void); -extern void driver_display_string(int x, int y, int fg, int bg, const char *text); -extern void driver_save_graphics(void); -extern void driver_restore_graphics(void); -extern int driver_key_cursor(int row, int col); -extern int driver_key_pressed(void); -extern int driver_wait_key_pressed(int timeout); -extern void driver_unget_key(int key); -extern void driver_shell(void); -extern void driver_put_string(int row, int col, int attr, const char *msg); -extern void driver_set_for_text(void); -extern void driver_set_for_graphics(void); -extern void driver_set_clear(void); -extern void driver_move_cursor(int row, int col); -extern void driver_hide_text_cursor(void); -extern void driver_set_attr(int row, int col, int attr, int count); -extern void driver_scroll_up(int top, int bot); -extern void driver_stack_screen(void); -extern void driver_unstack_screen(void); -extern void driver_discard_screen(void); -extern int driver_init_fm(void); -extern void driver_buzzer(int kind); -extern int driver_sound_on(int frequency); -extern void driver_sound_off(void); -extern void driver_mute(void); -extern int driver_diskp(void); -extern int driver_get_char_attr(void); -extern void driver_put_char_attr(int char_attr); -extern void driver_delay(int ms); -extern void driver_set_keyboard_timeout(int ms); -extern void driver_flush(void); - -#else - -#define driver_validate_mode(mode_) (*g_driver->validate_mode)(g_driver, mode_) -#define driver_get_max_screen(xmax_, ymax_) (*g_driver->get_max_screen)(g_driver, xmax_, ymax_) -#define driver_terminate() (*g_driver->terminate)(g_driver) -// pause and resume are only used internally in drivers.c -#define void driver_schedule_alarm(_secs) (*g_driver->schedule_alarm)(g_driver, _secs) -#define driver_window() (*g_driver->window)(g_driver) -#define driver_resize() (*g_driver->resize)(g_driver) -#define driver_redraw() (*g_driver->redraw)(g_driver) -#define driver_read_palette() (*g_driver->read_palette)(g_driver) -#define driver_write_palette() (*g_driver->write_palette)(g_driver) -#define driver_read_pixel(_x, _y) (*g_driver->read_pixel)(g_driver, _x, _y) -#define driver_write_pixel(_x, _y, _color) (*g_driver->write_pixel)(g_driver, _x, _y, _color) -#define driver_read_span(_y, _x, _lastx, _pixels) (*g_driver->read_span(g_driver, _y, _x, _lastx, _pixels) -#define driver_write_span(_y, _x, _lastx, _pixels) (*g_driver->write_span)(g_driver, _y, _x, _lastx, _pixels) -#define driver_get_truecolor(_x,_y, _r,_g,_b,_a) (*g_driver->get_truecolor)(g_driver, _x, _y, _r, _g, _b, _a) -#define driver_put_truecolor(_x,_y, _r,_g,_b,_a) (*g_driver->put_trueoclor)(g_driver, _x, _y, _r, _g, _b, _a) -#define driver_set_line_mode(_m) (*g_driver->set_line_mode)(g_driver, _m) -#define driver_draw_line(x1_, y1_, x2_, y2_, clr_) (*g_driver->draw_line)(g_driver, x1_, y1_, x1_, y2_, clr_) -#define driver_display_string(x_,y_,fg_,bg_,str_) (*g_driver->display_string)(g_driver, x_, y_, fg_, bg_, str_) -#define driver_save_graphics() (*g_driver->save_graphics)(g_driver) -#define driver_restore_graphics() (*g_driver->restore_graphics)(g_driver) -#define driver_get_key() (*g_driver->get_key)(g_driver) -#define driver_key_cursor(row_, col_) (*g_driver->key_cursor)(g_driver, row_, col_) -#define driver_key_pressed() (*g_driver->key_pressed)(g_driver) -#define driver_wait_key_pressed(timeout_) (*g_driver->wait_key_pressed)(g_driver, timeout_) -#define driver_unget_key(key_) (*g_driver->unget_key)(g_driver, key_) -#define driver_shell() (*g_driver->shell)(g_driver) -#define driver_put_string(_row, _col, _attr, _msg) (*g_driver->put_string)(g_driver, _row, _col, _attr, _msg) -#define driver_set_for_text() (*g_driver->set_for_text)(g_driver) -#define driver_set_for_graphics() (*g_driver->set_for_graphics)(g_driver) -#define driver_set_clear() (*g_driver->set_clear)(g_driver) -#define driver_move_cursor(_row, _col) (*g_driver->move_cursor)(g_driver, _row, _col) -#define driver_hide_text_cursor() (*g_driver->hide_text_cursor)(g_driver) -#define driver_set_attr(_row, _col, _attr, _count) (*g_driver->set_attr)(g_driver, _row, _col, _attr, _count) -#define driver_scroll_up(_top, _bot) (*g_driver->scroll_up)(g_driver, _top, _bot) -#define driver_stack_screen() (*g_driver->stack_screen)(g_driver) -#define driver_unstack_screen() (*g_driver->unstack_screen)(g_driver) -#define driver_discard_screen() (*g_driver->discard_screen)(g_driver) -#define driver_init_fm() (*g_driver->init_fm)(g_driver) -#define driver_buzzer(_kind) (*g_driver->buzzer)(g_driver, _kind) -#define driver_sound_on(_freq) (*g_driver->sound_on)(g_driver, _freq) -#define driver_sound_off() (*g_driver->sound_off)(g_driver) -#define driver_mute() (*g_driver->mute)(g_driver) -#define driver_diskp() (*g_driver->diskp)(g_driver) -#define driver_get_char_attr() (*g_driver->get_char_attr)(g_driver) -#define driver_put_char_attr(char_attr_) (*g_driver->put_char_attr)(g_driver, char_attr_) -#define driver_delay(ms_) (*g_driver->delay)(g_driver, ms_) -#define driver_set_keyboard_timeout(ms_) (*g_driver->set_keyboard_timeout)(g_driver, ms_) -#define driver_flush() (*g_driver->flush)(g_driver) - -#endif - -#endif /* DRIVERS_H */ diff --git a/fractint/headers/externs.h b/fractint/headers/externs.h deleted file mode 100644 index 79d82278e..000000000 --- a/fractint/headers/externs.h +++ /dev/null @@ -1,624 +0,0 @@ -#ifndef EXTERNS_H -#define EXTERNS_H - -#if 0 -/* #ifndef DEBUG */ -#define DEBUG 1 -#endif - - -/* keep var names in column 30 for sorting via sort /+30 out */ -extern int g_adapter; /* index into g_video_table[] */ -extern AlternateMath alternatemath[]; /* alternate math function pointers */ -extern int Ambient; /* Ambient= parameter value */ -extern int g_and_color; /* AND mask for iteration to get color index */ -extern struct MP Ans; -extern int Ap1deg; -extern int AplusOne; -extern int askvideo; -extern float aspectdrift; -extern int attractors; -extern int attrperiod[]; -extern _CMPLX attr[]; -extern int autobrowse; -extern char autoname[]; -extern char autoshowdot; -extern int AutoStereo_depth; -extern double AutoStereo_width; -extern BYTE back_color[]; -extern int g_bad_config; -extern int bad_code_count; -extern int bad_outside; -extern int bad_value; -extern long bailout; -extern enum bailouts bailoutest; -extern int basehertz; -extern int basin; -extern int bf_save_len; -extern int bfdigits; -extern int biomorph; -extern unsigned int bits; -extern int bitshift; -extern int bitshiftless1; -extern BYTE block[]; -extern int blue_bright; -extern int blue_crop_left; -extern int blue_crop_right; -extern int boxcolor; -extern int boxcount; -extern int boxvalues[]; -extern int boxx[]; -extern int boxy[]; -extern int BRIEF; -extern char browsemask[13]; -extern char browsename[]; -extern int browsing; -extern char brwscheckparms; -extern char brwschecktype; -extern char busy; -extern long calctime; -extern int (* calctype)(void); -extern int calc_status; -extern char calibrate; -extern int checkcurdir; -extern int g_checked_vvs; -extern long cimag; -extern double closenuff; -extern double closeprox; -extern _CMPLX coefficient; -extern int col; -extern int color; -extern char colorfile[]; -extern long coloriter; -extern int colorpreloaded; -extern int colors; -extern int colorstate; -extern int g_color_bright; /* brightest color in palette */ -extern int g_color_dark; /* darkest color in palette */ -extern int g_color_medium; /* nearest to medbright grey in palette */ -extern char CommandComment[4][MAXCMT]; -extern char CommandFile[FILE_MAX_PATH]; -extern char CommandName[ITEMNAMELEN + 1]; -extern int comparegif; -extern long con; -extern double cosx; -extern int cpu; -extern long creal; -extern int curcol; -extern int curpass; -extern int currow; -extern int cyclelimit; -extern int c_exp; -extern double d1overd; -extern BYTE g_dac_box[256][3]; -extern int g_dac_count; -extern int g_dac_learn; -extern double ddelmin; -extern int debugflag; -extern int decimals; -extern BYTE decoderline[]; -extern int decomp[]; -extern int degree; -extern long delmin; -extern long delx2; -extern long delx; -extern LDBL delxx2; -extern LDBL delxx; -extern long dely2; -extern long dely; -extern LDBL delyy2; -extern LDBL delyy; -extern float depthfp; -extern unsigned long dif_counter; -extern unsigned long dif_limit; -extern int disk16bit; -extern int g_disk_flag; /* disk video active flag */ -extern int disktarga; -extern int display3d; -extern long distest; -extern int distestwidth; -extern float distfp; -extern int Distribution; -extern int dither_flag; -extern char dontreadcolor; -extern int dotmode; -extern int doublecaution; -extern double dpx; -extern double dpy; -extern char drawmode; -extern BYTE dstack[]; -extern U16 dv_handle; -extern double * dx0; -extern double * dx1; -extern double (_fastcall * dxpixel)(void); /* set in FRACTALS.C */ -extern double dxsize; -extern double * dy0; -extern double * dy1; -extern double (_fastcall * dypixel)(void); /* set in FRACTALS.C */ -extern double dysize; -//extern int EPSFileType; -extern int escape_exit; -extern BYTE exitmode; -extern int evolving; -extern U16 evolve_handle; -extern int g_eye_separation; -extern float eyesfp; -extern int fastrestore; -extern long FgHalf; -extern double fgLimit; -extern long FgOne; -extern long FgTwo; -extern int gridsz; -extern double fiddlefactor; -extern double fiddle_reduction; -extern float fileaspectratio; -extern int filecolors; -extern int filetype; -extern int filexdots; -extern int fileydots; -extern char file_name_stack[16][13]; -extern int fillcolor; -extern float finalaspectratio; -extern int finattract; -extern int finishrow; -extern int first_init; -extern char floatflag; -extern double floatmax; -extern double floatmin; -extern _CMPLX * floatparm; -extern int fm_attack; -extern int fm_decay; -extern int fm_release; -extern int fm_sustain; -extern int fm_wavetype; -extern int fm_vol; /*volume of OPL-3 soundcard output*/ -extern int forcesymmetry; -extern char FormFileName[]; -extern char FormName[]; -extern int fpu; -extern int fractype; -extern char * fract_dir1; -extern char * fract_dir2; -extern char fromtext_flag; -extern long fudge; -extern int functionpreloaded; -extern double f_at_rad; -extern double f_radius; -extern double f_xcenter; -extern double f_ycenter; -extern U16 gene_handle; -extern int get_corners(void); -extern int gif87a_flag; -extern char gifmask[]; -extern char Glasses1Map[]; -extern int g_glasses_type; -extern int g_good_mode; /* video mode ok? */ -extern int g_got_real_dac; /* loaddac worked, really got a dac */ -extern int got_status; -extern char grayflag; -extern char GreyFile[]; -extern int hasinverse; -extern int haze; -extern unsigned int height; -extern float heightfp; -extern int helpmode; -extern int hi_atten; -extern U16 history; -extern char IFSFileName[]; -extern char IFSName[]; -extern float * ifs_defn; -extern int ifs_type; -extern int imgboxcount; -extern U16 imgboxhandle; -extern char image_map; -extern int init3d[20]; -extern _CMPLX init; -extern int initbatch; -extern int initcyclelimit; -extern int g_init_mode; -extern _CMPLX initorbit; -extern int initsavetime; -extern int inside; -extern char insufficient_ifs_mem[]; -extern int integerfractal; -extern double inversion[]; -extern int invert; -extern int g_is_true_color; -extern short ismand; -extern int ixstart; -extern int ixstop; -extern int iystart; -extern int iystop; -extern char * JIIMleftright[]; -extern char * JIIMmethod[]; -extern int juli3Dmode; -extern char * juli3Doptions[]; -extern int julibrot; -extern int kbdcount; -extern int keep_scrn_coords; -extern int keybuffer; -extern long l16triglim; -extern int LastInitOp; -extern unsigned LastOp; -extern int lastorbittype; -extern _LCMPLX lattr[]; -extern long lclosenuff; -extern _LCMPLX lcoefficient; -extern int ldcheck; -extern char LFileName[]; -extern char light_name[]; -extern BYTE * line_buff; -extern _LCMPLX linit; -extern _LCMPLX linitorbit; -extern long linitx; -extern long linity; -extern long llimit2; -extern long llimit; -extern long lmagnitud; -extern char LName[]; -extern _LCMPLX lnew; -extern int loaded3d; -extern int LodPtr; -extern int Log_Auto_Calc; -extern int Log_Calc; -extern int Log_Fly_Calc; -extern long LogFlag; -extern BYTE * LogTable; -extern _LCMPLX lold; -extern _LCMPLX * longparm; -extern int lookatmouse; -extern _LCMPLX lparm2; -extern _LCMPLX lparm; -//extern int LPTNumber; -extern long ltempsqrx; -extern long ltempsqry; -extern _LCMPLX ltmp; -extern long * lx0; -extern long * lx1; -extern long (_fastcall * lxpixel)(void); /* set in FRACTALS.C */ -extern long * ly0; -extern long * ly1; -extern long (_fastcall * lypixel)(void); /* set in FRACTALS.C */ -extern int lzw[2]; -extern long l_at_rad; -extern MATRIX m; -extern double magnitude; -extern enum Major major_method; -extern BYTE * mapdacbox; -extern int mapset; -extern char MAP_name[]; -extern int matherr_ct; -extern double math_tol[2]; -extern int maxcolor; -extern long maxct; -extern char maxfn; -extern long maxit; -extern int maxlinelength; -extern long MaxLTSize; -extern unsigned Max_Args; -extern unsigned Max_Ops; -extern long maxptr; -extern int max_colors; -extern int max_kbdcount; -extern int maxhistory; -extern int max_rhombus_depth; -extern int minbox; -extern enum Minor minor_method; -extern int minstack; -extern int minstackavail; -extern int g_mode_7_text; /* for egamono and hgc */ -extern MOREPARAMS moreparams[]; -extern struct MP mpAp1deg; -extern struct MP mpAplusOne; -extern struct MPC MPCone; -extern struct MPC * MPCroots; -extern struct MPC mpctmpparm; -extern struct MP mpd1overd; -extern struct MP mpone; -extern int MPOverflow; -extern struct MP mproverd; -extern struct MP mpt2; -extern struct MP mpthreshold; -extern struct MP mptmpparm2x; -extern double mxmaxfp; -extern double mxminfp; -extern double mymaxfp; -extern double myminfp; -extern int name_stack_ptr; -extern _CMPLX g_new; -extern char newodpx; -extern char newodpy; -extern double newopx; -extern double newopy; -extern int neworbittype; -extern int nextsavedincr; -extern int no_sub_images; -extern int no_mag_calc; -extern int nobof; -extern int numaffine; -extern unsigned numcolors; -extern const int numtrigfn; -extern int num_fractal_types; -extern int num_worklist; -extern int nxtscreenflag; -extern int Offset; -extern int g_ok_to_print; -extern _CMPLX old; -extern long oldcoloriter; -extern BYTE olddacbox[256][3]; -extern U16 oldhistory_handle; -extern int old_demm_colors; -extern char old_stdcalcmode; -extern char odpx; -extern char odpy; -extern double opx; -extern double opy; -extern int orbitsave; -extern int orbit_color; -extern int orbit_delay; -extern long orbit_interval; -extern int orbit_ptr; -extern char orgfrmdir[]; -extern int orgfrmsearch; -extern float originfp; -extern int (* outln) (BYTE *, int); -extern void (* outln_cleanup) (void); -extern int outside; -extern int overflow; -extern int overlay3d; -extern char fract_overwrite; -extern double ox3rd; -extern double oxmax; -extern double oxmin; -extern double oy3rd; -extern double oymax; -extern double oymin; -extern double param[]; -extern double paramrangex; -extern double paramrangey; -extern double parmzoom; -extern _CMPLX parm2; -extern _CMPLX parm; -extern int passes; -extern int g_patch_level; -extern int periodicitycheck; -extern struct fls * pfls; -extern int pixelpi; -extern void (_fastcall * plot)(int,int,int); -extern double plotmx1; -extern double plotmx2; -extern double plotmy1; -extern double plotmy2; -extern int polyphony; -extern unsigned posp; -extern int pot16bit; -extern int potflag; -extern double potparam[]; -#ifndef XFRACT -extern U16 prefix[]; -#endif -extern char preview; -extern int previewfactor; -extern int px; -extern int py; -extern U16 prmboxhandle; -extern int prmboxcount; -extern int pseudox; -extern int pseudoy; -extern void (_fastcall * putcolor)(int,int,int); -extern _CMPLX pwr; -extern double qc; -extern double qci; -extern double qcj; -extern double qck; -extern int quick_calc; -extern int RANDOMIZE; -extern int * ranges; -extern int rangeslen; -extern int RAY; -extern char ray_name[]; -extern char readname[]; -extern long realcoloriter; -extern int g_really_ega; /* "really an EGA" (faking a VGA) flag */ -extern char recordcolors; -extern int red_bright; -extern int red_crop_left; -extern int red_crop_right; -extern int g_release; -extern int resave_flag; -extern int reset_periodicity; -extern U16 resume_info; -extern int resume_len; -extern int resuming; -extern int rflag; -extern char rlebuf[]; -extern int rhombus_stack[]; -extern int root; -extern _CMPLX * roots; -extern int rotate_hi; -extern int rotate_lo; -extern double roverd; -extern int row; -extern int g_row_count; /* row-counter for decoder and out_line */ -extern double rqlim2; -extern double rqlim; -extern int rseed; -extern long savebase; -extern _CMPLX SaveC; -extern int savedac; -extern char savename[]; -extern long saveticks; -extern int save_orbit[]; -extern int save_release; -extern int save_system; -extern int scale_map[]; -extern float screenaspect; -extern char scrnfile[]; -extern struct SearchPath searchfor; -extern int set_orbit_corners; -extern char showbox; -extern int showdot; -extern int showfile; -extern int show_orbit; -extern double sinx; -extern int sizedot; -extern short sizeofstring[]; -extern short skipxdots; -extern short skipydots; -extern int g_slides; -extern int Slope; -extern int soundflag; -extern int sound_rollover; -extern char speed_prompt[]; -extern void (_fastcall* standardplot)(int,int,int); -extern char start_showorbit; -extern int started_resaves; -extern _CMPLX staticroots[]; -extern char stdcalcmode; -extern char stereomapname[]; -extern int StoPtr; -extern int stoppass; -extern unsigned int strlocn[]; -extern BYTE suffix[]; -#if defined(_WIN32) -extern char supervga_list[]; -#else -extern char supervga_list; -#endif -extern int g_svga_type; /* SuperVGA video adapter type */ -extern double sx3rd; -extern int sxdots; -extern double sxmax; -extern double sxmin; -extern int sxoffs; -extern double sy3rd; -extern int sydots; -extern double symax; -extern double symin; -extern int symmetry; -extern int syoffs; -extern char s_makepar[]; -extern int tabmode; -extern int taborhelp; -extern int Targa_Out; -extern int Targa_Overlay; -extern char temp1[]; -extern double tempsqrx; -extern double tempsqry; -extern BYTE teststring[]; -extern int g_text_cbase; /* g_text_col is relative to this */ -extern int g_text_col; /* current column in text mode */ -extern int g_text_rbase; /* g_text_row is relative to this */ -extern int g_text_row; /* current row in text mode */ -extern unsigned int this_gen_rseed; -extern unsigned * tga16; -extern long * tga32; -extern char three_pass; -extern double threshold; -extern int timedsave; -extern int timerflag; -extern long timer_interval; -extern long timer_start; -extern _CMPLX tmp; -extern char tempdir[]; -extern double toosmall; -extern int totpasses; -extern long total_formula_mem; -extern int transparent[]; -extern BYTE trigndx[]; -extern int truecolor; -extern int truemode; -extern char tstack[]; -extern double twopi; -extern VOIDPTR typespecific_workarea; -extern char useinitorbit; -extern int use_grid; -extern BYTE usemag; -extern short uses_ismand; -extern short uses_p1; -extern short uses_p2; -extern short uses_p3; -extern short uses_p4; -extern short uses_p5; -extern int use_old_distest; -extern int use_old_period; -extern int using_jiim; -extern int usr_biomorph; -extern long usr_distest; -extern char usr_floatflag; -extern int usr_periodicitycheck; -extern char usr_stdcalcmode; -extern int g_vesa_x_res; -extern int g_vesa_y_res; -extern struct videoinfo g_video_entry; -extern VIDEOINFO g_video_table[]; -extern int g_video_table_len; -extern int video_cutboth; -extern int g_video_scroll; -extern int g_video_start_x; -extern int g_video_start_y; -extern int g_video_type; /* video adapter type */ -extern VECTOR view; -extern int viewcrop; -extern float viewreduction; -extern int viewwindow; -extern int viewxdots; -extern int viewydots; -extern int g_virtual_screens; -extern unsigned vsp; -extern int g_vxdots; -extern int g_which_image; -extern float widthfp; -extern char workdir[]; -extern WORKLIST worklist[MAXCALCWORK]; -extern int workpass; -extern int worksym; -extern long x3rd; -extern int xadjust; -extern double xcjul; -extern int xdots; -extern long xmax; -extern long xmin; -extern int xshift1; -extern int xshift; -extern int xtrans; -extern double xx3rd; -extern int xxadjust1; -extern int xxadjust; -extern double xxmax; -extern double xxmin; -extern long XXOne; -extern int xxstart; -extern int xxstop; -extern long y3rd; -extern int yadjust; -extern double ycjul; -extern int ydots; -extern long ymax; -extern long ymin; -extern int yshift1; -extern int yshift; -extern int ytrans; -extern double yy3rd; -extern int yyadjust1; -extern int yyadjust; -extern int yyadjust; -extern double yymax; -extern double yymin; -extern int yystart; -extern int yystop; -extern double zbx; -extern double zby; -extern double zdepth; -extern int zdots; -extern int zoomoff; -extern int zrotate; -extern int zscroll; -extern double zskew; -extern double zwidth; - -#ifdef XFRACT -extern int fake_lut; -#endif - -#endif diff --git a/fractint/headers/fmath.h b/fractint/headers/fmath.h deleted file mode 100644 index 6e3d2447c..000000000 --- a/fractint/headers/fmath.h +++ /dev/null @@ -1,165 +0,0 @@ -#ifndef FMATH_H -#define FMATH_H - -/* FMath.h (C) 1989, Mark C. Peterson, CompuServe [70441,3353] - All rights reserved. - - Code may be used in any program provided the author is credited - either during program execution or in the documentation. Source - code may be distributed only in combination with public domain or - shareware source code. Source code may be modified provided the - copyright notice and this message is left unchanged and all - modifications are clearly documented. - - I would appreciate a copy of any work which incorporates this code, - however this is optional. - - Mark C. Peterson - 128 Hamden Ave., F - Waterbury, CT 06704 - (203) 754-1162 - - Notes below document changes to Mark's original file: - - Date Change Changer - ============================================================ - 07-16-89 - Added sqrt define per Mark's suggestion TIW - 07-26-89 - Added documentation and complex support MCP -*/ - -/***************** - * Documentation * - ***************** - - #include "fmath.h" - float x, y, z; - int Pot, Fudge; - - 23-bit accuracy (limit of type float) - Regular Implementation Fast Math Implementation - -------------------------------------------------------------------- - z = x + y; fAdd(x, y, z); - z = x * y; fMul(x, y, z); - z = x * x; fSqr(x, z); - z = x / y; fDiv(x, y, z); - z = x * 2; fShift(x, 1, z); - z = x * 16; fShift(x, 4, z); - z = x / 32; fShift(x, -5, z); - z = x / (pow(2.0, (double)Pot)); fShift(x, -Pot, z); - z = (float)Pot * (1L << Fudge); Fg2Float(Pot, Fudge, z); - Pot = (int)(z / (1L << Fudge)); Pot = Float2Fg(z, Fudge); - - Complex numbers using fComplex structures - z = x**2 fSqrZ(&x, &z); mod updated - z.mod = (z.x*z.x)+(z.y*z.y) fModZ(&z); mod updated - z = 1 / x fInvZ(&x, &z); mod updated - z = x * y fMulZ(&x, &y, &z); mod updated - z = x / y fDivZ(&x, &y, &z); mod updated - - 16-bit accuracy - Regular Implementation Fast Math Implementation - -------------------------------------------------------------------- - z = x * y; fMul16(x, y, z); - z = x * x; fSqr16(x, z); - - 14-bit accuracy - Regular Implementation Fast Math Implementation - -------------------------------------------------------------------- - z = log(x); fLog14(x, z); - z = exp(x); fExp14(x, z); - z = pow(x, y); fPow14(x, y, z); - - 12-bit accuracy - Regular Implementation Fast Math Implementation - -------------------------------------------------------------------- - z = sin(x); fSin12(x, z); - z = cos(x); fCos12(x, z); - z = sinh(x); fSinh12(x, z); - z = cosh(x); fCosh12(x, z); - - Complex numbers using fComplex structures - z = sin(x) fSinZ(&x, &z); - z = cos(x) fCosZ(&x, &z); - z = tan(x) fTagZ(&x, &z); - z = sinh(x) fSinhZ(&x, &z); - z = cosh(x) fCoshZ(&x, &z); - z = tanh(x) fCoshZ(&x, &z); - -Just be sure to declare x, y, and z as type floats instead of type double. -*/ - -long -#ifndef XFRACT - RegFg2Float(long x, char FudgeFact), - RegSftFloat(long x, char Shift), -#else - RegFg2Float(long x, int FudgeFact), - RegSftFloat(long x, int Shift), -#endif - RegFloat2Fg(long x, int Fudge), - RegAddFloat(long x, long y), - RegDivFloat(long x, long y), - RegMulFloat(long x, long y), - RegSqrFloat(long x), - RegSubFloat(long x, long y); -long - r16Mul(long x, long y), - r16Sqr(long x); -int - sin13(long x), - cos13(long x), - FastCosine(int x), - FastSine(int x); -long - FastHypCosine(int x), - FastHypSine(int x), - sinh13(long x), - cosh13(long x); -long LogFudged(unsigned long x, int Fudge); -long LogFloat14(unsigned long x); -unsigned long ExpFudged(long x, int Fudge); -long ExpFloat14(long x); - -#define fAdd(x, y, z) (void)((*(long*)&z) = RegAddFloat(*(long*)&x, *(long*)&y)) -#define fMul(x, y, z) (void)((*(long*)&z) = RegMulFloat(*(long*)&x, *(long*)&y)) -#define fDiv(x, y, z) (void)((*(long*)&z) = RegDivFloat(*(long*)&x, *(long*)&y)) -#define fSub(x, y, z) (void)((*(long*)&z) = RegSubFloat(*(long*)&x, *(long*)&y)) -#define fMul16(x, y, z) (void)((*(long*)&z) = r16Mul(*(long*)&x, *(long*)&y)) -#define fSqr16(x, z) (void)((*(long*)&z) = r16Sqr(*(long*)&x)) -#define fSqr(x, z) (void)((*(long*)&z) = RegSqrFloat(*(long*)&x)) -#define fShift(x, Shift, z) (void)((*(long*)&z) = \ - RegSftFloat(*(long*)&x, Shift)) -#define Fg2Float(x, f, z) (void)((*(long*)&z) = RegFg2Float(x, f)) -#define Float2Fg(x, f) RegFloat2Fg(*(long*)&x, f) -#define fSin12(x, z) (void)((*(long*)&z) = \ - RegFg2Float((long)sin13(Float2Fg(x, 13)), 13)) -#define fCos12(x, z) (void)((*(long*)&z) = \ - RegFg2Float((long)cos13(Float2Fg(x, 13)), 13)) -#define fSinh12(x, z) (void)((*(long*)&z) = \ - RegFg2Float(sinh13(Float2Fg(x, 13)), 13)) -#define fCosh12(x, z) (void)((*(long*)&z) = \ - RegFg2Float(cosh13(Float2Fg(x, 13)), 13)) -#define fLog14(x, z) (void)((*(long*)&z) = \ - RegFg2Float(LogFloat14(*(long*)&x), 16)) -#define fExp14(x, z) (void)((*(long*)&z) = ExpFloat14(*(long*)&x)); -#define fPow14(x, y, z) fLog14(x, z); fMul16(z, y, z); fExp14(z, z) -#define fSqrt14(x, z) fLog14(x, z); fShift(z, -1, z); fExp14(z, z) - -struct fComplex { - float x, y, mod; -}; - -void - fSqrZ(struct fComplex *x, struct fComplex *z), - fMod(struct fComplex *x), - fInvZ(struct fComplex *x, struct fComplex *z), - fMulZ(struct fComplex *x, struct fComplex *y, struct fComplex *z), - fDivZ(struct fComplex *x, struct fComplex *y, struct fComplex *z), - fSinZ(struct fComplex *x, struct fComplex *z), - fCosZ(struct fComplex *x, struct fComplex *z), - fTanZ(struct fComplex *x, struct fComplex *z), - fSinhZ(struct fComplex *x, struct fComplex *z), - fCoshZ(struct fComplex *x, struct fComplex *z), - fTanhZ(struct fComplex *x, struct fComplex *z); - -#endif diff --git a/fractint/headers/fractint.h b/fractint/headers/fractint.h deleted file mode 100644 index b9cdb8875..000000000 --- a/fractint/headers/fractint.h +++ /dev/null @@ -1,1197 +0,0 @@ -/* FRACTINT.H - common structures and values for the FRACTINT routines */ - -#ifndef FRACTINT_H -#define FRACTINT_H - -typedef BYTE BOOLEAN; - -#ifndef C6 -#ifndef _fastcall -#define _fastcall /* _fastcall is a Microsoft C6.00 extension */ -#endif -#endif - -/* Returns the number of items in an array declared of fixed size, i.e: - int stuff[100]; - NUM_OF(stuff) returns 100. -*/ -#define NUM_OF(ary_) (sizeof(ary_)/sizeof(ary_[0])) - -#ifndef XFRACT -#define clock_ticks() clock() -#endif - -#ifdef XFRACT -#define difftime(now,then) ((now)-(then)) -#endif - -#define NUM_BOXES 4096 -/* driver_buzzer() codes */ -#define BUZZER_COMPLETE 0 -#define BUZZER_INTERRUPT 1 -#define BUZZER_ERROR 2 - -/* stopmsg() flags */ -#define STOPMSG_NO_STACK 1 -#define STOPMSG_CANCEL 2 -#define STOPMSG_NO_BUZZER 4 -#define STOPMSG_FIXED_FONT 8 -#define STOPMSG_INFO_ONLY 16 - -/* g_video_type video types */ -#define VIDEO_TYPE_HGC 1 -#define VIDEO_TYPE_EGA 3 -#define VIDEO_TYPE_CGA 2 -#define VIDEO_TYPE_MCGA 4 -#define VIDEO_TYPE_VGA 5 - -/* for gotos in former FRACTINT.C pieces */ -#define RESTART 1 -#define IMAGESTART 2 -#define RESTORESTART 3 -#define CONTINUE 4 - -#define SLIDES_OFF 0 -#define SLIDES_PLAY 1 -#define SLIDES_RECORD 2 - -/* fullscreen_choice options */ -#define CHOICE_RETURN_KEY 1 -#define CHOICE_MENU 2 -#define CHOICE_HELP 4 -#define CHOICE_INSTRUCTIONS 8 -#define CHOICE_CRUNCH 16 -#define CHOICE_NOT_SORTED 32 - -/* calc_status values */ -#define CALCSTAT_NO_FRACTAL -1 -#define CALCSTAT_PARAMS_CHANGED 0 -#define CALCSTAT_IN_PROGRESS 1 -#define CALCSTAT_RESUMABLE 2 -#define CALCSTAT_NON_RESUMABLE 3 -#define CALCSTAT_COMPLETED 4 - -#define CMDARG_FRACTAL_PARAM 1 -#define CMDARG_3D_PARAM 2 -#define CMDARG_3D_YES 4 -#define CMDARG_RESET 8 - -#define CMDFILE_AT_CMDLINE 0 -#define CMDFILE_SSTOOLS_INI 1 -#define CMDFILE_AT_AFTER_STARTUP 2 -#define CMDFILE_AT_CMDLINE_SETNAME 3 - -#define INPUTFIELD_NUMERIC 1 -#define INPUTFIELD_INTEGER 2 -#define INPUTFIELD_DOUBLE 4 - -#define SOUNDFLAG_OFF 0 -#define SOUNDFLAG_BEEP 1 -#define SOUNDFLAG_X 2 -#define SOUNDFLAG_Y 3 -#define SOUNDFLAG_Z 4 -#define SOUNDFLAG_ORBITMASK 0x07 -#define SOUNDFLAG_SPEAKER 0x08 -#define SOUNDFLAG_OPL3_FM 0x10 -#define SOUNDFLAG_MIDI 0x20 -#define SOUNDFLAG_QUANTIZED 0x40 -#define SOUNDFLAG_MASK 0x7F - -/* these are used to declare arrays for file names */ -#if defined(_WIN32) -#define FILE_MAX_PATH _MAX_PATH -#define FILE_MAX_DIR _MAX_DIR -#else -#ifdef XFRACT -#define FILE_MAX_PATH 256 /* max length of path+filename */ -#define FILE_MAX_DIR 256 /* max length of directory name */ -#else -#define FILE_MAX_PATH 80 /* max length of path+filename */ -#define FILE_MAX_DIR 80 /* max length of directory name */ -#endif -#endif -#define FILE_MAX_DRIVE 3 /* max length of drive letter */ - -/* -The filename limits were increased in Xfract 3.02. But alas, -in this poor program that was originally developed on the -nearly-brain-dead DOS operating system, quite a few things -in the UI would break if file names were bigger than DOS 8-3 -names. So for now humor us and let's keep the names short. -*/ -#define FILE_MAX_FNAME 64 /* max length of filename */ -#define FILE_MAX_EXT 64 /* max length of extension */ - -#define MAXMAXLINELENGTH 128 /* upper limit for maxlinelength for PARs */ -#define MINMAXLINELENGTH 40 /* lower limit for maxlinelength for PARs */ - -#define MSGLEN 80 /* handy buffer size for messages */ -#define MAXCMT 57 /* length of par comments */ -#define MAXPARAMS 10 /* maximum number of parameters */ -#define MAXPIXELS 32767 /* Maximum pixel count across/down the screen */ -#define OLDMAXPIXELS 2048 /* Limit of some old fixed arrays */ -#define MINPIXELS 10 /* Minimum pixel count across/down the screen */ -#define DEFAULTASPECT 1.0f /* Assumed overall screen dimensions, y/x */ -#define DEFAULTASPECTDRIFT 0.02f /* drift of < 2% is forced to 0% */ - -typedef struct tagDriver Driver; - -struct videoinfo { /* All we need to know about a Video Adapter */ - char name[26]; /* Adapter name (IBM EGA, etc) */ - char comment[26]; /* Comments (UNTESTED, etc) */ - int keynum; /* key number used to invoked this mode */ - /* 2-10 = F2-10, 11-40 = S,C,A{F1-F10} */ - int videomodeax; /* begin with INT 10H, AX=(this) */ - int videomodebx; /* ...and BX=(this) */ - int videomodecx; /* ...and CX=(this) */ - int videomodedx; /* ...and DX=(this) */ - /* NOTE: IF AX==BX==CX==0, SEE BELOW */ - int dotmode; /* video access method used by asm code */ - /* 1 == BIOS 10H, AH=12,13 (SLOW) */ - /* 2 == access like EGA/VGA */ - /* 3 == access like MCGA */ - /* 4 == Tseng-like SuperVGA*256 */ - /* 5 == P'dise-like SuperVGA*256 */ - /* 6 == Vega-like SuperVGA*256 */ - /* 7 == "Tweaked" IBM-VGA ...*256 */ - /* 8 == "Tweaked" SuperVGA ...*256 */ - /* 9 == Targa Format */ - /* 10 = Hercules */ - /* 11 = "disk video" (no screen) */ - /* 12 = 8514/A */ - /* 13 = CGA 320x200x4, 640x200x2 */ - /* 14 = Tandy 1000 */ - /* 15 = TRIDENT SuperVGA*256 */ - /* 16 = Chips&Tech SuperVGA*256 */ - int xdots; /* number of dots across the screen */ - int ydots; /* number of dots down the screen */ - int colors; /* number of colors available */ - Driver *driver; - }; - -typedef struct videoinfo VIDEOINFO; -#define INFO_ID "Fractal" -typedef struct fractal_info FRACTAL_INFO; - -/* - * Note: because non-MSDOS machines store structures differently, we have - * to do special processing of the fractal_info structure in loadfile.c. - * Make sure changes to the structure here get reflected there. - */ -#ifndef XFRACT -#define FRACTAL_INFO_SIZE sizeof(FRACTAL_INFO) -#else -/* This value should be the MSDOS size, not the Unix size. */ -#define FRACTAL_INFO_SIZE 504 -#endif - -#define FRACTAL_INFO_VERSION 17 /* file version, independent of system */ - /* increment this EVERY time the fractal_info structure changes */ - -/* TODO: instead of hacking the padding here, adjust the code that reads - this structure */ -#if defined(_WIN32) -#pragma pack(push, 1) -#endif -struct fractal_info /* for saving data in GIF file */ -{ - char info_id[8]; /* Unique identifier for info block */ - short iterationsold; /* Pre version 18.24 */ - short fractal_type; /* 0=Mandelbrot 1=Julia 2= ... */ - double xmin; - double xmax; - double ymin; - double ymax; - double creal; - double cimag; - short videomodeax; - short videomodebx; - short videomodecx; - short videomodedx; - short dotmode; - short xdots; - short ydots; - short colors; - short version; /* used to be 'future[0]' */ - float parm3; - float parm4; - float potential[3]; - short rseed; - short rflag; - short biomorph; - short inside; - short logmapold; - float invert[3]; - short decomp[2]; - short symmetry; - /* version 2 stuff */ - short init3d[16]; - short previewfactor; - short xtrans; - short ytrans; - short red_crop_left; - short red_crop_right; - short blue_crop_left; - short blue_crop_right; - short red_bright; - short blue_bright; - short xadjust; - short eyeseparation; - short glassestype; - /* version 3 stuff, release 13 */ - short outside; - /* version 4 stuff, release 14 */ - double x3rd; /* 3rd corner */ - double y3rd; - char stdcalcmode; /* 1/2/g/b */ - char useinitorbit; /* init Mandelbrot orbit flag */ - short calc_status; /* resumable, finished, etc */ - long tot_extend_len; /* total length of extension blocks in .gif file */ - short distestold; - short floatflag; - short bailoutold; - long calctime; - BYTE trigndx[4]; /* which trig functions selected */ - short finattract; - double initorbit[2]; /* init Mandelbrot orbit values */ - short periodicity; /* periodicity checking */ - /* version 5 stuff, release 15 */ - short pot16bit; /* save 16 bit continuous potential info */ - float faspectratio; /* finalaspectratio, y/x */ - short system; /* 0 for dos, 1 for windows */ - short release; /* release number, with 2 decimals implied */ - short flag3d; /* stored only for now, for future use */ - short transparent[2]; - short ambient; - short haze; - short randomize; - /* version 6 stuff, release 15.x */ - short rotate_lo; - short rotate_hi; - short distestwidth; - /* version 7 stuff, release 16 */ - double dparm3; - double dparm4; - /* version 8 stuff, release 17 */ - short fillcolor; - /* version 9 stuff, release 18 */ - double mxmaxfp; - double mxminfp; - double mymaxfp; - double myminfp; - short zdots; - float originfp; - float depthfp; - float heightfp; - float widthfp; - float distfp; - float eyesfp; - short orbittype; - short juli3Dmode; - short maxfn; - short inversejulia; - double dparm5; - double dparm6; - double dparm7; - double dparm8; - double dparm9; - double dparm10; - /* version 10 stuff, release 19 */ - long bailout; - short bailoutest; - long iterations; - short bf_math; - short bflength; - short yadjust; /* yikes! we left this out ages ago! */ - short old_demm_colors; - long logmap; - long distest; - double dinvert[3]; - short logcalc; - short stoppass; - short quick_calc; - double closeprox; - short nobof; - long orbit_interval; - short orbit_delay; - double math_tol[2]; - short future[7]; /* for stuff we haven't thought of yet */ -}; -#if defined(_WIN32) -#pragma pack(pop) -#endif - -#define ITEMNAMELEN 18 /* max length of names in .frm/.l/.ifs/.fc */ -struct history_info -{ - short fractal_type; - double xmin; - double xmax; - double ymin; - double ymax; - double creal; - double cimag; - double potential[3]; - short rseed; - short rflag; - short biomorph; - short inside; - long logmap; - double invert[3]; - short decomp; - short symmetry; - short init3d[16]; - short previewfactor; - short xtrans; - short ytrans; - short red_crop_left; - short red_crop_right; - short blue_crop_left; - short blue_crop_right; - short red_bright; - short blue_bright; - short xadjust; - short eyeseparation; - short glassestype; - short outside; - double x3rd; - double y3rd; - long distest; - short bailoutold; - BYTE trigndx[4]; - short finattract; - double initorbit[2]; - short periodicity; - short pot16bit; - short release; - short save_release; - short flag3d; - short transparent[2]; - short ambient; - short haze; - short randomize; - short rotate_lo; - short rotate_hi; - short distestwidth; - double dparm3; - double dparm4; - short fillcolor; - double mxmaxfp; - double mxminfp; - double mymaxfp; - double myminfp; - short zdots; - float originfp; - float depthfp; - float heightfp; - float widthfp; - float distfp; - float eyesfp; - short orbittype; - short juli3Dmode; - short major_method; - short minor_method; - double dparm5; - double dparm6; - double dparm7; - double dparm8; - double dparm9; - double dparm10; - long bailout; - short bailoutest; - long iterations; - short bf_math; - short bflength; - short yadjust; - short old_demm_colors; - char filename[FILE_MAX_PATH]; - char itemname[ITEMNAMELEN+1]; - unsigned char dac[256][3]; - char maxfn; - char stdcalcmode; - char three_pass; - char useinitorbit; - short logcalc; - short stoppass; - short ismand; - double closeprox; - short nobof; - double math_tol[2]; - short orbit_delay; - long orbit_interval; - double oxmin; - double oxmax; - double oymin; - double oymax; - double ox3rd; - double oy3rd; - short keep_scrn_coords; - char drawmode; -}; - -typedef struct history_info HISTORY; - -struct formula_info /* for saving formula data in GIF file */ -{ - char form_name[40]; - short uses_p1; - short uses_p2; - short uses_p3; - short uses_ismand; - short ismand; - short uses_p4; - short uses_p5; - short future[6]; /* for stuff we haven't thought of, yet */ -}; - -enum stored_at_values -{ - NOWHERE, - MEMORY, - DISK -}; - -#define NUMGENES 21 - -typedef struct evolution_info EVOLUTION_INFO; -/* - * Note: because non-MSDOS machines store structures differently, we have - * to do special processing of the evolution_info structure in loadfile.c and - * encoder.c. See decode_evolver_info() in general.c. - * Make sure changes to the structure here get reflected there. - */ -#ifndef XFRACT -#define EVOLVER_INFO_SIZE sizeof(evolution_info) -#else -/* This value should be the MSDOS size, not the Unix size. */ -#define EVOLVER_INFO_SIZE 200 -#endif - -struct evolution_info /* for saving evolution data in a GIF file */ -{ - short evolving; - short gridsz; - unsigned short this_gen_rseed; - double fiddlefactor; - double paramrangex; - double paramrangey; - double opx; - double opy; - short odpx; - short odpy; - short px; - short py; - short sxoffs; - short syoffs; - short xdots; - short ydots; - short mutate[NUMGENES]; - short ecount; /* count of how many images have been calc'ed so far */ - short future[68 - NUMGENES]; /* total of 200 bytes */ -}; - - -typedef struct orbits_info ORBITS_INFO; -/* - * Note: because non-MSDOS machines store structures differently, we have - * to do special processing of the orbits_info structure in loadfile.c and - * encoder.c. See decode_orbits_info() in general.c. - * Make sure changes to the structure here get reflected there. - */ -#ifndef XFRACT -#define ORBITS_INFO_SIZE sizeof(orbits_info) -#else -/* This value should be the MSDOS size, not the Unix size. */ -#define ORBITS_INFO_SIZE 200 -#endif - -struct orbits_info /* for saving orbits data in a GIF file */ -{ - double oxmin; - double oxmax; - double oymin; - double oymax; - double ox3rd; - double oy3rd; - short keep_scrn_coords; - char drawmode; - char dummy; /* need an even number of bytes */ - short future[74]; /* total of 200 bytes */ -}; - -#define MAXVIDEOMODES 300 /* maximum entries in fractint.cfg */ - -#define AUTOINVERT -123456.789 -#define ENDVID 22400 /* video table uses extra seg up to here */ - -#define N_ATTR 8 /* max number of attractors */ - -extern long l_at_rad; /* finite attractor radius */ -extern double f_at_rad; /* finite attractor radius */ - -#define NUMIFS 64 /* number of ifs functions in ifs array */ -#define IFSPARM 7 /* number of ifs parameters */ -#define IFS3DPARM 13 /* number of ifs 3D parameters */ - -struct moreparams -{ - int type; /* index in fractalname of the fractal */ - char *param[MAXPARAMS-4]; /* name of the parameters */ - double paramvalue[MAXPARAMS-4]; /* default parameter values */ -}; - -typedef struct moreparams MOREPARAMS; - -struct fractalspecificstuff -{ - char *name; /* name of the fractal */ - /* (leading "*" supresses name display) */ - char *param[4]; /* name of the parameters */ - double paramvalue[4]; /* default parameter values */ - int helptext; /* helpdefs.h HT_xxxx, -1 for none */ - int helpformula; /* helpdefs.h HF_xxxx, -1 for none */ - unsigned flags; /* constraints, bits defined below */ - float xmin; /* default XMIN corner */ - float xmax; /* default XMAX corner */ - float ymin; /* default YMIN corner */ - float ymax; /* default YMAX corner */ - int isinteger; /* 1 if integerfractal, 0 otherwise */ - int tojulia; /* mandel-to-julia switch */ - int tomandel; /* julia-to-mandel switch */ - int tofloat; /* integer-to-floating switch */ - int symmetry; /* applicable symmetry logic - 0 = no symmetry - -1 = y-axis symmetry (If No Params) - 1 = y-axis symmetry - -2 = x-axis symmetry (No Parms) - 2 = x-axis symmetry - -3 = y-axis AND x-axis (No Parms) - 3 = y-axis AND x-axis symmetry - -4 = polar symmetry (No Parms) - 4 = polar symmetry - 5 = PI (sin/cos) symmetry - 6 = NEWTON (power) symmetry - */ -#ifdef XFRACT - int (*orbitcalc)(); /* function that calculates one orbit */ -#else - int (*orbitcalc)(void); /* function that calculates one orbit */ -#endif - int (*per_pixel)(void); /* once-per-pixel init */ - int (*per_image)(void); /* once-per-image setup */ - int (*calctype)(void); /* name of main fractal function */ - int orbit_bailout; /* usual bailout value for orbit calc */ -}; - -struct alternatemathstuff -{ - int type; /* index in fractalname of the fractal */ - int math; /* kind of math used */ -#ifdef XFRACT - int (*orbitcalc)(); /* function that calculates one orbit */ -#else - int (*orbitcalc)(void); /* function that calculates one orbit */ -#endif - int (*per_pixel)(void); /* once-per-pixel init */ - int (*per_image)(void); /* once-per-image setup */ -}; - -typedef struct alternatemathstuff AlternateMath; - -/* defines for symmetry */ -#define NOSYM 0 -#define XAXIS_NOPARM -1 -#define XAXIS 1 -#define YAXIS_NOPARM -2 -#define YAXIS 2 -#define XYAXIS_NOPARM -3 -#define XYAXIS 3 -#define ORIGIN_NOPARM -4 -#define ORIGIN 4 -#define PI_SYM_NOPARM -5 -#define PI_SYM 5 -#define XAXIS_NOIMAG -6 -#define XAXIS_NOREAL 6 -#define NOPLOT 99 -#define SETUP_SYM 100 - -/* defines for inside/outside */ -#define ITER -1 -#define REAL -2 -#define IMAG -3 -#define MULT -4 -#define SUM -5 -#define ATAN -6 -#define FMOD -7 -#define TDIS -8 -#define ZMAG -59 -#define BOF60 -60 -#define BOF61 -61 -#define EPSCROSS -100 -#define STARTRAIL -101 -#define PERIOD -102 -#define FMODI -103 -#define ATANI -104 - -/* defines for bailoutest */ -enum bailouts { Mod, Real, Imag, Or, And, Manh, Manr }; -enum Major {breadth_first, depth_first, random_walk, random_run}; -enum Minor {left_first, right_first}; - -/* bitmask defines for fractalspecific flags */ -#define NOZOOM 1 /* zoombox not allowed at all */ -#define NOGUESS 2 /* solid guessing not allowed */ -#define NOTRACE 4 /* boundary tracing not allowed */ -#define NOROTATE 8 /* zoombox rotate/stretch not allowed */ -#define NORESUME 16 /* can't interrupt and resume */ -#define INFCALC 32 /* this type calculates forever */ -#define TRIG1 64 /* number of trig functions in formula */ -#define TRIG2 128 -#define TRIG3 192 -#define TRIG4 256 -#define WINFRAC 512 /* supported in WinFrac */ -#define PARMS3D 1024 /* uses 3d parameters */ -#define OKJB 2048 /* works with Julibrot */ -#define MORE 4096 /* more than 4 parms */ -#define BAILTEST 8192 /* can use different bailout tests */ -#define BF_MATH 16384 /* supports arbitrary precision */ -#define LD_MATH 32768 /* supports long double */ - - -/* more bitmasks for evolution mode flag */ -#define FIELDMAP 1 /*steady field varyiations across screen */ -#define RANDWALK 2 /* newparm = lastparm +- rand() */ -#define RANDPARAM 4 /* newparm = constant +- rand() */ -#define NOGROUT 8 /* no gaps between images */ - - -extern struct fractalspecificstuff fractalspecific[]; -extern struct fractalspecificstuff *curfractalspecific; - -#define DEFAULTFRACTALTYPE ".gif" -#define ALTERNATEFRACTALTYPE ".fra" - - -#ifndef sqr -#define sqr(x) ((x)*(x)) -#endif - -#ifndef lsqr -#define lsqr(x) (multiply((x),(x),bitshift)) -#endif - -#define CMPLXmod(z) (sqr((z).x)+sqr((z).y)) -#define CMPLXconj(z) ((z).y = -((z).y)) -#define LCMPLXmod(z) (lsqr((z).x)+lsqr((z).y)) -#define LCMPLXconj(z) ((z).y = -((z).y)) - -#define PER_IMAGE (fractalspecific[fractype].per_image) -#define PER_PIXEL (fractalspecific[fractype].per_pixel) -#define ORBITCALC (fractalspecific[fractype].orbitcalc) - -typedef _LCMPLX LCMPLX; - -/* 3D stuff - formerly in 3d.h */ -#ifndef dot_product -#define dot_product(v1,v2) ((v1)[0]*(v2)[0]+(v1)[1]*(v2)[1]+(v1)[2]*(v2)[2]) /* TW 7-09-89 */ -#endif - -#define CMAX 4 /* maximum column (4 x 4 matrix) */ -#define RMAX 4 /* maximum row (4 x 4 matrix) */ -#define DIM 3 /* number of dimensions */ - -typedef double MATRIX [RMAX] [CMAX]; /* matrix of doubles */ -typedef int IMATRIX [RMAX] [CMAX]; /* matrix of ints */ -typedef long LMATRIX [RMAX] [CMAX]; /* matrix of longs */ - -/* A MATRIX is used to describe a transformation from one coordinate -system to another. Multiple transformations may be concatenated by -multiplying their transformation matrices. */ - -typedef double VECTOR [DIM]; /* vector of doubles */ -typedef int IVECTOR [DIM]; /* vector of ints */ -typedef long LVECTOR [DIM]; /* vector of longs */ - -/* A VECTOR is an array of three coordinates [x,y,z] representing magnitude -and direction. A fourth dimension is assumed to always have the value 1, but -is not in the data structure */ - -#ifdef PI -#undef PI -#endif -#define PI 3.14159265358979323846 -#define SPHERE init3d[0] /* sphere? 1 = yes, 0 = no */ -#define ILLUMINE (FILLTYPE>4) /* illumination model */ - -/* regular 3D */ -#define XROT init3d[1] /* rotate x-axis 60 degrees */ -#define YROT init3d[2] /* rotate y-axis 90 degrees */ -#define ZROT init3d[3] /* rotate x-axis 0 degrees */ -#define XSCALE init3d[4] /* scale x-axis, 90 percent */ -#define YSCALE init3d[5] /* scale y-axis, 90 percent */ - -/* sphere 3D */ -#define PHI1 init3d[1] /* longitude start, 180 */ -#define PHI2 init3d[2] /* longitude end , 0 */ -#define THETA1 init3d[3] /* latitude start,-90 degrees */ -#define THETA2 init3d[4] /* latitude stop, 90 degrees */ -#define RADIUS init3d[5] /* should be user input */ - -/* common parameters */ -#define ROUGH init3d[6] /* scale z-axis, 30 percent */ -#define WATERLINE init3d[7] /* water level */ -#define FILLTYPE init3d[8] /* fill type */ -#define ZVIEWER init3d[9] /* perspective view point */ -#define XSHIFT init3d[10] /* x shift */ -#define YSHIFT init3d[11] /* y shift */ -#define XLIGHT init3d[12] /* x light vector coordinate */ -#define YLIGHT init3d[13] /* y light vector coordinate */ -#define ZLIGHT init3d[14] /* z light vector coordinate */ -#define LIGHTAVG init3d[15] /* number of points to average */ - -#ifndef TRUE -#define TRUE 1 -#define FALSE 0 -#endif - -/* Math definitions (normally in float.h) that are missing on some systems. */ -#ifndef FLT_MIN -#define FLT_MIN 1.17549435e-38 -#endif -#ifndef FLT_MAX -#define FLT_MAX 3.40282347e+38 -#endif -#ifndef DBL_EPSILON -#define DBL_EPSILON 2.2204460492503131e-16 -#endif - -#ifndef XFRACT -#define UPARR "\x18" -#define DNARR "\x19" -#define RTARR "\x1A" -#define LTARR "\x1B" -#define UPARR1 "\x18" -#define DNARR1 "\x19" -#define RTARR1 "\x1A" -#define LTARR1 "\x1B" -#define FK_F1 "F1" -#define FK_F2 "F2" -#define FK_F3 "F3" -#define FK_F4 "F4" -#define FK_F5 "F5" -#define FK_F6 "F6" -#define FK_F7 "F7" -#define FK_F8 "F8" -#define FK_F9 "F9" -#else -#define UPARR "K" -#define DNARR "J" -#define RTARR "L" -#define LTARR "H" -#define UPARR1 "up(K)" -#define DNARR1 "down(J)" -#define RTARR1 "left(L)" -#define LTARR1 "right(H)" -#define FK_F1 "Shift-1" -#define FK_F2 "Shift-2" -#define FK_F3 "Shift-3" -#define FK_F4 "Shift-4" -#define FK_F5 "Shift-5" -#define FK_F6 "Shift-6" -#define FK_F7 "Shift-7" -#define FK_F8 "Shift-8" -#define FK_F9 "Shift-9" -#endif - -#ifndef XFRACT -#define Fractint "Fractint" -#define FRACTINT "FRACTINT" -#else -#define Fractint "Xfractint" -#define FRACTINT "XFRACTINT" -#endif - -#define JIIM 0 -#define ORBIT 1 - -struct workliststuff /* work list entry for std escape time engines */ -{ - int xxstart; /* screen window for this entry */ - int xxstop; - int yystart; - int yystop; - int yybegin; /* start row within window, for 2pass/ssg resume */ - int sym; /* if symmetry in window, prevents bad combines */ - int pass; /* for 2pass and solid guessing */ - int xxbegin; /* start col within window, =0 except on resume */ -}; - -typedef struct workliststuff WORKLIST; - - -#define MAXCALCWORK 12 - -struct coords { - int x,y; - }; - -struct dblcoords { - double x,y; - }; - -extern BYTE trigndx[]; -extern void (*ltrig0)(void), (*ltrig1)(void), (*ltrig2)(void), (*ltrig3)(void); -extern void (*dtrig0)(void), (*dtrig1)(void), (*dtrig2)(void), (*dtrig3)(void); - -struct trig_funct_lst -{ - char *name; - void (*lfunct)(void); - void (*dfunct)(void); - void (*mfunct)(void); -} ; -extern struct trig_funct_lst trigfn[]; - -/* function prototypes */ - -extern void (_fastcall *plot)(int, int, int); - -/* for overlay return stack */ - -#define BIG 100000.0 - -#define CTL(x) ((x)&0x1f) - -/* nonalpha tests if we have a control character */ -#define nonalpha(c) ((c)<32 || (c)>127) - -/* keys; FIK = "FractInt Key" - * Use this prefix to disambiguate key name symbols used in the fractint source - * from symbols defined by the external environment, i.e. "DELETE" on Win32 - */ -#define FIK_ALT_A 1030 -#define FIK_ALT_S 1031 -#define FIK_ALT_F1 1104 - -#define FIK_CTL_A 1 -#define FIK_CTL_B 2 -#define FIK_CTL_E 5 -#define FIK_CTL_F 6 -#define FIK_CTL_G 7 -#define FIK_CTL_O 15 -#define FIK_CTL_P 16 -#define FIK_CTL_S 19 -#define FIK_CTL_U 21 -#define FIK_CTL_X 24 -#define FIK_CTL_Y 25 -#define FIK_CTL_Z 26 -#define FIK_CTL_BACKSLASH 28 -#define FIK_CTL_DEL 1147 -#define FIK_CTL_DOWN_ARROW 1145 -#define FIK_CTL_END 1117 -#define FIK_CTL_ENTER 10 -#define FIK_CTL_ENTER_2 1010 -#define FIK_CTL_F1 1094 -#define FIK_CTL_HOME 1119 -#define FIK_CTL_INSERT 1146 -#define FIK_CTL_LEFT_ARROW 1115 -#define FIK_CTL_MINUS 1142 -#define FIK_CTL_PAGE_DOWN 1118 -#define FIK_CTL_PAGE_UP 1132 -#define FIK_CTL_PLUS 1144 -#define FIK_CTL_RIGHT_ARROW 1116 -#define FIK_CTL_TAB 1148 -#define FIK_CTL_UP_ARROW 1141 - -#define FIK_SHF_TAB 1015 /* shift tab aka BACKTAB */ - -#define FIK_BACKSPACE 8 -#define FIK_DELETE 1083 -#define FIK_DOWN_ARROW 1080 -#define FIK_END 1079 -#define FIK_ENTER 13 -#define FIK_ENTER_2 1013 -#define FIK_ESC 27 -#define FIK_F1 1059 -#define FIK_F2 1060 -#define FIK_F3 1061 -#define FIK_F4 1062 -#define FIK_F5 1063 -#define FIK_F6 1064 -#define FIK_F7 1065 -#define FIK_F8 1066 -#define FIK_F9 1067 -#define FIK_F10 1068 -#define FIK_HOME 1071 -#define FIK_INSERT 1082 -#define FIK_LEFT_ARROW 1075 -#define FIK_PAGE_DOWN 1081 -#define FIK_PAGE_UP 1073 -#define FIK_RIGHT_ARROW 1077 -#define FIK_SPACE 32 -#define FIK_SF1 1084 -#define FIK_SF2 1085 -#define FIK_SF3 1086 -#define FIK_SF4 1087 -#define FIK_SF5 1088 -#define FIK_SF6 1089 -#define FIK_SF7 1090 -#define FIK_SF8 1091 -#define FIK_SF9 1092 -#define FIK_SF10 1093 -#define FIK_TAB 9 -#define FIK_UP_ARROW 1072 - -/* text colors */ -#define BLACK 0 -#define BLUE 1 -#define GREEN 2 -#define CYAN 3 -#define RED 4 -#define MAGENTA 5 -#define BROWN 6 /* dirty yellow on cga */ -#define WHITE 7 -/* use values below this for foreground only, they don't work background */ -#define GRAY 8 /* don't use this much - is black on cga */ -#define L_BLUE 9 -#define L_GREEN 10 -#define L_CYAN 11 -#define L_RED 12 -#define L_MAGENTA 13 -#define YELLOW 14 -#define L_WHITE 15 -#define INVERSE 0x8000 /* when 640x200x2 text or mode 7, inverse */ -#define BRIGHT 0x4000 /* when mode 7, bright */ -/* and their use: */ -extern BYTE txtcolor[]; -#define C_TITLE txtcolor[0]+BRIGHT -#define C_TITLE_DEV txtcolor[1] -#define C_HELP_HDG txtcolor[2]+BRIGHT -#define C_HELP_BODY txtcolor[3] -#define C_HELP_INSTR txtcolor[4] -#define C_HELP_LINK txtcolor[5]+BRIGHT -#define C_HELP_CURLINK txtcolor[6]+INVERSE -#define C_PROMPT_BKGRD txtcolor[7] -#define C_PROMPT_TEXT txtcolor[8] -#define C_PROMPT_LO txtcolor[9] -#define C_PROMPT_MED txtcolor[10] -#ifndef XFRACT -#define C_PROMPT_HI txtcolor[11]+BRIGHT -#else -#define C_PROMPT_HI txtcolor[11] -#endif -#define C_PROMPT_INPUT txtcolor[12]+INVERSE -#define C_PROMPT_CHOOSE txtcolor[13]+INVERSE -#define C_CHOICE_CURRENT txtcolor[14]+INVERSE -#define C_CHOICE_SP_INSTR txtcolor[15] -#define C_CHOICE_SP_KEYIN txtcolor[16]+BRIGHT -#define C_GENERAL_HI txtcolor[17]+BRIGHT -#define C_GENERAL_MED txtcolor[18] -#define C_GENERAL_LO txtcolor[19] -#define C_GENERAL_INPUT txtcolor[20]+INVERSE -#define C_DVID_BKGRD txtcolor[21] -#define C_DVID_HI txtcolor[22]+BRIGHT -#define C_DVID_LO txtcolor[23] -#define C_STOP_ERR txtcolor[24]+BRIGHT -#define C_STOP_INFO txtcolor[25]+BRIGHT -#define C_TITLE_LOW txtcolor[26] -#define C_AUTHDIV1 txtcolor[27]+INVERSE -#define C_AUTHDIV2 txtcolor[28]+INVERSE -#define C_PRIMARY txtcolor[29] -#define C_CONTRIB txtcolor[30] - -/* structure for xmmmoveextended parameter */ -struct XMM_Move - { - unsigned long Length; - unsigned int SourceHandle; - unsigned long SourceOffset; - unsigned int DestHandle; - unsigned long DestOffset; - }; - -/* structure passed to fullscreen_prompts */ -struct fullscreenvalues -{ - int type; /* 'd' for double, 'f' for float, 's' for string, */ - /* 'D' for integer in double, '*' for comment */ - /* 'i' for integer, 'y' for yes=1 no=0 */ - /* 0x100+n for string of length n */ - /* 'l' for one of a list of strings */ - /* 'L' for long */ - union - { - double dval; /* when type 'd' or 'f' */ - int ival; /* when type is 'i' */ - long Lval; /* when type is 'L' */ - char sval[16]; /* when type is 's' */ - char *sbuf; /* when type is 0x100+n */ - struct { /* when type is 'l' */ - int val; /* selected choice */ - int vlen; /* char len per choice */ - char **list; /* list of values */ - int llen; /* number of values */ - } ch; - } uval; -}; - -#define FILEATTR 0x37 /* File attributes; select all but volume labels */ -#define HIDDEN 2 -#define SYSTEM 4 -#define SUBDIR 16 - -struct DIR_SEARCH /* Allocate DTA and define structure */ -{ - char path[FILE_MAX_PATH]; /* DOS path and filespec */ - char attribute; /* File attributes wanted */ - int ftime; /* File creation time */ - int fdate; /* File creation date */ - long size; /* File size in bytes */ - char filename[FILE_MAX_PATH]; /* Filename and extension */ -}; - -extern struct DIR_SEARCH DTA; /* Disk Transfer Area */ - -typedef struct palett -{ - BYTE red; - BYTE green; - BYTE blue; -} -Palettetype; - -#define MAX_JUMPS 200 /* size of JUMP_CONTROL array */ - -typedef struct frm_jmpptrs_st { - int JumpOpPtr; - int JumpLodPtr; - int JumpStoPtr; -} JUMP_PTRS_ST; - - -typedef struct frm_jump_st { - int type; - JUMP_PTRS_ST ptrs; - int DestJumpIndex; -} JUMP_CONTROL_ST; - -#if defined(_WIN32) -#pragma pack(push, 1) -#endif -struct ext_blk_2 { - char got_data; - int length; - int resume_data; - }; - -struct ext_blk_3 { - char got_data; - int length; - char form_name[40]; - short uses_p1; - short uses_p2; - short uses_p3; - short uses_ismand; - short ismand; - short uses_p4; - short uses_p5; - }; - -struct ext_blk_4 { - char got_data; - int length; - int *range_data; - }; - -struct ext_blk_5 { - char got_data; - int length; - char *apm_data; - }; - -/* parameter evolution stuff */ -struct ext_blk_6 { - char got_data; - int length; - short evolving; - short gridsz; - unsigned short this_gen_rseed; - double fiddlefactor; - double paramrangex; - double paramrangey; - double opx; - double opy; - short odpx; - short odpy; - short px; - short py; - short sxoffs; - short syoffs; - short xdots; - short ydots; - short ecount; - short mutate[NUMGENES]; - }; - -struct ext_blk_7 { - char got_data; - int length; - double oxmin; - double oxmax; - double oymin; - double oymax; - double ox3rd; - double oy3rd; - short keep_scrn_coords; - char drawmode; - }; -#if defined(_WIN32) -#pragma pack(pop) -#endif - -struct SearchPath { - char par[FILE_MAX_PATH]; - char frm[FILE_MAX_PATH]; - char ifs[FILE_MAX_PATH]; - char lsys[FILE_MAX_PATH]; -} ; - -struct affine -{ - /* weird order so a,b,e and c,d,f are vectors */ - double a; - double b; - double e; - double c; - double d; - double f; -}; - -struct baseunit { /* smallest part of a fractint 'gene' */ - void *addr ; /* address of variable to be referenced */ - void (*varyfunc)(struct baseunit*,int,int); /* pointer to func used to vary it */ - /* takes random number and pointer to var*/ - int mutate ; /* flag to switch on variation of this variable */ - /* 0 for no mutation, 1 for x axis, 2 for y axis */ - /* in steady field maps, either x or y=yes in random modes*/ - char name[16]; /* name of variable (for menu ) */ - char level; /* mutation level at which this should become active */ -}; - -typedef struct baseunit GENEBASE; - -#define sign(x) (((x) < 0) ? -1 : ((x) != 0) ? 1 : 0) - -#endif - - -#if _MSC_VER == 800 -#ifndef FIXTAN_DEFINED -/* !!!!! stupid MSVC tan(x) bug fix !!!!!!!! */ -/* tan(x) can return -tan(x) if -pi/2 < x < pi/2 */ -/* if tan(x) has been called before outside this range. */ -double fixtan( double x ); -#define tan fixtan -#define FIXTAN_DEFINED -#endif -#endif diff --git a/fractint/headers/helpcom.h b/fractint/headers/helpcom.h deleted file mode 100644 index 0cec72fa0..000000000 --- a/fractint/headers/helpcom.h +++ /dev/null @@ -1,812 +0,0 @@ - -/* - * helpcom.h - * - * - * Common #defines, structures and code for HC.C and HELP.C - * - */ - -#ifndef HELPCOM_H -#define HELPCOM_H - - -/* - * help file signature - * If you get a syntax error, remove the LU from the end of the number. - */ - -#define HELP_SIG (0xAFBC1823LU) - - -/* - * commands imbedded in the help text - */ - -#define CMD_LITERAL 1 /* next char taken literally */ -#define CMD_PARA 2 /* paragraph start code */ -#define CMD_LINK 3 /* hot-link start/end code */ -#define CMD_FF 4 /* force a form-feed */ -#define CMD_XONLINE 5 /* exclude from online help on/off */ -#define CMD_XDOC 6 /* exclude from printed document on/off */ -#define CMD_CENTER 7 /* center this line */ -#define CMD_SPACE 8 /* next byte is count of spaces */ - -#define MAX_CMD 8 - - -/* - * on-line help dimensions - */ - -#define SCREEN_WIDTH (78) -#define SCREEN_DEPTH (22) -#define SCREEN_INDENT (1) - - -/* - * printed document dimensions - */ - -#define PAGE_WIDTH (72) /* width of printed text */ -#define PAGE_INDENT (2) /* indent all text by this much */ -#define TITLE_INDENT (1) /* indent titles by this much */ - -#define PAGE_RDEPTH (59) /* the total depth (inc. heading) */ -#define PAGE_HEADING_DEPTH (3) /* depth of the heading */ -#define PAGE_DEPTH (PAGE_RDEPTH-PAGE_HEADING_DEPTH) /* depth of text */ - - -/* - * Document page-break macros. Goto to next page if this close (or closer) - * to end of page when starting a CONTENT, TOPIC, or at a BLANK line. - */ - -#define CONTENT_BREAK (7) /* start of a "DocContent" entry */ -#define TOPIC_BREAK (4) /* start of each topic under a DocContent entry */ -#define BLANK_BREAK (2) /* a blank line */ - - -/* - * tokens returned by find_token_length - */ - -#define TOK_DONE (0) /* len == 0 */ -#define TOK_SPACE (1) /* a run of spaces */ -#define TOK_LINK (2) /* an entire link */ -#define TOK_PARA (3) /* a CMD_PARA */ -#define TOK_NL (4) /* a new-line ('\n') */ -#define TOK_FF (5) /* a form-feed (CMD_FF) */ -#define TOK_WORD (6) /* a word */ -#define TOK_XONLINE (7) /* a CMD_XONLINE */ -#define TOK_XDOC (8) /* a CMD_XDOC */ -#define TOK_CENTER (9) /* a CMD_CENTER */ - - -/* - * modes for find_token_length() and find_line_width() - */ - -#define ONLINE 1 -#define DOC 2 - - -/* - * struct PD_INFO used by process_document() - */ - -typedef struct - { - - /* used by process_document -- look but don't touch! */ - - int pnum, - lnum; - - /* PD_GET_TOPIC is allowed to change these */ - - char *curr; - unsigned len; - - /* PD_GET_CONTENT is allowed to change these */ - - char *id; - char *title; - int new_page; - - /* general parameters */ - - char *s; - int i; - - - } PD_INFO; - - -/* - * Commands passed to (*get_info)() and (*output)() by process_document() - */ - -enum PD_COMMANDS - { - -/* commands sent to pd_output */ - - PD_HEADING, /* call at the top of each page */ - PD_FOOTING, /* called at the end of each page */ - PD_PRINT, /* called to send text to the printer */ - PD_PRINTN, /* called to print a char n times */ - PD_PRINT_SEC, /* called to print the section title line */ - PD_START_SECTION, /* called at the start of each section */ - PD_START_TOPIC, /* called at the start of each topic */ - PD_SET_SECTION_PAGE, /* set the current sections page number */ - PD_SET_TOPIC_PAGE, /* set the current topics page number */ - PD_PERIODIC, /* called just before curr is incremented to next token */ - -/* commands sent to pd_get_info */ - - PD_GET_CONTENT, - PD_GET_TOPIC, - PD_RELEASE_TOPIC, - PD_GET_LINK_PAGE - - } ; - - -typedef int (*PD_FUNC)(int cmd, PD_INFO *pd, VOIDPTR info); - - -int _find_token_length(char *curr, unsigned len, int *size, int *width); -int find_token_length(int mode, char *curr, unsigned len, int *size, int *width); -int find_line_width(int mode, char *curr, unsigned len); -int process_document(PD_FUNC get_info, PD_FUNC output, VOIDPTR info); - - -/* - * Code common to both HC.C and HELP.C (in Fractint). - * #include INCLUDE_COMMON once for each program - */ - - -#endif -#ifdef INCLUDE_COMMON - - -#ifndef XFRACT -#define getint(ptr) (*(int *)(ptr)) -#define setint(ptr,n) (*(int *)(ptr)) = n -#else -/* Get an int from an unaligned pointer - * This routine is needed because this program uses unaligned 2 byte - * pointers all over the place. - */ -int -getint(ptr) -char *ptr; -{ - int s; - bcopy(ptr,&s,sizeof(int)); - return s; -} - -/* Set an int to an unaligned pointer */ -void setint(ptr, n) -int n; -char *ptr; -{ - bcopy(&n,ptr,sizeof(int)); -} -#endif - - -static int is_hyphen(char *ptr) /* true if ptr points to a real hyphen */ - { /* checkes for "--" and " -" */ - if ( *ptr != '-' ) - return (0); /* that was easy! */ - - --ptr; - - return ( *ptr!=' ' && *ptr!='-' ); - } - - -int _find_token_length(register char *curr, unsigned len, int *size, int *width) - { - register int _size = 0; - register int _width = 0; - int tok; - - if (len == 0) - tok = TOK_DONE; - - else - { - switch ( *curr ) - { - case ' ': /* it's a run of spaces */ - tok = TOK_SPACE; - while ( *curr == ' ' && _size < (int)len ) - { - ++curr; - ++_size; - ++_width; - } - break; - - case CMD_SPACE: - tok = TOK_SPACE; - ++curr; - ++_size; - _width = *curr; - ++curr; - ++_size; - break; - - case CMD_LINK: - tok = TOK_LINK; - _size += 1+3*sizeof(int); /* skip CMD_LINK + topic_num + topic_off + page_num */ - curr += 1+3*sizeof(int); - - while ( *curr != CMD_LINK ) - { - if ( *curr == CMD_LITERAL ) - { - ++curr; - ++_size; - } - ++curr; - ++_size; - ++_width; - assert((unsigned) _size < len); - } - - ++_size; /* skip ending CMD_LINK */ - break; - - case CMD_PARA: - tok = TOK_PARA; - _size += 3; /* skip CMD_PARA + indent + margin */ - break; - - case CMD_XONLINE: - tok = TOK_XONLINE; - ++_size; - break; - - case CMD_XDOC: - tok = TOK_XDOC; - ++_size; - break; - - case CMD_CENTER: - tok = TOK_CENTER; - ++_size; - break; - - case '\n': - tok = TOK_NL; - ++_size; - break; - - case CMD_FF: - tok = TOK_FF; - ++_size; - break; - - default: /* it must be a word */ - tok = TOK_WORD; - for(;;) - { - if ( _size >= (int)len ) - break; - - else if ( *curr == CMD_LITERAL ) - { - curr += 2; - _size += 2; - _width += 1; - } - - else if ( *curr == '\0' ) - { - assert(0); - } - - else if ((unsigned)*curr <= MAX_CMD || *curr == ' ' || - *curr == '\n') - break; - - else if ( *curr == '-' ) - { - ++curr; - ++_size; - ++_width; - if ( is_hyphen(curr-1) ) - break; - } - - else - { - ++curr; - ++_size; - ++_width; - } - } - break; - } /* switch */ - } - - if (size != NULL) *size = _size; - if (width != NULL) *width = _width; - - return (tok); - } - - -int find_token_length(int mode, char *curr, unsigned len, int *size, int *width) - { - int tok; - int t; - int _size; - - tok = _find_token_length(curr, len, &t, width); - - if ( (tok == TOK_XONLINE && mode == ONLINE) || - (tok == TOK_XDOC && mode == DOC) ) - { - _size = 0; - - for(;;) - { - curr += t; - len -= t; - _size += t; - - tok = _find_token_length(curr, len, &t, NULL); - - if ( (tok == TOK_XONLINE && mode == ONLINE) || - (tok == TOK_XDOC && mode == DOC) || - (tok == TOK_DONE) ) - break; - } - - _size += t; - } - else - _size = t; - - if (size != NULL ) - *size = _size; - - return (tok); - } - - -int find_line_width(int mode, char *curr, unsigned len) - { - int size = 0, - width = 0, - lwidth = 0, - done = 0, - tok; - - do - { - tok = find_token_length(mode, curr, len, &size, &width); - - switch(tok) - { - case TOK_DONE: - case TOK_PARA: - case TOK_NL: - case TOK_FF: - done = 1; - break; - - case TOK_XONLINE: - case TOK_XDOC: - case TOK_CENTER: - curr += size; - len -= size; - break; - - default: /* TOK_SPACE, TOK_LINK or TOK_WORD */ - lwidth += width; - curr += size; - len -= size; - break; - } - } - while ( !done ); - - return (lwidth); - } - - -#define DO_PRINTN(ch,n) ( pd.s = &(ch), pd.i = (n), output(PD_PRINTN, &pd, info) ) -#define DO_PRINT(str,n) ( pd.s = (str), pd.i = (n), output(PD_PRINT, &pd, info) ) - - -int process_document(PD_FUNC get_info, PD_FUNC output, VOIDPTR info) - { - int skip_blanks; - int tok; - int size, - width; - int col; - char page_text[10]; - PD_INFO pd; - char nl = '\n', - sp = ' '; - int first_section, - first_topic; - - pd.pnum = 1; - pd.lnum = 0; - - col = 0; - - output(PD_HEADING, &pd, info); - - first_section = 1; - - while ( get_info(PD_GET_CONTENT, &pd, info) ) - { - if ( !output(PD_START_SECTION, &pd, info) ) - return (0); - - if ( pd.new_page && pd.lnum != 0 ) - { - if ( !output(PD_FOOTING, &pd, info) ) - return (0); - ++pd.pnum; - pd.lnum = 0; - if ( !output(PD_HEADING, &pd, info) ) - return (0); - } - - else - { - if ( pd.lnum+2 > PAGE_DEPTH-CONTENT_BREAK ) - { - if ( !output(PD_FOOTING, &pd, info) ) - return (0); - ++pd.pnum; - pd.lnum = 0; - if ( !output(PD_HEADING, &pd, info) ) - return (0); - } - else if (pd.lnum > 0) - { - if ( !DO_PRINTN(nl, 2) ) - return (0); - pd.lnum += 2; - } - } - - if ( !output(PD_SET_SECTION_PAGE, &pd, info) ) - return (0); - - if ( !first_section ) - { - if ( !output(PD_PRINT_SEC, &pd, info) ) - return (0); - ++pd.lnum; - } - - col = 0; - - first_topic = 1; - - while ( get_info(PD_GET_TOPIC, &pd, info) ) - { - if ( !output(PD_START_TOPIC, &pd, info) ) - return (0); - - skip_blanks = 0; - col = 0; - - if ( !first_section ) /* do not skip blanks for DocContents */ - { - while (pd.len > 0) - { - tok = find_token_length(DOC, pd.curr, pd.len, &size, NULL); - if (tok != TOK_XDOC && tok != TOK_XONLINE && - tok != TOK_NL && tok != TOK_DONE ) - break; - pd.curr += size; - pd.len -= size; - } - if ( first_topic && pd.len != 0 ) - { - if ( !DO_PRINTN(nl, 1) ) - return (0); - ++pd.lnum; - } - } - - if ( pd.lnum > PAGE_DEPTH-TOPIC_BREAK ) - { - if ( !output(PD_FOOTING, &pd, info) ) - return (0); - ++pd.pnum; - pd.lnum = 0; - if ( !output(PD_HEADING, &pd, info) ) - return (0); - } - else if ( !first_topic ) - { - if ( !DO_PRINTN(nl, 1) ) - return (0); - pd.lnum++; - } - - if ( !output(PD_SET_TOPIC_PAGE, &pd, info) ) - return (0); - - do - { - if ( !output(PD_PERIODIC, &pd, info) ) - return (0); - - tok = find_token_length(DOC, pd.curr, pd.len, &size, &width); - - switch ( tok ) - { - case TOK_PARA: - { - int indent, - margin; - unsigned holdlen = 0; - char *holdcurr = 0; - int in_link = 0; - - ++pd.curr; - - indent = *pd.curr++; - margin = *pd.curr++; - - pd.len -= 3; - - if ( !DO_PRINTN(sp, indent) ) - return (0); - - col = indent; - - for(;;) - { - if ( !output(PD_PERIODIC, &pd, info) ) - return (0); - - tok = find_token_length(DOC, pd.curr, pd.len, &size, &width); - - if ( tok == TOK_NL || tok == TOK_FF ) - break; - - if ( tok == TOK_DONE ) - { - if (in_link == 0) - { - col = 0; - ++pd.lnum; - if ( !DO_PRINTN(nl, 1) ) - return (0); - break; - } - - else if (in_link == 1) - { - tok = TOK_SPACE; - width = 1; - size = 0; - ++in_link; - } - - else if (in_link == 2) - { - tok = TOK_WORD; - width = (int) strlen(page_text); - col += 8 - width; - size = 0; - pd.curr = page_text; - ++in_link; - } - - else if (in_link == 3) - { - pd.curr = holdcurr; - pd.len = holdlen; - in_link = 0; - continue; - } - } - - if ( tok == TOK_PARA ) - { - col = 0; /* fake a nl */ - ++pd.lnum; - if ( !DO_PRINTN(nl, 1) ) - return (0); - break; - } - - if (tok == TOK_XONLINE || tok == TOK_XDOC ) - { - pd.curr += size; - pd.len -= size; - continue; - } - - if ( tok == TOK_LINK ) - { - pd.s = pd.curr+1; - if ( get_info(PD_GET_LINK_PAGE, &pd, info) ) - { - in_link = 1; - sprintf(page_text, "(p. %d)", pd.i); - } - else - in_link = 3; - holdcurr = pd.curr + size; - holdlen = pd.len - size; - pd.len = size - 2 - 3*sizeof(int); - pd.curr += 1 + 3*sizeof(int); - continue; - } - - /* now tok is TOK_SPACE or TOK_WORD */ - - if (col+width > PAGE_WIDTH) - { /* go to next line... */ - if ( !DO_PRINTN(nl, 1) ) - return (0); - if ( ++pd.lnum >= PAGE_DEPTH ) - { - if ( !output(PD_FOOTING, &pd, info) ) - return (0); - ++pd.pnum; - pd.lnum = 0; - if ( !output(PD_HEADING, &pd, info) ) - return (0); - } - - if ( tok == TOK_SPACE ) - width = 0; /* skip spaces at start of a line */ - - if ( !DO_PRINTN(sp, margin) ) - return (0); - col = margin; - } - - if (width > 0) - { - if (tok == TOK_SPACE) - { - if ( !DO_PRINTN(sp, width) ) - return (0); - } - else - { - if ( !DO_PRINT(pd.curr, (size==0) ? width : size) ) - return (0); - } - } - - col += width; - pd.curr += size; - pd.len -= size; - } - - skip_blanks = 0; - width = size = 0; - break; - } - - case TOK_NL: - if (skip_blanks && col == 0) - break; - - ++pd.lnum; - - if ( pd.lnum >= PAGE_DEPTH || (col == 0 && pd.lnum >= PAGE_DEPTH-BLANK_BREAK) ) - { - if ( col != 0 ) /* if last wasn't a blank line... */ - { - if ( !DO_PRINTN(nl, 1) ) - return (0); - } - if ( !output(PD_FOOTING, &pd, info) ) - return (0); - ++pd.pnum; - pd.lnum = 0; - skip_blanks = 1; - if ( !output(PD_HEADING, &pd, info) ) - return (0); - } - else - { - if ( !DO_PRINTN(nl, 1) ) - return (0); - } - - col = 0; - break; - - case TOK_FF: - if (skip_blanks) - break; - if ( !output(PD_FOOTING, &pd, info) ) - return (0); - col = 0; - pd.lnum = 0; - ++pd.pnum; - if ( !output(PD_HEADING, &pd, info) ) - return (0); - break; - - case TOK_CENTER: - width = (PAGE_WIDTH - find_line_width(DOC,pd.curr,pd.len)) / 2; - if ( !DO_PRINTN(sp, width) ) - return (0); - break; - - case TOK_LINK: - skip_blanks = 0; - if ( !DO_PRINT(pd.curr+1+3*sizeof(int), - size-3*sizeof(int)-2) ) - return (0); - pd.s = pd.curr+1; - if ( get_info(PD_GET_LINK_PAGE, &pd, info) ) - { - width += 9; - sprintf(page_text, " (p. %d)", pd.i); - if ( !DO_PRINT(page_text, (int) strlen(page_text)) ) - return (0); - } - break; - - case TOK_WORD: - skip_blanks = 0; - if ( !DO_PRINT(pd.curr, size) ) - return (0); - break; - - case TOK_SPACE: - skip_blanks = 0; - if ( !DO_PRINTN(sp, width) ) - return (0); - break; - - case TOK_DONE: - case TOK_XONLINE: /* skip */ - case TOK_XDOC: /* ignore */ - break; - - } /* switch */ - - pd.curr += size; - pd.len -= size; - col += width; - } - while (pd.len > 0); - - get_info(PD_RELEASE_TOPIC, &pd, info); - - first_topic = 0; - } /* while */ - - first_section = 0; - } /* while */ - - if ( !output(PD_FOOTING, &pd, info) ) - return (0); - - return (1); - } - -#undef DO_PRINT -#undef DO_PRINTN - - -#undef INCLUDE_COMMON -#endif /* #ifdef INCLUDE_COMMON */ diff --git a/fractint/headers/lsys.h b/fractint/headers/lsys.h deleted file mode 100644 index 56a2d2ebd..000000000 --- a/fractint/headers/lsys.h +++ /dev/null @@ -1,89 +0,0 @@ -/* lsys.h - * Header file for L-system code. - * Nicholas Wilt, 6/26/93. - */ - -#ifndef LSYS_H -#define LSYS_H - - -#define size ssize -/* Needed for use of asm -- helps decide which pointer to function - * to put into the struct lsys_cmds. - */ - -/* Macro to take an FP number and turn it into a - * 16/16-bit fixed-point number. - */ -#define FIXEDMUL 524288L -#define FIXEDPT(x) ((long) (FIXEDMUL * (x))) - -/* The number by which to multiply sines, cosines and other - * values with magnitudes less than or equal to 1. - * sins and coss are a 3/29 bit fixed-point scheme (so the - * range is +/- 2, with good accuracy. The range is to - * avoid overflowing when the aspect ratio is taken into - * account. - */ -#define FIXEDLT1 536870912.0 - -#define ANGLE2DOUBLE (2.0*PI / 4294967296.0) - -#define MAXRULES 27 /* this limits rules to 25 */ -#define MAX_LSYS_LINE_LEN 255 /* this limits line length to 255 */ - -struct lsys_turtlestatei { - char counter, angle, reverse, stackoflow; - /* dmaxangle is maxangle - 1 */ - char maxangle, dmaxangle, curcolor, dummy; /* dummy ensures longword alignment */ - long size; - long realangle; - long xpos, ypos; /* xpos and ypos are long, not fixed point */ - long xmin, ymin, xmax, ymax; /* as are these */ - long aspect; /* aspect ratio of each pixel, ysize/xsize */ - long num; -}; - -struct lsys_turtlestatef { - char counter, angle, reverse, stackoflow; - /* dmaxangle is maxangle - 1 */ - char maxangle, dmaxangle, curcolor, dummy; /* dummy ensures longword alignment */ - LDBL size; - LDBL realangle; - LDBL xpos, ypos; - LDBL xmin, ymin, xmax, ymax; - LDBL aspect; /* aspect ratio of each pixel, ysize/xsize */ - union { - long n; - LDBL nf; - } parm; -}; - -extern char maxangle; - -/* routines in lsysa.asm */ - -#if defined(XFRACT) || defined(_WIN32) -#define lsysi_doat_386 lsys_doat -#define lsysi_dosizegf_386 lsys_dosizegf -#define lsysi_dodrawg_386 lsys_dodrawg -#else -extern void lsysi_doat_386(struct lsys_turtlestatei *cmd); -extern void lsysi_dosizegf_386(struct lsys_turtlestatei *cmd); -extern void lsysi_dodrawg_386(struct lsys_turtlestatei *cmd); -#endif - -/* routines in lsysaf.asm */ - -extern void lsys_prepfpu(struct lsys_turtlestatef *); -extern void lsys_donefpu(struct lsys_turtlestatef *); - -/* routines in lsysf.c */ - -extern struct lsys_cmd * _fastcall drawLSysF(struct lsys_cmd *command,struct lsys_turtlestatef *ts, struct lsys_cmd **rules,int depth); -extern int _fastcall lsysf_findscale(struct lsys_cmd *command, struct lsys_turtlestatef *ts, struct lsys_cmd **rules, int depth); -extern struct lsys_cmd *LSysFSizeTransform(char *s, struct lsys_turtlestatef *ts); -extern struct lsys_cmd *LSysFDrawTransform(char *s, struct lsys_turtlestatef *ts); -extern void _fastcall lsysf_dosincos(void); - -#endif diff --git a/fractint/headers/mpmath.h b/fractint/headers/mpmath.h deleted file mode 100644 index 072d1de05..000000000 --- a/fractint/headers/mpmath.h +++ /dev/null @@ -1,205 +0,0 @@ -/* - * REMOVED FORMAL PARAMETERS FROM FUNCTION DEFINITIONS (1/4/92) - */ - - -#ifndef MPMATH_H -#define MPMATH_H - -#ifndef _CMPLX_DEFINED -#include "cmplx.h" -#endif - -#ifdef XFRACT -#define far -#endif - - -#if !defined(XFRACT) -struct MP { - int Exp; - unsigned long Mant; -}; -#else -struct MP { - double val; -}; -#endif - -struct MPC { - struct MP x, y; -}; - -extern int MPOverflow; -extern int DivideOverflow; - -/* Mark Peterson's expanded floating point operators. Automatically uses - either the 8086 or 80386 processor type specified in global 'cpu'. If - the operation results in an overflow (result < 2**(2**14), or division - by zero) the global 'MPoverflow' is set to one. */ - -/* function pointer support added by Tim Wegner 12/07/89 */ -extern int (*pMPcmp)(struct MP , struct MP ); -extern struct MP *(*pMPmul)(struct MP , struct MP ); -extern struct MP *(*pMPdiv)(struct MP , struct MP ); -extern struct MP *(*pMPadd)(struct MP , struct MP ); -extern struct MP *(*pMPsub)(struct MP , struct MP ); -extern struct MP *(*pd2MP)(double ) ; -extern double *(*pMP2d)(struct MP ) ; - - -/*** Formula Declarations ***/ -#if !defined(XFRACT) -enum MATH_TYPE { D_MATH, M_MATH, L_MATH }; -#else -enum MATH_TYPE { D_MATH}; -#endif -extern enum MATH_TYPE MathType; - -#define fDiv(x, y, z) (void)((*(long*)&z) = RegDivFloat(*(long*)&x, *(long*)&y)) -#define fMul16(x, y, z) (void)((*(long*)&z) = r16Mul(*(long*)&x, *(long*)&y)) -#define fShift(x, Shift, z) (void)((*(long*)&z) = \ - RegSftFloat(*(long*)&x, Shift)) -#define Fg2Float(x, f, z) (void)((*(long*)&z) = RegFg2Float(x, f)) -#define Float2Fg(x, f) RegFloat2Fg(*(long*)&x, f) -#define fLog14(x, z) (void)((*(long*)&z) = \ - RegFg2Float(LogFloat14(*(long*)&x), 16)) -#define fExp14(x, z) (void)((*(long*)&z) = ExpFloat14(*(long*)&x)); -#define fSqrt14(x, z) fLog14(x, z); fShift(z, -1, z); fExp14(z, z) - -/* the following are declared 4 dimensional as an experiment */ -/* changeing declarations to _CMPLX and _LCMPLX restores the code */ -/* to 2D */ -union Arg { - _CMPLX d; - struct MPC m; - _LCMPLX l; -/* - _DHCMPLX dh; - _LHCMPLX lh; */ -}; - -struct ConstArg { - char *s; - int len; - union Arg a; -}; - -extern union Arg *Arg1,*Arg2; - -extern void lStkSin(void),lStkCos(void),lStkSinh(void),lStkCosh(void),lStkLog(void),lStkExp(void),lStkSqr(void); -extern void dStkSin(void),dStkCos(void),dStkSinh(void),dStkCosh(void),dStkLog(void),dStkExp(void),dStkSqr(void); - -extern void (*ltrig0)(void); -extern void (*ltrig1)(void); -extern void (*ltrig2)(void); -extern void (*ltrig3)(void); -extern void (*dtrig0)(void); -extern void (*dtrig1)(void); -extern void (*dtrig2)(void); -extern void (*dtrig3)(void); - -/* -------------------------------------------------------------------- */ -/* The following #defines allow the complex transcendental functions */ -/* in parser.c to be used here thus avoiding duplicated code. */ -/* -------------------------------------------------------------------- */ -#if !defined(XFRACT) - -#define CMPLXmod(z) (sqr((z).x)+sqr((z).y)) -#define CMPLXconj(z) ((z).y = -((z).y)) -#define LCMPLXmod(z) (lsqr((z).x)+lsqr((z).y)) -#define LCMPLXconj(z) ((z).y = -((z).y)) - - -#define LCMPLXtrig0(arg,out) Arg1->l = (arg); ltrig0(); (out)=Arg1->l -#define LCMPLXtrig1(arg,out) Arg1->l = (arg); ltrig1(); (out)=Arg1->l -#define LCMPLXtrig2(arg,out) Arg1->l = (arg); ltrig2(); (out)=Arg1->l -#define LCMPLXtrig3(arg,out) Arg1->l = (arg); ltrig3(); (out)=Arg1->l - -#endif /* XFRACT */ - -#define CMPLXtrig0(arg,out) Arg1->d = (arg); dtrig0(); (out)=Arg1->d -#define CMPLXtrig1(arg,out) Arg1->d = (arg); dtrig1(); (out)=Arg1->d -#define CMPLXtrig2(arg,out) Arg1->d = (arg); dtrig2(); (out)=Arg1->d -#define CMPLXtrig3(arg,out) Arg1->d = (arg); dtrig3(); (out)=Arg1->d - -#if !defined(XFRACT) - -#define LCMPLXsin(arg,out) Arg1->l = (arg); lStkSin(); (out) = Arg1->l -#define LCMPLXcos(arg,out) Arg1->l = (arg); lStkCos(); (out) = Arg1->l -#define LCMPLXsinh(arg,out) Arg1->l = (arg); lStkSinh(); (out) = Arg1->l -#define LCMPLXcosh(arg,out) Arg1->l = (arg); lStkCosh(); (out) = Arg1->l -#define LCMPLXlog(arg,out) Arg1->l = (arg); lStkLog(); (out) = Arg1->l -#define LCMPLXexp(arg,out) Arg1->l = (arg); lStkExp(); (out) = Arg1->l -/* -#define LCMPLXsqr(arg,out) Arg1->l = (arg); lStkSqr(); (out) = Arg1->l -*/ -#define LCMPLXsqr(arg,out) \ - (out).x = lsqr((arg).x) - lsqr((arg).y);\ - (out).y = multiply((arg).x, (arg).y, bitshiftless1) -#define LCMPLXsqr_old(out) \ - (out).y = multiply(lold.x, lold.y, bitshiftless1);\ - (out).x = ltempsqrx - ltempsqry - -#define LCMPLXpwr(arg1,arg2,out) Arg2->l = (arg1); Arg1->l = (arg2);\ - lStkPwr(); Arg1++; Arg2++; (out) = Arg2->l -#define LCMPLXmult(arg1,arg2,out) Arg2->l = (arg1); Arg1->l = (arg2);\ - lStkMul(); Arg1++; Arg2++; (out) = Arg2->l -#define LCMPLXadd(arg1,arg2,out) \ - (out).x = (arg1).x + (arg2).x; (out).y = (arg1).y + (arg2).y -#define LCMPLXsub(arg1,arg2,out) \ - (out).x = (arg1).x - (arg2).x; (out).y = (arg1).y - (arg2).y - -#define LCMPLXtimesreal(arg,real,out) \ - (out).x = multiply((arg).x,(real),bitshift);\ - (out).y = multiply((arg).y,(real),bitshift) - -#define LCMPLXrecip(arg,out) \ -{ long denom; denom = lsqr((arg).x) + lsqr((arg).y);\ -if(denom==0L) overflow=1; else {(out).x = divide((arg).x,denom,bitshift);\ -(out).y = -divide((arg).y,denom,bitshift);}} -#endif /* XFRACT */ - -#define CMPLXsin(arg,out) Arg1->d = (arg); dStkSin(); (out) = Arg1->d -#define CMPLXcos(arg,out) Arg1->d = (arg); dStkCos(); (out) = Arg1->d -#define CMPLXsinh(arg,out) Arg1->d = (arg); dStkSinh(); (out) = Arg1->d -#define CMPLXcosh(arg,out) Arg1->d = (arg); dStkCosh(); (out) = Arg1->d -#define CMPLXlog(arg,out) Arg1->d = (arg); dStkLog(); (out) = Arg1->d -#define CMPLXexp(arg,out) FPUcplxexp(&(arg), &(out)) -/* -#define CMPLXsqr(arg,out) Arg1->d = (arg); dStkSqr(); (out) = Arg1->d -*/ -#define CMPLXsqr(arg,out) \ - (out).x = sqr((arg).x) - sqr((arg).y);\ - (out).y = ((arg).x+(arg).x) * (arg).y -#define CMPLXsqr_old(out) \ - (out).y = (old.x+old.x) * old.y;\ - (out).x = tempsqrx - tempsqry - -#define CMPLXpwr(arg1,arg2,out) (out)= ComplexPower((arg1), (arg2)) -#define CMPLXmult1(arg1,arg2,out) Arg2->d = (arg1); Arg1->d = (arg2);\ - dStkMul(); Arg1++; Arg2++; (out) = Arg2->d -#define CMPLXmult(arg1,arg2,out) \ - {\ - _CMPLX TmP;\ - TmP.x = (arg1).x*(arg2).x - (arg1).y*(arg2).y;\ - TmP.y = (arg1).x*(arg2).y + (arg1).y*(arg2).x;\ - (out) = TmP;\ - } -#define CMPLXadd(arg1,arg2,out) \ - (out).x = (arg1).x + (arg2).x; (out).y = (arg1).y + (arg2).y -#define CMPLXsub(arg1,arg2,out) \ - (out).x = (arg1).x - (arg2).x; (out).y = (arg1).y - (arg2).y -#define CMPLXtimesreal(arg,real,out) \ - (out).x = (arg).x*(real);\ - (out).y = (arg).y*(real) - -#define CMPLXrecip(arg,out) \ - { double denom; denom = sqr((arg).x) + sqr((arg).y);\ - if(denom==0.0) {(out).x = 1.0e10;(out).y = 1.0e10;}else\ - { (out).x = (arg).x/denom;\ - (out).y = -(arg).y/denom;}} - -#define CMPLXneg(arg,out) (out).x = -(arg).x; (out).y = -(arg).y - -#endif diff --git a/fractint/headers/port.h b/fractint/headers/port.h deleted file mode 100644 index 73e6698bd..000000000 --- a/fractint/headers/port.h +++ /dev/null @@ -1,425 +0,0 @@ -/************************************** -** -** PORT.H : Miscellaneous definitions for portability. Please add -** to this file for any new machines/compilers you may have. -** -** XFRACT file "SHARED.H" merged into PORT.H on 3/14/92 by --CWM-- -** TW also merged in Wes Loewer's BIGPORT.H. -*/ - -#ifndef PORT_H /* If this is defined, this file has been */ -#define PORT_H /* included already in this module. */ - -#if defined(_WIN32) -#define _CRTDBG_MAP_ALLOC -#include -#include -#define _CRT_SECURE_NO_DEPRECATE -/* disable unsafe CRT warnings */ -#pragma warning(disable: 4996) -#endif - -#if !defined(XFRACT) && !defined(_WIN32) -# include -#else -# if !defined(_WIN32) -# include -# endif -#endif -#include -#include -#include -#include - -#if defined(_WIN32) -extern long stackavail(); -#endif - -#if (defined(__STDC__) || defined(__cplusplus) || defined(_MSC_VER)) && !defined(STDC) -# define STDC -#endif - -#if (defined(LINUX)) && !defined(STDC) -# define STDC -#endif - -#ifndef STDC -# ifndef const /* cannot use !defined(STDC) && !defined(const) on Mac */ -# define const -# endif -#endif - -/* If endian.h is not present, it can be handled in the code below, */ -/* but if you have this file, it can make it more fool proof. */ -#if (defined(XFRACT) && !defined(__sun)) -# if defined(sgi) -# include -# else -# include -# endif -#endif -#ifndef BIG_ENDIAN -# define BIG_ENDIAN 4321 /* to show byte order (taken from gcc) */ -#endif -#ifndef LITTLE_ENDIAN -# define LITTLE_ENDIAN 1234 -#endif - -#define MSDOS 1 - -#if defined(_WIN32) -/* _WIN32 uses a flat model */ -# define BIG_ANSI_C -# ifdef far -# undef far -# endif -# define far -# ifdef _far -# undef _far -# endif -# define _far -# ifdef __far -# undef __far -# endif -# define __far -# ifndef USE_BIGNUM_C_CODE -# define USE_BIGNUM_C_CODE -# endif -# ifdef MSDOS -# undef MSDOS -# endif -# ifdef __MSDOS__ -# undef __MSDOS__ -# endif -#else -# ifdef XFRACT /* XFRACT forces unix configuration! --CWM-- */ -/* XFRACT forces unix configuration! --CWM-- */ - -# ifdef MSDOS -# undef MSDOS -# endif - -# ifdef __MSDOS__ -# undef __MSDOS__ -# endif - -# ifndef unix -# define unix -# endif -# endif /* XFRACT */ -#endif /* _WIN32 */ - -#if defined(_WIN32) - /*================================== Win32 definitions */ - typedef unsigned char U8; - typedef signed char S8; - typedef unsigned short U16; - typedef signed short S16; - typedef unsigned long U32; - typedef signed long S32; - typedef unsigned char BYTE; - typedef void *VOIDPTR; - typedef const void *VOIDCONSTPTR; - - #define CONST const - #define PRINTER "PRT:" - #define LOBYTEFIRST 1 - #define SLASHC '\\' - #define SLASH "\\" - #define SLASHSLASH "\\\\" - #define SLASHDOT "\\." - #define DOTSLASH ".\\" - #define DOTDOTSLASH "..\\" - #define READMODE "rb" /* Correct DOS text-mode */ - #define WRITEMODE "wb" /* file open "feature". */ - - #define write1(ptr,len,n,stream) fwrite(ptr,len,n,stream) - #define write2(ptr,len,n,stream) fwrite(ptr,len,n,stream) - #define rand15() rand() - - #ifndef BYTE_ORDER - /* change for little endians that don't have this defined elsewhere (endian.h) */ - #ifdef LINUX - #define BYTE_ORDER LITTLE_ENDIAN - #else - #define BYTE_ORDER BIG_ENDIAN /* the usual case */ - #endif - #endif - - #ifndef USE_BIGNUM_C_CODE - #define USE_BIGNUM_C_CODE - #endif - #ifndef BIG_ANSI_C - #define BIG_ANSI_C - #endif - - /* TODO: we should refactor this into something better instead of using unix.h */ - #include "unix.h" - - /*================================== Win32 definitions */ - -#else -#ifdef MSDOS /* Microsoft C 5.1 for OS/2 and MSDOS */ - /* NOTE: this is always true on DOS! */ - /* (MSDOS is defined above) */ -# define timebx timeb - -# ifndef BYTE_ORDER -# define BYTE_ORDER LITTLE_ENDIAN -# endif - -# ifdef _MSC_VER /* MSC assert does nothing under MSDOS */ -# ifdef assert -# undef assert -# define assert(X) -# endif -# endif - - typedef unsigned char U8; - typedef signed char S8; - typedef unsigned short U16; - typedef signed short S16; - typedef unsigned long U32; - typedef signed long S32; - typedef unsigned char BYTE; - typedef unsigned char CHAR; - typedef void *VOIDPTR; - typedef const void *VOIDCONSTPTR; - - #define CONST const - #define PRINTER "/dev/prn" - #define LOBYTEFIRST 1 - #define SLASHC '\\' - #define SLASH "\\" - #define SLASHSLASH "\\\\" - #define SLASHDOT "\\." - #define DOTSLASH ".\\" - #define DOTDOTSLASH "..\\" - #define READMODE "rb" /* Correct DOS text-mode */ - #define WRITEMODE "wb" /* file open "feature". */ - - #define write1(ptr,len,n,stream) fwrite(ptr,len,n,stream) - #define write2(ptr,len,n,stream) fwrite(ptr,len,n,stream) - #define rand15() rand() - -#else /* Have to nest because #elif is not portable */ -# ifdef AMIGA /* Lattice C 3.02 for Amiga */ - typedef UBYTE U8; - typedef BYTE S8; - typedef UWORD U16; - typedef WORD S16; - typedef unsigned int U32; - typedef int S32; - typedef UBYTE BYTE; - typedef UBYTE CHAR; - - typedef void *VOIDPTR; - typedef const void *VOIDCONSTPTR; - - #define PRINTER "PRT:" - #define LOBYTEFIRST 0 - #define SLASHC '/' - #define SLASH "/" - #define SLASHSLASH "//" - #define SLASHDOT "/." - #define DOTSLASH "./" - #define DOTDOTSLASH "../" - #define READMODE "rb" - #define WRITEMODE "wb" - - #define write1(ptr,len,n,stream) (fputc(*(ptr),stream),1) - #define write2(ptr,len,n,stream) (fputc((*(ptr))&255,stream),fputc((*(ptr))>>8,stream),1) - #define rand15() (rand()&0x7FFF) - - #define BYTE_ORDER BIG_ENDIAN - #define USE_BIGNUM_C_CODE - #define BIG_ANSI_C -# else -# ifdef unix /* Unix machine */ - typedef unsigned char U8; - typedef signed char S8; - typedef unsigned short U16; - typedef short S16; - typedef unsigned long U32; - typedef long S32; - typedef unsigned char BYTE; - typedef char CHAR; - - #ifndef __cdecl - #define __cdecl - #endif - - #ifdef __SVR4 - typedef void *VOIDPTR; - typedef const void *VOIDCONSTPTR; - #else - # ifdef BADVOID - typedef char *VOIDPTR; - typedef char *VOIDCONSTPTR; - # else - typedef void *VOIDPTR; - typedef const void *VOIDCONSTPTR; - # endif - #endif - - #ifdef __SVR4 - # include - typedef void sigfunc(int); - #else - typedef int sigfunc(int); - #endif - - #ifndef BYTE_ORDER - /* change for little endians that don't have this defined elsewhere (endian.h) */ - #ifdef LINUX - #define BYTE_ORDER LITTLE_ENDIAN - #else - #define BYTE_ORDER BIG_ENDIAN /* the usual case */ - #endif - #endif - - #ifndef USE_BIGNUM_C_CODE - #define USE_BIGNUM_C_CODE - #endif - #ifndef BIG_ANSI_C - #define BIG_ANSI_C - #endif - -# define CONST const -# define PRINTER "/dev/lp" -# define SLASHC '/' -# define SLASH "/" -# define SLASHSLASH "//" -# define SLASHDOT "/." -# define DOTSLASH "./" -# define DOTDOTSLASH "../" -# define READMODE "r" -# define WRITEMODE "w" - -# define write1(ptr,len,n,stream) (fputc(*(ptr),stream),1) -# define write2(ptr,len,n,stream) (fputc((*(ptr))&255,stream),fputc((*(ptr))>>8,stream),1) -# define rand15() (rand()&0x7FFF) - -# include "unix.h" - - -# endif /* unix */ -# endif /* AMIGA */ -#endif /* MSDOS */ -#endif /* _WIN32 */ - -/* Uses big_access32(), big_set32(),... functions instead of macros. */ -/* Some little endian machines may require this as well. */ -#if BYTE_ORDER == BIG_ENDIAN -#define ACCESS_BY_BYTE -#endif - -#ifdef LOBYTEFIRST -#define GET16(c,i) (i) = *((U16*)(&(c))) -#else -#define GET16(c,i) (i) = (*(unsigned char *)&(c))+\ - ((*((unsigned char*)&(c)+1))<<8) -#endif - -/* Some compiler libraries don't correctly handle long double.*/ -/* If you want to force the use of doubles, or */ -/* if the compiler supports long doubles, but does not allow */ -/* scanf("%Lf", &longdoublevar); */ -/* to read in a long double, then uncomment this next line */ -/* #define DO_NOT_USE_LONG_DOUBLE */ -/* #define USE_BIGNUM_C_CODE */ /* ASM code requires using long double */ - -/* HP-UX support long doubles and allows them to be read in with */ -/* scanf(), but does not support the functions sinl, cosl, fabsl, etc. */ -/* CAE added this 26Jan95 so it would compile (altered by Wes to new macro) */ -#ifdef _HPUX_SOURCE -#define DO_NOT_USE_LONG_DOUBLE -#endif - -/* Solaris itself does not provide long double arithmetics like sinl. - * However, the "sunmath" library that comes bundled with Sun C does - * provide them. */ -#ifdef sun -#ifdef USE_SUNMATH -#include -#else -#define DO_NOT_USE_LONG_DOUBLE -#endif -#endif - -/* This should not be neccessary, but below appears to not work */ -#ifdef CYGWIN -#define DO_NOT_USE_LONG_DOUBLE -#endif - -#ifndef DO_NOT_USE_LONG_DOUBLE -#ifdef LDBL_DIG -/* this is what we're hoping for */ -#define USE_LONG_DOUBLE - typedef long double LDBL; -#else -#define DO_NOT_USE_LONG_DOUBLE -#endif /* #ifdef LDBL_DIG */ -#endif /* #ifndef DO_NOT_USE_LONG_DOUBLE */ - - -#ifdef DO_NOT_USE_LONG_DOUBLE - -#ifdef USE_LONG_DOUBLE -#undef USE_LONG_DOUBLE -#endif - -/* long double isn't supported */ -/* impliment LDBL as double */ - typedef double LDBL; - -#if !defined(LDBL_DIG) -#define LDBL_DIG DBL_DIG /* # of decimal digits of precision */ -#endif -#if !defined(LDBL_EPSILON) -#define LDBL_EPSILON DBL_EPSILON /* smallest such that 1.0+LDBL_EPSILON != 1.0 */ -#endif -#if !defined(LDBL_MANT_DIG) -#define LDBL_MANT_DIG DBL_MANT_DIG /* # of bits in mantissa */ -#endif -#if !defined(LDBL_MAX) -#define LDBL_MAX DBL_MAX /* max value */ -#endif -#if !defined(LDBL_MAX_10_EXP) -#define LDBL_MAX_10_EXP DBL_MAX_10_EXP /* max decimal exponent */ -#endif -#if !defined(LDBL_MAX_EXP) -#define LDBL_MAX_EXP DBL_MAX_EXP /* max binary exponent */ -#endif -#if !defined(LDBL_MIN) -#define LDBL_MIN DBL_MIN /* min positive value */ -#endif -#if !defined(LDBL_MIN_10_EXP) -#define LDBL_MIN_10_EXP DBL_MIN_10_EXP /* min decimal exponent */ -#endif -#if !defined(LDBL_MIN_EXP) -#define LDBL_MIN_EXP DBL_MIN_EXP /* min binary exponent */ -#endif -#if !defined(LDBL_RADIX) -#define LDBL_RADIX DBL_RADIX /* exponent radix */ -#endif -#if !defined(LDBL_ROUNDS) -#define LDBL_ROUNDS DBL_ROUNDS /* addition rounding: near */ -#endif - -#define sqrtl sqrt -#define logl log -#define log10l log10 -#define atanl atan -#define fabsl fabs -#define sinl sin -#define cosl cos -#endif - -#if !defined(_WIN32) -#define _snprintf snprintf -#define _vsnprintf vsnprintf -#define _alloca alloca -#endif - -#endif /* PORT_H */ diff --git a/fractint/headers/prototyp.h b/fractint/headers/prototyp.h deleted file mode 100644 index 3f648f520..000000000 --- a/fractint/headers/prototyp.h +++ /dev/null @@ -1,1209 +0,0 @@ -#ifndef PROTOTYP_H -#define PROTOTYP_H - -/* includes needed to define the prototypes */ - -#include "mpmath.h" -#include "big.h" -#include "fractint.h" -#include "helpcom.h" -#include "externs.h" - -/* maintain the common prototypes in this file - * split the dos/win/unix prototypes into separate files. - */ - -#ifdef XFRACT -#include "unixprot.h" -#endif - -#ifdef _WIN32 -#include "winprot.h" -#endif - -#if (!defined(XFRACT) && !defined(WINFRACT) && !defined(_WIN32)) -#include "dosprot.h" -#endif - -/* calcmand -- assembler file prototypes */ - -extern long cdecl calcmandasm(void); - -/* calmanfp -- assembler file prototypes */ - -extern void cdecl calcmandfpasmstart(void); -/* extern long cdecl calcmandfpasm(void); */ -extern long cdecl calcmandfpasm_287(void); -extern long cdecl calcmandfpasm_87(void); -extern long (*calcmandfpasm)(void); - -/* fpu087 -- assembler file prototypes */ - -extern void cdecl FPUcplxmul(_CMPLX *, _CMPLX *, _CMPLX *); -extern void cdecl FPUcplxdiv(_CMPLX *, _CMPLX *, _CMPLX *); -extern void cdecl FPUsincos(double *, double *, double *); -extern void cdecl FPUsinhcosh(double *, double *, double *); -extern void cdecl FPUcplxlog(_CMPLX *, _CMPLX *); -extern void cdecl SinCos086(long , long *, long *); -extern void cdecl SinhCosh086(long , long *, long *); -extern long cdecl r16Mul(long , long ); -extern long cdecl RegFloat2Fg(long , int ); -extern long cdecl Exp086(long); -extern unsigned long cdecl ExpFudged(long , int ); -extern long cdecl RegDivFloat(long , long ); -extern long cdecl LogFudged(unsigned long , int ); -extern long cdecl LogFloat14(unsigned long ); -#if !defined(XFRACT) && !defined(_WIN32) -extern long cdecl RegFg2Float(long, char); -extern long cdecl RegSftFloat(long, char); -#else -extern long cdecl RegFg2Float(long , int ); -extern long cdecl RegSftFloat(long , int ); -#endif - -/* fpu387 -- assembler file prototypes */ - -extern void cdecl FPUaptan387(double *, double *, double *); -extern void cdecl FPUcplxexp387(_CMPLX *, _CMPLX *); - -/* fracsuba -- assembler file prototypes */ - -extern int near asmlMODbailout(void); -extern int near asmlREALbailout(void); -extern int near asmlIMAGbailout(void); -extern int near asmlORbailout(void); -extern int near asmlANDbailout(void); -extern int near asmlMANHbailout(void); -extern int near asmlMANRbailout(void); -extern int near asm386lMODbailout(void); -extern int near asm386lREALbailout(void); -extern int near asm386lIMAGbailout(void); -extern int near asm386lORbailout(void); -extern int near asm386lANDbailout(void); -extern int near asm386lMANHbailout(void); -extern int near asm386lMANRbailout(void); -extern int FManOWarfpFractal( void ); -extern int FJuliafpFractal( void ); -extern int FBarnsley1FPFractal( void ); -extern int FBarnsley2FPFractal( void ); -extern int FLambdaFPFractal( void ); -extern int near asmfpMODbailout(void); -extern int near asmfpREALbailout(void); -extern int near asmfpIMAGbailout(void); -extern int near asmfpORbailout(void); -extern int near asmfpANDbailout(void); -extern int near asmfpMANHbailout(void); -extern int near asmfpMANRbailout(void); - -/* mpmath_a -- assembler file prototypes */ - -extern struct MP * MPmul086(struct MP , struct MP ); -extern struct MP * MPdiv086(struct MP , struct MP ); -extern struct MP * MPadd086(struct MP , struct MP ); -extern int MPcmp086(struct MP , struct MP ); -extern struct MP * d2MP086(double ); -extern double * MP2d086(struct MP ); -extern struct MP * fg2MP086(long , int ); -extern struct MP * MPmul386(struct MP , struct MP ); -extern struct MP * MPdiv386(struct MP , struct MP ); -extern struct MP * MPadd386(struct MP , struct MP ); -extern int MPcmp386(struct MP , struct MP ); -extern struct MP * d2MP386(double ); -extern double * MP2d386(struct MP ); -extern struct MP * fg2MP386(long , int ); -extern double * MP2d(struct MP ); -extern int MPcmp(struct MP , struct MP ); -extern struct MP * MPmul(struct MP , struct MP ); -extern struct MP * MPadd(struct MP , struct MP ); -extern struct MP * MPdiv(struct MP , struct MP ); -extern struct MP * d2MP(double ); /* Convert double to type MP */ -extern struct MP * fg2MP(long , int ); /* Convert fudged to type MP */ - -/* newton -- assembler file prototypes */ - -extern int cdecl NewtonFractal2( void ); -extern void cdecl invertz2(_CMPLX *); - -/* tplus_a -- assembler file prototypes */ - -extern void WriteTPlusBankedPixel(int, int, unsigned long); -extern unsigned long ReadTPlusBankedPixel(int, int); - -/* 3d -- C file prototypes */ - -extern void identity(MATRIX); -extern void mat_mul(MATRIX,MATRIX,MATRIX); -extern void scale(double ,double ,double ,MATRIX); -extern void xrot(double ,MATRIX); -extern void yrot(double ,MATRIX); -extern void zrot(double ,MATRIX); -extern void trans(double ,double ,double ,MATRIX); -extern int cross_product(VECTOR,VECTOR,VECTOR); -extern int normalize_vector(VECTOR); -extern int vmult(VECTOR,MATRIX,VECTOR); -extern void mult_vec(VECTOR); -extern int perspective(VECTOR); -extern int longvmultpersp(LVECTOR,LMATRIX,LVECTOR,LVECTOR,LVECTOR,int); -extern int longpersp(LVECTOR,LVECTOR,int ); -extern int longvmult(LVECTOR,LMATRIX,LVECTOR,int ); - -/* biginit -- C file prototypes */ - -/* CAE removed static functions from header 28 Jan 95 */ - -void free_bf_vars(void); -bn_t alloc_stack(size_t size); -int save_stack(void); -void restore_stack(int old_offset); -void init_bf_dec(int dec); -void init_bf_length(int bnl); -void init_big_pi(void); - - -/* calcfrac -- C file prototypes */ - -extern int calcfract(void); -extern int calcmand(void); -extern int calcmandfp(void); -extern int StandardFractal(void); -extern int test(void); -extern int plasma(void); -extern int diffusion(void); -extern int Bifurcation(void ); -extern int BifurcLambda(void); -extern int BifurcSetTrigPi(void); -extern int LongBifurcSetTrigPi(void); -extern int BifurcAddTrigPi(void); -extern int LongBifurcAddTrigPi(void); -extern int BifurcMay(void); -extern int BifurcMaySetup(void); -extern int LongBifurcMay(void); -extern int BifurcLambdaTrig(void); -extern int LongBifurcLambdaTrig(void); -extern int BifurcVerhulstTrig(void); -extern int LongBifurcVerhulstTrig(void); -extern int BifurcStewartTrig(void); -extern int LongBifurcStewartTrig(void); -extern int popcorn(void); -extern int lyapunov(void); -extern int lya_setup(void); -extern int cellular(void); -extern int CellularSetup(void); -extern int calcfroth(void); -extern int froth_per_pixel(void); -extern int froth_per_orbit(void); -extern int froth_setup(void); -extern int logtable_in_extra_ok(void); -extern int find_alternate_math(int, int); - -/* cmdfiles -- C file prototypes */ - -extern int cmdfiles(int ,char **); -extern int load_commands(FILE *); -extern void set_3d_defaults(void); -extern int get_curarg_len(char *curarg); -extern int get_max_curarg_len(char *floatvalstr[], int totparm); -extern int init_msg(char *,char *,int); -extern int cmdarg(char *curarg,int mode); -extern int getpower10(LDBL x); -extern void dopause(int); - -/* decoder -- C file prototypes */ - -extern short decoder(short ); -extern void set_byte_buff(BYTE *ptr); - -/* diskvid -- C file prototypes */ - -extern int pot_startdisk(void); -extern int targa_startdisk(FILE *,int ); -extern void enddisk(void); -extern int readdisk(int, int); -extern void writedisk(int, int, int); -extern void targa_readdisk(unsigned int ,unsigned int ,BYTE *,BYTE *,BYTE *); -extern void targa_writedisk(unsigned int ,unsigned int ,BYTE ,BYTE ,BYTE ); -extern void dvid_status(int ,char *); -extern int _fastcall common_startdisk(long, long, int); -extern int FromMemDisk(long,int,void *); -extern int ToMemDisk(long,int,void *); - -/* editpal -- C file prototypes */ - -extern void EditPalette(void ); -extern VOIDPTR mem_alloc(unsigned size); -void putrow(int x, int y, int width, char *buff); -void getrow(int x, int y, int width, char *buff); -void mem_init(VOIDPTR block, unsigned size); -/* void hline(int x, int y, int width, int color); */ -int Cursor_WaitKey(void); -void Cursor_CheckBlink(void); -#ifdef XFRACT -void Cursor_StartMouseTracking(void); -void Cursor_EndMouseTracking(void); -#endif -void clip_putcolor(int x, int y, int color); -int clip_getcolor(int x, int y); -BOOLEAN Cursor_Construct (void); -void Cursor_Destroy (void); -void Cursor_SetPos (int x, int y); -void Cursor_Move (int xoff, int yoff); -int Cursor_GetX (void); -int Cursor_GetY (void); -void Cursor_Hide (void); -void Cursor_Show (void); -extern void displayc(int, int, int, int, int); - -/* encoder -- C file prototypes */ - -extern int savetodisk(char *); -extern int encoder(void); -extern int _fastcall new_to_old(int new_fractype); - -/* evolve -- C file prototypes */ - -extern void initgene(void); -extern void param_history(int); -extern int get_variations(void); -extern int get_evolve_Parms(void); -extern void set_current_params(void); -extern void fiddleparms(GENEBASE gene[], int ecount); -extern void set_evolve_ranges(void); -extern void set_mutation_level(int); -extern void drawparmbox(int); -extern void spiralmap(int); -extern int unspiralmap(void); -extern int explore_check(void); -extern void SetupParamBox(void); -extern void ReleaseParamBox(void); - -/* f16 -- C file prototypes */ - -extern FILE *t16_open(char *,int *,int *,int *,U8 *); -extern int t16_getline(FILE *,int ,U16 *); - -/* fracsubr -- C file prototypes */ - -extern void free_grid_pointers(void); -extern void calcfracinit(void); -extern void adjust_corner(void); -#ifndef USE_VARARGS -extern int put_resume(int ,... ); -extern int get_resume(int ,... ); -#else -extern int put_resume(); -extern int get_resume(); -#endif -extern int alloc_resume(int ,int ); -extern int start_resume(void); -extern void end_resume(void); -extern void sleepms(long ); -extern void reset_clock(void); -extern void iplot_orbit(long ,long ,int ); -extern void plot_orbit(double ,double ,int ); -extern void scrub_orbit(void); -extern int add_worklist(int ,int, int ,int ,int ,int ,int ,int ); -extern void tidy_worklist(void); -extern void get_julia_attractor(double ,double ); -extern int ssg_blocksize(void); -extern void _fastcall symPIplot(int ,int ,int ); -extern void _fastcall symPIplot2J(int ,int ,int ); -extern void _fastcall symPIplot4J(int ,int ,int ); -extern void _fastcall symplot2(int ,int ,int ); -extern void _fastcall symplot2Y(int ,int ,int ); -extern void _fastcall symplot2J(int ,int ,int ); -extern void _fastcall symplot4(int ,int ,int ); -extern void _fastcall symplot2basin(int ,int ,int ); -extern void _fastcall symplot4basin(int ,int ,int ); -extern void _fastcall noplot(int ,int ,int ); -extern void fractal_floattobf(void); -extern void adjust_cornerbf(void); -extern void set_grid_pointers(void); -extern void fill_dx_array(void); -extern void fill_lx_array(void); -extern int snd_open(void); -extern void w_snd(int); -extern void snd_time_write(void); -extern void close_snd(void); - -/* fractalp -- C file prototypes */ - -extern int typehasparm(int,int,char *); -extern int paramnotused(int); - -/* fractals -- C file prototypes */ - -extern void FloatPreCalcMagnet2(void); -extern void cpower(_CMPLX *,int ,_CMPLX *); -extern int lcpower(_LCMPLX *,int ,_LCMPLX *,int ); -extern int lcomplex_mult(_LCMPLX ,_LCMPLX ,_LCMPLX *,int ); -extern int MPCNewtonFractal(void); -extern int Barnsley1Fractal(void); -extern int Barnsley1FPFractal(void); -extern int Barnsley2Fractal(void); -extern int Barnsley2FPFractal(void); -extern int JuliaFractal(void); -extern int JuliafpFractal(void); -extern int LambdaFPFractal(void); -extern int LambdaFractal(void); -extern int SierpinskiFractal(void); -extern int SierpinskiFPFractal(void); -extern int LambdaexponentFractal(void); -extern int LongLambdaexponentFractal(void); -extern int FloatTrigPlusExponentFractal(void); -extern int LongTrigPlusExponentFractal(void); -extern int MarksLambdaFractal(void); -extern int MarksLambdafpFractal(void); -extern int UnityFractal(void); -extern int UnityfpFractal(void); -extern int Mandel4Fractal(void); -extern int Mandel4fpFractal(void); -extern int floatZtozPluszpwrFractal(void); -extern int longZpowerFractal(void); -extern int longCmplxZpowerFractal(void); -extern int floatZpowerFractal(void); -extern int floatCmplxZpowerFractal(void); -extern int Barnsley3Fractal(void); -extern int Barnsley3FPFractal(void); -extern int TrigPlusZsquaredFractal(void); -extern int TrigPlusZsquaredfpFractal(void); -extern int Richard8fpFractal(void); -extern int Richard8Fractal(void); -extern int PopcornFractal(void); -extern int LPopcornFractal(void); -extern int PopcornFractal_Old(void); -extern int LPopcornFractal_Old(void); -extern int PopcornFractalFn(void); -extern int LPopcornFractalFn(void); -extern int MarksCplxMand(void ); -extern int SpiderfpFractal(void ); -extern int SpiderFractal(void ); -extern int TetratefpFractal(void); -extern int ZXTrigPlusZFractal(void); -extern int ScottZXTrigPlusZFractal(void); -extern int SkinnerZXTrigSubZFractal(void); -extern int ZXTrigPlusZfpFractal(void); -extern int ScottZXTrigPlusZfpFractal(void); -extern int SkinnerZXTrigSubZfpFractal(void); -extern int Sqr1overTrigFractal(void); -extern int Sqr1overTrigfpFractal(void); -extern int TrigPlusTrigFractal(void); -extern int TrigPlusTrigfpFractal(void); -extern int ScottTrigPlusTrigFractal(void); -extern int ScottTrigPlusTrigfpFractal(void); -extern int SkinnerTrigSubTrigFractal(void); -extern int SkinnerTrigSubTrigfpFractal(void); -extern int TrigXTrigfpFractal(void); -extern int TrigXTrigFractal(void); -extern int TrigPlusSqrFractal(void); -extern int TrigPlusSqrfpFractal(void); -extern int ScottTrigPlusSqrFractal(void); -extern int ScottTrigPlusSqrfpFractal(void); -extern int SkinnerTrigSubSqrFractal(void); -extern int SkinnerTrigSubSqrfpFractal(void); -extern int TrigZsqrdfpFractal(void); -extern int TrigZsqrdFractal(void); -extern int SqrTrigFractal(void); -extern int SqrTrigfpFractal(void); -extern int Magnet1Fractal(void); -extern int Magnet2Fractal(void); -extern int LambdaTrigFractal(void); -extern int LambdaTrigfpFractal(void); -extern int LambdaTrigFractal1(void); -extern int LambdaTrigfpFractal1(void); -extern int LambdaTrigFractal2(void); -extern int LambdaTrigfpFractal2(void); -extern int ManOWarFractal(void); -extern int ManOWarfpFractal(void); -extern int MarksMandelPwrfpFractal(void); -extern int MarksMandelPwrFractal(void); -extern int TimsErrorfpFractal(void); -extern int TimsErrorFractal(void); -extern int CirclefpFractal(void); -extern int VLfpFractal(void); -extern int EscherfpFractal(void); -extern int long_julia_per_pixel(void); -extern int long_richard8_per_pixel(void); -extern int long_mandel_per_pixel(void); -extern int julia_per_pixel(void); -extern int marks_mandelpwr_per_pixel(void); -extern int mandel_per_pixel(void); -extern int marksmandel_per_pixel(void); -extern int marksmandelfp_per_pixel(void); -extern int marks_mandelpwrfp_per_pixel(void); -extern int mandelfp_per_pixel(void); -extern int juliafp_per_pixel(void); -extern int MPCjulia_per_pixel(void); -extern int otherrichard8fp_per_pixel(void); -extern int othermandelfp_per_pixel(void); -extern int otherjuliafp_per_pixel(void); -extern int MarksCplxMandperp(void ); -extern int LambdaTrigOrTrigFractal(void); -extern int LambdaTrigOrTrigfpFractal(void); -extern int JuliaTrigOrTrigFractal(void); -extern int JuliaTrigOrTrigfpFractal(void); -extern int HalleyFractal(void); -extern int Halley_per_pixel(void); -extern int MPCHalleyFractal(void); -extern int MPCHalley_per_pixel(void); -extern int dynamfloat(double *,double *,double*); -extern int mandelcloudfloat(double *,double *,double*); -extern int dynam2dfloat(void); -extern int QuaternionFPFractal(void); -extern int quaternionfp_per_pixel(void); -extern int quaternionjulfp_per_pixel(void); -extern int LongPhoenixFractal(void); -extern int PhoenixFractal(void); -extern int long_phoenix_per_pixel(void); -extern int phoenix_per_pixel(void); -extern int long_mandphoenix_per_pixel(void); -extern int mandphoenix_per_pixel(void); -extern int HyperComplexFPFractal(void); -extern int LongPhoenixFractalcplx(void); -extern int PhoenixFractalcplx(void); -extern int (near *floatbailout)(void); -extern int (near *longbailout)(void); -extern int (near *bignumbailout)(void); -extern int (near *bigfltbailout)(void); -extern int near fpMODbailout(void); -extern int near fpREALbailout(void); -extern int near fpIMAGbailout(void); -extern int near fpORbailout(void); -extern int near fpANDbailout(void); -extern int near fpMANHbailout(void); -extern int near fpMANRbailout(void); -extern int near bnMODbailout(void); -extern int near bnREALbailout(void); -extern int near bnIMAGbailout(void); -extern int near bnORbailout(void); -extern int near bnANDbailout(void); -extern int near bnMANHbailout(void); -extern int near bnMANRbailout(void); -extern int near bfMODbailout(void); -extern int near bfREALbailout(void); -extern int near bfIMAGbailout(void); -extern int near bfORbailout(void); -extern int near bfANDbailout(void); -extern int near bfMANHbailout(void); -extern int near bfMANRbailout(void); -extern int ant(void); -extern void free_ant_storage(void); -extern int LongPhoenixFractal(void); -extern int PhoenixFractal(void); -extern int LongPhoenixFractalcplx(void); -extern int PhoenixFractalcplx(void); -extern int LongPhoenixPlusFractal(void); -extern int PhoenixPlusFractal(void); -extern int LongPhoenixMinusFractal(void); -extern int PhoenixMinusFractal(void); -extern int LongPhoenixCplxPlusFractal(void); -extern int PhoenixCplxPlusFractal(void); -extern int LongPhoenixCplxMinusFractal(void); -extern int PhoenixCplxMinusFractal(void); -extern int long_phoenix_per_pixel(void); -extern int phoenix_per_pixel(void); -extern int long_mandphoenix_per_pixel(void); -extern int mandphoenix_per_pixel(void); -extern void set_pixel_calc_functions(void); -extern int MandelbrotMix4fp_per_pixel(void); -extern int MandelbrotMix4fpFractal(void); -extern int MandelbrotMix4Setup(void); - -/* fractint -- C file prototypes */ - -extern int main(int argc,char **argv ); -extern int elapsed_time(int); - -/* framain2 -- C file prototypes */ - -extern int big_while_loop(int *,char *,int); -extern int check_key(void); -extern int cmp_line(BYTE *,int ); -extern int key_count(int); -extern int main_menu_switch(int *,int *,int *,char *,int); -extern int pot_line(BYTE *,int ); -extern int sound_line(BYTE *,int ); -#if !defined(XFRACT) -#if !defined(_WIN32) -extern int _cdecl _matherr(struct exception *); -#endif -#else -extern int XZoomWaiting; -#endif -#ifndef USE_VARARGS -extern int timer(int,int (*subrtn)(),...); -#else -extern int timer(); -#endif - -extern void clear_zoombox(void); -extern void flip_image(int kbdchar); -#ifndef WINFRACT -extern void reset_zoom_corners(void); -#endif -extern void setup287code(void); - -/* frasetup -- C file prototypes */ - -extern int VLSetup(void); -extern int MandelSetup(void); -extern int MandelfpSetup(void); -extern int JuliaSetup(void); -extern int NewtonSetup(void); -extern int StandaloneSetup(void); -extern int UnitySetup(void); -extern int JuliafpSetup(void); -extern int MandellongSetup(void); -extern int JulialongSetup(void); -extern int TrigPlusSqrlongSetup(void); -extern int TrigPlusSqrfpSetup(void); -extern int TrigPlusTriglongSetup(void); -extern int TrigPlusTrigfpSetup(void); -extern int FnPlusFnSym(void); -extern int ZXTrigPlusZSetup(void); -extern int LambdaTrigSetup(void); -extern int JuliafnPlusZsqrdSetup(void); -extern int SqrTrigSetup(void); -extern int FnXFnSetup(void); -extern int MandelTrigSetup(void); -extern int MarksJuliaSetup(void); -extern int MarksJuliafpSetup(void); -extern int SierpinskiSetup(void); -extern int SierpinskiFPSetup(void); -extern int StandardSetup(void); -extern int LambdaTrigOrTrigSetup(void); -extern int JuliaTrigOrTrigSetup(void); -extern int ManlamTrigOrTrigSetup(void); -extern int MandelTrigOrTrigSetup(void); -extern int HalleySetup(void); -extern int dynam2dfloatsetup(void); -extern int PhoenixSetup(void); -extern int MandPhoenixSetup(void); -extern int PhoenixCplxSetup(void); -extern int MandPhoenixCplxSetup(void); - -/* gifview -- C file prototypes */ - -extern int get_byte(void); -extern int get_bytes(BYTE *,int ); -extern int gifview(void); - -/* hcmplx -- C file prototypes */ - -extern void HComplexTrig0(_HCMPLX *,_HCMPLX *); - -/* help -- C file prototypes */ - -extern int _find_token_length(char *,unsigned int ,int *,int *); -extern int find_token_length(int ,char *,unsigned int ,int *,int *); -extern int find_line_width(int ,char *,unsigned int ); -extern int process_document(PD_FUNC ,PD_FUNC ,VOIDPTR ); -extern int help(int ); -extern int read_help_topic(int ,int ,int ,VOIDPTR); -extern int makedoc_msg_func(int ,int ); -extern void print_document(char *,int (*)(int ,int ),int ); -extern int init_help(void ); -extern void end_help(void ); - -/* intro -- C file prototypes */ - -extern void intro(void ); - -/* jb -- C file prototypes */ - -extern int JulibrotSetup(void ); -extern int JulibrotfpSetup(void ); -extern int jb_per_pixel(void ); -extern int jbfp_per_pixel(void ); -extern int zline(long ,long ); -extern int zlinefp(double ,double ); -extern int Std4dFractal(void ); -extern int Std4dfpFractal(void ); - -/* jiim -- C file prototypes */ - -extern void Jiim(int); -extern LCMPLX PopLong (void); -extern _CMPLX PopFloat (void); -extern LCMPLX DeQueueLong (void); -extern _CMPLX DeQueueFloat (void); -extern LCMPLX ComplexSqrtLong (long , long); -extern _CMPLX ComplexSqrtFloat(double, double); -extern int Init_Queue (unsigned long); -extern void Free_Queue (void); -extern void ClearQueue (void); -extern int QueueEmpty (void); -extern int QueueFull (void); -extern int QueueFullAlmost (void); -extern int PushLong (long , long); -extern int PushFloat (float, float); -extern int EnQueueLong (long , long); -extern int EnQueueFloat (float, float); - -/* line3d -- C file prototypes */ - -extern int line3d(BYTE *,unsigned int ); -extern int _fastcall targa_color(int ,int ,int ); -extern int targa_validate(char *); -extern int startdisk1(char *, FILE *, int); - -/* loadfdos -- C file prototypes */ -#ifndef WINFRACT -extern int get_video_mode(struct fractal_info *,struct ext_blk_3 *); -#endif -/* loadfile -- C file prototypes */ - -extern int read_overlay(void); -extern void set_if_old_bif(void); -extern void set_function_parm_defaults(void); -extern int fgetwindow(void); -extern void backwards_v18(void); -extern void backwards_v19(void); -extern void backwards_v20(void); -extern int check_back(void); - -/* loadmap -- C file prototypes */ - -//extern void SetTgaColors(void); -extern int ValidateLuts(char *); -extern int SetColorPaletteName(char *); - -/* lorenz -- C file prototypes */ - -extern int orbit3dlongsetup(void); -extern int orbit3dfloatsetup(void); -extern int lorenz3dlongorbit(long *,long *,long *); -extern int lorenz3d1floatorbit(double *,double *,double *); -extern int lorenz3dfloatorbit(double *,double *,double *); -extern int lorenz3d3floatorbit(double *,double *,double *); -extern int lorenz3d4floatorbit(double *,double *,double *); -extern int henonfloatorbit(double *,double *,double *); -extern int henonlongorbit(long *,long *,long *); -extern int inverse_julia_orbit(double *,double *,double *); -extern int Minverse_julia_orbit(void); -extern int Linverse_julia_orbit(void); -extern int inverse_julia_per_image(void); -extern int rosslerfloatorbit(double *,double *,double *); -extern int pickoverfloatorbit(double *,double *,double *); -extern int gingerbreadfloatorbit(double *,double *,double *); -extern int rosslerlongorbit(long *,long *,long *); -extern int kamtorusfloatorbit(double *,double *,double *); -extern int kamtoruslongorbit(long *,long *,long *); -extern int hopalong2dfloatorbit(double *,double *,double *); -extern int chip2dfloatorbit(double *,double *,double *); -extern int quadruptwo2dfloatorbit(double *,double *,double *); -extern int threeply2dfloatorbit(double *,double *,double *); -extern int martin2dfloatorbit(double *,double *,double *); -extern int orbit2dfloat(void); -extern int orbit2dlong(void); -extern int funny_glasses_call(int (*)(void)); -extern int ifs(void); -extern int orbit3dfloat(void); -extern int orbit3dlong(void); -extern int iconfloatorbit(double *, double *, double *); /* dmf */ -extern int latoofloatorbit(double *, double *, double *); /* hb */ -extern int setup_convert_to_screen(struct affine *); -extern int plotorbits2dsetup(void); -extern int plotorbits2dfloat(void); - -/* lsys -- C file prototypes */ - -extern LDBL _fastcall getnumber(char **); -extern int _fastcall ispow2(int); -extern int Lsystem(void); -extern int LLoad(void); - -/* miscfrac -- C file prototypes */ - -extern void froth_cleanup(void); - -/* miscovl -- C file prototypes */ - -extern void make_batch_file(void); -extern void edit_text_colors(void); -extern int select_video_mode(int ); -extern void format_vid_table(int choice,char *buf); -extern void make_mig(unsigned int, unsigned int); -extern int getprecdbl(int); -extern int getprecbf(int); -extern int getprecbf_mag(void); -extern void parse_comments(char *value); -extern void init_comments(void); -extern void write_batch_parms(char *, int, int, int, int); -extern void expand_comments(char *, char *); - -/* miscres -- C file prototypes */ - -extern void restore_active_ovly(void); -extern void findpath(char *,char *); -extern void notdiskmsg(void); -extern void cvtcentermag(double *,double *,LDBL *, double *,double *,double *); -extern void cvtcorners(double,double,LDBL,double,double,double); -extern void cvtcentermagbf(bf_t, bf_t, LDBL *, double *, double *, double *); -extern void cvtcornersbf(bf_t, bf_t, LDBL,double,double,double); -extern void updatesavename(char *); -extern int check_writefile(char *,char *); -extern int check_key(void); -extern void showtrig(char *); -extern int set_trig_array(int ,char *); -extern void set_trig_pointers(int ); -extern int tab_display(void); -extern int endswithslash(char *); -extern int ifsload(void); -extern int find_file_item(char *,char *,FILE **, int); -extern int file_gets(char *,int ,FILE *); -extern void roundfloatd(double *); -extern void fix_inversion(double *); -extern int ungetakey(int); -extern void get_calculation_time(char *, long); - -/* mpmath_c -- C file prototypes */ - -extern struct MP *MPsub(struct MP ,struct MP ); -extern struct MP *MPsub086(struct MP ,struct MP ); -extern struct MP *MPsub386(struct MP ,struct MP ); -extern struct MP *MPabs(struct MP ); -extern struct MPC MPCsqr(struct MPC ); -extern struct MP MPCmod(struct MPC ); -extern struct MPC MPCmul(struct MPC ,struct MPC ); -extern struct MPC MPCdiv(struct MPC ,struct MPC ); -extern struct MPC MPCadd(struct MPC ,struct MPC ); -extern struct MPC MPCsub(struct MPC ,struct MPC ); -extern struct MPC MPCpow(struct MPC ,int ); -extern int MPCcmp(struct MPC ,struct MPC ); -extern _CMPLX MPC2cmplx(struct MPC ); -extern struct MPC cmplx2MPC(_CMPLX ); -extern void setMPfunctions(void ); -extern _CMPLX ComplexPower(_CMPLX ,_CMPLX ); -extern void SetupLogTable(void ); -extern long logtablecalc(long); -extern long ExpFloat14(long ); -extern int ComplexNewtonSetup(void ); -extern int ComplexNewton(void ); -extern int ComplexBasin(void ); -extern int GausianNumber(int ,int ); -extern void Arcsinz(_CMPLX z, _CMPLX *rz); -extern void Arccosz(_CMPLX z, _CMPLX *rz); -extern void Arcsinhz(_CMPLX z, _CMPLX *rz); -extern void Arccoshz(_CMPLX z, _CMPLX *rz); -extern void Arctanhz(_CMPLX z, _CMPLX *rz); -extern void Arctanz(_CMPLX z, _CMPLX *rz); - -/* msccos -- C file prototypes */ - -extern double _cos(double ); - -/* parser -- C file prototypes */ - -struct fls { /* function, load, store pointers CAE fp */ - void (near *function)(void); - union Arg near *operand; -}; - -extern unsigned int SkipWhiteSpace(char *); -extern unsigned long NewRandNum(void ); -extern void lRandom(void ); -extern void dRandom(void ); -extern void mRandom(void ); -extern void SetRandFnct(void ); -extern void RandomSeed(void ); -extern void lStkSRand(void ); -extern void mStkSRand(void ); -extern void dStkSRand(void ); -extern void dStkAbs(void ); -extern void mStkAbs(void ); -extern void lStkAbs(void ); -extern void dStkSqr(void ); -extern void mStkSqr(void ); -extern void lStkSqr(void ); -extern void dStkAdd(void ); -extern void mStkAdd(void ); -extern void lStkAdd(void ); -extern void dStkSub(void ); -extern void mStkSub(void ); -extern void lStkSub(void ); -extern void dStkConj(void ); -extern void mStkConj(void ); -extern void lStkConj(void ); -extern void dStkZero(void ); -extern void mStkZero(void ); -extern void lStkZero(void ); -extern void dStkOne(void ); -extern void mStkOne(void ); -extern void lStkOne(void ); -extern void dStkReal(void ); -extern void mStkReal(void ); -extern void lStkReal(void ); -extern void dStkImag(void ); -extern void mStkImag(void ); -extern void lStkImag(void ); -extern void dStkNeg(void ); -extern void mStkNeg(void ); -extern void lStkNeg(void ); -extern void dStkMul(void ); -extern void mStkMul(void ); -extern void lStkMul(void ); -extern void dStkDiv(void ); -extern void mStkDiv(void ); -extern void lStkDiv(void ); -extern void StkSto(void ); -extern void StkLod(void ); -extern void dStkMod(void ); -extern void mStkMod(void ); -extern void lStkMod(void ); -extern void StkClr(void ); -extern void dStkFlip(void ); -extern void mStkFlip(void ); -extern void lStkFlip(void ); -extern void dStkSin(void ); -extern void mStkSin(void ); -extern void lStkSin(void ); -extern void dStkTan(void ); -extern void mStkTan(void ); -extern void lStkTan(void ); -extern void dStkTanh(void ); -extern void mStkTanh(void ); -extern void lStkTanh(void ); -extern void dStkCoTan(void ); -extern void mStkCoTan(void ); -extern void lStkCoTan(void ); -extern void dStkCoTanh(void ); -extern void mStkCoTanh(void ); -extern void lStkCoTanh(void ); -extern void dStkRecip(void ); -extern void mStkRecip(void ); -extern void lStkRecip(void ); -extern void StkIdent(void ); -extern void dStkSinh(void ); -extern void mStkSinh(void ); -extern void lStkSinh(void ); -extern void dStkCos(void ); -extern void mStkCos(void ); -extern void lStkCos(void ); -extern void dStkCosXX(void ); -extern void mStkCosXX(void ); -extern void lStkCosXX(void ); -extern void dStkCosh(void ); -extern void mStkCosh(void ); -extern void lStkCosh(void ); -extern void dStkLT(void ); -extern void mStkLT(void ); -extern void lStkLT(void ); -extern void dStkGT(void ); -extern void mStkGT(void ); -extern void lStkGT(void ); -extern void dStkLTE(void ); -extern void mStkLTE(void ); -extern void lStkLTE(void ); -extern void dStkGTE(void ); -extern void mStkGTE(void ); -extern void lStkGTE(void ); -extern void dStkEQ(void ); -extern void mStkEQ(void ); -extern void lStkEQ(void ); -extern void dStkNE(void ); -extern void mStkNE(void ); -extern void lStkNE(void ); -extern void dStkOR(void ); -extern void mStkOR(void ); -extern void lStkOR(void ); -extern void dStkAND(void ); -extern void mStkAND(void ); -extern void lStkAND(void ); -extern void dStkLog(void ); -extern void mStkLog(void ); -extern void lStkLog(void ); -extern void FPUcplxexp(_CMPLX *,_CMPLX *); -extern void dStkExp(void ); -extern void mStkExp(void ); -extern void lStkExp(void ); -extern void dStkPwr(void ); -extern void mStkPwr(void ); -extern void lStkPwr(void ); -extern void dStkASin(void ); -extern void mStkASin(void ); -extern void lStkASin(void ); -extern void dStkASinh(void ); -extern void mStkASinh(void ); -extern void lStkASinh(void ); -extern void dStkACos(void ); -extern void mStkACos(void ); -extern void lStkACos(void ); -extern void dStkACosh(void ); -extern void mStkACosh(void ); -extern void lStkACosh(void ); -extern void dStkATan(void ); -extern void mStkATan(void ); -extern void lStkATan(void ); -extern void dStkATanh(void ); -extern void mStkATanh(void ); -extern void lStkATanh(void ); -extern void dStkCAbs(void ); -extern void mStkCAbs(void ); -extern void lStkCAbs(void ); -extern void dStkSqrt(void ); -extern void mStkSqrt(void ); -extern void lStkSqrt(void ); -extern void dStkFloor(void ); -extern void mStkFloor(void ); -extern void lStkFloor(void ); -extern void dStkCeil(void ); -extern void mStkCeil(void ); -extern void lStkCeil(void ); -extern void dStkTrunc(void ); -extern void mStkTrunc(void ); -extern void lStkTrunc(void ); -extern void dStkRound(void ); -extern void mStkRound(void ); -extern void lStkRound(void ); -extern void (*mtrig0)(void); -extern void (*mtrig1)(void); -extern void (*mtrig2)(void); -extern void (*mtrig3)(void); -extern void EndInit(void ); -extern struct ConstArg *isconst(char *,int ); -extern void NotAFnct(void ); -extern void FnctNotFound(void ); -extern int whichfn(char *,int ); -extern int CvtStk(void); -extern int fFormula(void ); -#ifndef XFRACT -extern void (*isfunct(char *,int ))(void ); -#else -extern void (*isfunct(char *,int ))(); -#endif -extern void RecSortPrec(void ); -extern int Formula(void ); -extern int BadFormula(void ); -extern int form_per_pixel(void ); -extern int frm_get_param_stuff (char * ); -extern int RunForm(char *, int); -extern int fpFormulaSetup(void ); -extern int intFormulaSetup(void ); -extern void init_misc(void); -extern void free_workarea(void); -extern int fill_if_group(int endif_index, JUMP_PTRS_ST *jump_data); - -/* plot3d -- C file prototypes */ - -extern void cdecl draw_line(int ,int ,int ,int ,int ); -extern void _fastcall plot3dsuperimpose16(int ,int ,int ); -extern void _fastcall plot3dsuperimpose256(int ,int ,int ); -extern void _fastcall plotIFS3dsuperimpose256(int ,int ,int ); -extern void _fastcall plot3dalternate(int ,int ,int ); -extern void plot_setup(void); - -/* printer -- C file prototypes */ - -extern void Print_Screen(void); - -/* prompts1 -- C file prototypes */ - -extern int fullscreen_prompt(char far*,int ,char **,struct fullscreenvalues *,int ,char *); -extern long get_file_entry(int,char *,char *,char *,char *); -extern int get_fracttype(void); -extern int get_fract_params(int ); -extern int get_fract3d_params(void); -extern int get_3d_params(void); -extern int prompt_valuestring(char *buf,struct fullscreenvalues *val); -extern void setbailoutformula(enum bailouts); -extern int find_extra_param(int); -extern void load_params(int fractype); -extern int check_orbit_name(char *); -extern int scan_entries(FILE *infile, void *ch, char *itemname); - -/* prompts2 -- C file prototypes */ - -extern int get_toggles(void); -extern int get_toggles2(void); -extern int passes_options(void); -extern int get_view_params(void); -extern int get_starfield_params(void ); -extern int get_commands(void); -extern void goodbye(void); -extern int isadirectory(char *s); -extern int getafilename(char *,char *,char *); -extern int splitpath(char *file_template,char *drive,char *dir,char *fname,char *ext); -extern int makepath(char *file_template,char *drive,char *dir,char *fname,char *ext); -extern int fr_findfirst(char *path); -extern int fr_findnext(void ); -extern void shell_sort(void *,int n,unsigned,int (__cdecl *fct)(VOIDPTR,VOIDPTR)); -extern void fix_dirname(char *dirname); -extern int merge_pathnames(char *, char *, int); -extern int get_browse_params(void); -extern int get_cmd_string(void); -extern int get_rds_params(void); -extern int starfield(void); -extern int get_a_number(double *, double *); -extern int lccompare(VOIDPTR, VOIDPTR); -extern int dir_remove(char *,char *); -extern FILE *dir_fopen(char *, char *, char *); -extern void extract_filename(char *, char *); -extern char *has_ext(char *source); - -/* realdos -- C file prototypes */ - -extern int showvidlength(void); -extern int stopmsg(int ,char *); -extern void blankrows(int ,int ,int ); -extern int texttempmsg(char *); -extern int fullscreen_choice(int options, char *hdg, char *hdg2, - char *instr, int numchoices, char **choices, int *attributes, - int boxwidth, int boxdepth, int colwidth, int current, - void (*formatitem)(int, char *), char *speedstring, - int (*speedprompt)(int, int, int, char *, int), - int (*checkkey)(int, int)); -#if !defined(WINFRACT) -extern int showtempmsg(char *); -extern void cleartempmsg(void); -extern void helptitle(void); -extern int putstringcenter(int ,int ,int ,int ,char *); -#ifndef XFRACT /* Unix should have this in string.h */ -extern int strncasecmp(char *,char *,int ); -#endif -extern int main_menu(int ); -extern int input_field(int ,int ,char *,int ,int ,int ,int (*)(int)); -extern int field_prompt(char *,char *,char *,int ,int (*)(int)); -extern int thinking(int ,char *); -extern int savegraphics(void); -extern int restoregraphics(void); -extern void discardgraphics(void); -extern void load_fractint_config(void); -extern int check_vidmode_key(int ,int ); -extern int check_vidmode_keyname(char *); -extern void vidmode_keyname(int ,char *); -extern void freetempmsg(void); -#endif -extern void load_videotable(int ); -extern void bad_fractint_cfg_msg(void); - -/* rotate -- C file prototypes */ - -extern void rotate(int ); -extern void save_palette(void); -extern int load_palette(void ); - -/* slideshw -- C file prototypes */ - -extern int slideshw(void); -extern int startslideshow(void); -extern void stopslideshow(void); -extern void recordshw(int ); - -/* stereo -- C file prototypes */ - -extern int do_AutoStereo(void); -extern int outline_stereo(BYTE *, int); - -/* targa -- C file prototypes */ - -extern void WriteTGA(int ,int ,int ); -extern int ReadTGA(int ,int ); -extern void EndTGA(void ); -extern void StartTGA(void); -extern void ReopenTGA(void); - -/* testpt -- C file prototypes */ - -extern int teststart(void); -extern void testend(void); -extern int testpt(double ,double ,double ,double ,long ,int ); - -/* tgaview -- C file prototypes */ - -extern int tgaview(void); -extern int outlin16(BYTE*,int ); - -/* yourvid -- C file prototypes */ - -//extern int startvideo(void); -//extern int endvideo(void); -//extern void writevideo(int ,int ,int ); -//extern int readvideo(int ,int ); -//extern int readvideopalette(void); -//extern int writevideopalette(void); -#ifdef XFRACT -//extern void readvideoline(int ,int, int, BYTE * ); -//extern void writevideoline(int ,int, int, BYTE * ); -#endif - -/* zoom -- C file prototypes */ - -extern void drawbox(int ); -extern void moveboxf(double ,double ); -extern void resizebox(int ); -extern void chgboxi(int ,int ); -extern void zoomout(void); -extern void aspectratio_crop(float ,float ); -extern int init_pan_or_recalc(int ); -extern void _fastcall drawlines(struct coords, struct coords, int, int); -extern void _fastcall addbox(struct coords); -extern void clearbox(void); -extern void dispbox(void); - -/* fractalb.c -- C file prototypes */ - -extern _CMPLX cmplxbntofloat(_BNCMPLX *); -extern _CMPLX cmplxbftofloat(_BFCMPLX *); -extern void comparevalues(char *,LDBL,bn_t); -extern void comparevaluesbf(char *,LDBL,bf_t); -extern void show_var_bf(char *s, bf_t n); -extern void show_two_bf(char *,bf_t,char *, bf_t, int); -extern void bfcornerstofloat(void); -extern void showcornersdbl(char *); -extern int MandelbnSetup(void); -extern int mandelbn_per_pixel(void); -extern int juliabn_per_pixel(void); -extern int JuliabnFractal(void); -extern int JuliaZpowerbnFractal(void); -extern _BNCMPLX *cmplxlog_bn(_BNCMPLX *t, _BNCMPLX *s); -extern _BNCMPLX *cplxmul_bn( _BNCMPLX *t, _BNCMPLX *x, _BNCMPLX *y); -extern _BNCMPLX *ComplexPower_bn(_BNCMPLX *t, _BNCMPLX *xx, _BNCMPLX *yy); -extern int MandelbfSetup(void); -extern int mandelbf_per_pixel(void); -extern int juliabf_per_pixel(void); -extern int JuliabfFractal(void); -extern int JuliaZpowerbfFractal(void); -extern _BFCMPLX *cmplxlog_bf(_BFCMPLX *t, _BFCMPLX *s); -extern _BFCMPLX *cplxmul_bf( _BFCMPLX *t, _BFCMPLX *x, _BFCMPLX *y); -extern _BFCMPLX *ComplexPower_bf(_BFCMPLX *t, _BFCMPLX *xx, _BFCMPLX *yy); - -/* memory -- C file prototypes */ -/* TODO: Get rid of this and use regular memory routines; -** see about creating standard disk memory routines for disk video -*/ -extern void DisplayHandle (U16 handle); -extern int MemoryType (U16 handle); -extern void InitMemory (void); -extern void ExitCheck (void); -extern U16 MemoryAlloc(U16 size, long count, int stored_at); -extern void MemoryRelease(U16 handle); -extern int MoveToMemory(BYTE *buffer,U16 size,long count,long offset,U16 handle); -extern int MoveFromMemory(BYTE *buffer,U16 size,long count,long offset,U16 handle); -extern int SetMemory(int value,U16 size,long count,long offset,U16 handle); - -/* soi -- C file prototypes */ - -extern void soi (void); -extern void soi_ldbl (void); - -/* - * uclock -- C file prototypes - * The uclock_t typedef placed here because uclock.h - * prototype is for DOS version only. - */ -typedef unsigned long uclock_t; - -extern uclock_t usec_clock(void); -extern void restart_uclock(void); -extern void wait_until(int index, uclock_t wait_time); - -extern void init_failure(const char *message); -extern int expand_dirname(char *dirname,char *drive); -extern int abortmsg(char *file, unsigned int line, int flags, char *msg); -#define ABORT(flags_,msg_) abortmsg(__FILE__, __LINE__, flags_, msg_) - -#ifndef DEBUG -/*#define DEBUG */ -#endif - -#endif diff --git a/fractint/headers/unix.h b/fractint/headers/unix.h deleted file mode 100644 index 074e913cf..000000000 --- a/fractint/headers/unix.h +++ /dev/null @@ -1,129 +0,0 @@ -/* UNIX.H - unix port declarations */ - - -#ifndef _UNIX_H -#define _UNIX_H - -#define far -#define cdecl -#define huge -#define near -#ifndef RAND_MAX -#define RAND_MAX 0x7fffffff -#endif - -#if !defined(O_BINARY) -#define O_BINARY 0 -#endif - -#ifdef CLK_TCK -#undef CLK_TCK -#endif -#define CLK_TCK 1000 -typedef float FLOAT4; -typedef short INT2; -typedef unsigned short UINT2; -typedef int INT4; -typedef unsigned int UINT4; -#if !defined(max) -#define max(a,b) ((a)>(b)?(a):(b)) -#endif -#if !defined(min) -#define min(a,b) ((a)<(b)?(a):(b)) -#endif -#define remove(x) unlink(x) -#if !defined(_MAX_FNAME) -#define _MAX_FNAME 20 -#endif -#if !defined(_MAX_EXT) -#define _MAX_EXT 4 -#endif -#if !defined(_WIN32) -#define chsize(fd,len) ftruncate(fd,len) -#endif - -#define inp(x) 0 -#define outp(x,y) - -#ifndef labs -#define labs(x) ((x)>0?(x):-(x)) -#endif - -/* We get a problem with connect, since it is used by X */ -#define connect connect1 -/* dysize may conflict with time.h */ -#define dysize dysize1 -/* inline is a reserved word, so fixed lsys.c */ -/* #define inline inline1 */ - -typedef void (*SignalHandler)(int); - -#ifdef NOSIGHAND -typedef void (*SignalHandler)(int); -#endif - -/* Some stdio.h's don't have this */ -#ifndef SEEK_SET -#define SEEK_SET 0 -#endif -#ifndef SEEK_CUR -#define SEEK_CUR 1 -#endif -#ifndef SEEK_END -#define SEEK_END 2 -#endif - -extern int iocount; - -char *strlwr(char *s); -char *strupr(char *s); - -#if defined(_WIN32) -#define bcopy(src,dst,n) memcpy(dst,src,n) -#define bzero(buf,siz) memset(buf,0,siz) -#define bcmp(buf1,buf2,len) memcmp(buf1,buf2,len) -#else -#ifndef LINUX -#ifndef __SVR4 -/* bcopy is probably faster than memmove, memcpy */ -# ifdef memcpy -# undef memcpy -# endif -# ifdef memmove -# undef memmove -# endif - -# define memcpy(dst,src,n) bcopy(src,dst,n) -# define memmove(dst,src,n) bcopy(src,dst,n) -#else -# define bcopy(src,dst,n) memcpy(dst,src,n) -# define bzero(buf,siz) memset(buf,0,siz) -# define bcmp(buf1,buf2,len) memcmp(buf1,buf2,len) -#endif -#endif -#endif - -/* - * These defines are so movedata, etc. will work properly, without worrying - * about the silly segment stuff. - */ -#define movedata(s_seg,s_off,d_seg,d_off,len) bcopy(s_off,d_off,len) -struct SREGS { - int ds; -}; -#define FP_SEG(x) 0 -#define FP_OFF(x) ((char *)(x)) -#define segread(x) - -/* ftime replacement */ -#include -typedef struct timebx -{ - time_t time; - unsigned short millitm; - int timezone; - int dstflag; -} timebx; - - -#endif diff --git a/fractint/headers/unixprot.h b/fractint/headers/unixprot.h deleted file mode 100644 index 939dbed48..000000000 --- a/fractint/headers/unixprot.h +++ /dev/null @@ -1,102 +0,0 @@ -#ifndef UNIXPROT_H -#define UNIXPROT_H - -/* This file contains prototypes for unix/linux specific functions. */ - - - - -/* calmanp5 -- assembler file prototypes */ - -extern long cdecl calcmandfpasm_c(void); -extern long cdecl calcmandfpasm_p5(void); -extern void cdecl calcmandfpasmstart_p5(void); - - -/* - * general.c -- C file prototypes - */ -extern int waitkeypressed(int); -extern void fix_ranges(int *, int, int); -extern void decode_evolver_info(struct evolution_info *, int); -extern void decode_fractal_info(struct fractal_info *, int); -extern void decode_orbits_info(struct orbits_info *, int); - -/* - * unix.c -- C file prototypes - */ -extern long clock_ticks(void); -#ifndef HAVESTRI -extern int stricmp(char *, char *); -extern int strnicmp(char *, char *, int); -#endif -#if !defined(_WIN32) -extern int memicmp(char *, char *, int); -extern unsigned short _rotl(unsigned short, short); -extern int ltoa(long, char *, int); -#endif -extern void ftimex(struct timebx *); -extern long stackavail(void); -extern int kbhit(void); - -/* unixscr.c -- C file prototypes */ - -int unixarg(int argc, char **argv, int *i); -/* Parses xfractint-specific command line arguments */ -void UnixInit(void); -/* initializes curses text window and the signal handlers. */ -void initUnixWindow(void); -/* initializes the graphics window, colormap, etc. */ -void UnixDone(void); -/* cleans up X window and curses. */ -int startvideo(void); -/* clears the graphics window */ -int endvideo(void); -/* just a stub. */ -int readvideo(int x, int y); -/* reads a pixel from the screen. */ -void readvideoline(int y, int x, int lastx, BYTE *pixels); -/* reads a line of pixels from the screen. */ -void writevideo(int x, int y, int color); -/* writes a pixel to the screen. */ -void writevideoline(int y, int x, int lastx, BYTE *pixels); -/* writes a line of pixels to the screen. */ -int readvideopalette(void); -/* reads the current colormap into dacbox. */ -int writevideopalette(void); -/* writes the current colormap from dacbox. */ -int resizeWindow(void); -/* Checks if the window has been resized, and handles the resize. */ -int xgetkey(int block); -/* Checks if a key has been pressed. */ -unsigned char * xgetfont(void); -/* Returns bitmap of an 8x8 font. */ -void drawline(int x1, int y1, int x2, int y2); -/* Draws a line from (x1,y1) to (x2,y2). */ -void setlinemode(int mode); -/* Sets line mode to draw or xor. */ -void shell_to_dos(void); -/* Calls a Unix subshell. */ -void xsync(void); -/* Forces all window events to be processed. */ -void redrawscreen(void); -/* Used with schedulealarm. Xfractint has a delayed write mode, - * where the screen is updated only every few seconds. - */ -void schedulealarm(int soon); -/* Schedules the next delayed update. */ - -/* - * video.c -- C file prototypes - */ -extern void putprompt(void); -extern void loaddac(void); -extern void putcolor_a(int, int, int); -extern int out_line(BYTE *, int); -extern int getcolor(int, int); -extern void setvideomode(int, int, int, int); -extern void putstring(int,int,int,char far *); -extern BYTE *findfont (int); - -#endif - diff --git a/fractint/headers/winprot.h b/fractint/headers/winprot.h deleted file mode 100644 index a8ecb145c..000000000 --- a/fractint/headers/winprot.h +++ /dev/null @@ -1,154 +0,0 @@ -#ifndef WINPROT_H -#define WINPROT_H - -/* This file contains prototypes for win specific functions. */ - -/* calmanp5 -- assembler file prototypes */ - -extern long cdecl calcmandfpasm_p5(void); -extern void cdecl calcmandfpasmstart_p5(void); - -/* wgeneral -- assembler file prototypes */ - -extern long cdecl multiply(long, long, int); -extern long cdecl divide(long, long, int); - -/* dialog -- C file prototypes */ - -extern void PrintFile(void); -extern int Win_OpenFile(unsigned char *); -extern Win_SaveFile(unsigned char *); - -/* prompts1 -- C file prototypes */ - -extern void set_default_parms(void); - -/* windos -- C file prototypes */ - -extern void debugmessage(char *, char *); -extern int stopmsg(int , char far *); -extern int farread(int, VOIDPTR, unsigned); -extern int farwrite(int, VOIDPTR, unsigned); -extern void far_memcpy(void far *, void far *, int); -extern void far_memset(void far *, int , int); -extern int getcolor(int, int); -extern int out_line(BYTE *, int); -extern void putcolor_a (int, int, int); -extern void spindac(int, int); -extern void buzzer (int); -extern int thinking(int, char far *); -extern void CalibrateDelay(void); -extern void start_wait(void); -extern void end_wait(void); - -extern int get_video_mode(struct fractal_info *,struct ext_blk_3 *); -extern int check_vidmode_keyname(char *); -extern void vidmode_keyname(int, char *); -extern int check_vidmode_key(int, int); -extern void put_line(int, int, int, BYTE *); -extern void get_line(int, int, int, BYTE *); -extern void restoredac(void); -extern void reset_zoom_corners(void); -extern void flush_screen(void); - -extern int win_load(void); -extern void win_save(void); -extern void win_cycle(void); - -extern void winfract_help(void); - -/* windos2 -- C file prototypes */ - -extern void movecursor(int, int); -extern void setattr(int, int, int, int); -extern int putstringcenter(int, int, int, int, char far *); -extern void putstring(int, int, int, unsigned char far *); -extern int strncasecmp(char far *,char far *,int); -extern int input_field(int, int, char *, int, int, int, int (*)(int) ); -extern void helptitle(void); -extern void stackscreen(void); -extern void unstackscreen(void); -extern void discardscreen(void); -extern void discardgraphics(void); -extern int load_palette(void); -extern void save_palette(void); -extern void fractint_help(void); -extern int getakeynohelp(void); -extern int win_make_batch_file(void); -extern int fractint_getkeypress(int); -extern int savegraphics(void); -extern int restoregraphics(void); - -extern int main_menu(int); - -/* winfract -- C file prototypes */ - -extern void win_set_title_text(void); -extern void win_savedac(void); - -/* winstubs -- C file prototypes */ - -extern void rotate(int); -extern void find_special_colors(void); -extern int showtempmsg(char far *); -extern void cleartempmsg(void); -extern void freetempmsg(void); -extern int FromMemDisk(long, int, void far *); -extern int ToMemDisk(long, int, void far *); -extern int _fastcall common_startdisk(long, long, int); -extern long cdecl normalize(char far *); -extern void drawbox(int); - -extern void farmessage(unsigned char far *); -extern void setvideomode(int, int, int, int); -extern int fromvideotable(void); -extern void home(void); - -extern int intro_overlay(void); -extern int rotate_overlay(void); -extern int printer_overlay(void); -extern int pot_startdisk(void); -//extern void SetTgaColors(void); -extern int startdisk(void); -extern void enddisk(void); -extern int targa_startdisk(FILE *,int); -extern void targa_writedisk(unsigned int,unsigned int,BYTE,BYTE,BYTE); -extern void targa_readdisk(unsigned int,unsigned int,BYTE *,BYTE *,BYTE *); -extern int SetColorPaletteName(char *); -extern BYTE far *findfont(int); -extern long cdecl readticker(void); -extern void EndTGA(void); - -extern int key_count(int); - -extern void dispbox(void); -extern void clearbox(void); -extern void _fastcall addbox(struct coords); -extern void _fastcall drawlines(struct coords, struct coords, int, int); -extern int showvidlength(void); - -extern int get_sound_params(void); -extern int soundon(int); -extern void soundoff(void); -extern int initfm(void); -extern void mute(void); - -extern void dvid_status(int, char far *); -extern int tovideotable(void); -extern void TranspPerPixel(void); -extern void stopslideshow(void); -extern void aspectratio_crop(float, float); -extern void setvideotext(void); - -/* added for Win32 port */ -extern void gettruecolor(int, int, int*, int*, int*); -extern void puttruecolor(int, int, int, int, int); -extern void scroll_center(int, int); -extern void scroll_relative(int, int); -extern void scroll_state(int); -extern void setnullvideo(void); -extern void delay(int); -extern void initasmvars(void); -extern void adapter_detect(void); - -#endif diff --git a/fractint/win/DIALOG.C b/fractint/win/DIALOG.C deleted file mode 100644 index 8b59da133..000000000 --- a/fractint/win/DIALOG.C +++ /dev/null @@ -1,2177 +0,0 @@ -/* - - various dialog-box code - -*/ - -#define STRICT - -#include "port.h" -#include "prototyp.h" - -#include -#include -#include -#include - -#include "winfract.h" -#include "dialog.h" -#include "fractype.h" -#include "mathtool.h" -#include "profile.h" - -extern HWND hwnd; /* handle to main window */ -extern char szHelpFileName[]; /* Help file name*/ - -extern BOOL zoomflag; /* TRUE is a zoom-box selected */ - -extern char *win_choices[]; -extern int win_numchoices, win_choicemade; -int CurrentFractal; - -extern HANDLE hDibInfo; /* handle to the Device-independent bitmap */ -extern LPBITMAPINFO pDibInfo; /* pointer to the DIB info */ - -extern int time_to_restart; /* time to restart? */ -extern int time_to_reinit; /* time to reinit? */ -extern int time_to_cycle; /* time to cycle? */ - -extern int xdots, ydots, colors; -extern long maxiter; -extern int ytop, ybottom, xleft, xright; - -int win_temp1, win_temp2, win_temp3, win_temp4; -long win_ltemp2; - - -int numparams,numtrig, numextra; -static char *trg[] = {"First Function","Second Function", - "Third Function","Fourth Function"}; -static int paramt[] = {ID_FRACPARTX1, ID_FRACPARTX2, - ID_FRACPARTX3, ID_FRACPARTX4, - ID_FRACPARTX5, ID_FRACPARTX6 }; -static int paramv[] = {ID_FRACPARAM1, ID_FRACPARAM2, - ID_FRACPARAM3, ID_FRACPARAM4, - ID_FRACPARAM5, ID_FRACPARAM6, }; - -extern int win_release; -extern char win_comment[]; - -extern char DialogTitle[]; -extern unsigned char DefExt[]; -extern unsigned char FullPathName[]; - -double win_oldprompts[20]; - -extern int stopmsg(int, char *); - -/* far strings (near space is precious) */ -char about_msg01[] = "(C) 1990-2006 The Stone Soup Group"; -char about_msg02[] = ""; -char about_msg03[] = ""; -char about_msg04[] = ""; -char about_msg05[] = "Winfract is copyrighted freeware and may not be"; -char about_msg06[] = "distributed for commercial or promotional purposes"; -char about_msg07[] = "without written permission from the Stone Soup Group."; -char about_msg08[] = "Distribution of Winfract by BBS, network, and"; -char about_msg09[] = "software shareware distributors, etc. is encouraged."; -char about_msg10[] = ""; - -BOOL CALLBACK About(hDlg, message, wParam, lParam) -HWND hDlg; -UINT message; -WPARAM wParam; -LPARAM lParam; -{ - -extern char winfract_title_text[]; -char about_msg00[80]; - - switch (message) { - - case WM_INITDIALOG: - sprintf(about_msg00,"Winfract version %d.%02d", - win_release/100, win_release%100); - SetDlgItemText(hDlg, ID_VERSION ,about_msg00); - SetDlgItemText(hDlg, ID_COMMENT ,about_msg01); - SetDlgItemText(hDlg, ID_COMMENT2 ,about_msg02); - SetDlgItemText(hDlg, ID_COMMENT3 ,about_msg03); - SetDlgItemText(hDlg, ID_COMMENT4 ,about_msg04); - SetDlgItemText(hDlg, ID_COMMENT5 ,about_msg05); - SetDlgItemText(hDlg, ID_COMMENT6 ,about_msg06); - SetDlgItemText(hDlg, ID_COMMENT7 ,about_msg07); - SetDlgItemText(hDlg, ID_COMMENT8 ,about_msg08); - SetDlgItemText(hDlg, ID_COMMENT9 ,about_msg09); - SetDlgItemText(hDlg, ID_COMMENT10,about_msg10); - return (TRUE); - - case WM_COMMAND: - if (wParam == IDOK - || wParam == IDCANCEL) { - EndDialog(hDlg, TRUE); - return (TRUE); - } - break; - } - return (FALSE); -} - - -BOOL CALLBACK Status(hDlg, message, wParam, lParam) -HWND hDlg; -UINT message; -WPARAM wParam; -LPARAM lParam; -{ -char tempstring[100]; -char parstr0[100], parstr1[100], parstr2[100], parstr3[100]; - - switch (message) { - - case WM_INITDIALOG: - sprintf(tempstring,"fractal type: "); - if (fractalspecific[fractype].name[0] != '*') - strcat(tempstring, fractalspecific[fractype].name); - else - strcat(tempstring, &fractalspecific[fractype].name[1]); - if (calc_status == 1) - strcat(tempstring," (still being calculated)"); - else if (calc_status == 2) - strcat(tempstring," (interrupted, resumable)"); - else if (calc_status == 3) - strcat(tempstring," (interrupted, not resumable)"); - else - strcat(tempstring," (completed)"); - /* ##### */ - SetDlgItemText(hDlg, IDS_LINE1,tempstring); - if(fractalspecific[fractype].param[0][0] == 0) - tempstring[0] = 0; - else { - _fstrcpy(parstr0,fractalspecific[fractype].param[0]); - sprintf(tempstring,"%-30.30s %14.10f", - parstr0, param[0]); - } - SetDlgItemText(hDlg, IDS_LINE2,tempstring); - if(fractalspecific[fractype].param[1][0] == 0) - tempstring[0] = 0; - else { - _fstrcpy(parstr1,fractalspecific[fractype].param[1]); - sprintf(tempstring,"%-30.30s %14.10f", - parstr1, param[1]); - } - SetDlgItemText(hDlg, IDS_LINE3,tempstring); - if(fractalspecific[fractype].param[2][0] == 0) - tempstring[0] = 0; - else { - _fstrcpy(parstr2,fractalspecific[fractype].param[2]); - sprintf(tempstring,"%-30.30s %14.10f", - parstr2, param[2]); - } - SetDlgItemText(hDlg, IDS_LINE4,tempstring); - if(fractalspecific[fractype].param[3][0] == 0) - tempstring[0] = 0; - else { - _fstrcpy(parstr3,fractalspecific[fractype].param[3]); - sprintf(tempstring,"%-30.30s %14.10f", - parstr3, param[3]); - } - SetDlgItemText(hDlg, IDS_LINE5,tempstring); - sprintf(tempstring,"Xmin: %25.16f", xxmin); - SetDlgItemText(hDlg, IDS_LINE6,tempstring); - sprintf(tempstring,"Xmax: %25.16f", xxmax); - SetDlgItemText(hDlg, IDS_LINE7,tempstring); - sprintf(tempstring,"Ymin: %25.16f", yymin); - SetDlgItemText(hDlg, IDS_LINE8,tempstring); - sprintf(tempstring,"Ymax: %25.16f", yymax); - SetDlgItemText(hDlg, IDS_LINE9,tempstring); - return (TRUE); - - case WM_COMMAND: - if (wParam == IDOK - || wParam == IDCANCEL) { - EndDialog(hDlg, TRUE); - return (TRUE); - } - break; - } - return (FALSE); -} - - -BOOL CALLBACK SelectFractal(hDlg, message, wParam, lParam) -HWND hDlg; -UINT message; -WPARAM wParam; -LPARAM lParam; -{ - - int i; - int index; - - switch (message) { - - case WM_INITDIALOG: - SetDlgItemText(hDlg, ID_LISTTITLE, DialogTitle); - for (i = 0; i < win_numchoices; i++) - SendDlgItemMessage(hDlg, IDM_FRACTAL, LB_ADDSTRING, - 0, (LONG) (LPSTR) win_choices[i]); - SendDlgItemMessage(hDlg, IDM_FRACTAL, LB_SETCURSEL, - win_choicemade, 0L); - return (TRUE); - - case WM_COMMAND: - switch (wParam) { - - case IDOK: -okay: - index = (int)SendDlgItemMessage(hDlg, IDM_FRACTAL, - LB_GETCURSEL, 0, 0L); - if (index == LB_ERR) { - MessageBox(hDlg, "No Choice selected", - "Select From a List", MB_OK | MB_ICONEXCLAMATION); - break; - } - win_choicemade = index; - EndDialog(hDlg, 1); - break; - - case IDCANCEL: - win_choicemade = -1; - EndDialog(hDlg, 0); - break; - - case IDM_FRACTAL: - switch (HIWORD(lParam)) { - case LBN_SELCHANGE: - index = (int)SendDlgItemMessage(hDlg, IDM_FRACTAL, - LB_GETCURSEL, 0, 0L); - if (index == LB_ERR) - break; - break; - - case LBN_DBLCLK: - goto okay; - - } - return (TRUE); - } - - } - return (FALSE); -} - - -BOOL CALLBACK SelectFracParams(hDlg, message, wParam, lParam) -HWND hDlg; -UINT message; -WPARAM wParam; -LPARAM lParam; -{ - - int i, j; - char temp[30]; - int curtype; - static long oldbailout; - - switch (message) { - - case WM_INITDIALOG: - curtype = CurrentFractal; - if (curfractalspecific->name[0] == '*' - && (i = curfractalspecific->tofloat) != NOFRACTAL /* FIXED BUG HERE!! */ - && fractalspecific[i].name[0] != '*') - curtype = i; - curfractalspecific = &fractalspecific[curtype]; - win_temp1 = curtype; - SetDlgItemText(hDlg, ID_FRACNAME, fractalspecific[win_temp1].name); - for (numparams = 0; numparams < 4; numparams++) - if (fractalspecific[win_temp1].param[numparams][0] == 0) - break; - numtrig = (fractalspecific[win_temp1].flags >> 6) & 7; - if (numparams+numtrig > 6) numparams = 6 - numtrig; - for (i = 0; i < 6; i++) { - temp[0] = 0; - if (i < numparams) - sprintf(temp,"%f",param[i]); - SetDlgItemText(hDlg, paramv[i], temp); - SetDlgItemText(hDlg, paramt[i],"(n/a)"); - if (i < numparams) - SetDlgItemText(hDlg, paramt[i], fractalspecific[win_temp1].param[i]); - } - for(i=0; i -1) - for (i = 0; i < 6 - numparams - numtrig; i++) - if (moreparams[extra].param[i][0] != 0) { - numextra++; - sprintf(temp,"%f", - moreparams[extra].paramvalue[i]); - SetDlgItemText(hDlg, paramt[i+numparams+numtrig], - moreparams[extra].param[i]); - SetDlgItemText(hDlg, paramv[i+numparams+numtrig], - temp); - } - } - CheckDlgButton(hDlg, ID_BAILOUTESTMOD+bailoutest,1); - oldbailout = bailout; - sprintf(temp,"%ld",bailout); - SetDlgItemText(hDlg, ID_BAILOUT, temp); - sprintf(temp,"%.12f",xxmin); - SetDlgItemText(hDlg, ID_FRACXMIN, temp); - sprintf(temp,"%.12f",xxmax); - SetDlgItemText(hDlg, ID_FRACXMAX, temp); - sprintf(temp,"%.12f",yymin); - SetDlgItemText(hDlg, ID_FRACYMIN, temp); - sprintf(temp,"%.12f",yymax); - SetDlgItemText(hDlg, ID_FRACYMAX, temp); - return (TRUE); - - case WM_COMMAND: - switch (wParam) { - - case IDOK: - { - for (i = 0; i < numtrig; i++) { - GetDlgItemText(hDlg, paramv[i+numparams], temp, 10); - temp[6] = 0; - for (j = 0; j <= 6; j++) - if(temp[j] == ' ') temp[j] = 0; - strlwr(temp); - for(j=0;j= numtrigfn) { - char oops[80]; - sprintf(oops, "Trig param %d, '%s' is not a valid trig function\n", i+1, temp); - strcat(oops, "Try sin, cos, tan, cotan, sinh, etc."); - stopmsg(0,oops); - break; - } - } - if (i != numtrig) break; - } - for (i = 0; i < numparams; i++) { - GetDlgItemText(hDlg, paramv[i], temp, 20); - param[i] = atof(temp); - } - for (i = 0; i < numtrig; i++) { - GetDlgItemText(hDlg, paramv[i+numparams], temp, 10); - temp[6] = 0; - for (j = 0; j <= 6; j++) - if (temp[j] == 32) temp[j] = 0; - set_trig_array(i, temp); - } - for (i = 0; i < numextra; i++) { - GetDlgItemText(hDlg, paramv[i+numparams+numtrig], temp, 20); - param[i+4] = atof(temp); - } - setbailoutformula(bailoutest); - GetDlgItemText(hDlg, ID_BAILOUT , temp, 11); - bailout = atol(temp); - if (bailout != 0 && (bailout < 1 || bailout > 2100000000L)) - bailout = oldbailout; - GetDlgItemText(hDlg, ID_FRACXMIN , temp, 20); - xxmin = atof(temp); - GetDlgItemText(hDlg, ID_FRACXMAX , temp, 20); - xxmax = atof(temp); - GetDlgItemText(hDlg, ID_FRACYMIN , temp, 20); - yymin = atof(temp); - GetDlgItemText(hDlg, ID_FRACYMAX , temp, 20); - yymax = atof(temp); - invert = 0; - inversion[0] = inversion[1] = inversion[2] = 0; - fractype = CurrentFractal; - EndDialog(hDlg, 1); - break; - - case ID_BAILOUTESTMOD: - case ID_BAILOUTESTREAL: - case ID_BAILOUTESTIMAG: - case ID_BAILOUTESTOR: - case ID_BAILOUTESTAND: - case ID_BAILOUTESTMANH: - case ID_BAILOUTESTMANR: - bailoutest = wParam - ID_BAILOUTESTMOD; - CheckRadioButton(hDlg, ID_BAILOUTESTMOD, ID_BAILOUTESTMANR, wParam); - break; - - case IDCANCEL: - EndDialog(hDlg, 0); - break; - - } - - } - return (FALSE); -} - - -BOOL CALLBACK SelectImage(hDlg, message, wParam, lParam) -HWND hDlg; -UINT message; -WPARAM wParam; -LPARAM lParam; -{ - - int i; - char temp[15]; - - switch (message) { - - case WM_INITDIALOG: - win_temp1 = colors; - if (win_temp1 == 2) - CheckDlgButton(hDlg, ID_ICOLORS1, 1); - else if (win_temp1 == 16) - CheckDlgButton(hDlg, ID_ICOLORS2, 1); - else - CheckDlgButton(hDlg, ID_ICOLORS3, 1); - sprintf(temp,"%d",xdots); - SetDlgItemText(hDlg, ID_ISIZEX, temp); - sprintf(temp,"%d",ydots); - SetDlgItemText(hDlg, ID_ISIZEY, temp); - i = ID_ISIZE7; - if (xdots == 200 && ydots == 150) i = ID_ISIZE1; - if (xdots == 320 && ydots == 200) i = ID_ISIZE2; - if (xdots == 640 && ydots == 350) i = ID_ISIZE3; - if (xdots == 640 && ydots == 480) i = ID_ISIZE4; - if (xdots == 800 && ydots == 600) i = ID_ISIZE5; - if (xdots == 1024 && ydots == 768) i = ID_ISIZE6; - CheckRadioButton(hDlg, ID_ISIZE1, ID_ISIZE7, i); - return (TRUE); - - case WM_COMMAND: - switch (wParam) { - - case IDOK: - /* retrieve and validate the results */ - GetDlgItemText(hDlg, ID_ISIZEX, temp, 10); - xdots = atoi(temp); - if (xdots < 50) xdots = 50; - if (xdots > 2048) xdots = 2048; - GetDlgItemText(hDlg, ID_ISIZEY, temp, 10); - ydots = atoi(temp); - if (ydots < 50) ydots = 50; - if (ydots > 2048) ydots = 2048; - colors = win_temp1; - win_savedac(); - /* allocate and lock a pixel array for the bitmap */ - /* problem, here - can't just RETURN!!! */ - tryagain: - if (!clear_screen(0)) { - MessageBox(hDlg, "Not Enough Memory for that sized Image", - NULL, MB_OK | MB_ICONHAND); - xdots = ydots = 100; - goto tryagain; - }; - ytop = 0; /* reset the zoom-box */ - ybottom = ydots-1; - xleft = 0; - xright = xdots-1; - set_win_offset(); - zoomflag = TRUE; - time_to_restart = 1; - - ProgStr = Winfract; - SaveIntParam(ImageWidthStr, xdots); - SaveIntParam(ImageHeightStr, ydots); - - EndDialog(hDlg, 1); - break; - - case IDCANCEL: - EndDialog(hDlg, 0); - break; - - case ID_ISIZE1: - CheckRadioButton(hDlg, ID_ISIZE1, ID_ISIZE7, ID_ISIZE1); - SetDlgItemInt(hDlg, ID_ISIZEX, 200, TRUE); - SetDlgItemInt(hDlg, ID_ISIZEY, 150, TRUE); - break; - - case ID_ISIZE2: - CheckRadioButton(hDlg, ID_ISIZE1, ID_ISIZE7, ID_ISIZE2); - SetDlgItemInt(hDlg, ID_ISIZEX, 320, TRUE); - SetDlgItemInt(hDlg, ID_ISIZEY, 200, TRUE); - break; - - case ID_ISIZE3: - CheckRadioButton(hDlg, ID_ISIZE1, ID_ISIZE7, ID_ISIZE3); - SetDlgItemInt(hDlg, ID_ISIZEX, 640, TRUE); - SetDlgItemInt(hDlg, ID_ISIZEY, 350, TRUE); - break; - - case ID_ISIZE4: - CheckRadioButton(hDlg, ID_ISIZE1, ID_ISIZE7, ID_ISIZE4); - SetDlgItemInt(hDlg, ID_ISIZEX, 640, TRUE); - SetDlgItemInt(hDlg, ID_ISIZEY, 480, TRUE); - break; - - case ID_ISIZE5: - CheckRadioButton(hDlg, ID_ISIZE1, ID_ISIZE7, ID_ISIZE5); - SetDlgItemInt(hDlg, ID_ISIZEX, 800, TRUE); - SetDlgItemInt(hDlg, ID_ISIZEY, 600, TRUE); - break; - - case ID_ISIZE6: - CheckRadioButton(hDlg, ID_ISIZE1, ID_ISIZE7, ID_ISIZE6); - SetDlgItemInt(hDlg, ID_ISIZEX, 1024, TRUE); - SetDlgItemInt(hDlg, ID_ISIZEY, 768, TRUE); - break; - - case ID_ISIZE7: - CheckRadioButton(hDlg, ID_ISIZE1, ID_ISIZE7, ID_ISIZE7); - break; - - case ID_ICOLORS1: - CheckRadioButton(hDlg, ID_ICOLORS1, ID_ICOLORS3, ID_ICOLORS1); - win_temp1 = 2; - break; - - case ID_ICOLORS2: - CheckRadioButton(hDlg, ID_ICOLORS1, ID_ICOLORS3, ID_ICOLORS2); - win_temp1 = 16; - break; - - case ID_ICOLORS3: - CheckRadioButton(hDlg, ID_ICOLORS1, ID_ICOLORS3, ID_ICOLORS3); - win_temp1 = 256; - break; - - } - - } - return (FALSE); -} - - -BOOL CALLBACK SelectDoodads(hDlg, message, wParam, lParam) -HWND hDlg; -UINT message; -WPARAM wParam; -LPARAM lParam; -{ - - char temp[80]; - long oldmaxiter; - - switch (message) { - - case WM_INITDIALOG: - win_temp1 = usr_floatflag; - win_temp2 = 0; - if (usr_stdcalcmode == '2') win_temp2 = 1; - if (usr_stdcalcmode == 'g') win_temp2 = 2; - if (usr_stdcalcmode == 'b') win_temp2 = 3; - if (usr_stdcalcmode == 't') win_temp2 = 4; - if (usr_stdcalcmode == 'd') win_temp2 = 5; - if (usr_stdcalcmode == 'o') win_temp2 = 6; - win_temp3 = 0; - if (inside == ITER) win_temp3 = 1; - if (inside == ZMAG) win_temp3 = 2; - if (inside == BOF60) win_temp3 = 3; - if (inside == BOF61) win_temp3 = 4; - if (inside == EPSCROSS) win_temp3 = 5; - if (inside == STARTRAIL) win_temp3 = 6; - if (inside == PERIOD) win_temp3 = 7; - if (inside == ATANI) win_temp3 = 8; - if (inside == FMODI) win_temp3 = 9; - win_temp4 = 0; - if (outside < 0 && outside > -9) win_temp4 = 0 - outside; - CheckDlgButton(hDlg, ID_PASS1+win_temp2,1); - CheckDlgButton(hDlg, ID_INSIDEC+win_temp3, 1); - CheckDlgButton(hDlg, ID_OUTSIDEN+win_temp4, 1); - if (win_temp1) - CheckDlgButton(hDlg, ID_MATHF, 1); - else - CheckDlgButton(hDlg, ID_MATHF, 0); - oldmaxiter = maxiter; - sprintf(temp,"%ld",maxiter); - SetDlgItemText(hDlg, ID_MAXIT, temp); - sprintf(temp,"%d",usr_biomorph); - SetDlgItemText(hDlg, ID_BIOMORPH, temp); - sprintf(temp,"%ld",LogFlag); - SetDlgItemText(hDlg, ID_LOGP, temp); - sprintf(temp,"%d",decomp[0]); - SetDlgItemText(hDlg, ID_DECOMP, temp); - sprintf(temp,"%d",fillcolor); - SetDlgItemText(hDlg, ID_FILLC, temp); - sprintf(temp,"%d",max(inside,0)); - SetDlgItemText(hDlg, ID_INSIDE, temp); - sprintf(temp,"%d",max(outside,0)); - SetDlgItemText(hDlg, ID_OUTSIDE, temp); - return (TRUE); - - case WM_COMMAND: - switch (wParam) { - - case IDOK: - /* retrieve and validate the results */ - usr_stdcalcmode = '1'; - if (win_temp2 == 1) usr_stdcalcmode = '2'; - if (win_temp2 == 2) usr_stdcalcmode = 'g'; - if (win_temp2 == 3) usr_stdcalcmode = 'b'; - if (win_temp2 == 4) usr_stdcalcmode = 't'; - if (win_temp2 == 5) usr_stdcalcmode = 'd'; - if (win_temp2 == 6) usr_stdcalcmode = 'o'; - usr_floatflag = win_temp1; - GetDlgItemText(hDlg, ID_MAXIT, temp, 11); - maxiter = atol(temp); - if (maxiter < 0) maxiter = oldmaxiter; - if (maxiter < 2) maxiter = 2; - GetDlgItemText(hDlg, ID_LOGP, temp, 11); - LogFlag = atol(temp); - GetDlgItemText(hDlg, ID_BIOMORPH, temp, 10); - usr_biomorph = atoi(temp); - if (usr_biomorph < 0) usr_biomorph = -1; - if (usr_biomorph >= colors) usr_biomorph = colors-1; - GetDlgItemText(hDlg, ID_DECOMP, temp, 10); - decomp[0] = atoi(temp); - if (decomp[0] < 0) decomp[0] = 0; - if (decomp[0] > 256) decomp[0] = 256; - GetDlgItemText(hDlg, ID_FILLC, temp, 10); - fillcolor = atoi(temp); - GetDlgItemText(hDlg, ID_INSIDE, temp, 10); - inside = atoi(temp); - if (inside < 0) inside = 0; - if (inside >= colors) inside = colors-1; - if (win_temp3 == 1) inside = ITER; - if (win_temp3 == 2) inside = ZMAG; - if (win_temp3 == 3) inside = BOF60; - if (win_temp3 == 4) inside = BOF61; - if (win_temp3 == 5) inside = EPSCROSS; - if (win_temp3 == 6) inside = STARTRAIL; - if (win_temp3 == 7) inside = PERIOD; - if (win_temp3 == 8) inside = ATANI; - if (win_temp3 == 9) inside = FMODI; - GetDlgItemText(hDlg, ID_OUTSIDE, temp, 10); - outside = atoi(temp); - if (outside < 0) outside = -1; - if (outside >= colors) outside = colors-1; - if (win_temp4 > 0) outside = 0 - win_temp4; - time_to_restart = 1; - EndDialog(hDlg, 1); - break; - - case IDCANCEL: - EndDialog(hDlg, 0); - break; - - case ID_PASS1: - case ID_PASS2: - case ID_PASSG: - case ID_PASSB: - case ID_PASST: - case ID_PASSD: - case ID_PASSO: - win_temp2 = wParam - ID_PASS1; - CheckRadioButton(hDlg, ID_PASS1, ID_PASSO, wParam); - break; - - case ID_INSIDEC: - case ID_INSIDEM: - case ID_INSIDEZ: - case ID_INSIDE60: - case ID_INSIDE61: - case ID_INSIDEE: - case ID_INSIDES: - case ID_INSIDEPER: - case ID_INSIDEAT: - case ID_INSIDEFM: - win_temp3 = wParam - ID_INSIDEC; - CheckRadioButton(hDlg, ID_INSIDEC, ID_INSIDEFM, wParam); - break; - - case ID_OUTSIDEN: - case ID_OUTSIDEIT: - case ID_OUTSIDER: - case ID_OUTSIDEIM: - case ID_OUTSIDEM: - case ID_OUTSIDES: - case ID_OUTSIDEAT: - case ID_OUTSIDEFM: - case ID_OUTSIDETD: - win_temp4 = wParam - ID_OUTSIDEN; - CheckRadioButton(hDlg, ID_OUTSIDEN, ID_OUTSIDETD, wParam); - break; - - case ID_MATHF: - if (win_temp1 == 0) - win_temp1 = 1; - else - win_temp1 = 0; - CheckDlgButton(hDlg, ID_MATHF, win_temp1); - break; - - } - - } - return (FALSE); -} - - -BOOL CALLBACK SelectExtended(hDlg, message, wParam, lParam) -HWND hDlg; -UINT message; -WPARAM wParam; -LPARAM lParam; -{ - char temp[80]; - int i; - - switch (message) { - - case WM_INITDIALOG: - sprintf(temp,"%i",finattract); - SetDlgItemText(hDlg, ID_FINITE, temp); - sprintf(temp,"%i",(int)potparam[0]); - SetDlgItemText(hDlg, ID_POTENTMAX, temp); - sprintf(temp,"%.12f",potparam[1]); - SetDlgItemText(hDlg, ID_POTENTSLOPE, temp); - sprintf(temp,"%i",(int)potparam[2]); - SetDlgItemText(hDlg, ID_POTENTBAIL, temp); - if (pot16bit) - win_temp2 = 1; - else - win_temp2 = 0; - CheckDlgButton(hDlg, ID_POTENT16, win_temp2); - sprintf(temp,"%ld",usr_distest); - SetDlgItemText(hDlg, ID_DISTEST, temp); - sprintf(temp,"%i",distestwidth); - SetDlgItemText(hDlg, ID_DISTESTWID, temp); - for (i = 0; i < 3; i++) { - sprintf(temp,"%.12f",inversion[i]); - if (inversion[i] == AUTOINVERT) - SetDlgItemText(hDlg, ID_INVERTRAD+i, "auto"); - else - SetDlgItemText(hDlg, ID_INVERTRAD+i, temp); - } - sprintf(temp,"%i",rotate_lo); - SetDlgItemText(hDlg, ID_COLORMIN, temp); - sprintf(temp,"%i",rotate_hi); - SetDlgItemText(hDlg, ID_COLORMAX, temp); - win_oldprompts[0] = finattract; - win_oldprompts[1] = potparam[0]; - win_oldprompts[2] = potparam[1]; - win_oldprompts[3] = potparam[2]; - win_oldprompts[4] = win_temp2; - win_oldprompts[5] = usr_distest; - win_oldprompts[6] = distestwidth; - win_oldprompts[7] = inversion[0]; - win_oldprompts[8] = inversion[1]; - win_oldprompts[9] = inversion[2]; - return (TRUE); - - case WM_COMMAND: - switch (wParam) { - - case IDOK: - /* retrieve and validate the results */ - GetDlgItemText(hDlg, ID_FINITE, temp, 10); - finattract = atoi(temp); - GetDlgItemText(hDlg, ID_POTENTMAX, temp, 10); - potparam[0] = atof(temp); - GetDlgItemText(hDlg, ID_POTENTSLOPE, temp, 10); - potparam[1] = atof(temp); - GetDlgItemText(hDlg, ID_POTENTBAIL, temp, 10); - potparam[2] = atof(temp); - pot16bit = win_temp2; - GetDlgItemText(hDlg, ID_DISTEST, temp, 11); - usr_distest = atol(temp); - GetDlgItemText(hDlg, ID_DISTESTWID, temp, 10); - distestwidth = atoi(temp); - for (i = 0; i < 3; i++) { - GetDlgItemText(hDlg, ID_INVERTRAD+i, temp, 20); - if (temp[0] == 'a' || temp[0] == 'A') - inversion[i] = AUTOINVERT; - else - inversion[i] = atof(temp); - } - invert = (inversion[0] == 0.0) ? 0 : 3; - GetDlgItemText(hDlg, ID_COLORMIN, temp, 10); - rotate_lo = atoi(temp); - GetDlgItemText(hDlg, ID_COLORMAX, temp, 10); - rotate_hi = atoi(temp); - if (rotate_lo < 0 || rotate_hi > 255 || rotate_lo > rotate_hi) { - rotate_lo = 0; - rotate_hi = 255; - } - time_to_restart = 0; - if ( - win_oldprompts[0] != finattract || - win_oldprompts[1] != potparam[0] || - win_oldprompts[2] != potparam[1] || - win_oldprompts[3] != potparam[2] || - win_oldprompts[4] != win_temp2 || - win_oldprompts[5] != usr_distest || - win_oldprompts[6] != distestwidth || - win_oldprompts[7] != inversion[0] || - win_oldprompts[8] != inversion[1] || - win_oldprompts[9] != inversion[2] - ) time_to_restart = 1; - EndDialog(hDlg, time_to_restart); - break; - - case IDCANCEL: - EndDialog(hDlg, 0); - break; - - case ID_POTENT16: - if (win_temp2 == 0) - win_temp2 = 1; - else - win_temp2 = 0; - CheckDlgButton(hDlg, ID_POTENT16, win_temp2); - break; - - } - - } - return (FALSE); -} - -extern char par_comment[4][MAXCMT]; - -BOOL CALLBACK SelectSavePar(hDlg, message, wParam, lParam) -HWND hDlg; -UINT message; -WPARAM wParam; -LPARAM lParam; -{ - char temp[80]; - int i; - extern int colorstate; /* comments in cmdfiles */ - extern char CommandFile[]; - extern char CommandName[]; - extern char colorfile[]; - extern int colorstate; - extern int potflag; /* continuous potential flag */ - extern double potparam[3]; /* three potential parameters*/ - - switch (message) { - - case WM_INITDIALOG: - win_temp1 = 1; - if (colorstate == 1) - win_temp1 = 1; - if (colorstate == 2) - win_temp1 = 2; - - win_temp2 = colors - 1; -/* if (maxiter < win_temp2) win_temp2 = maxiter; */ - if (inside > 0 && inside > win_temp2) win_temp2 = inside; - if (outside > 0 && outside > win_temp2) win_temp2 = outside; - if (distest < 0 && 0-distest > win_temp2) win_temp2 = (int)(0-distest); - if (decomp[0] > win_temp2) win_temp2 = decomp[0] - 1; - if (potflag && potparam[0] >= win_temp2) win_temp2 = (int)potparam[0]; - if (++win_temp2 > 256) win_temp2 = 256; - - SetDlgItemText(hDlg, ID_PFILE, CommandFile); - SetDlgItemText(hDlg, ID_PENTRY, CommandName); - for(i=0;i<4;i++) - { - expand_comments(CommandComment[i], par_comment[i]); - } - if (CommandName[0] == 0) - SetDlgItemText(hDlg, ID_PENTRY, "test"); - SetDlgItemText(hDlg, ID_PCOM1, CommandComment[0]); - SetDlgItemText(hDlg, ID_PCOM2, CommandComment[1]); - SetDlgItemText(hDlg, ID_PCOM3, CommandComment[2]); - SetDlgItemText(hDlg, ID_PCOM4, CommandComment[3]); - CheckDlgButton(hDlg, ID_PCOL1+win_temp1, 1); - sprintf(temp,"%i",win_temp2); - SetDlgItemText(hDlg, ID_PCNUM, temp); - if (colorstate == 2) - SetDlgItemText(hDlg, ID_PCFILE, colorfile); - return (TRUE); - - case WM_COMMAND: - switch (wParam) { - - case IDOK: - /* retrieve and validate the results */ - GetDlgItemText(hDlg, ID_PFILE, CommandFile, 50); - GetDlgItemText(hDlg, ID_PENTRY, CommandName, 50); - GetDlgItemText(hDlg, ID_PCOM1, CommandComment[0], 57); - GetDlgItemText(hDlg, ID_PCOM2, CommandComment[1], 57); - GetDlgItemText(hDlg, ID_PCOM3, CommandComment[2], 57); - GetDlgItemText(hDlg, ID_PCOM4, CommandComment[3], 57); - GetDlgItemText(hDlg, ID_PCNUM, temp, 10); - win_temp2 = atoi(temp); - GetDlgItemText(hDlg, ID_PCFILE, colorfile, 50); - EndDialog(hDlg, 1); - break; - - case IDCANCEL: - EndDialog(hDlg, 0); - break; - - case ID_PCOL1: - case ID_PCOL2: - case ID_PCOL3: - win_temp1 = wParam - ID_PCOL1; - CheckRadioButton(hDlg, ID_PCOL1, ID_PCOL3, wParam); - } - - } - return (FALSE); -} - - -int win_cycledir = -1, win_cyclerand = 0, win_cyclefreq = 0, win_cycledelay = 0; -int win_tempcycle, win_tempcycledir, win_tempcyclerand, win_tempcyclefreq; - -BOOL CALLBACK SelectCycle(hDlg, message, wParam, lParam) -HWND hDlg; -UINT message; -WPARAM wParam; -LPARAM lParam; -{ - switch (message) { - - case WM_INITDIALOG: - win_tempcycle = time_to_cycle; - win_tempcycledir = win_cycledir; - win_tempcyclerand = win_cyclerand; - win_tempcyclefreq = win_cyclefreq; - if (win_tempcycle == 0) - CheckDlgButton(hDlg, ID_CYCLEOFF, 1); - else - CheckDlgButton(hDlg, ID_CYCLEON, 1); - if (win_tempcycledir == -1) - CheckDlgButton(hDlg, ID_CYCLEOUT, 1); - else - CheckDlgButton(hDlg, ID_CYCLEIN, 1); - if (win_tempcyclerand == 0) - CheckDlgButton(hDlg, ID_CYCLESTAT, 1); - else - CheckDlgButton(hDlg, ID_CYCLECHG, 1); - if (win_tempcyclefreq == 0) - CheckDlgButton(hDlg, ID_CYCLELOW, 1); - else if (win_tempcyclefreq == 1) - CheckDlgButton(hDlg, ID_CYCLEMED, 1); - else - CheckDlgButton(hDlg, ID_CYCLEHIGH, 1); - return (TRUE); - - case WM_COMMAND: - switch (wParam) { - - case IDOK: - /* retrieve and validate the results */ - time_to_cycle = win_tempcycle; - win_cycledir = win_tempcycledir; - win_cyclerand = win_tempcyclerand; - win_cyclefreq = win_tempcyclefreq; - EndDialog(hDlg, 1); - break; - - case IDCANCEL: - EndDialog(hDlg, 0); - break; - - case ID_CYCLEOFF: - win_tempcycle = 0; - CheckRadioButton(hDlg, ID_CYCLEOFF, ID_CYCLEON, ID_CYCLEOFF); - break; - - case ID_CYCLEON: - win_tempcycle = 1; - CheckRadioButton(hDlg, ID_CYCLEOFF, ID_CYCLEON, ID_CYCLEON); - break; - - case ID_CYCLEOUT: - win_tempcycledir = -1; - CheckRadioButton(hDlg, ID_CYCLEOUT, ID_CYCLEIN, ID_CYCLEOUT); - break; - - case ID_CYCLEIN: - win_tempcycledir = 1; - CheckRadioButton(hDlg, ID_CYCLEOUT, ID_CYCLEIN, ID_CYCLEIN); - break; - - case ID_CYCLESTAT: - win_tempcyclerand = 0; - CheckRadioButton(hDlg, ID_CYCLESTAT, ID_CYCLECHG, ID_CYCLESTAT); - break; - - case ID_CYCLECHG: - win_tempcyclerand = 1; - CheckRadioButton(hDlg, ID_CYCLESTAT, ID_CYCLECHG, ID_CYCLECHG); - break; - - case ID_CYCLELOW: - win_tempcyclefreq = 0; - CheckRadioButton(hDlg, ID_CYCLELOW, ID_CYCLEHIGH, ID_CYCLELOW); - break; - - case ID_CYCLEMED: - win_tempcyclefreq = 1; - CheckRadioButton(hDlg, ID_CYCLELOW, ID_CYCLEHIGH, ID_CYCLEMED); - break; - - case ID_CYCLEHIGH: - win_tempcyclefreq = 2; - CheckRadioButton(hDlg, ID_CYCLELOW, ID_CYCLEHIGH, ID_CYCLEHIGH); - break; - - } - - } - return (FALSE); -} - -FARPROC lpSelectFullScreen; - -extern HANDLE hInst; - -int win_fullscreen_count; -char * win_fullscreen_prompts[20]; -char *win_fullscreen_heading; -static struct fullscreenvalues win_fullscreen_values[20]; - -int xxx_fullscreen_prompt( /* full-screen prompting routine */ - char *hdg, /* heading, lines separated by \n */ - int numprompts, /* there are this many prompts (max) */ - char * *prompts, /* array of prompting pointers */ - struct fullscreenvalues values[], /* array of values */ - int options, /* future use bits in case we need them */ - int fkeymask /* bit n on if Fn to cause return */ - ) -{ -int i; -int Return; - -win_fullscreen_count = numprompts; -win_fullscreen_heading = hdg; -win_fullscreen_count = numprompts; -for (i = 0; i < win_fullscreen_count; i++) { - win_fullscreen_prompts[i] = prompts[i]; - win_fullscreen_values[i] = values[i]; - } - -lpSelectFullScreen = MakeProcInstance((FARPROC)SelectFullScreen, hInst); -Return = DialogBox(hInst, "SelectFullScreen", hwnd, (DLGPROC)lpSelectFullScreen); -FreeProcInstance(lpSelectFullScreen); - -if (Return) { - for (i = 0; i < win_fullscreen_count; i++) { - values[i] = win_fullscreen_values[i]; - } - return(0); - } - -return(-1); -} - -BOOL CALLBACK SelectFullScreen(hDlg, message, wParam, lParam) -HWND hDlg; -UINT message; -WPARAM wParam; -LPARAM lParam; -{ - - int i; - char temp[80]; - - switch (message) { - - case WM_INITDIALOG: - SetDlgItemText(hDlg, ID_PROMPT00,win_fullscreen_heading); - for (i = 0; i < win_fullscreen_count; i++) { - SetDlgItemText(hDlg, ID_PROMPT01+i,win_fullscreen_prompts[i]); - if (win_fullscreen_values[i].type == 'd' || - win_fullscreen_values[i].type == 'f') - sprintf(temp,"%10.5f",win_fullscreen_values[i].uval.dval); - else if(win_fullscreen_values[i].type == 'i') - sprintf(temp,"%d",win_fullscreen_values[i].uval.ival); - else if(win_fullscreen_values[i].type == 's') - { - strncpy(temp,win_fullscreen_values[i].uval.sval,16); - temp[15] = 0; - } - else if(win_fullscreen_values[i].type == 'l') - strcpy(temp,win_fullscreen_values[i].uval.ch.list[win_fullscreen_values[i].uval.ch.val]); - else - strcpy(temp,win_fullscreen_values[i].uval.sval); - SetDlgItemText(hDlg, ID_ANSWER01+i,temp); - } - return (TRUE); - - case WM_COMMAND: - switch (wParam) { - - case IDOK: - for (i = 0; i < win_fullscreen_count; i++) { - GetDlgItemText(hDlg, ID_ANSWER01+i , temp, 20); - if (win_fullscreen_values[i].type == 'd' || - win_fullscreen_values[i].type == 'f') - win_fullscreen_values[i].uval.dval = atof(temp); - else if(win_fullscreen_values[i].type == 'i') - win_fullscreen_values[i].uval.ival = atoi(temp); - else if(win_fullscreen_values[i].type == 's') - strncpy(win_fullscreen_values[i].uval.sval,temp,16); - else if(win_fullscreen_values[i].type == 'l') - strcpy(win_fullscreen_values[i].uval.ch.list[win_fullscreen_values[i].uval.ch.val],temp); - else - strcpy(win_fullscreen_values[i].uval.sval,temp); - } - EndDialog(hDlg, 1); - break; - - case IDCANCEL: - EndDialog(hDlg, 0); - break; - - } - - } - return (FALSE); -} - - -extern int init3d[]; -extern int win_3dspherical; -extern char preview, showbox; -extern int previewfactor, glassestype, whichimage; -extern int xtrans, ytrans, transparent[2], RANDOMIZE; -extern int red_crop_left, red_crop_right; -extern int blue_crop_left, blue_crop_right; -extern int red_bright, blue_bright; -extern int RAY; -extern int BRIEF; -extern int Ambient; -extern char ray_name[]; -extern int Targa_Overlay; -extern int Targa_Out; -extern int overlay3d; /* 3D overlay flag: 0 = OFF */ -extern int xadjust; -extern int eyeseparation; - -static int win_answers[20]; - -BOOL CALLBACK Select3D(hDlg, message, wParam, lParam) -HWND hDlg; -UINT message; -WPARAM wParam; -LPARAM lParam; -{ - - int i; - char temp[80]; - - switch (message) { - - case WM_INITDIALOG: - win_answers[0] = preview; - win_answers[1] = showbox; - win_answers[2] = SPHERE; - win_answers[3] = previewfactor; - win_answers[4] = glassestype; - win_answers[5] = FILLTYPE+1; - win_answers[6] = RAY; - win_answers[7] = BRIEF; - win_answers[8] = Targa_Out; - CheckDlgButton(hDlg, ID_PREVIEW, win_answers[0]); - CheckDlgButton(hDlg, ID_SHOWBOX, win_answers[1]); - CheckDlgButton(hDlg, ID_SPHERICAL, win_answers[2]); - CheckDlgButton(hDlg, ID_RAYB, win_answers[7]); -/* - CheckDlgButton(hDlg, ID_TARGA, win_answers[8]); -*/ - sprintf(temp,"%d",win_answers[3]); - SetDlgItemText(hDlg, ID_PREVIEWFACTOR, temp); - CheckRadioButton(hDlg, ID_STEREO1, ID_STEREO4, - ID_STEREO1+win_answers[4]); - CheckRadioButton(hDlg, ID_FILL1, ID_FILL8, - ID_FILL1+win_answers[5]); - CheckRadioButton(hDlg, ID_RAY0, ID_RAY6, - ID_RAY0+win_answers[6]); - check_writefile(ray_name,".ray"); - SetDlgItemText(hDlg, ID_RAYN, ray_name); - return (TRUE); - - case WM_COMMAND: - switch (wParam) { - - case IDOK: - if(win_answers[2] != SPHERE) { - SPHERE = win_answers[2]; - set_3d_defaults(); - } - preview = win_answers[0]; - showbox = win_answers[1]; - SPHERE = win_answers[2]; - RAY = win_answers[6]; - BRIEF = win_answers[7]; - Targa_Out = win_answers[8]; - GetDlgItemText(hDlg, ID_PREVIEWFACTOR, temp, 10); - GetDlgItemText(hDlg, ID_RAYN, temp, 30); - strcpy(ray_name, temp); - previewfactor = atoi(temp); - glassestype = win_answers[4]; - FILLTYPE = win_answers[5]-1; - win_3dspherical = SPHERE; - if(previewfactor < 8) - previewfactor = 8; - if(previewfactor > 128) - previewfactor = 128; - if(glassestype < 0) - glassestype = 0; - if(glassestype > 3) - glassestype = 3; - whichimage = 0; - if(glassestype) - whichimage = 1; - if (Targa_Out && overlay3d) - Targa_Overlay = 1; - EndDialog(hDlg, 1); - break; - - case ID_PREVIEW: - case ID_SHOWBOX: - case ID_SPHERICAL: - i = wParam - ID_PREVIEW; - win_answers[i] = 1 - win_answers[i]; - CheckDlgButton(hDlg, ID_PREVIEW + i, win_answers[i]); - break; - - case ID_FILL1: - case ID_FILL2: - case ID_FILL3: - case ID_FILL4: - case ID_FILL5: - case ID_FILL6: - case ID_FILL7: - case ID_FILL8: - i = wParam - ID_FILL1; - win_answers[5] = i; - CheckRadioButton(hDlg, ID_FILL1, ID_FILL8, - ID_FILL1+win_answers[5]); - break; - - case ID_STEREO1: - case ID_STEREO2: - case ID_STEREO3: - case ID_STEREO4: - i = wParam - ID_STEREO1; - win_answers[4] = i; - CheckRadioButton(hDlg, ID_STEREO1, ID_STEREO4, - ID_STEREO1+win_answers[4]); - break; - - case ID_RAY0: - case ID_RAY1: - case ID_RAY2: - case ID_RAY3: - case ID_RAY4: - case ID_RAY5: - case ID_RAY6: - i = wParam - ID_RAY0; - win_answers[6] = i; - CheckRadioButton(hDlg, ID_RAY0, ID_RAY6, - ID_RAY0+win_answers[6]); - break; - - case ID_RAYB: - win_answers[7] = 1 - win_answers[7]; - CheckDlgButton(hDlg, ID_RAYB, win_answers[7]); - break; - - case ID_TARGA: - win_answers[8] = 1 - win_answers[8]; - CheckDlgButton(hDlg, ID_TARGA, win_answers[8]); - break; - - case IDCANCEL: - EndDialog(hDlg, 0); - break; - - } - - } - return (FALSE); -} - -BOOL CALLBACK Select3DPlanar(hDlg, message, wParam, lParam) -HWND hDlg; -UINT message; -WPARAM wParam; -LPARAM lParam; -{ - - int i; - char temp[80]; - - switch (message) { - - case WM_INITDIALOG: - win_answers[0] = XROT; - win_answers[1] = YROT; - win_answers[2] = ZROT; - win_answers[3] = XSCALE; - win_answers[4] = YSCALE; - win_answers[5] = ROUGH; - win_answers[6] = WATERLINE; - win_answers[7] = ZVIEWER; - win_answers[8] = XSHIFT; - win_answers[9] = YSHIFT; - win_answers[10] = xtrans; - win_answers[11] = ytrans; - win_answers[12] = transparent[0]; - win_answers[13] = transparent[1]; - win_answers[14] = RANDOMIZE; - for (i = 0; i < 15; i++) { - sprintf(temp,"%d", win_answers[i]); - SetDlgItemText(hDlg, ID_ANS1+i,temp); - } - return (TRUE); - - case WM_COMMAND: - switch (wParam) { - - case IDOK: - for (i = 0; i < 15; i++) { - GetDlgItemText(hDlg, ID_ANS1+i, temp, 20); - win_answers[i] = (int)atof(temp); - } - XROT = win_answers[0]; - YROT = win_answers[1]; - ZROT = win_answers[2]; - XSCALE = win_answers[3]; - YSCALE = win_answers[4]; - ROUGH = win_answers[5]; - WATERLINE = win_answers[6]; - ZVIEWER = win_answers[7]; - XSHIFT = win_answers[8]; - YSHIFT = win_answers[9]; - xtrans = win_answers[10]; - ytrans = win_answers[11]; - transparent[0] = win_answers[12]; - transparent[1] = win_answers[13]; - RANDOMIZE = win_answers[14]; - if (RANDOMIZE >= 7) RANDOMIZE = 7; - if (RANDOMIZE <= 0) RANDOMIZE = 0; - EndDialog(hDlg, 1); - break; - - case IDCANCEL: - EndDialog(hDlg, 0); - break; - - } - - } - return (FALSE); -} - - -BOOL CALLBACK SelectIFS3D(hDlg, message, wParam, lParam) -HWND hDlg; -UINT message; -WPARAM wParam; -LPARAM lParam; -{ - - int i, numanswers; - char temp[80]; - - numanswers = 5; - - switch (message) { - - case WM_INITDIALOG: - win_answers[0] = XROT; - win_answers[1] = YROT; - win_answers[2] = ZROT; - win_answers[3] = ZVIEWER; - win_answers[4] = XSHIFT; - win_answers[5] = YSHIFT; - win_answers[6] = glassestype; - for (i = 0; i <= numanswers; i++) { - sprintf(temp,"%d", win_answers[i]); - SetDlgItemText(hDlg, ID_ANS1+i,temp); - } - CheckRadioButton(hDlg, ID_STEREO1, ID_STEREO4, - ID_STEREO1+win_answers[6]); - return (TRUE); - - case WM_COMMAND: - switch (wParam) { - - case ID_STEREO1: - case ID_STEREO2: - case ID_STEREO3: - case ID_STEREO4: - i = wParam - ID_STEREO1; - win_answers[6] = i; - CheckRadioButton(hDlg, ID_STEREO1, ID_STEREO4, - ID_STEREO1+win_answers[6]); - break; - - case IDOK: - for (i = 0; i <= numanswers; i++) { - GetDlgItemText(hDlg, ID_ANS1+i, temp, 20); - win_answers[i] = (int)atof(temp); - } - XROT = win_answers[0]; - YROT = win_answers[1]; - ZROT = win_answers[2]; - ZVIEWER = win_answers[3]; - XSHIFT = win_answers[4]; - YSHIFT = win_answers[5]; - glassestype = win_answers[6]; - EndDialog(hDlg, 1); - break; - - case IDCANCEL: - EndDialog(hDlg, 0); - break; - - } - - } - return (FALSE); -} - -char win_funnyglasses_map_name[41]; - -BOOL CALLBACK SelectFunnyGlasses(hDlg, message, wParam, lParam) -HWND hDlg; -UINT message; -WPARAM wParam; -LPARAM lParam; -{ - - int i, numanswers; - char temp[80]; - - numanswers = 7; - - switch (message) { - - case WM_INITDIALOG: - - /* defaults */ - if(ZVIEWER == 0) - ZVIEWER = 150; - if(eyeseparation == 0) { - if(fractype==IFS3D || fractype==LLORENZ3D || fractype==FPLORENZ3D) { - eyeseparation = 2; - xadjust = -2; - } - else { - eyeseparation = 3; - xadjust = 0; - } - } - - win_funnyglasses_map_name[0] = 0; - if(glassestype == 1) - strcpy(win_funnyglasses_map_name,"glasses1.map"); - else if(glassestype == 2) { - if(FILLTYPE == -1) - strcpy(win_funnyglasses_map_name,"grid.map"); - else - strcpy(win_funnyglasses_map_name,"glasses2.map"); - } - - win_answers[0] = eyeseparation; - win_answers[1] = xadjust; - win_answers[2] = red_crop_left; - win_answers[3] = red_crop_right; - win_answers[4] = blue_crop_left; - win_answers[5] = blue_crop_right; - win_answers[6] = red_bright; - win_answers[7] = blue_bright; - for (i = 0; i < numanswers+1;i++) { - sprintf(temp,"%d", win_answers[i]); - SetDlgItemText(hDlg, ID_ANS1+i,temp); - } - SetDlgItemText(hDlg, ID_ANS9,win_funnyglasses_map_name); - return (TRUE); - - case WM_COMMAND: - switch (wParam) { - - case IDOK: - for (i = 0; i < numanswers+1; i++) { - GetDlgItemText(hDlg, ID_ANS1+i, temp, 20); - win_answers[i] = (int)atof(temp); - } - GetDlgItemText(hDlg, ID_ANS9, temp, 40); - strcpy(win_funnyglasses_map_name, temp); - eyeseparation = win_answers[0]; - xadjust = win_answers[1]; - red_crop_left = win_answers[2]; - red_crop_right = win_answers[3]; - blue_crop_left = win_answers[4]; - blue_crop_right = win_answers[5]; - red_bright = win_answers[6]; - blue_bright = win_answers[7]; - EndDialog(hDlg, 1); - break; - - case IDCANCEL: - EndDialog(hDlg, 0); - break; - - } - - } - return (FALSE); -} - -BOOL CALLBACK SelectLightSource(hDlg, message, wParam, lParam) -HWND hDlg; -UINT message; -WPARAM wParam; -LPARAM lParam; -{ - - int i, numanswers; - char temp[80]; - - numanswers = 5; - - switch (message) { - - case WM_INITDIALOG: - win_answers[0] = XLIGHT; - win_answers[1] = YLIGHT; - win_answers[2] = ZLIGHT; - win_answers[3] = LIGHTAVG; - win_answers[4] = Ambient; - for (i = 0; i < numanswers+1;i++) { - sprintf(temp,"%d", win_answers[i]); - SetDlgItemText(hDlg, ID_ANS1+i,temp); - } - return (TRUE); - - case WM_COMMAND: - switch (wParam) { - - case IDOK: - for (i = 0; i < numanswers+1; i++) { - GetDlgItemText(hDlg, ID_ANS1+i, temp, 20); - win_answers[i] = (int)atof(temp); - } - XLIGHT = win_answers[0]; - YLIGHT = win_answers[1]; - ZLIGHT = win_answers[2]; - LIGHTAVG = win_answers[3]; - Ambient = win_answers[4]; - EndDialog(hDlg, 1); - break; - - case IDCANCEL: - EndDialog(hDlg, 0); - break; - - } - - } - return (FALSE); -} - -BOOL CALLBACK Select3DSpherical(hDlg, message, wParam, lParam) -HWND hDlg; -UINT message; -WPARAM wParam; -LPARAM lParam; -{ - - int i; - char temp[80]; - - switch (message) { - - case WM_INITDIALOG: - win_answers[0] = XROT; - win_answers[1] = YROT; - win_answers[2] = ZROT; - win_answers[3] = XSCALE; - win_answers[4] = YSCALE; - win_answers[5] = ROUGH; - win_answers[6] = WATERLINE; - win_answers[7] = ZVIEWER; - win_answers[8] = XSHIFT; - win_answers[9] = YSHIFT; - win_answers[10] = xtrans; - win_answers[11] = ytrans; - win_answers[12] = transparent[0]; - win_answers[13] = transparent[1]; - win_answers[14] = RANDOMIZE; - for (i = 0; i < 15; i++) { - sprintf(temp,"%d", win_answers[i]); - SetDlgItemText(hDlg, ID_ANS1+i,temp); - } - return (TRUE); - - case WM_COMMAND: - switch (wParam) { - - case IDOK: - for (i = 0; i < 15; i++) { - GetDlgItemText(hDlg, ID_ANS1+i, temp, 10); - win_answers[i] = (int)atof(temp); - } - XROT = win_answers[0]; - YROT = win_answers[1]; - ZROT = win_answers[2]; - XSCALE = win_answers[3]; - YSCALE = win_answers[4]; - ROUGH = win_answers[5]; - WATERLINE = win_answers[6]; - ZVIEWER = win_answers[7]; - XSHIFT = win_answers[8]; - YSHIFT = win_answers[9]; - xtrans = win_answers[10]; - ytrans = win_answers[11]; - transparent[0] = win_answers[12]; - transparent[1] = win_answers[13]; - RANDOMIZE = win_answers[14]; - if (RANDOMIZE >= 7) RANDOMIZE = 7; - if (RANDOMIZE <= 0) RANDOMIZE = 0; - EndDialog(hDlg, 1); - break; - - case IDCANCEL: - EndDialog(hDlg, 0); - break; - - } - - } - return (FALSE); -} - -BOOL CALLBACK SelectStarfield(hDlg, message, wParam, lParam) -HWND hDlg; -UINT message; -WPARAM wParam; -LPARAM lParam; -{ -extern double starfield_values[4]; - - switch (message) { - - case WM_INITDIALOG: - SetDlgItemInt(hDlg, ID_NUMSTARS, (int)starfield_values[0], FALSE); - SetDlgItemInt(hDlg, ID_CLUMPINESS, (int)starfield_values[1], FALSE); - SetDlgItemInt(hDlg, ID_DIMRATIO, (int)starfield_values[2], FALSE); - return (TRUE); - - case WM_COMMAND: - switch (wParam) { - - case IDOK: - starfield_values[0] = GetDlgItemInt(hDlg, ID_NUMSTARS, NULL, FALSE); - starfield_values[1] = GetDlgItemInt(hDlg, ID_CLUMPINESS, NULL, FALSE); - starfield_values[2] = GetDlgItemInt(hDlg, ID_DIMRATIO, NULL, FALSE); - EndDialog(hDlg, 1); - break; - - case IDCANCEL: - EndDialog(hDlg, 0); - break; - - } - - } - return (FALSE); -} - -extern int time_to_save; -extern int gif87a_flag; -int FileFormat = 0; -FARPROC lpStatusBox = NULL; -HWND hStatusBox; -BOOL OperCancelled; -char StatusTitle[80]; - -extern LPBITMAPINFO pDibInfo; -extern char huge *pixels; -extern LPLOGPALETTE pLogPal; - -BOOL CALLBACK StatusBoxProc(HWND hDlg, UINT Msg, WPARAM wParam, - LPARAM lParam) -{ - char PerStr[10]; - RECT Rect, TextRect; - HWND hBar, hCancel; - HDC hBarDC; - unsigned Percent; - - switch(Msg) - { - case WM_INITDIALOG: - SetWindowText(hDlg, StatusTitle); - hCancel = GetDlgItem(hDlg, ID_CANCEL); - SetFocus(hCancel); - return(FALSE); - - case WM_CHAR: - if(wParam == VK_RETURN || wParam == VK_ESCAPE) - OperCancelled = TRUE; - break; - - case WM_COMMAND: - - if(wParam == ID_CANCEL) - OperCancelled = TRUE; - break; - - case WM_USER: - /* Invalidate Bar Window */ - hBar = GetDlgItem(hDlg, ID_PERCENT); - GetClientRect(hBar, &TextRect); - - /* Calculate Percentage */ - hBarDC = GetDC(hBar); - Percent = (unsigned)((lParam * 100) / wParam); - if(Percent <= 100) - { - wsprintf(PerStr, "%d", Percent); - strcat(PerStr, "%"); - - /* Display Bar */ - Rect = TextRect; - Rect.right = (unsigned)((((long)Percent) * Rect.right) / 100); - Rect.top += 2; - Rect.bottom -= 2; - Rectangle(hBarDC, Rect.left, Rect.top, Rect.right, Rect.bottom); - - /* Display Percentage */ - DrawText(hBarDC, PerStr, lstrlen(PerStr), &TextRect, - DT_CENTER | DT_VCENTER | DT_SINGLELINE); - } - - ReleaseDC(hBar, hBarDC); - break; - - case WM_DESTROY: - break; - - default: - return(FALSE); - } - return(TRUE); -} - -void OpenStatusBox(HWND hWnd, HANDLE hInst) -{ - if(lpStatusBox == NULL) - lpStatusBox = MakeProcInstance((FARPROC)StatusBoxProc, hInst); - hStatusBox = CreateDialog(hInst, "StatusBox", hWnd, (DLGPROC)lpStatusBox); -} - -void CloseStatusBox(void) -{ - DestroyWindow(hStatusBox); -} - -void UpdateStatusBox(unsigned long Partial, unsigned long Total) -{ - if(Total > 0xffff) - { - Total >>= 16; - Partial >>= 16; - } - SendMessage(hStatusBox, WM_USER, (unsigned)Total, Partial); -} - -void center_window(HWND hchild, int xadj, int yadj) -{ - RECT crect,prect; - int i,cwidth,cheight; - POINT center; - GetWindowRect(hchild, &crect); - GetClientRect(hwnd, &prect); /* main Fractint window */ - cwidth = crect.right - crect.left; - cheight = crect.bottom - crect.top; - center.x = (prect.right + prect.left) / 2; - center.y = (prect.bottom + prect.top) / 2; - ClientToScreen(hwnd, ¢er); - if ((center.x += xadj - (cwidth / 2)) < 0) center.x = 0; - if ((center.y += yadj - (cheight / 2)) < 0) center.y = 0; - if ((i = GetSystemMetrics(SM_CXSCREEN) - cwidth ) < center.x) center.x = i; - if ((i = GetSystemMetrics(SM_CYSCREEN) - cheight) < center.y) center.y = i; - MoveWindow(hchild, center.x, center.y, cwidth, cheight, FALSE); -} - -void SaveBitmapFile(HWND hWnd, char *FullPathName) -{ - long TotalSize, Saved = 0, ImageSize, n; - BITMAPFILEHEADER FileHeader; - unsigned PalSize, BitCount; - unsigned BlockSize = 10240; - int hFile; - char Temp[FILE_MAX_DIR]; - OFSTRUCT OfStruct; - HANDLE hPal; - RGBQUAD FAR *Pal; - - hFile = OpenFile(FullPathName, &OfStruct, OF_CREATE); - if(hFile == 0) - { -FileError: - wsprintf(Temp, "File I/O error while saving %s.", (LPSTR)FullPathName); - MessageBox(hWnd, Temp, "File Error . . .", MB_OK | MB_ICONEXCLAMATION); - -GeneralError: - _lclose(hFile); - OpenFile(FullPathName, &OfStruct, OF_DELETE); - CloseStatusBox(); - return; - } - - BitCount = pDibInfo->bmiHeader.biBitCount; - if(BitCount != 24) - PalSize = (1 << BitCount) * sizeof(RGBQUAD); - else - PalSize = 0; - - ImageSize = pDibInfo->bmiHeader.biSizeImage; - FileHeader.bfType = 0x4d42; /* 'BM'; */ - FileHeader.bfSize = sizeof(FileHeader) + - pDibInfo->bmiHeader.biSize + - PalSize + ImageSize; - TotalSize = FileHeader.bfSize; - FileHeader.bfReserved1 = FileHeader.bfReserved2 = 0; - FileHeader.bfOffBits = FileHeader.bfSize - ImageSize; - Saved += _lwrite(hFile, (LPSTR)&FileHeader, sizeof(FileHeader)); - Saved += _lwrite(hFile, (LPSTR)pDibInfo, (int)pDibInfo->bmiHeader.biSize); - if(PalSize) - { - hPal = GlobalAlloc(GMEM_FIXED, PalSize); - Pal = (RGBQUAD FAR *)GlobalLock(hPal); - if(Pal == NULL) - { - MessageBox(hWnd, "Insufficient Memory", "Memory Error . . .", - MB_ICONEXCLAMATION | MB_OK); - goto GeneralError; - } - for(n = 0; n < (1 << BitCount); n++) - { - Pal[n].rgbRed = pLogPal->palPalEntry[n].peRed; - Pal[n].rgbGreen = pLogPal->palPalEntry[n].peGreen; - Pal[n].rgbBlue = pLogPal->palPalEntry[n].peBlue; - Pal[n].rgbReserved = 0; - } - Saved += _lwrite(hFile, (LPSTR)Pal, PalSize); - GlobalUnlock(hPal); - GlobalFree(hPal); - } - UpdateStatusBox(Saved, TotalSize); - keypressed(); - - /* We should have saved enough bytes to reach the image offset. If not, - then there was an error. */ - if(Saved != (long)FileHeader.bfOffBits) - goto FileError; - - for(n = 0; n < (ImageSize - BlockSize); n += BlockSize) - { - if(_lwrite(hFile, (LPSTR)&pixels[n], BlockSize) != BlockSize) - goto FileError; - Saved += BlockSize; - UpdateStatusBox(Saved, TotalSize); - keypressed(); - if(OperCancelled) - { - MessageBox(hWnd, "File save cancelled.", "Save Cancelled", MB_OK); - goto GeneralError; - } - } - Saved += _lwrite(hFile, (LPSTR)&pixels[n], (int)(ImageSize - n)); - if(Saved != TotalSize) - goto FileError; - - UpdateStatusBox(Saved, TotalSize); - _lclose(hFile); - CloseStatusBox(); -} - -/* common dialog boxes */ - -static char *win_common_type[] = { - "BMP Files (*.BMP)|*.bmp|", - "GIF Files (*.GIF)|*.gif|", - "Palette Files (*.MAP)|*.map|", - "Parameter Files (*.PAR)|*.par|", - "IFS Files (*.IFS)|*.ifs|", - "Formula Files (*.FRM)|*.frm|", - "L-system Files (*.L)|*.l|", - "Any File (*.*)|*.*|", - }; - -static char *win_common_type2[] = { - ".bmp", - ".gif", - ".map", - ".par", - ".ifs", - ".frm", - ".l", - "" - }; - -int Win_OpenFile(unsigned char FileName[]) -{ -OPENFILENAME ofn; -char szFilter[FILE_MAX_DIR], szDirName[FILE_MAX_DIR], szFile[FILE_MAX_DIR]; -char szFileTitle[FILE_MAX_DIR]; -char chReplace; -int i; -char currdir[FILE_MAX_DIR], tempdir[FILE_MAX_DIR], tempext[FILE_MAX_DIR]; - -szFilter[0] = '\0'; -szDirName[0] = '\0'; -szFile[0] = '\0'; -szFileTitle[0] = '\0'; - - _getcwd(currdir, FILE_MAX_DIR); /* save current working directory so we */ - lstrcpy(szDirName,currdir); /* can restore it when we're done here */ - if (FileName[0] != 0) { - lstrcpy(szFile,FileName); - splitpath(FileName,"",tempdir,szFile,tempext); - if (tempext[0] != 0) - lstrcat(szFile,tempext); - else - lstrcat(szFile,DefExt); - } - if (tempdir[0] != 0) { - lstrcat(szDirName,SLASH); - lstrcat(szDirName,tempdir); - } -/* GetSystemDirectory(szDirName, sizeof(szDirName)); */ - -for (i = 0; i < 7; i++) - if (strcmp(DefExt,win_common_type2[i]) == 0) - break; -lstrcpy(szFilter, win_common_type[i]); -lstrcat(szFilter, win_common_type[7]); -chReplace = szFilter[strlen(szFilter) - 1]; -for (i = 0; szFilter[i] != '\0'; i++) { - if (szFilter[i] == chReplace) - szFilter[i] = '\0'; - } - -memset(&ofn, 0, sizeof(OPENFILENAME)); -ofn.lStructSize = sizeof(OPENFILENAME); -ofn.hwndOwner = hwnd; -ofn.lpstrFilter = szFilter; -ofn.nFilterIndex = 1; -ofn.lpstrFile = szFile; -ofn.nMaxFile = sizeof(szFile); -ofn.lpstrFileTitle = szFileTitle; -ofn.nMaxFileTitle = sizeof(szFileTitle); -ofn.lpstrInitialDir = szDirName; -ofn.lpstrTitle = DialogTitle; -ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST | OFN_HIDEREADONLY; - -i = GetOpenFileName(&ofn); -lstrcpy(FileName,szFile); -_chdir(currdir); - -return i; - -} - -Win_SaveFile(unsigned char FileName[]) -{ -OPENFILENAME ofn; -char szFilter[FILE_MAX_DIR], szDirName[FILE_MAX_DIR], szFile[FILE_MAX_DIR]; -char szFileTitle[FILE_MAX_DIR]; -char chReplace; -int i; -char currdir[FILE_MAX_DIR], tempdir[FILE_MAX_DIR], tempext[FILE_MAX_DIR]; - -szFilter[0] = '\0'; -szDirName[0] = '\0'; -szFile[0] = '\0'; -szFileTitle[0] = '\0'; - - _getcwd(currdir, FILE_MAX_DIR); /* save current working directory so we */ - lstrcpy(szDirName,currdir); /* can restore it when we're done here */ - if (FileName[0] != 0) { - lstrcpy(szFile,FileName); - splitpath(FileName,"",tempdir,szFile,tempext); - if (tempext[0] != 0) - lstrcat(szFile,tempext); - else - lstrcat(szFile,DefExt); - } - if (tempdir[0] != 0) { - lstrcat(szDirName,SLASH); - lstrcat(szDirName,tempdir); - } - -/* lstrcpy(szFile,FileName); */ -/* GetSystemDirectory(szDirName, sizeof(szDirName)); */ - -for (i = 0; i < 7; i++) - if (strcmp(DefExt,win_common_type2[i]) == 0) - break; -lstrcpy(szFilter, win_common_type[i]); -if (i == 1) - lstrcat(szFilter,win_common_type[0]); -lstrcat(szFilter,win_common_type[7]); - -chReplace = szFilter[strlen(szFilter) - 1]; -for (i = 0; szFilter[i] != '\0'; i++) { - if (szFilter[i] == chReplace) - szFilter[i] = '\0'; - } - -memset(&ofn, 0, sizeof(OPENFILENAME)); -ofn.lStructSize = sizeof(OPENFILENAME); -ofn.hwndOwner = hwnd; -ofn.lpstrFilter = szFilter; -ofn.nFilterIndex = 1; -ofn.lpstrFile = szFile; -ofn.nMaxFile = sizeof(szFile); -ofn.lpstrFileTitle = szFileTitle; -ofn.nMaxFileTitle = sizeof(szFileTitle); -ofn.lpstrInitialDir = szDirName; -ofn.lpstrTitle = DialogTitle; -ofn.Flags = OFN_PATHMUSTEXIST | OFN_OVERWRITEPROMPT | OFN_HIDEREADONLY; - -i = GetSaveFileName(&ofn); -lstrcpy(FileName,szFile); -lstrcpy(FullPathName,szFile); -lstrcpy(readname,szFile); - -FileFormat = ID_GIF89A; -if (strlen(FileName) > 4) - if (stricmp(&FileName[strlen(FileName)-4],".BMP") == 0) - FileFormat = ID_BMP; - -_chdir(currdir); - -return i; - -} - -static PRINTDLG pd; -static BOOL print_abort_flag; -static HWND print_abort_dialog; - -int CALLBACK PrintAbortDlg(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) -{ - if (msg == WM_COMMAND) { /* Cancel button (Enter, Esc, Return, Space) */ - print_abort_flag = TRUE; - DestroyWindow(hWnd); - return (TRUE); - } - if (msg == WM_INITDIALOG) { - center_window(hWnd,0,0); - SetFocus(hWnd); - return (TRUE); - } - return (FALSE); -} - -int CALLBACK PrintAbort(HDC hPr, int Code) -{ - MSG msg; - while (PeekMessage(&msg, 0, 0, 0, PM_REMOVE)) - if (!IsDialogMessage(print_abort_dialog, &msg)) { - TranslateMessage(&msg); - DispatchMessage(&msg); - } - return (! print_abort_flag); /* return FALSE iff aborted */ -} - -void PrintFile(void) -{ -int printer_xdots, printer_ydots; -float aspect; -extern int win_xdots, win_ydots; -extern int pixelshift_per_byte; -extern int bytes_per_pixelline; - - /* initialize the structure */ - memset(&pd, 0, sizeof(pd)); - pd.lStructSize = sizeof(pd); - pd.hwndOwner = (HWND)NULL; - pd.Flags = PD_RETURNDC | PD_NOPAGENUMS | PD_NOSELECTION | PD_PRINTSETUP; - - if (PrintDlg(&pd) == TRUE) { - int printer_bandable; - long firstpixel; - RECT printerRect; - FARPROC p_print_abort; - FARPROC p_pabort_dialog; - int more; - - print_abort_flag = FALSE; - - printer_bandable = GetDeviceCaps(pd.hDC,RASTERCAPS) & RC_BANDING; - - if (GetDeviceCaps(pd.hDC,NUMCOLORS) <= 2) - mono_dib_palette(); /* B&W stripes for B&W printers */ - else - rgb_dib_palette(); - - printer_xdots = GetDeviceCaps(pd.hDC,HORZRES); - printer_ydots = GetDeviceCaps(pd.hDC,VERTRES); - aspect = (float)((((1.0 * printer_ydots) / printer_xdots) * xdots) / ydots); - if (aspect > 1.0) printer_ydots = (int)(printer_ydots / aspect); - if (aspect < 1.0) printer_xdots = (int)(printer_xdots / aspect); - - firstpixel = win_ydots - ydots; - firstpixel = firstpixel * bytes_per_pixelline; - - p_print_abort = MakeProcInstance((FARPROC)PrintAbort, hInst); - p_pabort_dialog = MakeProcInstance((FARPROC)PrintAbortDlg, hInst); - print_abort_dialog = CreateDialog(hInst, "Printabort", hwnd, (DLGPROC)p_pabort_dialog); - ShowWindow(print_abort_dialog, SW_NORMAL); - UpdateWindow(print_abort_dialog); - EnableWindow(hwnd, FALSE); - Escape (pd.hDC, SETABORTPROC, 0, (LPSTR)p_print_abort, NULL); - - Escape(pd.hDC, STARTDOC, 17, (LPSTR)"Winfract Printout", NULL); - - if (printer_bandable) - Escape(pd.hDC, NEXTBAND, 0, (LPSTR) NULL, (LPSTR) &printerRect); - - more = 1; - while (more) { - if (printer_bandable) - DPtoLP(pd.hDC, (LPPOINT) &printerRect, 2); - StretchDIBits(pd.hDC, - 0, 0, - printer_xdots, printer_ydots, - 0, 0, - xdots, ydots, - (LPSTR)&pixels[firstpixel], (LPBITMAPINFO)pDibInfo, - DIB_RGB_COLORS, SRCCOPY); - if (printer_bandable) - Escape(pd.hDC, NEXTBAND, 0, (LPSTR) NULL, (LPSTR) &printerRect); - more = ! (IsRectEmpty(&printerRect)); - if (print_abort_flag) more = FALSE; - } - Escape(pd.hDC, NEWFRAME, 0, NULL, NULL); - Escape(pd.hDC, ENDDOC, 0, NULL, NULL ); - - EnableWindow(hwnd, TRUE); - DestroyWindow(print_abort_dialog); - FreeProcInstance(p_print_abort); - FreeProcInstance(p_pabort_dialog); - DeleteDC(pd.hDC); - if (pd.hDevMode) - GlobalFree(pd.hDevMode); - if (pd.hDevNames) - GlobalFree(pd.hDevNames); - } - default_dib_palette(); /* replace the palette */ -} diff --git a/fractint/win/MAINFRAC.C b/fractint/win/MAINFRAC.C deleted file mode 100644 index 8fd38496e..000000000 --- a/fractint/win/MAINFRAC.C +++ /dev/null @@ -1,679 +0,0 @@ -/* - non-windows main driver of Fractint for Windows - -*/ - -void win_cmdfiles(void); - -#include "port.h" -#include "prototyp.h" - -#include -#include -#include -#include -#include -#include -#include - -#include "winfract.h" -#include "fractype.h" - -struct videoinfo videoentry; -int helpmode; - -LPSTR win_lpCmdLine; - -extern int time_to_act; -extern int time_to_restart; -extern int time_to_reinit; -extern int time_to_resume; -extern int time_to_quit; -extern int time_to_load; -extern int time_to_save; -extern int time_to_print; -extern int time_to_cycle; -extern int time_to_starfield; -extern int time_to_orbit; - -extern char FileName[]; - -extern long maxiter; -extern int ytop, ybottom, xleft, xright; - -int fractype; - -double xxmin, xxmax, yymin, yymax; - -long maxit; -int boxcount; -int bitshift; -extern int colorpreloaded; /* comments in cmdfiles */ - -int calc_status; /* -1 no fractal */ - /* 0 parms changed, recalc reqd */ - /* 1 actively calculating */ - /* 2 interrupted, resumable */ - /* 3 interrupted, not resumable */ - /* 4 completed */ - -char usr_stdcalcmode; -long usr_distest; - -long delx, dely, delx2, dely2, delmin; -long xmin, xmax, ymin, ymax, x3rd, y3rd; -double dxsize, dysize; /* xdots-1, ydots-1 */ -LDBL delxx, delyy, delxx2, delyy2; -double ddelmin, xx3rd, yy3rd; -double param[MAXPARAMS]; -int diskvideo, savedac; - -#define MAXLINE 2048 -#define MAXNUMFRACTALS 110 - -long *lx0, *ly0, *lx1, *ly1; -double *dx0, *dy0, *dx1, *dy1; -extern double *temp_array; - -extern unsigned char win_dacbox[256][3]; -BYTE dacbox[256][3]; -int dotmode; -int andcolor, resave_flag; - -/* HISTORY *history = NULL; */ -U16 history = 0; -int maxhistory = 10; - -int extraseg; -extern int initbatch; -extern char readname[]; -int rowcount; -extern int showfile; -extern int initmode; -extern int overlay3d; -extern int display3d; -extern int filetype; -int comparegif = 0; -int diskisactive = 0; -extern int initsavetime; -long saveticks = 0; -long savebase = 0; -double zwidth = 0; -static int call_line3d(BYTE *, int); - -int sxdots,sydots; -int sxoffs=0,syoffs=0; -float finalaspectratio; -extern int filexdots, fileydots, filecolors; -int frommandel; - -int onthelist[MAXNUMFRACTALS]; /* list of available fractal types */ -int CountFractalList; /* how many are on the list? */ -extern int CurrentFractal; /* which one is current? */ - -extern int win_display3d, win_overlay3d; - -int release; -extern int win_release; -extern int save_release; -void (*outln_cleanup)(); -extern int fpu; - -int compare_fractalnames( const void *element1, const void *element2) -{ -int i, j, k; - j = *(int*)element1; - k = *(int*)element2; -for (i = 0; i < MAXNUMFRACTALS; i++) { - if (fractalspecific[j].name[i] < fractalspecific[k].name[i]) - return(-1); - if (fractalspecific[j].name[i] > fractalspecific[k].name[i]) - return(1); - if (fractalspecific[j].name[i] == 0) - return(0); - } -return(0); -} - -int fractint_main(void) -{ -int i, k; -double temp1, temp2; -double dtemp; - -outln_cleanup = NULL; /* outln routine can set this */ - -CountFractalList = 0; -for (k = 0; fractalspecific[k].name != NULL; k++) - if (fractalspecific[k].name[0] != '*' && - (fractalspecific[k].flags & WINFRAC) != 0 && - CountFractalList < MAXNUMFRACTALS) - onthelist[CountFractalList++] = k; -qsort(onthelist,CountFractalList,2,compare_fractalnames); -CurrentFractal = fractype; - -lx0 = (long *)&temp_array[0]; -ly0 = (long *)&lx0[MAXLINE]; -lx1 = (long *)&ly0[MAXLINE]; -ly1 = (long *)&ly0[MAXLINE]; -dx0 = (double *)&temp_array[0]; -dy0 = (double *)&dx0[MAXLINE]; -dx1 = (double *)&dy0[MAXLINE]; -dy1 = (double *)&dy0[MAXLINE]; - -extraseg = FP_SEG(dx0); - -win_cmdfiles(); /* SSTOOLS.INI processing */ - - { - /* wierd logic to initialize the palette */ - int iLoop, jLoop; - if (MAP_name[0] == 0) - strcpy(MAP_name, "defaultw.map"); - if (ValidateLuts(MAP_name) == 0) { - for (iLoop = 0; iLoop < 256; iLoop++) - for (jLoop = 0; jLoop < 3; jLoop++) - win_dacbox[iLoop][jLoop] = dacbox[iLoop][jLoop]; - spindac(0,1); - } - } - -restoredac(); /* ensure that the palette has been initialized */ - -initmode = 1; /* override SSTOOLS.INI */ - -release = win_release; -save_release = win_release; - -dotmode = 1; -diskvideo = 0; -usr_distest = 0; - -max_kbdcount=(cpu==386) ? 80 : 30; /* check the keyboard less often */ - -/* ----- */ - -calc_status = -1; -resave_flag = 1; -strcpy(FileName,"Fract001"); -if (showfile != 0) { - strcpy(readname, FileName); - } -else { - if (strchr(readname,'.') == NULL) - strcat(readname,".gif"); - strcpy(FileName,readname); - time_to_load = 1; - } - -if (debugflag == 17500) { /* force the release number for screen-shots */ - extern int win_release; -/* win_release = 1750; */ - win_set_title_text(); - } - -if (debugflag == 10000) { /* check for free memory */ - char temp[50]; - char *tempptr; - unsigned int i,i2; - - sprintf(temp," %d bytes of free stack space",stackavail()); - stopmsg(0,temp); - - i = 0; - i2 = 0x8000; - while ((i2 >>= 1) != 0) - if ((tempptr = malloc(i+i2)) != NULL) { - free(tempptr); - i += i2; - } - sprintf(temp," %d NEAR bytes free", i); - stopmsg(0,temp); - } - -if (debugflag == 70) fpu = 0; - -init_help(); - -/* ----- */ - -time_to_quit = 0; -if (debugflag == 23232) /* give the Windows stuff control first */ - getakey(); -if (time_to_quit) { - end_help(); - return(0); - } - -reinit: - time_to_reinit = 0; - - savedac = 0; /* don't save the VGA DAC */ - - for (i = 0; i < 4; i++) { - if(param[i] == FLT_MAX) - param[i] = fractalspecific[fractype].paramvalue[i]; -/* - else - fractalspecific[fractype].paramvalue[i] = param[i]; -*/ - } - -/* Not used, MCP 8-6-91 - ccreal = param[0]; ccimag = param[1]; */ /* default C-values */ - frommandel = 0; - - if (xxmin > xxmax) { - dtemp = xxmin; xxmin = xxmax; xxmax = dtemp;} - if (yymin > yymax) { - dtemp = yymin; yymin = yymax; yymax = dtemp;} - - ytop = 0; - ybottom = ydots-1; - xleft = 0; - xright = xdots-1; - filexdots = xdots; - fileydots = ydots; - filecolors = colors; - -restart: - time_to_restart = 0; - time_to_resume = 0; - time_to_orbit = 0; - - win_title_text(1); - - if (calc_status == -99) - calc_status = 2; /* force a recalc */ - else - calc_status = 0; /* force a restart */ - - maxit = maxiter; - - if (colors == 2 && (fractype == PLASMA || usr_stdcalcmode == 'b')) - colors = 16; /* 2-color mode just doesn't work on these */ - - andcolor = colors-1; - - /* compute the (new) screen co-ordinates */ - /* correct a possibly munged-up zoom-box outside the image range */ - if (ytop >= ydots) ytop = ydots-1; - if (ybottom >= ydots) ybottom = ydots-1; - if (xleft >= xdots) xleft = xdots-1; - if (xright >= xdots) xright = xdots-1; - if (xleft == xright || ytop == ybottom) { - } - if (xleft > xright) - { i = xleft; xleft = xright; xright = i;} - if (ytop > ybottom) - { i = ybottom; ybottom = ytop; ytop = i;} - temp1 = xxmin; - temp2 = xxmax - xxmin; - xxmin = temp1 + (temp2 * xleft )/(xdots-1); - xxmax = temp1 + (temp2 * xright)/(xdots-1); - temp1 = yymin; - temp2 = yymax - yymin; - yymin = temp1 + (temp2 * (ydots - 1 - ybottom)/(ydots-1)); - yymax = temp1 + (temp2 * (ydots - 1 - ytop )/(ydots-1)); - xx3rd = xxmin; - yy3rd = yymin; - - if (bf_math) { - int saved=0; - bf_t bftmp1, bftmp2, bftmp; - bf_t bftempxl, bftempxr, bftempyb, bftempyt; - bf_t bfxleft, bfxright, bfdxsize; - bf_t bfybottom, bfytop, bfdysize; - - saved = save_stack(); - bftmp1 = alloc_stack(rbflength+2); - bftmp2 = alloc_stack(rbflength+2); - bftmp = alloc_stack(rbflength+2); - bfxleft = alloc_stack(rbflength+2); - bfxright = alloc_stack(rbflength+2); - bfdxsize = alloc_stack(rbflength+2); - bfybottom = alloc_stack(rbflength+2); - bfytop = alloc_stack(rbflength+2); - bfdysize = alloc_stack(rbflength+2); - bftempxl = alloc_stack(rbflength+2); - bftempxr = alloc_stack(rbflength+2); - bftempyb = alloc_stack(rbflength+2); - bftempyt = alloc_stack(rbflength+2); - - floattobf(bfxleft,xleft); - floattobf(bfxright,xright); - floattobf(bfdxsize,dxsize); - floattobf(bfybottom,ybottom); - floattobf(bfytop,ytop); - floattobf(bfdysize,dysize); - -/* temp1 = xxmin; */ - copy_bf(bftmp1,bfxmin); -/* temp2 = xxmax - xxmin;*/ - sub_bf(bftmp2, bfxmax, bfxmin); -/* xxmin = temp1 + (temp2 * xleft )/(xdots-1); */ - mult_bf(bftmp, bftmp2, bfxleft); - div_bf(bftempxl, bftmp, bfdxsize); - add_bf(bfxmin, bftmp1, bftempxl); -/* xxmax = temp1 + (temp2 * xright)/(xdots-1); */ - mult_bf(bftmp, bftmp2, bfxright); - div_bf(bftempxr, bftmp, bfdxsize); - add_bf(bfxmax, bftmp1, bftempxr); - -/* temp1 = yymin; */ - copy_bf(bftmp1,bfymin); -/* temp2 = yymax - yymin;*/ - sub_bf(bftmp2, bfymax, bfymin); -/* yymin = temp1 + (temp2 * (ydots - 1 - ybottom)/(ydots-1)); */ - sub_bf(bftempyb, bfdysize, bfybottom); - mult_bf(bftmp, bftmp2, bftempyb); - div_bf(bftempyb, bftmp, bfdysize); - add_bf(bfymin, bftmp1, bftempyb); -/* yymax = temp1 + (temp2 * (ydots - 1 - ytop )/(ydots-1)); */ - sub_bf(bftempyt, bfdysize, bfytop); - mult_bf(bftmp, bftmp2, bftempyt); - div_bf(bftempyt, bftmp, bfdysize); - add_bf(bfymax, bftmp1, bftempyt); - - copy_bf(bfx3rd,bfxmin); - copy_bf(bfy3rd,bfymin); - restore_stack(saved); - } - - xleft = 0; - xright = xdots-1; - ytop = 0; - ybottom = ydots-1; - -/* - delxx = (xxmax - xxmin) / (xdots-1); - delyy = (yymax - yymin) / (ydots-1); - delxx2 = delyy2 = 0.0; - ddelmin = fabs(delxx); - if (fabs(delyy) < ddelmin) - ddelmin = fabs(delyy); -*/ - - if (calc_status != 2 && !overlay3d) - if (!clear_screen(1)) { - stopmsg(0,"Can't free and re-allocate the image"); - return(0); - } - - if (savedac || colorpreloaded) { - memcpy(dacbox,olddacbox,256*3); /* restore the DAC */ - spindac(0,1); - colorpreloaded = 0; - } - - dxsize = xdots - 1; dysize = ydots - 1; - sxdots = xdots; sydots = ydots; - finalaspectratio = ((float)ydots)/xdots; - - calcfracinit(); - - bitshiftless1 = bitshift - 1; - - sxmin = xxmin; /* save 3 corners for zoom.c ref points */ - sxmax = xxmax; - sx3rd = xx3rd; - symin = yymin; - symax = yymax; - sy3rd = yy3rd; - - if(bf_math) - { - copy_bf(bfsxmin,bfxmin); - copy_bf(bfsxmax,bfxmax); - copy_bf(bfsymin,bfymin); - copy_bf(bfsymax,bfymax); - copy_bf(bfsx3rd,bfx3rd); - copy_bf(bfsy3rd,bfy3rd); - } - - if (time_to_load) - goto wait_loop; - - if(showfile == 0) { /* loading an image */ - if (display3d) /* set up 3D decoding */ - outln = call_line3d; - else if(filetype >= 1) /* old .tga format input file */ - outln = outlin16; - else if(comparegif) /* debug 50 */ - outln = cmp_line; - else if(pot16bit) { /* .pot format input file */ - pot_startdisk(); - outln = pot_line; - } - else /* regular gif/fra input file */ - outln = out_line; - if(filetype == 0) - i = funny_glasses_call(gifview); - else - i = funny_glasses_call(tgaview); - if(i == 0) - buzzer(0); - else { - calc_status = -1; - } - } - - if(showfile == 0) { /* image has been loaded */ - showfile = 1; - if (initbatch == 1 && calc_status == 2) - initbatch = -1; /* flag to finish calc before save */ - if (calc_status == 2) goto try_to_resume; - } - else { /* draw an image */ - -try_to_resume: - - diskisactive = 1; /* flag for disk-video routines */ - if (initsavetime != 0 /* autosave and resumable? */ - && (fractalspecific[fractype].flags&NORESUME) == 0) { - savebase = readticker(); /* calc's start time */ - saveticks = (long)initsavetime * 1092; /* bios ticks/minute */ - if ((saveticks & 65535) == 0) - ++saveticks; /* make low word nonzero */ - } - kbdcount = 30; /* ensure that we check the keyboard */ - if ((i = calcfract()) == 0) /* draw the fractal using "C" */ - buzzer(0); /* finished!! */ - saveticks = 0; /* turn off autosave timer */ - diskisactive = 0; /* flag for disk-video routines */ - } - - overlay3d = 0; /* turn off overlay3d */ - display3d = 0; /* turn off display3d */ - - zwidth = 0; - - if (!keypressed()) { - flush_screen(); - buzzer(3); - win_title_text(0); - getakey(); - } - -wait_loop: - - win_title_text(0); - -for (;;) { - if (time_to_act) { - /* we bailed out of the main loop to take some secondary action */ - time_to_act = 0; - SecondaryWndProc(); - if (! keypressed()) - time_to_resume = 1; - } - if (time_to_quit) { - end_help(); - return(0); - } - if (time_to_starfield) { - time_to_starfield = 0; - win_title_text(4); - starfield(); - win_title_text(0); - flush_screen(); - } - if (time_to_load) { - strcpy(readname, FileName); - showfile = 1; - time_to_load = 0; - time_to_restart = 0; - overlay3d = win_overlay3d; - display3d = win_display3d; - if (win_load() >= 0) { - showfile = 0; - rowcount = 0; - ytop = 0; /* reset the zoom-box */ - ybottom = ydots-1; - xleft = 0; - xright = xdots-1; - maxiter = maxit; - time_to_load = 0; - time_to_restart = 1; - if (calc_status == 2) { - calc_status = -99; /* special klooge for restart */ - } - } - win_overlay3d = 0; - win_display3d = 0; - } - if (time_to_save) { - strcpy(readname, FileName); - if (readname[0] != 0) - win_save(); - time_to_save = 0; - if (calc_status == 2) { - calc_status = -99; - time_to_restart = 1; - } - } - if (time_to_print) { - PrintFile(); - time_to_print = 0; - } - if (time_to_cycle) { - win_cycle(); - } - if (time_to_reinit == 2) { - win_cmdfiles(); - maxiter = maxit; - } - if (time_to_reinit) - goto reinit; - if(time_to_restart) - goto restart; - if(time_to_resume) - if (calc_status == 2) { - calc_status = -99; - time_to_restart = 1; - goto restart; - } - getakey(); - } - -} - -/* displays differences between current image file and new image */ -/* Bert - suggest add this to video.asm */ -int cmp_line(unsigned char *pixels, int linelen) -{ - static errcount; - static FILE *fp = NULL; - extern int rowcount; - int row,col; - int oldcolor; - char *timestring; - time_t ltime; - if(fp == NULL) - fp = fopen("cmperr",(initbatch)?"a":"w"); - if((row = rowcount++) == 0) - errcount = 0; - if(pot16bit) { /* 16 bit info, ignore odd numbered rows */ - if((row & 1) != 0) return(0); - row >>= 1; - } - for(col=0;col>= 1); - if ((saverowcount & 1) != 0) /* odd line */ - row += ydots; - else /* even line */ - if (dotmode != 11) /* display the line too */ - out_line(pixels,linelen); - for (col = 0; col < xdots; ++col) - writedisk(col+sxoffs,row+syoffs,*(pixels+col)); - rowcount = saverowcount + 1; - return(0); -} -#endif - -static int call_line3d(BYTE *pixels, int linelen) -{ - /* this routine exists because line3d might be in an overlay */ - return(line3d(pixels,linelen)); -} - -void win_cmdfiles(void) /* convert lpCmdLine into argc, argv */ -{ -int i, k; -int argc; -char *argv[10]; -unsigned char arg[501]; /* max 10 args, 450 chars total */ - -arg[0] = 0; -for (i = 0; i < 10; i++) - argv[i] = &arg[0]; -argc = 1; -strcpy(&arg[1],"winfract.exe"); -argv[argc-1] = &arg[1]; - -for (i = 0; i < 460 && win_lpCmdLine[i] != 0; i++) - arg[20+i] = win_lpCmdLine[i]; -arg[20+i] = 0; -arg[21+i] = 0; - -for (k = 20; arg[k] != 0; k++) { - while(arg[k] <= ' ' && arg[k] != 0) k++; - if (arg[k] == 0) break; - if (argc >= 10) break; - argc++; - argv[argc-1] = &arg[k]; - while(arg[k] > ' ')k++; - arg[k] = 0; - } - -cmdfiles(argc,argv); - -} diff --git a/fractint/win/WINDOS.C b/fractint/win/WINDOS.C deleted file mode 100644 index e329b9d44..000000000 --- a/fractint/win/WINDOS.C +++ /dev/null @@ -1,1130 +0,0 @@ -/* - Routines which simulate DOS functions in the existing - Fractint for DOS -*/ - -#define STRICT - -#include "port.h" -#include "prototyp.h" - -#include -#include -#include -#include - -#include "winfract.h" -#include "mathtool.h" - -#ifndef USE_VARARGS -#include -#else -#include -#endif - -#ifndef TIMERINFO - /* define TIMERINFO stuff, if needs be */ -typedef struct tagTIMERINFO { - DWORD dwSize; - DWORD dwmsSinceStart; - DWORD dwmsThisVM; - } TIMERINFO; - -BOOL pascal TimerCount(TIMERINFO FAR *); -#endif - -int stopmsg(int , char *); -int farread(int, VOIDFARPTR, unsigned); -int farwrite(int, VOIDFARPTR, unsigned); - -extern unsigned char FullPathName[]; -extern int FileFormat; - -int save_system; /* tag identifying Fractint for Windows */ -int save_release; /* tag identifying version number */ -extern int win_release; /* tag identifying version number (in WINDOS2.C) */ - -extern BOOL bTrack, bMove; /* TRUE if user is selecting a region */ -extern BOOL zoomflag; /* TRUE is a zoom-box selected */ - -extern HWND hwnd; /* handle to main window */ -extern HANDLE hInst; - -extern HANDLE hAccTable; /* handle to accelerator table */ - -extern char szHelpFileName[]; /* Help file name*/ - -extern long maxiter; -extern int xposition, yposition, win_xoffset, win_yoffset, xpagesize, ypagesize; -extern int win_xdots, win_ydots; - -extern int last_written_y; /* last line written */ -extern int screen_to_be_cleared; /* clear screen flag */ - -extern int time_to_act; /* time to take some action? */ -extern int time_to_restart; /* time to restart? */ -extern int time_to_resume; /* time to resume? */ -extern int time_to_quit; /* time to quit? */ -extern int time_to_reinit; /* time to reinitialize? */ -extern int time_to_load; /* time to load? (DECODE) */ -extern int time_to_save; /* time to save? (ENCODE) */ -extern int time_to_print; /* time to print? (PRINTER) */ -extern int time_to_cycle; /* time to begin color-cycling? */ -extern int time_to_starfield; /* time to make a starfield? */ -extern int time_to_orbit; /* time to activate orbits? */ - -extern BOOL win_systempaletteused; /* flag system palette set */ - -extern unsigned char temp_array[]; /* temporary spot for Encoder rtns */ - -extern HANDLE hpixels; /* handle to the DIB pixels */ -extern unsigned char huge *pixels; /* the device-independent bitmap pixels */ -int pixels_per_byte; /* pixels/byte in the pixmap */ -long pixels_per_bytem1; /* pixels / byte - 1 (for ANDing) */ -int pixelshift_per_byte; /* 0, 1, 2, or 3 */ -int bytes_per_pixelline; /* pixels/line / pixels/byte */ -long win_bitmapsize; /* bitmap size, in bytes */ - -extern int win_overlay3d; -extern int win_display3d; - - -BOOL dont_wait_for_a_key = TRUE; - -#ifdef __BORLANDC__ - -/* Too many functions defaulting to a type 'int' return that should be - a type 'void'. I'll just get rid of the warning message for this file - only. MCP 8-6-91 */ - - #pragma warn -rvl - - int LPTNumber; - int stackavail() { return(10240 + (signed int)_SP); } -#else - int printf(const char *dummy, ...) {return(0);} - int _bios_serialcom(){return(0);} -#endif - - -extern int wintext_textmode, wintext_AltF4hit; - -int getakey(void) -{ -int i; - -if (time_to_orbit) { /* activate orbits? */ - zoomflag = FALSE; - time_to_orbit = 0; - i = 'o'; - return(i); - } - -dont_wait_for_a_key = FALSE; -i = keypressed(); -dont_wait_for_a_key = TRUE; -zoomflag = FALSE; -return(i); - -} - -int keypressed(void) -{ -MSG msg; -int time_to; - -/* is a text-mode screen active? */ -if (wintext_textmode == 2 || wintext_AltF4hit) { - if (dont_wait_for_a_key) - return(fractint_getkeypress(0)); - else - return(fractint_getkeypress(1)); - } - -if (dont_wait_for_a_key) - if (PeekMessage(&msg, 0, 0, 0, PM_NOREMOVE) == 0) { - time_to = time_to_act + time_to_reinit+time_to_restart+time_to_quit+ - time_to_load+time_to_save+time_to_print+time_to_cycle+ - time_to_resume+time_to_starfield; - if (time_to_orbit) { /* activate orbits? */ - time_to = 'o'; - } - /* bail out if nothing is happening */ - return(time_to); - } - -while (GetMessage(&msg, 0, 0, 0)) { - - if (!TranslateAccelerator(hwnd, hAccTable, &msg)) { - TranslateMessage(&msg); - DispatchMessage(&msg); - } - - CheckMathTools(); - if (!bTrack && !bMove) { /* don't do this if mouse-button is down */ - time_to = time_to_act+time_to_reinit+time_to_restart+time_to_quit+ - time_to_load+time_to_save+time_to_print+time_to_cycle+ - time_to_starfield; - if (time_to_orbit) { /* activate orbits? */ - time_to = 'o'; - } - if (dont_wait_for_a_key || time_to) - return(time_to); - } - - } - -if (!dont_wait_for_a_key) - time_to_quit = 1; - - /* bail out if nothing is happening */ - time_to = time_to_act+time_to_reinit+time_to_restart+time_to_quit+ - time_to_load+time_to_save+time_to_print+time_to_cycle; - if (time_to_orbit) { /* activate orbits? */ - time_to = 'o'; - } - return(time_to); - -} - -int farread(int handle, VOIDFARPTR buf, unsigned len) -{ -int i; - - i = _lread(handle, buf, len); - return(i); - -} - -int farwrite(int handle, VOIDFARPTR buf, unsigned len) -{ - - return(_lwrite(handle, buf, len)); - -} - - -extern int win_fastupdate; - -time_t last_time; -time_t update_time; -long minimum_update; -long pixelsout; -int top_changed, bottom_changed; - -/* Made global, MCP 6-16-91 */ -unsigned char win_andmask[8]; -unsigned char win_notmask[8]; -unsigned char win_bitshift[8]; - -void putcolor_a(int x, int y, int color) -{ -RECT tempRect; /* temporary rectangle structure */ -long i; -int temp_top_changed, temp_bottom_changed; -time_t this_time; - -last_written_y = y; -if (y < top_changed) top_changed = y; -if (y > bottom_changed) bottom_changed = y; - -i = win_ydots-1-y; -i = (i * win_xdots) + x; - -if (x >= 0 && x < xdots && y >= 0 && y < ydots) { - if (pixelshift_per_byte == 0) { - pixels[i] = color % colors; - } - else { - unsigned int j; - j = (unsigned int)(i & pixels_per_bytem1); - i = i >> pixelshift_per_byte; - pixels[i] = (pixels[i] & win_notmask[j]) + - (((unsigned char)(color % colors)) << win_bitshift[j]); - } - - /* check the time every nnn pixels */ - if (win_fastupdate || ++pixelsout > 100) { - pixelsout = 0; - this_time = time(NULL); - /* time to update the screen? */ - if (win_fastupdate || (this_time - last_time) > update_time || - ((int)(minimum_update*(this_time-last_time))) > (bottom_changed-top_changed)) { - temp_top_changed = top_changed - win_yoffset; - temp_bottom_changed = bottom_changed - win_yoffset; - if (!(temp_top_changed >= ypagesize || temp_bottom_changed < 0)) { - if (temp_top_changed < 0) temp_top_changed = 0; - if (temp_bottom_changed < 0) temp_bottom_changed = 0; - if (temp_top_changed > ypagesize) temp_top_changed = ypagesize; - if (temp_bottom_changed > ypagesize) temp_bottom_changed = ypagesize; - tempRect.top = temp_top_changed; - tempRect.bottom = temp_bottom_changed+1; - tempRect.left = 0; - tempRect.right = xdots; - if (win_fastupdate == 1) { - tempRect.left = x-win_xoffset; - tempRect.right = x-win_xoffset+1; - } - InvalidateRect(hwnd, &tempRect, FALSE); -/* - EndDeferWindowPos(BeginDeferWindowPos(0)); -*/ - } - if (win_fastupdate) { - extern int kbdcount; - if (kbdcount > 5) - kbdcount = 5; - win_fastupdate = 1; - } - keypressed(); /* force a look-see at the screen */ - last_time = this_time; - top_changed = win_ydots; - bottom_changed = 0; - } - } - } - -} - -int getcolor(int x, int y) -{ -long i; - -i = win_ydots-1-y; -i = (i * win_xdots) + x; - -if (x >= 0 && x < xdots && y >= 0 && y < ydots) { - if (pixelshift_per_byte == 0) { - return(pixels[i]); - } - else { - unsigned int j; - j = (unsigned int)(i & pixels_per_bytem1); - i = i >> pixelshift_per_byte; - return((int)((pixels[i] & win_andmask[j]) >> win_bitshift[j])); - } - } -else - return(0); -} - -int put_line(int rownum, int leftpt, int rightpt, BYTE *localvalues) -{ -int i, len; -long startloc; - -len = rightpt - leftpt; -if (rightpt >= xdots) len = xdots - 1 - leftpt; -startloc = win_ydots-1-rownum; -startloc = (startloc * win_xdots) + leftpt; - -if (rownum < 0 || rownum >= ydots || leftpt < 0) { - return(0); - } - -if (pixelshift_per_byte == 0) { - for (i = 0; i <= len; i++) - pixels[startloc+i] = localvalues[i]; - } -else { - unsigned int j; - long k; - for (i = 0; i <= len; i++) { - k = startloc + i; - j = (unsigned int)(k & pixels_per_bytem1); - k = k >> pixelshift_per_byte; - pixels[k] = (pixels[k] & win_notmask[j]) + - (((unsigned char)(localvalues[i] % colors)) << win_bitshift[j]); - } - } -pixelsout += len; -if (win_fastupdate) - win_fastupdate = 2; /* force 'putcolor()' to update a whole scanline */ -putcolor(leftpt, rownum, localvalues[0]); -} - -int get_line(int rownum, int leftpt, int rightpt, BYTE *localvalues) -{ -int i, len; -long startloc; - -len = rightpt - leftpt; -if (rightpt >= xdots) len = xdots - 1 - leftpt; -startloc = win_ydots-1-rownum; -startloc = (startloc * win_xdots) + leftpt; - -if (rownum < 0 || rownum >= ydots || leftpt < 0 || rightpt >= xdots) { - for (i = 0; i <= len; i++) - localvalues[i] = 0; - return(0); - } - -if (pixelshift_per_byte == 0) { - for (i = 0; i <= len; i++) - localvalues[i] = pixels[startloc+i]; - } -else { - unsigned int j; - long k; - for (i = 0; i <= len; i++) { - k = startloc + i; - j = (unsigned int)(k & pixels_per_bytem1); - k = k >> pixelshift_per_byte; - localvalues[i] = (pixels[k] & win_andmask[j]) >> win_bitshift[j]; - } - } -} - -extern int rowcount; - -int out_line(BYTE *localvalues, int numberofdots) -{ - put_line(rowcount++, 0, numberofdots, localvalues); - return (0); -} - -extern LPBITMAPINFO pDibInfo; /* pointer to the DIB info */ - -int clear_screen(int forceclear) -{ -long numdots; -int i; - -/* set up the videoentry values */ -strcpy(videoentry.name, "Windows Video Image"); -strcpy(videoentry.comment,"Generated using Winfract"); -videoentry.keynum = 40; -videoentry.videomodeax = 3; -videoentry.videomodebx = 0; -videoentry.videomodecx = 0; -videoentry.videomodedx = 0; -videoentry.dotmode = 1; -videoentry.xdots = xdots; -videoentry.ydots = ydots; -videoentry.colors = colors; - -win_xdots = (xdots+3) & 0xfffc; -win_ydots = ydots; -pixelshift_per_byte = 0; -pixels_per_byte = 1; -pixels_per_bytem1 = 0; -if (colors == 16) { - win_xdots = (xdots+7) & 0xfff8; - pixelshift_per_byte = 1; - pixels_per_byte = 2; - pixels_per_bytem1 = 1; - win_andmask[0] = 0xf0; win_notmask[0] = 0x0f; win_bitshift[0] = 4; - win_andmask[1] = 0x0f; win_notmask[1] = 0xf0; win_bitshift[1] = 0; - } -if (colors == 2) { - win_xdots = (xdots+31) & 0xffe0; - pixelshift_per_byte = 3; - pixels_per_byte = 8; - pixels_per_bytem1 = 7; - win_andmask[0] = 0x80; win_notmask[0] = 0x7f; win_bitshift[0] = 7; - for (i = 1; i < 8; i++) { - win_andmask[i] = win_andmask[i-1] >> 1; - win_notmask[i] = (win_notmask[i-1] >> 1) + 0x80; - win_bitshift[i] = win_bitshift[i-1] - 1; - } - } - -numdots = (long)win_xdots * (long) win_ydots; -update_time = 2; -/* disable the long delay logic -if (numdots > 200000L) update_time = 4; -if (numdots > 400000L) update_time = 8; -*/ -last_time = time(NULL) - update_time + 1; -minimum_update = 7500/xdots; /* assume 75,000 dots/sec drawing speed */ - -last_written_y = -1; -pixelsout = 0; -top_changed = win_ydots; -bottom_changed = 0; - -bytes_per_pixelline = win_xdots >> pixelshift_per_byte; - -/* Create the Device-independent Bitmap entries */ -pDibInfo->bmiHeader.biWidth = win_xdots; -pDibInfo->bmiHeader.biHeight = win_ydots; -pDibInfo->bmiHeader.biSizeImage = (DWORD)bytes_per_pixelline * win_ydots; -pDibInfo->bmiHeader.biBitCount = 8 / pixels_per_byte; - -/* hard to believe, but this is the fast way to clear the pixel map */ -if (hpixels) { - GlobalUnlock(hpixels); - GlobalFree(hpixels); - } - -win_bitmapsize = (numdots >> pixelshift_per_byte)+1; - -if (!(hpixels = GlobalAlloc(GMEM_FIXED | GMEM_ZEROINIT, win_bitmapsize))) - return(0); -if (!(pixels = (char huge *)GlobalLock(hpixels))) { - GlobalFree(hpixels); - return(0); - } - -/* adjust the colors for B&W or default */ -if (colors == 2) { - dacbox[0][0] = dacbox[0][1] = dacbox[0][2] = 0; - dacbox[1][0] = dacbox[1][1] = dacbox[1][2] = 63; - spindac(0,1); - } -else - restoredac(); /* color palette */ - -screen_to_be_cleared = 1; -InvalidateRect(hwnd, NULL, TRUE); - -if (forceclear) - keypressed(); /* force a look-see at the screen */ - -return(1); -} - -void flush_screen(void) -{ - -last_written_y = 0; - -InvalidateRect(hwnd, NULL, FALSE); - -} - -void buzzer(int i) -{ - -MessageBeep(0); - -} - - -#define MAXFARMEMALLOCS 50 /* max active farmemallocs */ -int farmemallocinit = 0; /* any memory been allocated yet? */ -HANDLE farmemallochandles[MAXFARMEMALLOCS]; /* handles */ -void *farmemallocpointers[MAXFARMEMALLOCS]; /* pointers */ - -void * cdecl malloc(long bytecount) -{ -int i; -HANDLE temphandle; -void *temppointer; - -if (!farmemallocinit) { /* never been here yet - initialize */ - farmemallocinit = 1; - for (i = 0; i < MAXFARMEMALLOCS; i++) { - farmemallochandles[i] = (HANDLE)0; - farmemallocpointers[i] = NULL; - } - } - -for (i = 0; i < MAXFARMEMALLOCS; i++) /* look for a free handle */ - if (farmemallochandles[i] == (HANDLE)0) break; - -if (i == MAXFARMEMALLOCS) /* uh-oh - no more handles */ - return(NULL); /* can't get far memory this way */ - -if (!(temphandle = GlobalAlloc(GMEM_FIXED | GMEM_ZEROINIT, bytecount))) - return(NULL); /* can't allocate the memory */ - -if ((temppointer = (void *)GlobalLock(temphandle)) == NULL) { - GlobalFree(temphandle); - return(NULL); /* ?? can't lock the memory ?? */ - } - -farmemallochandles[i] = temphandle; -farmemallocpointers[i] = temppointer; -return(temppointer); -} - -void debugmessage(char *msg1, char *msg2) -{ -MessageBox ( - GetFocus(), - msg2, - msg1, - MB_ICONASTERISK | MB_OK); - -} - -void texttempmsg(char *msg1) -{ -MessageBox ( - GetFocus(), - msg1, - "Encoder", - MB_ICONASTERISK | MB_OK); -} - -int stopmsg(int flags, char *msg1) -{ -int result; - -if (! (flags & 4)) MessageBeep(0); - -result = IDOK; - -if (!(flags & 2)) - MessageBox ( - 0, - msg1, - "Fractint for Windows", - MB_TASKMODAL | MB_ICONASTERISK | MB_OK); -else - result = MessageBox ( - 0, - msg1, - "Fractint for Windows", - MB_TASKMODAL | MB_ICONQUESTION | MB_OKCANCEL); - -if (result == 0 || result == IDOK || result == IDYES) - return(0); -else - return(-1); -} - -extern char readname[]; -extern int fileydots, filexdots, filecolors; -extern int iNumColors; /* Number of colors supported by device */ -extern int iRasterCaps; /* Raster capabilities */ - -int win_load(void) -{ -int i; - -time_to_load = 0; - - start_wait(); - if ((i = read_overlay()) >= 0 && (!win_display3d || - xdots < filexdots || ydots < fileydots)) { - if (win_display3d) stopmsg(0, - "3D and Overlay3D file image sizes must be\nat least as large as the display image.\nAltering your display image to match the file."); - xdots = filexdots; - ydots = fileydots; - colors = filecolors; - if (colors > 16) colors = 256; - if (colors > 2 && colors < 16) colors = 16; - if (xdots < 50) xdots = 50; - if (xdots > 2048) xdots = 2048; - if (ydots < 50) ydots = 50; - if (ydots > 2048) ydots = 2048; - set_win_offset(); - clear_screen(0); - } - end_wait(); - return(i); -} - -void win_save(void) -{ - time_to_save = 0; - save_system = 1; - save_release = win_release; - - /* MCP 10-27-91 */ - if(FileFormat != ID_BMP) - savetodisk(readname); - else - SaveBitmapFile(hwnd, FullPathName); - CloseStatusBox(); -} - -/* - Delay code - still not so good for a multi-tasking environment, - but what the hell... -*/ - -DWORD DelayCount; - -DWORD DelayMillisecond(void) -{ - DWORD i; - - i = 0; - while(i != DelayCount) - i++; - return(i); -} - -void delay(DWORD milliseconds) -{ - DWORD n, i, j; - -if (DelayCount == 0) { /* use version 3.1's 1ms timer */ - - TIMERINFO timerinfo; - - timerinfo.dwSize = sizeof(timerinfo); - TimerCount(&timerinfo); - n = timerinfo.dwmsSinceStart; - i = n + milliseconds; - for (;;) { - keypressed(); /* let the other folks in */ - TimerCount(&timerinfo); - j = timerinfo.dwmsSinceStart; - if (j < n || j >= i) - break; - } - - } -else { - for(n = 0; n < milliseconds; n++) - DelayMillisecond(); - } - -} - -void CalibrateDelay(void) -{ - DWORD Now, Time, Delta, TimeAdj; - - /* this logic switches tothe fast timer logic supplied by TimerCount */ - DelayCount = 0; - return; - - DelayCount = 128; - - /* Determine the Windows timer resolution. It's usually 38ms in - version 3.0, but that may change latter. */ - Now = Time = GetCurrentTime(); - while(Time == Now) - Now = GetCurrentTime(); - - /* Logrithmic Adjust */ - Delta = Now - Time; - Time = Now; - while(Time == Now) - { - delay(Delta); - Now = GetCurrentTime(); - if(Time == Now) - { - /* Resynch */ - Time = Now = GetCurrentTime(); - while(Time == Now) - Now = GetCurrentTime(); - Time = Now; - DelayCount <<= 1; - } - } - - /* Linear Adjust */ - Time = Now; - TimeAdj = (DelayCount - (DelayCount >> 1)) >> 1; - DelayCount -= TimeAdj; - while(TimeAdj > 16) - { - delay(Delta); - TimeAdj >>= 1; - if(GetCurrentTime() == Now) - DelayCount += TimeAdj; - else - DelayCount -= TimeAdj; - - /* Resynch */ - Time = Now = GetCurrentTime(); - while(Time == Now) - Now = GetCurrentTime(); - Time = Now; - } -} - -/* - Color-cycling logic - includes variable-delay capabilities -*/ - -extern int win_cycledir, win_cyclerand, win_cyclefreq, win_cycledelay; - -extern HANDLE hPal; /* Palette Handle */ -extern LPLOGPALETTE pLogPal; /* pointer to the application's logical palette */ -extern unsigned char win_dacbox[256][3]; -#define PALETTESIZE 256 /* dull-normal VGA */ - -static int win_fsteps[] = {54, 24, 8}; - -int win_animate_flag = 0; -int win_syscolorindex[21]; -DWORD win_syscolorold[21]; -DWORD win_syscolornew[21]; - -extern int debugflag; - -void win_cycle(void) -{ -int istep, jstep, fstep, step, oldstep, last, next, maxreg; -int incr, fromred, fromblue, fromgreen, tored, toblue, togreen; -HDC hDC; /* handle to device context */ - -fstep = 1; /* randomization frequency */ -oldstep = 1; /* single-step */ -step = 256; /* single-step */ -incr = 999; /* ready to randomize */ -maxreg = 256; /* maximum register to rotate */ -last = maxreg-1; /* last box that was filled */ -next = 1; /* next box to be filled */ -if (win_cycledir < 0) { - last = 1; - next = maxreg; - } - -win_title_text(2); - -srand((unsigned)time(NULL)); /* randomize things */ - -hDC = GetDC(GetFocus()); - -win_animate_flag = 1; -SetPaletteEntries(hPal, 0, pLogPal->palNumEntries, pLogPal->palPalEntry); -SelectPalette (hDC, hPal, 1); - -if ((iNumColors == 16 || debugflag == 1000) && !win_systempaletteused) { - int i; - DWORD white, black; - win_systempaletteused = TRUE; - white = 0xffffff00; - black = 0; - for (i = 0; i <= COLOR_ENDCOLORS; i++) { - win_syscolorindex[i] = i; - win_syscolorold[i] = GetSysColor(i); - win_syscolornew[i] = black; - } - win_syscolornew[COLOR_BTNTEXT] = white; - win_syscolornew[COLOR_CAPTIONTEXT] = white; - win_syscolornew[COLOR_GRAYTEXT] = white; - win_syscolornew[COLOR_HIGHLIGHTTEXT] = white; - win_syscolornew[COLOR_MENUTEXT] = white; - win_syscolornew[COLOR_WINDOWTEXT] = white; - win_syscolornew[COLOR_WINDOWFRAME] = white; - win_syscolornew[COLOR_INACTIVECAPTION] = white; - win_syscolornew[COLOR_INACTIVEBORDER] = white; - SetSysColors(COLOR_ENDCOLORS,(LPINT)win_syscolorindex,(LONG FAR *)win_syscolornew); - SetSystemPaletteUse(hDC,SYSPAL_NOSTATIC); - UnrealizeObject(hPal); - } - -while (time_to_cycle) { - if (win_cyclerand) { - for (istep = 0; istep < step; istep++) { - jstep = next + (istep * win_cycledir); - if (jstep <= 0) jstep += maxreg-1; - if (jstep >= maxreg) jstep -= maxreg-1; - if (++incr > fstep) { /* time to randomize */ - incr = 1; - fstep = ((win_fsteps[win_cyclefreq]* - (rand() >> 8)) >> 6) + 1; - fromred = dacbox[last][0]; - fromgreen = dacbox[last][1]; - fromblue = dacbox[last][2]; - tored = rand() >> 9; - togreen = rand() >> 9; - toblue = rand() >> 9; - } - dacbox[jstep][0] = fromred + (((tored - fromred )*incr)/fstep); - dacbox[jstep][1] = fromgreen + (((togreen - fromgreen)*incr)/fstep); - dacbox[jstep][2] = fromblue + (((toblue - fromblue )*incr)/fstep); - } - } - if (step >= 256) step = oldstep; - - spindac(win_cycledir,step); - delay(win_cycledelay); - AnimatePalette(hPal, 0, pLogPal->palNumEntries, pLogPal->palPalEntry); - RealizePalette(hDC); - keypressed(); - if (win_cyclerand == 2) { - win_cyclerand = 1; - step = 256; - } - } - -win_animate_flag = 0; -ReleaseDC(GetFocus(),hDC); - -win_title_text(0); - -} - -/* cursor routines */ - -extern HANDLE hSaveCursor; /* the original cursor value */ -extern HANDLE hHourGlass; /* the hourglass cursor value */ - -void start_wait(void) -{ - hSaveCursor = (HANDLE)SetClassWord(hwnd, GCW_HCURSOR, (WORD)hHourGlass); -} - -void end_wait(void) -{ - SetClassWord(hwnd, GCW_HCURSOR, (WORD)hSaveCursor); -} - -/* video-mode routines */ - -extern int viewwindow; /* 0 for full screen, 1 for window */ -extern float viewreduction; /* window auto-sizing */ -extern float finalaspectratio; /* for view shape and rotation */ -extern int viewxdots,viewydots; /* explicit view sizing */ -extern int fileydots, filexdots, filecolors; -extern float fileaspectratio; -extern short skipxdots,skipydots; /* for decoder, when reducing image */ - - -int get_video_mode(struct fractal_info *info,struct ext_blk_3 *dummy) -{ - viewwindow = viewxdots = viewydots = 0; - fileaspectratio = (float)(0.75); - skipxdots = skipydots = 0; - return(0); -} - - -void spindac(int direction, int step) -{ -int i, j, k; -int cycle_start, cycle_fin; -extern int rotate_lo,rotate_hi; -char tempdacbox; - -cycle_start = 0; -cycle_fin = 255; -if (time_to_cycle) { - cycle_start = rotate_lo; - cycle_fin = rotate_hi; - } - -for (k = 0; k < step; k++) { - if (direction > 0) { - for (j = 0; j < 3; j++) { - tempdacbox = dacbox[cycle_fin][j]; - for (i = cycle_fin; i > cycle_start; i--) - dacbox[i][j] = dacbox[i-1][j]; - dacbox[cycle_start][j] = tempdacbox; - } - } - if (direction < 0) { - for (j = 0; j < 3; j++) { - tempdacbox = dacbox[cycle_start][j]; - for (i = cycle_start; i < cycle_fin; i++) - dacbox[i][j] = dacbox[i+1][j]; - dacbox[cycle_fin][j] = tempdacbox; - } - } - } - - /* fill in intensities for all palette entry colors */ - for (i = 0; i < 256; i++) { - pLogPal->palPalEntry[i].peRed = ((BYTE)dacbox[i][0]) << 2; - pLogPal->palPalEntry[i].peGreen = ((BYTE)dacbox[i][1]) << 2; - pLogPal->palPalEntry[i].peBlue = ((BYTE)dacbox[i][2]) << 2; - pLogPal->palPalEntry[i].peFlags = PC_RESERVED; - } - - if (!win_animate_flag) { - HDC hDC; - hDC = GetDC(GetFocus()); - SetPaletteEntries(hPal, 0, pLogPal->palNumEntries, pLogPal->palPalEntry); - SelectPalette (hDC, hPal, 1); - RealizePalette(hDC); - ReleaseDC(GetFocus(),hDC); - /* for non-palette-based adapters, redraw the image */ - if (!iRasterCaps) { - InvalidateRect(hwnd, NULL, FALSE); - } - } -} - -void restoredac(void) -{ -int iLoop; -int j; - - /* fill in intensities for all palette entry colors */ - for (iLoop = 0; iLoop < PALETTESIZE; iLoop++) - for (j = 0; j < 3; j++) - dacbox[iLoop][j] = win_dacbox[iLoop][j]; - spindac(0,1); -} - -int win_thinking = 0; - -int thinking(int waiting, char *dummy) -{ -if (waiting && ! win_thinking) { - win_thinking = 1; - start_wait(); - } -if (!waiting) - end_wait(); -return(keypressed()); -} - -extern HWND wintext_hWndCopy; /* a Global copy of hWnd */ - -/* Call for help caused by pressing F1 inside the "fractint-style" - prompting routines */ -void winfract_help(void) -{ - WinHelp(wintext_hWndCopy,szHelpFileName,FIHELP_INDEX,0L); -} - -/* -; *************** Far string/memory functions ********* -*/ - -long timer_start,timer_interval; /* timer(...) start & total */ -extern int timerflag; -extern int show_orbit; -extern int dotmode; /* video access method */ -extern long maxit; /* try this many iterations */ - -int check_key() -{ - int key; - if((key = keypressed()) != 0) { - if(key != 'o' && key != 'O') { - return(-1); - } - getakey(); - if (dotmode != 11) - show_orbit = 1 - show_orbit; - } - return(0); -} - -/* timer function: - timer(0,(*fractal)()) fractal engine - timer(1,NULL,int width) decoder - timer(2) encoder - */ -#ifndef USE_VARARGS -int timer(int timertype,int(*subrtn)(),...) -#else -int timer(va_alist) -va_dcl -#endif -{ - va_list arg_marker; /* variable arg list */ - char *timestring; - time_t ltime; - FILE *fp; - int out; - int i; - int do_bench; - -#ifndef USE_VARARGS - va_start(arg_marker,subrtn); -#else - int timertype; - int (*subrtn)(); - va_start(arg_marker); - timertype = va_arg(arg_marker, int); - subrtn = ( int (*)()) va_arg(arg_marker, int *); -#endif - - do_bench = timerflag; /* record time? */ - if (timertype == 2) /* encoder, record time only if debug=200 */ - do_bench = (debugflag == 200); - if(do_bench) - fp=fopen("bench","a"); - timer_start = clock_ticks(); - switch(timertype) { - case 0: - out = (*subrtn)(); - break; - case 1: - i = va_arg(arg_marker,int); - out = decoder(i); /* not indirect, safer with overlays */ - break; - case 2: - out = encoder(); /* not indirect, safer with overlays */ - break; - } - /* next assumes CLK_TCK is 10^n, n>=2 */ - timer_interval = (clock_ticks() - timer_start) / (CLK_TCK/100); - - if(do_bench) { - time(<ime); - timestring = ctime(<ime); - timestring[24] = 0; /*clobber newline in time string */ - switch(timertype) { - case 1: - fprintf(fp,"decode "); - break; - case 2: - fprintf(fp,"encode "); - break; - } - fprintf(fp,"%s type=%s resolution = %dx%d maxiter=%d", - timestring, - curfractalspecific->name, - xdots, - ydots, - maxit); - fprintf(fp," time= %ld.%02ld secs\n",timer_interval/100,timer_interval%100); - if(fp != NULL) - fclose(fp); - } - return(out); -} - -/* dummy out the environment entries, as we never use them */ -#ifndef QUICKC -int _setenvp(void){return(0);} -#endif - -extern double zwidth; - -void clear_zoombox(void) -{ - zwidth = 0; - drawbox(0); - reset_zoom_corners(); -} - -extern double xxmin, xxmax, xx3rd, yymin, yymax, yy3rd; -extern double sxmin, sxmax, sx3rd, symin, symax, sy3rd; - -void reset_zoom_corners(void) -{ - xxmin = sxmin; - xxmax = sxmax; - xx3rd = sx3rd; - yymax = symax; - yymin = symin; - yy3rd = sy3rd; - if(bf_math) - { - copy_bf(bfxmin,bfsxmin); - copy_bf(bfxmax,bfsxmax); - copy_bf(bfymin,bfsymin); - copy_bf(bfymax,bfsymax); - copy_bf(bfx3rd,bfsx3rd); - copy_bf(bfy3rd,bfsy3rd); - } -} - -/* fake videotable stuff */ - -struct videoinfo videotable[1]; - -void vidmode_keyname(int num, char *string) -{ - strcpy(string," "); /* fill in a blank videomode name */ -} - -int check_vidmode_keyname(char *dummy) -{ - return(1); /* yeah, sure - that's a good videomode name. */ -} - -int check_vidmode_key(int dummy1, int dummy2) -{ - /* fill in a videomode structure that looks just like the current image */ - videotable[0].xdots = xdots; - videotable[0].ydots = ydots; - return 0; /* yeah, sure - that's a good key. */ -} diff --git a/fractint/win/WINDOS2.C b/fractint/win/WINDOS2.C deleted file mode 100644 index 5ac865881..000000000 --- a/fractint/win/WINDOS2.C +++ /dev/null @@ -1,1479 +0,0 @@ - -/* Windows versions of DOS functions needed by PROMPTS.C */ - -#define STRICT - -#include "port.h" -#include "prototyp.h" - -#include -#include -#include -#include -#include -#include -#include - -#include "fractype.h" -#include "helpdefs.h" - -/* routines in this module */ -void movecursor(int row, int col); -void setattr(int row, int col, int attr, int count); -int putstringcenter(int row, int col, int width, int attr, char *msg); -void putstring(int row, int col, int attr, unsigned char *buf); -int fullscreen_choice( - int options, char *hdg, char *hdg2, char *instr, int numchoices, - char * *choices, int *attributes, int boxwidth, int boxdepth, - int colwidth, int current, void (*formatitem)(), - char *speedstring, int (*speedprompt)(), int (*checkkey)()); -int strncasecmp(char *s,char *t,int ct); -int input_field(int options, int attr, char *fld, int len, int row, int col, int (*checkkey)(int) ); -int field_prompt(int options, char *hdg, char *instr, char *fld, int len, int (*checkkey)(int) ); -void helptitle(void); -void stackscreen(void); -void unstackscreen(void); -void discardscreen(void); -int load_palette(void); -void save_palette(void); -void fractint_help(void); -void setfortext(void); -void setforgraphics(void); -void setclear(void); - -extern VOIDFARPTR cdecl malloc(long); - -/* faked/unimplemented routines */ - -struct videoinfo *vidtbl; -int vidtbllen = 0; -int badconfig = 0; - -int in_fractint_help = 0; - -int win_release = 2004; -int patchlevel = 4; -char win_comment[] = - {" "}; /* publicly-released version */ -/* {"Test Version - Not for Release"}; /* interim test versions */ -/* {"'Public Beta' Release"}; /* interim test versions */ - -extern int time_to_resume; /* time to resume? */ - -int text_type = 0; -int textrow = 0, textcol = 0; -int textrbase = 0, textcbase = 0; -int lookatmouse; - -/* fullscreen_choice options */ -#define CHOICERETURNKEY 1 -#define CHOICEMENU 2 -#define CHOICEHELP 4 -#define CHOICESCRUNCH 16 -#define CHOICESNOTSORTED 32 - -static char par_comment[4][MAXCMT]; - -char speed_prompt[]="Speed key string"; - -int fullscreen_choice( - int options, /* &2 use menu coloring scheme */ - /* &4 include F1 for help in instructions */ - /* &8 add caller's instr after normal set */ - char *hdg, /* heading info, \n delimited */ - char *hdg2, /* column heading or NULL */ - char *instr, /* instructions, \n delimited, or NULL */ - int numchoices, /* How many choices in list */ - char * *choices, /* array of choice strings */ - int *attributes, /* &3: 0 normal color, 1,3 highlight */ - /* &256 marks a dummy entry */ - int boxwidth, /* box width, 0 for calc (in items) */ - int boxdepth, /* box depth, 0 for calc, 99 for max */ - int colwidth, /* data width of a column, 0 for calc */ - int current, /* start with this item */ - void (*formatitem)(),/* routine to display an item or NULL */ - char *speedstring, /* returned speed key value, or NULL >[30]*/ - int (*speedprompt)(),/* routine to display prompt or NULL */ - int (*checkkey)() /* routine to check keystroke or NULL */ -) - /* return is: n>=0 for choice n selected, - -1 for escape - k for checkkey routine return value k (if not 0 nor -1) - speedstring[0] != 0 on return if string is present - */ -{ -static char choiceinstr1a[]="Use the cursor keys to highlight your selection"; -static char choiceinstr1b[]="Use the cursor keys or type a value to make a selection"; -static char choiceinstr2a[]="Press ENTER for highlighted choice, or ESCAPE to back out"; -static char choiceinstr2b[]="Press ENTER for highlighted choice, ESCAPE to back out, or F1 for help"; -static char choiceinstr2c[]="Press ENTER for highlighted choice, or F1 for help"; - - int titlelines,titlewidth; - int reqdrows; - int topleftrow,topleftcol; - int topleftchoice; - int speedrow; /* speed key prompt */ - int boxitems; /* boxwidth*boxdepth */ - int curkey,increment,rev_increment; - int redisplay; - int i,j,k; - char *charptr; - char buf[81]; - int speed_match = 0; - char curitem[81]; - char *itemptr; - int ret,savelookatmouse; - - savelookatmouse = lookatmouse; - lookatmouse = 0; - ret = -1; - if (speedstring - && (i = strlen(speedstring)) > 0) { /* preset current to passed string */ - current = 0; - while (current < numchoices - && (k = strncasecmp(speedstring,choices[current],i)) > 0) - ++current; - if (k < 0 && current > 0) /* oops - overshot */ - --current; - if (current >= numchoices) /* bumped end of list */ - current = numchoices - 1; - } - - while (1) { - if (current >= numchoices) /* no real choice in the list? */ - goto fs_choice_end; - if ((attributes[current] & 256) == 0) - break; - ++current; /* scan for a real choice */ - } - - titlelines = titlewidth = 0; - if (hdg) { - charptr = hdg; /* count title lines, find widest */ - i = 0; - titlelines = 1; - while (*charptr) { - if (*(charptr++) == '\n') { - ++titlelines; - i = -1; - } - if (++i > titlewidth) - titlewidth = i; - } - } - - if (colwidth == 0) /* find widest column */ - for (i = 0; i < numchoices; ++i) - if ((int)_fstrlen(choices[i]) > colwidth) - colwidth = _fstrlen(choices[i]); - - /* title(1), blank(1), hdg(n), blank(1), body(n), blank(1), instr(?) */ - reqdrows = 3; /* calc rows available */ - if (hdg) - reqdrows += titlelines + 1; - if (instr) { /* count instructions lines */ - charptr = instr; - ++reqdrows; - while (*charptr) - if (*(charptr++) == '\n') - ++reqdrows; - if ((options & 8)) /* show std instr too */ - reqdrows += 2; - } - else - reqdrows += 2; /* standard instructions */ - if (speedstring) ++reqdrows; /* a row for speedkey prompt */ - if (boxdepth > (i = 25 - reqdrows)) /* limit the depth to max */ - boxdepth = i; - if (boxwidth == 0) { /* pick box width and depth */ - if (numchoices <= i - 2) { /* single column is 1st choice if we can */ - boxdepth = numchoices; - boxwidth = 1; - } - else { /* sort-of-wide is 2nd choice */ - boxwidth = 60 / (colwidth + 1); - if (boxwidth == 0 - || (boxdepth = (numchoices+boxwidth-1)/boxwidth) > i - 2) { - boxwidth = 80 / (colwidth + 1); /* last gasp, full width */ - if ((boxdepth = (numchoices+boxwidth-1)/boxwidth) > i) - boxdepth = i; - } - } - } - if ((i = 77 / boxwidth - colwidth) > 3) /* spaces to add @ left each choice */ - i = 3; - j = boxwidth * (colwidth += i) + i; /* overall width of box */ - if (j < titlewidth+2) - j = titlewidth + 2; - if (j > 80) - j = 80; - if (j <= 70 && boxwidth == 2) { /* special case makes menus nicer */ - ++j; - ++colwidth; - } - k = (80 - j) / 2; /* center the box */ - k -= (90 - j) / 20; - topleftcol = k + i; /* column of topleft choice */ - i = (25 - reqdrows - boxdepth) / 2; - i -= i / 4; /* higher is better if lots extra */ - topleftrow = 3 + titlelines + i; /* row of topleft choice */ - - /* now set up the overall display */ - helptitle(); /* clear, display title line */ - setattr(1,0,C_PROMPT_BKGRD,24*80); /* init rest to background */ - for (i = topleftrow-1-titlelines; i < topleftrow+boxdepth+1; ++i) - setattr(i,k,C_PROMPT_LO,j); /* draw empty box */ - if (hdg) { - textcbase = (80 - titlewidth) / 2; /* set left margin for putstring */ - textcbase -= (90 - titlewidth) / 20; /* put heading into box */ - putstring(topleftrow-titlelines-1,0,C_PROMPT_HI,hdg); - textcbase = 0; - } - if (hdg2) /* display 2nd heading */ - putstring(topleftrow-1,topleftcol,C_PROMPT_MED,hdg2); - i = topleftrow + boxdepth + 1; - if (instr == NULL || (options & 8)) { /* display default instructions */ - if (i < 20) ++i; - if (speedstring) { - speedrow = i; - *speedstring = 0; - if (++i < 22) ++i; - } - putstringcenter(i++,0,80,C_PROMPT_BKGRD, - (speedstring) ? choiceinstr1b : choiceinstr1a); - putstringcenter(i++,0,80,C_PROMPT_BKGRD, - (options&CHOICEMENU) ? choiceinstr2c - : ((options&CHOICEHELP) ? choiceinstr2b : choiceinstr2a)); - } - if (instr) { /* display caller's instructions */ - charptr = instr; - j = -1; - while ((buf[++j] = *(charptr++))) - if (buf[j] == '\n') { - buf[j] = 0; - putstringcenter(i++,0,80,C_PROMPT_BKGRD,buf); - j = -1; - } - putstringcenter(i,0,80,C_PROMPT_BKGRD,buf); - } - - boxitems = boxwidth * boxdepth; - topleftchoice = 0; /* pick topleft for init display */ - while (current - topleftchoice >= boxitems - || (current - topleftchoice > boxitems/2 - && topleftchoice + boxitems < numchoices)) - topleftchoice += boxwidth; - redisplay = 1; - - while (1) { /* main loop */ - - if (redisplay) { /* display the current choices */ - if ((options & CHOICEMENU) == 0) { - memset(buf,' ',80); - buf[boxwidth*colwidth] = 0; - for (i = (hdg2) ? 0 : -1; i <= boxdepth; ++i) /* blank the box */ - putstring(topleftrow+i,topleftcol,C_PROMPT_LO,buf); - } - for (i = 0; i+topleftchoice < numchoices && i < boxitems; ++i) { - /* display the choices */ - if ((k = attributes[j = i+topleftchoice] & 3) == 1) - k = C_PROMPT_LO; - else if (k == 3) - k = C_PROMPT_HI; - else - k = C_PROMPT_MED; - if (formatitem) - (*formatitem)(j,charptr=buf); - else - charptr = choices[j]; - putstring(topleftrow+i/boxwidth,topleftcol+(i%boxwidth)*colwidth, - k,charptr); - } - /*** - ... format differs for summary/detail, whups, force box width to - ... be 72 when detail toggle available? (2 grey margin each - ... side, 1 blue margin each side) - ***/ - if (topleftchoice > 0 && hdg2 == NULL) - putstring(topleftrow-1,topleftcol,C_PROMPT_LO,"(more)"); - if (topleftchoice + boxitems < numchoices) - putstring(topleftrow+boxdepth,topleftcol,C_PROMPT_LO,"(more)"); - redisplay = 0; - } - - i = current - topleftchoice; /* highlight the current choice */ - if (formatitem) - (*formatitem)(current,itemptr=curitem); - else - itemptr = choices[current]; - putstring(topleftrow+i/boxwidth,topleftcol+(i%boxwidth)*colwidth, - C_CHOICE_CURRENT,itemptr); - - if (speedstring) { /* show speedstring if any */ - memset(buf,' ',80); - buf[80] = 0; - putstring(speedrow,0,C_PROMPT_BKGRD,buf); - if (*speedstring) { /* got a speedstring on the go */ - putstring(speedrow,15,C_CHOICE_SP_INSTR," "); - if (speedprompt) - j = speedprompt(speedrow,16,C_CHOICE_SP_INSTR,speedstring,speed_match); - else { - putstring(speedrow,16,C_CHOICE_SP_INSTR,speed_prompt); - j = strlen(speed_prompt); - } - strcpy(buf,speedstring); - i = strlen(buf); - while (i < 30) - buf[i++] = ' '; - buf[i] = 0; - putstring(speedrow,16+j,C_CHOICE_SP_INSTR," "); - putstring(speedrow,17+j,C_CHOICE_SP_KEYIN,buf); - movecursor(speedrow,17+j+strlen(speedstring)); - } - else - movecursor(25,80); - } - else - movecursor(25,80); - -/* while (!keypressed()) { } /* enables help */ -/* curkey = getakey(); */ - curkey = keycursor(-2,-2); - - i = current - topleftchoice; /* unhighlight current choice */ - if ((k = attributes[current] & 3) == 1) - k = C_PROMPT_LO; - else if (k == 3) - k = C_PROMPT_HI; - else - k = C_PROMPT_MED; - putstring(topleftrow+i/boxwidth,topleftcol+(i%boxwidth)*colwidth, - k,itemptr); - - increment = 0; - switch (curkey) { /* deal with input key */ - case ENTER: - case ENTER_2: - ret = current; - goto fs_choice_end; - case ESC: - goto fs_choice_end; - case DOWN_ARROW: - case DOWN_ARROW_2: - rev_increment = 0 - (increment = boxwidth); - break; - case UP_ARROW: - case UP_ARROW_2: - increment = 0 - (rev_increment = boxwidth); - break; - case RIGHT_ARROW: - case RIGHT_ARROW_2: - if (boxwidth == 1) break; - increment = 1; rev_increment = -1; - break; - case LEFT_ARROW: - case LEFT_ARROW_2: - if (boxwidth == 1) break; - increment = -1; rev_increment = 1; - break; - case PAGE_UP: - if (numchoices > boxitems) { - topleftchoice -= boxitems; - increment = -boxitems; - rev_increment = boxwidth; - redisplay = 1; - } - break; - case PAGE_DOWN: - if (numchoices > boxitems) { - topleftchoice += boxitems; - increment = boxitems; - rev_increment = -boxwidth; - redisplay = 1; - } - break; - case CTL_HOME: - current = -1; - increment = rev_increment = 1; - break; - case CTL_END: - current = numchoices; - increment = rev_increment = -1; - break; - default: - if (checkkey) { - if ((ret = (*checkkey)(curkey,current)) < -1 || ret > 0) - goto fs_choice_end; - if (ret == -1) - redisplay = -1; - } - ret = -1; - if (speedstring) { - i = strlen(speedstring); - if (curkey == 8 && i > 0) /* backspace */ - speedstring[--i] = 0; - if (33 <= curkey && curkey <= 126 && i < 30) { - curkey = tolower(curkey); - speedstring[i] = curkey; - speedstring[++i] = 0; - } - if (i > 0) { /* locate matching type */ - current = 0; - while (current < numchoices - && (speed_match = strncasecmp(speedstring,choices[current],i)) > 0) - ++current; - if (speed_match < 0 && current > 0) /* oops - overshot */ - --current; - if (current >= numchoices) /* bumped end of list */ - current = numchoices - 1; - } - } - break; - } - - if (increment) { /* apply cursor movement */ - current += increment; - if (speedstring) /* zap speedstring */ - speedstring[0] = 0; - } - while (1) { /* adjust to a non-comment choice */ - if (current < 0 || current >= numchoices) - increment = rev_increment; - else if ((attributes[current] & 256) == 0) - break; - current += increment; - } - if (topleftchoice > numchoices - boxitems) - topleftchoice = ((numchoices+boxwidth-1)/boxwidth)*boxwidth - boxitems; - if (topleftchoice < 0) - topleftchoice = 0; - while (current < topleftchoice) { - topleftchoice -= boxwidth; - redisplay = 1; - } - while (current >= topleftchoice + boxitems) { - topleftchoice += boxwidth; - redisplay = 1; - } - } - -fs_choice_end: - lookatmouse = savelookatmouse; - return(ret); - -} - -int input_field( - int options, /* &1 numeric, &2 integer, &4 double */ - int attr, /* display attribute */ - char *fld, /* the field itself */ - int len, /* field length (declare as 1 larger for \0) */ - int row, /* display row */ - int col, /* display column */ - int (*checkkey)(int) /* routine to check non data keys, or NULL */ - ) -{ - char savefld[81]; - char buf[81]; - int insert, started, offset, curkey, display; - int i, j; - int ret,savelookatmouse; - savelookatmouse = lookatmouse; - lookatmouse = 0; - ret = -1; - strcpy(savefld,fld); - insert = started = offset = 0; - display = 1; - while (1) { - strcpy(buf,fld); - i = strlen(buf); - while (i < len) - buf[i++] = ' '; - buf[len] = 0; - if (display) { /* display current value */ - putstring(row,col,attr,buf); - display = 0; - } - curkey = keycursor(row+insert,col+offset); /* get a keystroke */ - switch (curkey) { - case ENTER: - case ENTER_2: - ret = 0; - goto inpfld_end; - case ESC: - goto inpfld_end; - case RIGHT_ARROW: - case RIGHT_ARROW_2: - if (offset < len) ++offset; - started = 1; - break; - case LEFT_ARROW: - case LEFT_ARROW_2: - if (offset > 0) --offset; - started = 1; - break; - case HOME: - offset = 0; - started = 1; - break; - case END: - offset = strlen(fld); - started = 1; - break; - case 8: - case 127: /* backspace */ - if (offset > 0) { - j = strlen(fld); - for (i = offset-1; i < j; ++i) - fld[i] = fld[i+1]; - --offset; - } - started = display = 1; - break; - case FIK_DELETE: /* delete */ - j = strlen(fld); - for (i = offset; i < j; ++i) - fld[i] = fld[i+1]; - started = display = 1; - break; - case 1082: /* insert */ - insert ^= 0x8000; - started = 1; - break; - case F5: - strcpy(fld,savefld); - insert = started = offset = 0; - display = 1; - break; - default: - if (curkey < 32 || curkey >= 127) { - if (checkkey && (ret = (*checkkey)(curkey))) - goto inpfld_end; - break; /* non alphanum char */ - } - if (offset >= len) break; /* at end of field */ - if ((int)(insert && started && strlen(fld)) >= len) - break; /* insert & full */ - if ((options & 1) - && (curkey < '0' || curkey > '9') - && curkey != '+' && curkey != '-') { - if ((options & 2)) - break; - /* allow scientific notation, and specials "e" and "p" */ - if ( ((curkey != 'e' && curkey != 'E') || offset >= 18) - && ((curkey != 'p' && curkey != 'P') || offset != 0 ) - && curkey != '.') - break; - } - if (started == 0) /* first char is data, zap field */ - fld[0] = 0; - if (insert) { - j = strlen(fld); - while (j >= offset) { - fld[j+1] = fld[j]; - --j; - } - } - if (offset >= (int)strlen(fld)) - fld[offset+1] = 0; - fld[offset++] = curkey; - /* if "e" or "p" in first col make number e or pi */ - if ((options & 3) == 1) { /* floating point */ - double tmpd; - int specialv; - char tmpfld[30]; - specialv = 0; - if (*fld == 'e' || *fld == 'E') { - tmpd = exp(1.0); - specialv = 1; - } - if (*fld == 'p' || *fld == 'P') { - tmpd = atan(1.0) * 4; - specialv = 1; - } - if (specialv) { - if ((options & 4) == 0) - roundfloatd(&tmpd); - sprintf(tmpfld,"%.15g",tmpd); - tmpfld[len-1] = 0; /* safety, field should be long enough */ - strcpy(fld,tmpfld); - offset = 0; - } - } - started = display = 1; - } - } -inpfld_end: - lookatmouse = savelookatmouse; - return(ret); -} - -int field_prompt( - int options, /* &1 numeric value, &2 integer */ - char *hdg, /* heading, \n delimited lines */ - char *instr, /* additional instructions or NULL */ - char *fld, /* the field itself */ - int len, /* field length (declare as 1 larger for \0) */ - int (*checkkey)(int) /* routine to check non data keys, or NULL */ - ) -{ - char *charptr; - int boxwidth,titlelines,titlecol,titlerow; - int promptcol; - int i,j; - char buf[81]; - helptitle(); /* clear screen, display title */ - setattr(1,0,C_PROMPT_BKGRD,24*80); /* init rest to background */ - charptr = hdg; /* count title lines, find widest */ - i = boxwidth = 0; - titlelines = 1; - while (*charptr) { - if (*(charptr++) == '\n') { - ++titlelines; - i = -1; - } - if (++i > boxwidth) - boxwidth = i; - } - if (len > boxwidth) - boxwidth = len; - i = titlelines + 4; /* total rows in box */ - titlerow = (25 - i) / 2; /* top row of it all when centered */ - titlerow -= titlerow / 4; /* higher is better if lots extra */ - titlecol = (80 - boxwidth) / 2; /* center the box */ - titlecol -= (90 - boxwidth) / 20; - promptcol = titlecol - (boxwidth-len)/2; - j = titlecol; /* add margin at each side of box */ - if ((i = (82-boxwidth)/4) > 3) - i = 3; - j -= i; - boxwidth += i * 2; - for (i = -1; i < titlelines+3; ++i) /* draw empty box */ - setattr(titlerow+i,j,C_PROMPT_LO,boxwidth); - textcbase = titlecol; /* set left margin for putstring */ - putstring(titlerow,0,C_PROMPT_HI,hdg); /* display heading */ - textcbase = 0; - i = titlerow + titlelines + 4; - if (instr) { /* display caller's instructions */ - charptr = instr; - j = -1; - while ((buf[++j] = *(charptr++))) - if (buf[j] == '\n') { - buf[j] = 0; - putstringcenter(i++,0,80,C_PROMPT_BKGRD,buf); - j = -1; - } - putstringcenter(i,0,80,C_PROMPT_BKGRD,buf); - } - else /* default instructions */ - putstringcenter(i,0,80,C_PROMPT_BKGRD, - "Press ENTER when finished (or ESCAPE to back out)"); - return(input_field(options,C_PROMPT_INPUT,fld,len, - titlerow+titlelines+1,promptcol,checkkey)); -} - -void helptitle() -{ - char msg[80],buf[10]; - setclear(); /* clear the screen */ - sprintf(msg,"WINFRACT Version %d.%01d",win_release/100, - (win_release%100)/10); - if (win_release%10) { - sprintf(buf,"%01d",win_release%10); - strcat(msg,buf); - } - putstringcenter(0,0,80,C_TITLE,msg); -/* uncomment next for production executable: */ -/* return; */ - putstring(0,2,C_TITLE_DEV,"Development Version"); -/* putstring(0,2,C_TITLE_DEV,"'Public-Beta' Release"); */ -/* replace above by next after creating production release, for release source */ -/* putstring(0,3,C_TITLE_DEV, "Customized Version"); */ - putstring(0,53,C_TITLE_DEV,"Not for Public Release"); -} - -/* squeeze space out of string */ -char *despace(char *str) -{ - char *obuf, *nbuf; - - for (obuf = str, nbuf = str; *obuf && obuf; ++obuf) - { - if (!isspace(*obuf)) - *nbuf++ = *obuf; - } - *nbuf = 0; - return str; -} - -int savegraphics(void) {return 0;} -int restoregraphics(void) {return 0;} - -static int screenctr=-1; -#define MAXSCREENS 3 -static unsigned char *savescreen[MAXSCREENS]; -static int saverc[MAXSCREENS+1]; -static FILE *savescf=NULL; -static char scsvfile[]="fractscr.tmp"; - -void stackscreen() -{ - extern unsigned char wintext_chars[25][80]; - extern unsigned char wintext_attrs[25][80]; - int savebytes; - int i; - unsigned char *ptr; - - saverc[screenctr+1] = textrow*80 + textcol; - if (++screenctr) { /* already have some stacked */ - static char msg[]={"stackscreen overflow"}; - if ((i = screenctr - 1) >= MAXSCREENS) { /* bug, missing unstack? */ - stopmsg(1,msg); - exit(1); - } - savebytes = 25*80; - if ((ptr = savescreen[i] = malloc((long)(2*savebytes)))) { - memcpy(ptr,wintext_chars,savebytes); - memcpy(ptr+savebytes,wintext_attrs,savebytes); - } - else { - static char msg[]={"insufficient memory, aborting"}; -fileproblem: stopmsg(1,msg); - exit(1); - } - setclear(); - } - else - setfortext(); -} - -void unstackscreen() -{ - extern unsigned char wintext_chars[25][80]; - extern unsigned char wintext_attrs[25][80]; - int savebytes; - unsigned char *ptr; - textrow = saverc[screenctr] / 80; - textcol = saverc[screenctr] % 80; - if (--screenctr >= 0) { /* unstack */ - savebytes = 25*80; - if ((ptr = savescreen[screenctr])) { - memcpy(wintext_chars,ptr,savebytes); - memcpy(wintext_attrs,ptr+savebytes,savebytes); - wintext_paintscreen(0,80,0,25); - farmemfree(ptr); - } - } - else - setforgraphics(); - movecursor(-1,-1); -} - -void discardscreen(void) -{ - if (--screenctr >= 0) { /* unstack */ - if (savescreen[screenctr]) - farmemfree(savescreen[screenctr]); - } - else - discardgraphics(); -} - -void discardgraphics(void) -{ -} - -void setfortext(void) -{ -wintext_texton(); -} - -void setforgraphics(void) -{ -wintext_textoff(); -} - -void setclear(void) -{ -extern int wintext_buffer_init; - - wintext_buffer_init = 0; - wintext_paintscreen(0,80,0,25); -} - -int putstringcenter(int row, int col, int width, int attr, char *msg) -{ - char buf[81]; - int i,j,k; - i = 0; - while (msg[i]) ++i; /* strlen for a */ - if (i == 0) return(-1); - j = (width - i) / 2; - j -= (width + 10 - i) / 20; /* when wide a bit left of center looks better */ - memset(buf,' ',width); - buf[width] = 0; - i = 0; - k = j; - while (msg[i]) buf[k++] = msg[i++]; /* strcpy for a far */ - putstring(row,col,attr,buf); - return j; -} - -void putstring(int row, int col, int attr, unsigned char *buf) -{ - extern unsigned char wintext_chars[25][80]; - extern unsigned char wintext_attrs[25][80]; - int i, j, k, maxrow, maxcol; - char xc, xa; - - if (row == -1) row = textrow; - if (col == -1) col = textcol; - - j = maxrow = row; - k = maxcol = col-1; - - for (i = 0; (xc = buf[i]) != 0; i++) { - if (xc == 13 || xc == 10) { - j++; - k = -1; - } - else { - if ((++k) + textcbase >= 80) { - j++; - k = 0; - } - if (j+textrbase >= 25) j = 24-textrbase; - if (k+textcbase >= 80) k = 79-textcbase; - if (maxrow < j) maxrow = j; - if (maxcol < k) maxcol = k; - xa = (attr & 0x0ff); - wintext_chars[j+textrbase][k+textcbase] = xc; - wintext_attrs[j+textrbase][k+textcbase] = xa; - } - } - if (i > 0) { - textrow = j; - textcol = k + 1; - wintext_paintscreen( - col+textcbase, maxcol+textcbase, - row+textrbase, maxrow+textrbase); - } -} - -void setattr(int row, int col, int attr, int count) -{ -extern unsigned char wintext_attrs[25][80]; - int i, j, k, maxrow, maxcol; - char xa; - - j = maxrow = row; - k = maxcol = col-1; - - xa = (attr & 0x0ff); - for (i = 0; i < count; i++) { - if ((++k + textcbase) >= 80) { - j++; - k = 0; - } - if (j+textrbase >= 25) j = 24-textrbase; - if (k+textcbase >= 80) k = 79-textcbase; - if (maxrow < j) maxrow = j; - if (maxcol < k) maxcol = k; - wintext_attrs[j+textrbase][k+textcbase] = xa; - } - if (count > 0) - wintext_paintscreen( - col+textcbase, maxcol+textcbase, - row+textrbase, maxrow+textrbase); -} - -void movecursor(int row, int col) -{ -int cursor_type; - - cursor_type = -1; - if (row >= 25 || col >= 80) { - row=1; - col=1; - cursor_type = 0; - } - if (row >= 0) - textrow = row; - if (col >= 0) - textcol = col; - wintext_cursor(col, row, -1); -} - -int keycursor(int row, int col) -{ -int i, cursor_style; - -if (row == -2 && col == -2) - return(fractint_getkeypress(1)); - -if (row == -1) - row = textrow; -if (col == -1) - col = textcol; - -cursor_style = 1; -if (row < 0) { - cursor_style = 2; - row = row & 0x7fff; - } - -i = fractint_getkeypress(0); -if (i == 0) - wintext_cursor(col, row, cursor_style); -i = fractint_getkeypress(1); -wintext_cursor(col, row, 0); - -return(i); - -} - -/* get a "fractint-style" keystroke, with "help" sensitivity */ -int fractint_getkeypress(int option) -{ -int i; - -restart: - i = wintext_getkeypress(option); - if (i == 0) - return(i); - /* "fractint-i-size" the keystroke */ - if (i != 0 && (i & 255) == 0) /* function key? */ - i = (i >> 8) + 1000; - else - i = (i & 255); - if (i == F1) { /* F1 - bring up Windows-style help */ - if (option == 0) wintext_getkeypress(1); - winfract_help(); - goto restart; - } - if (i == (F1+35)) { /* Control-F1 - bring up Fractint-style help */ - if (option == 0) wintext_getkeypress(1); - if (! in_fractint_help) { - fractint_help(); - goto restart; - } - } - -return(i); - -} - -int getakeynohelp(void) { -return(fractint_getkeypress(1)); -} - -int strncasecmp(char *s,char *t,int ct) -{ - return((int)_fstrnicmp(s,t,ct)); -} - -extern char temp1[]; -extern int colors; -extern unsigned char dacbox[256][3]; -extern unsigned char olddacbox[256][3]; -extern int colorstate; -extern char colorfile[]; -char mapmask[13] = {"*.map"}; - -void save_palette(void) -{ - FILE *dacfile; - int i,oldhelpmode; - oldhelpmode = helpmode; - stackscreen(); - temp1[0] = 0; - helpmode = HELPCOLORMAP; - i = field_prompt(0,"Name of map file to write",NULL,temp1,60,NULL); - unstackscreen(); - if (i != -1 && temp1[0]) { - if (strchr(temp1,'.') == NULL) - strcat(temp1,".map"); - dacfile = fopen(temp1,"w"); - if (dacfile == NULL) - buzzer(2); - else { - for (i = 0; i < colors; i++) - fprintf(dacfile, "%3d %3d %3d\n", - dacbox[i][0] << 2, - dacbox[i][1] << 2, - dacbox[i][2] << 2); - memcpy(olddacbox,dacbox,256*3); - colorstate = 2; - strcpy(colorfile,temp1); - } - fclose(dacfile); - } - helpmode = oldhelpmode; -} - - -int load_palette(void) -{ - int i,oldhelpmode; - char filename[80]; - oldhelpmode = helpmode; - strcpy(filename,colorfile); - stackscreen(); - helpmode = HELPCOLORMAP; - i = getafilename("Select a MAP File",mapmask,filename); - unstackscreen(); - if (i >= 0) - if (ValidateLuts(filename) == 0) { - memcpy(olddacbox,dacbox,256*3); - colorstate = 2; - strcpy(colorfile,filename); - } - helpmode = oldhelpmode; - return (0); -} - -void fractint_help(void) -{ - int oldhelpmode; - - in_fractint_help = 1; - oldhelpmode = helpmode; - helpmode = FIHELP_INDEX; - help(0); - in_fractint_help = 0; - helpmode = oldhelpmode; -} - -extern FILE *parmfile; - -int win_make_batch_file(void) -{ - int i; - int gotinfile; - char outname[81],buf[256],buf2[128]; - FILE *infile; - char colorspec[14]; - int colorsonly = 0; - int maxcolor; - char *sptr,*sptr2; - extern char CommandFile[]; - extern char CommandName[]; - extern int colorstate; - extern int win_temp1, win_temp2; - extern char colorfile[]; - extern int mapset; - extern char MAP_name[]; - - extern char s_cantopen[]; - extern char s_cantwrite[]; - extern char s_cantcreate[]; - extern char s_cantunderstand[]; - extern char s_cantfind[]; - - if (strchr(CommandFile,'.') == NULL) - strcat(CommandFile,".par"); /* default extension .par */ - if (win_temp2 > 0 && win_temp2 <= 256) - maxcolor = win_temp2; - strcpy(colorspec,"n"); - if (win_temp1 == 0) { /* default colors */ - } - else if (win_temp1 == 2) { /* colors match colorfile */ - strcpy(colorspec,"@"); - sptr = colorfile; - } - else { /* colors match no .map that we know of */ - strcpy(colorspec,"y"); - } - if (colorspec[0] == '@') { - if ((sptr2 = strrchr(sptr,'\\'))) sptr = sptr2 + 1; - if ((sptr2 = strrchr(sptr,':'))) sptr = sptr2 + 1; - strncpy(&colorspec[1],sptr,12); - colorspec[13] = 0; - } - - strcpy(outname,CommandFile); - gotinfile = 0; - if (access(CommandFile,0) == 0) { /* file exists */ - gotinfile = 1; - if (access(CommandFile,6)) { - sprintf(buf,s_cantwrite,CommandFile); - stopmsg(0,buf); - return(0); - } - i = strlen(outname); - while (--i >= 0 && outname[i] != '\\') - outname[i] = 0; - strcat(outname,"fractint.tmp"); - infile = fopen(CommandFile,"rt"); - setvbuf(infile,suffix,_IOFBF,4096); /* improves speed */ - } - if ((parmfile = fopen(outname,"wt")) == NULL) { - sprintf(buf,s_cantcreate,outname); - stopmsg(0,buf); - if (gotinfile) fclose(infile); - return(0); - } - - if (gotinfile) { - while (file_gets(buf,255,infile) >= 0) { - if (strchr(buf,'{') /* entry heading? */ - && sscanf(buf," %40[^ \t({]",buf2) - && stricmp(buf2,CommandName) == 0) { /* entry with same name */ - sprintf(buf2,"File already has an entry named %s\n\ -OK to replace it, Cancel to back out",CommandName); - if (stopmsg(18,buf2) < 0) { /* cancel */ - fclose(infile); - fclose(parmfile); - unlink(outname); - return(0); - } - while (strchr(buf,'}') == NULL - && file_gets(buf,255,infile) > 0 ) { } /* skip to end of set */ - break; - } - fputs(buf,parmfile); - fputc('\n',parmfile); - } - } - - fprintf(parmfile,"%-19s{",CommandName); - - { - /* guarantee that there are no blank comments above the last - non-blank par_comment */ - int i, last; - for(last=-1,i=0;i<4;i++) - if(*par_comment[i]) - last=i; - for(i=0;i= 0) { - fputs(buf,parmfile); - fputc('\n',parmfile); - i = file_gets(buf,255,infile); - } - fclose(infile); - } - fclose(parmfile); - if (gotinfile) { /* replace the original file with the new */ - unlink(CommandFile); /* success assumed on these lines */ - rename(outname,CommandFile); /* since we checked earlier with access */ - } - -return(1); -} - - -static int menutype; -#define MENU_HDG 3 -#define MENU_ITEM 1 - -static int menu_checkkey(int curkey,int choice) -{ /* choice is dummy used by other routines called by fullscreen_choice() */ - int testkey; - testkey = choice; /* for warning only */ - testkey = (curkey>='A' && curkey<='Z') ? curkey+('a'-'A') : curkey; -#ifdef XFRACT - /* We use F2 for shift-@, annoyingly enough */ - if (testkey == F2) return(0-testkey); -#endif - if(testkey == '2') - testkey = '@'; - if (strchr("#@2txyzgvir3dj",testkey) || testkey == INSERT || testkey == 2 - || testkey == ESC || testkey == FIK_DELETE || testkey == 6) /*RB 6== ctrl-F for sound menu */ - return(0-testkey); - if (menutype) { - if (strchr("\\sobpkrh",testkey) || testkey == TAB - || testkey == 1 || testkey == 5 || testkey == 8 - || testkey == 16 - || testkey == 19 || testkey == 21) /* ctrl-A, E, H, P, S, U */ - return(0-testkey); - if (testkey == ' ') - if ((curfractalspecific->tojulia != NOFRACTAL - && param[0] == 0.0 && param[1] == 0.0) - || curfractalspecific->tomandel != NOFRACTAL) - return(0-testkey); - if (gotrealdac && colors >= 16) { - if (strchr("c+-",testkey)) - return(0-testkey); - if (colors > 16 - && (testkey == 'a' || (!reallyega && testkey == 'e'))) - return(0-testkey); - } - /* Alt-A and Alt-S */ - if (testkey == 1030 || testkey == 1031 ) - return(0-testkey); - } - if (check_vidmode_key(0,testkey) >= 0) - return(0-testkey); - return(0); -} - -#define LOADPROMPTSCHOICES(X,Y) {\ - static char tmp[] = { Y };\ - choices[X]= (char *)tmp;\ - } - -int main_menu(int fullmenu) -{ - char *choices[44]; /* 2 columns * 22 rows */ - int attributes[44]; - int choicekey[44]; - int i; - int nextleft,nextright; - int oldtabmode /* ,oldhelpmode */; - static char MAIN_MENU[] = {"MAIN MENU"}; - int showjuliatoggle; - oldtabmode = tabmode; - /* oldhelpmode = helpmode; */ -top: - menutype = fullmenu; - tabmode = 0; - showjuliatoggle = 0; - for (i = 0; i < 44; ++i) { - attributes[i] = 256; - choices[i] = ""; - choicekey[i] = -1; - } - nextleft = -2; - nextright = -1; - - if (fullmenu) { - LOADPROMPTSCHOICES(nextleft+=2," CURRENT IMAGE "); - attributes[nextleft] = 256+MENU_HDG; - choicekey[nextleft+=2] = 13; /* enter */ - attributes[nextleft] = MENU_ITEM; - if (calc_status == 2) - { - LOADPROMPTSCHOICES(nextleft,"continue calculation "); - } - else - { - LOADPROMPTSCHOICES(nextleft,"return to image "); - } - choicekey[nextleft+=2] = 9; /* tab */ - attributes[nextleft] = MENU_ITEM; - LOADPROMPTSCHOICES(nextleft,"info about image "); - choicekey[nextleft+=2] = 'o'; - attributes[nextleft] = MENU_ITEM; - LOADPROMPTSCHOICES(nextleft,"orbits window "); - if(!(fractype==JULIA || fractype==JULIAFP || fractype==INVERSEJULIA)) - nextleft+=2; - } - LOADPROMPTSCHOICES(nextleft+=2," NEW IMAGE "); - attributes[nextleft] = 256+MENU_HDG; - choicekey[nextleft+=2] = FIK_DELETE; - attributes[nextleft] = MENU_ITEM; - LOADPROMPTSCHOICES(nextleft,"draw fractal "); - choicekey[nextleft+=2] = 't'; - attributes[nextleft] = MENU_ITEM; - LOADPROMPTSCHOICES(nextleft,"select fractal type "); - if (fullmenu) { - if ((curfractalspecific->tojulia != NOFRACTAL - && param[0] == 0.0 && param[1] == 0.0) - || curfractalspecific->tomandel != NOFRACTAL) { - choicekey[nextleft+=2] = ' '; - attributes[nextleft] = MENU_ITEM; - LOADPROMPTSCHOICES(nextleft,"toggle to/from julia "); - showjuliatoggle = 1; - } - if(fractype==JULIA || fractype==JULIAFP || fractype==INVERSEJULIA) { - choicekey[nextleft+=2] = 'j'; - attributes[nextleft] = MENU_ITEM; - LOADPROMPTSCHOICES(nextleft,"toggle to/from inverse "); - showjuliatoggle = 1; - } -/* History not implemented in WinFract - choicekey[nextleft+=2] = 'h'; - attributes[nextleft] = MENU_ITEM; - LOADPROMPTSCHOICES(nextleft,"return to prior image "); - - choicekey[nextleft+=2] = 8; - attributes[nextleft] = MENU_ITEM; - LOADPROMPTSCHOICES(nextleft,"reverse thru history "); - */ - } - else - nextleft += 2; - LOADPROMPTSCHOICES(nextleft+=2," OPTIONS "); - attributes[nextleft] = 256+MENU_HDG; - choicekey[nextleft+=2] = 'x'; - attributes[nextleft] = MENU_ITEM; - LOADPROMPTSCHOICES(nextleft,"basic options... "); - choicekey[nextleft+=2] = 'y'; - attributes[nextleft] = MENU_ITEM; - LOADPROMPTSCHOICES(nextleft,"extended options... "); - choicekey[nextleft+=2] = 'z'; - attributes[nextleft] = MENU_ITEM; - LOADPROMPTSCHOICES(nextleft,"type-specific parms... "); - choicekey[nextleft+=2] = 'p'; - attributes[nextleft] = MENU_ITEM; - LOADPROMPTSCHOICES(nextleft,"passes options...

"); -/* view window not implemented in WinFract - choicekey[nextleft+=2] = 'v'; - attributes[nextleft] = MENU_ITEM; - LOADPROMPTSCHOICES(nextleft,"view window options... "); - */ - if(showjuliatoggle == 0) - { - choicekey[nextleft+=2] = 'i'; - attributes[nextleft] = MENU_ITEM; - LOADPROMPTSCHOICES(nextleft,"fractal 3D parms... "); - } - choicekey[nextleft+=2] = 2; - attributes[nextleft] = MENU_ITEM; - LOADPROMPTSCHOICES(nextleft,"browse parms... "); - - if (fullmenu) { - choicekey[nextleft+=2] = 5; - attributes[nextleft] = MENU_ITEM; - LOADPROMPTSCHOICES(nextleft,"evolver parms... "); - } -/* Sound not yet implemented in WinFract - if (fullmenu) { - choicekey[nextleft+=2] = 6; - attributes[nextleft] = MENU_ITEM; - LOADPROMPTSCHOICES(nextleft,"sound parms... "); - } - */ - LOADPROMPTSCHOICES(nextright+=2," FILE "); - attributes[nextright] = 256+MENU_HDG; - choicekey[nextright+=2] = '@'; - attributes[nextright] = MENU_ITEM; - LOADPROMPTSCHOICES(nextright,"run saved command set... <@> "); - if (fullmenu) { - choicekey[nextright+=2] = 's'; - attributes[nextright] = MENU_ITEM; - LOADPROMPTSCHOICES(nextright,"save image to file "); - } - choicekey[nextright+=2] = 'r'; - attributes[nextright] = MENU_ITEM; - LOADPROMPTSCHOICES(nextright,"load image from file... "); - choicekey[nextright+=2] = '3'; - attributes[nextright] = MENU_ITEM; - LOADPROMPTSCHOICES(nextright,"3d transform from file...<3> "); - if (fullmenu) { - choicekey[nextright+=2] = '#'; - attributes[nextright] = MENU_ITEM; - LOADPROMPTSCHOICES(nextright,"3d overlay from file.....<#> "); - choicekey[nextright+=2] = 'b'; - attributes[nextright] = MENU_ITEM; - LOADPROMPTSCHOICES(nextright,"save current parameters.. "); - choicekey[nextright+=2] = 16; - attributes[nextright] = MENU_ITEM; - LOADPROMPTSCHOICES(nextright,"print image "); - } -/* No place to shell to in WinFract - choicekey[nextright+=2] = 'd'; - attributes[nextright] = MENU_ITEM; - LOADPROMPTSCHOICES(nextright,"shell to dos "); -*/ - choicekey[nextright+=2] = 'g'; - attributes[nextright] = MENU_ITEM; - LOADPROMPTSCHOICES(nextright,"give command string "); - choicekey[nextright+=2] = ESC; - attributes[nextright] = MENU_ITEM; - LOADPROMPTSCHOICES(nextright,"quit "FRACTINT" "); - choicekey[nextright+=2] = INSERT; - attributes[nextright] = MENU_ITEM; - LOADPROMPTSCHOICES(nextright,"restart "FRACTINT" "); - if (fullmenu && gotrealdac && colors >= 16) { - /* nextright += 2; */ - LOADPROMPTSCHOICES(nextright+=2," COLORS "); - attributes[nextright] = 256+MENU_HDG; - choicekey[nextright+=2] = 'c'; - attributes[nextright] = MENU_ITEM; - LOADPROMPTSCHOICES(nextright,"color cycling mode "); - choicekey[nextright+=2] = '+'; - attributes[nextright] = MENU_ITEM; - LOADPROMPTSCHOICES(nextright,"rotate palette <+>, <-> "); - if (colors > 16) { - if (!reallyega) { - choicekey[nextright+=2] = 'e'; - attributes[nextright] = MENU_ITEM; - LOADPROMPTSCHOICES(nextright,"palette editing mode "); - } - choicekey[nextright+=2] = 'a'; - attributes[nextright] = MENU_ITEM; - LOADPROMPTSCHOICES(nextright,"make starfield "); - } - } - choicekey[nextright+=2] = 1; - attributes[nextright] = MENU_ITEM; - LOADPROMPTSCHOICES(nextright, "ant automaton "); - - choicekey[nextright+=2] = 19; - attributes[nextright] = MENU_ITEM; - LOADPROMPTSCHOICES(nextright, "stereogram "); - - i = (keypressed()) ? getakey() : 0; - if (menu_checkkey(i,0) == 0) { - helpmode = HELPMAIN; /* switch help modes */ - if ((nextleft += 2) < nextright) - nextleft = nextright + 1; - i = fullscreen_choice(CHOICEMENU+CHOICESCRUNCH, - MAIN_MENU, - NULL,NULL,nextleft,(char * *)choices,attributes, - 2,nextleft/2,29,0,NULL,NULL,NULL,menu_checkkey); - if (i == -1) /* escape */ - i = ESC; - else if (i < 0) - i = 0 - i; - else { /* user selected a choice */ - i = choicekey[i]; - switch (i) { /* check for special cases */ - case -10: /* zoombox functions */ - helpmode = HELPZOOM; - help(0); - i = 0; - break; - } - } - } - if (i == ESC) { /* escape from menu exits Fractint */ - static char s[] = "Exit from WinFract (y/n)? y"; - helptitle(); - setattr(1,0,C_GENERAL_MED,24*80); - for (i = 9; i <= 11; ++i) - setattr(i,18,C_GENERAL_INPUT,40); - putstringcenter(10,18,40,C_GENERAL_INPUT,s); - movecursor(25,80); - while ((i = getakey()) != 'y' && i != 'Y' && i != 13) { - if (i == 'n' || i == 'N') - goto top; - } - goodbye(); /* this needs to be a Windows command JCO */ - } - if (i == TAB) { - tab_display(); - i = 0; - } - if (i == ENTER || i == ENTER_2) - i = 0; /* don't trigger new calc */ - tabmode = oldtabmode; - return(i); -} - diff --git a/fractint/win/WINFRACT.C b/fractint/win/WINFRACT.C deleted file mode 100644 index cbcc8378b..000000000 --- a/fractint/win/WINFRACT.C +++ /dev/null @@ -1,2496 +0,0 @@ -/**************************************************************************** - - - PROGRAM: winfract.c - - PURPOSE: Windows-specific main-driver code for Fractint for Windows - (look in MAINFRAC.C for the non-windows-specific code) - - Copyright (C) 1990-1993 The Stone Soup Group. Fractint for Windows - may be freely copied and distributed, but may not be sold. - - We are, of course, copyrighting the code we wrote to implement - Fractint-for-Windows, and not the routines we lifted directly - or indirectly from Microsoft's Windows 3.0 Software Development Kit. - -****************************************************************************/ - -#define STRICT - -#include "port.h" -#include "prototyp.h" - -#include -#include -#include -#include - -#include "winfract.h" -#include "mathtool.h" -#include "fractype.h" -#include "select.h" -#include "profile.h" - -unsigned int windows_version; /* 0x0300 = Win 3.0, 0x030A = 3.1 */ - -extern LPSTR win_lpCmdLine; - -HANDLE hInst; - -HANDLE hAccTable; /* handle to accelerator table */ -extern BOOL ZoomBarOpen; -int ZoomMode; - -HWND hMainWnd, hwnd; /* handle to main window */ -HWND hWndCopy; /* Copy of hWnd */ - -char winfract_title_text[41]; /* Winfract title-bar text */ - -#define PALETTESIZE 256 /* dull-normal VGA */ -HANDLE hpal; /* palette handle */ -PAINTSTRUCT ps; /* paint structure */ -HDC hDC; /* handle to device context */ -HDC hMemoryDC; /* handle to memory device context */ -BITMAP Bitmap; /* bitmap structure */ -extern time_t last_time; -unsigned IconWidth, IconHeight, IconSize; -HANDLE hIconBitmap; - -HANDLE hPal; /* Handle to the application's logical palette */ -HANDLE hLogPal; /* Temporary Handle */ -LPLOGPALETTE pLogPal; /* pointer to the application's logical palette */ -int iNumColors; /* Number of colors supported by device */ -int iRasterCaps; /* Raster capabilities */ -int iPalSize; /* Size of Physical palette */ - -BOOL win_systempaletteused = FALSE; /* flag system palette set */ -extern int win_syscolorindex[21]; -extern DWORD win_syscolorold[21]; -extern DWORD win_syscolornew[21]; - -/* MCP 6-16-91 */ -extern int pixelshift_per_byte; -extern long pixels_per_bytem1; /* pixels / byte - 1 (for ANDing) */ -extern unsigned char win_andmask[8]; -extern unsigned char win_notmask[8]; -extern unsigned char win_bitshift[8]; - -extern int CoordBoxOpen; -extern HWND hCoordBox; -extern int TrackingZoom, Zooming, ReSizing; - -#define EXE_NAME_MAX_SIZE 128 - -BOOL bHelp = FALSE; /* Help mode flag; TRUE = "ON"*/ -HCURSOR hHelpCursor; /* Cursor displayed when in help mode*/ -char szHelpFileName[EXE_NAME_MAX_SIZE+1]; /* Help file name*/ - -void MakeHelpPathName(char*); /* Function deriving help file path */ - -unsigned char win_dacbox[256][3]; - -int win_fastupdate; /* 0 for "normal" fast screen updates */ - -int max_colors; - -BOOL bTrack = FALSE; /* TRUE if user is selecting a region */ -BOOL bMove = FALSE; -BOOL bMoving = FALSE; -BOOL zoomflag = FALSE; /* TRUE if a zoom-box selected */ -extern POINT DragPoint; -RECT Rect; - -int Shape = SL_ZOOM; /* shape to use for the selection rectangle */ - -/* pointers to various dialog-box routines */ -FARPROC lpProcAbout; -FARPROC lpSelectFractal; -FARPROC lpSelectFracParams; -FARPROC lpSelectImage; -FARPROC lpSelectDoodads; -FARPROC lpSelectExtended; -FARPROC lpSelectSavePar; -FARPROC lpSelectCycle; -FARPROC lpProcStatus; -FARPROC lpSelect3D; -FARPROC lpSelect3DPlanar; -FARPROC lpSelect3DSpherical; -FARPROC lpSelectIFS3D; -FARPROC lpSelectFunnyGlasses; -FARPROC lpSelectLightSource; -FARPROC lpSelectStarfield; - -extern int FileFormat; -extern unsigned char DefPath[]; -extern char StatusTitle[]; -unsigned char DialogTitle[128]; -unsigned char FileName[128]; -unsigned char FullPathName[FILE_MAX_DIR]; -unsigned char DefSpec[13]; -unsigned char DefExt[10]; - -HBITMAP hBitmap, oldBitmap, oldoldbitmap; /* working bitmaps */ - -HANDLE hDibInfo; /* handle to the Device-independent bitmap */ -LPBITMAPINFO pDibInfo; /* pointer to the DIB info */ -HANDLE hpixels; /* handle to the DIB pixels */ -unsigned char huge *pixels; /* the device-independent bitmap pixels */ -extern int bytes_per_pixelline; /* pixels/line / pixels/byte */ -extern long win_bitmapsize; /* size of the DIB in bytes */ -extern int resave_flag; /* resaving after a timed save */ -extern char fract_overwrite; /* overwrite on/off */ - -HANDLE hClipboard1, hClipboard2, hClipboard3; /* handles to clipboard info */ -LPSTR lpClipboard1, lpClipboard2; /* pointers to clipboard info */ - -int last_written_y = -2; /* last line written */ -int screen_to_be_cleared = 1; /* flag that the screen is to be cleared */ -int time_to_act = 0; /* time to take some sort of action? */ -int time_to_restart = 0; /* time to restart? */ -int time_to_reinit = 0; /* time to reinitialize? */ -int time_to_resume = 0; /* time to resume? */ -int time_to_quit = 0; /* time to quit? */ -int time_to_save = 0; /* time to save the file? */ -int time_to_print = 0; /* time to print the file? */ -int time_to_load = 0; /* time to load a new file? */ -int time_to_cycle = 0; /* time to begin color-cycling? */ -int time_to_starfield = 0; /* time to make a starfield? */ -int time_to_orbit = 0; /* time to activate orbits? */ - -int win_3dspherical = 0; /* spherical 3D? */ -int win_display3d, win_overlay3d; /* 3D flags */ -extern int init3d[]; /* '3d=nn/nn/nn/...' values */ -extern int RAY; - -extern int win_cycledir, win_cyclerand, win_cycledelay; - -extern int calc_status; -extern int julibrot; - -int xdots, ydots, colors; -long maxiter; -int ytop, ybottom, xleft, xright; -int xposition, yposition, win_xoffset, win_yoffset, xpagesize, ypagesize; -int win_xdots, win_ydots; -double jxxmin, jxxmax, jyymin, jyymax, jxx3rd, jyy3rd; -extern int frommandel; - -int cpu, fpu; /* cpu, fpu flags */ - -extern int win_release; - -char *win_choices[110]; -int win_numchoices, win_choicemade; - -extern int onthelist[]; -extern int CountFractalList; -extern int CurrentFractal; -int MaxFormNameChoices = 80; -char FormNameChoices[80][25]; -extern char FormName[]; -extern char IFSFileName[]; /* IFS code file */ -extern char IFSName[]; /* IFS code item */ -double *temp_array; -HANDLE htemp_array; - -HANDLE hSaveCursor; /* the original cursor value */ -HANDLE hHourGlass; /* the hourglass cursor value */ - -BOOL winfract_menustyle = FALSE;/* Menu style: - FALSE = Winfract-style, - TRUE = Fractint-style */ - -/* strings (near space is precious) */ -char winfract_msg01[] = "Fractint For Windows"; -char winfract_msg02[] = "WinFracMenu"; -char winfract_msg03[] = "FractintForWindowsV0010"; -char winfract_msg04[] = "WinfractAcc"; -char winfract_msg96[] = "I'm sorry, but color-cycling \nrequires a palette-based\nvideo driver"; -char winfract_msg97[] = "There isn't enough available\nmemory to run Winfract"; -char winfract_msg98[] = "This program requires Standard\nor 386-Enhanced Mode"; -char winfract_msg99[] = "Not Enough Free Memory to Copy to the Clipboard"; - - -int PASCAL WinMain(hInstance, hPrevInstance, lpCmdLine, nCmdShow) -HINSTANCE hInstance; -HINSTANCE hPrevInstance; -LPSTR lpCmdLine; -int nCmdShow; -{ - win_lpCmdLine = lpCmdLine; - - if (!hPrevInstance) - if (!InitApplication(hInstance)) - return (FALSE); - - if (!InitInstance(hInstance, nCmdShow)) - return (FALSE); - - fractint_main(); /* fire up the main Fractint code */ - if(htemp_array) { - GlobalUnlock(htemp_array); - GlobalFree(htemp_array); - } - - wintext_destroy(); /* destroy the text window */ - - DestroyWindow(hWndCopy); /* stop everything when it returns */ - - return(0); /* we done when 'fractint_main' returns */ -} - - -BOOL InitApplication(hInstance) -HANDLE hInstance; -{ - WNDCLASS wc; - - wc.style = CS_VREDRAW | CS_HREDRAW | CS_DBLCLKS; - wc.lpfnWndProc = MainWndProc; - wc.cbClsExtra = 0; - wc.cbWndExtra = 0; - wc.hInstance = hInstance; - wc.hIcon = NULL; - wc.hCursor = LoadCursor(NULL, IDC_ARROW); - wc.hbrBackground = GetStockObject(BLACK_BRUSH); - wc.lpszMenuName = winfract_msg02; - wc.lpszClassName = winfract_msg03; - - return(RegisterClass(&wc) && RegisterMathWindows(hInstance)); -} - - -BOOL InitInstance(hInstance, nCmdShow) - HANDLE hInstance; - int nCmdShow; -{ - DWORD WinFlags; - unsigned int version; - int iLoop; - - autobrowse = FALSE; - brwschecktype = TRUE; - brwscheckparms = TRUE; - doublecaution = TRUE; - no_sub_images = FALSE; - toosmall = 6; - minbox = 3; - strcpy(browsemask,"*.gif"); - strcpy(browsename," "); - name_stack_ptr= -1; /* init loaded files stack */ - - evolving = FALSE; - paramrangex = 4; - opx = newopx = -2.0; - paramrangey = 3; - opy = newopy = -1.5; - odpx = odpy = 0; - gridsz = 9; - fiddlefactor = 1; - fiddle_reduction = 1.0; - this_gen_rseed = (unsigned int)clock_ticks(); - srand(this_gen_rseed); - initgene(); /*initialise pointers to lots of fractint variables for the evolution engine*/ - - /* so, what kind of a computer are we on, anyway? */ - WinFlags = GetWinFlags(); - cpu = 88; /* determine the CPU type */ - if (WinFlags & WF_CPU186) cpu = 186; - if (WinFlags & WF_CPU286) cpu = 286; - if (WinFlags & WF_CPU386) cpu = 386; - if (WinFlags & WF_CPU486) cpu = 386; - fpu = 0; /* determine the FPU type */ - if (WinFlags & WF_80x87) fpu = 87; - if (fpu && (cpu == 386)) fpu = 387; - - version = LOWORD(GetVersion()); /* which version of Windows is it? */ - windows_version = ((LOBYTE(version) << 8) | HIBYTE(version)); - - hInst = hInstance; - - hAccTable = LoadAccelerators(hInst, winfract_msg04); - - win_set_title_text(); - - hMainWnd = hwnd = CreateWindow( - winfract_msg03, - winfract_title_text, - WS_OVERLAPPEDWINDOW | WS_HSCROLL | WS_VSCROLL, - 140, 100, /* initial locn instead of CW_USEDEFAULT, CW_USEDEFAULT, */ - 360, 280, /* initial size instead of CW_USEDEFAULT, CW_USEDEFAULT, */ - NULL, - NULL, - hInstance, - NULL - ); - - if (!hwnd) { /* ?? can't create the initial window! */ - return (FALSE); - } - - wintext_initialize( - (HANDLE) hInstance, - (HWND) hwnd, - (LPSTR) winfract_title_text); - - /* This program doesn't run in "real" mode, so shut down right - now to keep from mucking up Windows */ - if (!((WinFlags & WF_STANDARD) || (WinFlags & WF_ENHANCED))) { - MessageBox ( - GetFocus(), - winfract_msg98, - winfract_msg01, - MB_ICONSTOP | MB_OK); - return(FALSE); - } - - win_xdots = xdots; - win_ydots = ydots; - maxiter = 150; /* and a few iterations */ - xposition = yposition = 0; /* dummy up a few pointers */ - xpagesize = ypagesize = 2000; - set_win_offset(); - - SizeWindow(hwnd); - ShowWindow(hwnd, nCmdShow); - UpdateWindow(hwnd); - - /* let's ensure that we have at lease 40K of free memory */ - { - HANDLE temphandle; - if (!(temphandle = GlobalAlloc(GMEM_FIXED,40000L)) || - !(htemp_array = GlobalAlloc(GMEM_FIXED, 5L * sizeof(double) * MAXPIXELS))) { - MessageBox ( - GetFocus(), - winfract_msg97, - winfract_msg01, - MB_ICONSTOP | MB_OK); - return(FALSE); - } - GlobalLock(temphandle); - GlobalUnlock(temphandle); - GlobalFree(temphandle); - temp_array = (double *)GlobalLock(htemp_array); - } - - MakeHelpPathName(szHelpFileName); - - /* so, what kind of a display are we using, anyway? */ - hDC = GetDC(NULL); - iPalSize = GetDeviceCaps (hDC, SIZEPALETTE); - iRasterCaps = GetDeviceCaps (hDC, RASTERCAPS); - iRasterCaps = (iRasterCaps & RC_PALETTE) ? TRUE : FALSE; - if (iRasterCaps) - iNumColors = GetDeviceCaps(hDC, SIZEPALETTE); - else - iNumColors = GetDeviceCaps(hDC, NUMCOLORS); - ReleaseDC(NULL,hDC); - - /* fudges for oddball stuff (is there any?) */ - /* also, note that "true color" devices return -1 for NUMCOLORS */ - colors = iNumColors; - if (colors < 2 || colors > 16) colors = 256; - if (colors > 2 && colors < 16) colors = 16; - /* adjust for Windows' 20 reserved palettes in 256-color mode */ - max_colors = 256; - if (colors == 256 && iNumColors >= 0) max_colors = 236; - - /* Allocate enough memory for a logical palette with - * PALETTESIZE entries and set the size and version fields - * of the logical palette structure. - */ - if (!(hLogPal = GlobalAlloc (GMEM_FIXED, - (sizeof (LOGPALETTE) + - (sizeof (PALETTEENTRY) * (PALETTESIZE)))))) { - MessageBox ( - GetFocus(), - winfract_msg97, - winfract_msg01, - MB_ICONSTOP | MB_OK); - return(FALSE); - } - pLogPal = (LPLOGPALETTE)GlobalLock(hLogPal); - pLogPal->palVersion = 0x300; - pLogPal->palNumEntries = PALETTESIZE; - /* fill in intensities for all palette entry colors */ - for (iLoop = 0; iLoop < PALETTESIZE; iLoop++) { - pLogPal->palPalEntry[iLoop].peRed = iLoop; - pLogPal->palPalEntry[iLoop].peGreen = 0; - pLogPal->palPalEntry[iLoop].peBlue = 0; - pLogPal->palPalEntry[iLoop].peFlags = PC_EXPLICIT; - } - /* flip the ugly red color #1 with the pretty blue color #4 */ -/* - if (iNumColors < 0 || iNumColors > 4) { - pLogPal->palPalEntry[1].peRed = 4; - pLogPal->palPalEntry[4].peRed = 1; - } -*/ - /* create a logical color palette according the information - in the LOGPALETTE structure. */ - hDC = GetDC(GetFocus()); - SetMapMode(hDC,MM_TEXT); - hPal = CreatePalette ((LPLOGPALETTE) pLogPal) ; - ReleaseDC(GetFocus(),hDC); - - /* allocate a device-independent bitmap header */ - if (!(hDibInfo = GlobalAlloc(GMEM_FIXED, - sizeof(BITMAPINFOHEADER)+256*sizeof(PALETTEENTRY)))) { - MessageBox ( - GetFocus(), - winfract_msg97, - winfract_msg01, - MB_ICONSTOP | MB_OK); - return(FALSE); - } - pDibInfo = (LPBITMAPINFO)GlobalLock(hDibInfo); - /* fill in the header */ - pDibInfo->bmiHeader.biSize = (long)sizeof(BITMAPINFOHEADER); - pDibInfo->bmiHeader.biWidth = win_xdots; - pDibInfo->bmiHeader.biHeight = win_ydots; - pDibInfo->bmiHeader.biSizeImage = (DWORD)win_xdots * win_ydots; - pDibInfo->bmiHeader.biPlanes = 1; - pDibInfo->bmiHeader.biBitCount = 8; - pDibInfo->bmiHeader.biCompression = BI_RGB; - pDibInfo->bmiHeader.biXPelsPerMeter = 0L; - pDibInfo->bmiHeader.biYPelsPerMeter = 0L; - pDibInfo->bmiHeader.biClrUsed = 0L; - pDibInfo->bmiHeader.biClrImportant = 0L; - default_dib_palette(); - - IconWidth = GetSystemMetrics(SM_CXICON); - IconHeight = GetSystemMetrics(SM_CYICON); - IconSize = (IconWidth * IconHeight) >> pixelshift_per_byte; - hIconBitmap = GlobalAlloc(GMEM_MOVEABLE, IconSize); - - /* initialize our delay counter */ - CalibrateDelay(); - win_cycledelay = 15; - - /* obtain an hourglass cursor */ - hHourGlass = LoadCursor(NULL, IDC_WAIT); - hSaveCursor = LoadCursor(NULL, IDC_ARROW); - - /* allocate and lock a pixel array for the initial bitmap */ - hpixels = (HANDLE) 0; - pixels = (char huge *) NULL; - if (hIconBitmap && clear_screen(0)) - return(TRUE); - - MessageBox ( - GetFocus(), - winfract_msg97, - winfract_msg01, - MB_ICONSTOP | MB_OK); - - return (FALSE); - -} - -void lmemcpy(char huge *to, char huge *from, long len) -{ -long i; - -for (i = 0; i < len; i++) - to[i] = from[i]; -} - -HWND SecondaryhWnd; -UINT Secondarymessage; -WPARAM SecondarywParam; -LPARAM SecondarylParam; - - -long FAR PASCAL MainWndProc(hWnd, message, wParam, lParam) -HWND hWnd; /* handle to main window */ -UINT message; -WPARAM wParam; -LPARAM lParam; -{ - - RECT tempRect; - HMENU hMenu; - - int i; - extern char FractintMenusStr[]; - extern char FractintPixelsStr[]; - - switch (message) { - - case WM_INITMENU: - if (!iRasterCaps || iNumColors < 16) { - EnableMenuItem(GetMenu(hWnd), IDM_CYCLE, MF_DISABLED | MF_GRAYED); - } - hMenu = GetMenu(hWnd); - if (winfract_menustyle) { - CheckMenuItem(hMenu, IDF_FRACTINTSTYLE, MF_CHECKED); - CheckMenuItem(hMenu, IDF_WINFRACTSTYLE, MF_UNCHECKED); - } - else { - CheckMenuItem(hMenu, IDF_FRACTINTSTYLE, MF_UNCHECKED); - CheckMenuItem(hMenu, IDF_WINFRACTSTYLE, MF_CHECKED); - } - if (win_fastupdate) - CheckMenuItem(hMenu, IDM_PIXELS, MF_CHECKED); - else - CheckMenuItem(hMenu, IDM_PIXELS, MF_UNCHECKED); - hWndCopy = hWnd; - return (TRUE); - - case WM_LBUTTONDBLCLK: - if(Zooming) { - win_savedac(); - ExecuteZoom(); - } - if (bMove) { - DragPoint = MAKEPOINT(lParam); - ExecZoom: - /* End the selection */ - EndSelection(DragPoint, &Rect); - ClearSelection(hWnd, &Rect, Shape); - win_title_text(-1); - - if(PtInRect(&Rect, DragPoint)) { - if (abs(Rect.bottom - Rect.top ) > 5 && - abs(Rect.right - Rect.left) > 5) { - double xd, yd, z; - double tmpx, tmpy; - bf_t bfxd, bfyd; - bf_t bftmpx, bftmpy; - bf_t bftmpzoomx, bftmpzoomy; - int saved=0; - extern POINT Center, ZoomDim; - - if(bf_math) - { - saved = save_stack(); - bfxd = alloc_stack(rbflength+2); - bfyd = alloc_stack(rbflength+2); - bftmpzoomx = alloc_stack(rbflength+2); - bftmpzoomy = alloc_stack(rbflength+2); - bftmpx = alloc_stack(rbflength+2); - bftmpy = alloc_stack(rbflength+2); - } - - z = (double)(ZoomDim.x << 1) / xdots; - if(ZoomMode == IDM_ZOOMOUT) { - z = 1.0 / z; - xd = (xxmin + xxmax) / 2 - (double)(delxx * z * (Center.x + win_xoffset - (xdots/2))); - yd = (yymin + yymax) / 2 + (double)(delyy * z * (Center.y + win_yoffset - (ydots/2))); - if(bf_math) { - tmpx = z * (Center.x + win_xoffset - (xdots/2)); - tmpy = z * (Center.y + win_yoffset - (ydots/2)); - floattobf(bftmpx, tmpx); - floattobf(bftmpy, tmpy); - mult_bf(bftmpzoomx, bfxdel, bftmpx); - mult_bf(bftmpzoomy, bfydel, bftmpy); - add_bf(bftmpx, bfxmin, bfxmax); - add_bf(bftmpy, bfymin, bfymax); - sub_bf(bfxd, half_a_bf(bftmpx), bftmpzoomx); - add_bf(bfyd, half_a_bf(bftmpy), bftmpzoomy); - } - } - else { - xd = xxmin + (double)(delxx * (Center.x + win_xoffset)); /* BDT 11/6/91 */ - yd = yymax - (double)(delyy * (Center.y + win_yoffset)); /* BDT 11/6/91 */ - if(bf_math) { - tmpx = Center.x + win_xoffset; - tmpy = Center.y + win_yoffset; - floattobf(bftmpx, tmpx); - floattobf(bftmpy, tmpy); - mult_bf(bftmpzoomx, bfxdel, bftmpx); - mult_bf(bftmpzoomy, bfydel, bftmpy); - add_bf(bfxd, bfxmin, bftmpzoomx); - sub_bf(bfyd, bfymax, bftmpzoomy); - } - } - xxmin = xd - (double)(delxx * z * (xdots / 2)); - xxmax = xd + (double)(delxx * z * (xdots / 2)); - yymin = yd - (double)(delyy * z * (ydots / 2)); - yymax = yd + (double)(delyy * z * (ydots / 2)); - if(bf_math) { - tmpx = z * (xdots / 2); - tmpy = z * (ydots / 2); - floattobf(bftmpx, tmpx); - floattobf(bftmpy, tmpy); - mult_bf(bftmpzoomx, bfxdel, bftmpx); - mult_bf(bftmpzoomy, bfydel, bftmpy); - sub_bf(bfxmin, bfxd, bftmpzoomx); - add_bf(bfxmax, bfxd, bftmpzoomx); - sub_bf(bfymin, bfyd, bftmpzoomy); - add_bf(bfymax, bfyd, bftmpzoomy); - restore_stack(saved); - } - } - - zoomflag = TRUE; - win_savedac(); - time_to_restart = 1; - time_to_cycle = 0; - calc_status = 0; - } - - bMove = FALSE; - bMoving = FALSE; - bTrack = FALSE; - } - - break; - - case WM_LBUTTONDOWN: /* message: left mouse button pressed */ - - /* Start selection of region */ - - if(bMove) - { - DragPoint = MAKEPOINT(lParam); - bMoving = PtInRect(&Rect, DragPoint); - if(bMoving) - SetCapture(hWnd); - } - else if(Zooming) - StartZoomTracking(lParam); - else if(ZoomMode == IDM_ZOOMIN || ZoomMode == IDM_ZOOMOUT) - { - win_title_text(3); - bTrack = TRUE; - bMoving = FALSE; - bMove = FALSE; - SetRectEmpty(&Rect); - StartSelection(hWnd, MAKEPOINT(lParam), &Rect, - (wParam & MK_SHIFT) ? (SL_EXTEND | Shape) : Shape); - } - break; - - case WM_MOUSEMOVE: /* message: mouse movement */ - - /* Update the selection region */ - - if (bTrack || bMoving) - UpdateSelection(hWnd, MAKEPOINT(lParam), &Rect, Shape); - if(CoordBoxOpen) - UpdateCoordBox(lParam); - if(TrackingZoom) - TrackZoom(lParam); - break; - - case WM_LBUTTONUP: /* message: left mouse button released */ - - if(bTrack) - { - bTrack = FALSE; - bMove = TRUE; - ReleaseCapture(); - if (abs(Rect.bottom - Rect.top ) <= 5 || - abs(Rect.right - Rect.left) <= 5) { - /* Zoom Box is too small - kill it off */ - ClearSelection(hWnd, &Rect, Shape); - win_title_text(-1); - bMove = bMoving = bTrack = FALSE; - } - } - else if(bMoving) - { - bMoving = FALSE; - ReleaseCapture(); - } - else if(TrackingZoom) - EndZoom(lParam); - break; - - case WM_RBUTTONUP: - { - int xx, yy; - win_kill_all_zooming(); - xx = LOWORD(lParam); - yy = HIWORD(lParam); - xx += win_xoffset; - yy += win_yoffset; - if (xx >= xdots || yy >= ydots || bf_math) - break; - if (fractalspecific[fractype].tojulia != NOFRACTAL - && param[0] == 0.0 && param[1] == 0.0) { - /* switch to corresponding Julia set */ - fractype = fractalspecific[fractype].tojulia; - curfractalspecific = &fractalspecific[fractype]; - param[0] = xxmin + (xxmax - xxmin) * xx / xdots; - param[1] = yymax - (yymax - yymin) * yy / ydots; - jxxmin = xxmin; jxxmax = xxmax; - jyymax = yymax; jyymin = yymin; - jxx3rd = xx3rd; jyy3rd = yy3rd; - frommandel = 1; - xxmin = fractalspecific[fractype].xmin; - xxmax = fractalspecific[fractype].xmax; - yymin = fractalspecific[fractype].ymin; - yymax = fractalspecific[fractype].ymax; - xx3rd = xxmin; - yy3rd = yymin; - if(biomorph != -1 && bitshift != 29) { - xxmin *= 3.0; - xxmax *= 3.0; - yymin *= 3.0; - yymax *= 3.0; - xx3rd *= 3.0; - yy3rd *= 3.0; - } - calc_status = 0; - } - else if (fractalspecific[fractype].tomandel != NOFRACTAL) { - /* switch to corresponding Mandel set */ - fractype = fractalspecific[fractype].tomandel; - curfractalspecific = &fractalspecific[fractype]; - if (frommandel) { - xxmin = jxxmin; xxmax = jxxmax; - yymin = jyymin; yymax = jyymax; - xx3rd = jxx3rd; yy3rd = jyy3rd; - } - else { - double ccreal,ccimag; - ccreal = (fractalspecific[fractype].xmax - fractalspecific[fractype].xmin) / 2; - ccimag = (fractalspecific[fractype].ymax - fractalspecific[fractype].ymin) / 2; - xxmin = xx3rd = param[0] - ccreal; - xxmax = param[0] + ccreal; - yymin = yy3rd = param[1] - ccimag; - yymax = param[1] + ccimag; - } - frommandel = 0; - param[0] = 0; - param[1] = 0; - calc_status = 0; - } - else { - buzzer(2); /* can't switch */ - break; - } - - ytop = 0; - ybottom = ydots-1; - xleft = 0; - xright = xdots-1; - - time_to_restart = 1; - time_to_cycle = 0; - calc_status = 0; - } - break; - - case WM_CREATE: - - /* the scroll bars are hard-coded to 100 possible values */ - xposition = yposition = 0; /* initial scroll-bar positions */ - SetScrollRange(hWnd,SB_HORZ,0,100,FALSE); - SetScrollRange(hWnd,SB_VERT,0,100,FALSE); - SetScrollPos(hWnd,SB_HORZ,xposition,TRUE); - SetScrollPos(hWnd,SB_VERT,yposition,TRUE); - InitializeParameters(hWnd); - break; - - case WM_SIZE: - win_kill_all_zooming(); - xpagesize = LOWORD(lParam); /* remember the window size */ - ypagesize = HIWORD(lParam); - set_win_offset(); - if(!ReSizing && !IsIconic(hWnd)) - ReSizeWindow(hWnd); - break; - - case WM_MOVE: - SaveWindowPosition(hWnd, WinfractPosStr); - break; - - case WM_HSCROLL: - win_kill_all_zooming(); - switch (wParam) { - case SB_LINEDOWN: xposition += 1; break; - case SB_LINEUP: xposition -= 1; break; - case SB_PAGEDOWN: xposition += 10; break; - case SB_PAGEUP: xposition -= 10; break; - case SB_THUMBTRACK: - case SB_THUMBPOSITION: xposition = LOWORD(lParam); - default: break; - } - if (xposition > 100) xposition = 100; - if (xposition < 0) xposition = 0; - if (xposition != GetScrollPos(hWnd,SB_HORZ)) { - SetScrollPos(hWnd,SB_HORZ,xposition,TRUE); - InvalidateRect(hWnd,NULL,TRUE); - } - set_win_offset(); - break; - case WM_VSCROLL: - win_kill_all_zooming(); - switch (wParam) { - case SB_LINEDOWN: yposition += 1; break; - case SB_LINEUP: yposition -= 1; break; - case SB_PAGEDOWN: yposition += 10; break; - case SB_PAGEUP: yposition -= 10; break; - case SB_THUMBTRACK: - case SB_THUMBPOSITION: yposition = LOWORD(lParam); - default: break; - } - if (yposition > 100) yposition = 100; - if (yposition < 0) yposition = 0; - if (yposition != GetScrollPos(hWnd,SB_VERT)) { - SetScrollPos(hWnd,SB_VERT,yposition,TRUE); - InvalidateRect(hWnd,NULL,TRUE); - } - set_win_offset(); - break; - - case WM_CLOSE: - message = WM_COMMAND; - wParam = IDM_EXIT; - goto GlobalExit; - - case WM_PAINT: - if (screen_to_be_cleared && last_written_y < 0) { - /* an empty window */ - screen_to_be_cleared = 0; - GetUpdateRect(hWnd, &tempRect, TRUE); - hDC = BeginPaint(hWnd,&ps); - if (last_written_y == -2) - last_written_y = -1; - else - BitBlt(hDC, 0, 0, xdots, ydots, - NULL, 0, 0, BLACKNESS); - ValidateRect(hWnd, &tempRect); - EndPaint(hWnd,&ps); - break; - } - if(IsIconic(hWnd)) { - long x, y; - LPSTR icon; - long lx, ly, dlx, dly; - DWORD tSize, tWidth, tHeight; - - if((icon = GlobalLock(hIconBitmap)) == NULL) - break; - - dlx = ((long)xdots << 8) / IconWidth; - dly = ((long)ydots << 8) / IconHeight; - for(ly = y = 0; y < (long)IconHeight; y++, ly += dly) - { - for(lx = x = 0; x < (long)IconWidth; x++, lx += dlx) - { - unsigned int ix, iy; - unsigned char color; - - ix = (unsigned int) (lx >> 8); - iy = (unsigned int) (ly >> 8); - color = getcolor(ix, iy); - - ix = IconWidth - (unsigned int)y - 1; - ix = (ix * IconWidth) + (unsigned int)x; - iy = ix & (unsigned int)pixels_per_bytem1; - ix = ix >> pixelshift_per_byte; - icon[ix] = (icon[ix] & win_notmask[iy]) + - (color << win_bitshift[iy]); - } - } - - hDC = BeginPaint(hWnd, &ps); - - SelectPalette (hDC, hPal, 0); - RealizePalette(hDC); - - tSize = pDibInfo->bmiHeader.biSizeImage; - tHeight = pDibInfo->bmiHeader.biHeight; - tWidth = pDibInfo->bmiHeader.biWidth; - - pDibInfo->bmiHeader.biSizeImage = IconSize; - pDibInfo->bmiHeader.biHeight = IconHeight; - pDibInfo->bmiHeader.biWidth = IconWidth; - - SetDIBitsToDevice(hDC, - 2, 2, - IconWidth, IconHeight, - 0, 0, - 0, IconHeight, - icon, (LPBITMAPINFO)pDibInfo, - DIB_PAL_COLORS); - - pDibInfo->bmiHeader.biSizeImage = tSize; - pDibInfo->bmiHeader.biHeight = tHeight; - pDibInfo->bmiHeader.biWidth = tWidth; - - GlobalUnlock(hIconBitmap); - - EndPaint(hWnd, &ps); - break; - } - screen_to_be_cleared = 0; - GetUpdateRect(hWnd, &tempRect, FALSE); - if (Zooming) - PaintMathTools(); - if (bTrack || bMove || bMoving) - UpdateSelection(hWnd, DragPoint, &Rect, Shape); - hDC = BeginPaint(hWnd,&ps); - if (last_written_y >= 0) { - int top, bottom, left, right, xcount, ycount; - /* bit-blit the invalidated bitmap area */ - int fromleft, fromtop; - top = tempRect.top; - bottom = tempRect.bottom; - left = tempRect.left; - right = tempRect.right; - if (bottom > ydots) bottom = ydots; - if (right >= xdots) right = xdots-1; - if (top > ydots) top = ydots; - if (left >= xdots) left = xdots; - xcount = right - left + 1; - ycount = bottom - top; - fromleft = left + win_xoffset; - fromtop = win_ydots - bottom - win_yoffset; - if (left < xdots && top < ydots) { - SelectPalette (hDC, hPal, 0); - RealizePalette(hDC); - SetMapMode(hDC,MM_TEXT); - SetDIBitsToDevice(hDC, - left, top, - xcount, ycount, - fromleft, fromtop, - 0, ydots, - (LPSTR)pixels, (LPBITMAPINFO)pDibInfo, - DIB_PAL_COLORS); - } - } - ValidateRect(hWnd, &tempRect); - EndPaint(hWnd,&ps); - if (bTrack || bMove || bMoving) - UpdateSelection(hWnd, DragPoint, &Rect, Shape); - if (Zooming) - PaintMathTools(); - last_time = time(NULL); /* reset the "end-paint" time */ - break; - - case WM_DESTROY: - win_kill_all_zooming(); - if (win_systempaletteused) - win_stop_cycling(); - SaveParameters(hWnd); - /* delete the handle to the logical palette if it has any - color entries and quit. */ - if (pLogPal->palNumEntries) - DeleteObject (hPal); - time_to_quit = 1; - time_to_cycle = 0; - WinHelp(hWnd,szHelpFileName,HELP_QUIT,0L); - GlobalFree(hIconBitmap); - PostQuitMessage(0); - hWndCopy = hWnd; - break; - - case WM_ACTIVATE: - if (!wParam) { /* app. is being de-activated */ - if (win_systempaletteused) - win_stop_cycling(); - break; - } - - case WM_QUERYNEWPALETTE: - /* If palette realization causes a palette change, - * we need to do a full redraw. - */ - if (last_written_y >= 0) { - hDC = GetDC (hWnd); - SelectPalette (hDC, hPal, 0); - i = RealizePalette(hDC); - ReleaseDC (hWnd, hDC); - if (i) { - InvalidateRect (hWnd, (LPRECT) (NULL), 1); - return 1; - } - else - return FALSE; - } - else - return FALSE; - - case WM_PALETTECHANGED: - if (wParam != (WPARAM)hWnd){ - if (last_written_y >= 0) { - hDC = GetDC (hWnd); - SelectPalette (hDC, hPal, 0); - i = RealizePalette (hDC); - if (i) - UpdateColors (hDC); - else - InvalidateRect (hWnd, (LPRECT) (NULL), 1); - ReleaseDC (hWnd, hDC); - } - } - break; - - case WM_COMMAND: - -GlobalExit: - switch (wParam) { - - /* Help menu items */ - - case IDM_HELP_INDEX: - case IDF_HELP_INDEX: - WinHelp(hWnd,szHelpFileName,FIHELP_INDEX,0L); - break; - - case IDM_HELP_FRACTINT: - case IDF_HELP_FRACTINT: - fractint_help(); - break; - - case IDM_HELP_KEYBOARD: - WinHelp(hWnd,szHelpFileName,HELP_KEY,(DWORD)(LPSTR)"keys"); - break; - - case IDM_HELP_HELP: - WinHelp(hWnd,"WINHELP.HLP",FIHELP_INDEX,0L); - break; - - case IDM_ABOUT: - lpProcAbout = MakeProcInstance((FARPROC)About, hInst); - DialogBox(hInst, "AboutBox", hWnd, (DLGPROC)lpProcAbout); - FreeProcInstance(lpProcAbout); - break; - - /* View menu items */ - - case IDF_STATUS: - if (winfract_menustyle) { /* Fractint prompts */ - tab_display(); - break; - } - case IDS_STATUS: - lpProcStatus = MakeProcInstance((FARPROC)Status, hInst); - DialogBox(hInst, "ShowStatus", hWnd, (DLGPROC)lpProcStatus); - FreeProcInstance(lpProcStatus); - break; - - case IDF_FRACTINTSTYLE: - winfract_menustyle = TRUE; - hMenu = GetMenu(hWnd); - CheckMenuItem(hMenu, IDF_FRACTINTSTYLE, MF_CHECKED); - CheckMenuItem(hMenu, IDF_WINFRACTSTYLE, MF_UNCHECKED); - SaveParamSwitch(FractintMenusStr, winfract_menustyle); - break; - - case IDF_WINFRACTSTYLE: - winfract_menustyle = FALSE; - hMenu = GetMenu(hWnd); - CheckMenuItem(hMenu, IDF_FRACTINTSTYLE, MF_UNCHECKED); - CheckMenuItem(hMenu, IDF_WINFRACTSTYLE, MF_CHECKED); - SaveParamSwitch(FractintMenusStr, winfract_menustyle); - break; - - /* Color-Cycling (and Zooming) hotkeys */ - - case IDF_HOTCYCLERAND: - if(Zooming) { - win_savedac(); - ExecuteZoom(); - } - else if(bMove) - { - extern POINT Center; - - DragPoint = Center; - goto ExecZoom; - } - else if (win_oktocycle()) { - win_kill_all_zooming(); - time_to_cycle = 1; - win_cyclerand = 2; - colorstate = 1; - } - break; - - case IDF_HOTNOZOOM: - win_kill_all_zooming(); - if(Zooming) - CancelZoom(); - else if(bMove) - { - extern POINT Center; - - EndSelection(Center, &Rect); - - ClearSelection(hWnd, &Rect, Shape); - bMove = bMoving = bTrack = FALSE; - win_title_text(-1); - } - break; - - case IDF_HOTCYCLEON: - /* Space/etc.. toggles Color-cycling parameters */ - win_kill_all_zooming(); - if (time_to_cycle == 1) { - time_to_resume = 1; - time_to_cycle = 0; - } - else - if (win_oktocycle()) { - time_to_cycle = 1; - colorstate = 1; - } - break; - - case IDF_HOTCYCLERIGHT: - win_kill_all_zooming(); - if (win_oktocycle()) { - time_to_cycle = 1; - win_cycledir = -1; - colorstate = 1; - } - break; - - case IDF_HOTCYCLELEFT: - win_kill_all_zooming(); - if (win_oktocycle()) { - time_to_cycle = 1; - win_cycledir = 1; - colorstate = 1; - } - break; - - case IDF_HOTCYCLERSTEP: - if (win_oktocycle()) { - time_to_cycle = 0; - win_cycledir = -1; - colorstate = 1; - spindac(win_cycledir,1); - } - break; - - case IDF_HOTCYCLELSTEP: - win_kill_all_zooming(); - if (win_oktocycle()) { - time_to_cycle = 0; - win_cycledir = 1; - colorstate = 1; - spindac(win_cycledir,1); - } - break; - - case IDF_HOTCYCLEFAST: - win_kill_all_zooming(); - if (time_to_cycle != 0 && win_cycledelay > 4) - win_cycledelay -= 5; - break; - - case IDF_HOTCYCLESLOW: - win_kill_all_zooming(); - if (time_to_cycle != 0 && win_cycledelay < 100) - win_cycledelay += 5; - break; - - case IDM_ORBITS: - /* toggle orbits only if in pixel-by-pixel mode */ - if (win_fastupdate) - time_to_orbit = 1; - break; - - /* the following commands all cause a flag to be set - which causes the main fractal engine to return to - its main level, call SecondaryWndProc(), and then - either resume, restart, or exit */ - case IDM_EXIT: - case IDM_OPEN: - case IDF_OPEN: - case IDM_NEW: - case IDM_SAVE: - case IDF_SAVE: - case IDM_SAVEAS: - case IDM_PRINT: - case IDF_PRINT: - case IDM_3D: - case IDF_3D: - case IDM_3DOVER: - case IDF_3DOVER: - case IDM_PARFILE: - case IDF_PARFILE: - case IDM_SAVEPAR: - case IDF_SAVEPAR: - case IDM_COPY: - case IDC_EDIT: - case IDM_FORMULA: - case IDF_FORMULA: - case IDM_DOODADX: - case IDF_DOODADX: - case IDM_DOODADY: - case IDF_DOODADY: - case IDM_DOODADZ: - case IDF_DOODADZ: - case IDM_IFS3D: - case IDF_IFS3D: - case IDM_RESTART: - case IDF_RESTART: - case IDM_STARFIELD: - case IDF_STARFIELD: - case IDM_IMAGE: - case IDF_IMAGE: - case IDM_COORD: - case IDM_SIZING: - case IDM_PIXELS: - case IDF_MAPIN: - case IDF_MAPOUT: - case IDM_MAPIN: - case IDM_MAPOUT: - case IDF_CYCLE: - case IDM_CYCLE: - case IDM_MATH_TOOLS: - case IDM_ZOOMIN: - case IDM_ZOOMOUT: - case IDM_ZOOM: - case IDF_PASSES: - case IDM_PASSES: - case IDF_BROWSER: - case IDM_BROWSER: - case IDF_EVOLVER: - case IDM_EVOLVER: - case IDM_MAINMENU: - case IDF_MAINMENU: - case IDF_CMDSTRING: - win_kill_all_zooming(); - time_to_cycle = 0; - SecondaryhWnd = hWnd; - Secondarymessage = message; - SecondarywParam = wParam; - SecondarylParam = lParam; - time_to_act = 1; - break; - - } - break; - - default: - return (DefWindowProc(hWnd, message, wParam, lParam)); - } - return (0); -} - - -void SecondaryWndProc(void) -{ - HWND hWnd; /* handle to main window */ - unsigned message; - WORD wParam; - LONG lParam; - - HMENU hMenu; - - int Return; - int i, fchoice; - extern char FractintMenusStr[]; - extern char FractintPixelsStr[]; - - hWnd = SecondaryhWnd; - message = Secondarymessage; - wParam = SecondarywParam; - lParam = SecondarylParam; - - switch (message) { - - case WM_COMMAND: - - switch (wParam) { - - /* File menu items */ - - case IDF_OPEN: - case IDF_3D: - case IDF_3DOVER: - if (winfract_menustyle) { /* Fractint prompts */ - extern int display3d, overlay3d; - extern int tabmode, helpmode, initbatch; - extern char gifmask[]; - int showfile; - char *hdg; - - win_kill_all_zooming(); - time_to_resume = 1; - initbatch = 0; - display3d = 0; - overlay3d = 0; - if (wParam == IDM_3D || wParam == IDM_3DOVER - || wParam == IDF_3D || wParam == IDF_3DOVER) - display3d = 1; - if (wParam == IDM_3DOVER || wParam == IDF_3DOVER) - overlay3d = 1; - win_display3d = 0; - win_overlay3d = 0; - stackscreen(); - tabmode = 0; - showfile = -1; - while (showfile <= 0) { /* image is to be loaded */ - if (overlay3d) - hdg = "Select File for 3D Overlay"; - else if (display3d) - hdg = "Select File for 3D Transform"; - else - hdg = "Select File to Restore"; - if (showfile < 0 && - getafilename(hdg,gifmask,readname) < 0) { - showfile = 1; /* cancelled */ - break; - } - showfile = 0; - tabmode = 1; - if (read_overlay() == 0) /* read hdr, get video mode */ - break; /* got it, exit */ - showfile = -1; /* retry */ - } - if (!showfile) { - lstrcpy(FileName, readname); - time_to_load = 1; - time_to_cycle = 0; - if (wParam == IDM_3D || wParam == IDM_3DOVER - || wParam == IDF_3D || wParam == IDF_3DOVER) - win_display3d = 1; - if (wParam == IDM_3DOVER || wParam == IDF_3DOVER) - win_overlay3d = 1; - } - tabmode = 1; - unstackscreen(); - break; - } - case IDM_NEW: - case IDM_OPEN: - case IDM_3D: - case IDM_3DOVER: - win_display3d = 0; - win_overlay3d = 0; - lstrcpy(DialogTitle,"File to Open"); - if (wParam == IDM_3D || wParam == IDF_3D) - lstrcpy(DialogTitle,"File for 3D Transform"); - if (wParam == IDM_3DOVER || wParam == IDF_3DOVER) - lstrcpy(DialogTitle,"File for 3D Overlay Transform"); - lstrcpy(FileName, readname); - lstrcpy(DefSpec,"*.gif"); - lstrcpy(DefExt,".gif"); - Return = Win_OpenFile(FileName); - if (Return && (wParam == IDM_3D || wParam == IDM_3DOVER)) { - extern int glassestype; - lpSelect3D = MakeProcInstance( - (FARPROC) Select3D, hInst); - Return = DialogBox(hInst, "Select3D", - hWnd, (DLGPROC)lpSelect3D); - FreeProcInstance(lpSelect3D); - if (glassestype) { - int Return2; - lpSelectFunnyGlasses = MakeProcInstance( - (FARPROC) SelectFunnyGlasses, hInst); - Return2 = DialogBox(hInst, "SelectFunnyGlasses", - hWnd, (DLGPROC)lpSelectFunnyGlasses); - FreeProcInstance(lpSelectFunnyGlasses); - check_funnyglasses_name(); - } - if (Return && !win_3dspherical) { - lpSelect3DPlanar = MakeProcInstance( - (FARPROC) Select3DPlanar, hInst); - Return = DialogBox(hInst, "Select3DPlanar", - hWnd, (DLGPROC)lpSelect3DPlanar); - FreeProcInstance(lpSelect3DPlanar); - } - if (Return && win_3dspherical) { - lpSelect3DSpherical = MakeProcInstance( - (FARPROC) Select3DSpherical, hInst); - Return = DialogBox(hInst, "Select3DSpherical", - hWnd, (DLGPROC)lpSelect3DSpherical); - FreeProcInstance(lpSelect3DSpherical); - } - if (Return && (ILLUMINE || RAY)) { - lpSelectLightSource = MakeProcInstance( - (FARPROC) SelectLightSource, hInst); - Return = DialogBox(hInst, "SelectLightSource", - hWnd, (DLGPROC)lpSelectLightSource); - FreeProcInstance(lpSelectLightSource); - } - } - if (Return) { - lstrcpy(readname,FileName); - time_to_load = 1; - win_kill_all_zooming(); - time_to_cycle = 0; - if (wParam == IDM_3D || wParam == IDM_3DOVER - || wParam == IDF_3D || wParam == IDF_3DOVER) - win_display3d = 1; - if (wParam == IDM_3DOVER || wParam == IDF_3DOVER) - win_overlay3d = 1; - } - break; - - case IDF_SAVE: - if (winfract_menustyle) { /* Fractint prompts */ - /* (no change) */ - } - case IDM_SAVE: - case IDM_SAVEAS: - lstrcpy(DialogTitle,"File to SaveAs"); - lstrcpy(FileName, savename); - lstrcpy(DefSpec,"*.gif"); - lstrcpy(DefExt,".gif"); - Return = Win_SaveFile(FileName); - if (Return) - time_to_save = 1; - if (time_to_save) - { - time_to_cycle = 0; - wsprintf(StatusTitle, "Saving: %s", (LPSTR)FullPathName); - OpenStatusBox(hWnd, hInst); - resave_flag = fract_overwrite = 1; - } - break; - - case IDF_PRINT: - if (winfract_menustyle) { /* Fractint prompts */ - /* (no change) */ - } - case IDM_PRINT: - time_to_print = 1; - time_to_cycle = 0; - break; - - case IDM_PARFILE: -winfract_loadpar: - { - FILE *parmfile; - extern char CommandFile[]; - extern char CommandName[]; - long point; - - win_kill_all_zooming(); - lstrcpy(DialogTitle,"Parameter File to Load"); - lstrcpy(FileName, CommandFile); - lstrcpy(DefSpec,"*.par"); - lstrcpy(DefExt,".par"); - Return = Win_OpenFile(FileName); - if (Return) { - lstrcpy(LFileName, FileName); - lstrcpy(CommandFile, FileName); - get_lsys_name(); - lstrcpy(DialogTitle,"Parameter Entry to Load"); - win_choicemade = 0; - lpSelectFractal = MakeProcInstance((FARPROC)SelectFractal, hInst); - Return = DialogBox(hInst, "SelectFractal", - hWnd, (DLGPROC)lpSelectFractal); - FreeProcInstance(lpSelectFractal); - if (Return) { - parmfile = fopen(CommandFile,"rb"); - memcpy((char *)&point, - (char *)&win_choices[win_choicemade][21], - 4); - fseek(parmfile,point,SEEK_SET); - Return = load_commands(parmfile); - } - if (Return) { - if (xx3rd != xxmin || yy3rd != yymin) - stopmsg(4," This image uses a skewed zoom-box,\n a feature not available in Winfract.\n All Skewness has been dropped"); - if (colorpreloaded) - win_savedac(); - maxiter = maxit; - time_to_restart = 1; - time_to_cycle = 0; - calc_status = 0; - } - } - break; - } - - case IDM_SAVEPAR: - { - extern char CommandFile[]; - win_kill_all_zooming(); - lstrcpy(DialogTitle,"Parameter File to SaveAs"); - lstrcpy(FileName, CommandFile); - lstrcpy(DefSpec,"*.par"); - lstrcpy(DefExt,".par"); - Return = Win_SaveFile(FileName); - if (Return) { - lstrcpy(LFileName, FileName); - lstrcpy(CommandFile, FileName); - lpSelectSavePar = MakeProcInstance((FARPROC)SelectSavePar, hInst); - Return = DialogBox(hInst, "SelectSavePar", - hWnd, (DLGPROC)lpSelectSavePar); - FreeProcInstance(lpSelectSavePar); - } - if (Return) { - time_to_resume = 1; - win_make_batch_file(); - } - break; - } - - case IDF_SAVEPAR: - win_kill_all_zooming(); - time_to_resume = 1; - make_batch_file(); - break; - - case IDM_COPY: - win_copy_to_clipboard(); - - break; - - case IDM_EXIT: - win_kill_all_zooming(); - time_to_quit = 1; - time_to_cycle = 0; - ValidateRect(hWnd, NULL); - hWndCopy = hWnd; - /* the main routine will actually call 'DestroyWindow()' */ - break; - - /* Fractals menu items */ - - case IDF_FORMULA: - if (winfract_menustyle) { /* Fractint prompts */ - win_kill_all_zooming(); - time_to_resume = 1; - julibrot = 0; /* disable Julibrot logic */ -julibrot_fudge: /* dive in here for Julibrots */ - stackscreen(); - i = get_fracttype(); - unstackscreen(); - SetFocus(hWnd); - if (i == 0) { /* time to redraw? */ - time_to_restart = 1; - time_to_cycle = 0; - calc_status = 0; - } - break; - } - case IDM_FORMULA: - lstrcpy(DialogTitle,"Select a Fractal Formula"); - win_kill_all_zooming(); - win_numchoices = CountFractalList; - win_choicemade = 0; - CurrentFractal = fractype; - for (i = 0; i < win_numchoices; i++) { - win_choices[i] = fractalspecific[onthelist[i]].name; - if (onthelist[i] == fractype || - fractalspecific[onthelist[i]].tofloat == fractype) - win_choicemade = i; - } - lpSelectFractal = MakeProcInstance((FARPROC)SelectFractal, hInst); - Return = DialogBox(hInst, "SelectFractal", - hWnd, (DLGPROC)lpSelectFractal); - FreeProcInstance(lpSelectFractal); - fchoice = win_choicemade; - if (Return && (onthelist[fchoice] == IFS || - onthelist[fchoice] == IFS3D)) { - lstrcpy(DialogTitle,"IFS Filename to Load"); - lstrcpy(FileName, IFSFileName); - lstrcpy(DefSpec,"*.ifs"); - lstrcpy(DefExt,".ifs"); - Return = Win_OpenFile(FileName); - if (Return) { - lstrcpy(IFSFileName, FileName); - lstrcpy(FormFileName, FileName); - get_formula_names(); - lstrcpy(DialogTitle,"Select an IFS type"); - win_choicemade = 0; - lpSelectFractal = MakeProcInstance((FARPROC)SelectFractal, hInst); - Return = DialogBox(hInst, "SelectFractal", - hWnd, (DLGPROC)lpSelectFractal); - FreeProcInstance(lpSelectFractal); - if (Return) { - lstrcpy(IFSName, win_choices[win_choicemade]); - Return = ! ifsload(); - } - } - } - if (Return && (onthelist[fchoice] == FORMULA || - onthelist[fchoice] == FFORMULA)) { - /* obtain the formula filename */ - lstrcpy(DialogTitle,"Formula File to Load"); - lstrcpy(FileName, FormFileName); - lstrcpy(DefSpec,"*.frm"); - lstrcpy(DefExt,".frm"); - Return = Win_OpenFile(FileName); - if (Return) { - lstrcpy(FormFileName, FileName); - get_formula_names(); - lstrcpy(DialogTitle,"Select a Formula"); - win_choicemade = 0; - lpSelectFractal = MakeProcInstance((FARPROC)SelectFractal, hInst); - Return = DialogBox(hInst, "SelectFractal", - hWnd, (DLGPROC)lpSelectFractal); - FreeProcInstance(lpSelectFractal); - if (Return) - Return = parse_formula_names(); - } - } - if (Return && (onthelist[fchoice] == LSYSTEM)) { - lstrcpy(DialogTitle,"Lsystem File to Load"); - lstrcpy(FileName, LFileName); - lstrcpy(DefSpec,"*.l"); - lstrcpy(DefExt,".l"); - Return = Win_OpenFile(FileName); - if (Return) { - lstrcpy(LFileName, FileName); - get_lsys_name(); - lstrcpy(DialogTitle,"Select a Formula"); - win_choicemade = 0; - lpSelectFractal = MakeProcInstance((FARPROC)SelectFractal, hInst); - Return = DialogBox(hInst, "SelectFractal", - hWnd, (DLGPROC)lpSelectFractal); - FreeProcInstance(lpSelectFractal); - if (Return) { - lstrcpy(LName, win_choices[win_choicemade]); - Return = !LLoad(); - } - } - } - julibrot = 0; - if (Return) { - double oldxxmin, oldxxmax, oldyymin, oldyymax; - double oldparam[4]; - int i; - oldxxmin = xxmin; - oldxxmax = xxmax; - oldyymin = yymin; - oldyymax = yymax; - for (i = 0; i < 4; i++) - oldparam[i] = param[i]; - CurrentFractal = onthelist[fchoice]; - curfractalspecific = &fractalspecific[CurrentFractal]; - if (CurrentFractal == BIFURCATION - || CurrentFractal == LBIFURCATION - || CurrentFractal == BIFSTEWART - || CurrentFractal == LBIFSTEWART - || CurrentFractal == BIFLAMBDA - || CurrentFractal == LBIFLAMBDA - ) set_trig_array(0,"ident"); - if (CurrentFractal == BIFEQSINPI - || CurrentFractal == LBIFEQSINPI - || CurrentFractal == BIFADSINPI - || CurrentFractal == LBIFADSINPI - ) set_trig_array(0,"sin"); - set_default_parms(); - if (CurrentFractal == JULIBROT || CurrentFractal == JULIBROTFP) { - fractype = CurrentFractal; - julibrot = 1; - stackscreen(); - if (get_fract_params(0) < 0) - Return = 0; - unstackscreen(); - } - else { - lpSelectFracParams = MakeProcInstance((FARPROC)SelectFracParams, - hInst); - Return = DialogBox(hInst, "SelectFracParams", - hWnd, (DLGPROC)lpSelectFracParams); - FreeProcInstance(lpSelectFracParams); - } - if (! Return) { - xxmin = oldxxmin; - xxmax = oldxxmax; - yymin = oldyymin; - yymax = oldyymax; - for (i = 0; i < 4; i++) - param[i] = oldparam[i]; - } - } - if (Return) { - time_to_reinit = 1; - time_to_cycle = 0; - calc_status = 0; - } - break; - - case IDF_PARFILE: - if (!winfract_menustyle) { /* winfract prompts */ - goto winfract_loadpar; /* for now */ - } - case IDF_DOODADX: - if (!winfract_menustyle) /* Windows menus */ - goto winfract_xmenu; /* for now */ - case IDF_DOODADY: - if (!winfract_menustyle) /* Windows menus */ - goto winfract_ymenu; /* for now */ - case IDF_DOODADZ: - if (!winfract_menustyle) /* Windows menus */ - goto winfract_zmenu; /* for now */ - case IDF_PASSES: - if (!winfract_menustyle) /* Windows menus */ - goto winfract_pmenu; /* for now */ - case IDF_BROWSER: - if (!winfract_menustyle) /* Windows menus */ - goto winfract_bmenu; /* for now */ - case IDF_EVOLVER: - if (!winfract_menustyle) /* Windows menus */ - goto winfract_emenu; /* for now */ - case IDF_MAINMENU: - if (!winfract_menustyle) /* Windows menus */ - goto winfract_mmenu; /* for now */ - case IDF_CMDSTRING: - - if (winfract_menustyle) { /* fractint prompts */ - win_kill_all_zooming(); - time_to_resume = 1; - stackscreen(); - maxiter = maxit; - if (wParam == IDF_DOODADX || wParam == IDM_DOODADX) - i = get_toggles(); - else if (wParam == IDF_DOODADY || wParam == IDM_DOODADY) - i = get_toggles2(); - else if (wParam == IDF_DOODADZ || wParam == IDM_DOODADZ) - i = get_fract_params(1); - else if (wParam == IDF_PASSES || wParam == IDM_PASSES) - i = passes_options(); - else if (wParam == IDF_BROWSER || wParam == IDM_BROWSER) - i = get_browse_params(); - else if (wParam == IDF_EVOLVER || wParam == IDM_EVOLVER) - i = get_evolve_Parms(); - else if (wParam == IDF_MAINMENU || wParam == IDM_MAINMENU) - i = main_menu(1); - else if (wParam == IDF_CMDSTRING) - i = get_cmd_string(); - else { - i = get_commands(); - if (xx3rd != xxmin || yy3rd != yymin) - stopmsg(4," This image uses a skewed zoom-box,\n a feature not available in Winfract.\n All Skewness has been dropped"); - if (colorpreloaded) - win_savedac(); - } - unstackscreen(); - SetFocus(hWnd); - time_to_cycle = 0; - if (i > 0) { /* time to redraw? */ - maxiter = maxit; - time_to_restart = 1; - calc_status = 0; - } - break; - } - - case IDM_DOODADX: -winfract_xmenu: - lpSelectDoodads = MakeProcInstance((FARPROC)SelectDoodads, hInst); - Return = DialogBox(hInst, "SelectDoodads", - hWnd, (DLGPROC)lpSelectDoodads); - FreeProcInstance(lpSelectDoodads); - if (Return) { - win_kill_all_zooming(); - win_savedac(); - time_to_restart = 1; - time_to_cycle = 0; - calc_status = 0; - } - break; - - case IDM_DOODADY: -winfract_ymenu: - lpSelectExtended = MakeProcInstance((FARPROC)SelectExtended, hInst); - Return = DialogBox(hInst, "SelectExtended", - hWnd, (DLGPROC)lpSelectExtended); - FreeProcInstance(lpSelectExtended); - if (Return) { - win_kill_all_zooming(); - win_savedac(); - time_to_restart = 1; - time_to_cycle = 0; - calc_status = 0; - } - break; - - case IDM_DOODADZ: -winfract_zmenu: - CurrentFractal = fractype; - lpSelectFracParams = MakeProcInstance((FARPROC)SelectFracParams, - hInst); - Return = DialogBox(hInst, "SelectFracParams", - hWnd, (DLGPROC)lpSelectFracParams); - FreeProcInstance(lpSelectFracParams); - if (Return) { - win_kill_all_zooming(); - win_savedac(); - time_to_reinit = 1; - time_to_cycle = 0; - calc_status = 0; - } - break; - - case IDM_PASSES: -winfract_pmenu: - break; - - case IDM_BROWSER: -winfract_bmenu: - break; - - case IDM_EVOLVER: -winfract_emenu: - break; - - case IDM_MAINMENU: -winfract_mmenu: - break; - - case IDF_IFS3D: - if (winfract_menustyle) { /* Fractint prompts */ - extern int display3d, overlay3d; - extern int tabmode, helpmode, initbatch; - extern char gifmask[]; - tabmode = 0; - if (get_fract3d_params() >= 0) { - win_kill_all_zooming(); - time_to_restart = 1; - } - tabmode = 1; - break; - } - case IDM_IFS3D: - { - extern int glassestype; - lpSelectIFS3D = MakeProcInstance( - (FARPROC) SelectIFS3D, hInst); - Return = DialogBox(hInst, "SelectIFS3D", - hWnd, (DLGPROC)lpSelectIFS3D); - FreeProcInstance(lpSelectIFS3D); - if (Return) { - win_kill_all_zooming(); - time_to_restart = 1; - if (glassestype) { - lpSelectFunnyGlasses = MakeProcInstance( - (FARPROC) SelectFunnyGlasses, hInst); - Return = DialogBox(hInst, "SelectFunnyGlasses", - hWnd, (DLGPROC)lpSelectFunnyGlasses); - FreeProcInstance(lpSelectFunnyGlasses); - check_funnyglasses_name(); - } - } - break; - } - - case IDM_RESTART: - case IDF_RESTART: - time_to_reinit = 2; - time_to_cycle = 0; - calc_status = 0; - break; - - case IDF_STARFIELD: - if (winfract_menustyle) { /* fractint prompts */ - if (get_starfield_params() >= 0) { - win_kill_all_zooming(); - time_to_starfield = 1; - time_to_cycle = 0; - calc_status = 0; - } - break; - } - case IDM_STARFIELD: - lpSelectStarfield = MakeProcInstance( - (FARPROC) SelectStarfield, hInst); - Return = DialogBox(hInst, "Starfield", - hWnd, (DLGPROC)lpSelectStarfield); - FreeProcInstance(lpSelectStarfield); - if (Return) { - win_kill_all_zooming(); - time_to_starfield = 1; - time_to_cycle = 0; - calc_status = 0; - } - break; - - /* View menu items */ - - case IDF_IMAGE: - if (winfract_menustyle) { /* Fractint prompts */ - /* (no change) */ - } - case IDM_IMAGE: - win_kill_all_zooming(); - lpSelectImage = MakeProcInstance((FARPROC)SelectImage, hInst); - Return = DialogBox(hInst, "SelectImage", - hWnd, (DLGPROC)lpSelectImage); - FreeProcInstance(lpSelectImage); - if (Return) { - time_to_restart = 1; - time_to_cycle = 0; - calc_status = 0; - } - ReSizeWindow(hWnd); - break; - - case IDM_MATH_TOOLS: - MathToolBox(hWnd); - break; - - case IDM_ZOOMOUT: - case IDM_ZOOMIN: - if(ZoomBarOpen) - ZoomBar(hWnd); - else - CheckMenuItem(GetMenu(hWnd), ZoomMode, MF_UNCHECKED); - CheckMenuItem(GetMenu(hWnd), wParam, MF_CHECKED); - ZoomMode = wParam; - break; - - case IDM_ZOOM: - if(!ZoomBarOpen) - CheckMenuItem(GetMenu(hWnd), ZoomMode, MF_UNCHECKED); - win_kill_all_zooming(); - ZoomBar(hWnd); - break; - - case IDM_COORD: - CoordinateBox(hWnd); - break; - - case IDM_SIZING: - win_kill_all_zooming(); - WindowSizing(hWnd); - break; - - case IDM_PIXELS: - { - BOOL profile_fastupdate; - hMenu = GetMenu(hWnd); - if (win_fastupdate) { - win_fastupdate = 0; - /* if disabling p-by-p, disable orbits, too */ - if (show_orbit) - time_to_orbit = 1; - profile_fastupdate = FALSE; - CheckMenuItem(hMenu, IDM_PIXELS, MF_UNCHECKED); - } - else { - win_fastupdate = 2; - profile_fastupdate = TRUE; - CheckMenuItem(hMenu, IDM_PIXELS, MF_CHECKED); - } - SaveParamSwitch(FractintPixelsStr, profile_fastupdate); - } - break; - - case IDF_STATUS: - if (winfract_menustyle) { /* Fractint prompts */ - tab_display(); - break; - } - case IDS_STATUS: - lpProcStatus = MakeProcInstance((FARPROC)Status, hInst); - DialogBox(hInst, "ShowStatus", hWnd, (DLGPROC)lpProcStatus); - FreeProcInstance(lpProcStatus); - break; - - /* Colors menu items */ - - case IDF_MAPIN: - if (winfract_menustyle) { /* fractint-style prompts */ - win_kill_all_zooming(); - time_to_resume = 1; - time_to_cycle = 0; - if (wParam == IDF_MAPIN) - load_palette(); - else - save_palette(); - spindac(0,1); - break; - } - case IDF_MAPOUT: - case IDM_MAPIN: - case IDM_MAPOUT: - lstrcpy(DialogTitle,"Palette File to Load"); - lstrcpy(FileName, MAP_name); - if (wParam == IDM_MAPOUT || wParam == IDF_MAPOUT) - lstrcpy(FileName, "mymap"); - lstrcpy(DefSpec,"*.map"); - lstrcpy(DefExt,".map"); - if (wParam == IDM_MAPOUT || wParam == IDF_MAPOUT) { - Return = Win_SaveFile(FileName); - } - else { - Return = Win_OpenFile(FileName); - } - if (Return && (wParam == IDM_MAPIN || wParam == IDF_MAPIN)) { - win_kill_all_zooming(); - ValidateLuts(FileName); - spindac(0,1); - } - if (Return && (wParam == IDM_MAPOUT || wParam == IDF_MAPOUT)) { - FILE *dacfile; - dacfile = fopen(FileName,"w"); - if (dacfile == NULL) { - break; - } - fprintf(dacfile," 0 0 0\n"); - for (i = 1; i < 256; i++) - fprintf(dacfile, "%3d %3d %3d\n", - dacbox[i][0] << 2, - dacbox[i][1] << 2, - dacbox[i][2] << 2); - fclose(dacfile); - } - break; - - case IDF_CYCLE: - if (winfract_menustyle) { /* Fractint prompts */ - /* (no change) */ - } - case IDM_CYCLE: - if (!win_oktocycle()) - break; - win_kill_all_zooming(); - lpSelectCycle = MakeProcInstance((FARPROC)SelectCycle, hInst); - Return = DialogBox(hInst, "SelectCycle", - hWnd, (DLGPROC)lpSelectCycle); - FreeProcInstance(lpSelectCycle); - break; - - case IDC_EDIT: - if (HIWORD (lParam) == EN_ERRSPACE) { - MessageBox ( - GetFocus () - , "Out of memory." - , "Fractint For Windows" - , MB_ICONSTOP | MB_OK - ); - } - break; - - } - break; - - } - return; -} - -void win_set_title_text(void) -{ - float temp; - char ctemp[80]; - - temp = (float)(win_release / 100.0); - sprintf(ctemp,"Fractint for Windows - Vers %5.2f", temp); - lstrcpy(winfract_title_text, ctemp); -} - -char win_oldtitle[30]; -char win_title1[] = " (calculating)"; -char win_title2[] = " (color-cycling)"; -char win_title3[] = " (zooming "; -char win_title4[] = " (starfield generation)"; - -void win_title_text(int title) -{ -char newtitle[80]; - -lstrcpy(newtitle, winfract_title_text); - -if (title < 0) { - lstrcat(newtitle, win_oldtitle); - } -if (title == 0) { - win_oldtitle[0] = 0; - lstrcat(newtitle, win_oldtitle); - } -if (title == 1) { - lstrcpy(win_oldtitle, win_title1); - lstrcat(newtitle, win_oldtitle); - } -if (title == 2) { - lstrcat(newtitle, win_title2); - } -if (title == 3) { - lstrcat(newtitle, win_title3); -if (ZoomMode == IDM_ZOOMOUT) - lstrcat(newtitle, "out)"); -else - lstrcat(newtitle, "in)"); - } -if (title == 4) { - lstrcat(newtitle, win_title4); - } - -SetWindowText(hMainWnd, newtitle); - -} - -int win_oktocycle(void) -{ -if (!(iRasterCaps) || iNumColors < 16) { - stopmsg(0, - winfract_msg96 - ); - return(0); - } -return(1); -} - -extern int win_animate_flag; - -int win_stop_cycling(void) -{ -HDC hDC; /* handle to device context */ - -hDC = GetDC(GetFocus()); -SetSystemPaletteUse(hDC,SYSPAL_STATIC); -ReleaseDC(GetFocus(),hDC); - -time_to_cycle = 0; -win_animate_flag = 0; -restoredac(); -win_systempaletteused = FALSE; -SetSysColors(COLOR_ENDCOLORS,(LPINT)win_syscolorindex,(LONG FAR *)win_syscolorold); -return(0); -} - -void win_kill_all_zooming(void) -{ - if(Zooming) - CancelZoom(); - else if(bMove) - { - extern POINT Center; - - EndSelection(Center, &Rect); - ClearSelection(hWndCopy, &Rect, Shape); - bMove = bMoving = bTrack = FALSE; - win_title_text(-1); - } -} - -void mono_dib_palette(void) -{ -int i; /* fill in the palette index values */ - for (i = 0; i < 128; i = i+2) { - pDibInfo->bmiColors[i ].rgbBlue = 0; - pDibInfo->bmiColors[i ].rgbGreen = 0; - pDibInfo->bmiColors[i ].rgbRed = 0; - pDibInfo->bmiColors[i ].rgbReserved = 0; - pDibInfo->bmiColors[i+1].rgbBlue = 255; - pDibInfo->bmiColors[i+1].rgbGreen = 255; - pDibInfo->bmiColors[i+1].rgbRed = 255; - pDibInfo->bmiColors[i+1].rgbReserved = 0; - } -} - -int default_dib_palette(void) -{ -int i, k; /* fill in the palette index values */ -int *palette_values; /* pointer to palette values */ - - palette_values = (int *)&pDibInfo->bmiColors[0]; - k = 0; - for (i = 0; i < 256; i++) { - palette_values[i] = k; - if (++k >= iNumColors) - if (iNumColors > 0) - k = 0; - } - return(0); -} - -int rgb_dib_palette(void) -{ -int i; /* fill in the palette index values */ - - for (i = 0; i < 256; i++) { - pDibInfo->bmiColors[i].rgbRed = dacbox[i][0] << 2; - pDibInfo->bmiColors[i].rgbGreen = dacbox[i][1] << 2; - pDibInfo->bmiColors[i].rgbBlue = dacbox[i][2] << 2; - pDibInfo->bmiColors[i].rgbReserved = 0; - } - return(0); -} - -int win_copy_to_clipboard(void) -{ -HWND hWnd; - - hWnd = SecondaryhWnd; - - /* allocate the memory for the BITMAPINFO structure - (followed by the bitmap bits) */ - if (!(hClipboard1 = GlobalAlloc(GMEM_FIXED, - sizeof(BITMAPINFOHEADER)+colors*sizeof(PALETTEENTRY) - + win_bitmapsize))) { - cant_clip(); - return(0); - } - if (!(lpClipboard1 = - (LPSTR) GlobalLock(hClipboard1))) { - GlobalFree(hClipboard1); - cant_clip(); - return(0); - } - rgb_dib_palette(); - lmemcpy((char huge *)lpClipboard1, (char huge *)pDibInfo, - sizeof(BITMAPINFOHEADER)+colors*sizeof(RGBQUAD) - ); - lpClipboard1 += - (sizeof(BITMAPINFOHEADER))+ - (colors*sizeof(RGBQUAD)); - lmemcpy((char huge *)lpClipboard1, (char huge *)pixels, - win_bitmapsize); - - GlobalUnlock(hClipboard1); - - /* allocate the memory for the palette info */ - if (!lpClipboard2) { - if (!(hClipboard2 = GlobalAlloc (GMEM_FIXED, - (sizeof (LOGPALETTE) + - (sizeof (PALETTEENTRY) * (PALETTESIZE)))))) { - GlobalFree(hClipboard1); - cant_clip(); - return(0); - } - if (!(lpClipboard2 = - (LPSTR) GlobalLock(hClipboard2))) { - GlobalFree(hClipboard1); - GlobalFree(hClipboard2); - cant_clip(); - return(0); - } - } - - /* fill in the palette info */ - lpClipboard2[0] = 0; - lpClipboard2[1] = 3; - lpClipboard2[2] = 0; - lpClipboard2[3] = 1; - lmemcpy((char huge *)&lpClipboard2[4], - (char huge *)&pDibInfo->bmiColors[0], - PALETTESIZE*sizeof(RGBQUAD) - ); - hClipboard3 = CreatePalette ((LPLOGPALETTE) lpClipboard2); - - hDC = GetDC(hWnd); - hBitmap = CreateDIBitmap(hDC, &pDibInfo->bmiHeader, - CBM_INIT, (LPSTR)pixels, pDibInfo, - DIB_RGB_COLORS); - ReleaseDC(hWnd, hDC); - - if (OpenClipboard(hWnd)) { - EmptyClipboard(); - SetClipboardData(CF_PALETTE, hClipboard3); - SetClipboardData(CF_DIB, hClipboard1); - if(hBitmap) - SetClipboardData(CF_BITMAP, hBitmap); - CloseClipboard(); - } - - default_dib_palette(); -} - -extern char win_funnyglasses_map_name[]; - -void check_funnyglasses_name(void) -{ - if (win_funnyglasses_map_name[0] != 0) { - if (ValidateLuts(win_funnyglasses_map_name) == 0) { - win_savedac(); - } - else { - char temp[80]; - sprintf(temp,"Can't find map file: %s", - win_funnyglasses_map_name); - stopmsg(0,temp); - } - } -} - -void MakeHelpPathName(szFileName) -char * szFileName; -{ - char * pcFileName; - int nFileNameLen; - - nFileNameLen = GetModuleFileName(hInst,szFileName,EXE_NAME_MAX_SIZE); - pcFileName = szFileName + nFileNameLen; - - while (pcFileName > szFileName) { - if (*pcFileName == '\\' || *pcFileName == ':') { - *(++pcFileName) = '\0'; - break; - } - nFileNameLen--; - pcFileName--; - } - - if ((nFileNameLen+13) < EXE_NAME_MAX_SIZE) { - lstrcat(szFileName, "winfract.hlp"); - } - - else { - lstrcat(szFileName, "?"); - } - - return; -} - -int set_win_offset(void) -{ -win_xoffset = (int)(((long)xposition*((long)xdots-(long)xpagesize))/100L); -win_yoffset = (int)(((long)yposition*((long)ydots-(long)ypagesize))/100L); -if (win_xoffset+xpagesize > xdots) win_xoffset = xdots-xpagesize; -if (win_yoffset+ypagesize > ydots) win_yoffset = ydots-ypagesize; -if (xpagesize >= xdots) win_xoffset = 0; -if (ypagesize >= ydots) win_yoffset = 0; -return(0); -} - -void win_savedac(void) -{ - memcpy(olddacbox,dacbox,256*3); /* save the DAC */ - colorpreloaded = 1; /* indicate it needs to be restored */ - -} - -/* - Read a formula file, picking off the formula names. - Formulas use the format " name = { ... } name = { ... } " -*/ - -int get_formula_names(void) /* get the fractal formula names */ -{ - int numformulas, i; - FILE *File; - char msg[81], tempstring[201]; - - FormName[0] = 0; /* start by declaring failure */ - for (i = 0; i < MaxFormNameChoices; i++) { - FormNameChoices[i][0] = 0; - win_choices[i] = FormNameChoices[i]; - } - - if((File = fopen(FormFileName, "rt")) == NULL) { - sprintf("I Can't find %s", FormFileName); - stopmsg(1,msg); - return(-1); - } - - numformulas = 0; - while(fscanf(File, " %20[^ \n\t({]", FormNameChoices[numformulas]) != EOF) { - int c; - - while(c = getc(File)) { - if(c == EOF || c == '{' || c == '\n') - break; - } - if(c == EOF) - break; - else if(c != '\n'){ - numformulas++; - if (numformulas >= MaxFormNameChoices) break; -skipcomments: - if(fscanf(File, "%200[^}]", tempstring) == EOF) break; - if (getc(File) != '}') goto skipcomments; - if (stricmp(FormNameChoices[numformulas-1],"") == 0 || - stricmp(FormNameChoices[numformulas-1],"comment") == 0) - numformulas--; - } - } - fclose(File); - win_numchoices = numformulas; - qsort(FormNameChoices,win_numchoices,25, - (int(*)(const void*, const void *))strcmp); - return(0); -} - -int parse_formula_names(void) /* parse a fractal formula name */ -{ - - lstrcpy(FormName, win_choices[win_choicemade]); - - if (RunForm(FormName, 0)) { - FormName[0] = 0; /* declare failure */ - stopmsg(0,"Can't Parse that Formula"); - return(0); - } - -return(1); -} - -/* --------------------------------------------------------------------- */ - -int get_lsys_name(void) /* get the Lsystem formula name */ -{ - int numentries, i; - FILE *File; - char buf[201]; - long file_offset,name_offset; - - for (i = 0; i < MaxFormNameChoices; i++) { - FormNameChoices[i][0] = 0; - win_choices[i] = FormNameChoices[i]; - } - - if ((File = fopen(LFileName, "rb")) == NULL) { - sprintf(buf,"I Can't find %s", LFileName); - stopmsg(1,buf); - LName[0] = 0; - return(-1); - } - - numentries = 0; - file_offset = -1; - while (1) { - int c,len; - do { - ++file_offset; - c = getc(File); - } while (c == ' ' /* skip white space */ - || c == '\t' || c == '\n' || c == '\r'); - if (c == ';') { - do { - ++file_offset; - c = getc(File); - } while (c != '\n' && c != EOF && c != '\x1a'); - if (c == EOF || c == '\x1a') break; - continue; - } - name_offset = file_offset; - len = 0; /* next equiv roughly to fscanf(..,"%40[^ \n\r\t({\x1a]",buf) */ - while (c != ' ' && c != '\t' && c != '(' - && c != '{' && c != '\n' && c != '\r' && c != EOF && c != '\x1a') { - if (len < 40) buf[len++] = c; - c = getc(File); - ++file_offset; - } - buf[len] = 0; - while (c != '{' && c != '\n' && c != '\r' && c != EOF && c != '\x1a') { - c = getc(File); - ++file_offset; - } - if (c == '{') { - while (c != '}' && c != EOF && c != '\x1a') { - c = getc(File); - ++file_offset; - } - if (c != '}') break; - buf[ITEMNAMELEN] = 0; - if (buf[0] != 0 && lstrcmpi(buf,"comment") != 0) { - lstrcpy(FormNameChoices[numentries],buf); - memcpy((char *)&FormNameChoices[numentries][21], - (char *)&name_offset,4); - if (++numentries >= MaxFormNameChoices) { - sprintf(buf,"Too many entries in file, first %d used", - MaxFormNameChoices); - stopmsg(0,buf); - break; - } - } - } - else - if (c == EOF || c == '\x1a') break; - } - fclose(File); - - win_numchoices = numentries; - qsort(FormNameChoices,win_numchoices,25, - (int(*)(const void *, const void *))strcmp); - return(0); -} - -BOOL cant_clip(void) -{ -MessageBox ( - GetFocus(), - winfract_msg99, - winfract_msg01, - MB_ICONSTOP | MB_OK); - return(TRUE); -} diff --git a/fractint/win/WINSTUBS.C b/fractint/win/WINSTUBS.C deleted file mode 100644 index 58df0e8a2..000000000 --- a/fractint/win/WINSTUBS.C +++ /dev/null @@ -1,178 +0,0 @@ -/* - "Stubbed-Off" Routines and variables - which exist only in Fractint for DOS -*/ - -#include "port.h" -#include "prototyp.h" - -/* not-yet-implemented variables */ - -double sxmin, sxmax, sx3rd, symin, symax, sy3rd; -int color_bright = 15; -int color_medium = 7; -int color_dark = 0; -int hasinverse = 0; -char diskfilename[] = {"FRACTINT.$$$"}; -BYTE *line_buff; -char *fract_dir1=".", *fract_dir2="."; -int Printer_Compress; -int keybuffer; -int LPTnumber; -int ColorPS; -int Print_To_File; -int Printer_Type; -int Printer_CRLF; -int Printer_Resolution; -int Printer_Titleblock; -int Printer_ColorXlat; -int Printer_BAngle; -int Printer_GAngle; -int Printer_SAngle; -int Printer_RAngle; -int Printer_RFrequency; -int Printer_GFrequency; -int Printer_BFrequency; -int Printer_SFrequency; -int Printer_SetScreen; -int Printer_RStyle; -int Printer_GStyle; -int Printer_BStyle; -int Printer_SStyle; -int EPSFileType; -int integerfractal; -int video_type; -int adapter; -int usr_periodicitycheck; -int active_system = WINFRAC; /* running under windows */ -char busy; -int mode7text; -int textsafe; -long calctime; -char stdcalcmode; -int compiled_by_turboc = 0; -int tabmode; -double plotmx1, plotmx2, plotmy1, plotmy2; -int vesa_detect; -long creal, cimag; -int TranspSymmetry; -long fudge; -long l_at_rad; /* finite attractor radius */ -double f_at_rad; /* finite attractor radius */ -int timedsave = 0; -int made_dsktemp = 0; -int reallyega = 0; -int started_resaves = 0; -float viewreduction=1; -int viewxdots=0,viewydots=0; -char usr_floatflag; -int disk16bit = 0; -double potparam[3]; -int gotrealdac = 1; -int svga_type = 0; -int viewcrop = 1; -int viewwindow = 0; - -int video_cutboth = 0; /* nonzero to keep virtual aspect */ -int zscroll = 0; /* screen/zoombox 0 fixed, 1 relaxed */ -int video_startx = 0; -int video_starty = 0; -int vesa_xres = 0; -int vesa_yres = 0; -int video_vram = 0; -int virtual_screens = 0; -int istruecolor = 0; -int video_scroll = 0; - -int fm_attack; -int fm_decay; -int fm_sustain; -int fm_release; -int fm_vol; -int fm_wavetype; -int polyphony; -int hi_atten; - -U16 evolve_handle = 0; -int disktarga = 0; - -int boxcolor; -int chkd_vvs = 0; - -int max_colors; /* maximum palette size */ -int zoomoff; /* = 0 when zoom is disabled */ -int savedac; /* save-the-Video DAC flag */ -int browsing; /* browse mode flag */ -char file_name_stack[16][13]; /* array of file names used while browsing */ -int name_stack_ptr ; -double toosmall; -int minbox; -int no_sub_images; -int autobrowse,doublecaution; -char brwscheckparms,brwschecktype; -char browsemask[13]; -int scale_map[12] = {1,2,3,4,5,6,7,8,9,10,11,12}; /*RB, array for mapping notes to a (user defined) scale */ - -/* fake/not-yet-implemented subroutines */ - -void rotate(int x) {} -void find_special_colors(void) {} -int spawnl(int dummy1, char *dummy2, char *dummy3) {return 0;} -int showtempmsg(char *foo) {return 1;} -void cleartempmsg(void) {} -void freetempmsg(void) {} -int FromMemDisk(long offset, int size, void *src) {return 0;} -int ToMemDisk(long offset, int size, void *src) {return 0;} -int common_startdisk(long newrowsize, long newcolsize, int colors) {return 0;} -long cdecl normalize(char *foo) {return 0;} -void drawbox(int foo) {} - -void farmessage(unsigned char *foo) {} -void setvideomode(int foo1, int foo2, int foo3, int foo4) {} -int fromvideotable(void) {return 0;} -void home(void) {} - -int intro_overlay(void) {return 0;} -int rotate_overlay(void) {return 0;} -int printer_overlay(void) {return 0;} -int pot_startdisk(void) {return 0;} -//void SetTgaColors(void) {} -int startdisk(void) {return 0;} -void enddisk(void) {} -int readdisk(unsigned int foo1,unsigned int foo2) {return 0;} -void writedisk(unsigned int foo1,unsigned int foo2,unsigned int foo3) {} -int targa_startdisk(FILE *foo1,int foo2){return 0;} -void targa_writedisk(unsigned int foo1,unsigned int foo2,BYTE foo3,BYTE foo4,BYTE foo5){} -void targa_readdisk(unsigned int foo1,unsigned int foo2,BYTE *foo3,BYTE *foo4,BYTE *foo5){} -BYTE *findfont(int foo1) {return(0);} -long cdecl readticker(void){return(0);} -void EndTGA(void){} - -int key_count(int keynum) {return 0;} - -void dispbox(void) {} -void clearbox(void) {} -void _fastcall addbox(struct coords point) {} -void _fastcall drawlines(struct coords fr, struct coords to, int dx, int dy) {} -int showvidlength(void) {return 0;} - -/* sound.c file prototypes */ -int get_sound_params(void) {return(0);} - -int soundon(int i) {return(0);} - -void soundoff(void) {} - -int initfm(void) {return(0);} - -void mute(void) {} - -void dvid_status(int foo1, char *foo2){} -int tovideotable(void){return 0;} - -void TranspPerPixel(void){} - -void stopslideshow(void) {} -void aspectratio_crop(float foo1, float foo2) {} -void setvideotext(void) {} -int load_fractint_cfg(int foo1) {return 0;} diff --git a/fractint/win/WINTEXT.C b/fractint/win/WINTEXT.C deleted file mode 100644 index 7df448e13..000000000 --- a/fractint/win/WINTEXT.C +++ /dev/null @@ -1,770 +0,0 @@ - -#define STRICT - -#include -#include -#include - -/* - WINTEXT.C handles the character-based "prompt screens", - using a 24x80 character-window driver that I wrote originally - for the Windows port of the DOS-based "Screen Generator" - commercial package - Bert Tyler - - the subroutines and their functions are: - -BOOL wintext_initialize(HANDLE hInstance, LPSTR title); - Registers and initializes the text window - must be called - once (and only once). Its parameters are the handle of the application - instance and a pointer to a string containing the title of the window. -void wintext_destroy(); - Destroys items like bitmaps that the initialization routine has - created. Should be called once (and only once) as your program exits. - -int wintext_texton(); - Brings up and blanks out the text window. No parameters. -int wintext_textoff(); - Removes the text window. No parameters. - -void wintext_putstring(int xpos, int ypos, int attrib, char *string); - Sends a character string to the screen starting at (xpos, ypos) - using the (CGA-style and, yes, it should be a 'char') specified attribute. -void wintext_paintscreen(int xmin, int xmax, int ymin, int ymax); - Repaints the rectangular portion of the text screen specified by - the four parameters, which are in character co-ordinates. This - routine is called automatically by 'wintext_putstring()' as well as - other internal routines whenever Windows uncovers the window. It can - also be called manually by your program when it wants a portion - of the screen updated (the actual data is kept in two arrays, which - your program has presumably updated:) - unsigned char wintext_chars[25][80] holds the text - unsigned char wintext_attrs[25][80] holds the (CGA-style) attributes - -void wintext_cursor(int xpos, int ypos, int cursor_type); - Sets the cursor to character position (xpos, ypos) and switches to - a cursor type specified by 'cursor_type': 0 = none, 1 = underline, - 2 = block cursor. A cursor type of -1 means use whatever cursor - type (0, 1, or 2) was already active. - -unsigned int wintext_getkeypress(int option); - A simple keypress-retriever that, based on the parameter, either checks - for any keypress activity (option = 0) or waits for a keypress before - returning (option != 0). Returns a 0 to indicate no keystroke, or the - keystroke itself. Up to 80 keystrokes are queued in an internal buffer. - If the text window is not open, returns an ESCAPE keystroke (27). - The keystroke is returned as an integer value identical to that a - DOS program receives in AX when it invokes INT 16H, AX = 0 or 1. - -int wintext_look_for_activity(int option); - An internal routine that handles buffered keystrokes and lets - Windows messaging (multitasking) take place. Called with option=0, - it returns without waiting for the presence of a keystroke. Called - with option !=0, it waits for a keystroke before returning. Returns - 1 if a keystroke is pending, 0 if none pending. Called internally - (and automatically) by 'wintext_getkeypress()'. -void wintext_addkeypress(unsigned int); - An internal routine, called by 'wintext_look_for_activity()' and - 'wintext_proc()', that adds keystrokes to an internal buffer. - Never called directly by the applications program. -long FAR PASCAL wintext_proc(HANDLE, UINT, WPARAM, LPARAM); - An internal routine that handles all message functions while - the text window is on the screen. Never called directly by - the applications program, but must be referenced as a call-back - routine by your ".DEF" file. - - The 'wintext_textmode' flag tracks the current textmode status. - Note that pressing Alt-F4 closes and destroys the window *and* - resets this flag (to 1), so the main program should look at - this flag whenever it is possible that Alt-F4 has been hit! - ('wintext_getkeypress()' returns a 27 (ESCAPE) if this happens) - (Note that you can use an 'WM_CLOSE' case to handle this situation.) - The 'wintext_textmode' values are: - 0 = the initialization routine has never been called! - 1 = text mode is *not* active - 2 = text mode *is* active - There is also a 'wintext_AltF4hit' flag that is non-zero if - the window has been closed (by an Alt-F4, or a WM_CLOSE sequence) - but the application program hasn't officially closed the window yet. -*/ - -int wintext_textmode = 0; -int wintext_AltF4hit = 0; - -/* function prototypes */ - -BOOL wintext_initialize(HANDLE, HWND, LPSTR); -void wintext_destroy(void); -long FAR PASCAL wintext_proc(HWND, UINT, WPARAM, LPARAM); -int wintext_texton(void); -int wintext_textoff(void); -void wintext_putstring(int, int, int, char *); -void wintext_paintscreen(int, int, int, int); -void wintext_cursor(int, int, int); -int wintext_look_for_activity(int); -void wintext_addkeypress(unsigned int); -unsigned int wintext_getkeypress(int); - -/* Local copy of the "screen" characters and attributes */ - -unsigned char wintext_chars[25][80]; -unsigned char wintext_attrs[25][80]; -int wintext_buffer_init; /* zero if 'screen' is uninitialized */ - -/* font information */ - -HFONT wintext_hFont; -int wintext_char_font; -int wintext_char_width; -int wintext_char_height; -int wintext_char_xchars; -int wintext_char_ychars; -int wintext_max_width; -int wintext_max_height; - -/* "cursor" variables (AKA the "caret" in Window-Speak) */ -int wintext_cursor_x; -int wintext_cursor_y; -int wintext_cursor_type; -int wintext_cursor_owned; -HBITMAP wintext_bitmap[3]; -short wintext_cursor_pattern[3][40]; - -LPSTR wintext_title_text; /* title-bar text */ - -/* a few Windows variables we need to remember globally */ - -HWND wintext_hWndCopy; /* a Global copy of hWnd */ -HWND wintext_hWndParent; /* a Global copy of hWnd's Parent */ -HANDLE wintext_hInstance; /* a global copy of hInstance */ - -/* the keypress buffer */ - -#define BUFMAX 80 -unsigned int wintext_keypress_count; -unsigned int wintext_keypress_head; -unsigned int wintext_keypress_tail; -unsigned char wintext_keypress_initstate; -unsigned int wintext_keypress_buffer[BUFMAX]; -unsigned char wintext_keypress_state[BUFMAX]; - -/* EGA/VGA 16-color palette (which doesn't match Windows palette exactly) */ -/* -COLORREF wintext_color[] = { - RGB(0,0,0), - RGB(0,0,168), - RGB(0,168,0), - RGB(0,168,168), - RGB(168,0,0), - RGB(168,0,168), - RGB(168,84,0), - RGB(168,168,168), - RGB(84,84,84), - RGB(84,84,255), - RGB(84,255,84), - RGB(84,255,255), - RGB(255,84,84), - RGB(255,84,255), - RGB(255,255,84), - RGB(255,255,255) - }; -*/ -/* 16-color Windows Palette */ - -COLORREF wintext_color[] = { - RGB(0,0,0), - RGB(0,0,128), - RGB(0,128,0), - RGB(0,128,128), - RGB(128,0,0), - RGB(128,0,128), - RGB(128,128,0), - RGB(192,192,192), -/* RGB(128,128,128), This looks lousy - make it black */ RGB(0,0,0), - RGB(0,0,255), - RGB(0,255,0), - RGB(0,255,255), - RGB(255,0,0), - RGB(255,0,255), - RGB(255,255,0), - RGB(255,255,255) - }; - -/* - Register the text window - a one-time function which perfomrs - all of the neccessary registration and initialization -*/ - -BOOL wintext_initialize(HANDLE hInstance, HWND hWndParent, LPSTR titletext) -{ - WNDCLASS wc; - BOOL return_value; - HDC hDC; - HFONT hOldFont; - TEXTMETRIC TextMetric; - int i, j; - - wintext_hInstance = hInstance; - wintext_title_text = titletext; - wintext_hWndParent = hWndParent; - - wc.style = NULL; - wc.lpfnWndProc = wintext_proc; - wc.cbClsExtra = 0; - wc.cbWndExtra = 0; - wc.hInstance = hInstance; - wc.hIcon = NULL; - wc.hCursor = LoadCursor(NULL, IDC_ARROW); - wc.hbrBackground = GetStockObject(BLACK_BRUSH); - wc.lpszMenuName = titletext; - wc.lpszClassName = "FractintForWindowsV0011"; - - return_value = RegisterClass(&wc); - - /* set up the font characteristics */ - wintext_char_font = OEM_FIXED_FONT; - wintext_hFont = GetStockObject(wintext_char_font); - hDC=GetDC(hWndParent); - hOldFont = SelectObject(hDC, wintext_hFont); - GetTextMetrics(hDC, &TextMetric); - SelectObject(hDC, hOldFont); - ReleaseDC(hWndParent, hDC); - wintext_char_width = TextMetric.tmMaxCharWidth; - wintext_char_height = TextMetric.tmHeight; - wintext_char_xchars = 80; - wintext_char_ychars = 25; - - wintext_max_width = /* maximum screen width */ - wintext_char_xchars*wintext_char_width+ - (GetSystemMetrics(SM_CXFRAME) * 2); - wintext_max_height = /* maximum screen height */ - wintext_char_ychars*wintext_char_height+ - (GetSystemMetrics(SM_CYFRAME) * 2) - -1 - + GetSystemMetrics(SM_CYCAPTION); - - /* set up the font and caret information */ - for (i = 0; i < 3; i++) - for (j = 0; j < wintext_char_height; j++) - wintext_cursor_pattern[i][j] = 0; - for (j = wintext_char_height-2; j < wintext_char_height; j++) - wintext_cursor_pattern[1][j] = 0x00ff; - for (j = 0; j < wintext_char_height; j++) - wintext_cursor_pattern[2][j] = 0x00ff; - wintext_bitmap[0] = CreateBitmap(8, wintext_char_height, 1, 1, - (LPSTR)wintext_cursor_pattern[0]); - wintext_bitmap[1] = CreateBitmap(8, wintext_char_height, 1, 1, - (LPSTR)wintext_cursor_pattern[1]); - wintext_bitmap[2] = CreateBitmap(8, wintext_char_height, 1, 1, - (LPSTR)wintext_cursor_pattern[2]); - - wintext_textmode = 1; - wintext_AltF4hit = 0; - - return(return_value); -} - -/* - clean-up routine -*/ -void wintext_destroy(void) -{ -int i; - - if (wintext_textmode == 2) /* text is still active! */ - wintext_textoff(); - if (wintext_textmode != 1) /* not in the right mode */ - return; - -/* - DeleteObject((HANDLE)wintext_hFont); -*/ - for (i = 0; i < 3; i++) - DeleteObject((HANDLE)wintext_bitmap[i]); - wintext_textmode = 0; - wintext_AltF4hit = 0; -} - - -/* - Set up the text window and clear it -*/ - -int wintext_texton(void) -{ - HWND hWnd; - - if (wintext_textmode != 1) /* not in the right mode */ - return(0); - - /* initialize the cursor */ - wintext_cursor_x = 0; - wintext_cursor_y = 0; - wintext_cursor_type = 0; - wintext_cursor_owned = 0; - - /* clear the keyboard buffer */ - wintext_keypress_count = 0; - wintext_keypress_head = 0; - wintext_keypress_tail = 0; - wintext_keypress_initstate = 0; - wintext_buffer_init = 0; - - hWnd = CreateWindow( - "FractintForWindowsV0011", - wintext_title_text, - WS_OVERLAPPEDWINDOW, - CW_USEDEFAULT, /* default horizontal position */ - CW_USEDEFAULT, /* default vertical position */ - wintext_max_width, - wintext_max_height, - wintext_hWndParent, - NULL, - wintext_hInstance, - NULL); - - /* squirrel away a global copy of 'hWnd' for later */ - wintext_hWndCopy = hWnd; - - wintext_textmode = 2; - wintext_AltF4hit = 0; - - ShowWindow(wintext_hWndCopy, SW_SHOWNORMAL); - UpdateWindow(wintext_hWndCopy); - - InvalidateRect(wintext_hWndCopy,NULL,FALSE); - - return(0); -} - -/* - Remove the text window -*/ - -int wintext_textoff(void) -{ - - wintext_AltF4hit = 0; - if (wintext_textmode != 2) /* not in the right mode */ - return(0); - DestroyWindow(wintext_hWndCopy); - wintext_textmode = 1; - return(0); -} - -/* - Window-handling procedure -*/ - - -long FAR PASCAL wintext_proc(hWnd, message, wParam, lParam) -HWND hWnd; -UINT message; -WPARAM wParam; -LPARAM lParam; -{ - RECT tempRect; - PAINTSTRUCT ps; - HDC hDC; - - if (hWnd != wintext_hWndCopy) /* ??? not the text-mode window! */ - return (DefWindowProc(hWnd, message, wParam, lParam)); - - switch (message) { - - case WM_INITMENU: - /* first time through*/ - /* someday we might want to do something special here */ - return (TRUE); - - case WM_COMMAND: - /* if we added menu items, they would go here */ - return (DefWindowProc(hWnd, message, wParam, lParam)); - - case WM_CLOSE: - wintext_textmode = 1; - wintext_AltF4hit = 1; - return (DefWindowProc(hWnd, message, wParam, lParam)); - - case WM_SIZE: - /* code to prevent the window from exceeding a "full text page" */ - if (LOWORD(lParam) > (WORD)wintext_max_width || - HIWORD(lParam) > (WORD)wintext_max_height) - SetWindowPos(wintext_hWndCopy, - GetNextWindow(wintext_hWndCopy, GW_HWNDPREV), - 0, 0, wintext_max_width, wintext_max_height, SWP_NOMOVE); - break; - - case WM_SETFOCUS : /* get focus - display caret */ - /* create caret & display */ - wintext_cursor_owned = 1; - CreateCaret( wintext_hWndCopy, wintext_bitmap[wintext_cursor_type], - wintext_char_width, wintext_char_height); - SetCaretPos( wintext_cursor_x*wintext_char_width, - wintext_cursor_y*wintext_char_height); - SetCaretBlinkTime(500); - ShowCaret( wintext_hWndCopy ); - break; - - case WM_KILLFOCUS : /* kill focus - hide caret */ - wintext_cursor_owned = 0; - DestroyCaret(); - break; - - case WM_PAINT: /* "Paint" routine - call the worker routine */ - hDC = BeginPaint(hWnd, &ps); - GetUpdateRect(hWnd, &tempRect, FALSE); - ValidateRect(hWnd, &tempRect); - /* the routine below handles *all* window updates */ - wintext_paintscreen(0, wintext_char_xchars-1, 0, wintext_char_ychars-1); - EndPaint(hWnd, &ps); - break; - - case WM_KEYDOWN: /* KEYUP, KEYDOWN, and CHAR msgs go to the 'keypressed' code */ - /* a key has been pressed - maybe ASCII, maybe not */ - /* if it's an ASCII key, 'WM_CHAR' will handle it */ - { - unsigned int i, j, k; - i = (MapVirtualKey(wParam,0)); - j = (MapVirtualKey(wParam,2)); - k = (i << 8) + j; - if (wParam == 0x10 || wParam == 0x11) { /* shift or ctl key */ - j = 0; /* send flag: special key down */ - k = 0xff00 + wParam; - } - if (j == 0) /* use this call only for non-ASCII keys */ - wintext_addkeypress(k); - } - break; - - case WM_KEYUP: /* KEYUP, KEYDOWN, and CHAR msgs go to the SG code */ - /* a key has been released - maybe ASCII, maybe not */ - /* Watch for Shift, Ctl keys */ - { - unsigned int i, j, k; - i = (MapVirtualKey(wParam,0)); - j = (MapVirtualKey(wParam,2)); - k = (i << 8) + j; - j = 1; - if (wParam == 0x10 || wParam == 0x11) { /* shift or ctl key */ - j = 0; /* send flag: special key up */ - k = 0xfe00 + wParam; - } - if (j == 0) /* use this call only for non-ASCII keys */ - wintext_addkeypress(k); - } - break; - - case WM_CHAR: /* KEYUP, KEYDOWN, and CHAR msgs go to the SG code */ - /* an ASCII key has been pressed */ - { - unsigned int i, j, k; - i = (unsigned int)((lParam & 0x00ff0000) >> 16); - j = wParam; - k = (i << 8) + j; - wintext_addkeypress(k); - } - break; - - default: - return (DefWindowProc(hWnd, message, wParam, lParam)); - } - return (NULL); -} - -/* - simple keyboard logic capable of handling 80 - typed-ahead keyboard characters (more, if BUFMAX is changed) - wintext_addkeypress() inserts a new keypress - wintext_getkeypress(0) returns keypress-available info - wintext_getkeypress(1) takes away the oldest keypress -*/ - -void wintext_addkeypress(unsigned int keypress) -{ - if (wintext_textmode != 2) /* not in the right mode */ - { - return; - } - - if (wintext_keypress_count >= BUFMAX) - /* no room */ - return; - - if ((keypress & 0xfe00) == 0xfe00) - { - if (keypress == 0xff10) wintext_keypress_initstate |= 0x01; - if (keypress == 0xfe10) wintext_keypress_initstate &= 0xfe; - if (keypress == 0xff11) wintext_keypress_initstate |= 0x02; - if (keypress == 0xfe11) wintext_keypress_initstate &= 0xfd; - return; - } - - if (wintext_keypress_initstate != 0) /* shift/ctl key down */ - { - if ((wintext_keypress_initstate & 1) != 0) /* shift key down */ - { - if ((keypress & 0x00ff) == 9) /* TAB key down */ - { - keypress = (15 << 8); /* convert to shift-tab */ - } - if ((keypress & 0x00ff) == 0) /* special character */ - { - int i; - i = (keypress >> 8) & 0xff; - if (i >= 59 && i <= 68) /* F1 thru F10 */ - { - keypress = ((i + 25) << 8); /* convert to Shifted-Fn */ - } - } - } - else - { /* control key down */ - if ((keypress & 0x00ff) == 0) - { /* special character */ - int i; - i = ((keypress & 0xff00) >> 8); - if (i >= 59 && i <= 68) /* F1 thru F10 */ - { - keypress = ((i + 35) << 8); /* convert to Ctl-Fn */ - } - if (i == 71) - { - keypress = (119 << 8); - } - if (i == 73) - { - keypress = (unsigned int)(132 << 8); - } - if (i == 75) - { - keypress = (115 << 8); - } - if (i == 77) - { - keypress = (116 << 8); - } - if (i == 79) - { - keypress = (117 << 8); - } - if (i == 81) - { - keypress = (118 << 8); - } - } - } - } - -wintext_keypress_buffer[wintext_keypress_head] = keypress; -wintext_keypress_state[wintext_keypress_head] = wintext_keypress_initstate; -if (++wintext_keypress_head >= BUFMAX) - wintext_keypress_head = 0; -wintext_keypress_count++; -} - -unsigned int wintext_getkeypress(int option) -{ -int i; - -wintext_look_for_activity(option); - -if (wintext_textmode != 2) /* not in the right mode */ - return(27); - -if (wintext_keypress_count == 0) - return(0); - -i = wintext_keypress_buffer[wintext_keypress_tail]; - -if (option != 0) { - if (++wintext_keypress_tail >= BUFMAX) - wintext_keypress_tail = 0; - wintext_keypress_count--; - } - -return(i); - -} - - -/* - simple event-handler and look-for-keyboard-activity process - - called with parameter: - 0 = tell me if a key was pressed - 1 = wait for a keypress - returns: - 0 = no activity - 1 = key pressed -*/ - -int wintext_look_for_activity(int wintext_waitflag) -{ -MSG msg; - -if (wintext_textmode != 2) /* not in the right mode */ - return(0); - -for (;;) { - if (PeekMessage(&msg, NULL, NULL, NULL, PM_NOREMOVE) == 0) - if (wintext_waitflag == 0 || wintext_keypress_count != 0 - || wintext_textmode != 2) - return(wintext_keypress_count == 0 ? 0 : 1); - - if (GetMessage(&msg, NULL, NULL, NULL)) { - TranslateMessage(&msg); - DispatchMessage(&msg); - } - } - -return(wintext_keypress_count == 0 ? 0 : 1); - -} - -/* - general routine to send a string to the screen -*/ - -void wintext_putstring(int xpos, int ypos, int attrib, char *string) -{ - int i, j, k, maxrow, maxcol; - char xc, xa; - - xa = (attrib & 0x0ff); - j = maxrow = ypos; - k = maxcol = xpos-1; - - for (i = 0; (xc = string[i]) != 0; i++) { - if (xc == 13 || xc == 10) { - if (j < 24) j++; - k = -1; - } - else { - if ((++k) >= 80) { - if (j < 24) j++; - k = 0; - } - if (maxrow < j) maxrow = j; - if (maxcol < k) maxcol = k; - wintext_chars[j][k] = xc; - wintext_attrs[j][k] = xa; - } - } - if (i > 0) { - wintext_paintscreen(xpos, maxcol, ypos, maxrow); - } -} - -/* - general routine to repaint the screen -*/ - -void wintext_paintscreen( - int xmin, /* update this rectangular section */ - int xmax, /* of the 'screen' */ - int ymin, - int ymax) -{ -int i, j, k; -int istart, jstart, length, foreground, background; -unsigned char wintext_oldbk; -unsigned char wintext_oldfg; -HDC hDC; - -if (wintext_textmode != 2) /* not in the right mode */ - return; - -/* first time through? Initialize the 'screen' */ -if (wintext_buffer_init == 0) { - wintext_buffer_init = 1; - wintext_oldbk = 0x00; - wintext_oldfg = 0x0f; - k = (wintext_oldbk << 4) + wintext_oldfg; - wintext_buffer_init = 1; - for (i = 0; i < wintext_char_xchars; i++) { - for (j = 0; j < wintext_char_ychars; j++) { - wintext_chars[j][i] = ' '; - wintext_attrs[j][i] = k; - } - } - } - -if (xmin < 0) xmin = 0; -if (xmax >= wintext_char_xchars) xmax = wintext_char_xchars-1; -if (ymin < 0) ymin = 0; -if (ymax >= wintext_char_ychars) ymax = wintext_char_ychars-1; - -hDC=GetDC(wintext_hWndCopy); -SelectObject(hDC, wintext_hFont); -SetBkMode(hDC, OPAQUE); -SetTextAlign(hDC, TA_LEFT | TA_TOP); - -if (wintext_cursor_owned != 0) - HideCaret( wintext_hWndCopy ); - -/* - the following convoluted code minimizes the number of - discrete calls to the Windows interface by locating - 'strings' of screen locations with common foreground - and background colors -*/ - -for (j = ymin; j <= ymax; j++) { - length = 0; - wintext_oldbk = 99; - wintext_oldfg = 99; - for (i = xmin; i <= xmax+1; i++) { - k = -1; - if (i <= xmax) - k = wintext_attrs[j][i]; - foreground = (k & 15); - background = (k >> 4); - if (i > xmax || foreground != (int)wintext_oldfg || background != (int)wintext_oldbk) { - if (length > 0) { - SetBkColor(hDC,wintext_color[wintext_oldbk]); - SetTextColor(hDC,wintext_color[wintext_oldfg]); - TextOut(hDC, - istart*wintext_char_width, - jstart*wintext_char_height, - &wintext_chars[jstart][istart], - length); - } - wintext_oldbk = background; - wintext_oldfg = foreground; - istart = i; - jstart = j; - length = 0; - } - length++; - } - } - -if (wintext_cursor_owned != 0) - ShowCaret( wintext_hWndCopy ); - -ReleaseDC(wintext_hWndCopy,hDC); - -} - -void wintext_cursor(int xpos, int ypos, int cursor_type) -{ - -if (wintext_textmode != 2) /* not in the right mode */ - return; - - wintext_cursor_x = xpos; - wintext_cursor_y = ypos; - if (cursor_type >= 0) wintext_cursor_type = cursor_type; - if (wintext_cursor_type < 0) wintext_cursor_type = 0; - if (wintext_cursor_type > 2) wintext_cursor_type = 2; - if (wintext_cursor_owned != 0) - { - CreateCaret( wintext_hWndCopy, wintext_bitmap[wintext_cursor_type], - wintext_char_width, wintext_char_height); - SetCaretPos( wintext_cursor_x*wintext_char_width, - wintext_cursor_y*wintext_char_height); - SetCaretBlinkTime(500); - ShowCaret( wintext_hWndCopy ); - } - -}