2
Command-line / Command-File Parser Routines
12
/* see Fractint.c for a description of the "include" hierarchy */
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 */
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 */
30
#define far_strncmp far_strnicmp
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);
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 */
73
int biomorph; /* flag for 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 */
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 */
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 */
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 */
141
BYTE exitmode = 3; /* video mode on exit */
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 */
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;
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 */
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 */
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";
221
char s_and[] = "and";
222
char s_mod[] = "mod";
223
char s_16bit[] = "16bit";
224
char s_387[] = "387";
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";
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";
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";
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";
457
static FCODE s_escapetoabort[] = "Press Escape to abort, any other key to continue";
458
char far s_pressanykeytocontinue[] = "press any key to continue";
461
cmdfiles(argc,argv) process the command-line arguments
462
it also processes the 'sstools.ini' file and any
463
indirect files ('fractint @myfile')
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)
472
char string[11]; /* space for "+x.xe-xxxx" */
475
#ifdef USE_LONG_DOUBLE
476
sprintf(string,"%+.1Le", x);
478
sprintf(string,"%+.1le", x);
486
int cmdfiles(int argc,char **argv)
490
char tempstring[101];
494
if (first_init) initvars_run(); /* once per run initialization */
495
initvars_restart(); /* <ins> key initialization */
496
initvars_fractal(); /* image initialization */
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 */
504
for (i = 1; i < argc; i++) { /* cycle through args */
506
/* Let the xfract code take a look at the argument */
507
if (unixarg(argc,argv,&i)) continue;
509
strcpy(curarg,argv[i]);
510
if (curarg[0] == ';') /* start of comments? */
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);
532
cmdarg(curarg,0); /* process simple command */
534
else if ((sptr = strchr(curarg,'/')) != NULL) { /* @filename/setname? */
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)
543
else { /* @filename */
544
if ((initfile = fopen(&curarg[1],"r")) == NULL)
550
if (first_init == 0) {
551
initmode = -1; /* don't set video when <ins> key used */
552
showfile = 1; /* nor startup image file */
555
init_msg(0,"",NULL,0); /* this causes getakey if init_msg called on runup */
561
sprintf(msg,"cmdfiles colorpreloaded %d showfile %d savedac %d",
562
colorpreloaded, showfile, savedac);
566
if(colorpreloaded && showfile==0) /* PAR reads a file and sets color */
567
dontreadcolor = 1; /* don't read colors from GIF */
569
dontreadcolor = 0; /* read colors from GIF */
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);
580
int load_commands(FILE *infile)
582
/* when called, file is open in binary mode, positioned at the */
583
/* '(' or '{' following the desired parameter set's name */
585
initcorners = initparams = 0; /* reset flags for type= */
586
ret = cmdfile(infile,2);
590
sprintf(msg,"load commands colorpreloaded %d showfile %d savedac %d",
591
colorpreloaded, showfile, savedac);
596
if(colorpreloaded && showfile==0) /* PAR reads a file and sets color */
597
dontreadcolor = 1; /* don't read colors from GIF */
599
dontreadcolor = 0; /* read colors from GIF */
604
static void initvars_run() /* once per run init */
607
init_rseed = (int)time(NULL);
609
if((p = getenv("TMP")) == NULL)
613
if(isadirectory(p) != 0)
616
fix_dirname(tempdir);
623
static void initvars_restart() /* <ins> key init */
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;
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 */
652
far_strcpy(LFileName,s_fractintl);
654
far_strcpy(CommandFile,s_fractintpar);
657
CommandComment[i][0] = 0;
658
far_strcpy(IFSFileName,s_fractintifs);
661
rflag = 0; /* not a fixed srand() seed */
663
strcpy(readname,DOTSLASH); /* initially current directory */
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 */
669
farmemfree(mapdacbox);
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 */
695
Print_To_File = 0; /* No print-to-file */
696
Printer_CRLF = 0; /* Assume CR+LF */
698
Print_To_File = 1; /* Print-to-file */
699
Printer_CRLF = 2; /* Assume LF */
700
Printer_Compress = 0; /* Assume NO PostScript compression */
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 */
711
static void initvars_fractal() /* init vars affecting calculation */
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 */
726
ismand = 1; /* default formula mand/jul toggle */
728
usr_floatflag = 0; /* turn off the float flag */
730
usr_floatflag = 1; /* turn on the float flag */
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 */
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 */
744
decomp[0] = decomp[1] = 0;
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 */
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);
760
farmemfree((char far *)ranges);
763
usemag = 1; /* use center-mag, not corners */
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 */
770
display3d = 0; /* 3D display is off */
771
overlay3d = 0; /* 3D overlay is off */
775
floatbailout = (int (near *)(void))fpMODbailout;
776
longbailout = (int (near *)(void))asmlMODbailout;
777
bignumbailout = (int (near *)(void))bnMODbailout;
778
bigfltbailout = (int (near *)(void))bfMODbailout;
780
functionpreloaded = 0; /* for old bifs JCO 7/5/92 */
791
neworbittype = JULIA;
794
basehertz = 440; /* basic hertz rate */
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 */
808
static void initvars_3d() /* init vars affecting 3d */
826
transparent[0] = transparent[1] = 0; /* no min/max transparency */
830
static void reset_ifs_defn()
833
farmemfree((char far *)ifs_defn);
839
static int cmdfile(FILE *handle,int mode)
840
/* mode = 0 command line @filename */
842
/* 2 <@> command after startup */
843
/* 3 command line @filename/setname */
845
/* note that cmdfile could be open as text OR as binary */
846
/* binary is used in @ command processing for reasonable speed note/point */
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);
859
if (mode == 2 || mode == 3) {
860
while ((i = getc(handle)) != '{' && i != EOF) { }
862
CommandComment[i][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;
872
initmode = 0; /* Skip credits if @file is used. */
874
far_memcpy(suffix,savesuffix,10000);
884
static int next_command(char *cmdbuf,int maxlen,
885
FILE *handle,char *linebuf,int *lineoffset,int mode)
890
lineptr = linebuf + *lineoffset;
892
while (*lineptr <= ' ' || *lineptr == ';') {
893
if (cmdlen) { /* space or ; marks end of command */
895
*lineoffset = lineptr - linebuf;
898
while (*lineptr && *lineptr <= ' ')
899
++lineptr; /* skip spaces and tabs */
900
if (*lineptr == ';' || *lineptr == 0) {
902
&& (mode == 2 || mode == 3)
903
&& (CommandComment[0][0] == 0 || CommandComment[1][0] == 0 ||
904
CommandComment[2][0] == 0 || CommandComment[3][0] == 0)) {
907
&& (*lineptr == ' ' || *lineptr == '\t')) { }
909
if ((int)strlen(lineptr) >= MAXCMT)
910
*(lineptr+MAXCMT-1) = 0;
912
if (CommandComment[i][0] == 0)
914
far_strcpy(CommandComment[i],lineptr);
919
if (next_line(handle,linebuf,mode) != 0)
920
return(-1); /* eof */
921
lineptr = linebuf; /* start new line */
924
if (*lineptr == '\\' /* continuation onto next line? */
925
&& *(lineptr+1) == 0) {
926
if (next_line(handle,linebuf,mode) != 0) {
927
argerror(cmdbuf); /* missing continuation */
931
while (*lineptr && *lineptr <= ' ')
932
++lineptr; /* skip white space @ start next line */
933
continue; /* loop to check end of line again */
935
cmdbuf[cmdlen] = *(lineptr++); /* copy character to command buffer */
936
if (++cmdlen >= maxlen) { /* command too long? */
943
static int next_line(FILE *handle,char *linebuf,int mode)
948
while (file_gets(linebuf,512,handle) >= 0) {
949
if (mode == 1 && linebuf[0] == '[') { /* check for [fractint] */
950
strncpy(tmpbuf,&linebuf[1],9);
953
toolssection = far_strncmp(tmpbuf,"fractint]",9);
954
continue; /* skip tools section heading */
956
if (toolssection == 0) return(0);
962
cmdarg(string,mode) processes a single command-line/command-file argument
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
972
/* following gets rid of "too big for optimization" warning */
974
#if (_MSC_VER >= 600)
975
#pragma optimize( "el", off )
979
int cmdarg(char *curarg,int mode) /* process a single argument */
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 */
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 */
999
double Xctr, Yctr, Xmagfactor, Rotation, Skew;
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 */
1017
if ((value = strchr(&curarg[1],'=')) != NULL) {
1018
if ((j = (value++) - curarg) > 1 && curarg[j-1] == ':')
1019
--j; /* treat := same as = */
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;
1033
numval = totparms = intparms = floatparms = 0;
1034
while (*argptr) { /* count and pre-parse parms */
1037
if ((argptr2 = strchr(argptr,'/')) == NULL) { /* find next '/' */
1038
argptr2 = argptr + strlen(argptr);
1042
if (totparms == 0) numval = NONNUMERIC;
1046
charval[totparms] = *argptr; /* first letter of value */
1047
if (charval[totparms] == 'n') yesnoval[totparms] = 0;
1048
if (charval[totparms] == 'y') yesnoval[totparms] = 1;
1051
if (sscanf(argptr,"%c%c",(char *)&j,&tmpc) > 0 /* NULL entry */
1052
&& ((char)j == '/' || (char)j == '=') && tmpc == '/') {
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;
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;
1067
else if (sscanf(argptr,"%lg%c",&ftemp,&tmpc) > 0 /* got a float */
1069
else if (sscanf(argptr,"%lf%c",&ftemp,&tmpc) > 0 /* got a float */
1073
if (totparms < 16) {floatval[totparms] = ftemp;floatvalstr[totparms]=argptr;}
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
1079
|| isabigfloat(argptr)) {
1081
floatval[totparms] = FLT_MAX;
1082
floatvalstr[totparms]=argptr;
1085
argptr = argptr2; /* on to the next */
1092
if (mode != 2 || debugflag==110) {
1093
/* these commands are allowed only at startup */
1095
if (far_strcmp(variable,s_batch) == 0 ) { /* batch=? */
1096
if (yesnoval[0] < 0) goto badarg;
1098
initmode = yesnoval[0]?0:-1; /* skip credits for batch mode */
1100
initbatch = yesnoval[0];
1103
if (far_strcmp(variable,"maxhistory") == 0) { /* maxhistory=? */
1104
if(numval == NONNUMERIC)
1106
else if(numval < 0 /* || numval > 1000 */) goto badarg;
1107
else maxhistory = numval;
1112
if (far_strcmp(variable,s_adapter) == 0 ) { /* adapter==? */
1114
char adapter_name[8]; /* entry lenth from VIDEO.ASM */
1117
adapter_ptr = &supervga_list;
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) {
1133
if (svga_type != 0) return 3;
1135
video_type = 5; /* assume video=vga */
1136
if (far_strcmp(value,s_egamono) == 0) {
1140
else if (far_strcmp(value,s_hgc) == 0) { /* video = hgc */
1144
else if (far_strcmp(value,s_ega) == 0) /* video = ega */
1146
else if (far_strcmp(value,s_cga) == 0) /* video = cga */
1148
else if (far_strcmp(value,s_mcga) == 0) /* video = mcga */
1150
else if (far_strcmp(value,s_vga) == 0) /* video = vga */
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 */
1163
if (far_strcmp(variable,s_textsafe) == 0 ) { /* textsafe==? */
1165
if (charval[0] == 'n') /* no */
1167
else if (charval[0] == 'y') /* yes */
1169
else if (charval[0] == 'b') /* bios */
1171
else if (charval[0] == 's') /* save */
1179
if (far_strcmp(variable,s_vesadetect) == 0) {
1180
if (yesnoval[0] < 0) goto badarg;
1181
vesa_detect = yesnoval[0];
1185
if (far_strcmp(variable,s_biospalette) == 0) {
1186
if (yesnoval[0] < 0) goto badarg;
1187
bios_palette = yesnoval[0];
1192
if (far_strcmp(variable,s_fpu) == 0) {
1193
if (far_strcmp(value,s_387) == 0) {
1204
if (far_strcmp(variable,s_exitnoask) == 0) {
1205
if (yesnoval[0] < 0) goto badarg;
1206
escape_exit = yesnoval[0];
1210
if (far_strcmp(variable,s_makedoc) == 0) {
1211
print_document(*value ? value : "fractint.doc", makedoc_msg_func, 0);
1216
if (far_strcmp(variable,s_makepar) == 0) {
1217
char *slash, *next=NULL;
1218
if(totparms < 1 || totparms > 2)
1220
if((slash = strchr(value,'/')) != NULL)
1226
strcpy(CommandFile,value);
1227
if(strchr(CommandFile,'.') == NULL)
1228
strcat(CommandFile,".par");
1229
if(strcmp(readname,DOTSLASH)==0)
1234
extract_filename(CommandName,readname);
1235
else if(*MAP_name != 0)
1236
extract_filename(CommandName,MAP_name);
1242
strncpy(CommandName,next,ITEMNAMELEN);
1243
CommandName[ITEMNAMELEN] = 0;
1245
*s_makepar = 0; /* used as a flag for makepar case */
1248
if(read_overlay() != 0)
1251
else if(*MAP_name != 0)
1253
s_makepar[1] = 0; /* second char is flag for map */
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);
1274
} /* end of commands allowed only at startup */
1276
if (far_strcmp(variable,s_reset) == 0) {
1279
/* PAR release unknown unless specified */
1280
if (numval>=0) save_release = numval;
1282
if (save_release == 0)
1283
save_release = 1730; /* before start of lyapunov wierdness */
1287
if (far_strcmp(variable,s_filename) == 0) { /* filename=? */
1289
if (charval[0] == '.' && value[1] != SLASHC) {
1290
if (valuelen > 4) goto badarg;
1293
strcat(gifmask,value);
1296
if (valuelen > (FILE_MAX_PATH-1)) goto badarg;
1297
if (mode == 2 && display3d == 0) /* can't do this in @ command */
1300
if((existdir=merge_pathnames(readname, value, mode))==0)
1302
else if(existdir < 0)
1303
init_msg(0,variable,value,mode);
1305
extract_filename(browsename,readname);
1309
if (far_strcmp(variable,s_video) == 0) { /* video=? */
1310
if (active_system == 0) {
1311
if ((k = check_vidmode_keyname(value)) == 0) goto badarg;
1313
for (i = 0; i < MAXVIDEOTABLE; ++i) {
1314
if (videotable[i].keynum == k) {
1319
if (initmode == -1) goto badarg;
1324
if (far_strcmp(variable,s_map) == 0 ) { /* map=, set default colors */
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);
1333
SetColorPaletteName(MAP_name);
1337
if (far_strcmp(variable,s_colors) == 0) { /* colors=, set current colors */
1338
if (parse_colors(value) < 0) goto badarg;
1342
if (far_strcmp(variable,s_recordcolors) == 0) { /* recordcolors= */
1343
if(*value != 'y' && *value != 'c' && *value != 'a')
1345
recordcolors = *value;
1349
if (far_strcmp(variable,s_maxlinelength) == 0) { /* maxlinelength= */
1350
if(numval < MINMAXLINELENGTH || numval > MAXMAXLINELENGTH)
1352
maxlinelength = numval;
1356
if (far_strcmp(variable,s_comment) == 0) { /* comment= */
1357
parse_comments(value);
1361
if (far_strcmp(variable,s_tplus) == 0) { /* Use the TARGA+ if found? */
1362
if (yesnoval[0] < 0) goto badarg;
1363
TPlusFlag = yesnoval[0];
1367
if (far_strcmp(variable,s_noninterlaced) == 0) {
1368
if (yesnoval[0] < 0) goto badarg;
1369
NonInterlaced = yesnoval[0];
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;
1382
if (far_strcmp(variable,s_pixelzoom) == 0) {
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);
1394
if (far_strcmp(variable,s_overwrite) == 0 ) { /* overwrite=? */
1395
if (yesnoval[0] < 0) goto badarg;
1396
overwrite = (char)yesnoval[0];
1400
if (far_strcmp(variable,s_gif87a) == 0 ) { /* gif87a=? */
1401
if (yesnoval[0] < 0) goto badarg;
1402
gif87a_flag = yesnoval[0];
1406
if (far_strcmp(variable,s_dither) == 0 ) { /* dither=? */
1407
if (yesnoval[0] < 0) goto badarg;
1408
dither_flag = yesnoval[0];
1412
if (far_strcmp(variable,s_savetime) == 0) { /* savetime=? */
1413
initsavetime = numval;
1417
if (far_strcmp(variable,s_autokey) == 0) { /* autokey=? */
1418
if (far_strcmp(value,s_record)==0)
1420
else if (far_strcmp(value,s_play)==0)
1427
if (far_strcmp(variable,s_autokeyname) == 0) { /* autokeyname=? */
1428
if(merge_pathnames(autoname, value,mode) < 0)
1429
init_msg(0,variable,value,mode);
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)
1439
for (k = 0; fractalspecific[k].name != NULL; k++)
1440
if (far_strcmp(value,fractalspecific[k].name) == 0)
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;
1450
if (initparams == 0)
1451
load_params(fractype);
1454
if (far_strcmp(variable,s_inside) == 0 ) { /* inside=? */
1455
if(far_strcmp(value,s_zmag)==0)
1457
else if(far_strcmp(value,s_bof60)==0)
1459
else if(far_strcmp(value,s_bof61)==0)
1461
else if(far_strncmp(value,s_epscross,3)==0)
1463
else if(far_strncmp(value,s_startrail,4)==0)
1465
else if(far_strncmp(value,s_period,3)==0)
1467
else if(far_strncmp(value,s_fmod,3)==0)
1469
else if(far_strncmp(value,s_atan,3)==0)
1471
else if(far_strcmp(value,s_maxiter)==0)
1473
else if(numval == NONNUMERIC)
1479
if (far_strcmp(variable,s_prox) == 0 ) { /* proximity=? */
1480
closeprox = floatval[0];
1483
if (far_strcmp(variable,s_fillcolor) == 0 ) { /* fillcolor */
1484
if(far_strcmp(value,s_normal)==0)
1486
else if(numval == NONNUMERIC)
1493
if (far_strcmp(variable,s_finattract) == 0 ) { /* finattract=? */
1494
if (yesnoval[0] < 0) goto badarg;
1495
finattract = yesnoval[0];
1499
if (far_strcmp(variable,s_nobof) == 0 ) { /* nobof=? */
1500
if (yesnoval[0] < 0) goto badarg;
1501
nobof = yesnoval[0];
1505
if (far_strcmp(variable,s_function) == 0) { /* function=?,? */
1507
while (*value && k < 4) {
1508
if(set_trig_array(k++,value)) goto badarg;
1509
if ((value = strchr(value,'/')) == NULL) break;
1512
functionpreloaded = 1; /* for old bifs JCO 7/5/92 */
1516
if (far_strcmp(variable,s_outside) == 0 ) { /* outside=? */
1517
if(far_strcmp(value,s_iter)==0)
1519
else if(far_strcmp(value,s_real)==0)
1521
else if(far_strcmp(value,s_imag)==0)
1523
else if(far_strcmp(value,s_mult)==0)
1525
else if(far_strcmp(value,s_sum)==0)
1527
else if(far_strcmp(value,s_atan)==0)
1529
else if(far_strcmp(value,s_fmod)==0)
1531
else if(far_strcmp(value,s_tdis)==0)
1534
else if(numval == NONNUMERIC)
1536
else if(numval < TDIS || numval > 255) goto badarg;
1537
else outside = numval;
1541
if (far_strcmp(variable,s_bfdigits) == 0 ) { /* bfdigits=? */
1542
if(numval == NONNUMERIC)
1544
else if(numval < 0 || numval > 2000) goto badarg;
1545
else bfdigits = numval;
1549
if (far_strcmp(variable,s_maxiter) == 0) { /* maxiter=? */
1550
if (floatval[0] < 2) goto badarg;
1551
maxit = (long)floatval[0];
1555
if (far_strcmp(variable,s_iterincr) == 0) /* iterincr=? */
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')
1564
usr_stdcalcmode = charval[0];
1565
if(charval[0] == 'g')
1567
stoppass = ((int)value[1] - (int)'0');
1568
if(stoppass < 0 || stoppass > 6)
1574
if (far_strcmp(variable,s_ismand) == 0 ) { /* ismand=? */
1575
if (yesnoval[0] < 0) goto badarg;
1576
ismand = (short int)yesnoval[0];
1580
if (far_strcmp(variable,s_cyclelimit) == 0 ) { /* cyclelimit=? */
1581
if (numval <= 1 || numval > 256) goto badarg;
1582
initcyclelimit = numval;
1586
if (far_strcmp(variable,s_makemig) == 0) {
1588
if (totparms < 2) goto badarg;
1591
make_mig(xmult, ymult);
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])
1603
rotate_lo = intval[0];
1604
rotate_hi = intval[1];
1608
if (far_strcmp(variable,s_ranges) == 0) {
1609
int i,j,entries,prev;
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;
1621
if (j < prev) goto badarg;
1622
tmpranges[entries++] = prev = j;
1624
if (prev == 0) goto badarg;
1625
if ((ranges = (int far *)farmemalloc(sizeof(int)*entries)) == NULL) {
1626
static FCODE msg[] = {"Insufficient memory for ranges="};
1630
rangeslen = entries;
1631
for (i = 0; i < rangeslen; ++i)
1632
ranges[i] = tmpranges[i];
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);
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];
1651
if (far_strcmp(variable,s_minstack) == 0) { /* minstack=? */
1654
minstack = intval[0];
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];
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);
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);
1680
if (far_strcmp(variable,s_exitmode) == 0) { /* exitmode=? */
1681
sscanf(value,"%x",&numval);
1682
exitmode = (BYTE)numval;
1686
if (far_strcmp(variable,s_textcolors) == 0) {
1687
parse_textcolors(value);
1691
if (far_strcmp(variable,s_potential) == 0) { /* potential=? */
1693
while (k < 3 && *value) {
1695
potparam[k] = atof(value);
1697
potparam[k] = atoi(value);
1699
if ((value = strchr(value,'/')) == NULL) k = 99;
1704
if (far_strcmp(value,s_16bit)) goto badarg;
1710
if (far_strcmp(variable,s_params) == 0) { /* params=?,? */
1711
if (totparms != floatparms || totparms > MAXPARAMS)
1714
for (k = 0; k < MAXPARAMS; ++k)
1715
param[k] = (k < totparms) ? floatval[k] : 0.0;
1717
for (k = 0; k < MAXPARAMS; k++)
1718
floattobf(bfparms[k],param[k]);
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;
1731
else if (charval[0] == 'r')
1732
major_method = random_run;
1736
if (charval[1] == 'l')
1737
minor_method = left_first;
1738
else if (charval[1] == 'r')
1739
minor_method = right_first;
1742
/* keep this next part in for backwards compatibility with old PARs ??? */
1745
for (k = 2; k < 6; ++k)
1746
param[k-2] = (k < totparms) ? floatval[k] : 0.0;
1751
if (far_strcmp(variable,s_initorbit) == 0) { /* initorbit=?,? */
1752
if(far_strcmp(value,s_pixel)==0)
1755
if (totparms != 2 || floatparms != 2) goto badarg;
1756
initorbit.x = floatval[0];
1757
initorbit.y = floatval[1];
1763
if (far_strcmp(variable,s_orbitname) == 0 ) { /* orbitname=? */
1764
if(check_orbit_name(value))
1768
if (far_strcmp(variable,s_3dmode) == 0 ) { /* orbitname=? */
1772
if(far_strcmp(value,juli3Doptions[i])==0)
1781
if (far_strcmp(variable,s_julibrot3d) == 0) { /* julibrot3d=?,?,?,? */
1782
if (floatparms != totparms)
1785
zdots = (int)floatval[0];
1787
originfp = (float)floatval[1];
1789
depthfp = (float)floatval[2];
1791
heightfp = (float)floatval[3];
1793
widthfp = (float)floatval[4];
1795
distfp = (float)floatval[5];
1799
if (far_strcmp(variable,s_julibroteyes) == 0) { /* julibroteyes=?,?,?,? */
1800
if (floatparms != totparms || totparms != 1)
1802
eyesfp = (float)floatval[0];
1806
if (far_strcmp(variable,s_julibrotfromto) == 0) { /* julibrotfromto=?,?,?,? */
1807
if (floatparms != totparms || totparms != 4)
1809
mxmaxfp = floatval[0];
1810
mxminfp = floatval[1];
1811
mymaxfp = floatval[2];
1812
myminfp = floatval[3];
1816
if (far_strcmp(variable,s_corners) == 0) { /* corners=?,?,?,? */
1818
if (fractype == CELLULAR)
1819
return 1; /* skip setting the corners */
1821
printf("totparms %d floatparms %d\n",totparms, floatparms);
1824
if ( floatparms != totparms
1825
|| (totparms != 0 && totparms != 4 && totparms != 6))
1828
if (totparms == 0) return 0; /* turns corners mode on */
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) {
1835
old_bf_math = bf_math;
1836
if(!bf_math || dec > decimals)
1838
if(old_bf_math == 0) {
1840
for (k = 0; k < MAXPARAMS; k++)
1841
floattobf(bfparms[k],param[k]);
1844
/* xx3rd = xxmin = floatval[0]; */
1845
get_bf(bfxmin,floatvalstr[0]);
1846
get_bf(bfx3rd,floatvalstr[0]);
1848
/* xxmax = floatval[1]; */
1849
get_bf(bfxmax,floatvalstr[1]);
1851
/* yy3rd = yymin = floatval[2]; */
1852
get_bf(bfymin,floatvalstr[2]);
1853
get_bf(bfy3rd,floatvalstr[2]);
1855
/* yymax = floatval[3]; */
1856
get_bf(bfymax,floatvalstr[3]);
1858
if (totparms == 6) {
1859
/* xx3rd = floatval[4]; */
1860
get_bf(bfx3rd,floatvalstr[4]);
1862
/* yy3rd = floatval[5]; */
1863
get_bf(bfy3rd,floatvalstr[5]);
1866
/* now that all the corners have been read in, get a more */
1867
/* accurate value for dec and do it all again */
1869
dec = getprecbf_mag();
1871
goto badarg; /* ie: Magnification is +-1.#INF */
1873
if(dec > decimals) /* get corners again if need more precision */
1877
/* now get parameters and corners all over again at new
1879
for (k = 0; k < MAXPARAMS; k++)
1880
floattobf(bfparms[k],param[k]);
1882
/* xx3rd = xxmin = floatval[0]; */
1883
get_bf(bfxmin,floatvalstr[0]);
1884
get_bf(bfx3rd,floatvalstr[0]);
1886
/* xxmax = floatval[1]; */
1887
get_bf(bfxmax,floatvalstr[1]);
1889
/* yy3rd = yymin = floatval[2]; */
1890
get_bf(bfymin,floatvalstr[2]);
1891
get_bf(bfy3rd,floatvalstr[2]);
1893
/* yymax = floatval[3]; */
1894
get_bf(bfymax,floatvalstr[3]);
1896
if (totparms == 6) {
1897
/* xx3rd = floatval[4]; */
1898
get_bf(bfx3rd,floatvalstr[4]);
1900
/* yy3rd = floatval[5]; */
1901
get_bf(bfy3rd,floatvalstr[5]);
1905
xx3rd = xxmin = floatval[0];
1906
xxmax = floatval[1];
1907
yy3rd = yymin = floatval[2];
1908
yymax = floatval[3];
1910
if (totparms == 6) {
1911
xx3rd = floatval[4];
1912
yy3rd = floatval[5];
1917
if (far_strcmp(variable,s_viewwindows) == 0) { /* viewwindows=?,?,?,?,? */
1918
if (totparms > 5 || floatparms-intparms > 2 || intparms > 4)
1921
viewreduction = (float)4.2; /* reset default values */
1922
finalaspectratio = screenaspect;
1923
viewcrop = 1; /* yes */
1924
viewxdots = viewydots = 0;
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];
1939
if (far_strcmp(variable,s_centermag) == 0) { /* center-mag=?,?,?[,?,?,?] */
1942
if ( (totparms != floatparms)
1943
|| (totparms != 0 && totparms < 3)
1944
|| (totparms >= 3 && floatval[2] == 0.0))
1946
if (fractype == CELLULAR)
1947
return 1; /* skip setting the corners */
1949
if (totparms == 0) return 0; /* turns center-mag mode on */
1951
/* dec = get_max_curarg_len(floatvalstr,totparms); */
1952
#ifdef USE_LONG_DOUBLE
1953
sscanf(floatvalstr[2], "%Lf", &Magnification);
1955
sscanf(floatvalstr[2], "%lf", &Magnification);
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 */
1963
dec = getpower10(Magnification) + 4; /* 4 digits of padding sounds good */
1965
if((dec <= DBL_DIG+1 && debugflag != 3200) || debugflag == 3400) { /* rough estimate that double is OK */
1968
/* Magnification = floatval[2]; */ /* already done above */
1973
Xmagfactor = floatval[3];
1974
if (Xmagfactor == 0)
1977
Rotation = floatval[4];
1980
/* calculate bounds */
1981
cvtcorners(Xctr, Yctr, Magnification, Xmagfactor, Rotation, Skew);
1984
else { /* use arbitrary precision */
1988
old_bf_math = bf_math;
1989
if(!bf_math || dec > decimals)
1991
if(old_bf_math == 0) {
1993
for (k = 0; k < MAXPARAMS; k++)
1994
floattobf(bfparms[k],param[k]);
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 */
2009
Xmagfactor = floatval[3];
2010
if (Xmagfactor == 0)
2013
Rotation = floatval[4];
2016
/* calculate bounds */
2017
cvtcornersbf(bXctr, bYctr, Magnification, Xmagfactor, Rotation, Skew);
2019
restore_stack(saved);
2024
if (far_strcmp(variable,s_aspectdrift) == 0 ) { /* aspectdrift=? */
2025
if(floatparms != 1 || floatval[0] < 0)
2027
aspectdrift = (float)floatval[0];
2031
if (far_strcmp(variable,s_invert) == 0) { /* invert=?,?,? */
2032
if (totparms != floatparms || (totparms != 1 && totparms != 3))
2034
invert = ((inversion[0] = floatval[0]) != 0.0) ? totparms : 0;
2035
if (totparms == 3) {
2036
inversion[1] = floatval[1];
2037
inversion[2] = floatval[2];
2042
if (far_strcmp(variable,s_olddemmcolors) == 0 ) { /* olddemmcolors=? */
2043
if (yesnoval[0] < 0) goto badarg;
2044
old_demm_colors = yesnoval[0];
2048
if (far_strcmp(variable,s_askvideo) == 0 ) { /* askvideo=? */
2049
if (yesnoval[0] < 0) goto badarg;
2050
askvideo = yesnoval[0];
2054
if (far_strcmp(variable,s_ramvideo) == 0 ) /* ramvideo=? */
2055
return 0; /* just ignore and return, for old time's sake */
2057
if (far_strcmp(variable,s_float) == 0 ) { /* float=? */
2058
if (yesnoval[0] < 0) goto badarg;
2060
usr_floatflag = (char)yesnoval[0];
2062
usr_floatflag = 1; /* must use floating point */
2067
if (far_strcmp(variable,s_fastrestore) == 0 ) { /* fastrestore=? */
2068
if (yesnoval[0] < 0) goto badarg;
2069
fastrestore = (char)yesnoval[0];
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;
2077
strcpy(orgfrmdir,value);
2078
fix_dirname(orgfrmdir);
2082
if (far_strcmp(variable,s_biomorph) == 0 ) { /* biomorph=? */
2083
usr_biomorph = numval;
2087
if (far_strcmp(variable,s_orbitsave) == 0 ) { /* orbitsave=? */
2088
if(charval[0] == 's')
2090
else if (yesnoval[0] < 0) goto badarg;
2091
orbitsave |= yesnoval[0];
2095
if (far_strcmp(variable,s_bailout) == 0 ) { /* bailout=? */
2096
if (floatval[0] < 1 || floatval[0] > 2100000000L) goto badarg;
2097
bailout = (long)floatval[0];
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;
2110
setbailoutformula(bailoutest);
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;
2125
if (far_strcmp(variable,s_printer) == 0 ) { /* printer=? */
2126
if (parse_printer(value) < 0) goto badarg;
2130
if (far_strcmp(variable,s_printfile) == 0) { /* printfile=? */
2132
if (valuelen > (FILE_MAX_PATH-1)) goto badarg;
2133
if((existdir=merge_pathnames(PrintName, value, mode))==0)
2135
else if (existdir < 0)
2136
init_msg(0,variable,value,mode);
2139
if(far_strcmp(variable,s_rleps) == 0) {
2140
Printer_Compress = yesnoval[0];
2143
if(far_strcmp(variable,s_colorps) == 0) {
2144
ColorPS = yesnoval[0];
2148
if (far_strcmp(variable,s_epsf) == 0) { /* EPS type? SWT */
2150
EPSFileType = numval;
2152
if (far_strcmp(PrintName,s_fract001prn)==0)
2153
strcpy(PrintName,"fract001.eps");
2157
if (far_strcmp(variable,s_title) == 0) { /* Printer title block? SWT */
2158
if (yesnoval[0] < 0) goto badarg;
2159
Printer_Titleblock = yesnoval[0];
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;
2172
if (far_strcmp(variable,s_plotstyle) == 0) { /* plot style? SWT */
2173
Printer_SStyle = numval;
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];
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;
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;
2226
default: l = 224; break;
2228
if ((value=strchr(value,'/')) == NULL) goto badarg;
2229
for (k=0; k < (int)strlen(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;
2240
_bios_serialcom(0,numval-1,l);
2246
if (far_strcmp(variable,s_sound) == 0 ) { /* sound=?,?,? */
2249
soundflag = 0; /* start with a clean slate, add bits as we go */
2251
soundflag = 8; /* old command, default to PC speaker */
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) */
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;
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 */
2282
soundflag = soundflag | 16;
2283
else soundflag = (soundflag & 0xEF);
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;
2294
} /* end totparms > 1 */
2298
if (far_strcmp(variable,s_hertz) == 0) { /* Hertz=? */
2303
if (far_strcmp(variable,s_volume) == 0) { /* Volume =? */
2304
fm_vol = numval & 0x3F; /* 63 */
2308
if (far_strcmp(variable,s_atten) == 0) {
2309
if (charval[0] == 'n')
2311
else if (charval[0] == 'l')
2313
else if (charval[0] == 'm')
2315
else if (charval[0] == 'h')
2322
if(far_strcmp(variable,s_polyphony) == 0) {
2325
polyphony = abs(numval-1);
2329
if(far_strcmp(variable,s_wavetype) == 0) { /* wavetype = ? */
2330
fm_wavetype = numval & 0x0F;
2334
if(far_strcmp(variable,s_attack) == 0) { /* attack = ? */
2335
fm_attack = numval & 0x0F;
2339
if(far_strcmp(variable,s_decay) == 0) { /* decay = ? */
2340
fm_decay = numval & 0x0F;
2344
if(far_strcmp(variable,s_sustain) == 0) { /* sustain = ? */
2345
fm_sustain = numval & 0x0F;
2349
if(far_strcmp(variable,s_srelease) == 0) { /* release = ? */
2350
fm_release = numval & 0x0F;
2354
if (far_strcmp(variable,s_scalemap) == 0) { /* Scalemap=?,?,?,?,?,?,?,?,?,?,? */
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];
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)
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;
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')
2388
else if (charval[0] == 'o')
2389
LogFlag = -1; /* old log palette */
2391
LogFlag = (long)floatval[0];
2395
if (far_strcmp(variable,s_logmode) == 0 ) { /* logmode=? */
2396
Log_Fly_Calc = 0; /* turn off if error */
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 */
2409
if (far_strcmp(variable,s_debugflag) == 0
2410
|| far_strcmp(variable,s_debug) == 0) { /* internal use only */
2412
timerflag = debugflag & 1; /* separate timer flag */
2413
debugflag -= timerflag;
2417
if (far_strcmp(variable,s_rseed) == 0) {
2423
if (far_strcmp(variable,s_orbitdelay) == 0) {
2424
orbit_delay = numval;
2428
if (far_strcmp(variable,s_orbitinterval) == 0) {
2429
orbit_interval = numval;
2430
if (orbit_interval < 1)
2432
if (orbit_interval > 255)
2433
orbit_interval = 255;
2437
if (far_strcmp(variable,s_showdot) == 0) {
2441
autoshowdot = (char)0;
2442
if(isalpha(charval[0]))
2444
if(strchr("abdm",(int)charval[0]) != NULL)
2445
autoshowdot = charval[0];
2455
if(totparms > 1 && intparms > 0)
2456
sizedot = intval[1];
2463
if (far_strcmp(variable,s_showorbit) == 0) { /* showorbit=yes|no */
2464
start_showorbit=(char)yesnoval[0];
2468
if (far_strcmp(variable,s_decomp) == 0) {
2469
if (totparms != intparms || totparms < 1) goto badarg;
2470
decomp[0] = intval[0];
2472
if (totparms > 1) /* backward compatibility */
2473
bailout = decomp[1] = intval[1];
2477
if (far_strcmp(variable,s_distest) == 0) {
2478
if (totparms != intparms || totparms < 1) goto badarg;
2479
usr_distest = (long)floatval[0];
2482
distestwidth = intval[1];
2483
if(totparms > 3 && intval[2] > 0 && intval[3] > 0) {
2484
pseudox = intval[2];
2485
pseudoy = intval[3];
2488
pseudox = pseudoy = 0;
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);
2499
if (far_strcmp(variable,s_formulaname) == 0) { /* formulaname=? */
2500
if (valuelen > ITEMNAMELEN) goto badarg;
2501
strcpy(FormName,value);
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);
2512
if (far_strcmp(variable,s_lname) == 0) {
2513
if (valuelen > ITEMNAMELEN) goto badarg;
2514
strcpy(LName,value);
2518
if (far_strcmp(variable,s_ifsfile) == 0) { /* ifsfile=?? */
2520
if (valuelen > (FILE_MAX_PATH-1)) goto badarg;
2521
if((existdir=merge_pathnames(IFSFileName, value, mode))==0)
2523
else if(existdir < 0)
2524
init_msg(0,variable,value,mode);
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);
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);
2544
if (far_strcmp(variable,s_stereo) == 0) { /* stereo=? */
2545
if ((numval<0) || (numval>4)) goto badarg;
2546
glassestype = numval;
2550
if (far_strcmp(variable,s_rotation) == 0) { /* rotation=?/?/? */
2551
if (totparms != 3 || intparms != 3) goto badarg;
2558
if (far_strcmp(variable,s_perspective) == 0) { /* perspective=? */
2559
if (numval == NONNUMERIC) goto badarg;
2564
if (far_strcmp(variable,s_xyshift) == 0) { /* xyshift=?/? */
2565
if (totparms != 2 || intparms != 2) goto badarg;
2571
if (far_strcmp(variable,s_interocular) == 0) { /* interocular=? */
2572
eyeseparation = numval;
2576
if (far_strcmp(variable,s_converge) == 0) { /* converg=? */
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)
2588
red_crop_left = intval[0];
2589
red_crop_right = intval[1];
2590
blue_crop_left = intval[2];
2591
blue_crop_right = intval[3];
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];
2602
if (far_strcmp(variable,s_xyadjust) == 0) { /* trans=? */
2603
if (totparms != 2 || intparms != 2) goto badarg;
2609
if (far_strcmp(variable,s_3d) == 0) { /* 3d=?/?/.. */
2610
if(far_strcmp(value,s_overlay)==0) {
2612
if(calc_status > -1) /* if no image, treat same as 3D=yes */
2615
else if (yesnoval[0] < 0) goto badarg;
2616
display3d = yesnoval[0];
2618
return (display3d) ? 6 : 2;
2621
if (far_strcmp(variable,s_sphere) == 0 ) { /* sphere=? */
2622
if (yesnoval[0] < 0) goto badarg;
2623
SPHERE = yesnoval[0];
2627
if (far_strcmp(variable,s_scalexyz) == 0) { /* scalexyz=?/?/? */
2628
if (totparms < 2 || intparms != totparms) goto badarg;
2631
if (totparms > 2) ROUGH = intval[2];
2635
/* "rough" is really scale z, but we add it here for convenience */
2636
if (far_strcmp(variable,s_roughness) == 0) { /* roughness=? */
2641
if (far_strcmp(variable,s_waterline) == 0) { /* waterline=? */
2642
if (numval<0) goto badarg;
2647
if (far_strcmp(variable,s_filltype) == 0) { /* filltype=? */
2648
if (numval < -1 || numval > 6) goto badarg;
2653
if (far_strcmp(variable,s_lightsource) == 0) { /* lightsource=?/?/? */
2654
if (totparms != 3 || intparms != 3) goto badarg;
2661
if (far_strcmp(variable,s_smoothing) == 0) { /* smoothing=? */
2662
if (numval<0) goto badarg;
2667
if (far_strcmp(variable,s_latitude) == 0) { /* latitude=?/? */
2668
if (totparms != 2 || intparms != 2) goto badarg;
2674
if (far_strcmp(variable,s_longitude) == 0) { /* longitude=?/? */
2675
if (totparms != 2 || intparms != 2) goto badarg;
2681
if (far_strcmp(variable,s_radius) == 0) { /* radius=? */
2682
if (numval < 0) goto badarg;
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];
2694
if (far_strcmp(variable,s_preview) == 0) { /* preview? */
2695
if (yesnoval[0] < 0) goto badarg;
2696
preview = (char)yesnoval[0];
2700
if (far_strcmp(variable,s_showbox) == 0) { /* showbox? */
2701
if (yesnoval[0] < 0) goto badarg;
2702
showbox = (char)yesnoval[0];
2706
if (far_strcmp(variable,s_coarse) == 0) { /* coarse=? */
2707
if (numval < 3 || numval > 2000) goto badarg;
2708
previewfactor = numval;
2712
if (far_strcmp(variable,s_randomize) == 0) { /* RANDOMIZE=? */
2713
if (numval<0 || numval>7) goto badarg;
2718
if (far_strcmp(variable,s_ambient) == 0) { /* ambient=? */
2719
if (numval<0||numval>100) goto badarg;
2724
if (far_strcmp(variable,s_haze) == 0) { /* haze=? */
2725
if (numval<0||numval>100) goto badarg;
2730
if (far_strcmp(variable,s_fullcolor) == 0) { /* fullcolor=? */
2731
if (yesnoval[0] < 0) goto badarg;
2732
Targa_Out = yesnoval[0];
2736
if (far_strcmp(variable,s_truecolor) == 0) { /* truecolor=? */
2737
if (yesnoval[0] < 0) goto badarg;
2738
truecolor = yesnoval[0];
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 */
2755
if (far_strcmp(variable,s_usegrayscale) == 0) { /* usegrayscale? */
2756
if (yesnoval[0] < 0) goto badarg;
2757
grayflag = (char)yesnoval[0];
2761
if (far_strcmp(variable,s_monitorwidth) == 0) { /* monitorwidth=? */
2762
if (totparms != 1 || floatparms != 1) goto badarg;
2763
AutoStereo_width = floatval[0];
2767
if (far_strcmp(variable,s_targa_overlay) == 0) { /* Targa Overlay? */
2768
if (yesnoval[0] < 0) goto badarg;
2769
Targa_Overlay = yesnoval[0];
2773
if (far_strcmp(variable,s_background) == 0) { /* background=?/? */
2774
if (totparms != 3 || intparms != 3) goto badarg;
2776
if (intval[i] & ~0xff)
2778
back_color[0] = (BYTE)intval[0];
2779
back_color[1] = (BYTE)intval[1];
2780
back_color[2] = (BYTE)intval[2];
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);
2791
if (far_strcmp(variable,s_ray) == 0) { /* RAY=? */
2792
if (numval < 0 || numval > 6) goto badarg;
2797
if (far_strcmp(variable,s_brief) == 0) { /* BRIEF? */
2798
if (yesnoval[0] < 0) goto badarg;
2799
BRIEF = yesnoval[0];
2803
if (far_strcmp(variable,s_release) == 0) { /* release */
2804
if (numval < 0) goto badarg;
2806
save_release = numval;
2810
if (far_strcmp(variable,s_curdir) == 0) { /* curdir= */
2811
if (yesnoval[0] < 0) goto badarg;
2812
checkcurdir = yesnoval[0];
2816
if (far_strcmp(variable,s_virtual) == 0) { /* virtual= */
2817
if (yesnoval[0] < 0) goto badarg;
2818
virtual = yesnoval[0];
2829
#if (_MSC_VER >= 600)
2830
#pragma optimize( "el", on )
2834
/* Some routines broken out of above so compiler doesn't run out of heap: */
2836
static void parse_textcolors(char *value)
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;
2855
while ( k < sizeof(txtcolor)) {
2856
if (*value == 0) break;
2857
if (*value != '/') {
2858
sscanf(value,"%x",&hexval);
2859
i = (hexval / 16) & 7;
2861
if (i == j || (i == 0 && j == 8)) /* force contrast */
2863
txtcolor[k] = (BYTE)(i * 16 + j);
2864
if ((value = strchr(value,'/')) == NULL) break;
2872
static int parse_colors(char *value)
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)
2884
if(merge_pathnames(colorfile,&value[1],3)<0)
2885
init_msg(0,"",&value[1],3);
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)
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;
2910
dacbox[i][j] = (BYTE)k;
2912
int start,spread,cnum;
2913
start = i - (spread = smooth + 1);
2915
if ((k - (int)dacbox[start][j]) == 0) {
2916
while (++cnum < spread)
2917
dacbox[start+cnum][j] = (BYTE)k;
2920
while (++cnum < spread)
2921
dacbox[start+cnum][j] =
2922
(BYTE)(( cnum *dacbox[i][j]
2923
+ (i-(start+cnum))*dacbox[start][j]
2933
if (smooth) goto badcolor;
2934
while (i < 256) { /* zap unset entries */
2935
dacbox[i][0] = dacbox[i][1] = dacbox[i][2] = 40;
2941
memcpy(olddacbox,dacbox,256*3);
2947
static int parse_printer(char *value)
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') {
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')
2967
Printer_Type=7; /* HP Plotter (semi-color) */
2969
if (Printer_Type == 1) /* assume low resolution */
2970
Printer_Resolution = 75;
2972
Printer_Resolution = 60;
2973
if (EPSFileType > 0) /* EPS save - force 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;
2992
static void argerror(char *badarg) /* oops. couldn't decode this */
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)"};
3000
if ((int)strlen(badarg) > 70) badarg[70] = 0;
3001
if (active_system == 0 /* DOS */
3002
&& first_init) /* & this is 1st call to cmdfiles */
3004
sprintf(msg,"%Fs%s%Fs",(char far *)argerrmsg1,badarg,(char far *)argerrmsg2);
3006
sprintf(msg,"%Fs%s",(char far *)argerrmsg1,badarg);
3008
sprintf(msg,"%s%s%s",argerrmsg1,badarg,argerrmsg2);
3010
sprintf(msg,"%s%s",argerrmsg1,badarg);
3019
void set_3d_defaults()
3032
back_color[0] = 51; back_color[1] = 153; back_color[2] = 200;
3051
if (active_system != 0)
3059
/* copy a big number from a string, up to slash */
3060
static int get_bf(bf_t bf, char *curarg)
3063
s=strchr(curarg,'/');
3072
/* Get length of current args */
3073
int get_curarg_len(char *curarg)
3077
s=strchr(curarg,'/');
3080
len = strlen(curarg);
3086
/* Get max length of current args */
3087
int get_max_curarg_len(char *floatvalstr[], int totparms)
3091
for(i=0;i<totparms;i++)
3092
if((tmp=get_curarg_len(floatvalstr[i])) > max_str)
3097
/* mode = 0 command line @filename */
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)
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: "};
3113
if (initbatch == 1) { /* in batch mode */
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 */
3120
strncpy(cmd,cmdstr,30);
3127
sprintf(msg,"Can't find %s%Fs, please check %Fs",cmd,badfilename,modestr[mode]);
3129
sprintf(msg,"Can't find %s%s, please check %s",cmd,badfilename,modestr[mode]);
3131
if (active_system == 0 /* DOS */
3132
&& first_init) { /* & cmdfiles hasn't finished 1st try */
3133
if(row == 1 && badfilename) {
3135
putstring(0,0,15,diags);
3138
putstring(row++,0,7,msg);
3140
putstring(++row,0,15,s_escapetoabort);
3141
movecursor(row+1,0);
3143
if(getakeynohelp()==27)
3146
dopause(2); /* defer getakeynohelp until after parseing */
3149
else if(badfilename)
3154
/* defer pause until after parsing so we know if in batch mode */
3155
void dopause(int action)
3157
static unsigned char needpause = 0;
3165
else if (needpause == 2)
3166
if(getakeynohelp() == ESC)
3173
needpause = (char)action;
3181
Crude function to detect a floating point number. Intended for
3182
use with arbitrary precision.
3184
static int isabigfloat(char *str)
3186
/* [+|-]numbers][.]numbers[+|-][e|g]numbers */
3192
while(*s != 0 && *s != '/' && *s != ' ')
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;}
3200
if(numdot > 1 || numsign > 2 || nume > 1) result=0;