home *** CD-ROM | disk | FTP | other *** search
/ Super PC 26 / Super PC 26 (Shareware).iso / spc / util / fractint / source / cmdfiles.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-03-21  |  87.9 KB  |  2,782 lines

  1. /*
  2.     Command-line / Command-File Parser Routines
  3. */
  4.  
  5. #include <stdlib.h>
  6. #include <stdio.h>
  7. #include <string.h>
  8. #include <float.h>
  9. #include <ctype.h>
  10. #include <time.h>
  11. #include <math.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. static int  get_bf(bf_t, char *);
  46.  
  47. /* variables defined by the command line/files processor */
  48. int    pseudox=0;        /* xdots to use for video independence */
  49. int    pseudoy=0;        /* ydots to use for video independence */
  50. int     bfdigits=0;            /* digits to use (force) for bf_math */
  51. int    showdot;        /* color to show crawling graphics cursor */
  52. char    temp1[256];        /* temporary strings        */
  53. char    readname[FILE_MAX_PATH];/* name of fractal input file */
  54. char    tempdir[FILE_MAX_DIR] = {""}; /* name of temporary directory */
  55. char    workdir[FILE_MAX_DIR] = {""}; /* name of directory for misc files */
  56. char    gifmask[13] = {""};
  57. char    PrintName[FILE_MAX_PATH]={"fract001.prn"}; /* Name for print-to-file */
  58. char    savename[FILE_MAX_PATH]={"fract001"};  /* save files using this name */
  59. char    autoname[FILE_MAX_PATH]={"auto.key"}; /* record auto keystrokes here */
  60. int    potflag=0;        /* continuous potential enabled? */
  61. int    pot16bit;        /* store 16 bit continuous potential values */
  62. int    gif87a_flag;        /* 1 if GIF87a format, 0 otherwise */
  63. int     dither_flag;        /* 1 if want to dither GIFs */
  64. int    askvideo;        /* flag for video prompting */
  65. char    floatflag;
  66. int    biomorph;        /* flag for biomorph */
  67. int    usr_biomorph;
  68. int    forcesymmetry;        /* force symmetry */
  69. int    showfile;        /* zero if file display pending */
  70. int    rflag, rseed;        /* Random number seeding flag and value */
  71. int    decomp[2];        /* Decomposition coloring */
  72. int    distest;
  73. int    distestwidth;
  74. char     overwrite = 0;    /* 0 if file overwrite not allowed */
  75. int    soundflag;        /* 0 if sound is off, 1 if on */
  76. int    basehertz;        /* sound=x/y/x hertz value */
  77. int    debugflag;        /* internal use only - you didn't see this */
  78. int    timerflag;        /* you didn't see this, either */
  79. int    cyclelimit;        /* color-rotator upper limit */
  80. int    inside;         /* inside color: 1=blue     */
  81. int    fillcolor;         /* fillcolor: -1=normal     */
  82. int    outside;        /* outside color    */
  83. int    finattract;        /* finite attractor logic */
  84. int    display3d;        /* 3D display flag: 0 = OFF */
  85. int    overlay3d;        /* 3D overlay flag: 0 = OFF */
  86. int    init3d[20];        /* '3d=nn/nn/nn/...' values */
  87. int    checkcurdir;        /* flag to check current dir for files */
  88. int    initbatch;        /* 1 if batch run (no kbd)  */
  89. int    initsavetime;        /* autosave minutes        */
  90. _CMPLX  initorbit;        /* initial orbitvalue */
  91. char    useinitorbit;        /* flag for initorbit */
  92. int    initmode;        /* initial video mode        */
  93. int    initcyclelimit;     /* initial cycle limit        */
  94. BYTE    usemag;                 /* use center-mag corners   */
  95. long    bailout;                /* user input bailout value */
  96. enum bailouts bailoutest;    /* test used for determining bailout */
  97. double    inversion[3];        /* radius, xcenter, ycenter */
  98. int    rotate_lo,rotate_hi;    /* cycling color range        */
  99. int far *ranges;        /* iter->color ranges mapping */
  100. int    rangeslen = 0;        /* size of ranges array     */
  101. BYTE far *mapdacbox = NULL;    /* map= (default colors)    */
  102. int    colorstate;        /* 0, dacbox matches default (bios or map=) */
  103.                 /* 1, dacbox matches no known defined map   */
  104.                 /* 2, dacbox matches the colorfile map        */
  105. int    colorpreloaded;     /* if dacbox preloaded for next mode select */
  106. int     save_release;        /* release creating PAR file*/
  107. char    dontreadcolor=0;    /* flag for reading color from GIF */
  108.  
  109. int Targa_Out = 0;
  110. char    colorfile[FILE_MAX_PATH];/* from last <l> <s> or colors=@filename */
  111. int functionpreloaded; /* if function loaded for new bifs, JCO 7/5/92 */
  112. float   screenaspect = DEFAULTASPECT;   /* aspect ratio of the screen */
  113. float   aspectdrift = DEFAULTASPECTDRIFT;  /* how much drift is allowed and */
  114.                                            /* still forced to screenaspect  */
  115.  
  116. /* TARGA+ variables */
  117. int    TPlusFlag;        /* Use the TARGA+ if found  */
  118. int    MaxColorRes;        /* Default Color Resolution if available */
  119. int    PixelZoom;        /* TPlus Zoom Level */
  120. int    NonInterlaced;        /* Non-Interlaced video flag */
  121.  
  122. int    orbitsave = 0;        /* for IFS and LORENZ to output acrospin file */
  123. int orbit_delay;                /* clock ticks delating orbit release */
  124. int    transparent[2];     /* transparency min/max values */
  125. int    LogFlag;        /* Logarithmic palette flag: 0 = no */
  126.  
  127. BYTE exitmode = 3;    /* video mode on exit */
  128.  
  129. char    ai_8514;    /* Flag for using 8514a afi JCO 4/11/92 */
  130.  
  131. int        bios_palette;        /* set to 1 to force BIOS palette updates */
  132. int        escape_exit;         /* set to 1 to avoid the "are you sure?" screen */
  133. int first_init=1;        /* first time into cmdfiles? */
  134. static int init_rseed;
  135. static char initcorners,initparams;
  136. struct fractalspecificstuff far *curfractalspecific;
  137.  
  138. char FormFileName[FILE_MAX_PATH];/* file to find (type=)formulas in */
  139. char FormName[ITEMNAMELEN+1];    /* Name of the Formula (if not null) */
  140. char LFileName[FILE_MAX_PATH];   /* file to find (type=)L-System's in */
  141. char LName[ITEMNAMELEN+1];     /* Name of L-System */
  142. char CommandFile[FILE_MAX_PATH]; /* file to find command sets in */
  143. char CommandName[ITEMNAMELEN+1]; /* Name of Command set */
  144. char CommandComment1[57];     /* comments for command set */
  145. char CommandComment2[57];
  146. char CommandComment3[57];
  147. char CommandComment4[57];
  148. char IFSFileName[FILE_MAX_PATH];/* file to find (type=)IFS in */
  149. char IFSName[ITEMNAMELEN+1];    /* Name of the IFS def'n (if not null) */
  150. float far *ifs_defn = NULL;    /* ifs parameters */
  151. int  ifs_type;            /* 0=2d, 1=3d */
  152. int  slides = 0;        /* 1 autokey=play, 2 autokey=record */
  153.  
  154. BYTE txtcolor[]={
  155.       BLUE*16+L_WHITE,      /* C_TITLE           title background */
  156.       BLUE*16+L_GREEN,      /* C_TITLE_DEV       development vsn foreground */
  157.       GREEN*16+YELLOW,      /* C_HELP_HDG        help page title line */
  158.       WHITE*16+BLACK,      /* C_HELP_BODY       help page body */
  159.       GREEN*16+GRAY,      /* C_HELP_INSTR      help page instr at bottom */
  160.       WHITE*16+BLUE,      /* C_HELP_LINK       help page links */
  161.       CYAN*16+BLUE,      /* C_HELP_CURLINK    help page current link */
  162.       WHITE*16+GRAY,      /* C_PROMPT_BKGRD    prompt/choice background */
  163.       WHITE*16+BLACK,      /* C_PROMPT_TEXT     prompt/choice extra info */
  164.       BLUE*16+WHITE,      /* C_PROMPT_LO       prompt/choice text */
  165.       BLUE*16+L_WHITE,      /* C_PROMPT_MED      prompt/choice hdg2/... */
  166.       BLUE*16+YELLOW,      /* C_PROMPT_HI       prompt/choice hdg/cur/... */
  167.       GREEN*16+L_WHITE,   /* C_PROMPT_INPUT    fullscreen_prompt input */
  168.       CYAN*16+L_WHITE,      /* C_PROMPT_CHOOSE   fullscreen_prompt choice */
  169.       MAGENTA*16+L_WHITE, /* C_CHOICE_CURRENT  fullscreen_choice input */
  170.       BLACK*16+WHITE,      /* C_CHOICE_SP_INSTR speed key bar & instr */
  171.       BLACK*16+L_MAGENTA, /* C_CHOICE_SP_KEYIN speed key value */
  172.       WHITE*16+BLUE,      /* C_GENERAL_HI      tab, thinking, IFS */
  173.       WHITE*16+BLACK,      /* C_GENERAL_MED */
  174.       WHITE*16+GRAY,      /* C_GENERAL_LO */
  175.       BLACK*16+L_WHITE,   /* C_GENERAL_INPUT */
  176.       WHITE*16+BLACK,      /* C_DVID_BKGRD      disk video */
  177.       BLACK*16+YELLOW,      /* C_DVID_HI */
  178.       BLACK*16+L_WHITE,   /* C_DVID_LO */
  179.       RED*16+L_WHITE,      /* C_STOP_ERR        stop message, error */
  180.       GREEN*16+BLACK,      /* C_STOP_INFO       stop message, info */
  181.       BLUE*16+WHITE,      /* C_TITLE_LOW       bottom lines of title screen */
  182.       GREEN*16+BLACK,      /* C_AUTHDIV1        title screen dividers */
  183.       GREEN*16+GRAY,      /* C_AUTHDIV2        title screen dividers */
  184.       BLACK*16+L_WHITE,   /* C_PRIMARY           primary authors */
  185.       BLACK*16+WHITE      /* C_CONTRIB           contributing authors */
  186.       };
  187.  
  188. /* start of string literals cleanup */
  189. char s_atan[]    = "atan";
  190. char s_iter[]    = "iter";
  191. char s_real[]    = "real";
  192. char s_mult[]     = "mult";
  193. char s_sum[]     = "summ";
  194. char s_imag[]    = "imag";
  195. char s_zmag[]    = "zmag";
  196. char s_bof60[]   = "bof60";
  197. char s_bof61[]   = "bof61";
  198. char s_maxiter[] =  "maxiter";
  199. char s_epscross[] =  "epsiloncross";
  200. char s_startrail[] =  "startrail";
  201. char s_normal[] =  "normal";
  202. char s_period[] = "period";
  203. char s_or[]     = "or";
  204. char s_and[]    = "and";
  205. char s_mod[]    = "mod";
  206. char s_16bit[] =            "16bit";
  207. char s_387[] =              "387";
  208. char s_3d[] =               "3d";
  209. char s_3dmode[] =           "3dmode";
  210. char s_adapter[] =          "adapter";
  211. char s_afi[] =              "afi";
  212. char s_ambient[] =          "ambient";
  213. char s_askvideo[] =         "askvideo";
  214. char s_aspectdrift[] =      "aspectdrift";
  215. char s_autokey[] =          "autokey";
  216. char s_autokeyname[] =      "autokeyname";
  217. char s_background[] =       "background";
  218. char s_bailout[] =          "bailout";
  219. char s_bailoutest[] =       "bailoutest";
  220. char s_batch[] =            "batch";
  221. char s_biomorph[] =         "biomorph";
  222. char s_biospalette[] =      "biospalette";
  223. char s_brief[] =            "brief";
  224. char s_bright[] =           "bright";
  225. char s_centermag[] =        "center-mag";
  226. char s_cga[] =              "cga";
  227. char s_coarse[] =           "coarse";
  228. char s_colorps[] =          "colorps";
  229. char s_colors[] =           "colors";
  230. char s_comport[] =          "comport";
  231. char s_converge[] =         "converge";
  232. char s_corners[] =          "corners";
  233. char s_cr[] =               "cr";
  234. char s_crlf[] =             "crlf";
  235. char s_crop[] =             "crop";
  236. char s_cyclelimit[] =       "cyclelimit";
  237. char s_cyclerange[] =       "cyclerange";
  238. char s_curdir[] =           "curdir";
  239. char s_debug[] =            "debug";
  240. char s_debugflag[] =        "debugflag";
  241. char s_decomp[] =           "decomp";
  242. char s_distest[] =          "distest";
  243. char s_dither[] =           "dither";
  244. char s_ega[] =              "ega";
  245. char s_egamono[] =          "egamono";
  246. char s_epsf[] =             "epsf";
  247. char s_exitmode[] =         "exitmode";
  248. char s_exitnoask[] =        "exitnoask";
  249. char s_filename[] =         "filename";
  250. char s_fillcolor[] =        "fillcolor";
  251. char s_filltype[] =         "filltype";
  252. char s_finattract[] =       "finattract";
  253. char s_float[] =            "float";
  254. char s_formulafile[] =      "formulafile";
  255. char s_formulaname[] =      "formulaname";
  256. char s_fpu[] =              "fpu";
  257. char s_fract001prn[] =     "fract001.prn";
  258. char s_fullcolor[] =        "fullcolor";
  259. char s_function[] =         "function";
  260. char s_gif87a[] =           "gif87a";
  261. char s_halftone[] =         "halftone";
  262. char s_haze[] =             "haze";
  263. char s_hertz[] =            "hertz";
  264. char s_hgc[] =              "hgc";
  265. char s_ifs[] =              "ifs";
  266. char s_ifs3d[] =            "ifs3d";
  267. char s_ifsfile[] =          "ifsfile";
  268. char s_iit[] =              "iit";
  269. char s_initorbit[] =        "initorbit";
  270. char s_inside[] =           "inside";
  271. char s_interocular[] =      "interocular";
  272. char s_invert[] =           "invert";
  273. char s_iterincr[] =         "iterincr";
  274. char s_julibrot3d[] =       "julibrot3d";
  275. char s_julibroteyes[] =     "julibroteyes";
  276. char s_julibrotfromto[] =   "julibrotfromto";
  277. char s_latitude[] =         "latitude";
  278. char s_lf[] =               "lf";
  279. char s_lfile[] =            "lfile";
  280. char s_lightname[] =        "lightname";
  281. char s_lightsource[] =      "lightsource";
  282. char s_linefeed[] =         "linefeed";
  283. char s_lname[] =            "lname";
  284. char s_logmap[] =           "logmap";
  285. char s_longitude[] =        "longitude";
  286. char s_makedoc[] =          "makedoc";
  287. char s_makemig[] =          "makemig";
  288. char s_map[] =              "map";
  289. char s_maxcolorres[] =      "maxcolorres";
  290. char s_mcga[] =             "mcga";
  291. char s_miim[] =             "miim";
  292. char s_mono[] =             "mono";
  293. char s_noiit[] =            "noiit";
  294. char s_none[] =             "none";
  295. char s_noninterlaced[] =    "noninterlaced";
  296. char s_olddemmcolors[] =    "olddemmcolors";
  297. char s_orbitdelay[] =       "orbitdelay";
  298. char s_orbitname[] =        "orbitname";
  299. char s_orbitsave[] =        "orbitsave";
  300. char s_origin[] =           "origin";
  301. char s_outside[] =          "outside";
  302. char s_overlay[] =          "overlay";
  303. char s_overwrite[] =        "overwrite";
  304. char s_params[] =           "params";
  305. char s_parmfile[] =         "parmfile";
  306. char s_passes[] =           "passes";
  307. char s_periodicity[] =      "periodicity";
  308. char s_perspective[] =      "perspective";
  309. char s_pi[] =               "pi";
  310. char s_pixel[] =            "pixel";
  311. char s_pixelzoom[] =        "pixelzoom";
  312. char s_play[] =             "play";
  313. char s_plotstyle[] =        "plotstyle";
  314. char s_potential[] =        "potential";
  315. char s_preview[] =          "preview";
  316. char s_printer[] =          "printer";
  317. char s_printfile[] =        "printfile";
  318. char s_radius[] =           "radius";
  319. char s_ramvideo[] =         "ramvideo";
  320. char s_randomize[] =        "randomize";
  321. char s_ranges[] =           "ranges";
  322. char s_ray[] =              "ray";
  323. char s_record[] =           "record";
  324. char s_release[] =          "release";
  325. char s_reset[] =            "reset";
  326. char s_rleps[] =            "rleps";
  327. char s_rotation[] =         "rotation";
  328. char s_roughness[] =        "roughness";
  329. char s_rseed[] =            "rseed";
  330. char s_savename[] =         "savename";
  331. char s_savetime[] =         "savetime";
  332. char s_scalexyz[] =         "scalexyz";
  333. char s_showbox[] =          "showbox";
  334. char s_showdot[] =          "showdot";
  335. char s_smoothing[] =        "smoothing";
  336. char s_sound[] =            "sound";
  337. char s_sphere[] =           "sphere";
  338. char s_stereo[] =           "stereo";
  339. char s_symmetry[] =         "symmetry";
  340. char s_targa_out[] =        "targa_out";
  341. char s_tempdir[] =          "tempdir";
  342. char s_workdir[] =          "workdir";
  343. char s_usegrayscale[] =     "usegrayscale";
  344. char s_monitorwidth[] =     "monitorwidth";
  345. char s_targa_overlay[] =    "targa_overlay";
  346. char s_textcolors[] =       "textcolors";
  347. char s_textsafe[] =         "textsafe";
  348. char s_title[] =            "title";
  349. char s_tplus[] =            "tplus";
  350. char s_translate[] =        "translate";
  351. char s_transparent[] =      "transparent";
  352. char s_type[] =             "type";
  353. char s_vesadetect[] =       "vesadetect";
  354. char s_vga[] =              "vga";
  355. char s_video[] =            "video";
  356. char s_viewwindows[] =      "viewwindows";
  357. char s_warn[] =             "warn";
  358. char s_waterline[] =        "waterline";
  359. char s_xaxis[] =            "xaxis";
  360. char s_xyadjust[] =         "xyadjust";
  361. char s_xyaxis[] =           "xyaxis";
  362. char s_xyshift[] =          "xyshift";
  363. char s_yaxis [] =              "yaxis"; 
  364. char s_sin [] =             "sin";
  365. char s_sinh [] =            "sinh";
  366. char s_cos [] =             "cos"; 
  367. char s_cosh [] =            "cosh";
  368. char s_sqr [] =             "sqr"; 
  369. char s_log [] =             "log"; 
  370. char s_exp [] =             "exp"; 
  371. char s_abs [] =             "abs"; 
  372. char s_conj [] =            "conj";
  373. char s_fn1 [] =             "fn1"; 
  374. char s_fn2 [] =             "fn2"; 
  375. char s_fn3 [] =             "fn3"; 
  376. char s_fn4 [] =             "fn4"; 
  377. char s_flip [] =            "flip";
  378. char s_tan [] =             "tan"; 
  379. char s_tanh [] =            "tanh";
  380. char s_cotan [] =           "cotan";
  381. char s_cotanh [] =          "cotanh";
  382. char s_cosxx [] =           "cosxx";
  383. char s_srand [] =           "srand";
  384. char s_recip [] =           "recip";
  385. char s_ident [] =           "ident";
  386. char s_zero [] =            "zero";
  387. char s_asin [] =            "asin";
  388. char s_asinh [] =            "asinh";
  389. char s_acos [] =            "acos";
  390. char s_acosh [] =           "acosh";
  391. char s_atanh [] =           "atanh";
  392. char s_cabs [] =            "cabs";
  393. char s_sqrt [] =            "sqrt";
  394. char s_bfdigits [] =        "bfdigits";
  395.  
  396. static char s_sstoolsini [] =  "sstools.ini";
  397. static char s_fractintfrm [] = "fractint.frm";
  398. static char s_fractintl [] =   "fractint.l";
  399. static char s_fractintpar [] = "fractint.par";
  400. static char s_fractintifs [] = "fractint.ifs";
  401. static char s_commandline [] = "command line";
  402. static char s_at_cmd [] =      "PAR file";
  403.  
  404. char far s_escapetoabort[] = "Press Escape to abort, any other key to continue";
  405. char far s_pressanykeytocontinue[] = "press any key to continue";
  406.     
  407. /*
  408.     cmdfiles(argc,argv) process the command-line arguments
  409.         it also processes the 'sstools.ini' file and any
  410.         indirect files ('fractint @myfile')
  411. */
  412.  
  413. /* This probably ought to go somewhere else, but it's used here.        */
  414. /* getpower10(x) returns the magnitude of x.  This rounds               */
  415. /* a little so 9.95 rounds to 10, but we're using a binary base anyway, */
  416. /* so there's nothing magic about changing to the next power of 10.     */
  417. int getpower10(LDBL x)
  418. {
  419.     char string[11]; /* space for "+x.xe-xxxx" */
  420.     int p;
  421.  
  422. #ifdef USE_LONG_DOUBLE
  423.     sprintf(string,"%+.1Le", x);
  424. #else
  425.     sprintf(string,"%+.1le", x);
  426. #endif
  427.     p = atoi(string+5);
  428.     return p;
  429. }
  430.  
  431.  
  432.  
  433. int cmdfiles(int argc,char **argv)
  434. {
  435.    int       i;
  436.    char    curarg[141];
  437.    char    tempstring[101];
  438.    char    *sptr;
  439.    FILE    *initfile;
  440.  
  441.    if (first_init) initvars_run();    /* once per run initialization */
  442.    initvars_restart();            /* <ins> key initialization */
  443.    initvars_fractal();            /* image initialization */
  444.  
  445.    findpath(s_sstoolsini, tempstring); /* look for SSTOOLS.INI */
  446.    if (tempstring[0] != 0)        /* found it! */
  447.       if ((initfile = fopen(tempstring,"r")) != NULL)
  448.      cmdfile(initfile,1);        /* process it */
  449.  
  450.    for (i = 1; i < argc; i++) {     /* cycle through args */
  451. #ifdef XFRACT
  452.       /* Let the xfract code take a look at the argument */
  453.       if (unixarg(argc,argv,&i)) continue;
  454. #endif
  455.       strcpy(curarg,argv[i]);
  456.       if (curarg[0] == ';')             /* start of comments? */
  457.      break;
  458.       if (curarg[0] != '@') {           /* simple command? */
  459.      if (strchr(curarg,'=') == NULL) { /* not xxx=yyy, so check for gif */
  460.         strcpy(tempstring,curarg);
  461.         if (has_ext(curarg) == NULL)
  462.            strcat(tempstring,".gif");
  463.         if ((initfile = fopen(tempstring,"rb")) != NULL) {
  464.            fread(tempstring,6,1,initfile);
  465.            if ( tempstring[0] == 'G'
  466.          && tempstring[1] == 'I'
  467.          && tempstring[2] == 'F'
  468.          && tempstring[3] >= '8' && tempstring[3] <= '9'
  469.          && tempstring[4] >= '0' && tempstring[4] <= '9') {
  470.           strcpy(readname,curarg);
  471.           extract_filename(browsename,readname);
  472.           curarg[0] = (char)(showfile = 0);
  473.           }
  474.            fclose(initfile);
  475.            }
  476.         }
  477.      if (curarg[0])
  478.         cmdarg(curarg,0);        /* process simple command */
  479.      }
  480.       else if ((sptr = strchr(curarg,'/')) != NULL) { /* @filename/setname? */
  481.      *sptr = 0;
  482.          if(merge_pathnames(CommandFile, &curarg[1], 0) < 0)
  483.             init_msg(0,"",CommandFile,0);
  484.      strcpy(CommandName,sptr+1);
  485.      if(find_file_item(CommandFile,CommandName,&initfile)<0 || initfile==NULL)
  486.         argerror(curarg);
  487.      cmdfile(initfile,3);
  488.      }
  489.       else {                /* @filename */
  490.      if ((initfile = fopen(&curarg[1],"r")) == NULL)
  491.         argerror(curarg);
  492.      cmdfile(initfile,0);
  493.      }
  494.       }
  495.  
  496.    if (first_init == 0) {
  497.       initmode = -1; /* don't set video when <ins> key used */
  498.       showfile = 1;  /* nor startup image file            */
  499.       }
  500.  
  501.    init_msg(0,"",NULL,0);  /* this causes getakey if init_msg called on runup */
  502.  
  503.    if(debugflag != 110)
  504.        first_init = 0;
  505. /*     {
  506.         char msg[80];
  507.         sprintf(msg,"cmdfiles colorpreloaded %d showfile %d savedac %d",
  508.             colorpreloaded, showfile, savedac);
  509.         stopmsg(0,msg);
  510.      }
  511. */     
  512.    if(colorpreloaded && showfile==0) /* PAR reads a file and sets color */
  513.       dontreadcolor = 1;   /* don't read colors from GIF */
  514.    else
  515.       dontreadcolor = 0;   /* read colors from GIF */    
  516.    return(0);
  517. }
  518.  
  519.  
  520. int load_commands(FILE *infile)
  521. {
  522.    /* when called, file is open in binary mode, positioned at the */
  523.    /* '(' or '{' following the desired parameter set's name       */
  524.    int ret;
  525.    initcorners = initparams = 0; /* reset flags for type= */
  526.    ret = cmdfile(infile,2);
  527. /*     
  528.      {
  529.         char msg[80];
  530.         sprintf(msg,"load commands colorpreloaded %d showfile %d savedac %d",
  531.             colorpreloaded, showfile, savedac);
  532.         stopmsg(0,msg);
  533.      }
  534. */     
  535.  
  536.    if(colorpreloaded && showfile==0) /* PAR reads a file and sets color */
  537.       dontreadcolor = 1;   /* don't read colors from GIF */
  538.    else
  539.       dontreadcolor = 0;   /* read colors from GIF */    
  540.    return ret;
  541. }
  542.  
  543.  
  544. static void initvars_run()        /* once per run init */
  545. {
  546.    char *p;
  547.    init_rseed = (int)time(NULL);
  548.    if((p = getenv("TMP")) == NULL)
  549.       p = getenv("TEMP");
  550.    if(p != NULL)
  551.    {
  552.       if(isadirectory(p) != 0)
  553.       {
  554.          strcpy(tempdir,p);
  555.          fix_dirname(tempdir);
  556.       }   
  557.    }
  558.    else
  559.       *tempdir = 0;  
  560. }
  561.  
  562. static void initvars_restart()        /* <ins> key init */
  563. {
  564.    save_release = release;              /* this release number */
  565.    gif87a_flag = INIT_GIF87;            /* turn on GIF89a processing */
  566.    dither_flag = 0;            /* no dithering */
  567.    askvideo = 1;            /* turn on video-prompt flag */
  568.    overwrite = 0;            /* don't overwrite           */
  569.    soundflag = -1;            /* sound is on             */
  570.    basehertz = 440;            /* basic hertz rate         */
  571.    initbatch = 0;            /* not in batch mode         */
  572.    checkcurdir = 0;            /* flag to check current dire for files */
  573.    initsavetime = 0;            /* no auto-save          */
  574.    initmode = -1;            /* no initial video mode     */
  575.    viewwindow = 0;            /* no view window         */
  576.    viewreduction = (float)4.2;
  577.    viewcrop = 1;
  578.    ai_8514 = 0;                         /* no need for the 8514 API  */
  579.    finalaspectratio = screenaspect;
  580.    viewxdots = viewydots = 0;
  581.    orbit_delay = 0;                     /* full speed orbits */
  582.    debugflag = 0;            /* debugging flag(s) are off */
  583.    timerflag = 0;            /* timer flags are off         */
  584.    far_strcpy(FormFileName,s_fractintfrm); /* default formula file      */
  585.    FormName[0] = 0;
  586.    far_strcpy(LFileName,s_fractintl);
  587.    LName[0] = 0;
  588.    far_strcpy(CommandFile,s_fractintpar);
  589.    CommandName[0] = CommandComment1[0] = CommandComment2[0] = 0;
  590.    CommandComment3[0] = CommandComment4[0] = 0;
  591.    far_strcpy(IFSFileName,s_fractintifs);
  592.    IFSName[0] = 0;
  593.    reset_ifs_defn();
  594.    rflag = 0;                /* not a fixed srand() seed */
  595.    rseed = init_rseed;
  596.    strcpy(readname,DOTSLASH);           /* initially current directory */
  597.    showfile = 1;
  598.    /* next should perhaps be fractal re-init, not just <ins> ? */
  599.    initcyclelimit=55;            /* spin-DAC default speed limit */
  600.    mapset = 0;                /* no map= name active */
  601.    if (mapdacbox) {
  602.       farmemfree(mapdacbox);
  603.       mapdacbox = NULL;
  604.       }
  605.    TPlusFlag = 1;
  606.    MaxColorRes = 8;
  607.    PixelZoom = 0;
  608.    NonInterlaced = 0;
  609.  
  610.    Printer_Type = DEFAULT_PRINTER;      /* assume an IBM/EPSON    */
  611.    Printer_Resolution = PRT_RESOLUTION; /* assume low resolution  */
  612.    Printer_Titleblock = 0;        /* assume no title block  */
  613.    Printer_ColorXlat = 0;        /* assume positive image  */
  614.    Printer_SetScreen = 0;               /* assume default screen  */
  615.    Printer_SFrequency = 45;             /* New screen frequency K */
  616.    Printer_SAngle = 45;                 /* New screen angle     K */
  617.    Printer_SStyle = 1;                  /* New screen style     K */
  618.    Printer_RFrequency = 45;             /* New screen frequency R */
  619.    Printer_RAngle = 75;                 /* New screen angle     R */
  620.    Printer_RStyle = 1;                  /* New screen style     R */
  621.    Printer_GFrequency = 45;             /* New screen frequency G */
  622.    Printer_GAngle = 15;                 /* New screen angle     G */
  623.    Printer_GStyle = 1;                  /* New screen style     G */
  624.    Printer_BFrequency = 45;             /* New screen frequency B */
  625.    Printer_BAngle = 0;                  /* New screen angle     B */
  626.    Printer_BStyle = 1;                  /* New screen style     B */
  627. #ifndef XFRACT
  628.    Print_To_File = 0;                   /* No print-to-file       */
  629.    Printer_CRLF = 0;                    /* Assume CR+LF           */
  630. #else
  631.    Print_To_File = 1;                   /* Print-to-file          */
  632.    Printer_CRLF = 2;                    /* Assume LF              */
  633.    Printer_Compress = 0;                /* Assume NO PostScript compression */
  634. #endif
  635.    EPSFileType = 0;            /* Assume no save to .EPS */
  636.    LPTNumber = 1;            /* assume LPT1 */
  637.    ColorPS = 0;                         /* Assume NO Color PostScr*/
  638.    major_method = breadth_first;    /* default inverse julia methods */
  639.    minor_method = left_first;    /* default inverse julia methods */
  640. }
  641.  
  642. static void initvars_fractal()        /* init vars affecting calculation */
  643. {
  644.    int i;
  645.    bios_palette = 0;                    /* don't force use of a BIOS palette */
  646.    escape_exit = 0;                     /* don't disable the "are you sure?" screen */
  647.    usr_periodicitycheck = 1;        /* turn on periodicity      */
  648.    inside = 1;                /* inside color = blue      */
  649.    fillcolor = -1;            /* no special fill color */
  650.    usr_biomorph = -1;            /* turn off biomorph flag */
  651.    outside = -1;            /* outside color = -1 (not used) */
  652.    maxit = 150;             /* initial maxiter      */
  653.    usr_stdcalcmode = 'g';               /* initial solid-guessing */
  654. #ifndef XFRACT
  655.    usr_floatflag = 0;            /* turn off the float flag */
  656. #else
  657.    usr_floatflag = 1;            /* turn on the float flag */
  658. #endif
  659.    finattract = 0;            /* disable finite attractor logic */
  660.    fractype = 0;            /* initial type Set flag  */
  661.    curfractalspecific = &fractalspecific[0];
  662.    initcorners = initparams = 0;
  663.    bailout = 0;             /* no user-entered bailout */
  664.    useinitorbit = 0;
  665.    for (i = 0; i < MAXPARAMS; i++) param[i] = 0.0;     /* initial parameter values */
  666.    for (i = 0; i < 3; i++) potparam[i]    = 0.0; /* initial potential values */
  667.    for (i = 0; i < 3; i++) inversion[i] = 0.0;    /* initial invert values */
  668.    initorbit.x = initorbit.y = 0.0;    /* initial orbit values */
  669.    invert = 0;
  670.    decomp[0] = decomp[1] = 0;
  671.    usr_distest = 0;
  672.    pseudox = 0;
  673.    pseudoy = 0;
  674.    distestwidth = 71;
  675.    forcesymmetry = 999;         /* symmetry not forced */
  676.    xx3rd = xxmin = -2.5; xxmax = 1.5;    /* initial corner values  */
  677.    yy3rd = yymin = -1.5; yymax = 1.5;    /* initial corner values  */
  678.    bf_math = 0;
  679.    pot16bit = potflag = 0;
  680.    LogFlag = 0;             /* no logarithmic palette */
  681.    set_trig_array(0,s_sin);             /* trigfn defaults */
  682.    set_trig_array(1,s_sqr);
  683.    set_trig_array(2,s_sinh);
  684.    set_trig_array(3,s_cosh);
  685.    if (rangeslen) {
  686.       farmemfree((char far *)ranges);
  687.       rangeslen = 0;
  688.       }
  689.    usemag = 0;                          /* use corners, not center-mag */
  690.  
  691.    colorstate = colorpreloaded = 0;
  692.    rotate_lo = 1; rotate_hi = 255;    /* color cycling default range */
  693.  
  694.    display3d = 0;            /* 3D display is off        */
  695.    overlay3d = 0;            /* 3D overlay is off        */
  696.  
  697.    old_demm_colors = 0;
  698.    bailoutest    = Mod;
  699.    floatbailout  = (int (near *)(void))fpMODbailout;
  700.    longbailout   = (int (near *)(void))asmlMODbailout;
  701.    bignumbailout = (int (near *)(void))bnMODbailout;
  702.    bigfltbailout = (int (near *)(void))bfMODbailout;
  703.  
  704.    functionpreloaded = 0; /* for old bifs  JCO 7/5/92 */
  705.    mxminfp = -.83;
  706.    myminfp = -.25;
  707.    mxmaxfp = -.83;
  708.    mymaxfp =  .25;
  709.    originfp = 8;
  710.    heightfp = 7;
  711.    widthfp = 10;
  712.    distfp = 24;
  713.    eyesfp = (float)2.5;
  714.    depthfp = 8;
  715.    neworbittype = JULIA;
  716.    zdots = 128;
  717.    initvars_3d();
  718. }
  719.  
  720. static void initvars_3d()        /* init vars affecting 3d */
  721. {
  722.    RAY     = 0;
  723.    BRIEF   = 0;
  724.    SPHERE = FALSE;
  725.    preview = 0;
  726.    showbox = 0;
  727.    xadjust = 0;
  728.    yadjust = 0;
  729.    eyeseparation = 0;
  730.    glassestype = 0;
  731.    previewfactor = 20;
  732.    red_crop_left   = 4;
  733.    red_crop_right  = 0;
  734.    blue_crop_left  = 0;
  735.    blue_crop_right = 4;
  736.    red_bright      = 80;
  737.    blue_bright     = 100;
  738.    transparent[0] = transparent[1] = 0; /* no min/max transparency */
  739.    set_3d_defaults();
  740. }
  741.  
  742. static void reset_ifs_defn()
  743. {
  744.    if (ifs_defn) {
  745.       farmemfree((char far *)ifs_defn);
  746.       ifs_defn = NULL;
  747.       }
  748. }
  749.  
  750.  
  751. static int cmdfile(FILE *handle,int mode)
  752.    /* mode = 0 command line @filename          */
  753.    /*         1 sstools.ini              */
  754.    /*         2 <@> command after startup      */
  755.    /*         3 command line @filename/setname */
  756. {
  757.    /* note that cmdfile could be open as text OR as binary */
  758.    /* binary is used in @ command processing for reasonable speed note/point */
  759.    int i;
  760.    int lineoffset = 0;
  761.    int changeflag = 0; /* &1 fractal stuff chgd, &2 3d stuff chgd */
  762.    char linebuf[513],*cmdbuf;
  763.    char far *savesuffix;
  764.    /* use near array suffix for large argument buffer, but save existing
  765.       contents to extraseg */
  766.    cmdbuf = (char *)suffix;
  767.    savesuffix = MK_FP(extraseg,0);
  768.    far_memcpy(savesuffix,suffix,10000);
  769.    far_memset(suffix,0,10000);
  770.  
  771.    if (mode == 2 || mode == 3) {
  772.       while ((i = getc(handle)) != '{' && i != EOF) { }
  773.       CommandComment1[0] = CommandComment2[0] = 0;
  774.       CommandComment3[0] = CommandComment4[0] = 0;
  775.       }
  776.    linebuf[0] = 0;
  777.    while (next_command(cmdbuf,10000,handle,linebuf,&lineoffset,mode) > 0) {
  778.       if ((mode == 2 || mode == 3) && strcmp(cmdbuf,"}") == 0) break;
  779.       if ((i = cmdarg(cmdbuf,mode)) < 0) break;
  780.       changeflag |= i;
  781.       }
  782.    fclose(handle);
  783. #ifdef XFRACT
  784.    initmode = 0;        /* Skip credits if @file is used. */
  785. #endif
  786.    far_memcpy(suffix,savesuffix,10000);
  787.    if(changeflag&1)
  788.    {
  789.       backwards_v18();
  790.       backwards_v19();
  791.    }
  792.    return changeflag;
  793. }
  794.  
  795. static int next_command(char *cmdbuf,int maxlen,
  796.               FILE *handle,char *linebuf,int *lineoffset,int mode)
  797. {
  798.    int cmdlen = 0;
  799.    char *lineptr;
  800.    lineptr = linebuf + *lineoffset;
  801.    for(;;) {
  802.       while (*lineptr <= ' ' || *lineptr == ';') {
  803.      if (cmdlen) {            /* space or ; marks end of command */
  804.         cmdbuf[cmdlen] = 0;
  805.         *lineoffset = lineptr - linebuf;
  806.         return cmdlen;
  807.         }
  808.      while (*lineptr && *lineptr <= ' ')
  809.         ++lineptr;            /* skip spaces and tabs */
  810.      if (*lineptr == ';' || *lineptr == 0) {
  811.         if (*lineptr == ';'
  812.           && (mode == 2 || mode == 3)
  813.           && (CommandComment1[0] == 0 || CommandComment2[0] == 0 ||
  814.               CommandComment3[0] == 0 || CommandComment4[0] == 0)) {
  815.            /* save comment */
  816.            while (*(++lineptr)
  817.          && (*lineptr == ' ' || *lineptr == '\t')) { }
  818.            if (*lineptr) {
  819.           if (strlen(lineptr) > 56)
  820.              *(lineptr+56) = 0;
  821.           if (CommandComment1[0] == 0)
  822.              far_strcpy(CommandComment1,lineptr);
  823.           else if (CommandComment2[0] == 0)
  824.              far_strcpy(CommandComment2,lineptr);
  825.           else if (CommandComment3[0] == 0)
  826.              far_strcpy(CommandComment3,lineptr);
  827.           else
  828.              far_strcpy(CommandComment4,lineptr);
  829.           }
  830.            }
  831.         if (next_line(handle,linebuf,mode) != 0)
  832.            return(-1); /* eof */
  833.         lineptr = linebuf; /* start new line */
  834.         }
  835.      }
  836.       if (*lineptr == '\\'              /* continuation onto next line? */
  837.     && *(lineptr+1) == 0) {
  838.      if (next_line(handle,linebuf,mode) != 0) {
  839.         argerror(cmdbuf);        /* missing continuation */
  840.         return(-1);
  841.         }
  842.      lineptr = linebuf;
  843.      while (*lineptr && *lineptr <= ' ')
  844.         ++lineptr;            /* skip white space @ start next line */
  845.      continue;            /* loop to check end of line again */
  846.      }
  847.       cmdbuf[cmdlen] = *(lineptr++);    /* copy character to command buffer */
  848.       if (++cmdlen >= maxlen) {     /* command too long? */
  849.      argerror(cmdbuf);
  850.      return(-1);
  851.      }
  852.       }
  853. }
  854.  
  855. static int next_line(FILE *handle,char *linebuf,int mode)
  856. {
  857.    int toolssection;
  858.    char tmpbuf[10];
  859.    toolssection = 0;
  860.    while (file_gets(linebuf,512,handle) >= 0) {
  861.       if (mode == 1 && linebuf[0] == '[') {     /* check for [fractint] */
  862.      strncpy(tmpbuf,&linebuf[1],9);
  863.      tmpbuf[9] = 0;
  864.      strlwr(tmpbuf);
  865.      toolssection = strncmp(tmpbuf,"fractint]",9);
  866.      continue;                /* skip tools section heading */
  867.      }
  868.       if (toolssection == 0) return(0);
  869.       }
  870.    return(-1);
  871. }
  872.  
  873. /*
  874.   cmdarg(string,mode) processes a single command-line/command-file argument
  875.     return:
  876.       -1 error, >= 0 ok
  877.       if ok, return value:
  878.     | 1 means fractal parm has been set
  879.     | 2 means 3d parm has been set
  880.     | 4 means 3d=yes specified
  881.     | 8 means reset specified
  882. */
  883.  
  884. /* following gets rid of "too big for optimization" warning */
  885. #ifdef _MSC_VER
  886. #if (_MSC_VER >= 600)
  887. #pragma optimize( "el", off )
  888. #endif
  889. #endif
  890.  
  891. int cmdarg(char *curarg,int mode) /* process a single argument */
  892. {
  893.    char    variable[21];        /* variable name goes here   */
  894.    char    *value;            /* pointer to variable value */
  895.    int       valuelen;            /* length of value         */
  896.    int       numval;            /* numeric value of arg      */
  897. #define NONNUMERIC -32767
  898.    char    charval;            /* first character of arg    */
  899.    int       yesnoval;            /* 0 if 'n', 1 if 'y', -1 if not */
  900.    double  ftemp;
  901.    int       i, j, k, l;
  902.    char    *argptr,*argptr2;
  903.    int       totparms;            /* # of / delimited parms    */
  904.    int       intparms;            /* # of / delimited ints     */
  905.    int       floatparms;            /* # of / delimited floats   */
  906.    int       intval[64];            /* pre-parsed integer parms  */
  907.    double  floatval[16];        /* pre-parsed floating parms */
  908.    char    *floatvalstr[16];        /* pointers to float vals */
  909.    char    tmpc;
  910.    int     lastarg;
  911.    double Xctr, Yctr, Xmagfactor, Rotation, Skew;
  912.    LDBL Magnification;
  913.    bf_t bXctr, bYctr;
  914.  
  915.  
  916.    argptr = curarg;
  917.    while (*argptr) {            /* convert to lower case */
  918.       if (*argptr >= 'A' && *argptr <= 'Z')
  919.      *argptr += 'a' - 'A';
  920.       if (*argptr == '=' && strncmp(curarg,"colors=",7) == 0)
  921.      break;             /* don't convert colors=value */
  922.       ++argptr;
  923.       }
  924.  
  925.    if ((value = strchr(&curarg[1],'=')) != NULL) {
  926.       if ((j = (value++) - curarg) > 1 && curarg[j-1] == ':')
  927.      --j;                /* treat := same as =      */
  928.       }
  929.    else
  930.       value = curarg + (j = strlen(curarg));
  931.    if (j > 20) goto badarg;        /* keyword too long */
  932.    strncpy(variable,curarg,j);        /* get the variable name  */
  933.    variable[j] = 0;            /* truncate variable name */
  934.    valuelen = strlen(value);        /* note value's length    */
  935.    charval = value[0];            /* first letter of value  */
  936.    yesnoval = -1;            /* note yes|no value      */
  937.    if (charval == 'n') yesnoval = 0;
  938.    if (charval == 'y') yesnoval = 1;
  939.  
  940.    argptr = value;
  941.    numval = totparms = intparms = floatparms = 0;
  942.    while (*argptr) {            /* count and pre-parse parms */
  943.       long ll;
  944.       lastarg = 0;
  945.       if ((argptr2 = strchr(argptr,'/')) == NULL) {     /* find next '/' */
  946.      argptr2 = argptr + strlen(argptr);
  947.      *argptr2 = '/';
  948.      lastarg = 1;
  949.      }
  950.       if (totparms == 0) numval = NONNUMERIC;
  951.       i = -1;
  952.       charval = *argptr;            /* first letter of value  */
  953.       if (charval == 'n') yesnoval = 0;    /* allows only ONE y/n param */
  954.       if (charval == 'y') yesnoval = 1;
  955.       j=0;
  956.       if (sscanf(argptr,"%c%c",(char *)&j,&tmpc) > 0    /* NULL entry */
  957.       && ((char)j == '/' || (char)j == '=') && tmpc == '/') {
  958.      j = 0;
  959.      ++floatparms; ++intparms;
  960.      if (totparms < 16) {floatval[totparms] = j; floatvalstr[totparms]="0";}
  961.      if (totparms < 64) intval[totparms] = j;
  962.      if (totparms == 0) numval = j;
  963.      }
  964.       else if (sscanf(argptr,"%ld%c",&ll,&tmpc) > 0       /* got an integer */
  965.     && tmpc == '/') {        /* needs a long int, ll, here for lyapunov */
  966.      ++floatparms; ++intparms;
  967.      if (totparms < 16) {floatval[totparms] = ll; floatvalstr[totparms]=argptr;}
  968.      if (totparms < 64) intval[totparms] = (int)ll;
  969.      if (totparms == 0) numval = (int)ll;
  970.      }
  971. #ifndef XFRACT
  972.       else if (sscanf(argptr,"%lg%c",&ftemp,&tmpc) > 0  /* got a float */
  973. #else
  974.       else if (sscanf(argptr,"%lf%c",&ftemp,&tmpc) > 0  /* got a float */
  975. #endif
  976.          && tmpc == '/') {
  977.      ++floatparms;
  978.      if (totparms < 16) {floatval[totparms] = ftemp;floatvalstr[totparms]=argptr;}
  979.      }
  980.       /* using arbitrary precision and above failed */
  981.       else if ((strlen(argptr) > 513)  /* very long command */ 
  982.                  || (totparms > 0 && floatval[totparms-1] == FLT_MAX 
  983.                  && totparms < 6)) { 
  984.      ++floatparms;
  985.      floatval[totparms] = FLT_MAX;
  986.      floatvalstr[totparms]=argptr;
  987.       } 
  988.       ++totparms;
  989.       argptr = argptr2;                 /* on to the next */
  990.       if (lastarg)
  991.      *argptr = 0;
  992.       else
  993.      ++argptr;
  994.       }
  995.  
  996.    if (mode != 2 || debugflag==110) {
  997.       /* these commands are allowed only at startup */
  998.  
  999.       if (strcmp(variable,s_batch) == 0 ) {     /* batch=?      */
  1000.      if (yesnoval < 0) goto badarg;
  1001. #ifdef XFRACT
  1002.          initmode = yesnoval?0:-1; /* skip credits for batch mode */
  1003. #endif
  1004.      initbatch = yesnoval;
  1005.      return 3;
  1006.      }
  1007.    if (strcmp(variable,"maxhistory") == 0) {       /* maxhistory=? */
  1008.       if(numval == NONNUMERIC)
  1009.      goto badarg;
  1010.       else if(numval < 0 /* || numval > 1000 */) goto badarg;
  1011.       else maxhistory = numval;
  1012.       return 3;
  1013.       }
  1014.  
  1015. #ifndef XFRACT
  1016.       if (strcmp(variable,s_adapter) == 0 ) {   /* adapter==?     */
  1017.          int i, j;
  1018.          char adapter_name[8];      /* entry lenth from VIDEO.ASM */
  1019.          char *adapter_ptr;
  1020.          
  1021.          adapter_ptr = &supervga_list;
  1022.          
  1023.          for(i = 0 ; ; i++) {        /* find the SuperVGA entry */
  1024.              memcpy(adapter_name , adapter_ptr, 8);
  1025.              adapter_name[6] = ' ';
  1026.              for (j = 0; j < 8; j++)
  1027.                  if(adapter_name[j] == ' ')
  1028.                      adapter_name[j] = 0;
  1029.              if (adapter_name[0] == 0) break;  /* end-of-the-list */
  1030.              if (strncmp(value,adapter_name,strlen(adapter_name)) == 0) {
  1031.                 svga_type = i+1;
  1032.                 adapter_ptr[6] = 1;
  1033.                 break;
  1034.                 }
  1035.              adapter_ptr += 8;
  1036.              }
  1037.          if (svga_type != 0) return 3;
  1038.  
  1039.      video_type = 5;            /* assume video=vga */
  1040.      if (strcmp(value,s_egamono) == 0) {
  1041.         video_type = 3;
  1042.         mode7text = 1;
  1043.         }
  1044.      else if (strcmp(value,s_hgc) == 0) {   /* video = hgc */
  1045.         video_type = 1;
  1046.         mode7text = 1;
  1047.         }
  1048.      else if (strcmp(value,s_ega) == 0)     /* video = ega */
  1049.         video_type = 3;
  1050.      else if (strcmp(value,s_cga) == 0)     /* video = cga */
  1051.         video_type = 2;
  1052.      else if (strcmp(value,s_mcga) == 0)    /* video = mcga */
  1053.         video_type = 4;
  1054.      else if (strcmp(value,s_vga) == 0)     /* video = vga */
  1055.         video_type = 5;
  1056.      else
  1057.         goto badarg;
  1058.      return 3;
  1059.      }
  1060.  
  1061.       if (strcmp(variable,s_afi) == 0) {
  1062.        if (strncmp(value,"8514"  ,4) == 0
  1063.            || charval == 'y') ai_8514 = 1; /* set afi flag JCO 4/11/92 */
  1064.        return 3;
  1065.     }
  1066.  
  1067.       if (strcmp(variable,s_textsafe) == 0 ) {  /* textsafe==? */
  1068.      if (first_init) {
  1069.         if (charval == 'n') /* no */
  1070.            textsafe = 2;
  1071.         else if (charval == 'y') /* yes */
  1072.            textsafe = 1;
  1073.         else if (charval == 'b') /* bios */
  1074.            textsafe = 3;
  1075.         else if (charval == 's') /* save */
  1076.            textsafe = 4;
  1077.         else
  1078.            goto badarg;
  1079.         }   
  1080.      return 3;
  1081.      }
  1082.  
  1083.       if (strcmp(variable,s_vesadetect) == 0) {
  1084.      if (yesnoval < 0) goto badarg;
  1085.      vesa_detect = yesnoval;
  1086.      return 3;
  1087.      }
  1088.  
  1089.       if (strcmp(variable,s_biospalette) == 0) {
  1090.          if (yesnoval < 0) goto badarg;
  1091.          bios_palette = yesnoval;
  1092.          return 3;
  1093.          }
  1094.  
  1095.       if (strcmp(variable,s_fpu) == 0) {
  1096.      if (strcmp(value,s_iit) == 0) {
  1097.         fpu = 387;
  1098.         iit = 1;
  1099.         return 0;
  1100.         }
  1101.      if (strcmp(value,s_noiit) == 0) {
  1102.         iit = -2;
  1103.         return 0;
  1104.         }
  1105.      if (strcmp(value,s_387) == 0) {
  1106.         fpu = 387;
  1107.         iit = -2;
  1108.         return 0;
  1109.         }
  1110.      goto badarg;
  1111.      }
  1112. #endif
  1113.  
  1114.       if (strcmp(variable,s_exitnoask) == 0) {
  1115.          if (yesnoval < 0) goto badarg;
  1116.          escape_exit = yesnoval;
  1117.          return 3;
  1118.          }
  1119.  
  1120.       if (strcmp(variable,s_makedoc) == 0) {
  1121.      print_document(*value ? value : "fractint.doc", makedoc_msg_func, 0);
  1122. #ifndef WINFRACT
  1123.      goodbye();
  1124. #endif
  1125.      }
  1126.  
  1127.       } /* end of commands allowed only at startup */
  1128.  
  1129.    if (strcmp(variable,s_reset) == 0) {
  1130.       initvars_fractal();
  1131.  
  1132.       /* PAR release unknown unless specified */
  1133.       if (numval>=0) save_release = numval;
  1134.       else goto badarg;
  1135.       if (save_release == 0)
  1136.          save_release = 1730; /* before start of lyapunov wierdness */
  1137.       return 9;
  1138.       }
  1139.  
  1140.    if (strcmp(variable,s_filename) == 0) {      /* filename=?     */
  1141.       int existdir;
  1142.       if (charval == '.' && value[1] != SLASHC) {
  1143.      if (valuelen > 4) goto badarg;
  1144.      gifmask[0] = '*';
  1145.      gifmask[1] = 0;
  1146.      strcat(gifmask,value);
  1147.      return 0;
  1148.      }
  1149.       if (valuelen > (FILE_MAX_PATH-1)) goto badarg;
  1150.       if (mode == 2 && display3d == 0) /* can't do this in @ command */
  1151.      goto badarg;
  1152.  
  1153.       if((existdir=merge_pathnames(readname, value, mode))==0)
  1154.          showfile = 0;
  1155.       else if(existdir < 0)
  1156.          init_msg(0,variable,value,mode);
  1157.       else
  1158.          extract_filename(browsename,readname);
  1159.       return 3;
  1160.       }
  1161.  
  1162.    if (strcmp(variable,s_video) == 0) {         /* video=? */
  1163.       if (active_system == 0) {
  1164.      if ((k = check_vidmode_keyname(value)) == 0) goto badarg;
  1165.      initmode = -1;
  1166.      for (i = 0; i < MAXVIDEOTABLE; ++i) {
  1167.         if (videotable[i].keynum == k) {
  1168.            initmode = i;
  1169.            break;
  1170.            }
  1171.         }
  1172.      if (initmode == -1) goto badarg;
  1173.      }
  1174.       return 3;
  1175.       }
  1176.  
  1177.    if (strcmp(variable,s_map) == 0 ) {         /* map=, set default colors */
  1178.       int existdir;
  1179.       if (valuelen > (FILE_MAX_PATH-1)) goto badarg;
  1180.       if((existdir=merge_pathnames(MAP_name,value,mode))>0)
  1181.          return 0;    /* got a directory */
  1182.       else if (existdir < 0) {
  1183.          init_msg(0,variable,value,mode);
  1184.          return (0);
  1185.       }   
  1186.       SetColorPaletteName(MAP_name);
  1187.       return 0;
  1188.       }
  1189.  
  1190.    if (strcmp(variable,s_colors) == 0) {       /* colors=, set current colors */
  1191.       if (parse_colors(value) < 0) goto badarg;
  1192.       return 0;
  1193.       }
  1194.  
  1195.    if (strcmp(variable,s_tplus) == 0) {       /* Use the TARGA+ if found? */
  1196.       if (yesnoval < 0) goto badarg;
  1197.       TPlusFlag = yesnoval;
  1198.       return 0;
  1199.       }
  1200.  
  1201.    if (strcmp(variable,s_noninterlaced) == 0) {
  1202.       if (yesnoval < 0) goto badarg;
  1203.       NonInterlaced = yesnoval;
  1204.       return 0;
  1205.       }
  1206.  
  1207.    if (strcmp(variable,s_maxcolorres) == 0) { /* Change default color resolution */
  1208.       if (numval == 1 || numval == 4 || numval == 8 ||
  1209.             numval == 16 || numval == 24) {
  1210.      MaxColorRes = numval;
  1211.      return 0;
  1212.      }
  1213.       goto badarg;
  1214.       }
  1215.  
  1216.    if (strcmp(variable,s_pixelzoom) == 0) {
  1217.       if (numval < 5)
  1218.      PixelZoom = numval;
  1219.       return 0;
  1220.       }
  1221.  
  1222.    /* keep this for backward compatibility */
  1223.    if (strcmp(variable,s_warn) == 0 ) {         /* warn=? */
  1224.       if (yesnoval < 0) goto badarg;
  1225.       overwrite = (char)(yesnoval ^ 1);
  1226.       return 0;
  1227.       }
  1228.    if (strcmp(variable,s_overwrite) == 0 ) {    /* overwrite=? */
  1229.       if (yesnoval < 0) goto badarg;
  1230.       overwrite = (char)yesnoval;
  1231.       return 0;
  1232.       }
  1233.  
  1234.    if (strcmp(variable,s_gif87a) == 0 ) {       /* gif87a=? */
  1235.       if (yesnoval < 0) goto badarg;
  1236.       gif87a_flag = yesnoval;
  1237.       return 0;
  1238.       }
  1239.  
  1240.    if (strcmp(variable,s_dither) == 0 ) {       /* dither=? */
  1241.       if (yesnoval < 0) goto badarg;
  1242.       dither_flag = yesnoval;
  1243.       return 0;
  1244.       }
  1245.  
  1246.    if (strcmp(variable,s_savetime) == 0) {      /* savetime=? */
  1247.       initsavetime = numval;
  1248.       return 0;
  1249.       }
  1250.  
  1251.    if (strcmp(variable,s_autokey) == 0) {       /* autokey=? */
  1252.       if (strcmp(value,s_record)==0)
  1253.      slides=2;
  1254.       else if (strcmp(value,s_play)==0)
  1255.      slides=1;
  1256.       else
  1257.      goto badarg;
  1258.       return 0;
  1259.       }
  1260.  
  1261.    if (strcmp(variable,s_autokeyname) == 0) {   /* autokeyname=? */
  1262.       if(merge_pathnames(autoname, value,mode) < 0)
  1263.          init_msg(0,variable,value,mode);
  1264.       return 0;
  1265.       }
  1266.  
  1267.    if (strcmp(variable,s_type) == 0 ) {         /* type=? */
  1268.       int extra;
  1269.       if (value[valuelen-1] == '*')
  1270.      value[--valuelen] = 0;
  1271.       /* kludge because type ifs3d has an asterisk in front */
  1272.       if(strcmp(value,s_ifs3d)==0)
  1273.          value[3]=0;
  1274.       for (k = 0; fractalspecific[k].name != NULL; k++)
  1275.      if (strcmp(value,fractalspecific[k].name) == 0)
  1276.         break;
  1277.       if (fractalspecific[k].name == NULL) goto badarg;
  1278.       curfractalspecific = &fractalspecific[fractype = k];
  1279.       if (initcorners == 0) {
  1280.      xx3rd = xxmin = curfractalspecific->xmin;
  1281.      xxmax           = curfractalspecific->xmax;
  1282.      yy3rd = yymin = curfractalspecific->ymin;
  1283.      yymax           = curfractalspecific->ymax;
  1284.       }     
  1285.       if (initparams == 0) {
  1286.      for (k = 0; k < 4; ++k) {
  1287.         param[k] = curfractalspecific->paramvalue[k];
  1288.         if(fractype != CELLULAR) /* don't round cellular */
  1289.            roundfloatd(¶m[k]);
  1290.       }
  1291.           if((extra=find_extra_param(fractype)) > -1)
  1292.              for(i=0;i<MAXPARAMS-4;i++) {
  1293.                 param[i+4] = moreparams[extra].paramvalue[i];
  1294.          }
  1295.       }   
  1296.       return 1;
  1297.       }
  1298.    if (strcmp(variable,s_inside) == 0 ) {       /* inside=? */
  1299.       if(strcmp(value,s_zmag)==0)
  1300.      inside = -59;
  1301.       else if(strcmp(value,s_bof60)==0)
  1302.      inside = -60;
  1303.       else if(strcmp(value,s_bof61)==0)
  1304.      inside = -61;
  1305.       else if(strncmp(value,s_epscross,3)==0)
  1306.      inside = -100;
  1307.       else if(strncmp(value,s_startrail,4)==0)
  1308.      inside = -101;
  1309.       else if(strncmp(value,s_period,3)==0)
  1310.      inside = -102;
  1311.       else if(strcmp(value,s_maxiter)==0)
  1312.      inside = -1;
  1313.       else if(numval == NONNUMERIC)
  1314.      goto badarg;
  1315.       else
  1316.      inside = numval;
  1317.       return 1;
  1318.       }
  1319.    if (strcmp(variable,s_fillcolor) == 0 ) {       /* fillcolor */
  1320.       if(strcmp(value,s_normal)==0)
  1321.      fillcolor = -1;
  1322.       else if(numval == NONNUMERIC)
  1323.      goto badarg;
  1324.       else
  1325.      fillcolor = numval;
  1326.       return 1;
  1327.       }
  1328.  
  1329.    if (strcmp(variable,s_finattract) == 0 ) {   /* finattract=? */
  1330.       if (yesnoval < 0) goto badarg;
  1331.       finattract = yesnoval;
  1332.       return 1;
  1333.       }
  1334.  
  1335.    if (strcmp(variable,s_function) == 0) {      /* function=?,? */
  1336.       k = 0;
  1337.       while (*value && k < 4) {
  1338.      if(set_trig_array(k++,value)) goto badarg;
  1339.      if ((value = strchr(value,'/')) == NULL) break;
  1340.      ++value;
  1341.      }
  1342.        functionpreloaded = 1; /* for old bifs  JCO 7/5/92 */
  1343.       return 1;
  1344.       }
  1345.  
  1346.    if (strcmp(variable,s_outside) == 0 ) {      /* outside=? */
  1347.       if(strcmp(value,s_iter)==0)
  1348.      outside = -1;
  1349.       else if(strcmp(value,s_real)==0)
  1350.      outside = -2;
  1351.       else if(strcmp(value,s_imag)==0)
  1352.      outside = -3;
  1353.       else if(strcmp(value,s_mult)==0)
  1354.      outside = -4;
  1355.       else if(strcmp(value,s_sum)==0)
  1356.      outside = -5;
  1357.       else if(strcmp(value,s_atan)==0)
  1358.      outside = -6;
  1359.  
  1360.       else if(numval == NONNUMERIC)
  1361.      goto badarg;
  1362.       else if(numval < -6 || numval > 255) goto badarg;
  1363.       else outside = numval;
  1364.       return 1;
  1365.       }
  1366.  
  1367.    if (strcmp(variable,s_bfdigits) == 0 ) {      /* bfdigits=? */
  1368.       if(numval == NONNUMERIC)
  1369.      goto badarg;
  1370.       else if(numval < 0 || numval > 2000) goto badarg;
  1371.       else bfdigits = numval;
  1372.       return 1;
  1373.       }
  1374.  
  1375.    if (strcmp(variable,s_maxiter) == 0) {       /* maxiter=? */
  1376.       if (floatval[0] < 2) goto badarg;
  1377.       maxit = (long)floatval[0];
  1378.       return 1;
  1379.       }
  1380.  
  1381.    if (strcmp(variable,s_iterincr) == 0)        /* iterincr=? */
  1382.       return 0;
  1383.  
  1384.    if (strcmp(variable,s_passes) == 0) {        /* passes=? */
  1385.       if ( charval != '1' && charval != '2' && charval != '3'
  1386.     && charval != 'g' && charval != 'b'
  1387.     && charval != 't')
  1388.      goto badarg;
  1389.       usr_stdcalcmode = charval;
  1390.       return 1;
  1391.       }
  1392.  
  1393.    if (strcmp(variable,s_cyclelimit) == 0 ) {   /* cyclelimit=? */
  1394.       if (numval <= 1 || numval > 256) goto badarg;
  1395.       initcyclelimit = numval;
  1396.       return 0;
  1397.       }
  1398.  
  1399.    if (strcmp(variable,s_makemig) == 0) {
  1400.        int xmult, ymult;
  1401.        if (totparms < 2) goto badarg;
  1402.        xmult = intval[0];
  1403.        ymult = intval[1];
  1404.        make_mig(xmult, ymult);
  1405. #ifndef WINFRACT
  1406.        exit(0);
  1407. #endif
  1408.        }
  1409.  
  1410.    if (strcmp(variable,s_cyclerange) == 0) {
  1411.       if (totparms < 2) intval[1] = 255;
  1412.       if (totparms < 1) intval[0] = 1;
  1413.       if (totparms != intparms
  1414.     || intval[0] < 0 || intval[1] > 255 || intval[0] > intval[1])
  1415.      goto badarg;
  1416.       rotate_lo = intval[0];
  1417.       rotate_hi = intval[1];
  1418.       return 0;
  1419.       }
  1420.  
  1421.    if (strcmp(variable,s_ranges) == 0) {
  1422.       int i,j,entries,prev;
  1423.       int tmpranges[128];
  1424.       if (totparms != intparms) goto badarg;
  1425.       entries = prev = i = 0;
  1426.       while (i < totparms) {
  1427.      if ((j = intval[i++]) < 0) { /* striping */
  1428.         if ((j = 0-j) < 1 || j >= 16384 || i >= totparms) goto badarg;
  1429.         tmpranges[entries++] = -1; /* {-1,width,limit} for striping */
  1430.         tmpranges[entries++] = j;
  1431.         j = intval[i++];
  1432.         }
  1433.      if (j < prev) goto badarg;
  1434.      tmpranges[entries++] = prev = j;
  1435.      }
  1436.       if (prev == 0) goto badarg;
  1437.       if ((ranges = (int far *)farmemalloc(2L*entries)) == NULL) {
  1438.      static FCODE msg[] = {"Insufficient memory for ranges="};
  1439.      stopmsg(1,msg);
  1440.      return(-1);
  1441.      }
  1442.       rangeslen = entries;
  1443.       for (i = 0; i < rangeslen; ++i)
  1444.      ranges[i] = tmpranges[i];
  1445.       return 1;
  1446.       }
  1447.  
  1448.    if (strcmp(variable,s_savename) == 0) {      /* savename=? */
  1449.       if (valuelen > (FILE_MAX_PATH-1)) goto badarg;
  1450.       if (first_init || mode == 2) {
  1451.          if(merge_pathnames(savename, value, mode) < 0)
  1452.             init_msg(0,variable,value,mode);
  1453.       }
  1454.       return 0;
  1455.       }
  1456.  
  1457.    if (strcmp(variable,s_tempdir) == 0) {      /* tempdir=? */
  1458.       if (valuelen > (FILE_MAX_DIR-1)) goto badarg;
  1459.       if(isadirectory(value) == 0) goto badarg;
  1460.       strcpy(tempdir,value);
  1461.       fix_dirname(tempdir);
  1462.       return 0;
  1463.       }
  1464.  
  1465.    if (strcmp(variable,s_workdir) == 0) {      /* workdir=? */
  1466.       if (valuelen > (FILE_MAX_DIR-1)) goto badarg;
  1467.       if(isadirectory(value) == 0) goto badarg;
  1468.       strcpy(workdir,value);
  1469.       fix_dirname(workdir);
  1470.       return 0;
  1471.       }
  1472.  
  1473.    if (strcmp(variable,s_exitmode) == 0) {      /* exitmode=? */
  1474.       sscanf(value,"%x",&numval);
  1475.       exitmode = (BYTE)numval;
  1476.       return 0;
  1477.       }
  1478.  
  1479.    if (strcmp(variable,s_textcolors) == 0) {
  1480.       parse_textcolors(value);
  1481.       return 0;
  1482.       }
  1483.  
  1484.    if (strcmp(variable,s_potential) == 0) {     /* potential=? */
  1485.       k = 0;
  1486.       while (k < 3 && *value) {
  1487.          if(k==1)
  1488.         potparam[k] = atof(value);
  1489.      else
  1490.         potparam[k] = atoi(value);
  1491.      k++;
  1492.        if ((value = strchr(value,'/')) == NULL) k = 99;
  1493.      ++value;
  1494.      }
  1495.       pot16bit = 0;
  1496.       if (k < 99) {
  1497.      if (strcmp(value,s_16bit)) goto badarg;
  1498.      pot16bit = 1;
  1499.      }
  1500.       return 1;
  1501.       }
  1502.  
  1503.    if (strcmp(variable,s_params) == 0) {        /* params=?,? */
  1504.       if (totparms != floatparms || totparms > MAXPARAMS)
  1505.      goto badarg;
  1506.       initparams = 1;
  1507.       for (k = 0; k < MAXPARAMS; ++k) 
  1508.          param[k] = (k < totparms) ? floatval[k] : 0.0;
  1509.       if(bf_math)
  1510.          for (k = 0; k < MAXPARAMS; k++)
  1511.             floattobf(bfparms[k],param[k]);
  1512.       return 1;
  1513.       }
  1514.  
  1515.    if (strcmp(variable,s_miim) == 0) {        /* miim=?[/?[/?[/?]]] */
  1516.       k = 0;
  1517.       do {
  1518.      if (isdigit(*value) ||
  1519.          *value == '.' || *value == '-' || *value == '+') {
  1520.         if (k >= 4)
  1521.            goto badarg;
  1522.         param[k++] = atof(value);
  1523.      }
  1524.      else if (strncmp(value, JIIMmethod[breadth_first], 
  1525.                  strlen(JIIMmethod[breadth_first])) == 0)
  1526.         major_method = breadth_first;
  1527.      else if (strncmp(value, JIIMmethod[depth_first], 
  1528.                  strlen(JIIMmethod[depth_first])) == 0)
  1529.         major_method = depth_first;
  1530.      else if (strncmp(value, JIIMmethod[random_walk], 
  1531.                  strlen(JIIMmethod[random_walk])) == 0)
  1532.         major_method = random_walk;
  1533. #ifdef RANDOM_RUN
  1534.      else if (strncmp(value, JIIMmethod[random_run], 
  1535.                  strlen(JIIMmethod[random_run])) == 0)
  1536.         major_method = random_run;
  1537. #endif
  1538.      else if (strncmp(value, JIIMleftright[left_first], 
  1539.                  strlen(JIIMleftright[left_first])) == 0)
  1540.         minor_method = left_first;
  1541.      else if (strncmp(value, JIIMleftright[right_first], 
  1542.                  strlen(JIIMleftright[right_first])) == 0)
  1543.         minor_method = right_first;
  1544.      else goto badarg;
  1545.      value = strchr(value, '/');
  1546.       } while (value++);
  1547.       return 1;
  1548.    }
  1549.  
  1550.    if (strcmp(variable,s_initorbit) == 0) {     /* initorbit=?,? */
  1551.       if(strcmp(value,s_pixel)==0)
  1552.      useinitorbit = 2;
  1553.       else {
  1554.      if (totparms != 2 || floatparms != 2) goto badarg;
  1555.      initorbit.x = floatval[0];
  1556.      initorbit.y = floatval[1];
  1557.      useinitorbit = 1;
  1558.      }
  1559.       return 1;
  1560.       }
  1561.  
  1562.    if (strcmp(variable,s_orbitname) == 0 ) {         /* orbitname=? */
  1563.       if(check_orbit_name(value))
  1564.          goto badarg;
  1565.       return 1;
  1566.       }
  1567.    if (strcmp(variable,s_3dmode) == 0 ) {         /* orbitname=? */
  1568.       int i,j;
  1569.       j = -1;
  1570.       for(i=0;i<4;i++)
  1571.          if(strcmp(value,juli3Doptions[i])==0)
  1572.             j = i; 
  1573.       if(j < 0)
  1574.          goto badarg;
  1575.       else
  1576.          juli3Dmode = j;
  1577.       return 1;
  1578.       }
  1579.  
  1580.    if (strcmp(variable,s_julibrot3d) == 0) {       /* julibrot3d=?,?,?,? */
  1581.       if (floatparms != totparms)
  1582.      goto badarg;
  1583.       if(totparms > 0)
  1584.          zdots = (int)floatval[0];
  1585.       if (totparms > 1)
  1586.          originfp = (float)floatval[1];
  1587.       if (totparms > 2)
  1588.          depthfp = (float)floatval[2];
  1589.       if (totparms > 3)
  1590.          heightfp = (float)floatval[3];
  1591.       if (totparms > 4)
  1592.          widthfp = (float)floatval[4];
  1593.       if (totparms > 5)
  1594.          distfp = (float)floatval[5];
  1595.       return 1;
  1596.       }
  1597.  
  1598.    if (strcmp(variable,s_julibroteyes) == 0) {       /* julibroteyes=?,?,?,? */
  1599.       if (floatparms != totparms || totparms != 1)
  1600.      goto badarg;
  1601.       eyesfp =  (float)floatval[0];
  1602.       return 1;
  1603.       }
  1604.  
  1605.    if (strcmp(variable,s_julibrotfromto) == 0) {       /* julibrotfromto=?,?,?,? */
  1606.       if (floatparms != totparms || totparms != 4)
  1607.      goto badarg;
  1608.       mxmaxfp = floatval[0];
  1609.       mxminfp = floatval[1];
  1610.       mymaxfp = floatval[2];
  1611.       myminfp = floatval[3];
  1612.       return 1;
  1613.       }
  1614.  
  1615.    if (strcmp(variable,s_corners) == 0) {       /* corners=?,?,?,? */
  1616.       int dec;
  1617.       if (fractype == CELLULAR)
  1618.           return 1; /* skip setting the corners */
  1619. #if 0 
  1620.       printf("totparms %d floatparms %d\n",totparms, floatparms);
  1621.       getch();
  1622. #endif
  1623.       if (  floatparms != totparms
  1624.             || (totparms != 0 && totparms != 4 && totparms != 6))
  1625.      goto badarg;
  1626.       usemag = 0;
  1627.       if (totparms == 0) return 0; /* turns corners mode on */
  1628.       initcorners = 1;
  1629.       /* good first approx, but dec could be too big */
  1630.       dec = get_max_curarg_len(floatvalstr,totparms) + 1;
  1631.       if((dec > DBL_DIG+1 || debugflag == 3200) && debugflag != 3400) {
  1632.          int old_bf_math;
  1633.  
  1634.          old_bf_math = bf_math;
  1635.          if(!bf_math || dec > decimals)
  1636.             init_bf_dec(dec);
  1637.          if(old_bf_math == 0) {
  1638.             int k;
  1639.             for (k = 0; k < MAXPARAMS; k++)
  1640.                floattobf(bfparms[k],param[k]);
  1641.          }
  1642.          
  1643.          /* xx3rd = xxmin = floatval[0]; */
  1644.          get_bf(bfxmin,floatvalstr[0]);
  1645.          get_bf(bfx3rd,floatvalstr[0]);
  1646.  
  1647.          /* xxmax = floatval[1]; */
  1648.          get_bf(bfxmax,floatvalstr[1]);
  1649.  
  1650.          /* yy3rd = yymin = floatval[2]; */
  1651.          get_bf(bfymin,floatvalstr[2]);
  1652.          get_bf(bfy3rd,floatvalstr[2]);
  1653.  
  1654.          /* yymax = floatval[3]; */
  1655.          get_bf(bfymax,floatvalstr[3]);
  1656.  
  1657.          if (totparms == 6) {
  1658.         /* xx3rd = floatval[4]; */
  1659.             get_bf(bfx3rd,floatvalstr[4]);
  1660.  
  1661.         /* yy3rd = floatval[5]; */
  1662.             get_bf(bfy3rd,floatvalstr[5]);
  1663.          }
  1664.  
  1665.          /* now that all the corners have been read in, get a more */
  1666.          /* accurate value for dec and do it all again             */
  1667.  
  1668.          dec = getprecbf_mag();
  1669.          if (dec < 0)
  1670.             goto badarg;     /* ie: Magnification is +-1.#INF */
  1671.  
  1672.          /* if(dec > decimals) */
  1673.             init_bf_dec(dec);
  1674.  
  1675.          /* now get parameters and corners all over again at new decimal setting */
  1676. #if 0
  1677.          for (k = 0; k < MAXPARAMS; k++)
  1678.             floattobf(bfparms[k],param[k]);
  1679.  
  1680.          /* xx3rd = xxmin = floatval[0]; */
  1681.          get_bf(bfxmin,floatvalstr[0]);
  1682.          get_bf(bfx3rd,floatvalstr[0]);
  1683.  
  1684.          /* xxmax = floatval[1]; */
  1685.          get_bf(bfxmax,floatvalstr[1]);
  1686.  
  1687.          /* yy3rd = yymin = floatval[2]; */
  1688.          get_bf(bfymin,floatvalstr[2]);
  1689.          get_bf(bfy3rd,floatvalstr[2]);
  1690.  
  1691.          /* yymax = floatval[3]; */
  1692.          get_bf(bfymax,floatvalstr[3]);
  1693.  
  1694.          if (totparms == 6) {
  1695.         /* xx3rd = floatval[4]; */
  1696.             get_bf(bfx3rd,floatvalstr[4]);
  1697.  
  1698.         /* yy3rd = floatval[5]; */
  1699.             get_bf(bfy3rd,floatvalstr[5]);
  1700.          }
  1701. #endif         
  1702.       }
  1703.       xx3rd = xxmin = floatval[0];
  1704.       xxmax =          floatval[1];
  1705.       yy3rd = yymin = floatval[2];
  1706.       yymax =          floatval[3];
  1707.  
  1708.       if (totparms == 6) {
  1709.      xx3rd =      floatval[4];
  1710.      yy3rd =      floatval[5];
  1711.      }
  1712.       return 1;
  1713.       }
  1714.  
  1715.    if (strcmp(variable,s_viewwindows) == 0) {  /* viewwindows=?,?,?,?,? */
  1716.       if (totparms > 5 || floatparms-intparms > 2 || intparms > 4)
  1717.      goto badarg;
  1718.       viewwindow = 1;
  1719.       viewreduction = (float)4.2;  /* reset default values */
  1720.       finalaspectratio = screenaspect;
  1721.       viewcrop = 1; /* yes */
  1722.       viewxdots = viewydots = 0;
  1723.  
  1724.       if((totparms > 0) && (floatval[0] > 0.001))
  1725.         viewreduction = (float)floatval[0];
  1726.       if((totparms > 1) && (floatval[1] > 0.001))
  1727.         finalaspectratio = (float)floatval[1];
  1728.       if((totparms > 2) && (yesnoval == 0))
  1729.         viewcrop = yesnoval;
  1730.       if((totparms > 3) && (intval[3] > 0))
  1731.         viewxdots = intval[3];
  1732.       if((totparms == 5) && (intval[4] > 0))
  1733.         viewydots = intval[4];
  1734.       return 1;
  1735.       }
  1736.  
  1737.    if (strcmp(variable,s_centermag) == 0) {    /* center-mag=?,?,?[,?,?,?] */
  1738.       int dec;
  1739.  
  1740.       if ( (totparms != floatparms)
  1741.         || (totparms != 0 && totparms < 3)
  1742.         || (totparms >= 3 && floatval[2] == 0.0))
  1743.      goto badarg;
  1744.       if (fractype == CELLULAR)
  1745.           return 1; /* skip setting the corners */
  1746.       usemag = 1;
  1747.       if (totparms == 0) return 0; /* turns center-mag mode on */
  1748.       initcorners = 1;
  1749.       /* dec = get_max_curarg_len(floatvalstr,totparms); */
  1750. #ifdef USE_LONG_DOUBLE
  1751.       sscanf(floatvalstr[2], "%Lf", &Magnification);
  1752. #else
  1753.       sscanf(floatvalstr[2], "%lf", &Magnification);
  1754. #endif
  1755.  
  1756.       /* I don't know if this is portable, but something needs to */
  1757.       /* be used in case compiler's LDBL_MAX is not big enough    */
  1758.       if (Magnification > LDBL_MAX || Magnification < -LDBL_MAX)
  1759.          goto badarg;     /* ie: Magnification is +-1.#INF */
  1760.  
  1761.       dec = getpower10(Magnification) + 4; /* 4 digits of padding sounds good */
  1762.  
  1763.       if((dec <= DBL_DIG+1 && debugflag != 3200) || debugflag == 3400) { /* rough estimate that double is OK */
  1764.          Xctr = floatval[0];
  1765.          Yctr = floatval[1];
  1766.          /* Magnification = floatval[2]; */  /* already done above */
  1767.          Xmagfactor = 1;
  1768.          Rotation = 0;
  1769.          Skew = 0;
  1770.          if (floatparms > 3)
  1771.             Xmagfactor = floatval[3];
  1772.          if (Xmagfactor == 0)
  1773.             Xmagfactor = 1;
  1774.          if (floatparms > 4)
  1775.             Rotation = floatval[4];
  1776.          if (floatparms > 5)
  1777.             Skew = floatval[5];
  1778.          /* calculate bounds */
  1779.          cvtcorners(Xctr, Yctr, Magnification, Xmagfactor, Rotation, Skew);
  1780.          return 1;
  1781.       }
  1782.       else { /* use arbitrary precision */
  1783.          int old_bf_math;
  1784.          int saved;
  1785.          initcorners = 1;
  1786.          old_bf_math = bf_math;
  1787.          if(!bf_math || dec > decimals)
  1788.             init_bf_dec(dec);
  1789.          if(old_bf_math == 0) {
  1790.             int k;
  1791.             for (k = 0; k < MAXPARAMS; k++)
  1792.                floattobf(bfparms[k],param[k]);
  1793.          }
  1794.          usemag = 1;
  1795.          saved = save_stack();
  1796.          bXctr            = alloc_stack(bflength+2);
  1797.          bYctr            = alloc_stack(bflength+2);
  1798.          /* Xctr = floatval[0]; */
  1799.          get_bf(bXctr,floatvalstr[0]);
  1800.          /* Yctr = floatval[1]; */
  1801.          get_bf(bYctr,floatvalstr[1]);
  1802.          /* Magnification = floatval[2]; */  /* already done above */
  1803.          Xmagfactor = 1;
  1804.          Rotation = 0;
  1805.          Skew = 0;
  1806.          if (floatparms > 3)
  1807.             Xmagfactor = floatval[3];
  1808.          if (Xmagfactor == 0)
  1809.             Xmagfactor = 1;
  1810.          if (floatparms > 4)
  1811.             Rotation = floatval[4];
  1812.          if (floatparms > 5)
  1813.             Skew = floatval[5];
  1814.          /* calculate bounds */
  1815.          cvtcornersbf(bXctr, bYctr, Magnification, Xmagfactor, Rotation, Skew);
  1816.          bfcornerstofloat();
  1817.          restore_stack(saved);
  1818.          return 1;
  1819.       }
  1820.    }
  1821.  
  1822.    if (strcmp(variable,s_aspectdrift) == 0 ) {  /* aspectdrift=? */
  1823.       if(floatparms != 1 || floatval[0] < 0)
  1824.      goto badarg;
  1825.       aspectdrift = (float)floatval[0];
  1826.       return 1;
  1827.       }
  1828.  
  1829.    if (strcmp(variable,s_invert) == 0) {        /* invert=?,?,? */
  1830.       if (totparms != floatparms || (totparms != 1 && totparms != 3))
  1831.      goto badarg;
  1832.       invert = ((inversion[0] = floatval[0]) != 0.0) ? totparms : 0;
  1833.       if (totparms == 3) {
  1834.      inversion[1] = floatval[1];
  1835.      inversion[2] = floatval[2];
  1836.      }
  1837.       return 1;
  1838.       }
  1839.  
  1840.    if (strcmp(variable,s_olddemmcolors) == 0 ) {     /* olddemmcolors=?   */
  1841.       if (yesnoval < 0) goto badarg;
  1842.       old_demm_colors = yesnoval;
  1843.       return 0;
  1844.       }
  1845.  
  1846.    if (strcmp(variable,s_askvideo) == 0 ) {     /* askvideo=?   */
  1847.       if (yesnoval < 0) goto badarg;
  1848.       askvideo = yesnoval;
  1849.       return 0;
  1850.       }
  1851.  
  1852.    if (strcmp(variable,s_ramvideo) == 0 )       /* ramvideo=?   */
  1853.       return 0; /* just ignore and return, for old time's sake */
  1854.  
  1855.    if (strcmp(variable,s_float) == 0 ) {        /* float=? */
  1856.       if (yesnoval < 0) goto badarg;
  1857.       usr_floatflag = (char)yesnoval;
  1858.       return 3;
  1859.       }
  1860.  
  1861.    if (strcmp(variable,s_biomorph) == 0 ) {     /* biomorph=? */
  1862.       usr_biomorph = numval;
  1863.       return 1;
  1864.       }
  1865.  
  1866.    if (strcmp(variable,s_orbitsave) == 0 ) {     /* orbitsave=? */
  1867.       if (yesnoval < 0) goto badarg;
  1868.       orbitsave = yesnoval;
  1869.       return 1;
  1870.       }
  1871.  
  1872.    if (strcmp(variable,s_bailout) == 0 ) {      /* bailout=? */
  1873.       if (floatval[0] < 1 || floatval[0] > 2100000000L) goto badarg;
  1874.       bailout = (long)floatval[0];
  1875.       return 1;
  1876.       }
  1877.  
  1878.    if (strcmp(variable,s_bailoutest) == 0 ) {   /* bailoutest=? */
  1879.       if     (strcmp(value,s_mod )==0) bailoutest = Mod;
  1880.       else if(strcmp(value,s_real)==0) bailoutest = Real;
  1881.       else if(strcmp(value,s_imag)==0) bailoutest = Imag;
  1882.       else if(strcmp(value,s_or  )==0) bailoutest = Or;
  1883.       else if(strcmp(value,s_and )==0) bailoutest = And;
  1884.       else goto badarg;
  1885.       setbailoutformula(bailoutest);
  1886.       return 1;
  1887.       }
  1888.  
  1889.    if (strcmp(variable,s_symmetry) == 0 ) {     /* symmetry=? */
  1890.       if     (strcmp(value,s_xaxis )==0) forcesymmetry = XAXIS;
  1891.       else if(strcmp(value,s_yaxis )==0) forcesymmetry = YAXIS;
  1892.       else if(strcmp(value,s_xyaxis)==0) forcesymmetry = XYAXIS;
  1893.       else if(strcmp(value,s_origin)==0) forcesymmetry = ORIGIN;
  1894.       else if(strcmp(value,s_pi    )==0) forcesymmetry = PI_SYM;
  1895.       else if(strcmp(value,s_none  )==0) forcesymmetry = NOSYM;
  1896.       else goto badarg;
  1897.       return 1;
  1898.       }
  1899.  
  1900.    if (strcmp(variable,s_printer) == 0 ) {      /* printer=? */
  1901.       if (parse_printer(value) < 0) goto badarg;
  1902.       return 0;
  1903.       }
  1904.  
  1905.    if (strcmp(variable,s_printfile) == 0) {     /* printfile=? */
  1906.       int existdir;
  1907.       if (valuelen > (FILE_MAX_PATH-1)) goto badarg;
  1908.       if((existdir=merge_pathnames(PrintName, value, mode))==0)
  1909.          Print_To_File = 1;
  1910.       else if (existdir < 0)
  1911.          init_msg(0,variable,value,mode);
  1912.       return 0;
  1913.       }
  1914.    if(strcmp(variable,s_rleps) == 0) {
  1915.       Printer_Compress = yesnoval;
  1916.       return(0);
  1917.       }
  1918.    if(strcmp(variable,s_colorps) == 0) {
  1919.       ColorPS = yesnoval;
  1920.       return(0);
  1921.       }
  1922.  
  1923.    if (strcmp(variable,s_epsf) == 0) {          /* EPS type? SWT */
  1924.       Print_To_File = 1;
  1925.       EPSFileType = numval;
  1926.       Printer_Type = 5;
  1927.       if (strcmp(PrintName,s_fract001prn)==0)
  1928.      strcpy(PrintName,"fract001.eps");
  1929.       return 0;
  1930.       }
  1931.  
  1932.    if (strcmp(variable,s_title) == 0) {         /* Printer title block? SWT */
  1933.       if (yesnoval < 0) goto badarg;
  1934.       Printer_Titleblock = yesnoval;
  1935.       return 0;
  1936.       }
  1937.  
  1938.    if (strcmp(variable,s_translate) == 0) {     /* Translate color? SWT */
  1939.       Printer_ColorXlat=0;
  1940.       if (charval == 'y')
  1941.      Printer_ColorXlat=1;
  1942.       else if (numval > 1 || numval < -1)
  1943.      Printer_ColorXlat=numval;
  1944.       return 0;
  1945.       }
  1946.  
  1947.    if (strcmp(variable,s_plotstyle) == 0) {     /* plot style? SWT */
  1948.       Printer_SStyle = numval;
  1949.       return 0;
  1950.       }
  1951.  
  1952.    if (strcmp(variable,s_halftone) == 0) {      /* New halftoning? SWT */
  1953.       if (totparms != intparms) goto badarg;
  1954.       Printer_SetScreen=1;
  1955.       if ((totparms >  0) && ( intval[ 0] >= 0))
  1956.                       Printer_SFrequency = intval[ 0];
  1957.       if ((totparms >  1) && ( intval[ 1] >= 0))
  1958.                       Printer_SAngle     = intval[ 1];
  1959.       if ((totparms >  2) && ( intval[ 2] >= 0))
  1960.                       Printer_SStyle     = intval[ 2];
  1961.       if ((totparms >  3) && ( intval[ 3] >= 0))
  1962.                       Printer_RFrequency = intval[ 3];
  1963.       if ((totparms >  4) && ( intval[ 4] >= 0))
  1964.                       Printer_RAngle     = intval[ 4];
  1965.       if ((totparms >  5) && ( intval[ 5] >= 0))
  1966.                       Printer_RStyle     = intval[ 5];
  1967.       if ((totparms >  6) && ( intval[ 6] >= 0))
  1968.                       Printer_GFrequency = intval[ 6];
  1969.       if ((totparms >  7) && ( intval[ 7] >= 0))
  1970.                       Printer_GAngle     = intval[ 7];
  1971.       if ((totparms >  8) && ( intval[ 8] >= 0))
  1972.                       Printer_GStyle     = intval[ 8];
  1973.       if ((totparms >  9) && ( intval[ 9] >= 0))
  1974.                       Printer_BFrequency = intval[ 9];
  1975.       if ((totparms > 10) && ( intval[10] >= 0))
  1976.                       Printer_BAngle     = intval[10];
  1977.       if ((totparms > 11) && ( intval[11] >= 0))
  1978.                       Printer_BStyle     = intval[11];
  1979.       return 0;
  1980.       }
  1981.  
  1982.    if (strcmp(variable,s_linefeed) == 0) {      /* Use LF for printer */
  1983.       if      (strcmp(value,s_cr)   == 0) Printer_CRLF = 1;
  1984.       else if (strcmp(value,s_lf)   == 0) Printer_CRLF = 2;
  1985.       else if (strcmp(value,s_crlf) == 0) Printer_CRLF = 0;
  1986.       else goto badarg;
  1987.       return 0;
  1988.       }
  1989.  
  1990.    if (strcmp(variable,s_comport) == 0 ) {      /* Set the COM parameters */
  1991.       if ((value=strchr(value,'/')) == NULL) goto badarg;
  1992.       switch (atoi(++value)) {
  1993.      case 110:  l = 0;   break;
  1994.      case 150:  l = 32;  break;
  1995.      case 300:  l = 64;  break;
  1996.      case 600:  l = 96;  break;
  1997.      case 1200: l = 128; break;
  1998.      case 2400: l = 160; break;
  1999.      case 4800: l = 192; break;
  2000.      case 9600:
  2001.      default:   l = 224; break;
  2002.      }
  2003.       if ((value=strchr(value,'/')) == NULL) goto badarg;
  2004.       for (k=0; k < (int)strlen(value); k++) {
  2005.      switch (value[k]) {
  2006.         case '7':  l |= 2;  break;
  2007.         case '8':  l |= 3;  break;
  2008.         case 'o':  l |= 8;  break;
  2009.         case 'e':  l |= 24; break;
  2010.         case '2':  l |= 4;  break;
  2011.         }
  2012.      }
  2013. #ifndef XFRACT
  2014. #ifndef WINFRACT
  2015.       _bios_serialcom(0,numval-1,l);
  2016. #endif
  2017. #endif
  2018.       return 0;
  2019.       }
  2020.  
  2021.    if (strcmp(variable,s_sound) == 0 ) {        /* sound=? */
  2022.       soundflag = 0;
  2023.       if (strncmp(value,"ye",2) == 0) {
  2024.      soundflag = -1;
  2025.      return(0);
  2026.      }
  2027.       if (charval == 'x')
  2028.      soundflag = 1;
  2029.       if (charval == 'y')
  2030.      soundflag = 2;
  2031.       if (charval == 'z')
  2032.      soundflag = 3;
  2033.       return 0;
  2034.       }
  2035.  
  2036.    if (strcmp(variable,s_hertz) == 0) {         /* Hertz=? */
  2037.       if (numval < 200 || numval > 10000) goto badarg;
  2038.       basehertz = numval;
  2039.       return 0;
  2040.       }
  2041.  
  2042.    if (strcmp(variable,s_periodicity) == 0 ) {  /* periodicity=? */
  2043.       usr_periodicitycheck=1;
  2044.       if ((charval == 'n') || (numval == 0))
  2045.      usr_periodicitycheck=0;
  2046.       else if (charval == 'y')
  2047.      usr_periodicitycheck=1;
  2048.       else if (charval == 's')   /* 's' for 'show' */
  2049.      usr_periodicitycheck= -1;
  2050.       else if(numval == NONNUMERIC)
  2051.      goto badarg;
  2052.       else if(numval != 0)
  2053.      usr_periodicitycheck=numval;
  2054.       return 1;
  2055.       }
  2056.  
  2057.    if (strcmp(variable,s_logmap) == 0 ) {       /* logmap=? */
  2058.       if (charval == 'y')
  2059.      LogFlag = 1;                /* palette is logarithmic */
  2060.       else if (charval == 'n')
  2061.      LogFlag = 0;
  2062.       else if (charval == 'o')
  2063.      LogFlag = -1;                /* old log palette */
  2064.       else
  2065.      LogFlag = numval;
  2066.       return 1;
  2067.       }
  2068.  
  2069.    if (strcmp(variable,s_debugflag) == 0
  2070.      || strcmp(variable,s_debug) == 0) {        /* internal use only */
  2071.       debugflag = numval;
  2072.       timerflag = debugflag & 1;        /* separate timer flag */
  2073.       debugflag -= timerflag;
  2074.       return 0;
  2075.       }
  2076.  
  2077.    if (strcmp(variable,s_rseed) == 0) {
  2078.       rseed = numval;
  2079.       rflag = 1;
  2080.       return 1;
  2081.       }
  2082.  
  2083.    if (strcmp(variable,s_orbitdelay) == 0) {
  2084.       orbit_delay = numval;
  2085.       return 0;
  2086.       }
  2087.  
  2088.    if (strcmp(variable,s_showdot) == 0) {
  2089.       showdot=numval;
  2090.       if(showdot<0)
  2091.          showdot=0;
  2092.       return 0;
  2093.       }
  2094.  
  2095.    if (strcmp(variable,s_decomp) == 0) {
  2096.       if (totparms != intparms || totparms < 1) goto badarg;
  2097.       decomp[0] = intval[0];
  2098.       decomp[1] = 0;
  2099.       if (totparms > 1) /* backward compatibility */
  2100.      bailout = decomp[1] = intval[1];
  2101.       return 1;
  2102.       }
  2103.  
  2104.    if (strcmp(variable,s_distest) == 0) {
  2105.       if (totparms != intparms || totparms < 1) goto badarg;
  2106.       usr_distest = intval[0];
  2107.       distestwidth = 71;
  2108.       if (totparms > 1)
  2109.      distestwidth = intval[1];
  2110.       if(totparms > 3 && intval[2] > 0 && intval[3] > 0) {
  2111.          pseudox = intval[2];
  2112.          pseudoy = intval[3];
  2113.       }
  2114.       else
  2115.      pseudox = pseudoy = 0;
  2116.       return 1;
  2117.       }
  2118.  
  2119.    if (strcmp(variable,s_formulafile) == 0) {   /* formulafile=? */
  2120.       if (valuelen > (FILE_MAX_PATH-1)) goto badarg;
  2121.       if(merge_pathnames(FormFileName, value, mode)<0)
  2122.          init_msg(0,variable,value,mode);
  2123.       return 1;
  2124.       }
  2125.  
  2126.    if (strcmp(variable,s_formulaname) == 0) {   /* formulaname=? */
  2127.       if (valuelen > ITEMNAMELEN) goto badarg;
  2128.       strcpy(FormName,value);
  2129.       return 1;
  2130.       }
  2131.  
  2132.    if (strcmp(variable,s_lfile) == 0) {    /* lfile=? */
  2133.       if (valuelen > (FILE_MAX_PATH-1)) goto badarg;
  2134.       if(merge_pathnames(LFileName, value, mode)<0)
  2135.          init_msg(0,variable,value,mode);
  2136.       return 1;
  2137.       }
  2138.  
  2139.    if (strcmp(variable,s_lname) == 0) {
  2140.       if (valuelen > ITEMNAMELEN) goto badarg;
  2141.       strcpy(LName,value);
  2142.       return 1;
  2143.       }
  2144.  
  2145.    if (strcmp(variable,s_ifsfile) == 0) {    /* ifsfile=?? */ 
  2146.       int existdir;
  2147.       if (valuelen > (FILE_MAX_PATH-1)) goto badarg;
  2148.       if((existdir=merge_pathnames(IFSFileName, value, mode))==0)
  2149.          reset_ifs_defn();
  2150.       else if(existdir < 0)
  2151.          init_msg(0,variable,value,mode);
  2152.       return 1;
  2153.       }
  2154.  
  2155.  
  2156.    if (strcmp(variable,s_ifs) == 0
  2157.      || strcmp(variable,s_ifs3d) == 0) {        /* ifs3d for old time's sake */
  2158.       if (valuelen > ITEMNAMELEN) goto badarg;
  2159.       strcpy(IFSName,value);
  2160.       reset_ifs_defn();
  2161.       return 1;
  2162.       }
  2163.  
  2164.    if (strcmp(variable,s_parmfile) == 0) {   /* parmfile=? */ 
  2165.       if (valuelen > (FILE_MAX_PATH-1)) goto badarg;
  2166.       if(merge_pathnames(CommandFile, value, mode)<0)
  2167.          init_msg(0,variable,value,mode);
  2168.       return 1;
  2169.       }
  2170.  
  2171.    if (strcmp(variable,s_stereo) == 0) {        /* stereo=? */
  2172.       if ((numval<0) || (numval>3)) goto badarg;
  2173.       glassestype = numval;
  2174.       return 3;
  2175.       }
  2176.  
  2177.    if (strcmp(variable,s_rotation) == 0) {      /* rotation=?/?/? */
  2178.       if (totparms != 3 || intparms != 3) goto badarg;
  2179.       XROT = intval[0];
  2180.       YROT = intval[1];
  2181.       ZROT = intval[2];
  2182.       return 3;
  2183.       }
  2184.  
  2185.    if (strcmp(variable,s_perspective) == 0) {   /* perspective=? */
  2186.       if (numval == NONNUMERIC) goto badarg;
  2187.       ZVIEWER = numval;
  2188.       return 3;
  2189.       }
  2190.  
  2191.    if (strcmp(variable,s_xyshift) == 0) {       /* xyshift=?/?  */
  2192.       if (totparms != 2 || intparms != 2) goto badarg;
  2193.       XSHIFT = intval[0];
  2194.       YSHIFT = intval[1];
  2195.       return 3;
  2196.       }
  2197.  
  2198.    if (strcmp(variable,s_interocular) == 0) {   /* interocular=? */
  2199.       eyeseparation = numval;
  2200.       return 3;
  2201.       }
  2202.  
  2203.    if (strcmp(variable,s_converge) == 0) {      /* converg=? */
  2204.       xadjust = numval;
  2205.       return 3;
  2206.       }
  2207.  
  2208.    if (strcmp(variable,s_crop) == 0) {          /* crop=? */
  2209.       if (totparms != 4 || intparms != 4
  2210.     || intval[0] < 0 || intval[0] > 100
  2211.     || intval[1] < 0 || intval[1] > 100
  2212.     || intval[2] < 0 || intval[2] > 100
  2213.     || intval[3] < 0 || intval[3] > 100)
  2214.       goto badarg;
  2215.       red_crop_left   = intval[0];
  2216.       red_crop_right  = intval[1];
  2217.       blue_crop_left  = intval[2];
  2218.       blue_crop_right = intval[3];
  2219.       return 3;
  2220.       }
  2221.  
  2222.    if (strcmp(variable,s_bright) == 0) {        /* bright=? */
  2223.       if (totparms != 2 || intparms != 2) goto badarg;
  2224.       red_bright  = intval[0];
  2225.       blue_bright = intval[1];
  2226.       return 3;
  2227.       }
  2228.  
  2229.    if (strcmp(variable,s_xyadjust) == 0) {      /* trans=? */
  2230.       if (totparms != 2 || intparms != 2) goto badarg;
  2231.       xtrans = intval[0];
  2232.       ytrans = intval[1];
  2233.       return 3;
  2234.       }
  2235.  
  2236.    if (strcmp(variable,s_3d) == 0) {            /* 3d=?/?/..    */
  2237.       if(strcmp(value,s_overlay)==0) {
  2238.          yesnoval=1;
  2239.          if(calc_status > -1) /* if no image, treat same as 3D=yes */
  2240.             overlay3d=1;
  2241.       }      
  2242.       else if (yesnoval < 0) goto badarg;
  2243.       display3d = yesnoval;
  2244.       initvars_3d();
  2245.       return (display3d) ? 6 : 2;
  2246.       }
  2247.  
  2248.    if (strcmp(variable,s_sphere) == 0 ) {       /* sphere=? */
  2249.       if (yesnoval < 0) goto badarg;
  2250.       SPHERE = yesnoval;
  2251.       return 2;
  2252.       }
  2253.  
  2254.    if (strcmp(variable,s_scalexyz) == 0) {      /* scalexyz=?/?/? */
  2255.       if (totparms < 2 || intparms != totparms) goto badarg;
  2256.       XSCALE = intval[0];
  2257.       YSCALE = intval[1];
  2258.       if (totparms > 2) ROUGH = intval[2];
  2259.       return 2;
  2260.       }
  2261.  
  2262.    /* "rough" is really scale z, but we add it here for convenience */
  2263.    if (strcmp(variable,s_roughness) == 0) {     /* roughness=?  */
  2264.       ROUGH = numval;
  2265.       return 2;
  2266.       }
  2267.  
  2268.    if (strcmp(variable,s_waterline) == 0) {     /* waterline=?  */
  2269.       if (numval<0) goto badarg;
  2270.       WATERLINE = numval;
  2271.       return 2;
  2272.       }
  2273.  
  2274.    if (strcmp(variable,s_filltype) == 0) {      /* filltype=?   */
  2275.       if (numval < -1 || numval > 6) goto badarg;
  2276.       FILLTYPE = numval;
  2277.       return 2;
  2278.       }
  2279.  
  2280.    if (strcmp(variable,s_lightsource) == 0) {   /* lightsource=?/?/? */
  2281.       if (totparms != 3 || intparms != 3) goto badarg;
  2282.       XLIGHT = intval[0];
  2283.       YLIGHT = intval[1];
  2284.       ZLIGHT = intval[2];
  2285.       return 2;
  2286.       }
  2287.  
  2288.    if (strcmp(variable,s_smoothing) == 0) {     /* smoothing=?  */
  2289.       if (numval<0) goto badarg;
  2290.       LIGHTAVG = numval;
  2291.       return 2;
  2292.       }
  2293.  
  2294.    if (strcmp(variable,s_latitude) == 0) {      /* latitude=?/? */
  2295.       if (totparms != 2 || intparms != 2) goto badarg;
  2296.       THETA1 = intval[0];
  2297.       THETA2 = intval[1];
  2298.       return 2;
  2299.       }
  2300.  
  2301.    if (strcmp(variable,s_longitude) == 0) {     /* longitude=?/? */
  2302.       if (totparms != 2 || intparms != 2) goto badarg;
  2303.       PHI1 = intval[0];
  2304.       PHI2 = intval[1];
  2305.       return 2;
  2306.       }
  2307.  
  2308.    if (strcmp(variable,s_radius) == 0) {        /* radius=? */
  2309.       if (numval < 0) goto badarg;
  2310.       RADIUS = numval;
  2311.       return 2;
  2312.       }
  2313.  
  2314.    if (strcmp(variable,s_transparent) == 0) {   /* transparent? */
  2315.       if (totparms != intparms || totparms < 1) goto badarg;
  2316.       transparent[1] = transparent[0] = intval[0];
  2317.       if (totparms > 1) transparent[1] = intval[1];
  2318.       return 2;
  2319.       }
  2320.  
  2321.    if (strcmp(variable,s_preview) == 0) {       /* preview? */
  2322.       if (yesnoval < 0) goto badarg;
  2323.       preview = (char)yesnoval;
  2324.       return 2;
  2325.       }
  2326.  
  2327.    if (strcmp(variable,s_showbox) == 0) {       /* showbox? */
  2328.       if (yesnoval < 0) goto badarg;
  2329.       showbox = (char)yesnoval;
  2330.       return 2;
  2331.       }
  2332.  
  2333.    if (strcmp(variable,s_coarse) == 0) {        /* coarse=? */
  2334.       if (numval < 3 || numval > 2000) goto badarg;
  2335.       previewfactor = numval;
  2336.       return 2;
  2337.       }
  2338.  
  2339.    if (strcmp(variable,s_randomize) == 0) {     /* RANDOMIZE=? */
  2340.       if (numval<0 || numval>7) goto badarg;
  2341.       RANDOMIZE = numval;
  2342.       return 2;
  2343.       }
  2344.  
  2345.    if (strcmp(variable,s_ambient) == 0) {       /* ambient=? */
  2346.       if (numval<0||numval>100) goto badarg;
  2347.       Ambient = numval;
  2348.       return 2;
  2349.       }
  2350.  
  2351.    if (strcmp(variable,s_haze) == 0) {          /* haze=? */
  2352.       if (numval<0||numval>100) goto badarg;
  2353.       haze = numval;
  2354.       return 2;
  2355.       }
  2356.  
  2357.    if (strcmp(variable,s_fullcolor) == 0) {     /* fullcolor=? */
  2358.       if (yesnoval < 0) goto badarg;
  2359.       Targa_Out = yesnoval;
  2360.       return 2;
  2361.       }
  2362.    if (strcmp(variable,s_targa_out) == 0) {     /* Targa Out? */
  2363.       if (yesnoval < 0) goto badarg;
  2364.       Targa_Out = yesnoval;
  2365.       return 2;
  2366.       }
  2367.  
  2368.    if (strcmp(variable,s_usegrayscale) == 0) {     /* usegrayscale? */
  2369.       if (yesnoval < 0) goto badarg;
  2370.       grayflag = (char)yesnoval;
  2371.       return 2;
  2372.       }
  2373.  
  2374.    if (strcmp(variable,s_monitorwidth) == 0) {     /* monitorwidth=? */
  2375.       if (totparms != 1 || floatparms != 1) goto badarg;
  2376.       AutoStereo_width  = floatval[0];
  2377.       return 2;
  2378.       }
  2379.  
  2380.    if (strcmp(variable,s_targa_overlay) == 0) {         /* Targa Overlay? */
  2381.       if (yesnoval < 0) goto badarg;
  2382.       Targa_Overlay = yesnoval;
  2383.       return 2;
  2384.       }
  2385.  
  2386.    if (strcmp(variable,s_background) == 0) {     /* background=?/? */
  2387.       if (totparms != 3 || intparms != 3) goto badarg;
  2388.                 for (i=0;i<3;i++)
  2389.                         if (intval[i] & 0xff)
  2390.                                 goto badarg;
  2391.       back_color[0] = (BYTE)intval[0];
  2392.       back_color[1] = (BYTE)intval[1];
  2393.       back_color[2] = (BYTE)intval[2];
  2394.       return 2;
  2395.       }
  2396.  
  2397.    if (strcmp(variable,s_lightname) == 0) {     /* lightname=?   */
  2398.       if (valuelen > (FILE_MAX_PATH-1)) goto badarg;
  2399.       if (first_init || mode == 2)
  2400.      strcpy(light_name,value);
  2401.       return 0;
  2402.       }
  2403.  
  2404.    if (strcmp(variable,s_ray) == 0) {           /* RAY=? */
  2405.       if (numval < 0 || numval > 6) goto badarg;
  2406.       RAY = numval;
  2407.       return 2;
  2408.       }
  2409.  
  2410.    if (strcmp(variable,s_brief) == 0) {         /* BRIEF? */
  2411.       if (yesnoval < 0) goto badarg;
  2412.       BRIEF = yesnoval;
  2413.       return 2;
  2414.       }
  2415.  
  2416.    if (strcmp(variable,s_release) == 0) {       /* release */
  2417.       if (numval < 0) goto badarg;
  2418.  
  2419.       save_release = numval;
  2420.       return 2;
  2421.       }
  2422.  
  2423.    if (strcmp(variable,s_curdir) == 0) {         /* curdir= */
  2424.       if (yesnoval < 0) goto badarg;
  2425.       checkcurdir = yesnoval;
  2426.       return 0;
  2427.       }
  2428.  
  2429. badarg:
  2430.    argerror(curarg);
  2431.    return(-1);
  2432.  
  2433. }
  2434.  
  2435. #ifdef _MSC_VER
  2436. #if (_MSC_VER >= 600)
  2437. #pragma optimize( "el", on )
  2438. #endif
  2439. #endif
  2440.  
  2441. /* Some routines broken out of above so compiler doesn't run out of heap: */
  2442.  
  2443. static void parse_textcolors(char *value)
  2444. {
  2445.    int i,j,k,hexval;
  2446.    if (strcmp(value,s_mono) == 0) {
  2447.       for (k = 0; k < sizeof(txtcolor); ++k)
  2448.      txtcolor[k] = BLACK*16+WHITE;
  2449.    /* C_HELP_CURLINK = C_PROMPT_INPUT = C_CHOICE_CURRENT = C_GENERAL_INPUT
  2450.              = C_AUTHDIV1 = C_AUTHDIV2 = WHITE*16+BLACK; */
  2451.       txtcolor[6] = txtcolor[12] = txtcolor[13] = txtcolor[14] = txtcolor[20]
  2452.           = txtcolor[27] = txtcolor[28] = WHITE*16+BLACK;
  2453.       /* C_TITLE = C_HELP_HDG = C_HELP_LINK = C_PROMPT_HI = C_CHOICE_SP_KEYIN
  2454.          = C_GENERAL_HI = C_DVID_HI = C_STOP_ERR
  2455.          = C_STOP_INFO = BLACK*16+L_WHITE; */
  2456.       txtcolor[0] = txtcolor[2] = txtcolor[5] = txtcolor[11] = txtcolor[16]
  2457.           = txtcolor[17] = txtcolor[22] = txtcolor[24]
  2458.           = txtcolor[25] = BLACK*16+L_WHITE;
  2459.       }
  2460.    else {
  2461.       k = 0;
  2462.       while ( k < sizeof(txtcolor)) {
  2463.      if (*value == 0) break;
  2464.      if (*value != '/') {
  2465.         sscanf(value,"%x",&hexval);
  2466.         i = (hexval / 16) & 7;
  2467.         j = hexval & 15;
  2468.         if (i == j || (i == 0 && j == 8)) /* force contrast */
  2469.            j = 15;
  2470.         txtcolor[k] = (BYTE)(i * 16 + j);
  2471.         if ((value = strchr(value,'/')) == NULL) break;
  2472.         }
  2473.      ++value;
  2474.      ++k;
  2475.      }
  2476.       }
  2477. }
  2478.  
  2479. static int parse_colors(char *value)
  2480. {
  2481.    int i,j,k;
  2482.    if (*value == '@') {
  2483.       if(merge_pathnames(MAP_name,&value[1],3)<0)
  2484.          init_msg(0,"",&value[1],3);
  2485.       if (strlen(value) > FILE_MAX_PATH || ValidateLuts(MAP_name) != 0) 
  2486.          goto badcolor;
  2487.       if (display3d) {
  2488.         mapset = 1;
  2489.         }
  2490.       else {
  2491.         if(merge_pathnames(colorfile,&value[1],3)<0)
  2492.           init_msg(0,"",&value[1],3);
  2493.         colorstate = 2;
  2494.         }
  2495.       }
  2496.    else {
  2497.       int smooth;
  2498.       i = smooth = 0;
  2499.       while (*value) {
  2500.      if (i >= 256) goto badcolor;
  2501.      if (*value == '<') {
  2502.         if (i == 0 || smooth
  2503.           || (smooth = atoi(value+1)) < 2
  2504.           || (value = strchr(value,'>')) == NULL)
  2505.            goto badcolor;
  2506.         i += smooth;
  2507.         ++value;
  2508.         }
  2509.      else {
  2510.         for (j = 0; j < 3; ++j) {
  2511.            if ((k = *(value++)) < '0')  goto badcolor;
  2512.            else if (k <= '9')       k -= '0';
  2513.            else if (k < 'A')            goto badcolor;
  2514.            else if (k <= 'Z')       k -= ('A'-10);
  2515.            else if (k < '_' || k > 'z') goto badcolor;
  2516.            else            k -= ('_'-36);
  2517.            dacbox[i][j] = (BYTE)k;
  2518.            if (smooth) {
  2519.           int start,spread,cnum;
  2520.           start = i - (spread = smooth + 1);
  2521.           cnum = 0;
  2522.           if ((k - (int)dacbox[start][j]) == 0) {
  2523.              while (++cnum < spread)
  2524.             dacbox[start+cnum][j] = (BYTE)k;
  2525.              }
  2526.           else {
  2527.              while (++cnum < spread)
  2528.             dacbox[start+cnum][j] =
  2529.                (BYTE)(( cnum *dacbox[i][j]
  2530.                + (i-(start+cnum))*dacbox[start][j]
  2531.                + spread/2 )
  2532.                / spread);
  2533.              }
  2534.           }
  2535.            }
  2536.         smooth = 0;
  2537.         ++i;
  2538.         }
  2539.      }
  2540.       if (smooth) goto badcolor;
  2541.       while (i < 256)  { /* zap unset entries */
  2542.      dacbox[i][0] = dacbox[i][1] = dacbox[i][2] = 40;
  2543.      ++i;
  2544.      }
  2545.       colorstate = 1;
  2546.       }
  2547.    colorpreloaded = 1;
  2548.    memcpy(olddacbox,dacbox,256*3);
  2549.    return(0);
  2550. badcolor:
  2551.    return(-1);
  2552. }
  2553.  
  2554. static int parse_printer(char *value)
  2555. {
  2556.    int k;
  2557.    if (value[0]=='h' && value[1]=='p')
  2558.       Printer_Type=1;                 /* HP LaserJet           */
  2559.    if (value[0]=='i' && value[1]=='b')
  2560.       Printer_Type=2;                 /* IBM Graphics           */
  2561.    if (value[0]=='e' && value[1]=='p')
  2562.       Printer_Type=2;                 /* Epson (model?)           */
  2563.    if (value[0]=='c' && value[1]=='o')
  2564.       Printer_Type=3;                 /* Star (Epson-Comp?) color */
  2565.    if (value[0]=='p') {
  2566.       if (value[1]=='a')
  2567.      Printer_Type=4;             /* HP Paintjet (color)    */
  2568.       if ((value[1]=='o' || value[1]=='s')) {
  2569.      Printer_Type=5;             /* PostScript  SWT */
  2570.      if (value[2]=='h' || value[2]=='l')
  2571.         Printer_Type=6;
  2572.      }
  2573.       if (value[1]=='l')
  2574.      Printer_Type=7;             /* HP Plotter (semi-color) */
  2575.       }
  2576.    if (Printer_Type == 1)             /* assume low resolution */
  2577.       Printer_Resolution = 75;
  2578.    else
  2579.       Printer_Resolution = 60;
  2580.    if (EPSFileType > 0)              /* EPS save - force type 5 */
  2581.       Printer_Type = 5;
  2582.    if ((Printer_Type == 5) || (Printer_Type == 6))
  2583.       Printer_Resolution = 150;          /* PostScript def. res. */
  2584.    if ((value=strchr(value,'/')) != NULL) {
  2585.       if ((k=atoi(++value)) >= 0) Printer_Resolution=k;
  2586.       if ((value=strchr(value,'/')) != NULL) {
  2587.      if ((k=atoi(++value))> 0) LPTNumber = k;
  2588.      if (k < 0) {
  2589.         Print_To_File = 1;
  2590.         LPTNumber = 1;
  2591.         }
  2592.      }
  2593.       }
  2594.    return(0);
  2595. }
  2596.  
  2597.  
  2598.  
  2599. static void argerror(char *badarg)    /* oops. couldn't decode this */
  2600. {
  2601.    static FCODE argerrmsg1[]={"\
  2602. Oops. I couldn't understand the argument:\n  "};
  2603.    static FCODE argerrmsg2[]={"\n\n\
  2604. (see the Startup Help screens or documentation for a complete\n\
  2605.  argument list with descriptions)"};
  2606.    char msg[300];
  2607.    if (strlen(badarg) > 70) badarg[70] = 0;
  2608.    if (active_system == 0 /* DOS */
  2609.      && first_init)      /* & this is 1st call to cmdfiles */
  2610. #ifndef XFRACT
  2611.       sprintf(msg,"%Fs%s%Fs",(char far *)argerrmsg1,badarg,(char far *)argerrmsg2);
  2612.    else
  2613.       sprintf(msg,"%Fs%s",(char far *)argerrmsg1,badarg);
  2614. #else
  2615.       sprintf(msg,"%s%s%s",argerrmsg1,badarg,argerrmsg2);
  2616.    else
  2617.       sprintf(msg,"%s%s",argerrmsg1,badarg);
  2618. #endif
  2619.    stopmsg(0,msg);
  2620. }
  2621.  
  2622. void set_3d_defaults()
  2623. {
  2624.    ROUGH     = 30;
  2625.    WATERLINE = 0;
  2626.    ZVIEWER   = 0;
  2627.    XSHIFT    = 0;
  2628.    YSHIFT    = 0;
  2629.    xtrans    = 0;
  2630.    ytrans    = 0;
  2631.    LIGHTAVG  = 0;
  2632.    Ambient   = 20;
  2633.    RANDOMIZE = 0;
  2634.    haze      = 0;
  2635.    back_color[0] = 51; back_color[1] = 153; back_color[2] = 200;
  2636.    if(SPHERE) {
  2637.       PHI1    =  180;
  2638.       PHI2    =  0;
  2639.       THETA1    =  -90;
  2640.       THETA2    =  90;
  2641.       RADIUS    =  100;
  2642.       FILLTYPE    = 2;
  2643.       XLIGHT    = 1;
  2644.       YLIGHT    = 1;
  2645.       ZLIGHT    = 1;
  2646.       }
  2647.    else {
  2648.       XROT    = 60;
  2649.       YROT    = 30;
  2650.       ZROT    = 0;
  2651.       XSCALE    = 90;
  2652.       YSCALE    = 90;
  2653.       FILLTYPE    = 0;
  2654.       if (active_system != 0)
  2655.      FILLTYPE = 2;
  2656.       XLIGHT    = 1;
  2657.       YLIGHT    = -1;
  2658.       ZLIGHT    = 1;
  2659.       }
  2660. }
  2661.  
  2662. /* copy a big number from a string, up to slash */
  2663. static int get_bf(bf_t bf, char *curarg)
  2664. {
  2665.    char *s;
  2666.    s=strchr(curarg,'/');
  2667.    if(s)
  2668.       *s = 0;
  2669.    strtobf(bf,curarg);
  2670.    if(s)
  2671.       *s = '/';
  2672.    return(0);       
  2673. }
  2674.  
  2675. /* Get length of current args */
  2676. int get_curarg_len(char *curarg)
  2677. {
  2678.    int len;
  2679.    char *s;
  2680.    s=strchr(curarg,'/');
  2681.    if(s)
  2682.       *s = 0;
  2683.    len = strlen(curarg);
  2684.    if(s)
  2685.       *s = '/';
  2686.    return(len);       
  2687. }
  2688.  
  2689. /* Get max length of current args */
  2690. int get_max_curarg_len(char *floatvalstr[], int totparms)
  2691. {
  2692.    int i,tmp,max_str;
  2693.    max_str = 0;
  2694.    for(i=0;i<totparms;i++)
  2695.       if((tmp=get_curarg_len(floatvalstr[i])) > max_str)
  2696.          max_str = tmp;
  2697.    return(max_str);
  2698. }
  2699.  
  2700. /* mode = 0 command line @filename         */
  2701. /*        1 sstools.ini                   */
  2702. /*        2 <@> command after startup      */
  2703. /*        3 command line @filename/setname */
  2704. /* this is like stopmsg() but can be used in cmdfiles()      */
  2705. /* call with NULL for badfilename to get pause for getakey() */
  2706. int init_msg(int flags,char *cmdstr,char far *badfilename,int mode)
  2707. {
  2708.    static char far *modestr[4] =
  2709.        {s_commandline,s_sstoolsini,s_at_cmd,s_at_cmd};
  2710.    static FCODE diags[] = 
  2711.        {"Fractint found the following problems when parsing commands: "};
  2712.    char msg[256];
  2713.    char cmd[80];
  2714.    static int row = 1;
  2715.  
  2716.    if (initbatch == 1) { /* in batch mode */
  2717.       if(badfilename)
  2718.          /* uncomment next if wish to cause abort in batch mode for 
  2719.             errors in CMDFILES.C such as parsing SSTOOLS.INI */ 
  2720.          /* initbatch = 4; */ /* used to set errorlevel */
  2721.       return (-1);
  2722.    }
  2723.    strncpy(cmd,cmdstr,30);
  2724.    cmd[29] = 0;
  2725.    
  2726.    if(*cmd)
  2727.       strcat(cmd,"=");
  2728.    if(badfilename)
  2729. #ifndef XFRACT
  2730.       sprintf(msg,"Can't find %s%Fs, please check %Fs",cmd,badfilename,modestr[mode]);
  2731. #else
  2732.       sprintf(msg,"Can't find %s%s, please check %s",cmd,badfilename,modestr[mode]);
  2733. #endif
  2734.    if (active_system == 0 /* DOS */
  2735.      && first_init) {       /* & cmdfiles hasn't finished 1st try */
  2736.       if(row == 1 && badfilename) {
  2737.          setvideotext();
  2738.          putstring(0,0,15,diags);
  2739.       }
  2740.       if(badfilename)
  2741.          putstring(row++,0,7,msg);
  2742.       else if(row > 1){
  2743.          putstring(++row,0,15,s_escapetoabort);
  2744.          movecursor(row+1,0);
  2745.          /*
  2746.          if(getakeynohelp()==27)
  2747.             goodbye();
  2748.          */
  2749.          dopause(2);  /* defer getakeynohelp until after parseing */
  2750.       }   
  2751.    }   
  2752.    else if(badfilename)
  2753.       stopmsg(flags,msg);
  2754.    return(0);   
  2755. }
  2756.  
  2757. /* defer pause until after parsing so we know if in batch mode */
  2758. void dopause(int action)
  2759. {
  2760.    static unsigned char needpause = 0;
  2761.    switch(action)
  2762.    {
  2763.    case 0:
  2764.       if(initbatch == 0)
  2765.       {
  2766.          if(needpause == 1)
  2767.             getakey();
  2768.          else if (needpause == 2)
  2769.             if(getakeynohelp() == ESC)
  2770.                goodbye();
  2771.       }
  2772.       needpause = 0;      
  2773.       break;
  2774.    case 1:
  2775.    case 2:
  2776.       needpause = (char)action;
  2777.       break;
  2778.    default:
  2779.       break;         
  2780.    }
  2781. }
  2782.