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