📄 cmdfiles.c
字号:
char *s_rleps= "rleps";
char *s_rotation= "rotation";
char *s_roughness= "roughness";
char *s_rseed= "rseed";
char *s_savename= "savename";
char *s_savetime= "savetime";
char *s_scalexyz= "scalexyz";
char *s_showbox= "showbox";
char *s_showdot= "showdot";
char *s_smoothing= "smoothing";
char *s_solidcore= "solidcore";
char *s_sound= "sound";
char *s_sphere= "sphere";
char *s_stereo= "stereo";
char *s_symmetry= "symmetry";
char *s_targa_out= "targa_out";
char *s_targa_overlay= "targa_overlay";
char *s_textcolors= "textcolors";
char *s_textsafe= "textsafe";
char *s_title= "title";
char *s_tplus= "tplus";
char *s_translate= "translate";
char *s_transparent= "transparent";
char *s_transparent3d= "transparent3d";
char *s_type= "type";
char *s_vesadetect= "vesadetect";
char *s_vga= "vga";
char *s_video= "video";
char *s_viewwindows= "viewwindows";
char *s_warn= "warn";
char *s_waterline= "waterline";
char *s_xaxis= "xaxis";
char *s_xyadjust= "xyadjust";
char *s_xyaxis= "xyaxis";
char *s_xyshift= "xyshift";
char *s_yaxis = "yaxis";
void cmdfiles_overlay() { } /* for restore_active_ovly */
/*
cmdfiles(argc,argv) process the command-line arguments
it also processes the 'sstools.ini' file and any
indirect files ('fractint @myfile')
*/
int cmdfiles(int argc,char **argv)
{
int i;
char curarg[141];
char tempstring[101];
char *sptr;
FILE *initfile;
ENTER_OVLY(OVLY_CMDFILES);
if (first_init) initvars_run(); /* once per run initialization */
initvars_restart(); /* <ins> key initialization */
initvars_fractal(); /* image initialization */
findpath("sstools.ini", tempstring); /* look for SSTOOLS.INI */
if (tempstring[0] != 0) /* found it! */
if ((initfile = fopen(tempstring,"r")) != NULL)
cmdfile(initfile,1); /* process it */
for (i = 1; i < argc; i++) { /* cycle through args */
#ifdef XFRACT
/* Let the xfract code take a look at the argument */
if (unixarg(argc,argv,&i)) continue;
#endif
strcpy(curarg,argv[i]);
if (curarg[0] == ';') /* start of comments? */
break;
if (curarg[0] != '@') { /* simple command? */
if (strchr(curarg,'=') == NULL) { /* not xxx=yyy, so check for gif */
strcpy(tempstring,curarg);
if (strchr(curarg,'.') == NULL)
strcat(tempstring,".gif");
if ((initfile = fopen(tempstring,"rb"))) {
fread(tempstring,6,1,initfile);
if ( tempstring[0] == 'G'
&& tempstring[1] == 'I'
&& tempstring[2] == 'F'
&& tempstring[3] >= '8' && tempstring[3] <= '9'
&& tempstring[4] >= '0' && tempstring[4] <= '9') {
strcpy(readname,curarg);
curarg[0] = showfile = 0;
}
fclose(initfile);
}
}
if (curarg[0])
cmdarg(curarg,0); /* process simple command */
}
else if ((sptr = strchr(curarg,'/'))) { /* @filename/setname? */
*sptr = 0;
strcpy(CommandFile,&curarg[1]);
strcpy(CommandName,sptr+1);
find_file_item(CommandFile,CommandName,&initfile);
cmdfile(initfile,3);
}
else { /* @filename */
if ((initfile = fopen(&curarg[1],"r")) == NULL)
argerror(curarg);
cmdfile(initfile,0);
}
}
if (first_init == 0) {
initmode = -1; /* don't set video when <ins> key used */
showfile = 1; /* nor startup image file */
}
if(debugflag != 110)
first_init = 0;
EXIT_OVLY;
return(0);
}
int load_commands(FILE *infile)
{
/* when called, file is open in binary mode, positioned at the */
/* '(' or '{' following the desired parameter set's name */
int ret;
ENTER_OVLY(OVLY_CMDFILES);
initcorners = initparams = 0; /* reset flags for type= */
ret = cmdfile(infile,2);
EXIT_OVLY;
return ret;
}
static void initvars_run() /* once per run init */
{
init_rseed = (int)time(NULL);
}
static void initvars_restart() /* <ins> key init */
{
save_release = release; /* this release number */
gif87a_flag = INIT_GIF87; /* turn on GIF89a processing */
dither_flag = 0; /* no dithering */
askvideo = 1; /* turn on video-prompt flag */
overwrite = 0; /* don't overwrite */
soundflag = -1; /* sound is on */
basehertz = 440; /* basic hertz rate */
initbatch = 0; /* not in batch mode */
initsavetime = 0; /* no auto-save */
initmode = -1; /* no initial video mode */
viewwindow = 0; /* no view window */
viewreduction = 4.2;
viewcrop = 1;
ai_8514 = 0; /* no need for the 8514 API */
finalaspectratio = screenaspect;
viewxdots = viewydots = 0;
orbit_delay = 0; /* full speed orbits */
debugflag = 0; /* debugging flag(s) are off */
timerflag = 0; /* timer flags are off */
strcpy(FormFileName,"fractint.frm"); /* default formula file */
FormName[0] = 0;
strcpy(LFileName,"fractint.l");
LName[0] = 0;
strcpy(CommandFile,"fractint.par");
CommandName[0] = CommandComment1[0] = CommandComment2[0] = 0;
CommandComment3[0] = CommandComment4[0] = 0;
strcpy(IFSFileName,"fractint.ifs");
IFSName[0] = 0;
reset_ifs_defn();
rflag = 0; /* not a fixed srand() seed */
rseed = init_rseed;
strcpy(readname,DOTSLASH); /* initially current directory */
showfile = 1;
/* next should perhaps be fractal re-init, not just <ins> ? */
initcyclelimit=55; /* spin-DAC default speed limit */
mapset = 0; /* no map= name active */
if (mapdacbox) {
farmemfree(mapdacbox);
mapdacbox = NULL;
}
TPlusFlag = 1;
MaxColorRes = 8;
PixelZoom = 0;
NonInterlaced = 0;
Transparent3D = 0;
SolidCore = 1;
CoreRed = 128;
CoreGreen = 128;
CoreBlue = 128;
zzmin = -1.5;
zzmax = 1.5;
ttmin = 0.0;
ttmax = 0.0;
NumFrames = 1;
tpdepth = tptime = 0;
AntiAliasing = 0;
Shadowing = 0;
Printer_Type = DEFAULT_PRINTER; /* assume an IBM/EPSON */
Printer_Resolution = PRT_RESOLUTION; /* assume low resolution */
Printer_Titleblock = 0; /* assume no title block */
Printer_ColorXlat = 0; /* assume positive image */
Printer_SetScreen = 0; /* assume default screen */
Printer_SFrequency = 45; /* New screen frequency K */
Printer_SAngle = 45; /* New screen angle K */
Printer_SStyle = 1; /* New screen style K */
Printer_RFrequency = 45; /* New screen frequency R */
Printer_RAngle = 75; /* New screen angle R */
Printer_RStyle = 1; /* New screen style R */
Printer_GFrequency = 45; /* New screen frequency G */
Printer_GAngle = 15; /* New screen angle G */
Printer_GStyle = 1; /* New screen style G */
Printer_BFrequency = 45; /* New screen frequency B */
Printer_BAngle = 0; /* New screen angle B */
Printer_BStyle = 1; /* New screen style B */
#ifndef XFRACT
Print_To_File = 0; /* No print-to-file */
Printer_CRLF = 0; /* Assume CR+LF */
#else
Print_To_File = 1; /* Print-to-file */
Printer_CRLF = 2; /* Assume LF */
Printer_Compress = 0; /* Assume NO PostScript compression */
#endif
EPSFileType = 0; /* Assume no save to .EPS */
LPTNumber = 1; /* assume LPT1 */
ColorPS = 0; /* Assume NO Color PostScr*/
major_method = minor_method = 0; /* default inverse julia methods */
}
static void initvars_fractal() /* init vars affecting calculation */
{
int i;
bios_palette = 0; /* don't force use of a BIOS palette */
escape_exit = 0; /* don't disable the "are you sure?" screen */
usr_periodicitycheck = 1; /* turn on periodicity */
inside = 1; /* inside color = blue */
fillcolor = -1; /* no special fill color */
usr_biomorph = -1; /* turn off biomorph flag */
outside = -1; /* outside color = -1 (not used) */
maxit = 150; /* initial maxiter */
usr_stdcalcmode = 'g'; /* initial solid-guessing */
#ifndef XFRACT
usr_floatflag = 0; /* turn off the float flag */
#else
usr_floatflag = 1; /* turn on the float flag */
#endif
finattract = 0; /* disable finite attractor logic */
fractype = 0; /* initial type Set flag */
curfractalspecific = &fractalspecific[0];
initcorners = initparams = 0;
bailout = 0; /* no user-entered bailout */
useinitorbit = 0;
for (i = 0; i < MAXPARAMS; i++) param[i] = 0.0; /* initial parameter values */
for (i = 0; i < 3; i++) potparam[i] = 0.0; /* initial potential values */
for (i = 0; i < 3; i++) inversion[i] = 0.0; /* initial invert values */
initorbit[0] = initorbit[1] = 0.0; /* initial orbit values */
invert = 0;
decomp[0] = decomp[1] = 0;
usr_distest = 0;
distestwidth = 71;
forcesymmetry = 999; /* symmetry not forced */
xx3rd = xxmin = -2.5; xxmax = 1.5; /* initial corner values */
yy3rd = yymin = -1.5; yymax = 1.5; /* initial corner values */
pot16bit = potflag = 0;
LogFlag = 0; /* no logarithmic palette */
set_trig_array(0,"sin"); /* trigfn defaults */
set_trig_array(1,"sqr");
set_trig_array(2,"sinh");
set_trig_array(3,"cosh");
if (rangeslen) {
farmemfree((char far *)ranges);
rangeslen = 0;
}
usemag = 0; /* use corners, not center-mag */
colorstate = colorpreloaded = 0;
rotate_lo = 1; rotate_hi = 255; /* color cycling default range */
display3d = 0; /* 3D display is off */
overlay3d = 0; /* 3D overlay is off */
functionpreloaded = 0; /* for old bifs JCO 7/5/92 */
mxminfp = -.83;
myminfp = -.25;
mxmaxfp = -.83;
mymaxfp = .25;
originfp = 8;
heightfp = 7;
widthfp = 10;
distfp = 24;
eyesfp = 2.5;
depthfp = 8;
lastorbittype = -1;
neworbittype = JULIA;
zdots = 128;
initvars_3d();
}
static void initvars_3d() /* init vars affecting 3d */
{
RAY = 0;
BRIEF = 0;
SPHERE = FALSE;
preview = 0;
showbox = 0;
xadjust = 0;
yadjust = 0;
eyeseparation = 0;
glassestype = 0;
previewfactor = 20;
red_crop_left = 4;
red_crop_right = 0;
blue_crop_left = 0;
blue_crop_right = 4;
red_bright = 80;
blue_bright = 100;
transparent[0] = transparent[1] = 0; /* no min/max transparency */
set_3d_defaults();
}
static void reset_ifs_defn()
{
if (ifs_defn) {
farmemfree((char far *)ifs_defn);
ifs_defn = NULL;
}
}
static int cmdfile(FILE *handle,int mode)
/* mode = 0 command line @filename */
/* 1 sstools.ini */
/* 2 <@> command after startup */
/* 3 command line @filename/setname */
{
/* note that cmdfile could be open as text OR as binary */
/* binary is used in @ command processing for reasonable speed note/point */
int i;
int lineoffset = 0;
int changeflag = 0; /* &1 fractal stuff chgd, &2 3d stuff chgd */
char linebuf[513],cmdbuf[1001];
if (mode == 2 || mode == 3) {
while ((i = getc(handle)) != '{' && i != EOF) { }
CommandComment1[0] = CommandComment2[0] = 0;
CommandComment3[0] = CommandComment4[0] = 0;
}
linebuf[0] = 0;
while (next_command(cmdbuf,1000,handle,linebuf,&lineoffset,mode) > 0) {
if ((mode == 2 || mode == 3) && strcmp(cmdbuf,"}") == 0) break;
if ((i = cmdarg(cmdbuf,mode)) < 0) break;
changeflag |= i;
}
fclose(handle);
#ifdef XFRACT
initmode = 0; /* Skip credits if @file is used. */
#endif
return changeflag;
}
static int next_command(char *cmdbuf,int maxlen,
FILE *handle,char *linebuf,int *lineoffset,int mode)
{
int cmdlen = 0;
char *lineptr;
lineptr = linebuf + *lineoffset;
while(1) {
while (*lineptr <= ' ' || *lineptr == ';') {
if (cmdlen) { /* space or ; marks end of command */
cmdbuf[cmdlen] = 0;
*lineoffset = lineptr - linebuf;
return cmdlen;
}
while (*lineptr && *lineptr <= ' ')
++lineptr; /* skip spaces and tabs */
if (*lineptr == ';' || *lineptr == 0) {
if (*lineptr == ';'
&& (mode == 2 || mode == 3)
&& (CommandComment1[0] == 0 || CommandComment2[0] == 0 ||
CommandComment3[0] == 0 || CommandComment4[0] == 0)) {
/* save comment */
while (*(++lineptr)
&& (*lineptr == ' ' || *lineptr == '\t')) { }
if (*lineptr) {
if (strlen(lineptr) > 56)
*(lineptr+56) = 0;
if (CommandComment1[0] == 0)
far_strcpy(CommandComment1,lineptr);
else if (CommandComment2[0] == 0)
far_strcpy(CommandComment2,lineptr);
else if (CommandComment3[0] == 0)
far_strcpy(CommandComment3,lineptr);
else
far_strcpy(CommandComment4,lineptr);
}
}
if (next_line(handle,linebuf,mode) != 0)
return(-1); /* eof */
lineptr = linebuf; /* start new line */
}
}
if (*lineptr == '\\' /* continuation onto next line? */
&& *(lineptr+1) == 0) {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -