📄 cmdfiles.c
字号:
if (next_line(handle,linebuf,mode) != 0) {
argerror(cmdbuf); /* missing continuation */
return(-1);
}
lineptr = linebuf;
while (*lineptr && *lineptr <= ' ')
++lineptr; /* skip white space @ start next line */
continue; /* loop to check end of line again */
}
cmdbuf[cmdlen] = *(lineptr++); /* copy character to command buffer */
if (++cmdlen >= maxlen) { /* command too long? */
argerror(cmdbuf);
return(-1);
}
}
}
static int next_line(FILE *handle,char *linebuf,int mode)
{
int toolssection;
char tmpbuf[10];
toolssection = 0;
while (file_gets(linebuf,512,handle) >= 0) {
if (mode == 1 && linebuf[0] == '[') { /* check for [fractint] */
strncpy(tmpbuf,&linebuf[1],9);
tmpbuf[9] = 0;
strlwr(tmpbuf);
toolssection = strncmp(tmpbuf,"fractint]",9);
continue; /* skip tools section heading */
}
if (toolssection == 0) return(0);
}
return(-1);
}
/*
cmdarg(string,mode) processes a single command-line/command-file argument
return:
-1 error, >= 0 ok
if ok, return value:
| 1 means fractal parm has been set
| 2 means 3d parm has been set
| 4 means 3d=yes specified
| 8 means reset specified
*/
int cmdarg(char *curarg,int mode) /* process a single argument */
{
char variable[21]; /* variable name goes here */
char *value; /* pointer to variable value */
int valuelen; /* length of value */
int numval; /* numeric value of arg */
#define NONNUMERIC -32767
char charval; /* first character of arg */
int yesnoval; /* 0 if 'n', 1 if 'y', -1 if not */
double ftemp;
int i, j, k, l;
char *argptr,*argptr2;
int totparms; /* # of / delimited parms */
int intparms; /* # of / delimited ints */
int floatparms; /* # of / delimited floats */
int intval[64]; /* pre-parsed integer parms */
double floatval[16]; /* pre-parsed floating parms */
char tmpc;
int lastarg;
argptr = curarg;
while (*argptr) { /* convert to lower case */
if (*argptr >= 'A' && *argptr <= 'Z')
*argptr += 'a' - 'A';
if (*argptr == '=' && strncmp(curarg,"colors=",7) == 0)
break; /* don't convert colors=value */
++argptr;
}
if ((value = strchr(&curarg[1],'='))) {
if ((j = (value++) - curarg) > 1 && curarg[j-1] == ':')
--j; /* treat := same as = */
}
else
value = curarg + (j = strlen(curarg));
if (j > 20) goto badarg; /* keyword too long */
strncpy(variable,curarg,j); /* get the variable name */
variable[j] = 0; /* truncate variable name */
valuelen = strlen(value); /* note value's length */
charval = value[0]; /* first letter of value */
yesnoval = -1; /* note yes|no value */
if (charval == 'n') yesnoval = 0;
if (charval == 'y') yesnoval = 1;
argptr = value;
numval = totparms = intparms = floatparms = 0;
while (*argptr) { /* count and pre-parse parms */
long ll;
lastarg = 0;
if ((argptr2 = strchr(argptr,'/')) == NULL) { /* find next '/' */
argptr2 = argptr + strlen(argptr);
*argptr2 = '/';
lastarg = 1;
}
if (totparms == 0) numval = NONNUMERIC;
i = -1;
charval = *argptr; /* first letter of value */
if (charval == 'n') yesnoval = 0; /* allows only ONE y/n param */
if (charval == 'y') yesnoval = 1;
if (sscanf(argptr,"%c%c",&j,&tmpc) > 0 /* NULL entry */
&& (j == '/' || j == '=') && tmpc == '/') {
j = 0;
++floatparms; ++intparms;
if (totparms < 16) floatval[totparms] = j;
if (totparms < 64) intval[totparms] = j;
if (totparms == 0) numval = j;
}
else if (sscanf(argptr,"%ld%c",&ll,&tmpc) > 0 /* got an integer */
&& tmpc == '/') { /* needs a long int, ll, here for lyapunov */
++floatparms; ++intparms;
if (totparms < 16) floatval[totparms] = ll;
if (totparms < 64) intval[totparms] = (int)ll;
if (totparms == 0) numval = (int)ll;
}
#ifndef XFRACT
else if (sscanf(argptr,"%lg%c",&ftemp,&tmpc) > 0 /* got a float */
#else
else if (sscanf(argptr,"%lf%c",&ftemp,&tmpc) > 0 /* got a float */
#endif
&& tmpc == '/') {
++floatparms;
if (totparms < 16) floatval[totparms] = ftemp;
}
++totparms;
argptr = argptr2; /* on to the next */
if (lastarg)
*argptr = 0;
else
++argptr;
}
if (mode != 2 || debugflag==110) {
/* these commands are allowed only at startup */
if (strcmp(variable,s_batch) == 0 ) { /* batch=? */
if (yesnoval < 0) goto badarg;
#ifdef XFRACT
initmode = yesnoval?0:-1; /* skip credits for batch mode */
#endif
initbatch = yesnoval;
return 3;
}
#ifndef XFRACT
if (strcmp(variable,s_adapter) == 0 ) { /* adapter==? */
int i, j;
extern char supervga_list; /* from the list in VIDEO.ASM */
char adapter_name[8]; /* entry lenth from VIDEO.ASM */
char *adapter_ptr;
adapter_ptr = &supervga_list;
for(i = 0 ; ; i++) { /* find the SuperVGA entry */
memcpy(adapter_name , adapter_ptr, 8);
adapter_name[6] = ' ';
for (j = 0; j < 8; j++)
if(adapter_name[j] == ' ')
adapter_name[j] = 0;
if (adapter_name[0] == 0) break; /* end-of-the-list */
if (strncmp(value,adapter_name,strlen(adapter_name)) == 0) {
svga_type = i+1;
adapter_ptr[6] = 1;
break;
}
adapter_ptr += 8;
}
if (svga_type != 0) return 3;
video_type = 5; /* assume video=vga */
if (strcmp(value,s_egamono) == 0) {
video_type = 3;
mode7text = 1;
}
else if (strcmp(value,s_hgc) == 0) { /* video = hgc */
video_type = 1;
mode7text = 1;
}
else if (strcmp(value,s_ega) == 0) /* video = ega */
video_type = 3;
else if (strcmp(value,s_cga) == 0) /* video = cga */
video_type = 2;
else if (strcmp(value,s_mcga) == 0) /* video = mcga */
video_type = 4;
else if (strcmp(value,s_vga) == 0) /* video = vga */
video_type = 5;
else
goto badarg;
return 3;
}
if (strcmp(variable,s_afi) == 0) {
if (strncmp(value,"8514" ,4) == 0
|| charval == 'y') ai_8514 = 1; /* set afi flag JCO 4/11/92 */
return 3;
}
if (strcmp(variable,s_textsafe) == 0 ) { /* textsafe==? */
if (first_init) {
if (charval == 'n') /* no */
textsafe = 2;
else if (charval == 'y') /* yes */
textsafe = 1;
else if (charval == 'b') /* bios */
textsafe = 3;
else if (charval == 's') /* save */
textsafe = 4;
else
goto badarg;
}
return 3;
}
if (strcmp(variable,s_vesadetect) == 0) {
if (yesnoval < 0) goto badarg;
vesa_detect = yesnoval;
return 3;
}
if (strcmp(variable,s_biospalette) == 0) {
if (yesnoval < 0) goto badarg;
bios_palette = yesnoval;
return 3;
}
if (strcmp(variable,s_fpu) == 0) {
if (strcmp(value,s_iit) == 0) {
fpu = 387;
iit = 1;
return 0;
}
if (strcmp(value,s_noiit) == 0) {
iit = -2;
return 0;
}
if (strcmp(value,s_387) == 0) {
fpu = 387;
iit = -2;
return 0;
}
goto badarg;
}
#endif
if (strcmp(variable,s_exitnoask) == 0) {
if (yesnoval < 0) goto badarg;
escape_exit = yesnoval;
return 3;
}
if (strcmp(variable,s_makedoc) == 0) {
print_document(*value ? value : "fractint.doc", makedoc_msg_func, 0);
#ifndef WINFRACT
goodbye();
#endif
}
} /* end of commands allowed only at startup */
if (strcmp(variable,s_reset) == 0) {
initvars_fractal();
/* PAR release unknown unless specified */
if (numval>=0) save_release = numval;
else goto badarg;
return 9;
}
if (strcmp(variable,s_filename) == 0) { /* filename=? */
if (charval == '.') {
if (valuelen > 4) goto badarg;
gifmask[0] = '*';
gifmask[1] = 0;
strcat(gifmask,value);
return 0;
}
if (valuelen > 79) goto badarg;
if (mode == 2 && display3d == 0) /* can't do this in @ command */
goto badarg;
strcpy(readname,value);
showfile = 0;
return 3;
}
if (strcmp(variable,s_video) == 0) { /* video=? */
if (active_system == 0) {
if ((k = check_vidmode_keyname(value)) == 0) goto badarg;
initmode = -1;
for (i = 0; i < MAXVIDEOTABLE; ++i) {
if (videotable[i].keynum == k) {
initmode = i;
break;
}
}
if (initmode == -1) goto badarg;
}
return 3;
}
if (strcmp(variable,s_map) == 0 ) { /* map=, set default colors */
if (valuelen > 79 || SetColorPaletteName(value) != 0) goto badarg;
mapset = 1;
strcpy(MAP_name,value);
return 0;
}
if (strcmp(variable,s_colors) == 0) { /* colors=, set current colors */
if (parse_colors(value) < 0) goto badarg;
return 0;
}
if (strcmp(variable,s_tplus) == 0) { /* Use the TARGA+ if found? */
if (yesnoval < 0) goto badarg;
TPlusFlag = yesnoval;
return 0;
}
if (strcmp(variable,s_noninterlaced) == 0) {
if (yesnoval < 0) goto badarg;
NonInterlaced = yesnoval;
return 0;
}
if (strcmp(variable,s_maxcolorres) == 0) { /* Change default color resolution */
if (numval == 1 || numval == 4 || numval == 8 ||
numval == 16 || numval == 24) {
MaxColorRes = numval;
return 0;
}
goto badarg;
}
if (strcmp(variable,s_pixelzoom) == 0) {
if (numval < 5)
PixelZoom = numval;
return 0;
}
/* keep this for backward compatibility */
if (strcmp(variable,s_warn) == 0 ) { /* warn=? */
if (yesnoval < 0) goto badarg;
overwrite = yesnoval ^ 1;
return 0;
}
if (strcmp(variable,s_overwrite) == 0 ) { /* overwrite=? */
if (yesnoval < 0) goto badarg;
overwrite = yesnoval;
return 0;
}
if (strcmp(variable,s_gif87a) == 0 ) { /* gif87a=? */
if (yesnoval < 0) goto badarg;
gif87a_flag = yesnoval;
return 0;
}
if (strcmp(variable,s_dither) == 0 ) { /* dither=? */
if (yesnoval < 0) goto badarg;
dither_flag = yesnoval;
return 0;
}
if (strcmp(variable,s_savetime) == 0) { /* savetime=? */
initsavetime = numval;
return 0;
}
if (strcmp(variable,s_autokey) == 0) { /* autokey=? */
if (strcmp(value,s_record)==0)
slides=2;
else if (strcmp(value,s_play)==0)
slides=1;
else
goto badarg;
return 0;
}
if(strcmp(variable,s_solidcore) == 0) {
SolidCore = yesnoval;
return(0);
}
/* (nuked until antialiasing become an option)
if(strcmp(variable,s_antialias) == 0) {
if(numval < 0 || numval > 8)
goto badarg;
AntiAliasing = numval;
return(0);
}
*/
if(strcmp(variable,s_transparent3d) == 0) {
Transparent3D = yesnoval;
return(0);
}
if(strcmp(variable,s_corecolor) == 0) {
if(floatparms != totparms || totparms != 3)
goto badarg;
CoreRed = (int)floatval[0];
CoreGreen = (int)floatval[1];
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -