home *** CD-ROM | disk | FTP | other *** search
/ ProfitPress Mega CDROM2 …eeware (MSDOS)(1992)(Eng) / ProfitPress-MegaCDROM2.B6I / WINDOWS / PROGRAM / WINSRC20.ZIP / CMDFILES.C < prev    next >
Encoding:
C/C++ Source or Header  |  1990-10-17  |  39.6 KB  |  1,300 lines

  1. /*
  2.     Command-line / Command-File Parser Routines
  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 <float.h>
  10. #include <ctype.h>
  11. #include "fractint.h"
  12. #ifdef __TURBOC__
  13. #include <dir.h>
  14. #endif
  15.  
  16. /* routines in this module    */
  17.  
  18. void cmdfiles_overlay(void);
  19. int  cmdfiles(int argc, char *argv[]);
  20. void set_3d_defaults(void);
  21. int  readconfig(void);
  22.  
  23. static void cmdfile(FILE *);
  24. static int  cmdarg(char *);
  25. static void argerror(char *);
  26. static void makeconfig(void);
  27.  
  28. /* variables defined by the command line/files processor */
  29. char    temp1[256];        /* temporary strings        */
  30. char    ifsfilename[80];    /* IFS code file */
  31. char    readname[80];        /* name of fractal input file */
  32. int    potflag=0;        /* continuous potential enabled? */
  33. int    pot16bit;        /* store 16 bit continuous potential values */
  34. char    savename[80];        /* save files using this name */
  35. char    ifs3dfilename[80];    /* IFS 3D code file */
  36. int    gif87a_flag;        /* 1 if GIF87a format, 0 otherwise */
  37. int    askvideo;        /* flag for video prompting */
  38. char    floatflag;
  39. int    biomorph;        /* flag for biomorph */
  40. int    forcesymmetry;        /* force symmetry */
  41. int    showfile;        /* zero if file display pending */
  42. int    rflag, rseed;        /* Random number seeding flag and value */
  43. int    decomp[2];        /* Decomposition coloring */
  44. int    distest;
  45. int    warn;            /* 0 if savename warnings off, 1 if on */
  46. int    soundflag;        /* 0 if sound is off, 1 if on */
  47. int    basehertz;        /* sound=x/y/x hertz value */
  48. int    debugflag;        /* internal use only - you didn't see this */
  49. int    timerflag;        /* you didn't see this, either */
  50. int    cyclelimit;        /* color-rotator upper limit */
  51. int    inside;         /* inside color: 1=blue     */
  52. int    outside;        /* outside color    */
  53. int    finattract;        /* finite attractor logic */
  54. int    display3d;        /* 3D display flag: 0 = OFF */
  55. int    overlay3d;        /* 3D overlay flag: 0 = OFF */
  56. int    init3d[20];        /* '3d=nn/nn/nn/...' values */
  57. int    initbatch;        /* 1 if batch run (no kbd)  */
  58. unsigned initsavetime;        /* autosave minutes        */
  59. double    initorbit[2];        /* initial orbitvalue */
  60. char    useinitorbit;        /* flag for initorbit */
  61. int    initmode;        /* initial video mode        */
  62. int    initincr;        /* initial maxiter incrmnt  */
  63. int    initcyclelimit;     /* initial cycle limit        */
  64. unsigned char usemag;        /* use center-mag corners   */
  65. int    bailout;        /* user input bailout value */
  66. double    inversion[3];        /* radius, xcenter, ycenter */
  67. extern    int invert;
  68. extern int fractype;        /* fractal type         */
  69. extern double param[4];     /* initial parameters        */
  70. extern double xxmin,xxmax;    /* initial corner values    */
  71. extern double yymin,yymax;    /* initial corner values    */
  72. extern double xx3rd,yy3rd;    /* initial corner values    */
  73. extern char usr_stdcalcmode;    /* '1', '2', 'g', 'b'       */
  74. extern int maxit;        /* max iterations        */
  75. extern int usr_periodicitycheck; /* periodicity checking  1=on,0=off */
  76. extern char usr_floatflag;    /* flag for float calcs */
  77. extern int usr_distest;     /* nonzero if distance estimator option */
  78. extern char color_lakes;    /* finite attractor flag */
  79. extern int haze;
  80. extern int RANDOMIZE;
  81. extern int Ambient;
  82. extern int full_color;
  83. extern char light_name[];
  84. extern char back_color[];
  85.  
  86. extern double potparam[];    /* potential parameters  */
  87. extern int Printer_Resolution, LPTNumber,
  88.            Printer_Type, Printer_Titleblock,
  89.            Printer_ColorXlat, Printer_SetScreen,
  90.            Printer_SFrequency, Printer_SAngle,
  91.            Printer_SStyle;                          /* for printer functions */
  92.  
  93.  
  94. int    transparent[2];     /* transparency min/max values */
  95. int    LogFlag;            /* Logarithmic palette flag: 0 = no */
  96.  
  97. char FormFileName[80];        /* file to find (type=)formulas in */
  98. char FormName[40];        /* Name of the Formula (if not null) */
  99.  
  100. extern int video_type;
  101. extern int no_color_text;
  102. extern unsigned char olddacbox[256][3];    /* Video-DAC saved values */
  103. extern unsigned char dacbox[256][3];       /* Video-DAC values */
  104.  
  105. extern int   viewwindow;
  106. extern float viewreduction;
  107. extern int   viewcrop;
  108. extern float finalaspectratio;
  109. extern int   viewxdots,viewydots;
  110.  
  111. extern    char *fkeys[];        /* Function Key names for display table */
  112.  
  113. static    int toolsfile;        /* 1 if inside a TOOLS file, 0 otherwise */
  114.  
  115. extern char MAP_name[];
  116. extern int mapset;
  117. extern char loadPalette;
  118.  
  119. extern int eyeseparation; /* Occular Separation */
  120. extern int glassestype;
  121. extern int xadjust; /* Convergence */
  122. extern int yadjust;
  123. extern int xtrans, ytrans; /* X,Y shift with no perspective */
  124. extern int red_crop_left, red_crop_right;
  125. extern int blue_crop_left, blue_crop_right;
  126. extern int red_bright, blue_bright;
  127. extern char showbox; /* flag to show box and vector in preview */
  128. extern char preview;        /* 3D preview mode flag */
  129. extern int previewfactor; /* Coarsness */
  130.  
  131. static int first_init=1;    /* first time into cmdfiles? */
  132. static int init_rseed;
  133. static int initcorners;     /* corners set flag */
  134.  
  135.  
  136. void cmdfiles_overlay() { }    /* for restore_active_ovly */
  137.  
  138. char LFileName[80]; /* file to find (type=)L-System's in */
  139. char LName[40];    /* Name of L-System */
  140.  
  141. extern int  active_system;        /* 0=dos, 1=windows */
  142.  
  143. /*
  144.     cmdfiles(argc,argv) process the command-line arguments
  145.         it also processes the 'sstools.ini' file and any
  146.         indirect files ('fractint @myfile')
  147. */
  148.  
  149. int cmdfiles(argc,argv)
  150. int argc;
  151. char *argv[];
  152. {
  153. double    atof(), ftemp;            /* floating point stuff    */
  154. int    i, j, k, l;            /* temporary loop counters */
  155.  
  156. char    curarg[141];            /* temporary strings        */
  157.  
  158. char tempstring[101];            /* temporary strings        */
  159. FILE *initfile;             /* for .INI, '@' files      */
  160.  
  161. ENTER_OVLY(OVLY_CMDFILES);
  162.  
  163. gif87a_flag = 0;            /* turn on GIF89a processing */
  164.  
  165. usr_periodicitycheck = 1;        /* turn on periodicity      */
  166. rflag = 0;                /* not a fixed srand() seed */
  167. if (first_init)
  168.     init_rseed = (int)time(NULL);
  169. rseed = init_rseed;
  170. usr_floatflag = 0;            /* turn off the float flag */
  171. biomorph = -1;                /* turn off biomorph flag */
  172. askvideo = 1;                /* turn on video-prompt flag */
  173. warn = 0;                /* no warnings on savename */
  174. soundflag = -1;             /* sound is on          */
  175. basehertz = 440;            /* basic hertz rate */
  176. initbatch = 0;                /* not in batch mode      */
  177. initsavetime = 0;            /* no auto-save       */
  178. initmode = -1;                /* no initial video mode  */
  179. inside = 1;                /* inside color = blue      */
  180. outside = -1;                /* outside color = -1 (not used) */
  181. finattract = 0;             /* disable finite attractor logic */
  182. maxit = 150;                /* initial maxiter      */
  183. initincr = 50;                /* initial iter increment */
  184. usr_stdcalcmode = 'g';                  /* initial solid-guessing */
  185. fractype = 0;                /* initial type Set flag  */
  186. initcorners = 0;            /* initial flag: no corners */
  187. usemag = 0;                /* use corners, not center-mag */
  188. bailout = 0;                /* no user-entered bailout */
  189. for (i = 0; i < 4; i++) param[i] = FLT_MAX; /* initial parameter values */
  190. for (i = 0; i < 3; i++) potparam[i]  = 0.0; /* initial potential values */
  191. for (i = 0; i < 3; i++) inversion[i] = 0.0;  /* initial invert values */
  192. invert = 0;
  193. decomp[0] = decomp[1] = 0;
  194. usr_distest = 0;
  195. initorbit[0] = initorbit[1] = 0.0;    /* initial orbit values */
  196. useinitorbit = 0;
  197. forcesymmetry = 999;            /* symmetry not forced */
  198.  
  199. viewwindow = 0;             /* full screen */
  200. viewreduction = 4.2;
  201. viewcrop = 1;
  202. finalaspectratio = SCREENASPECT;
  203. viewxdots = viewydots = 0;
  204.  
  205. xx3rd = xxmin = -2.5; xxmax = 1.5;    /* initial corner values  */
  206. yy3rd = yymin = -1.5; yymax = 1.5;    /* initial corner values  */
  207. pot16bit = potflag = 0;
  208. initcyclelimit=55;            /* spin-DAC default speed limit */
  209. transparent[0] = transparent[1] = 0;        /* no min/max transparency */
  210. LogFlag = 0;                    /* no logarithmic palette */
  211. strcpy(ifsfilename,".\\");                      /* initially current directory */
  212. strcpy(ifs3dfilename,".\\");                    /* initially current directory */
  213. mapset = 0;                    /* no map= name active */
  214. loadPalette = 0;
  215.  
  216. debugflag = 0;                    /* debugging flag(s) are off */
  217. timerflag = 0;                    /* timer flags are off        */
  218.  
  219. display3d = 0;                    /* 3D display is off        */
  220. overlay3d = 0;                    /* 3D overlay is off        */
  221.  
  222. /* 3D defaults */
  223. SPHERE = FALSE;
  224. preview = 0;
  225. showbox = 0;
  226. previewfactor = 20;
  227. xadjust = 0;
  228. yadjust = 0;
  229. eyeseparation = 0;
  230. glassestype = 0;
  231. xtrans = 0;
  232. ytrans = 0;
  233. red_crop_left    = 4;
  234. red_crop_right    = 0;
  235. blue_crop_left    = 0;
  236. blue_crop_right = 4;
  237. red_bright     = 80;
  238. blue_bright   = 100;
  239. set_3d_defaults();
  240.  
  241. set_trig_array(0,"sin");                        /* trigfn defaults */
  242. set_trig_array(1,"sqr");
  243. set_trig_array(2,"sinh");
  244. set_trig_array(3,"cosh");
  245.  
  246. strcpy(readname,".\\");                         /* initially current directory */
  247. showfile = 1;
  248.  
  249. Printer_Type = 2;                /* assume an IBM/EPSON */
  250. Printer_Resolution = 60;            /* assume low resolution */
  251. Printer_Titleblock = 0;                         /* assume no title block */
  252. Printer_ColorXlat = 0;                           /* assume positive image */
  253. Printer_SetScreen = 0;                          /* assume default screen */
  254. Printer_SFrequency = 0;                         /* New screen frequency  */
  255. Printer_SAngle = 0;                             /* New screen angle      */
  256. Printer_SStyle = 0;                             /* New screen style      */
  257.  
  258. LPTNumber = 1;                    /* assume LPT1 */
  259.  
  260. strcpy(FormFileName,"fractint.frm");            /* default formula file */
  261. strcpy(FormName,"");                            /* default formula name */
  262.  
  263. strcpy(LFileName,"fractint.l");
  264. strcpy(LName,"");
  265.  
  266. if (first_init) {
  267.     strcpy(savename,"fract001");            /* initial save filename  */
  268.     strcpy(light_name,"light001.tga");      /* initial light filename */
  269.     }
  270.  
  271.  
  272. toolsfile = 1;                    /* enable TOOLS processing */
  273.  
  274. findpath("sstools.ini", tempstring);            /* look for SSTOOLS.INI */
  275. if (tempstring[0] != 0)             /* found it! */
  276.     if ((initfile = fopen(tempstring,"r")) != NULL)
  277.         cmdfile(initfile);        /* process it */
  278.  
  279. toolsfile = 0;                    /* disable TOOLS processing */
  280.  
  281. for (i = 1; i < argc; i++) {            /* cycle through args    */
  282.     strcpy(curarg,argv[i]);
  283.     strlwr(curarg);             /* using lower case    */
  284.     for (j = 1; j < strlen(curarg) && curarg[j] != '='; j++) ;
  285.  
  286.     if (j < strlen(curarg)) {        /* xxx=yyy argument? */
  287.         cmdarg(curarg);         /* process it */
  288.         continue;
  289.         }
  290.  
  291.     if (curarg[0] == ';')                   /* start of comments? */
  292.         break;                /* we done! */
  293.  
  294.     if (curarg[0] == '@') {                 /* command indirection? */
  295.         if ((initfile = fopen(&curarg[1],"r")) != NULL) {
  296.             cmdfile(initfile);    /* process it */
  297.             continue;
  298.             }
  299.         else argerror(curarg);        /* oops.  error. */
  300.         }
  301.  
  302.     strcpy(readname,curarg);        /* else, assume a filename */
  303.     showfile = 0;
  304.  
  305.     }
  306.  
  307. for (i = 0; i < 4; i++) {
  308.     if (param[i] != FLT_MAX)
  309.         fractalspecific[fractype].paramvalue[i] = param[i];
  310.     else
  311.         param[i] = fractalspecific[fractype].paramvalue[i];
  312.     }
  313.  
  314. first_init = 0;
  315. EXIT_OVLY;
  316. return(0);                    /* we done */
  317. }
  318.  
  319. /*
  320.     cmdfile(handle) processes a single command-file.
  321.         if (toolsfile), it looks for '[...]' codes as well
  322. */
  323.  
  324. static void cmdfile(handle)        /* process a command file of some sort */
  325. FILE *handle;
  326. {
  327. char line[513];
  328. int toolssection;
  329. int i, j;
  330.  
  331. toolssection = 1;            /* assume an implied [fractint] */
  332.  
  333. while (fgets(line,512,handle) != NULL) {    /* read thru a line at a time */
  334.     i = strlen(line);
  335.     if (i > 0 && line[i-1] == '\n') line[i-1] = 0;  /* strip trailing \n */
  336.     else line[i+1] = 0;                /* add second null   */
  337.  
  338.     strlwr(line);                /* convert to lower case */
  339.     if (toolsfile && line[0] == '[') {      /* TOOLS-style header */
  340.         toolssection = 0;
  341.         if (strncmp(line,"[fractint]",10) == 0)
  342.             toolssection = 1;
  343.         continue;            /* ignore this line in any case */
  344.         }
  345.  
  346.     if (! toolssection) continue;        /* not our section */
  347.  
  348.     i = -1;                 /* get a running start */
  349.     while (line[++i] != 0) {        /* scan through the line */
  350.         if (line[i] <= ' ') continue;   /* white space */
  351.         if (line[i] == ';') break;      /* comments */
  352.         j = i;                /* argument starts here */
  353.         while (line[++i] > ' ');        /* find the argument end */
  354.         line[i] = 0;            /* force an end-of-string */
  355.         if (j == 0 && strcmp(&line[j],"fractint") == 0)
  356.             continue;        /* skip leading "fractint " */
  357.         cmdarg(&line[j]);        /* process the argument */
  358.         }
  359.     }
  360.  
  361. fclose(handle);
  362. }
  363.  
  364. /*
  365.     cmdarg(string) processes a single command-line/command-file argument
  366.         isolate 'variable=value' (or 'variable:=value') into
  367.         its components and process it.
  368.         All components have already been converted to lower case.
  369. */
  370.  
  371. static int cmdarg(char *curarg)     /* process a single argument */
  372. {
  373.     char    variable[21];            /* variable name goes here */
  374.     char    value[141];            /* variable value goes here*/
  375.     int    numval;             /* numeric value of arg    */
  376.     char    charval;            /* character value of arg  */
  377.  
  378.     double    atof(), ftemp;            /* floating point stuff    */
  379.     int    i, j, k, l;            /* temporary loop counters */
  380.     char    *slash;             /* temporary string ptr    */
  381.  
  382.     strlwr(curarg);             /* using lower case      */
  383.     for (j = 1; j < strlen(curarg) && curarg[j] != '='; j++) ;
  384.     if (j > 20 || j >= strlen(curarg))
  385.         argerror(curarg);        /* oops.  '=' not found   */
  386.  
  387.     strncpy(variable,curarg,j);        /* get the variable name  */
  388.     variable[j] = 0;            /* truncate it          */
  389.     if (j > 1 && variable[j-1] == ':')      /* strip any trailing ':' */
  390.         variable[j-1] = 0;
  391.     strcpy(value,&curarg[j+1]);        /* get the value string   */
  392.     numval = atoi(value);            /* get any numeric value  */
  393.     charval = value[0];            /* get any letter  value  */
  394.  
  395.     if (strcmp(variable,"filename") == 0) {         /* filename=?   */
  396.         strcpy(readname,value);         /* set up filename */
  397.         showfile = 0;
  398.         return(0);
  399.         }
  400.     if( strcmp(variable, "map") == 0 ) {    /* map option */
  401.         if (SetColorPaletteName(value) != 0)
  402.             argerror(curarg);
  403.         mapset = 1;
  404.         strcpy(MAP_name,value);
  405.         return(0);
  406.         }
  407.     if (strcmp(variable,"batch") == 0 ) {           /* batch=?      */
  408.         if (charval == 'c') {                   /* config run   */
  409.             makeconfig();
  410.             goodbye();
  411.             }
  412.         if (charval == 'y'){                    /* batch = yes  */
  413.             initbatch = 1;
  414.             return(0);
  415.             }
  416.         if (charval == 'n'){
  417.             initbatch = 0;
  418.             return(0);
  419.             }
  420.         }
  421.     if (strcmp(variable,"warn") == 0 ) {            /* warn=?       */
  422.         if (charval == 'y')
  423.             warn = 1;
  424.         return(0);
  425.         }
  426.     if (strcmp(variable,"gif87a") == 0 ) {          /* gif87a=?     */
  427.         if (charval == 'y')
  428.             gif87a_flag = 1;
  429.         return(0);
  430.         }
  431.     if (strcmp(variable,"savetime") == 0) {         /* savetime=?   */
  432.         initsavetime = numval;
  433.         return(0);
  434.         }
  435.     if (strcmp(variable,"type") == 0 ) {            /* type=?       */
  436.         if (value[strlen(value)-1] == '*')
  437.             value[strlen(value)-1] = 0;
  438.         for (k = 0; fractalspecific[k].name != NULL; k++)
  439.             if (strcmp(value,fractalspecific[k].name) == 0)
  440.                 break;
  441.         if (fractalspecific[k].name == NULL) argerror(curarg);
  442.         fractype = k;
  443.         if (initcorners == 0) {
  444.             xx3rd = xxmin = fractalspecific[fractype].xmin;
  445.             xxmax          = fractalspecific[fractype].xmax;
  446.             yy3rd = yymin = fractalspecific[fractype].ymin;
  447.             yymax          = fractalspecific[fractype].ymax;
  448.             }
  449.         return(0);
  450.         }
  451.     if (strcmp(variable,"inside") == 0 ) {          /* inside=?     */
  452.         if(strcmp(value,"bof60")==0)
  453.             inside = -60;
  454.         else if(strcmp(value,"bof61")==0)
  455.             inside = -61;
  456.         else if(strcmp(value,"maxiter")==0)
  457.             inside = -1;
  458.         else if(isalpha(*value))
  459.             argerror(curarg);
  460.         else
  461.             inside = numval;
  462.         return(0);
  463.         }
  464.     if (strcmp(variable,"finattract") == 0 ) {      /* finattract=? */
  465.         if (charval == 'y')
  466.             finattract = 1;
  467.         return(0);
  468.         }
  469.  
  470.     if (strcmp(variable,"function") == 0) {           /* function=?,?   */
  471.         k = 0;
  472.         slash = strchr(curarg,'=');
  473.         while ( k < 4) {
  474.             slash++;
  475.             if(set_trig_array(k++,slash)) {
  476.                argerror(curarg);
  477.                return(0);
  478.                }
  479.             if ((slash = strchr(slash,'/')) == NULL) k = 99;
  480.             }
  481.         return(0);
  482.         }
  483.     if (strcmp(variable,"outside") == 0 ) {         /* outside=?    */
  484.         if(numval < -1 || numval > 255)
  485.             argerror(curarg);
  486.         else
  487.             outside = numval;
  488.         return(0);
  489.         }
  490.     if (strcmp(variable,"maxiter") == 0) {          /* maxiter=?    */
  491.         if (numval < 10 || numval > 32000) argerror(curarg);
  492.         maxit = numval;
  493.         return(0);
  494.         }
  495.     if (strcmp(variable,"iterincr") == 0) {         /* iterincr=?   */
  496.         if (numval <= 0 || numval > 32000) argerror(curarg);
  497.         initincr = numval;
  498.         return(0);
  499.         }
  500.     if (strcmp(variable,"passes") == 0) {           /* passes=?     */
  501.         if ( charval != '1' && charval != '2'
  502.           && charval != 'g' && charval != 'b')
  503.            argerror(curarg);
  504.         usr_stdcalcmode = charval;
  505.         return(0);
  506.         }
  507.     if (strcmp(variable,"cyclelimit") == 0 ) {      /* cyclelimit=? */
  508.         if (numval > 1 && numval <= 256)
  509.             initcyclelimit = numval;
  510.         return(0);
  511.         }
  512.     if (strcmp(variable,"savename") == 0) {         /* savename=?   */
  513.         if (first_init)
  514.             strcpy(savename,value);
  515.         return(0);
  516.         }
  517.     if (strcmp(variable,"video") == 0) {            /* video=?      */
  518.             if (active_system != 0)
  519.                 return(0);
  520.         for (k = 0; k < maxvideomode; k++) {
  521.             strcpy(variable,fkeys[k]);
  522.             strlwr(variable);
  523.             if (strcmp(variable, value) == 0)
  524.                 break;
  525.             }
  526.         if (k == maxvideomode) argerror(curarg);
  527.         initmode = k;
  528.         return(0);
  529.         }
  530.     if (strcmp(variable,"adapter") == 0 ) {         /* adapter==?     */
  531.         video_type = 5;             /* assume video=vga */
  532.         if (charval == 'e')                     /* video = ega */
  533.             video_type = 3;
  534.         if (charval == 'c')                     /* video = cga */
  535.             video_type = 2;
  536.         if (charval == 'm')                     /* video = mcga */
  537.             video_type = 4;
  538.         return(0);
  539.         }
  540.     if (strcmp(variable,"textsafe") == 0 ) {        /* textsafe==?     */
  541.         if (charval == 'n')                     /*           no    */
  542.             no_color_text = 1;
  543.         return(0);
  544.         }
  545.     if (strcmp(variable,"potential") == 0) {        /* potential=?  */
  546.         k = 0;
  547.         slash = strchr(curarg,'=');
  548.         while ( k < 3) {
  549.             potparam[k++] = atoi(++slash);
  550.             if ((slash = strchr(slash,'/')) == NULL) k = 99;
  551.             }
  552.         pot16bit = 0;
  553.         if (k < 99) {
  554.             if (strcmp(++slash,"16bit"))
  555.                 argerror(curarg);
  556.             pot16bit = 1;
  557.             }
  558.         return(0);
  559.         }
  560.     if (strcmp(variable,"params") == 0) {           /* params=?,?   */
  561.         k = 0;
  562.         slash = strchr(curarg,'=');
  563.         while ( k < 4) {
  564.             param[k++] = atof(++slash);
  565.             if ((slash = strchr(slash,'/')) == NULL) k = 99;
  566.             }
  567.         return(0);
  568.         }
  569.     if (strcmp(variable,"initorbit") == 0) {           /* initorbit=?,?   */
  570.         k = 0;
  571.         slash = strchr(curarg,'=');
  572.         if(strcmp(slash+1,"pixel")==0)
  573.         {
  574.            useinitorbit = 2;
  575.            return(0);
  576.         }
  577.         while ( k < 2) {
  578.             initorbit[k++] = atof(++slash);
  579.             if ((slash = strchr(slash,'/')) == NULL) k = 99;
  580.             }
  581.         useinitorbit = 1;
  582.         return(0);
  583.         }
  584.     if (strcmp(variable,"corners") == 0) {          /* corners=?,?,?,? */
  585.         initcorners = 1;
  586.         slash = strchr(curarg,'=');
  587.         xx3rd=xxmin=atof(++slash);
  588.         if ((slash = strchr(slash,'/')) == NULL) argerror(curarg);
  589.         xxmax=atof(++slash);
  590.         if ((slash = strchr(slash,'/')) == NULL) argerror(curarg);
  591.         yy3rd=yymin=atof(++slash);
  592.         if ((slash = strchr(slash,'/')) == NULL) argerror(curarg);
  593.         yymax=atof(++slash);
  594.         if ((slash = strchr(slash,'/')) != NULL) {
  595.             xx3rd=atof(++slash);
  596.             if ((slash = strchr(slash,'/')) == NULL) argerror(curarg);
  597.             yy3rd=atof(++slash);
  598.             }
  599.         return(0);
  600.         }
  601.     if (strcmp(variable,"center-mag") == 0) {          /* center-mag=?,?,? */
  602.         double Xctr, Yctr,Magnification,Ratio,Height, Width,Radius;
  603.         usemag = 1;
  604.         slash = strchr(curarg,'=');
  605.         Xctr=atof(++slash);
  606.         if ((slash = strchr(slash,'/')) == NULL)
  607.            return(0);
  608.         initcorners = 1;
  609.         Yctr=atof(++slash);
  610.         if ((slash = strchr(slash,'/')) == NULL) argerror(curarg);
  611.         if((Magnification=atof(++slash))<=0.0)
  612.             argerror(curarg);
  613.         else
  614.             Radius = 1.0 / Magnification;
  615.  
  616.         if ((slash = strchr(slash,'/')) != NULL) argerror(curarg);
  617.         Ratio = .75;    /* inverse aspect ratio of screen  */
  618.  
  619.         /* calculate bounds */
  620.         Height = 2.0 * Radius;
  621.         Width = Height / Ratio;
  622.         yymax = Yctr + Radius;
  623.         yy3rd = yymin = Yctr - Radius;
  624.         xxmax = Xctr + Width / 2.0;
  625.         xx3rd = xxmin = Xctr - Width / 2.0;
  626.         return(0);
  627.         }
  628.     if (strcmp(variable,"3d") == 0) {               /* 3d=?/?/..    */
  629.         display3d = 1;                /* turn on 3D */
  630.         k = 0;
  631.         slash = strchr(curarg,'=');
  632.         while ( k < 20) {
  633.             l = atoi(++slash);
  634.             if (slash[0] > 32 && slash[0] != '/') init3d[k] = l;
  635.             /* reset sphere defaults, done here cause [0]==sphere */
  636.             if (k == 0)
  637.                 set_3d_defaults();
  638.             if ((slash = strchr(slash,'/')) == NULL) break;
  639.             k++;
  640.             }
  641.         return(0);
  642.         }
  643.     if (strcmp(variable,"sphere") == 0 ) {          /* sphere=?     */
  644.         if (charval == 'y')
  645.             SPHERE      = TRUE;
  646.         else if (charval == 'n')
  647.             SPHERE      = FALSE;
  648.         else
  649.             argerror(curarg);        /* oops.  error. */
  650.         return(0);
  651.         }
  652.     if (strcmp(variable,"rotation") == 0) {         /* rotation=?/?/?       */
  653.         k = 0;
  654.         slash = strchr(curarg,'=');
  655.         while ( k < 3) {
  656.             l = atoi(++slash);
  657.             if (slash[0] > 32 && slash[0] != '/') *(&XROT+k) = l;
  658.             if ((slash = strchr(slash,'/')) == NULL) k = 99;
  659.             k++;
  660.             }
  661.         return(0);
  662.         }
  663.     if (strcmp(variable,"scalexyz") == 0) {         /* scalexyz=?/?/?       */
  664.         k = 0;
  665.         slash = strchr(curarg,'=');
  666.         while ( k < 3) {
  667.             l = atoi(++slash);
  668.             if (slash[0] > 32 && slash[0] != '/') *(&XSCALE+k) = l;
  669.             if ((slash = strchr(slash,'/')) == NULL) k = 99;
  670.             k++;
  671.             }
  672.         return(0);
  673.         }
  674.     /* "rough" is really scale z, but we add it here for convenience */
  675.     if (strcmp(variable,"roughness") == 0) {        /* roughness=?  */
  676.         ROUGH = numval;
  677.         return(0);
  678.         }
  679.     if (strcmp(variable,"waterline") == 0) {        /* waterline=?  */
  680.         if (numval<0) argerror(curarg);
  681.         WATERLINE = numval;
  682.         return(0);
  683.         }
  684.     if (strcmp(variable,"filltype") == 0) {         /* filltype=?   */
  685.         if (numval < -1 || numval > 6) argerror(curarg);
  686.         FILLTYPE = numval;
  687.         return(0);
  688.         }
  689.     if (strcmp(variable,"perspective") == 0) {      /* perspective=?        */
  690.         k = 0;
  691.         slash = strchr(curarg,'=');
  692.         while ( k < 1) {
  693.             l = atoi(++slash);
  694.             if (slash[0] > 32 && slash[0] != '/') *(&ZVIEWER+k) = l;
  695.             if ((slash = strchr(slash,'/')) == NULL) k = 99;
  696.             k++;
  697.             }
  698.         return(0);
  699.         }
  700.     if (strcmp(variable,"xyshift") == 0) {          /* xyshift=?/?  */
  701.         k = 0;
  702.         slash = strchr(curarg,'=');
  703.         while ( k < 2) {
  704.             l = atoi(++slash);
  705.             if (slash[0] > 32 && slash[0] != '/') *(&XSHIFT+k) = l;
  706.             if ((slash = strchr(slash,'/')) == NULL) k = 99;
  707.             k++;
  708.             }
  709.         return(0);
  710.         }
  711.     if (strcmp(variable,"lightsource") == 0) {      /* lightsource=?/?/?    */
  712.         k = 0;
  713.         slash = strchr(curarg,'=');
  714.         while ( k < 3) {
  715.             l = atoi(++slash);
  716.             if (slash[0] > 32 && slash[0] != '/') *(&XLIGHT+k) = l;
  717.             if ((slash = strchr(slash,'/')) == NULL) k = 99;
  718.             k++;
  719.             }
  720.         return(0);
  721.         }
  722.     if (strcmp(variable,"smoothing") == 0) {        /* smoothing=?  */
  723.         if (numval<0) argerror(curarg);
  724.         LIGHTAVG = numval;
  725.         return(0);
  726.         }
  727.     if (strcmp(variable,"latitude") == 0) {         /* latitude=?/? */
  728.         k = 0;
  729.         slash = strchr(curarg,'=');
  730.         while ( k < 2) {
  731.             l = atoi(++slash);
  732.             if (slash[0] > 32 && slash[0] != '/') *(&THETA1+k) = l;
  733.             if ((slash = strchr(slash,'/')) == NULL) k = 99;
  734.             k++;
  735.             }
  736.         return(0);
  737.         }
  738.     if (strcmp(variable,"longitude") == 0) {        /* longitude=?/?        */
  739.         k = 0;
  740.         slash = strchr(curarg,'=');
  741.         while ( k < 2) {
  742.             l = atoi(++slash);
  743.             if (slash[0] > 32 && slash[0] != '/') *(&PHI1+k) = l;
  744.             if ((slash = strchr(slash,'/')) == NULL) k = 99;
  745.             k++;
  746.             }
  747.         return(0);
  748.         }
  749.     if (strcmp(variable,"radius") == 0) {           /* radius=?     */
  750.         if (numval<0) argerror(curarg);
  751.         RADIUS = numval;
  752.         return(0);
  753.         }
  754.     if (strcmp(variable,"invert") == 0) {           /* invert=?,?,? */
  755.         k = 0;
  756.         slash = strchr(curarg,'=');
  757.         while ( k < 3) {
  758.             inversion[k++] = atof(++slash);
  759.             if(inversion[0] != 0.0)
  760.                 invert = k; /* record highest inversion parameter set */
  761.             if ((slash = strchr(slash,'/')) == NULL) k = 99;
  762.             }
  763.         return(0);
  764.         }
  765.     if (strcmp(variable,"askvideo") == 0 ) {        /* askvideo=?   */
  766.         if (charval == 'y')
  767.             askvideo = 1;
  768.         else if (charval == 'n')
  769.             askvideo = 0;
  770.         else
  771.             argerror(curarg);
  772.         return(0);
  773.         }
  774.     if (strcmp(variable,"ramvideo") == 0 ) {        /* ramvideo=?   */
  775.         return(0); /* just ignore and return, for old time's sake */
  776.         }
  777.     if (strcmp(variable,"float") == 0 ) {           /* float=?      */
  778.         if (charval == 'y')
  779.             usr_floatflag = 1;
  780.         else if (charval == 'n')
  781.             usr_floatflag = 0;
  782.         else
  783.             argerror(curarg);
  784.         return(0);
  785.         }
  786.     if (strcmp(variable,"biomorph") == 0 ) {        /* biomorph=?   */
  787.         biomorph = numval;
  788.         return(0);
  789.         }
  790.     if (strcmp(variable,"bailout") == 0 ) {         /* bailout=?    */
  791.         if (numval < 4 || numval > 32000) argerror(curarg);
  792.         bailout = numval;
  793.         return(0);
  794.         }
  795.     if (strcmp(variable,"symmetry") == 0 ) {        /* symmetry=?   */
  796.         if     (strcmp(value,"xaxis" )==0) forcesymmetry = XAXIS;
  797.         else if(strcmp(value,"yaxis" )==0) forcesymmetry = YAXIS;
  798.         else if(strcmp(value,"xyaxis")==0) forcesymmetry = XYAXIS;
  799.         else if(strcmp(value,"origin")==0) forcesymmetry = ORIGIN;
  800.         else if(strcmp(value,"pi"    )==0) forcesymmetry = PI_SYM;
  801.         else if(strcmp(value,"none"  )==0) forcesymmetry = NOSYM;
  802.         else argerror(curarg);
  803.         return(0);
  804.         }
  805.  
  806.     if (strcmp(variable,"printer") == 0 ) { /* printer=?    */
  807.         if (charval=='h' && value[1]=='p')
  808.             Printer_Type=1;               /* HP LaserJet            */
  809.         if (charval=='i' && value[1]=='b')
  810.             Printer_Type=2;               /* IBM Graphics           */
  811.         if (charval=='e' && value[1]=='p')
  812.             Printer_Type=2;               /* Epson (model?)         */
  813.         if (charval=='c' && value[1]=='o')
  814.             Printer_Type=3;               /* Star (Epson-Comp?) color */
  815.         if (charval=='p' && value[1]=='a')
  816.             Printer_Type=4;               /* HP Paintjet (color)    */
  817.         if (charval=='p' && (value[1]=='o' || value[1]=='s'))
  818.             {                             /* PostScript  SWT */
  819.             Printer_Type=5;
  820.             slash=strchr(curarg,'=');
  821.             if ((slash=strchr(slash,'/'))==NULL)
  822.                slash = strchr(slash,'\0');
  823.             slash--;
  824.             if (*slash=='h' || *slash=='l')
  825.                Printer_Type=6;
  826.             }
  827.  
  828.         if (Printer_Type == 1)        /* assume low resolution */
  829.             Printer_Resolution = 75;
  830.         else
  831.             Printer_Resolution = 60;
  832.  
  833.         if ((Printer_Type == 5) || (Printer_Type == 6))
  834.             Printer_Resolution = 150; /* PostScript def. res. */
  835.  
  836.         slash=strchr(curarg,'=');
  837.         if ((slash=strchr(slash,'/')) == NULL) return(0);
  838.         if ((k=atoi(++slash)) > 0) Printer_Resolution=k;
  839.         if ((slash=strchr(slash,'/')) == NULL) return(0);
  840.         if ((k=atoi(++slash))> 0) LPTNumber = k;
  841.         return(0);
  842.         }
  843.  
  844.     if (strcmp(variable,"title") == 0) {   /* Printer title block? SWT */
  845.         if (charval=='y') Printer_Titleblock=1;
  846.         return(0);
  847.         }
  848.  
  849.     if (strcmp(variable,"translate") == 0) {   /* Translate color? SWT */
  850.         if (charval=='y')
  851.           {
  852.           Printer_ColorXlat=1;
  853.           return(0);
  854.           }
  855.         if ((numval>1) || (numval<-1))
  856.           {
  857.           Printer_ColorXlat=numval;
  858.           return(0);
  859.           }
  860.         Printer_ColorXlat=0;
  861.         return(0);
  862.         }
  863.  
  864.     if (strcmp(variable,"halftone") == 0) {   /* New halftoning? SWT */
  865.         Printer_SetScreen=1;
  866.         slash = strchr(curarg,'=');
  867.         if ((k=atoi(++slash))>0) Printer_SFrequency=k;
  868.         else Printer_SFrequency=80;
  869.         if ((slash=strchr(slash,'/')) == NULL)
  870.           {
  871.           Printer_SAngle=45;
  872.           Printer_SStyle=0;
  873.           return(0);
  874.           }
  875.         Printer_SAngle=atoi(++slash);
  876.         if ((slash=strchr(slash,'/')) == NULL)
  877.           {
  878.           Printer_SStyle=0;
  879.           return(0);
  880.           }
  881.         Printer_SStyle=atoi(++slash)-1;
  882.         return(0);
  883.         }
  884.  
  885.     if (strcmp(variable,"transparent") == 0) { /* transparent? */
  886.         slash = strchr(curarg,'=');
  887.         if ((k=atoi(++slash)) > 0) transparent[0] = k;
  888.         transparent[1] = transparent[0];
  889.         if ((slash=strchr(slash,'/')) == NULL) return(0);
  890.         if ((k=atoi(++slash)) > 0) transparent[1] = k;
  891.         return(0);
  892.         }
  893.     if (strcmp(variable,"sound") == 0 ) {           /* sound=?      */
  894.         soundflag = 0;                /* sound is off */
  895.         if (strncmp(value,"ye",2) == 0)
  896.             soundflag = -1;         /* sound is on    */
  897.         if (charval == 'x')
  898.             soundflag = 1;
  899.         if (charval == 'y')
  900.             soundflag = 2;
  901.         if (charval == 'z')
  902.             soundflag = 3;
  903.         return(0);
  904.         }
  905.  
  906.     if (strcmp(variable,"hertz") == 0) {   /* Hertz=? */
  907.         if (numval < 200 || numval > 10000) argerror(curarg);
  908.         basehertz = numval;
  909.         return(0);
  910.         }
  911.  
  912.     if (strcmp(variable,"periodicity") == 0 ) {     /* periodicity=?    */
  913.         usr_periodicitycheck=1;
  914.         if (charval == 'n')
  915.             usr_periodicitycheck=0;
  916.         else if (charval == 'y')
  917.             usr_periodicitycheck=1;
  918.         else if (charval == 's')   /* 's' for 'show' */
  919.             usr_periodicitycheck=-1;
  920.         else if(isalpha(*value))
  921.             argerror(curarg);
  922.         else if(numval != 0)
  923.             usr_periodicitycheck=numval;
  924.         return(0);
  925.         }
  926.  
  927.     if (strcmp(variable,"logmap") == 0 ) {          /* logmap=?     */
  928.         if (charval == 'y')
  929.             LogFlag = 1;            /* palette is logarithmic */
  930.         else if (charval == 'n')
  931.             LogFlag = 0;
  932.         else if (charval == 'o')
  933.             LogFlag = -1;            /* old log palette */
  934.         else
  935.             LogFlag = numval;
  936.         return(0);
  937.         }
  938.     if (strcmp(variable,"debugflag") == 0 ||
  939.          strcmp(variable,"debug") == 0) {       /* internal use only */
  940.         debugflag = numval;
  941.         timerflag = debugflag & 1;        /* separate timer flag */
  942.         debugflag -= timerflag;
  943.         return(0);
  944.         }
  945.     if (strcmp(variable,"ifs") == 0) {              /* ifs=?        */
  946.         strcpy(ifsfilename,value);
  947.         if (strchr(value,'.') == NULL)
  948.             strcat(ifsfilename,".ifs");
  949.         ifsgetfile();
  950.         return(0);
  951.         }
  952.     if (strcmp(variable,"ifs3d") == 0) {            /* ifs3d=?      */
  953.         strcpy(ifs3dfilename,value);
  954.         if (strchr(value,'.') == NULL)
  955.             strcat(ifs3dfilename,".ifs");
  956.         ifs3dgetfile();
  957.         return(0);
  958.         }
  959.     if (strcmp(variable,"ifscodes") == 0) {    /* ifscodes=?,?,?,? */
  960.         int ifsindex;
  961.         slash = strchr(curarg,'=');
  962.         ifsindex=atoi(++slash) - 1;
  963.         if(ifsindex < 0 || ifsindex > NUMIFS) argerror(curarg);
  964.         if ((slash = strchr(slash,'/')) == NULL) argerror(curarg);
  965.         initifs[ifsindex][0]=atof(++slash);
  966.         if ((slash = strchr(slash,'/')) == NULL) argerror(curarg);
  967.         initifs[ifsindex][1]=atof(++slash);
  968.         if ((slash = strchr(slash,'/')) == NULL) argerror(curarg);
  969.         initifs[ifsindex][2]=atof(++slash);
  970.         if ((slash = strchr(slash,'/')) == NULL) argerror(curarg);
  971.         initifs[ifsindex][3]=atof(++slash);
  972.         if ((slash = strchr(slash,'/')) == NULL) argerror(curarg);
  973.         initifs[ifsindex][4]=atof(++slash);
  974.         if ((slash = strchr(slash,'/')) == NULL) argerror(curarg);
  975.         initifs[ifsindex][5]=atof(++slash);
  976.         if ((slash = strchr(slash,'/')) == NULL) argerror(curarg);
  977.         initifs[ifsindex][6]=atof(++slash);
  978.         return(0);
  979.         }
  980.     if (strcmp(variable, "rseed") == 0) {
  981.         rseed = numval;
  982.         rflag = 1;
  983.         return(0);
  984.         }
  985.     if (strcmp(variable, "decomp") == 0) {
  986.         k = 0;
  987.         slash = strchr(curarg,'=');
  988.         while (k < 2) {
  989.             decomp[k++] = atoi(++slash);
  990.             if ((slash = strchr(slash,'/')) == NULL) break;
  991.             }
  992.         return(0);
  993.         }
  994.     if (strcmp(variable, "distest") == 0) {
  995.         usr_distest = numval;
  996.         return(0);
  997.         }
  998.     if (strcmp(variable,"formulafile") == 0) {      /* formulafile=?        */
  999.         strcpy(FormFileName,value);
  1000.         return(0);
  1001.         }
  1002.     if (strcmp(variable,"formulaname") == 0) {      /* formulaname=?        */
  1003.         strcpy(FormName,value);
  1004.         return(0);
  1005.         }
  1006.     if (strcmp(variable,"lfile") == 0) {
  1007.            strcpy(LFileName,value);
  1008.           return(0);
  1009.      }
  1010.      if (strcmp(variable,"lname") == 0) {
  1011.            strcpy(LName,value);
  1012.            return(0);
  1013.      }
  1014.  
  1015.     if (strcmp(variable,"preview") == 0) { /* preview? */
  1016.         if (charval == 'y')
  1017.             preview = 1;
  1018.         return(0);
  1019.         }
  1020.     if (strcmp(variable,"showbox") == 0) { /* showbox? */
  1021.         if (charval == 'y')
  1022.         showbox = 1;
  1023.         return(0);
  1024.         }
  1025.     if (strcmp(variable,"coarse") == 0) {  /* coarse=? */
  1026.         if (numval<1) argerror(curarg);
  1027.         previewfactor = numval;
  1028.         return(0);
  1029.         }
  1030.     if (strcmp(variable,"stereo") == 0) {  /* stereo=? */
  1031.         if ((numval<0) || (numval>3)) argerror(curarg);
  1032.         glassestype = numval;
  1033.         return(0);
  1034.         }
  1035.     if (strcmp(variable,"interocular") == 0) {  /* interocular=? */
  1036.         eyeseparation = numval;
  1037.         return(0);
  1038.         }
  1039.     if (strcmp(variable,"converge") == 0) {  /* converg=? */
  1040.         xadjust = numval;
  1041.         return(0);
  1042.         }
  1043.     if (strcmp(variable,"crop") == 0) {  /* crop=? */
  1044.         slash = strchr(curarg,'=');
  1045.         if ((k=atoi(++slash)) >= 0 && atoi(slash) <= 100) red_crop_left = k;
  1046.         else argerror(curarg);
  1047.         if ((slash=strchr(slash,'/')) == NULL) return(0);
  1048.         if ((k=atoi(++slash)) >= 0 && atoi(slash) <= 100) red_crop_right = k;
  1049.         else argerror(curarg);
  1050.         if ((slash=strchr(slash,'/')) == NULL) return(0);
  1051.         if ((k=atoi(++slash)) >= 0 && atoi(slash) <= 100) blue_crop_left = k;
  1052.         else argerror(curarg);
  1053.         if ((slash=strchr(slash,'/')) == NULL) return(0);
  1054.         if ((k=atoi(++slash)) >= 0 && atoi(slash) <= 100) blue_crop_right = k;
  1055.         else argerror(curarg);
  1056.         return(0);
  1057.         }
  1058.     if (strcmp(variable,"bright") == 0) {  /* bright=? */
  1059.         slash = strchr(curarg,'=');
  1060.         if ((k=atoi(++slash)) >= 0) red_bright = k;
  1061.         else argerror(curarg);
  1062.         if ((slash=strchr(slash,'/')) == NULL) return(0);
  1063.         if ((k=atoi(++slash)) >= 0) blue_bright = k;
  1064.         else argerror(curarg);
  1065.         return(0);
  1066.         }
  1067.     if (strcmp(variable,"xyadjust") == 0) { /* trans=? */
  1068.         slash = strchr(curarg,'=');
  1069.         xtrans=atoi(++slash);
  1070.         if ((slash=strchr(slash,'/')) == NULL) return(0);
  1071.         ytrans=atoi(++slash);
  1072.         return(0);
  1073.         }
  1074.     if (strcmp(variable,"randomize") == 0) {  /* RANDOMIZE=? */
  1075.         if (numval<0 || numval>7) argerror(curarg);
  1076.         RANDOMIZE = numval;
  1077.         return(0);
  1078.         }
  1079.     if (strcmp(variable,"ambient") == 0) {  /* ambient=? */
  1080.         if (numval<0||numval>100) argerror(curarg);
  1081.         Ambient = numval;
  1082.         return(0);
  1083.         }
  1084.     if (strcmp(variable,"haze") == 0) {  /* haze=? */
  1085.         if (numval<0||numval>100) argerror(curarg);
  1086.         haze = numval;
  1087.         return(0);
  1088.         }
  1089.     if (strcmp(variable,"fullcolor") == 0) {  /* fullcolor=? */
  1090.         if (charval != 'y' && charval != 'n') argerror(curarg);
  1091.         if (charval == 'y') full_color = 1;
  1092.         return(0);
  1093.         }
  1094.     if (strcmp(variable,"lightname") == 0) {         /* lightname=?   */
  1095.         if (first_init)
  1096.             strcpy(light_name,value);
  1097.         return(0);
  1098.         }
  1099.  
  1100.     argerror(curarg);
  1101.     return(-1);
  1102. }
  1103.  
  1104. static void argerror(char *badarg)    /* oops. couldn't decode this */
  1105. {
  1106.    static char far argerrormessage[]={"\
  1107. (see the Startup Help screens or FRACTINT.DOC for a complete\n\
  1108.  argument list with descriptions)"};
  1109.    char msg[200];
  1110.    setvideomode(3,0,0,0);
  1111.    sprintf(msg,"Oops.  I couldn't understand the argument:\n  '%s'",
  1112.       badarg);
  1113.    if (active_system == 0) {
  1114.       buzzer(2);
  1115.       putstring(0,0,15,msg);
  1116.       putstring(3,0,7,argerrormessage);
  1117.       movecursor(8,0);
  1118.       exit(1);
  1119.       }
  1120.    else
  1121.       stopmsg(0,msg);
  1122. }
  1123.  
  1124. void set_3d_defaults()
  1125. {
  1126.    ENTER_OVLY(OVLY_CMDFILES);
  1127.    if(SPHERE) {
  1128.       PHI1    =  180;
  1129.       PHI2    =  0;
  1130.       THETA1    =  -90;
  1131.       THETA2    =  90;
  1132.       RADIUS    =  100;
  1133.       ROUGH    =  30;
  1134.       WATERLINE = 0;
  1135.       FILLTYPE    = 2;
  1136.       ZVIEWER    = 0;
  1137.       XSHIFT    = 0;
  1138.       YSHIFT    = 0;
  1139.       xtrans    = 0;
  1140.       ytrans    = 0;
  1141.       XLIGHT    = 1;
  1142.       YLIGHT    = 1;
  1143.       ZLIGHT    = 1;
  1144.       LIGHTAVG    = 0;
  1145.       Ambient    = 20;
  1146.       RANDOMIZE = 0;
  1147.       haze    = 0;
  1148.       full_color= 0;
  1149.       back_color[0] = 51; back_color[1] = 153; back_color[2] = 200;
  1150.       }
  1151.    else {
  1152.       XROT    = 60;
  1153.       YROT    = 30;
  1154.       ZROT    = 0;
  1155.       XSCALE    = 90;
  1156.       YSCALE    = 90;
  1157.       ROUGH    = 30;
  1158.       WATERLINE = 0;
  1159.       FILLTYPE    = 0;
  1160.       if (active_system != 0)
  1161.           FILLTYPE    = 2;
  1162.       ZVIEWER    = 0;
  1163.       XSHIFT    = 0;
  1164.       YSHIFT    = 0;
  1165.       xtrans    = 0;
  1166.       ytrans    = 0;
  1167.       XLIGHT    = 1;
  1168.       YLIGHT    = -1;
  1169.       ZLIGHT    = 1;
  1170.       LIGHTAVG    = 0;
  1171.       Ambient    = 20;
  1172.       RANDOMIZE = 0;
  1173.       haze    = 0;
  1174.       full_color= 0;
  1175.       back_color[0] = 51; back_color[1] = 153; back_color[2] = 200;
  1176.       }
  1177.     EXIT_OVLY;
  1178. }
  1179.  
  1180. int readconfig()    /* search for, read, decode fractint.cfg file */
  1181. {
  1182.    char tempstring[101];
  1183.    FILE *cfgfile;
  1184.    int count, i, j, ax, bx, cx, dx, dotmode, xdots, ydots, colors, commas[10];
  1185.    ENTER_OVLY(OVLY_CMDFILES);
  1186.    findpath("fractint.cfg",tempstring); /* look for FRACTINT.CFG */
  1187.    if (tempstring[0] == 0                 /* can't find the file */
  1188.      || (cfgfile = fopen(tempstring,"r")) == NULL) { /* can't open it */
  1189.       EXIT_OVLY;
  1190.       return(-1);
  1191.       }
  1192.  
  1193.    count = 0;                /* build a new videomode file */
  1194.    while (feof(cfgfile) == 0 && count < MAXVIDEOMODES) {   /* scan through strings */
  1195.       if (!fgets(tempstring, 100, cfgfile)) break;
  1196.       tempstring[strlen(tempstring)-1] = 0;
  1197.       if (tempstring[0] <= 32) continue;    /* comment line     */
  1198.       j = 9;
  1199.       for (i = 0; i <= j; i++) commas[i] = 0;
  1200.       for (i = strlen(tempstring); i >= 0 && j >= 0; i--)  /* check for commas */
  1201.      if (tempstring[i] == ',') {
  1202.         tempstring[i] = 0;
  1203.         commas[--j] = i+1;
  1204.         }
  1205.       sscanf(&tempstring[commas[0]],"%x",&ax);
  1206.       sscanf(&tempstring[commas[1]],"%x",&bx);
  1207.       sscanf(&tempstring[commas[2]],"%x",&cx);
  1208.       sscanf(&tempstring[commas[3]],"%x",&dx);
  1209.       dotmode      = atoi(&tempstring[commas[4]]);
  1210.       xdots      = atoi(&tempstring[commas[5]]);
  1211.       ydots      = atoi(&tempstring[commas[6]]);
  1212.       colors      = atoi(&tempstring[commas[7]]);
  1213.       if (  i >= 0 || j != 0 ||
  1214.         dotmode < 0 || dotmode > 30 ||
  1215.         xdots < 160 || xdots > 2048 ||
  1216.         ydots < 160 || ydots > 2048 ||
  1217.         (colors != 2 && colors != 4 && colors != 16 && colors != 256)
  1218.        ) {
  1219.      buzzer(2);
  1220.      printf("\n\n There is a bad entry in fractint.cfg\n\n");
  1221.      printf(" ==> %s \n", tempstring);
  1222.      exit(-1);
  1223.      }
  1224.       tempstring[commas[8]+25] = 0;
  1225.       if (commas[0] >= 25) tempstring[25] = 0;
  1226.       strcpy(videoentry.name,     tempstring);
  1227.       strcpy(videoentry.comment, &tempstring[commas[8]]);
  1228.       if (tempstring[commas[8]] == ' ')
  1229.      strcpy(videoentry.comment, &tempstring[commas[8]+1]);
  1230.       videoentry.videomodeax =     ax;
  1231.       videoentry.videomodebx =     bx;
  1232.       videoentry.videomodecx =     cx;
  1233.       videoentry.videomodedx =     dx;
  1234.       videoentry.dotmode     =     dotmode;
  1235.       videoentry.xdots         =     xdots;
  1236.       videoentry.ydots         =     ydots;
  1237.       videoentry.colors      =     colors;
  1238.       tovideotable(count);
  1239.       count++;
  1240.       }
  1241.  
  1242.    if (count > 0) strcpy(videoentry.name, "END");
  1243.    videoentry.colors = 0;
  1244.    tovideotable(count);
  1245.    fclose(cfgfile);
  1246.    EXIT_OVLY;
  1247.    if (count <= 0) return(-1);
  1248.    return(0);            /* successful return    */
  1249. }
  1250.  
  1251. static void makeconfig()    /* routine to build a FRACTINT.CFG file */
  1252. {
  1253.    char tempstring[101];
  1254.    FILE *cfgfile;
  1255.    int count;
  1256.  
  1257. if (active_system != 0)  /* windows version */
  1258.    return;
  1259.  
  1260. #ifdef __TURBOC__
  1261.    strcpy(tempstring,searchpath("fractint.cfg"));
  1262. #else
  1263.    _searchenv("fractint.cfg","PATH",tempstring);
  1264. #endif
  1265.  
  1266.    if (tempstring[0] != 0) {
  1267.       buzzer(2);
  1268.       printf("\n There is a FRACTINT.CFG file already located in the PATH.\n\n");
  1269.       printf(" I won't make another one until after you manually remove\n");
  1270.       printf(" the old one.  Safety first!\n\n");
  1271.       exit(-1);
  1272.       }
  1273.  
  1274.    if ((cfgfile = fopen("fractint.cfg","w")) == NULL)
  1275.       exit(-1);                   /* ?? can't open file   */
  1276.    fprintf(cfgfile,"   Full FRACTINT.CFG File, built by a 'fractint batch=config' command\n\n");
  1277.    fprintf(cfgfile," name of adapter/mode    | AX | BX | CX | DX |mode|  x |  y |clrs| comments\n");
  1278.    fprintf(cfgfile," =============================================================================\n\n");
  1279.    for (count = 0; count < maxvideomode; count++) {    /* write the entries */
  1280.       fromvideotable(count);
  1281. #ifdef __TURBOC__
  1282.       fprintf(cfgfile,"%-25.25s,%4x,%4x,%4x,%4x,%4d,%4d,%4d,%4d, %-25.25s\n",
  1283. #else
  1284.       fprintf(cfgfile,"%-25s,%4x,%4x,%4x,%4x,%4d,%4d,%4d,%4d, %-25s\n",
  1285. #endif
  1286.           videoentry.name,
  1287.           videoentry.videomodeax,
  1288.           videoentry.videomodebx,
  1289.           videoentry.videomodecx,
  1290.           videoentry.videomodedx,
  1291.           videoentry.dotmode,
  1292.           videoentry.xdots,
  1293.           videoentry.ydots,
  1294.           videoentry.colors,
  1295.           videoentry.comment);
  1296.       }
  1297.    fclose(cfgfile);
  1298. }
  1299.  
  1300.