📄 prompts2.c
字号:
return(-1);
}
spindac(0,1); /* load it, but don't spin */
for(row = 0; row < ydots; row++) {
for(col = 0; col < xdots; col++) {
if(keypressed()) {
buzzer(1);
busy = 0;
return(1);
}
c = getcolor(col, row);
if(c == inside)
c = colors-1;
putcolor(col, row, GausianNumber(c, colors));
}
}
buzzer(0);
busy = 0;
return(0);
}
int get_starfield_params(void) {
static char far hdg[]={"Starfield Parameters"};
struct fullscreenvalues uvalues[3];
int oldhelpmode, status;
int i;
ENTER_OVLY(OVLY_PROMPTS2);
if(colors < 255) {
static char far msg[]={"starfield requires 256 color mode"};
stopmsg(0,msg);
EXIT_OVLY;
return(-1);
}
for (i = 0; i < 3; i++) {
uvalues[i].uval.dval = starfield_values[i];
uvalues[i].type = 'f';
}
stackscreen();
oldhelpmode = helpmode;
helpmode = HELPSTARFLD;
i = fullscreen_prompt(hdg,3,starfield_prompts,uvalues,0,0,NULL);
helpmode = oldhelpmode;
if (i < 0) {
unstackscreen();
EXIT_OVLY;
return(-1);
}
unstackscreen();
for (i = 0; i < 3; i++)
starfield_values[i] = uvalues[i].uval.dval;
EXIT_OVLY;
return(0);
}
int get_a_number(double *x, double *y)
{
static char far hdg[]={"Set Cursor Coordinates"};
double x1,y2;
char far *choices[2];
int oldhelpmode;
struct fullscreenvalues uvalues[2];
int i, k;
ENTER_OVLY(OVLY_PROMPTS2);
stackscreen();
/* fill up the previous values arrays */
k = -1;
LOADCHOICES("X coordinate at cursor");
uvalues[k].type = 'd';
uvalues[k].uval.dval = *x;
LOADCHOICES("Y coordinate at cursor");
uvalues[k].type = 'd';
uvalues[k].uval.dval = *y;
i = fullscreen_prompt(hdg,k+1,choices,uvalues,0,25,NULL);
if (i < 0) {
unstackscreen();
EXIT_OVLY;
return(-1);
}
/* now check out the results (*hopefully* in the same order <grin>) */
k = -1;
*x = uvalues[++k].uval.dval;
*y = uvalues[++k].uval.dval;
unstackscreen();
EXIT_OVLY;
return(i);
}
/* --------------------------------------------------------------------- */
int get_commands() /* execute commands from file */
{
int ret;
FILE *parmfile;
long point;
int oldhelpmode;
ENTER_OVLY(OVLY_PROMPTS2);
ret = 0;
oldhelpmode = helpmode;
helpmode = HELPPARMFILE;
if ((point = get_file_entry(GETPARM,"Parameter Set",
commandmask,CommandFile,CommandName)) >= 0
&& (parmfile = fopen(CommandFile,"rb"))) {
fseek(parmfile,point,SEEK_SET);
ret = load_commands(parmfile);
}
helpmode = oldhelpmode;
EXIT_OVLY;
return(ret);
}
/* --------------------------------------------------------------------- */
void goodbye() /* we done. Bail out */
{
static char far goodbyemessage[]={" Thank You for using FRACTINT"};
extern BYTE exitmode;
extern int mode7text;
extern int made_dsktemp;
#ifndef XFRACT
union REGS r;
#endif
#ifdef WINFRACT
return;
#endif
setvideotext();
#ifdef XFRACT
UnixDone();
printf("\n\n\n%s\n",goodbyemessage); /* printf takes far pointer */
#else
r.h.al = (mode7text == 0) ? exitmode : 7;
r.h.ah = 0;
int86(0x10, &r, &r);
printf("\n\n\n%Fs\n",goodbyemessage); /* printf takes far pointer */
#endif
movecursor(6,0);
discardgraphics(); /* if any emm/xmm tied up there, release it */
stopslideshow();
#ifndef XFRACT
if (made_dsktemp)
remove(diskfilename);
#endif
end_help();
if (initbatch == 3) /* exit with error code for batch file */
exit(2);
else if (initbatch == 4)
exit(1);
else
exit(0);
}
/* --------------------------------------------------------------------- */
#ifdef XFRACT
static char searchdir[FILE_MAX_DIR];
static char searchname[FILE_MAX_PATH];
static char searchext[FILE_MAX_EXT];
static DIR *currdir = NULL;
#endif
static int findfirst(char *path) /* Find 1st file (or subdir) meeting path/filespec */
{
#ifndef XFRACT
union REGS regs;
regs.h.ah = 0x1A; /* Set DTA to filedata */
regs.x.dx = (unsigned)&DTA;
intdos(®s, ®s);
regs.h.ah = 0x4E; /* Find 1st file meeting path */
regs.x.dx = (unsigned)path;
regs.x.cx = FILEATTR;
intdos(®s, ®s);
return(regs.x.ax); /* Return error code */
#else
if (currdir != NULL) {
closedir(currdir);
currdir = NULL;
}
splitpath(path,NULL,searchdir,searchname,searchext);
if (searchdir[0]=='\0') {
currdir = opendir(".");
} else {
currdir = opendir(searchdir);
}
if (currdir==NULL) {
return -1;
} else {
return findnext();
}
#endif
}
static int findnext() /* Find next file (or subdir) meeting above path/filespec */
{
#ifndef XFRACT
union REGS regs;
regs.h.ah = 0x4F; /* Find next file meeting path */
regs.x.dx = (unsigned)&DTA;
intdos(®s, ®s);
return(regs.x.ax);
#else
#ifdef DIRENT
struct dirent *dirEntry;
#else
struct direct *dirEntry;
#endif
struct stat sbuf;
char thisname[FILE_MAX_PATH];
char tmpname[FILE_MAX_PATH];
char thisext[FILE_MAX_EXT];
while (1) {
dirEntry = readdir(currdir);
if (dirEntry == NULL) {
closedir(currdir);
currdir = NULL;
return -1;
} else if (dirEntry->d_ino != 0) {
splitpath(dirEntry->d_name,NULL,NULL,thisname,thisext);
if ((searchname[0]=='*' || strcmp(searchname,thisname)==0) &&
(searchext[0]=='*' || strcmp(searchext,thisext)==0)) {
strncpy(DTA.filename,dirEntry->d_name,20);
DTA.filename[20]=='\0';
strcpy(tmpname,searchdir);
strcat(tmpname,"/");
strcat(tmpname,dirEntry->d_name);
stat(tmpname,&sbuf);
if ((sbuf.st_mode&S_IFMT)==S_IFREG) {
DTA.attribute = 0;
} else if ((sbuf.st_mode&S_IFMT)==S_IFDIR) {
DTA.attribute = SUBDIR;
} else {
continue;
}
DTA.size = sbuf.st_size;
return 0;
}
}
}
#endif
}
int lccompare(VOIDCONSTPTR arg1, VOIDCONSTPTR arg2) /* for qsort */
{
return(strncasecmp(*((char **)arg1),*((char **)arg2),40));
}
static char *masks[] = {"*.pot","*.gif"};
static int speedstate;
int getafilename(char *hdg,char *template,char *flname)
{
static char far instr[]={"Press F6 for default or environment directory"};
int masklen;
char filename[13];
char speedstr[81];
char tmpmask[FILE_MAX_PATH]; /* used to locate next file in list */
static int numtemplates = 1;
int i,j;
int out;
int retried;
struct CHOICE
{
char name[13];
char type;
}
*choices[MAXNUMFILES];
int attributes[MAXNUMFILES];
int filecount; /* how many files */
int dircount; /* how many directories */
int notroot; /* not the root directory */
char drive[FILE_MAX_DRIVE];
char dir[FILE_MAX_DIR];
char fname[FILE_MAX_FNAME];
char ext[FILE_MAX_EXT];
ENTER_OVLY(OVLY_PROMPTS2);
/* steal existing array for "choices" */
choices[0] = (struct CHOICE *)boxy;
attributes[0] = 1;
for(i=1;i<MAXNUMFILES;i++)
{
choices[i] = choices[i-1] + 1;
attributes[i] = 1;
}
restart: /* return here if template or directory changes */
tmpmask[0] = 0;
if(flname[0] == 0)
strcpy(flname,DOTSLASH);
splitpath(flname ,drive,dir,fname,ext);
makepath(filename,"" ,"" ,fname,ext);
retried = 0;
retry_dir:
if (dir[0] == 0)
strcpy(dir,".");
expand_dirname(dir,drive);
makepath(tmpmask,drive,dir,"","");
fix_dirname(tmpmask);
if (retried == 0 && strcmp(dir,SLASH) && strcmp(dir,DOTSLASH))
{
tmpmask[(j = strlen(tmpmask) - 1)] = 0; /* strip trailing \ */
if (strchr(tmpmask,'*') || strchr(tmpmask,'?')
|| findfirst(tmpmask) != 0
|| (DTA.attribute & SUBDIR) == 0)
{
strcpy(dir,DOTSLASH);
++retried;
goto retry_dir;
}
tmpmask[j] = SLASHC;
}
if(template[0])
{
numtemplates = 1;
splitpath(template,NULL,NULL,fname,ext);
}
else
numtemplates = sizeof(masks)/sizeof(masks[0]);
filecount = -1;
dircount = 0;
notroot = 0;
j = 0;
masklen = strlen(tmpmask);
strcat(tmpmask,"*.*");
out = findfirst(tmpmask);
while(out == 0 && filecount < MAXNUMFILES)
{
if((DTA.attribute & SUBDIR) && strcmp(DTA.filename,"."))
{
#ifndef XFRACT
strlwr(DTA.filename);
#endif
if(strcmp(DTA.filename,".."))
strcat(DTA.filename,SLASH);
strncpy(choices[++filecount]->name,DTA.filename,13);
choices[filecount]->name[12] = '\0';
choices[filecount]->type = 1;
dircount++;
if(strcmp(DTA.filename,"..")==0)
notroot = 1;
}
out = findnext();
}
tmpmask[masklen] = 0;
if(template[0])
makepath(tmpmask,drive,dir,fname,ext);
do
{
if(numtemplates > 1)
strcpy(&(tmpmask[masklen]),masks[j]);
out = findfirst(tmpmask);
while(out == 0 && filecount < MAXNUMFILES)
{
if(!(DTA.attribute & SUBDIR))
{
strlwr(DTA.filename);
strncpy(choices[++filecount]->name,DTA.filename,13);
choices[filecount]->type = 0;
}
out = findnext();
}
}
while (++j < numtemplates);
if (++filecount == 0)
{
strcpy(choices[filecount]->name,"*nofiles*");
choices[filecount]->type = 0;
++filecount;
}
qsort(choices,filecount,sizeof(char *),lccompare); /* sort type list */
if(notroot == 0 && dir[0] && dir[0] != SLASHC) /* must be in root directory */
{
splitpath(tmpmask,drive,dir,fname,ext);
strcpy(dir,SLASH);
makepath(tmpmask,drive,dir,fname,ext);
}
if(numtemplates > 1)
strcat(tmpmask," *.pot");
strcpy(temp1,hdg);
strcat(temp1,"\nTemplate: ");
strcat(temp1,tmpmask);
strcpy(speedstr,filename);
if (speedstr[0] == 0)
{
for (i=0; i<filecount; i++) /* find first file */
if (choices[i]->type == 0)
break;
if (i >= filecount)
i = 0;
}
i = fullscreen_choice(8,temp1,NULL,instr,filecount,(char **)choices,
attributes,5,99,12,i,NULL,speedstr,filename_speedstr,check_f6_key);
if (i==-F6)
{
static int lastdir=0;
if (lastdir==0)
{
strcpy(dir,fract_dir1);
}
else
{
strcpy(dir,fract_dir2);
}
fix_dirname(dir);
makepath(flname,drive,dir,"","");
lastdir = 1-lastdir;
goto restart;
}
if (i < 0)
{
EXIT_OVLY;
return(-1);
}
if(speedstr[0] == 0 || speedstate == MATCHING)
{
if(choices[i]->type)
{
if(strcmp(choices[i]->name,"..") == 0) /* go up a directory */
{
if(strcmp(dir,DOTSLASH) == 0)
strcpy(dir,DOTDOTSLASH);
else
{
char *s;
if(s = strrchr(dir,SLASHC)) /* trailing slash */
{
*s = 0;
if(s = strrchr(dir,SLASHC))
*(s+1) = 0;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -