home *** CD-ROM | disk | FTP | other *** search
/ Media Share 9 / MEDIASHARE_09.ISO / progmisc / frasrc18.zip / CMDFILES.C < prev    next >
C/C++ Source or Header  |  1993-05-08  |  70KB  |  2,232 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 <time.h>
  12. #ifndef XFRACT
  13. #include <bios.h>
  14. #endif
  15. #include "fractint.h"
  16. #include "fractype.h"
  17. #ifdef __TURBOC__
  18. #include <dir.h>
  19. #endif
  20. #include "prototyp.h"
  21.  
  22. #ifdef XFRACT
  23. #define DEFAULT_PRINTER 5    /* Assume a Postscript printer */
  24. #define PRT_RESOLUTION  100    /* Assume medium resolution    */
  25. #define INIT_GIF87      0    /* Turn on GIF 89a processing  */
  26. #else
  27. #define DEFAULT_PRINTER 2    /* Assume an IBM/Epson printer */
  28. #define PRT_RESOLUTION  60    /* Assume low resolution       */
  29. #define INIT_GIF87      0    /* Turn on GIF 89a processing  */
  30. #endif
  31.  
  32. static int  cmdfile(FILE *,int);
  33. static int  next_command(char *,int,FILE *,char *,int *,int);
  34. static int  next_line(FILE *,char *,int);
  35. int  cmdarg(char *,int);
  36. static void argerror(char *);
  37. static void initvars_run(void);
  38. static void initvars_restart(void);
  39. static void initvars_fractal(void);
  40. static void initvars_3d(void);
  41. static void reset_ifs_defn(void);
  42. static void parse_textcolors(char *value);
  43. static int  parse_colors(char *value);
  44. static int  parse_printer(char *value);
  45.  
  46. /* variables defined by the command line/files processor */
  47. int        showdot;    /* color to show crawling graphics cursor */
  48. char    temp1[256];        /* temporary strings        */
  49. char    readname[80];        /* name of fractal input file */
  50. char    gifmask[13] = {""};
  51. char    PrintName[80]={"fract001.prn"}; /* Name for print-to-file */
  52. char    savename[80]={"fract001"};      /* save files using this name */
  53. char    autoname[80]={"auto.key"};      /* record auto keystrokes here */
  54. int    potflag=0;        /* continuous potential enabled? */
  55. int    pot16bit;        /* store 16 bit continuous potential values */
  56. int    gif87a_flag;        /* 1 if GIF87a format, 0 otherwise */
  57. int     dither_flag;        /* 1 if want to dither GIFs */
  58. int    askvideo;        /* flag for video prompting */
  59. char    floatflag;
  60. int    biomorph;        /* flag for biomorph */
  61. int    usr_biomorph;
  62. int    forcesymmetry;        /* force symmetry */
  63. int    showfile;        /* zero if file display pending */
  64. int    rflag, rseed;        /* Random number seeding flag and value */
  65. int    decomp[2];        /* Decomposition coloring */
  66. int    distest;
  67. int    distestwidth;
  68. char overwrite = 0;    /* 0 if file overwrite not allowed */
  69. int    soundflag;        /* 0 if sound is off, 1 if on */
  70. int    basehertz;        /* sound=x/y/x hertz value */
  71. int    debugflag;        /* internal use only - you didn't see this */
  72. int    timerflag;        /* you didn't see this, either */
  73. int    cyclelimit;        /* color-rotator upper limit */
  74. int    inside;         /* inside color: 1=blue     */
  75. int    fillcolor;         /* fillcolor: -1=normal     */
  76. int    outside;        /* outside color    */
  77. int    finattract;        /* finite attractor logic */
  78. int    display3d;        /* 3D display flag: 0 = OFF */
  79. int    overlay3d;        /* 3D overlay flag: 0 = OFF */
  80. int    init3d[20];        /* '3d=nn/nn/nn/...' values */
  81. int    initbatch;        /* 1 if batch run (no kbd)  */
  82. unsigned initsavetime;        /* autosave minutes        */
  83. double    initorbit[2];        /* initial orbitvalue */
  84. char    useinitorbit;        /* flag for initorbit */
  85. int    initmode;        /* initial video mode        */
  86. int    initcyclelimit;     /* initial cycle limit        */
  87. BYTE usemag;        /* use center-mag corners   */
  88. int    bailout;        /* user input bailout value */
  89. double    inversion[3];        /* radius, xcenter, ycenter */
  90. int    rotate_lo,rotate_hi;    /* cycling color range        */
  91. int far *ranges;        /* iter->color ranges mapping */
  92. int    rangeslen = 0;        /* size of ranges array     */
  93. char far *mapdacbox = NULL;    /* map= (default colors)    */
  94. int    colorstate;        /* 0, dacbox matches default (bios or map=) */
  95.                 /* 1, dacbox matches no known defined map   */
  96.                 /* 2, dacbox matches the colorfile map        */
  97. int    colorpreloaded;     /* if dacbox preloaded for next mode select */
  98. int     save_release;        /* release creating PAR file*/
  99.  
  100. extern int calc_status;
  101. extern int Targa_Overlay;
  102. int Targa_Out = 0;
  103. char    colorfile[80];        /* from last <l> <s> or colors=@filename    */
  104. int functionpreloaded; /* if function loaded for new bifs, JCO 7/5/92 */
  105. float    screenaspect = DEFAULTASPECT;    /* aspect ratio of the screen */
  106.  
  107. /* TARGA+ variables */
  108. int    TPlusFlag;        /* Use the TARGA+ if found  */
  109. int    MaxColorRes;        /* Default Color Resolution if available */
  110. int    PixelZoom;        /* TPlus Zoom Level */
  111. int    NonInterlaced;        /* Non-Interlaced video flag */
  112.  
  113. /* 3D Transparency Variables, MCP 5-30-91 */
  114. double xcoord, ycoord, zcoord, tcoord;
  115. double zzmin, zzmax;        /* initial depth corner values */
  116. double ttmin, ttmax;        /* initial time coordinates */
  117. int Transparent3D, SolidCore, MultiDrawing;
  118. int tpdepth, tptime;
  119. unsigned CoreRed, CoreGreen, CoreBlue, NumFrames;
  120.  
  121. /* AntiAliasing variables, MCP 6-6-91 */
  122. int AntiAliasing, Shadowing;
  123.  
  124. /* Julibrot variables TIW 1/24/93 */
  125. extern double mxmaxfp, mxminfp, mymaxfp, myminfp, originfp;
  126. extern double depthfp, heightfp, widthfp, distfp, eyesfp;
  127. extern int zdots; 
  128.  
  129. extern int lastorbittype, neworbittype;
  130. extern char *juli3Doptions[];
  131. extern int juli3Dmode;
  132. extern struct moreparams far moreparams[];
  133.  
  134. /* inverse julia methods. MVS 3/15/93 */
  135. extern int major_method;
  136. extern int minor_method;
  137.  
  138. int    orbitsave = 0;        /* for IFS and LORENZ to output acrospin file */
  139. int orbit_delay;                /* clock ticks delating orbit release */
  140. extern    int invert;
  141. extern int fractype;        /* fractal type         */
  142. extern double param[];         /* initial parameters        */
  143. extern double xxmin,xxmax;    /* initial corner values    */
  144. extern double yymin,yymax;    /* initial corner values    */
  145. extern double xx3rd,yy3rd;    /* initial corner values    */
  146. extern char usr_stdcalcmode;    /* '1', '2', 'g', 'b'       */
  147. extern int maxit;        /* max iterations        */
  148. extern int usr_periodicitycheck; /* periodicity checking  1=on,0=off */
  149. extern char usr_floatflag;    /* flag for float calcs */
  150. extern int usr_distest;     /* nonzero if distance estimator option */
  151. extern char color_lakes;    /* finite attractor flag */
  152. extern int haze;
  153. extern int RANDOMIZE;
  154. extern int Ambient;
  155. extern char light_name[];
  156. extern int BRIEF;
  157. extern int RAY;
  158. extern int release;
  159.  
  160. extern BYTE back_color[];
  161. extern BYTE dacbox[256][3];
  162. extern struct videoinfo far videotable[];
  163. extern int fpu;
  164. extern int iit;
  165.  
  166. extern double potparam[];    /* potential parameters  */
  167. extern int Printer_Resolution, LPTNumber,
  168.        Printer_Type, Printer_Titleblock,
  169.        Printer_ColorXlat, Printer_SetScreen,
  170.        Printer_SFrequency, Printer_SAngle, Printer_SStyle,
  171.        Printer_RFrequency, Printer_RAngle, Printer_RStyle,
  172.        Printer_GFrequency, Printer_GAngle, Printer_GStyle,
  173.        Printer_BFrequency, Printer_BAngle, Printer_BStyle,
  174.        Printer_Compress,
  175.        EPSFileType, ColorPS,
  176.        Print_To_File,Printer_CRLF;        /* for printer functions */
  177.  
  178. int    transparent[2];     /* transparency min/max values */
  179. int    LogFlag;        /* Logarithmic palette flag: 0 = no */
  180.  
  181. BYTE exitmode = 3;    /* video mode on exit */
  182.  
  183. extern int video_type;
  184. extern int svga_type;           /* for forcing a specific SVGA adapter */
  185. extern int mode7text;
  186. extern int textsafe;
  187. extern int vesa_detect;
  188. char    ai_8514;    /* Flag for using 8514a afi JCO 4/11/92 */
  189.  
  190. int        bios_palette;        /* set to 1 to force BIOS palette updates */
  191. int        escape_exit;         /* set to 1 to avoid the "are you sure?" screen */
  192.  
  193. extern int   viewwindow;
  194. extern float viewreduction;
  195. extern int   viewcrop;
  196. extern float finalaspectratio;
  197. extern int   viewxdots,viewydots;
  198.  
  199. extern char MAP_name[];
  200. extern int mapset;
  201.  
  202. extern int eyeseparation; /* Occular Separation */
  203. extern int glassestype;
  204. extern int xadjust; /* Convergence */
  205. extern int yadjust;
  206. extern int xtrans, ytrans; /* X,Y shift with no perspective */
  207. extern int red_crop_left, red_crop_right;
  208. extern int blue_crop_left, blue_crop_right;
  209. extern int red_bright, blue_bright;
  210. extern char showbox; /* flag to show box and vector in preview */
  211. extern char preview;        /* 3D preview mode flag */
  212. extern int previewfactor; /* Coarsness */
  213.  
  214. int first_init=1;        /* first time into cmdfiles? */
  215. static int init_rseed;
  216. static char initcorners,initparams;
  217. struct fractalspecificstuff far *curfractalspecific;
  218.  
  219. char FormFileName[80];        /* file to find (type=)formulas in */
  220. char FormName[ITEMNAMELEN+1];    /* Name of the Formula (if not null) */
  221. char LFileName[80];        /* file to find (type=)L-System's in */
  222. char LName[ITEMNAMELEN+1];    /* Name of L-System */
  223. char CommandFile[80];        /* file to find command sets in */
  224. char CommandName[ITEMNAMELEN+1];/* Name of Command set */
  225. char far CommandComment1[57];    /* comments for command set */
  226. char far CommandComment2[57];
  227. char far CommandComment3[57];
  228. char far CommandComment4[57];
  229. char IFSFileName[80];        /* file to find (type=)IFS in */
  230. char IFSName[ITEMNAMELEN+1];    /* Name of the IFS def'n (if not null) */
  231. float far *ifs_defn = NULL;    /* ifs parameters */
  232. int  ifs_changed;        /* nonzero if parameters have been edited */
  233. int  ifs_type;            /* 0=2d, 1=3d */
  234. int  slides = 0;        /* 1 autokey=play, 2 autokey=record */
  235.  
  236. BYTE txtcolor[]={
  237.       BLUE*16+L_WHITE,      /* C_TITLE           title background */
  238.       BLUE*16+L_GREEN,      /* C_TITLE_DEV       development vsn foreground */
  239.       GREEN*16+YELLOW,      /* C_HELP_HDG        help page title line */
  240.       WHITE*16+BLACK,      /* C_HELP_BODY       help page body */
  241.       GREEN*16+GRAY,      /* C_HELP_INSTR      help page instr at bottom */
  242.       WHITE*16+BLUE,      /* C_HELP_LINK       help page links */
  243.       CYAN*16+BLUE,      /* C_HELP_CURLINK    help page current link */
  244.       WHITE*16+GRAY,      /* C_PROMPT_BKGRD    prompt/choice background */
  245.       WHITE*16+BLACK,      /* C_PROMPT_TEXT     prompt/choice extra info */
  246.       BLUE*16+WHITE,      /* C_PROMPT_LO       prompt/choice text */
  247.       BLUE*16+L_WHITE,      /* C_PROMPT_MED      prompt/choice hdg2/... */
  248.       BLUE*16+YELLOW,      /* C_PROMPT_HI       prompt/choice hdg/cur/... */
  249.       GREEN*16+L_WHITE,   /* C_PROMPT_INPUT    fullscreen_prompt input */
  250.       CYAN*16+L_WHITE,      /* C_PROMPT_CHOOSE   fullscreen_prompt choice */
  251.       MAGENTA*16+L_WHITE, /* C_CHOICE_CURRENT  fullscreen_choice input */
  252.       BLACK*16+WHITE,      /* C_CHOICE_SP_INSTR speed key bar & instr */
  253.       BLACK*16+L_MAGENTA, /* C_CHOICE_SP_KEYIN speed key value */
  254.       WHITE*16+BLUE,      /* C_GENERAL_HI      tab, thinking, IFS */
  255.       WHITE*16+BLACK,      /* C_GENERAL_MED */
  256.       WHITE*16+GRAY,      /* C_GENERAL_LO */
  257.       BLACK*16+L_WHITE,   /* C_GENERAL_INPUT */
  258.       WHITE*16+BLACK,      /* C_DVID_BKGRD      disk video */
  259.       BLACK*16+YELLOW,      /* C_DVID_HI */
  260.       BLACK*16+L_WHITE,   /* C_DVID_LO */
  261.       RED*16+L_WHITE,      /* C_STOP_ERR        stop message, error */
  262.       GREEN*16+BLACK,      /* C_STOP_INFO       stop message, info */
  263.       BLUE*16+WHITE,      /* C_TITLE_LOW       bottom lines of title screen */
  264.       GREEN*16+BLACK,      /* C_AUTHDIV1        title screen dividers */
  265.       GREEN*16+GRAY,      /* C_AUTHDIV2        title screen dividers */
  266.       BLACK*16+L_WHITE,   /* C_PRIMARY           primary authors */
  267.       BLACK*16+WHITE      /* C_CONTRIB           contributing authors */
  268.       };
  269.  
  270. extern int active_system;
  271. /* start of string literals cleanup */
  272. char s_iter[]    = "iter";
  273. char s_real[]    = "real";
  274. char s_mult[]     = "mult";
  275. char s_sum[]     = "summ";
  276. char s_imag[]    = "imag";
  277. char s_zmag[]    = "zmag";
  278. char s_bof60[]   = "bof60";
  279. char s_bof61[]   = "bof61";
  280. char s_maxiter[] =  "maxiter";
  281. char s_epscross[] =  "epsiloncross";
  282. char s_startrail[] =  "startrail";
  283. char s_normal[] =  "normal";
  284. char s_period[] = "period";
  285.  
  286.  
  287. void cmdfiles_overlay() { }    /* for restore_active_ovly */
  288.  
  289. /*
  290.     cmdfiles(argc,argv) process the command-line arguments
  291.         it also processes the 'sstools.ini' file and any
  292.         indirect files ('fractint @myfile')
  293. */
  294.  
  295. int cmdfiles(int argc,char **argv)
  296. {
  297.    int       i;
  298.    char    curarg[141];
  299.    char    tempstring[101];
  300.    char    *sptr;
  301.    FILE    *initfile;
  302.  
  303.    ENTER_OVLY(OVLY_CMDFILES);
  304.  
  305.    if (first_init) initvars_run();    /* once per run initialization */
  306.    initvars_restart();            /* <ins> key initialization */
  307.    initvars_fractal();            /* image initialization */
  308.  
  309.    findpath("sstools.ini", tempstring); /* look for SSTOOLS.INI */
  310.    if (tempstring[0] != 0)        /* found it! */
  311.       if ((initfile = fopen(tempstring,"r")) != NULL)
  312.      cmdfile(initfile,1);        /* process it */
  313.  
  314.    for (i = 1; i < argc; i++) {     /* cycle through args */
  315. #ifdef XFRACT
  316.       /* Let the xfract code take a look at the argument */
  317.       if (unixarg(argc,argv,&i)) continue;
  318. #endif
  319.       strcpy(curarg,argv[i]);
  320.       if (curarg[0] == ';')             /* start of comments? */
  321.      break;
  322.       if (curarg[0] != '@') {           /* simple command? */
  323.      if (strchr(curarg,'=') == NULL) { /* not xxx=yyy, so check for gif */
  324.         strcpy(tempstring,curarg);
  325.         if (strchr(curarg,'.') == NULL)
  326.            strcat(tempstring,".gif");
  327.         if ((initfile = fopen(tempstring,"rb"))) {
  328.            fread(tempstring,6,1,initfile);
  329.            if ( tempstring[0] == 'G'
  330.          && tempstring[1] == 'I'
  331.          && tempstring[2] == 'F'
  332.          && tempstring[3] >= '8' && tempstring[3] <= '9'
  333.          && tempstring[4] >= '0' && tempstring[4] <= '9') {
  334.           strcpy(readname,curarg);
  335.           curarg[0] = showfile = 0;
  336.           }
  337.            fclose(initfile);
  338.            }
  339.         }
  340.      if (curarg[0])
  341.         cmdarg(curarg,0);        /* process simple command */
  342.      }
  343.       else if ((sptr = strchr(curarg,'/'))) { /* @filename/setname? */
  344.      *sptr = 0;
  345.      strcpy(CommandFile,&curarg[1]);
  346.      strcpy(CommandName,sptr+1);
  347.      find_file_item(CommandFile,CommandName,&initfile);
  348.      cmdfile(initfile,3);
  349.      }
  350.       else {                /* @filename */
  351.      if ((initfile = fopen(&curarg[1],"r")) == NULL)
  352.         argerror(curarg);
  353.      cmdfile(initfile,0);
  354.      }
  355.       }
  356.  
  357.    if (first_init == 0) {
  358.       initmode = -1; /* don't set video when <ins> key used */
  359.       showfile = 1;  /* nor startup image file            */
  360.       }
  361.  
  362.    if(debugflag != 110)
  363.        first_init = 0;
  364.    EXIT_OVLY;
  365.    return(0);
  366. }
  367.  
  368.  
  369. int load_commands(FILE *infile)
  370. {
  371.    /* when called, file is open in binary mode, positioned at the */
  372.    /* '(' or '{' following the desired parameter set's name       */
  373.    int ret;
  374.    ENTER_OVLY(OVLY_CMDFILES);
  375.    initcorners = initparams = 0; /* reset flags for type= */
  376.    ret = cmdfile(infile,2);
  377.    EXIT_OVLY;
  378.    return ret;
  379. }
  380.  
  381.  
  382. static void initvars_run()        /* once per run init */
  383. {
  384.    init_rseed = (int)time(NULL);
  385. }
  386.  
  387. static void initvars_restart()        /* <ins> key init */
  388. {
  389.    save_release = release;              /* this release number */
  390.    gif87a_flag = INIT_GIF87;            /* turn on GIF89a processing */
  391.    dither_flag = 0;            /* no dithering */
  392.    askvideo = 1;            /* turn on video-prompt flag */
  393.    overwrite = 0;            /* don't overwrite           */
  394.    soundflag = -1;            /* sound is on             */
  395.    basehertz = 440;            /* basic hertz rate         */
  396.    initbatch = 0;            /* not in batch mode         */
  397.    initsavetime = 0;            /* no auto-save          */
  398.    initmode = -1;            /* no initial video mode     */
  399.    viewwindow = 0;            /* no view window         */
  400.    viewreduction = 4.2;
  401.    viewcrop = 1;
  402.    ai_8514 = 0;                         /* no need for the 8514 API  */
  403.    finalaspectratio = screenaspect;
  404.    viewxdots = viewydots = 0;
  405.    orbit_delay = 0;                     /* full speed orbits */
  406.    debugflag = 0;            /* debugging flag(s) are off */
  407.    timerflag = 0;            /* timer flags are off         */
  408.    strcpy(FormFileName,"fractint.frm"); /* default formula file      */
  409.    FormName[0] = 0;
  410.    strcpy(LFileName,"fractint.l");
  411.    LName[0] = 0;
  412.    strcpy(CommandFile,"fractint.par");
  413.    CommandName[0] = CommandComment1[0] = CommandComment2[0] = 0;
  414.    CommandComment3[0] = CommandComment4[0] = 0;
  415.    strcpy(IFSFileName,"fractint.ifs");
  416.    IFSName[0] = 0;
  417.    reset_ifs_defn();
  418.    rflag = 0;                /* not a fixed srand() seed */
  419.    rseed = init_rseed;
  420.    strcpy(readname,DOTSLASH);           /* initially current directory */
  421.    showfile = 1;
  422.    /* next should perhaps be fractal re-init, not just <ins> ? */
  423.    initcyclelimit=55;            /* spin-DAC default speed limit */
  424.    mapset = 0;                /* no map= name active */
  425.    if (mapdacbox) {
  426.       farmemfree(mapdacbox);
  427.       mapdacbox = NULL;
  428.       }
  429.    TPlusFlag = 1;
  430.    MaxColorRes = 8;
  431.    PixelZoom = 0;
  432.    NonInterlaced = 0;
  433.  
  434.    Transparent3D = 0;
  435.    SolidCore = 1;
  436.    CoreRed   = 128;
  437.    CoreGreen = 128;
  438.    CoreBlue  = 128;
  439.    zzmin = -1.5;
  440.    zzmax = 1.5;
  441.    ttmin = 0.0;
  442.    ttmax = 0.0;
  443.    NumFrames = 1;
  444.    tpdepth = tptime = 0;
  445.  
  446.    AntiAliasing = 0;
  447.    Shadowing = 0;
  448.  
  449.    Printer_Type = DEFAULT_PRINTER;      /* assume an IBM/EPSON    */
  450.    Printer_Resolution = PRT_RESOLUTION; /* assume low resolution  */
  451.    Printer_Titleblock = 0;        /* assume no title block  */
  452.    Printer_ColorXlat = 0;        /* assume positive image  */
  453.    Printer_SetScreen = 0;               /* assume default screen  */
  454.    Printer_SFrequency = 45;             /* New screen frequency K */
  455.    Printer_SAngle = 45;                 /* New screen angle     K */
  456.    Printer_SStyle = 1;                  /* New screen style     K */
  457.    Printer_RFrequency = 45;             /* New screen frequency R */
  458.    Printer_RAngle = 75;                 /* New screen angle     R */
  459.    Printer_RStyle = 1;                  /* New screen style     R */
  460.    Printer_GFrequency = 45;             /* New screen frequency G */
  461.    Printer_GAngle = 15;                 /* New screen angle     G */
  462.    Printer_GStyle = 1;                  /* New screen style     G */
  463.    Printer_BFrequency = 45;             /* New screen frequency B */
  464.    Printer_BAngle = 0;                  /* New screen angle     B */
  465.    Printer_BStyle = 1;                  /* New screen style     B */
  466. #ifndef XFRACT
  467.    Print_To_File = 0;                   /* No print-to-file       */
  468.    Printer_CRLF = 0;                    /* Assume CR+LF           */
  469. #else
  470.    Print_To_File = 1;                   /* Print-to-file          */
  471.    Printer_CRLF = 2;                    /* Assume LF              */
  472.    Printer_Compress = 0;                /* Assume NO PostScript compression */
  473. #endif
  474.    EPSFileType = 0;            /* Assume no save to .EPS */
  475.    LPTNumber = 1;            /* assume LPT1 */
  476.    ColorPS = 0;                         /* Assume NO Color PostScr*/
  477.    major_method = minor_method = 0;    /* default inverse julia methods */
  478. }
  479.  
  480. static void initvars_fractal()        /* init vars affecting calculation */
  481. {
  482.    int i;
  483.    bios_palette = 0;                    /* don't force use of a BIOS palette */
  484.    escape_exit = 0;                     /* don't disable the "are you sure?" screen */
  485.    usr_periodicitycheck = 1;        /* turn on periodicity      */
  486.    inside = 1;                /* inside color = blue      */
  487.    fillcolor = -1;            /* no special fill color */
  488.    usr_biomorph = -1;            /* turn off biomorph flag */
  489.    outside = -1;            /* outside color = -1 (not used) */
  490.    maxit = 150;             /* initial maxiter      */
  491.    usr_stdcalcmode = 'g';               /* initial solid-guessing */
  492. #ifndef XFRACT
  493.    usr_floatflag = 0;            /* turn off the float flag */
  494. #else
  495.    usr_floatflag = 1;            /* turn on the float flag */
  496. #endif
  497.    finattract = 0;            /* disable finite attractor logic */
  498.    fractype = 0;            /* initial type Set flag  */
  499.    curfractalspecific = &fractalspecific[0];
  500.    initcorners = initparams = 0;
  501.    bailout = 0;             /* no user-entered bailout */
  502.    useinitorbit = 0;
  503.    for (i = 0; i < MAXPARAMS; i++) param[i] = 0.0;     /* initial parameter values */
  504.    for (i = 0; i < 3; i++) potparam[i]    = 0.0; /* initial potential values */
  505.    for (i = 0; i < 3; i++) inversion[i] = 0.0;    /* initial invert values */
  506.    initorbit[0] = initorbit[1] = 0.0;    /* initial orbit values */
  507.    invert = 0;
  508.    decomp[0] = decomp[1] = 0;
  509.    usr_distest = 0;
  510.    distestwidth = 71;
  511.    forcesymmetry = 999;         /* symmetry not forced */
  512.    xx3rd = xxmin = -2.5; xxmax = 1.5;    /* initial corner values  */
  513.    yy3rd = yymin = -1.5; yymax = 1.5;    /* initial corner values  */
  514.    pot16bit = potflag = 0;
  515.    LogFlag = 0;             /* no logarithmic palette */
  516.    set_trig_array(0,"sin");             /* trigfn defaults */
  517.    set_trig_array(1,"sqr");
  518.    set_trig_array(2,"sinh");
  519.    set_trig_array(3,"cosh");
  520.    if (rangeslen) {
  521.       farmemfree((char far *)ranges);
  522.       rangeslen = 0;
  523.       }
  524.    usemag = 0;                /* use corners, not center-mag */
  525.  
  526.    colorstate = colorpreloaded = 0;
  527.    rotate_lo = 1; rotate_hi = 255;    /* color cycling default range */
  528.  
  529.    display3d = 0;            /* 3D display is off        */
  530.    overlay3d = 0;            /* 3D overlay is off        */
  531.  
  532.    functionpreloaded = 0; /* for old bifs  JCO 7/5/92 */
  533.    mxminfp = -.83;
  534.    myminfp = -.25;
  535.    mxmaxfp = -.83;
  536.    mymaxfp =  .25;
  537.    originfp = 8;
  538.    heightfp = 7;
  539.    widthfp = 10;
  540.    distfp = 24;
  541.    eyesfp = 2.5;
  542.    depthfp = 8;
  543.    lastorbittype = -1;
  544.    neworbittype = JULIA;
  545.    zdots = 128;
  546.    initvars_3d();
  547. }
  548.  
  549. static void initvars_3d()        /* init vars affecting 3d */
  550. {
  551.    RAY     = 0;
  552.    BRIEF   = 0;
  553.    SPHERE = FALSE;
  554.    preview = 0;
  555.    showbox = 0;
  556.    xadjust = 0;
  557.    yadjust = 0;
  558.    eyeseparation = 0;
  559.    glassestype = 0;
  560.    previewfactor = 20;
  561.    red_crop_left   = 4;
  562.    red_crop_right  = 0;
  563.    blue_crop_left  = 0;
  564.    blue_crop_right = 4;
  565.    red_bright      = 80;
  566.    blue_bright     = 100;
  567.    transparent[0] = transparent[1] = 0; /* no min/max transparency */
  568.    set_3d_defaults();
  569. }
  570.  
  571. static void reset_ifs_defn()
  572. {
  573.    if (ifs_defn) {
  574.       farmemfree((char far *)ifs_defn);
  575.       ifs_defn = NULL;
  576.       }
  577. }
  578.  
  579.  
  580. static int cmdfile(FILE *handle,int mode)
  581.    /* mode = 0 command line @filename          */
  582.    /*         1 sstools.ini              */
  583.    /*         2 <@> command after startup      */
  584.    /*         3 command line @filename/setname */
  585. {
  586.    /* note that cmdfile could be open as text OR as binary */
  587.    /* binary is used in @ command processing for reasonable speed note/point */
  588.    int i;
  589.    int lineoffset = 0;
  590.    int changeflag = 0; /* &1 fractal stuff chgd, &2 3d stuff chgd */
  591.    char linebuf[513],cmdbuf[1001];
  592.    if (mode == 2 || mode == 3) {
  593.       while ((i = getc(handle)) != '{' && i != EOF) { }
  594.       CommandComment1[0] = CommandComment2[0] = 0;
  595.       CommandComment3[0] = CommandComment4[0] = 0;
  596.       }
  597.    linebuf[0] = 0;
  598.    while (next_command(cmdbuf,1000,handle,linebuf,&lineoffset,mode) > 0) {
  599.       if ((mode == 2 || mode == 3) && strcmp(cmdbuf,"}") == 0) break;
  600.       if ((i = cmdarg(cmdbuf,mode)) < 0) break;
  601.       changeflag |= i;
  602.       }
  603.    fclose(handle);
  604. #ifdef XFRACT
  605.    initmode = 0;        /* Skip credits if @file is used. */
  606. #endif
  607.    return changeflag;
  608. }
  609.  
  610. static int next_command(char *cmdbuf,int maxlen,
  611.               FILE *handle,char *linebuf,int *lineoffset,int mode)
  612. {
  613.    int cmdlen = 0;
  614.    char *lineptr;
  615.    lineptr = linebuf + *lineoffset;
  616.    while(1) {
  617.       while (*lineptr <= ' ' || *lineptr == ';') {
  618.      if (cmdlen) {            /* space or ; marks end of command */
  619.         cmdbuf[cmdlen] = 0;
  620.         *lineoffset = lineptr - linebuf;
  621.         return cmdlen;
  622.         }
  623.      while (*lineptr && *lineptr <= ' ')
  624.         ++lineptr;            /* skip spaces and tabs */
  625.      if (*lineptr == ';' || *lineptr == 0) {
  626.         if (*lineptr == ';'
  627.           && (mode == 2 || mode == 3)
  628.           && (CommandComment1[0] == 0 || CommandComment2[0] == 0 ||
  629.               CommandComment3[0] == 0 || CommandComment4[0] == 0)) {
  630.            /* save comment */
  631.            while (*(++lineptr)
  632.          && (*lineptr == ' ' || *lineptr == '\t')) { }
  633.            if (*lineptr) {
  634.           if (strlen(lineptr) > 56)
  635.              *(lineptr+56) = 0;
  636.           if (CommandComment1[0] == 0)
  637.              far_strcpy(CommandComment1,lineptr);
  638.           else if (CommandComment2[0] == 0)
  639.              far_strcpy(CommandComment2,lineptr);
  640.           else if (CommandComment3[0] == 0)
  641.              far_strcpy(CommandComment3,lineptr);
  642.           else
  643.              far_strcpy(CommandComment4,lineptr);
  644.           }
  645.            }
  646.         if (next_line(handle,linebuf,mode) != 0)
  647.            return(-1); /* eof */
  648.         lineptr = linebuf; /* start new line */
  649.         }
  650.      }
  651.       if (*lineptr == '\\'              /* continuation onto next line? */
  652.     && *(lineptr+1) == 0) {
  653.      if (next_line(handle,linebuf,mode) != 0) {
  654.         argerror(cmdbuf);        /* missing continuation */
  655.         return(-1);
  656.         }
  657.      lineptr = linebuf;
  658.      while (*lineptr && *lineptr <= ' ')
  659.         ++lineptr;            /* skip white space @ start next line */
  660.      continue;            /* loop to check end of line again */
  661.      }
  662.       cmdbuf[cmdlen] = *(lineptr++);    /* copy character to command buffer */
  663.       if (++cmdlen >= maxlen) {     /* command too long? */
  664.      argerror(cmdbuf);
  665.      return(-1);
  666.      }
  667.       }
  668. }
  669.  
  670. static int next_line(FILE *handle,char *linebuf,int mode)
  671. {
  672.    int toolssection;
  673.    char tmpbuf[10];
  674.    toolssection = 0;
  675.    while (file_gets(linebuf,512,handle) >= 0) {
  676.       if (mode == 1 && linebuf[0] == '[') {     /* check for [fractint] */
  677.      strncpy(tmpbuf,&linebuf[1],9);
  678.      tmpbuf[9] = 0;
  679.      strlwr(tmpbuf);
  680.      toolssection = strncmp(tmpbuf,"fractint]",9);
  681.      continue;                /* skip tools section heading */
  682.      }
  683.       if (toolssection == 0) return(0);
  684.       }
  685.    return(-1);
  686. }
  687.  
  688. /*
  689.   cmdarg(string,mode) processes a single command-line/command-file argument
  690.     return:
  691.       -1 error, >= 0 ok
  692.       if ok, return value:
  693.     | 1 means fractal parm has been set
  694.     | 2 means 3d parm has been set
  695.     | 4 means 3d=yes specified
  696.     | 8 means reset specified
  697. */
  698.  
  699. int cmdarg(char *curarg,int mode) /* process a single argument */
  700. {
  701.    char    variable[21];        /* variable name goes here   */
  702.    char    *value;            /* pointer to variable value */
  703.    int       valuelen;            /* length of value         */
  704.    int       numval;            /* numeric value of arg      */
  705. #define NONNUMERIC -32767
  706.    char    charval;            /* first character of arg    */
  707.    int       yesnoval;            /* 0 if 'n', 1 if 'y', -1 if not */
  708.    double  ftemp;
  709.    int       i, j, k, l;
  710.    char    *argptr,*argptr2;
  711.    int       totparms;            /* # of / delimited parms    */
  712.    int       intparms;            /* # of / delimited ints     */
  713.    int       floatparms;            /* # of / delimited floats   */
  714.    int       intval[64];            /* pre-parsed integer parms  */
  715.    double  floatval[16];        /* pre-parsed floating parms */
  716.    char    tmpc;
  717.    int       lastarg;
  718.  
  719.    argptr = curarg;
  720.    while (*argptr) {            /* convert to lower case */
  721.       if (*argptr >= 'A' && *argptr <= 'Z')
  722.      *argptr += 'a' - 'A';
  723.       if (*argptr == '=' && strncmp(curarg,"colors=",7) == 0)
  724.      break;             /* don't convert colors=value */
  725.       ++argptr;
  726.       }
  727.  
  728.    if ((value = strchr(&curarg[1],'='))) {
  729.       if ((j = (value++) - curarg) > 1 && curarg[j-1] == ':')
  730.      --j;                /* treat := same as =      */
  731.       }
  732.    else
  733.       value = curarg + (j = strlen(curarg));
  734.    if (j > 20) goto badarg;        /* keyword too long */
  735.    strncpy(variable,curarg,j);        /* get the variable name  */
  736.    variable[j] = 0;            /* truncate variable name */
  737.    valuelen = strlen(value);        /* note value's length    */
  738.    charval = value[0];            /* first letter of value  */
  739.    yesnoval = -1;            /* note yes|no value      */
  740.    if (charval == 'n') yesnoval = 0;
  741.    if (charval == 'y') yesnoval = 1;
  742.  
  743.    argptr = value;
  744.    numval = totparms = intparms = floatparms = 0;
  745.    while (*argptr) {            /* count and pre-parse parms */
  746.       long ll;
  747.       lastarg = 0;
  748.       if ((argptr2 = strchr(argptr,'/')) == NULL) {     /* find next '/' */
  749.      argptr2 = argptr + strlen(argptr);
  750.      *argptr2 = '/';
  751.      lastarg = 1;
  752.      }
  753.       if (totparms == 0) numval = NONNUMERIC;
  754.       i = -1;
  755.       charval = *argptr;            /* first letter of value  */
  756.       if (charval == 'n') yesnoval = 0;    /* allows only ONE y/n param */
  757.       if (charval == 'y') yesnoval = 1;
  758.       if (sscanf(argptr,"%c%c",&j,&tmpc) > 0    /* NULL entry */
  759.       && (j == '/' || j == '=') && tmpc == '/') {
  760.      j = 0;
  761.      ++floatparms; ++intparms;
  762.      if (totparms < 16) floatval[totparms] = j;
  763.      if (totparms < 64) intval[totparms] = j;
  764.      if (totparms == 0) numval = j;
  765.      }
  766.       else if (sscanf(argptr,"%ld%c",&ll,&tmpc) > 0       /* got an integer */
  767.     && tmpc == '/') {        /* needs a long int, ll, here for lyapunov */
  768.      ++floatparms; ++intparms;
  769.      if (totparms < 16) floatval[totparms] = ll;
  770.      if (totparms < 64) intval[totparms] = (int)ll;
  771.      if (totparms == 0) numval = (int)ll;
  772.      }
  773. #ifndef XFRACT
  774.       else if (sscanf(argptr,"%lg%c",&ftemp,&tmpc) > 0  /* got a float */
  775. #else
  776.       else if (sscanf(argptr,"%lf%c",&ftemp,&tmpc) > 0  /* got a float */
  777. #endif
  778.          && tmpc == '/') {
  779.      ++floatparms;
  780.      if (totparms < 16) floatval[totparms] = ftemp;
  781.      }
  782.       ++totparms;
  783.       argptr = argptr2;                 /* on to the next */
  784.       if (lastarg)
  785.      *argptr = 0;
  786.       else
  787.      ++argptr;
  788.       }
  789.  
  790.    if (mode != 2 || debugflag==110) {
  791.       /* these commands are allowed only at startup */
  792.  
  793.       if (strcmp(variable,"batch") == 0 ) {     /* batch=?      */
  794.      if (yesnoval < 0) goto badarg;
  795. #ifdef XFRACT
  796.          initmode = yesnoval?0:-1; /* skip credits for batch mode */
  797. #endif
  798.      initbatch = yesnoval;
  799.      return 3;
  800.      }
  801.  
  802. #ifndef XFRACT
  803.       if (strcmp(variable,"adapter") == 0 ) {   /* adapter==?     */
  804.          int i, j;
  805.          extern char supervga_list;    /* from the list in VIDEO.ASM */
  806.          char adapter_name[8];      /* entry lenth from VIDEO.ASM */
  807.          char *adapter_ptr;
  808.          
  809.          adapter_ptr = &supervga_list;
  810.          
  811.          for(i = 0 ; ; i++) {        /* find the SuperVGA entry */
  812.              memcpy(adapter_name , adapter_ptr, 8);
  813.              adapter_name[6] = ' ';
  814.              for (j = 0; j < 8; j++)
  815.                  if(adapter_name[j] == ' ')
  816.                      adapter_name[j] = 0;
  817.              if (adapter_name[0] == 0) break;  /* end-of-the-list */
  818.              if (strncmp(value,adapter_name,strlen(adapter_name)) == 0) {
  819.                 svga_type = i+1;
  820.                 adapter_ptr[6] = 1;
  821.                 break;
  822.                 }
  823.              adapter_ptr += 8;
  824.              }
  825.          if (svga_type != 0) return 3;
  826.  
  827.      video_type = 5;            /* assume video=vga */
  828.      if (strcmp(value,"egamono") == 0) {
  829.         video_type = 3;
  830.         mode7text = 1;
  831.         }
  832.      else if (strcmp(value,"hgc") == 0) {   /* video = hgc */
  833.         video_type = 1;
  834.         mode7text = 1;
  835.         }
  836.      else if (strcmp(value,"ega") == 0)     /* video = ega */
  837.         video_type = 3;
  838.      else if (strcmp(value,"cga") == 0)     /* video = cga */
  839.         video_type = 2;
  840.      else if (strcmp(value,"mcga") == 0)    /* video = mcga */
  841.         video_type = 4;
  842.      else if (strcmp(value,"vga") == 0)     /* video = vga */
  843.         video_type = 5;
  844.      else
  845.         goto badarg;
  846.      return 3;
  847.      }
  848.  
  849.       if (strcmp(variable,"afi") == 0) {
  850.        if (strncmp(value,"8514"  ,4) == 0
  851.            || charval == 'y') ai_8514 = 1; /* set afi flag JCO 4/11/92 */
  852.        return 3;
  853.     }
  854.  
  855.       if (strcmp(variable,"textsafe") == 0 ) {  /* textsafe==? */
  856.      if (first_init) {
  857.         if (charval == 'n') /* no */
  858.            textsafe = 2;
  859.         else if (charval == 'y') /* yes */
  860.            textsafe = 1;
  861.         else if (charval == 'b') /* bios */
  862.            textsafe = 3;
  863.         else if (charval == 's') /* save */
  864.            textsafe = 4;
  865.         else
  866.            goto badarg;
  867.         }   
  868.      return 3;
  869.      }
  870.  
  871.       if (strcmp(variable, "vesadetect") == 0) {
  872.      if (yesnoval < 0) goto badarg;
  873.      vesa_detect = yesnoval;
  874.      return 3;
  875.      }
  876.  
  877.       if (strcmp(variable, "biospalette") == 0) {
  878.          if (yesnoval < 0) goto badarg;
  879.          bios_palette = yesnoval;
  880.          return 3;
  881.          }
  882.  
  883.       if (strcmp(variable,"fpu") == 0) {
  884.      if (strcmp(value,"iit") == 0) {
  885.         fpu = 387;
  886.         iit = 1;
  887.         return 0;
  888.         }
  889.      if (strcmp(value,"noiit") == 0) {
  890.         iit = -2;
  891.         return 0;
  892.         }
  893.      if (strcmp(value,"387") == 0) {
  894.         fpu = 387;
  895.         iit = -2;
  896.         return 0;
  897.         }
  898.      goto badarg;
  899.      }
  900. #endif
  901.  
  902.       if (strcmp(variable, "exitnoask") == 0) {
  903.          if (yesnoval < 0) goto badarg;
  904.          escape_exit = yesnoval;
  905.          return 3;
  906.          }
  907.  
  908.       if (strcmp(variable,"makedoc") == 0) {
  909.      print_document(*value ? value : "fractint.doc", makedoc_msg_func, 0);
  910. #ifndef WINFRACT
  911.      goodbye();
  912. #endif
  913.      }
  914.  
  915.       } /* end of commands allowed only at startup */
  916.  
  917.    if (strcmp(variable,"reset") == 0) {
  918.       initvars_fractal();
  919.  
  920.       /* PAR release unknown unless specified */
  921.       if (numval>=0) save_release = numval;
  922.       else goto badarg;
  923.       return 9;
  924.       }
  925.  
  926.    if (strcmp(variable,"filename") == 0) {      /* filename=?     */
  927.       if (charval == '.') {
  928.      if (valuelen > 4) goto badarg;
  929.      gifmask[0] = '*';
  930.      gifmask[1] = 0;
  931.      strcat(gifmask,value);
  932.      return 0;
  933.      }
  934.       if (valuelen > 79) goto badarg;
  935.       if (mode == 2 && display3d == 0) /* can't do this in @ command */
  936.      goto badarg;
  937.       strcpy(readname,value);
  938.       showfile = 0;
  939.       return 3;
  940.       }
  941.  
  942.    if (strcmp(variable,"video") == 0) {         /* video=? */
  943.       if (active_system == 0) {
  944.      if ((k = check_vidmode_keyname(value)) == 0) goto badarg;
  945.      initmode = -1;
  946.      for (i = 0; i < MAXVIDEOTABLE; ++i) {
  947.         if (videotable[i].keynum == k) {
  948.            initmode = i;
  949.            break;
  950.            }
  951.         }
  952.      if (initmode == -1) goto badarg;
  953.      }
  954.       return 3;
  955.       }
  956.  
  957.    if (strcmp(variable,"map") == 0 ) {         /* map=, set default colors */
  958.       if (valuelen > 79 || SetColorPaletteName(value) != 0) goto badarg;
  959.       mapset = 1;
  960.       strcpy(MAP_name,value);
  961.       return 0;
  962.       }
  963.  
  964.    if (strcmp(variable,"colors") == 0) {       /* colors=, set current colors */
  965.       if (parse_colors(value) < 0) goto badarg;
  966.       return 0;
  967.       }
  968.  
  969.    if (strcmp(variable, "tplus") == 0) {       /* Use the TARGA+ if found? */
  970.       if (yesnoval < 0) goto badarg;
  971.       TPlusFlag = yesnoval;
  972.       return 0;
  973.       }
  974.  
  975.    if (strcmp(variable, "noninterlaced") == 0) {
  976.       if (yesnoval < 0) goto badarg;
  977.       NonInterlaced = yesnoval;
  978.       return 0;
  979.       }
  980.  
  981.    if (strcmp(variable, "maxcolorres") == 0) { /* Change default color resolution */
  982.       if (numval == 1 || numval == 4 || numval == 8 ||
  983.             numval == 16 || numval == 24) {
  984.      MaxColorRes = numval;
  985.      return 0;
  986.      }
  987.       goto badarg;
  988.       }
  989.  
  990.    if (strcmp(variable, "pixelzoom") == 0) {
  991.       if (numval < 5)
  992.      PixelZoom = numval;
  993.       return 0;
  994.       }
  995.  
  996.    /* keep this for backward compatibility */
  997.    if (strcmp(variable,"warn") == 0 ) {         /* warn=? */
  998.       if (yesnoval < 0) goto badarg;
  999.       overwrite = yesnoval ^ 1;
  1000.       return 0;
  1001.       }
  1002.    if (strcmp(variable,"overwrite") == 0 ) {    /* overwrite=? */
  1003.       if (yesnoval < 0) goto badarg;
  1004.       overwrite = yesnoval;
  1005.       return 0;
  1006.       }
  1007.  
  1008.    if (strcmp(variable,"gif87a") == 0 ) {       /* gif87a=? */
  1009.       if (yesnoval < 0) goto badarg;
  1010.       gif87a_flag = yesnoval;
  1011.       return 0;
  1012.       }
  1013.  
  1014.    if (strcmp(variable,"dither") == 0 ) {       /* dither=? */
  1015.       if (yesnoval < 0) goto badarg;
  1016.       dither_flag = yesnoval;
  1017.       return 0;
  1018.       }
  1019.  
  1020.    if (strcmp(variable,"savetime") == 0) {      /* savetime=? */
  1021.       initsavetime = numval;
  1022.       return 0;
  1023.       }
  1024.  
  1025.    if (strcmp(variable,"autokey") == 0) {       /* autokey=? */
  1026.       if (strcmp(value,"record")==0)
  1027.      slides=2;
  1028.       else if (strcmp(value,"play")==0)
  1029.      slides=1;
  1030.       else
  1031.      goto badarg;
  1032.       return 0;
  1033.       }
  1034.  
  1035.    if(strcmp(variable, "solidcore") == 0) {
  1036.       SolidCore = yesnoval;
  1037.       return(0);
  1038.       }
  1039. /* (nuked until antialiasing become an option)
  1040.    if(strcmp(variable, "antialias") == 0) {
  1041.       if(numval < 0 || numval > 8)
  1042.      goto badarg;
  1043.       AntiAliasing = numval;
  1044.       return(0);
  1045.       }
  1046. */
  1047.    if(strcmp(variable, "transparent3d") == 0) {
  1048.       Transparent3D = yesnoval;
  1049.       return(0);
  1050.       }
  1051.  
  1052.    if(strcmp(variable, "corecolor") == 0) {
  1053.       if(floatparms != totparms || totparms != 3)
  1054.      goto badarg;
  1055.       CoreRed    = (int)floatval[0];
  1056.       CoreGreen = (int)floatval[1];
  1057.       CoreBlue    = (int)floatval[2];
  1058.       return(0);
  1059.       }
  1060.  
  1061.    if(strcmp(variable, "mdcorners") == 0) {
  1062.       if(floatparms != totparms || totparms < 2 || totparms > 4)
  1063.      goto badarg;
  1064.       zzmin = floatval[0];
  1065.       zzmax = floatval[1];
  1066.       if(totparms >= 3)
  1067.      ttmin = floatval[2];
  1068.       if(totparms == 4)
  1069.      ttmax = floatval[3];
  1070.       return(0);
  1071.       }
  1072.  
  1073.    if(strcmp(variable, "numframes") == 0) {
  1074.       NumFrames = numval;
  1075.       return(0);
  1076.       }
  1077.  
  1078.    if (strcmp(variable,"autokeyname") == 0) {   /* autokeyname=? */
  1079.       strcpy(autoname,value);
  1080.       return 0;
  1081.       }
  1082.  
  1083.    if (strcmp(variable,"type") == 0 ) {         /* type=? */
  1084.       if (value[valuelen-1] == '*')
  1085.      value[--valuelen] = 0;
  1086.       /* kludge because type ifs3d has an asterisk in front */
  1087.       if(strcmp(value,"ifs3d")==0)
  1088.          value[3]=0;
  1089.       for (k = 0; fractalspecific[k].name != NULL; k++)
  1090.      if (strcmp(value,fractalspecific[k].name) == 0)
  1091.         break;
  1092.       if (fractalspecific[k].name == NULL) goto badarg;
  1093.       curfractalspecific = &fractalspecific[fractype = k];
  1094.       if (initcorners == 0) {
  1095.      xx3rd = xxmin = curfractalspecific->xmin;
  1096.      xxmax           = curfractalspecific->xmax;
  1097.      yy3rd = yymin = curfractalspecific->ymin;
  1098.      yymax           = curfractalspecific->ymax;
  1099.      }
  1100.       if (initparams == 0) {
  1101.      for (k = 0; k < 4; ++k) {
  1102.         param[k] = curfractalspecific->paramvalue[k];
  1103.         if(fractype != CELLULAR) /* don't round cellular */
  1104.            roundfloatd(¶m[k]);
  1105.       }
  1106.          if(curfractalspecific->flags&MORE) {
  1107.             int extra;
  1108.             if((extra=find_extra_param(fractype)) > -1)
  1109.             for(i=0;i<MAXPARAMS-4;i++) {
  1110.                param[i+4] = moreparams[extra].paramvalue[i];
  1111.            }
  1112.          }
  1113.       }   
  1114.       return 1;
  1115.       }
  1116.    if (strcmp(variable,"inside") == 0 ) {       /* inside=? */
  1117.       if(strcmp(value,s_zmag)==0)
  1118.      inside = -59;
  1119.       else if(strcmp(value,s_bof60)==0)
  1120.      inside = -60;
  1121.       else if(strcmp(value,s_bof61)==0)
  1122.      inside = -61;
  1123.       else if(strncmp(value,s_epscross,3)==0)
  1124.      inside = -100;
  1125.       else if(strncmp(value,s_startrail,4)==0)
  1126.      inside = -101;
  1127.       else if(strncmp(value,s_period,3)==0)
  1128.      inside = -102;
  1129.       else if(strcmp(value,s_maxiter)==0)
  1130.      inside = -1;
  1131.       else if(numval == NONNUMERIC)
  1132.      goto badarg;
  1133.       else
  1134.      inside = numval;
  1135.       return 1;
  1136.       }
  1137.    if (strcmp(variable,"fillcolor") == 0 ) {       /* fillcolor */
  1138.       if(strcmp(value,s_normal)==0)
  1139.      fillcolor = -1;
  1140.       else if(numval == NONNUMERIC)
  1141.      goto badarg;
  1142.       else
  1143.      fillcolor = numval;
  1144.       return 1;
  1145.       }
  1146.  
  1147.    if (strcmp(variable,"finattract") == 0 ) {   /* finattract=? */
  1148.       if (yesnoval < 0) goto badarg;
  1149.       finattract = yesnoval;
  1150.       return 1;
  1151.       }
  1152.  
  1153.    if (strcmp(variable,"function") == 0) {      /* function=?,? */
  1154.       k = 0;
  1155.       while (*value && k < 4) {
  1156.      if(set_trig_array(k++,value)) goto badarg;
  1157.      if ((value = strchr(value,'/')) == NULL) break;
  1158.      ++value;
  1159.      }
  1160.        functionpreloaded = 1; /* for old bifs  JCO 7/5/92 */
  1161.       return 1;
  1162.       }
  1163.  
  1164.    if (strcmp(variable,"outside") == 0 ) {      /* outside=? */
  1165.       if(strcmp(value,s_iter)==0)
  1166.      outside = -1;
  1167.       if(strcmp(value,s_real)==0)
  1168.      outside = -2;
  1169.       else if(strcmp(value,s_imag)==0)
  1170.      outside = -3;
  1171.       else if(strcmp(value,s_mult)==0)
  1172.      outside = -4;
  1173.       else if(strcmp(value,s_sum)==0)
  1174.      outside = -5;
  1175.  
  1176.       else if(numval == NONNUMERIC)
  1177.      goto badarg;
  1178.       else if(numval < -5 || numval > 255) goto badarg;
  1179.       else outside = numval;
  1180.       return 1;
  1181.       }
  1182.  
  1183.    if (strcmp(variable,s_maxiter) == 0) {       /* maxiter=? */
  1184.       if (numval < 2) goto badarg;
  1185.       maxit = numval;
  1186.       return 1;
  1187.       }
  1188.  
  1189.    if (strcmp(variable,"iterincr") == 0)        /* iterincr=? */
  1190.       return 0;
  1191.  
  1192.    if (strcmp(variable,"passes") == 0) {        /* passes=? */
  1193.       if ( charval != '1' && charval != '2'
  1194.     && charval != 'g' && charval != 'b'
  1195.     && charval != 't')
  1196.      goto badarg;
  1197.       usr_stdcalcmode = charval;
  1198.       return 1;
  1199.       }
  1200.  
  1201.    if (strcmp(variable,"cyclelimit") == 0 ) {   /* cyclelimit=? */
  1202.       if (numval <= 1 || numval > 256) goto badarg;
  1203.       initcyclelimit = numval;
  1204.       return 0;
  1205.       }
  1206.  
  1207.    if (strcmp(variable,"makemig") == 0) {
  1208.        int xmult, ymult;
  1209.        if (totparms < 2) goto badarg;
  1210.        xmult = intval[0];
  1211.        ymult = intval[1];
  1212.        make_mig(xmult, ymult);
  1213. #ifndef WINFRACT
  1214.        exit(0);
  1215. #endif
  1216.        }
  1217.  
  1218.    if (strcmp(variable,"cyclerange") == 0) {
  1219.       if (totparms < 2) intval[1] = 255;
  1220.       if (totparms < 1) intval[0] = 1;
  1221.       if (totparms != intparms
  1222.     || intval[0] < 0 || intval[1] > 255 || intval[0] > intval[1])
  1223.      goto badarg;
  1224.       rotate_lo = intval[0];
  1225.       rotate_hi = intval[1];
  1226.       return 0;
  1227.       }
  1228.  
  1229.    if (strcmp(variable,"ranges") == 0) {
  1230.       int i,j,entries,prev;
  1231.       int tmpranges[128];
  1232.       if (totparms != intparms) goto badarg;
  1233.       entries = prev = i = 0;
  1234.       while (i < totparms) {
  1235.      if ((j = intval[i++]) < 0) { /* striping */
  1236.         if ((j = 0-j) < 1 || j >= 16384 || i >= totparms) goto badarg;
  1237.         tmpranges[entries++] = -1; /* {-1,width,limit} for striping */
  1238.         tmpranges[entries++] = j;
  1239.         j = intval[i++];
  1240.         }
  1241.      if (j < prev) goto badarg;
  1242.      tmpranges[entries++] = prev = j;
  1243.      }
  1244.       if (prev == 0) goto badarg;
  1245.       if ((ranges = (int far *)farmemalloc(2L*entries)) == NULL) {
  1246.      static char far msg[] = {"Insufficient memory for ranges="};
  1247.      stopmsg(0,msg);
  1248.      return(-1);
  1249.      }
  1250.       rangeslen = entries;
  1251.       for (i = 0; i < rangeslen; ++i)
  1252.      ranges[i] = tmpranges[i];
  1253.       return 1;
  1254.       }
  1255.  
  1256.    if (strcmp(variable,"savename") == 0) {      /* savename=? */
  1257.       if (valuelen > 79) goto badarg;
  1258.       if (first_init || mode == 2)
  1259.      strcpy(savename,value);
  1260.       return 0;
  1261.       }
  1262.  
  1263.    if (strcmp(variable,"exitmode") == 0) {      /* exitmode=? */
  1264.       sscanf(value,"%x",&numval);
  1265.       exitmode = numval;
  1266.       return 0;
  1267.       }
  1268.  
  1269.    if (strcmp(variable,"textcolors") == 0) {
  1270.       parse_textcolors(value);
  1271.       return 0;
  1272.       }
  1273.  
  1274.    if (strcmp(variable,"potential") == 0) {     /* potential=? */
  1275.       k = 0;
  1276.       while (k < 3 && *value) {
  1277.          if(k==1)
  1278.         potparam[k] = atof(value);
  1279.      else
  1280.         potparam[k] = atoi(value);
  1281.      k++;
  1282.        if ((value = strchr(value,'/')) == NULL) k = 99;
  1283.      ++value;
  1284.      }
  1285.       pot16bit = 0;
  1286.       if (k < 99) {
  1287.      if (strcmp(value,"16bit")) goto badarg;
  1288.      pot16bit = 1;
  1289.      }
  1290.       return 1;
  1291.       }
  1292.  
  1293.    if (strcmp(variable,"params") == 0) {        /* params=?,? */
  1294.       if (totparms != floatparms || totparms > MAXPARAMS)
  1295.      goto badarg;
  1296.       for (k = 0; k < MAXPARAMS; ++k)
  1297.      param[k] = (k < totparms) ? floatval[k] : 0.0;
  1298.       initparams = 1;
  1299.       return 1;
  1300.       }
  1301.  
  1302.    if (strcmp(variable, "miim") == 0) {        /* miim=?[/?[/?[/?]]] */
  1303.       k = 0;
  1304.       do {
  1305.      if (isdigit(*value) ||
  1306.          *value == '.' || *value == '-' || *value == '+') {
  1307.         if (k >= 4)
  1308.            goto badarg;
  1309.         param[k++] = atof(value);
  1310.      }
  1311.      else if (strncmp(value, "breadth", 7) == 0)
  1312.         major_method = 0;
  1313.      else if (strncmp(value, "depth",   5) == 0)
  1314.         major_method = 1;
  1315.      else if (strncmp(value, "walk",    4) == 0)
  1316.         major_method = 2;
  1317.      else if (strncmp(value, "run",     3) == 0)
  1318.         major_method = 3;
  1319.      else if (strncmp(value, "left",    4) == 0)
  1320.         minor_method = 0;
  1321.      else if (strncmp(value, "right",   5) == 0)
  1322.         minor_method = 1;
  1323.      else goto badarg;
  1324.      value = strchr(value, '/');
  1325.       } while (value++);
  1326.       return 1;
  1327.    }
  1328.  
  1329.    if (strcmp(variable,"initorbit") == 0) {     /* initorbit=?,? */
  1330.       if(strcmp(value,"pixel")==0)
  1331.      useinitorbit = 2;
  1332.       else {
  1333.      if (totparms != 2 || floatparms != 2) goto badarg;
  1334.      initorbit[0] = floatval[0];
  1335.      initorbit[1] = floatval[1];
  1336.      useinitorbit = 1;
  1337.      }
  1338.       return 1;
  1339.       }
  1340.  
  1341.    if (strcmp(variable,"orbitname") == 0 ) {         /* orbitname=? */
  1342.       if(check_orbit_name(value))
  1343.          goto badarg;
  1344.       return 1;
  1345.       }
  1346.    if (strcmp(variable,"3dmode") == 0 ) {         /* orbitname=? */
  1347.       int i,j;
  1348.       j = -1;
  1349.       for(i=0;i<4;i++)
  1350.          if(strcmp(value,juli3Doptions[i])==0)
  1351.             j = i; 
  1352.       if(j < 0)
  1353.          goto badarg;
  1354.       else
  1355.          juli3Dmode = j;
  1356.       return 1;
  1357.       }
  1358.  
  1359.    if (strcmp(variable,"julibrot3d") == 0) {       /* julibrot3d=?,?,?,? */
  1360.       if (floatparms != totparms)
  1361.      goto badarg;
  1362.       if(totparms > 0)
  1363.          zdots = floatval[0];
  1364.       if (totparms > 1)
  1365.          originfp = floatval[1];
  1366.       if (totparms > 2)
  1367.          depthfp = floatval[2];
  1368.       if (totparms > 3)
  1369.          heightfp = floatval[3];
  1370.       if (totparms > 4)
  1371.          widthfp = floatval[4];
  1372.       if (totparms > 5)
  1373.          distfp = floatval[5];
  1374.       return 1;
  1375.       }
  1376.  
  1377.    if (strcmp(variable,"julibroteyes") == 0) {       /* julibroteyes=?,?,?,? */
  1378.       if (floatparms != totparms || totparms != 1)
  1379.      goto badarg;
  1380.       eyesfp =  floatval[0];
  1381.       return 1;
  1382.       }
  1383.  
  1384.    if (strcmp(variable,"julibrotfromto") == 0) {       /* julibrotfromto=?,?,?,? */
  1385.       if (floatparms != totparms || totparms != 4)
  1386.      goto badarg;
  1387.       mxmaxfp = floatval[0];
  1388.       mxminfp = floatval[1];
  1389.       mymaxfp = floatval[2];
  1390.       myminfp = floatval[3];
  1391.       return 1;
  1392.       }
  1393.  
  1394.    if (strcmp(variable,"corners") == 0) {       /* corners=?,?,?,? */
  1395.       if (fractype == CELLULAR)
  1396.           return 1; /* skip setting the corners */
  1397.       if (floatparms != totparms || (totparms != 4 && totparms != 6))
  1398.      goto badarg;
  1399.       usemag = 0;
  1400.       initcorners = 1;
  1401.       xx3rd = xxmin = floatval[0];
  1402.       xxmax =          floatval[1];
  1403.       yy3rd = yymin = floatval[2];
  1404.       yymax =          floatval[3];
  1405.       if (totparms == 6) {
  1406.      xx3rd =      floatval[4];
  1407.      yy3rd =      floatval[5];
  1408.      }
  1409.       return 1;
  1410.       }
  1411.  
  1412.    if (strcmp(variable,"viewwindows") == 0) {  /* viewwindows=?,?,?,?,? */
  1413.       if (totparms > 5 || floatparms-intparms > 2 || intparms > 4)
  1414.      goto badarg;
  1415.       viewwindow = 1;
  1416.       viewreduction = 4.2;  /* reset default values */
  1417.       finalaspectratio = screenaspect;
  1418.       viewcrop = 1; /* yes */
  1419.       viewxdots = viewydots = 0;
  1420.  
  1421.       if((totparms > 0) && (floatval[0] > 0.001))
  1422.         viewreduction = floatval[0];
  1423.       if((totparms > 1) && (floatval[1] > 0.001))
  1424.         finalaspectratio = floatval[1];
  1425.       if((totparms > 2) && (yesnoval == 0))
  1426.         viewcrop = yesnoval;
  1427.       if((totparms > 3) && (intval[3] > 0))
  1428.         viewxdots = intval[3];
  1429.       if((totparms == 5) && (intval[4] > 0))
  1430.         viewydots = intval[4];
  1431.       return 1;
  1432.       }
  1433.  
  1434.    if (strcmp(variable,"center-mag") == 0) {    /* center-mag=?,?,? */
  1435.       double Xctr, Yctr,Magnification,Ratio,Height, Width,Radius;
  1436.       if (totparms != floatparms
  1437.     || (totparms != 0 && totparms != 3)
  1438.     || (totparms == 3 && floatval[2] <= 0.0))
  1439.      goto badarg;
  1440.       usemag = 1;
  1441.       if (totparms == 0) return 0;
  1442.       initcorners = 1;
  1443.       Xctr = floatval[0];
  1444.       Yctr = floatval[1];
  1445.       Magnification = floatval[2];
  1446.       Radius = 1.0 / Magnification;
  1447.       Ratio = .75;    /* inverse aspect ratio of screen  */
  1448.       /* calculate bounds */
  1449.       Height = 2.0 * Radius;
  1450.       Width = Height / Ratio;
  1451.       yymax = Yctr + Radius;
  1452.       yy3rd = yymin = Yctr - Radius;
  1453.       xxmax = Xctr + Width / 2.0;
  1454.       xx3rd = xxmin = Xctr - Width / 2.0;
  1455.       return 1;
  1456.       }
  1457.  
  1458.    if (strcmp(variable,"invert") == 0) {        /* invert=?,?,? */
  1459.       if (totparms != floatparms || (totparms != 1 && totparms != 3))
  1460.      goto badarg;
  1461.       invert = ((inversion[0] = floatval[0]) != 0.0) ? totparms : 0;
  1462.       if (totparms == 3) {
  1463.      inversion[1] = floatval[1];
  1464.      inversion[2] = floatval[2];
  1465.      }
  1466.       return 1;
  1467.       }
  1468.  
  1469.    if (strcmp(variable,"askvideo") == 0 ) {     /* askvideo=?   */
  1470.       if (yesnoval < 0) goto badarg;
  1471.       askvideo = yesnoval;
  1472.       return 0;
  1473.       }
  1474.  
  1475.    if (strcmp(variable,"ramvideo") == 0 )       /* ramvideo=?   */
  1476.       return 0; /* just ignore and return, for old time's sake */
  1477.  
  1478.    if (strcmp(variable,"float") == 0 ) {        /* float=? */
  1479.       if (yesnoval < 0) goto badarg;
  1480.       usr_floatflag = yesnoval;
  1481.       return 3;
  1482.       }
  1483.  
  1484.    if (strcmp(variable,"biomorph") == 0 ) {     /* biomorph=? */
  1485.       usr_biomorph = numval;
  1486.       return 1;
  1487.       }
  1488.  
  1489.    if (strcmp(variable,"orbitsave") == 0 ) {     /* orbitsave=? */
  1490.       if (yesnoval < 0) goto badarg;
  1491.       orbitsave = yesnoval;
  1492.       return 1;
  1493.       }
  1494.  
  1495.    if (strcmp(variable,"bailout") == 0 ) {      /* bailout=? */
  1496.       if (numval < 4 || numval > 32000) goto badarg;
  1497.       bailout = numval;
  1498.       return 1;
  1499.       }
  1500.  
  1501.    if (strcmp(variable,"symmetry") == 0 ) {     /* symmetry=? */
  1502.       if     (strcmp(value,"xaxis" )==0) forcesymmetry = XAXIS;
  1503.       else if(strcmp(value,"yaxis" )==0) forcesymmetry = YAXIS;
  1504.       else if(strcmp(value,"xyaxis")==0) forcesymmetry = XYAXIS;
  1505.       else if(strcmp(value,"origin")==0) forcesymmetry = ORIGIN;
  1506.       else if(strcmp(value,"pi"    )==0) forcesymmetry = PI_SYM;
  1507.       else if(strcmp(value,"none"  )==0) forcesymmetry = NOSYM;
  1508.       else goto badarg;
  1509.       return 1;
  1510.       }
  1511.  
  1512.    if (strcmp(variable,"printer") == 0 ) {      /* printer=? */
  1513.       if (parse_printer(value) < 0) goto badarg;
  1514.       return 0;
  1515.       }
  1516.  
  1517.    if (strcmp(variable,"printfile") == 0) {     /* print-to-file? SWT */
  1518.       if (valuelen > 79) goto badarg;
  1519.       Print_To_File = 1;
  1520.       strcpy(PrintName,value);
  1521.       return 0;
  1522.       }
  1523.    if(strcmp(variable, "rleps") == 0) {
  1524.       Printer_Compress = yesnoval;
  1525.       return(0);
  1526.       }
  1527.    if(strcmp(variable, "colorps") == 0) {
  1528.       ColorPS = yesnoval;
  1529.       return(0);
  1530.       }
  1531.  
  1532.    if (strcmp(variable,"epsf") == 0) {          /* EPS type? SWT */
  1533.       Print_To_File = 1;
  1534.       EPSFileType = numval;
  1535.       Printer_Type = 5;
  1536.       if (strcmp(PrintName,"fract001.prn")==0)
  1537.      strcpy(PrintName,"fract001.eps");
  1538.       return 0;
  1539.       }
  1540.  
  1541.    if (strcmp(variable,"title") == 0) {         /* Printer title block? SWT */
  1542.       if (yesnoval < 0) goto badarg;
  1543.       Printer_Titleblock = yesnoval;
  1544.       return 0;
  1545.       }
  1546.  
  1547.    if (strcmp(variable,"translate") == 0) {     /* Translate color? SWT */
  1548.       Printer_ColorXlat=0;
  1549.       if (charval == 'y')
  1550.      Printer_ColorXlat=1;
  1551.       else if (numval > 1 || numval < -1)
  1552.      Printer_ColorXlat=numval;
  1553.       return 0;
  1554.       }
  1555.  
  1556.    if (strcmp(variable,"plotstyle") == 0) {     /* plot style? SWT */
  1557.       Printer_SStyle = numval;
  1558.       return 0;
  1559.       }
  1560.  
  1561.    if (strcmp(variable,"halftone") == 0) {      /* New halftoning? SWT */
  1562.       if (totparms != intparms) goto badarg;
  1563.       Printer_SetScreen=1;
  1564.       if ((totparms >  0) && ( intval[ 0] >= 0))
  1565.                       Printer_SFrequency = intval[ 0];
  1566.       if ((totparms >  1) && ( intval[ 1] >= 0))
  1567.                       Printer_SAngle     = intval[ 1];
  1568.       if ((totparms >  2) && ( intval[ 2] >= 0))
  1569.                       Printer_SStyle     = intval[ 2];
  1570.       if ((totparms >  3) && ( intval[ 3] >= 0))
  1571.                       Printer_RFrequency = intval[ 3];
  1572.       if ((totparms >  4) && ( intval[ 4] >= 0))
  1573.                       Printer_RAngle     = intval[ 4];
  1574.       if ((totparms >  5) && ( intval[ 5] >= 0))
  1575.                       Printer_RStyle     = intval[ 5];
  1576.       if ((totparms >  6) && ( intval[ 6] >= 0))
  1577.                       Printer_GFrequency = intval[ 6];
  1578.       if ((totparms >  7) && ( intval[ 7] >= 0))
  1579.                       Printer_GAngle     = intval[ 7];
  1580.       if ((totparms >  8) && ( intval[ 8] >= 0))
  1581.                       Printer_GStyle     = intval[ 8];
  1582.       if ((totparms >  9) && ( intval[ 9] >= 0))
  1583.                       Printer_BFrequency = intval[ 9];
  1584.       if ((totparms > 10) && ( intval[10] >= 0))
  1585.                       Printer_BAngle     = intval[10];
  1586.       if ((totparms > 11) && ( intval[11] >= 0))
  1587.                       Printer_BStyle     = intval[11];
  1588.       return 0;
  1589.       }
  1590.  
  1591.    if (strcmp(variable,"linefeed") == 0) {      /* Use LF for printer */
  1592.       if      (strcmp(value,"cr")   == 0) Printer_CRLF = 1;
  1593.       else if (strcmp(value,"lf")   == 0) Printer_CRLF = 2;
  1594.       else if (strcmp(value,"crlf") == 0) Printer_CRLF = 0;
  1595.       else goto badarg;
  1596.       return 0;
  1597.       }
  1598.  
  1599.    if (strcmp(variable,"comport") == 0 ) {      /* Set the COM parameters */
  1600.       if ((value=strchr(value,'/')) == NULL) goto badarg;
  1601.       switch (atoi(++value)) {
  1602.      case 110:  l = 0;   break;
  1603.      case 150:  l = 32;  break;
  1604.      case 300:  l = 64;  break;
  1605.      case 600:  l = 96;  break;
  1606.      case 1200: l = 128; break;
  1607.      case 2400: l = 160; break;
  1608.      case 4800: l = 192; break;
  1609.      case 9600:
  1610.      default:   l = 224; break;
  1611.      }
  1612.       if ((value=strchr(value,'/')) == NULL) goto badarg;
  1613.       for (k=0; k < strlen(value); k++) {
  1614.      switch (value[k]) {
  1615.         case '7':  l |= 2;  break;
  1616.         case '8':  l |= 3;  break;
  1617.         case 'o':  l |= 8;  break;
  1618.         case 'e':  l |= 24; break;
  1619.         case '2':  l |= 4;  break;
  1620.         }
  1621.      }
  1622. #ifndef XFRACT
  1623. #ifndef WINFRACT
  1624.       _bios_serialcom(0,numval-1,l);
  1625. #endif
  1626. #endif
  1627.       return 0;
  1628.       }
  1629.  
  1630.    if (strcmp(variable,"sound") == 0 ) {        /* sound=? */
  1631.       soundflag = 0;
  1632.       if (strncmp(value,"ye",2) == 0) {
  1633.      soundflag = -1;
  1634.      return(0);
  1635.      }
  1636.       if (charval == 'x')
  1637.      soundflag = 1;
  1638.       if (charval == 'y')
  1639.      soundflag = 2;
  1640.       if (charval == 'z')
  1641.      soundflag = 3;
  1642.       return 0;
  1643.       }
  1644.  
  1645.    if (strcmp(variable,"hertz") == 0) {         /* Hertz=? */
  1646.       if (numval < 200 || numval > 10000) goto badarg;
  1647.       basehertz = numval;
  1648.       return 0;
  1649.       }
  1650.  
  1651.    if (strcmp(variable,"periodicity") == 0 ) {  /* periodicity=? */
  1652.       usr_periodicitycheck=1;
  1653.       if ((charval == 'n') || (numval == 0))
  1654.      usr_periodicitycheck=0;
  1655.       else if (charval == 'y')
  1656.      usr_periodicitycheck=1;
  1657.       else if (charval == 's')   /* 's' for 'show' */
  1658.      usr_periodicitycheck= -1;
  1659.       else if(numval == NONNUMERIC)
  1660.      goto badarg;
  1661.       else if(numval != 0)
  1662.      usr_periodicitycheck=numval;
  1663.       return 1;
  1664.       }
  1665.  
  1666.    if (strcmp(variable,"logmap") == 0 ) {       /* logmap=? */
  1667.       if (charval == 'y')
  1668.      LogFlag = 1;                /* palette is logarithmic */
  1669.       else if (charval == 'n')
  1670.      LogFlag = 0;
  1671.       else if (charval == 'o')
  1672.      LogFlag = -1;                /* old log palette */
  1673.       else
  1674.      LogFlag = numval;
  1675.       return 1;
  1676.       }
  1677.  
  1678.    if (strcmp(variable,"debugflag") == 0
  1679.      || strcmp(variable,"debug") == 0) {        /* internal use only */
  1680.       debugflag = numval;
  1681.       timerflag = debugflag & 1;        /* separate timer flag */
  1682.       debugflag -= timerflag;
  1683.       return 0;
  1684.       }
  1685.  
  1686.    if (strcmp(variable, "rseed") == 0) {
  1687.       rseed = numval;
  1688.       rflag = 1;
  1689.       return 1;
  1690.       }
  1691.  
  1692.    if (strcmp(variable, "orbitdelay") == 0) {
  1693.       orbit_delay = numval;
  1694.       return 0;
  1695.       }
  1696.  
  1697.    if (strcmp(variable, "showdot") == 0) {
  1698.       showdot=numval;
  1699.       if(showdot<0)
  1700.          showdot=0;
  1701.       return 0;
  1702.       }
  1703.  
  1704.    if (strcmp(variable, "decomp") == 0) {
  1705.       if (totparms != intparms || totparms < 1) goto badarg;
  1706.       decomp[0] = intval[0];
  1707.       decomp[1] = 0;
  1708.       if (totparms > 1) /* backward compatibility */
  1709.      bailout = decomp[1] = intval[1];
  1710.       return 1;
  1711.       }
  1712.  
  1713.    if (strcmp(variable, "distest") == 0) {
  1714.       if (totparms != intparms || totparms < 1) goto badarg;
  1715.       usr_distest = intval[0];
  1716.       distestwidth = 71;
  1717.       if (totparms > 1)
  1718.      distestwidth = intval[1];
  1719.       return 1;
  1720.       }
  1721.  
  1722.    if (strcmp(variable,"formulafile") == 0) {   /* formulafile=? */
  1723.       if (valuelen > 79) goto badarg;
  1724.       strcpy(FormFileName,value);
  1725.       return 1;
  1726.       }
  1727.  
  1728.    if (strcmp(variable,"formulaname") == 0) {   /* formulaname=? */
  1729.       if (valuelen > ITEMNAMELEN) goto badarg;
  1730.       strcpy(FormName,value);
  1731.       return 1;
  1732.       }
  1733.  
  1734.    if (strcmp(variable,"lfile") == 0) {
  1735.       if (valuelen > 79) goto badarg;
  1736.       strcpy(LFileName,value);
  1737.       return 1;
  1738.       }
  1739.  
  1740.    if (strcmp(variable,"lname") == 0) {
  1741.       if (valuelen > ITEMNAMELEN) goto badarg;
  1742.       strcpy(LName,value);
  1743.       return 1;
  1744.       }
  1745.  
  1746.    if (strcmp(variable,"ifsfile") == 0) {
  1747.       if (valuelen > 79) goto badarg;
  1748.       strcpy(IFSFileName,value);
  1749.       reset_ifs_defn();
  1750.       return 1;
  1751.       }
  1752.  
  1753.    if (strcmp(variable,"ifs") == 0
  1754.      || strcmp(variable,"ifs3d") == 0) {        /* ifs3d for old time's sake */
  1755.       if (valuelen > ITEMNAMELEN) goto badarg;
  1756.       strcpy(IFSName,value);
  1757.       reset_ifs_defn();
  1758.       return 1;
  1759.       }
  1760.  
  1761.    if (strcmp(variable,"parmfile") == 0) {
  1762.       if (valuelen > 79) goto badarg;
  1763.       strcpy(CommandFile,value);
  1764.       return 0;
  1765.       }
  1766.  
  1767.    if (strcmp(variable,"stereo") == 0) {        /* stereo=? */
  1768.       if ((numval<0) || (numval>3)) goto badarg;
  1769.       glassestype = numval;
  1770.       return 3;
  1771.       }
  1772.  
  1773.    if (strcmp(variable,"rotation") == 0) {      /* rotation=?/?/? */
  1774.       if (totparms != 3 || intparms != 3) goto badarg;
  1775.       XROT = intval[0];
  1776.       YROT = intval[1];
  1777.       ZROT = intval[2];
  1778.       return 3;
  1779.       }
  1780.  
  1781.    if (strcmp(variable,"perspective") == 0) {   /* perspective=? */
  1782.       if (numval == NONNUMERIC) goto badarg;
  1783.       ZVIEWER = numval;
  1784.       return 3;
  1785.       }
  1786.  
  1787.    if (strcmp(variable,"xyshift") == 0) {       /* xyshift=?/?  */
  1788.       if (totparms != 2 || intparms != 2) goto badarg;
  1789.       XSHIFT = intval[0];
  1790.       YSHIFT = intval[1];
  1791.       return 3;
  1792.       }
  1793.  
  1794.    if (strcmp(variable,"interocular") == 0) {   /* interocular=? */
  1795.       eyeseparation = numval;
  1796.       return 3;
  1797.       }
  1798.  
  1799.    if (strcmp(variable,"converge") == 0) {      /* converg=? */
  1800.       xadjust = numval;
  1801.       return 3;
  1802.       }
  1803.  
  1804.    if (strcmp(variable,"crop") == 0) {          /* crop=? */
  1805.       if (totparms != 4 || intparms != 4
  1806.     || intval[0] < 0 || intval[0] > 100
  1807.     || intval[1] < 0 || intval[1] > 100
  1808.     || intval[2] < 0 || intval[2] > 100
  1809.     || intval[3] < 0 || intval[3] > 100)
  1810.       goto badarg;
  1811.       red_crop_left   = intval[0];
  1812.       red_crop_right  = intval[1];
  1813.       blue_crop_left  = intval[2];
  1814.       blue_crop_right = intval[3];
  1815.       return 3;
  1816.       }
  1817.  
  1818.    if (strcmp(variable,"bright") == 0) {        /* bright=? */
  1819.       if (totparms != 2 || intparms != 2) goto badarg;
  1820.       red_bright  = intval[0];
  1821.       blue_bright = intval[1];
  1822.       return 3;
  1823.       }
  1824.  
  1825.    if (strcmp(variable,"xyadjust") == 0) {      /* trans=? */
  1826.       if (totparms != 2 || intparms != 2) goto badarg;
  1827.       xtrans = intval[0];
  1828.       ytrans = intval[1];
  1829.       return 3;
  1830.       }
  1831.  
  1832.    if (strcmp(variable,"3d") == 0) {            /* 3d=?/?/..    */
  1833.       if(strcmp(value,"overlay")==0) {
  1834.          yesnoval=1;
  1835.          if(calc_status > -1) /* if no image, treat same as 3D=yes */
  1836.             overlay3d=1;
  1837.       }      
  1838.       else if (yesnoval < 0) goto badarg;
  1839.       display3d = yesnoval;
  1840.       initvars_3d();
  1841.       return (display3d) ? 6 : 2;
  1842.       }
  1843.  
  1844.    if (strcmp(variable,"sphere") == 0 ) {       /* sphere=? */
  1845.       if (yesnoval < 0) goto badarg;
  1846.       SPHERE = yesnoval;
  1847.       return 2;
  1848.       }
  1849.  
  1850.    if (strcmp(variable,"scalexyz") == 0) {      /* scalexyz=?/?/? */
  1851.       if (totparms < 2 || intparms != totparms) goto badarg;
  1852.       XSCALE = intval[0];
  1853.       YSCALE = intval[1];
  1854.       if (totparms > 2) ROUGH = intval[2];
  1855.       return 2;
  1856.       }
  1857.  
  1858.    /* "rough" is really scale z, but we add it here for convenience */
  1859.    if (strcmp(variable,"roughness") == 0) {     /* roughness=?  */
  1860.       ROUGH = numval;
  1861.       return 2;
  1862.       }
  1863.  
  1864.    if (strcmp(variable,"waterline") == 0) {     /* waterline=?  */
  1865.       if (numval<0) goto badarg;
  1866.       WATERLINE = numval;
  1867.       return 2;
  1868.       }
  1869.  
  1870.    if (strcmp(variable,"filltype") == 0) {      /* filltype=?   */
  1871.       if (numval < -1 || numval > 6) goto badarg;
  1872.       FILLTYPE = numval;
  1873.       return 2;
  1874.       }
  1875.  
  1876.    if (strcmp(variable,"lightsource") == 0) {   /* lightsource=?/?/? */
  1877.       if (totparms != 3 || intparms != 3) goto badarg;
  1878.       XLIGHT = intval[0];
  1879.       YLIGHT = intval[1];
  1880.       ZLIGHT = intval[2];
  1881.       return 2;
  1882.       }
  1883.  
  1884.    if (strcmp(variable,"smoothing") == 0) {     /* smoothing=?  */
  1885.       if (numval<0) goto badarg;
  1886.       LIGHTAVG = numval;
  1887.       return 2;
  1888.       }
  1889.  
  1890.    if (strcmp(variable,"latitude") == 0) {      /* latitude=?/? */
  1891.       if (totparms != 2 || intparms != 2) goto badarg;
  1892.       THETA1 = intval[0];
  1893.       THETA2 = intval[1];
  1894.       return 2;
  1895.       }
  1896.  
  1897.    if (strcmp(variable,"longitude") == 0) {     /* longitude=?/? */
  1898.       if (totparms != 2 || intparms != 2) goto badarg;
  1899.       PHI1 = intval[0];
  1900.       PHI2 = intval[1];
  1901.       return 2;
  1902.       }
  1903.  
  1904.    if (strcmp(variable,"radius") == 0) {        /* radius=? */
  1905.       if (numval < 0) goto badarg;
  1906.       RADIUS = numval;
  1907.       return 2;
  1908.       }
  1909.  
  1910.    if (strcmp(variable,"transparent") == 0) {   /* transparent? */
  1911.       if (totparms != intparms || totparms < 1) goto badarg;
  1912.       transparent[1] = transparent[0] = intval[0];
  1913.       if (totparms > 1) transparent[1] = intval[1];
  1914.       return 2;
  1915.       }
  1916.  
  1917.    if (strcmp(variable,"preview") == 0) {       /* preview? */
  1918.       if (yesnoval < 0) goto badarg;
  1919.       preview = yesnoval;
  1920.       return 2;
  1921.       }
  1922.  
  1923.    if (strcmp(variable,"showbox") == 0) {       /* showbox? */
  1924.       if (yesnoval < 0) goto badarg;
  1925.       showbox = yesnoval;
  1926.       return 2;
  1927.       }
  1928.  
  1929.    if (strcmp(variable,"coarse") == 0) {        /* coarse=? */
  1930.       if (numval < 3 || numval > 2000) goto badarg;
  1931.       previewfactor = numval;
  1932.       return 2;
  1933.       }
  1934.  
  1935.    if (strcmp(variable,"randomize") == 0) {     /* RANDOMIZE=? */
  1936.       if (numval<0 || numval>7) goto badarg;
  1937.       RANDOMIZE = numval;
  1938.       return 2;
  1939.       }
  1940.  
  1941.    if (strcmp(variable,"ambient") == 0) {       /* ambient=? */
  1942.       if (numval<0||numval>100) goto badarg;
  1943.       Ambient = numval;
  1944.       return 2;
  1945.       }
  1946.  
  1947.    if (strcmp(variable,"haze") == 0) {          /* haze=? */
  1948.       if (numval<0||numval>100) goto badarg;
  1949.       haze = numval;
  1950.       return 2;
  1951.       }
  1952.  
  1953.    if (strcmp(variable,"fullcolor") == 0) {     /* fullcolor=? */
  1954.       if (yesnoval < 0) goto badarg;
  1955.       Targa_Out = yesnoval;
  1956.       return 2;
  1957.       }
  1958.    if (strcmp(variable,"targa_out") == 0) {     /* Targa Out? */
  1959.       if (yesnoval < 0) goto badarg;
  1960.       Targa_Out = yesnoval;
  1961.       return 2;
  1962.       }
  1963.  
  1964.    if (strcmp(variable,"targa_overlay") == 0) {         /* Targa Overlay? */
  1965.       if (yesnoval < 0) goto badarg;
  1966.       Targa_Overlay = yesnoval;
  1967.       return 2;
  1968.       }
  1969.  
  1970.    if (strcmp(variable,"background") == 0) {     /* background=?/? */
  1971.       if (totparms != 3 || intparms != 3) goto badarg;
  1972.                 for (i=0;i<3;i++)
  1973.                         if (intval[i] & 0xff)
  1974.                                 goto badarg;
  1975.       back_color[0] = intval[0];
  1976.       back_color[1] = intval[1];
  1977.       back_color[2] = intval[2];
  1978.       return 2;
  1979.       }
  1980.  
  1981.    if (strcmp(variable,"lightname") == 0) {     /* lightname=?   */
  1982.       if (valuelen > 79) goto badarg;
  1983.       if (first_init || mode == 2)
  1984.      strcpy(light_name,value);
  1985.       return 0;
  1986.       }
  1987.  
  1988.    if (strcmp(variable,"ray") == 0) {           /* RAY=? */
  1989.       if (numval < 0 || numval > 6) goto badarg;
  1990.       RAY = numval;
  1991.       return 2;
  1992.       }
  1993.  
  1994.    if (strcmp(variable,"brief") == 0) {         /* BRIEF? */
  1995.       if (yesnoval < 0) goto badarg;
  1996.       BRIEF = yesnoval;
  1997.       return 2;
  1998.       }
  1999.  
  2000.    if (strcmp(variable,"release") == 0) {       /* release */
  2001.       if (numval < 0) goto badarg;
  2002.  
  2003.       save_release = numval;
  2004.       return 2;
  2005.       }
  2006.  
  2007.  
  2008. badarg:
  2009.    argerror(curarg);
  2010.    return(-1);
  2011.  
  2012. }
  2013.  
  2014. /* Some routines broken out of above so compiler doesn't run out of heap: */
  2015.  
  2016. static void parse_textcolors(char *value)
  2017. {
  2018.    int i,j,k,hexval;
  2019.    if (strcmp(value,"mono") == 0) {
  2020.       for (k = 0; k < sizeof(txtcolor); ++k)
  2021.      txtcolor[k] = BLACK*16+WHITE;
  2022.    /* C_HELP_CURLINK = C_PROMPT_INPUT = C_CHOICE_CURRENT = C_GENERAL_INPUT
  2023.              = C_AUTHDIV1 = C_AUTHDIV2 = WHITE*16+BLACK; */
  2024.       txtcolor[6] = txtcolor[12] = txtcolor[13] = txtcolor[14] = txtcolor[20]
  2025.           = txtcolor[27] = txtcolor[28] = WHITE*16+BLACK;
  2026.       /* C_TITLE = C_HELP_HDG = C_HELP_LINK = C_PROMPT_HI = C_CHOICE_SP_KEYIN
  2027.          = C_GENERAL_HI = C_DVID_HI = C_STOP_ERR
  2028.          = C_STOP_INFO = BLACK*16+L_WHITE; */
  2029.       txtcolor[0] = txtcolor[2] = txtcolor[5] = txtcolor[11] = txtcolor[16]
  2030.           = txtcolor[17] = txtcolor[22] = txtcolor[24]
  2031.           = txtcolor[25] = BLACK*16+L_WHITE;
  2032.       }
  2033.    else {
  2034.       k = 0;
  2035.       while ( k < sizeof(txtcolor)) {
  2036.      if (*value == 0) break;
  2037.      if (*value != '/') {
  2038.         sscanf(value,"%x",&hexval);
  2039.         i = (hexval / 16) & 7;
  2040.         j = hexval & 15;
  2041.         if (i == j || (i == 0 && j == 8)) /* force contrast */
  2042.            j = 15;
  2043.         txtcolor[k] = i * 16 + j;
  2044.         if ((value = strchr(value,'/')) == NULL) break;
  2045.         }
  2046.      ++value;
  2047.      ++k;
  2048.      }
  2049.       }
  2050. }
  2051.  
  2052. static int parse_colors(char *value)
  2053. {
  2054.    int i,j,k;
  2055.    if (*value == '@') {
  2056.       if (strlen(value) > 80 || ValidateLuts(&value[1]) != 0) goto badcolor;
  2057.       if (display3d) {
  2058.         mapset = 1;
  2059.         strcpy(MAP_name,&value[1]);
  2060.         }
  2061.       else {
  2062.         strcpy(colorfile,&value[1]);
  2063.         colorstate = 2;
  2064.         }
  2065.       }
  2066.    else {
  2067.       int smooth;
  2068.       i = smooth = 0;
  2069.       while (*value) {
  2070.      if (i >= 256) goto badcolor;
  2071.      if (*value == '<') {
  2072.         if (i == 0 || smooth
  2073.           || (smooth = atoi(value+1)) < 2
  2074.           || (value = strchr(value,'>')) == NULL)
  2075.            goto badcolor;
  2076.         i += smooth;
  2077.         ++value;
  2078.         }
  2079.      else {
  2080.         for (j = 0; j < 3; ++j) {
  2081.            if ((k = *(value++)) < '0')  goto badcolor;
  2082.            else if (k <= '9')       k -= '0';
  2083.            else if (k < 'A')            goto badcolor;
  2084.            else if (k <= 'Z')       k -= ('A'-10);
  2085.            else if (k < '_' || k > 'z') goto badcolor;
  2086.            else            k -= ('_'-36);
  2087.            dacbox[i][j] = k;
  2088.            if (smooth) {
  2089.           int start,spread,cnum;
  2090.           start = i - (spread = smooth + 1);
  2091.           cnum = 0;
  2092.           if ((k - (int)dacbox[start][j]) == 0) {
  2093.              while (++cnum < spread)
  2094.             dacbox[start+cnum][j] = k;
  2095.              }
  2096.           else {
  2097.              while (++cnum < spread)
  2098.             dacbox[start+cnum][j] =
  2099.                ( cnum         *dacbox[i][j]
  2100.                + (i-(start+cnum))*dacbox[start][j]
  2101.                + spread/2 )
  2102.                / spread;
  2103.              }
  2104.           }
  2105.            }
  2106.         smooth = 0;
  2107.         ++i;
  2108.         }
  2109.      }
  2110.       if (smooth) goto badcolor;
  2111.       while (i < 256)  { /* zap unset entries */
  2112.      dacbox[i][0] = dacbox[i][1] = dacbox[i][2] = 40;
  2113.      ++i;
  2114.      }
  2115.       colorstate = 1;
  2116.       }
  2117.    colorpreloaded = 1;
  2118.    return(0);
  2119. badcolor:
  2120.    return(-1);
  2121. }
  2122.  
  2123. static int parse_printer(char *value)
  2124. {
  2125.    int k;
  2126.    if (value[0]=='h' && value[1]=='p')
  2127.       Printer_Type=1;                 /* HP LaserJet           */
  2128.    if (value[0]=='i' && value[1]=='b')
  2129.       Printer_Type=2;                 /* IBM Graphics           */
  2130.    if (value[0]=='e' && value[1]=='p')
  2131.       Printer_Type=2;                 /* Epson (model?)           */
  2132.    if (value[0]=='c' && value[1]=='o')
  2133.       Printer_Type=3;                 /* Star (Epson-Comp?) color */
  2134.    if (value[0]=='p') {
  2135.       if (value[1]=='a')
  2136.      Printer_Type=4;             /* HP Paintjet (color)    */
  2137.       if ((value[1]=='o' || value[1]=='s')) {
  2138.      Printer_Type=5;             /* PostScript  SWT */
  2139.      if (value[2]=='h' || value[2]=='l')
  2140.         Printer_Type=6;
  2141.      }
  2142.       if (value[1]=='l')
  2143.      Printer_Type=7;             /* HP Plotter (semi-color) */
  2144.       }
  2145.    if (Printer_Type == 1)             /* assume low resolution */
  2146.       Printer_Resolution = 75;
  2147.    else
  2148.       Printer_Resolution = 60;
  2149.    if (EPSFileType > 0)              /* EPS save - force type 5 */
  2150.       Printer_Type = 5;
  2151.    if ((Printer_Type == 5) || (Printer_Type == 6))
  2152.       Printer_Resolution = 150;          /* PostScript def. res. */
  2153.    if ((value=strchr(value,'/'))) {
  2154.       if ((k=atoi(++value)) >= 0) Printer_Resolution=k;
  2155.       if ((value=strchr(value,'/'))) {
  2156.      if ((k=atoi(++value))> 0) LPTNumber = k;
  2157.      if (k < 0) {
  2158.         Print_To_File = 1;
  2159.         LPTNumber = 1;
  2160.         }
  2161.      }
  2162.       }
  2163.    return(0);
  2164. }
  2165.  
  2166.  
  2167.  
  2168. static void argerror(char *badarg)    /* oops. couldn't decode this */
  2169. {
  2170.    static char far argerrmsg1[]={"\
  2171. Oops. I couldn't understand the argument:\n  "};
  2172.    static char far argerrmsg2[]={"\n\n\
  2173. (see the Startup Help screens or documentation for a complete\n\
  2174.  argument list with descriptions)"};
  2175.    char msg[300];
  2176.    if (strlen(badarg) > 70) badarg[70] = 0;
  2177.    if (active_system == 0 /* DOS */
  2178.      && first_init)      /* & this is 1st call to cmdfiles */
  2179. #ifndef XFRACT
  2180.       sprintf(msg,"%Fs%s%Fs",argerrmsg1,badarg,argerrmsg2);
  2181.    else
  2182.       sprintf(msg,"%Fs%s",argerrmsg1,badarg);
  2183. #else
  2184.       sprintf(msg,"%s%s%s",argerrmsg1,badarg,argerrmsg2);
  2185.    else
  2186.       sprintf(msg,"%s%s",argerrmsg1,badarg);
  2187. #endif
  2188.    stopmsg(0,msg);
  2189. }
  2190.  
  2191. void set_3d_defaults()
  2192. {
  2193.    ENTER_OVLY(OVLY_CMDFILES);
  2194.    ROUGH     = 30;
  2195.    WATERLINE = 0;
  2196.    ZVIEWER   = 0;
  2197.    XSHIFT    = 0;
  2198.    YSHIFT    = 0;
  2199.    xtrans    = 0;
  2200.    ytrans    = 0;
  2201.    LIGHTAVG  = 0;
  2202.    Ambient   = 20;
  2203.    RANDOMIZE = 0;
  2204.    haze      = 0;
  2205.    back_color[0] = 51; back_color[1] = 153; back_color[2] = 200;
  2206.    if(SPHERE) {
  2207.       PHI1    =  180;
  2208.       PHI2    =  0;
  2209.       THETA1    =  -90;
  2210.       THETA2    =  90;
  2211.       RADIUS    =  100;
  2212.       FILLTYPE    = 2;
  2213.       XLIGHT    = 1;
  2214.       YLIGHT    = 1;
  2215.       ZLIGHT    = 1;
  2216.       }
  2217.    else {
  2218.       XROT    = 60;
  2219.       YROT    = 30;
  2220.       ZROT    = 0;
  2221.       XSCALE    = 90;
  2222.       YSCALE    = 90;
  2223.       FILLTYPE    = 0;
  2224.       if (active_system != 0)
  2225.      FILLTYPE = 2;
  2226.       XLIGHT    = 1;
  2227.       YLIGHT    = -1;
  2228.       ZLIGHT    = 1;
  2229.       }
  2230.     EXIT_OVLY;
  2231. }
  2232.