~ubuntu-branches/ubuntu/trusty/xfractint/trusty

« back to all changes in this revision

Viewing changes to cmdfiles.c

  • Committer: Bazaar Package Importer
  • Author(s): Riku Voipio
  • Date: 2010-11-24 21:24:54 UTC
  • mfrom: (1.2.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20101124212454-a2vxdh9pk5p5lhlm
Tags: 20.4.10-1
* New upstream version
* enable autobuilding, Closes: #410674, #587959
* update watch file. Closes: #449889
* remove bashism from rules, Closes: #581474

Show diffs side-by-side

added added

removed removed

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