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