📄 prompts2.c
字号:
/*
Various routines that prompt for things.
This module is linked as an overlay, use ENTER_OVLY and EXIT_OVLY.
*/
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#ifndef XFRACT
#include <dos.h>
#elif !defined(__386BSD__)
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/dir.h>
#endif
#ifdef __TURBOC__
#include <alloc.h>
#elif !defined(__386BSD__)
#include <malloc.h>
#endif
#ifdef __hpux
#include <sys/param.h>
#define getwd(a) getcwd(a,MAXPATHLEN)
#endif
#include "fractint.h"
#include "fractype.h"
#include "helpdefs.h"
#include "prototyp.h"
/* Routines defined in prompts1.c */
extern int prompt_checkkey(int curkey);
extern long get_file_entry(int,char *,char *,char *,char *);
/* Routines used in prompts1.c */
int get_corners(void);
int edit_ifs_params(void );
int lccompare(VOIDCONSTPTR, VOIDCONSTPTR); /* Needed in prompts1.c PAV */
/* Routines in this module */
static int findfirst(char *path);
static int check_f6_key(int curkey,int choice);
static int findnext(void );
int splitpath(char *template,char *drive,char *dir,char *fname,char *ext);
int makepath(char *template,char *drive,char *dir,char *fname,char *ext);
static void fix_dirname(char *dirname);
static int expand_dirname(char *dirname,char *drive);
static int filename_speedstr(int, int, int, char *, int);
static int isadirectory(char *s);
static int check_f6_key(int curkey,int choice);
extern int dotmode;
extern int orbit_delay;
extern char diskfilename[];
extern char *fract_dir1, *fract_dir2;
#ifndef XFRACT
extern int strncasecmp(char *s,char *t,int ct);
#endif
extern char temp1[256]; /* temporary strings */
extern double xxmin,xxmax; /* initial corner values */
extern double yymin,yymax; /* initial corner values */
extern BYTE usemag;
extern int AntiAliasing;
extern double zzmin, zzmax, ttmin, ttmax;
extern int Transparent3D;
extern double xx3rd,yy3rd; /* initial corner values */
extern int invert; /* non-zero if inversion active */
extern double inversion[3]; /* radius, xcenter, ycenter */
extern int pot16bit;
extern int disk16bit;
extern double potparam[3]; /* three potential parameters*/
extern int fractype; /* if == 0, use Mandelbrot */
extern char usr_floatflag; /* floating-point fractals? */
extern int maxit; /* try this many iterations */
extern int inside; /* inside color */
extern int fillcolor; /* fill color */
extern int outside; /* outside color */
extern int finattract; /* finite attractor switch */
extern char savename[80]; /* save files using this name */
extern int decomp[]; /* decomposition parameters */
extern int usr_distest; /* distance estimator option */
extern int distestwidth;
extern char usr_stdcalcmode; /* '1', '2', 'g', 'b' */
extern char overwrite; /* overwrite= flag */
extern int soundflag; /* sound option */
extern int LogFlag; /* non-zero if logarithmic palettes */
extern int usr_biomorph; /* Biomorph flag */
#if 0
//extern long xmin, xmax, ymin, ymax; /* screen corner values */
#endif
extern int xdots, ydots; /* coordinates of dots on the screen */
extern int colors; /* maximum colors available */
extern int row, col;
extern int viewwindow;
extern float viewreduction;
extern int viewcrop;
extern float finalaspectratio;
extern int viewxdots,viewydots;
extern int textcbase;
extern int textrow,textcol;
extern int resave_flag; /* resaving after a timed save */
extern int started_resaves;
extern char boxy[];
extern int rotate_lo,rotate_hi;
extern int rangeslen;
extern float screenaspect;
extern int cmdarg(char *,int);
extern char CommandFile[];
extern char CommandName[];
extern float far *ifs_defn;
extern int ifs_type;
extern int ifs_changed;
extern int initbatch; /* 1 if batch run (no kbd) */
/* speed key state values */
#define MATCHING 0 /* string matches list - speed key mode */
#define TEMPLATE -2 /* wild cards present - buiding template */
#define SEARCHPATH -3 /* no match - building path search name */
#define FILEATTR 0x37 /* File attributes; select all but volume labels */
#define HIDDEN 2
#define SYSTEM 4
#define SUBDIR 16
#define MAXNUMFILES 300
struct /* Allocate DTA and define structure */
{
char path[21]; /* DOS path and filespec */
char attribute; /* File attributes wanted */
int ftime; /* File creation time */
int fdate; /* File creation date */
long size; /* File size in bytes */
char filename[13]; /* Filename and extension */
} DTA; /* Disk Transfer Area */
#define GETFORMULA 0
#define GETLSYS 1
#define GETIFS 2
#define GETPARM 3
/* --------------------------------------------------------------------- */
extern char s_iter[];
extern char s_real[];
extern char s_mult[];
extern char s_sum[];
extern char s_imag[];
extern char s_zmag[];
extern char s_bof60[];
extern char s_bof61[];
extern char s_maxiter[];
extern char s_epscross[];
extern char s_startrail[];
extern char s_normal[];
extern char s_period[];
char commandmask[13] = {"*.par"};
void prompts2_overlay() { } /* for restore_active_ovly */
#if 0
/* --------------------------------------------------------------------- */
extern int promptfkeys;
int edit_ifs_params() /* prompt for IFS params */
{
int totcols;
int i, j, k, numlines, ret;
FILE *tempfile;
char msg[81];
char filename[81];
float ftemp;
int oldhelpmode;
int low, hi;
if (!ifs_defn && !ifsload())
return(-1);
totcols = (ifs_type == 0) ? IFSPARM : IFS3DPARM;
ret = 0;
oldhelpmode = helpmode;
helpmode = HT_IFS;
low = 0;
for ( ;; ) {
static char far ifshdg2[]={"2D IFS Parameters"};
static char far ifshdg3[]={"3D IFS Parameters"};
static char far ifsparmmsg1[]={"# a b c d e f"};
static char far ifsparmmsg2[]={" g h i j k l"};
static char far ifsprompt[]={"\
Enter the number of the line you want to edit,\n\
S to save, F6 for corners, or ENTER to end ==>"};
int leftcol,promptrow,promptcol;
#define IFS_NUM 12
for (numlines = 0; numlines < NUMIFS; numlines++) /* find the first zero entry */
if (ifs_defn[(numlines * totcols) + totcols - 1] <= 0.0001) break;
helptitle();
setattr(1,0,C_PROMPT_BKGRD,24*80); /* init rest of screen to background */
putstringcenter(2,0,80,C_GENERAL_HI,(ifs_type == 0) ? ifshdg2 : ifshdg3);
leftcol = (ifs_type == 0) ? 15 : 0;
putstring(4,leftcol+1,C_GENERAL_HI,ifsparmmsg1);
if (ifs_type != 0)
putstring(-1,-1,C_GENERAL_HI,ifsparmmsg2);
putstring(-1,-1,C_GENERAL_HI," prob \n\n");
hi = low+IFS_NUM;
if (hi>numlines) hi = numlines;
for (i = low; i < hi; i++) {
sprintf(msg,"%2d", i+1);
putstring(5+i-low,leftcol,C_GENERAL_HI,msg);
for (j = 0; j < totcols; j++) {
sprintf(msg,"%6.2f",ifs_defn[(i*totcols)+j]);
putstring(-1,-1,C_GENERAL_MED,msg);
}
}
if (hi<numlines) {
putstring(5+IFS_NUM,leftcol,C_GENERAL_HI,"(more)");
}
textcbase = 14;
putstring(5+i-low+1,0,C_GENERAL_HI,ifsprompt);
promptrow = textrow;
promptcol = textcol + textcbase + 1;
temp1[0] = textcbase = 0;
promptfkeys = 1<<6;
i = input_field(0,C_GENERAL_INPUT,temp1,2,promptrow,promptcol,
prompt_checkkey);
if (i<0) {
break;
} else if (i==PAGE_UP) {
low -= IFS_NUM;
if (low<0) low=0;
} else if (i==UP_ARROW) {
low -= 1;
if (low<0) low=0;
} else if (i==DOWN_ARROW) {
low += 1;
if (low+IFS_NUM>numlines) low=numlines-IFS_NUM;
if (low<0) low=0;
} else if (i==PAGE_DOWN) {
low += IFS_NUM;
if (low+IFS_NUM>numlines) low=numlines-IFS_NUM;
if (low<0) low=0;
} else if (i==F6) {
if (get_corners()) {
ret = 1;
}
} else if (i==0) {
if (temp1[0]==0) break;
} else {
continue;
}
putstring(promptrow,promptcol,C_GENERAL_HI,temp1);
if (temp1[0] == 's' || temp1[0] == 'S') {
stackscreen();
filename[0] = 0;
i = field_prompt(0,"Enter the name of the .IFS file to save:",
NULL,filename,60,NULL);
unstackscreen();
if (i != -1) {
if (strchr(filename,'.') == NULL)
strcat(filename,".ifs");
if ((tempfile=fopen(filename,"w")) != NULL) {
for (i = 0; i < numlines; i++) {
for (j = 0; j < totcols; j++)
fprintf(tempfile, "%6.2f", (float)ifs_defn[(i*totcols)+j]);
fprintf(tempfile, "\n");
}
fclose(tempfile);
ifs_changed = 0;
}
else {
static char far msg[]={"Could not create file"};
stopmsg(0,msg);
}
}
continue;
}
i = atoi(temp1) - 1;
if (i >= 0 && i < numlines) {
for (j = 0; j < totcols; j++) {
if (j < totcols-1)
sprintf(msg,"Parameter %c",'a'+j);
else
sprintf(msg,"Probability");
putstring(promptrow+2,25,C_GENERAL_HI,msg);
sprintf(temp1,"%6.2f",(float)ifs_defn[k=(i*totcols)+j]);
if (input_field(1,C_GENERAL_INPUT,temp1,6,
textrow,textcol+1,NULL) < 0)
break;
if (ifs_defn[k] != (ftemp = atof(temp1))) {
ifs_defn[k] = ftemp;
ret = ifs_changed = 1;
}
}
memset(msg,' ',80); msg[81] = 0;
putstring(promptrow+2,0,C_PROMPT_BKGRD,msg);
}
}
helpmode = oldhelpmode;
return(ret);
}
#endif
/* --------------------------------------------------------------------- */
/*
get_toggles() is called from FRACTINT.C whenever the 'x' key
is pressed. This routine prompts for several options,
sets the appropriate variables, and returns the following code
to the calling routine:
-1 routine was ESCAPEd - no need to re-generate the image.
0 nothing changed, or minor variable such as "overwrite=".
No need to re-generate the image.
1 major variable changed (such as "inside="). Re-generate
the image.
Finally, remember to insert variables in the list *and* check
for them in the same order!!!
*/
#define LOADCHOICES(X) {\
static char far tmp[] = { X };\
choices[++k]= tmp;\
}
int get_toggles()
{
static char far hdg[]={" Basic Options\n\
(not all combinations make sense)"};
char far *choices[20];
int oldhelpmode;
char prevsavename[81];
struct fullscreenvalues uvalues[25];
int i, j, k;
char old_usr_stdcalcmode;
int old_maxit,old_inside,old_outside,old_soundflag;
int old_logflag,old_biomorph,old_decomp;
int old_fillcolor;
static char *calcmodes[] ={"1","2","g","b","t"};
static char *soundmodes[5]={"yes","no","x","y","z"};
ENTER_OVLY(OVLY_PROMPTS2);
k = -1;
LOADCHOICES("Passes (1, 2, g[uessing], b[oundary trace], t[esseral])");
uvalues[k].type = 'l';
uvalues[k].uval.ch.vlen = 3;
uvalues[k].uval.ch.llen = sizeof(calcmodes)/sizeof(*calcmodes);
uvalues[k].uval.ch.list = calcmodes;
uvalues[k].uval.ch.val = (usr_stdcalcmode == '1') ? 0
: (usr_stdcalcmode == '2') ? 1
: (usr_stdcalcmode == 'g') ? 2
: (usr_stdcalcmode == 'b') ? 3 :4 ;
old_usr_stdcalcmode = usr_stdcalcmode;
LOADCHOICES("Floating Point Algorithm");
uvalues[k].type = 'y';
uvalues[k].uval.ch.val = usr_floatflag;
LOADCHOICES("Maximum Iterations (2 to 32767)");
uvalues[k].type = 'i';
uvalues[k].uval.ival = old_maxit = maxit;
LOADCHOICES("Inside Color (<nnn>,maxiter,zmag,bof60,bof61,epscr,star,per)");
uvalues[k].type = 's';
if(inside == -59)
strcpy(uvalues[k].uval.sval,s_zmag);
else if(inside == -60)
strcpy(uvalues[k].uval.sval,s_bof60);
else if(inside == -61)
strcpy(uvalues[k].uval.sval,s_bof61);
else if(inside == -100)
strcpy(uvalues[k].uval.sval,s_epscross);
else if(inside == -101)
strcpy(uvalues[k].uval.sval,s_startrail);
else if(inside == -102)
strcpy(uvalues[k].uval.sval,s_period);
else if(inside == -1)
strcpy(uvalues[k].uval.sval,s_maxiter);
else
sprintf(uvalues[k].uval.sval,"%d",inside);
old_inside = inside;
LOADCHOICES("Outside Color (<nnn>,iter,real,imag,mult,summ)");
uvalues[k].type = 's';
if(outside == -1)
strcpy(uvalues[k].uval.sval,s_iter);
else if(outside == -2)
strcpy(uvalues[k].uval.sval,s_real);
else if(outside == -3)
strcpy(uvalues[k].uval.sval,s_imag);
else if(outside == -4)
strcpy(uvalues[k].uval.sval,s_mult);
else if(outside == -5)
strcpy(uvalues[k].uval.sval,s_sum);
else
sprintf(uvalues[k].uval.sval,"%d",outside);
old_outside = outside;
LOADCHOICES("Savename (.GIF implied)");
uvalues[k].type = 's';
strcpy(prevsavename,savename);
strcpy(uvalues[k].uval.sval,savename);
LOADCHOICES("File Overwrite ('overwrite=')");
uvalues[k].type = 'y';
uvalues[k].uval.ch.val = overwrite;
LOADCHOICES("Sound (no, yes, x, y, z)");
uvalues[k].type = 'l';
uvalues[k].uval.ch.vlen = 3;
uvalues[k].uval.ch.llen = 5;
uvalues[k].uval.ch.list = soundmodes;
uvalues[k].uval.ch.val = 1 + (old_soundflag = soundflag);
if (rangeslen == 0) {
LOADCHOICES("Log Palette (0=no,1=yes,-1=old,+n=cmprsd,-n=sqrt)");
uvalues[k].type = 'i';
}
else {
LOADCHOICES("Log Palette (n/a, ranges= parameter is in effect)");
uvalues[k].type = '*';
}
uvalues[k].uval.ival = old_logflag = LogFlag;
LOADCHOICES("Biomorph Color (-1 means OFF)");
uvalues[k].type = 'i';
uvalues[k].uval.ival = old_biomorph = usr_biomorph;
LOADCHOICES("Decomp Option (2,4,8,..,256, 0=OFF)");
uvalues[k].type = 'i';
uvalues[k].uval.ival = old_decomp = decomp[0];
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -