home *** CD-ROM | disk | FTP | other *** search
/ Fractal Frenzy 1 / WalnutCreekFractalFrenzy-1.iso / pc / programs / frasrc.exe / PROMPTS2.C < prev    next >
C/C++ Source or Header  |  1993-08-18  |  51KB  |  1,795 lines

  1. /*
  2.     Various routines that prompt for things.
  3.     This module is linked as an overlay, use ENTER_OVLY and EXIT_OVLY.
  4. */
  5.  
  6. #include <stdlib.h>
  7. #include <stdio.h>
  8. #include <string.h>
  9. #include <ctype.h>
  10. #ifndef XFRACT
  11. #include <dos.h>
  12. #elif !defined(__386BSD__)
  13. #include <sys/types.h>
  14. #include <sys/stat.h>
  15. #include <sys/dir.h>
  16. #endif
  17. #ifdef __TURBOC__
  18. #include <alloc.h>
  19. #elif !defined(__386BSD__)
  20. #include <malloc.h>
  21. #endif
  22.  
  23. #ifdef __hpux
  24. #include <sys/param.h>
  25. #define getwd(a) getcwd(a,MAXPATHLEN)
  26. #endif
  27.  
  28. #include "fractint.h"
  29. #include "fractype.h"
  30. #include "helpdefs.h"
  31. #include "prototyp.h"
  32.  
  33. /* Routines defined in prompts1.c */
  34.  
  35. extern    int prompt_checkkey(int curkey);
  36. extern    long get_file_entry(int,char *,char *,char *,char *);
  37.  
  38. /* Routines used in prompts1.c */
  39.  
  40.     int get_corners(void);
  41.     int edit_ifs_params(void );
  42.     int lccompare(VOIDCONSTPTR, VOIDCONSTPTR); /* Needed in prompts1.c PAV */
  43.  
  44. /* Routines in this module    */
  45.  
  46. static    int findfirst(char *path);
  47. static  int check_f6_key(int curkey,int choice);
  48. static    int findnext(void );
  49.     int splitpath(char *template,char *drive,char *dir,char *fname,char *ext);
  50.         int makepath(char *template,char *drive,char *dir,char *fname,char *ext);
  51. static    void fix_dirname(char *dirname);
  52. static    int expand_dirname(char *dirname,char *drive);
  53. static    int filename_speedstr(int, int, int, char *, int);
  54. static    int isadirectory(char *s);
  55. static  int check_f6_key(int curkey,int choice);
  56.  
  57. extern int dotmode;
  58. extern int orbit_delay;
  59. extern char diskfilename[];
  60.  
  61. extern char *fract_dir1, *fract_dir2;
  62.  
  63. #ifndef XFRACT
  64. extern int strncasecmp(char *s,char *t,int ct);
  65. #endif
  66.  
  67. extern char temp1[256];   /* temporary strings          */
  68.  
  69. extern    double    xxmin,xxmax;    /* initial corner values    */
  70. extern    double    yymin,yymax;    /* initial corner values    */
  71. extern    BYTE usemag;
  72.  
  73. extern    int AntiAliasing;
  74. extern double zzmin, zzmax, ttmin, ttmax;
  75. extern int Transparent3D;
  76.  
  77. extern    double    xx3rd,yy3rd;    /* initial corner values    */
  78. extern    int    invert;     /* non-zero if inversion active */
  79. extern    double    inversion[3];    /* radius, xcenter, ycenter */
  80. extern    int    pot16bit;
  81. extern    int    disk16bit;
  82. extern    double    potparam[3];    /* three potential parameters*/
  83. extern    int    fractype;    /* if == 0, use Mandelbrot  */
  84. extern    char    usr_floatflag;    /* floating-point fractals? */
  85. extern    int    maxit;        /* try this many iterations */
  86. extern    int    inside;     /* inside color */
  87. extern    int    fillcolor;     /* fill color */
  88. extern    int    outside;    /* outside color */
  89. extern    int    finattract;    /* finite attractor switch */
  90. extern    char    savename[80];    /* save files using this name */
  91. extern    int    decomp[];    /* decomposition parameters */
  92. extern    int    usr_distest;    /* distance estimator option */
  93. extern    int    distestwidth;
  94. extern    char    usr_stdcalcmode; /* '1', '2', 'g', 'b' */
  95. extern    char    overwrite;     /* overwrite= flag */
  96. extern    int    soundflag;    /* sound option */
  97. extern    int    LogFlag;    /* non-zero if logarithmic palettes */
  98. extern    int    usr_biomorph;    /* Biomorph flag */
  99. #if 0
  100. //extern    long    xmin, xmax, ymin, ymax; /* screen corner values */
  101. #endif
  102. extern    int    xdots, ydots;    /* coordinates of dots on the screen  */
  103. extern    int    colors;     /* maximum colors available */
  104. extern    int    row, col;
  105. extern    int    viewwindow;
  106. extern    float    viewreduction;
  107. extern    int    viewcrop;
  108. extern    float    finalaspectratio;
  109. extern    int    viewxdots,viewydots;
  110. extern    int    textcbase;
  111. extern    int    textrow,textcol;
  112. extern    int    resave_flag;    /* resaving after a timed save */
  113. extern    int    started_resaves;
  114. extern    char    boxy[];
  115. extern    int    rotate_lo,rotate_hi;
  116. extern    int    rangeslen;
  117. extern float  screenaspect;
  118.  
  119. extern  int  cmdarg(char *,int);
  120.  
  121. extern char CommandFile[];
  122. extern char CommandName[];
  123. extern float far *ifs_defn;
  124. extern int ifs_type;
  125. extern int ifs_changed;
  126. extern int initbatch;        /* 1 if batch run (no kbd)  */
  127.  
  128. /* speed key state values */
  129. #define MATCHING     0    /* string matches list - speed key mode */
  130. #define TEMPLATE    -2    /* wild cards present - buiding template */
  131. #define SEARCHPATH    -3    /* no match - building path search name */
  132.  
  133. #define   FILEATTR     0x37       /* File attributes; select all but volume labels */
  134. #define   HIDDEN     2
  135. #define   SYSTEM     4
  136. #define   SUBDIR     16
  137. #define   MAXNUMFILES     300
  138.  
  139. struct                   /* Allocate DTA and define structure */
  140. {
  141.      char path[21];            /* DOS path and filespec */
  142.      char attribute;            /* File attributes wanted */
  143.      int  ftime;            /* File creation time */
  144.      int  fdate;            /* File creation date */
  145.      long size;             /* File size in bytes */
  146.      char filename[13];         /* Filename and extension */
  147. } DTA;                   /* Disk Transfer Area */
  148.  
  149. #define GETFORMULA 0
  150. #define GETLSYS    1
  151. #define GETIFS       2
  152. #define GETPARM    3
  153.  
  154. /* --------------------------------------------------------------------- */
  155. extern char s_iter[];
  156. extern char s_real[];
  157. extern char s_mult[];
  158. extern char s_sum[];
  159. extern char s_imag[];
  160. extern char s_zmag[];
  161. extern char s_bof60[];
  162. extern char s_bof61[];
  163. extern char s_maxiter[];
  164. extern char s_epscross[];
  165. extern char s_startrail[];
  166. extern char s_normal[];
  167. extern char s_period[];
  168.  
  169. char commandmask[13] = {"*.par"};
  170.  
  171. void prompts2_overlay() { }    /* for restore_active_ovly */
  172.  
  173. #if 0
  174. /* --------------------------------------------------------------------- */
  175.  
  176. extern int promptfkeys;
  177.  
  178. int edit_ifs_params()    /* prompt for IFS params */
  179. {
  180.    int totcols;
  181.    int i, j, k, numlines, ret;
  182.    FILE *tempfile;
  183.    char msg[81];
  184.    char filename[81];
  185.    float ftemp;
  186.    int oldhelpmode;
  187.    int low, hi;
  188.  
  189.    if (!ifs_defn && !ifsload())
  190.       return(-1);
  191.  
  192.    totcols = (ifs_type == 0) ? IFSPARM : IFS3DPARM;
  193.    ret = 0;
  194.    oldhelpmode = helpmode;
  195.    helpmode = HT_IFS;
  196.  
  197.    low = 0;
  198.  
  199.    for ( ;; ) {
  200. static char far ifshdg2[]={"2D IFS Parameters"};
  201. static char far ifshdg3[]={"3D IFS Parameters"};
  202. static char far ifsparmmsg1[]={"#    a     b     c     d     e     f"};
  203. static char far ifsparmmsg2[]={"     g     h     i     j     k     l"};
  204. static char far ifsprompt[]={"\
  205. Enter the number of the line you want to edit,\n\
  206. S to save, F6 for corners, or ENTER to end ==>"};
  207.       int leftcol,promptrow,promptcol;
  208. #define IFS_NUM 12
  209.  
  210.       for (numlines = 0; numlines < NUMIFS; numlines++) /* find the first zero entry */
  211.      if (ifs_defn[(numlines * totcols) + totcols - 1] <= 0.0001) break;
  212.  
  213.       helptitle();
  214.       setattr(1,0,C_PROMPT_BKGRD,24*80); /* init rest of screen to background */
  215.       putstringcenter(2,0,80,C_GENERAL_HI,(ifs_type == 0) ? ifshdg2 : ifshdg3);
  216.       leftcol = (ifs_type == 0) ? 15 : 0;
  217.       putstring(4,leftcol+1,C_GENERAL_HI,ifsparmmsg1);
  218.       if (ifs_type != 0)
  219.      putstring(-1,-1,C_GENERAL_HI,ifsparmmsg2);
  220.       putstring(-1,-1,C_GENERAL_HI,"   prob \n\n");
  221.  
  222.       hi = low+IFS_NUM;
  223.       if (hi>numlines) hi = numlines;
  224.       for (i = low; i < hi; i++) {
  225.      sprintf(msg,"%2d", i+1);
  226.      putstring(5+i-low,leftcol,C_GENERAL_HI,msg);
  227.      for (j = 0; j < totcols; j++) {
  228.         sprintf(msg,"%6.2f",ifs_defn[(i*totcols)+j]);
  229.         putstring(-1,-1,C_GENERAL_MED,msg);
  230.         }
  231.      }
  232.       if (hi<numlines) {
  233.      putstring(5+IFS_NUM,leftcol,C_GENERAL_HI,"(more)");
  234.       }
  235.  
  236.       textcbase = 14;
  237.       putstring(5+i-low+1,0,C_GENERAL_HI,ifsprompt);
  238.       promptrow = textrow;
  239.       promptcol = textcol + textcbase + 1;
  240.       temp1[0] = textcbase = 0;
  241.       promptfkeys = 1<<6;
  242.       i = input_field(0,C_GENERAL_INPUT,temp1,2,promptrow,promptcol,
  243.           prompt_checkkey);
  244.       if (i<0) {
  245.       break;
  246.       } else if (i==PAGE_UP) {
  247.       low -= IFS_NUM;
  248.       if (low<0) low=0;
  249.       } else if (i==UP_ARROW) {
  250.       low -= 1;
  251.       if (low<0) low=0;
  252.       } else if (i==DOWN_ARROW) {
  253.       low += 1;
  254.       if (low+IFS_NUM>numlines) low=numlines-IFS_NUM;
  255.       if (low<0) low=0;
  256.       } else if (i==PAGE_DOWN) {
  257.       low += IFS_NUM;
  258.       if (low+IFS_NUM>numlines) low=numlines-IFS_NUM;
  259.       if (low<0) low=0;
  260.       } else if (i==F6) {
  261.       if (get_corners()) {
  262.           ret = 1;
  263.       }
  264.       } else if (i==0) {
  265.       if (temp1[0]==0) break;
  266.       } else {
  267.       continue;
  268.       }
  269.  
  270.       putstring(promptrow,promptcol,C_GENERAL_HI,temp1);
  271.       if (temp1[0] == 's' || temp1[0] == 'S') {
  272.      stackscreen();
  273.      filename[0] = 0;
  274.      i = field_prompt(0,"Enter the name of the .IFS file to save:",
  275.              NULL,filename,60,NULL);
  276.      unstackscreen();
  277.      if (i != -1) {
  278.         if (strchr(filename,'.') == NULL)
  279.            strcat(filename,".ifs");
  280.         if ((tempfile=fopen(filename,"w")) != NULL) {
  281.            for (i = 0; i < numlines; i++) {
  282.           for (j = 0; j < totcols; j++)
  283.              fprintf(tempfile, "%6.2f", (float)ifs_defn[(i*totcols)+j]);
  284.           fprintf(tempfile, "\n");
  285.           }
  286.            fclose(tempfile);
  287.            ifs_changed = 0;
  288.            }
  289.         else {
  290.            static char far msg[]={"Could not create file"};
  291.            stopmsg(0,msg);
  292.            }
  293.         }
  294.      continue;
  295.      }
  296.       i = atoi(temp1) - 1;
  297.       if (i >= 0 && i < numlines) {
  298.      for (j = 0; j < totcols; j++) {
  299.         if (j < totcols-1)
  300.            sprintf(msg,"Parameter %c",'a'+j);
  301.         else
  302.            sprintf(msg,"Probability");
  303.         putstring(promptrow+2,25,C_GENERAL_HI,msg);
  304.         sprintf(temp1,"%6.2f",(float)ifs_defn[k=(i*totcols)+j]);
  305.         if (input_field(1,C_GENERAL_INPUT,temp1,6,
  306.                 textrow,textcol+1,NULL) < 0)
  307.            break;
  308.         if (ifs_defn[k] != (ftemp = atof(temp1))) {
  309.            ifs_defn[k] = ftemp;
  310.            ret = ifs_changed = 1;
  311.            }
  312.         }
  313.      memset(msg,' ',80); msg[81] = 0;
  314.      putstring(promptrow+2,0,C_PROMPT_BKGRD,msg);
  315.      }
  316.       }
  317.  
  318.    helpmode = oldhelpmode;
  319.    return(ret);
  320. }
  321. #endif
  322. /* --------------------------------------------------------------------- */
  323. /*
  324.     get_toggles() is called from FRACTINT.C whenever the 'x' key
  325.     is pressed.  This routine prompts for several options,
  326.     sets the appropriate variables, and returns the following code
  327.     to the calling routine:
  328.  
  329.     -1  routine was ESCAPEd - no need to re-generate the image.
  330.      0  nothing changed, or minor variable such as "overwrite=".
  331.         No need to re-generate the image.
  332.      1  major variable changed (such as "inside=").  Re-generate
  333.         the image.
  334.  
  335.     Finally, remember to insert variables in the list *and* check
  336.     for them in the same order!!!
  337. */
  338. #define LOADCHOICES(X)     {\
  339.    static char far tmp[] = { X };\
  340.    choices[++k]= tmp;\
  341.    }
  342. int get_toggles()
  343. {
  344.    static char far hdg[]={"        Basic Options\n\
  345. (not all combinations make sense)"};
  346.    char far *choices[20];
  347.    int oldhelpmode;
  348.    char prevsavename[81];
  349.    struct fullscreenvalues uvalues[25];
  350.    int i, j, k;
  351.    char old_usr_stdcalcmode;
  352.    int old_maxit,old_inside,old_outside,old_soundflag;
  353.    int old_logflag,old_biomorph,old_decomp;
  354.    int old_fillcolor;
  355.    static char *calcmodes[] ={"1","2","g","b","t"};
  356.    static char *soundmodes[5]={"yes","no","x","y","z"};
  357.  
  358.    ENTER_OVLY(OVLY_PROMPTS2);
  359.  
  360.    k = -1;
  361.  
  362.    LOADCHOICES("Passes (1, 2, g[uessing], b[oundary trace], t[esseral])");
  363.    uvalues[k].type = 'l';
  364.    uvalues[k].uval.ch.vlen = 3;
  365.    uvalues[k].uval.ch.llen = sizeof(calcmodes)/sizeof(*calcmodes);
  366.    uvalues[k].uval.ch.list = calcmodes;
  367.    uvalues[k].uval.ch.val = (usr_stdcalcmode == '1') ? 0
  368.               : (usr_stdcalcmode == '2') ? 1
  369.                           : (usr_stdcalcmode == 'g') ? 2
  370.                           : (usr_stdcalcmode == 'b') ? 3 :4 ;
  371.    old_usr_stdcalcmode = usr_stdcalcmode;
  372.  
  373.    LOADCHOICES("Floating Point Algorithm");
  374.    uvalues[k].type = 'y';
  375.    uvalues[k].uval.ch.val = usr_floatflag;
  376.  
  377.    LOADCHOICES("Maximum Iterations (2 to 32767)");
  378.    uvalues[k].type = 'i';
  379.    uvalues[k].uval.ival = old_maxit = maxit;
  380.  
  381.    LOADCHOICES("Inside Color (<nnn>,maxiter,zmag,bof60,bof61,epscr,star,per)");
  382.    uvalues[k].type = 's';
  383.    if(inside == -59)
  384.       strcpy(uvalues[k].uval.sval,s_zmag);
  385.    else if(inside == -60)
  386.       strcpy(uvalues[k].uval.sval,s_bof60);
  387.    else if(inside == -61)
  388.       strcpy(uvalues[k].uval.sval,s_bof61);
  389.    else if(inside == -100)
  390.       strcpy(uvalues[k].uval.sval,s_epscross);
  391.    else if(inside == -101)
  392.       strcpy(uvalues[k].uval.sval,s_startrail);
  393.    else if(inside == -102)
  394.       strcpy(uvalues[k].uval.sval,s_period);
  395.    else if(inside == -1)
  396.       strcpy(uvalues[k].uval.sval,s_maxiter);
  397.    else
  398.       sprintf(uvalues[k].uval.sval,"%d",inside);
  399.    old_inside = inside;
  400.  
  401.    LOADCHOICES("Outside Color (<nnn>,iter,real,imag,mult,summ)");
  402.    uvalues[k].type = 's';
  403.    if(outside == -1)
  404.       strcpy(uvalues[k].uval.sval,s_iter);
  405.    else if(outside == -2)
  406.       strcpy(uvalues[k].uval.sval,s_real);
  407.    else if(outside == -3)
  408.       strcpy(uvalues[k].uval.sval,s_imag);
  409.    else if(outside == -4)
  410.       strcpy(uvalues[k].uval.sval,s_mult);
  411.    else if(outside == -5)
  412.       strcpy(uvalues[k].uval.sval,s_sum);
  413.    else
  414.       sprintf(uvalues[k].uval.sval,"%d",outside);
  415.    old_outside = outside;
  416.  
  417.    LOADCHOICES("Savename (.GIF implied)");
  418.    uvalues[k].type = 's';
  419.    strcpy(prevsavename,savename);
  420.    strcpy(uvalues[k].uval.sval,savename);
  421.  
  422.    LOADCHOICES("File Overwrite ('overwrite=')");
  423.    uvalues[k].type = 'y';
  424.    uvalues[k].uval.ch.val = overwrite;
  425.  
  426.    LOADCHOICES("Sound (no, yes, x, y, z)");
  427.    uvalues[k].type = 'l';
  428.    uvalues[k].uval.ch.vlen = 3;
  429.    uvalues[k].uval.ch.llen = 5;
  430.    uvalues[k].uval.ch.list = soundmodes;
  431.    uvalues[k].uval.ch.val = 1 + (old_soundflag = soundflag);
  432.  
  433.    if (rangeslen == 0) {
  434.       LOADCHOICES("Log Palette (0=no,1=yes,-1=old,+n=cmprsd,-n=sqrt)");
  435.       uvalues[k].type = 'i';
  436.       }
  437.    else {
  438.       LOADCHOICES("Log Palette (n/a, ranges= parameter is in effect)");
  439.       uvalues[k].type = '*';
  440.       }
  441.    uvalues[k].uval.ival = old_logflag = LogFlag;
  442.  
  443.    LOADCHOICES("Biomorph Color (-1 means OFF)");
  444.    uvalues[k].type = 'i';
  445.    uvalues[k].uval.ival = old_biomorph = usr_biomorph;
  446.  
  447.    LOADCHOICES("Decomp Option (2,4,8,..,256, 0=OFF)");
  448.    uvalues[k].type = 'i';
  449.    uvalues[k].uval.ival = old_decomp = decomp[0];
  450.  
  451.    LOADCHOICES("Fill Color (normal,<nnn>) (works with passes=t and =b)");
  452.    uvalues[k].type = 's';
  453.    if(fillcolor < 0)
  454.       strcpy(uvalues[k].uval.sval,s_normal);
  455.    else
  456.       sprintf(uvalues[k].uval.sval,"%d",fillcolor);
  457.    old_fillcolor = fillcolor;
  458.  
  459.    LOADCHOICES("Orbit delay (0 = none)");
  460.    uvalues[k].type = 'i';
  461.    uvalues[k].uval.ival = orbit_delay;
  462.  
  463. /*
  464.    LOADCHOICES("Antialiasing (0 to 8)");
  465.    uvalues[k].type = 'i';
  466.    uvalues[k].uval.ival = AntiAliasing;
  467. */
  468.  
  469.    oldhelpmode = helpmode;
  470.    helpmode = HELPXOPTS;
  471.    i = fullscreen_prompt(hdg,k+1,choices,uvalues,0,0,NULL);
  472.    helpmode = oldhelpmode;
  473.    if (i < 0) {
  474.       EXIT_OVLY;
  475.       return(-1);
  476.       }
  477.  
  478.    /* now check out the results (*hopefully* in the same order <grin>) */
  479.    k = -1;
  480.    j = 0;   /* return code */
  481.  
  482.    usr_stdcalcmode = calcmodes[uvalues[++k].uval.ch.val][0];
  483.    if (old_usr_stdcalcmode != usr_stdcalcmode) j = 1;
  484.  
  485.    if (uvalues[++k].uval.ch.val != usr_floatflag) {
  486.       usr_floatflag = uvalues[k].uval.ch.val;
  487.       j = 1;
  488.       }
  489.  
  490.    ++k;
  491.    maxit = uvalues[k].uval.ival;
  492.    if (maxit < 2) maxit = 2;
  493.  
  494. /* 'maxit' is an int so it is always <= 32767, MCP 12-3-91
  495.    if (maxit > 32767) maxit = 32767;
  496. */
  497.  
  498.    if (maxit != old_maxit) j = 1;
  499.  
  500.    if(strncmp(strlwr(uvalues[++k].uval.sval),s_zmag,4)==0)
  501.       inside = -59;
  502.    else if(strncmp(strlwr(uvalues[k].uval.sval),s_bof60,5)==0)
  503.       inside = -60;
  504.    else if(strncmp(strlwr(uvalues[k].uval.sval),s_bof61,5)==0)
  505.       inside = -61;
  506.    else if(strncmp(strlwr(uvalues[k].uval.sval),s_epscross,3)==0)
  507.       inside = -100;
  508.    else if(strncmp(strlwr(uvalues[k].uval.sval),s_startrail,4)==0)
  509.       inside = -101;
  510.    else if(strncmp(strlwr(uvalues[k].uval.sval),s_period,3)==0)
  511.       inside = -102;
  512.    else if(strncmp(strlwr(uvalues[k].uval.sval),s_maxiter,5)==0)
  513.       inside = -1;
  514.    else
  515.       inside = atoi(uvalues[k].uval.sval);
  516.    if (inside != old_inside) j = 1;
  517.  
  518.    if(strncmp(strlwr(uvalues[++k].uval.sval),s_real,4)==0)
  519.       outside = -2;
  520.    else if(strncmp(strlwr(uvalues[k].uval.sval),s_imag,4)==0)
  521.       outside = -3;
  522.    else if(strncmp(strlwr(uvalues[k].uval.sval),s_mult,4)==0)
  523.       outside = -4;
  524.    else if(strncmp(strlwr(uvalues[k].uval.sval),s_sum,4)==0)
  525.       outside = -5;
  526.    else if(strncmp(strlwr(uvalues[k].uval.sval),s_iter,4)==0)
  527.       outside = -1;
  528.    else
  529.       outside = atoi(uvalues[k].uval.sval);
  530.    if (outside != old_outside) j = 1;
  531.  
  532.    strcpy(savename,uvalues[++k].uval.sval);
  533.    if (strcmp(savename,prevsavename))
  534.       resave_flag = started_resaves = 0; /* forget pending increment */
  535.  
  536.    overwrite = uvalues[++k].uval.ch.val;
  537.  
  538.    soundflag = uvalues[++k].uval.ch.val - 1;
  539.    if (soundflag != old_soundflag && (soundflag > 1 || old_soundflag > 1))
  540.       j = 1;
  541.  
  542.    LogFlag = uvalues[++k].uval.ival;
  543.    if (LogFlag != old_logflag) j = 1;
  544.  
  545.    usr_biomorph = uvalues[++k].uval.ival;
  546.    if (usr_biomorph != old_biomorph) j = 1;
  547.  
  548.    decomp[0] = uvalues[++k].uval.ival;
  549.    if (decomp[0] != old_decomp) j = 1;
  550.  
  551.    if(strncmp(strlwr(uvalues[++k].uval.sval),s_normal,4)==0)
  552.       fillcolor = -1;
  553.    else
  554.       fillcolor = atoi(uvalues[k].uval.sval);
  555.    if (fillcolor != old_fillcolor) j = 1;
  556.  
  557.    orbit_delay = uvalues[++k].uval.ival;
  558.  
  559. /*
  560.    if(AntiAliasing != uvalues[++k].uval.ival) j = 1;
  561.    AntiAliasing = uvalues[k].uval.ival;
  562.    if(AntiAliasing < 0) AntiAliasing = 0;
  563.    if(AntiAliasing > 8) AntiAliasing = 8;
  564. */
  565.  
  566.    EXIT_OVLY;
  567.    return(j);
  568. }
  569.  
  570. /*
  571.     get_toggles2() is similar to get_toggles, invoked by 'y' key
  572. */
  573.  
  574. int get_toggles2()
  575. {
  576.    static char far hdg[]={"       Extended Options\n\
  577. (not all combinations make sense)"};
  578.    char far *choices[20];
  579.    int oldhelpmode;
  580.  
  581.    struct fullscreenvalues uvalues[25];
  582.    int i, j, k;
  583.  
  584.    int old_rotate_lo,old_rotate_hi;
  585.    int old_usr_distest,old_distestwidth;
  586.    double old_potparam[3],old_inversion[3];
  587.  
  588.    ENTER_OVLY(OVLY_PROMPTS2);
  589.  
  590.    /* fill up the choices (and previous values) arrays */
  591.    k = -1;
  592.  
  593.    LOADCHOICES("Look for finite attractor (0=no,>0=yes,<0=phase)");
  594.    uvalues[k].type = 'i';
  595.    uvalues[k].uval.ch.val = finattract;
  596.  
  597.    LOADCHOICES("Potential Max Color (0 means off)");
  598.    uvalues[k].type = 'i';
  599.    uvalues[k].uval.ival = old_potparam[0] = potparam[0];
  600.  
  601.    LOADCHOICES("          Slope");
  602.    uvalues[k].type = 'd';
  603.    uvalues[k].uval.dval = old_potparam[1] = potparam[1];
  604.  
  605.    LOADCHOICES("          Bailout");
  606.    uvalues[k].type = 'i';
  607.    uvalues[k].uval.ival = old_potparam[2] = potparam[2];
  608.  
  609.    LOADCHOICES("          16 bit values");
  610.    uvalues[k].type = 'y';
  611.    uvalues[k].uval.ch.val = pot16bit;
  612.  
  613.    LOADCHOICES("Distance Estimator (0=off, <0=edge, >0=on):");
  614.    uvalues[k].type = 'i';
  615.    uvalues[k].uval.ival = old_usr_distest = usr_distest;
  616.  
  617.    LOADCHOICES("          width factor:");
  618.    uvalues[k].type = 'i';
  619.    uvalues[k].uval.ival = old_distestwidth = distestwidth;
  620.  
  621.  
  622.  
  623.    LOADCHOICES("Inversion radius or \"auto\" (0 means off)");
  624.    LOADCHOICES("          center X coordinate or \"auto\"");
  625.    LOADCHOICES("          center Y coordinate or \"auto\"");
  626.    k = k - 3;
  627.    for (i= 0; i < 3; i++) {
  628.       uvalues[++k].type = 's';
  629.       if ((old_inversion[i] = inversion[i]) == AUTOINVERT)
  630.      sprintf(uvalues[k].uval.sval,"auto");
  631.       else
  632.      sprintf(uvalues[k].uval.sval,"%g",inversion[i]);
  633.       }
  634.    LOADCHOICES("  (use fixed radius & center when zooming)");
  635.    uvalues[k].type = '*';
  636.  
  637.    LOADCHOICES("Color cycling from color (0 ... 254)");
  638.    uvalues[k].type = 'i';
  639.    uvalues[k].uval.ival = old_rotate_lo = rotate_lo;
  640.  
  641.    LOADCHOICES("              to   color (1 ... 255)");
  642.    uvalues[k].type = 'i';
  643.    uvalues[k].uval.ival = old_rotate_hi = rotate_hi;
  644.  
  645.    oldhelpmode = helpmode;
  646.    helpmode = HELPYOPTS;
  647.    i = fullscreen_prompt(hdg,k+1,choices,uvalues,0,0,NULL);
  648.    helpmode = oldhelpmode;
  649.    if (i < 0) {
  650.       EXIT_OVLY;
  651.       return(-1);
  652.       }
  653.  
  654.    /* now check out the results (*hopefully* in the same order <grin>) */
  655.    k = -1;
  656.    j = 0;   /* return code */
  657.  
  658.    if (uvalues[++k].uval.ch.val != finattract) {
  659.       finattract = uvalues[k].uval.ch.val;
  660.       j = 1;
  661.       }
  662.  
  663.    potparam[0] = uvalues[++k].uval.ival;
  664.    if (potparam[0] != old_potparam[0]) j = 1;
  665.  
  666.    potparam[1] = uvalues[++k].uval.dval;
  667.    if (potparam[0] != 0.0 && potparam[1] != old_potparam[1]) j = 1;
  668.  
  669.    potparam[2] = uvalues[++k].uval.ival;
  670.    if (potparam[0] != 0.0 && potparam[2] != old_potparam[2]) j = 1;
  671.  
  672.    if (uvalues[++k].uval.ch.val != pot16bit) {
  673.       pot16bit = uvalues[k].uval.ch.val;
  674.       if (pot16bit) { /* turned it on */
  675.      if (potparam[0] != 0.0) j = 1;
  676.      }
  677.       else /* turned it off */
  678.      if (dotmode != 11) /* ditch the disk video */
  679.         enddisk();
  680.      else /* keep disk video, but ditch the fraction part at end */
  681.         disk16bit = 0;
  682.       }
  683.  
  684.    ++k;
  685.    usr_distest = (uvalues[k].uval.ival > 32000) ? 32000 : uvalues[k].uval.ival;
  686.    if (usr_distest != old_usr_distest) j = 1;
  687.    ++k;
  688.    distestwidth = uvalues[k].uval.ival;
  689.    if (usr_distest && distestwidth != old_distestwidth) j = 1;
  690.  
  691.    for (i = 0; i < 3; i++) {
  692.       if (uvalues[++k].uval.sval[0] == 'a' || uvalues[k].uval.sval[0] == 'A')
  693.      inversion[i] = AUTOINVERT;
  694.       else
  695.      inversion[i] = atof(uvalues[k].uval.sval);
  696.       if (old_inversion[i] != inversion[i]
  697.     && (i == 0 || inversion[0] != 0.0))
  698.      j = 1;
  699.       }
  700.    invert = (inversion[0] == 0.0) ? 0 : 3;
  701.    ++k;
  702.  
  703.    rotate_lo = uvalues[++k].uval.ival;
  704.    rotate_hi = uvalues[++k].uval.ival;
  705.    if (rotate_lo < 0 || rotate_hi > 255 || rotate_lo > rotate_hi) {
  706.       rotate_lo = old_rotate_lo;
  707.       rotate_hi = old_rotate_hi;
  708.       }
  709.  
  710.    EXIT_OVLY;
  711.    return(j);
  712. }
  713.  
  714. /* --------------------------------------------------------------------- */
  715. /*
  716.     get_view_params() is called from FRACTINT.C whenever the 'v' key
  717.     is pressed.  Return codes are:
  718.     -1  routine was ESCAPEd - no need to re-generate the image.
  719.      0  minor variable changed.  No need to re-generate the image.
  720.      1  View changed.  Re-generate the image.
  721. */
  722.  
  723. int get_view_params()
  724. {
  725.    static char far hdg[]={"View Window Options"};
  726.    char far *choices[8];
  727.  
  728.    int oldhelpmode;
  729.    struct fullscreenvalues uvalues[25];
  730.    int i, k;
  731.    float old_viewreduction,old_aspectratio;
  732.    int old_viewwindow,old_viewcrop,old_viewxdots,old_viewydots;
  733.  
  734.    ENTER_OVLY(OVLY_PROMPTS2);
  735.    stackscreen();
  736.  
  737.    old_viewwindow    = viewwindow;
  738.    old_viewcrop      = viewcrop;
  739.    old_viewreduction = viewreduction;
  740.    old_aspectratio   = finalaspectratio;
  741.    old_viewxdots     = viewxdots;
  742.    old_viewydots     = viewydots;
  743.  
  744. get_view_restart:
  745.    /* fill up the previous values arrays */
  746.    k = -1;
  747.  
  748.    LOADCHOICES("Preview display? (no for full screen)");
  749.    uvalues[k].type = 'y';
  750.    uvalues[k].uval.ch.val = viewwindow;
  751.  
  752.    LOADCHOICES("Auto window size reduction factor");
  753.    uvalues[k].type = 'f';
  754.    uvalues[k].uval.dval = viewreduction;
  755.  
  756.    LOADCHOICES("Final media overall aspect ratio, y/x");
  757.    uvalues[k].type = 'f';
  758.    uvalues[k].uval.dval = finalaspectratio;
  759.  
  760.    LOADCHOICES("Crop starting coordinates to new aspect ratio?");
  761.    uvalues[k].type = 'y';
  762.    uvalues[k].uval.ch.val = viewcrop;
  763.  
  764.    LOADCHOICES("Explicit size x pixels (0 for auto size)");
  765.    uvalues[k].type = 'i';
  766.    uvalues[k].uval.ival = viewxdots;
  767.  
  768.    LOADCHOICES("              y pixels (0 to base on aspect ratio)");
  769.    uvalues[k].type = 'i';
  770.    uvalues[k].uval.ival = viewydots;
  771.  
  772.    LOADCHOICES("");
  773.    uvalues[k].type = '*';
  774.  
  775.    LOADCHOICES("Press F4 to reset view parameters to defaults.");
  776.    uvalues[k].type = '*';
  777.  
  778.    oldhelpmode = helpmode;     /* this prevents HELP from activating */
  779.    helpmode = HELPVIEW;
  780.    i = fullscreen_prompt(hdg,k+1,choices,uvalues,0,16,NULL);
  781.    helpmode = oldhelpmode;     /* re-enable HELP */
  782.    if (i < 0) {
  783.       viewwindow    = old_viewwindow;
  784.       viewcrop        = old_viewcrop;
  785.       viewreduction = old_viewreduction;
  786.       finalaspectratio = old_aspectratio;
  787.       viewxdots     = old_viewxdots;
  788.       viewydots     = old_viewydots;
  789.       unstackscreen();
  790.       EXIT_OVLY;
  791.       return(-1);
  792.       }
  793.  
  794.    if (i == F4) {
  795.       viewwindow = viewxdots = viewydots = 0;
  796.       viewreduction = 4.2;
  797.       viewcrop = 1;
  798.       finalaspectratio = screenaspect;
  799.       goto get_view_restart;
  800.       }
  801.  
  802.    /* now check out the results (*hopefully* in the same order <grin>) */
  803.    k = -1;
  804.  
  805.    viewwindow = uvalues[++k].uval.ch.val;
  806.  
  807.    viewreduction = uvalues[++k].uval.dval;
  808.  
  809.    if ((finalaspectratio = uvalues[++k].uval.dval) == 0)
  810.       finalaspectratio = screenaspect;
  811.  
  812.    viewcrop = uvalues[++k].uval.ch.val;
  813.  
  814.    viewxdots = uvalues[++k].uval.ival;
  815.    viewydots = uvalues[++k].uval.ival;
  816.  
  817.    if (finalaspectratio != old_aspectratio && viewcrop)
  818.       aspectratio_crop(old_aspectratio,finalaspectratio);
  819.  
  820.    i = 0;
  821.    if (viewwindow != old_viewwindow
  822.       || (viewwindow
  823.      && (  viewreduction != old_viewreduction
  824.         || finalaspectratio != old_aspectratio
  825.         || viewxdots != old_viewxdots
  826.         || (viewydots != old_viewydots && viewxdots) ) ) )
  827.       i = 1;
  828.  
  829.    unstackscreen();
  830.    EXIT_OVLY;
  831.    return(i);
  832. }
  833.  
  834. /*
  835.     get_cmd_string() is called from FRACTINT.C whenever the 'g' key
  836.     is pressed.  Return codes are:
  837.     -1  routine was ESCAPEd - no need to re-generate the image.
  838.      0  parameter changed, no need to regenerate
  839.     >0  parameter changed, regenerate
  840. */
  841.  
  842. int get_cmd_string()
  843. {
  844.    int oldhelpmode;
  845.    int i;
  846.    char cmdbuf[61];
  847.  
  848.    ENTER_OVLY(OVLY_PROMPTS2);
  849.  
  850.    oldhelpmode = helpmode;
  851.    helpmode = HELPCOMMANDS;
  852.    cmdbuf[0] = 0;
  853.    i = field_prompt(0,"Enter command string to use.",NULL,cmdbuf,60,NULL);
  854.    helpmode = oldhelpmode;
  855.    if (i >= 0 && cmdbuf[0] != 0)
  856.        i = cmdarg(cmdbuf, 2);
  857.  
  858.    EXIT_OVLY;
  859.    return(i);
  860. }
  861.  
  862.  
  863. /* --------------------------------------------------------------------- */
  864.  
  865. int Distribution = 30, Offset = 0, Slope = 25;
  866. long con;
  867.  
  868. static char far sf1[] = {"Star Density in Pixels per Star"};
  869. static char far sf2[] = {"Percent Clumpiness"};
  870. static char far sf3[] = {"Ratio of Dim stars to Bright"};
  871. static char far *starfield_prompts[] = {sf1,sf2,sf3};
  872.  
  873. static double starfield_values[4] = {
  874.     30.0,100.0,5.0,0.0
  875.     };
  876.  
  877. char GreyFile[] = "altern.map";
  878.  
  879. int starfield(void)
  880. {
  881.    int c;
  882.    extern char busy;
  883.    busy = 1;
  884.    if (starfield_values[0] <   1.0) starfield_values[0] =   1.0;
  885.    if (starfield_values[0] > 100.0) starfield_values[0] = 100.0;
  886.    if (starfield_values[1] <   1.0) starfield_values[1] =   1.0;
  887.    if (starfield_values[1] > 100.0) starfield_values[1] = 100.0;
  888.    if (starfield_values[2] <   1.0) starfield_values[2] =   1.0;
  889.    if (starfield_values[2] > 100.0) starfield_values[2] = 100.0;
  890.  
  891.    Distribution = (int)(starfield_values[0]);
  892.    con    = (long)(((starfield_values[1]) / 100.0) * (1L << 16));
  893.    Slope = (int)(starfield_values[2]);
  894.  
  895.    if (ValidateLuts(GreyFile) != 0) {
  896.       static char far msg[]={"Unable to load ALTERN.MAP"};
  897.       stopmsg(0,msg);
  898.       busy = 0;
  899.       return(-1);
  900.       }
  901.    spindac(0,1);         /* load it, but don't spin */
  902.    for(row = 0; row < ydots; row++) {
  903.       for(col = 0; col < xdots; col++) {
  904.      if(keypressed()) {
  905.         buzzer(1);
  906.         busy = 0;
  907.         return(1);
  908.         }
  909.      c = getcolor(col, row);
  910.          if(c == inside)
  911.             c = colors-1;
  912.      putcolor(col, row, GausianNumber(c, colors));
  913.       }
  914.    }
  915.    buzzer(0);
  916.    busy = 0;
  917.    return(0);
  918. }
  919.  
  920. int get_starfield_params(void) {
  921.    static char far hdg[]={"Starfield Parameters"};
  922.    struct fullscreenvalues uvalues[3];
  923.    int oldhelpmode, status;
  924.    int i;
  925.  
  926.    ENTER_OVLY(OVLY_PROMPTS2);
  927.  
  928.    if(colors < 255) {
  929.       static char far msg[]={"starfield requires 256 color mode"};
  930.       stopmsg(0,msg);
  931.  
  932.       EXIT_OVLY;
  933.       return(-1);
  934.    }
  935.    for (i = 0; i < 3; i++) {
  936.       uvalues[i].uval.dval = starfield_values[i];
  937.       uvalues[i].type = 'f';
  938.    }
  939.    stackscreen();
  940.    oldhelpmode = helpmode;
  941.    helpmode = HELPSTARFLD;
  942.    i = fullscreen_prompt(hdg,3,starfield_prompts,uvalues,0,0,NULL);
  943.    helpmode = oldhelpmode;
  944.    if (i < 0) {
  945.       unstackscreen();
  946.       EXIT_OVLY;
  947.       return(-1);
  948.       }
  949.    unstackscreen();
  950.  
  951.    for (i = 0; i < 3; i++)
  952.       starfield_values[i] = uvalues[i].uval.dval;
  953.  
  954.    EXIT_OVLY;
  955.    return(0);
  956. }
  957.  
  958. int get_a_number(double *x, double *y)
  959. {
  960.    static char far hdg[]={"Set Cursor Coordinates"};
  961.    double x1,y2;
  962.    char far *choices[2];
  963.  
  964.    int oldhelpmode;
  965.    struct fullscreenvalues uvalues[2];
  966.    int i, k;
  967.  
  968.    ENTER_OVLY(OVLY_PROMPTS2);
  969.    stackscreen();
  970.  
  971.    /* fill up the previous values arrays */
  972.    k = -1;
  973.  
  974.    LOADCHOICES("X coordinate at cursor");
  975.    uvalues[k].type = 'd';
  976.    uvalues[k].uval.dval = *x;
  977.  
  978.    LOADCHOICES("Y coordinate at cursor");
  979.    uvalues[k].type = 'd';
  980.    uvalues[k].uval.dval = *y;
  981.  
  982.    i = fullscreen_prompt(hdg,k+1,choices,uvalues,0,25,NULL);
  983.    if (i < 0) {
  984.       unstackscreen();
  985.       EXIT_OVLY;
  986.       return(-1);
  987.       }
  988.  
  989.    /* now check out the results (*hopefully* in the same order <grin>) */
  990.    k = -1;
  991.  
  992.    *x = uvalues[++k].uval.dval;
  993.    *y = uvalues[++k].uval.dval;
  994.  
  995.    unstackscreen();
  996.    EXIT_OVLY;
  997.    return(i);
  998. }
  999.  
  1000. /* --------------------------------------------------------------------- */
  1001.  
  1002. int get_commands()        /* execute commands from file */
  1003. {
  1004.    int ret;
  1005.    FILE *parmfile;
  1006.    long point;
  1007.    int oldhelpmode;
  1008.    ENTER_OVLY(OVLY_PROMPTS2);
  1009.    ret = 0;
  1010.    oldhelpmode = helpmode;
  1011.    helpmode = HELPPARMFILE;
  1012.    if ((point = get_file_entry(GETPARM,"Parameter Set",
  1013.                    commandmask,CommandFile,CommandName)) >= 0
  1014.      && (parmfile = fopen(CommandFile,"rb"))) {
  1015.       fseek(parmfile,point,SEEK_SET);
  1016.       ret = load_commands(parmfile);
  1017.       }
  1018.    helpmode = oldhelpmode;
  1019.    EXIT_OVLY;
  1020.    return(ret);
  1021. }
  1022.  
  1023. /* --------------------------------------------------------------------- */
  1024.  
  1025. void goodbye()            /* we done.  Bail out */
  1026. {
  1027.    static char far goodbyemessage[]={"   Thank You for using FRACTINT"};
  1028.    extern BYTE exitmode;
  1029.    extern int mode7text;
  1030.    extern int made_dsktemp;
  1031. #ifndef XFRACT
  1032.    union REGS r;
  1033. #endif
  1034.  
  1035. #ifdef WINFRACT
  1036.    return;
  1037. #endif
  1038.  
  1039.    setvideotext();
  1040. #ifdef XFRACT
  1041.    UnixDone();
  1042.    printf("\n\n\n%s\n",goodbyemessage); /* printf takes far pointer */
  1043. #else
  1044.    r.h.al = (mode7text == 0) ? exitmode : 7;
  1045.    r.h.ah = 0;
  1046.    int86(0x10, &r, &r);
  1047.    printf("\n\n\n%Fs\n",goodbyemessage); /* printf takes far pointer */
  1048. #endif
  1049.    movecursor(6,0);
  1050.    discardgraphics(); /* if any emm/xmm tied up there, release it */
  1051.    stopslideshow();
  1052. #ifndef XFRACT
  1053.    if (made_dsktemp)
  1054.       remove(diskfilename);
  1055. #endif
  1056.    end_help();
  1057.    if (initbatch == 3) /* exit with error code for batch file */
  1058.      exit(2);
  1059.    else if (initbatch == 4)
  1060.      exit(1);
  1061.    else
  1062.      exit(0);
  1063. }
  1064.  
  1065.  
  1066. /* --------------------------------------------------------------------- */
  1067.  
  1068. #ifdef XFRACT
  1069. static char searchdir[FILE_MAX_DIR];
  1070. static char searchname[FILE_MAX_PATH];
  1071. static char searchext[FILE_MAX_EXT];
  1072. static DIR *currdir = NULL;
  1073. #endif
  1074. static int  findfirst(char *path)       /* Find 1st file (or subdir) meeting path/filespec */
  1075. {
  1076. #ifndef XFRACT
  1077.      union REGS regs;
  1078.      regs.h.ah = 0x1A;           /* Set DTA to filedata */
  1079.      regs.x.dx = (unsigned)&DTA;
  1080.      intdos(®s, ®s);
  1081.      regs.h.ah = 0x4E;           /* Find 1st file meeting path */
  1082.      regs.x.dx = (unsigned)path;
  1083.      regs.x.cx = FILEATTR;
  1084.      intdos(®s, ®s);
  1085.      return(regs.x.ax);        /* Return error code */
  1086. #else
  1087.      if (currdir != NULL) {
  1088.          closedir(currdir);
  1089.          currdir = NULL;
  1090.      }
  1091.      splitpath(path,NULL,searchdir,searchname,searchext);
  1092.      if (searchdir[0]=='\0') {
  1093.          currdir = opendir(".");
  1094.      } else {
  1095.          currdir = opendir(searchdir);
  1096.      }
  1097.      if (currdir==NULL) {
  1098.          return -1;
  1099.      } else {
  1100.          return findnext();
  1101.      }
  1102. #endif
  1103. }
  1104.  
  1105. static int  findnext()        /* Find next file (or subdir) meeting above path/filespec */
  1106. {
  1107. #ifndef XFRACT
  1108.      union REGS regs;
  1109.      regs.h.ah = 0x4F;           /* Find next file meeting path */
  1110.      regs.x.dx = (unsigned)&DTA;
  1111.      intdos(®s, ®s);
  1112.      return(regs.x.ax);
  1113. #else
  1114. #ifdef DIRENT
  1115.      struct dirent *dirEntry;
  1116. #else
  1117.      struct direct *dirEntry;
  1118. #endif
  1119.      struct stat sbuf;
  1120.      char thisname[FILE_MAX_PATH];
  1121.      char tmpname[FILE_MAX_PATH];
  1122.      char thisext[FILE_MAX_EXT];
  1123.      while (1) {
  1124.          dirEntry = readdir(currdir);
  1125.          if (dirEntry == NULL) {
  1126.              closedir(currdir);
  1127.              currdir = NULL;
  1128.              return -1;
  1129.          } else if (dirEntry->d_ino != 0) {
  1130.              splitpath(dirEntry->d_name,NULL,NULL,thisname,thisext);
  1131.              if ((searchname[0]=='*' || strcmp(searchname,thisname)==0) &&
  1132.                      (searchext[0]=='*' || strcmp(searchext,thisext)==0)) {
  1133.                  strncpy(DTA.filename,dirEntry->d_name,20);
  1134.                  DTA.filename[20]=='\0';
  1135.                  strcpy(tmpname,searchdir);
  1136.                  strcat(tmpname,"/");
  1137.                  strcat(tmpname,dirEntry->d_name);
  1138.                  stat(tmpname,&sbuf);
  1139.                  if ((sbuf.st_mode&S_IFMT)==S_IFREG) {
  1140.                      DTA.attribute = 0;
  1141.                  } else if ((sbuf.st_mode&S_IFMT)==S_IFDIR) {
  1142.                      DTA.attribute = SUBDIR;
  1143.                  } else {
  1144.                      continue;
  1145.                  }
  1146.                  DTA.size = sbuf.st_size;
  1147.                  return 0;
  1148.              }
  1149.          }
  1150.      }
  1151. #endif
  1152. }
  1153.  
  1154. int lccompare(VOIDCONSTPTR arg1, VOIDCONSTPTR arg2) /* for qsort */
  1155. {
  1156.    return(strncasecmp(*((char **)arg1),*((char **)arg2),40));
  1157. }
  1158.  
  1159. static char *masks[] = {"*.pot","*.gif"};
  1160. static int speedstate;
  1161.  
  1162. int getafilename(char *hdg,char *template,char *flname)
  1163. {
  1164.    static char far instr[]={"Press F6 for default or environment directory"};
  1165.    int masklen;
  1166.    char filename[13];
  1167.    char speedstr[81];
  1168.    char tmpmask[FILE_MAX_PATH];   /* used to locate next file in list */
  1169.    static int numtemplates = 1;
  1170.    int i,j;
  1171.    int out;
  1172.    int retried;
  1173.    struct CHOICE
  1174.    {
  1175.       char name[13];
  1176.       char type;
  1177.    }
  1178.    *choices[MAXNUMFILES];
  1179.    int attributes[MAXNUMFILES];
  1180.    int filecount;   /* how many files */
  1181.    int dircount;    /* how many directories */
  1182.    int notroot;     /* not the root directory */
  1183.  
  1184.    char drive[FILE_MAX_DRIVE];
  1185.    char dir[FILE_MAX_DIR];
  1186.    char fname[FILE_MAX_FNAME];
  1187.    char ext[FILE_MAX_EXT];
  1188.  
  1189.    ENTER_OVLY(OVLY_PROMPTS2);
  1190.  
  1191.    /* steal existing array for "choices" */
  1192.    choices[0] = (struct CHOICE *)boxy;
  1193.    attributes[0] = 1;
  1194.    for(i=1;i<MAXNUMFILES;i++)
  1195.    {
  1196.       choices[i] = choices[i-1] + 1;
  1197.       attributes[i] = 1;
  1198.    }
  1199.  
  1200. restart:  /* return here if template or directory changes */
  1201.  
  1202.    tmpmask[0] = 0;
  1203.    if(flname[0] == 0)
  1204.       strcpy(flname,DOTSLASH);
  1205.    splitpath(flname ,drive,dir,fname,ext);
  1206.    makepath(filename,""   ,"" ,fname,ext);
  1207.    retried = 0;
  1208. retry_dir:
  1209.    if (dir[0] == 0)
  1210.       strcpy(dir,".");
  1211.    expand_dirname(dir,drive);
  1212.    makepath(tmpmask,drive,dir,"","");
  1213.    fix_dirname(tmpmask);
  1214.    if (retried == 0 && strcmp(dir,SLASH) && strcmp(dir,DOTSLASH))
  1215.    {
  1216.       tmpmask[(j = strlen(tmpmask) - 1)] = 0; /* strip trailing \ */
  1217.       if (strchr(tmpmask,'*') || strchr(tmpmask,'?')
  1218.     || findfirst(tmpmask) != 0
  1219.     || (DTA.attribute & SUBDIR) == 0)
  1220.       {
  1221.          strcpy(dir,DOTSLASH);
  1222.      ++retried;
  1223.      goto retry_dir;
  1224.       }
  1225.       tmpmask[j] = SLASHC;
  1226.    }
  1227.    if(template[0])
  1228.    {
  1229.       numtemplates = 1;
  1230.       splitpath(template,NULL,NULL,fname,ext);
  1231.    }
  1232.    else
  1233.       numtemplates = sizeof(masks)/sizeof(masks[0]);
  1234.    filecount = -1;
  1235.    dircount  = 0;
  1236.    notroot   = 0;
  1237.    j = 0;
  1238.    masklen = strlen(tmpmask);
  1239.    strcat(tmpmask,"*.*");
  1240.    out = findfirst(tmpmask);
  1241.    while(out == 0 && filecount < MAXNUMFILES)
  1242.    {
  1243.       if((DTA.attribute & SUBDIR) && strcmp(DTA.filename,"."))
  1244.       {
  1245. #ifndef XFRACT
  1246.      strlwr(DTA.filename);
  1247. #endif
  1248.      if(strcmp(DTA.filename,".."))
  1249.             strcat(DTA.filename,SLASH);
  1250.      strncpy(choices[++filecount]->name,DTA.filename,13);
  1251.      choices[filecount]->name[12] = '\0';
  1252.      choices[filecount]->type = 1;
  1253.      dircount++;
  1254.      if(strcmp(DTA.filename,"..")==0)
  1255.         notroot = 1;
  1256.       }
  1257.       out = findnext();
  1258.    }
  1259.    tmpmask[masklen] = 0;
  1260.    if(template[0])
  1261.       makepath(tmpmask,drive,dir,fname,ext);
  1262.    do
  1263.    {
  1264.       if(numtemplates > 1)
  1265.      strcpy(&(tmpmask[masklen]),masks[j]);
  1266.       out = findfirst(tmpmask);
  1267.       while(out == 0 && filecount < MAXNUMFILES)
  1268.       {
  1269.      if(!(DTA.attribute & SUBDIR))
  1270.      {
  1271.         strlwr(DTA.filename);
  1272.         strncpy(choices[++filecount]->name,DTA.filename,13);
  1273.         choices[filecount]->type = 0;
  1274.      }
  1275.      out = findnext();
  1276.       }
  1277.    }
  1278.    while (++j < numtemplates);
  1279.    if (++filecount == 0)
  1280.    {
  1281.       strcpy(choices[filecount]->name,"*nofiles*");
  1282.       choices[filecount]->type = 0;
  1283.       ++filecount;
  1284.    }
  1285.    qsort(choices,filecount,sizeof(char *),lccompare); /* sort type list */
  1286.    if(notroot == 0 && dir[0] && dir[0] != SLASHC) /* must be in root directory */
  1287.    {
  1288.       splitpath(tmpmask,drive,dir,fname,ext);
  1289.       strcpy(dir,SLASH);
  1290.       makepath(tmpmask,drive,dir,fname,ext);
  1291.    }
  1292.    if(numtemplates > 1)
  1293.       strcat(tmpmask," *.pot");
  1294.    strcpy(temp1,hdg);
  1295.    strcat(temp1,"\nTemplate: ");
  1296.    strcat(temp1,tmpmask);
  1297.    strcpy(speedstr,filename);
  1298.    if (speedstr[0] == 0)
  1299.    {
  1300.       for (i=0; i<filecount; i++) /* find first file */
  1301.      if (choices[i]->type == 0)
  1302.         break;
  1303.       if (i >= filecount)
  1304.      i = 0;
  1305.    }
  1306.    i = fullscreen_choice(8,temp1,NULL,instr,filecount,(char **)choices,
  1307.           attributes,5,99,12,i,NULL,speedstr,filename_speedstr,check_f6_key);
  1308.    if (i==-F6)
  1309.    {
  1310.       static int lastdir=0;
  1311.       if (lastdir==0)
  1312.       {
  1313.      strcpy(dir,fract_dir1);
  1314.       }
  1315.       else
  1316.       {
  1317.      strcpy(dir,fract_dir2);
  1318.       }
  1319.       fix_dirname(dir);
  1320.        makepath(flname,drive,dir,"","");
  1321.        lastdir = 1-lastdir;
  1322.        goto restart;
  1323.    }
  1324.    if (i < 0)
  1325.    {
  1326.       EXIT_OVLY;
  1327.       return(-1);
  1328.    }
  1329.    if(speedstr[0] == 0 || speedstate == MATCHING)
  1330.    {
  1331.       if(choices[i]->type)
  1332.       {
  1333.      if(strcmp(choices[i]->name,"..") == 0) /* go up a directory */
  1334.      {
  1335.         if(strcmp(dir,DOTSLASH) == 0)
  1336.            strcpy(dir,DOTDOTSLASH);
  1337.         else
  1338.         {
  1339.            char *s;
  1340.            if(s = strrchr(dir,SLASHC)) /* trailing slash */
  1341.            {
  1342.           *s = 0;
  1343.           if(s = strrchr(dir,SLASHC))
  1344.              *(s+1) = 0;
  1345.            }
  1346.         }
  1347.      }
  1348.      else  /* go down a directory */
  1349.         strcat(dir,choices[i]->name);
  1350.      fix_dirname(dir);
  1351.      makepath(flname,drive,dir,"","");
  1352.      goto restart;
  1353.       }
  1354.       splitpath(choices[i]->name,NULL,NULL,fname,ext);
  1355.       makepath(flname,drive,dir,fname,ext);
  1356.    }
  1357.    else
  1358.    {
  1359.       if (speedstate == SEARCHPATH
  1360.     && strchr(speedstr,'*') == 0 && strchr(speedstr,'?') == 0
  1361.     && findfirst(speedstr) == 0
  1362.     && (DTA.attribute & SUBDIR)) /* it is a directory */
  1363.      speedstate = TEMPLATE;
  1364.       if(speedstate == TEMPLATE)
  1365.       {
  1366.      /* extract from tempstr the pathname and template information,
  1367.         being careful not to overwrite drive and directory if not
  1368.         newly specified */
  1369.      char drive1[FILE_MAX_DRIVE];
  1370.      char dir1[FILE_MAX_DIR];
  1371.      char fname1[FILE_MAX_FNAME];
  1372.      char ext1[FILE_MAX_EXT];
  1373.      splitpath(speedstr,drive1,dir1,fname1,ext1);
  1374.      if(drive1[0])
  1375.         strcpy(drive,drive1);
  1376.      if(dir1[0])
  1377.         strcpy(dir,dir1);
  1378.      makepath(flname,drive,dir,fname1,ext1);
  1379.      if(strchr(fname1,'*') || strchr(fname1,'?') ||
  1380.          strchr(ext1  ,'*') || strchr(ext1  ,'?'))
  1381.         makepath(template,"","",fname1,ext1);
  1382.      else if(isadirectory(flname))
  1383.         fix_dirname(flname);
  1384.      goto restart;
  1385.       }
  1386.       else /* speedstate == SEARCHPATH */
  1387.       {
  1388.      char fullpath[80];
  1389.       /* if (strchr(speedstr,'.') == NULL)
  1390.         strcat(speedstr,".gif"); */
  1391.      findpath(speedstr,fullpath);
  1392.      if(fullpath[0])
  1393.         strcpy(flname,fullpath);
  1394.      else
  1395.      {  /* failed, make diagnostic useful: */
  1396.         strcpy(flname,speedstr);
  1397.         if (strchr(speedstr,SLASHC) == NULL)
  1398.         {
  1399.            splitpath(speedstr,NULL,NULL,fname,ext);
  1400.            makepath(flname,drive,dir,fname,ext);
  1401.         }
  1402.      }
  1403.       }
  1404.    }
  1405.    EXIT_OVLY;
  1406.    return(0);
  1407. }
  1408.  
  1409. static int check_f6_key(int curkey,int choice)
  1410. {
  1411.    if (curkey == F6)
  1412.       return 0-F6;
  1413.    return 0;
  1414. }
  1415.  
  1416. static int filename_speedstr(int row, int col, int vid,
  1417.                  char *speedstring, int speed_match)
  1418. {
  1419.    extern char speed_prompt[];
  1420.    char *prompt;
  1421.    if ( strchr(speedstring,':')
  1422.      || strchr(speedstring,'*') || strchr(speedstring,'*')
  1423.      || strchr(speedstring,'?')) {
  1424.       speedstate = TEMPLATE;  /* template */
  1425.       prompt = "File Template";
  1426.       }
  1427.    else if (speed_match) {
  1428.       speedstate = SEARCHPATH; /* does not match list */
  1429.       prompt = "Search Path for";
  1430.       }
  1431.    else {
  1432.       speedstate = MATCHING;
  1433.       prompt = speed_prompt;
  1434.       }
  1435.    putstring(row,col,vid,prompt);
  1436.    return(strlen(prompt));
  1437. }
  1438.  
  1439. static int isadirectory(char *s)
  1440. {
  1441.    if(strchr(s,'*') || strchr(s,'?'))
  1442.       return(0); /* for my purposes, not a directory */
  1443.    if(findfirst(s) != 0) /* couldn't find it */
  1444.    {
  1445.       /* any better ideas?? */
  1446.       if(strchr(s,SLASHC)) /* we'll guess it is a directory */
  1447.      return(1);
  1448.       else
  1449.      return(0);  /* no slashes - we'll guess it's a file */
  1450.    }
  1451.    else if(DTA.attribute & SUBDIR)
  1452.       return(1);   /* we're SURE it's a directory */
  1453.    else
  1454.       return(0);
  1455. }
  1456.  
  1457.  
  1458. #ifndef XFRACT    /* This routine moved to unix.c so we can use it in hc.c */
  1459. int splitpath(char *template,char *drive,char *dir,char *fname,char *ext)
  1460. {
  1461.    int length;
  1462.    int len;
  1463.    int offset;
  1464.    char *tmp;
  1465.  
  1466.    if(drive)
  1467.       drive[0] = 0;
  1468.    if(dir)
  1469.       dir[0]   = 0;
  1470.    if(fname)
  1471.       fname[0] = 0;
  1472.    if(ext)
  1473.       ext[0]   = 0;
  1474.  
  1475.    if((length = strlen(template)) == 0)
  1476.       return(0);
  1477.    offset = 0;
  1478.  
  1479.    /* get drive */
  1480.    if(length >= 2)
  1481.       if(template[1] == ':')
  1482.       {
  1483.      if(drive)
  1484.      {
  1485.         drive[0] = template[offset++];
  1486.         drive[1] = template[offset++];
  1487.         drive[2] = 0;
  1488.      }
  1489.      else
  1490.      {
  1491.         offset++;
  1492.         offset++;
  1493.      }
  1494.       }
  1495.  
  1496.    /* get dir */
  1497.    if(offset < length)
  1498.    {
  1499.       tmp = strrchr(template,SLASHC);
  1500.       if(tmp)
  1501.       {
  1502.      tmp++;  /* first character after slash */
  1503.      len = tmp - &template[offset];
  1504.      if(len >=0 && len < 80 && dir)
  1505.         strncpy(dir,&template[offset],len);
  1506.      if(len < 80 && dir)
  1507.         dir[len] = 0;
  1508.      offset += len;
  1509.       }
  1510.    }
  1511.    else
  1512.       return(0);
  1513.  
  1514.    /* get fname */
  1515.    if(offset < length)
  1516.    {
  1517.       tmp = strrchr(template,'.');
  1518.       if(tmp < strrchr(template,SLASHC) || tmp < strrchr(template,':'))
  1519.      tmp = 0; /* in this case the '.' must be a directory */
  1520.       if(tmp)
  1521.       {
  1522.      tmp++; /* first character past "." */
  1523.      len = tmp - &template[offset];
  1524.      if((len > 0) && (offset+len < length) && fname)
  1525.      {
  1526.         strncpy(fname,&template[offset],len);
  1527.         fname[len] = 0;
  1528.      }
  1529.      offset += len;
  1530.      if((offset < length) && ext)
  1531.         strcpy(ext,&template[offset]);
  1532.       }
  1533.       else if((offset < length) && fname)
  1534.      strcpy(fname,&template[offset]);
  1535.    }
  1536.    return(0);
  1537. }
  1538. #endif
  1539.  
  1540. makepath(char *template,char *drive,char *dir,char *fname,char *ext)
  1541. {
  1542. #ifndef XFRACT
  1543.    strcpy(template,drive);
  1544.    strcat(template,dir);
  1545. #else
  1546.    strcpy(template,dir);
  1547. #endif
  1548.    strcat(template,fname);
  1549.    strcat(template,ext);
  1550.    return(0);
  1551. }
  1552.  
  1553.  
  1554. /* fix up directory names */
  1555. static void fix_dirname(char *dirname)
  1556. {
  1557.    int length;
  1558.    /* scrub white space from end for safety */
  1559.    length = strlen(dirname); /* index of last character */
  1560.    while (--length >= 0 && isspace(dirname[length])) { }
  1561.    dirname[++length] = 0;
  1562.    /* make sure dirname ends with a slash */
  1563.    if(length == 0 || dirname[length-1] != SLASHC)
  1564.       strcat(dirname,SLASH);
  1565. }
  1566.  
  1567. static int expand_dirname(char *dirname,char *drive)
  1568. {
  1569.    fix_dirname(dirname);
  1570.    if (dirname[0] != SLASHC) {
  1571.       char buf[81],curdir[81];
  1572. #ifndef XFRACT
  1573.       union REGS regs;
  1574.       struct SREGS sregs;
  1575.       curdir[0] = 0;
  1576.       regs.h.ah = 0x47; /* get current directory */
  1577.       regs.h.dl = 0;
  1578.       if (drive[0] && drive[0] != ' ')
  1579.      regs.h.dl = tolower(drive[0])-'a'+1;
  1580.       regs.x.si = (unsigned int) &curdir[0];
  1581.       segread(&sregs);
  1582.       intdosx(®s, ®s, &sregs);
  1583. #else
  1584.       getwd(curdir);
  1585. #endif
  1586.       strcat(curdir,SLASH);
  1587.       while (strncmp(dirname,DOTSLASH,2) == 0) {
  1588.      strcpy(buf,&dirname[2]);
  1589.      strcpy(dirname,buf);
  1590.      }
  1591.       while (strncmp(dirname,DOTDOTSLASH,3) == 0) {
  1592.      char *s;
  1593.      curdir[strlen(curdir)-1] = 0; /* strip trailing slash */
  1594.      if (s = strrchr(curdir,SLASHC))
  1595.         *s = 0;
  1596.      strcat(curdir,SLASH);
  1597.      strcpy(buf,&dirname[3]);
  1598.      strcpy(dirname,buf);
  1599.      }
  1600.       strcpy(buf,dirname);
  1601.       dirname[0] = 0;
  1602.       if (curdir[0] != SLASHC)
  1603.      strcpy(dirname,SLASH);
  1604.       strcat(dirname,curdir);
  1605.       strcat(dirname,buf);
  1606.       }
  1607.    return(0);
  1608. }
  1609.  
  1610. #define LOADPROMPTS(X)     {\
  1611.    static char far tmp[] = { X };\
  1612.    prompts[++nump]= tmp;\
  1613.    }
  1614.  
  1615. int get_corners()
  1616. {
  1617.    struct fullscreenvalues values[15];
  1618.    char far *prompts[15];
  1619.    static char far xprompt[]={"          X"};
  1620.    static char far yprompt[]={"          Y"};
  1621.    static char far zprompt[]={"          Z"};
  1622.    int i,nump,prompt_ret;
  1623.    int cmag,transp3d;
  1624.    double Xctr,Yctr,Mag;
  1625.    BYTE ousemag;
  1626.    double oxxmin,oxxmax,oyymin,oyymax,oxx3rd,oyy3rd;
  1627.    double ozzmin,ozzmax,ottmin,ottmax;
  1628.    /* note that hdg[15] is used for non-transparent heading: */
  1629.    static char far hdg[]={"Transparent 3d Image Coordinates"};
  1630.    int oldhelpmode;
  1631.  
  1632.    transp3d = (Transparent3D && fractalspecific[fractype].orbitcalc == Formula);
  1633.    oldhelpmode = helpmode;
  1634.    ousemag = usemag;
  1635.    oxxmin = xxmin; oxxmax = xxmax;
  1636.    oyymin = yymin; oyymax = yymax;
  1637.    oxx3rd = xx3rd; oyy3rd = yy3rd;
  1638.    ozzmin = zzmin; ozzmax = zzmax;
  1639.    ottmin = ttmin; ottmax = ttmax;
  1640.  
  1641. gc_loop:
  1642.    for (i = 0; i < 15; ++i)
  1643.       values[i].type = 'd'; /* most values on this screen are type d */
  1644.    cmag = (!transp3d && usemag && cvtcentermag(&Xctr, &Yctr, &Mag));
  1645.  
  1646.    nump = -1;
  1647.    if (cmag) {
  1648.       LOADPROMPTS("Center X");
  1649.       values[nump].uval.dval = Xctr;
  1650.       LOADPROMPTS("Center Y");
  1651.       values[nump].uval.dval = Yctr;
  1652.       LOADPROMPTS("Magnification");
  1653.       values[nump].uval.dval = Mag;
  1654.       LOADPROMPTS("");
  1655.       values[nump].type = '*';
  1656.       LOADPROMPTS("Press F7 to switch to \"corners\" mode");
  1657.       values[nump].type = '*';
  1658.       }
  1659.  
  1660.    else {
  1661.       LOADPROMPTS("Top-Left Corner");
  1662.       values[nump].type = '*';
  1663.       prompts[++nump] = xprompt;
  1664.       values[nump].uval.dval = xxmin;
  1665.       prompts[++nump] = yprompt;
  1666.       values[nump].uval.dval = yymax;
  1667.       if (transp3d) {
  1668.          prompts[++nump] = zprompt;
  1669.          values[nump].uval.dval = zzmin;
  1670.       }
  1671.       LOADPROMPTS("Bottom-Right Corner");
  1672.       values[nump].type = '*';
  1673.       prompts[++nump] = xprompt;
  1674.       values[nump].uval.dval = xxmax;
  1675.       prompts[++nump] = yprompt;
  1676.       values[nump].uval.dval = yymin;
  1677.       if (transp3d) {
  1678.      prompts[++nump] = zprompt;
  1679.      values[nump].uval.dval = zzmax;
  1680.      }
  1681.       if (transp3d) {
  1682.      LOADPROMPTS("Time Step");
  1683.      values[nump].type = '*';
  1684.      LOADPROMPTS("          From");
  1685.      values[nump].uval.dval = ttmin;
  1686.      LOADPROMPTS("          To");
  1687.      values[nump].uval.dval = ttmax;
  1688.      }
  1689.       else {
  1690.      if (xxmin == xx3rd && yymin == yy3rd)
  1691.         xx3rd = yy3rd = 0;
  1692.      LOADPROMPTS("Bottom-left (zeros for top-left X, bottom-right Y)");
  1693.      values[nump].type = '*';
  1694.      prompts[++nump] = xprompt;
  1695.      values[nump].uval.dval = xx3rd;
  1696.      prompts[++nump] = yprompt;
  1697.      values[nump].uval.dval = yy3rd;
  1698.      LOADPROMPTS("Press F7 to switch to \"center-mag\" mode");
  1699.      values[nump].type = '*';
  1700.      }
  1701.       }
  1702.  
  1703.    LOADPROMPTS("Press F4 to reset to type default values");
  1704.    values[nump].type = '*';
  1705.  
  1706.    oldhelpmode = helpmode;
  1707.    helpmode = HELPCOORDS;
  1708.    prompt_ret = fullscreen_prompt((transp3d) ? hdg : &hdg[15],
  1709.              nump+1, prompts, values, 0,
  1710.              (transp3d) ? 0x10 : 0x90, /* function keys */
  1711.              NULL);
  1712.    helpmode = oldhelpmode;
  1713.  
  1714.    if (prompt_ret < 0) {
  1715.       usemag = ousemag;
  1716.       xxmin = oxxmin; xxmax = oxxmax;
  1717.       yymin = oyymin; yymax = oyymax;
  1718.       xx3rd = oxx3rd; yy3rd = oyy3rd;
  1719.       zzmin = ozzmin; zzmax = ozzmax;
  1720.       ttmin = ottmin; ttmax = ottmax;
  1721.       return -1;
  1722.       }
  1723.  
  1724.    if (prompt_ret == F4) { /* reset to type defaults */
  1725.       xx3rd = xxmin = curfractalspecific->xmin;
  1726.       xxmax        = curfractalspecific->xmax;
  1727.       yy3rd = yymin = curfractalspecific->ymin;
  1728.       yymax        = curfractalspecific->ymax;
  1729.       if (viewcrop && finalaspectratio != screenaspect)
  1730.      aspectratio_crop(screenaspect,finalaspectratio);
  1731.       goto gc_loop;
  1732.       }
  1733.  
  1734.    if (cmag) {
  1735.       if ( values[0].uval.dval != Xctr
  1736.     || values[1].uval.dval != Yctr
  1737.     || values[2].uval.dval != Mag) {
  1738.      double radius,width;
  1739.      radius = 1.0 / values[2].uval.dval;
  1740.      width = radius * (1.0 / screenaspect);
  1741.      yymax           = values[1].uval.dval + radius;
  1742.      yy3rd = yymin = values[1].uval.dval - radius;
  1743.      xxmax           = values[0].uval.dval + width;
  1744.      xx3rd = xxmin = values[0].uval.dval - width;
  1745.      }
  1746.       }
  1747.  
  1748.    else {
  1749.       nump = 1;
  1750.       xxmin = values[nump++].uval.dval;
  1751.       yymax = values[nump++].uval.dval;
  1752.       if (transp3d)
  1753.      zzmin = values[nump++].uval.dval;
  1754.       nump++;
  1755.       xxmax = values[nump++].uval.dval;
  1756.       yymin = values[nump++].uval.dval;
  1757.       if (transp3d)
  1758.      zzmax = values[nump++].uval.dval;
  1759.       nump++;
  1760.       if (transp3d) {
  1761.      ttmin = values[nump++].uval.dval;
  1762.      ttmax = values[nump++].uval.dval;
  1763.      }
  1764.       else {
  1765.      xx3rd = values[nump++].uval.dval;
  1766.      yy3rd = values[nump++].uval.dval;
  1767.      if (xx3rd == 0 && yy3rd == 0) {
  1768.         xx3rd = xxmin;
  1769.         yy3rd = yymin;
  1770.         }
  1771.      }
  1772.       }
  1773.  
  1774.    if (prompt_ret == F7) { /* toggle corners/center-mag mode */
  1775.       if (usemag == 0)
  1776.      if (cvtcentermag(&Xctr, &Yctr, &Mag) == 0)
  1777.      {
  1778.         static char far msg[] = 
  1779.            {"Corners rotated or stretched, can't use center-mag"};
  1780.         stopmsg(0,msg);
  1781.      }   
  1782.      else
  1783.         usemag = 1;
  1784.       else
  1785.      usemag = 0;
  1786.       goto gc_loop;
  1787.       }
  1788.  
  1789.    return((xxmin == oxxmin && xxmax == oxxmax
  1790.     && yymin == oyymin && yymax == oyymax
  1791.     && xx3rd == oxx3rd && yy3rd == oyy3rd
  1792.     && zzmin == ozzmin && zzmax == ozzmax
  1793.     && ttmin == ottmin && ttmax == ottmax) ? 0 : 1);
  1794. }
  1795.