⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 windos.c

📁 frasr200的win 版本源码(18.21),使用make文件,使用的vc版本较低,在我的环境下编译有问题! 很不错的分形程序代码!
💻 C
📖 第 1 页 / 共 2 页
字号:

time_to_load = 0;

    start_wait();
    if ((i = read_overlay()) >= 0 && (!win_display3d ||
	xdots < filexdots || ydots < fileydots)) {
	if (win_display3d) stopmsg(0,
	    "3D and Overlay3D file image sizes must be\nat least as large as the display image.\nAltering your display image to match the file.");
	xdots = filexdots;
	ydots = fileydots;
	colors = filecolors;
	if (colors > 16) colors = 256;
	if (colors >  2 && colors < 16) colors = 16;
	if (xdots < 50) xdots = 50;
	if (xdots > 2048) xdots = 2048;
	if (ydots < 50) ydots = 50;
	if (ydots > 2048) ydots = 2048;
	set_win_offset();
	clear_screen(0);
	}
    end_wait();
    return(i);
}

win_save()
{
    time_to_save = 0;
    save_system = 1;
    save_release = win_release;

    /* MCP 10-27-91 */
    if(FileFormat != ID_BMP)
       savetodisk(readname);
    else
       SaveBitmapFile(hwnd, FullPathName);
    CloseStatusBox();
}

/*
	Delay code - still not so good for a multi-tasking environment, 
	but what the hell...
*/

DWORD DelayCount;

DWORD DelayMillisecond(void)
{
   DWORD i;

   i = 0;
   while(i != DelayCount)
      i++;
   return(i);
}

void delay(DWORD milliseconds)
{
   DWORD n, i, j;

if (DelayCount == 0) {      /* use version 3.1's 1ms timer */

    TIMERINFO timerinfo;

    timerinfo.dwSize = sizeof(timerinfo);
    TimerCount(&timerinfo);
    n = timerinfo.dwmsSinceStart;
    i = n + milliseconds;
    for (;;) {
        keypressed();        /* let the other folks in */
        TimerCount(&timerinfo);
        j = timerinfo.dwmsSinceStart;
        if (j < n || j >= i)
            break;
        }   

   }
else {
   for(n = 0; n < milliseconds; n++)
      DelayMillisecond();
   }

}

void CalibrateDelay(void)
{
    DWORD Now, Time, Delta, TimeAdj;
    
    /* this logic switches tothe fast timer logic supplied by TimerCount */
    DelayCount = 0;
    return;

   DelayCount = 128;

   /* Determine the Windows timer resolution.  It's usually 38ms in
      version 3.0, but that may change latter. */
   Now = Time = GetCurrentTime();
   while(Time == Now)
      Now = GetCurrentTime();

   /* Logrithmic Adjust */
   Delta = Now - Time;
   Time = Now;
   while(Time == Now)
   {
      delay(Delta);
      Now = GetCurrentTime();
      if(Time == Now)
      {
         /* Resynch */
         Time = Now = GetCurrentTime();
         while(Time == Now)
            Now = GetCurrentTime();
         Time = Now;
         DelayCount <<= 1;
      }
   }

   /* Linear Adjust */
   Time = Now;
   TimeAdj = (DelayCount - (DelayCount >> 1)) >> 1;
   DelayCount -= TimeAdj;
   while(TimeAdj > 16)
   {
      delay(Delta);
      TimeAdj >>= 1;
      if(GetCurrentTime() == Now)
         DelayCount += TimeAdj;
      else
         DelayCount -= TimeAdj;

      /* Resynch */
      Time = Now = GetCurrentTime();
      while(Time == Now)
         Now = GetCurrentTime();
      Time = Now;
   }
}

/*
	Color-cycling logic
	includes variable-delay capabilities
*/

extern int win_cycledir, win_cyclerand, win_cyclefreq, win_cycledelay;

extern HANDLE  hPal;	   /* Palette Handle */
extern LPLOGPALETTE pLogPal;  /* pointer to the application's logical palette */
extern unsigned char far win_dacbox[256][3];
#define PALETTESIZE 256 	      /* dull-normal VGA		    */

static int win_fsteps[] = {54, 24, 8};

int win_animate_flag = 0;
int win_syscolorindex[21];
DWORD win_syscolorold[21];
DWORD win_syscolornew[21];

extern int debugflag;

win_cycle()
{
int istep, jstep, fstep, step, oldstep, last, next, maxreg;
int incr, fromred, fromblue, fromgreen, tored, toblue, togreen;
HDC hDC;		      /* handle to device context	    */

fstep = 1;				/* randomization frequency	*/
oldstep = 1;				/* single-step			*/
step = 256;				/* single-step			*/
incr = 999;				/* ready to randomize		*/
maxreg = 256;				/* maximum register to rotate	*/
last = maxreg-1;			/* last box that was filled	*/
next = 1;				/* next box to be filled	*/
if (win_cycledir < 0) {
	last = 1;
	next = maxreg;
	}

win_title_text(2);

srand((unsigned)time(NULL));		/* randomize things		*/

hDC = GetDC(GetFocus());

win_animate_flag = 1;
SetPaletteEntries(hPal, 0, pLogPal->palNumEntries, pLogPal->palPalEntry);
SelectPalette (hDC, hPal, 1);

if ((iNumColors == 16 || debugflag == 1000) && !win_systempaletteused) {
    int i;
    DWORD white, black;
    win_systempaletteused = TRUE;
    white = 0xffffff00;
    black = 0;
    for (i = 0; i <= COLOR_ENDCOLORS; i++) {
	win_syscolorindex[i] = i;
	win_syscolorold[i] = GetSysColor(i);
	win_syscolornew[i] = black;
	}
    win_syscolornew[COLOR_BTNTEXT] = white;
    win_syscolornew[COLOR_CAPTIONTEXT] = white;
    win_syscolornew[COLOR_GRAYTEXT] = white;
    win_syscolornew[COLOR_HIGHLIGHTTEXT] = white;
    win_syscolornew[COLOR_MENUTEXT] = white;
    win_syscolornew[COLOR_WINDOWTEXT] = white;
    win_syscolornew[COLOR_WINDOWFRAME] = white;
    win_syscolornew[COLOR_INACTIVECAPTION] = white;
    win_syscolornew[COLOR_INACTIVEBORDER] = white;
    SetSysColors(COLOR_ENDCOLORS,(LPINT)win_syscolorindex,(LONG FAR *)win_syscolornew);
    SetSystemPaletteUse(hDC,SYSPAL_NOSTATIC);
    UnrealizeObject(hPal);
    }

while (time_to_cycle) {
    if (win_cyclerand) {
	for (istep = 0; istep < step; istep++) {
	    jstep = next + (istep * win_cycledir);
	    if (jstep <=	  0) jstep += maxreg-1;
	    if (jstep >= maxreg) jstep -= maxreg-1;
	    if (++incr > fstep) {	/* time to randomize	*/
		incr = 1;
		fstep = ((win_fsteps[win_cyclefreq]*
		    (rand() >> 8)) >> 6) + 1;
		fromred   = dacbox[last][0];
		fromgreen = dacbox[last][1];
		fromblue  = dacbox[last][2];
		tored	  = rand() >> 9;
		togreen   = rand() >> 9;
		toblue	  = rand() >> 9;
		}
	    dacbox[jstep][0] = fromred	 + (((tored   - fromred  )*incr)/fstep);
	    dacbox[jstep][1] = fromgreen + (((togreen - fromgreen)*incr)/fstep);
	    dacbox[jstep][2] = fromblue  + (((toblue  - fromblue )*incr)/fstep);
	    }
	}
	if (step >= 256) step = oldstep;

    spindac(win_cycledir,step);
    delay(win_cycledelay);
    AnimatePalette(hPal, 0, pLogPal->palNumEntries, pLogPal->palPalEntry);
    RealizePalette(hDC);
    keypressed();
    if (win_cyclerand == 2) {
	win_cyclerand = 1;
	step = 256;
	}
    }

win_animate_flag = 0;
ReleaseDC(GetFocus(),hDC);

win_title_text(0);

}

/* cursor routines */

extern HANDLE hSaveCursor;	       /* the original cursor value */
extern HANDLE hHourGlass;	       /* the hourglass cursor value */

start_wait()
{
   hSaveCursor = SetClassWord(hwnd, GCW_HCURSOR, hHourGlass);
}

end_wait()
{
   SetClassWord(hwnd, GCW_HCURSOR, hSaveCursor);
}

/* video-mode routines */

extern int    viewwindow;		/* 0 for full screen, 1 for window */
extern float  viewreduction;		/* window auto-sizing */
extern float  finalaspectratio; 	/* for view shape and rotation */
extern int    viewxdots,viewydots;	/* explicit view sizing */
extern int    fileydots, filexdots, filecolors;
extern float  fileaspectratio;
extern int    skipxdots,skipydots;	/* for decoder, when reducing image */

int get_video_mode(struct fractal_info *info)
{
   viewwindow = viewxdots = viewydots = 0;
   fileaspectratio = .75;
   skipxdots = skipydots = 0;
   return(0);
}


int spindac(int direction, int step)
{
int i, j, k;
int cycle_start, cycle_fin;
extern int rotate_lo,rotate_hi;
char tempdacbox;

cycle_start = 0;
cycle_fin = 255;
if (time_to_cycle) {
   cycle_start = rotate_lo;
   cycle_fin = rotate_hi;
   }

for (k = 0; k < step; k++) {
    if (direction > 0) {
	for (j = 0; j < 3; j++) {
	    tempdacbox = dacbox[cycle_fin][j];
	    for (i = cycle_fin; i > cycle_start; i--)
		dacbox[i][j] = dacbox[i-1][j];
	    dacbox[cycle_start][j] = tempdacbox;
	    }
	}
    if (direction < 0) {
	for (j = 0; j < 3; j++) {
	    tempdacbox = dacbox[cycle_start][j];
	    for (i = cycle_start; i < cycle_fin; i++)
		dacbox[i][j] = dacbox[i+1][j];
	    dacbox[cycle_fin][j] = tempdacbox;
	    }
	}
    }

    /* fill in intensities for all palette entry colors */
    for (i = 0; i < 256; i++) {
	pLogPal->palPalEntry[i].peRed	= ((BYTE)dacbox[i][0]) << 2;
	pLogPal->palPalEntry[i].peGreen = ((BYTE)dacbox[i][1]) << 2;
	pLogPal->palPalEntry[i].peBlue	= ((BYTE)dacbox[i][2]) << 2;
	pLogPal->palPalEntry[i].peFlags = PC_RESERVED;
	}

    if (!win_animate_flag) {
	HDC hDC;
	hDC = GetDC(GetFocus());
	SetPaletteEntries(hPal, 0, pLogPal->palNumEntries, pLogPal->palPalEntry);
	SelectPalette (hDC, hPal, 1);
	RealizePalette(hDC);
	ReleaseDC(GetFocus(),hDC);
        /* for non-palette-based adapters, redraw the image */
	if (!iRasterCaps) {
            InvalidateRect(hwnd, NULL, FALSE);
            }
	}
}

restoredac()
{
int iLoop;
int j;

    /* fill in intensities for all palette entry colors */
    for (iLoop = 0; iLoop < PALETTESIZE; iLoop++)
	for (j = 0; j < 3; j++)
	    dacbox[iLoop][j] = win_dacbox[iLoop][j];
    spindac(0,1);
}

extern int colorstate;
extern char	colorfile[];

int ValidateLuts( char * fn )
{
FILE * f;
unsigned	r, g, b, index;
unsigned char	line[101];
unsigned char	temp[81];
	strcpy (temp,fn);
	if (strchr(temp,'.') == NULL) /* Did name have an extension? */
		strcat(temp,".map");  /* No? Then add .map */
	findpath( temp, line);	      /* search the dos path */
	f = fopen( line, "r" );
	if (f == NULL)
		return 1;
	for( index = 0; index < 256; index++ ) {
		if (fgets(line,100,f) == NULL)
			break;
		sscanf( line, "%d %d %d", &r, &g, &b );
		/** load global dac values **/
		dacbox[index][0] = r >> 2;	/* maps default to 8 bits */
		dacbox[index][1] = g >> 2;	/* DAC wants 6 bits */
		dacbox[index][2] = b >> 2;
	}
	fclose( f );
	colorstate = 2;
	strcpy(colorfile,temp);
	return 0;
}

int win_thinking = 0;

int thinking(int waiting, char *dummy)
{
if (waiting && ! win_thinking) {
    win_thinking = 1;
    start_wait();
    }
if (!waiting)
    end_wait();
return(keypressed());
}

extern HWND far wintext_hWndCopy;                /* a Global copy of hWnd */

/* Call for help caused by pressing F1 inside the "fractint-style"
   prompting routines */
int winfract_help()
{
        WinHelp(wintext_hWndCopy,szHelpFileName,HELP_INDEX,0L);
}

int far_strlen(char far *string) {
int i;
for (i = 0; ; i++)
    if (string[i] == 0)
	return(i);
}

int far_strnicmp(char far *string1, char far *string2, int maxlen) {
int i;
unsigned char j, k;
for (i = 0;i < maxlen ; i++) {
    j = string1[i];
    k = string2[i];
    if (j >= 'a' && j <= 'z') j -= ('a' - 'A');
    if (k >= 'a' && k <= 'z') k -= ('a' - 'A');
    if (j-k != 0)
	return(j-k);
    }
return(0);
}

int far_memcpy(void far *string1, void far *string2, int maxlen) {
int i;
for (i = 0;i < maxlen ; i++)
    ((char far *)string1)[i] = ((char far *)string2)[i];
}

int far_memcmp(void far *string1, void far *string2, int maxlen) {
int i;
unsigned char j, k;
for (i = 0;i < maxlen ; i++) {
    j = ((char far *)string1)[i];
    k = ((char far *)string2)[i];
    if (j-k != 0)
	return(j-k);
    }
return(0);
}

int far_memset(void far *string1, char char2, int maxlen) {
int i;
for (i = 0;i < maxlen ; i++)
    ((char far *)string1)[i] = char2;
}

long timer_start,timer_interval;	/* timer(...) start & total */
extern int  timerflag;
extern int  show_orbit;
extern	int	dotmode;		/* video access method	    */
extern	int	maxit;			/* try this many iterations */

int check_key()
{
   int key;
   if((key = keypressed()) != 0) {
      if(key != 'o' && key != 'O') {
	 return(-1);
      }
      getakey();
      if (dotmode != 11)
	 show_orbit = 1 - show_orbit;
   }
   return(0);
}

/* timer function:
     timer(0,(*fractal)())		fractal engine
     timer(1,NULL,int width)		decoder
     timer(2)				encoder
  */
#ifndef XFRACT
int timer(int timertype,int(*subrtn)(),...)
#else
int timer(va_alist)
va_dcl
#endif
{
   va_list arg_marker;	/* variable arg list */
   char *timestring;
   time_t ltime;
   FILE *fp;
   int out;
   int i;
   int do_bench;

#ifndef XFRACT
   va_start(arg_marker,subrtn);
#else
   int timertype;
   int (*subrtn)();
   va_start(arg_marker);
   timertype = va_arg(arg_marker, int);
   subrtn = ( int (*)()) va_arg(arg_marker, int *);
#endif

   do_bench = timerflag; /* record time? */
   if (timertype == 2)	 /* encoder, record time only if debug=200 */
      do_bench = (debugflag == 200);
   if(do_bench)
      fp=fopen("bench","a");
   timer_start = clock_ticks();
   switch(timertype) {
      case 0:
	 out = (*subrtn)();
	 break;
      case 1:
	 i = va_arg(arg_marker,int);
	 out = decoder(i);	     /* not indirect, safer with overlays */
	 break;
      case 2:
	 out = encoder();	     /* not indirect, safer with overlays */
	 break;
      }
   /* next assumes CLK_TCK is 10^n, n>=2 */
   timer_interval = (clock_ticks() - timer_start) / (CLK_TCK/100);

   if(do_bench) {
      time(&ltime);
      timestring = ctime(&ltime);
      timestring[24] = 0; /*clobber newline in time string */
      switch(timertype) {
	 case 1:
	    fprintf(fp,"decode ");
	    break;
	 case 2:
	    fprintf(fp,"encode ");
	    break;
	 }
      fprintf(fp,"%s type=%s resolution = %dx%d maxiter=%d",
	  timestring,
	  curfractalspecific->name,
	  xdots,
	  ydots,
	  maxit);
      fprintf(fp," time= %ld.%02ld secs\n",timer_interval/100,timer_interval%100);
      if(fp != NULL)
	 fclose(fp);
      }
   return(out);
}

/* dummy out the environment entries, as we never use them */
#ifndef QUICKC
int _setenvp(){return(0);}
#endif

void   cdecl far_strcpy( char far *to, char far *from)
{
_fstrcpy(to, from);
}

extern double zwidth;

void clear_zoombox()
{
   zwidth = 0;
   drawbox(0);
   reset_zoom_corners();
}

extern double xxmin, xxmax, xx3rd, yymin, yymax, yy3rd;
extern double sxmin, sxmax, sx3rd, symin, symax, sy3rd;

int reset_zoom_corners()
{
   xxmin = sxmin;
   xxmax = sxmax;
   xx3rd = sx3rd;
   yymax = symax;
   yymin = symin;
   yy3rd = sy3rd;
}

// fake videotable stuff

struct videoinfo far videotable[1];

void vidmode_keyname(int num, char *string)
{
    strcpy(string,"    ");  // fill in a blank videomode name
}

int check_vidmode_keyname()
{
    return(1);  // yeah, sure - that;s a good videomdoe name.
}

int check_vidmode_key()
{
    // fill in a videomode structure that looks just like the current image
    videotable[0].xdots = xdots;
    videotable[0].ydots = ydots;
    return 0;  // yeah, sure - that's a good key.
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -